Subject: Re: [PATCH net-next 1/3] Add LAN743X driver

From: Stephen Hemminger <[email-masked]>
Date: Fri, 11 Aug 2017 16:05:32 -0700

On Fri, 11 Aug 2017 19:47:57 +0000
<[email-masked]> wrote:

> +
> +static struct net_device_stats *mac_get_stats(struct lan743x_adapter *adapter)
> +{
> +	struct lan743x_mac *mac = &adapter->mac;
> +
> +	memset(&mac->statistics, 0, sizeof(mac->statistics));
> +	mac->statistics.rx_packets = lan743x_csr_read(adapter,
> +						      STAT_RX_TOTAL_FRAMES);
> +	mac->statistics.tx_packets = lan743x_csr_read(adapter,
> +						      STAT_TX_TOTAL_FRAMES);
> +	return &mac->statistics;
> +}

The statistics code here is confused.
You are already counting rx_packets in software in napi_poll
Then you get values from MAC. One or the other?
There are two copies of stats, one in netdev and other in your mac structure.

Also what about byte and error counts?

If possible implement 64 bit get_stats64 instead.