Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: dsa: tag_ocelot: use the dsa_xmit_port_mask() helper

The "ocelot" and "seville" tagging protocols populate a bit mask for the
TX ports, so we can use dsa_xmit_port_mask() to centralize the decision
of how to set that field.

This protocol used BIT_ULL() rather than simple BIT() to silence Smatch,
as explained in commit 1f778d500df3 ("net: mscc: ocelot: avoid type
promotion when calling ocelot_ifh_set_dest"). I would expect that this
tool no longer complains now, when the BIT(dp->index) is hidden inside
the dsa_xmit_port_mask() function, the return value of which is promoted
to u64.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://patch.msgid.link/20251127120902.292555-9-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Vladimir Oltean and committed by
Jakub Kicinski
5733fe2a a4a00d9e

+2 -4
+2 -4
net/dsa/tag_ocelot.c
··· 46 46 static struct sk_buff *ocelot_xmit(struct sk_buff *skb, 47 47 struct net_device *netdev) 48 48 { 49 - struct dsa_port *dp = dsa_user_to_port(netdev); 50 49 void *injection; 51 50 52 51 ocelot_xmit_common(skb, netdev, cpu_to_be32(0x8880000a), &injection); 53 - ocelot_ifh_set_dest(injection, BIT_ULL(dp->index)); 52 + ocelot_ifh_set_dest(injection, dsa_xmit_port_mask(skb, netdev)); 54 53 55 54 return skb; 56 55 } ··· 57 58 static struct sk_buff *seville_xmit(struct sk_buff *skb, 58 59 struct net_device *netdev) 59 60 { 60 - struct dsa_port *dp = dsa_user_to_port(netdev); 61 61 void *injection; 62 62 63 63 ocelot_xmit_common(skb, netdev, cpu_to_be32(0x88800005), &injection); 64 - seville_ifh_set_dest(injection, BIT_ULL(dp->index)); 64 + seville_ifh_set_dest(injection, dsa_xmit_port_mask(skb, netdev)); 65 65 66 66 return skb; 67 67 }