public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Sabrina Dubroca <sd@queasysnail.net>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: Re: [PATCH 5/5] alx: add stats to ethtool
Date: Thu, 2 Jan 2014 19:19:15 +0100	[thread overview]
Message-ID: <20140102181915.GB25216@kria> (raw)
In-Reply-To: <1388668154.4326.1.camel@jlt4.sipsolutions.net>

[2014-01-02, 14:09:14] Johannes Berg wrote:
> On Thu, 2014-01-02 at 00:40 +0100, Sabrina Dubroca wrote:
> 
> > +static const char alx_gstrings_stats[][ETH_GSTRING_LEN] = {
> 
> You should probably have a comment here and on the stats struct
> declaration that they must absolutely match in order/size/etc.


With these comments, and something similar before
__alx_update_hw_stats, should I use the code for __alx_update_hw_stats
mentionned in mail 0?


/* Statistics counters collected by the MAC
 *
 * The order of the fields must match the strings in alx_gstrings_stats
 * See ethtool.c
 */
struct alx_hw_stats {
	/* ... */
}

/* The order of these strings must match the order of the fields in
 * struct alx_hw_stats
 * See hw.h
 */
static const char alx_gstrings_stats[][ETH_GSTRING_LEN] = {
	/* ... */
}



> Maybe try to put in some BUILD_BUG_ON() as well, at least checking the
> sizeof() vs. ARRAY_SIZE*sizeof(u64) - that might already have caught the
> bug that Ben pointed out.


static void alx_get_ethtool_stats(struct net_device *netdev,
				  struct ethtool_stats *estats, u64 *data)
{
	struct alx_priv *alx = netdev_priv(netdev);
	struct alx_hw *hw = &alx->hw;

	spin_lock(&alx->stats_lock);

	__alx_update_hw_stats(hw);
	BUILD_BUG_ON(sizeof(hw->stats) - offsetof(struct alx_hw_stats, rx_ok) <
		     ALX_NUM_STATS * sizeof(u64));
	memcpy(data, &hw->stats.rx_ok, ALX_NUM_STATS * sizeof(u64));

	spin_unlock(&alx->stats_lock);
}

This way, rx_ok doesn't need to come first in struct alx_hw_stats, and
the size of the structure is checked as you said.



> > +	"rx_packets",
> 
> Is it useful to provide stats that are already elsewhere? Then again, it
> doesn't really hurt and simplifies the code ...

You're right, rx_packets is the sum of all the rx_SIZE_RANGE_packets
and is redundant information. The values split by size range are only
for ethtool. ndo_get_stats(64) uses only the sum. I think this
information is more relevant to the user, and anyway, it's available,
so we might as well provide it.


Thanks,

-- 
Sabrina Dubroca

      reply	other threads:[~2014-01-02 18:19 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-01 23:40 [PATCH 0/5] alx: add statistics Sabrina Dubroca
2014-01-01 23:40 ` [PATCH 1/5] alx: add a hardware stats structure Sabrina Dubroca
2014-01-02 11:52   ` Ben Hutchings
2014-01-01 23:40 ` [PATCH 2/5] alx: add constants for the stats fields Sabrina Dubroca
2014-01-01 23:40 ` [PATCH 3/5] alx: add stats update function Sabrina Dubroca
2014-01-02  5:55   ` Stephen Hemminger
2014-01-02 11:52     ` Ben Hutchings
2014-01-01 23:40 ` [PATCH 4/5] alx: add alx_get_stats operation Sabrina Dubroca
2014-01-02  3:27   ` David Miller
2014-01-02 11:56     ` Ben Hutchings
2014-01-02 16:05       ` Sabrina Dubroca
2014-01-02 16:25         ` Ben Hutchings
2014-01-02 17:39       ` David Miller
2014-01-02 11:57   ` Ben Hutchings
2014-01-01 23:40 ` [PATCH 5/5] alx: add stats to ethtool Sabrina Dubroca
2014-01-02 12:01   ` Ben Hutchings
2014-01-02 18:23     ` Ben Hutchings
2014-01-02 13:09   ` Johannes Berg
2014-01-02 18:19     ` Sabrina Dubroca [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140102181915.GB25216@kria \
    --to=sd@queasysnail.net \
    --cc=davem@davemloft.net \
    --cc=johannes@sipsolutions.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox