From patchwork Sat May 21 21:37:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12858041 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 1CEDBC433EF for ; Sat, 21 May 2022 21:38:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346688AbiEUViG (ORCPT ); Sat, 21 May 2022 17:38:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346622AbiEUViD (ORCPT ); Sat, 21 May 2022 17:38:03 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2066.outbound.protection.outlook.com [40.107.22.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4489552B37 for ; Sat, 21 May 2022 14:38:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iQGr0E4ttP3wgEe5b9KUZNa/Jn83/ifTFZlEles+E4qdo3gSLGObE+vRVwhfFw5SBnOAPFVxjptZqATfRwlL3GJ5S91F42eTNOGgBr/+9decbyj2dpP3iNuKvs8sVRr1JPZHfHaH+QeAacujtSYjAU4ZBwgTjr6Fc4GrYJHqiyyzTeslDnjNK8TIwPoJqoFuFCvxFE6IP1+aFx5zpTochLjRoIDiKZfetcoqrMoe9AGFy/MGmqoxi5011mApZciX5X3xUm4QeeNWfYPikZvKlYDMAUsKEgFMNlEK4j9aT4mZVeTlb0XvAB3qL/+xyY5bhDhGPhS5xczxCZLu6tQ84A== 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=sHHaPd4FmBCV6rapFMDun+drIxR6g+mTOGqd1IaAYIg=; b=ETmH8GZyLPnQXE6H+Qg6NZseCOMjUIrJwjiQSvg2CITXMU75WFFbSvloos8QoG1xjnWIcsqjmizwpxOloVIQgbtX85i+FqAWct9js4jLvU8s2vgOyuygyf7b/7+uRftIJyp2QpfJZp7sKiWJVU1Vd+whiBHMatYgE7uzSZq/V2FR3jwwD+npnTbRoMrLgzq9OlTEeGWMDioqtbSCGXAIXew/s66Ur9Ao8kz0cAny2CFJWSL6RZ/eUwG3rJyRo9D9g478h7ZAacXQrDgmVxUPANXn2YYzHA8YhbCE+dWpwmtvWc+ZBNTdJSGb/+caeGtN4rP0OgajEEaUCZvd7ZfaOg== 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=sHHaPd4FmBCV6rapFMDun+drIxR6g+mTOGqd1IaAYIg=; b=cjmxLJL4BaHN8RKtvrTYf524cFg3H/M7bFo0ipraQQS5QTbKBdydzIo9ThEW0mCJrC57BlC5ajb4+6nAFbZ38Kyq73N0fRKdKdrjKahoY6+BjHBVj+n4w4YCNZfUFWYjJV45PYP/4Alc51P4h0Dls4SfGpKAac0opUOk58AEfvI= 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 AM0PR04MB6275.eurprd04.prod.outlook.com (2603:10a6:208:147::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5273.19; Sat, 21 May 2022 21:37:59 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::fd1f:cc16:dafe:4bf5]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::fd1f:cc16:dafe:4bf5%5]) with mapi id 15.20.5250.014; Sat, 21 May 2022 21:37:59 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Jakub Kicinski , "David S. Miller" , Paolo Abeni , Eric Dumazet , Florian Fainelli , Vivien Didelot , Andrew Lunn , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Colin Foster Subject: [PATCH net-next 1/6] net: dsa: fix missing adjustment of host broadcast flooding Date: Sun, 22 May 2022 00:37:38 +0300 Message-Id: <20220521213743.2735445-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220521213743.2735445-1-vladimir.oltean@nxp.com> References: <20220521213743.2735445-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM6P193CA0079.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:88::20) 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: 21853cb1-22d8-453a-a3d0-08da3b722c9b X-MS-TrafficTypeDiagnostic: AM0PR04MB6275:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sgkm9TrpAaJkhLrWJP8fgBl3h9zc0PZN1rTIGkBh0BpJ6soczhT+A2HtgFwD+36MtHOLCWEnWJjfTaTyiMd9BVuRwBTAZPAaFj2vzR0mPpNtDGu3MUnZjU6rzZpKXdWFbAWVEFhhbtMI6DT3cjWctOHFuiM0Q0s4HDEqJEJ7DRadYZJ2U9NFCVrwPBWrhLvjVnF0oXgx4ofG+CqSIh/N5d+fzQ9TbG/oMayihgSFFSmj8dZS1kEpwjcKE63+JkME81+UKt0jVA4LU79ahAULsglLT+yOR7Rc4qb1YLBeucBJqWAxpfS62EF6lVO7uOsUkV/LlKZIl2GArR1i8l/qUPzRqNlN0Bh6qSIoTgHp1YhzAdphEfz2sXBYNdkjpOZtOp71JR0mkL7ENtDFZGZmhBTCvVbDOgDJ3kV45mRXXtxDasFTpKSX+h7exWxAuOV+/SeAL6ZeoKZgneXhne45IL1KlvBkA2t7eIR53/fC1jTxHI6dZWeChYsB5rkQqRdVTnIm/bKR7pBvdxQViWTDHRnRYNd1aheYCrscbeoL9LIeqEpVVuf/SAJAmVcN8dKrlTQ05ZRyrWBJM6ANjxp8cU2rZ0gBwl1gjUJPTXR17N0wCOZwq5+dVw5G5NwhvBgTNXSWXbb1DFTVV0XsFr6y6W92umMi3+2ZjeAi4k4byzposkZdHMhaCbkna66wyll3MylGc1qXEc5VEXC8RliPqQ== 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:(13230001)(4636009)(366004)(6666004)(86362001)(26005)(6512007)(6506007)(52116002)(36756003)(2906002)(6486002)(8676002)(66946007)(4326008)(66476007)(66556008)(54906003)(44832011)(83380400001)(7416002)(2616005)(186003)(508600001)(38350700002)(8936002)(38100700002)(5660300002)(316002)(6916009)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AQC47HrnfGJl+MOagv24tbFs8o2XmT6tMS6HliWTR5aq3GMS2y75il2pgWnpkhYVqKymxhrkwh/fz8LsW2DT4Ovj+ZGBFq72x8wY4LydLIySEIgyyRhWSt21LOpL96bUzYBAC40Gp6Jsj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I/g/mSNLoi4XjP9/yxfPKMXatT689NuwfNlSsukFRAsq9hLnoeiBj7kST6uEEsRKsimpimgeAo0ErUHc6mkBBBwtfMaj/hDwS1HcmYpBxjHH+1u01yMkkDOA3Lsd+Y2Nf15z1VZxfOjLYfvLZwlNee7KdXkNelFrwfme8/w2oQ0t3zhmOVKyEQNg11VR8wU11xzVy8p8UmkSgluNExdLzqe7kIcdwKgkJ+vHHTLVkPxjkZG4HyltHwGK9O7HJOnq/rrCwcfAoAJttAu4TSeTTFk2rDDdj6yeuaDQ4alIMa1CTxGrFTJwqnh4CB1XYI2A8bhddrZhHxNgxLAjlr5kKyzGQ973bNdXF48WMep7bCgLbET1X8Dk6+6jZrXfw9tj6jLpX3J3rN4JJ0RRqnwSCc0UNvpGFAhqttJNYJCtAykahuJsEXFqBX3BcJBevjk55ZG0DaiSeGz5Indcp5enZXlioHaw64SSoB8BOc6cFLlE39Lt3wU7vQA6EDJtE+CykaItppEs/KQAENRI5+AHztFXbQ5yB23BHNS9v09ki8XTY= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 21853cb1-22d8-453a-a3d0-08da3b722c9b X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2022 21:37:58.8929 (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: /LI/gbznlXzHm1jXHtJ2YWBFtKXXKekw975IJkRa2zqVTpBJxavYA+9cpBRKwPeZvTK1eKY8SuUmpVM6FUwIoA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6275 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org PGID_BC is configured statically by ocelot_init() to flood towards the CPU port module, and dynamically by ocelot_port_set_bcast_flood() towards all user ports. When the tagging protocol changes, the intention is to turn off flooding towards the old pipe towards the host, and to turn it on towards the new pipe. Due to a recent change which removed the adjustment of PGID_BC from felix_set_host_flood(), 3 things happen. - when we change from NPI to tag_8021q mode: in this mode, the CPU port module is accessed via registers, and used to read PTP packets with timestamps. We fail to disable broadcast flooding towards the CPU port module, and to enable broadcast flooding towards the physical port that serves as a DSA tag_8021q CPU port. - from tag_8021q to NPI mode: in this mode, the CPU port module is redirected to a physical port. We fail to disable broadcast flooding towards the physical tag_8021q CPU port, and to enable it towards the CPU port module at ocelot->num_phys_ports. - when the ports are put in promiscuous mode, we also fail to update PGID_BC towards the host pipe of the current protocol. First issue means that felix_check_xtr_pkt() has to do extra work, because it will not see only PTP packets, but also broadcasts. It needs to dequeue these packets just to drop them. Third issue is inconsequential, since PGID_BC is allocated from the nonreserved multicast PGID space, and these PGIDs are conveniently initialized to 0x7f (i.e. flood towards all ports except the CPU port module). Broadcasts reach the NPI port via ocelot_init(), and reach the tag_8021q CPU port via the hardware defaults. Second issue is also inconsequential, because we fail both at disabling and at enabling broadcast flooding on a port, so the defaults mentioned above are preserved, and they are fine except for the performance impact. Fixes: 7a29d220f4c0 ("net: dsa: felix: reimplement tagging protocol change with function pointers") Signed-off-by: Vladimir Oltean --- drivers/net/dsa/ocelot/felix.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index d38258a39d07..78c32b7de185 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -534,6 +534,9 @@ static void felix_set_host_flood(struct dsa_switch *ds, unsigned long mask, ocelot_rmw_rix(ocelot, val, mask, ANA_PGID_PGID, PGID_MC); ocelot_rmw_rix(ocelot, val, mask, ANA_PGID_PGID, PGID_MCIPV4); ocelot_rmw_rix(ocelot, val, mask, ANA_PGID_PGID, PGID_MCIPV6); + + val = bc ? mask : 0; + ocelot_rmw_rix(ocelot, val, mask, ANA_PGID_PGID, PGID_BC); } static void From patchwork Sat May 21 21:37:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12858042 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 1C7A5C433FE for ; Sat, 21 May 2022 21:38:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346779AbiEUViJ (ORCPT ); Sat, 21 May 2022 17:38:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346686AbiEUViE (ORCPT ); Sat, 21 May 2022 17:38:04 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2066.outbound.protection.outlook.com [40.107.22.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D4F6527F0 for ; Sat, 21 May 2022 14:38:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aYA8b0J0Ocm9yDJXgW5/aoOYXmcbniobmKw2xopwmYEMS1GZamqFwtEQCderiGKkQHAT8aCNOKqYe8i3KmsdpOXwqSMM/8jZoWQ3MitOMfnu2QvLhnGiMHNiBQgoIRBGQbZTXxkkoF7RnFhsDX18Y1rlO1E22sfBqDuK/i9PXTQLf6lL72KXsW2mAh55gI8atOH/S4uFaVnOgmRvKCqLp1fJOoriNo8wWNgmCkewbYHbLhUH5m5GLBbUOMSjhXPgkwhviHtzblM98DUDUR4WaekaEuEpHcSxoqROf+7cMdfsj6WreXvpX5w8Qt55xhFF0QzRDDdYjOb/yuRMt7KrgQ== 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=9zT6ne/QRMR/gkZyrn2u+CqZkdgijeoRgil493fcCwU=; b=BToKY125FwdPadOV716lHKO4uUXHKTnYClgH4eSmyHkHD7DX+ZsxCi4KLLsBmkwk88KdOrLxPSCE1txL1y7uYQQNum3o3JPrN2kKNNSES6vuZE5BXYVtDFlOM3jBbCW4ewTLJJXkJYRJd3t33q88zzGKOr/2os3a7Sfy83XG8HHFu5RGeMgn7QzH/45/v2bmQc4jgLihy6WyHMlR57WAiBmO0AIuXY0BJL8LZtDDHVc+FuBjqMPAGb00JevWOx5vcD/ttmYZzW79p+cQjC3ROPW0Ei5sVMGbmkTcciPKuYnNFWI0sQ6u98mmfWnMcCrjed04tdM+qab1lylN2ub97g== 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=9zT6ne/QRMR/gkZyrn2u+CqZkdgijeoRgil493fcCwU=; b=so25qgMj+vrDocSfzCJDl4kciR8jY2SzimM4N2f7nBiYPby7RSp2z4sOgXykyUM0APeiiMtaMiwXQxYGoReRjaKTB/Y9QLENg95NXVLVkHWww7B4T/CkcEWgvb+ypshqGEEQwmDPPnX2H6E9tXe1Y2W6XyqN67mvm0er5bRNkEE= 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 AM0PR04MB6275.eurprd04.prod.outlook.com (2603:10a6:208:147::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5273.19; Sat, 21 May 2022 21:38:00 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::fd1f:cc16:dafe:4bf5]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::fd1f:cc16:dafe:4bf5%5]) with mapi id 15.20.5250.014; Sat, 21 May 2022 21:38:00 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Jakub Kicinski , "David S. Miller" , Paolo Abeni , Eric Dumazet , Florian Fainelli , Vivien Didelot , Andrew Lunn , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Colin Foster Subject: [PATCH net-next 2/6] net: dsa: felix: move the updating of PGID_CPU to the ocelot lib Date: Sun, 22 May 2022 00:37:39 +0300 Message-Id: <20220521213743.2735445-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220521213743.2735445-1-vladimir.oltean@nxp.com> References: <20220521213743.2735445-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM6P193CA0079.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:88::20) 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: 321eb2ca-c1c0-453f-a859-08da3b722d87 X-MS-TrafficTypeDiagnostic: AM0PR04MB6275:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XkKzcc5rkb6PfbVutGDe/umu4q9H0wEQUJs2h9UmKq2TeeiI5Gs3uUDQzCJRDM5GerLLSt1b5VJRBjiJRP4J7PAjBF9tSQV80ZYRMRdv8UIkG06eY33tHodc2pIK4jX+WVQ4doGZmTD2dEO/7Aganew57GBB1S7i+A8rsCqSjVeMnc2cMLy6pzAGwkTIm2LFKRgen4bAzwUv9stfF7/HuD7NChKXZs7KtlPNaOkg578R1PIsctQdOu/NAz9JzsZdwRKr9YtJ876XQFf+d7csWovPMadmcMsUpxg4O8y8eK0Y/HDisV2KRch8igsObFkkLRSn2BkB6K5SqRoENEd345rYyv5WHXLhtPOi7As5xJNoaRu6m18jMll/7j4k9WpsfsKvclhF4MSRQQ/4fdaI0V7j6HJ2x90XqL9yXrEyrLR+7iF2oM6CpG4Sd9DOPHwVYzWmEBOUqD95/8Mt0RPRbWPcwkYrNTnwC3aR+7fO0Y38rNluoDtLAZyRkM5LMNZ4cJvDD0DH+SvZATPUunBTewaa1d0guyDsk5R5pp4yLhCr8YjqQlb69C2wRfSkBM2BblH1utKvpax9PnKNX3xXoYVFWHGpzc6I+cotbB9kiYYzO+2BQCuax2plQnDCROMkfSOYJvnuYRCR4632nr87idezixbuSFcl/GPTfmGh8Std/7agNmGYr7TQD487gI/XFf7jzNLGJCmZ/gWZHIkEyw== 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:(13230001)(4636009)(366004)(6666004)(86362001)(26005)(6512007)(6506007)(52116002)(36756003)(2906002)(6486002)(8676002)(66946007)(4326008)(66476007)(66556008)(54906003)(44832011)(83380400001)(7416002)(2616005)(186003)(508600001)(38350700002)(8936002)(38100700002)(5660300002)(316002)(6916009)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WP/zHdY6XvI3VM92Gm1If6AJDImZbnXYTxLF36W1XH7Y33XUEw9yKVqW2sDM7hTLqJKNelK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k7a+cLNVg5ieUgTnseUtLeKYJVYKsAlPTJpfPx6Kqj9MZc/rsUgm/tw10pyH9Jav1bDlygxZizzdNrj+BwqkxkYhsjMNHp4D0BixXU0S0OKH+jEzHMQIVTMkrCsMswNKLYQkYXtDtuvPgWO1MiDh9AjDCp4fLWdW11Ck1rNremgGd2A3u/dHRoNBmjKHvMND+zimT71vlFN/WVOOBhrFlztvddQbbSldBz9OQHrxNM0a+ebLU/7eNlrRs1DoLzRJxAqBNn8Gtjqj/ViI+v1Z5WYmE8ljoVNcfiPHq5Bs0DiDiNo2UaTqA492061e9QDusQjFLC1U6bZfAA2gZqbI8Xz6YeAV9VwsXCuAcpDDij3okciVFin9giezIBHesfPVKoO18HOSlDTf0iKcCWY/zUhUGyIkfcbDhMl+ErgDBs8z6mZSUhINI7TFm5LWRcVxY/Dk82cGrSuL4jmiiYoDKx6vjPihlRWG5O+/1B6LdJnrNK9kunPZLWzui2E/wgysd2Sv7oAtUTxg4xp5vwuRKWrjS/3JnQ67dmXJCAgGbf1PpL1BGQlBo6+l4n83w1YfHzMMo5l5a8xajfRBhF1iU07JzZGz2yZPt0IWpDY/0Cqfo8= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 321eb2ca-c1c0-453f-a859-08da3b722d87 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2022 21:38:00.4084 (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: G8syNKZMFXrrGeSdMGKOj2wmvwxN5CCYGfmJ+LEFFQd8S1603w0UIcVzzOKGuGcEwrhfpZXy+b3ZX0XAugjbsg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6275 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org PGID_CPU must be updated every time a port is configured or unconfigured as a tag_8021q CPU port. The ocelot switch lib already has a hook for that operation, so move the updating of PGID_CPU to those hooks. These bits are pretty specific to DSA, so normally I would keep them out of the common switch lib, but when tag_8021q is in use, this has implications upon the forwarding mask determined by ocelot_apply_bridge_fwd_mask() and called extensively by the switch lib. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/ocelot/felix.c | 7 ------- drivers/net/ethernet/mscc/ocelot.c | 31 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 78c32b7de185..1299f6a8ac5b 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -253,9 +253,6 @@ static void felix_8021q_cpu_port_init(struct ocelot *ocelot, int port) ocelot_port_set_dsa_8021q_cpu(ocelot, port); - /* Overwrite PGID_CPU with the non-tagging port */ - ocelot_write_rix(ocelot, BIT(port), ANA_PGID_PGID, PGID_CPU); - ocelot_apply_bridge_fwd_mask(ocelot, true); mutex_unlock(&ocelot->fwd_domain_lock); @@ -267,10 +264,6 @@ static void felix_8021q_cpu_port_deinit(struct ocelot *ocelot, int port) ocelot_port_unset_dsa_8021q_cpu(ocelot, port); - /* Restore PGID_CPU */ - ocelot_write_rix(ocelot, BIT(ocelot->num_phys_ports), ANA_PGID_PGID, - PGID_CPU); - ocelot_apply_bridge_fwd_mask(ocelot, true); mutex_unlock(&ocelot->fwd_domain_lock); diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index e0d1d5b59981..ac9faf1923c5 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -2165,6 +2165,33 @@ void ocelot_apply_bridge_fwd_mask(struct ocelot *ocelot, bool joining) } EXPORT_SYMBOL(ocelot_apply_bridge_fwd_mask); +/* Update PGID_CPU which is the destination port mask used for whitelisting + * unicast addresses filtered towards the host. In the normal and NPI modes, + * this points to the analyzer entry for the CPU port module, while in DSA + * tag_8021q mode, it is a bit mask of all active CPU ports. + * PGID_SRC will take care of forwarding a packet from one user port to + * no more than a single CPU port. + */ +static void ocelot_update_pgid_cpu(struct ocelot *ocelot) +{ + int pgid_cpu = 0; + int port; + + for (port = 0; port < ocelot->num_phys_ports; port++) { + struct ocelot_port *ocelot_port = ocelot->ports[port]; + + if (!ocelot_port || !ocelot_port->is_dsa_8021q_cpu) + continue; + + pgid_cpu |= BIT(port); + } + + if (!pgid_cpu) + pgid_cpu = BIT(ocelot->num_phys_ports); + + ocelot_write_rix(ocelot, pgid_cpu, ANA_PGID_PGID, PGID_CPU); +} + void ocelot_port_set_dsa_8021q_cpu(struct ocelot *ocelot, int port) { u16 vid; @@ -2173,6 +2200,8 @@ void ocelot_port_set_dsa_8021q_cpu(struct ocelot *ocelot, int port) for (vid = OCELOT_RSV_VLAN_RANGE_START; vid < VLAN_N_VID; vid++) ocelot_vlan_member_add(ocelot, port, vid, true); + + ocelot_update_pgid_cpu(ocelot); } EXPORT_SYMBOL_GPL(ocelot_port_set_dsa_8021q_cpu); @@ -2184,6 +2213,8 @@ void ocelot_port_unset_dsa_8021q_cpu(struct ocelot *ocelot, int port) for (vid = OCELOT_RSV_VLAN_RANGE_START; vid < VLAN_N_VID; vid++) ocelot_vlan_member_del(ocelot, port, vid); + + ocelot_update_pgid_cpu(ocelot); } EXPORT_SYMBOL_GPL(ocelot_port_unset_dsa_8021q_cpu); From patchwork Sat May 21 21:37:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12858043 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 A1C54C433EF for ; Sat, 21 May 2022 21:38:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346981AbiEUViT (ORCPT ); Sat, 21 May 2022 17:38:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346669AbiEUViF (ORCPT ); Sat, 21 May 2022 17:38:05 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2066.outbound.protection.outlook.com [40.107.22.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6007A527F0 for ; Sat, 21 May 2022 14:38:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H4R0lJFMJa/W/cn60w6wH/xcInSuyK8n4rVRFHoTHHVlWK0+TDJI+b+Cgn9cjjbEKOwpy/irEmbDdoO1t+p7gaQ15paTgDhYcHPFAvAKwNcmrGWsK23IWKeEs9795la5+K7FkRhTUMLYgkDtsa3rmcn+GNJjiqxM51d4oO0vbDMl9GgrKK5JuhegAjvrrhXDhdacT0qhZDXCvFmv8BnCPDxI1kbxvOYq/HVZIo6CSUB7yDxRpvxkZ2FqFi278n1EATcexXcu35NGtFSf4q5IRIGjsnSsRHqlkZvlw9Wgd62ipCPwJxY/BXNN39fUnjJ0pWuPBmbcPEMvt2nH/LgrPg== 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=oX05ylXEkLGh9XCM77Hye08h/qx97TYDeNAuvyPtAOA=; b=cSjyuwkzEefsTuf4ZBZiI5hNDy50hZ1PR1tTBe3pz/XRrBv2IpYHoOaAyiZAIc/LelsfeySRbLWNdrtro3mpwDZawXaIOIYbG42zhsB7v8I1AI3sD41P2B2tI39l4RGT6dQkp/NbtfcwbPCyWhM8GkE/vKLqFz/BCQCMljkQlmyoVvJZsM2l8X2YzCARhbvmIezpYLM/Z799A086/ZevbGWdP8VssYWlG0kmML58gufnmrOlFfxULxwAngdHBJJSqoTH6G7htIH0yHkErmTcO6TJULQK85DqY4oO0W7oKQkDKp1dy35lF9ACK1ZfURmuhIVTcouC/0n9kzJ1IyqASQ== 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=oX05ylXEkLGh9XCM77Hye08h/qx97TYDeNAuvyPtAOA=; b=KE9qa0iX2niFmQ0kiih7ifju1g41WJCB4VsdboWg41kzED0kgVtY3J9CQA5iLzo7e3BGjrxTxz7GYgO1LKO4Qt/tRBBknLCZYRFCm00y7K85wjucin34rh2rpcxtrP9RR+zyqSz+4hnaIFAnWZFeB+aH8EZE4gvEIFug3MQLMRA= 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 AM0PR04MB6275.eurprd04.prod.outlook.com (2603:10a6:208:147::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5273.19; Sat, 21 May 2022 21:38:02 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::fd1f:cc16:dafe:4bf5]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::fd1f:cc16:dafe:4bf5%5]) with mapi id 15.20.5250.014; Sat, 21 May 2022 21:38:02 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Jakub Kicinski , "David S. Miller" , Paolo Abeni , Eric Dumazet , Florian Fainelli , Vivien Didelot , Andrew Lunn , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Colin Foster Subject: [PATCH net-next 3/6] net: dsa: felix: update bridge fwd mask from ocelot lib when changing tag_8021q CPU Date: Sun, 22 May 2022 00:37:40 +0300 Message-Id: <20220521213743.2735445-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220521213743.2735445-1-vladimir.oltean@nxp.com> References: <20220521213743.2735445-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM6P193CA0079.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:88::20) 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: fd8ee22d-e5e8-469d-e84a-08da3b722e6e X-MS-TrafficTypeDiagnostic: AM0PR04MB6275:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EaC7MWkYzH5rYd4nHO9Cmu94BE+fdojpkyGltyoEIBKG2mLn1pRM0WxOiwBjSEhFggBP0RrSR3dynycHUiKZaQsj8GGS50uScY5WyjD5vrnEjSYKucmauCsfcxw0bDRbDDyRIzHD/QxiL/YnHwPMjRyrWs5fgO2xN0eRwJX3PDfZBYEvt4kWBaxDGR3X6uc99uCi5xI6BMbqv28CEu6rxTnMEjmzNYsij634pRJKvGf2dg6E2dbsmXP4sXK21LJJSnOZZv3saqWPiA/2lM/4V8b6l/zlmPbwucUhPZ0b705Z4qcJpFqUSJ+TEWlwCgnAPHtkf7mVY+7q0h5d7W2apAg0JLp9BiqoDY1ZoT5NCqz3t4vbe8iw6jtd1kZ+h4PFTrmrrXMZxFaIu8jhutf+HGkbsNn1GPmBud0IXtwnvwVdpsDbSm4G84Gi+JzRrw7hLGC0C/txTPuPKtFi7XhLJcw+/0ZlxNtgCYWRrQfGT+dBt9b7Rmeba2285I2FxW2owckaPBuPWf6sdqtLe79UKAViqBVklmRNbo1AdNLuesw53pO5Zi7/DVc50Jy168jAGuU9EuoT4oIh2qytFo274PKzaKr4/ErSZEIdk5756hvdFByGdUDQ+CIsx1h4tmEtiLaELhULnk6GxLX4SQvL0xkxthCForib8oN3MG+fFx20IDRqPumHOwpqHCANSBtzZ3tmv/l0lZDKNv1Yp4aE5g== 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:(13230001)(4636009)(366004)(6666004)(86362001)(26005)(6512007)(6506007)(52116002)(36756003)(2906002)(6486002)(8676002)(66946007)(15650500001)(4326008)(66476007)(66556008)(54906003)(44832011)(83380400001)(7416002)(2616005)(186003)(508600001)(38350700002)(8936002)(38100700002)(5660300002)(316002)(6916009)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cS7XLiGka1OmZGJg5Urh2F2tyK7nvJDZTpOQ/QG3L+fg9B5KbAO4y5naqiOACojYSFhzIvoBTSueUmn6QxXBb/ssgsqZIgv/4qfEh2x3tfo+/D823RP82voCR+VmslOsiJauLSeCgBHmWOmpFNrY0+dynngJeEyRwb/wGdiw4TLz5Exl6x052jSgIn+6HVy4d8GqhOEvNmQVJpxN0ZWA+7NjCk+jH1n6fBlhJ0Vb9HU9xjptsMHrkcG/TY+4jP6NREz5QOtXMW88PKtO8J4MnSfx6vjszJVFeHmrYolzueGaxEZC2Z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/GZiT2ueYiEmlH5KN28R3DblosZI7jmVrUGMwjIuoZlcbOAGh4bp9P3yaBbJkdv0ObXtELKQ2KHEF7LHup95XjsW4t8EB0lpSoBsRu0d1BPvcgXx0kN9HPPk7XS1hviqP0cQaGb/y89+5z2KlxAaa1iYCh5J9hgIMfOkcr1d8+3Xcf2jGmuivD/V1sx9qODWisSuBJIwPYrl3Q1Y+fc5LaPppy5GWeBdiURJ9NuPfhoYnK+aVmPPIP/sWoYlnXEOcgCabuCm+I3IwcEMg5kOGLK+V670vTx7y12/qRUQGZY6yqyTQcZ9Vd1wCO0uo627/q+Et8wkjwguWttc0/Y+F6WtvBzKog9ZyokyLZxWmZHcQrmyURnzbdmuVBmF+p4SbfC6508= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fd8ee22d-e5e8-469d-e84a-08da3b722e6e X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2022 21:38:01.9239 (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: RGk2qfgkuWvLnEn4hIELB7DzGdd3LUR4QcGaraomE0m407Mp7z3Xs7cJknUeKRv/0B0nTtkT+kQynISB5cr6Yg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6275 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add more logic to ocelot_port_{,un}set_dsa_8021q_cpu() from the ocelot switch lib by encapsulating the ocelot_apply_bridge_fwd_mask() call that felix used to have. This is necessary because the CPU port change procedure will also need to do this, and it's good to reduce code duplication by having an entry point in the ocelot switch lib that does all that is needed. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/ocelot/felix.c | 4 ---- drivers/net/ethernet/mscc/ocelot.c | 7 +++++-- include/soc/mscc/ocelot.h | 1 - 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 1299f6a8ac5b..b60d6e7295e1 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -253,8 +253,6 @@ static void felix_8021q_cpu_port_init(struct ocelot *ocelot, int port) ocelot_port_set_dsa_8021q_cpu(ocelot, port); - ocelot_apply_bridge_fwd_mask(ocelot, true); - mutex_unlock(&ocelot->fwd_domain_lock); } @@ -264,8 +262,6 @@ static void felix_8021q_cpu_port_deinit(struct ocelot *ocelot, int port) ocelot_port_unset_dsa_8021q_cpu(ocelot, port); - ocelot_apply_bridge_fwd_mask(ocelot, true); - mutex_unlock(&ocelot->fwd_domain_lock); } diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index ac9faf1923c5..4011a7968be5 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -2094,7 +2094,7 @@ u32 ocelot_get_dsa_8021q_cpu_mask(struct ocelot *ocelot) } EXPORT_SYMBOL_GPL(ocelot_get_dsa_8021q_cpu_mask); -void ocelot_apply_bridge_fwd_mask(struct ocelot *ocelot, bool joining) +static void ocelot_apply_bridge_fwd_mask(struct ocelot *ocelot, bool joining) { unsigned long cpu_fwd_mask; int port; @@ -2163,7 +2163,6 @@ void ocelot_apply_bridge_fwd_mask(struct ocelot *ocelot, bool joining) if (!joining && ocelot->ops->cut_through_fwd) ocelot->ops->cut_through_fwd(ocelot); } -EXPORT_SYMBOL(ocelot_apply_bridge_fwd_mask); /* Update PGID_CPU which is the destination port mask used for whitelisting * unicast addresses filtered towards the host. In the normal and NPI modes, @@ -2202,6 +2201,8 @@ void ocelot_port_set_dsa_8021q_cpu(struct ocelot *ocelot, int port) ocelot_vlan_member_add(ocelot, port, vid, true); ocelot_update_pgid_cpu(ocelot); + + ocelot_apply_bridge_fwd_mask(ocelot, true); } EXPORT_SYMBOL_GPL(ocelot_port_set_dsa_8021q_cpu); @@ -2215,6 +2216,8 @@ void ocelot_port_unset_dsa_8021q_cpu(struct ocelot *ocelot, int port) ocelot_vlan_member_del(ocelot, port, vid); ocelot_update_pgid_cpu(ocelot); + + ocelot_apply_bridge_fwd_mask(ocelot, true); } EXPORT_SYMBOL_GPL(ocelot_port_unset_dsa_8021q_cpu); diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 3b8c5a54fb00..2c90a24ca064 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -880,7 +880,6 @@ int ocelot_port_vlan_filtering(struct ocelot *ocelot, int port, bool enabled, void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state); u32 ocelot_get_dsa_8021q_cpu_mask(struct ocelot *ocelot); u32 ocelot_get_bridge_fwd_mask(struct ocelot *ocelot, int src_port); -void ocelot_apply_bridge_fwd_mask(struct ocelot *ocelot, bool joining); int ocelot_port_pre_bridge_flags(struct ocelot *ocelot, int port, struct switchdev_brport_flags val); void ocelot_port_bridge_flags(struct ocelot *ocelot, int port, From patchwork Sat May 21 21:37:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12858044 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 5E168C433F5 for ; Sat, 21 May 2022 21:38:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346622AbiEUViW (ORCPT ); Sat, 21 May 2022 17:38:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346690AbiEUViG (ORCPT ); Sat, 21 May 2022 17:38:06 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2066.outbound.protection.outlook.com [40.107.22.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A78B53A60 for ; Sat, 21 May 2022 14:38:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XY99gHEw2vK89SytSOr4DXwFSlxiphnHZMxXNg0cSavxpU8upit0iSCi5bSpzBsg7Bf76mhTNWuI12r/LdcY23cAUqNE2BqSjrqg3Bsh3NLqCo0wCPxvrk3eNOoK9i7H2h2Xj5FnpktpiuUL0XEGZ86OQAWl99Ampq0l5akb94gI9UmgkgqUCqh2Ayy/Sz2Ys9K8PlmlH5bSHzqiUL5dmbTKfy5020pjb0MhQLKlkl1S8i3tWnr2S2ahFOXCg7YyA+XmXIs5C/LC932CKYb6ZnHwfiZ1hoA3Fj8qZlUwgMggighk+iUlCx3n2GdiN2O/T1dVheWVdXHB0zpJ2zp8pw== 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=nWgeboLPkapGpcLVsPzMwhQYK6IS32scSxDdA/xGeFk=; b=FkSrdSA5b5d98yWlHrmyk7pVYfrefTVvwflJ72AoW1Y7n+K/W/Ycf/d7y9WuiFcWcx3JCkkNE+LDe2kq5RrHCsXkeokUrmYY7Kb+iLLOR73lqWSAWBr2GBEmmFkS4J/uq9MoG5e2TALe3IFhb5u/AGzZfpvtgldBGKqjy2YJgZtjwvcsPFg06f77hdXV7dNo3bGP1ssZD/qpx3+9mheoZi5mKb1kyVMZ3YgsfVfnxNkGH8/l7P0gOJPeYMpiOatbYVmXmvm9chvYrqL/ELTvZGlcB41mqSFUCfDuDKv0JFjRuoAFuFXFTvFQ2Dujbra4rxa//vD0bBjV0XPzg5EHNA== 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=nWgeboLPkapGpcLVsPzMwhQYK6IS32scSxDdA/xGeFk=; b=ZIK9hFhUErtv0XudJn2ap2EfFsvrQYwSi3T0l/zqvNtcHudRyT3kGDqr2sxt3usUKmtK8weQUd8/iq9RKZUPECECprUEvC6yASB1wyiqvWnPPZzgxJvBP2+h3cIoBUacbpX2WCiCXzFOLuj0oGzMWRLG+OCOkR29+yTdLq1BhRw= 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 AM0PR04MB6275.eurprd04.prod.outlook.com (2603:10a6:208:147::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5273.19; Sat, 21 May 2022 21:38:03 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::fd1f:cc16:dafe:4bf5]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::fd1f:cc16:dafe:4bf5%5]) with mapi id 15.20.5250.014; Sat, 21 May 2022 21:38:03 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Jakub Kicinski , "David S. Miller" , Paolo Abeni , Eric Dumazet , Florian Fainelli , Vivien Didelot , Andrew Lunn , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Colin Foster Subject: [PATCH net-next 4/6] net: dsa: felix: directly call ocelot_port_{set,unset}_dsa_8021q_cpu Date: Sun, 22 May 2022 00:37:41 +0300 Message-Id: <20220521213743.2735445-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220521213743.2735445-1-vladimir.oltean@nxp.com> References: <20220521213743.2735445-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM6P193CA0079.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:88::20) 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: 62708912-01f5-43f1-6393-08da3b722f51 X-MS-TrafficTypeDiagnostic: AM0PR04MB6275:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Uzu5ir5IHO5+dIVeVVysef5mvhXaL4YZKJpqjRmX/kbUiq+dVWqVG6lnBp/TX1s/Rv1wo+Tua5GBBESfZPUmmnf6WWSSUE05r/KNr8n1sqmgO5A8YAoeW2sxzWZ/NzXmPfO/Rsmk/uLsfLasVhOezK8oKgdyzpD60wn3NDQ0k3OSNVeG+UpvjuTsVi/45c+xIta61LlCXQtTaehmL4FJzNlAkuETbh0qT1GkQYculuP6IStw1FTndqsBRkORtkr5n6xtxj+Tuype4ZJ/EUagvxR9h8aSXfzdmH/L8YHgoJB1/SZnT5Oq5ys9yWMSBjQW8FZwDEYOrPKFBi3Bqn9FatlocQmAlZojns1DIqLNIZrjAnR9Rr6W7XCfuuXD4hiv2ZTw29JQ7MD4EZ4fgsTAUU9TLcuml6/BO8+OrGl4XWwArQmWn9DFhPOxTZuVxOOkAnIGhmeZMUbiTVb8AEBeO2xTy27WpYnHSj4GbdeXvQjEywG/TjJSfhj42T/T39DboZvzRwwVraPntNm+NAzv6Fd3iKqb4MUMc4HHw1yT9blZ96zabU44QXLuLPHeeYVG9S+D65hdGC1Njjb2RfOVQYjc7TltpZ4eHY7akfwyYoZZYWL8zdqzBg0j5cy3QdEOmnJGzMJZtjaVTYR7DwCxK7WCb+q2kdD3z8mlI0lIdCDb8G5/0pXBO34U9j/zWyV98OG2ehCkIOjA/MZRIZgEdw== 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:(13230001)(4636009)(366004)(6666004)(86362001)(26005)(6512007)(6506007)(52116002)(36756003)(2906002)(6486002)(8676002)(66946007)(4326008)(66476007)(66556008)(54906003)(44832011)(83380400001)(7416002)(2616005)(186003)(508600001)(38350700002)(8936002)(38100700002)(5660300002)(316002)(6916009)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: g/0UfxqYSYLK4S5PiK++cVwqPOwWmxgAW7yGLeL5oqOiM6bMP9Bb6iznkkXO1vuWgRHJO7g3VDBDlOZcKRfb1hN8DdEaBhLojr/WRn7gieblYcfJoawwWEEmbkFTBfmjfNK9lNKpzWkjPWhx/XnxpdlubimdGv1qHDHrgxK1z7s9MaPwrK5LNlh+HeQtd7DjJfV0mTJ7pPz2az0vLSUnUhwEytOkYdlnsOSyBxt+Xsfx1IzXIYw9Tz3GFBEr/yvQl9Y4uGhjls5nLyPetbhK0iVmSsLo5ExrP99QCNqvCR64IU+D007cXq6DIQ/wYbbq269cGzPCTNjU+hia7pTk4c7q6MMRRAty4ndWn18huU+63ILOt+OurofZMXDb7JCdyTY/8BP3j9efW2GhmmyWNBp0o/gLasGnlbxTNGEV9AF4Ab8HX8sAv/qWLybLo2obxLok0QRLcpyyA1raOh0flwxRyy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rPCbNRCqGT/ijllZkgnB4SO3QTUgBkmQXzuedYUeSFZWx/zMxm23lo1qfB3OHBu2/geYPhMpaRrZhMubDdLcEiVrwvcvG7uCt4f7O3d8zKGK2RjvP0GGcz9CXqvcfGVhaQk1kqPumPzwQfugmQAWOlZcABlLhgZsjfJjPsZiL//bpKmGbL9n4/Emm9A4ehiFkMjqBFJNaIuizDqIWAvc= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 62708912-01f5-43f1-6393-08da3b722f51 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2022 21:38:03.4394 (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: GxotQ2INWopBFw89EJz9VbPranL5gGkBI5gesALOAPccqMjo5A1GYkWvcBnHseRSsTgMQ/uzIb/jYUapG82k4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6275 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Absorb the final details of calling ocelot_port_{,un}set_dsa_8021q_cpu(), i.e. the need to lock &ocelot->fwd_domain_lock, into the callee, to simplify the caller and permit easier code reuse later. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/ocelot/felix.c | 36 ++++++++---------------------- drivers/net/ethernet/mscc/ocelot.c | 8 +++++++ 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index b60d6e7295e1..033f7d5cc03d 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -240,31 +240,6 @@ static int felix_tag_8021q_vlan_del(struct dsa_switch *ds, int port, u16 vid) return 0; } -/* Alternatively to using the NPI functionality, that same hardware MAC - * connected internally to the enetc or fman DSA master can be configured to - * use the software-defined tag_8021q frame format. As far as the hardware is - * concerned, it thinks it is a "dumb switch" - the queues of the CPU port - * module are now disconnected from it, but can still be accessed through - * register-based MMIO. - */ -static void felix_8021q_cpu_port_init(struct ocelot *ocelot, int port) -{ - mutex_lock(&ocelot->fwd_domain_lock); - - ocelot_port_set_dsa_8021q_cpu(ocelot, port); - - mutex_unlock(&ocelot->fwd_domain_lock); -} - -static void felix_8021q_cpu_port_deinit(struct ocelot *ocelot, int port) -{ - mutex_lock(&ocelot->fwd_domain_lock); - - ocelot_port_unset_dsa_8021q_cpu(ocelot, port); - - mutex_unlock(&ocelot->fwd_domain_lock); -} - static int felix_trap_get_cpu_port(struct dsa_switch *ds, const struct ocelot_vcap_filter *trap) { @@ -423,6 +398,13 @@ static unsigned long felix_tag_npi_get_host_fwd_mask(struct dsa_switch *ds) return BIT(ocelot->num_phys_ports); } +/* Alternatively to using the NPI functionality, that same hardware MAC + * connected internally to the enetc or fman DSA master can be configured to + * use the software-defined tag_8021q frame format. As far as the hardware is + * concerned, it thinks it is a "dumb switch" - the queues of the CPU port + * module are now disconnected from it, but can still be accessed through + * register-based MMIO. + */ static const struct felix_tag_proto_ops felix_tag_npi_proto_ops = { .setup = felix_tag_npi_setup, .teardown = felix_tag_npi_teardown, @@ -440,7 +422,7 @@ static int felix_tag_8021q_setup(struct dsa_switch *ds) return err; dsa_switch_for_each_cpu_port(cpu_dp, ds) { - felix_8021q_cpu_port_init(ocelot, cpu_dp->index); + ocelot_port_set_dsa_8021q_cpu(ocelot, cpu_dp->index); /* TODO we could support multiple CPU ports in tag_8021q mode */ break; @@ -490,7 +472,7 @@ static void felix_tag_8021q_teardown(struct dsa_switch *ds) } dsa_switch_for_each_cpu_port(cpu_dp, ds) { - felix_8021q_cpu_port_deinit(ocelot, cpu_dp->index); + ocelot_port_unset_dsa_8021q_cpu(ocelot, cpu_dp->index); /* TODO we could support multiple CPU ports in tag_8021q mode */ break; diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 4011a7968be5..d208d57f4894 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -2195,6 +2195,8 @@ void ocelot_port_set_dsa_8021q_cpu(struct ocelot *ocelot, int port) { u16 vid; + mutex_lock(&ocelot->fwd_domain_lock); + ocelot->ports[port]->is_dsa_8021q_cpu = true; for (vid = OCELOT_RSV_VLAN_RANGE_START; vid < VLAN_N_VID; vid++) @@ -2203,6 +2205,8 @@ void ocelot_port_set_dsa_8021q_cpu(struct ocelot *ocelot, int port) ocelot_update_pgid_cpu(ocelot); ocelot_apply_bridge_fwd_mask(ocelot, true); + + mutex_unlock(&ocelot->fwd_domain_lock); } EXPORT_SYMBOL_GPL(ocelot_port_set_dsa_8021q_cpu); @@ -2210,6 +2214,8 @@ void ocelot_port_unset_dsa_8021q_cpu(struct ocelot *ocelot, int port) { u16 vid; + mutex_lock(&ocelot->fwd_domain_lock); + ocelot->ports[port]->is_dsa_8021q_cpu = false; for (vid = OCELOT_RSV_VLAN_RANGE_START; vid < VLAN_N_VID; vid++) @@ -2218,6 +2224,8 @@ void ocelot_port_unset_dsa_8021q_cpu(struct ocelot *ocelot, int port) ocelot_update_pgid_cpu(ocelot); ocelot_apply_bridge_fwd_mask(ocelot, true); + + mutex_unlock(&ocelot->fwd_domain_lock); } EXPORT_SYMBOL_GPL(ocelot_port_unset_dsa_8021q_cpu); From patchwork Sat May 21 21:37:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12858045 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 C9F31C433EF for ; Sat, 21 May 2022 21:38:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346860AbiEUVi1 (ORCPT ); Sat, 21 May 2022 17:38:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346686AbiEUViS (ORCPT ); Sat, 21 May 2022 17:38:18 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2066.outbound.protection.outlook.com [40.107.22.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D861C5400F for ; Sat, 21 May 2022 14:38:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nz8G6/YwnshKf3dhzGp19swEtxgpeFl/iZJQTRQ9xRxqCcyFwrEzXSz0vvbHC0Xl/IDykp5XeUT7H1JdIXn+ADVutg0UjytpP+ZwFBmRbvMsPLpR5GDOu6B7ja6W/iyjIj+jx+LwBaqr0Bjlof9tlGdwT/vJ3L8q1WAJB3lGciRuu+SCoyJJqSs3NyQIFSKeRHfCdP8KV11cCYe3IM+qbV4+gBaOoN51xACikEhB9LoFHduPYYSHQpaWE3x4+pe3VSAkgz5Qrb9rg98q7kRIfijxhkIPir074Iar7W0TeAxFF21febgMrfGZpmo2GFHnJlw262B9sgrLO+esjsSjIw== 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=0fpvBvw1XgLjKLYjFiuWbjJdQhDf5q9eoYH47+5hIyo=; b=clIHZrtlomvg/oEeGINbG19IIFJ70GEem3dsC4Dmqwrgrm72tYj37sEIQ4b01UBfBVkgdOYnMkNnPJpDlbZFmmgigHULjPshAu+iOs7o8kZlnUo1gQPYss6583ZjTmq+s4FeuVcdZ6LLFZHLMY9qbUHnetTvMD1ZuopMlKqQ9OOrxSf6U6A9rM0L23gJhdtZeqiZMQUvGeUOSQ+jqRq4UBaIbQMp3iEUSPY7UHG0a5YURKOt5MhFGYcNcl+O8t5Mn52RPNotVkIL4bEXeRRNaRqkJL+c+x/nVeOYUm8Kmx4pfpf7y8UFAU1N7ayXH9cg5hwGUi046MztIntnODuRYA== 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=0fpvBvw1XgLjKLYjFiuWbjJdQhDf5q9eoYH47+5hIyo=; b=EoaGZFhDZ7TQ/NBj8VA5833s6K2npNA79ijtxKBBfQO15XyqnaDzZ4bn/k7Yb4AmD9qgL0cTbbTusGKOFcK2MG9nDXEyUXdm1b06nRm+EWR2cWnl573kh92u3h+m1vQNFPhC4/+azNZOJ5y7ZDMVGhZL9AmCnSoqZsyfRhhp9LY= 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 AM0PR04MB6275.eurprd04.prod.outlook.com (2603:10a6:208:147::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5273.19; Sat, 21 May 2022 21:38:05 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::fd1f:cc16:dafe:4bf5]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::fd1f:cc16:dafe:4bf5%5]) with mapi id 15.20.5250.014; Sat, 21 May 2022 21:38:05 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Jakub Kicinski , "David S. Miller" , Paolo Abeni , Eric Dumazet , Florian Fainelli , Vivien Didelot , Andrew Lunn , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Colin Foster Subject: [PATCH net-next 5/6] net: mscc: ocelot: switch from {,un}set to {,un}assign for tag_8021q CPU ports Date: Sun, 22 May 2022 00:37:42 +0300 Message-Id: <20220521213743.2735445-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220521213743.2735445-1-vladimir.oltean@nxp.com> References: <20220521213743.2735445-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM6P193CA0079.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:88::20) 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: 36e723c9-e865-4fd8-05bd-08da3b72303b X-MS-TrafficTypeDiagnostic: AM0PR04MB6275:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0A9K8zCJxIh6g3bkrPtg0D9+HecF7SvDpcrkAdyf9cnhaLPQPiwt7FZ1hB38n3toFaI0XKFJqwBOYKYu3AcNAt9UcqNou66c4Rn3H0OgAxXmYh0MY4jaW9QYBJy6vFIiSsGTLRYF3VSQNQffsO+vS5972kJ3WuTtRi4zk6L3jlmWzhilBltgJgarSlXv2dHQfB+juxz4wIjtnE7j0lHzXCJGBv01skM3pV0AZKPPmkMI9T9qPUmBaanksMh/3eW6nKjOEF3sSkTMC+5DWkrO6y9W4C5TjjE453O5kWtMiW2DbSm1pxbjC+1oq2gqIosKbnq2sW+nkwUohQFYKZlGB2b/ySuTeRuLtDn+DQvm+kx6n0V79ics1sn7mjFNTYb2XOrdfR1FDFlyft//o14MMi5+WSTZrwO6JS6+dX0pEHGl/RM/Isy4vRJpnZWnkpab3oOPdzmzRLKiSKLrHrc4B/lteM1W6D/gL0+f3t43ue4hbrK1Mvt5thuOFUDHU9Nr/1yPCe00eSAK011x7n/wRnSt4zGBGPbKSJwQgNSGHOC46vUtqbp7b5fReRwF5ns/wzRx7a4Xua2KsFNAQchNuZ0K7FqIn1Vx6utx7ZtWIqU+uO3sBIYm9bsD9/9QaizTAbXr5UFUSO22HLghk46E2N7UF2BLvLhHEgbKC3CE/QOMZFf0xMkPN/RHhbIygOTkr5jc+vB8JZRh0/qKH97ekw== 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:(13230001)(4636009)(366004)(6666004)(86362001)(26005)(6512007)(6506007)(52116002)(36756003)(2906002)(6486002)(8676002)(66946007)(30864003)(4326008)(66476007)(66556008)(54906003)(44832011)(83380400001)(7416002)(2616005)(186003)(508600001)(38350700002)(8936002)(38100700002)(5660300002)(316002)(6916009)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lpDJWKnds9GEA+M717HNJZSk2aVpn2ecP5TOXxz6UZAL3cziLHyGAf2HudBGt4hi1MbBZfBDf2lz8d+NmyQlxywdKkig4rOMCwz2TGRxEyd5ORX8dJ18BM533Fdg1BK4QVC9o0AJ4rZYZaB5LamvGzQXYExA6yFj/3bc2f7/NHLYtJZJG/kuXqTfyrveFKM9Tbtj8VDhKWx9Ts1B0cVeA+iwhN3kgc3IIBqPLGf6EYqym7wCvLdiUBIitS2sHoJifpUkjOIW3/afFDOHRMhz9cRQsPdD+aJ3bCnmPU2W2xrQwDtNnAlqiW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mWK4DZJH8RtljGBFD131lh51ZAtGFIExol5b2dlszpfFOVdtLbCBxt69D+ZiKHkkyCl36a05AifD6a/m7Ok/Q03qcRCiNkTtWwj6aDb+3vAlUzne0dgW9EXbg/6X7UlceUwT3c1xF9SV0V/qKzaZv9rLr+K6Y5/p/2SkVP276KoU/6HRpD4nV5Mcc/8cQbyqJmJ7eSo2RCuifXw9adg6IZhZvoFUsa+KK7axrSrUPW2RlDU9DiweGink0d1gnxEYcM+5GeULKccAEQkiBCvwrTa2GIxCtby9128llYftVoWtegv4DUhZBvDypF3j/3YxrLw0QU7Hr+QMuW+MMBdHHjsn5wLo7UFmHR6h+Cm9rmPDorX3YWjGtE83xrEi2cRPf/VsPO1DRYJy1YiI= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 36e723c9-e865-4fd8-05bd-08da3b72303b X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2022 21:38:04.9550 (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: qn4R2tAfrMRYY9qm6UJk7vgpunACkV1HLgWk4s/3du42mNFFh4C/PDuQyYTMVAwOFA/8Cyj3EJ+beRGMB0U1Jg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6275 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org There is a desire for the felix driver to gain support for multiple tag_8021q CPU ports, but the current model prevents it. This is because ocelot_apply_bridge_fwd_mask() only takes into consideration whether a port is a tag_8021q CPU port, but not whose CPU port it is. We need a model where we can have a direct affinity between an ocelot port and a tag_8021q CPU port. This serves as the basis for multiple CPU ports. Declare a "dsa_8021q_cpu" backpointer in struct ocelot_port which encodes that affinity. Repurpose the "ocelot_set_dsa_8021q_cpu" API to "ocelot_assign_dsa_8021q_cpu" to express the change of paradigm. Note that this change makes the first practical use of the new ocelot_port->index field in ocelot_port_unassign_dsa_8021q_cpu(), where we need to remove the old tag_8021q CPU port from the reserved VLAN range. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/ocelot/felix.c | 27 ++---- drivers/net/dsa/ocelot/felix_vsc9959.c | 3 +- drivers/net/ethernet/mscc/ocelot.c | 120 +++++++++++++++---------- include/soc/mscc/ocelot.h | 10 ++- 4 files changed, 92 insertions(+), 68 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 033f7d5cc03d..01d8a731851e 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -414,21 +414,18 @@ static const struct felix_tag_proto_ops felix_tag_npi_proto_ops = { static int felix_tag_8021q_setup(struct dsa_switch *ds) { struct ocelot *ocelot = ds->priv; - struct dsa_port *dp, *cpu_dp; + struct dsa_port *dp; int err; err = dsa_tag_8021q_register(ds, htons(ETH_P_8021AD)); if (err) return err; - dsa_switch_for_each_cpu_port(cpu_dp, ds) { - ocelot_port_set_dsa_8021q_cpu(ocelot, cpu_dp->index); - - /* TODO we could support multiple CPU ports in tag_8021q mode */ - break; - } + dsa_switch_for_each_user_port(dp, ds) + ocelot_port_assign_dsa_8021q_cpu(ocelot, dp->index, + dp->cpu_dp->index); - dsa_switch_for_each_available_port(dp, ds) { + dsa_switch_for_each_available_port(dp, ds) /* This overwrites ocelot_init(): * Do not forward BPDU frames to the CPU port module, * for 2 reasons: @@ -442,7 +439,6 @@ static int felix_tag_8021q_setup(struct dsa_switch *ds) ocelot_write_gix(ocelot, ANA_PORT_CPU_FWD_BPDU_CFG_BPDU_REDIR_ENA(0), ANA_PORT_CPU_FWD_BPDU_CFG, dp->index); - } /* The ownership of the CPU port module's queues might have just been * transferred to the tag_8021q tagger from the NPI-based tagger. @@ -459,9 +455,9 @@ static int felix_tag_8021q_setup(struct dsa_switch *ds) static void felix_tag_8021q_teardown(struct dsa_switch *ds) { struct ocelot *ocelot = ds->priv; - struct dsa_port *dp, *cpu_dp; + struct dsa_port *dp; - dsa_switch_for_each_available_port(dp, ds) { + dsa_switch_for_each_available_port(dp, ds) /* Restore the logic from ocelot_init: * do not forward BPDU frames to the front ports. */ @@ -469,14 +465,9 @@ static void felix_tag_8021q_teardown(struct dsa_switch *ds) ANA_PORT_CPU_FWD_BPDU_CFG_BPDU_REDIR_ENA(0xffff), ANA_PORT_CPU_FWD_BPDU_CFG, dp->index); - } - dsa_switch_for_each_cpu_port(cpu_dp, ds) { - ocelot_port_unset_dsa_8021q_cpu(ocelot, cpu_dp->index); - - /* TODO we could support multiple CPU ports in tag_8021q mode */ - break; - } + dsa_switch_for_each_user_port(dp, ds) + ocelot_port_unassign_dsa_8021q_cpu(ocelot, dp->index); dsa_tag_8021q_unregister(ds); } diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 98caca4317d7..570d0204b7be 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -2162,7 +2162,8 @@ static void vsc9959_cut_through_fwd(struct ocelot *ocelot) if (ocelot->npi >= 0) mask |= BIT(ocelot->npi); else - mask |= ocelot_get_dsa_8021q_cpu_mask(ocelot); + mask |= ocelot_port_assigned_dsa_8021q_cpu_mask(ocelot, + port); } /* Calculate the minimum link speed, among the ports that are diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index d208d57f4894..8da7e25a47c9 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -2046,57 +2046,68 @@ static int ocelot_bond_get_id(struct ocelot *ocelot, struct net_device *bond) return __ffs(bond_mask); } -u32 ocelot_get_bridge_fwd_mask(struct ocelot *ocelot, int src_port) +static u32 ocelot_dsa_8021q_cpu_assigned_ports(struct ocelot *ocelot, + struct ocelot_port *cpu) { - struct ocelot_port *ocelot_port = ocelot->ports[src_port]; - const struct net_device *bridge; u32 mask = 0; int port; - if (!ocelot_port || ocelot_port->stp_state != BR_STATE_FORWARDING) - return 0; - - bridge = ocelot_port->bridge; - if (!bridge) - return 0; - for (port = 0; port < ocelot->num_phys_ports; port++) { - ocelot_port = ocelot->ports[port]; + struct ocelot_port *ocelot_port = ocelot->ports[port]; if (!ocelot_port) continue; - if (ocelot_port->stp_state == BR_STATE_FORWARDING && - ocelot_port->bridge == bridge) + if (ocelot_port->dsa_8021q_cpu == cpu) mask |= BIT(port); } return mask; } -EXPORT_SYMBOL_GPL(ocelot_get_bridge_fwd_mask); -u32 ocelot_get_dsa_8021q_cpu_mask(struct ocelot *ocelot) +u32 ocelot_port_assigned_dsa_8021q_cpu_mask(struct ocelot *ocelot, int port) { + struct ocelot_port *ocelot_port = ocelot->ports[port]; + struct ocelot_port *cpu_port = ocelot_port->dsa_8021q_cpu; + + if (!cpu_port) + return 0; + + return BIT(cpu_port->index); +} +EXPORT_SYMBOL_GPL(ocelot_port_assigned_dsa_8021q_cpu_mask); + +u32 ocelot_get_bridge_fwd_mask(struct ocelot *ocelot, int src_port) +{ + struct ocelot_port *ocelot_port = ocelot->ports[src_port]; + const struct net_device *bridge; u32 mask = 0; int port; + if (!ocelot_port || ocelot_port->stp_state != BR_STATE_FORWARDING) + return 0; + + bridge = ocelot_port->bridge; + if (!bridge) + return 0; + for (port = 0; port < ocelot->num_phys_ports; port++) { - struct ocelot_port *ocelot_port = ocelot->ports[port]; + ocelot_port = ocelot->ports[port]; if (!ocelot_port) continue; - if (ocelot_port->is_dsa_8021q_cpu) + if (ocelot_port->stp_state == BR_STATE_FORWARDING && + ocelot_port->bridge == bridge) mask |= BIT(port); } return mask; } -EXPORT_SYMBOL_GPL(ocelot_get_dsa_8021q_cpu_mask); +EXPORT_SYMBOL_GPL(ocelot_get_bridge_fwd_mask); static void ocelot_apply_bridge_fwd_mask(struct ocelot *ocelot, bool joining) { - unsigned long cpu_fwd_mask; int port; lockdep_assert_held(&ocelot->fwd_domain_lock); @@ -2108,15 +2119,6 @@ static void ocelot_apply_bridge_fwd_mask(struct ocelot *ocelot, bool joining) if (joining && ocelot->ops->cut_through_fwd) ocelot->ops->cut_through_fwd(ocelot); - /* If a DSA tag_8021q CPU exists, it needs to be included in the - * regular forwarding path of the front ports regardless of whether - * those are bridged or standalone. - * If DSA tag_8021q is not used, this returns 0, which is fine because - * the hardware-based CPU port module can be a destination for packets - * even if it isn't part of PGID_SRC. - */ - cpu_fwd_mask = ocelot_get_dsa_8021q_cpu_mask(ocelot); - /* Apply FWD mask. The loop is needed to add/remove the current port as * a source for the other ports. */ @@ -2129,17 +2131,19 @@ static void ocelot_apply_bridge_fwd_mask(struct ocelot *ocelot, bool joining) mask = 0; } else if (ocelot_port->is_dsa_8021q_cpu) { /* The DSA tag_8021q CPU ports need to be able to - * forward packets to all other ports except for - * themselves + * forward packets to all ports assigned to them. */ - mask = GENMASK(ocelot->num_phys_ports - 1, 0); - mask &= ~cpu_fwd_mask; + mask = ocelot_dsa_8021q_cpu_assigned_ports(ocelot, + ocelot_port); } else if (ocelot_port->bridge) { struct net_device *bond = ocelot_port->bond; mask = ocelot_get_bridge_fwd_mask(ocelot, port); - mask |= cpu_fwd_mask; mask &= ~BIT(port); + + mask |= ocelot_port_assigned_dsa_8021q_cpu_mask(ocelot, + port); + if (bond) mask &= ~ocelot_get_bond_mask(ocelot, bond); } else { @@ -2147,7 +2151,8 @@ static void ocelot_apply_bridge_fwd_mask(struct ocelot *ocelot, bool joining) * ports (if those exist), or to the hardware CPU port * module otherwise. */ - mask = cpu_fwd_mask; + mask = ocelot_port_assigned_dsa_8021q_cpu_mask(ocelot, + port); } ocelot_write_rix(ocelot, mask, ANA_PGID_PGID, PGID_SRC + port); @@ -2191,43 +2196,66 @@ static void ocelot_update_pgid_cpu(struct ocelot *ocelot) ocelot_write_rix(ocelot, pgid_cpu, ANA_PGID_PGID, PGID_CPU); } -void ocelot_port_set_dsa_8021q_cpu(struct ocelot *ocelot, int port) +void ocelot_port_assign_dsa_8021q_cpu(struct ocelot *ocelot, int port, + int cpu) { + struct ocelot_port *cpu_port = ocelot->ports[cpu]; u16 vid; mutex_lock(&ocelot->fwd_domain_lock); - ocelot->ports[port]->is_dsa_8021q_cpu = true; + ocelot->ports[port]->dsa_8021q_cpu = cpu_port; + + if (!cpu_port->is_dsa_8021q_cpu) { + cpu_port->is_dsa_8021q_cpu = true; - for (vid = OCELOT_RSV_VLAN_RANGE_START; vid < VLAN_N_VID; vid++) - ocelot_vlan_member_add(ocelot, port, vid, true); + for (vid = OCELOT_RSV_VLAN_RANGE_START; vid < VLAN_N_VID; vid++) + ocelot_vlan_member_add(ocelot, cpu, vid, true); - ocelot_update_pgid_cpu(ocelot); + ocelot_update_pgid_cpu(ocelot); + } ocelot_apply_bridge_fwd_mask(ocelot, true); mutex_unlock(&ocelot->fwd_domain_lock); } -EXPORT_SYMBOL_GPL(ocelot_port_set_dsa_8021q_cpu); +EXPORT_SYMBOL_GPL(ocelot_port_assign_dsa_8021q_cpu); -void ocelot_port_unset_dsa_8021q_cpu(struct ocelot *ocelot, int port) +void ocelot_port_unassign_dsa_8021q_cpu(struct ocelot *ocelot, int port) { + struct ocelot_port *cpu_port = ocelot->ports[port]->dsa_8021q_cpu; + bool keep = false; u16 vid; + int p; mutex_lock(&ocelot->fwd_domain_lock); - ocelot->ports[port]->is_dsa_8021q_cpu = false; + ocelot->ports[port]->dsa_8021q_cpu = NULL; + + for (p = 0; p < ocelot->num_phys_ports; p++) { + if (!ocelot->ports[p]) + continue; + + if (ocelot->ports[p]->dsa_8021q_cpu == cpu_port) { + keep = true; + break; + } + } + + if (!keep) { + cpu_port->is_dsa_8021q_cpu = false; - for (vid = OCELOT_RSV_VLAN_RANGE_START; vid < VLAN_N_VID; vid++) - ocelot_vlan_member_del(ocelot, port, vid); + for (vid = OCELOT_RSV_VLAN_RANGE_START; vid < VLAN_N_VID; vid++) + ocelot_vlan_member_del(ocelot, cpu_port->index, vid); - ocelot_update_pgid_cpu(ocelot); + ocelot_update_pgid_cpu(ocelot); + } ocelot_apply_bridge_fwd_mask(ocelot, true); mutex_unlock(&ocelot->fwd_domain_lock); } -EXPORT_SYMBOL_GPL(ocelot_port_unset_dsa_8021q_cpu); +EXPORT_SYMBOL_GPL(ocelot_port_unassign_dsa_8021q_cpu); void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state) { diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 2c90a24ca064..5f88385a7748 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -654,6 +654,8 @@ struct ocelot_mirror { int to; }; +struct ocelot_port; + struct ocelot_port { struct ocelot *ocelot; @@ -662,6 +664,8 @@ struct ocelot_port { struct net_device *bond; struct net_device *bridge; + struct ocelot_port *dsa_8021q_cpu; + /* VLAN that untagged frames are classified to, on ingress */ const struct ocelot_bridge_vlan *pvid_vlan; @@ -865,8 +869,9 @@ void ocelot_deinit(struct ocelot *ocelot); void ocelot_init_port(struct ocelot *ocelot, int port); void ocelot_deinit_port(struct ocelot *ocelot, int port); -void ocelot_port_set_dsa_8021q_cpu(struct ocelot *ocelot, int port); -void ocelot_port_unset_dsa_8021q_cpu(struct ocelot *ocelot, int port); +void ocelot_port_assign_dsa_8021q_cpu(struct ocelot *ocelot, int port, int cpu); +void ocelot_port_unassign_dsa_8021q_cpu(struct ocelot *ocelot, int port); +u32 ocelot_port_assigned_dsa_8021q_cpu_mask(struct ocelot *ocelot, int port); /* DSA callbacks */ void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data); @@ -878,7 +883,6 @@ void ocelot_set_ageing_time(struct ocelot *ocelot, unsigned int msecs); int ocelot_port_vlan_filtering(struct ocelot *ocelot, int port, bool enabled, struct netlink_ext_ack *extack); void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state); -u32 ocelot_get_dsa_8021q_cpu_mask(struct ocelot *ocelot); u32 ocelot_get_bridge_fwd_mask(struct ocelot *ocelot, int src_port); int ocelot_port_pre_bridge_flags(struct ocelot *ocelot, int port, struct switchdev_brport_flags val); From patchwork Sat May 21 21:37:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12858046 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 5052DC433F5 for ; Sat, 21 May 2022 21:38:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346795AbiEUVib (ORCPT ); Sat, 21 May 2022 17:38:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346786AbiEUViS (ORCPT ); Sat, 21 May 2022 17:38:18 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2066.outbound.protection.outlook.com [40.107.22.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B92F532FF for ; Sat, 21 May 2022 14:38:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ofTL1UEGYglmmejpYwQ0PrPBQidzw6W9ur5+NjWb2Sv2gnmFmJrpiXx6Z0Ul382r/FmV8Yiy9k6+iDgTQY7AsmfSqO3hwoj1WRrRkk5/DcR4OyLOMB6gZNhEwHGaaK3in1TFZE+CX+nvfyFP8fKPMd0JQv8c3ONzBFjb5c/j2uj0nRlubAgH+QYdBhV+wjDb9Mhv0p3or3vA79Vk4u+fuxvkkFuteUtKhATU0TanERWXDckovanldIUUQfCpZVX+Z5MiRxPsENvnesODuLck2VRc+uH1Yra391dULZ8rvvxZ4deLDSHiHQQRrqBUuNIPrYKU24oOcW/sf9xhQa/dEg== 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=UDlTloIpa6EUEbpw7Qwl3qE9gxi/h/Gezie1iv6Yg3Y=; b=EUrOKBhBrpZmflI2azH+zz2GyRUQOJF4m1BOxBLsGE+SRfVoPzhvol31FGBC+nsJ2x35b3lTUj918Vt0Ec9NcD1jIZbWpj8YPgnTqZpDocSCq+SJSXlQF6lSqpSrmLHBVXpD6ZIIsEqm0yXgBv+N3Ju77l2IyH9+Ha2TxR8elMve473YyJgvyQxxPgFXh4NIGlVSZKg/xdBIRvFmDAlScBulhCJH/somUbQO6o0GDA/ZOp7Hnnkg3gVMDpqYnxEhivU6a/bJUlSkLGWDXd/JSmm9kRnQnMrzr8G1Y/JgmKFeKS8hS1rk8wjYLDL9P3X5x9OQ8k4AsmsO9bletv4q1w== 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=UDlTloIpa6EUEbpw7Qwl3qE9gxi/h/Gezie1iv6Yg3Y=; b=KYroqAsKQifI4MNKt30Fq24WF7INraA5m91AhnvaXkhJsDUh2iJk8PynQYdyqLeJ6m+K5Lfk73zUx7PYpKGL4ReTKd2JJZqYkylH6oEu0GIL+lvlHw0ZTxRbPayILCn73xCohZaGbN9mDyLuLN78lMtl1t9ZmeTW04G6Zrc5Uu8= 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 AM0PR04MB6275.eurprd04.prod.outlook.com (2603:10a6:208:147::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5273.19; Sat, 21 May 2022 21:38:06 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::fd1f:cc16:dafe:4bf5]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::fd1f:cc16:dafe:4bf5%5]) with mapi id 15.20.5250.014; Sat, 21 May 2022 21:38:06 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Jakub Kicinski , "David S. Miller" , Paolo Abeni , Eric Dumazet , Florian Fainelli , Vivien Didelot , Andrew Lunn , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Colin Foster Subject: [PATCH net-next 6/6] net: dsa: felix: tag_8021q preparation for multiple CPU ports Date: Sun, 22 May 2022 00:37:43 +0300 Message-Id: <20220521213743.2735445-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220521213743.2735445-1-vladimir.oltean@nxp.com> References: <20220521213743.2735445-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM6P193CA0079.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:88::20) 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: 1591f129-f24c-4d7f-e35c-08da3b72311f X-MS-TrafficTypeDiagnostic: AM0PR04MB6275:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: C+KHZmtnP3EOBg/dn+12/5pVsTcsB/oIdiiW6t4TVtL6njTcR81s8OFZEmbwpx9+/Y/BuoRO12be89ETqqHkDTAKMrJVbgZKlqHv798SNp25CcYFJcaDxb0nCNrsHwYTg1idtsXmAhe5dDzXRKo6RBYos6ofkBdd8bSQtCYSvZdgx/Zxu8rA3MUD5Zx/NFeo4rsO/sHy0GwbzAdfFislvCLSfr5iPGM7wAm3tVRgHUzC/oGLY0l9YJxiSP91ARIDVpDsQdHWC+11NjimBJ7wtCVuGRWy7IKv7CsOBEg9lJ9SU8a7RvK9WlYEiAL7fE1BIQVU50G32Q5doTuYkmsOB8VEy9mUrE3yAKfHhThSd6ldZ76MQX7ERHtibUy4zqgyScs27umJV+nJZbNQkY2MokLjYdUo5zw3qsmh8mgstCIOSK/9opaCrMBNNmlznysuQEfqsniHvsfDYY1Ou4iewJ/NZwovFF+NqLtnpvpAnSdBVFmWUHsI6SBaQNmsUJpuDdZ+6EnvS/WmjVYh50tE4YcvpQjGu6aMDSbfiNfJgzNZVUWRiOwgOPqPL9Kg+95/J24tbsxOQWnx+/cqe74Qvw1/Xi2ZTBVi1NTJ/pRWt0itWMrtZixYWd7WE1Y1LmBWExlfKPfF6XkR4BmRf3vJRQSy7UKAROvNBuTpdLmDlWYmz5smu02R6tvHy2agTasLIjM+0MV6mlsj1HqY4xgQrw== 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:(13230001)(4636009)(366004)(6666004)(86362001)(26005)(6512007)(6506007)(52116002)(36756003)(2906002)(6486002)(8676002)(66946007)(4326008)(66476007)(66556008)(54906003)(44832011)(83380400001)(7416002)(2616005)(186003)(508600001)(38350700002)(8936002)(38100700002)(5660300002)(316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NRj6PHxRsVGFrfm1CyK/XYK1NM7djVhnIwVAhh+kJX4JG0Qf7cebct0tEGWxD4SWuKyv0yFYXX5Na1bkBkknLMd8zJE3JWG0EeKZ7TFkPL0XEhyB+StdcrUAISa+3HtMb4Tof4b5MvI/24Bo1qoKmUxd61AUo6R0ZsO1Ei0OaxWA9dL6/AfteYQtNFJ02YlUyLOj/q6o53yJgazLVjPYz8bQHeE/iyOHxrue3hWoDB6c0Md364QJF3eia4vzlcXeuW2T4xigt+aQuQHoFV4BvOXPZTcGogFcbMhdk1EOCFooc1S2tfD+LHWGBambKuITc1p1eyI6SuF+78UCZXZSy40O80CcxPR+D3+9b9gAanxy4RUdyyPj8KT93V1+vzRfZj9g5aDkmnisw6RS9THXyvN0HbYfkuM5yvOqnowqXXHXafKCqxjIVz3q/Xbvq+zZXQQ5IFtoIRqFweX4pg5gTfFD1sfX8702rY9IkT8EDOMmEq8UNT5pIa85ZnghLmKmPItp0LdQd8I0pJXWxVr8QvaaJgov9RMXDdc4KzTr2pob0eAo10J6GaSzCMJRTKbft8YlcKtPxR+mpU3AW33wAwLshwHtiYNBHSsn4FT4A+gdZkvrMMSJTTG/ZaSJtYjEsOuSXpXMu8H1HYXk7nbeulHREHC2OJWphmQzEfmEAJoBH09WtqxRUvXF+O+LpA15VTeLXN9mr/vz+Xzbvx6bHWLkvO3TNGmMQr6hnN8ZkNT3UABtkzTr8DrixsA9ZBkcq6Z+LyOl2WDtqeA/1ySXkQnXL9UY= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1591f129-f24c-4d7f-e35c-08da3b72311f X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2022 21:38:06.4549 (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: xrHgiFdrYpyf4btActmQd25RY/eM7zgFf09gTZAooJbGP40A+Xnm0P6RKhk7O0yn0t7FuFCZhjOjUdirQnECNQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6275 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Update the VCAP filters to support multiple tag_8021q CPU ports. TX works using a filter for VLAN ID on the ingress of the CPU port, with a redirect and a VLAN pop action. This can be updated trivially by amending the ingress port mask of this rule to match on all tag_8021q CPU ports. RX works using a filter for ingress port on the egress of the CPU port, with a VLAN push action. Here we need to replicate these filters for each tag_8021q CPU port, and let them all have the same action. This means that the OCELOT_VCAP_ES0_TAG_8021Q_RXVLAN() cookie needs to encode a unique value for every {user port, CPU port} pair it's given. Do this by encoding the CPU port in the upper 16 bits of the cookie, and the user port in the lower 16 bits. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/ocelot/felix.c | 104 ++++++++++++++++++++------------- include/soc/mscc/ocelot_vcap.h | 2 +- 2 files changed, 65 insertions(+), 41 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 01d8a731851e..3e07dc39007a 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -45,24 +45,26 @@ static struct net_device *felix_classify_db(struct dsa_db db) /* Set up VCAP ES0 rules for pushing a tag_8021q VLAN towards the CPU such that * the tagger can perform RX source port identification. */ -static int felix_tag_8021q_vlan_add_rx(struct felix *felix, int port, u16 vid) +static int felix_tag_8021q_vlan_add_rx(struct dsa_switch *ds, int port, + int upstream, u16 vid) { struct ocelot_vcap_filter *outer_tagging_rule; - struct ocelot *ocelot = &felix->ocelot; - struct dsa_switch *ds = felix->ds; - int key_length, upstream, err; + struct ocelot *ocelot = ds->priv; + unsigned long cookie; + int key_length, err; key_length = ocelot->vcap[VCAP_ES0].keys[VCAP_ES0_IGR_PORT].length; - upstream = dsa_upstream_port(ds, port); outer_tagging_rule = kzalloc(sizeof(struct ocelot_vcap_filter), GFP_KERNEL); if (!outer_tagging_rule) return -ENOMEM; + cookie = OCELOT_VCAP_ES0_TAG_8021Q_RXVLAN(ocelot, port, upstream); + outer_tagging_rule->key_type = OCELOT_VCAP_KEY_ANY; outer_tagging_rule->prio = 1; - outer_tagging_rule->id.cookie = OCELOT_VCAP_ES0_TAG_8021Q_RXVLAN(ocelot, port); + outer_tagging_rule->id.cookie = cookie; outer_tagging_rule->id.tc_offload = false; outer_tagging_rule->block_id = VCAP_ES0; outer_tagging_rule->type = OCELOT_VCAP_FILTER_OFFLOAD; @@ -83,16 +85,19 @@ static int felix_tag_8021q_vlan_add_rx(struct felix *felix, int port, u16 vid) return err; } -static int felix_tag_8021q_vlan_del_rx(struct felix *felix, int port, u16 vid) +static int felix_tag_8021q_vlan_del_rx(struct dsa_switch *ds, int port, + int upstream, u16 vid) { struct ocelot_vcap_filter *outer_tagging_rule; struct ocelot_vcap_block *block_vcap_es0; - struct ocelot *ocelot = &felix->ocelot; + struct ocelot *ocelot = ds->priv; + unsigned long cookie; block_vcap_es0 = &ocelot->block[VCAP_ES0]; + cookie = OCELOT_VCAP_ES0_TAG_8021Q_RXVLAN(ocelot, port, upstream); outer_tagging_rule = ocelot_vcap_block_find_filter_by_id(block_vcap_es0, - port, false); + cookie, false); if (!outer_tagging_rule) return -ENOENT; @@ -102,12 +107,14 @@ static int felix_tag_8021q_vlan_del_rx(struct felix *felix, int port, u16 vid) /* Set up VCAP IS1 rules for stripping the tag_8021q VLAN on TX and VCAP IS2 * rules for steering those tagged packets towards the correct destination port */ -static int felix_tag_8021q_vlan_add_tx(struct felix *felix, int port, u16 vid) +static int felix_tag_8021q_vlan_add_tx(struct dsa_switch *ds, int port, + u16 vid) { struct ocelot_vcap_filter *untagging_rule, *redirect_rule; - struct ocelot *ocelot = &felix->ocelot; - struct dsa_switch *ds = felix->ds; - int upstream, err; + unsigned long cpu_ports = dsa_cpu_ports(ds); + struct ocelot *ocelot = ds->priv; + unsigned long cookie; + int err; untagging_rule = kzalloc(sizeof(struct ocelot_vcap_filter), GFP_KERNEL); if (!untagging_rule) @@ -119,14 +126,14 @@ static int felix_tag_8021q_vlan_add_tx(struct felix *felix, int port, u16 vid) return -ENOMEM; } - upstream = dsa_upstream_port(ds, port); + cookie = OCELOT_VCAP_IS1_TAG_8021Q_TXVLAN(ocelot, port); untagging_rule->key_type = OCELOT_VCAP_KEY_ANY; - untagging_rule->ingress_port_mask = BIT(upstream); + untagging_rule->ingress_port_mask = cpu_ports; untagging_rule->vlan.vid.value = vid; untagging_rule->vlan.vid.mask = VLAN_VID_MASK; untagging_rule->prio = 1; - untagging_rule->id.cookie = OCELOT_VCAP_IS1_TAG_8021Q_TXVLAN(ocelot, port); + untagging_rule->id.cookie = cookie; untagging_rule->id.tc_offload = false; untagging_rule->block_id = VCAP_IS1; untagging_rule->type = OCELOT_VCAP_FILTER_OFFLOAD; @@ -143,11 +150,13 @@ static int felix_tag_8021q_vlan_add_tx(struct felix *felix, int port, u16 vid) return err; } + cookie = OCELOT_VCAP_IS2_TAG_8021Q_TXVLAN(ocelot, port); + redirect_rule->key_type = OCELOT_VCAP_KEY_ANY; - redirect_rule->ingress_port_mask = BIT(upstream); + redirect_rule->ingress_port_mask = cpu_ports; redirect_rule->pag = port; redirect_rule->prio = 1; - redirect_rule->id.cookie = OCELOT_VCAP_IS2_TAG_8021Q_TXVLAN(ocelot, port); + redirect_rule->id.cookie = cookie; redirect_rule->id.tc_offload = false; redirect_rule->block_id = VCAP_IS2; redirect_rule->type = OCELOT_VCAP_FILTER_OFFLOAD; @@ -165,19 +174,21 @@ static int felix_tag_8021q_vlan_add_tx(struct felix *felix, int port, u16 vid) return 0; } -static int felix_tag_8021q_vlan_del_tx(struct felix *felix, int port, u16 vid) +static int felix_tag_8021q_vlan_del_tx(struct dsa_switch *ds, int port, u16 vid) { struct ocelot_vcap_filter *untagging_rule, *redirect_rule; struct ocelot_vcap_block *block_vcap_is1; struct ocelot_vcap_block *block_vcap_is2; - struct ocelot *ocelot = &felix->ocelot; + struct ocelot *ocelot = ds->priv; + unsigned long cookie; int err; block_vcap_is1 = &ocelot->block[VCAP_IS1]; block_vcap_is2 = &ocelot->block[VCAP_IS2]; + cookie = OCELOT_VCAP_IS1_TAG_8021Q_TXVLAN(ocelot, port); untagging_rule = ocelot_vcap_block_find_filter_by_id(block_vcap_is1, - port, false); + cookie, false); if (!untagging_rule) return -ENOENT; @@ -185,8 +196,9 @@ static int felix_tag_8021q_vlan_del_tx(struct felix *felix, int port, u16 vid) if (err) return err; + cookie = OCELOT_VCAP_IS2_TAG_8021Q_TXVLAN(ocelot, port); redirect_rule = ocelot_vcap_block_find_filter_by_id(block_vcap_is2, - port, false); + cookie, false); if (!redirect_rule) return -ENOENT; @@ -196,7 +208,7 @@ static int felix_tag_8021q_vlan_del_tx(struct felix *felix, int port, u16 vid) static int felix_tag_8021q_vlan_add(struct dsa_switch *ds, int port, u16 vid, u16 flags) { - struct ocelot *ocelot = ds->priv; + struct dsa_port *cpu_dp; int err; /* tag_8021q.c assumes we are implementing this via port VLAN @@ -206,38 +218,50 @@ static int felix_tag_8021q_vlan_add(struct dsa_switch *ds, int port, u16 vid, if (!dsa_is_user_port(ds, port)) return 0; - err = felix_tag_8021q_vlan_add_rx(ocelot_to_felix(ocelot), port, vid); - if (err) - return err; - - err = felix_tag_8021q_vlan_add_tx(ocelot_to_felix(ocelot), port, vid); - if (err) { - felix_tag_8021q_vlan_del_rx(ocelot_to_felix(ocelot), port, vid); - return err; + dsa_switch_for_each_cpu_port(cpu_dp, ds) { + err = felix_tag_8021q_vlan_add_rx(ds, port, cpu_dp->index, vid); + if (err) + return err; } + err = felix_tag_8021q_vlan_add_tx(ds, port, vid); + if (err) + goto add_tx_failed; + return 0; + +add_tx_failed: + dsa_switch_for_each_cpu_port(cpu_dp, ds) + felix_tag_8021q_vlan_del_rx(ds, port, cpu_dp->index, vid); + + return err; } static int felix_tag_8021q_vlan_del(struct dsa_switch *ds, int port, u16 vid) { - struct ocelot *ocelot = ds->priv; + struct dsa_port *cpu_dp; int err; if (!dsa_is_user_port(ds, port)) return 0; - err = felix_tag_8021q_vlan_del_rx(ocelot_to_felix(ocelot), port, vid); - if (err) - return err; - - err = felix_tag_8021q_vlan_del_tx(ocelot_to_felix(ocelot), port, vid); - if (err) { - felix_tag_8021q_vlan_add_rx(ocelot_to_felix(ocelot), port, vid); - return err; + dsa_switch_for_each_cpu_port(cpu_dp, ds) { + err = felix_tag_8021q_vlan_del_rx(ds, port, cpu_dp->index, vid); + if (err) + return err; } + err = felix_tag_8021q_vlan_del_tx(ds, port, vid); + if (err) + goto del_tx_failed; + return 0; + +del_tx_failed: + dsa_switch_for_each_cpu_port(cpu_dp, ds) + felix_tag_8021q_vlan_add_rx(ds, port, cpu_dp->index, vid); + + return err; } static int felix_trap_get_cpu_port(struct dsa_switch *ds, diff --git a/include/soc/mscc/ocelot_vcap.h b/include/soc/mscc/ocelot_vcap.h index de26c992f821..c601a4598b0d 100644 --- a/include/soc/mscc/ocelot_vcap.h +++ b/include/soc/mscc/ocelot_vcap.h @@ -11,7 +11,7 @@ /* Cookie definitions for private VCAP filters installed by the driver. * Must be unique per VCAP block. */ -#define OCELOT_VCAP_ES0_TAG_8021Q_RXVLAN(ocelot, port) (port) +#define OCELOT_VCAP_ES0_TAG_8021Q_RXVLAN(ocelot, port, upstream) ((upstream) << 16 | (port)) #define OCELOT_VCAP_IS1_TAG_8021Q_TXVLAN(ocelot, port) (port) #define OCELOT_VCAP_IS2_TAG_8021Q_TXVLAN(ocelot, port) (port) #define OCELOT_VCAP_IS2_MRP_REDIRECT(ocelot, port) ((ocelot)->num_phys_ports + (port))