From patchwork Tue Feb 7 10:30:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 53819 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2770859wrn; Tue, 7 Feb 2023 02:34:04 -0800 (PST) X-Google-Smtp-Source: AK7set83qr5bezLTK45jyhInJ6Ju/qkLLfBQD/TElnjKvTpWOWuzIvkLrphpZIoej7O/r6b/xheR X-Received: by 2002:a17:907:1612:b0:82e:a57b:cc9b with SMTP id hb18-20020a170907161200b0082ea57bcc9bmr3832130ejc.24.1675766044235; Tue, 07 Feb 2023 02:34:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675766044; cv=pass; d=google.com; s=arc-20160816; b=woou8NJAViHHRNkNpmXIVHYY8//E3z6iUd+4ZRCIdCW4jPcMqOPaW/SfSwAQnGMW4C jMdw9F/cLsriALGebB1opONNjQBccxvONtouKo7k6+6mwYivPC7MzZEP5qKrf2hhG1Cp LqHV+WMxB/piRsx01fY/OfATsh1AjqXKAoX/Qy6Y5Usjl/tbBmc4kbJVzEgmDVmkLRym hOaFLE1Bd63y5NYuuGOD+9pj2uM9HU1pcVbUj76SL8b51IOcPxc9CcnRQi3ehA5FoIkn kVfBlC2MK0o2/H+i787DzY2wJeWNK4tNnOviWv9MZWGm2Y9Zxo/QC8XMdBbWVgXDA9Ws Z7ow== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=4Y4OMC14risVihGyOmksynEVTFRTeMEHgGToHfOtsM4=; b=uX6I1JrWjc01hmJNkhdv3eFaOewlf8B4mRXd+fB/7LoTSRiCTAG2VrHF5IezIUhbn9 xy/K/5y+NK2t58nvG5c+P0GlwG2Aljp+3DFKLIbRZGQmThmKjZQbU2U/3Bd4AMvB1Rv/ amc/MHQZxDpGMsJyz2waWRB5C9JnqKs3Ke6erOaK9yIVLmcOZtwsF0P1AWrvFb/pOYLN sTKpSadH7riJejl1/3xL++0vXmsTWjUNYRfRU+WaMAxnOm/8LF9YNAJ/Zknfdkqf9cLO tLSBq3IlFwgP7TgRiP5LVEdqMB7MyQG60y2OO87iNnNuDLfgocl1lR0dGRQGXONzJgFG kQUA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=FQzowdrJ; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wi20-20020a170906fd5400b0086e4bf68769si15197474ejb.716.2023.02.07.02.33.40; Tue, 07 Feb 2023 02:34:04 -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=pass header.i=@nxp.com header.s=selector2 header.b=FQzowdrJ; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231272AbjBGKbS (ORCPT + 99 others); Tue, 7 Feb 2023 05:31:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231163AbjBGKbQ (ORCPT ); Tue, 7 Feb 2023 05:31:16 -0500 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2068.outbound.protection.outlook.com [40.107.241.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A79852B2A2; Tue, 7 Feb 2023 02:30:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R3vxlteb4LUSYWpb8GpCOgmzfEQBR0RRp+Pw6lyaE+5gwOblUUqdGI/QVAZAvLa1yRNCftob3dhhprLw7F+faxQAMAb299ig9pOQ3fN9Mou7We9B92hviqroWJ/w9EYx4/UO8Qae5fRwquXJTfT1sMiVL2MhW1iOGbBXtYp7bteDkcSd0xy8C5IRIQYPI6/n1VADfDcOivbtB+i3/ZrZa6wKeF6x5hUzxzjMIfuKENcikuGSlzXfFvSOlTxMtb5s6STHGHwzCXjrWPgWac8etahZEJgrMNGR7wizL/wqVF+m7/oeOFGsMf4q3WUM0XBSdvxc8upIWYUfyS2Hx8zMKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4Y4OMC14risVihGyOmksynEVTFRTeMEHgGToHfOtsM4=; b=fp9t0J37kDZezmhUkmg5jKBPtCDcVJXmzATq5KI2E91VnPoNzpUwN5Lp2PKsqOAw09VltkPDPlrccVRK+EssHLH6cCiVx07djXgHlKxx3G1ru6jFruUVw72+2GTvEfQzlodXszzqD8qX/mZzFAsG4pypTc9tuW6YrtLevPZXXQ7ydpuWO8qBhnUXNe3VYkFa7UFRbXgCnbg0+Lp3Cxkguw2KIQetJzA7x1Ps/I4pGhAouU7EdhDgWjPXhU/XdTZLplQpUnek/Vc1LC1/krXUkLGApd84XC+gDoyTPxgGTlTiAYi8WSkQME1MQKGpSGIWXPfyJGRoEd2nC8z+cubDbQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4Y4OMC14risVihGyOmksynEVTFRTeMEHgGToHfOtsM4=; b=FQzowdrJvjrsqk4MZc5O1yrPXfb2zYxzO5nNJhhAMI/5dmyGgE6P5gOeV88/22fzff4xNaFf+SpTAM/No4N2i/dm4dY+XQ7y2pIyEzOB1LMNicJzfG4DVdr+yxzD6sqC7V/HHkuO51jXOTYd3zI74fQmtxb7GO14U5y8zhMBrDA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AM9PR04MB8274.eurprd04.prod.outlook.com (2603:10a6:20b:3e8::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36; Tue, 7 Feb 2023 10:30:43 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%5]) with mapi id 15.20.6064.034; Tue, 7 Feb 2023 10:30:43 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Felix Fietkau , John Crispin , Sean Wang , Mark Lee , Lorenzo Bianconi , Matthias Brugger , AngeloGioacchino Del Regno , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= Subject: [PATCH net] net: ethernet: mtk_eth_soc: fix DSA TX tag hwaccel for switch port 0 Date: Tue, 7 Feb 2023 12:30:27 +0200 Message-Id: <20230207103027.1203344-1-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: AS4P191CA0006.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:5d5::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AM9PR04MB8274:EE_ X-MS-Office365-Filtering-Correlation-Id: 09968a17-4ed3-4557-5078-08db08f65de8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZMxrWPusrYCB0sMmJfiiwNmb5utU0+Mtlyu6xC6rf+qx2VuVfAFas5YZJ3y3Y4CWZvuQF3GAxlnsx7g7r0G+Mqsa4OrfgAqRMLQYB1AFesb1KW5dB2oehcEcy86t2IBiCqB44spf++GHgSklfbHhQS3vcglGkuy557lhyEfl/DMPCh9DAsmCoq33ik4fHQfZuwrnXZbB/JldLjTf1fjWAEQSvTEWIaAVSb6kFyxKwhIS6ddPG5uKvq1OxGqD8vmQSG7BvqjFNGYdt0jv8m9lnIe1ZqIpUFT8wm0Gb8Y91ETKdw/G8CUMhfnKK+mJx1L2BoRVWSIqlJUlPPZsfnM4gUquw+5Jsq/iL2FuVI89mBCKz86JXAoyd8DZGjvCmhjLaJ2/Pb6xw3wFa3svD6Pd9SStx3qd+gmJtfi+d5zXqKNycsn1a6IKLXek52gv+dnp4NwJ/9qBKc7suq1DRUk2p0NdNtMTjW9gtCPFHgX+3AVZhIDOqY93BE/rhpQrEPYDw6Ene6j2Y8i75jVr91rEqZ1PEan6057t3s02DPRzjXEaGatcJj9fX+0hC5gAXQSVB6kLXH50g77KTR0y9JCKTFe8M0QUyIQUdAXR663v5QhF813b23EzQ1DabMmTxhFZIH6li7RnKwDMfALFJNtXyV9IaZuIjbIfQsyZpcFtoTqxW1WaBmsbIivXTlVhhCIyvmtnIBaAIqRd937N9hXf1UhPdcEqNXwkgdLx8OJ8Nvk= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(366004)(346002)(136003)(396003)(39860400002)(376002)(451199018)(54906003)(186003)(6512007)(86362001)(52116002)(66574015)(36756003)(2906002)(44832011)(41300700001)(5660300002)(66556008)(66476007)(8936002)(66946007)(4326008)(8676002)(6916009)(26005)(478600001)(2616005)(1076003)(6666004)(7416002)(6506007)(966005)(6486002)(38100700002)(38350700002)(83380400001)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?AyOTJFDNqsa2in5My8KMBB0JftUf?= =?utf-8?q?62eE0riOfrmIdaOhf+ufvibdNIJnIyUA7+WDJLVo0SlrWIgH5d87iOZAGACvloBzz?= =?utf-8?q?pa0sBDcILBWYTTthlYzN7/gIIKAMWAj/F/N2gG+oSVPSdT//qAunxGxQHm6A7F7hJ?= =?utf-8?q?CsSxrjGOraWPIv5prmgsBDSieB5Mqi5s574aIBbK2pmtUzncFZpUa8OTmkNvPSg/T?= =?utf-8?q?HZMxqIPg2pQh4WD7XpMZ+eZg4uWSHuJzd9j5SBVoRIjATS9rNcZGb9XNpWpZggEVS?= =?utf-8?q?3FDoZiexj7iVMnmbLT/GjIYt5M1uH53dui7S47VfNrqr7Tx4kKcTdZfSqctJ4U7sD?= =?utf-8?q?ZycbGLJigCQbCK7hLPU3sitEvmyfYrmIGzk101VWz5UCZg2Uza8Xu2HME67+hqCrG?= =?utf-8?q?6Klz5P8E+8Etoo5pleEk98Y4CsXRI6S1FzsVEBa1XrhtNAVNqbFAbJnRXMNQGXaXK?= =?utf-8?q?Mm8IDkN1MFSZ1ddCrDNWQU1DiiCNXsSxFIAOE12SO+qGv6lzUFhfi4lHHAP5/d/JQ?= =?utf-8?q?oh+EKvIyCVFTQhERM1on5W5KDLdzC961xnlIfbArZ8zjZXXYFXNXbCRWA0pxvOb1i?= =?utf-8?q?dMTzgr6OrbpMIMVII+BrwM2KyCJjPriK4BGKt/TwTOqsAVlnBEOO8C6aEMHgGxU2H?= =?utf-8?q?e32AWadNMxDk59y98kA5v5JGia1vuqCTCokkMiTtgl3ITorHHf/lEys5xHkbaj8Nn?= =?utf-8?q?kpv+zagiBUwf17JWZ9+u+ADr64fnZHuFIUBLWwlvUEOwy8RiGv3ZNBQ94oFieaK5S?= =?utf-8?q?FqTPluk6LN11X19q8sU9jxRCvpIIx2EfUT3Qq+DfVrP6nZO+Bog1aMitMNUvK+r7i?= =?utf-8?q?hcrwm+rTjWnyC5phISh/pm6Vq3A+LOlyPUqWZ9CmG31L5Fx6u0FFJVcJCmcZ/XhJE?= =?utf-8?q?JdR5ZsnrF1rKBrLfQUx0SngjMCUEndhVOQ3r1058qUoLB45bpJTSoPgVKiQdr0WTV?= =?utf-8?q?Wyi2SnpoIOtEaYzBdD9ZSOpxXvRBWV7tJxkg2/Odo36NX/4tcitOP9lPRqihatEE2?= =?utf-8?q?nRZCEPLOTi/5d69FGKrw1QB5hnB9XPsqUaEVUvDPQFWS5UIuTeOm6CxekFMnl0n6D?= =?utf-8?q?GU48hR44nUDAHy0tM1CvK1DH1SAKA6KJo+umm1Y+d1QVxkNU44RQyBg4Tlwkgdk3Z?= =?utf-8?q?/WnLv+2btlKC6dVFwL2DYA9QdDc5fJGayjw6x9StSBl+f1NNs83Exy5Agdo5pJeez?= =?utf-8?q?qRde3vMgFx152AhGFydAE72MN6//zIcqxQiFWc/rOn4p14fic94zToG86SWZjb4xu?= =?utf-8?q?C5erUJu9v8zvKd+cFVQP91USF5Lkhc0ROzQkUJn9vbYVBXQRUvVrM5SFSMcKood7V?= =?utf-8?q?9Xj/KUVb67/MdY/fu2HY5kgxGHALKUyA2je4KnKnfjCLNMaZF2ugVQek5TpcoBZiI?= =?utf-8?q?5lKqhWLg+JppIFYlTZ35cMynyWbfRAzo6a0fseQYxR7OhkGCE6bCUI9WWwKJLFlpK?= =?utf-8?q?y+dWNqzotYwO/FZxZQDUto16JVUMNjeMoXvNdFKQmh3chTwhGyhUjly9v/rMYFAni?= =?utf-8?q?usY3tk7tUqdfIwcu6ct35vRYWBIqL4ko+g=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 09968a17-4ed3-4557-5078-08db08f65de8 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2023 10:30:43.5883 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mLBjsKgWoNImZGCiTVYUMcuESKFVrrwK8JoZIQFF+bwkEy084bV6mGuOuw6TLtFf+rGTdvrRZldP6rjHgyNsSQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8274 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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?1757168055871231307?= X-GMAIL-MSGID: =?utf-8?q?1757168055871231307?= Arınç reports that on his MT7621AT Unielec U7621-06 board and MT7623NI Bananapi BPI-R2, packets received by the CPU over mt7530 switch port 0 (of which this driver acts as the DSA master) are not processed correctly by software. More precisely, they arrive without a DSA tag (in packet or in the hwaccel area - skb_metadata_dst()), so DSA cannot demux them towards the switch's interface for port 0. Traffic from other ports receives a skb_metadata_dst() with the correct port and is demuxed properly. Looking at mtk_poll_rx(), it becomes apparent that this driver uses the skb vlan hwaccel area: union { u32 vlan_all; struct { __be16 vlan_proto; __u16 vlan_tci; }; }; as a temporary storage for the VLAN hwaccel tag, or the DSA hwaccel tag. If this is a DSA master it's a DSA hwaccel tag, and finally clears up the skb VLAN hwaccel header. I'm guessing that the problem is the (mis)use of API. skb_vlan_tag_present() looks like this: #define skb_vlan_tag_present(__skb) (!!(__skb)->vlan_all) So if both vlan_proto and vlan_tci are zeroes, skb_vlan_tag_present() returns precisely false. I don't know for sure what is the format of the DSA hwaccel tag, but I surely know that lowermost 3 bits of vlan_proto are 0 when receiving from port 0: unsigned int port = vlan_proto & GENMASK(2, 0); If the RX descriptor has no other bits set to non-zero values in RX_DMA_VTAG, then the call to __vlan_hwaccel_put_tag() will not, in fact, make the subsequent skb_vlan_tag_present() return true, because it's implemented like this: static inline void __vlan_hwaccel_put_tag(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci) { skb->vlan_proto = vlan_proto; skb->vlan_tci = vlan_tci; } What we need to do to fix this problem (assuming this is the problem) is to stop using skb->vlan_all as temporary storage for driver affairs, and just create some local variables that serve the same purpose, but hopefully better. Instead of calling skb_vlan_tag_present(), let's look at a boolean has_hwaccel_tag which we set to true when the RX DMA descriptors have something. Disambiguate based on netdev_uses_dsa() whether this is a VLAN or DSA hwaccel tag, and only call __vlan_hwaccel_put_tag() if we're certain it's a VLAN tag. Arınç confirms that the treatment works, so this validates the assumption. Link: https://lore.kernel.org/netdev/704f3a72-fc9e-714a-db54-272e17612637@arinc9.com/ Fixes: 2d7605a72906 ("net: ethernet: mtk_eth_soc: enable hardware DSA untagging") Reported-by: Arınç ÜNAL Tested-by: Arınç ÜNAL Signed-off-by: Vladimir Oltean Reviewed-by: Felix Fietkau --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 24 ++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index f1cb1efc94cf..64b575fbe317 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1921,7 +1921,9 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, while (done < budget) { unsigned int pktlen, *rxdcsum; + bool has_hwaccel_tag = false; struct net_device *netdev; + u16 vlan_proto, vlan_tci; dma_addr_t dma_addr; u32 hash, reason; int mac = 0; @@ -2061,27 +2063,29 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX) { if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) { - if (trxd.rxd3 & RX_DMA_VTAG_V2) - __vlan_hwaccel_put_tag(skb, - htons(RX_DMA_VPID(trxd.rxd4)), - RX_DMA_VID(trxd.rxd4)); + if (trxd.rxd3 & RX_DMA_VTAG_V2) { + vlan_proto = RX_DMA_VPID(trxd.rxd4); + vlan_tci = RX_DMA_VID(trxd.rxd4); + has_hwaccel_tag = true; + } } else if (trxd.rxd2 & RX_DMA_VTAG) { - __vlan_hwaccel_put_tag(skb, htons(RX_DMA_VPID(trxd.rxd3)), - RX_DMA_VID(trxd.rxd3)); + vlan_proto = RX_DMA_VPID(trxd.rxd3); + vlan_tci = RX_DMA_VID(trxd.rxd3); + has_hwaccel_tag = true; } } /* 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 (has_hwaccel_tag && netdev_uses_dsa(netdev)) { + unsigned int port = vlan_proto & GENMASK(2, 0); 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); + } else if (has_hwaccel_tag) { + __vlan_hwaccel_put_tag(skb, htons(vlan_proto), vlan_tci); } skb_record_rx_queue(skb, 0);