DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] fib: fix return value behavior
@ 2024-10-15 17:11 Vladimir Medvedkin
  2024-10-16  5:29 ` Stephen Hemminger
  0 siblings, 1 reply; 5+ messages in thread
From: Vladimir Medvedkin @ 2024-10-15 17:11 UTC (permalink / raw)
  To: dev; +Cc: david.marchand

Fixes the behavior of the rte_fib_rcu_qsbr_add() function regarding its
return value to align with the existing rte_fib API.

Fixes: 96c3d06a3547 ("fib: implement RCU rule reclamation")

Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
---
 lib/fib/dir24_8.c | 21 ++++++++-------------
 lib/fib/rte_fib.h |  8 ++++----
 2 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/lib/fib/dir24_8.c b/lib/fib/dir24_8.c
index 2fb01a3f99..73a59f3397 100644
--- a/lib/fib/dir24_8.c
+++ b/lib/fib/dir24_8.c
@@ -617,15 +617,11 @@ dir24_8_rcu_qsbr_add(struct dir24_8_tbl *dp, struct rte_fib_rcu_config *cfg,
 	struct rte_rcu_qsbr_dq_parameters params = {0};
 	char rcu_dq_name[RTE_RCU_QSBR_DQ_NAMESIZE];
 
-	if (dp == NULL || cfg == NULL) {
-		rte_errno = EINVAL;
-		return 1;
-	}
+	if (dp == NULL || cfg == NULL)
+		return -EINVAL;
 
-	if (dp->v != NULL) {
-		rte_errno = EEXIST;
-		return 1;
-	}
+	if (dp->v != NULL)
+		return -EEXIST;
 
 	if (cfg->mode == RTE_FIB_QSBR_MODE_SYNC) {
 		/* No other things to do. */
@@ -648,12 +644,11 @@ dir24_8_rcu_qsbr_add(struct dir24_8_tbl *dp, struct rte_fib_rcu_config *cfg,
 		dp->dq = rte_rcu_qsbr_dq_create(&params);
 		if (dp->dq == NULL) {
 			FIB_LOG(ERR, "LPM defer queue creation failed");
-			return 1;
+			return -rte_errno;
 		}
-	} else {
-		rte_errno = EINVAL;
-		return 1;
-	}
+	} else
+		return -EINVAL;
+
 	dp->rcu_mode = cfg->mode;
 	dp->v = cfg->v;
 
diff --git a/lib/fib/rte_fib.h b/lib/fib/rte_fib.h
index 9732ace2e4..c49b02ab11 100644
--- a/lib/fib/rte_fib.h
+++ b/lib/fib/rte_fib.h
@@ -266,10 +266,10 @@ rte_fib_select_lookup(struct rte_fib *fib, enum rte_fib_lookup_type type);
  * @param cfg
  *   RCU QSBR configuration
  * @return
- *   On success - 0
- *   On error - 1 with error code set in rte_errno.
- *   Possible rte_errno codes are:
- *   - EINVAL - invalid pointer
+ *   0 on success
+ *   Negative otherwise
+ *   Possible error codes are:
+ *   - EINVAL - invalid parameters
  *   - EEXIST - already added QSBR
  *   - ENOMEM - memory allocation failure
  *   - ENOTSUP - not supported by configured dataplane algorithm
-- 
2.43.0


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

* Re: [PATCH] fib: fix return value behavior
  2024-10-15 17:11 [PATCH] fib: fix return value behavior Vladimir Medvedkin
@ 2024-10-16  5:29 ` Stephen Hemminger
  2024-10-16  9:28   ` David Marchand
  2024-10-16 15:59   ` Medvedkin, Vladimir
  0 siblings, 2 replies; 5+ messages in thread
From: Stephen Hemminger @ 2024-10-16  5:29 UTC (permalink / raw)
  To: Vladimir Medvedkin; +Cc: dev, david.marchand

On Tue, 15 Oct 2024 17:11:43 +0000
Vladimir Medvedkin <vladimir.medvedkin@intel.com> wrote:

> Fixes the behavior of the rte_fib_rcu_qsbr_add() function regarding its
> return value to align with the existing rte_fib API.
> 
> Fixes: 96c3d06a3547 ("fib: implement RCU rule reclamation")
> 
> Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
> ---

Looks good, although DPDK often uses rte_errno, it is better for this part
in fib to be consistent across rcu and non-rcu variants.

PS: there don't seem to be any negative tests on this function in test_fib.c
would be good to hit some of the basics.

Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>

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

* Re: [PATCH] fib: fix return value behavior
  2024-10-16  5:29 ` Stephen Hemminger
@ 2024-10-16  9:28   ` David Marchand
  2024-10-16 15:59   ` Medvedkin, Vladimir
  1 sibling, 0 replies; 5+ messages in thread
From: David Marchand @ 2024-10-16  9:28 UTC (permalink / raw)
  To: Vladimir Medvedkin; +Cc: Stephen Hemminger, dev

On Wed, Oct 16, 2024 at 7:29 AM Stephen Hemminger
<stephen@networkplumber.org> wrote:
> On Tue, 15 Oct 2024 17:11:43 +0000
> Vladimir Medvedkin <vladimir.medvedkin@intel.com> wrote:
>
> > Fixes the behavior of the rte_fib_rcu_qsbr_add() function regarding its
> > return value to align with the existing rte_fib API.
> >
> > Fixes: 96c3d06a3547 ("fib: implement RCU rule reclamation")
> >
> > Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
> Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>

Applied, thanks.
As Stephen noted, this new API needs better coverage.


-- 
David Marchand


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

* Re: [PATCH] fib: fix return value behavior
  2024-10-16  5:29 ` Stephen Hemminger
  2024-10-16  9:28   ` David Marchand
@ 2024-10-16 15:59   ` Medvedkin, Vladimir
  2024-10-16 17:11     ` Stephen Hemminger
  1 sibling, 1 reply; 5+ messages in thread
From: Medvedkin, Vladimir @ 2024-10-16 15:59 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, david.marchand

[-- Attachment #1: Type: text/plain, Size: 945 bytes --]

Hi Stephen,

On 16/10/2024 06:29, Stephen Hemminger wrote:
> On Tue, 15 Oct 2024 17:11:43 +0000
> Vladimir Medvedkin<vladimir.medvedkin@intel.com>  wrote:
>
>> Fixes the behavior of the rte_fib_rcu_qsbr_add() function regarding its
>> return value to align with the existing rte_fib API.
>>
>> Fixes: 96c3d06a3547 ("fib: implement RCU rule reclamation")
>>
>> Signed-off-by: Vladimir Medvedkin<vladimir.medvedkin@intel.com>
>> ---
> Looks good, although DPDK often uses rte_errno, it is better for this part
> in fib to be consistent across rcu and non-rcu variants.
Iwouldpreferit tobeconsistentwith the restof the FIBAPI.
> PS: there don't seem to be any negative tests on this function in test_fib.c
> would be good to hit some of the basics.
maybeIdidn'tquiteunderstandyou,butthere is basic negative teston 
thisfunction (plz see test_invalid_rcu() test)
>
> Reviewed-by: Stephen Hemminger<stephen@networkplumber.org>

-- 
Regards,
Vladimir

[-- Attachment #2: Type: text/html, Size: 4831 bytes --]

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

* Re: [PATCH] fib: fix return value behavior
  2024-10-16 15:59   ` Medvedkin, Vladimir
@ 2024-10-16 17:11     ` Stephen Hemminger
  0 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2024-10-16 17:11 UTC (permalink / raw)
  To: Medvedkin, Vladimir; +Cc: dev, david.marchand

On Wed, 16 Oct 2024 16:59:48 +0100
"Medvedkin, Vladimir" <vladimir.medvedkin@intel.com> wrote:

> Hi Stephen,
> 
> On 16/10/2024 06:29, Stephen Hemminger wrote:
> > On Tue, 15 Oct 2024 17:11:43 +0000
> > Vladimir Medvedkin<vladimir.medvedkin@intel.com>  wrote:
> >  
> >> Fixes the behavior of the rte_fib_rcu_qsbr_add() function regarding its
> >> return value to align with the existing rte_fib API.
> >>
> >> Fixes: 96c3d06a3547 ("fib: implement RCU rule reclamation")
> >>
> >> Signed-off-by: Vladimir Medvedkin<vladimir.medvedkin@intel.com>
> >> ---  
> > Looks good, although DPDK often uses rte_errno, it is better for this part
> > in fib to be consistent across rcu and non-rcu variants.  
> Iwouldpreferit tobeconsistentwith the restof the FIBAPI.
> > PS: there don't seem to be any negative tests on this function in test_fib.c
> > would be good to hit some of the basics.  
> maybeIdidn'tquiteunderstandyou,butthere is basic negative teston 
> thisfunction (plz see test_invalid_rcu() test)
> >
> > Reviewed-by: Stephen Hemminger<stephen@networkplumber.org>  
> 
The test_fib does not do any tests where it calls these functions with
bad arguments and expects failure. Mostly it tries to do normal calls.

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

end of thread, other threads:[~2024-10-16 17:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-15 17:11 [PATCH] fib: fix return value behavior Vladimir Medvedkin
2024-10-16  5:29 ` Stephen Hemminger
2024-10-16  9:28   ` David Marchand
2024-10-16 15:59   ` Medvedkin, Vladimir
2024-10-16 17:11     ` Stephen Hemminger

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