Skip to content

Commit ea659a9

Browse files
vladimirolteankuba-moo
authored andcommitted
net: dsa: tag_ksz: use the dsa_xmit_port_mask() helper
The "ksz8795", "ksz9893", "ksz9477" and "lan937x" tagging protocols populate a bit mask for the TX ports. Unlike the others, "ksz9477" also accelerates HSR packet duplication. Make the HSR duplication logic available generically to all 4 taggers by using the dsa_xmit_port_mask() function to set the TX port mask. Cc: Woojung Huh <woojung.huh@microchip.com> Cc: UNGLinuxDriver@microchip.com Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Link: https://patch.msgid.link/20251127120902.292555-6-vladimir.oltean@nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent f59e44c commit ea659a9

1 file changed

Lines changed: 4 additions & 16 deletions

File tree

net/dsa/tag_ksz.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ static struct sk_buff *ksz_common_rcv(struct sk_buff *skb,
120120

121121
static struct sk_buff *ksz8795_xmit(struct sk_buff *skb, struct net_device *dev)
122122
{
123-
struct dsa_port *dp = dsa_user_to_port(dev);
124123
struct ethhdr *hdr;
125124
u8 *tag;
126125

@@ -131,7 +130,7 @@ static struct sk_buff *ksz8795_xmit(struct sk_buff *skb, struct net_device *dev)
131130
tag = skb_put(skb, KSZ_INGRESS_TAG_LEN);
132131
hdr = skb_eth_hdr(skb);
133132

134-
*tag = 1 << dp->index;
133+
*tag = dsa_xmit_port_mask(skb, dev);
135134
if (is_link_local_ether_addr(hdr->h_dest))
136135
*tag |= KSZ8795_TAIL_TAG_OVERRIDE;
137136

@@ -294,21 +293,12 @@ static struct sk_buff *ksz9477_xmit(struct sk_buff *skb,
294293
tag = skb_put(skb, KSZ9477_INGRESS_TAG_LEN);
295294
hdr = skb_eth_hdr(skb);
296295

297-
val = BIT(dp->index);
298-
296+
val = dsa_xmit_port_mask(skb, dev);
299297
val |= FIELD_PREP(KSZ9477_TAIL_TAG_PRIO, prio);
300298

301299
if (is_link_local_ether_addr(hdr->h_dest))
302300
val |= KSZ9477_TAIL_TAG_OVERRIDE;
303301

304-
if (dev->features & NETIF_F_HW_HSR_DUP) {
305-
struct net_device *hsr_dev = dp->hsr_dev;
306-
struct dsa_port *other_dp;
307-
308-
dsa_hsr_foreach_port(other_dp, dp->ds, hsr_dev)
309-
val |= BIT(other_dp->index);
310-
}
311-
312302
*tag = cpu_to_be16(val);
313303

314304
return ksz_defer_xmit(dp, skb);
@@ -371,8 +361,7 @@ static struct sk_buff *ksz9893_xmit(struct sk_buff *skb,
371361
tag = skb_put(skb, KSZ_INGRESS_TAG_LEN);
372362
hdr = skb_eth_hdr(skb);
373363

374-
*tag = BIT(dp->index);
375-
364+
*tag = dsa_xmit_port_mask(skb, dev);
376365
*tag |= FIELD_PREP(KSZ9893_TAIL_TAG_PRIO, prio);
377366

378367
if (is_link_local_ether_addr(hdr->h_dest))
@@ -436,8 +425,7 @@ static struct sk_buff *lan937x_xmit(struct sk_buff *skb,
436425

437426
tag = skb_put(skb, LAN937X_EGRESS_TAG_LEN);
438427

439-
val = BIT(dp->index);
440-
428+
val = dsa_xmit_port_mask(skb, dev);
441429
val |= FIELD_PREP(LAN937X_TAIL_TAG_PRIO, prio);
442430

443431
if (is_link_local_ether_addr(hdr->h_dest))

0 commit comments

Comments
 (0)