070-v4.8-0003-bgmac-Maintain-some-netdev-statistics.patch 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. From 6d490f62a4c7f11c552591bdd08eda3636aa0db9 Mon Sep 17 00:00:00 2001
  2. From: Florian Fainelli <f.fainelli@gmail.com>
  3. Date: Tue, 7 Jun 2016 15:06:15 -0700
  4. Subject: [PATCH 3/3] bgmac: Maintain some netdev statistics
  5. Add a few netdev statistics to report transmitted and received bytes and
  6. packets and a few obvious errors.
  7. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
  8. Signed-off-by: David S. Miller <davem@davemloft.net>
  9. ---
  10. drivers/net/ethernet/broadcom/bgmac.c | 10 ++++++++++
  11. 1 file changed, 10 insertions(+)
  12. --- a/drivers/net/ethernet/broadcom/bgmac.c
  13. +++ b/drivers/net/ethernet/broadcom/bgmac.c
  14. @@ -246,6 +246,8 @@ err_dma_head:
  15. err_drop:
  16. dev_kfree_skb(skb);
  17. + net_dev->stats.tx_dropped++;
  18. + net_dev->stats.tx_errors++;
  19. return NETDEV_TX_OK;
  20. }
  21. @@ -284,6 +286,8 @@ static void bgmac_dma_tx_free(struct bgm
  22. DMA_TO_DEVICE);
  23. if (slot->skb) {
  24. + bgmac->net_dev->stats.tx_bytes += slot->skb->len;
  25. + bgmac->net_dev->stats.tx_packets++;
  26. bytes_compl += slot->skb->len;
  27. pkts_compl++;
  28. @@ -467,6 +471,7 @@ static int bgmac_dma_rx_read(struct bgma
  29. bgmac_err(bgmac, "Found poisoned packet at slot %d, DMA issue!\n",
  30. ring->start);
  31. put_page(virt_to_head_page(buf));
  32. + bgmac->net_dev->stats.rx_errors++;
  33. break;
  34. }
  35. @@ -474,6 +479,8 @@ static int bgmac_dma_rx_read(struct bgma
  36. bgmac_err(bgmac, "Found oversized packet at slot %d, DMA issue!\n",
  37. ring->start);
  38. put_page(virt_to_head_page(buf));
  39. + bgmac->net_dev->stats.rx_length_errors++;
  40. + bgmac->net_dev->stats.rx_errors++;
  41. break;
  42. }
  43. @@ -484,6 +491,7 @@ static int bgmac_dma_rx_read(struct bgma
  44. if (unlikely(!skb)) {
  45. bgmac_err(bgmac, "build_skb failed\n");
  46. put_page(virt_to_head_page(buf));
  47. + bgmac->net_dev->stats.rx_errors++;
  48. break;
  49. }
  50. skb_put(skb, BGMAC_RX_FRAME_OFFSET +
  51. @@ -493,6 +501,8 @@ static int bgmac_dma_rx_read(struct bgma
  52. skb_checksum_none_assert(skb);
  53. skb->protocol = eth_type_trans(skb, bgmac->net_dev);
  54. + bgmac->net_dev->stats.rx_bytes += len;
  55. + bgmac->net_dev->stats.rx_packets++;
  56. napi_gro_receive(&bgmac->napi, skb);
  57. handled++;
  58. } while (0);