From patchwork Thu Aug 18 13:52:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12947119 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 520D5C32772 for ; Thu, 18 Aug 2022 13:56:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245333AbiHRN4M (ORCPT ); Thu, 18 Aug 2022 09:56:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245441AbiHRNyp (ORCPT ); Thu, 18 Aug 2022 09:54:45 -0400 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2082.outbound.protection.outlook.com [40.107.105.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C177748CB8 for ; Thu, 18 Aug 2022 06:54:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KNpXucNfutHshQMdCFUBVWEKQUZ5W5mT8UgH0R9i21CY0yGR4fuds0aBg0yvIA9WDrVjba8JeNX1D8hQxftBHLJroARzTkH3M9/FtNh6qhRUTte+W/EBox768VRKn1yuAg+0vLExD7kp1+zuR5MDCFVpUtuQ6qcmOqup7/CFeKbCTD5pN9gk54manO/znqrWITr4xXiZ4bH2/05b07xkCUzJG4ySrZ8F9VybbD6UHHYvlQrlfXDzQu7L5SLobwy0plTzc071IFJdnP5uquYNezG53LZV1Iu3u5fFUYvKr7zF7PlTCmvJVl2u9aU9xmnf0FogxQKivbk2a53I043Gjg== 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=KHVdB2ZhTs/doedGL+2YYe9oxrYb5flL3/o8zc9of6o=; b=Ql7iEsF6pfzEvDc1bFw6SDmfYyaUjL8mcwDnQ+B7FV/vS3xrwLPU+a+a0yeogkIY1ZRIE6U27E2NeQ2TA2hjtvLQVzjXX99aCU5YuI0z3kI+SXi8WIzklC8IDbNQP1k8HUGmi7j2smSYVGC0wqNpPmRl4OZsbUPFM8WwZq9UegxF+cNxA7RuhJ4hA1D/Tz2hbk9a56AxxlK9Bs1GoK+/bcb+MYVRtiaNANtJEK94xT5Y8YwQBElRKQ0SMXKr7jmNPWVkVyYYat/8tq4L9gpTBdv7xaGgKTZjD1aHODBKlAvGJbhYZmgQ4ONTKCEb5wVCv058vQgpVMTPIVX0j/+XVQ== 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=KHVdB2ZhTs/doedGL+2YYe9oxrYb5flL3/o8zc9of6o=; b=YNiHo5YwTE8FIIe3blpbEnZ58n7y4WhuXgI89fgKD3+C3CFQ65GvhwQZRM++ZgMQ4/lA6HQVQtKNQ0CE4peMGzNk9TL7TNlkrGrJ2XGhLwNNJMgOSwhnKFEAwNg4Fiajj/ILk1+Zhz6v6nFnA9fP3jSE2XfX8mM5PpqESHMLpYA= 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 AM6PR04MB6088.eurprd04.prod.outlook.com (2603:10a6:20b:b6::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.28; Thu, 18 Aug 2022 13:53:43 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857%4]) with mapi id 15.20.5525.011; Thu, 18 Aug 2022 13:53:43 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Fainelli , Vivien Didelot , Andrew Lunn , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Colin Foster , Roopa Prabhu , Nikolay Aleksandrov Subject: [PATCH v2 net-next 9/9] net: mscc: ocelot: adjust forwarding domain for CPU ports in a LAG Date: Thu, 18 Aug 2022 16:52:56 +0300 Message-Id: <20220818135256.2763602-10-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220818135256.2763602-1-vladimir.oltean@nxp.com> References: <20220818135256.2763602-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM9P250CA0017.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:21c::22) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 18b2abe4-6edb-4d24-6f39-08da812103d8 X-MS-TrafficTypeDiagnostic: AM6PR04MB6088:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KdS6RIXDwXDnY1DLGzw5xhmkrJWYTUtyEJxrSXpjcmUu7Sb6BgmwpEuIlqu0kpxytzUyPlmN/d5hTaAYpWj9pDE9d1aVH4fxu4OvJvf2z6Pfnqb5tWUedDal7ja8TDFXsIblCPBgdrvWBZpCutHuCahWvKlo4vHddzKV9Bk0cT9EyR1LZ264Oxy5zNjyQND8N7cvTWC472qWvuDg2oCD0veYlOU1S5B99hTmsgb9+oi+kcK/E8WNOYifxKEoC6vZcm3fRxKhnfBG6LXTbXLOH4cmc6gVsp0fEEz2zIqcAauFAvrMK5H0jpE8FpkG37lEQ+7gFRxI5HHz6dY3WQrASexdHXNSyAdB4e3ar6v5AXSgBgTRO3xO2yNMinCltKT2fu8fU1St4yILYhy91wtnJd63r+9BxR6zCvrjCNok3zXL5COgrmTKlLuc5TjWghhWn7Q9nTm19ko7NREGCCrJ6mPh4PQpHShDwzbNfPbkx4pUHC8yv5xEFkokBDw0dV0YHDVHpXKlJv8v8gg8kmuQgFxDOoFs4VCMIwDSI6NJ43nM90quhwxGe38iiWZAZzjUM166ix16v/0dL6leahBQVU1bwb/0hEKjfEwHnwgeeW2+mJ2HsR1IS7Xjp+PB5az8JMc2Pgg0L1+L3QoapiHrKFuAxCAtJyb+/Ly/+cA5aBpvQ/YmdXS39ypvPo8MzfyzA8FWlo68OxLMr1plhOpNOff0lO4+1dBD8fbmzsNzNg/laPWelA+PmYmoiIyfVVcz 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:(13230016)(4636009)(136003)(366004)(396003)(346002)(376002)(39860400002)(66476007)(5660300002)(6916009)(4326008)(54906003)(66556008)(316002)(2906002)(44832011)(8936002)(38100700002)(66946007)(8676002)(38350700002)(7416002)(36756003)(478600001)(6506007)(52116002)(6666004)(83380400001)(6486002)(26005)(186003)(2616005)(6512007)(41300700001)(1076003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RK3h2RXykHo2uhIb4to6hjYnfBO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lMVpi13MP8bbFwzBDx820vgggWxbXB4nx5uwx9rRZ5eV0RqsT9TsSHiH8Enc4S58VS8rKiToSgJdQdVln9wx1W793FKZvAzwfxVj8y5CnXDui5y3f4AnqzFj2JwcGCYVbdYMNhO0sTFN4d8XxfQ+zu+SaXfYEvp+vyQJ2XVHW98xcPRFnZh0M8kxSTf4rc63UI6xlMyhFammz2DKKVZbLUf1WpTItamd5gPvI+MmJDP/xOqkhoZdxlfnaMTYNNUreGSusy4UHxY/gIXddTYIe09VfzmVVcB8lDPh9LTiEFbtmduXPZmv5lpORDmwLbSh5FYTrqO7hnCWOsbCfZd2aDrFdc9ZzPO9xXlQEab8uYG5CiC7xX/Zy5e/EdJoWxII5fPWtMxH7vnfVzWmQPQgIbm8IfKzg3tSeQ8uMzb1QEpK366MFCsBmLz9halixWaXE7I47ih9ruv+zqXx/iOj2A5OgCmfHMICUIBcA93b395nXpOcYCkIJmzhCvirA+ingBynI3xli0wOgZq8+6ZQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18b2abe4-6edb-4d24-6f39-08da812103d8 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 13:53:22.6797 (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: q5xqNhVtsQAmCxrKqUUxCyPvfAK0v1u74GfJbpsuAd92w1UXMoE7ICvB/1/X4GLrXUOv7KDRefWXADGXe1uL/g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB6088 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Currently when we have 2 CPU ports configured for DSA tag_8021q mode and we put them in a LAG, a PGID dump looks like this: PGID_SRC[0] = ports 4, PGID_SRC[1] = ports 4, PGID_SRC[2] = ports 4, PGID_SRC[3] = ports 4, PGID_SRC[4] = ports 0, 1, 2, 3, 4, 5, PGID_SRC[5] = no ports (ports 0-3 are user ports, ports 4 and 5 are CPU ports) There are 2 problems with the configuration above: - user ports should enable forwarding towards both CPU ports, not just 4, and the aggregation PGIDs should prune one CPU port or the other from the destination port mask, based on a hash computed from packet headers. - CPU ports should not be allowed to forward towards themselves and also not towards other ports in the same LAG as themselves The first problem requires fixing up the PGID_SRC of user ports, when ocelot_port_assigned_dsa_8021q_cpu_mask() is called. We need to say that when a user port is assigned to a tag_8021q CPU port and that port is in a LAG, it should forward towards all ports in that LAG. The second problem requires fixing up the PGID_SRC of port 4, to remove ports 4 and 5 (in a LAG) from the allowed destinations. After this change, the PGID source masks look as follows: PGID_SRC[0] = ports 4, 5, PGID_SRC[1] = ports 4, 5, PGID_SRC[2] = ports 4, 5, PGID_SRC[3] = ports 4, 5, PGID_SRC[4] = ports 0, 1, 2, 3, PGID_SRC[5] = no ports Note that PGID_SRC[5] still looks weird (it should say "0, 1, 2, 3" just like PGID_SRC[4] does), but I've tested forwarding through this CPU port and it doesn't seem like anything is affected (it appears that PGID_SRC[4] is being looked up on forwarding from the CPU, since both ports 4 and 5 have logical port ID 4). The reason why it looks weird is because we've never called ocelot_port_assign_dsa_8021q_cpu() for any user port towards port 5 (all user ports are assigned to port 4 which is in a LAG with 5). Since things aren't broken, I'm willing to leave it like that for now and just document the oddity. Signed-off-by: Vladimir Oltean --- v1->v2: patch is new drivers/net/ethernet/mscc/ocelot.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 7d350c944521..af46ea385c31 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -2046,6 +2046,16 @@ static int ocelot_bond_get_id(struct ocelot *ocelot, struct net_device *bond) return __ffs(bond_mask); } +/* Returns the mask of user ports assigned to this DSA tag_8021q CPU port. + * Note that when CPU ports are in a LAG, the user ports are assigned to the + * 'primary' CPU port, the one whose physical port number gives the logical + * port number of the LAG. + * + * We leave PGID_SRC poorly configured for the 'secondary' CPU port in the LAG + * (to which no user port is assigned), but it appears that forwarding from + * this secondary CPU port looks at the PGID_SRC associated with the logical + * port ID that it's assigned to, which *is* configured properly. + */ static u32 ocelot_dsa_8021q_cpu_assigned_ports(struct ocelot *ocelot, struct ocelot_port *cpu) { @@ -2062,9 +2072,15 @@ static u32 ocelot_dsa_8021q_cpu_assigned_ports(struct ocelot *ocelot, mask |= BIT(port); } + if (cpu->bond) + mask &= ~ocelot_get_bond_mask(ocelot, cpu->bond); + return mask; } +/* Returns the DSA tag_8021q CPU port that the given port is assigned to, + * or the bit mask of CPU ports if said CPU port is in a LAG. + */ u32 ocelot_port_assigned_dsa_8021q_cpu_mask(struct ocelot *ocelot, int port) { struct ocelot_port *ocelot_port = ocelot->ports[port]; @@ -2073,6 +2089,9 @@ u32 ocelot_port_assigned_dsa_8021q_cpu_mask(struct ocelot *ocelot, int port) if (!cpu_port) return 0; + if (cpu_port->bond) + return ocelot_get_bond_mask(ocelot, cpu_port->bond); + return BIT(cpu_port->index); } EXPORT_SYMBOL_GPL(ocelot_port_assigned_dsa_8021q_cpu_mask);