From patchwork Wed Aug 4 13:16:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 492762 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 498BFC432BE for ; Wed, 4 Aug 2021 13:16:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2E2AD60F94 for ; Wed, 4 Aug 2021 13:16:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238345AbhHDNQ7 (ORCPT ); Wed, 4 Aug 2021 09:16:59 -0400 Received: from mail-db8eur05on2086.outbound.protection.outlook.com ([40.107.20.86]:63904 "EHLO EUR05-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237972AbhHDNQ4 (ORCPT ); Wed, 4 Aug 2021 09:16:56 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZtwmDf6GMPqVkQTGTMBKnqzBWijAQob1mmaJ7KPd2S3GWd3v6C7+9+nsHouxsfOdMScJrw1UQPqrn8aSxbfI/Zlkyaz8AVtSXLj+DAUgkeUXhWTH3oWaRanE3PzuaIH3rwtSS+B302zZCfGoiCwwohH1/30F3DpaVaXSwhXiu5+vFTxXZS8sOCmOy52NYBHCCppbqM+HdBcqzdiTQNojz6/ZLpNhVaXJEZ3uky/Gww0cdbFYhnlkdw+uVgDxCk9GRmYNOGIJGfEzVyegy6GMdoPVZXIitpq8Jy5Z+lX9WdRSLqDbfJmtzPHxknfHHMuYzMlO2oWLlI3KNVU+lMEtDg== 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-SenderADCheck; bh=bUJQTskF/PxUROiNR9u0KutptxhC7rr7ejtMqyblQE4=; b=IDBEBmeLUBKqMCASu3AcuA4coKlPYPO5m9lMdGOXGv6aKDujdd0flbAjTl9dieo2P+CUByQXBigbyldQK/kGLDRbjs5ea4jIx4/aVcdXzYIA7ddi7uA9taSuS0rmYbtxKkIWSY/3Zy9ABRKLBOEZjbUCbhusYZDn4+Da0fjEIB5ZzImkv5n/dGfBoNUN0S9NXbf3dKKQ723e1hJDuLXae+0fHaWT7oU8sTM7Kejsow5Zm1UVXy3TQ1KReD7OOci/8r+ubpwauwJpmFqlkLqzkKSfw5/vH3fwU87D7bLaQc7gNKcwlSFgYGGjgOLRiCm9/raNuVITA5/7psAl4R8TFw== 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=bUJQTskF/PxUROiNR9u0KutptxhC7rr7ejtMqyblQE4=; b=ahuK/WLOh0rMcrRCdBZ9QHP+O9Jt7dMFNRLxgjlwRY9LLbe1FtlBtsBObNbCAgt/NDa8ykdF2ZrU9+CEg7qGPtYrwGQKcCI4KF1Imyeajpi7+hiD0SfcqTPwIglijRXSzS+xLKW0eU1bZGUYObaPcZCE2aiuwRduoWlFUU4UkKI= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR04MB3967.eurprd04.prod.outlook.com (2603:10a6:803:4c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.25; Wed, 4 Aug 2021 13:16:42 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4373.027; Wed, 4 Aug 2021 13:16:42 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean Subject: [PATCH v2 net-next 1/8] net: dsa: rename teardown_default_cpu to teardown_cpu_ports Date: Wed, 4 Aug 2021 16:16:15 +0300 Message-Id: <20210804131622.1695024-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210804131622.1695024-1-vladimir.oltean@nxp.com> References: <20210804131622.1695024-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR03CA0083.eurprd03.prod.outlook.com (2603:10a6:208:69::24) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by AM0PR03CA0083.eurprd03.prod.outlook.com (2603:10a6:208:69::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Wed, 4 Aug 2021 13:16:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6e02d7dc-d893-482f-8149-08d9574a19e3 X-MS-TrafficTypeDiagnostic: VI1PR04MB3967: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +6qauFheyLhpyMihRDFkZ1qpua55el4aii+OCpL/Adha927F7sIoA+eHZqbhhOGdWb3wquJwWxEqg0PeNRtl1tgcxSXL41Qpd34qS4m+Gm8Ekq2rR7NL6Ab9H1bNzb5AE1i+yI78/9UoFXCxqdX0BRFlmt96QsBZ5xrGw5rnouz3wD5LQRX0hLRzr2EELRuU4DNxdF9xnGnP0055fClhrJnw5Vidz9ckC128Z4+fI7p0mVurUfwad4GtSTMeEmKGwlCtcwwv4bMsF+hBY7N5K4tTklZ70ZfMexm+yxReyWRd6OAm67AbvDdIFb5kGW5gDCXix8pTqchEDugyMHm+DLPMoGH39KfEaDkd+4i3wj4PmDGkoe4HtD5Y/8W8Cot3u1iSkWGl/XDUvizrkaH+0XSxtjCbIjpHJEOY4AuG/Y5q0gEr2NEsIU6aktp3NJwsbIXlcT0DteP0irFlZ5+buO5bA2o56MiAkppLQ8WCRG0cJH3vipPG4+hx2cmlntgF4aaHY64R2kanIVrrsYEu9bMPhlhjxED1IdcIUkq03AVVBoLkGEGWzKhKLUxWCF+KopWK7wqEemmwB51SdqD0bNyleGJVggZqWMn8lJ257CBoBDctZ6mojixPRO0RNfySMtRjZRQll/61ol0q5vEi9aEp811iI9g+y6nE3WU+wlCD5+2dhk3BnD+vjz93tsKm12723toylsogoJIZtLmGPw== 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:(4636009)(396003)(366004)(376002)(136003)(39860400002)(346002)(478600001)(36756003)(1076003)(66476007)(2906002)(6512007)(66946007)(83380400001)(66556008)(54906003)(8936002)(86362001)(5660300002)(8676002)(6666004)(316002)(26005)(6486002)(110136005)(6506007)(38350700002)(52116002)(956004)(2616005)(4326008)(38100700002)(44832011)(186003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XUQzScDS7m7FnMNaBR3LcsfScwIiPtPeke7Px4FkTzcNJQXR2dZMlNtUX5TL4b9ghxNM60u2XGn9+N3N0LCuhOjnsbiKR8x5ja84KWgKNxgXVSEWuv6wt01JIChRxbR5r6y3VJ+8TavObd+On10SKsIQtJuC7IlZ1ErBkpwvNrMVc8DR1AbpyKQnL0LrEpBUZ0jCOpALf4BFpRBhSYPIEZ5RqdlOEfw3EwgbkI9sAQhH7UsPAuDcH7O73npcYpheg7eSGlZuLe7GXIYaUBk5USi/4Y2G0OIxNXZ6mW682/Ntgp2GNPq1omQUm46gzUYX7yL5GIWX/uwRPZ/s0Wh4z3OA4xBH3FTEXk3uVgAJ0t58p8omR0k6pp8XsLKfhIf0EGurhXQnK/OjZ6BAdOIGX/byJRTxLs9TfIWnzkc2fn1o+7HlP/tgOu73OpaFiYqDjfQbFxoDk8XDyeIbDvOZYgN9Xlx4RbrR9b0CyeKbggBc/OUa4KKE75dQGukuYt++18/dwBXsXtjclG6sGxfIxU6MDszdDjNIWI8Dsgz1yUKM4ussKAGg9v1jlU7iCYyCaNGgBq3ihr89Lu0GhLgSfwfiieJLwEPYpSQUGaZtvrp4zcYkTXk+p0xYbZdYTHSBAbSUmF3P9GWdLDOEGMP1kzdpoZrct2awVMMGeu9U+e6l1EWZ6AZjnc0nkL0ldw31HV8WLa1Iam3Ad/AX6tkKyGfQv1pog1HYxXyGiehodLOVcsfQjWRTjQm/5PXFZ4FCnn71AZ+q3OyomYRUpzj5Ew451lLhArAJ/VoQJ/PKToQHJhvjaAmV8IHwUbfNCUknzP22+DbLgHy+8qbEjJkFTkSQggYuiY/QhP243UVv5l1Fvq2gLPVNkIdBHVpF8r0LI4/YkH7mI/GzpwCJuKBgj6OIVy3sRgEbXWoWKWX5MfPOHYnfOqwqx9e9kqnqK44ZpAXlT+7+/CPkCgUQUYKjPx8nyYErgaj3maLxFSwuNGwcH7DAbSN6f1Mh+OcfvKkfeTcm9k7rZufN9tMGonN3ZDHgiumlgYACxDmxwqK8uyYXKnGLpT6gAz3U09BfnVpoDMSwnjul+CktReodQe1sFYaNEfIzvViqwXBswYXKs96Yryv55K0zEKLzuro6v2+lnXiIYt+QiFfEarH8NNWKo81dLuKuonmhzPOLcnDMTZgA5JZNP8JBIjRG1J/w4rYJhmk7SIvCiUXqCQglFEnDGLzq+NXHEIDambu9nnPC4gLQjVXng6HKEontVSp26x8Vm0qSNOWf8xilnaejKio5tr4JbGJXhNx6oCF5dnUAEoP5xP97UsarrDbnrr14ZxLU X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e02d7dc-d893-482f-8149-08d9574a19e3 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2021 13:16:42.4731 (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: sz8eBR/5G40z/msr2TCpAUbGyryhmXHTMr46cwVPYVEc0OvZ03edkZjE6tbWMJTmWOKksEHYBTaV5h2O28hhAA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3967 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There is nothing specific to having a default CPU port to what dsa_tree_teardown_default_cpu() does. Even with multiple CPU ports, it would do the same thing: iterate through the ports of this switch tree and reset the ->cpu_dp pointer to NULL. So rename it accordingly. Signed-off-by: Vladimir Oltean --- net/dsa/dsa2.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index c7fa85fb3086..4f1aab6cf964 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -329,7 +329,7 @@ static int dsa_tree_setup_default_cpu(struct dsa_switch_tree *dst) return 0; } -static void dsa_tree_teardown_default_cpu(struct dsa_switch_tree *dst) +static void dsa_tree_teardown_cpu_ports(struct dsa_switch_tree *dst) { struct dsa_port *dp; @@ -927,7 +927,7 @@ static int dsa_tree_setup(struct dsa_switch_tree *dst) err = dsa_tree_setup_switches(dst); if (err) - goto teardown_default_cpu; + goto teardown_cpu_ports; err = dsa_tree_setup_master(dst); if (err) @@ -947,8 +947,8 @@ static int dsa_tree_setup(struct dsa_switch_tree *dst) dsa_tree_teardown_master(dst); teardown_switches: dsa_tree_teardown_switches(dst); -teardown_default_cpu: - dsa_tree_teardown_default_cpu(dst); +teardown_cpu_ports: + dsa_tree_teardown_cpu_ports(dst); return err; } @@ -966,7 +966,7 @@ static void dsa_tree_teardown(struct dsa_switch_tree *dst) dsa_tree_teardown_switches(dst); - dsa_tree_teardown_default_cpu(dst); + dsa_tree_teardown_cpu_ports(dst); list_for_each_entry_safe(dl, next, &dst->rtable, list) { list_del(&dl->list); From patchwork Wed Aug 4 13:16:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 492114 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2BCEC4338F for ; Wed, 4 Aug 2021 13:16:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8692D60F43 for ; Wed, 4 Aug 2021 13:16:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238392AbhHDNRE (ORCPT ); Wed, 4 Aug 2021 09:17:04 -0400 Received: from mail-db8eur05on2086.outbound.protection.outlook.com ([40.107.20.86]:63904 "EHLO EUR05-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238008AbhHDNQ5 (ORCPT ); Wed, 4 Aug 2021 09:16:57 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MurvQMntGQoBgjCKenlg6s0q0g0kDY5Wp/3cqMiuL76EsOuKZKHmSvNUfy38xBf5oAIKX0RuCUMuAKVwUp49n2Bf5u2aBiYmMbdcITQ6RCRiv2c2kpfGukLwsa59ejjHSZqQyWoO5OQdbFg6oTG5XkOk6WLlepds4trOT7MLNIKkkSIYxY2P59u94gJ/sHfPGAqFNdmjllLi4DHgKVpkZGaNfExhwMAHmpMrK0ViBgzX0ksXHI89/oqPsU1q+6iwV3ls/QIWNwaBXZHAa55iJRDmfXjnpf1GMlh7lsHnL6Cl7fHWa6x9XLVtdxzoHaFckgw0a+MsELJhLyS1HxCP+w== 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-SenderADCheck; bh=kQ4VLjmrVUZqTzilbfHTVPCgRVFwI2Iy3E4oqB3Vfd0=; b=m1goNdBmikK+wfCzofbq84pb1Ok6ONnGRUDoroyChedQKe9qakkp5gE4aVtE+2NzvvI1RyE4a5PTFY373/Q0id+Ec0GMEo5oiLm8KJ6EkRGuFeVEAUjBFy5aJW3+Q/pCodfylclVcDhiIWIYJJVwkCYc+v5dZOmegLYvPXC+UftpOhX6w9swKyMzmfUNju0BabRx7WEyMDpKXOhPOsU4aZtBjfEyThbFH9rdc7TbxREknCdhTVOwx4EJcNgoPH8gqQllXxOuyQaCMKOXLj7gEIA8CcusroTN543kAKEVhQ3PO/xGKQTc0XZSTv+yUP+IYTpN9M1y+jKsqmmWo5NOvA== 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=kQ4VLjmrVUZqTzilbfHTVPCgRVFwI2Iy3E4oqB3Vfd0=; b=Oz0IBlkCQqExn6n32AQTcygOUxpRRMYIWkoqLbH04LdmC5GobMa7WjJOc+2+tnuJ6g2ZyjHO9bytyPv0wloln7I/nkZgw2bMbcUhZWNsdpEH2YMSc5JUAt/UgB4Buok07BwtRNIn5TuBppflXDUHoJB8pKY48L75rDdASTk3zIw= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR04MB3967.eurprd04.prod.outlook.com (2603:10a6:803:4c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.25; Wed, 4 Aug 2021 13:16:43 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4373.027; Wed, 4 Aug 2021 13:16:43 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean Subject: [PATCH v2 net-next 2/8] net: dsa: give preference to local CPU ports Date: Wed, 4 Aug 2021 16:16:16 +0300 Message-Id: <20210804131622.1695024-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210804131622.1695024-1-vladimir.oltean@nxp.com> References: <20210804131622.1695024-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR03CA0083.eurprd03.prod.outlook.com (2603:10a6:208:69::24) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by AM0PR03CA0083.eurprd03.prod.outlook.com (2603:10a6:208:69::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Wed, 4 Aug 2021 13:16:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2700edde-94ba-40d2-9e28-08d9574a1a73 X-MS-TrafficTypeDiagnostic: VI1PR04MB3967: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XGZaEwGKo98Z1O7FYqx7jpQJpLDVNqae1hcJ4XCwo/yyIfWfRSC6plO95o/iy/eeapiikcKS86NcYaTvj9zyD6AN98Qt7YwmQXfKjjjU/XUrQwjgtP6flI6AGiNHAbr/2PYuVRvnF06J+8h15x2/verEhLtqtZikcDJyRb1WWz9+a7MyUS6JtyUdCAD/EOya4empebFmxTJHwR+JdbZc0dD9f5sWB4hVtUWMt4Ycr/AkNZ1oS8Otk7G05ux+Mfkx0YJb5e5kfbVX7Sixx/xZGY5GFFCut3GdEGF2+VqvfdHo92+qFKQdGXItQL+Yegg3VFeD1+QGQIYKWJWXL0FZimqwKfBpK8RpOp4kCjmLI1fMIucM4uqhcpEpHe5PZD1IsEzBwjldbGOcN+nsS+3xVegAqiB/kgrkfqXlMSXb3Gqqcc7hm6OYDYZrOxYtOtSDssP69Y7nHxRRoGDwl2qxwIPxFVx9l+PONk9BgEmBk/glZWIYPhxXN8g1RjPpkL1MnWbvW+f1v9gVRS2Mz3UZuD8qaRt99J8xek7Pu18T9yflgk8Kit0HEuacwQbvXl72KBNx1hlMyfPAZCoKxqfuIgR59pgtZEcDIdjutzrtACvjJ0B5HyBen77uCubEgE0loWHg2v3NNBtoAU53MDR4UvmDNNXna9daZ/TbklwqT/mwlKmapq9HuTQJe1P1dAKrIy611bVegMEofeuOwe1mvw== 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:(4636009)(396003)(366004)(376002)(136003)(39860400002)(346002)(478600001)(36756003)(1076003)(66476007)(2906002)(6512007)(66946007)(83380400001)(66556008)(54906003)(8936002)(86362001)(5660300002)(8676002)(6666004)(316002)(26005)(6486002)(110136005)(6506007)(38350700002)(52116002)(956004)(2616005)(4326008)(38100700002)(44832011)(186003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OVkTQbyrMG9z+tzzi17Y8UEpnK248KrihpzFu9kMsnCTVcPu3+pYXQc4Jx/nkFZ7V/qSW0BBZez31ZrXx2vcdv40+uCSyY2/lumGpaldO00h/iNPFxUfrUx3mgLRnR/GbmSIgtitXfklNuRQlAbjYNg5IXA9/fJySdCTuuy61dXPfjNzZHuJaIgXfNRQXLjQMUnuKwR6WDWA55HAJEnb0Kv38u1jMuJGiUVmhdhOcgjXbWI3BMRGOQTTGjxig4D2qnZ5L9SVRTUEWaPb0s5mlQN5F32fKejdSSc9dJbrqUh8Bhlh7pxw8IWUeqEd56FWyq0tE5rh7KVfzpLvc577dla6/fk+C1EkcuXibyAUqOfbCBa6nnSG9m5wDO11laYHawOrMAmazLDco1RA2qOZeaT1uaYDXas4J3EXkp3GH0J+uX0GEKN/eq+vFAUdQDHCcslOA20HZq/HlfoJsbPfUlLtqFVHe7JLhFCM5LxK93aTyhB/vkQ3iCUFCCT/JfgOSYK6+DnzAuqK7HNsKW192mxfnfNosHFqUKQpBUtZ4Zr6OJHj4J12xDfcMPediXoF825FnufTSgE6Lp7L8zXX15/zpDxhJniwAcDDzQgLbKnH1NrfjRKEqFjYsiZy75LHlA0XdLSM06G4XUaryDXYWTCkdc3ipy8UzVOgmM0Me9Nj6L71p5rNxD+NzS+6SPctGi3fcaiuQ6cBlXlZfgfa0Dw+4TpVuB677h5h8yBaIQs8OmKP2nT5MZV6dKCpk3+n1JGzIzCA3gpYh06WjSzV+HEZG5rh3Hvx2Spy+HRgzfLiWeo4STF+Ki0Pp0uhfxz+KmL1I/5JmBhryMkNeyWzJgJGoqvcu6iW1TFJwNf1Ca4iJfKgPD57vCZ28/+loBuu7chXyw/jmoQuQoBOJGY0YEfwjtKC+YvqyOfkN4jbLza4mGh368BRXzV1G6he6v3W886yB0kmNoatsx6ayAPkuB9+EwUq41CftnUka6nxyGkrwbKdbWFQdKfd8D21PiHNq70U7kcintyT4S9Ko6xZSczVaP5xIntaoBX2/sAsmjhFNDFfkZ9E7oWHmuZtDkQV4vsKuNmkJb0yNeU1BerrhsFReSQf6KKazPSwupAJ2uqFKHlTBKp2593Wdjh6Mi1ypldG6MUoOrppjS4rIe4NNr7bdBv29W1Ijt0srFXy3hdSE94xi16WEut9XG9ZqqZQua8/ILy/AgTIrZDFsB+osM7Ppa6LRXmjy7s2ISAj9Wx+WJZER9O0Nx07oJObStzke2BVnnZI32KvRoH+9TRHqe/ACihmGl5FfyNP0cg2s91rRtKr3wAuPgAXLzHGJAES X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2700edde-94ba-40d2-9e28-08d9574a1a73 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2021 13:16:43.4176 (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: HhUtl0ATyEuTQf7/vp9JEwXG0mQpGS8dOoU2T8XekYPEQYHcmfhA3nZblmMxT2AiPuu1EOne3ka7I36DUzgtDA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3967 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Be there an "H" switch topology, where there are 2 switches connected as follows: eth0 eth1 | | CPU port CPU port | DSA link | sw0p0 sw0p1 sw0p2 sw0p3 sw0p4 -------- sw1p4 sw1p3 sw1p2 sw1p1 sw1p0 | | | | | | user user user user user user port port port port port port basically one where each switch has its own CPU port for termination, but there is also a DSA link in case packets need to be forwarded in hardware between one switch and another. DSA insists to see this as a daisy chain topology, basically registering all network interfaces as sw0p0@eth0, ... sw1p0@eth0 and disregarding eth1 as a valid DSA master. This is only half the story, since when asked using dsa_port_is_cpu(), DSA will respond that sw1p1 is a CPU port, however one which has no dp->cpu_dp pointing to it. So sw1p1 is enabled, but not used. Furthermore, be there a driver for switches which support only one upstream port. This driver iterates through its ports and checks using dsa_is_upstream_port() whether the current port is an upstream one. For switch 1, two ports pass the "is upstream port" checks: - sw1p4 is an upstream port because it is a routing port towards the dedicated CPU port assigned using dsa_tree_setup_default_cpu() - sw1p1 is also an upstream port because it is a CPU port, albeit one that is disabled. This is because dsa_upstream_port() returns: if (!cpu_dp) return port; which means that if @dp does not have a ->cpu_dp pointer (which is a characteristic of CPU ports themselves as well as unused ports), then @dp is its own upstream port. So the driver for switch 1 rightfully says: I have two upstream ports, but I don't support multiple upstream ports! So let me error out, I don't know which one to choose and what to do with the other one. Generally I am against enforcing any default policy in the kernel in terms of user to CPU port assignment (like round robin or such) but this case is different. To solve the conundrum, one would have to: - Disable sw1p1 in the device tree or mark it as "not a CPU port" in order to comply with DSA's view of this topology as a daisy chain, where the termination traffic from switch 1 must pass through switch 0. This is counter-productive because it wastes 1Gbps of termination throughput in switch 1. - Disable the DSA link between sw0p4 and sw1p4 and do software forwarding between switch 0 and 1, and basically treat the switches as part of disjoint switch trees. This is counter-productive because it wastes 1Gbps of autonomous forwarding throughput between switch 0 and 1. - Treat sw0p4 and sw1p4 as user ports instead of DSA links. This could work, but it makes cross-chip bridging impossible. In this setup we would need to have 2 separate bridges, br0 spanning the ports of switch 0, and br1 spanning the ports of switch 1, and the "DSA links treated as user ports" sw0p4 (part of br0) and sw1p4 (part of br1) are the gateway ports between one bridge and another. This is hard to manage from a user's perspective, who wants to have a unified view of the switching fabric and the ability to transparently add ports to the same bridge. VLANs would also need to be explicitly managed by the user on these gateway ports. So it seems that the only reasonable thing to do is to make DSA prefer CPU ports that are local to the switch. Meaning that by default, the user and DSA ports of switch 0 will get assigned to the CPU port from switch 0 (sw0p1) and the user and DSA ports of switch 1 will get assigned to the CPU port from switch 1. The way this solves the problem is that sw1p4 is no longer an upstream port as far as switch 1 is concerned (it no longer views sw0p1 as its dedicated CPU port). So here we are, the first multi-CPU port that DSA supports is also perhaps the most uneventful one: the individual switches don't support multiple CPUs, however the DSA switch tree as a whole does have multiple CPU ports. No user space assignment of user ports to CPU ports is desirable, necessary, or possible. Ports that do not have a local CPU port (say there was an extra switch hanging off of sw0p0) default to the standard implementation of getting assigned to the first CPU port of the DSA switch tree. Is that good enough? Probably not (if the downstream switch was hanging off of switch 1, we would most certainly prefer its CPU port to be sw1p1), but in order to support that use case too, we would need to traverse the dst->rtable in search of an optimum dedicated CPU port, one that has the smallest number of hops between dp->ds and dp->cpu_dp->ds. At the moment, the DSA routing table structure does not keep the number of hops between dl->dp and dl->link_dp, and while it is probably deducible, there is zero justification to write that code now. Let's hope DSA will never have to support that use case. Signed-off-by: Vladimir Oltean --- net/dsa/dsa2.c | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index 4f1aab6cf964..9ff928ccddb0 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -311,6 +311,9 @@ static struct dsa_port *dsa_tree_find_first_cpu(struct dsa_switch_tree *dst) return NULL; } +/* Assign the default CPU port (the first one in the tree) to all ports of the + * fabric which don't already have one as part of their own switch. + */ static int dsa_tree_setup_default_cpu(struct dsa_switch_tree *dst) { struct dsa_port *cpu_dp, *dp; @@ -321,14 +324,42 @@ static int dsa_tree_setup_default_cpu(struct dsa_switch_tree *dst) return -EINVAL; } - /* Assign the default CPU port to all ports of the fabric */ - list_for_each_entry(dp, &dst->ports, list) + list_for_each_entry(dp, &dst->ports, list) { + if (dp->cpu_dp) + continue; + if (dsa_port_is_user(dp) || dsa_port_is_dsa(dp)) dp->cpu_dp = cpu_dp; + } return 0; } +/* Perform initial assignment of CPU ports to user ports and DSA links in the + * fabric, giving preference to CPU ports local to each switch. Default to + * using the first CPU port in the switch tree if the port does not have a CPU + * port local to this switch. + */ +static int dsa_tree_setup_cpu_ports(struct dsa_switch_tree *dst) +{ + struct dsa_port *cpu_dp, *dp; + + list_for_each_entry(cpu_dp, &dst->ports, list) { + if (!dsa_port_is_cpu(cpu_dp)) + continue; + + list_for_each_entry(dp, &dst->ports, list) { + if (dp->ds != cpu_dp->ds) + continue; + + if (dsa_port_is_user(dp) || dsa_port_is_dsa(dp)) + dp->cpu_dp = cpu_dp; + } + } + + return dsa_tree_setup_default_cpu(dst); +} + static void dsa_tree_teardown_cpu_ports(struct dsa_switch_tree *dst) { struct dsa_port *dp; @@ -921,7 +952,7 @@ static int dsa_tree_setup(struct dsa_switch_tree *dst) if (!complete) return 0; - err = dsa_tree_setup_default_cpu(dst); + err = dsa_tree_setup_cpu_ports(dst); if (err) return err; From patchwork Wed Aug 4 13:16:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 492761 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8869AC432BE for ; Wed, 4 Aug 2021 13:16:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7150A60F41 for ; Wed, 4 Aug 2021 13:16:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238400AbhHDNRK (ORCPT ); Wed, 4 Aug 2021 09:17:10 -0400 Received: from mail-db8eur05on2086.outbound.protection.outlook.com ([40.107.20.86]:63904 "EHLO EUR05-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238339AbhHDNQ6 (ORCPT ); Wed, 4 Aug 2021 09:16:58 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ETo/R/qZykIgtUzwH38Cy3cfJ+pyXPX3FX7ZB9FXLb7kusF4qgHFVqG8xsJouBK98HIkpHaEMu5+RmJjTyY0Vhz9WQn5Qs+bWAd5A4xd2xOgfGMswc/YwW6XGQB/kYSIIOUJ7eJSE8k27GGJBrZYNKbFeCkKumLlGxjM+xnKmhLGzSKTcY1vjfpEzfS9AwYl9fH8GoG2i0cOR35P7TS5zLW6FGyS61iPO5R4k9PB0xjBTCHWfrs0ygVikBQ21wLXTPe2I1/ng6UPE4iPUkNGSOBMBPzzPaeyw2gvkRLKmXAqvXuGx69HhVpB8OSm0touot0wjxvZQDlc9hCZiylyBw== 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-SenderADCheck; bh=amoeNrWJ4532H2p7QkiIVWJGcprWXA9ktT8T2gaXz0o=; b=NZcRMWaZ0lXDgJZcBdtzy4idKQfys1NWKlD5y8Wr/s7zA4w7sftAMRJh613B1BtObSDvVpZX8WvU2xHp1Ptf8wke4qYcHgmmL9squ0LxpTWgoxjsyUEvs54soqyzCfF99N3IyZBQHOLU6jbBqrIr9QdFQoZkUdsFO4Bk0hnHEU1t1aj2q7iHm0cxbj0emqWNisau6HgF6ZNqBSaV8i5WneSwxltDltI0IlUx0cvm8LcCv7Wk750gIbZKWSCYqGPYUxdkK7VL1v0H3ll/rwi0HFIrp2azh/6/jXU8pyTTaD/El+RBxs23rM7f8PGxzAN4xLtEn/F7z6QigFBSOSiLWA== 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=amoeNrWJ4532H2p7QkiIVWJGcprWXA9ktT8T2gaXz0o=; b=VAG6o5tR3od3qsfMwvntjyZuSX03l1TetViwbgFZtPQUY1D21bFSvaLnaRrAFCqP5dh3rp/p0MaKRpnDwqpBYhvUKRNw8EfGRNwH/drDHJWRAlN3hKrwRApt3PN5GtmUtSSOOt35Wvb8EM2FTKDb9uCU9lnS/GuwSFea7BO8Hak= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR04MB3967.eurprd04.prod.outlook.com (2603:10a6:803:4c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.25; Wed, 4 Aug 2021 13:16:44 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4373.027; Wed, 4 Aug 2021 13:16:44 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean Subject: [PATCH v2 net-next 3/8] net: dsa: sja1105: configure the cascade ports based on topology Date: Wed, 4 Aug 2021 16:16:17 +0300 Message-Id: <20210804131622.1695024-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210804131622.1695024-1-vladimir.oltean@nxp.com> References: <20210804131622.1695024-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR03CA0083.eurprd03.prod.outlook.com (2603:10a6:208:69::24) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by AM0PR03CA0083.eurprd03.prod.outlook.com (2603:10a6:208:69::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Wed, 4 Aug 2021 13:16:43 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 73d1af8a-eff3-4be6-7a61-08d9574a1afd X-MS-TrafficTypeDiagnostic: VI1PR04MB3967: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: v+zLDmuqbf9yG/33P92lsy6ou4LCqa/fSdvxJHFafbn5z0j1p8DmFIwyw4R7/vgNokc3/hL6DCTrY6imxzkq3p/Sgdc4255TskwBnILJW2oOcf6y1FSrUjsGMsk9bNyVhyVjOMSzBYCENBCfHMAiqtIEINHP7TKAnQVOynyOhenK1ZiV8IEWQEOQAHYgdhTBU1r1HQIwpHE7yp08cMT3BZ0/2HWR0P1tRSWmKMYMkm26feYgR5sJc9UjNqg3K9LvK08B/d9uuV7pr6P2vHkpJTvJZqi22GYFP8Z1EPfAqdYjhKt+mJXIFcyp8vuyfX0G8WAGMUrhdLqxriCuv2EF/QBtuUUzGw3wd1q5DopX1CyluKAWW97d96j+oOa5ZoJLeT9Hfwl9YbZv1uXs4GMDnyuIX3nhnWJgtZJnjRPZvdBvGGt/NaDX4JYxptazYdznaXYN6GLEiZeSivzGb5+thCXOiMnT92LE9f2ivu/MmhjDfcwvP8DLoB0FDHP8wCce2z/D+32ACARIXj2iejauF/amfGyYAZVvIkWM6izQ9fI8ICjbZMGT/UswbY5mHmikEf3wsZXA10wCNrIyUqgsxvTtZn2TpeVrs30kWF48hoKxbCBat7RtIkjFyZiIXaUgTofjHGy3nxTp13ydjMw9R24kJY7s0ov7lKaMb3JmIN2N/sBnTub3KjIzroEnUq67 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:(4636009)(396003)(366004)(376002)(136003)(39860400002)(346002)(478600001)(36756003)(1076003)(66476007)(2906002)(6512007)(66946007)(83380400001)(66556008)(54906003)(8936002)(86362001)(5660300002)(8676002)(6666004)(316002)(26005)(6486002)(110136005)(6506007)(38350700002)(52116002)(956004)(2616005)(4326008)(38100700002)(44832011)(186003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: s6c/UHRcCcr0uVrtGuMOzseM02PW67eTKnGfRLutNl3YQjixgpTqTAPlhyepAhRK0aHtPc+mNURBlKDyrtTQABUXrwmJ5ktkm28OCbjrtK1HLuw30oeg2K+LGtg/xx66GynWZbzFq6K45+CskLQItyd4kIEkvJvgJOuQ4kqAuOPg8uHseF+qSBP2W3KtJB4jzqxoqdUOHmqqysCwIM6zpcE48WFcztLinpJwaf3/YBMBkDNvlWaQWpjJXnqrdcs4D8/Kudw2/UNLwAJvru9WzXicQrjAVi3ZEe+pyPBxhKCafFJ7bd+NZHLVIhVvkWDyqO/BzccD6Zik2Udl0qu+kUtHfgGGJ4qMfIcAw/x1b10+ZKBYYoeOf3g1CMNxYg4BWEj5O6ZIW6Qx0r0nEBoVSYxtV3vPIyZEfvJPuVm3OMQC3jG/YlietuiNJKJSGYVGcttMLvXT6f0wtuE9xJsBIkyLLkNl+3Ii38m1f4bHRIuQnKh8lCiFuP7xxX3ISllabQpQkhHODF9M1DT7DiMJZmOMyZw4DusIVFDaKZPt4HGSxhtc0/rFjjrx5GYHb6HiwVBFJEijQ+kREbI5xoQzSOUXPPCvfgtV3T87Lxv1/h2R2mmXYUZjR5DF0rbNhCwGR8+mC9dWSiUiJp3oRD+YG2w3Qb4vQ6Mcnu3WjhVgtuVrRAIJImz/lrznlXsMszFF8DI/aLvMFFkwauKdzuEIsxSDgx958d/ryTJ8uQUL+jOj31E3pmTyDbpr9Hlw7sKmpV0SpGRS14TAm0cMgatnVkfLCIr+3m8gTePWsvzQ8nMbwIMfbuAkRTFL7kGkMHdHhYVS0WRHB/CzdqIrbqP3cwm4yoQqP1MO9B8aP8qLDyWoRLyBXlmekn3t+ZQl1C2ww35sPC9ASnuzPL/NgbCr389HYnJFZ3Imzw7DUlEr+LVnsLGTegf8EbE30jETyMx3um1AcDIoSM7i6FNcvyNdDCqF4yMkZRAR5v2yxxiNG3/HKdxkBPYmLb4RYh4QoG+JXB0s17IjIxmO2rN1U2/uCkwFxkWAwyCpZdBno6bdQ0NUvz2k8j7cQ9pm03GUh4mwX7KkalG1kaT1jXXp3+ESfF4nk/2S9lPl+8X89q/0LzTd5+w28UTxZnrE5PTFaDi01U4gVKpxFrDDJvhaUFIhczAfThICtdcd8sDuNv2hBGpsGmb1Jba/H96rH6LEM2qi/TUWP8xLjkIjtAW2oRgm0n9reiAtdcq88I4k5NZTSrIRVu20HufoeFUn2CE9VKFTT+yQfeuO9YGKOXRZ28cssLYvHESeoCY/3oJ/qW1ICgvPV5kzlnEXf3e16L8FrSxT X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 73d1af8a-eff3-4be6-7a61-08d9574a1afd X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2021 13:16:44.3490 (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: Jq/tl9O8sDrcrsobyXsW4mK37ymxqD20DamORdw1wLcpnDeC7vV0tB0Nj6lOAsQyncj7O+AIKLcHPFKbw7IGlg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3967 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The sja1105 switch family has a feature called "cascade ports" which can be used in topologies where multiple SJA1105/SJA1110 switches are daisy chained. Upstream switches set this bit for the DSA link towards the downstream switches. This is used when the upstream switch receives a control packet (PTP, STP) from a downstream switch, because if the source port for a control packet is marked as a cascade port, then the source port, switch ID and RX timestamp will not be taken again on the upstream switch, it is assumed that this has already been done by the downstream switch (the leaf port in the tree) and that the CPU has everything it needs to decode the information from this packet. We need to distinguish between an upstream-facing DSA link and a downstream-facing DSA link, because the upstream-facing DSA links are "host ports" for the SJA1105/SJA1110 switches, and the downstream-facing DSA links are "cascade ports". Note that SJA1105 supports a single cascade port, so only daisy chain topologies work. With SJA1110, there can be more complex topologies such as: eth0 | host port | sw0p0 sw0p1 sw0p2 sw0p3 sw0p4 | | | | cascade cascade user user port port port port | | | | | | | host | port | | | sw1p0 sw1p1 sw1p2 sw1p3 sw1p4 | | | | | | user user user user host port port port port port | sw2p0 sw2p1 sw2p2 sw2p3 sw2p4 | | | | user user user user port port port port Signed-off-by: Vladimir Oltean --- drivers/net/dsa/sja1105/sja1105_main.c | 97 +++++++++++++++++++------- 1 file changed, 70 insertions(+), 27 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 5ab1676a7448..74cd5bf7abc6 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -688,6 +688,72 @@ static void sja1110_select_tdmaconfigidx(struct sja1105_private *priv) general_params->tdmaconfigidx = tdmaconfigidx; } +static int sja1105_init_topology(struct sja1105_private *priv, + struct sja1105_general_params_entry *general_params) +{ + struct dsa_switch *ds = priv->ds; + int port; + + /* The host port is the destination for traffic matching mac_fltres1 + * and mac_fltres0 on all ports except itself. Default to an invalid + * value. + */ + general_params->host_port = ds->num_ports; + + /* Link-local traffic received on casc_port will be forwarded + * to host_port without embedding the source port and device ID + * info in the destination MAC address, and no RX timestamps will be + * taken either (presumably because it is a cascaded port and a + * downstream SJA switch already did that). + * To disable the feature, we need to do different things depending on + * switch generation. On SJA1105 we need to set an invalid port, while + * on SJA1110 which support multiple cascaded ports, this field is a + * bitmask so it must be left zero. + */ + if (!priv->info->multiple_cascade_ports) + general_params->casc_port = ds->num_ports; + + for (port = 0; port < ds->num_ports; port++) { + bool is_upstream = dsa_is_upstream_port(ds, port); + bool is_dsa_link = dsa_is_dsa_port(ds, port); + + /* Upstream ports can be dedicated CPU ports or + * upstream-facing DSA links + */ + if (is_upstream) { + if (general_params->host_port == ds->num_ports) { + general_params->host_port = port; + } else { + dev_err(ds->dev, + "Port %llu is already a host port, configuring %d as one too is not supported\n", + general_params->host_port, port); + return -EINVAL; + } + } + + /* Cascade ports are downstream-facing DSA links */ + if (is_dsa_link && !is_upstream) { + if (priv->info->multiple_cascade_ports) { + general_params->casc_port |= BIT(port); + } else if (general_params->casc_port == ds->num_ports) { + general_params->casc_port = port; + } else { + dev_err(ds->dev, + "Port %llu is already a cascade port, configuring %d as one too is not supported\n", + general_params->casc_port, port); + return -EINVAL; + } + } + } + + if (general_params->host_port == ds->num_ports) { + dev_err(ds->dev, "No host port configured\n"); + return -EINVAL; + } + + return 0; +} + static int sja1105_init_general_params(struct sja1105_private *priv) { struct sja1105_general_params_entry default_general_params = { @@ -706,12 +772,6 @@ static int sja1105_init_general_params(struct sja1105_private *priv) .mac_flt0 = SJA1105_LINKLOCAL_FILTER_B_MASK, .incl_srcpt0 = false, .send_meta0 = false, - /* The destination for traffic matching mac_fltres1 and - * mac_fltres0 on all ports except host_port. Such traffic - * receieved on host_port itself would be dropped, except - * by installing a temporary 'management route' - */ - .host_port = priv->ds->num_ports, /* Default to an invalid value */ .mirr_port = priv->ds->num_ports, /* No TTEthernet */ @@ -731,16 +791,12 @@ static int sja1105_init_general_params(struct sja1105_private *priv) .header_type = ETH_P_SJA1110, }; struct sja1105_general_params_entry *general_params; - struct dsa_switch *ds = priv->ds; struct sja1105_table *table; - int port; + int rc; - for (port = 0; port < ds->num_ports; port++) { - if (dsa_is_cpu_port(ds, port)) { - default_general_params.host_port = port; - break; - } - } + rc = sja1105_init_topology(priv, &default_general_params); + if (rc) + return rc; table = &priv->static_config.tables[BLK_IDX_GENERAL_PARAMS]; @@ -763,19 +819,6 @@ static int sja1105_init_general_params(struct sja1105_private *priv) sja1110_select_tdmaconfigidx(priv); - /* Link-local traffic received on casc_port will be forwarded - * to host_port without embedding the source port and device ID - * info in the destination MAC address, and no RX timestamps will be - * taken either (presumably because it is a cascaded port and a - * downstream SJA switch already did that). - * To disable the feature, we need to do different things depending on - * switch generation. On SJA1105 we need to set an invalid port, while - * on SJA1110 which support multiple cascaded ports, this field is a - * bitmask so it must be left zero. - */ - if (!priv->info->multiple_cascade_ports) - general_params->casc_port = ds->num_ports; - return 0; } From patchwork Wed Aug 4 13:16:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 492113 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7229CC4338F for ; Wed, 4 Aug 2021 13:17:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5D0C060F41 for ; Wed, 4 Aug 2021 13:17:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238423AbhHDNRP (ORCPT ); Wed, 4 Aug 2021 09:17:15 -0400 Received: from mail-db8eur05on2086.outbound.protection.outlook.com ([40.107.20.86]:63904 "EHLO EUR05-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238360AbhHDNRE (ORCPT ); Wed, 4 Aug 2021 09:17:04 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AX7FZ8EOvLsmvWV060XAvT0UaLzivpBB4MMtuc564Uinj4+BCEV4IKWunb75JJFQUm3Sz9CHjXlIR3W8nvvayie79swlJ//L5Waw5WfwZGFf+9tojW6cLauEFkk2SllUG4gJhGhj4Lyuzj52ivLAQpftvix8EyNorX1GbWY92qKwOZxULoBOC+3cQQBo/uZRmBsCKHBiMHKD19R25aNJ5p2XlBD5kkJ37pDwn3wH0aOpiE+/+3GcXy1EN97K/XeGE8ZQr7H/U8RGnT6L7WdJ5ZCc2SZcczkfdHkFGUAbR5nvbGP53R9PzAwM2QkggJw6Gvks8VvxYRrcGNoWPyz6xA== 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-SenderADCheck; bh=+FUbX4vC43iGoyFViHGeh8jv2RK37AK+Gwbm2JgVWoQ=; b=mwB42miRfhtuZtVHsl01zrOx5HQIgB8gV8GN4kY6eVYl42ayNSHtNCXIkm9htAfB/T5qswMbHpkrRGq+uw1oJ0sITsqFKouGv6lEYwQmdSlXYSmphgTimfOG6ikiQ+t042f+voTrLQiHzsWsORiyxtyxTY/Z6fTrTWhXMYA6w13aeMSh+rQgnI2nld4WPiGD9JIDlvF8P2s8D7aXmlp+vr9wLLYT3UJ41Sk015+Y41+TCYzvpzsIOxqKQDlmhVeryfh81+Au9Bv/VoHuWH2PLhIxaRpqj7VwV5KOPrTlGmqh2xsFQ1iaWl/Nz7xK2wIyLhhBIuhBi/v7fS/HfOY8ow== 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=+FUbX4vC43iGoyFViHGeh8jv2RK37AK+Gwbm2JgVWoQ=; b=YfDP/M4AYhXDi26/sRmVAH7iFR2X1vbXlhOTrHwSBOogNzmxzFLTA8gqUpfDQjLVsk9m7RfAEq/qxJg4mPNamgVcI7oHRgDqAP3hhgLQEulBhhMEuwY1SDJcCvImoNxD04CurdczDZFIcxTCnQFW5Ttv3Byp8/qveILfg2J1aPw= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR04MB3967.eurprd04.prod.outlook.com (2603:10a6:803:4c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.25; Wed, 4 Aug 2021 13:16:45 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4373.027; Wed, 4 Aug 2021 13:16:45 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean Subject: [PATCH v2 net-next 4/8] net: dsa: sja1105: manage the forwarding domain towards DSA ports Date: Wed, 4 Aug 2021 16:16:18 +0300 Message-Id: <20210804131622.1695024-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210804131622.1695024-1-vladimir.oltean@nxp.com> References: <20210804131622.1695024-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR03CA0083.eurprd03.prod.outlook.com (2603:10a6:208:69::24) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by AM0PR03CA0083.eurprd03.prod.outlook.com (2603:10a6:208:69::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Wed, 4 Aug 2021 13:16:44 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5c45303c-3916-42c3-cf8c-08d9574a1b8e X-MS-TrafficTypeDiagnostic: VI1PR04MB3967: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2pp+UzoTgdtO4KXOgJThi/k6gRX2HJiifBfr+l9GgjtsIdtQq43oq77YyqRIlEotBQQy9nkME2u8qLyPsiUk074rkHbx5gFDcFZVy2qwfs3o4ytJFSwFcQwe2/I6AuD0y86PHBjXKY1KWMZIzSUNNFiYkj8wF9WuVQVrzJC5Pg2tDQbDlLEFBPxe9x0SXspf3724hs7I06vzJg2/zK0XlS4cFpLG+u8diK54n84jodSTGCo21iY0hrsFzLStLJEbvvHtKuViIoRLYWi49dwbA/bRcLgd2siwaMYJ8wUYj9Q8wat+PjWzgJY0pkGsFhY0n7ZUI8L317ioxckhvDweL4rcc3J3OkcKXJ4CY9sd6tUzc+LZLGLUlpzJz2U4yxETO1EO01NpN0yp/tBUnzLg3MZpxZvwW20I5OiJZRkEVa4U8aTib795b53yaXSaLY4ZYPOswCGlFyN0JPPp5kyXogoFvsTZojjj/T0dxSKUJT/pTAhK2eRCxYd1VeH5RA2xDcubg6pOG5+H0GHuFrG57CEesPDdD861Q4KpyE6SZWVvjeCfymLKH4dGh+mBpT5g5W7zgiBVM40QnpT4v7cVs0BPdbveZbQziccgSiUEm808Q7CrmKc1CHeV5slv1Vx+z5n5FcVF+IkoG32IIUOOztl8mpHj81SQ6gxbhWOlM91bUMIKzlCrmHjuvZfHwD0H 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:(4636009)(396003)(366004)(376002)(136003)(39860400002)(346002)(478600001)(36756003)(1076003)(66476007)(2906002)(6512007)(66946007)(83380400001)(66556008)(54906003)(8936002)(86362001)(5660300002)(8676002)(6666004)(316002)(26005)(6486002)(110136005)(6506007)(38350700002)(52116002)(956004)(2616005)(4326008)(38100700002)(44832011)(186003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NePi7wxh42bkJJo/VhUdP6r8rXcK3FLYtT1kbXEHP7ZhluhVUWNcmVZVtRcE1VKEqUYtVwPuETzft0SvxLrUSRQoZ46Ey7I1xR2esXI58KSMLnS+fIUcVuZxAO3NpKIv7858KyBRZC+37Nov9L5zyBVVqvmCpWHL7KaQKFOA+Foy6KoI5X5zPTSj1nZ72GVaitjGIvmXA93j3xRPJN93IdwHWvIQi8v9glh1kZWyNPknbrgtxUz0NHN9UWcUtUpQINLAKk0eC4JQd2OWBWRSP8YPDCDEFFy1az7n1QBQqDDKB2XxcU/WHXy3yVug+3BTZ/LkbB8HNWZJKRwFkV99Sk2Bre9sjBMpISPh5MVqPqEYNJx+3t3/clhshnthsWdVaa2xT681ePdIt/aqojr/mB0LbD3l2IhB0xayzuSjYsu8wXRnA/dP3eRVvEwha2wZKMnHW79bzBUZjz8g5abi5WMm4L/Gk1trc3VAnOPXBoZBjV5abZb/rtB/yruLCFz+QeGxT81I1yiU1PlupLEjyKpV9BbEJ4qvxOBjIM/wyTAuvXyVirIcuoiNA5FL9a5bdSnKxz4sMOJfk0WBud6RS86PEVkrw6EaEZOBkNWryKo4/51yXI6pDI0W+rt6WxPmb94YAq2j5Zbgy2zy1akmQXlGoH16htUN2XkPiQQeQtadhTgAjsnumVldhH4nE4hY/J77UeJY6bmr1OjK7qViJ0saELaB8UzBkP0Ds2CupVO58M6upupC6iFNVD7BBQnraR1Y7TQg6wEfsNpPKab0SHFFltaLnqG+R+J6Nyev6Aoo+jRjVwmxrXRoXtFWiBJQdVjFd4MiWsSb7X08YiEFGST9jiG217cgBHXcxKurdY7axtH4vihQNqCswBINZJ5tZ+1VyZgfaK7bdhlZuqXPcCCiICEp9dZWp4LiqsNbMNBHdQNsZupPEpwEcjCbrWfB42XhkPtI4dqVryojmzqAgvi3ty00i4p5FKlfUdKv6gE4V17ztZ5YDqPgkXXpI6/+gTDk4tH91YKpBskYp+e9ClpTvlbxs27S9NIzqm0vWfW8YNc4G5bhx7tirBHrKj11ic3kSSYAMVz22JzUWAUQVWabT/RMi0JVpVbkEjBqJTKhb48msjMcjOjNVdB5IIXquyGiEeVw+myUvk7m/fjUkAVgHzWGzpSY6YaUQHV/mY1goRsWARCL2bX1dqHJf7LC0/7grteqtDYSJkCiyilbIXlZoC1GFqiXlqgfAkdVM/oJUQOvJem1AhXncI+t0b+7Ya6NakYli5xzDtIWXKh2UEQmPHfJuwdWQU8eRC5l7ljpOPmfJtbkHuxTme/QVoPI X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5c45303c-3916-42c3-cf8c-08d9574a1b8e X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2021 13:16:45.2555 (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: kGi7/McikVo0vjJP0XNvQiSDWW32HSkJemVEkqB7mDw47HuMUSK3RVxPEzlvnzEkjm3ypp6xIKO4qPTc4tRS6w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3967 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Manage DSA links towards other switches, be they host ports or cascade ports, the same as the CPU port, i.e. allow forwarding and flooding unconditionally from all user ports. We send packets as always VLAN-tagged on a DSA port, and we rely on the cross-chip notifiers from tag_8021q to install the RX VLAN of a switch port only on the proper remote ports of another switch (the ports that are in the same bridging domain). So if there is no cross-chip bridging in the system, the flooded packets will be sent on the DSA ports too, but they will be dropped by the remote switches due to either (a) a lack of the RX VLAN in the VLAN table of the ingress DSA port, or (b) a lack of valid destinations for those packets, due to a lack of the RX VLAN on the user ports of the switch Note that switches which only transport packets in a cross-chip bridge, but have no user ports of their own as part of that bridge, such as switch 1 in this case: DSA link DSA link sw0p0 sw0p1 sw0p2 -------- sw1p0 sw1p2 sw1p3 -------- sw2p0 sw2p2 sw2p3 ip link set sw0p0 master br0 ip link set sw2p3 master br0 will still work, because the tag_8021q cross-chip notifiers keep the RX VLANs installed on all DSA ports. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/sja1105/sja1105_main.c | 84 ++++++++++++++++++-------- 1 file changed, 60 insertions(+), 24 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 74cd5bf7abc6..66a54defde18 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -475,7 +475,8 @@ static int sja1105_init_l2_forwarding(struct sja1105_private *priv) struct sja1105_l2_forwarding_entry *l2fwd; struct dsa_switch *ds = priv->ds; struct sja1105_table *table; - int i, j; + int port, tc; + int from, to; table = &priv->static_config.tables[BLK_IDX_L2_FORWARDING]; @@ -493,47 +494,82 @@ static int sja1105_init_l2_forwarding(struct sja1105_private *priv) l2fwd = table->entries; - /* First 5 entries define the forwarding rules */ - for (i = 0; i < ds->num_ports; i++) { - unsigned int upstream = dsa_upstream_port(priv->ds, i); + /* First 5 entries in the L2 Forwarding Table define the forwarding + * rules and the VLAN PCP to ingress queue mapping. + * Set up the ingress queue mapping first. + */ + for (port = 0; port < ds->num_ports; port++) { + if (dsa_is_unused_port(ds, port)) + continue; - if (dsa_is_unused_port(ds, i)) + for (tc = 0; tc < SJA1105_NUM_TC; tc++) + l2fwd[port].vlan_pmap[tc] = tc; + } + + /* Then manage the forwarding domain for user ports. These can forward + * only to the always-on domain (CPU port and DSA links) + */ + for (from = 0; from < ds->num_ports; from++) { + if (!dsa_is_user_port(ds, from)) continue; - for (j = 0; j < SJA1105_NUM_TC; j++) - l2fwd[i].vlan_pmap[j] = j; + for (to = 0; to < ds->num_ports; to++) { + if (!dsa_is_cpu_port(ds, to) && + !dsa_is_dsa_port(ds, to)) + continue; - /* All ports start up with egress flooding enabled, - * including the CPU port. - */ - priv->ucast_egress_floods |= BIT(i); - priv->bcast_egress_floods |= BIT(i); + l2fwd[from].bc_domain |= BIT(to); + l2fwd[from].fl_domain |= BIT(to); + + sja1105_port_allow_traffic(l2fwd, from, to, true); + } + } - if (i == upstream) + /* Then manage the forwarding domain for DSA links and CPU ports (the + * always-on domain). These can send packets to any enabled port except + * themselves. + */ + for (from = 0; from < ds->num_ports; from++) { + if (!dsa_is_cpu_port(ds, from) && !dsa_is_dsa_port(ds, from)) continue; - sja1105_port_allow_traffic(l2fwd, i, upstream, true); - sja1105_port_allow_traffic(l2fwd, upstream, i, true); + for (to = 0; to < ds->num_ports; to++) { + if (dsa_is_unused_port(ds, to)) + continue; + + if (from == to) + continue; - l2fwd[i].bc_domain = BIT(upstream); - l2fwd[i].fl_domain = BIT(upstream); + l2fwd[from].bc_domain |= BIT(to); + l2fwd[from].fl_domain |= BIT(to); - l2fwd[upstream].bc_domain |= BIT(i); - l2fwd[upstream].fl_domain |= BIT(i); + sja1105_port_allow_traffic(l2fwd, from, to, true); + } + } + + /* Finally, manage the egress flooding domain. All ports start up with + * flooding enabled, including the CPU port and DSA links. + */ + for (port = 0; port < ds->num_ports; port++) { + if (dsa_is_unused_port(ds, port)) + continue; + + priv->ucast_egress_floods |= BIT(port); + priv->bcast_egress_floods |= BIT(port); } /* Next 8 entries define VLAN PCP mapping from ingress to egress. * Create a one-to-one mapping. */ - for (i = 0; i < SJA1105_NUM_TC; i++) { - for (j = 0; j < ds->num_ports; j++) { - if (dsa_is_unused_port(ds, j)) + for (tc = 0; tc < SJA1105_NUM_TC; tc++) { + for (port = 0; port < ds->num_ports; port++) { + if (dsa_is_unused_port(ds, port)) continue; - l2fwd[ds->num_ports + i].vlan_pmap[j] = i; + l2fwd[ds->num_ports + tc].vlan_pmap[port] = tc; } - l2fwd[ds->num_ports + i].type_egrpcp2outputq = true; + l2fwd[ds->num_ports + tc].type_egrpcp2outputq = true; } return 0; From patchwork Wed Aug 4 13:16:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 492760 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF1C6C4338F for ; Wed, 4 Aug 2021 13:17:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CE6F560D07 for ; Wed, 4 Aug 2021 13:17:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238352AbhHDNR0 (ORCPT ); Wed, 4 Aug 2021 09:17:26 -0400 Received: from mail-db8eur05on2086.outbound.protection.outlook.com ([40.107.20.86]:63904 "EHLO EUR05-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238343AbhHDNRO (ORCPT ); Wed, 4 Aug 2021 09:17:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VBVCN0PQTgLnmcLmpCWr5R5069Pa9eB6XSgfHvRPr6DDHnjw4mNYRcbrS26sJ8kZE996DiFx61yh0eG4IPzkDwV6AKEd0fQeVR/Gqqc3nQclmXIjPGE+UNzUeP8QRCW5jG/M5RI/FXEM4Zu7vMsxl3/cuwDsF0YZjg9rPkVxMVws8/EKWHVfrzlcMiHVkM3Es8LDqoDmUBlIwsbBHIOkPmpjpGPCu5N/M2OAWCMpd1WUCY93Lj/hdPLyJn38wYSTjjCdRD260t7sVtLoPgoNBvTg1SsjkqqkPJ4ym/VjV3PaHpW7TzasL4pNiykLqhuvfLlHjReRJwJLE6mfBJ7e2Q== 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-SenderADCheck; bh=HwI0jm+ZWgmCnORWmGh1d1TegTIKQ6d1GNKUNNMaqnI=; b=d7Br2vaLR46kl/YFsGF1wUnvgKZarjzv25bahjUtNR602kIPmTGSo9Ld0+jKKEUwMccbtoxJF004HOq6TfeSLbeOK3gKTOC7zmGvRXkT0H28euW37+XfgukfiXSB2K9gTnWIRxB8g2H55806iOSMcArj9gCvD2zdLcgzfh/zu5QmxsHyTOMEaauSCBNzUZPh1GbqYJylw96C0eWJrR0HDCcuaXE7evXV2hk0yYhzttaS3Q503Ez2dOOCTbSdqc/1e2UT/PBbnxS0FsZ7iOEGF+tIlINiGC0rJWhfkK+cOMexH+OMTw0gnHT/8NsxcHZeQrRNqpdYcmCJVVYwXffIPA== 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=HwI0jm+ZWgmCnORWmGh1d1TegTIKQ6d1GNKUNNMaqnI=; b=rWisHJZUqRRz/cy5MjRFyKVT9dLUhXppiXXxLi3VLBwrhVnbuFqWoLk8Iw6f/TSD3xy+uIeM2Rkh7f+6wcLYB9uT0cphjtde8kBb0pqlRNW40syAwjUotM0pjuYAzRSKpA8qraAeU2ejDEIL8RLMrFVFokO8IF4xJcUYVS/m01I= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR04MB3967.eurprd04.prod.outlook.com (2603:10a6:803:4c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.25; Wed, 4 Aug 2021 13:16:46 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4373.027; Wed, 4 Aug 2021 13:16:46 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean Subject: [PATCH v2 net-next 5/8] net: dsa: sja1105: manage VLANs on cascade ports Date: Wed, 4 Aug 2021 16:16:19 +0300 Message-Id: <20210804131622.1695024-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210804131622.1695024-1-vladimir.oltean@nxp.com> References: <20210804131622.1695024-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR03CA0083.eurprd03.prod.outlook.com (2603:10a6:208:69::24) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by AM0PR03CA0083.eurprd03.prod.outlook.com (2603:10a6:208:69::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Wed, 4 Aug 2021 13:16:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9d0dc72c-dbbe-4977-803f-08d9574a1c1a X-MS-TrafficTypeDiagnostic: VI1PR04MB3967: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:949; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AAVdPsiA+oSGSLGgvYeE3BZEQ87ppKaqXx5LK3UEQIhkghAOKrXhMjfJln0WCfi7qEi9nW/IRFHpBccGQYgCev35pkVEjDgq2rhgg6fUUywqsBeXXX7MxVgom/df6CVtxO2MLBDqbLvsOHNphIaBN6WPKHiUbo4+qI9W8KZRaDvPipuhZNQgZD3SUN4uqIp8QfkK/me3kQA14LOslUQGNUIbLwlfBtWsGCUQflOWRwe+yRPNTOMuZCBIgaK7NKu3xPJf9lpEzGcUDrZfib3na4cyQcmUtVVDUE/Q6MGWm8ASTRv36GqMq25k1gpaamwdz4/onga3U9M3uWNWTr5cHRHOuYD/AWQizdCtCnsYA1nWLnJokVzGOiA997QeNkXnD/C4meO8tU0oPUuoXjQiD6CeyO9qxDbm/agXrb/zMRe/a85ga6oWwT4MgBusLxgXH2X/udQSuAXa6xTR7PzX7jZth9LszngSFk5iN6gE39jK+IX+dTYewI7V9GcAI+P8nqqHdFj5GL3Obywb9I+KGDSKb3SRfokIVyEZO6qwjDNW4KUJzo4IwT/5bjrXjvyz5no26ShOYPEvYLhtatp0TYlIJHQ4C+AsYk2t/3t4dt/ZYb+b2a4mYcn/JcUgLedMmTKaz1EnedhiKkBXpTwEyGkhnL3IxmX6S8AtRCSs1It29afgbtSpiT/WvRHhc9MATTbqsWs95rHvtk9tLuTUbA== 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:(4636009)(396003)(366004)(376002)(136003)(39860400002)(346002)(478600001)(36756003)(1076003)(66476007)(2906002)(6512007)(66946007)(83380400001)(66556008)(54906003)(8936002)(86362001)(5660300002)(8676002)(6666004)(316002)(26005)(6486002)(110136005)(6506007)(38350700002)(52116002)(956004)(2616005)(4326008)(38100700002)(44832011)(186003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Nx85FMm8BJNVcUixCOSlrhSZUn/h43h8GxH7sWShgIyK/mwzH8jFIYGEaGBOhrbR6f4XEKpNmua4Or0B9iSWP5Oy7NRpENdnq3ySW4t0XqjuBn78/2XMG1Comi1SDosShRH2rfc7dZsAMAs9jDdsestJQrIdPH2v3tlkJ0p/g1ivgI9rxqtAt1bvaua4LHYRrsjTkMMkvEm1m9V38MKvsnH8dqBsdw7ykjuQe8vWhqoBX+mlSTRbxpVC1L0H/F6TkN8LUTbcevMgGl4hGGT8QSXhICzYiHGSDwkjvzozhQaPKi2UtUSDQKyOq5B45EqZ13jeETdBR1c/ZdVwea6XK0PD0i4Wwm1jdFrSMcvwkvpacxqxp92tmf5/1D57OMIII2XjHoUq36j48H6m8n3Zhzv8cogAx2CZ3r2QautbmVwFoV3RS63CCpwgUovnmriKkBKJRUwITq2pilKOPtu9/s4cxpZ2GS3oae1gnO2b+qfhUTXnE5M3wsrSiZdF0vefzY4bzhQhGMrWFgWkfjbZg2g5J49ywBMjp+VZF6De0aOMTmKSjPm74f58P370Laeq3zjIb90uy8Cp1LqNK1i/cJPGtsu0czDDYGVAbDk52n3m36FfpwZrpwAjbltpGuKsCmp0X/EpVoEx7EiZyh7DGhiT6K2z3SGoFBx4lVr3EWYVziujWVmBBBC3OXMpbKABpPitxDmAOdH55aghkurDppZVgnsCDScPHj0xoP0SIoIg/JDDsotT4O5H0LsHU+ptOyM6e6kHbbvzTSgJ/9XsH5C0N8kR5qAUZF8NKcoPi7KO3u6i4Zo6DsiOLid0VouoiEW2TVO28nGCgi9teFUPNbBUojqj8GYa532pjvFX/GSP71F2CHeqrYcsoe8FYH/rSaHN6wPz3yGO0RMiBkEsw9hDDoe+V5JwU9qzb2de1T+T6N1yNomRtY2IppwYO5PRDkdzEJ080l7AkfdDXCXpe9A+T+NjdgqyrIXFP74NOGvGEv5Rppn6cC2Rs6gmM6/SmB0zd0gUzOYgzpfHYsvQOp6HqyvUkJr9EU4RnRmlb/2XD80KGMfSspEJO6jGiyTaW5Wv72ugM1jkIcrobbkG3WRPwqL+9BlSnGs085JsrR8YjOiDkvEwAMAZYF4A6Np3uDLZ1dOJd33ShTfCvDUxaEt1Veaq3+4F/zwhS4gk3CYyh0zAP2Pmv/BdBd+QyObEHcZ2X1/XKgsiSKMi9lfMcRvfhOPT1zcl1LBiOtwVzQrigztUsT+8oHdvvl++YFdBlp9opbk4nfzRgt+4mDZLxU83lTdMMdb7mFzIU4n9rpoa4HOXZ4mg46dAGlaDEVYd X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9d0dc72c-dbbe-4977-803f-08d9574a1c1a X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2021 13:16:46.4448 (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: CCC3VBl4fdfSxwJHJ6T397wVzppWGtiRIWgCM6dliN7BSO3bcvmbbACYJJHSGBPDOms5Vo0xbulWNoVlyE77YQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3967 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Since commit ed040abca4c1 ("net: dsa: sja1105: use 4095 as the private VLAN for untagged traffic"), this driver uses a reserved value as pvid for the host port (DSA CPU port). Control packets which are sent as untagged get classified to this VLAN, and all ports are members of it (this is to be expected for control packets). Manage all cascade ports in the same way and allow control packets to egress everywhere. Also, all VLANs need to be sent as egress-tagged on all cascade ports. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/sja1105/sja1105_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 66a54defde18..d1d4d956cae8 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -460,7 +460,7 @@ static int sja1105_init_static_vlan(struct sja1105_private *priv) pvid.vlan_bc |= BIT(port); pvid.tag_port &= ~BIT(port); - if (dsa_is_cpu_port(ds, port)) { + if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) { priv->tag_8021q_pvid[port] = SJA1105_DEFAULT_VLAN; priv->bridge_pvid[port] = SJA1105_DEFAULT_VLAN; } @@ -2310,8 +2310,8 @@ static int sja1105_bridge_vlan_add(struct dsa_switch *ds, int port, return -EBUSY; } - /* Always install bridge VLANs as egress-tagged on the CPU port. */ - if (dsa_is_cpu_port(ds, port)) + /* Always install bridge VLANs as egress-tagged on CPU and DSA ports */ + if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) flags = 0; rc = sja1105_vlan_add(priv, port, vlan->vid, flags); From patchwork Wed Aug 4 13:16:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 492112 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 780C7C4338F for ; Wed, 4 Aug 2021 13:17:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D45660D07 for ; Wed, 4 Aug 2021 13:17:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238021AbhHDNRo (ORCPT ); Wed, 4 Aug 2021 09:17:44 -0400 Received: from mail-db8eur05on2086.outbound.protection.outlook.com ([40.107.20.86]:63904 "EHLO EUR05-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238339AbhHDNR0 (ORCPT ); Wed, 4 Aug 2021 09:17:26 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kl8LVN1BohSM5jRJgLCoH5amO2ZZ9R9JfMhxe2EZYzGxbMtLIxEKFr8JBoAaqq6KwebJvKTjA4wtbb/QV5lMCaVK2wbWe3rxNQWT5GgIrABliYsRDo8F7jkqTwBx1iyRNYvJKTRA7A5ZpAAfTuJ8Ebeo1BmsaBDMzgIuCvSxaRCedIsCuzo3FiHQ+jMdideoy0U07bMFUdzfdaXHedgmonMYxqXa9SbNKMkJtrCW/IHlLp2wNslKIiCdwt426XatnC+GpDDksoF4HwPnmh49EUMy89Eajxuda+J26b4rKX7rDktR7ZyY0kKiQ5iCW1JdlKknT+0X5wfJzlXtpEBKow== 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-SenderADCheck; bh=Xv8psI/5kz8emCRqcS+SdgKVUIb5qDFIY0g5PQAGfMo=; b=U84aBqN1pd7vkympd/H5jYmTs6xz0anbsZyBk0HmMcSJVUWrJSu0q5XGR8+sp8CoX2UphaXq8FvNeShsdU0GfaGmI6VVVkymLc0fQGcdIgS4inHN+FGR7xmzVf5aD6AakEp9kGAQh6dgNQJvxqOHRvdr+RwpVigGLxz/M5oHRwy4l36HEndGGOGY1kONVQqLjZHZtblb4yqUBpUwA2+H2NdrSvKVx3AfqdqD9jkswQJlqEDbeWaxqVIpBC12HLPTzTfOdUw/PTGicazNsEG95AdKWGtHKHVZmdX38bRvw7pXy+Ot6YrJ3lzE6dfHXOxqYpxYjvnBe6h4xYRaFbOfNQ== 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=Xv8psI/5kz8emCRqcS+SdgKVUIb5qDFIY0g5PQAGfMo=; b=mBBR3ULgrACowoFMsZSzRJZZuA0/unNo06sXcghEb4Bk3ufpg2IiAjqbA0LAV9QoYzLQF8/KXm7/rZv3Mjg/wlqvunP6M/KrE0WnDAqDLGti9hOQeWgzVoUuB36tXetjeHuulUU9v1cyFpHgyR2hBCiePHaxHvk/xRCEFnWk1xg= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR04MB3967.eurprd04.prod.outlook.com (2603:10a6:803:4c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.25; Wed, 4 Aug 2021 13:16:47 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4373.027; Wed, 4 Aug 2021 13:16:47 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean Subject: [PATCH v2 net-next 6/8] net: dsa: sja1105: increase MTU to account for VLAN header on DSA ports Date: Wed, 4 Aug 2021 16:16:20 +0300 Message-Id: <20210804131622.1695024-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210804131622.1695024-1-vladimir.oltean@nxp.com> References: <20210804131622.1695024-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR03CA0083.eurprd03.prod.outlook.com (2603:10a6:208:69::24) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by AM0PR03CA0083.eurprd03.prod.outlook.com (2603:10a6:208:69::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Wed, 4 Aug 2021 13:16:46 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6e457acb-b1f6-4499-d23d-08d9574a1cd8 X-MS-TrafficTypeDiagnostic: VI1PR04MB3967: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Pr3wSC6gdX76m1ojd/NQIVk5GuPSoAgbzUbSNAyvjFp+/sSHYcXvYqGFvxdF6yflKyIW2wdobInyZk+Ygydyi6gycEOcNYbNDTK+oMhGENR5t7vwu2ij/+QDK/asHL1v77iK8k0IH3Fo+D4G1PmoLydMgfQGK1w9IANoSoztXkrV7/3iGeakZUoTUPU5YYj8myUW7OsfWnfHIbh3SADk4qw80g+cq7YEYvUtuZ19DjkmELr+tzID8PNT+vhBmslJ1KuJb5iDlCF0S33ST6SOmpDb+y4/y8hYm7p388DOnDk7fp9N8spnZlIGlGq6p0MOtyRQzPcyhbzKB61dpFVM3WNS5g/ZkqjSaJfpcb9eJ9rcgB2t2J34r2DaIeOt5dILuJm5fKQNxnzi/z2J1cZQ9y05tNqhjRutu58yh68e7QiDeUYq1R6Saq3JWVz5GvmSI+PImZiYRdAaWzqJVb2iy3PasNklaNFab+5fMi62yK2uRWtZYBPDQAZcEv8ZAw98opXmxm2emZYX8Nge9txpp+/6qwh8E923HM+dajb6vpbBiSx4DrlXsQQUP7gsq1zseXtl4NDmQplvQtf2OU/d58JdbQp00kEBRu+hZcwtHVMa81JDKc7SSZThDEgUvX9aG1wg57rl9RYcqSDtpKQeZSpeI11rUckdqSXh5VZLcS6A8p0yDfL5grtyFm3IVgkFNsXOhp7+QTygC5tzZArAMg== 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:(4636009)(396003)(366004)(376002)(136003)(39860400002)(346002)(478600001)(36756003)(1076003)(66476007)(2906002)(6512007)(66946007)(83380400001)(66556008)(54906003)(8936002)(15650500001)(86362001)(5660300002)(8676002)(6666004)(316002)(26005)(6486002)(110136005)(6506007)(38350700002)(52116002)(956004)(2616005)(4326008)(38100700002)(44832011)(186003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JzSHmmItf8B019K8/6riASiRiJuOBzT0Cqs4L7Lc5+9nEsZVQosxnayju0Aawz2TRWUuhV3GE1a8tW1L3q32hd/DIcz3miG+RG+P1nNkNu7MMmilOWlDbTN52IBfUuYtpmPNTD72SlTECsbWxPuc2ke/6K5rDGnxNPb3JuVwsxoja+Yp6Xsxco0g+J6pO0pfmFYiwydmyjpcbpW4rG4stpGP8unlvOP62wc5zEIsNMpYGvhmR7/vxOlcLfkdEcJgWAPBUL3NDhG8ed7qSfI3mbFSTgOGUx31dtQt5t/ywCcS+ShsZTKS84wPVjHysRfkOK5jrXbzQK77uASLYgr0x3jSGpeXUhgRLS66u5rufrj9qaiMfzHbUTMF/qt1i3C5z0QCRli/HxYEYtBVvyOAIkZkyrIWcSDBULIdDi0Fa6Kg2TkEHSEExSki89WoJ8kWMB8WWM3egfKHz3vWn+Abs18vjrjEAc7pzp3KAFv6Bhc/fwJOUpRqcbvMl3YvFwWI2Pg7SIUhG3jxzYXwgJ0XUqwxbegnoYaKx1pTsQUG2w5aTmMnRBfCh8KerTOWZDsKNFJySgEI9+bjNQ8fbSHdDEGUpJ+Rg45XK1GQBisdjKAJehNjuUOmkgLdA9+PNR/5didymNxIRsb/pCmaGySodgojG0qVYybe4VpL4FfhK8dkpcRrtb7CdgXRj9d0DVCvX1ZofE6Oyvw4uX+kA1ItHMfL1GLuwcE4BKK9AhwPPU/4IXxLTAO3MBWSnYlDpTZ1YyJKxZRy3+GMH+9+XqFDNNXmvdkmdu+dX5OZf03P6tH06i/i+bhiK9CsoKUWKTZ2kFXMFtSh65FyP5lrgc1O1I60P4OZeVlrpH1OeBIjWeMDdctUYxKuCG/3PC/Al/h7iC5F3zjCrzr0RuOUHyt/1N6F3qJrWXiQc1ltiKg3XrJ0X+N3+aTjKl96EVpT8RZDsA0b3jOPoqHTHajlt2/0M+XkM40eqXur1JYeXZx8uXwhQ1ewl1mab4lgIf17MfBKp2Zradxjfb8fRfFX9t+Q2GByjPqToYjPcwLhpeSnC0PDqrNZVIqvWR2+ZeNL/RB2EWpzKtQsgU23Ey5V/yybPeXifSyYweiF/TAb+TfalK3K6705w1ct2ZRon0sO9eXMTFjWENNA/rAPrmAdNwHkvaWfR6oRjrnJ/hHO5dKlURetza4p/pYoYYASs8bw3LBQHF273sW/jecvz3tkMC2jgjgfrRio7gE6zFZ+TlZglA2BLnN+NWYM3c2H7KggEavPT7k8PchiuNUdZxZXizLDGLg/FUVGDFOgiG68Hq/aAq654pCkHUFTPMqfHVcwNK2h X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e457acb-b1f6-4499-d23d-08d9574a1cd8 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2021 13:16:47.4642 (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: pqFw0MuxdICnNuXBjTdICDF1C0649fbXRmOcNvNnk0H7si8WlfIzObF4MtvbKay9QfcV+lHQe7iPnVu0nJU9+g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3967 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Since all packets are transmitted as VLAN-tagged over a DSA link (this VLAN tag represents the tag_8021q header), we need to increase the MTU of these interfaces to account for the possibility that we are already transporting a user-visible VLAN header. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/sja1105/sja1105_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index d1d4d956cae8..fffcaef6b148 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -982,7 +982,7 @@ static int sja1105_init_l2_policing(struct sja1105_private *priv) for (port = 0; port < ds->num_ports; port++) { int mtu = VLAN_ETH_FRAME_LEN + ETH_FCS_LEN; - if (dsa_is_cpu_port(priv->ds, port)) + if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) mtu += VLAN_HLEN; policing[port].smax = 65535; /* Burst size in bytes */ @@ -2664,7 +2664,7 @@ static int sja1105_change_mtu(struct dsa_switch *ds, int port, int new_mtu) new_mtu += VLAN_ETH_HLEN + ETH_FCS_LEN; - if (dsa_is_cpu_port(ds, port)) + if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) new_mtu += VLAN_HLEN; policing = priv->static_config.tables[BLK_IDX_L2_POLICING].entries; From patchwork Wed Aug 4 13:16:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 492759 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D3A3C4338F for ; Wed, 4 Aug 2021 13:17:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8551C60D07 for ; Wed, 4 Aug 2021 13:17:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238418AbhHDNRt (ORCPT ); Wed, 4 Aug 2021 09:17:49 -0400 Received: from mail-db8eur05on2086.outbound.protection.outlook.com ([40.107.20.86]:63904 "EHLO EUR05-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238395AbhHDNRd (ORCPT ); Wed, 4 Aug 2021 09:17:33 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GZ631Hx+ocN/MJL376Ym3LXaN9XUq4FV/aOyqVIB8JhGq2NcZopDCuDmVFogtfnu/H5DXyMsQUmQP/PPzN5JMfu5x9qmRSBumXKpqQ29Wrhn32f0Ul5LlhHvj0g6Sz0JUJTjzags9EGO2PttLX5diVrjPPjSyeEDVGSnkAFj8buW2efU4fvPpheksw1FFcddHqHmVW0sp1VAx1tIG5VF63c68u2+SI6/UghOrJ0EUY6w89ED94l+YqmVos9p4tYbWOgS5D/BENDcbdZMARf/K8zbP9S9t6QeXYiK+g1V+1wTj01EMqvoskd5p4LCKm7zlvZuVbekcqDd/vMRjYckzw== 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-SenderADCheck; bh=4TuMvmJH7L+Vlds5rFAsFSG1+pHMWI8Fb91zoNxYNiQ=; b=kmk/XZpQaglGOkG7G/3ZeFP2trAvE+SdcNX1RP/ySg/0wpyt4/ZKYZA7X2qHHYe5czueVjTlIKCttny7zhHIkdONQe0raayOvV17+gf9gPlNlhKdUY/aV/Ed+g445qYxrI8JyYwVCVfqhKSBmHtJa7Fda9yKUxRriMeCbAiq5VtDfolRlrUnFJuKIfTRRVbBev/OmVlzCx/BgZlRj9h4FvxzkNpyCXVJyIgP+tw8CGf01g75PwXInHBUOJismZz616IDcl4i0g3pNp5yIWKgdzm1OW3UcXy+oEo9kpneUnMtnpWVmxpQp3SNa9ou3zG7q63cI7AifAs/nzJgXweNDQ== 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=4TuMvmJH7L+Vlds5rFAsFSG1+pHMWI8Fb91zoNxYNiQ=; b=BAqS764intfuNEkFW7u9aJMo3TU5BhdJN3eKvqidXxEOrPshh9ou3YoioEDPz/uC5Y2L78jKAPsU1Iw72G0aFKg8j2zOEPTEnXwn9RGOurDYF/VPwGxtIApN4gdyqnVYiNBK0Z0C58MtY8SK1QnNdJCgklc0RzVtPzadOLQ/Il8= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR04MB3967.eurprd04.prod.outlook.com (2603:10a6:803:4c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.25; Wed, 4 Aug 2021 13:16:48 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4373.027; Wed, 4 Aug 2021 13:16:48 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean Subject: [PATCH v2 net-next 7/8] net: dsa: sja1105: suppress TX packets from looping back in "H" topologies Date: Wed, 4 Aug 2021 16:16:21 +0300 Message-Id: <20210804131622.1695024-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210804131622.1695024-1-vladimir.oltean@nxp.com> References: <20210804131622.1695024-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR03CA0083.eurprd03.prod.outlook.com (2603:10a6:208:69::24) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by AM0PR03CA0083.eurprd03.prod.outlook.com (2603:10a6:208:69::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Wed, 4 Aug 2021 13:16:47 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: baad7471-94f1-4d7d-52f1-08d9574a1d68 X-MS-TrafficTypeDiagnostic: VI1PR04MB3967: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6LBIrtcVkrOX97CMzTB+Tb70cJWSk3PqR7Sia0N87/l8M18vEkKuMLgO+JlaL92beMPglafB9QwxWEvuL0tjHxZYV/lVJARpZX5L+IbhhKtyjcsT9WbPVgS9o6LdC6UZMXp6ehvNfrCoS7hMQUJzyB8KvC0qPxuZtCL1Z+DyK/bZ7NVZTxdRSLxNhrmw2ukBadww59GlY8FkWMTYb/wBNGueQ8XRcyLRX8+zD6nlRvhQqnKn2wrJlFKqzPvg6biC8sgILoXDgOv8IdUTkVlNRDS7TMmkcBuVE7JhZsUWtI/dyqRY9fMdIpWwZt99d8yEeZ6r6coDugB7UFQnXcwFRkNNNX+o9G9cSeenK+GDa/QDkcdfcPmIce1kz0ByxdTKFIHuI5IrVDjx5tM5iI9IT08dloUaIO14cCinCGvJzchLHLIz2UwepifuYBOW1GnjCUs7n+zJhTF++CzFpATeJnQtUpZOAkz9ds4tuIq2gs1Yh8/vphUGBQv5bbcn45N/qLMI+mjhlj5U4zadNHzSwrhtpA48dzXmg9t0wRcSGkxYYl81utPD30l4T13UwkaYSugILJDd3tHoImtlXsYNSsYsNBHo8SwTpNczMx/j5gKnGwsUsG+KBZZxY0bogwfc4eMNUXvI/yv//xKJnxL/n2vaKjLWvQ73dtB0Nh7V+YPOOx2a8lSR4mO+m06+o21RfV3GStFmWdfa3EY67RZpZA== 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:(4636009)(396003)(366004)(376002)(136003)(39860400002)(346002)(478600001)(36756003)(1076003)(66476007)(2906002)(6512007)(66946007)(83380400001)(66556008)(54906003)(8936002)(86362001)(5660300002)(8676002)(6666004)(316002)(26005)(6486002)(110136005)(6506007)(38350700002)(52116002)(956004)(2616005)(4326008)(38100700002)(44832011)(186003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FGG1JQTZNuf7Uteb23V+kW0mLsxk0ETgp7afwwLVmkkuEv/K4AwKPME1UiG87jJoa+0312YCrvDk+u+hyuwTqCKAYzB3HnuC7ci/Z55zUk/tWdwsF5X9psGbbN9r/3SoEf/pPwH9GjYj2d4JnXUSXjQwuY3MJRGX6ZRSFLlHAqRcpnz+6RRM+PzWU4Rm4hazz/1CN9abKmiM+dK4PStd3dAL24owCw54tVnqS54axcf9YtF2fQwnHFZtV//xjUbagS2eIFAbR9fjX2yR2LOml/DMnlN9G7KBWpUfvtU/4DiEYoP3lQ7pObt89eDmKHnVuaZgJrsoLNU5Io/F0w5HKBXDQODi6ru/nQLs5rzGQdh2WNNkPnTAHApPhDzDFql0WDgkKwo97PltYEndR99ikmpS1ey5Ad3ZllCcEB9803PIUH3upGw7JZ9qG1qWkQEoaHewLbxhodxGn/oqMcp0DcsJgXJteOFWwUCTf7HgYF+vQR6UwLSkzERawppljezfqPycMEJ63qcupzKifc3bOqpSi8OKgyL3gGZi8ljf2DyWeVeezl+K9ojr8Kid5YS5zxF5DC6MijdlS2qnfkA75BYUefmclxYmxGQAQ7W7E9hZ52cc6yA2j8DF9HS5KbiSeufZvgGib5RNTK54DrVdqbn7CKSrWHjNGxM4i0/Hwi6styOLsSitDdw0u3NYlr5AycoaujXI9An7eOnR+STm1ttENknV3uVbKJFuzVFCxZ5FHT+p4YLm4O1scYBmM76sGmvwOLyqCDuoinxbAXpnIgzdaVA+V6AKPHFXymfh61sxHEMy7YabTMasvABqvPKmGeBBM3cYk3MPYEOcJ5oQyilxC+EHuqWrMzfaon0wLbWx3QSdnfFlUcQ1oQnZrYWRl2Yt8k8ztvK+T6Gndyfk+t6J4IZYn80Wlh8jbzd65dj5BWhTBAkZGlsW+UPqQFkcSp5uqjYel1rdP+NKyo2U/R+jXgoeai5Ge9sAUvMLF8ubjo8UPsXJD3yl1wXpiLgZNPOVCTDeyGjJvz/aEo23A+kAwVsAOwyEI5beWljkIUyEYYu0KWcQF6rlDCPdJ8CtLJR/9GW8zvQQ4lybWW9e/uaRINmINijEVDa0LvgjWXopCM5dzFEBh3ejBftUAoMN1sDsc4tHQjk6l8ONEc83mHsTdRQv/U4xNCSkC/Akd8ptlFBezcHbxhSTJIAx6eHkOKWXlR99mpAKx+OsNu2f1t03y4HkeGue3tbAbFFeoAQhX+7w1CQB6ueherkOMo+dko0KcS17JAdpA8hOdMm9xWlUaHiufA5D8buxq3F82oxs2HalwyB6PUd3qUsmHcpl X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: baad7471-94f1-4d7d-52f1-08d9574a1d68 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2021 13:16:48.3877 (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: HgG5REWdjGTRJbav1qqGR30R/ANeatY06FLuiZe+uSBpNIopM08wfGlwfCwADKw2nJPv2MCxxuSKCWGB79hZSA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3967 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org H topologies like this one have a problem: eth0 eth1 | | CPU port CPU port | DSA link | sw0p0 sw0p1 sw0p2 sw0p3 sw0p4 -------- sw1p4 sw1p3 sw1p2 sw1p1 sw1p0 | | | | | | user user user user user user port port port port port port Basically any packet sent by the eth0 DSA master can be flooded on the interconnecting DSA link sw0p4 <-> sw1p4 and it will be received by the eth1 DSA master too. Basically we are talking to ourselves. In VLAN-unaware mode, these packets are encoded using a tag_8021q TX VLAN, which dsa_8021q_rcv() rightfully cannot decode and complains. Whereas in VLAN-aware mode, the packets are encoded with a bridge VLAN which _can_ be decoded by the tagger running on eth1, so it will attempt to reinject that packet into the network stack (the bridge, if there is any port under eth1 that is under a bridge). In the case where the ports under eth1 are under the same cross-chip bridge as the ports under eth0, the TX packets will even be learned as RX packets. The only thing that will prevent loops with the software bridging path, and therefore disaster, is that the source port and the destination port are in the same hardware domain, and the bridge will receive packets from the driver with skb->offload_fwd_mark = true and will not forward between the two. The proper solution to this problem is to detect H topologies and enforce that all packets are received through the local switch and we do not attempt to receive packets on our CPU port from switches that have their own. This is a viable solution which works thanks to the fact that MAC addresses which should be filtered towards the host are installed by DSA as static MAC addresses towards the CPU port of each switch. TX from a CPU port towards the DSA port continues to be allowed, this is because sja1105 supports bridge TX forwarding offload, and the skb->dev used initially for xmit does not have any direct correlation with where the station that will respond to that packet is connected. It may very well happen that when we send a ping through a br0 interface that spans all switch ports, the xmit packet will exit the system through a DSA switch interface under eth1 (say sw1p2), but the destination station is connected to a switch port under eth0, like sw0p0. So the switch under eth1 needs to communicate on TX with the switch under eth0. The response, however, will not follow the same path, but instead, this patch enforces that the response is sent by the first switch directly to its DSA master which is eth0. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/sja1105/sja1105_main.c | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index fffcaef6b148..b3b5ae3ef408 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -474,7 +474,9 @@ static int sja1105_init_l2_forwarding(struct sja1105_private *priv) { struct sja1105_l2_forwarding_entry *l2fwd; struct dsa_switch *ds = priv->ds; + struct dsa_switch_tree *dst; struct sja1105_table *table; + struct dsa_link *dl; int port, tc; int from, to; @@ -547,6 +549,33 @@ static int sja1105_init_l2_forwarding(struct sja1105_private *priv) } } + /* In odd topologies ("H" connections where there is a DSA link to + * another switch which also has its own CPU port), TX packets can loop + * back into the system (they are flooded from CPU port 1 to the DSA + * link, and from there to CPU port 2). Prevent this from happening by + * cutting RX from DSA links towards our CPU port, if the remote switch + * has its own CPU port and therefore doesn't need ours for network + * stack termination. + */ + dst = ds->dst; + + list_for_each_entry(dl, &dst->rtable, list) { + if (dl->dp->ds != ds || dl->link_dp->cpu_dp == dl->dp->cpu_dp) + continue; + + from = dl->dp->index; + to = dsa_upstream_port(ds, from); + + dev_warn(ds->dev, + "H topology detected, cutting RX from DSA link %d to CPU port %d to prevent TX packet loops\n", + from, to); + + sja1105_port_allow_traffic(l2fwd, from, to, false); + + l2fwd[from].bc_domain &= ~BIT(to); + l2fwd[from].fl_domain &= ~BIT(to); + } + /* Finally, manage the egress flooding domain. All ports start up with * flooding enabled, including the CPU port and DSA links. */ From patchwork Wed Aug 4 13:16:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 492111 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BC38C4338F for ; Wed, 4 Aug 2021 13:17:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B30E60D07 for ; Wed, 4 Aug 2021 13:17:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238427AbhHDNRw (ORCPT ); Wed, 4 Aug 2021 09:17:52 -0400 Received: from mail-db8eur05on2086.outbound.protection.outlook.com ([40.107.20.86]:63904 "EHLO EUR05-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238369AbhHDNRn (ORCPT ); Wed, 4 Aug 2021 09:17:43 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T521XhAKySN7SQ+VWJx0a7CewTatDU+SjONF3hYb1Gne9WsB17+B5VL07nvtJw12ncaTrfzYIUPaut84FMbobqOPfcKueLMPsC7sLV0UiA9aq1IoDwyWGUidBVHleEb/6zlQ5F9f8s2w3MSAjHfmfHVkVYjdvIrXOUYNXH5q5I2jhZpIBy5ozz//zSMVMLI/rYYgUzmy87z0mI8hPfrcvVubQUA2VlqAzidT8O6E3R5zpbtKY8S55X0M8ztBOUVgTDaAKUHhv0EPHA/83xAtv8LJ7CaV63ZwNGbNIlPsclLI2H/fL2GxEPxXIpu2slayKLgjwzLY0HjdvxOXGeEleQ== 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-SenderADCheck; bh=tFP0ZDXnCmxYhygfqgxLl3BCxbUOVWsrQ3TY81MvUAI=; b=ehTYP8uCWr/fKNrJoEl7HebRlULlNrXqt0jLdJ4soWw9esjLCyCSXLwF2ae4NrxnGs6A+QVjUH2famyIIl0PU14tJ9f+Oi15cNDbV4pQDWT/7mXcps/46BwZSKDDndvHNcrd4zJFfSJVYqjrDDb3U3CnEuyrugGgQ1/w5DL7RSDKlnefUEtoxHCSc/QaaAqm/Bsl4QPZMz0ud2jkhgDMYbZGrvB3RBrPtUpB7dqkRe+yV34z2+GHpKz/+vG7faQf9o58FXGqiMDBfAhkmgLUoxiJXR9uad0/L9VboG+T81goDnqdCcWclGfJZLeHxDs0/gv/uUO651OrRNZpelw8OA== 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=tFP0ZDXnCmxYhygfqgxLl3BCxbUOVWsrQ3TY81MvUAI=; b=iuhdBCb+iC+XJnHN0Sv5SNlPvepp18r9hU1iOhaybPAP48sKMaedtfGsUGIBe5rlFZaO5lJL85JMbwVXg26wsbvV28vaa2IqSRzB7OiupG3Luw8OF8o78WwXal1vurxePhhq4rWAbJ9AjI+lJ2wmcItJsZFJt8yZ0s/1HyXCX3w= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR04MB3967.eurprd04.prod.outlook.com (2603:10a6:803:4c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.25; Wed, 4 Aug 2021 13:16:49 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4373.027; Wed, 4 Aug 2021 13:16:49 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean Subject: [PATCH v2 net-next 8/8] net: dsa: sja1105: enable address learning on cascade ports Date: Wed, 4 Aug 2021 16:16:22 +0300 Message-Id: <20210804131622.1695024-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210804131622.1695024-1-vladimir.oltean@nxp.com> References: <20210804131622.1695024-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR03CA0083.eurprd03.prod.outlook.com (2603:10a6:208:69::24) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by AM0PR03CA0083.eurprd03.prod.outlook.com (2603:10a6:208:69::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Wed, 4 Aug 2021 13:16:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a3879bca-572f-4718-96d7-08d9574a1df8 X-MS-TrafficTypeDiagnostic: VI1PR04MB3967: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vXDH+cTQHoGYa6vPZN0MY652/y3qfptoLpohmxJGJSu/hoO7U/+fD7kdq04bE7M1KpoY8rQA1jqE8EKoBywL4MMZAwXJ/85SylYWTuEuW8AudrDdCEj1igsEfdUHDUFW/PIU9Zg4goNePNuhPaiGD5HIysViJaPUbqZ9PNea0h0abOxnjciXlEx1mHWaEgPJnHnRWEcv1MH9QTe5mlD0IAHQzzmlSaEWJC9nVuSCh41cnwwhc4sXxpYGD9W/BAjhO9pXP72/MqnWPNMoB9CsUjo4Hxrk77YXLVK8ODpXlC0PY6h0gXymk+k66TiHJcy4X+M5pMqsC8Ortp7kywI1pUEjRo7pmqdwz5i56vb/buAOmvEOC9ZIIBk3lXTwomX0ui8s/rUrKGNege8mhbcARjcDudY2YFXBu0vKb/0n0Mr70pY1OMqusfWpQXonqXn64IDvNfT6zI6kISVVmGXz87j9LERCUQgofwSHXwD71+Z/6TOy09j1FGPG+luLPSLqrzIBE8AhdGx/lp1XD65Po1ue+645D18AldYpNJfDQ/TGeE5B3DNlrOjugQSBQTuEG8QRGrjN29EhxH6CC3jxbwLIgNnRIbdjPARn2kv7XVyZZhwm/V+0CQILyuZ1dVkew7Y2fpt0Zrf4TLlDgWqlBcCze49w0YHOASuCgrCmX7+/D1lnlb018JYV7dnaPOVGpnw3oEwrswClgqiEHAsGUA== 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:(4636009)(396003)(366004)(376002)(136003)(39860400002)(346002)(478600001)(36756003)(1076003)(66476007)(2906002)(6512007)(66946007)(83380400001)(66556008)(54906003)(8936002)(86362001)(5660300002)(8676002)(6666004)(316002)(26005)(6486002)(110136005)(6506007)(38350700002)(52116002)(956004)(2616005)(4326008)(38100700002)(44832011)(186003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Oxr7Q6wch5CldzUcxHdiaQsWNMIHCRFX1/5OKZ5/1cyWOTQWpBJeS9R0y8MB6w/3L8k/LGUpnPqZ0QX6dPaKPYPIEEe2CRfWr2AuHFoJldxaHLFApezjgyT4Hsd7nFNTS3zM3QRKYRyxOewNwMW1zHumWdCCKwRdFcyZ0ouwiyiJ6DbNlfpyOloKHRVr/HFSw7GnIreK24PkaiCGd9B1zX55qBnQg5qVCWfT2S1Cca5U9TlGh0nyuF9jHW8kkGvJhZAXIclbmZ3zkQG7148S3Z+YAUvCKRV7VPLdLxmCX2UXrgR9N1WiI70XwzEZ+SG9ySfm09oW98gx1rgGSE4SYwfi5VEbgz6LUpsqYw5j0sPk9BKGjDe9ywQIUUcZGIFoRxP2/fqzp93IBxCNcgm/YI6rRfz7CUZz3S08c/e0RPOyKBYuWxomlesL2Dc1W4V375/UZCghIIEtp8P6aVyz/gP/yZ4jgxl9ybnENAIb/dlAUorTLH0DLfuyk8wQ+0g/zmNN33GB0boO3yssLF+CkUG0KAFplkdrFJCan4nSDDrGvTe91TDfqXp9PTIg/W5y1HuLdLNid2DuzM83mJALm+AlUg/4dq4DsV3VWJu7ndm5xX7rxwlZyfswruRJXuM6RwaLj0S3H0E/hCM42xQXxlnWFP30W7I2eWdLOyKNcoik1I+TnBGHsiu3KIkEISX9g1HgtTfddS/Pf2pIZccrh9Ivz8MVPujkTGqj/BILkOrKfENNb+sR9EZnXtwWtcqftNx8G+ivb0odPaQN43qs+DtVQb2nP2JUr6Gws+v/c5c6MxaAl+G1fkuwbMFe6fAnxPmb0F3tzdozXuoOKOR4gMx7K3xxfPKa6/2vV4TDps2Lnj4D8Kr7sHK4smmharH7e+RhBDzSe30RpJixKtuH+R7pMPZv2BGENeOcEmAONg/lV5H7qW4LqDzYY3yVg66vlriSbKltNfIU2vXyd2gEbcood3WGvmKCe0vIX4MaOrI76GkVKb6ioeJkQMvnyiIDQSCBa0XWk0K396PszV3JrFhrBJ+JtgNAtrZxWHw8H6lG30Dhi9cYvMHiVS3FOB1Hjex1l0VyabFZNns50WzckuyVrMNoaXvuBLq2y1TAdtx2b1cQWf1n88qEInvRTxQcry77M8rg6xNBWOnsCuVxHKJnOKLzYoDGdNpfY4q4Cw9+XRq2zb2Mxnz2I5ijgnkzOYzMz6J9hYqAjkn2Q2jRXrW5JVutCGJZqDFPCPDWmlFUumfbx//zcXVTOcBQf3MDKIUOlRqtm9OMsi1h/G+BLJBGYjEeWwix+sBqH/XVEViRQLr96u+SFpsiTyMJzPoO X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a3879bca-572f-4718-96d7-08d9574a1df8 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2021 13:16:49.3242 (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: z+ueLq+eFtJ4RzZZ8V7jiiPU9Qbf2nIyen2OBHLlKF18RrPTMc4XgAp5DNNq69c3LLL9uqNn58YHJVz6AxL65Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3967 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Right now, address learning is disabled on DSA ports, which means that a packet received over a DSA port from a cross-chip switch will be flooded to unrelated ports. It is desirable to eliminate that, but for that we need a breakdown of the possibilities for the sja1105 driver. A DSA port can be: - a downstream-facing cascade port. This is simple because it will always receive packets from a downstream switch, and there should be no other route to reach that downstream switch in the first place, which means it should be safe to learn that MAC address towards that switch. - an upstream-facing cascade port. This receives packets either: * autonomously forwarded by an upstream switch (and therefore these packets belong to the data plane of a bridge, so address learning should be ok), or * injected from the CPU. This deserves further discussion, as normally, an upstream-facing cascade port is no different than the CPU port itself. But with "H" topologies (a DSA link towards a switch that has its own CPU port), these are more "laterally-facing" cascade ports than they are "upstream-facing". Here, there is a risk that the port might learn the host addresses on the wrong port (on the DSA port instead of on its own CPU port), but this is solved by DSA's RX filtering infrastructure, which installs the host addresses as static FDB entries on the CPU port of all switches in a "H" tree. So even if there will be an attempt from the switch to migrate the FDB entry from the CPU port to the laterally-facing cascade port, it will fail to do that, because the FDB entry that already exists is static and cannot migrate. So address learning should be safe for this configuration too. Ok, so what about other MAC addresses coming from the host, not necessarily the bridge local FDB entries? What about MAC addresses dynamically learned on foreign interfaces, isn't there a risk that cascade ports will learn these entries dynamically when they are supposed to be delivered towards the CPU port? Well, that is correct, and this is why we also need to enable the assisted learning feature, to snoop for these addresses and write them to hardware as static FDB entries towards the CPU, to make the switch's learning process on the cascade ports ineffective for them. With assisted learning enabled, the hardware learning on the CPU port must be disabled. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/sja1105/sja1105_main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index b3b5ae3ef408..f13a6766dd41 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -199,9 +199,13 @@ static int sja1105_init_mac_settings(struct sja1105_private *priv) mac[i] = default_mac; /* Let sja1105_bridge_stp_state_set() keep address learning - * enabled for the CPU port. + * enabled for the DSA ports. CPU ports use software-assisted + * learning to ensure that only FDB entries belonging to the + * bridge are learned, and that they are learned towards all + * CPU ports in a cross-chip topology if multiple CPU ports + * exist. */ - if (dsa_is_cpu_port(ds, i)) + if (dsa_is_dsa_port(ds, i)) priv->learn_ena |= BIT(i); } @@ -2509,6 +2513,7 @@ static int sja1105_setup(struct dsa_switch *ds) ds->num_tx_queues = SJA1105_NUM_TC; ds->mtu_enforcement_ingress = true; + ds->assisted_learning_on_cpu_port = true; rc = sja1105_devlink_setup(ds); if (rc < 0)