[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1458768237.10868.46.camel@edumazet-glaptop3.roam.corp.google.com>
Date: Wed, 23 Mar 2016 14:23:57 -0700
From: Eric Dumazet <eric.dumazet@...il.com>
To: Petri Gynther <pgynther@...gle.com>
Cc: netdev@...r.kernel.org, davem@...emloft.net, f.fainelli@...il.com,
jaedon.shin@...il.com, edumazet@...gle.com
Subject: Re: [PATCH net 1/2] net: bcmgenet: fix dev->stats.tx_bytes
accounting
On Wed, 2016-03-23 at 13:01 -0700, Petri Gynther wrote:
> 1. Add bytes_compl local variable to collect transmitted bytes
> - dev->stats updates can then be moved outside the while-loop
> - bytes_compl is also needed for future BQL support
> 2. When bcmgenet device uses Tx checksum offload, each transmitted
> skb has an extra 64-byte header prepended to it. This needs to
> be deducted when counting transmitted bytes.
> 3. skb->len covers the entire length of skb, whether it is linear or
> fragmented. Thus, when we clean the fragments, do not increase
> transmitted bytes.
>
> Signed-off-by: Petri Gynther <pgynther@...gle.com>
> ---
> drivers/net/ethernet/broadcom/genet/bcmgenet.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> index 6746fd0..9990582 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> @@ -1171,6 +1171,7 @@ static unsigned int __bcmgenet_tx_reclaim(struct net_device *dev,
> struct enet_cb *tx_cb_ptr;
> struct netdev_queue *txq;
> unsigned int pkts_compl = 0;
> + unsigned int bytes_compl = 0;
> unsigned int c_index;
> unsigned int txbds_ready;
> unsigned int txbds_processed = 0;
> @@ -1193,16 +1194,14 @@ static unsigned int __bcmgenet_tx_reclaim(struct net_device *dev,
> tx_cb_ptr = &priv->tx_cbs[ring->clean_ptr];
> if (tx_cb_ptr->skb) {
> pkts_compl++;
> - dev->stats.tx_packets++;
> - dev->stats.tx_bytes += tx_cb_ptr->skb->len;
> + bytes_compl += tx_cb_ptr->skb->len -
> + (priv->desc_64b_en ? 64 : 0);
Please do not use this 64 scalar, prefer sizeof(struct status_64)
I know this driver uses skb_pull(skb, 64); len -= 64; in
bcmgenet_desc_rx(), but I would prefer not adding magic values.
Thanks.
Powered by blists - more mailing lists