DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net/nfp: fix wrong argument order in nfp_encode_basic
@ 2026-11-13 14:28 Bulatov Mark
  2026-11-15 21:48 ` Stephen Hemminger
  0 siblings, 1 reply; 2+ messages in thread
From: Bulatov Mark @ 2026-11-13 14:28 UTC (permalink / raw)
  To: Niklas Söderlund, Chaoyong He; +Cc: dev, stable, Mark Bulatov

The function nfp_encode_basic_qdr() takes cpp_tgt as its second argument
and dest_island as its third. However, the implementation of this function
implies the opposite: dest_island should be the second argument, and
cpp_tgt the third.

Furthermore, the implementation compares the second argument against a
negative value, whereas the cpp_tgt parameter — as defined in the
nfp_target.h header file—consists of a set of values ​​that does not
include any negative numbers. The situation is exactly the reverse for
the nfp_decode_basic() function, which receives a value for which these
definitions are not entirely appropriate.

Fix this by swapping the arguments.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: e6858e7e7c ("net/nfp: move shared target logic to own file")
Cc: stable@dpdk.org

Signed-off-by: Mark Bulatov <ms.bulatov7@gmail.com>
---
 drivers/net/nfp/nfpcore/nfp_target.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/nfp/nfpcore/nfp_target.c b/drivers/net/nfp/nfpcore/nfp_target.c
index 0e7a5cbb05..239ffff869 100644
--- a/drivers/net/nfp/nfpcore/nfp_target.c
+++ b/drivers/net/nfp/nfpcore/nfp_target.c
@@ -728,7 +728,7 @@ nfp_encode_basic(uint64_t *addr,
 			 * address but we can verify if the existing contents
 			 * will point to a valid island.
 			 */
-			return nfp_encode_basic_qdr(*addr, cpp_tgt, dest_island,
+			return nfp_encode_basic_qdr(*addr, dest_island, cpp_tgt,
 					mode, addr40, isld1, isld0);
 		}
 
@@ -741,7 +741,7 @@ nfp_encode_basic(uint64_t *addr,
 		return 0;
 	case 1:
 		if (cpp_tgt == NFP_CPP_TARGET_QDR && addr40 == 0) {
-			return nfp_encode_basic_qdr(*addr, cpp_tgt, dest_island,
+			return nfp_encode_basic_qdr(*addr, dest_island, cpp_tgt,
 					mode, addr40, isld1, isld0);
 		}
 
@@ -763,7 +763,7 @@ nfp_encode_basic(uint64_t *addr,
 		if (cpp_tgt == NFP_CPP_TARGET_QDR && addr40 == 0) {
 			/* iid<0> = addr<30> = channel<0> */
 			/* channel<1> = addr<31> = Index */
-			return nfp_encode_basic_qdr(*addr, cpp_tgt, dest_island,
+			return nfp_encode_basic_qdr(*addr, dest_island, cpp_tgt,
 					mode, addr40, isld1, isld0);
 		}
 
@@ -786,7 +786,7 @@ nfp_encode_basic(uint64_t *addr,
 			 * iid<1> = addr<30> = channel<0>
 			 * channel<1> = addr<31> = Index
 			 */
-			return nfp_encode_basic_qdr(*addr, cpp_tgt, dest_island,
+			return nfp_encode_basic_qdr(*addr, dest_island, cpp_tgt,
 					mode, addr40, isld1, isld0);
 		}
 
-- 
2.39.5


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

* Re: [PATCH] net/nfp: fix wrong argument order in nfp_encode_basic
  2026-11-13 14:28 [PATCH] net/nfp: fix wrong argument order in nfp_encode_basic Bulatov Mark
@ 2026-11-15 21:48 ` Stephen Hemminger
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2026-11-15 21:48 UTC (permalink / raw)
  To: Bulatov Mark; +Cc: Niklas Söderlund, Chaoyong He, dev, stable

On Fri, 13 Nov 2026 17:28:23 +0300
Bulatov Mark <ms.bulatov7@gmail.com> wrote:

> The function nfp_encode_basic_qdr() takes cpp_tgt as its second argument
> and dest_island as its third. However, the implementation of this function
> implies the opposite: dest_island should be the second argument, and
> cpp_tgt the third.
> 
> Furthermore, the implementation compares the second argument against a
> negative value, whereas the cpp_tgt parameter — as defined in the
> nfp_target.h header file—consists of a set of values ​​that does not
> include any negative numbers. The situation is exactly the reverse for
> the nfp_decode_basic() function, which receives a value for which these
> definitions are not entirely appropriate.
> 
> Fix this by swapping the arguments.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: e6858e7e7c ("net/nfp: move shared target logic to own file")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Mark Bulatov <ms.bulatov7@gmail.com>
> ---

Several issues need fixing from AI review.

[PATCH] net/nfp: fix wrong argument order in nfp_encode_basic

The fix is correct. nfp_encode_basic_qdr() is declared as
(addr, dest_island, cpp_tgt, ...) and all four callers pass
(addr, cpp_tgt, dest_island, ...). With the swap, decode skipped the
MU/CT_XPB guard on the real target and the final compare checked the
decoded island against NFP_CPP_TARGET_QDR (2) instead of dest_island,
so QDR encoding failed with -EINVAL unless the island happened to be 2.

Warning: Author does not match Signed-off-by.

  The patch has no "From: Mark Bulatov" line in the body, so git am
  records the author as "Bulatov Mark" while the Signed-off-by is
  "Mark Bulatov". The first patch has the body From: line; this one
  needs it too, or fix user.name so the header is right.

Warning: Commit message contains non-ASCII characters: two em-dashes
and two zero-width spaces (U+200B) in "values that". The second
paragraph is also hard to follow. Suggest:

	nfp_encode_basic_qdr() takes dest_island as its second argument
	and cpp_tgt as its third, but all callers in nfp_encode_basic()
	pass them in the opposite order. As a result nfp_decode_basic()
	gets the island ID as the target, and the island check compares
	against NFP_CPP_TARGET_QDR instead of the requested island.

	Swap the arguments.

Warning: Fixes tag needs a 12 character hash:

	Fixes: e6858e7e7cd3 ("net/nfp: move shared target logic to own file")

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

end of thread, other threads:[~2026-11-15 21:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-13 14:28 [PATCH] net/nfp: fix wrong argument order in nfp_encode_basic Bulatov Mark
2026-11-15 21:48 ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox