Skip to contentSkip to conversation

net: stmmac: selftests: Add missing endianness conversions

PATCH Applied Maxime Chevallier 4 participants 4 messages Nov 3 – Nov 6

Subsystems (4)
lore
Share & tools
lore

Maxime Chevallier

author maintainer
#0 lore raw

PATCH 1/1 net: stmmac: selftests: Add missing endianness conversions

The kbuild bot found some endianness issues in the stmmac ethtool selftests [1] let's address these.

In practice these missing conversions didn't cause any issue, as the masks / values on which the conversions were missing were either always 0 or ~0, so skipping the byte swaps lead to the same value being passed anyway.

[1]: https://lore.kernel.org/oe-kbuild-all/[email protected]/

---
This isn't worth sending to net, I've dropped the Fixes / Reported-by / Closes tags, let me know if I should add'em back.

There are more of these endianness warnings in other places, but they require a bit more attention. This'll be addressed at a later point, I don't think we have many big-endian stmmac setups anyways.

 drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +5 -5
index 40811df8f2b7..df696e2c1528 100644
@@ -1216,7 +1216,7 @@ static int stmmac_test_rxp(struct stmmac_priv *priv)
 	sel->offshift = 0;
 	sel->keys[0].off = 6;
 	sel->keys[0].val = htonl(0xdeadbeef);
-	sel->keys[0].mask = ~0x0;
+	sel->keys[0].mask = htonl(~0x0);
 
 	ret = stmmac_tc_setup_cls_u32(priv, priv, &cls_u32);
 	if (ret)
@@ -1463,8 +1463,8 @@ static int __stmmac_test_l3filt(struct stmmac_priv *priv, u32 dst, u32 src,
 
 	key.src = htonl(src);
 	key.dst = htonl(dst);
-	mask.src = src_mask;
-	mask.dst = dst_mask;
+	mask.src = htonl(src_mask);
+	mask.dst = htonl(dst_mask);
 
 	cls->rule = rule;
 
@@ -1594,8 +1594,8 @@ static int __stmmac_test_l4filt(struct stmmac_priv *priv, u32 dst, u32 src,
 	keys.key.dst = htons(dst);
 	/* Match the full IP proto field */
 	masks.bmask.ip_proto = 0xff;
-	masks.mask.src = src_mask;
-	masks.mask.dst = dst_mask;
+	masks.mask.src = htons(src_mask);
+	masks.mask.dst = htons(dst_mask);
 
 	cls->rule = rule;
 
Signature · 1 line
2.56.0
Reviewed-by on v1 1/1
#1 lore raw

Hi Maxime

Quoted 8 lines · Maxime Chevallier

The kbuild bot found some endianness issues in the stmmac ethtool selftests [1] let's address these.

In practice these missing conversions didn't cause any issue, as the masks / values on which the conversions were missing were either always 0 or ~0, so skipping the byte swaps lead to the same value being passed anyway.

Quoted 6 lines

[1]: https://lore.kernel.org/oe-kbuild-all/[email protected]/

---

[...]

Thanks,
Nicolai

Reviewed-by on v1 1/1
#2 lore raw
In reply to Maxime Chevallier
Quoted 11 lines

The kbuild bot found some endianness issues in the stmmac ethtool selftests [1] let's address these.

In practice these missing conversions didn't cause any issue, as the masks / values on which the conversions were missing were either always 0 or ~0, so skipping the byte swaps lead to the same value being passed anyway.

[1]: https://lore.kernel.org/oe-kbuild-all/[email protected]/

Quoted 50 lines

---
This isn't worth sending to net, I've dropped the Fixes / Reported-by / Closes tags, let me know if I should add'em back.

There are more of these endianness warnings in other places, but they require a bit more attention. This'll be addressed at a later point, I don't think we have many big-endian stmmac setups anyways.

 drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +5 -5
index 40811df8f2b7..df696e2c1528 100644
@@ -1216,7 +1216,7 @@ static int stmmac_test_rxp(struct stmmac_priv *priv)
 	sel->offshift = 0;
 	sel->keys[0].off = 6;
 	sel->keys[0].val = htonl(0xdeadbeef);
-	sel->keys[0].mask = ~0x0;
+	sel->keys[0].mask = htonl(~0x0);
 
 	ret = stmmac_tc_setup_cls_u32(priv, priv, &cls_u32);
 	if (ret)
@@ -1463,8 +1463,8 @@ static int __stmmac_test_l3filt(struct stmmac_priv *priv, u32 dst, u32 src,
 
 	key.src = htonl(src);
 	key.dst = htonl(dst);
-	mask.src = src_mask;
-	mask.dst = dst_mask;
+	mask.src = htonl(src_mask);
+	mask.dst = htonl(dst_mask);
 
 	cls->rule = rule;
 
@@ -1594,8 +1594,8 @@ static int __stmmac_test_l4filt(struct stmmac_priv *priv, u32 dst, u32 src,
 	keys.key.dst = htons(dst);
 	/* Match the full IP proto field */
 	masks.bmask.ip_proto = 0xff;
-	masks.mask.src = src_mask;
-	masks.mask.dst = dst_mask;
+	masks.mask.src = htons(src_mask);
+	masks.mask.dst = htons(dst_mask);
 
 	cls->rule = rule;
 
Signature · 1 line
2.56.0
#3 lore raw
In reply to Maxime Chevallier
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Quoted 9 lines · On Tue, 3 Nov 2026 13:22:48 +0100 you wrote:

The kbuild bot found some endianness issues in the stmmac ethtool selftests [1] let's address these.

In practice these missing conversions didn't cause any issue, as the masks / values on which the conversions were missing were either always 0 or ~0, so skipping the byte swaps lead to the same value being passed anyway.

[...]

Here is the summary with links:
- [net-next] net: stmmac: selftests: Add missing endianness conversions

    https://git.kernel.org/netdev/net-next/c/bb67589c8724

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html