Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1669349

Re: [PATCH V2 net-next 1/8] net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC

From Stephen Hemminger <stephen@networkplumber.org>
Newsgroups linux.kernel
Subject Re: [PATCH V2 net-next 1/8] net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC
Date 2017-06-19 17:50 +0200
Message-ID <tU769-4xl-1@gated-at.bofh.it> (permalink)
References <tS3gl-5Od-5@gated-at.bofh.it> <tS3gn-5Od-47@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, 14 Jun 2017 00:10:28 +0100
Salil Mehta <salil.mehta@huawei.com> wrote:

> +hns3_nic_get_stats64(struct net_device *ndev, struct rtnl_link_stats64 *stats)
> +{
> +	struct hns3_nic_priv *priv = netdev_priv(ndev);
> +	int queue_num = priv->ae_handle->kinfo.num_tqps;
> +	u64 tx_bytes = 0;
> +	u64 rx_bytes = 0;
> +	u64 tx_pkts = 0;
> +	u64 rx_pkts = 0;
> +	int idx = 0;
unnecessary initialization

> +
> +	for (idx = 0; idx < queue_num; idx++) {
> +		tx_bytes += priv->ring_data[idx].ring->stats.tx_bytes;
> +		tx_pkts += priv->ring_data[idx].ring->stats.tx_pkts;
> +		rx_bytes +=
> +			priv->ring_data[idx + queue_num].ring->stats.rx_bytes;
> +		rx_pkts += priv->ring_data[idx + queue_num].ring->stats.rx_pkts;
> +	}
> +

Since rx_bytes and other statistics are 64 bit values. You need to use
something to ensure that updates to these values are atomic on 32 bit
platforms.  The most common way to handle this is with the u64_stats_sync
mechanism which is a nop on 64 bit architectures, and uses a seqcount
to do updates on 32 bit CPU's.

  

Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

[PATCH V2 net-next 0/8] Hisilicon Network Subsystem 3 Ethernet Driver Salil Mehta <salil.mehta@huawei.com> - 2017-06-14 01:20 +0200
  Re: [PATCH V2 net-next 1/8] net: hns3: Add support of HNS3 Ethernet  Driver for hip08 SoC Stephen Hemminger <stephen@networkplumber.org> - 2017-06-14 02:00 +0200
    RE: [PATCH V2 net-next 1/8] net: hns3: Add support of HNS3 Ethernet  Driver for hip08 SoC Salil Mehta <salil.mehta@huawei.com> - 2017-06-17 12:50 +0200
  Re: [PATCH V2 net-next 1/8] net: hns3: Add support of HNS3 Ethernet  Driver for hip08 SoC Stephen Hemminger <stephen@networkplumber.org> - 2017-06-19 17:50 +0200

csiph-web