[net-next,v4,1/4] net: dsa: add support for DSA rx offloading via metadata dst
Commit Message
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>
---
net/core/flow_dissector.c | 4 +++-
net/dsa/dsa.c | 19 ++++++++++++++++++-
2 files changed, 21 insertions(+), 2 deletions(-)
Comments
On Mon, Nov 14, 2022 at 01:42:11PM +0100, Felix Fietkau wrote:
> 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>
On 11/14/22 04:42, Felix Fietkau wrote:
> 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: Florian Fainelli <f.fainelli@gmail.com>
Is the plan to use the lwoer bits of the 32-bit port_id as the port
number for now, and we can use the remaining 24 or so bits for passing
classification (reason why we forward the packet, QoS etc. ) information
in the future?
Might be time for me to revive the systemport patches supporting
Broadcom tags in the the DMA descriptor.
Thanks!
On Mon, Nov 14, 2022 at 09:59:09AM -0800, Florian Fainelli wrote:
> On 11/14/22 04:42, Felix Fietkau wrote:
> > 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: Florian Fainelli <f.fainelli@gmail.com>
>
> Is the plan to use the lwoer bits of the 32-bit port_id as the port number
> for now, and we can use the remaining 24 or so bits for passing
> classification (reason why we forward the packet, QoS etc. ) information in
> the future?
>
> Might be time for me to revive the systemport patches supporting Broadcom
> tags in the the DMA descriptor.
It's not really clear how to expand the HW_PORT_MUX model to provide QoS
info and trap reason, without switching to per-packet allocation, which
is what Jakub seemingly wanted to avoid with skb extensions (among other
more minor things).
https://patchwork.kernel.org/project/netdevbpf/patch/20221104174151.439008-4-maxime.chevallier@bootlin.com/#25078661
Felix didn't present a need for more than the port id either, so this is
why we have what we have right now.
@@ -971,12 +971,14 @@ bool __skb_flow_dissect(const struct net *net,
#if IS_ENABLED(CONFIG_NET_DSA)
if (unlikely(skb->dev && netdev_uses_dsa(skb->dev) &&
proto == htons(ETH_P_XDSA))) {
+ struct metadata_dst *md_dst = skb_metadata_dst(skb);
const struct dsa_device_ops *ops;
int offset = 0;
ops = skb->dev->dsa_ptr->tag_ops;
/* Only DSA header taggers break flow dissection */
- if (ops->needed_headroom) {
+ if (ops->needed_headroom &&
+ (!md_dst || md_dst->type != METADATA_HW_PORT_MUX)) {
if (ops->flow_dissect)
ops->flow_dissect(skb, &proto, &offset);
else
@@ -11,6 +11,7 @@
#include <linux/netdevice.h>
#include <linux/sysfs.h>
#include <linux/ptp_classify.h>
+#include <net/dst_metadata.h>
#include "dsa_priv.h"
@@ -216,6 +217,7 @@ static bool dsa_skb_defer_rx_timestamp(struct dsa_slave_priv *p,
static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt, struct net_device *unused)
{
+ struct metadata_dst *md_dst = skb_metadata_dst(skb);
struct dsa_port *cpu_dp = dev->dsa_ptr;
struct sk_buff *nskb = NULL;
struct dsa_slave_priv *p;
@@ -229,7 +231,22 @@ static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev,
if (!skb)
return 0;
- nskb = cpu_dp->rcv(skb, dev);
+ if (md_dst && md_dst->type == METADATA_HW_PORT_MUX) {
+ unsigned int port = md_dst->u.port_info.port_id;
+
+ skb_dst_drop(skb);
+ if (!skb_has_extensions(skb))
+ skb->slow_gro = 0;
+
+ skb->dev = dsa_master_find_slave(dev, 0, port);
+ if (likely(skb->dev)) {
+ dsa_default_offload_fwd_mark(skb);
+ nskb = skb;
+ }
+ } else {
+ nskb = cpu_dp->rcv(skb, dev);
+ }
+
if (!nskb) {
kfree_skb(skb);
return 0;