net: hns3: Fix an error of total drop packet statistics
authorJian Shen <shenjian15@huawei.com>
Fri, 5 Jan 2018 10:18:12 +0000 (18:18 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Apr 2018 10:32:17 +0000 (12:32 +0200)
[ Upstream commit d2a5dca8404871be683c6bbc175ebf9c56dd2865 ]

The dropped tx/rx packets number of each tqp should also
be counted into the total drop tx/rx packets numbers.

Fixes: 76ad4f0ee74 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC")
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c

index 3e7e13b9a38515754fb1eafaa3d6e0dc68dc4543..fad480e323dd404c7fd037147ef9fc8b48b24769 100644 (file)
@@ -1060,6 +1060,8 @@ hns3_nic_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
        u64 rx_bytes = 0;
        u64 tx_pkts = 0;
        u64 rx_pkts = 0;
+       u64 tx_drop = 0;
+       u64 rx_drop = 0;
 
        for (idx = 0; idx < queue_num; idx++) {
                /* fetch the tx stats */
@@ -1068,6 +1070,8 @@ hns3_nic_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
                        start = u64_stats_fetch_begin_irq(&ring->syncp);
                        tx_bytes += ring->stats.tx_bytes;
                        tx_pkts += ring->stats.tx_pkts;
+                       tx_drop += ring->stats.tx_busy;
+                       tx_drop += ring->stats.sw_err_cnt;
                } while (u64_stats_fetch_retry_irq(&ring->syncp, start));
 
                /* fetch the rx stats */
@@ -1076,6 +1080,9 @@ hns3_nic_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
                        start = u64_stats_fetch_begin_irq(&ring->syncp);
                        rx_bytes += ring->stats.rx_bytes;
                        rx_pkts += ring->stats.rx_pkts;
+                       rx_drop += ring->stats.non_vld_descs;
+                       rx_drop += ring->stats.err_pkt_len;
+                       rx_drop += ring->stats.l2_err;
                } while (u64_stats_fetch_retry_irq(&ring->syncp, start));
        }
 
@@ -1091,8 +1098,8 @@ hns3_nic_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
        stats->rx_missed_errors = netdev->stats.rx_missed_errors;
 
        stats->tx_errors = netdev->stats.tx_errors;
-       stats->rx_dropped = netdev->stats.rx_dropped;
-       stats->tx_dropped = netdev->stats.tx_dropped;
+       stats->rx_dropped = rx_drop + netdev->stats.rx_dropped;
+       stats->tx_dropped = tx_drop + netdev->stats.tx_dropped;
        stats->collisions = netdev->stats.collisions;
        stats->rx_over_errors = netdev->stats.rx_over_errors;
        stats->rx_frame_errors = netdev->stats.rx_frame_errors;