Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1255296rwb; Thu, 10 Nov 2022 13:30:11 -0800 (PST) X-Google-Smtp-Source: AMsMyM4BYWRsFXpjrFVY67Md/H7++z7AVmGYfZKVshWMfL9wEpkDn/lym65lYoHxTerawkpmaFNc X-Received: by 2002:aa7:db07:0:b0:461:ac48:a5ec with SMTP id t7-20020aa7db07000000b00461ac48a5ecmr3545670eds.193.1668115810895; Thu, 10 Nov 2022 13:30:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668115810; cv=none; d=google.com; s=arc-20160816; b=X6YJAWphlu9uMtlOxAE5/+Mj7qwGe0qXFrJdIkIJNCZvnerdLy+Sns0B0ks7Q/cfEB YS6eJqnJM3YyiPDR7HhkI90ErKCFzQjQ4xbr6YZ84xcwWnfVhyA41uVq5DEKys7VRM+Z XBLtpkBoyHWsV0gX6aJZ10UHg5iGN1ARjb9xRYqO9SF6KySRanfQbF4jp1B59np2IfT6 KtDpNuJI87VTFGcLgH5didakcrPgv0aGFDDCv8C1eIwy9K5IQjpxcaVwfX0qlGa9lPgs 2Q66/oXQKUvpPHoHwXykPgjI9L5N8AvRXehEgAYUjSoRi8BqvllpfeMiCeHRvI4AByMs ar9A== 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=7YOqTAIpTyPR6mQCHgQBNU1g+1Wa2tNkkOYC8pLG3QQ=; b=vpYdfvyxsJ6Oafqueb2pFgzq0RBzyBP9ZWIzht2d5VStvtMW68OCZSD8MmgpMFiu+v /lgfR6PDSepxiH6qxYOOw0lqqX/gGZhPXNiDsaHqN80DCDXgILp9hwPP+ZD2ntY4W/It aS55YOtW8yD5WPHNTo0aJotFNjFvGsVXROU1Ce16V4+J/Zi3xpwIN2lOdmLMkPE37w3n O5N7e2DfZO6l+JRUaJlaGKlI5Zd2Z12STVDEpbUXv3Izdqcf5vjirAD9pDx0dwy8shcq C92lVIMNRztaXxfjhlfREoEzfGSBeDZURRZZQQwidal3d0qUeIQh+GJPED87H0VA+YE1 FhCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=qd7tgTon; 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 cr18-20020a170906d55200b007adc8c49d83si338903ejc.477.2022.11.10.13.29.47; Thu, 10 Nov 2022 13:30:10 -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=qd7tgTon; 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 S232231AbiKJVWm (ORCPT + 92 others); Thu, 10 Nov 2022 16:22:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231616AbiKJVW1 (ORCPT ); Thu, 10 Nov 2022 16:22:27 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C17331DFD; Thu, 10 Nov 2022 13:22:26 -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=7YOqTAIpTyPR6mQCHgQBNU1g+1Wa2tNkkOYC8pLG3QQ=; b=qd7tgTonse0varUI6g3+Doev/W LPC7NVpe2PjeGWqkpFK8Ww8IA3E+Z7C4YCbql0i6iGv/qwdsH39sz3gL600IvbA1lyoMSM3H+moxD zJZF66RkUEVUNc+r4VlWcErZGp1BNr8IV505BNT2RmQ0l/fTs9E5RK/BNnmqT+rOG4Q0=; Received: from p200300daa72ee10c199752172ce6dd7a.dip0.t-ipconnect.de ([2003:da:a72e:e10c:1997:5217:2ce6:dd7a] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1otF03-0011Om-SI; Thu, 10 Nov 2022 22:22:15 +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 v3 1/4] net: dsa: add support for DSA rx offloading via metadata dst Date: Thu, 10 Nov 2022 22:22:08 +0100 Message-Id: <20221110212212.96825-2-nbd@nbd.name> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221110212212.96825-1-nbd@nbd.name> References: <20221110212212.96825-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 | 19 ++++++++++++++++++- 2 files changed, 21 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..0b67622cf905 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_set(skb, NULL); + 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; -- 2.38.1