From patchwork Thu Nov 10 21:22:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 18325 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp384372wru; Thu, 10 Nov 2022 13:28:47 -0800 (PST) X-Google-Smtp-Source: AMsMyM7vzEao4+nbk5VyWQAROKwRCH7k/DVdq0ixKk6uAi21VtB9Igb032gUZ6P+WhmeZZW9kIoT X-Received: by 2002:a05:6402:c87:b0:459:9dd3:2217 with SMTP id cm7-20020a0564020c8700b004599dd32217mr3489146edb.163.1668115727542; Thu, 10 Nov 2022 13:28:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668115727; cv=none; d=google.com; s=arc-20160816; b=AYpgKK+KFcgR2oTXVqm1IDcXBIYiWI/b633nVJr64d4z3F3+GUX1En0bvtxYxiMDx+ 4piHB03BtwHn7lpPxRTmtnwbIbFEzbun0bgRdX+x5KCKXaen+s7n/buqmSEo/Syq0NTq GAE24gfo0UA0hGuJ/7D9NETacdan3WGaSi33KqNSLQh+Hwgmzyfp2HwK3SP0C7LooA+v 5KEhIOx9r8OAJXLKKuh4ulbg+3RVUJImHxzMEVlDU+QfcY0z/BC2RTWIHKRNtIyDav8x BPxV9MQwSwQzxcdOY39paEu4OA3WunMTrNLZvWRm4KfJcMwDVNUwfT/f/yCGlARi0P3W YPDg== 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 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.28.22; Thu, 10 Nov 2022 13:28:47 -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 + 99 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 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?1749146117081846523?= X-GMAIL-MSGID: =?utf-8?q?1749146117081846523?= 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; From patchwork Thu Nov 10 21:22:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 18327 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp384791wru; Thu, 10 Nov 2022 13:30:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf59PmVYgwwHXpuZY6Ns09irSqzCMVWbGBUsTvW5WNHGuVFiXdK+/FlpBElbiL2BKMoUmrPM X-Received: by 2002:a17:907:75e7:b0:7ae:6450:9269 with SMTP id jz7-20020a17090775e700b007ae64509269mr3485108ejc.408.1668115801107; Thu, 10 Nov 2022 13:30:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668115801; cv=none; d=google.com; s=arc-20160816; b=gLidLez6zv6FSz7SwinE/NKOCQlC8bTr38SevuYGgJd1rcU6mxq6anLhfDXhzVKnft svJk4hnTX1J2fjCHQP27N3o6mKjhWdYlUIB4yha7qwUmfSok9TRbn8JxBc2wl04x1dmm F8gfZl57btulfL5tR8AZxXM+He+LwK2LrV7xnVFb15i3tlTb/bFVyiBuBqYkiCQoci2V FrUVukq+2egCdPnga7vThu3qt5Os4wgvxB0vMi5ImN7iQiXNDeSUEIEEnA5z5E15s/za Xq3Wg7W1gKr7J36Ii1EGS4f/ybfpJaU/I5H5JZsAD6gmlh+SEmVugc4Hb39BK1hWnrq0 a95g== 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=SrrVhy6/M0c4wZ60YS59zn2L76BsVbta7bt6rGHPm7McspKN3SyOMbfrl+ktuvgy02 SM53SryZf3aCYACPNGa4TA+82m+RMGTYEwfWi2hjfkPwAYd6F2mAYzrnkr3OcgK4r+jb cTSaed76i1URU7EXeKaZ2J0O+05+pclEHn6wzxSO+sfbne6GV4WIEEhSUdFu6Ml0Qnp2 P8RNUYEL4jVKXyyculfHTIRN6vb3hix5SxrzyRoa6NXkqhYmIjjKaHh6jBCuMvdsaw+n iKvQg3rulidcRFFhY4aUPZx3o4J28N6obxzuZqAyF6KHcVbvtul9h6rUV5uFyrMzm+ar nxWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=s1z7yzME; 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 dr22-20020a170907721600b007ad9adaf33dsi409431ejc.372.2022.11.10.13.29.37; Thu, 10 Nov 2022 13:30:01 -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=s1z7yzME; 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 S232273AbiKJVWp (ORCPT + 99 others); Thu, 10 Nov 2022 16:22:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231985AbiKJVW2 (ORCPT ); Thu, 10 Nov 2022 16:22:28 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEE0A31DCE; Thu, 10 Nov 2022 13:22:27 -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=s1z7yzMESfXzDhx7aJHfunCO5+ u1WwU4WteCJetVzMY4zgbJndQmKkGHnp15bUZPLAabaMhQkzi5yxvWm72msGHOhhjREaQAW9NyXs1 VWkoC9lnFfMukB7Nyn/UB6RNlKqZ1qJtZjNQj4PSVb0HpxnFazol4H5alBY+S9tbh1lA=; 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 1otF04-0011Om-G7; Thu, 10 Nov 2022 22:22:16 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, John Crispin , Sean Wang , Mark Lee , "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 v3 2/4] net: ethernet: mtk_eth_soc: pass correct VLAN protocol ID to the network stack Date: Thu, 10 Nov 2022 22:22:09 +0100 Message-Id: <20221110212212.96825-3-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 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?1749146194406100989?= X-GMAIL-MSGID: =?utf-8?q?1749146194406100989?= 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 Thu Nov 10 21:22:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 18326 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp384456wru; Thu, 10 Nov 2022 13:29:03 -0800 (PST) X-Google-Smtp-Source: AMsMyM6MjFOH3Rh0Q0Z9nRS3Gc9nVKk4r1H24DkRygc8ZfDvSj0GS6nmXli8ez2FS9iLxPd+/sG4 X-Received: by 2002:a05:6402:5c2:b0:463:7312:a94 with SMTP id n2-20020a05640205c200b0046373120a94mr3615921edx.178.1668115743134; Thu, 10 Nov 2022 13:29:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668115743; cv=none; d=google.com; s=arc-20160816; b=HD6pey9Se1p7ddjX+dTc/OIPabs49JU7YOXdWJNSjF8SRtyPWbVawOdbZ++DDh9WOP cIT5db4COe+Es0v3mMwfgoF4LbXgIPS6mXY75fT7XF1aJfwanOh9gvxFtzuKbcH/n7vM 0z+IdsgG23ZIdBJlJizmI5g5ipFJfojaMILCAAGtDLU6YHo6/NMtizmW+OUgd4f7CdJt /F3pRVeiFkrA/x0wCkFYkGlFF0VFHV/ever87szR/oikATOIdQSAVBLprx7LFttjOyAD xQs7ejsOiu9g/tCxx9N4+xIDwp/XivBYtxwU1AXgY4QS9zUtfgHjyyWfgBfx7OHnM/Pg Bo6A== 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=VHnIpGA7gh85kX+OpJimxOsLKh1DS95TiAISYckykKQS9JpqLkK3CxcG54N64caVMR 9K0BvtwJEtU/p4B0yyU8giDuSPlvKfEVcLe1TUKzgPzDqOj1RJiKg1ktKA9xJ4GffVyj 0IlyG3eYjR7azk30HON3B1mXkC1H0Vsne4c40B7c4fFcKRZ+xRQHLfSi1Tyx/rBxcco7 U7lxuD2qvuedHU4EBrNcsk53DWddOMgrN8BWIWDgbJs8aapsz41EcpUMSYw13OlO1S5u I+Zqeleiitm9HoaEsflDl9Q9NQXH5Zz7uEqQ5D1UwcT5z6ft6Wao5PAGi46XRzctsj6w l6nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=Vg+Gz68d; 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 g16-20020a056402321000b00461f7a7a797si597412eda.292.2022.11.10.13.28.39; Thu, 10 Nov 2022 13:29:03 -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=Vg+Gz68d; 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 S232287AbiKJVWr (ORCPT + 99 others); Thu, 10 Nov 2022 16:22:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232082AbiKJVWa (ORCPT ); Thu, 10 Nov 2022 16:22:30 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5877B31DCE; Thu, 10 Nov 2022 13:22:29 -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=Vg+Gz68dE57MbwQ0dhLtvumyDd ebGhYqxGEYqPJc9VPH7VcB8yrCP9698BO09vSHRoFSQXakILrWTh1AhPptBbTOIAU8d6LVBRx8xXo WTF4SCk+QYjm+fSO/JB8zeqaXySy3qn4/fiXJoifG4z1COT5Z2Tw7M135I9pesKZomm0=; 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 1otF05-0011Om-4w; Thu, 10 Nov 2022 22:22:17 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, John Crispin , Sean Wang , Mark Lee , "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 v3 3/4] net: ethernet: mtk_eth_soc: add support for configuring vlan rx offload Date: Thu, 10 Nov 2022 22:22:10 +0100 Message-Id: <20221110212212.96825-4-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 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?1749146133354812498?= X-GMAIL-MSGID: =?utf-8?q?1749146133354812498?= 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 Thu Nov 10 21:22: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: 18328 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp384854wru; Thu, 10 Nov 2022 13:30:09 -0800 (PST) X-Google-Smtp-Source: AMsMyM7mGXZg6+mBg5gjut2Lh216Tq0a+CWgnmyrkpSetMxPlFKLrHrm+ocWk+tqrflK4SXfwbHe X-Received: by 2002:a05:6402:5c2:b0:463:7312:a94 with SMTP id n2-20020a05640205c200b0046373120a94mr3618770edx.178.1668115809482; Thu, 10 Nov 2022 13:30:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668115809; cv=none; d=google.com; s=arc-20160816; b=yWuFEM6kcfP/25X8zVLBIRooc47vIxF24AYykB7dgTuz9FakyOR7ZCg1ZkgC7bFBPv caYsyfVc+X1em8tTP8GHx2BR0CvgXHRJqn1NQgAPJ/Tr2uUSnD6GIndYbNnuFaoEWD2d ZTVo80+OONWGUOC1t9KNMHaBwQNo/6P7BLEyRw4AFQPq6KdiyiUxqTcfPrW8DACnSy7E swSmFpe5bER1EY68bZlo35E8fAKo2o5hs+nFWKXMdxj93H9DRrxvdW67MHp1HgRP0suw a2t8g4B/YdhHmLOptKehJ1WYapY7FBezM5LQ4VnBFW6/HM2Y6IZsCIqVHCxbSQfO4cNa XKMA== 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=CtmGvO+Y27LomRwiSBbwQG3+4u8RGeKxNxvjoDf6oK0=; b=gtDOAEBtVGI3WTCaAsYeglFu8Dsc+UjcY33pO3IKoJ+8astMC6sN+R3ASoCOEs9KRr jTDUNTl6PDmuRX2iPVwuSUMr3l1vhgwrCO3VnqRCUX5ZIbaocXTWO5eHHB95kcQHCbYt RMCN4F/JT3XaUGSrPG6j8fwNQlQYALAjOrldyUbc437yn9rnV8WXXj1/vTT4Pe7wJcaj WghGmcK6we4h5X2e+t+AxBTDceiKkbZnS43bQyfGGLgJ9J9vYqWGw4dRssYHn9NsDRB2 VLDipXNyk5IyLuMQUChbwgs95X8sH6jemyF85s02tzldj0bY8tpDBUIo/JHAtvzcurMk EZmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=qR6c6Ftx; 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 t10-20020a170906064a00b007adb2868da6si275071ejb.646.2022.11.10.13.29.46; Thu, 10 Nov 2022 13:30: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=qR6c6Ftx; 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 S232320AbiKJVWt (ORCPT + 99 others); Thu, 10 Nov 2022 16:22:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232086AbiKJVWd (ORCPT ); Thu, 10 Nov 2022 16:22:33 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 986AE31DFD; Thu, 10 Nov 2022 13:22:32 -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=CtmGvO+Y27LomRwiSBbwQG3+4u8RGeKxNxvjoDf6oK0=; b=qR6c6Ftx4P7oFmkPrhdd+peSoP BxtW50Whwo8o809uTCr9IIfuR9gXdcXwuFV1Ss47zVkVXdFuJCpCcEe0i9rxQZJkOJVNPTfeWnNA0 3ouYXYqmJe6cexCLB0AHJvd8gAGCZoNk65YQstBtkrfnUVQoJyxqaoBzaO8/BO3gBDj4=; 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 1otF05-0011Om-UX; Thu, 10 Nov 2022 22:22:18 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, John Crispin , Sean Wang , Mark Lee , "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 v3 4/4] net: ethernet: mtk_eth_soc: enable hardware DSA untagging Date: Thu, 10 Nov 2022 22:22:11 +0100 Message-Id: <20221110212212.96825-5-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 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?1749146203296255816?= X-GMAIL-MSGID: =?utf-8?q?1749146203296255816?= - 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..991ffa0b02f5 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)) { + 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;