Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3513558rwb; Tue, 8 Nov 2022 05:32:09 -0800 (PST) X-Google-Smtp-Source: AMsMyM6nWOjPky/7U0Wk3ni7XAEDrfhUMOfGjw2FLoJ19noSlMEMyIqS4YcYPA8KG/qKGrpRWoiE X-Received: by 2002:a05:6402:616:b0:463:e2cd:a88d with SMTP id n22-20020a056402061600b00463e2cda88dmr35283675edv.400.1667914329709; Tue, 08 Nov 2022 05:32:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667914329; cv=none; d=google.com; s=arc-20160816; b=KSx79T80LrKeW0Y8uo0B1BAhcJvf2BvVtjA1OfZ9E3Ekq05IYoaC2y2G9LH3uvpob/ m6J5LMCC+CKrKYF3U26FXkVEeMIyZUA2aBqX6BaRmean0s1Zz6blwPZ7p/Nmb9Rx8fMi m8lbgF7KqXSWwXPefoVEwcYMW+1vIXvFPYpaDa7RyAQHGA4n07mT3fFheYFwZQEMVgeu w+uFvDkm4oIxjESPQjILM0fk2mPALhSEF0ODT7ttsPpKEHO8kVd6Xa13gjk+7hnT0AUO th3jeb7xVUTUcN2J1ybYBwswlGUOLKhXPdmPyGuv3vFTPF/GSz1B5Oww/+1KoXw1Zl8B 0aWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:dkim-signature; bh=fgQwEkH8uRLIyzAJvAaLR6EdvjROWR71Np+0VG6O3UU=; b=L5BRAjRpnn5YiurXWKNYkLz+v9OhcoyxvEHKjIZgHj4l8VqBV5hSKn3HfYLLrH97hy FfK5WRJMiYJZ53+2KmrLuU3+lV7IKEmI5WR3BX1WweAHYSpzC6BCyQyDRA2TvfYWt95Z lbxuNqYxOIJeedE1AnsU1kFQxT6/QFodMarub9Xjt1HYTZfgiDJBmAUk9lHi8V7PwosY 8vdkiGZQsC9OuOFIFbud4lw7E6mA81TF+wLHtTw3x0P0J/9jsyqJp6VRc5Z9r+ND+S6G 0AkEJmIN+QZZjlflmmxDqlOGh+yw/zzWxp0XMk9PgKWPdeQXtapwg460r3q06sd0+g6f YiqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=nitwdRgJ; 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 di19-20020a170906731300b007ada030c2e9si14916513ejc.944.2022.11.08.05.31.47; Tue, 08 Nov 2022 05:32:09 -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=nitwdRgJ; 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 S233925AbiKHMjY (ORCPT + 89 others); Tue, 8 Nov 2022 07:39:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233613AbiKHMjW (ORCPT ); Tue, 8 Nov 2022 07:39:22 -0500 X-Greylist: delayed 1013 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 08 Nov 2022 04:39:21 PST Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0671BDF0D; Tue, 8 Nov 2022 04:39:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:Subject:From :References:Cc:To:MIME-Version:Date:Message-ID:Sender:Reply-To: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=fgQwEkH8uRLIyzAJvAaLR6EdvjROWR71Np+0VG6O3UU=; b=nitwdRgJEnOLhDL6edIbrobgDb JT1qJTkHeOn2LIW+8O7bbLc0R4C827LiB7LNjnFFaqhkG25Ag252h700DcaYB87k4zAUV0UUeZhxV 87CpusS+NrxvVOQNIOjRMe0QYVpHoWEgHjm1dbbAod4TT1UiIZ+YY/8pY9kyQkl0+5Nk=; Received: from p200300daa72ee1006d973cebf3767a25.dip0.t-ipconnect.de ([2003:da:a72e:e100:6d97:3ceb:f376:7a25] helo=nf.local) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1osNcQ-000VU5-Uc; Tue, 08 Nov 2022 13:22:19 +0100 Message-ID: <6b38ec27-65a3-c973-c5e1-a25bbe4f6104@nbd.name> Date: Tue, 8 Nov 2022 13:22:17 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.3.2 Content-Language: en-US To: Maxime Chevallier , Jakub Kicinski Cc: davem@davemloft.net, Rob Herring , Krzysztof Kozlowski , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Florian Fainelli , Heiner Kallweit , Russell King , linux-arm-kernel@lists.infradead.org, Vladimir Oltean , Luka Perkov , Robert Marko , Andy Gross , Bjorn Andersson , Konrad Dybcio References: <20221104174151.439008-1-maxime.chevallier@bootlin.com> <20221104174151.439008-4-maxime.chevallier@bootlin.com> <20221104200530.3bbe18c6@kernel.org> <20221107093950.74de3fa1@pc-8.home> From: Felix Fietkau Subject: Re: [PATCH net-next v8 3/5] net: dsa: add out-of-band tagging protocol In-Reply-To: <20221107093950.74de3fa1@pc-8.home> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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 On 07.11.22 09:39, Maxime Chevallier wrote: >> On Fri, 4 Nov 2022 18:41:49 +0100 Maxime Chevallier wrote: >> > This tagging protocol is designed for the situation where the link >> > between the MAC and the Switch is designed such that the Destination >> > Port, which is usually embedded in some part of the Ethernet >> > Header, is sent out-of-band, and isn't present at all in the >> > Ethernet frame. >> > >> > This can happen when the MAC and Switch are tightly integrated on an >> > SoC, as is the case with the Qualcomm IPQ4019 for example, where >> > the DSA tag is inserted directly into the DMA descriptors. In that >> > case, the MAC driver is responsible for sending the tag to the >> > switch using the out-of-band medium. To do so, the MAC driver needs >> > to have the information of the destination port for that skb. >> > >> > Add a new tagging protocol based on SKB extensions to convey the >> > information about the destination port to the MAC driver >> >> This is what METADATA_HW_PORT_MUX is for, you shouldn't have >> to allocate a piece of memory for every single packet. > > Does this work with DSA ? The information conveyed in the extension is > the DSA port identifier. I'm not familiar at all with > METADATA_HW_PORT_MUX, should we extend that mechanism to convey the > DSA port id ? > > I also agree that allocating data isn't the best way to go, but from > the history of this series, we've tried 3 approaches so far : > > - Adding a new field to struct sk_buff, which isn't a good idea > - Using the skb headroom, but then we can't know for sure is the skb > contains a DSA tag or not > - Using skb extensions, that comes with the cost of this memory > allocation. Is this approach also incorrect then ? FYI, I'm currently working on hardware DSA untagging on the mediatek mtk_eth_soc driver. On this hardware, I definitely need to keep the custom DSA tag driver, as hardware untagging is not always available. For the receive side, I came up with this patch (still untested) for using METADATA_HW_PORT_MUX. It has the advantage of being able to skip the tag protocol rcv ops call for offload-enabled packets. Maybe for the transmit side we could have some kind of netdev feature or capability that indicates offload support and allows skipping the tag xmit function as well. In that case, ipqess could simply use a no-op tag driver. What do you think? --- --- 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) && skb->protocol == 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 --- 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;