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 */