DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] rawdev: fix device ID retrieval function prototype
@ 2025-09-24  5:56 Nawal Kishor
  2025-10-15 15:05 ` Thomas Monjalon
  0 siblings, 1 reply; 6+ messages in thread
From: Nawal Kishor @ 2025-09-24  5:56 UTC (permalink / raw)
  To: dev, Sachin Saxena, Hemant Agrawal, Shreyansh Jain
  Cc: jerinj, asekhar, Nawal Kishor

Fixed rte_rawdev_get_dev_id() function prototype and its usage.

Fixes: c88b3f2558ed ("rawdev: introduce raw device library")

Signed-off-by: Nawal Kishor <nkishor@marvell.com>
---
This patch fixes the return type of rte_rawdev_get_dev_id(). It would be good
to have it merged before the 25.11 release, as it corrects a user-visible API
bug and is a safe change.

 app/test/test_rawdev.c  | 11 +++++++++--
 lib/rawdev/rte_rawdev.c |  2 +-
 lib/rawdev/rte_rawdev.h |  2 +-
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/app/test/test_rawdev.c b/app/test/test_rawdev.c
index d34691dacf..d1d250c9ac 100644
--- a/app/test/test_rawdev.c
+++ b/app/test/test_rawdev.c
@@ -25,11 +25,18 @@ test_rawdev_selftests(void)
 static int
 test_rawdev_selftest_impl(const char *pmd, const char *opts)
 {
-	int ret;
+	int dev_id, ret;
 
 	printf("\n### Test rawdev infrastructure using skeleton driver\n");
 	rte_vdev_init(pmd, opts);
-	ret = rte_rawdev_selftest(rte_rawdev_get_dev_id(pmd));
+	dev_id = rte_rawdev_get_dev_id(pmd);
+	if (dev_id < 0) {
+		printf("Failed to get dev_id for %s\n", pmd);
+		ret = dev_id;
+		goto exit;
+	}
+	ret = rte_rawdev_selftest(dev_id);
+exit:
 	rte_vdev_uninit(pmd);
 	return ret;
 }
diff --git a/lib/rawdev/rte_rawdev.c b/lib/rawdev/rte_rawdev.c
index 4da7956d5a..f21d29114c 100644
--- a/lib/rawdev/rte_rawdev.c
+++ b/lib/rawdev/rte_rawdev.c
@@ -39,7 +39,7 @@ rte_rawdev_count(void)
 }
 
 RTE_EXPORT_SYMBOL(rte_rawdev_get_dev_id)
-uint16_t
+int
 rte_rawdev_get_dev_id(const char *name)
 {
 	uint16_t i;
diff --git a/lib/rawdev/rte_rawdev.h b/lib/rawdev/rte_rawdev.h
index 3fc471526e..ad849e5bea 100644
--- a/lib/rawdev/rte_rawdev.h
+++ b/lib/rawdev/rte_rawdev.h
@@ -44,7 +44,7 @@ rte_rawdev_count(void);
  *   Returns raw device identifier on success.
  *   - <0: Failure to find named raw device.
  */
-uint16_t
+int
 rte_rawdev_get_dev_id(const char *name);
 
 /**
-- 
2.48.1


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

* Re: [PATCH] rawdev: fix device ID retrieval function prototype
  2025-09-24  5:56 [PATCH] rawdev: fix device ID retrieval function prototype Nawal Kishor
@ 2025-10-15 15:05 ` Thomas Monjalon
  2025-10-16  6:56   ` Nawal Kishor
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Monjalon @ 2025-10-15 15:05 UTC (permalink / raw)
  To: Nawal Kishor
  Cc: dev, Sachin Saxena, Hemant Agrawal, Shreyansh Jain, jerinj, asekhar

24/09/2025 07:56, Nawal Kishor:
> Fixed rte_rawdev_get_dev_id() function prototype and its usage.

What? Why?

[...]
> -uint16_t
> +int
>  rte_rawdev_get_dev_id(const char *name);

Other functions handle dev_id as uint16_t, so why changing this function?



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

* Re: [PATCH] rawdev: fix device ID retrieval function prototype
  2025-10-15 15:05 ` Thomas Monjalon
@ 2025-10-16  6:56   ` Nawal Kishor
  2025-10-16  8:08     ` Thomas Monjalon
  0 siblings, 1 reply; 6+ messages in thread
From: Nawal Kishor @ 2025-10-16  6:56 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, Sachin Saxena, Hemant Agrawal, Shreyansh Jain, Jerin Jacob,
	Ashwin Sekhar T K


>> Fixed rte_rawdev_get_dev_id() function prototype and its usage.
>
>What? Why?

>[...]
>> -uint16_t
>> +int
>>  rte_rawdev_get_dev_id(const char *name);

>Other functions handle dev_id as uint16_t, so why changing this function?

The spec says that rte_rawdev_get_dev_id() returns negative number in case of failure.
But in the definition it is returning uint16_t which will never be negative, hence changed it to int.

If this is not acceptable, what fix will you suggest?


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

* Re: [PATCH] rawdev: fix device ID retrieval function prototype
  2025-10-16  6:56   ` Nawal Kishor
@ 2025-10-16  8:08     ` Thomas Monjalon
  2025-10-17 11:05       ` [EXTERNAL] " Akhil Goyal
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Monjalon @ 2025-10-16  8:08 UTC (permalink / raw)
  To: Nawal Kishor
  Cc: dev, Sachin Saxena, Hemant Agrawal, Shreyansh Jain, Jerin Jacob,
	Ashwin Sekhar T K

16/10/2025 08:56, Nawal Kishor:
> 
> >> Fixed rte_rawdev_get_dev_id() function prototype and its usage.
> >
> >What? Why?
> 
> >[...]
> >> -uint16_t
> >> +int
> >>  rte_rawdev_get_dev_id(const char *name);
> 
> >Other functions handle dev_id as uint16_t, so why changing this function?
> 
> The spec says that rte_rawdev_get_dev_id() returns negative number in case of failure.
> But in the definition it is returning uint16_t which will never be negative, hence changed it to int.
> 
> If this is not acceptable, what fix will you suggest?

You should change to int16_t for all rawdev id parameters.



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

* RE: [EXTERNAL] Re: [PATCH] rawdev: fix device ID retrieval function prototype
  2025-10-16  8:08     ` Thomas Monjalon
@ 2025-10-17 11:05       ` Akhil Goyal
  2025-10-17 15:52         ` Thomas Monjalon
  0 siblings, 1 reply; 6+ messages in thread
From: Akhil Goyal @ 2025-10-17 11:05 UTC (permalink / raw)
  To: Thomas Monjalon, Nawal Kishor
  Cc: dev, Sachin Saxena, Hemant Agrawal, Jerin Jacob, Ashwin Sekhar T K

Hi Thomas,
> 16/10/2025 08:56, Nawal Kishor:
> >
> > >> Fixed rte_rawdev_get_dev_id() function prototype and its usage.
> > >
> > >What? Why?
> >
> > >[...]
> > >> -uint16_t
> > >> +int
> > >>  rte_rawdev_get_dev_id(const char *name);
> >
> > >Other functions handle dev_id as uint16_t, so why changing this function?
> >
> > The spec says that rte_rawdev_get_dev_id() returns negative number in case of
> failure.
> > But in the definition it is returning uint16_t which will never be negative, hence
> changed it to int.
> >
> > If this is not acceptable, what fix will you suggest?
> 
> You should change to int16_t for all rawdev id parameters.
> 
Wont that be an API/ABI break for all the APIs?
We have a similar rte_cryptodev_get_dev_id() and rte_event_dev_get_dev_id() APIs which 
return <0 value in case of failure and a positive value for valid ones.
dev_id is defined as unsigned value which is being used everywhere in all APIs of cryptodev, eventdev and rawdev.
The negative value here is just to denote that the API fails to retrieve dev_id and application should take action and not proceed further with that value.
Changing dev_id to a signed value in my opinion is not necessary just because this API may return <0 value on failure.

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

* Re: [EXTERNAL] Re: [PATCH] rawdev: fix device ID retrieval function prototype
  2025-10-17 11:05       ` [EXTERNAL] " Akhil Goyal
@ 2025-10-17 15:52         ` Thomas Monjalon
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2025-10-17 15:52 UTC (permalink / raw)
  To: Nawal Kishor, Akhil Goyal
  Cc: dev, Sachin Saxena, Hemant Agrawal, Jerin Jacob, Ashwin Sekhar T K

17/10/2025 13:05, Akhil Goyal:
> Hi Thomas,
> > 16/10/2025 08:56, Nawal Kishor:
> > >
> > > >> Fixed rte_rawdev_get_dev_id() function prototype and its usage.
> > > >
> > > >What? Why?
> > >
> > > >[...]
> > > >> -uint16_t
> > > >> +int
> > > >>  rte_rawdev_get_dev_id(const char *name);
> > >
> > > >Other functions handle dev_id as uint16_t, so why changing this function?
> > >
> > > The spec says that rte_rawdev_get_dev_id() returns negative number in case of
> > failure.
> > > But in the definition it is returning uint16_t which will never be negative, hence
> > changed it to int.
> > >
> > > If this is not acceptable, what fix will you suggest?
> > 
> > You should change to int16_t for all rawdev id parameters.
> > 
> Wont that be an API/ABI break for all the APIs?
> We have a similar rte_cryptodev_get_dev_id() and rte_event_dev_get_dev_id() APIs which 
> return <0 value in case of failure and a positive value for valid ones.
> dev_id is defined as unsigned value which is being used everywhere in all APIs of cryptodev, eventdev and rawdev.
> The negative value here is just to denote that the API fails to retrieve dev_id and application should take action and not proceed further with that value.
> Changing dev_id to a signed value in my opinion is not necessary just because this API may return <0 value on failure.

OK but then it means that very high port IDs would be considered an error.
It is not realistic, but theoritically wrong.
OK to change only this function then.



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

end of thread, other threads:[~2025-10-17 15:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-24  5:56 [PATCH] rawdev: fix device ID retrieval function prototype Nawal Kishor
2025-10-15 15:05 ` Thomas Monjalon
2025-10-16  6:56   ` Nawal Kishor
2025-10-16  8:08     ` Thomas Monjalon
2025-10-17 11:05       ` [EXTERNAL] " Akhil Goyal
2025-10-17 15:52         ` 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).