1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Tue, 8 Nov 2022 15:03:15 +0100
3 Subject: [PATCH] net: dsa: add support for DSA rx offloading via
6 If a metadata dst is present with the type METADATA_HW_PORT_MUX on a dsa cpu
7 port netdev, assume that it carries the port number and that there is no DSA
8 tag present in the skb data.
10 Signed-off-by: Felix Fietkau <nbd@nbd.name>
13 --- a/net/core/flow_dissector.c
14 +++ b/net/core/flow_dissector.c
15 @@ -940,12 +940,14 @@ bool __skb_flow_dissect(const struct net
16 #if IS_ENABLED(CONFIG_NET_DSA)
17 if (unlikely(skb->dev && netdev_uses_dsa(skb->dev) &&
18 proto == htons(ETH_P_XDSA))) {
19 + struct metadata_dst *md_dst = skb_metadata_dst(skb);
20 const struct dsa_device_ops *ops;
23 ops = skb->dev->dsa_ptr->tag_ops;
24 /* Only DSA header taggers break flow dissection */
25 - if (ops->needed_headroom) {
26 + if (ops->needed_headroom &&
27 + (!md_dst || md_dst->type != METADATA_HW_PORT_MUX)) {
28 if (ops->flow_dissect)
29 ops->flow_dissect(skb, &proto, &offset);
34 #include <linux/netdevice.h>
35 #include <linux/sysfs.h>
36 #include <linux/ptp_classify.h>
37 +#include <net/dst_metadata.h>
41 @@ -225,6 +226,7 @@ static bool dsa_skb_defer_rx_timestamp(s
42 static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev,
43 struct packet_type *pt, struct net_device *unused)
45 + struct metadata_dst *md_dst = skb_metadata_dst(skb);
46 struct dsa_port *cpu_dp = dev->dsa_ptr;
47 struct sk_buff *nskb = NULL;
48 struct dsa_slave_priv *p;
49 @@ -238,7 +240,22 @@ static int dsa_switch_rcv(struct sk_buff
53 - nskb = cpu_dp->rcv(skb, dev);
54 + if (md_dst && md_dst->type == METADATA_HW_PORT_MUX) {
55 + unsigned int port = md_dst->u.port_info.port_id;
58 + if (!skb_has_extensions(skb))
61 + skb->dev = dsa_master_find_slave(dev, 0, port);
62 + if (likely(skb->dev)) {
63 + dsa_default_offload_fwd_mark(skb);
67 + nskb = cpu_dp->rcv(skb, dev);