Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Huazhong Tan <tanhuazhong@huawei.com>, davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	huangdaode@hisilicon.com, yisen.zhuang@huawei.com,
	salil.mehta@huawei.com, linuxarm@huawei.com,
	Jian Shen <shenjian15@huawei.com>, Peng Li <lipeng321@huawei.com>
Subject: Re: [PATCH net-next 02/12] net: hns3: add rx multicast packets statistic
Date: Tue, 22 Jan 2019 10:39:29 -0800	[thread overview]
Message-ID: <c915dbd7-8a04-9b38-bb5f-a3e8340ce6a2@gmail.com> (raw)
In-Reply-To: <20190122163940.7876-3-tanhuazhong@huawei.com>



On 01/22/2019 08:39 AM, Huazhong Tan wrote:
> From: Jian Shen <shenjian15@huawei.com>
> 
> 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>
> ---
>  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++;
	...

>  	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)
> 

  reply	other threads:[~2019-01-22 18:39 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-22 16:39 [PATCH net-next 00/12] code optimizations & bugfixes for HNS3 driver Huazhong Tan
2019-01-22 16:39 ` [PATCH net-next 01/12] net: hns3: add calling roce callback function when link status change Huazhong Tan
2019-01-22 16:39 ` [PATCH net-next 02/12] net: hns3: add rx multicast packets statistic Huazhong Tan
2019-01-22 18:39   ` Eric Dumazet [this message]
2019-01-22 23:19     ` tanhuazhong
2019-01-22 16:39 ` [PATCH net-next 03/12] net: hns3: refactor the statistics updating for netdev Huazhong Tan
2019-01-22 16:39 ` [PATCH net-next 04/12] net: hns3: fix rss configuration lost problem when setting channel Huazhong Tan
2019-01-22 16:39 ` [PATCH net-next 05/12] net: hns3: fix for shaper not setting when TC num changes Huazhong Tan
2019-01-22 16:39 ` [PATCH net-next 06/12] net: hns3: fix bug of ethtool_ops.get_channels for VF Huazhong Tan
2019-01-22 16:39 ` [PATCH net-next 07/12] net: hns3: clear param in ring when free ring Huazhong Tan
2019-01-22 16:39 ` [PATCH net-next 08/12] net: hns3: Change fw error code NOT_EXEC to NOT_SUPPORTED Huazhong Tan
2019-01-22 16:39 ` [PATCH net-next 09/12] net: hns3: do not return GE PFC setting err when initializing Huazhong Tan
2019-01-22 16:39 ` [PATCH net-next 10/12] net: hns3: add ETS TC weight setting in SSU module Huazhong Tan
2019-01-22 16:39 ` [PATCH net-next 11/12] net: hns3: add statistics for PFC frames and MAC control frames Huazhong Tan
2019-01-22 16:39 ` [PATCH net-next 12/12] net: hns3: fix PFC not setting problem for DCB module Huazhong Tan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c915dbd7-8a04-9b38-bb5f-a3e8340ce6a2@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=huangdaode@hisilicon.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=lipeng321@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=salil.mehta@huawei.com \
    --cc=shenjian15@huawei.com \
    --cc=tanhuazhong@huawei.com \
    --cc=yisen.zhuang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox