Skip to content

Commit 570d0a5

Browse files
nbd168kuba-moo
authored andcommitted
net: dsa: add support for DSA rx offloading via metadata dst
If a metadata dst is present with the type METADATA_HW_PORT_MUX on a dsa cpu port netdev, assume that it carries the port number and that there is no DSA tag present in the skb data. Signed-off-by: Felix Fietkau <nbd@nbd.name> Reviewed-by: Vladimir Oltean <olteanv@gmail.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 7eba450 commit 570d0a5

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

net/core/flow_dissector.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,12 +971,14 @@ bool __skb_flow_dissect(const struct net *net,
971971
#if IS_ENABLED(CONFIG_NET_DSA)
972972
if (unlikely(skb->dev && netdev_uses_dsa(skb->dev) &&
973973
proto == htons(ETH_P_XDSA))) {
974+
struct metadata_dst *md_dst = skb_metadata_dst(skb);
974975
const struct dsa_device_ops *ops;
975976
int offset = 0;
976977

977978
ops = skb->dev->dsa_ptr->tag_ops;
978979
/* Only DSA header taggers break flow dissection */
979-
if (ops->needed_headroom) {
980+
if (ops->needed_headroom &&
981+
(!md_dst || md_dst->type != METADATA_HW_PORT_MUX)) {
980982
if (ops->flow_dissect)
981983
ops->flow_dissect(skb, &proto, &offset);
982984
else

net/dsa/dsa.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/netdevice.h>
1212
#include <linux/sysfs.h>
1313
#include <linux/ptp_classify.h>
14+
#include <net/dst_metadata.h>
1415

1516
#include "dsa_priv.h"
1617

@@ -216,6 +217,7 @@ static bool dsa_skb_defer_rx_timestamp(struct dsa_slave_priv *p,
216217
static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev,
217218
struct packet_type *pt, struct net_device *unused)
218219
{
220+
struct metadata_dst *md_dst = skb_metadata_dst(skb);
219221
struct dsa_port *cpu_dp = dev->dsa_ptr;
220222
struct sk_buff *nskb = NULL;
221223
struct dsa_slave_priv *p;
@@ -229,7 +231,22 @@ static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev,
229231
if (!skb)
230232
return 0;
231233

232-
nskb = cpu_dp->rcv(skb, dev);
234+
if (md_dst && md_dst->type == METADATA_HW_PORT_MUX) {
235+
unsigned int port = md_dst->u.port_info.port_id;
236+
237+
skb_dst_drop(skb);
238+
if (!skb_has_extensions(skb))
239+
skb->slow_gro = 0;
240+
241+
skb->dev = dsa_master_find_slave(dev, 0, port);
242+
if (likely(skb->dev)) {
243+
dsa_default_offload_fwd_mark(skb);
244+
nskb = skb;
245+
}
246+
} else {
247+
nskb = cpu_dp->rcv(skb, dev);
248+
}
249+
233250
if (!nskb) {
234251
kfree_skb(skb);
235252
return 0;

0 commit comments

Comments
 (0)