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: 52905 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1794145wrn; Sun, 5 Feb 2023 06:20:19 -0800 (PST) X-Google-Smtp-Source: AK7set+5jvotjyU0pandJ5E9gsgvLi8gHa2f9eNR4kWPkuq94Inv9hAUf8azG+3aUbl+AST/cpsI X-Received: by 2002:a17:906:5054:b0:878:7eb7:3488 with SMTP id e20-20020a170906505400b008787eb73488mr15369685ejk.21.1675606818969; Sun, 05 Feb 2023 06:20:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675606818; cv=pass; d=google.com; s=arc-20160816; b=Nlrq6Pfpo2Llzirqwa/OzNT6gFW1bG5G5bcVaLj36ChFamsJFOSET7wOCJJeQh3+cX Z4co4q8omE5WjT9Lgn88QKj+sU8LGRgboIAZZBo2XL+t6O7yerzR6n01+Da40n4Begjv +3kqwH35rhwRnyzOmQdjUclEzPmmSSNHYDa8xSQuDx+JMyUaUpzTHAstFo2LBa1md584 WkkD+BvuQcK2wgC+d0b/G5PcTKUFNEWDX9I/ILya9wnG6+vJ7+pWfiklzSl+dUxpmbpJ oLpjLOEjg+c/wEhVHGTAXVWBandl6kO53CDQDfsL1VH48Df/ziwII5kKN6TlRBbsoN46 M+zw== 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=Jxxr2yQ5S/NthU3f8DVdtDcg4i5m1zYwVRueFbsz/zw=; b=FwiXZjDcogX/f7BWGykrk6mCZCo/GEjUy2uCDMp1HW42T8sO+CFMhxNCBRmUK5RgoT iolCfskXLW+Msw6DDFu5hOANgXSyNUaqbZgH5QNBI2lEr9xmvfzYZw/WsXNmwtNmwU4F NRmlsRV6vYzOWie+69oDrk1BsUiG51Kp1u+eJi1SuytCsIOmg3Xy2uxEEvLgORnvlUvs UYF7Oz8HwBDKoiR5tvYKnkKowTxeNTMR1CucNOcN3XUTniVHrTqVMMq0Fo8id4dT/3DZ QHqPny9w3a550ht93n6DGtZ+x5l1yQcMcBIDC49LEPChSpzTlWiFvkQZcGjew52QUul4 1qsg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=cMzbZyic; 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 e11-20020a170906748b00b0087bd6ca2cb2si12423902ejl.372.2023.02.05.06.19.50; Sun, 05 Feb 2023 06:20:18 -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=cMzbZyic; 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 S229734AbjBEOIU (ORCPT + 99 others); Sun, 5 Feb 2023 09:08:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbjBEOIS (ORCPT ); Sun, 5 Feb 2023 09:08:18 -0500 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2048.outbound.protection.outlook.com [40.107.6.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EDE91F918; Sun, 5 Feb 2023 06:08:17 -0800 (PST) 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/kIaZbssLS3xhzLcbSX67uX3mrY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xp.com 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-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?1757001096095952060?= X-GMAIL-MSGID: =?utf-8?q?1757001096095952060?= 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