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; From patchwork Mon Nov 14 12:42:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 19796 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2121768wru; Mon, 14 Nov 2022 04:46:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf51ydkASl0/i+WyYNYqsqfSRtudY5hOROqleOZ5Mo2rcVbBGxP3HZ0g+JMq54CG2Iu0QW68 X-Received: by 2002:a17:907:98e1:b0:7ae:f441:6ade with SMTP id ke1-20020a17090798e100b007aef4416ademr4046235ejc.436.1668429969993; Mon, 14 Nov 2022 04:46:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668429969; cv=none; d=google.com; s=arc-20160816; b=E1hmG15Up0BzxW0BKhmUMZx98o9jgKnjw3HHXnurMmegwOmTBj/6NTROLeLnHGABvD BVzdmg/BJfWcO55r4B4XGtYZRrla3QNzvc7tiwZk9nW1N9fYkX9ngTViftfthcuv7F+V KGggU9g0lh/VzpgcfRmmFhf0HAKNLVOxd9lPI3g4r5Bkp7piRt/p4WfwOzQnbQKB1iXf 0LrVIlIbQA7nPJJlsebKaojRe8ALbWDZktaBZWQoDzbpFoK258KG2z7dyi/UKx+c7YWd 6cfM0KH+aCMCwVCVO8UB1B+ZJwX+2tW5Xvk3xu8BvYYLCOABCc6eFNVpaDDK57dpeMGo e0iA== 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=XKOsIjWD9UiWHhSPTpYvwZctofSL/DoRkI6SCzJGFi8=; b=lXDyaFvg50mlPb6ND8xpvv2dNTBBSxaiLJ+kVihya1xlsbnfPzbtnIdFbBAwekQM3e 2/ekhcdiFq0Lb5jj3M+2InT664VLbx91cioFROptZ5YTbNPEbjyG9y41dBh0eLW7euZX A1819Eo6bxmRYsLfE5VKLNKbnX8AGSsx2ZXglNTtAbYHNTwmP/1twYP3lHTF/1l0qCax FT/EDuFH7TSlCHKlhTevcrlSocaDr1bkraaksrYn5PzoG8xaK7A2srflS2XeeSJRmFjd Lg2NA1+y/mrHqLEybHYWxgJexLVQPu+mrSWzb6h72lVRIOjM9RN8PyoO3TcJohOVtkl1 lqyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=mpH1bONm; 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 cs15-20020a170906dc8f00b007ad2d85d753si8535067ejc.495.2022.11.14.04.45.46; Mon, 14 Nov 2022 04:46: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=mpH1bONm; 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 S237414AbiKNMnr (ORCPT + 99 others); Mon, 14 Nov 2022 07:43:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237377AbiKNMnJ (ORCPT ); Mon, 14 Nov 2022 07:43:09 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FC57252B3; Mon, 14 Nov 2022 04:42:36 -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=XKOsIjWD9UiWHhSPTpYvwZctofSL/DoRkI6SCzJGFi8=; b=mpH1bONmjSCvOi0+J+hPhjU8mC 1oswAP9yAi37PrMZNA8IxVosUeXdtgxMiZvyEb5db48xJYzlS24FUVO8xJoKMkJYuBPLajw02u9CN paP0lkBfKFQjAbPqtNyfTDwXTmoyjO1ZXjP0OwGobN6abNAkVW8u4sq9bOrF+5zqzam4=; 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 1ouYn8-0021wc-7O; Mon, 14 Nov 2022 13:42:22 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, John Crispin , Sean Wang , Mark Lee , Lorenzo Bianconi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger Cc: Vladimir Oltean , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 2/4] net: ethernet: mtk_eth_soc: pass correct VLAN protocol ID to the network stack Date: Mon, 14 Nov 2022 13:42:12 +0100 Message-Id: <20221114124214.58199-3-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?1749475624537750164?= X-GMAIL-MSGID: =?utf-8?q?1749475624537750164?= Use the id from the DMA descriptor instead of hardcoding 802.1q Signed-off-by: Felix Fietkau --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 1cf76fd7afbc..891dd6937f89 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1936,7 +1936,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, htons(RX_DMA_VPID(trxd.rxd4)), RX_DMA_VID(trxd.rxd4)); } else if (trxd.rxd2 & RX_DMA_VTAG) { - __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), + __vlan_hwaccel_put_tag(skb, htons(RX_DMA_VPID(trxd.rxd3)), RX_DMA_VID(trxd.rxd3)); } From patchwork Mon Nov 14 12:42:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 19797 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2121888wru; Mon, 14 Nov 2022 04:46:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf4i9HKJWk+gmw+TlM0d5pTY88JV/wtPTrMbIKJmGVeoQYYPJae2U4y5swhX9Jx0Xzrs3lY1 X-Received: by 2002:a05:6402:2d2:b0:459:4c7b:e852 with SMTP id b18-20020a05640202d200b004594c7be852mr11179625edx.347.1668429988310; Mon, 14 Nov 2022 04:46:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668429988; cv=none; d=google.com; s=arc-20160816; b=kogU+1q6qvsEk//Gpsx8HFwCvURUp3XDQzXpPd/kRr/ivEYi6SfHf7hH42UPV9q4WP CIUCG7fQPMRfcpToaonSU4QLV0P5w5sP2BsOZuo8wfMO3CnMny+3YrDLUlY6pnAYApto qjCHWI5tW8cMkmni+QCMSDepRo24sJUDJKWCAzmTnm12txlFvLbvHhxR771+mjAZ4owB Cdb47+QJmyKbgACIxp8m+k8N1Vi21e/Gcj1UYazCP3g6+RvbhXGH4jIaAcPuMkLVx4MS DITkLblctZPRqe9dcQnvS0v1+o/MPPfbFexTBaDnwaEH2K6FTlfSjEVM+0imvsP2vbT1 afOA== 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=H+eftt8l6Bnn209SyArb1oaE+v3tXc1RSpc0VaS+BPM=; b=0ZydJ+BI1ckxiwMC/6lEPod9f/s/qqF5Ow6Gqt33gNolJxpzK9Ruq/CK8JiRlqjyED FzNGgmaMlmQUXG401EbZ6FdW7NXPiIL7dr0sppNNkJsoTGqpoQzFA+ebbDMUKCPzKVED GIduDMj/gGGlTfQbRqSeyDeCPzs0fi5szEJ3B5vVkP/13FaMP9ulJKhZpZojyZG54+it VgJEAuHLamRNjjNuI6ZsgjIkzHwL+UwW0WdHOGikB/+FEe5Rh11obVrbCySwVWOKkqxQ cqheOAAZgstCBaGdUlolTYLA7yvxd8zXEINETNU9rLBQQiHOoD+lK0xWzhSydPMqLeib zS+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=WHepIjbX; 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 wu10-20020a170906eeca00b0078d27c1b499si9115751ejb.500.2022.11.14.04.46.04; Mon, 14 Nov 2022 04:46:28 -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=WHepIjbX; 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 S237145AbiKNMnv (ORCPT + 99 others); Mon, 14 Nov 2022 07:43:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237238AbiKNMnS (ORCPT ); Mon, 14 Nov 2022 07:43:18 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A8CB2612F; Mon, 14 Nov 2022 04:42:37 -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=H+eftt8l6Bnn209SyArb1oaE+v3tXc1RSpc0VaS+BPM=; b=WHepIjbX3dKpEn6yNU7rq6UdWL NWS3b335IF3WiAXwTR7P9j5aj4wACnG4+wNvTUg1osbaEEkp84/tYe6854eKNlkN/qRrroWkSsgQJ boW5xLyX/hmzZFXnFz1hVOyEnSQDbbsTmFtKS0aLJn2ubRaSsiYKM0cuzhXltl2PiDqg=; 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 1ouYn8-0021wc-SQ; Mon, 14 Nov 2022 13:42:22 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, John Crispin , Sean Wang , Mark Lee , Lorenzo Bianconi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger Cc: Vladimir Oltean , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 3/4] net: ethernet: mtk_eth_soc: add support for configuring vlan rx offload Date: Mon, 14 Nov 2022 13:42:13 +0100 Message-Id: <20221114124214.58199-4-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?1749475643350273718?= X-GMAIL-MSGID: =?utf-8?q?1749475643350273718?= Keep the vlan rx offload feature in sync across all netdevs belonging to the device, since the feature is global and can't be turned off per MAC Signed-off-by: Felix Fietkau --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 25 ++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 891dd6937f89..a118c715b09b 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -2724,15 +2724,30 @@ static netdev_features_t mtk_fix_features(struct net_device *dev, static int mtk_set_features(struct net_device *dev, netdev_features_t features) { - int err = 0; + struct mtk_mac *mac = netdev_priv(dev); + struct mtk_eth *eth = mac->hw; + netdev_features_t diff = dev->features ^ features; + int i; - if (!((dev->features ^ features) & NETIF_F_LRO)) + if ((diff & NETIF_F_LRO) && !(features & NETIF_F_LRO)) + mtk_hwlro_netdev_disable(dev); + + /* Set RX VLAN offloading */ + if (!(diff & NETIF_F_HW_VLAN_CTAG_RX)) return 0; - if (!(features & NETIF_F_LRO)) - mtk_hwlro_netdev_disable(dev); + mtk_w32(eth, !!(features & NETIF_F_HW_VLAN_CTAG_RX), + MTK_CDMP_EG_CTRL); - return err; + /* sync features with other MAC */ + for (i = 0; i < MTK_MAC_COUNT; i++) { + if (!eth->netdev[i] || eth->netdev[i] == dev) + continue; + eth->netdev[i]->features &= ~NETIF_F_HW_VLAN_CTAG_RX; + eth->netdev[i]->features |= features & NETIF_F_HW_VLAN_CTAG_RX; + } + + return 0; } /* wait for DMA to finish whatever it is doing before we start using it again */ From patchwork Mon Nov 14 12:42:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 19798 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2122631wru; Mon, 14 Nov 2022 04:48:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf6g0XE7iH3dh1g1d3k7H+8LaT6BjBFadXmZ4E52Y6k+fXm2blNjtbFQyqwkF9tRRrs1Owij X-Received: by 2002:a17:907:2a93:b0:7ae:9dd:e54d with SMTP id fl19-20020a1709072a9300b007ae09dde54dmr10177715ejc.163.1668430106496; Mon, 14 Nov 2022 04:48:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668430106; cv=none; d=google.com; s=arc-20160816; b=LD4ziz/T0T08Tvgw2SgML7LhixPC8IkupUZjY9DT+4fJQDnJxB7Gz25hcN3syPmw7c V859ZKV+dcBG1uopGG0ZDvXmgccyFX/5odPRyrvu/U4oxYS/nNFk/1aJ7DorcgxeZZyq SarB8ty4ylNpo/raNV69kiKKFudICeUASTSA9F2R3N+83ElbW5bv6o+p7nufwQ6e3nCb EmsscRTjb59l4jWjNmFLQt15NPNMYyy/DnIgF5zLFx+lFmQks/VJpGnhZz776rlN/Go6 3EKqx9zf92mAyII+qH6+jYbm6Uns0oWG0ybkPxM+OI69QmrkJgMlx6ETH8nNpsY/5knb 4Bsw== 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=28+5OR0aYRLcARp6ZCFbRP38vXPboMXzA307Ks+YLvQ=; b=KUpl/4AB+DGXANHkfz6PBdW//miJgYexzyB4+3VVeDuJdh1dqnM4q/6a0Hdjdyyjnv glx9qlVeRzN1tmKbZXUQr/juA1Eml5pyWtjwnbONT0SYLMJdN/rc2Wovi0qMdvo6BIqc 01qYs1jH0c7Z3zlSagSIIA6JD4LFZkfE9ttIsxLC7kQ9ra6nQZeQ81RS4CoLtdXqw4FJ p6nB4Og8KDOxdpFKPVh5KMykb994eIpViNgLQZX9IUerHAMvQQS0aRjoNjQQMVL4+12o M3nqt75ELr6dz/KQ4Vvg9IEXbyzEXI9PzV563zoqAl2q++zjaBZT9zoV1D+LWJ38GUjR hKkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=nqwmnvjG; 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 m15-20020a056402510f00b00467631dfc0esi8026398edd.145.2022.11.14.04.48.02; Mon, 14 Nov 2022 04:48:26 -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=nqwmnvjG; 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 S237262AbiKNMoM (ORCPT + 99 others); Mon, 14 Nov 2022 07:44:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237252AbiKNMn0 (ORCPT ); Mon, 14 Nov 2022 07:43:26 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AE6B26AE2; Mon, 14 Nov 2022 04:42:43 -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=28+5OR0aYRLcARp6ZCFbRP38vXPboMXzA307Ks+YLvQ=; b=nqwmnvjGWRlEJOK5JJm3of44Os jp4SUfWTJJTuJtU/SLnG9jGjfxDALCgcWRk+h/LR/1QD8B3mJkKaDXh4QbaEIzGHs1QlIXc+OvCYl vntMzxMyW9hlFRhAhUFzGkobxmADRa104B+fi3wDxlspMk/aCSgYqRyMmlPEHLS9lN38=; 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 1ouYn9-0021wc-LY; Mon, 14 Nov 2022 13:42:23 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, John Crispin , Sean Wang , Mark Lee , Lorenzo Bianconi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , Russell King Cc: Vladimir Oltean , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 4/4] net: ethernet: mtk_eth_soc: enable hardware DSA untagging Date: Mon, 14 Nov 2022 13:42:14 +0100 Message-Id: <20221114124214.58199-5-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?1749475767154165413?= X-GMAIL-MSGID: =?utf-8?q?1749475767154165413?= - pass the tag to DSA via metadata dst - disabled on 7986 for now, since it's not working yet - disabled if a MAC is enabled that does not use DSA This improves performance by bypassing the DSA tag driver and avoiding extra skb data mangling Signed-off-by: Felix Fietkau --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 66 ++++++++++++++++++--- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 8 +++ 2 files changed, 67 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index a118c715b09b..3e9f5536f0f3 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "mtk_eth_soc.h" #include "mtk_wed.h" @@ -1939,13 +1940,19 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, __vlan_hwaccel_put_tag(skb, htons(RX_DMA_VPID(trxd.rxd3)), RX_DMA_VID(trxd.rxd3)); } + } + + /* When using VLAN untagging in combination with DSA, the + * hardware treats the MTK special tag as a VLAN and untags it. + */ + if (skb_vlan_tag_present(skb) && netdev_uses_dsa(netdev)) { + unsigned int port = ntohs(skb->vlan_proto) & GENMASK(2, 0); - /* If the device is attached to a dsa switch, the special - * tag inserted in VLAN field by hw switch can * be offloaded - * by RX HW VLAN offload. Clear vlan info. - */ - if (netdev_uses_dsa(netdev)) - __vlan_hwaccel_clear_tag(skb); + if (port < ARRAY_SIZE(eth->dsa_meta) && + eth->dsa_meta[port]) + skb_dst_set_noref(skb, ð->dsa_meta[port]->dst); + + __vlan_hwaccel_clear_tag(skb); } skb_record_rx_queue(skb, 0); @@ -2990,11 +2997,46 @@ static void mtk_gdm_config(struct mtk_eth *eth, u32 config) mtk_w32(eth, 0, MTK_RST_GL); } + +static bool mtk_uses_dsa(struct net_device *dev) +{ +#if IS_ENABLED(CONFIG_NET_DSA) + return netdev_uses_dsa(dev) && + dev->dsa_ptr->tag_ops->proto == DSA_TAG_PROTO_MTK; +#else + return false; +#endif +} + static int mtk_open(struct net_device *dev) { struct mtk_mac *mac = netdev_priv(dev); struct mtk_eth *eth = mac->hw; - int err; + int i, err; + + if (mtk_uses_dsa(dev) && !eth->prog) { + for (i = 0; i < ARRAY_SIZE(eth->dsa_meta); i++) { + struct metadata_dst *md_dst = eth->dsa_meta[i]; + + if (md_dst) + continue; + + md_dst = metadata_dst_alloc(0, METADATA_HW_PORT_MUX, + GFP_KERNEL); + if (!md_dst) + return -ENOMEM; + + md_dst->u.port_info.port_id = i; + eth->dsa_meta[i] = md_dst; + } + } else { + /* Hardware special tag parsing needs to be disabled if at least + * one MAC does not use DSA. + */ + u32 val = mtk_r32(eth, MTK_CDMP_IG_CTRL); + val &= ~MTK_CDMP_STAG_EN; + mtk_w32(eth, val, MTK_CDMP_IG_CTRL); + } err = phylink_of_phy_connect(mac->phylink, mac->of_node, 0); if (err) { @@ -3321,6 +3363,10 @@ static int mtk_hw_init(struct mtk_eth *eth) */ val = mtk_r32(eth, MTK_CDMQ_IG_CTRL); mtk_w32(eth, val | MTK_CDMQ_STAG_EN, MTK_CDMQ_IG_CTRL); + if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) { + val = mtk_r32(eth, MTK_CDMP_IG_CTRL); + mtk_w32(eth, val | MTK_CDMP_STAG_EN, MTK_CDMP_IG_CTRL); + } /* Enable RX VLan Offloading */ mtk_w32(eth, 1, MTK_CDMP_EG_CTRL); @@ -3538,6 +3584,12 @@ static int mtk_free_dev(struct mtk_eth *eth) free_netdev(eth->netdev[i]); } + for (i = 0; i < ARRAY_SIZE(eth->dsa_meta); i++) { + if (!eth->dsa_meta[i]) + break; + metadata_dst_free(eth->dsa_meta[i]); + } + return 0; } diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 589f27ddc401..a572416e25de 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -22,6 +22,9 @@ #include #include "mtk_ppe.h" +#define MTK_MAX_DSA_PORTS 7 +#define MTK_DSA_PORT_MASK GENMASK(2, 0) + #define MTK_QDMA_PAGE_SIZE 2048 #define MTK_MAX_RX_LENGTH 1536 #define MTK_MAX_RX_LENGTH_2K 2048 @@ -91,6 +94,9 @@ #define MTK_CDMQ_IG_CTRL 0x1400 #define MTK_CDMQ_STAG_EN BIT(0) +/* CDMQ Exgress Control Register */ +#define MTK_CDMQ_EG_CTRL 0x1404 + /* CDMP Ingress Control Register */ #define MTK_CDMP_IG_CTRL 0x400 #define MTK_CDMP_STAG_EN BIT(0) @@ -1121,6 +1127,8 @@ struct mtk_eth { int ip_align; + struct metadata_dst *dsa_meta[MTK_MAX_DSA_PORTS]; + struct mtk_ppe *ppe[2]; struct rhashtable flow_table;