libubox: update to the latest version
[openwrt/staging/wigyori.git] / target / linux / generic / pending-4.4 / 070-v4.8-0003-bgmac-Maintain-some-netdev-statistics.patch
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
6 Add a few netdev statistics to report transmitted and received bytes and
7 packets and a few obvious errors.
8
9 Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
10 Signed-off-by: David S. Miller <davem@davemloft.net>
11 ---
12 drivers/net/ethernet/broadcom/bgmac.c | 10 ++++++++++
13 1 file changed, 10 insertions(+)
14
15 --- a/drivers/net/ethernet/broadcom/bgmac.c
16 +++ b/drivers/net/ethernet/broadcom/bgmac.c
17 @@ -246,6 +246,8 @@ err_dma_head:
18
19 err_drop:
20 dev_kfree_skb(skb);
21 + net_dev->stats.tx_dropped++;
22 + net_dev->stats.tx_errors++;
23 return NETDEV_TX_OK;
24 }
25
26 @@ -285,6 +287,8 @@ static void bgmac_dma_tx_free(struct bgm
27 DMA_TO_DEVICE);
28
29 if (slot->skb) {
30 + bgmac->net_dev->stats.tx_bytes += slot->skb->len;
31 + bgmac->net_dev->stats.tx_packets++;
32 bytes_compl += slot->skb->len;
33 pkts_compl++;
34
35 @@ -468,6 +472,7 @@ static int bgmac_dma_rx_read(struct bgma
36 bgmac_err(bgmac, "Found poisoned packet at slot %d, DMA issue!\n",
37 ring->start);
38 put_page(virt_to_head_page(buf));
39 + bgmac->net_dev->stats.rx_errors++;
40 break;
41 }
42
43 @@ -475,6 +480,8 @@ static int bgmac_dma_rx_read(struct bgma
44 bgmac_err(bgmac, "Found oversized packet at slot %d, DMA issue!\n",
45 ring->start);
46 put_page(virt_to_head_page(buf));
47 + bgmac->net_dev->stats.rx_length_errors++;
48 + bgmac->net_dev->stats.rx_errors++;
49 break;
50 }
51
52 @@ -485,6 +492,7 @@ static int bgmac_dma_rx_read(struct bgma
53 if (unlikely(!skb)) {
54 bgmac_err(bgmac, "build_skb failed\n");
55 put_page(virt_to_head_page(buf));
56 + bgmac->net_dev->stats.rx_errors++;
57 break;
58 }
59 skb_put(skb, BGMAC_RX_FRAME_OFFSET +
60 @@ -494,6 +502,8 @@ static int bgmac_dma_rx_read(struct bgma
61
62 skb_checksum_none_assert(skb);
63 skb->protocol = eth_type_trans(skb, bgmac->net_dev);
64 + bgmac->net_dev->stats.rx_bytes += len;
65 + bgmac->net_dev->stats.rx_packets++;
66 napi_gro_receive(&bgmac->napi, skb);
67 handled++;
68 } while (0);