DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] event/sw: fix selftest xstats reset API usage
@ 2022-10-12 12:34 Harry van Haaren
  2022-10-12 13:05 ` Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: Harry van Haaren @ 2022-10-12 12:34 UTC (permalink / raw)
  To: dev
  Cc: jerinj, weiyuanx.li, thomas, ferruh.yigit, andrew.rybchenko,
	Harry van Haaren, Morten Brørup

The eventdev xstats reset API takes an ID of "uint32_t", while
the rest of the xstats APIs require an "unsigned int". On some
platforms these might not be the same bitwidth, however this was
assumed in the code.

Fix by providing a uint32_t to the xstats_reset() function.
Fixes: e21df4b062b5 ("test/eventdev: add SW xstats tests")

Reported-by: Morten Brørup <mb@smartsharesystems.com>
Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>

---

Note this is a fix for a potential build issue in 64-bit BE systems.

---
 drivers/event/sw/sw_evdev_selftest.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/event/sw/sw_evdev_selftest.c b/drivers/event/sw/sw_evdev_selftest.c
index ed7ae6a685..f8496bc44e 100644
--- a/drivers/event/sw/sw_evdev_selftest.c
+++ b/drivers/event/sw/sw_evdev_selftest.c
@@ -1525,10 +1525,11 @@ xstats_id_reset_tests(struct test *t)
 				dev_names[i], dev_expected[i], val);
 			goto fail;
 		}
-		/* reset to zero */
+		/* reset to zero: note API requires uint32_t not unsigned int */
+		uint32_t reset_id = id;
 		int reset_ret = rte_event_dev_xstats_reset(evdev,
 						RTE_EVENT_DEV_XSTATS_DEVICE, 0,
-						&id,
+						&reset_id,
 						1);
 		if (reset_ret) {
 			printf("%d: failed to reset successfully\n", __LINE__);
@@ -1647,10 +1648,11 @@ xstats_id_reset_tests(struct test *t)
 				port_expected[i], id);
 			failed = 1;
 		}
-		/* reset to zero */
+		/* reset to zero: note API requires uint32_t not unsigned int */
+		uint32_t reset_id = id;
 		int reset_ret = rte_event_dev_xstats_reset(evdev,
 						RTE_EVENT_DEV_XSTATS_PORT, PORT,
-						&id,
+						&reset_id,
 						1);
 		if (reset_ret) {
 			printf("%d: failed to reset successfully\n", __LINE__);
@@ -1762,10 +1764,11 @@ xstats_id_reset_tests(struct test *t)
 				queue_names[i], queue_expected[i], val);
 			failed = 1;
 		}
-		/* reset to zero */
+		/* reset to zero: note API requires uint32_t not unsigned int */
+		uint32_t reset_id = id;
 		int reset_ret = rte_event_dev_xstats_reset(evdev,
 						RTE_EVENT_DEV_XSTATS_QUEUE,
-						queue, &id, 1);
+						queue, &reset_id, 1);
 		if (reset_ret) {
 			printf("%d: failed to reset successfully\n", __LINE__);
 			failed = 1;
-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] event/sw: fix selftest xstats reset API usage
  2022-10-12 12:34 [PATCH] event/sw: fix selftest xstats reset API usage Harry van Haaren
@ 2022-10-12 13:05 ` Thomas Monjalon
  2022-10-12 13:08   ` Van Haaren, Harry
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Monjalon @ 2022-10-12 13:05 UTC (permalink / raw)
  To: Harry van Haaren
  Cc: dev, jerinj, weiyuanx.li, ferruh.yigit, andrew.rybchenko,
	Morten Brørup

12/10/2022 14:34, Harry van Haaren:
> The eventdev xstats reset API takes an ID of "uint32_t", while
> the rest of the xstats APIs require an "unsigned int". On some
> platforms these might not be the same bitwidth, however this was
> assumed in the code.
> 
> Fix by providing a uint32_t to the xstats_reset() function.

Why adding a comment about the type in the code?
We are not adding /* using the right type */ in each line of code.

[...]
> -		/* reset to zero */
> +		/* reset to zero: note API requires uint32_t not unsigned int */
> +		uint32_t reset_id = id;
>  		int reset_ret = rte_event_dev_xstats_reset(evdev,




^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] event/sw: fix selftest xstats reset API usage
  2022-10-12 13:05 ` Thomas Monjalon
@ 2022-10-12 13:08   ` Van Haaren, Harry
  2022-10-12 15:09     ` Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: Van Haaren, Harry @ 2022-10-12 13:08 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, jerinj, Li, WeiyuanX, ferruh.yigit, andrew.rybchenko,
	Morten Brørup

> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Wednesday, October 12, 2022 2:06 PM
> To: Van Haaren, Harry <harry.van.haaren@intel.com>
> Cc: dev@dpdk.org; jerinj@marvell.com; Li, WeiyuanX <weiyuanx.li@intel.com>;
> ferruh.yigit@amd.com; andrew.rybchenko@oktetlabs.ru; Morten Brørup
> <mb@smartsharesystems.com>
> Subject: Re: [PATCH] event/sw: fix selftest xstats reset API usage
> 
> 12/10/2022 14:34, Harry van Haaren:
> > The eventdev xstats reset API takes an ID of "uint32_t", while
> > the rest of the xstats APIs require an "unsigned int". On some
> > platforms these might not be the same bitwidth, however this was
> > assumed in the code.
> >
> > Fix by providing a uint32_t to the xstats_reset() function.
> 
> Why adding a comment about the type in the code?
> We are not adding /* using the right type */ in each line of code.

Correct; but as the SW PMD was the only selftest code that actually
uses xstats_reset() I err-ed on the side of warning devs that there's
some "funky" or inconsistent API requirements here.

I can respin without if that seems better, but my intention was to
help future readers..?

<snip>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] event/sw: fix selftest xstats reset API usage
  2022-10-12 13:08   ` Van Haaren, Harry
@ 2022-10-12 15:09     ` Thomas Monjalon
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2022-10-12 15:09 UTC (permalink / raw)
  To: Van Haaren, Harry
  Cc: dev, jerinj, Li, WeiyuanX, ferruh.yigit, andrew.rybchenko,
	Morten Brørup, david.marchand

12/10/2022 15:08, Van Haaren, Harry:
> From: Thomas Monjalon <thomas@monjalon.net>
> > 12/10/2022 14:34, Harry van Haaren:
> > > The eventdev xstats reset API takes an ID of "uint32_t", while
> > > the rest of the xstats APIs require an "unsigned int". On some
> > > platforms these might not be the same bitwidth, however this was
> > > assumed in the code.
> > >
> > > Fix by providing a uint32_t to the xstats_reset() function.
> > 
> > Why adding a comment about the type in the code?
> > We are not adding /* using the right type */ in each line of code.
> 
> Correct; but as the SW PMD was the only selftest code that actually
> uses xstats_reset() I err-ed on the side of warning devs that there's
> some "funky" or inconsistent API requirements here.
> 
> I can respin without if that seems better, but my intention was to
> help future readers..?

It does not really help.
If you want to help, and you think the API is wrong,
then please send a patch to propose a change in the API.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-12 15:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-12 12:34 [PATCH] event/sw: fix selftest xstats reset API usage Harry van Haaren
2022-10-12 13:05 ` Thomas Monjalon
2022-10-12 13:08   ` Van Haaren, Harry
2022-10-12 15:09     ` Thomas Monjalon

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).