net/ixgbe: fix per-queue stats for less queues

Message ID 20241024111757.791634-1-mb@smartsharesystems.com (mailing list archive)
State Superseded, archived
Delegated to: Bruce Richardson
Headers
Series net/ixgbe: fix per-queue stats for less queues |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS

Commit Message

Morten Brørup Oct. 24, 2024, 11:17 a.m. UTC
Remove the requirement that the configured number of queues to provide
statistics for (RTE_ETHDEV_QUEUE_STAT_CNTRS) cannot be less than the
driver's max supported number of the same (IXGBE_QUEUE_STAT_COUNTERS).

Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Morten Brørup Oct. 24, 2024, 3:15 p.m. UTC | #1
Forwarding to the now official maintainers for review. :-)

Thank you for updating the MAINTAINERS file, Bruce.

PS: Please correct "fix"->"support" in the subject when merging, it was a typo.

> From: Morten Brørup [mailto:mb@smartsharesystems.com]
> Sent: Thursday, 24 October 2024 13.18
> 
> Remove the requirement that the configured number of queues to provide
> statistics for (RTE_ETHDEV_QUEUE_STAT_CNTRS) cannot be less than the
> driver's max supported number of the same (IXGBE_QUEUE_STAT_COUNTERS).
> 
> Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
> ---
>  drivers/net/ixgbe/ixgbe_ethdev.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c
> b/drivers/net/ixgbe/ixgbe_ethdev.c
> index ab37c37469..895d6e7169 100644
> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> @@ -3385,7 +3385,8 @@ ixgbe_dev_stats_get(struct rte_eth_dev *dev,
> struct rte_eth_stats *stats)
>  	stats->opackets = hw_stats->gptc;
>  	stats->obytes = hw_stats->gotc;
> 
> -	for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
> +	for (i = 0; i < RTE_MIN(IXGBE_QUEUE_STAT_COUNTERS,
> +
> 	(typeof(IXGBE_QUEUE_STAT_COUNTERS))RTE_ETHDEV_QUEUE_STAT_CNTRS);
> i++) {
>  		stats->q_ipackets[i] = hw_stats->qprc[i];
>  		stats->q_opackets[i] = hw_stats->qptc[i];
>  		stats->q_ibytes[i] = hw_stats->qbrc[i];
> --
> 2.43.0
  
Bruce Richardson Oct. 24, 2024, 4:02 p.m. UTC | #2
On Thu, Oct 24, 2024 at 05:15:10PM +0200, Morten Brørup wrote:
> Forwarding to the now official maintainers for review. :-)
> 
> Thank you for updating the MAINTAINERS file, Bruce.
> 
> PS: Please correct "fix"->"support" in the subject when merging, it was a typo.
> 
> > From: Morten Brørup [mailto:mb@smartsharesystems.com]
> > Sent: Thursday, 24 October 2024 13.18
> > 
> > Remove the requirement that the configured number of queues to provide
> > statistics for (RTE_ETHDEV_QUEUE_STAT_CNTRS) cannot be less than the
> > driver's max supported number of the same (IXGBE_QUEUE_STAT_COUNTERS).
> > 
> > Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
> > ---
> >  drivers/net/ixgbe/ixgbe_ethdev.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c
> > b/drivers/net/ixgbe/ixgbe_ethdev.c
> > index ab37c37469..895d6e7169 100644
> > --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> > +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> > @@ -3385,7 +3385,8 @@ ixgbe_dev_stats_get(struct rte_eth_dev *dev,
> > struct rte_eth_stats *stats)
> >  	stats->opackets = hw_stats->gptc;
> >  	stats->obytes = hw_stats->gotc;
> > 
> > -	for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
> > +	for (i = 0; i < RTE_MIN(IXGBE_QUEUE_STAT_COUNTERS,
> > +
> > 	(typeof(IXGBE_QUEUE_STAT_COUNTERS))RTE_ETHDEV_QUEUE_STAT_CNTRS);
> > i++) {

The big cast using "typeof" is awkward-looking but is probably the best way
to do this!

Thanks.

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

> >  		stats->q_ipackets[i] = hw_stats->qprc[i];
> >  		stats->q_opackets[i] = hw_stats->qptc[i];
> >  		stats->q_ibytes[i] = hw_stats->qbrc[i];
> > --
> > 2.43.0
>
  
Morten Brørup Oct. 24, 2024, 4:28 p.m. UTC | #3
> > > -	for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
> > > +	for (i = 0; i < RTE_MIN(IXGBE_QUEUE_STAT_COUNTERS,
> > > +
> > > 	(typeof(IXGBE_QUEUE_STAT_COUNTERS))RTE_ETHDEV_QUEUE_STAT_CNTRS);
> > > i++) {
> 
> The big cast using "typeof" is awkward-looking but is probably the best
> way
> to do this!

Yes. It fixes a signed/unsigned comparison warning.

RTE_ETHDEV_QUEUE_STAT_CNTRS is int, "i" is unsigned, and IXGBE_QUEUE_STAT_COUNTERS is size_t.

Not easy choosing a good common type without adding an explanation. The typeof() seemed like an acceptable compromise.
  
Bruce Richardson Oct. 24, 2024, 4:46 p.m. UTC | #4
On Thu, Oct 24, 2024 at 06:28:27PM +0200, Morten Brørup wrote:
> > > > -	for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
> > > > +	for (i = 0; i < RTE_MIN(IXGBE_QUEUE_STAT_COUNTERS,
> > > > +
> > > > 	(typeof(IXGBE_QUEUE_STAT_COUNTERS))RTE_ETHDEV_QUEUE_STAT_CNTRS);
> > > > i++) {
> > 
> > The big cast using "typeof" is awkward-looking but is probably the best
> > way
> > to do this!
> 
> Yes. It fixes a signed/unsigned comparison warning.
> 
> RTE_ETHDEV_QUEUE_STAT_CNTRS is int, "i" is unsigned, and IXGBE_QUEUE_STAT_COUNTERS is size_t.
> 
> Not easy choosing a good common type without adding an explanation. The typeof() seemed like an acceptable compromise.
> 

If I may suggest it, "typeof(i)" is shorter :-)
  
Stephen Hemminger Oct. 24, 2024, 4:49 p.m. UTC | #5
On Thu, 24 Oct 2024 11:17:57 +0000
Morten Brørup <mb@smartsharesystems.com> wrote:

> Remove the requirement that the configured number of queues to provide
> statistics for (RTE_ETHDEV_QUEUE_STAT_CNTRS) cannot be less than the
> driver's max supported number of the same (IXGBE_QUEUE_STAT_COUNTERS).
> 
> Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
> ---
>  drivers/net/ixgbe/ixgbe_ethdev.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
> index ab37c37469..895d6e7169 100644
> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> @@ -3385,7 +3385,8 @@ ixgbe_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
>  	stats->opackets = hw_stats->gptc;
>  	stats->obytes = hw_stats->gotc;
>  
> -	for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
> +	for (i = 0; i < RTE_MIN(IXGBE_QUEUE_STAT_COUNTERS,
> +			(typeof(IXGBE_QUEUE_STAT_COUNTERS))RTE_ETHDEV_QUEUE_STAT_CNTRS); i++) {

Maybe use RTE_MIN_T to avoid using typeof directly here.

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index ab37c37469..cdf689c22d 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -3385,7 +3385,8 @@ ixgbe_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
        stats->opackets = hw_stats->gptc;
        stats->obytes = hw_stats->gotc;
 
-       for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
+       for (i = 0; i < RTE_MIN_T(IXGBE_QUEUE_STAT_COUNTERS,
+                         RTE_ETHDEV_QUEUE_STAT_CNTRS, unsigned); i++) {
                stats->q_ipackets[i] = hw_stats->qprc[i];
                stats->q_opackets[i] = hw_stats->qptc[i];
                stats->q_ibytes[i] = hw_stats->qbrc[i];
  
Morten Brørup Oct. 24, 2024, 7 p.m. UTC | #6
Forgot the --in-reply-to, so here's the link to the V2 patch:
https://inbox.dpdk.org/dev/20241024185352.987356-1-mb@smartsharesystems.com/
  

Patch

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index ab37c37469..895d6e7169 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -3385,7 +3385,8 @@  ixgbe_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 	stats->opackets = hw_stats->gptc;
 	stats->obytes = hw_stats->gotc;
 
-	for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
+	for (i = 0; i < RTE_MIN(IXGBE_QUEUE_STAT_COUNTERS,
+			(typeof(IXGBE_QUEUE_STAT_COUNTERS))RTE_ETHDEV_QUEUE_STAT_CNTRS); i++) {
 		stats->q_ipackets[i] = hw_stats->qprc[i];
 		stats->q_opackets[i] = hw_stats->qptc[i];
 		stats->q_ibytes[i] = hw_stats->qbrc[i];