[PATCH 2/7] net/hns3: fix MAC and queues HW statistics reversion

Ferruh Yigit ferruh.yigit at xilinx.com
Tue May 3 21:05:13 CEST 2022


On 4/6/2022 10:22 AM, Min Hu (Connor) wrote:
> From: Huisong Li <lihuisong at huawei.com>
> 
> The MAC and queues statistics aren't 64-bit registers in hardware. If
> hardware statistics are not obtained for a long time, these statistics will
> be reversed. 

I think using 'overflow' instead of 'reversed' is more clear.

As far as I can see from code, these are 32 bit values, can be good to 
mention in the commit log.

> So PF and VF driver have to periodically obtain and save these
> statistics. Since the periodical task and the stats API are in different
> threads, we introduce a statistics lock to protect the statistics.
> 
> Fixes: 8839c5e202f3 ("net/hns3: support device stats")
> Cc: stable at dpdk.org
> 
> Signed-off-by: Huisong Li <lihuisong at huawei.com>
> Signed-off-by: Min Hu (Connor) <humin29 at huawei.com>

<...>

> @@ -604,16 +626,15 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats)
>   	struct hns3_tqp_stats *stats = &hw->tqp_stats;
>   	struct hns3_rx_queue *rxq;
>   	struct hns3_tx_queue *txq;
> -	uint64_t cnt;
>   	uint16_t i;
>   	int ret;
>   
> +	rte_spinlock_lock(&hw->stats_lock);

The lock covers most of the 'stats_get()' function, but only Rx/Tx queue 
stats needs to be protected, you may consider reducing the scope of the 
lock. Same for below functions.

<...>

> @@ -1453,6 +1464,7 @@ int
>   hns3_dev_xstats_reset(struct rte_eth_dev *dev)
>   {
>   	struct hns3_adapter *hns = dev->data->dev_private;
> +	struct hns3_hw *hw = &hns->hw;
>   	int ret;
>   
>   	/* Clear tqp stats */
> @@ -1460,20 +1472,22 @@ hns3_dev_xstats_reset(struct rte_eth_dev *dev)
>   	if (ret)
>   		return ret;
>   
> +	rte_spinlock_unlock(&hw->stats_lock);

I guess this should be 'rte_spinlock_lock()'


More information about the dev mailing list