From patchwork Mon Nov 14 12:42:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 19795 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2121623wru; Mon, 14 Nov 2022 04:45:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf6yQDqdE9cdWzyB1r0RAWM3t0S0GDz3KpsfKkMxvTRcCQS6iKH+V3e/ZCHtMmMVsW9Rc/Kb X-Received: by 2002:a17:906:a86:b0:78a:d0a4:176 with SMTP id y6-20020a1709060a8600b0078ad0a40176mr10231053ejf.720.1668429957135; Mon, 14 Nov 2022 04:45:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668429957; cv=none; d=google.com; s=arc-20160816; b=MqlXA80tW+6vM+E00BCYA9iuSiVoPX34Z6ffhIDmoWgGL7y4aKPEUOCxb6iaHjDFBp wTwrzUkk/YRQG3q/IqoSsHPKn+C/nTHiCWf6boNtPyT+qB5/bI6aY+jezQWwIYH7qnAo +FHq0BfD1Vv3698PP1JSHvf7lWBCW8AfMBC4ydTcQrQltJJw1pZhhMXUB29P3B8qWwF8 CDRPO1/okBpzujia4NCFb9kQSO4ipFE8+aopUMC/vvIkeFN78fg7lZTtdWDiInlrz1E2 TDE1tPUu2gbXcUWcH8p/789KUz2bwXQH3ohwH+fiL8ayyHPet4bXgQsXaEw/ucKMUThZ x8Vg== 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=9y7P2AOYEluuMvwNtI2JOIUn32WWK6gjZOLBZl08Qkc=; b=y03WuaT2ork5OSAYiswqOF7FqPjh5YMyL6Weth1Y7/RLQlKbkrqbn91eDTMvJepgk3 QUPzm5893UaZww6KlTYOgVmNg8caeCgCHU0Zr3MRqwzPqCTXj7hGiv2WLHeBUqkUPfOn Emg6lss3CxvJeiqJ5yTdhEXPwEj7nNc+YwMLebNHybJs2uFYIno+++Mj56GP5wF9ZVR3 Hfm2jydVe0TWqdjaTAlRh4jFdbu3lqQso2p/mISkyIqa6G1xvmj8uIVNndLxLbx/Qw94 UDMxTbFaZrfszs0rQDuHFiAV1/VhwkfdpGXc54oikvbHieMz5wtYW7jlV3c/SWxEdcSx EmDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=Rsxs0CSL; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga7-20020a1709070c0700b0078a19032c70si10195084ejc.334.2022.11.14.04.45.32; Mon, 14 Nov 2022 04:45:57 -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=Rsxs0CSL; 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 S237443AbiKNMne (ORCPT + 99 others); Mon, 14 Nov 2022 07:43:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237269AbiKNMnA (ORCPT ); Mon, 14 Nov 2022 07:43:00 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F41CA25EB2; Mon, 14 Nov 2022 04:42:30 -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=9y7P2AOYEluuMvwNtI2JOIUn32WWK6gjZOLBZl08Qkc=; b=Rsxs0CSLozVk4T+Vh6ToJXMrqc a/Szhu4OowHDqFGX+GA9yfyX55AGqmiflGsEPVhlHYOS/mxG01nN/GLArXNfjbGEdwdzYIjeAhUXK LFiCSF7jwaP2ljFYPmx15HbCeFUEBujiKLVRa4owzAtjI89g3y1bOYRqWLPinjhucmWI=; Received: from p54ae9c3f.dip0.t-ipconnect.de ([84.174.156.63] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1ouYn7-0021wc-IT; Mon, 14 Nov 2022 13:42:21 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Florian Fainelli , Vladimir Oltean Cc: linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 1/4] net: dsa: add support for DSA rx offloading via metadata dst Date: Mon, 14 Nov 2022 13:42:11 +0100 Message-Id: <20221114124214.58199-2-nbd@nbd.name> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221114124214.58199-1-nbd@nbd.name> References: <20221114124214.58199-1-nbd@nbd.name> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749475611181180068?= X-GMAIL-MSGID: =?utf-8?q?1749475611181180068?= 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 Reviewed-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- net/core/flow_dissector.c | 4 +++- net/dsa/dsa.c | 19 ++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 25cd35f5922e..3e81798ed3e0 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -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 diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 64b14f655b23..6caf2ec648fd 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,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;