net: hns3: add rx multicast packets statistic
authorJian Shen <shenjian15@huawei.com>
Tue, 22 Jan 2019 23:39:28 +0000 (07:39 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 23 Jan 2019 19:13:01 +0000 (11:13 -0800)
This patch adds rx multicast packets statistic for each ring.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c

index 9dd8949381bc67b622741f64842be77954268feb..2ec3759961f1136b1acaadb6d2f895605f943f78 100644 (file)
@@ -2572,6 +2572,7 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring *ring,
                             struct sk_buff **out_skb)
 {
        struct net_device *netdev = ring->tqp->handle->kinfo.netdev;
+       enum hns3_pkt_l2t_type l2_frame_type;
        struct sk_buff *skb = ring->skb;
        struct hns3_desc_cb *desc_cb;
        struct hns3_desc *desc;
@@ -2680,7 +2681,12 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring *ring,
                return -EFAULT;
        }
 
+       l2_frame_type = hnae3_get_field(l234info, HNS3_RXD_DMAC_M,
+                                       HNS3_RXD_DMAC_S);
        u64_stats_update_begin(&ring->syncp);
+       if (l2_frame_type == HNS3_L2_TYPE_MULTICAST)
+               ring->stats.rx_multicast++;
+
        ring->stats.rx_pkts++;
        ring->stats.rx_bytes += skb->len;
        u64_stats_update_end(&ring->syncp);
index f59ab7387b1f5823427e31cff5c814c6ba5be285..f3d248626ab3e060c6d1668c4508c9c67d50d332 100644 (file)
@@ -202,6 +202,13 @@ enum hns3_nic_state {
 
 #define HNS3_RING_EN_B                         0
 
+enum hns3_pkt_l2t_type {
+       HNS3_L2_TYPE_UNICAST,
+       HNS3_L2_TYPE_MULTICAST,
+       HNS3_L2_TYPE_BROADCAST,
+       HNS3_L2_TYPE_INVALID,
+};
+
 enum hns3_pkt_l3t_type {
        HNS3_L3T_NONE,
        HNS3_L3T_IPV6,
@@ -376,6 +383,7 @@ struct ring_stats {
                        u64 err_bd_num;
                        u64 l2_err;
                        u64 l3l4_csum_err;
+                       u64 rx_multicast;
                };
        };
 };
index e678b6939da39e6d9b099da0976c81b5bda4f914..abb78696d7ce31bc32e9cf58f142e77ffb2c756b 100644 (file)
@@ -47,6 +47,7 @@ static const struct hns3_stats hns3_rxq_stats[] = {
        HNS3_TQP_STAT("err_bd_num", err_bd_num),
        HNS3_TQP_STAT("l2_err", l2_err),
        HNS3_TQP_STAT("l3l4_csum_err", l3l4_csum_err),
+       HNS3_TQP_STAT("multicast", rx_multicast),
 };
 
 #define HNS3_RXQ_STATS_COUNT ARRAY_SIZE(hns3_rxq_stats)