From patchwork Sun Feb 5 14:07:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13129044 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0253FC636CD for ; Sun, 5 Feb 2023 14:24:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=8kLyhQJuo6jBmiS9ZHuf7i9hb7ksHkiO4tj0V79zXOo=; b=iylg5/TPv8vhJa Ro61aE8C9WiPdWI75dKexR2XKJPozApVjXbMY4dI3njrnP6WRNVvMg5wFzPATTwWUhsEprBCsqBYE X2yNf+vaqiYn7SWjtSqG41TBEqrRYU2jYXMQZ+5ThC1TMcAP6VehDKM5nyhjUgMq3skkLby7i/b6j W9PY78kEjsBYPZzuW0s9anT0Y0APAxmh2Ff9pP1I3j7yJydCZ9PAPBE7X+gekCt4n/xi7rsdVCsaP K5EmAlT3sAztZSTiKTJI1ZoCL5JmEYHrBMjaI4KcWU8yBVQKiTcazXk3RXEesGKC/roMsF7i5iX5o A1JyAqFxON+2vZlmVWzg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pOfvb-006Pby-Pd; Sun, 05 Feb 2023 14:23:35 +0000 Received: from mail-db3eur04on0614.outbound.protection.outlook.com ([2a01:111:f400:fe0c::614] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pOfvV-006PbS-1w; Sun, 05 Feb 2023 14:23:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gromoGcPMwVnqsrTZSX7Fxhw3ipnoDetJXyHtc8oVXyUobTjlKoR4/DzBw97f/qsufOGnIuZV/asziC2dh95Onqd9ExG20IW+K25jHKh4ztjNAyBpb8Zl0FKezUKIil/hNdR4xnFoWCXtBQayEyPZ1EHjMtWN4prKTNMKOSXjxL9uL138psKovofjPVSfkyhax6vUewxUFVMfAdTGg4jiJ/ZUamtxjJyHmaZIP9L7fcdMqVgGSBFR8klCHC0FX7Z9i3bY5e3u9AKbc5ugzQysiU7WBjCcLXxQDkZqcMKmv0cAHw1vmTOlCzOLUHT05euE6YaGDY1N8CQ3WNuKeYrxg== 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=Jxxr2yQ5S/NthU3f8DVdtDcg4i5m1zYwVRueFbsz/zw=; b=bhadNPHMekdZiSgb5ZmlKlUREBNwXh7nYzBLFCBrstExwIWgKTK5A69/1hjJYlL9cfnKqBR/zSOHPvrevBq+9DT64iFHBA82GrRDMkwebLsxRyI5aUwT6Kmb+wM/kmFGwlTiGXaiQKGHi8kJEkTbr/uDY0JQOMmMSr33cvbaah3KEKblnWxYcvL6DJ4xTUhyITTIpY88I1f4Cmq9pQFgnogNy9v8TlEQg7scppnA0hkKVv4mmhvNnn2onla+26bJlwckou06GIi3drOd9g544xEUJKmUORbHBgL8LmMvwNHXAJsdOdzTv/sOVdMCO/zWG2irHthrIiHUKLd2shTdpA== 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=Jxxr2yQ5S/NthU3f8DVdtDcg4i5m1zYwVRueFbsz/zw=; b=cMzbZyicTfqErMqYgmwnbOSdwDcL+wq+rqEW4S1XJjJoQHPzXy7s5KAmtyf2ARlzdbJoZj4gp719wPnDETVRolNqtnNqKtma/nDHfjEz/RDBmpptS5Y/7HVRyoZXjT0Om906MkA7b4pPzCq1X7xRncwH1vfjJYEc688qMX+7LQU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB5121.eurprd04.prod.outlook.com (2603:10a6:208:c1::16) by AS8PR04MB9142.eurprd04.prod.outlook.com (2603:10a6:20b:449::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.32; Sun, 5 Feb 2023 14:08:13 +0000 Received: from AM0PR04MB5121.eurprd04.prod.outlook.com ([fe80::4c1:95d7:30fc:d730]) by AM0PR04MB5121.eurprd04.prod.outlook.com ([fe80::4c1:95d7:30fc:d730%4]) with mapi id 15.20.6064.034; Sun, 5 Feb 2023 14:08:07 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Sean Wang , Landen Chao , DENG Qingfang , Andrew Lunn , Florian Fainelli , Matthias Brugger , AngeloGioacchino Del Regno , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Frank Wunderlich Subject: [PATCH net] net: dsa: mt7530: don't change PVC_EG_TAG when CPU port becomes VLAN-aware Date: Sun, 5 Feb 2023 16:07:13 +0200 Message-Id: <20230205140713.1609281-1-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: BE0P281CA0028.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:14::15) To AM0PR04MB5121.eurprd04.prod.outlook.com (2603:10a6:208:c1::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB5121:EE_|AS8PR04MB9142:EE_ X-MS-Office365-Filtering-Correlation-Id: 01156a90-22bf-4e7b-7613-08db07826787 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mDuriRDDKPIi6Pd5j6TNOGsvzbn7TG0Eh7i49wCvyjAedeT5rvBnw9n26MGXuuBFDabsuWMUHHBzBkYHTNy4x/bOC/GomhG9ketCt273TRT18CF8Ezfa6cbdDNWUXNBvN5X/XBQtOwDsd1tIRuHTCA7OnvklHRu1zxsnAkWZ/Vh+YE+O/4jIJxLAtc7uaejBvSWYsarT+rI79du4Gc+ZeKb42QXFCNJTfYcNaR5BKlws9yG1RfXBpeDz7SFVGe3hd3I4a118o6tx6Ejl9kWW0mtnXHDoJ+TaUeYOt9g0ZmYErTtjV52uNu5MoWD926kWFy64MMa7s76pEXK4vzVe2JwoBrmueni+iGSjXuC5vqSwDH6+N3HIt9ksU0p5rlEuz2se4h8/swH+JFsq7pwn9JFFuepbeyjEhSWHGqYe48g1i3sGr26K54va4uKF5VxYHp6rZFFMpGWm+N3HvvmMkdEdmwW3s+mc1zVY+BrL/WTiywI/JFhZueCqqHyJ3nDynXmz01gLX3BZoyl/xul3012VTPsGIrr3/yK2MQVSepMkYYrLNVAjxwpaU3ZKDZKjyxBPRPGQy3lZV5R4oOJltb+mtTbY+rTIiwCpOVQa3q+hy9vMizZUt5i7T5fYQHHia878xNZTQVExd+Hz1DAyWSeH0JxcEmQ6CcinIUVEkMHB5KcEv/T63V2npGQ1Bvh0n8MhOcDKW0lFH7RDtgpxCPgqFfvanEVo+cf/gCOBkDQ= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB5121.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(136003)(376002)(396003)(39860400002)(346002)(366004)(451199018)(54906003)(316002)(8676002)(66556008)(66476007)(6916009)(4326008)(8936002)(41300700001)(66946007)(38350700002)(86362001)(36756003)(38100700002)(6666004)(6512007)(6506007)(1076003)(186003)(26005)(966005)(2906002)(52116002)(5660300002)(7416002)(83380400001)(44832011)(478600001)(6486002)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 424KdFPL4lkEpiqAr2egW7yTREv8QTJlVKbwE2ClSfrmAJQKc3fr4G9n/csLzLB03B7OU5hFn6z0vih2GMMTTzyxfFnIBKAa3wp0nPvaMkWm7Rm7GtqG68iu8YAKchm6eMP2pcmt3aSOrmPB7ovGDCf9MIxxk4jpZA5ezeKaczGhRIHMR7AK1oncKqO3CR8X5z99Z9BmEhu8IzDf7uFo2vke6/3YCilEgmkZEVxlXj+K8MfWmCZvFSD72G2r6UVVbT1nF7oYm7R4dVvSzxdi3FUrKWfBrlMTjVHkr4K7FpygBlE4IRqj+pMOoB8o2VrtTIkRvm2TboFX9SRGjxnY7aVU+eI5V0jEGpvFXlDMaaAsNDcRhaR0RRm9gihxXTxNMeP5L+GM6ZpaCmgAOaH/m39NMjMhkt3EA8bzGQV5kBQg+RfgiNYoNbH6frJZ476xWQFNRPVWEDjZV80pNkmJ2039Y1IiaxbgpoNt/KjwYNpOHEw/SWaKcrVpae40SjLxFXyQm9VtlFbTRwzH/kIaZbssLS3xhzLcbSX67uX3mrYsDWP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X-MS-Exchange-CrossTenant-Network-Message-Id: 01156a90-22bf-4e7b-7613-08db07826787 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5121.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Feb 2023 14:08:06.9318 (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: VRh21KfJ6BnixRAsjaUjbZqDNZTmGmVGC1WunK/LU22ljK2WRFEm+L5Rv6EdgKbWHTkjSQjFa4qVNhosnW9Ing== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB9142 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230205_062329_135109_B3C9B6BC X-CRM114-Status: GOOD ( 18.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Frank reports that in a mt7530 setup where some ports are standalone and some are in a VLAN-aware bridge, 8021q uppers of the standalone ports lose their VLAN tag on xmit, as seen by the link partner. This seems to occur because once the other ports join the VLAN-aware bridge, mt7530_port_vlan_filtering() also calls mt7530_port_set_vlan_aware(ds, cpu_dp->index), and this affects the way that the switch processes the traffic of the standalone port. Relevant is the PVC_EG_TAG bit. The MT7530 documentation says about it: EG_TAG: Incoming Port Egress Tag VLAN Attribution 0: disabled (system default) 1: consistent (keep the original ingress tag attribute) My interpretation is that this setting applies on the ingress port, and "disabled" is basically the normal behavior, where the egress tag format of the packet (tagged or untagged) is decided by the VLAN table (MT7530_VLAN_EGRESS_UNTAG or MT7530_VLAN_EGRESS_TAG). But there is also an option of overriding the system default behavior, and for the egress tagging format of packets to be decided not by the VLAN table, but simply by copying the ingress tag format (if ingress was tagged, egress is tagged; if ingress was untagged, egress is untagged; aka "consistent). This is useful in 2 scenarios: - VLAN-unaware bridge ports will always encounter a miss in the VLAN table. They should forward a packet as-is, though. So we use "consistent" there. See commit e045124e9399 ("net: dsa: mt7530: fix tagged frames pass-through in VLAN-unaware mode"). - Traffic injected from the CPU port. The operating system is in god mode; if it wants a packet to exit as VLAN-tagged, it sends it as VLAN-tagged. Otherwise it sends it as VLAN-untagged*. *This is true only if we don't consider the bridge TX forwarding offload feature, which mt7530 doesn't support. So for now, make the CPU port always stay in "consistent" mode to allow software VLANs to be forwarded to their egress ports with the VLAN tag intact, and not stripped. Link: https://lore.kernel.org/netdev/trinity-e6294d28-636c-4c40-bb8b-b523521b00be-1674233135062@3c-app-gmx-bs36/ Fixes: e045124e9399 ("net: dsa: mt7530: fix tagged frames pass-through in VLAN-unaware mode") Reported-by: Frank Wunderlich Tested-by: Frank Wunderlich Signed-off-by: Vladimir Oltean Tested-by: Arınç ÜNAL Reported-by: Arınç ÜNAL Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- drivers/net/dsa/mt7530.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 616b21c90d05..3a15015bc409 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -1302,14 +1302,26 @@ mt7530_port_set_vlan_aware(struct dsa_switch *ds, int port) if (!priv->ports[port].pvid) mt7530_rmw(priv, MT7530_PVC_P(port), ACC_FRM_MASK, MT7530_VLAN_ACC_TAGGED); - } - /* Set the port as a user port which is to be able to recognize VID - * from incoming packets before fetching entry within the VLAN table. - */ - mt7530_rmw(priv, MT7530_PVC_P(port), VLAN_ATTR_MASK | PVC_EG_TAG_MASK, - VLAN_ATTR(MT7530_VLAN_USER) | - PVC_EG_TAG(MT7530_VLAN_EG_DISABLED)); + /* Set the port as a user port which is to be able to recognize + * VID from incoming packets before fetching entry within the + * VLAN table. + */ + mt7530_rmw(priv, MT7530_PVC_P(port), + VLAN_ATTR_MASK | PVC_EG_TAG_MASK, + VLAN_ATTR(MT7530_VLAN_USER) | + PVC_EG_TAG(MT7530_VLAN_EG_DISABLED)); + } else { + /* Also set CPU ports to the "user" VLAN port attribute, to + * allow VLAN classification, but keep the EG_TAG attribute as + * "consistent" (i.o.w. don't change its value) for packets + * received by the switch from the CPU, so that tagged packets + * are forwarded to user ports as tagged, and untagged as + * untagged. + */ + mt7530_rmw(priv, MT7530_PVC_P(port), VLAN_ATTR_MASK, + VLAN_ATTR(MT7530_VLAN_USER)); + } } static void