* [dpdk-dev] [PATCH] net/ixgbevf: update VF_STAT macros to handle rollover
@ 2019-12-11 2:38 David Harton
2020-01-26 9:42 ` Ye Xiaolong
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: David Harton @ 2019-12-11 2:38 UTC (permalink / raw)
To: dev, wenzhuo.lu, konstantin.ananyev; +Cc: David Harton
Added rollover logic to UPDATE_VF_STAT and UPDATE_VF_STAT_36BIT macros.
Signed-off-by: David Harton <dharton@cisco.com>
---
drivers/net/ixgbe/ixgbe_ethdev.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 49285ce53..bc73ad195 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -385,7 +385,11 @@ 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 >= last) \
+ cur += (latest - last); \
+ else \
+ cur += ((latest + ((uint64_t)1 << 32)) - last); \
+ cur &= UINT_MAX; \
last = latest; \
}
@@ -394,7 +398,11 @@ 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 >= last) \
+ cur += (latest - last); \
+ else \
+ cur += ((latest + ((u64)1 << 36)) - last); \
+ cur &= 0xFFFFFFFFFLL; \
last = latest; \
}
--
2.19.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] [PATCH] net/ixgbevf: update VF_STAT macros to handle rollover
2019-12-11 2:38 [dpdk-dev] [PATCH] net/ixgbevf: update VF_STAT macros to handle rollover David Harton
@ 2020-01-26 9:42 ` Ye Xiaolong
2020-01-26 17:13 ` Stephen Hemminger
2020-01-26 17:32 ` [dpdk-dev] [PATCH v2] " David Harton
2 siblings, 0 replies; 7+ messages in thread
From: Ye Xiaolong @ 2020-01-26 9:42 UTC (permalink / raw)
To: David Harton; +Cc: dev, wenzhuo.lu, konstantin.ananyev
On 12/10, David Harton wrote:
>Added rollover logic to UPDATE_VF_STAT and UPDATE_VF_STAT_36BIT macros.
>
>Signed-off-by: David Harton <dharton@cisco.com>
>---
> drivers/net/ixgbe/ixgbe_ethdev.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
>index 49285ce53..bc73ad195 100644
>--- a/drivers/net/ixgbe/ixgbe_ethdev.c
>+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
>@@ -385,7 +385,11 @@ 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 >= last) \
>+ cur += (latest - last); \
>+ else \
>+ cur += ((latest + ((uint64_t)1 << 32)) - last); \
>+ cur &= UINT_MAX; \
> last = latest; \
> }
>
>@@ -394,7 +398,11 @@ 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 >= last) \
>+ cur += (latest - last); \
>+ else \
>+ cur += ((latest + ((u64)1 << 36)) - last); \
>+ cur &= 0xFFFFFFFFFLL; \
> last = latest; \
> }
>
>--
>2.19.1
>o
Could you provide Fixes: tag and cc stable?
Acked-by: Xiaolong Ye <xiaolong.ye@intel.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] [PATCH] net/ixgbevf: update VF_STAT macros to handle rollover
2019-12-11 2:38 [dpdk-dev] [PATCH] net/ixgbevf: update VF_STAT macros to handle rollover David Harton
2020-01-26 9:42 ` Ye Xiaolong
@ 2020-01-26 17:13 ` Stephen Hemminger
2020-01-26 17:32 ` [dpdk-dev] [PATCH v2] " David Harton
2 siblings, 0 replies; 7+ messages in thread
From: Stephen Hemminger @ 2020-01-26 17:13 UTC (permalink / raw)
To: David Harton; +Cc: dev, wenzhuo.lu, konstantin.ananyev
On Tue, 10 Dec 2019 21:38:36 -0500
David Harton <dharton@cisco.com> wrote:
> Added rollover logic to UPDATE_VF_STAT and UPDATE_VF_STAT_36BIT macros.
>
> Signed-off-by: David Harton <dharton@cisco.com>
> ---
> drivers/net/ixgbe/ixgbe_ethdev.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
> index 49285ce53..bc73ad195 100644
> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> @@ -385,7 +385,11 @@ 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 >= last) \
> + cur += (latest - last); \
> + else \
> + cur += ((latest + ((uint64_t)1 << 32)) - last); \
> + cur &= UINT_MAX; \
> last = latest; \
> }
>
> @@ -394,7 +398,11 @@ 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 >= last) \
> + cur += (latest - last); \
> + else \
> + cur += ((latest + ((u64)1 << 36)) - last); \
> + cur &= 0xFFFFFFFFFLL; \
> last = latest; \
> }
The overall approach looks fine.
The code is now long enough the macro should turn into an inline.
Also lots of (extra) parenthesis
^ permalink raw reply [flat|nested] 7+ messages in thread
* [dpdk-dev] [PATCH v2] net/ixgbevf: update VF_STAT macros to handle rollover
2019-12-11 2:38 [dpdk-dev] [PATCH] net/ixgbevf: update VF_STAT macros to handle rollover David Harton
2020-01-26 9:42 ` Ye Xiaolong
2020-01-26 17:13 ` Stephen Hemminger
@ 2020-01-26 17:32 ` David Harton
2020-01-29 7:53 ` Ye Xiaolong
2020-01-29 11:22 ` Ferruh Yigit
2 siblings, 2 replies; 7+ messages in thread
From: David Harton @ 2020-01-26 17:32 UTC (permalink / raw)
To: dev; +Cc: wenzhuo.lu, konstantin.ananyev, xiaolong.ye, David Harton, intel.com
Added rollover logic to UPDATE_VF_STAT and UPDATE_VF_STAT_36BIT macros.
Fixes: af75078fece3 ("first public release")
Cc: intel.com
Signed-off-by: David Harton <dharton@cisco.com>
---
drivers/net/ixgbe/ixgbe_ethdev.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 49285ce53..bc73ad195 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -385,7 +385,11 @@ 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 >= last) \
+ cur += (latest - last); \
+ else \
+ cur += ((latest + ((uint64_t)1 << 32)) - last); \
+ cur &= UINT_MAX; \
last = latest; \
}
@@ -394,7 +398,11 @@ 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 >= last) \
+ cur += (latest - last); \
+ else \
+ cur += ((latest + ((u64)1 << 36)) - last); \
+ cur &= 0xFFFFFFFFFLL; \
last = latest; \
}
--
2.19.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] [PATCH v2] net/ixgbevf: update VF_STAT macros to handle rollover
2020-01-26 17:32 ` [dpdk-dev] [PATCH v2] " David Harton
@ 2020-01-29 7:53 ` Ye Xiaolong
2020-01-29 11:22 ` Ferruh Yigit
1 sibling, 0 replies; 7+ messages in thread
From: Ye Xiaolong @ 2020-01-29 7:53 UTC (permalink / raw)
To: David Harton; +Cc: dev, wenzhuo.lu, konstantin.ananyev, intel.com
On 01/26, David Harton wrote:
>Added rollover logic to UPDATE_VF_STAT and UPDATE_VF_STAT_36BIT macros.
>
>Fixes: af75078fece3 ("first public release")
>Cc: intel.com
Cc: stable@dpdk.org
>
>Signed-off-by: David Harton <dharton@cisco.com>
>---
> drivers/net/ixgbe/ixgbe_ethdev.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
>index 49285ce53..bc73ad195 100644
>--- a/drivers/net/ixgbe/ixgbe_ethdev.c
>+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
>@@ -385,7 +385,11 @@ 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 >= last) \
>+ cur += (latest - last); \
>+ else \
>+ cur += ((latest + ((uint64_t)1 << 32)) - last); \
>+ cur &= UINT_MAX; \
> last = latest; \
> }
>
>@@ -394,7 +398,11 @@ 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 >= last) \
>+ cur += (latest - last); \
>+ else \
>+ cur += ((latest + ((u64)1 << 36)) - last); \
>+ cur &= 0xFFFFFFFFFLL; \
> last = latest; \
> }
>
>--
>2.19.1
>
Acked-by: Xiaolong Ye <xiaolong.ye@intel.com>
Applied to dpdk-next-net-intel, Thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] [PATCH v2] net/ixgbevf: update VF_STAT macros to handle rollover
2020-01-26 17:32 ` [dpdk-dev] [PATCH v2] " David Harton
2020-01-29 7:53 ` Ye Xiaolong
@ 2020-01-29 11:22 ` Ferruh Yigit
2020-01-29 17:57 ` David Harton (dharton)
1 sibling, 1 reply; 7+ messages in thread
From: Ferruh Yigit @ 2020-01-29 11:22 UTC (permalink / raw)
To: David Harton, dev; +Cc: wenzhuo.lu, konstantin.ananyev, xiaolong.ye, intel.com
On 1/26/2020 5:32 PM, David Harton wrote:
> Added rollover logic to UPDATE_VF_STAT and UPDATE_VF_STAT_36BIT macros.
>
> Fixes: af75078fece3 ("first public release")
> Cc: intel.com
>
> Signed-off-by: David Harton <dharton@cisco.com>
> ---
> drivers/net/ixgbe/ixgbe_ethdev.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
> index 49285ce53..bc73ad195 100644
> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> @@ -385,7 +385,11 @@ 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; \
Here since 'last' is 'u64', the 'UINT_MAX' is required, but overall this looks
good, original code should be OK.
> + if (latest >= last) \
> + cur += (latest - last); \
> + else \
> + cur += ((latest + ((uint64_t)1 << 32)) - last); \
> + cur &= UINT_MAX; \
> last = latest; \
> }
>
> @@ -394,7 +398,11 @@ 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 >= last) \
> + cur += (latest - last); \
> + else \
> + cur += ((latest + ((u64)1 << 36)) - last); \
> + cur &= 0xFFFFFFFFFLL; \
For this case old and new implementation looks same to me.
> last = latest; \
> }
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] [PATCH v2] net/ixgbevf: update VF_STAT macros to handle rollover
2020-01-29 11:22 ` Ferruh Yigit
@ 2020-01-29 17:57 ` David Harton (dharton)
0 siblings, 0 replies; 7+ messages in thread
From: David Harton (dharton) @ 2020-01-29 17:57 UTC (permalink / raw)
To: Ferruh Yigit, dev; +Cc: wenzhuo.lu, konstantin.ananyev, xiaolong.ye, intel.com
> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@intel.com>
> Sent: Wednesday, January 29, 2020 6:23 AM
> To: David Harton (dharton) <dharton@cisco.com>; dev@dpdk.org
> Cc: wenzhuo.lu@intel.com; konstantin.ananyev@intel.com;
> xiaolong.ye@intel.com; intel.com@cisco.com
> Subject: Re: [dpdk-dev] [PATCH v2] net/ixgbevf: update VF_STAT macros to
> handle rollover
>
> On 1/26/2020 5:32 PM, David Harton wrote:
> > Added rollover logic to UPDATE_VF_STAT and UPDATE_VF_STAT_36BIT macros.
> >
> > Fixes: af75078fece3 ("first public release")
> > Cc: intel.com
> >
> > Signed-off-by: David Harton <dharton@cisco.com>
> > ---
> > drivers/net/ixgbe/ixgbe_ethdev.c | 12 ++++++++++--
> > 1 file changed, 10 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c
> > b/drivers/net/ixgbe/ixgbe_ethdev.c
> > index 49285ce53..bc73ad195 100644
> > --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> > +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> > @@ -385,7 +385,11 @@ 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; \
>
> Here since 'last' is 'u64', the 'UINT_MAX' is required, but overall this
> looks good, original code should be OK.
Agreed. As mentioned on the igbvf thread I've gone back to the developer for justification.
Regards,
Dave
>
> > + if (latest >= last) \
> > + cur += (latest - last); \
> > + else \
> > + cur += ((latest + ((uint64_t)1 << 32)) - last); \
> > + cur &= UINT_MAX; \
> > last = latest; \
> > }
> >
> > @@ -394,7 +398,11 @@ 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 >= last) \
> > + cur += (latest - last); \
> > + else \
> > + cur += ((latest + ((u64)1 << 36)) - last); \
> > + cur &= 0xFFFFFFFFFLL; \
>
> For this case old and new implementation looks same to me.
>
> > last = latest; \
> > }
> >
> >
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-01-29 17:57 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-11 2:38 [dpdk-dev] [PATCH] net/ixgbevf: update VF_STAT macros to handle rollover David Harton
2020-01-26 9:42 ` Ye Xiaolong
2020-01-26 17:13 ` Stephen Hemminger
2020-01-26 17:32 ` [dpdk-dev] [PATCH v2] " David Harton
2020-01-29 7:53 ` Ye Xiaolong
2020-01-29 11:22 ` Ferruh Yigit
2020-01-29 17:57 ` David Harton (dharton)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).