lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 22 Jan 2019 23:19:46 +0000
From:   tanhuazhong <tanhuazhong@...wei.com>
To:     Eric Dumazet <eric.dumazet@...il.com>,
        "davem@...emloft.net" <davem@...emloft.net>
CC:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        huangdaode <huangdaode@...ilicon.com>,
        "Zhuangyuzeng (Yisen)" <yisen.zhuang@...wei.com>,
        Salil Mehta <salil.mehta@...wei.com>,
        Linuxarm <linuxarm@...wei.com>,
        "shenjian (K)" <shenjian15@...wei.com>,
        "lipeng (Y)" <lipeng321@...wei.com>
Subject: RE: [PATCH net-next 02/12] net: hns3: add rx multicast packets
 statistic



-----Original Message-----
From: Eric Dumazet [mailto:eric.dumazet@...il.com] 
Sent: Wednesday, January 23, 2019 2:39 AM
To: tanhuazhong <tanhuazhong@...wei.com>; davem@...emloft.net
Cc: netdev@...r.kernel.org; linux-kernel@...r.kernel.org; huangdaode <huangdaode@...ilicon.com>; Zhuangyuzeng (Yisen) <yisen.zhuang@...wei.com>; Salil Mehta <salil.mehta@...wei.com>; Linuxarm <linuxarm@...wei.com>; shenjian (K) <shenjian15@...wei.com>; lipeng (Y) <lipeng321@...wei.com>
Subject: Re: [PATCH net-next 02/12] net: hns3: add rx multicast packets statistic



On 01/22/2019 08:39 AM, Huazhong Tan wrote:
> From: Jian Shen <shenjian15@...wei.com>
> 
> This patch adds rx multicast packets statistic for each ring.
> 
> Signed-off-by: Jian Shen <shenjian15@...wei.com>
> Signed-off-by: Peng Li <lipeng321@...wei.com>
> Signed-off-by: Huazhong Tan <tanhuazhong@...wei.com>
> ---
>  drivers/net/ethernet/hisilicon/hns3/hns3_enet.c    | 9 +++++++++
>  drivers/net/ethernet/hisilicon/hns3/hns3_enet.h    | 8 ++++++++
>  drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 1 +
>  3 files changed, 18 insertions(+)
> 
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> index 9dd8949381bc..f1ab2e4ca49e 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> @@ -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,6 +2681,14 @@ 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);
> +	if (l2_frame_type == HNS3_L2_TYPE_MULTICAST) {
> +		u64_stats_update_begin(&ring->syncp);
> +		ring->stats.rx_multicast++;
> +		u64_stats_update_end(&ring->syncp);
> +	}
> +
>  	u64_stats_update_begin(&ring->syncp);


This is a bit suboptimal to call u64_stats_update_begin() twice.

You could rewrite the thing to be :

        u64_stats_update_begin(&ring->syncp);
        if (l2_frame_type == HNS3_L2_TYPE_MULTICAST)
             ring->stats.rx_multicast++;
           
	ring->stats.rx_pkts++;
	...

Ok, thanks.

>  	ring->stats.rx_pkts++;
>  	ring->stats.rx_bytes += skb->len;
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
> index f59ab7387b1f..f3d248626ab3 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
> @@ -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;
>  		};
>  	};
>  };
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
> index e678b6939da3..abb78696d7ce 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
> @@ -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)
> 

Powered by blists - more mailing lists