Skip to contentSkip to conversation

net/nfp: fix wrong argument order in nfp_encode_basic

PATCH Superseded Mark Bulatov 2 participants 3 messages Nov 17 – Nov 20 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net/nfp: fix wrong argument order in nfp_encode_basic

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.

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.

Fix this by swapping the arguments.

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

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

---
v2 changes: Correction of the 'Fixes' tag and description

v1 link:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

 drivers/net/nfp/nfpcore/nfp_target.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/nfp/nfpcore/nfp_target.c +4 -4
index 0e7a5cbb05..239ffff869 100644
@@ -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);
 		}
 
Signature · 1 line
2.39.5
#1 lore raw
Quoted 13 lines · On Mon, 16 Nov 2026 20:20:37 +0300 Mark Bulatov <[email protected]> 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.

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.

Fix this by swapping the arguments.

Quoted 7 lines

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

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

---

AI complains about the commit message.

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

Warning: the first paragraph of the commit message is wrong and contradicts the second.
It says nfp_encode_basic_qdr() takes cpp_tgt second and dest_island third. The prototype is (addr, dest_island, cpp_tgt, ...), as the second paragraph correctly says. This looks like v1 text that was left in. Drop the first paragraph:

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.

Fix this by swapping the arguments.

The fix matches the Linux nfp driver, where all four callers in nfpcore/nfp_target.c already pass (*addr, dest_island, cpp_tgt, ...). Saying so in the commit message would help the NFP maintainers confirm it.

#2 lore raw

PATCH v3 1/1 net/nfp: fix wrong argument order in nfp_encode_basic

In reply to Mark Bulatov

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.

Fix this by swapping the arguments.

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

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

---
v3 changes: Correction description

v2 link:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/
v2 changes: Correction of the 'Fixes' tag and description

v1 link:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

 drivers/net/nfp/nfpcore/nfp_target.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/nfp/nfpcore/nfp_target.c +4 -4
index 0e7a5cbb05..239ffff869 100644
@@ -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);
 		}
 
Signature · 1 line
2.39.5