[1/1] net/ixgbevf: fix stats update after a PF reset
diff mbox series

Message ID eab62f16c7670d2f1257ef32ecb413cae35c9395.1568216743.git.thierry.herbelot@6wind.com
State Changes Requested, archived
Delegated to: xiaolong ye
Headers show
Series
  • [1/1] net/ixgbevf: fix stats update after a PF reset
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-dpdk_compile_ovs success Compile Testing PASS
ci/iol-dpdk_compile_spdk success Compile Testing PASS
ci/iol-dpdk_compile success Compile Testing PASS
ci/intel-Performance success Performance Testing PASS
ci/mellanox-Performance success Performance Testing PASS

Commit Message

Thierry Herbelot Sept. 11, 2019, 4 p.m. UTC
From: Guo Fengtian <fengtian.guo@6wind.com>

When PF is set down, in VF, the value of stats register is zero.
So only increase stats when it's non zero.

Fixes: af75078fece3 ('first public release')
Cc: stable@dpdk.org
Cc: wenzhuo.lu@intel.com
Cc: konstantin.ananyev@intel.com

Signed-off-by: Guo Fengtian <fengtian.guo@6wind.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Zhang, Qi Z Sept. 17, 2019, 3:16 a.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Thierry Herbelot
> Sent: Thursday, September 12, 2019 12:01 AM
> To: dev@dpdk.org
> Cc: Guo Fengtian <fengtian.guo@6wind.com>; Thomas Monjalon
> <thomas@monjalon.net>; stable@dpdk.org; Lu, Wenzhuo
> <wenzhuo.lu@intel.com>; Ananyev, Konstantin
> <konstantin.ananyev@intel.com>
> Subject: [dpdk-dev] [PATCH 1/1] net/ixgbevf: fix stats update after a PF reset
> 
> From: Guo Fengtian <fengtian.guo@6wind.com>
> 
> When PF is set down, in VF, the value of stats register is zero.
> So only increase stats when it's non zero.
> 
> Fixes: af75078fece3 ('first public release')
> Cc: stable@dpdk.org
> Cc: wenzhuo.lu@intel.com
> Cc: konstantin.ananyev@intel.com
> 
> Signed-off-by: Guo Fengtian <fengtian.guo@6wind.com>
> ---
>  drivers/net/ixgbe/ixgbe_ethdev.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c
> b/drivers/net/ixgbe/ixgbe_ethdev.c
> index 7eb3d0567b58..27c540f60563 100644
> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> @@ -385,7 +385,8 @@ static void ixgbe_l2_tunnel_conf(struct rte_eth_dev
> *dev);
>  #define UPDATE_VF_STAT(reg, last, cur)                          \
>  {                                                               \
>  	uint32_t latest = IXGBE_READ_REG(hw, reg);              \
> -	cur += (latest - last) & UINT_MAX;                      \
> +	if (latest)                                             \
> +		cur += (latest - last) & UINT_MAX;              \

There is still a chance that PF is up but the latest reg read returns 0, since it's a cyclic counter, is any way to check the PF status directly?

>  	last = latest;                                          \
>  }
> 
> @@ -394,7 +395,8 @@ static void ixgbe_l2_tunnel_conf(struct rte_eth_dev
> *dev);
>  	u64 new_lsb = IXGBE_READ_REG(hw, lsb);                   \
>  	u64 new_msb = IXGBE_READ_REG(hw, msb);                   \
>  	u64 latest = ((new_msb << 32) | new_lsb);                \
> -	cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL; \
> +	if (latest)                                              \
> +		cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL;\
>  	last = latest;                                           \
>  }
> 
> --
> 2.20.1
Xiaolong Ye Sept. 30, 2019, 10:58 a.m. UTC | #2
Hi, Thierry & Fengtian

Any update about this patch according to Qi's comment?

Thanks,
Xiaolong

On 09/17, Zhang, Qi Z wrote:
>
>
>> -----Original Message-----
>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Thierry Herbelot
>> Sent: Thursday, September 12, 2019 12:01 AM
>> To: dev@dpdk.org
>> Cc: Guo Fengtian <fengtian.guo@6wind.com>; Thomas Monjalon
>> <thomas@monjalon.net>; stable@dpdk.org; Lu, Wenzhuo
>> <wenzhuo.lu@intel.com>; Ananyev, Konstantin
>> <konstantin.ananyev@intel.com>
>> Subject: [dpdk-dev] [PATCH 1/1] net/ixgbevf: fix stats update after a PF reset
>> 
>> From: Guo Fengtian <fengtian.guo@6wind.com>
>> 
>> When PF is set down, in VF, the value of stats register is zero.
>> So only increase stats when it's non zero.
>> 
>> Fixes: af75078fece3 ('first public release')
>> Cc: stable@dpdk.org
>> Cc: wenzhuo.lu@intel.com
>> Cc: konstantin.ananyev@intel.com
>> 
>> Signed-off-by: Guo Fengtian <fengtian.guo@6wind.com>
>> ---
>>  drivers/net/ixgbe/ixgbe_ethdev.c | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>> 
>> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c
>> b/drivers/net/ixgbe/ixgbe_ethdev.c
>> index 7eb3d0567b58..27c540f60563 100644
>> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
>> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
>> @@ -385,7 +385,8 @@ static void ixgbe_l2_tunnel_conf(struct rte_eth_dev
>> *dev);
>>  #define UPDATE_VF_STAT(reg, last, cur)                          \
>>  {                                                               \
>>  	uint32_t latest = IXGBE_READ_REG(hw, reg);              \
>> -	cur += (latest - last) & UINT_MAX;                      \
>> +	if (latest)                                             \
>> +		cur += (latest - last) & UINT_MAX;              \
>
>There is still a chance that PF is up but the latest reg read returns 0, since it's a cyclic counter, is any way to check the PF status directly?
>
>>  	last = latest;                                          \
>>  }
>> 
>> @@ -394,7 +395,8 @@ static void ixgbe_l2_tunnel_conf(struct rte_eth_dev
>> *dev);
>>  	u64 new_lsb = IXGBE_READ_REG(hw, lsb);                   \
>>  	u64 new_msb = IXGBE_READ_REG(hw, msb);                   \
>>  	u64 latest = ((new_msb << 32) | new_lsb);                \
>> -	cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL; \
>> +	if (latest)                                              \
>> +		cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL;\
>>  	last = latest;                                           \
>>  }
>> 
>> --
>> 2.20.1
>
Thierry Herbelot Sept. 30, 2019, 11:06 a.m. UTC | #3
On 9/30/19 12:58 PM, Ye Xiaolong wrote:
> Hi, Thierry & Fengtian
> 
> Any update about this patch according to Qi's comment?

Hello, Xiaolong

I agreee with Qi's comment: this patch solves one issue, but causes 
another problem.

I am completely open to any suggestion about how to retrieve the PF 
status from the VF device.

	Regards

	Thierry

> 
> Thanks,
> Xiaolong
> 
> On 09/17, Zhang, Qi Z wrote:
>>
>>
>>> -----Original Message-----
>>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Thierry Herbelot
>>> Sent: Thursday, September 12, 2019 12:01 AM
>>> To: dev@dpdk.org
>>> Cc: Guo Fengtian <fengtian.guo@6wind.com>; Thomas Monjalon
>>> <thomas@monjalon.net>; stable@dpdk.org; Lu, Wenzhuo
>>> <wenzhuo.lu@intel.com>; Ananyev, Konstantin
>>> <konstantin.ananyev@intel.com>
>>> Subject: [dpdk-dev] [PATCH 1/1] net/ixgbevf: fix stats update after a PF reset
>>>
>>> From: Guo Fengtian <fengtian.guo@6wind.com>
>>>
>>> When PF is set down, in VF, the value of stats register is zero.
>>> So only increase stats when it's non zero.
>>>
>>> Fixes: af75078fece3 ('first public release')
>>> Cc: stable@dpdk.org
>>> Cc: wenzhuo.lu@intel.com
>>> Cc: konstantin.ananyev@intel.com
>>>
>>> Signed-off-by: Guo Fengtian <fengtian.guo@6wind.com>
>>> ---
>>>   drivers/net/ixgbe/ixgbe_ethdev.c | 6 ++++--
>>>   1 file changed, 4 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c
>>> b/drivers/net/ixgbe/ixgbe_ethdev.c
>>> index 7eb3d0567b58..27c540f60563 100644
>>> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
>>> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
>>> @@ -385,7 +385,8 @@ static void ixgbe_l2_tunnel_conf(struct rte_eth_dev
>>> *dev);
>>>   #define UPDATE_VF_STAT(reg, last, cur)                          \
>>>   {                                                               \
>>>   	uint32_t latest = IXGBE_READ_REG(hw, reg);              \
>>> -	cur += (latest - last) & UINT_MAX;                      \
>>> +	if (latest)                                             \
>>> +		cur += (latest - last) & UINT_MAX;              \
>>
>> There is still a chance that PF is up but the latest reg read returns 0, since it's a cyclic counter, is any way to check the PF status directly?
>>
>>>   	last = latest;                                          \
>>>   }
>>>
>>> @@ -394,7 +395,8 @@ static void ixgbe_l2_tunnel_conf(struct rte_eth_dev
>>> *dev);
>>>   	u64 new_lsb = IXGBE_READ_REG(hw, lsb);                   \
>>>   	u64 new_msb = IXGBE_READ_REG(hw, msb);                   \
>>>   	u64 latest = ((new_msb << 32) | new_lsb);                \
>>> -	cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL; \
>>> +	if (latest)                                              \
>>> +		cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL;\
>>>   	last = latest;                                           \
>>>   }
>>>
>>> --
>>> 2.20.1
>>

Patch
diff mbox series

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 7eb3d0567b58..27c540f60563 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -385,7 +385,8 @@  static void ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev);
 #define UPDATE_VF_STAT(reg, last, cur)                          \
 {                                                               \
 	uint32_t latest = IXGBE_READ_REG(hw, reg);              \
-	cur += (latest - last) & UINT_MAX;                      \
+	if (latest)                                             \
+		cur += (latest - last) & UINT_MAX;              \
 	last = latest;                                          \
 }
 
@@ -394,7 +395,8 @@  static void ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev);
 	u64 new_lsb = IXGBE_READ_REG(hw, lsb);                   \
 	u64 new_msb = IXGBE_READ_REG(hw, msb);                   \
 	u64 latest = ((new_msb << 32) | new_lsb);                \
-	cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL; \
+	if (latest)                                              \
+		cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL;\
 	last = latest;                                           \
 }