Subject: Re: [PATCH 27/27] HFI: hf ethtool support

From: Ben Hutchings <[email-masked]>
Date: Wed, 02 Mar 2011 21:52:42 +0000

On Wed, 2011-03-02 at 16:10 -0500, [email-masked] wrote:
[...]
> +static int hf_get_sset_count(struct net_device *netdev, int sset)
> +{
> +	switch (sset) {
> +	case ETH_SS_STATS:
> +		return ARRAY_SIZE(hf_ethtool_stats_keys);
> +	default:
> +		return -EOPNOTSUPP;

The error code should be -EINVAL, I think.

> +	}
> +}
> +
> +static void hf_get_ethtool_stats(struct net_device *netdev,
> +		struct ethtool_stats *stats, u64 *data)
> +{
> +	struct hf_net	*net = netdev_priv(netdev);
> +	struct hf_if	*net_if = &(net->hfif);
> +
> +	memcpy(data, &(net_if->eth_stats), sizeof(struct hf_ethtool_stats));
[...]

This may result in word tearing, particularly if this driver can be
built for a 32-bit system.  Since the stats appear to be updated
asynchronously in the data path, you may have to declare them as
unsigned long and then extend them to 64-bit in hf_get_ethtool_stats().

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.