Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp808480rwb; Wed, 9 Nov 2022 08:52:37 -0800 (PST) X-Google-Smtp-Source: AMsMyM60BR/iaikeEPUfA5+134peSb6NuJ73V98ei4eA96HJCLgUk3aLKZQzsRWpt7+FhsUDgS8F X-Received: by 2002:a05:6402:50d3:b0:461:ba8a:8779 with SMTP id h19-20020a05640250d300b00461ba8a8779mr61008546edb.411.1668012757455; Wed, 09 Nov 2022 08:52:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668012757; cv=none; d=google.com; s=arc-20160816; b=PchB51zQeUUhwUKDIrFVG7tDMbb1whv5phCTkby7Dq4ruxmQVpqVlz3q+H8hzYecD6 OxJKL7BOBgcwbDqLXvIpaHTTnSD/sJU+G55Q6LiFGM8EmrmYslKGmVpp+1Cf6LzHvBnr aiXMW3XnqL2g40WOgdHcaw8ayfAg5KYRfQhRuFWNtkUvVfyfRqYeBP7SK4rautrDGPFa W403hW44A2HqpIIHJW3n+ETGzcH/UOiH7yilE4yQRFx6RFweXEu++F0jf6tlA4yulslZ YnDJWzbGp2FAPLsmrNVC+Ic+Xp4aG8vEfPAi+FroxyKPpuBE0UOZkZgGl4ev0vFr4t5I 6prw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WpWzU38sZahtcrw07Mp5eEqyTgQmSc3A1QzCHmwEN28=; b=ZhqbP79N6lICtVg0hw3kFiT6X0JgV44kbEgdU9sVhgqkgokCJP8qfj47yImpjDK1PK YlMzPRAub4qGruraK7+PDt7mIE/JWoV6F0F50/19LDtc9hVTOcTyra5zdfIHrkPjTXLi jACZZw3BSnRTsrBXiaz2rosYIip1f9Ch07DPlvdCktunZfCqGtNXfI8ybv12bMlevvZc LbR4EfUJ5mY5XIFrCjE+aXdn1VNoEH25bJjuJQ6jvTYyI0YqL+lQtwqFeR7scALdpjd3 7rYAIsvw6eX92VxUteOZ9+b8pkNi1RQN1SSt5+NCwW/Ap0Am5bBrEU+2d/n6Bzoo2g9A AyCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=ipGOmIs6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qf24-20020a1709077f1800b00787d0dfe70csi15787481ejc.981.2022.11.09.08.52.14; Wed, 09 Nov 2022 08:52:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=ipGOmIs6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231136AbiKIQew (ORCPT + 93 others); Wed, 9 Nov 2022 11:34:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230359AbiKIQeu (ORCPT ); Wed, 9 Nov 2022 11:34:50 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C8DC1A214; Wed, 9 Nov 2022 08:34:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=WpWzU38sZahtcrw07Mp5eEqyTgQmSc3A1QzCHmwEN28=; b=ipGOmIs6PBntXhEE2KDZqLvtTS 0jmp3nC0C1dm/cVH7uQotqyB4IQQvFf3tjjqzbzGmQFweWQ0nj53iQSRq85pafup2hibW60Mnk3VK ujiZjtHU+BuSFNgB5LiRYv5kswNfFV8HbVERdLwBz7fu6BMfJzCw52hRg9xlCKUg+mxk=; Received: from p200300daa72ee100054f3c61b16ef6e7.dip0.t-ipconnect.de ([2003:da:a72e:e100:54f:3c61:b16e:f6e7] helo=localhost.localdomain) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1oso28-000l4N-QM; Wed, 09 Nov 2022 17:34:37 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean Cc: linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 08/12] net: dsa: add support for DSA rx offloading via metadata dst Date: Wed, 9 Nov 2022 17:34:22 +0100 Message-Id: <20221109163426.76164-9-nbd@nbd.name> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221109163426.76164-1-nbd@nbd.name> References: <20221109163426.76164-1-nbd@nbd.name> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- net/core/flow_dissector.c | 4 +++- net/dsa/dsa.c | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 25cd35f5922e..1f476abc25e1 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -972,11 +972,13 @@ bool __skb_flow_dissect(const struct net *net, if (unlikely(skb->dev && netdev_uses_dsa(skb->dev) && proto == htons(ETH_P_XDSA))) { const struct dsa_device_ops *ops; + struct metadata_dst *md_dst = skb_metadata_dst(skb); 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 diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 64b14f655b23..a20440e82dec 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c @@ -11,6 +11,7 @@ #include #include #include +#include #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,21 @@ 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; + + dsa_default_offload_fwd_mark(skb); + skb_dst_set(skb, NULL); + if (!skb_has_extensions(skb)) + skb->slow_gro = 0; + + skb->dev = dsa_master_find_slave(dev, 0, port); + if (skb->dev) + nskb = skb; + } else { + nskb = cpu_dp->rcv(skb, dev); + } + if (!nskb) { kfree_skb(skb); return 0; -- 2.38.1