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