From patchwork Fri Sep 8 13:33:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13377472 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E0F763B0 for ; Fri, 8 Sep 2023 13:34:17 +0000 (UTC) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2040.outbound.protection.outlook.com [40.107.22.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1F8719BC; Fri, 8 Sep 2023 06:34:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J1sx+59DrrqIf9wVvMB5jpsK9cusDORMgyq7uUTEhwEHdQLvC/LYbFToL91WcFugj4nqQwXxhGQiVvEmatHTLcpR9UGcdJsEWzRL0P7LWMb6clOYh+KivnNawfnsxnq+XJwAkwM01ZAGOQI2HRNgEsig2/sWZxR2bouw5DP5WHVn+33xRrVWpRN/8XnLJF7YeLZka1YpVpwT++RpHK/6R5A3xnm2ODgP1xwUYBJwVFh50H9ZsOgPiSP/3DfhKI9I7zzL1WK4szDL1262dYusBrNRYIXLcGbpsBOtACbNMiC0jesM2KD873EGnfDGvFLRQrI4AzzyWtWE5ttLd+D2lw== 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=xjb7B1O9DlPIb0eyKB2G/SgS2Ntu/1itOg2hzWof3RE=; b=nMlKtWqRciqpB+jRNWS7rpGXlqwAoPTC10ppV2Zm38122xcIx711Wq1r8X6tgAnGR8lQB4D20MmwWNmJPYyFcKNhQLW+Xir8goITxwGhM13xl4A+Fn4nKxPJ8SUTy8lkqCF8OOJvUNkTS3u5PGDbT7RHFAY2CVVHVJ+Y77JeLtIE7EcgDMu6dY4an9QkBQ3rMfiyMgsMCm0Zejpjb1U6ZLOb3l5EBEvOIKS+m5xWCBPlefs31ujkTZIY3yXqMnrP7Sm4mR+O1ayvwg2WyE1cW8Er9F+M4NSGEPW3I7PTbr1nKAquPSN4lDxYTOw08lq4UK3+OfFsAsN6W4sKdDq3+A== 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=xjb7B1O9DlPIb0eyKB2G/SgS2Ntu/1itOg2hzWof3RE=; b=neGwolei2FmbrIAkvNLjjYJu9YpR7pKYlyj8++aM8s7o7dOWyRgwYkcMeBsVkDf8eH4QGTl9dsKuyb5VlLL39ST04M+G45Xf3iyj/7Mi7x/4Y3bbh2JB1JoYs4zz8RrU/xHkI4tmYS2xT4hbJq2kZvTvLQr8X3zVA2SG8koYAoI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by PAWPR04MB9718.eurprd04.prod.outlook.com (2603:10a6:102:381::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.34; Fri, 8 Sep 2023 13:34:04 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454%3]) with mapi id 15.20.6745.034; Fri, 8 Sep 2023 13:34:04 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Eric Dumazet , Jakub Kicinski , Paolo Abeni , "David S. Miller" , Xiaoliang Yang , Andrew Lunn , Florian Fainelli , Yanan Yang , linux-kernel@vger.kernel.org Subject: [PATCH net 1/5] net: dsa: sja1105: hide all multicast addresses from "bridge fdb show" Date: Fri, 8 Sep 2023 16:33:48 +0300 Message-Id: <20230908133352.2007218-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230908133352.2007218-1-vladimir.oltean@nxp.com> References: <20230908133352.2007218-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0036.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::23) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|PAWPR04MB9718:EE_ X-MS-Office365-Filtering-Correlation-Id: ad7d018d-bab2-4d38-186d-08dbb07044df X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6dvDPh3O0bMd2iy7K4nJ8yA2Bg8E6z+w/szUNSXNyAXFywz6hNMe1FYgeLkXecEFYcSyYXbkTv1oujUgJ1Ja4LhuwzkOzgoCprQCKfxPGGKs1lccPatYVm6/mCXHWmP85MaXBxh7OFrF8azWS4ueiOYOZQRy32L6htI6oq/lOEIKiG8Ko+MlJeWugr2gmrgYb+iwwIDedz6hhyIIDMUyajYXclJn5tQcu5We4y/i67YQXXmv8ZTK8nifA0lq0oiJgwqlvsXozOK93eo9J1luSfqmSra9SPXAoABOCrNy15i71RqbOe18TY5xQEiUP6f3wFCxaj1Wf+JAtFx+7Gvj1Fkgt7RsfBugCWU7Pf+4qaH/lFudYxVV6FJkmpAOxsDitPrTxvsPFQfgqD/vhKjwsdEugl/29/XSZjBsouwn/5CnMyahFzBphi1XBexrBmsA/7ElHxmZHDlWWJQzNBrPyoUoZscOdyGXET1bHAevo5kSO+wTW8FJe87VYnJK+zvkYRAGPbC+BQRmjy+uhMwKpn3IxBJ6CDP/vUjClIUGhRTn5iux4MfQxOhGyFuou0OLvLcr851+QRn3Z1nOyFmpbsudTJa/MRiAosBA2d3Q+TjZqc2D1PUku2g1OdgcTBUF X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(396003)(366004)(346002)(39860400002)(376002)(1800799009)(186009)(451199024)(2906002)(38350700002)(38100700002)(36756003)(6506007)(41300700001)(6512007)(6486002)(52116002)(66556008)(54906003)(2616005)(66946007)(66476007)(6916009)(316002)(1076003)(86362001)(8676002)(8936002)(4326008)(6666004)(478600001)(5660300002)(26005)(83380400001)(44832011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NWv2FmCVoSVhez8nJVBRdWsgZ1B5jXKiGoM7XL1/43CQoNiF0m9RqN8N/nugU1yd8D54XE62yZombZoSuVMqy9mW81Q+dmKhpphdiBK1EsMxl11kA6VIAVTQAWbzqTUExj2E481KHIT3DCzfJBdJVFRn0/OOyLp1QucSpwCu7kpRguifXVQHm24i1kY4YURZRagtS7XfKq1Hs4pwKpNnTuPPe3dl5PyXkfyk0p7RKz3i4OueptUXQKuBsvqis6ue+Ls2f6SSUiUtGDWeQ2D/Po47NRgMsckkPdyv8xU2b9i69+YKTvfOwnriZEiP+daACQQOKz2eAqj3c5x2gb26a1lnMAZcsdK0oDBQMODaCWzTW+yvDTk6AzXGYhMTENWEBMAOejgqIgHt4NxHNKhXM79AqF/U3nYKSOv3wWyn4jyG3n/Z+6TuiXnUZwexeQ841aSgGu8yBlixI1NkdPx0e9Gs8L/2fCuN6Fv5Ftze9Q44FSjkihgpJa+eX7mQD+weY6y4S9ZPUrQR6HxOn6Ep5kt1ER2XlqBZslEdU35KRQuvG5Xm53wwTxRFCO4PlN8eCNtI3h0UYI+ACX6iBw+YdMi+veAig5arnYlCq4jlVjflAbf3b5eT8QhVqLYG3kr9M0FryI3m3fBmpdOgCHtytFlcs2qQeiwYG5Y+BWXqdoSXceQXD8TSMWYDKnG7wlJG8ZYH83LhoUVleSKsLbJ9h0h4ywWju9/OFJjBT9isxa08sCiZ2p0dEdzTTjO2KkuSRTziA0fV4x4Z6AzQsAn7pmUOGf9/UDHnOsK594SNqPpgJrSq8FnB7XK8OrvKMXRWwGA6PgPZ65CyPik5TbAmQIPwm5geNxfj2/17cFA/okdvt+fj72600UY7Yq55/flk7NBDTUN/YeGqfxseJokdUu+l6Tse2TB4obsqJWgkN1pIkcRYSQr75yxEaoePY4crBzNW8Sd1KK5sB/b1DMo1O+qQL9J9Q9lzSzMKS2U1f2tL1luR/85v6EpRSZ8gVbHQv/n2J0LaqmZx9vR4+0TAcAnJgaoJBvKDK1jeAA5H1OCOQQ+Wojw8NhM+HXDHjNdP7Mnf83Zu37uKFTaKvbqzRyBsfgZh4YFZ/qoIl3npsYaHTjomsuz0kzwORhJq2hPucenNa+oDG+DStM9i8YyHVJF3tLiMR/8lZcYhDJ/ijYIq3taRHuQUD5NxJRFtFuPrPWn6UmDeOxzsiEDVRofReJ1fNxa8e1Ev/Cxln0svQXEVC7VDh7JuR4UcPe+JYhcsH1T4G0ePQ8aN+UhU3Xa97hIckVmrQjcs3ZNxZ/Pxu6cNyfdRQubDnooA2Qg2zk7FOdXTzEwV58fcq/PKuslYCUO3eWSaVQbIWu7hcA6kmgDhskxeEWZz+xJMu1oDgfIu+e5HNHCZCxtYh2x8gFy6FkFSuYhN1z3CrYWXBGJ0VDpLi4ZJq5LCIu3hu9jOfSai0LnOWQM5c79pQ3pArwMPe3nxvYQoNTe78ozkhPOuvmu+p0FmVPYJ70a5Wga/m+NNid0WORoAv7Qeum7R25NUF/CWxKfJAtKpM6zGDucrVD9hC/ymLh90AWoUfmSsik2qDwQqMFILM9FQhAqVEbXKWg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ad7d018d-bab2-4d38-186d-08dbb07044df X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2023 13:34:04.2735 (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: n3Yr5m+oxh8Ext7jAwy3Wgcv25tXlG84wuheWI72g7z3QFW/zrXeXVbGcTnedPWOgChpmp4GjligOoYzyUDrqA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR04MB9718 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_BLOCKED, 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 X-Patchwork-Delegate: kuba@kernel.org Commit 4d9423549501 ("net: dsa: sja1105: offload bridge port flags to device") has partially hidden some multicast entries from showing up in the "bridge fdb show" output, but it wasn't enough. Addresses which are added through "bridge mdb add" still show up. Hide them all. Fixes: 291d1e72b756 ("net: dsa: sja1105: Add support for FDB and MDB management") Signed-off-by: Vladimir Oltean --- drivers/net/dsa/sja1105/sja1105_main.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index a23d980d28f5..11c917d5ce43 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -1868,13 +1868,14 @@ static int sja1105_fdb_dump(struct dsa_switch *ds, int port, if (!(l2_lookup.destports & BIT(port))) continue; - /* We need to hide the FDB entry for unknown multicast */ - if (l2_lookup.macaddr == SJA1105_UNKNOWN_MULTICAST && - l2_lookup.mask_macaddr == SJA1105_UNKNOWN_MULTICAST) - continue; - u64_to_ether_addr(l2_lookup.macaddr, macaddr); + /* Hardware FDB is shared for fdb and mdb, "bridge fdb show" + * only wants to see unicast + */ + if (is_multicast_ether_addr(macaddr)) + continue; + /* We need to hide the dsa_8021q VLANs from the user. */ if (vid_is_dsa_8021q(l2_lookup.vlanid)) l2_lookup.vlanid = 0; From patchwork Fri Sep 8 13:33:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13377473 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DAED63B0 for ; Fri, 8 Sep 2023 13:34:18 +0000 (UTC) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2040.outbound.protection.outlook.com [40.107.22.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50FA51BF5; Fri, 8 Sep 2023 06:34:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DqhNWsjEeTfxrn1jStt8dYj9eJyIVn97atz38MLNL5FBUSlZRQ5eR7PjJFpo0g3f3X5JrQ4Dpuy79r1rI15iCrYNu7zesnrKl0zV6/mOO2d9RPtbmHYnow0ZhyKJe4JYT2uhgM5cZ/STr1qoNtVCdWX9CQ0FGgcSothbkk0o7K+W+NVhvLqt4ej9CgvQryncL05a1NtbD5i9UBZ3ABd+QeOTzyH1+80xOsFio569EAqV6YxWlRyV7pJxXXP8epULK7KvkY720yWUWE+RGjjVQPU6L3wQyWP/YzAKOMAy/yhe/duzcwc1pCTvkMBTyWiXYh99yDUNaRTUt6rZ6BWtuQ== 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=ySJTRLEGqGbB3AVN1DuxY0Qnndm7K6rlK8U+gwGYmiU=; b=jPQSH4YHiEK75OkYlw9yPZmxg5uzr8WMA4bF5OYSBY9u1weEGw5o5TEsR7k+y4E7c/j6nqvXdmRjzJlhcxC2Zou5mEZZAxcI1RqxyFoW5jNJhkvFIrZl5Tpfn7um3sMjiVFI1N2uEDSmVfKqLBN3r42Xp01PiVsKsTvgQ3yWQUBRtcQgUa/S+IXaGD9pCmJikidd3F0vWrVUZi1Do0yky4dsMzDZhRnVPCcEgZyTJ1R98xJ0NSc3TmqCE4QtgVZTYxHEANcnBl8mcgGATvxAvAnt5cMLZTptifkDssS7TiKOiv7EdixIlEkSL2rdS1ufMV9L5WBfrVOuA5NceYTv8Q== 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=ySJTRLEGqGbB3AVN1DuxY0Qnndm7K6rlK8U+gwGYmiU=; b=RbrFflcdmJhOmSikz9mFDYwD9QkQT5X4eub9LMe3UeJc30cyYYOMSM6WWxKe1BsaqVVXljQH2MgKSyG37Z+7DHE6JkSp/rVVWU1/WzDDU7WbcrYVErNNS8UItNvCnZW3rF+2BltWmLUer85h8EoJi8QeRJew7pF7ih+FbPyLGdI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by PAWPR04MB9718.eurprd04.prod.outlook.com (2603:10a6:102:381::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.34; Fri, 8 Sep 2023 13:34:05 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454%3]) with mapi id 15.20.6745.034; Fri, 8 Sep 2023 13:34:05 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Eric Dumazet , Jakub Kicinski , Paolo Abeni , "David S. Miller" , Xiaoliang Yang , Andrew Lunn , Florian Fainelli , Yanan Yang , linux-kernel@vger.kernel.org Subject: [PATCH net 2/5] net: dsa: sja1105: propagate exact error code from sja1105_dynamic_config_poll_valid() Date: Fri, 8 Sep 2023 16:33:49 +0300 Message-Id: <20230908133352.2007218-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230908133352.2007218-1-vladimir.oltean@nxp.com> References: <20230908133352.2007218-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0036.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::23) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|PAWPR04MB9718:EE_ X-MS-Office365-Filtering-Correlation-Id: bfddfd14-ac41-425e-aeb7-08dbb0704558 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lvd+oZA9MprYD3NHC3S6DVKi7sn+eEvrKdN4ytciunQChPFIif1M7jniAfM54TQObK9/oP3twNNqn+bkw5YZgCQuK3a6G4ZV6/mF89xxdTjayficnQr3OEup8C1baHGOYpiNWw9b/OHcNbiTTlnki/O44jJ7a6ouFfkt1gjGdJzD6PgBwK973MpArIJnmH5tDkSMqgDHkX3gs6eZNgEckTQVZc7TSdbBURr9N67wB+EzVoUWJSAyQtLtF3rP47WVTFtrhvU7uqqQVlfypHJBTGrSPV6WcOwdgWSy//C9wp+eZnDNCFL7V+wGGXyui3ZmFZLRoXNfpZ6p7gOxpQtgOJZ0pnW101hJ/47tIp+AOyKAODzggXV26C+G+Xryvh0F/8AgwbUrWezGkuIHRLeUTHx2tJ0R1ADN2CZA8Unt88qLwbPbqPzkwi37BCtZUlYKIhMSgmCo6i0rYQLsTOAF0rgq4oig0MWx/8eIuG+xH2YyOFNxYkovacmp7H6/oPEAGVSCnP5feAppDxw3JYJ20llxGmYbI6+dCmgShxREtEJKlpvw/eAmlIdfzXZ/GIiVpHJ5RoUE9M6IjsiAZgmOAm9xIEqhdZtu1fyhB4lxSro6V+crPeIYnhnCMtv5px1h X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(396003)(366004)(346002)(39860400002)(376002)(1800799009)(186009)(451199024)(2906002)(38350700002)(38100700002)(36756003)(6506007)(41300700001)(6512007)(6486002)(52116002)(66556008)(54906003)(2616005)(66946007)(66476007)(6916009)(316002)(1076003)(86362001)(8676002)(8936002)(4326008)(6666004)(478600001)(5660300002)(26005)(83380400001)(44832011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mm6nMtPIt8qqPTr7ooXrxWUuo1wPGXjLroiPhq4SqB/U2EuOz9F0j3WcNeKQy2Z53iU6WfSrJ412tYGAFpDyEEsrBevcBrAdNJUhXLNQSWKDINPm5sJ6WcOevYXqGj38SAGeCoiKlgJGrzUPLjJzmbUi2IqpPPKfaSHF5HY4avAf1DHVE4NxsRf86B+fsTupnMhjXbFp79suH3Fl5QCu+nEv8em4eZXLTopFVKb+6XtRc3LBT2rmWey8067NPPYutbbrZ028t5zkVEt+yzOGNEk70FL9Gg9FTzd3dj9UyW3KibE+Rn+ycI3apRIV17b3o8pWg6748ABIMao/ng6n3TtzXCQLUD+gJdjozTCBuEWN3b2/uUaNJuXtnUlOuBek8lTEhVlLg7bGJCauJU4OJ3TJwsYGmqSRlpENUrXBEoF3y9Ceb+ggKOvGBQ3T933lMPU4iO6bB5dU/1jaIruVPhcmcnasPbR01OtxsHgwYl0YihQ6b2CcOLlB++QOCC4b3p8Gzqak8xj0wcDUkQe5wDPBplSHbXliK8rA+iYfyTfT6BcSXT92evVKN1/UNlEyCCNeSNRolYmw/+WzOtmVbRiFz27h2zAS2DGPCwb3LAehdIUgQuJmdbRRAWy+QvaxojJRBvmOpIuHNTcGRKbrsIJObbl14ZHdv394ztLKmw4YJOjMZ9/CzRqumGvKUBqikY283TmAtSVmFKIULCMPCfBfp7pEQRgSywnKuPZMLihMy+4EfvCTmMZQokQ9svZA2iM4wuQDPXnmVZMiBfBe+XDvvA/HUSMoKUwXs7Pe7GRiGPB35JuGI4HAI0321RJrLE0F372EyOa7GARbz7A+rAQpSpXjUIEOeW/GfnzT679bIaOuT6eZgFNKABEHhq2YTWQFRik7PPZ8PYPNWssep5M57oCQ2lbHRJgg/ov7IDWVVjUorzDdQyqmCY8dcyWV3iy1o+9rUQ2Dl/gC7YFDmCNoPtTtrRFagpvOIgnOHy5tSEt7Q7B7tgH4/QJy7ibj4kfLcJdquQSt/n01fPpXyqY9/AEf5xRn9S/CL99GLnQpPVkgGx2qwmF8lensxPoNZ54jT3UonJ/PJn+ccS/vKIz11zDNQlahPBp0GZG53K8OEHQT10VBEvfx4+Znywv8IeKcFVdJKSZ2jqQkg0Ix83LdDC2o2XfJ8klr7JtZWGUZASCRV9CRqwXUMLhUb9I0/Z+XbOrLwyIg0ce1/gtpDKDoqUSoE0+qpp6X5ca810frdihteCB7j6hCQTzJDi/8enuo+msagQUhgVMz/gd2+v8igcZaCam6CsKC0u+BBCRfhnLJN2rMdHWi+3zA8bkkDHAASNREtebpgwPailtQnFq1gDaFEY99pXAn/cL9IlzUf8ujTDtUNe2FWOvf0cdgo6M0nIHQvi40Onsqs0UnG5P8P8VQ9/WXsvgQ8Y77f3TPer5f4fOeURRXsf553lnKYCmIaCr7UVgW11BJn5YO8yy7gg1NKZTsZOCTIaSLUQI/CUffIWyn10mF4vvdls7oOaCYzmJMLs/pVunwQP674FS+KHcyWHJ7yxfSA4A8JlZiDyELuDl+hXkZ66hUGAiRvtYwEvc79Yko26fW7VhnIA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bfddfd14-ac41-425e-aeb7-08dbb0704558 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2023 13:34:05.0650 (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: pNOB4KaqnTlFsXR57DgYFHE7g6x4I/VJeeaKnZxdjEosVziz9xb29/VevFVkDcb/hOFZQ2uldoL3ZNqxZG8zHA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR04MB9718 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_BLOCKED, 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 X-Patchwork-Delegate: kuba@kernel.org Currently, sja1105_dynamic_config_wait_complete() returns either 0 or -ETIMEDOUT, because it just looks at the read_poll_timeout() return code. There will be future changes which move some more checks to sja1105_dynamic_config_poll_valid(). It is important that we propagate their exact return code (-ENOENT, -EINVAL), because callers of sja1105_dynamic_config_read() depend on them. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/sja1105/sja1105_dynamic_config.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_dynamic_config.c b/drivers/net/dsa/sja1105/sja1105_dynamic_config.c index 7729d3f8b7f5..93d47dab8d3e 100644 --- a/drivers/net/dsa/sja1105/sja1105_dynamic_config.c +++ b/drivers/net/dsa/sja1105/sja1105_dynamic_config.c @@ -1211,13 +1211,14 @@ sja1105_dynamic_config_wait_complete(struct sja1105_private *priv, struct sja1105_dyn_cmd *cmd, const struct sja1105_dynamic_table_ops *ops) { - int rc; - - return read_poll_timeout(sja1105_dynamic_config_poll_valid, - rc, rc != -EAGAIN, - SJA1105_DYNAMIC_CONFIG_SLEEP_US, - SJA1105_DYNAMIC_CONFIG_TIMEOUT_US, - false, priv, cmd, ops); + int err, rc; + + err = read_poll_timeout(sja1105_dynamic_config_poll_valid, + rc, rc != -EAGAIN, + SJA1105_DYNAMIC_CONFIG_SLEEP_US, + SJA1105_DYNAMIC_CONFIG_TIMEOUT_US, + false, priv, cmd, ops); + return err < 0 ? err : rc; } /* Provides read access to the settings through the dynamic interface From patchwork Fri Sep 8 13:33:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13377474 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B8B46AB0 for ; Fri, 8 Sep 2023 13:34:19 +0000 (UTC) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2040.outbound.protection.outlook.com [40.107.22.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 551B51BFF; Fri, 8 Sep 2023 06:34:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n6mY/1VVGSvz6uDrRbvkOZzeoOtNH9vMuENWdsxxksHPb0IDCDg+CwfqXOGwCYl+XhfEd9WNMk+G9MX7/3IVyP1uB95HRt90AYOmPouQr7QZ0lwrpc9HDNYgtxo1Pb0nyPKFLjHHRM3of55Kxk/N5m2EJOv1KelT2XdfdgH2InxVcmylXt9OlWc8nV3XdWWHMUX3UMIAHUWUOCoSNzLBuPEWeyne13tfqOTnz4kXx46wHd3WL/08Ix2qsksbmDSa6Sdm8VBOXNF/BjDN7DGwZnBIIq4Wnc+1FzVu71/xUh8jnASAJ82ADZ51ihQrqIyHfSZk4HobdNlq5fVc9qba3A== 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=+BS16mT6U7ksigGV4l4NLqWUfFQK5C5DsjU08zJ7G5k=; b=dv01hJkatjIuwTRVwDVzDYwZA1mHMVOdVwsd0eFEYuJHdY4zNhfKEOxRf14c2gONAmwVWJC3tOZG9DeZ7FqS1IhiUFioM46tSFDHnBwwKTfN05/qQLcCsKAcds4hNL0/R+QZUrQQ5bqgzPyz/x/e/Bc6/infHJ+x+8GwRnvCb5Mg/l/s+HzhqXYNTb44R76ZpH+aVxIdVdG+HMJ5POeln/9kbliLLEGg3bGyuKpcPt+HUhH1tZ7KbCfT3XxXBOFSrbCwuf8ootpUbdIizTkSeuf86i+2ptr8CCaxhYkOyJY+nQpE3aJOLzmlqmefBYT7IljUPGt+ULk/YRDcZAjy0Q== 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=+BS16mT6U7ksigGV4l4NLqWUfFQK5C5DsjU08zJ7G5k=; b=sQZwYVbIdP/EOZ3WcYfDWHy7r8HbhFCKMR17bXb1BVSRzHOfTKLkVG4+ns9p+HYmcAh6ABkLyA2kJOdJPrsONXjQ9LDoffaWznEHSA+n+XkndOsvn46MNC1wqpBFQCySSZtl2Th8WZelv2woWlAJrSAHrDXs8AmhxNWmskhTvB4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by PAWPR04MB9718.eurprd04.prod.outlook.com (2603:10a6:102:381::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.34; Fri, 8 Sep 2023 13:34:07 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454%3]) with mapi id 15.20.6745.034; Fri, 8 Sep 2023 13:34:05 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Eric Dumazet , Jakub Kicinski , Paolo Abeni , "David S. Miller" , Xiaoliang Yang , Andrew Lunn , Florian Fainelli , Yanan Yang , linux-kernel@vger.kernel.org Subject: [PATCH net 3/5] net: dsa: sja1105: fix multicast forwarding working only for last added mdb entry Date: Fri, 8 Sep 2023 16:33:50 +0300 Message-Id: <20230908133352.2007218-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230908133352.2007218-1-vladimir.oltean@nxp.com> References: <20230908133352.2007218-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0036.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::23) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|PAWPR04MB9718:EE_ X-MS-Office365-Filtering-Correlation-Id: ce190eb6-30a9-46cc-a759-08dbb07045d4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VcKKthYc48Vd9WysnHt++/8/dU/e0w6n4OT0SoIc2rdw/B+hah45dJoB48rvGiwnR2aRBhvyt4gzcsQJWa/15No8GWp+D1x1cauxc86L43iZPhps3r2TkyFIP2ze+feovXBoH9Qx47Wt4xxXMegTnvanMYpVRPLE+6qolR4pkCUXMOf+iiiDpzhAC2Fh7CQfTco49iPh3jfaGUFHJ96vGIZ+AOZFw4pwR3ucYSOrw/kbJ1nDxur2w+PDK5pbSN7t0EpyP2gj++XpDIuDICK2+R75nQxYKeR7HxPvSJlKsSEbrGCz3OJPjYIkUFppfo+xE4QwULI+J1MoSdDgSVHZLV5D073pee341nfIUa3Mq/LD/9y9OUiTmpTe5IxpXcifTV5koZNFbwy30nhFQqo/2l5fMDmKEBMHh7R7UC9J3ySL+k6dQ/rk3ja47MmnTDj73kPbiOI/W2E+1aVbjwUXMpcpaFr0iLppzGyyGpf5s3rX8/vwAudPKdqXAeyJWPkRE5IDRtIZ+hO9PLvkeO3xRlc748Zd2xZfrPkiz5VWBIJLG1cNCa/batrYqWDQxqy/u+SWkTmt44nqttzXYQZyoIl6I+xMugiePwaQtta69JriUl2mJMjfWc2HvqBrIsTM X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(396003)(366004)(346002)(39860400002)(376002)(1800799009)(186009)(451199024)(2906002)(38350700002)(38100700002)(36756003)(6506007)(41300700001)(6512007)(6486002)(52116002)(66556008)(54906003)(2616005)(66946007)(66476007)(6916009)(316002)(1076003)(86362001)(8676002)(8936002)(4326008)(6666004)(478600001)(5660300002)(26005)(83380400001)(44832011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: STkOtH9TKquaOKWmZhBAvs7lE0gkQVTfIf9BBc24BK8B8ux807Tob3bvhkwV/m4+7w+nKW+H2RF2fio5IjQrIT+rjwjnc0qjlFmw2d3EAcVi8KkNn9CMyqHXR3IKQBW8EMyH4RruuI6c0zJsETZSvJD4oPIrOWb8NLba2AVA04UYOdmApb8+xrRBMUT6goPi1kv+bcRSgOc7wYc6O0heH3k1+1X5Sm9jqUuV5MKZ9hj1PSvF4FsN6V88cLDGGxM1gVvMz/+Unm7T2NkNHWxuX8v9vUoXx8yLeemDgcplMYmcR2fFpKhDU+WLbZ3+o1GjDvwmKZsYIXPR3Q+UI0wbVh8O0K0aXUHJ/tKdSnfrNT7YpNi0+kZA93oaX7GCKFQ0Jiy5avLqQZsIzGg30sg/7muuh35/nez5sdtY/Fr3kRCw/Bwhelk3W6nTbde0puFD7ql4qjx2NPg1X1VOFhw+c15F7b0mOV6iWOOydKeYF7kVai11R+5+sAfNKJS22+616JI+IePHwC69cMNKhRdKb6hvkCpMSDzKf6WNkPrry72P0kw6AFoy9K3y57pBFNUr6hgHXAUQmrNTK7nBh0qzsRn534hJYCeslt1KT4kaVvR/51PYvyZ7yJnW7S5d1o9Tw19x5rZkGWkMpnwU2XxPIC+cMvARi9/duUG3Z1c20Gvn+Y8Q1dDicS6cTwX8R8R1hnRWYvtSruKywgFL74fu0v1zkd/v5EeG1HUbJICc5kVecvGJ8dKgcwFh1pQ0PZPzs5iQ/JtWoqvWZgMFJ8eyrcBMzsTFHPRTEu54g3ofklzhMaYKVpMNXIgbp3LeolZXBi3Se6DpEUHUIzJU+oSi6LJV51kHgj28qsTEhiWbz/hmhY1uFwsNP0mQLnaU3pfZTcHK6WZC9+oUwhWPT9hadKEgcTu+r7diRErCFPAdUNVDb7vI7rO/3cvZymBIaZVbcnZ551NacmLfuoMAZ+wfroKXPa5LwICq8Mt92nTdH9f/Y0iFibrAtmVZlF4G/uOIMZLbaYHrNyZbjynRv+qWWe9mkFyO5gdB5B4dvHWtFA0ahQTlNFNDLMIWMZ2BZqnNHrEX/56cPYO9D6lcgrXpTSGF3bUXzSCKBwEJmVKg1b3V+YQUDsam8vMca6T4M3OozqcUaAFRriRK59zH53orqNf6wQtijhH7xPCFpLDINuy/EVpOarTEPJaGIjFn0l9xerGVzpcLDyZ2iurr4Tv1dU+zdAvSpMVJ+EPs/Fedj+MneckQZ3DSpViTDrdh4fiF51rArCVTQfVQV6A2uQJJEL/tyhCXf2Wr25uRe0hzv0pbjJbCjAsj+A4jqqJOSPp/sLNdfbGhGhpA4EXP69XNILWQm30AmapQVNtZqplXaJHJ2jPhxAjiO8BJr69r0kXw+/ek5joQpvUBwHWaLUGc0uiarZXm2qo0SEqBixDA43SIZzn3MzqHQNpENRnPpZ5Ds653Q1fBHEKalFFuVPD+vvq1Nn0FoDA5j8p/F+7wvLUQ677bm0JgUqFy6pFZ9lb3imrTU6Rc2d8XZyfVNyKu7NjxDMG1Wz2nHlle7wylm5XdkFbWXUM85uQ9uJBataBP8a6/8SMLKrEXL3LWDIhscw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ce190eb6-30a9-46cc-a759-08dbb07045d4 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2023 13:34:05.8635 (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: lpA2UUCjqVXjNXetH8HGlAzbN+p5JIvyG6qR75tZm4PPktZNgykkpD2aivnOrHbL5lBjPGxI6omcBcEwWtt96g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR04MB9718 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_BLOCKED, 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 X-Patchwork-Delegate: kuba@kernel.org The commit cited in Fixes: did 2 things: it refactored the read-back polling from sja1105_dynamic_config_read() into a new function, sja1105_dynamic_config_wait_complete(), and it called that from sja1105_dynamic_config_write() too. What is problematic is the refactoring. The refactored code from sja1105_dynamic_config_poll_valid() works like the previous one, but the problem is that it uses another packed_buf[] SPI buffer, and there was code at the end of sja1105_dynamic_config_read() which was relying on the read-back packed_buf[]: /* Don't dereference possibly NULL pointer - maybe caller * only wanted to see whether the entry existed or not. */ if (entry) ops->entry_packing(packed_buf, entry, UNPACK); After the change, the packed_buf[] that this code sees is no longer the entry read back from hardware, but the original entry that the caller passed to the sja1105_dynamic_config_read(), packed into this buffer. This difference is the most notable with the SJA1105_SEARCH uses from sja1105pqrs_fdb_add() - used for both fdb and mdb. There, we have logic added by commit 728db843df88 ("net: dsa: sja1105: ignore the FDB entry for unknown multicast when adding a new address") to figure out whether the address we're trying to add matches on any existing hardware entry, with the exception of the catch-all multicast address. That logic was broken, because with sja1105_dynamic_config_read() not working properly, it doesn't return us the entry read back from hardware, but the entry that we passed to it. And, since for multicast, a match will always exist, it will tell us that any mdb entry already exists at index=0 L2 Address Lookup table. It is index=0 because the caller doesn't know the index - it wants to find it out, and sja1105_dynamic_config_read() does: if (index < 0) { // SJA1105_SEARCH /* Avoid copying a signed negative number to an u64 */ cmd.index = 0; // <- this cmd.search = true; } else { cmd.index = index; cmd.search = false; } So, to the caller of sja1105_dynamic_config_read(), the returned info looks entirely legit, and it will add all mdb entries to FDB index 0. There, they will always overwrite each other (not to mention, potentially they can also overwrite a pre-existing bridge fdb entry), and the user-visible impact will be that only the last mdb entry will be forwarded as it should. The others won't (will be flooded or dropped, depending on the egress flood settings). Fixing is a bit more complicated, and involves either passing the same packed_buf[] to sja1105_dynamic_config_wait_complete(), or moving all the extra processing on the packed_buf[] to sja1105_dynamic_config_wait_complete(). I've opted for the latter, because it makes sja1105_dynamic_config_wait_complete() a bit more self-contained. Fixes: df405910ab9f ("net: dsa: sja1105: wait for dynamic config command completion on writes too") Reported-by: Yanan Yang Signed-off-by: Vladimir Oltean --- .../net/dsa/sja1105/sja1105_dynamic_config.c | 80 +++++++++---------- 1 file changed, 37 insertions(+), 43 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_dynamic_config.c b/drivers/net/dsa/sja1105/sja1105_dynamic_config.c index 93d47dab8d3e..984c0e604e8d 100644 --- a/drivers/net/dsa/sja1105/sja1105_dynamic_config.c +++ b/drivers/net/dsa/sja1105/sja1105_dynamic_config.c @@ -1175,18 +1175,15 @@ const struct sja1105_dynamic_table_ops sja1110_dyn_ops[BLK_IDX_MAX_DYN] = { static int sja1105_dynamic_config_poll_valid(struct sja1105_private *priv, - struct sja1105_dyn_cmd *cmd, - const struct sja1105_dynamic_table_ops *ops) + const struct sja1105_dynamic_table_ops *ops, + void *entry, bool check_valident, + bool check_errors) { u8 packed_buf[SJA1105_MAX_DYN_CMD_SIZE] = {}; + struct sja1105_dyn_cmd cmd = {}; int rc; - /* We don't _need_ to read the full entry, just the command area which - * is a fixed SJA1105_SIZE_DYN_CMD. But our cmd_packing() API expects a - * buffer that contains the full entry too. Additionally, our API - * doesn't really know how many bytes into the buffer does the command - * area really begin. So just read back the whole entry. - */ + /* Read back the whole entry + command structure. */ rc = sja1105_xfer_buf(priv, SPI_READ, ops->addr, packed_buf, ops->packed_size); if (rc) @@ -1195,11 +1192,25 @@ sja1105_dynamic_config_poll_valid(struct sja1105_private *priv, /* Unpack the command structure, and return it to the caller in case it * needs to perform further checks on it (VALIDENT). */ - memset(cmd, 0, sizeof(*cmd)); - ops->cmd_packing(packed_buf, cmd, UNPACK); + ops->cmd_packing(packed_buf, &cmd, UNPACK); /* Hardware hasn't cleared VALID => still working on it */ - return cmd->valid ? -EAGAIN : 0; + if (cmd.valid) + return -EAGAIN; + + if (check_valident && !cmd.valident && !(ops->access & OP_VALID_ANYWAY)) + return -ENOENT; + + if (check_errors && cmd.errors) + return -EINVAL; + + /* Don't dereference possibly NULL pointer - maybe caller + * only wanted to see whether the entry existed or not. + */ + if (entry) + ops->entry_packing(packed_buf, entry, UNPACK); + + return 0; } /* Poll the dynamic config entry's control area until the hardware has @@ -1208,8 +1219,9 @@ sja1105_dynamic_config_poll_valid(struct sja1105_private *priv, */ static int sja1105_dynamic_config_wait_complete(struct sja1105_private *priv, - struct sja1105_dyn_cmd *cmd, - const struct sja1105_dynamic_table_ops *ops) + const struct sja1105_dynamic_table_ops *ops, + void *entry, bool check_valident, + bool check_errors) { int err, rc; @@ -1217,7 +1229,8 @@ sja1105_dynamic_config_wait_complete(struct sja1105_private *priv, rc, rc != -EAGAIN, SJA1105_DYNAMIC_CONFIG_SLEEP_US, SJA1105_DYNAMIC_CONFIG_TIMEOUT_US, - false, priv, cmd, ops); + false, priv, ops, entry, check_valident, + check_errors); return err < 0 ? err : rc; } @@ -1287,25 +1300,14 @@ int sja1105_dynamic_config_read(struct sja1105_private *priv, mutex_lock(&priv->dynamic_config_lock); rc = sja1105_xfer_buf(priv, SPI_WRITE, ops->addr, packed_buf, ops->packed_size); - if (rc < 0) { - mutex_unlock(&priv->dynamic_config_lock); - return rc; - } - - rc = sja1105_dynamic_config_wait_complete(priv, &cmd, ops); - mutex_unlock(&priv->dynamic_config_lock); if (rc < 0) - return rc; + goto out; - if (!cmd.valident && !(ops->access & OP_VALID_ANYWAY)) - return -ENOENT; + rc = sja1105_dynamic_config_wait_complete(priv, ops, entry, true, false); +out: + mutex_unlock(&priv->dynamic_config_lock); - /* Don't dereference possibly NULL pointer - maybe caller - * only wanted to see whether the entry existed or not. - */ - if (entry) - ops->entry_packing(packed_buf, entry, UNPACK); - return 0; + return rc; } int sja1105_dynamic_config_write(struct sja1105_private *priv, @@ -1357,22 +1359,14 @@ int sja1105_dynamic_config_write(struct sja1105_private *priv, mutex_lock(&priv->dynamic_config_lock); rc = sja1105_xfer_buf(priv, SPI_WRITE, ops->addr, packed_buf, ops->packed_size); - if (rc < 0) { - mutex_unlock(&priv->dynamic_config_lock); - return rc; - } - - rc = sja1105_dynamic_config_wait_complete(priv, &cmd, ops); - mutex_unlock(&priv->dynamic_config_lock); if (rc < 0) - return rc; + goto out; - cmd = (struct sja1105_dyn_cmd) {0}; - ops->cmd_packing(packed_buf, &cmd, UNPACK); - if (cmd.errors) - return -EINVAL; + rc = sja1105_dynamic_config_wait_complete(priv, ops, NULL, false, true); +out: + mutex_unlock(&priv->dynamic_config_lock); - return 0; + return rc; } static u8 sja1105_crc8_add(u8 crc, u8 byte, u8 poly) From patchwork Fri Sep 8 13:33:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13377476 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DA03F4E7 for ; Fri, 8 Sep 2023 13:34:24 +0000 (UTC) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2047.outbound.protection.outlook.com [40.107.22.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7510919BC; Fri, 8 Sep 2023 06:34:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mGLMSVPlzraYHjsLj2GsOmj3WOeREolMEmakKwMk1OEl0+8TIMx3zSEKCVZaZwy+T9/FiSKkg05cMDsSxEZ1yb3vF3wkUEKFcSKpReuPcYlxlMZxPKRl8530ID6DWYPzEZKr0Ru/LYPDIajXLmdMpr8g7dbPCEQI0VQEC3t+qW0eqimFLtIPwC1/bd+AmIO3Ze8BWiKmhj/tq4YRNOcqjYQ0dj6GvzdBY05XCBU1G8V5OhneYn2y6biWUiVovN4T0nHjEEFmvAW6UrT0YXwJ6DvdRg1ANDZG0R5Z3pi76W2bt1rl7yFYFD7TRZ/HIln6selxVPRRwkfKc3HDuOhD6w== 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=7ZNLITou5yVf/sIOWaZk9PVNCJQqaJYoYFEev5erSqY=; b=Xfv6vmBeKYjll05fTPJNb1ZfUiOk+b25CuMcArjW7yEN2wWo5aR1HgBXV53DqXbgidO3hiSGAljZKYNDqjM9B9J9rI7Gyvvo0nVukcnqHSrb8VlVIpr4uBkl3wuDbecnmyi/SNCKPSLQ6KNJXN/TSL7++MLCJcCB4BpEiqCa95jK1np3LaEIlmi6jbk83/6VlIUVLYZmGdat5r6JK4aJ+Ec9gZYeXBJZy1v4Wq+1wNQYJbgR8k3mvpo1m1+tR2vsoCzyW35GOepFYaXM2r8endscSDzApwU+NucVdfMOcI2l9Anx879K6/wHDj9MmL6LVTSeCcCUAqHnrkEjro0GTA== 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=7ZNLITou5yVf/sIOWaZk9PVNCJQqaJYoYFEev5erSqY=; b=bGN86w0udcmLZE5Bwqr223JujKehHW4ImpkzsWiIyvoThj2LdsVU0jGG7n8WGD0CvTuOczj0b8Z8k+Nn5nB9/lkQTpHEEb/367yTU3aQdx6bHUxmiwEfUFnoOSeatGWqzeFKKK0oiJ5z91KFwcJqEJnMrL02Ja0IDJPoCNHKILw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by PAWPR04MB9718.eurprd04.prod.outlook.com (2603:10a6:102:381::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.34; Fri, 8 Sep 2023 13:34:08 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454%3]) with mapi id 15.20.6745.034; Fri, 8 Sep 2023 13:34:07 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Eric Dumazet , Jakub Kicinski , Paolo Abeni , "David S. Miller" , Xiaoliang Yang , Andrew Lunn , Florian Fainelli , Yanan Yang , linux-kernel@vger.kernel.org Subject: [PATCH net 4/5] net: dsa: sja1105: serialize sja1105_port_mcast_flood() with other FDB accesses Date: Fri, 8 Sep 2023 16:33:51 +0300 Message-Id: <20230908133352.2007218-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230908133352.2007218-1-vladimir.oltean@nxp.com> References: <20230908133352.2007218-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0036.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::23) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|PAWPR04MB9718:EE_ X-MS-Office365-Filtering-Correlation-Id: 05c540bc-86a1-4420-3dad-08dbb070464e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9PawD+yjhHDwVobpLms98kilkj9w4ZtlpLTeMvfeAay04N22WsrW5FlNMUnJPik4ztBESm+Y8KPuP3Ch2taEzRxUg6E0FOtzU3gb1Zg61eQny/P47F2hISjBENppd9vbZtoIEi3mnCukeMBv8h9pz3p6WWKTbm442YJ93jNUYWH5E9lyTVKSt/CuHxF6T7eAlKtuaSmOjMI3qDUXZd17qJEFTHZ4DSTsYVwVjRRh93vgA5IVQrWPnYhOYy96Pjw1ESGZze0vmAxJsVoFAXb/tXuxL+8E0Rt5L2VguAyc/eQCfzCmfWVtLFQ6S+yof0PoVPj0XRUXry3f+EHzphC6haOmLqBruypPNii8Ce+gFt1y0MAWurhmeikSmTaYdys+RAJTxeCDMrawh1pZvU9XhEYrDAgkhajgDP5xC8FndVmb2BvVYm75Haknz12WE+w3hNKnme6HFrfIVIKcUPJhkkcJeknsijK7pn6jiYEz1r0Jbh4qnjZiPjCfcP4sUWSyxACH344vmkw9EARVZcchRxZDpqcLTQ9H3X8FTlVsTt1CrjMVPfIxT8pM5OtBoxIpi2GQP0WzYD0rapsTubB6BeoWOxYlBiFktcR3C3KUSnXO1/jQZg2INfBWLqG+Ez2Z X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(396003)(366004)(346002)(39860400002)(376002)(1800799009)(186009)(451199024)(66899024)(2906002)(38350700002)(38100700002)(36756003)(6506007)(41300700001)(6512007)(6486002)(52116002)(66556008)(54906003)(2616005)(66946007)(66476007)(6916009)(316002)(1076003)(86362001)(8676002)(8936002)(4326008)(6666004)(478600001)(5660300002)(26005)(83380400001)(44832011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ydteNYWU0KEx4Q/wn6fzyKcXOqMbuMXbYahNLTPfsfoYUlr9b4nEq8TL59aY4tC/BGBBHf9/qP0hEcovaKdu7NEopcP/oEDsfsRNSVfeIvkPg6AWJDacwLFakzxwHBR5wNWQKAw1zrNuGgyaZroAqSsdTDGWL6+ciADygn8OqIWBWmIDouun7rrxJNMqZgCYQdlnLjqwnlFb71wVXXqzT16lvs2XXWBG1+MkXGVIL586w6i2Ulcq0m1Wf5HPt7uxvK+5yVwprd2d6YLcSlcxtlYq5HVYG6tyT99KmN7Vate5SahdcoNVHRyM5Fk/hA7FZfAMRU8gGIQD6uKMZuso6Z0KBzDT8hLgzqqlbyp2oPpc5CDr9RaqW+G4QttM/5HR5anma6YA3Tng4j3zBYOtXYyrQO/AD2JyWlvbuTHt+XdXJ/HNocprhe6xyVLfet6XPLxkVsNrRiBQkc0RTxCb50yN4lvJe/y6DEdwEE6m47VxAR3F3XaE5oIWmw3rXVD1Hyviu+D50GCA+DUa1Fi12LcoypVYw6dUK9lQkKDL7rjc3E3niMYJ3UAK5FT8KLlWqRyES1+iw54K3I2NZftWZuUl6sNMGda1psSYCULQViwwb9RIf5igTI9kpbBD/28jsXYzTCGExH9qc+pp3JyR1bODPjPVh5K22qzwf5rJVWJXLpV0XcZOLzMckmgtt/ehZ5H8w2beHuvdzw0ab5HpiC9bsiT+GV2uB+EK7Gjf/F9q4EMfBjxvmnTBmRdvsAWCemobzF9asfXiucLxLz7aL+qyLmqzsGZr+AfEU4MiOPh3yF4ExLq5vDVDIRpiipkF/Y62Tj0av1e3mqAG4u29LDRcqNEOUJR6udXG+q0v7ueFFaIld5PTXvpA8vhZNAxPLbp3umVw/Pvmqcg1lza02h7TL2AK1o+f/Es8XtNYOgwPKdz+HV6jHk46kVccnnIQQnTKRxGwKYp3OO6k/zSM1f7vaS4IFKQGpqQ3zA1ri1GBcrb2ByoIEKyj5HJi4lioZPt8v/0bgKKx2eEkKIMFgW+8KYKElzG9lI1YpyhfmKcbqpVypPsrQ9jSVpUDczcZWFGrgYVkAFKwgbv3gRtaNU9VLKFR+5DJvIWXkAANBxJqkuR+k5HP70G25e11/Ss+S19Wlbf+pZtSJ4OtcUsLHYeVChmH5jCQceiMbdWNra3esL9MabR9YYlopv+3ZxHc6bYwOMi+3FROynzT+zjJA0VlpVThpSbu/m/dma8gk0s9LUS1DJpjPGQw1Q2bkXOTeE5VX0WAsKYYt1dXK8i+9ltZluuP0dUFVCAYnfMYdCFHRwup6uLExiBR3HHRxNWC2z7YR+84qSXs2xtiHw05TzfXPRwBJCBYB1iSCNZGpqjnnMsF0gki4/pELYDVTxma5+LFGHAINcqQ8GixXH7LbNEddX2oF2HdjKRY4lQZIj4W+o60Z9g4d0znvr0ww5jlNCSLAiYVzDiyIy31/PpGWbDSJtAnkMZWvbwlirqV/zs/HgG5FAsvEM5Oex0uIl4D23al/EnziEqNw5cm+81NkBgHkuZircJh7P2qzl3Mn+zTUJmJVJJ49PkuaTglaY9eC9QHKJKHZe12eSn0LPXscw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 05c540bc-86a1-4420-3dad-08dbb070464e X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2023 13:34:06.6812 (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: HSNFZszmAKvEwVRryA1DEkOw5vZOXYKCCi4zdgxfmyMkvAtPF1m0MHujx1PjE40WWb6fSJ8SUXUh1LvHhvwRLg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR04MB9718 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_BLOCKED, 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 X-Patchwork-Delegate: kuba@kernel.org sja1105_fdb_add() runs from the dsa_owq, and sja1105_port_mcast_flood() runs from switchdev_deferred_process_work(). Prior to the blamed commit, they used to be indirectly serialized through the rtnl_lock(), which no longer holds true because dsa_owq dropped that. So, it is now possible that we traverse the static config BLK_IDX_L2_LOOKUP elements concurrently compared to when we change them, in sja1105_static_fdb_change(). That is not ideal, since it might result in data corruption. Introduce a mutex which serializes accesses to the hardware FDB and to the static config elements for the L2 Address Lookup table. I can't find a good reason to add locking around sja1105_fdb_dump(). I'll add it later if needed. Fixes: 0faf890fc519 ("net: dsa: drop rtnl_lock from dsa_slave_switchdev_event_work") Signed-off-by: Vladimir Oltean --- drivers/net/dsa/sja1105/sja1105.h | 2 + drivers/net/dsa/sja1105/sja1105_main.c | 56 ++++++++++++++++++++------ 2 files changed, 45 insertions(+), 13 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105.h b/drivers/net/dsa/sja1105/sja1105.h index 0617d5ccd3ff..8c66d3bf61f0 100644 --- a/drivers/net/dsa/sja1105/sja1105.h +++ b/drivers/net/dsa/sja1105/sja1105.h @@ -266,6 +266,8 @@ struct sja1105_private { * the switch doesn't confuse them with one another. */ struct mutex mgmt_lock; + /* Serializes accesses to the FDB */ + struct mutex fdb_lock; /* PTP two-step TX timestamp ID, and its serialization lock */ spinlock_t ts_id_lock; u8 ts_id; diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 11c917d5ce43..cefd72617af4 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -1798,6 +1798,7 @@ static int sja1105_fdb_add(struct dsa_switch *ds, int port, struct dsa_db db) { struct sja1105_private *priv = ds->priv; + int rc; if (!vid) { switch (db.type) { @@ -1812,12 +1813,16 @@ static int sja1105_fdb_add(struct dsa_switch *ds, int port, } } - return priv->info->fdb_add_cmd(ds, port, addr, vid); + mutex_lock(&priv->fdb_lock); + rc = priv->info->fdb_add_cmd(ds, port, addr, vid); + mutex_unlock(&priv->fdb_lock); + + return rc; } -static int sja1105_fdb_del(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid, - struct dsa_db db) +static int __sja1105_fdb_del(struct dsa_switch *ds, int port, + const unsigned char *addr, u16 vid, + struct dsa_db db) { struct sja1105_private *priv = ds->priv; @@ -1837,6 +1842,20 @@ static int sja1105_fdb_del(struct dsa_switch *ds, int port, return priv->info->fdb_del_cmd(ds, port, addr, vid); } +static int sja1105_fdb_del(struct dsa_switch *ds, int port, + const unsigned char *addr, u16 vid, + struct dsa_db db) +{ + struct sja1105_private *priv = ds->priv; + int rc; + + mutex_lock(&priv->fdb_lock); + rc = __sja1105_fdb_del(ds, port, addr, vid, db); + mutex_unlock(&priv->fdb_lock); + + return rc; +} + static int sja1105_fdb_dump(struct dsa_switch *ds, int port, dsa_fdb_dump_cb_t *cb, void *data) { @@ -1899,6 +1918,8 @@ static void sja1105_fast_age(struct dsa_switch *ds, int port) }; int i; + mutex_lock(&priv->fdb_lock); + for (i = 0; i < SJA1105_MAX_L2_LOOKUP_COUNT; i++) { struct sja1105_l2_lookup_entry l2_lookup = {0}; u8 macaddr[ETH_ALEN]; @@ -1912,7 +1933,7 @@ static void sja1105_fast_age(struct dsa_switch *ds, int port) if (rc) { dev_err(ds->dev, "Failed to read FDB: %pe\n", ERR_PTR(rc)); - return; + break; } if (!(l2_lookup.destports & BIT(port))) @@ -1924,14 +1945,16 @@ static void sja1105_fast_age(struct dsa_switch *ds, int port) u64_to_ether_addr(l2_lookup.macaddr, macaddr); - rc = sja1105_fdb_del(ds, port, macaddr, l2_lookup.vlanid, db); + rc = __sja1105_fdb_del(ds, port, macaddr, l2_lookup.vlanid, db); if (rc) { dev_err(ds->dev, "Failed to delete FDB entry %pM vid %lld: %pe\n", macaddr, l2_lookup.vlanid, ERR_PTR(rc)); - return; + break; } } + + mutex_unlock(&priv->fdb_lock); } static int sja1105_mdb_add(struct dsa_switch *ds, int port, @@ -2955,7 +2978,9 @@ static int sja1105_port_mcast_flood(struct sja1105_private *priv, int to, { struct sja1105_l2_lookup_entry *l2_lookup; struct sja1105_table *table; - int match; + int match, rc; + + mutex_lock(&priv->fdb_lock); table = &priv->static_config.tables[BLK_IDX_L2_LOOKUP]; l2_lookup = table->entries; @@ -2968,7 +2993,8 @@ static int sja1105_port_mcast_flood(struct sja1105_private *priv, int to, if (match == table->entry_count) { NL_SET_ERR_MSG_MOD(extack, "Could not find FDB entry for unknown multicast"); - return -ENOSPC; + rc = -ENOSPC; + goto out; } if (flags.val & BR_MCAST_FLOOD) @@ -2976,10 +3002,13 @@ static int sja1105_port_mcast_flood(struct sja1105_private *priv, int to, else l2_lookup[match].destports &= ~BIT(to); - return sja1105_dynamic_config_write(priv, BLK_IDX_L2_LOOKUP, - l2_lookup[match].index, - &l2_lookup[match], - true); + rc = sja1105_dynamic_config_write(priv, BLK_IDX_L2_LOOKUP, + l2_lookup[match].index, + &l2_lookup[match], true); +out: + mutex_unlock(&priv->fdb_lock); + + return rc; } static int sja1105_port_pre_bridge_flags(struct dsa_switch *ds, int port, @@ -3349,6 +3378,7 @@ static int sja1105_probe(struct spi_device *spi) mutex_init(&priv->ptp_data.lock); mutex_init(&priv->dynamic_config_lock); mutex_init(&priv->mgmt_lock); + mutex_init(&priv->fdb_lock); spin_lock_init(&priv->ts_id_lock); rc = sja1105_parse_dt(priv); From patchwork Fri Sep 8 13:33:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13377475 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 858BDE549 for ; Fri, 8 Sep 2023 13:34:22 +0000 (UTC) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2047.outbound.protection.outlook.com [40.107.22.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3324D1BFF; Fri, 8 Sep 2023 06:34:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z/MTOQQEVzTMBPUPRD7/rW/sx58t7F6E+Jz0B/htgdeMANY4sFeJCHUbsj9qQZRjrLfabLYiDhxF7S+lUEOY+OUv5iDFT4nzTQcTz6cmJFwH/vAI17KZk/gxXS6/lZ9g4VuoduwJSSeLFcRnLnSWzfbZsZ37byWpPJ9vWCqJgAD+2twN+BS/MVMoa6RageBDUli4/RNkcs4v2eyvm877YhUS/39eYbnv7s5yx/sGXRkKfTQs2EqzyM1AKpXCCmYakCSi1/2mq7EIIhEyDhlH9wag0UP7uAAeLFfaXQJIrwyqQczUuaurDvlnr0mcGoNsBjakys5aPPgtHGdnm60+oQ== 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=8+g2IKLU2ZGJtJuDxpqLwraWi9QGxrMdy/6lHn4ydRE=; b=hStYqbUcs8FG8OzXNGHpLs7slYsAB7O+4DYtAu82MoDr/KrCpTN6FtBHy8VJWLE6eImlHrdx8nS4SC8E1O+QpgY6gRvteb6cP2iELJiHIoVLm05QqMdAQMS0M4VdA8LPdJ9gyHjwDn/guxFTE499qHIhWcI1hsDyzDZZBLCXxIzeA+yCmz3aGAk5z3SYQDkSYSNvwSPc7xIqMfShsDryIzVcC5yVn2hzIt5eMSjwZ+GemPHZyqo1H5n40beYpfKWTwTu49iPcB8wexsAuXy8GbDU3sqXtuKOGQ0glv5YLnh9e4pg2UUfOfS994fNzmzvJ1n9BkieXPx8lEVO+nRKyw== 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=8+g2IKLU2ZGJtJuDxpqLwraWi9QGxrMdy/6lHn4ydRE=; b=dTIblAqW93PpMtubCyxMIZ0C02czS9VZdx8/pH1hVk50Z7s63fnY6A1g0PeJwg21h3WLIAWHU65naq9uJBfbwHYEH+a3BT1xn0lLbeuDsEHmySSuXXmhqbhuq/JXx2pCPu5LBh8vptnAkzmhpqeoJq5ruGxXMe+nNmjiMW4bSqY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by PAWPR04MB9718.eurprd04.prod.outlook.com (2603:10a6:102:381::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.34; Fri, 8 Sep 2023 13:34:08 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454%3]) with mapi id 15.20.6745.034; Fri, 8 Sep 2023 13:34:08 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Eric Dumazet , Jakub Kicinski , Paolo Abeni , "David S. Miller" , Xiaoliang Yang , Andrew Lunn , Florian Fainelli , Yanan Yang , linux-kernel@vger.kernel.org Subject: [PATCH net 5/5] net: dsa: sja1105: block FDB accesses that are concurrent with a switch reset Date: Fri, 8 Sep 2023 16:33:52 +0300 Message-Id: <20230908133352.2007218-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230908133352.2007218-1-vladimir.oltean@nxp.com> References: <20230908133352.2007218-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0036.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::23) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|PAWPR04MB9718:EE_ X-MS-Office365-Filtering-Correlation-Id: 4ea46e1a-ad03-4e7c-d3ef-08dbb07046c7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VHxjuhmzc8fVMrM3bOBzstp58MS1m24wvyDzjQL9X66A1n29ZZGB33IJ+rDmu38xlr7VrB6whEWlx6t23f/P00KEHA0Hs/qZoxIBjcXxhlV9q10Mh73JiJGdF83RPj5Evj4acsGrwvCHDzT/f/e2+a6PmMRDNld+rKXcLNVQqU2LM9s6hqiJwoVten9VadFHBg4+SLk2raBpB0WZzkZbZEUql/Y84DxI/yyvVgSxAcRY7yIQR15p6FauXvld5sEpdRVBHvuyFQPo7oW3Eg8VaYhh6itP3YNKu8jWB61cz0dYxjj/+1OoGgcpU+MvlFEqR/GQeVho+nnpxtez5w7gO6txNNGUKkfbPDszhOkf2kNndGHrUVkWFDKU31gPLR7Z2sA2iGWsuTPiPHayUyWdLlI1R5WO5p8PUcbTFRVGpwUQ/lRq/c3SMoOkWhcqaRSsZJhx3+SUslNuD5fCs39Zfaso+NycTqRkZG7PJll+VoJKHiEvm607e5/ORp5Nsw9hbuG92+ImTg1jJu1ZhNXz/WNJ10RTVVh8aO+bmri+gtyxOt6QlufVBA/6dSaQA2f7YdCKJnD/e5qI56V41QyYfNsnFGwF3gWu1I6nVO3yTb2ojBFFhdvlrRHX/GTrU4xI X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(396003)(366004)(346002)(39860400002)(376002)(1800799009)(186009)(451199024)(2906002)(38350700002)(38100700002)(36756003)(6506007)(41300700001)(6512007)(6486002)(52116002)(66556008)(54906003)(2616005)(66946007)(66476007)(6916009)(316002)(1076003)(86362001)(8676002)(8936002)(4326008)(6666004)(478600001)(5660300002)(26005)(83380400001)(44832011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: w+eRUpHYgTYf5EgvQN28s7bMWUTmJ+iI2l5VY42XDkzlJjz1K1xn1PP8IRF5ea+mnbh87jrj0Uch6cE18mrl0PW1mSQDj3Cf/7cH6hfPclHpnANLgYgTMIywRLyFr2ikC2V+b2D4C/2+inUBHZMdPwnLh/earBfT5aymx6nvmOxHchvgjC7tX3vti+/+sPoojgMTnoQV0gUrt0PXwma9xAMLG3EvyJBSzoXpoZBEgU6g8z3Pfpes5RvULwiUcnJEdP59YC+W2/RMuUrzzk/na4SsXtQYMNyROmcWCbxtBl8S9oI15b38pYnfN2PJ23KY7uiQr1f+bC4iDmuCLxn/9i6lr+bhmuK/hEyVtA3lKsufYIyCxVkqMMM9pLbstop7nVNzAXkwnto7LxZawbAsIvj6bB5i2OaiC2BsYfdKRDu1D5+e6FjV0BlmRy5x+KIfmRar1+IhEuZsPyLDC8ozjB+yIELp5t3M1+LxSXPjTqZfoyPCQpasPWN+CEhVVE4i/KKFdQxsxBPFJ8yBmxmfXJ70F3/pH3q6/YbyYPMg5VKR3yXyXxe3ve7idN1q78nOHPE3DwpqjhWHUUfugmr2f9mHLGWrts2DNCHkGmVBivQQ0IOAhNwTslKR/o+KkeFkZp+OHl/9LYaHnCu3fhCkcVc4bWwctVRdupvxWbX7oOF5LJmXV0UDKkbTCRWtrzU6PHvRelrEyAPu3cUJNRkQi1Q7FbwhmVzYhvSSxh5hMyuw8QtH4DrNysxqYEIm8XOfukv5yWjaDjWJEh9g2CLPwTXgcoztFpfq9Z9NGbj69boleFwGZzO5ZjXukVwMGOyENMGhz4hqmL6Dtzb4x1nsF/hwdyepjtYu4eY0BfnCyM/y8zOl01303Q6W01ifeX1W2oLhXgjaSVdSObm9ABJIZ2jGKe1Tiqm1TZwMb5cD8iZRnt88oFApiZzP4UhVtLKvTt0HvgolEXNf19tGmTH5kXjeGxui3YKx1ru1uNgzYhfjU85YMV+fgWUtu5hzvK6sqcoiiadBY3rIIVILpCd8SeK14wxq7TDD0ZgWowp57z0i/pob5W/PG4ksNfKfNx0ec8kgLukY1myxj/GCFpoZ+TSlMBP2DS+BobT89vmVU+V5F0cJ+lKuvXQWFGGm+Yf9QS3uyPi/JLFjjMTlOjaU8WkvO1vhTGdWSVTUE7IeIE/NrqbdithmAI1gFNBP8CoXYmymDJW8qAPEdfJn3YCiOVmZ/NOB2bInIW1mmsma5NFvpv8Xus5hpsNt+jf+NBO4Wka/C1txWAhZ/D785MsNacQE4675RhhXe8BFQRYliSCIhy8hq40pg46cuQM1skUAwA0wGEQwJwEs44tDRs5Rl8tIrvfc0kOiRTn6jF7RJYFPysVJpDX/Kq8HDlSYEJtuHMZCNGfktidP6F1HIak03f5Jan2e+Z94ZhHN/k6+NPnMUeVWLeLgJQO1B7nmuII3h9YO548ga7gYCAs7p2hnWkjpq6iAvbRZ+jOIVR5zDZg4z+3mjgdPqLgLTiVW2EOZ5KWjUYRgxnG8kNfwH5NT0QPmvh+H9bExA0Mi7w5QOa65MEOxWPKv4GACAEBpQ1L1A+xBnZ/wQSjKMcb2IY/19Q== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ea46e1a-ad03-4e7c-d3ef-08dbb07046c7 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2023 13:34:07.4530 (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: QuCpCcH02MhjZG+jnhlffbciM9fTNEkgSrcpaK7LKL68rxeB94ITAN4peO0jdaZXtKsbkdFMLSBTxl5LjcL/BA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR04MB9718 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_BLOCKED, 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 X-Patchwork-Delegate: kuba@kernel.org Currently, when we add the first sja1105 port to a bridge with vlan_filtering 1, then we sometimes see this output: sja1105 spi2.2: port 4 failed to read back entry for be:79:b4:9e:9e:96 vid 3088: -ENOENT sja1105 spi2.2: Reset switch and programmed static config. Reason: VLAN filtering sja1105 spi2.2: port 0 failed to add be:79:b4:9e:9e:96 vid 0 to fdb: -2 It is because sja1105_fdb_add() runs from the dsa_owq which is no longer serialized with switch resets since it dropped the rtnl_lock() in the blamed commit. Either performing the FDB accesses before the reset, or after the reset, is equally fine, because sja1105_static_fdb_change() backs up those changes in the static config, but FDB access during reset isn't ok. Make sja1105_static_config_reload() take the fdb_lock to fix that. Fixes: 0faf890fc519 ("net: dsa: drop rtnl_lock from dsa_slave_switchdev_event_work") Signed-off-by: Vladimir Oltean --- drivers/net/dsa/sja1105/sja1105_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index cefd72617af4..1a367e64bc3b 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -2297,6 +2297,7 @@ int sja1105_static_config_reload(struct sja1105_private *priv, int rc, i; s64 now; + mutex_lock(&priv->fdb_lock); mutex_lock(&priv->mgmt_lock); mac = priv->static_config.tables[BLK_IDX_MAC_CONFIG].entries; @@ -2409,6 +2410,7 @@ int sja1105_static_config_reload(struct sja1105_private *priv, goto out; out: mutex_unlock(&priv->mgmt_lock); + mutex_unlock(&priv->fdb_lock); return rc; }