From patchwork Sat Jul 31 00:13:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 489687 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.8 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 85E57C4338F for ; Sat, 31 Jul 2021 00:14:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58A836101C for ; Sat, 31 Jul 2021 00:14:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234448AbhGaAOc (ORCPT ); Fri, 30 Jul 2021 20:14:32 -0400 Received: from mail-eopbgr00066.outbound.protection.outlook.com ([40.107.0.66]:14636 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231355AbhGaAO3 (ORCPT ); Fri, 30 Jul 2021 20:14:29 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BgK3v6dADlAzJtBdXGBTSXabU4vrl6Lf0s2U/2cWB7rg6ZeSVxODVwOAOZtmoK444GVFh/Jz0hX9yMUOPQOyQLCfOcf9ddkGfYZEFuFOqgNMutizGC+GrwESeNl7qe+7MPI7nRQ8cMQv+L6YR3AsI0dydudGibl1Byh7b57/FykV8R5dNUSyt8kDHJkSQdWhPu2/e1JsFvG2njCBy3GQ1z4dk9Qan2wwtmYoGE4Q2tHiBoM7JBrGH9TPMsUCmwgChy8qrbxgFGFbMMh11kWp2eidt9GJTtzIpW3V8l9S3ykVDG4ZFTwQ4LlnSPoCIbsGcFyXcmV+Kgh2m17L2BxT/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=bUJQTskF/PxUROiNR9u0KutptxhC7rr7ejtMqyblQE4=; b=BOfuZpxfWU2F8X6qq1Rg74hIJ+lxO0LacewDnnLz8xrKGejesoeiu5ppV9sAlprK7YK+wXeL2gT+PqKh2gVAhN5uPYrNPrevbMYI2uMGn2po2QDHSsQr+LQn1vfFCSw/+gCjKkFqQJNPPHjJCuS5t4Me8E4y2niIMNNmvWD5nLO45m5NhqTDEIjwV11A+nZm8k7/AWS3qZuJe7WYL8QI1K6PSk7cGb+ZzlqcRXLXyUL0tXA1PKHNmFol0xQF22FfXGyLA6AN1Eypynmm3WxbPYSRr8QgsTdwuinuzxelYPmGYI+h3vWyy5VgBFFldtjEoU9hN2rhwFsXfjSmhTIPqw== 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=Kvdl5oLg6lNM7+prRD1CwcdCuOYj51LI3dQPctah8/Khp6DuEX5irbUJn7NFsSyz9vIcEGA/cOb+KRAdbSBUHXAmSBUfoyuMTbAz+wA9VbuoS6ylKWOxASPKxcOV8374cKIkQWo81l7nQ0wNdGsMAKr0FEWSpU7EHOG36rHrzi8= 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 VI1PR04MB5854.eurprd04.prod.outlook.com (2603:10a6:803:e2::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21; Sat, 31 Jul 2021 00:14:21 +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.025; Sat, 31 Jul 2021 00:14:21 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Andrew Lunn , Florian Fainelli , Vivien Didelot Subject: [RFC PATCH net-next 01/10] net: dsa: rename teardown_default_cpu to teardown_cpu_ports Date: Sat, 31 Jul 2021 03:13:59 +0300 Message-Id: <20210731001408.1882772-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210731001408.1882772-1-vladimir.oltean@nxp.com> References: <20210731001408.1882772-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR02CA0161.eurprd02.prod.outlook.com (2603:10a6:20b:28d::28) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (82.76.66.29) by AM0PR02CA0161.eurprd02.prod.outlook.com (2603:10a6:20b:28d::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21 via Frontend Transport; Sat, 31 Jul 2021 00:14:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a1aa0ada-c75f-428f-7baa-08d953b82529 X-MS-TrafficTypeDiagnostic: VI1PR04MB5854: 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: x/BSZzLCHShica2KoO9t+xKQHywyFTjRO7XkmNdfibeiWc24GuA/PGvCCV9AcD03AHRUEqHdn3fYD8cP4SYB8wFiMMKkmAGVnJgG3d63zvg407ejd+IfJLpLEF6+4bYDRost6hD1fTh5OSVTolaNVyhz13STFl5ZjOtH9WylRIE0el1fwS6nJjQK17ByullOEEgW7pqhuxCH4riKrANgVCvgDAYm536yU0yF607V2f631W2sSwZtL40x00/JZTUuK+ebooUlc7cnRkpLpkHpJoGVcee+iib8kzsVWP8la+KU8oYUNkh99eDLbT9t/AtBp1OqC5DvEJukI2vrw+a2u3DtlZm+MrA6qcsscZDb2HIA2v2c8WoJ0AbAMVmax9Ptq14HznM0/0yDJWw7eX+/gSUytD0fwU1YcjbMe3sUb0XnIsyR+SzZCjmGIh5A5RUzftgiHCKFJgBeyE1mhffTrHhU3hb7hzk/IZjlfEBexlzxgnrH1/35poiriyDr0h8zE+yN5LfwiPXhuN4wbBLbYLppaEnuajjJppej1oDj1Hop3ZqIYa48UEPJltA0jt9T8W8cnJ5ubhyXkUcXsjqWEAFcwjfT4U/47V9sjt0JGWUBfUtS3GeYxjdEHdQaLX3KPfliUvMRrdlF/yPafRzsYHd+VRovNnKJVtaNITmOMCEaTEqoGw7w2gUcOmjqup7RevHcuniIIFtc2ZROj5qj2w== 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)(39850400004)(396003)(346002)(136003)(376002)(366004)(478600001)(83380400001)(6666004)(110136005)(54906003)(66556008)(2906002)(86362001)(52116002)(38100700002)(36756003)(316002)(66476007)(66946007)(1076003)(38350700002)(44832011)(2616005)(8676002)(5660300002)(6512007)(6506007)(26005)(186003)(6486002)(8936002)(956004)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: elccm5YvLUifAcelNyqj5zs0ERaRzrpU63zz2kc8UHcT+znhHIuS2eRKCd2D2FaWEsUL9e6hLO+QeDw6Z6LTLLKVuG1EPa8rvpM4X8VNmwPzHiHVzh79UTAETA2aB1pgP9vSfc3vBt95CV4/AmfzZCvVBjms1unySNWZna0SjjWMEIOUIuxuvEcB1lVzEUjhTRT6B5VaRL3OWFfuaeSHBdyNwpqoAmRRqsEdqDeISpeJfnzwb03XTmX0NW9ZKgxyhuThlsYWwVmkp3AwQ4Rq5jWtUIVIi9oukKPpfaN6w5wwo60+lOGpIcLdMWzy/sZ4vGcfOZghqaLDyNCIIJ+M7Io6wa035aSm0uYkfISl3ZKLvFDh3h7CXMegzSPgBcewy/tg43o1a1XoNokkal2YuoILNDzNmGTbzlYPgv7kitbB8eTtxPv+eLf+LrqYyJBzjSDQ0nm8vEoKxqmvql+mnNPOT/K75OiY2HHejR6STJYXQcE3UyGppGO1n3HRFB8PFtGtMK/Uq/llAogaSg9w0w+NE0R4srmdz7BEjHNMk+GMw0CAzlCaNfTtS5Fo35+xVkH7Pvmn1dnJmG0v/hNh1obJFRZOvAIA5bP4t6J71L2fLq+rA1gSsVihHN9at2JJFU5PH0tCHkJPJ0DASmo60vXugC77NgYCNRF64ZdU3bRDpmgbvYQynSouq7vncAdPtT611UufnzuontNXShYhoubPMAvgFVBgbd7rZXA8ZQZyfBzDdsr+yCDFKW2HK+pG7KqSee3Ngna7Y3Xl7iyHrYR8sXSmDPPcm1+4mfHt1SZJwxQhCy7KuHxXqbs200uEdwLqArPs2U0j+FFmvGR+Rk6W9EyQdrnRwM+reae7EQcV9TKPTZAYLkuTAr7SnE2GE4aRHL3KAJB/A54LPjf4Qkz/iUiWxqV3UYH/pRDl9OY8AXVv4KYcagI5ki/7S2mMjWD89klFVzMT4Tto2mgL0rgFPR+oxESfjxsPg/ykS7QTPvzYjvDfc2xLvh+F12mR1Tw+awpdS8nJy9L/C5qY9zebG4qqN9RF3serXkvly9SQnw6wPYCN4bUPWVOSele1DKDn+I3uW0ZH1WBUEcmADme0Bq6tGTTfs1zsli1qhzsFjbgtzz1t+2blC7Jtbt6BgcqoiPaJJXbARpEn8yRcbOB6f7jFqmo2RzpNfcGtIELA3UhgKHBnMM7lwq8MsuN76bBa/ucHaT1BQ08VXqDgZDfItdvIo9pge8HFVMx9On5CHOVLHQrqWvX8BYtWfk8uENLWbLXJUxk1+nUn+t92KlTYwFKCIsholdQk7JLzRqjsLPYcQLAwed6w+tBeL4Ly X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a1aa0ada-c75f-428f-7baa-08d953b82529 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2021 00:14:21.3908 (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: ZftUqf01jvooDTAn4HqkiASpixJn2Nkav4fFoXjqhPplQU970y4fEOtXKnqe06j56PZSmDrYXHurx6ursTAFsw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5854 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 Sat Jul 31 00:14:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 489686 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.8 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 CCF52C4338F for ; Sat, 31 Jul 2021 00:14:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A77FA60FE7 for ; Sat, 31 Jul 2021 00:14:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234496AbhGaAOf (ORCPT ); Fri, 30 Jul 2021 20:14:35 -0400 Received: from mail-eopbgr40043.outbound.protection.outlook.com ([40.107.4.43]:13735 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234366AbhGaAOb (ORCPT ); Fri, 30 Jul 2021 20:14:31 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cIaeeUr3WvyRR6OgtWvcX0PHFzkv1TeML3XGF242O6Alp2rAScwoWWhvV8KPQQSxcou+z2W1cvUeVW5ntF3eJf4abBKn2NnDvMcUgRaRKMlVGgd48FBD0ogiaFDj+S2IZV75baUlJ7Rf+AlVF6wdp1Rs97ErBBpRyVxQf6HaovlZbAYoRuksOAJCWmIbtTmai21ccWgobAAuEm/3QpMGVK+rNCX/QDqDtJVceRTwgnGBpdUb19uur4DQksqnW6h0mkKmDhvmRzwABRUTAByBVNSU9vDO6jRqHBy6RpTa+BWdfCnkF9OMNII6g1ULi9ru5ZrZldk2Cc1pvILw97cxww== 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=EIV7CUg1VRWxgWwffS3qNGtXgbQctWEf4u3dJXJ1TqijpPDNgM+bcCNsa6rcnifLYg9TmhR2GJaxC3l5goyrXGr5XsaPSu5S21n5rrtIDBU95ci77rfaQfHeoyPB3gAEjCiPDBxpoItvGCQtH4efa6yeLlTPZ4wmF+uEJeoNIqLkFuWJIACgFLAIxbGp5Lr5cApcKVo6OwSZvherC30MX7dwa8b1YTe3kersli4VPAxbhIl15JUTXlj6ZejZ8T98/g7KdEW2lyoHmrAob7rkO/QJbF4/dwODcPcJchm/yhndYTO7yp8ojL6cep2W1TlO+BRyXfHt6sD/erg5mwvd5w== 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=ntYEoAnG7Q19HwDuSYQqujWAU4RWmjEcuyA0VgBexomhI2anM2n2fRynIPfcjnZbhqRiuPN9LtR9nQO7X6Pl5OnRKzAZylPewnbXGOz1mMksPzVgEYYzz9JYsmBo5Ch70TgHQGmB3Gir9mNbjcOMI3WQ9U59t/QCfTkF1+OtRMM= 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 VE1PR04MB6511.eurprd04.prod.outlook.com (2603:10a6:803:11f::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.26; Sat, 31 Jul 2021 00:14:23 +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.025; Sat, 31 Jul 2021 00:14:23 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Andrew Lunn , Florian Fainelli , Vivien Didelot Subject: [RFC PATCH net-next 03/10] net: dsa: sja1105: configure the cascade ports based on topology Date: Sat, 31 Jul 2021 03:14:01 +0300 Message-Id: <20210731001408.1882772-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210731001408.1882772-1-vladimir.oltean@nxp.com> References: <20210731001408.1882772-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR02CA0161.eurprd02.prod.outlook.com (2603:10a6:20b:28d::28) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (82.76.66.29) by AM0PR02CA0161.eurprd02.prod.outlook.com (2603:10a6:20b:28d::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21 via Frontend Transport; Sat, 31 Jul 2021 00:14:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 21b35c65-daa7-4204-3c71-08d953b82642 X-MS-TrafficTypeDiagnostic: VE1PR04MB6511: 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: CUrZH70vti25+GYd3HkzEZtn4aHgtr9vH0TcUPQsSe2d1pvN/PsbgH5C/I+dMRbPIlhfLOD4sp6WdCvG4PO80IjchYOOmuN5D7BiBqt/2BXpMX0JGHNIiGQKNdh6qJTi8WF2uMplANTNY25j/8X35rxpjkiSTSRT6/smPdzEAify55kLT9dbT6GEpYi9s1rQo6GoL5OpTtJdmH7bRHDaJlYI5whYtNbFXEyCCG3aF23T1jWD8sV58E1BwNrobArrJHOksrMREiBJJXT91IZv7qnw/rEIY7YGmgShLAXK/95SiQL5YwgZ0EFyuwaE4ks+w/HPFJfqOF+GlM4eDZvkB/c4CRb5a81bi7ikhhSW0WHBZPxBOCXzzm72UiwCkN3o5XgyaU8ebU+p7e8R5yJRBuVxpmtqmI8I3xuQUVUdhQ2lrFo/niDBaFsn6wtJL5fhtJU3N6whQIDd1xkGYXgT+tJDpUQr5NRPWSUSmJL3gOlGTGMM4P70tIh2BxSY9chj+RmYxk9L9oxLX40kjX0EsaCE4ZIVDAWAfjQarEgS71GhqLYts2KkAxn0WBBZpioic6wXln6baTt5ksOtFRgFYRb8HFVIzqjUbozsJco9G73tMHpXSiDsqG6xluvOnLXZplGi4mvCe3+IZm/7KmgwEwvp2i/o5kQ08wYWGsxmJ1Imaoe9YjduYD/wUxicMTHM 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)(366004)(26005)(186003)(8936002)(6486002)(6506007)(52116002)(6512007)(508600001)(66946007)(66476007)(4326008)(66556008)(956004)(5660300002)(36756003)(44832011)(38100700002)(38350700002)(83380400001)(54906003)(2906002)(8676002)(6666004)(1076003)(110136005)(2616005)(86362001)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HBU19mBGet2t57qNI9kRpn1Wwdqdls29QC4adAu6/FHKEcbq3fGds+Z1C+/0EEqlo+NTRQZLvo5iQMA22H6YwxT7K247Yv0VeI0ZmdVWj5ISHMnGUyNcIMdXc79jz0Vy7WTj4WRviDd9tvNV6Xy/gxLMe+Q+ktzAsnmGH0AYN7dX6MA2dANigTR/chzxdBkRKcqmRFNf7L4yAQ+V58h1GLI7PWjH1YfUgp+KNny1A5Nb62oLYDeziFMoFzC4H5ztPjf41jk1JZtQN7hgyW4LQCrAyViSqG2+/7WptbU6/wDUeJnrxh749Twyr0vmfzLfekc4mdl9+FqflZEhmkBgj3O+HLSnLkIgavVmjGlQQBpGaTBvUhTwUyGdOEA9Nh0A+/7rXuV5N+WwPjmxMVrtu2lf2H8ZtAQ6q9OKfSUTPUVV1FBBm0xC9tfc9YCmDaEACIyI/z7P5gGmbLeOVC4gCDpiZhWu31jy1v55ALfuNQogIAtRT+I7ffiWpSuOnRiKwF1jUyCFr7y9+ScUw2qiIxTemrK1NJTt9IXxCLWo+4IXyaiDahpo+1khCz1HThtPSAIFB+eKMzElJJXtIwDR9jnd9BZSrvRJItd+FhGWRPykj38tu0iutvP2bYcLz8Y39q85j38eZaL+Wkert6xY7gW30Y9e84QM/4WHI4Z0EO3ozu+5rMsmrJHp4sFqYczPySK/ly7iPzA1W4O90aDnNWfURgRFKI1HZkOkp5htMPKqqL5PRzQQBpb8k7O42RAWY1B2Gj+I5mNTIZK7ryevyT6vFG6qhs5+xM9DhDX9Zu25VycsWiozPsPGgqCKGHHC1QY8z9aaAEmbHbgv9r4qytNF4KxZxpcA+hxidBoX0WUn+IQiuOB2zrhiO8bwc1gTrSJqACSJK2WRkmfwJI42pJceQPyobC+LPkh+1IrrN+wUolrEhY0P93PGN+baeZI1qm6uzDQqUfq9xJ3T4E1yvlLBWAWjVNjF/NVFgVTO2YiSJNJl2EsGGqmeyLUez2NdQiFJljKqfM5XDOJRI9Gjue7LLAx5kUezKjZnJSghym5CPHzh+FAG9z0wSZVrpNXfYlYtzOCNhpWgLomQLjXwTQISPVh7REIf/iK9ni0r79iMiBlA/AELbCF5fAdO7QViuS4JA0+R3dsinriaTXI2GqOCSIDRaSh5BEyRhlxrZaVlfur57gfPoQCSsZkG91UHPIzZe4Bh76443AG3ghpa/KF+IUsy4OgLA6gzOLz052d/yNGy48WvBzWmaVyLYV/DzUa2dexgAfOrtzPYM13cqOkGiCAj9V2RjzP9AEQPz+gz8qArXgQV5xKphVL5W7nF X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 21b35c65-daa7-4204-3c71-08d953b82642 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2021 00:14:23.2237 (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: VcvhjbCPekcq/gNTFM7tZRCPJl1F3lzoThalT5nArsOjZXf8gl4cI936fdVc5hHOssdUP/xSYTff2jOkCEpLqQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6511 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 Sat Jul 31 00:14:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 489685 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.8 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 C8974C4338F for ; Sat, 31 Jul 2021 00:14:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A941660FED for ; Sat, 31 Jul 2021 00:14:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234535AbhGaAOn (ORCPT ); Fri, 30 Jul 2021 20:14:43 -0400 Received: from mail-eopbgr40043.outbound.protection.outlook.com ([40.107.4.43]:13735 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234366AbhGaAOh (ORCPT ); Fri, 30 Jul 2021 20:14:37 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ACEom6KtdgHClUlCG3BKSs8O5mXX3FYXaEQiSbAomha2XSSs1DVJfYCfvs7/ssPu1lNPCKCcs52HQ+ap2KOP3yumThkwZQxbtGFpw+a21P2IePNlmtDX+/a4BPlRV2pnuuqv82c8YAHXak5EW+BTmBMjDSHhy7ZPteCs7A9jvVIQdvJvqvij2KVGAkh13FmVQ+Wni915AfAwF/7uUQcJHUGp+VcF+vfliYSeBsV5SI8bQJL5SnI/09Q//8NxDwtb/cc5x5VX3r6V65GEk0B8GGQNfMOspjRqM4psOwIL28CfwbVts3nSt0/zqA+jLo6fkfkb1UMs6LGMDYZukYolPA== 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=AOoWftExYeWn/rT/Mu+2w2OpdG6usRb/FoT3l9hSEjbfnfnmpFdvdxWDXopdDhA9R1YKTtgeFAxfjxVCX5DjqWoslhJueRd692rlwxbwbfsdk1ZyEwTDooTnLE8Y0b4Nwr0J8UpVLlnLAaSuXmqU4yvY09rtUxLg/5D7MpmyyXTUYMD69VCejwsBgRPMhlvKAxJ0g6UG9zDwpG0IN/mzTICjPbPwvj42oz0siaSEk9EBGcoDjDD2qzN/qRWvaf/naKuNg2zRJFdsBuivwASnW0dUi54In1eRBUlWDPAfQBdmgGbAeEvu8AWmvnD/Uac19WUUuHBeFpgc8JvsCL08gQ== 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=AUPLAKVyveRjFrt5A72NQTL/Hwiyg46zi2ZyEUpj4LJ3DzYnEdv/15S7YtoFG3FpoLUYjYjnc5MhBbWE322DoWTmqZoicld4a1Lg9IS8Ui1k41QTG26Uwoalq4UuAA3bpac9rKK0SpcWahDvwoyZNzM+QgCJwwE9xunOOwpVPW0= 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 VE1PR04MB6511.eurprd04.prod.outlook.com (2603:10a6:803:11f::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.26; Sat, 31 Jul 2021 00:14:25 +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.025; Sat, 31 Jul 2021 00:14:25 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Andrew Lunn , Florian Fainelli , Vivien Didelot Subject: [RFC PATCH net-next 05/10] net: dsa: sja1105: manage VLANs on cascade ports Date: Sat, 31 Jul 2021 03:14:03 +0300 Message-Id: <20210731001408.1882772-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210731001408.1882772-1-vladimir.oltean@nxp.com> References: <20210731001408.1882772-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR02CA0161.eurprd02.prod.outlook.com (2603:10a6:20b:28d::28) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (82.76.66.29) by AM0PR02CA0161.eurprd02.prod.outlook.com (2603:10a6:20b:28d::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21 via Frontend Transport; Sat, 31 Jul 2021 00:14:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4243b2e8-0478-4abc-46d2-08d953b8275d X-MS-TrafficTypeDiagnostic: VE1PR04MB6511: 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: gL5FSY5wGz45NWg1e3qeGxEqZcpM9qtFIaVoDN4XiVd0Jhz//0mv+5Ojo4w9+NzQnySROiXcr9o5aucE9SqSxV2PNXK7hQdxKVMP4EqPAZFGmqpHEiXAF+WNaShGaJcDv9UfGXfUNaKehA+XLfvQdZQEWA4bsVt2mXERTtyjFuLbWp8YWzWz6/+2kSDPbgjBIx/8FDRmevjchTVAtEeDucYO0uf69dofKE66n0SB8CP9ziMEWvpUzXvJ4pIccBg2B+oIyx72ZYM3+DmDbfkEcJde7KE2Tij0MHLzX0ZSVtdgSRds+sRJSw6xVG6yJZONT2UrsFwNc7iKh5eyUfiSE0CP9+uLELAZseWcizlSBJuzP1v1qtacBWSGrlBONU5E/aTotYanlh1UWI1U+3X44rRCr4YjOmf2oUyrx6IZTFVQurpoeU5gW4U0WtneHnZQgWyJ8czS3B0ZrFysNjwVsD3wNG1j95hDDMYJ6T9DF/2Pyq/PQNYLY7MQ6LR5HLf1J9L0Hy4d47A6UrsNcddZjxBuTlqYVzCtAV0RakcZgI6HqXbNDrHJXwVkAhgQIHTwQYshiohK5vvNOMRy3mWBmCVkAgb5hh1Vl/GlSbl0CUwa9MmqARdkDMIVLX6TY9ThRGq+Vo/fXTZVxJ/SMSGc01w60dpHvDAzdmdtUBIX6E+ArOINO42dspYTaEi0pUqaWvx4L0W9vsg733quy4E5eA== 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)(366004)(26005)(186003)(8936002)(6486002)(6506007)(52116002)(6512007)(508600001)(66946007)(66476007)(4326008)(66556008)(956004)(5660300002)(36756003)(44832011)(38100700002)(38350700002)(83380400001)(54906003)(2906002)(8676002)(6666004)(1076003)(110136005)(2616005)(86362001)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Y7Yc7PoI0FhtLyR3+74hC6AeU5AHPcPcnQ17UqmDF+WuYmGyBl+RZeVg+2rS3aEc3AeaY2YRY6koDYxhSzQewp5NEOf0fpdlzMOpYNxAhcJF90QklYfpxFuiEZbciQ0yPQyopswarK8t8lQINuIRUVa/HF57vXEL3JMJfj5Ft8RfTd6SvYHj6y1Fitl+/t0lp2F1noQ2HpkMeAbgQlapeEuYnsJ9+MgORBTzYXj6S5LzvrVh2jK5Jj3Cokxq/85lYYj70lCWlPxIaIjnI+mtG824WF6KbL4amLhNZXZ/PCOJhtuAffNUNJ7au5iOdNyo4mTNmcRPhXnpy1nMr477EKBi7j+/Wb3r/0nu41Dsr6c0eRqVuiAldVrOvR40/pBOs1rHrRNSnfNL1sDMCD+O/jj/oZtc9SMC5sZxZrssDOZq2JF/M1Jf6T7ZLXrfdFOAbzhjmz+yzDIflnESbbmsnI0kjtPRe/Yp0DGqxiDm8ppR0ZXqukVdEhhW0A4BP8lGFDXz4XyJQzq0HsbuI5rcLkp64O4m/Ci1JUseheUD26adZWTR6z7YL1dfwvJfKzf2uJB4OpqRlyZO1UcWjzoFbs0oHb/q0fNyatR19kg7nsacL190CGACDqZfYEj8RWv2e4IvnCOGlMdtBnZbNZQJdodS0uOfu6xX7RAm5EMDp2XbdChEa+8mJ+KHHW8BTs+tNWUl/qWRnlmJbzhqXhdPprS+vpXjvL1/YbencogVw/ME2t37od0/z7y+IhFFEqubrqrKsmt0BmRe8C1rfVSIqBpa4mYNmvnvXCft5gDZUVi+1kc3Qd7EkXZEUXAYlfETYyWoLOOJxsFOP//d4wt6rTopB2i2UmSMSqz6Z7qA3afl8T8sWwB87Dmsl/bTVDMaNxmpVN8ncIBri2v58y9TguEmDvfMmn/hl9FOsLfN6vEHP7GcO2RSmiexmeBmdktY37eFAdmmLTIUc4H277gxrRUrkLap4kKNkvPZ1uogomJ9Mk0I9DKMN363Cy61GQGRd1gSCJBD7K3wJyQaBS/Ooxo7dv2M8MWnLD/5o2Q3DVrOcyTowk2sr+aho2SRmrx/6OX2NXQoJEHs7FkJr0nLH+QwQNGPP69yzPktkGqUnx49Hx3SOyUxLeo9tsbDBjLXgLvgyNEyFSxLAsAEXH049JqI4jedNFn7yLXj3IuwAFivPIgtFTmLe0eVqlQRp+4Sce3MUr815gaFR4etlV35rIlpIu0vpOfPC37s0bafqtTQJ4wg1n0NekAq0gamV83zvt5NcVzbGeM0Gg1fO73xFNRLCD9YkxMI8vszGAC3vHKwAlSP2nrFrfj1qQd8NK+Z X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4243b2e8-0478-4abc-46d2-08d953b8275d X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2021 00:14:25.0647 (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: TG0LY1wOPKJewc3DHrU4rRoPiQ8wErIzMBNsPBAxmZy1MZfIh9NF23w3e0wVNjjlU11BZKfK4MAK6IGMkxjQ/w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6511 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 Sat Jul 31 00:14:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 489684 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.8 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 6E8DAC4338F for ; Sat, 31 Jul 2021 00:14:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 53A5760FED for ; Sat, 31 Jul 2021 00:14:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234881AbhGaAOp (ORCPT ); Fri, 30 Jul 2021 20:14:45 -0400 Received: from mail-eopbgr40043.outbound.protection.outlook.com ([40.107.4.43]:13735 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234751AbhGaAOm (ORCPT ); Fri, 30 Jul 2021 20:14:42 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X8UGxS9Ca/txF37LQI2Dj6/UKbUnd+ifZnvdXQA74ehqWFyyIsb2kzQqx11Rt/VzqTlPqUqCSIkfHKEmaFpzVsPkgrZK6OwfIHYinOtU44oiNh8YKxBK8plnA8otm1wjsyT5nG6gg6hmZ1owRwz3kEFmRx9eyJ9388j+8dQJqzovNr97+PBRMRFXo1HR6KSxs6KfUMdstl21ZubTwh30uVHfeMxxFTE4ETAIOcM2QSW/pW/kte8+HPkO5r4TWNCl8qfv40ZjwiNNekpdl8GcXqybSOZPhQpcvZ+BygBA715RkxtEFhBmRH6l77uWnXkZXSKNRCsL0DbvxNjiZEkAVg== 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=FyfrO73Td4dAMsnNDSs9GL0mHeOp2mgHZ+jyCZdu2xc=; b=Vg/cMblyWzlIFfaiK+UOhuO7g7Uq+Tzw4cpRXkAb5VeVJcDQ5ExVtdlLyUVIYcrJOSOCe0wo5Ee/K0EbUFbrYjTcG/Du81mVmwgkNxW9J35c5NOlijmCB0FQu+89Xj4IhmGIyY4XnsPQcFheFz3DZoXi1md5Eskn34eOTDbdbGnyeGHhOHPsdJbd64tOEMKXWCzK5A/m5pmsBukxhNYwmzHjG4sHPPL8LJcovwgyEUPT1UIPALEfwQjQq7FWX+PzdaI3yQMlNog0H7s4zEmA1A1hXanAF4RUb5bZ8qo4TVEUf8t3BZjkCWea8995OevXePuHEvbQFQL9PQkvjXHUuA== 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=FyfrO73Td4dAMsnNDSs9GL0mHeOp2mgHZ+jyCZdu2xc=; b=R3XJu0R8xz9iZNnOBEnSLQGuj/QBnab5AUim6awkm9BN7rnUzQg3xA8e9JLpgMKDRU7lQB293XGeU2pzRIY0Tn0g+ZkNKfG5ot/Fm+N/1YfZrOxsr5jSu2L9mmrU0aXBGpZV1POrf3/wup/MCUIT1rvhQrCzaFLNavEU4ng12fo= 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 VE1PR04MB6511.eurprd04.prod.outlook.com (2603:10a6:803:11f::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.26; Sat, 31 Jul 2021 00:14:26 +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.025; Sat, 31 Jul 2021 00:14:26 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Andrew Lunn , Florian Fainelli , Vivien Didelot Subject: [RFC PATCH net-next 06/10] net: dsa: sja1105: suppress TX packets from looping back in "H" topologies Date: Sat, 31 Jul 2021 03:14:04 +0300 Message-Id: <20210731001408.1882772-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210731001408.1882772-1-vladimir.oltean@nxp.com> References: <20210731001408.1882772-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR02CA0161.eurprd02.prod.outlook.com (2603:10a6:20b:28d::28) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (82.76.66.29) by AM0PR02CA0161.eurprd02.prod.outlook.com (2603:10a6:20b:28d::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21 via Frontend Transport; Sat, 31 Jul 2021 00:14:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5947fd04-4add-405b-682c-08d953b827eb X-MS-TrafficTypeDiagnostic: VE1PR04MB6511: 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: dn1EOLtuJ3jTrzqMPwRcHxUkbVMYjuKqxc6E094p/Nb+Ntdz+/lAB08D5FqbeSbrzFnynUsH1MlLWwmttLHz0FSShmcWVk9EMVk36iN1UZbHHkLf6b6NKQSpKyZJTiW9+UnF5eQUn1VIqjx0LegkMwJhTULFlhqW7D2izOdGXhQOTyfswsZwyua2V/YqID/LR8nLamZ6ciCWZrysgYWhT3HY5n5keXiouKFO461/N27HuhPbd38kWiTkduH5rQiNEFR7Y2XlV3t/fJZNf33CCej1ar466TTblB8ELomQoPR7HuFzwFz7HDmiv5atMiUDK4BkSw4ac6t/22hkv/UNiVHI8XYzKrRbU9665L1BTG18ZjPp4whk4wKNfrhmZSM+NWDmhOSo2KkmBYDeVxbTBkjBptQhGiCZNlgvfQAnD8/TAHe6OmKy/hZw/VaFJoOMLZrNc84VzRtvr/RQme+BNvWER1A97AHmOQU3QhixPpZVovkG4lYtshxkhbbM62j7vG2/DCmgRJ2BFBEpSnZZDAH5WpMH0U0BM9kCFtW9/hlvmJ+EV+5yuWhnhyA8cHRi2uu8YM1USCq/39EmTInCK9xwlT3A0hhe73tc09N5AhEeLJFvFbbPe33qHOcO2OkL+JnMXP4H5hyQq7ZOzHvznjFub4hwvQ0cz+A+w3UI8vXACZrqRsy0+SSacYEo1lbSIdpvEl4IAUgQyHWGzY9YlQ== 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)(366004)(26005)(186003)(8936002)(6486002)(6506007)(52116002)(6512007)(508600001)(66946007)(66476007)(4326008)(66556008)(956004)(5660300002)(36756003)(44832011)(38100700002)(38350700002)(83380400001)(54906003)(2906002)(8676002)(6666004)(1076003)(110136005)(2616005)(86362001)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: y57fEVB2PFJqYonHvctmnh02qVtithhfLGB/sVMf45/djfuTTiHI4deoA374epn1PgGGXU6UFhzk7BH7YnlY5RLZl/LOa6mbM88vVede3H9Y9wLDJdxO2I1Bck8XGqFb0JJDuT3x5e6MZwHwfh710qY8S7tVZADbj/lfEVRD/OokrrrVgdyvNFeqjYuqsYvqZ+khSiKyKe9+wC7a2PCYxOdDYxW2eMja6rxZEtB1WLIkPkTUQwGI/HzPTmo3HX2nJ1fwq7DA1WhyHw5ZNugnVR2uG5ANJxg/Kjfew5dXBm9LaOhbsjYLp9GagCUoyLvxZH4GxWiGZe2yHMAMcxHokpJq74jgHrD64Iet+0X0Z9+rb/3LLWF/KChvng2Bp34ePLO085AKr922QOO6EZlSbcrtoRkggU6vi36n+rYDXosrCuHB4jJNwpDijv7BfTKS77TscyGvKtnPw9RUbn75VQLwUFSPdYsjF2Xb5O00LobM7Y9+HZMBcirqGNd74n7atkyJMaqeEB02xUd9nbQhENU/pCOblz+aK1rEBEZNRwOFKfZLICyQIGTTU3YdSgFOfzQqNEZtqfRlbjmFZKCK/puF78xxqmnSAzfTkJistzTwzwnMowTtHXrI/hjg1V4ka4MVmzQpDdEnZ3ANFNcq7YIjSDKROpl98xLVZuyCAcPvnIJ5VW1TYnRHgZXSSE649PcRahvI46JhBLcaYssFpylS3eoqvMk3JgwSJav3LZVfJ4EoDQX/hTARgfHWJ4raveoHwEsT2hP0Aylr1uiAJiSsmYYPYgfzjHVw0y2P0/MWimYjIyV8A4TnfeRy/hmw9W+p5McWaJ1czJzouT8d5JMtaEpEFH+8KIMIiq8B1cOn7lL19bFP//zmkWRnntypdbpcLCwlFRcThIadZw3PDR5qKWuiHBfdeN9hYOx75M68FTDKth3ROUi5pPCds2bxkY6FU9osxOMRIlZUnSO2/TMaN5xN8uHbG0AxJMDj4cE3j4fGgItwf8SW7BjAujUQv4EBHtkqnxDZqXOIFjOwX6iY8ZA9SkVJ0ArEiIJg7SlRDSOEFBrCihGiacSilMWOATVuIXc4NeWLlpwSwM/D01ILNoYmYerXZzEwH0XxOqKXYVetuB8Sbmjzo5fIf0bYh8xM8uTC+z46Pm+1w6BtZHcFld6saJS8CAy1eoxvn6qWcD87NfSELKJrUVZzTpRGYNxB7vOf3h1eF/Yj186MC1OMnRP25VSQn07TNXEkeWxnzXWL9GxwztZ0Vn2N3CthsSn/sJ2ZxC5mS4SWBB83mjwK/XUOXeKoojfAXpD9bnM7UofNKotfrT+pMaxSl4zr X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5947fd04-4add-405b-682c-08d953b827eb X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2021 00:14:25.9971 (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: nwMfnLaxgR0nQ/4RvQvIbMJdUjJWpvGXMJ36uSJqhAhyqpBLmT6sbEoRUHPZCbkEJTjTReaUMlFUsOMAiu+Ynw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6511 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 d1d4d956cae8..ff6f08037234 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 Sat Jul 31 00:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 489683 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.8 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 8AE47C4338F for ; Sat, 31 Jul 2021 00:14:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B99C60FED for ; Sat, 31 Jul 2021 00:14:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234995AbhGaAOt (ORCPT ); Fri, 30 Jul 2021 20:14:49 -0400 Received: from mail-eopbgr40043.outbound.protection.outlook.com ([40.107.4.43]:13735 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234449AbhGaAOo (ORCPT ); Fri, 30 Jul 2021 20:14:44 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RqS7O+2mNvtyKupWSx5yPPT2j0g8zNk6XHCWutEXlkxto9Is6y7PKr+mrwFz7lf9eRxLkuBKk1Na7kyYyh5sd6/299YIOlGFn65GtPeIKCV/1Zrh3J1SU5LFdgdUs3ztBJa9Gn8OAogrj4DGmrK3ZorX8FxHGl9wtjqKI05wyb0BGoYIDRhGQ2LjZ5BxMN7PHEBvySxyd37acSTFEKcA6vygD+XuU01SEwlIBp6ITV5iIUqP/pc0U5gET3XXgrQ0dQWma9kt2uMA723afAWW0wL35VA0rjPR2rsmt1oXYo7aFpuqo57BY163qbDZsAscczQHE19aStkuntkcnf4ISQ== 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=vEtCJ1X9G0kmqlnTdHcBIMQ0/dTooO5wwsOTtCqwSFQ=; b=WdQoalrLfsouYZfCXWWR2pdjpyCZBzOnrKs+Knfl+Ho0tZEvfAJNvjL85CGSZkc1VLNqAxugyl6savt1Py/jPpPjtje21ToeOZjMj+ZgVHNtn2JWrWR5Xj3PkiA0VYkfogkwQjUm3M5lW4i2u6jyDJIlw6QdEiXoRxzzWvwTuClDSD9OCi6jgHFdhh9I+dQ2IfYkhiWn+cTPJWlWFNnyIvUBWolc7c/eh/h21Mlt1uS9UoORuXuSbGQgXhzt25T7fFpyxcPLzgFa5lRaZ6a6rnLTkGTXgdHTq8ueYcmfZFj1TgJCVOzxyvCZUvX/ZjRcaOzpz76S7OzvX1O5ecK0qQ== 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=vEtCJ1X9G0kmqlnTdHcBIMQ0/dTooO5wwsOTtCqwSFQ=; b=nTt/Ea54N2OQAq9EqaM4dHHCO16YuvVzXmDPRF6jKxE/ee9PcV1DZ6z6fZ+5oRrsbdnVunNBb02FDG4SCeQQJIKOLQpo9IRrmIyqVf/bofwgfySelyqk0/FFtYTeI1H8kOuXqXbOyOjxKmjr/xKJDjhQanlOGVyPwslupQVzDAY= 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 VE1PR04MB6511.eurprd04.prod.outlook.com (2603:10a6:803:11f::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.26; Sat, 31 Jul 2021 00:14:28 +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.025; Sat, 31 Jul 2021 00:14:28 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Andrew Lunn , Florian Fainelli , Vivien Didelot Subject: [RFC PATCH net-next 08/10] net: dsa: sja1105: increase MTU to account for VLAN header on DSA ports Date: Sat, 31 Jul 2021 03:14:06 +0300 Message-Id: <20210731001408.1882772-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210731001408.1882772-1-vladimir.oltean@nxp.com> References: <20210731001408.1882772-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR02CA0161.eurprd02.prod.outlook.com (2603:10a6:20b:28d::28) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (82.76.66.29) by AM0PR02CA0161.eurprd02.prod.outlook.com (2603:10a6:20b:28d::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21 via Frontend Transport; Sat, 31 Jul 2021 00:14:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ce801eb5-445d-45a0-f8f2-08d953b82907 X-MS-TrafficTypeDiagnostic: VE1PR04MB6511: 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: U2pJluD0FWyjB6wZ0vnTJd9kcCTaVIjDOpugfkvuDQb4ToiqPwdCqFneOZxg5XDbshlhzti7TkC9jjfMOPTU79LV/JEfcKADxb+Ymu8EwBvytcLlcbpFN8C6bBRBETWR0mV/Gs/BkhRWE8ieZ5fIUH6vDPXh7fo4McjkN+Meut+EKswFrsHJUSTJ82wveFBUr6AX7EgXs73xA326kaO3HNUrppFfNXzmaBy7uLGHmJ14DPhZgbXdvlc/fIft/URCcWZfk37y/A2OM5cSrB/zAhppMCyrQwcjiglYT6LAOuJ7GehSWidGF/vYgXsaq28qYXhnl+QVgmD1PotJBAFg1ZC85S/Dju2+andPb5ZbX0M5xBPdyxgkF84MfyZV7DLdKpeB7P/Ls7xJanCczL860TJ3zZogoh3LZYNEjFFYwZeaLqA2uabQS3U50PAhrARvT491NYcU01T2xTmFdRSlq7BuiP4lb8vdka4wNlp28Sz7T3s/j8f98LYJ3EWguFn22vk+7aMDVSe7MgK5mIpYgPJA0jog5QvY5s6peWk66KFkobkUEEQqmUypRwtcLUZ64i1JzgPzIVRD4i8f9N+ScW/y8D6TPkH0YPQmBpEW1WT4bDziM0iIqQlz17xDlp7xYGUd8JWnDHimAWTT2Lpq77UaVDASlqzfop/Evna6b63ocu3Sb1+KTu7CE7OxEVfe5juZ/aIMgr5+o8TdVf7wgA== 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)(366004)(26005)(186003)(8936002)(6486002)(6506007)(52116002)(6512007)(508600001)(66946007)(66476007)(4326008)(15650500001)(66556008)(956004)(5660300002)(36756003)(44832011)(38100700002)(38350700002)(83380400001)(54906003)(2906002)(8676002)(6666004)(1076003)(110136005)(2616005)(86362001)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4Prt0DLKyLFec0N+M/bfxMHXds00PEdsl2jKa4Qr/DTJRTjWIvXvVCcDybEFxy22pB9i6XEGLEJUlASb0kQ5j2HpeN/wbtz2TGzx1uJ3ml0Ru5PUOsiw+sG+bmTNmRCQv8y4xDyBY3m6xqRqXtd0DF7MFTduGc99eDYCBje3dZJrDIcsvcSdTQeWwdG0Ar7WfRPPWUcifLYTb2LL1LuQD6x8WyyFdVNF/ujBMe6QMc6/6OuQgNS8g4NaRtUjOvTdYUQrjnbTAHd3kvys/ft3uuCGyz9Rbb3UH17/rQKBTnbXvvnlOmpXvhItd5VReMwgnchx/q/QBOh+VQ9TWvEo6Zj8c9i/HSYiXV/aQCuPFzaeswXBszlbVaSz0wKWt9TO3s7oJOhsGCIrjvalZlju3NUPQK35to3FMzUjCBFpF5H8ySHe8Y8gsxOinoqAuTBFH4vdcj8i2htl8SVPlTdZ8+Z9k7VcLAxxTYcghfwr1kfzCa9ePRvPxyAJcaBxm85ghX1ymcvuA6goG+GT0n4xw5p+rTwS3AJK+sY3A2HBZ0NJKuzGaDn8w9JOwPrMKnougK8dCGCO7nG4hPZ0uxHu+B2kmMB1gnqJN/yUvxN+94bh2ZPCV44tjZ42LwvycDGXnz6sltyyHXPkdmfUnc18sFRwzqXM6BAUuKTxPp5zKmYB771NwwtgSCKymKBonl8TypZAFrnNsOsJIIQaH1c/lcUBS0jLdIrLbWMVhNVblzzrUM91Mf5w258m4khgDhVVY7JaXiRtjur2sDAqVyodBXRxqFqOY9d+0t2scUqmJ6tY0w+6zju6njBL95IJ6ON9f3YOUXw24LF7f61P7fszJ3BCiNr+mvU2ZQN8syd0hR53eaOcVfHy3vWV6uklQ7LUrLoCXb0si1VEMkGfxzfVRomBBxwOrjkmcT7IKbOlwW1vEMjAs0YS7uBZWrzOKom1bJxtoJRWd+5X9CMhjWtvFIaKkJIy56+sgn7Oju9pWXa40kk4TVj/fnR1Fykqeji9P+TQXGEdBtl6kUWcNIu7ShNBU46fn6x3XwXCSPVgCwgcGoJatcF3z4iTtvHR2QRtcBXO53tHDx4qXwq3lQz2AfTfMVpiBr4ceCJoGOA/pZoM7un0hQv4/BbPzYXqFllfb9nNaF8oQMI8V3K96e61RXFRTexOOGHLk5AAdkfuuEgqtF3EFmNnMQdEuifM++0ef11BaiqnL2CP93ntuMM0JJ/c4Tn3Lf62xUYZS8QFTeKlOU08DoC/FDUIoXeBUJ7b+eXqE8UYD49t1mAP9n4J1KcHKhd21vVVQYvQ2LTY79Fn0Yo9pGfKm2J99h4KCCar X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ce801eb5-445d-45a0-f8f2-08d953b82907 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2021 00:14:27.8901 (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: FeiqD76GWyI/OQmyfyK3opiqJ8PtFBpZ3gSV8wJd+aIVuQv1Eo0vcD0Onrq5p3v4+KP98UxwwG4AdieKCSkdSA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6511 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 31dd4b5a2c80..2bca922d7b8c 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -1020,7 +1020,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 */ @@ -2714,7 +2714,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 Sat Jul 31 00:14:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 489682 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.8 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 6A709C4338F for ; Sat, 31 Jul 2021 00:14:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 552B560FED for ; Sat, 31 Jul 2021 00:14:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233795AbhGaAOy (ORCPT ); Fri, 30 Jul 2021 20:14:54 -0400 Received: from mail-eopbgr40043.outbound.protection.outlook.com ([40.107.4.43]:13735 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234753AbhGaAOp (ORCPT ); Fri, 30 Jul 2021 20:14:45 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iawFErW1kd9vwxclWR50TyLKA5b9dhyJa+MLB5+Fb3G6Nekz3rF9T2ydtd7Yy9sriEV4L+/5OW/BHBmtxPXQYOh47/UoxtkRxn8o5AXNhn6dsusGLijSzLV5xtroYv1UXPXXyDSHyOyQPRECde3mI1XhSLA4pAJ6GCsBYFFo3/B+S8VEFcJgGNp2Lv61ToF4iJa7HCMLuS2nUO8ziU13kiHGgbtKx/5Nt6SIXri3YyhSNbyQdPNHvzlBKHR5QLb5Tn7cpNPwHxhnJQ56/WtYsx5CUuboT+caEbLQ5kMXdD6rdBBVgq4UtkTdYl6C/H6pOzcYcvveLeQFTnDr5gZ2dg== 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=agCFnOJqp8Q/p3ojNpBvwkDFp6diFTnViRZ0jE99qNg=; b=MF4uhsIGU3VZ4P9XNX8cQJWr8V1PHUV+ACv55dwGTOcE1+zf/xFnnA+TV/fwsSl7aFvRSiBtvo55gSb/cTOFSbMtPw3/+8KiP79JXCfg+KWu05AEqhNOJr91Tlxhnca44PtFBuxfz3ZrcOSDkWEMVHfXjkA4//2mJtCr2c5scqg7WZpyKn5UpdT9IaPbLkvvNt7uSwhr4Ry0c/Tz8jSW/IJavtuZvzB3qUKdyV9DS1WcQmk1/xNIouqf/5Q5bLvT9p/3+TAbjdjwIHopTjbx3xDmRJqzhL4Ge7k8SxXPWd4cSgdLX2zqSmi3KaBTqodwHOPTpOW+p3tWrGp5Hx2u+w== 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=agCFnOJqp8Q/p3ojNpBvwkDFp6diFTnViRZ0jE99qNg=; b=UvqclgnUeD6a6YUfrT+DPGopdfMc/r93KMni/ydYW7E0pPyoOuFZdykIpN/1VLnOFAE5T5f5gnfnMe/IAPE+yYPnq7VOUmdeXp+vAk36Z9uKVGesEq+V0PzAlEP8ACzrOH/VvHRPjdujMxi3fHy07fI6tDOjOAxsX4ogo2uoowg= 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 VE1PR04MB6511.eurprd04.prod.outlook.com (2603:10a6:803:11f::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.26; Sat, 31 Jul 2021 00:14:29 +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.025; Sat, 31 Jul 2021 00:14:29 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Andrew Lunn , Florian Fainelli , Vivien Didelot Subject: [RFC PATCH net-next 10/10] net: dsa: sja1105: drop untagged packets on the CPU and DSA ports Date: Sat, 31 Jul 2021 03:14:08 +0300 Message-Id: <20210731001408.1882772-11-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210731001408.1882772-1-vladimir.oltean@nxp.com> References: <20210731001408.1882772-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR02CA0161.eurprd02.prod.outlook.com (2603:10a6:20b:28d::28) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (82.76.66.29) by AM0PR02CA0161.eurprd02.prod.outlook.com (2603:10a6:20b:28d::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21 via Frontend Transport; Sat, 31 Jul 2021 00:14:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f4355335-a416-4af5-4498-08d953b82a20 X-MS-TrafficTypeDiagnostic: VE1PR04MB6511: 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: 1qzw64S5gvL5/8EJazH5aRLg6TdSIrqcbecqM0sdMAl2lxmew5YqhFNlHNdRKeZP8CljT48P2vLXH0eYfP38eTzvxtIc3Rpc5UklW2i7XecJZ7L4XkXBAR2Y6ieyLWZ56TMYtts+HAFsNFVr12Lmtq0e+cQ8fGBNk+EoBygFrVqHYHCTvsry9nCHJn6xWya0UV7gq3h1MFZjFWDXwpc32OmSkR1bQIlUMHdDhn/lA73a8HylPA+8qIVikoR34viQl9IoLxhM7YU5YrXNLfk7DceJujQZe+sW6F2OACdi6HmwbBjUBiZedWC4qbMhuKfF04CM83Doqbo+cJdiCizgx+ICcdXP8RBcCVhIcBZowZjLj9x9t0836kZZlrXXSpBRK9Oe7H61ulQDt+JEvUJA4e9MPJXGHEpEMAsqxONWITs0gmaS/O/E/2I4BfHByL7PRIHpDu0fBbSXEtcFzR1zvuVUXQXxk05eZn+g3CzwUyqnCdTNQibS4xNtqPsPNJ51dIh2g8NBhbtID5C1RQKj7lQFJviu9aJPjU+TnoE87hI3kP5SyU0Ocdod10v9xnoySaT1tFlLkvKf+iGaqq6lkfTI6JbK7I3BGvV17Df5ZAQqh/Lb9Zhy7aWqeADFQDRIf+mH0q6uxcmoH2afjCpMthqqrN6ASXGNdMIf/c2s8bixPBM3gVDvOtYIJlTksLNEkGlPXMr8jl4D+JWM6+fJ2Q== 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)(366004)(26005)(186003)(8936002)(6486002)(6506007)(52116002)(6512007)(508600001)(66946007)(66476007)(4326008)(66556008)(956004)(5660300002)(36756003)(44832011)(38100700002)(38350700002)(83380400001)(54906003)(2906002)(8676002)(6666004)(1076003)(110136005)(2616005)(86362001)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 62iqnkww0cPtAeKTz/EKM94PAYPF8SmuQLwx5/FvWlA+kA++0q3q7TBQJ2j++0L0bPsWB67ICPQCsTuA5RztoiaMZN1A8md01iAMCiCeYa36rkobF3qaPszXjnjwkmdcUN8H7LWUe+HnN7HVTGkp4YFUCcEEdygzNGZ0FGcXgg52fD0lIL8CZU0zSwPaYE5CjutdiUAJcGeCoD6qYbwOmGJElqRZdIYUx8+aKj5k4uxckBp7aiJpLCJiAYZO3SFBwIS3+zA1QCCHji4K8aPTNDbMG84uYnSIDOaSkqh8ons6DMtPeZJRs60qQPwOaVw6tcbNKd5vCL8wONAC00E3bjPuArYMLzRXHWpaNq1bCY2l2QcrG3Zaoskncx/JLoJ7Y0RqblysJCoy4azDSswsR7FiT8Oi46NsbJEflfhyR8i3Ez78tm+bvVmBHrzy28hywkqZzrXLlgKGGg7TSYxa+WIm29TIVt9scK+WIhiBQKXJqHSXdSmDwHsr2yQGAdeHdgRVT/IZrEBtftVTRWT3EDh+0XGMTpgiZaub0Vcdxb4QzUynR4ER7OJ8QS6VnOLim4M0lzBIX6FHt2f5be8dCq8zCyvqvDhSDrwL162q3unD7UFVzn3eveuZ4XYMDplN4fUXxKs5g7RDKjFWfsjnnVc+yry9NFQEa0Ii5FAFLrE5leoEyeP32vRdKicbVbs6tfu9elHMLQnherEjYMNU+ozRZCg4vsM2eAKER9L8pwUGJIVpWglyjwYNnc7pXq8QvEo89sL+x2TcnfPkf2RU5G/lko2EbonUf0NB8/wIMpQJ1H02WoCU0Ki+nDN0TdLV6BwKcqc9njg34RSRqefNAUTeitBuwfZ9lhYDPJxN0uIvO10Bv8Myv1aYHJafDe0I4CFi1eiRVCPVoQT0CBNXbToXIAEYBWhLEpT5NtSJS6xbAAqU8KRB0hdWrWlHgnPrJmYvjOQ+poRbOdA4cGYW24XjwUhQEHriUa1Ct3lrFBB1JJGZjWx58nxAVgyNGXxJNKzecoink9XjK0yOL2oH0yaN0vlvnBbH+LHqY4mzJ8aeUB8lDGhbPP2YK0fght83dlMurcgJx5J/KUN2DhzQSCh5xS1NcmlfOnAaytQ+roGQdQJulIjRQuQ09CuJNjrucwY9AeMw05iHtC2Yk8g+EHuNy+/VY7KZsdGZvMh3PTuq31MED5Gu4V+A7kbzRrHzACUN6UNsw6SlYhgOpdCUMIMpp9+rYsF7Um9vqCR0968b7oICfxKP/JKzUr604NDy68l/P3xGPYisS1YjLq6tE3OvCFmjxbzCPnBOs4ax1YEApshG+N8zlQgKD7pV58s8 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4355335-a416-4af5-4498-08d953b82a20 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2021 00:14:29.6960 (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: TZ6FjtrB+nK5AX9oWtIlYyGBkvXG1NumkeIyDFFDEVKOC5Y3V59y2DuERebkWhMH3emWzyjEmpixz0bUgAzt6w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6511 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The sja1105 driver is a bit special in its use of VLAN headers as DSA tags. This is because in VLAN-aware mode, the VLAN headers use an actual TPID of 0x8100, which is understood even by the DSA master as an actual VLAN header. Furthermore, control packets such as PTP and STP are transmitted with no VLAN header as a DSA tag, because, depending on switch generation, there are ways to steer these control packets towards a precise egress port other than VLAN tags. Transmitting control packets as untagged means leaving a door open for traffic in general to be transmitted as untagged from the DSA master, and for it to traverse the switch and exit a random switch port according to the FDB lookup. This behavior is a bit out of line with other DSA drivers which have native support for DSA tagging. There, it is to be expected that the switch only accepts DSA-tagged packets on its CPU port, dropping everything that does not match this pattern. We perhaps rely a bit too much on the switches' hardware dropping on the CPU port, and place no other restrictions in the kernel data path to avoid that. For example, sja1105 is also a bit special in that STP/PTP packets are transmitted using "management routes" (sja1105_port_deferred_xmit): when sending a link-local packet from the CPU, we must first write a SPI message to the switch to tell it to expect a packet towards multicast MAC DA 01-80-c2-00-00-0e, and to route it towards port 3 when it gets it. This entry expires as soon as it matches a packet received by the switch, and it needs to be reinstalled for the next packet etc. All in all quite a ghetto mechanism, but it is all that the sja1105 switches offer for injecting a control packet. The driver takes a mutex for serializing control packets and making the pairs of SPI writes of a management route and its associated skb atomic, but to be honest, a mutex is only relevant as long as all parties agree to take it. With the DSA design, it is possible to open an AF_PACKET socket on the DSA master net device, and blast packets towards 01-80-c2-00-00-0e, and whatever locking the DSA switch driver might use, it all goes kaput because management routes installed by the driver will match skbs sent by the DSA master, and not skbs generated by the driver itself. So they will end up being routed on the wrong port. So through the lens of that, maybe it would make sense to avoid that from happening by doing something in the network stack, like: introduce a new bit in struct sk_buff, like xmit_from_dsa. Then, somewhere around dev_hard_start_xmit(), introduce the following check: if (netdev_uses_dsa(dev) && !skb->xmit_from_dsa) kfree_skb(skb); Ok, maybe that is a bit drastic, but that would at least prevent a bunch of problems. For example, right now, even though the majority of DSA switches drop packets without DSA tags sent by the DSA master (and therefore the majority of garbage that user space daemons like avahi and udhcpcd and friends create), it is still conceivable that an aggressive user space program can open an AF_PACKET socket and inject a spoofed DSA tag directly on the DSA master. We have no protection against that; the packet will be understood by the switch and be routed wherever user space says. Furthermore: there are some DSA switches where we even have register access over Ethernet, using DSA tags. So even user space drivers are possible in this way. This is a huge hole. However, the biggest thing that bothers me is that udhcpcd attempts to ask for an IP address on all interfaces by default, and with sja1105, it will attempt to get a valid IP address on both the DSA master as well as on sja1105 switch ports themselves. So with IP addresses in the same subnet on multiple interfaces, the routing table will be messed up and the system will be unusable for traffic until it is configured manually to not ask for an IP address on the DSA master itself. It turns out that it is possible to avoid that in the sja1105 driver, at least very superficially, by requesting the switch to drop VLAN-untagged packets on the CPU port. With the exception of control packets, all traffic originated from tag_sja1105.c is already VLAN-tagged, so only STP and PTP packets need to be converted. For that, we need to uphold the equivalence between an untagged and a pvid-tagged packet, and to remember that the CPU port of sja1105 uses a pvid of 4095. Now that we drop untagged traffic on the CPU port, non-aggressive user space applications like udhcpcd stop bothering us, and sja1105 effectively becomes just as vulnerable to the aggressive kind of user space programs as other DSA switches are (ok, users can also create 8021q uppers on top of the DSA master in the case of sja1105, but in future patches we can easily deny that, but it still doesn't change the fact that VLAN-tagged packets can still be injected over raw sockets). Signed-off-by: Vladimir Oltean --- drivers/net/dsa/sja1105/sja1105_main.c | 10 ++++++- include/linux/dsa/sja1105.h | 2 ++ net/dsa/tag_sja1105.c | 41 +++++++++++++++++++++++++- 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 6e0b67228d68..47f480cf9e77 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -26,7 +26,6 @@ #include "sja1105_tas.h" #define SJA1105_UNKNOWN_MULTICAST 0x010000000000ull -#define SJA1105_DEFAULT_VLAN (VLAN_N_VID - 1) static const struct dsa_switch_ops sja1105_switch_ops; @@ -138,6 +137,9 @@ static int sja1105_commit_pvid(struct dsa_switch *ds, int port) drop_untagged = true; } + if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) + drop_untagged = true; + return sja1105_drop_untagged(ds, port, drop_untagged); } @@ -216,6 +218,12 @@ static int sja1105_init_mac_settings(struct sja1105_private *priv) */ if (dsa_is_dsa_port(ds, i)) priv->learn_ena |= BIT(i); + + /* Disallow untagged packets from being received on the + * CPU and DSA ports. + */ + if (dsa_is_cpu_port(ds, i) || dsa_is_dsa_port(ds, i)) + mac[i].drpuntag = true; } return 0; diff --git a/include/linux/dsa/sja1105.h b/include/linux/dsa/sja1105.h index 0eadc7ac44ec..edf2509936ed 100644 --- a/include/linux/dsa/sja1105.h +++ b/include/linux/dsa/sja1105.h @@ -16,6 +16,8 @@ #define ETH_P_SJA1105_META 0x0008 #define ETH_P_SJA1110 0xdadc +#define SJA1105_DEFAULT_VLAN (VLAN_N_VID - 1) + /* IEEE 802.3 Annex 57A: Slow Protocols PDUs (01:80:C2:xx:xx:xx) */ #define SJA1105_LINKLOCAL_FILTER_A 0x0180C2000000ull #define SJA1105_LINKLOCAL_FILTER_A_MASK 0xFFFFFF000000ull diff --git a/net/dsa/tag_sja1105.c b/net/dsa/tag_sja1105.c index 664cb802b71a..c23f520db540 100644 --- a/net/dsa/tag_sja1105.c +++ b/net/dsa/tag_sja1105.c @@ -158,6 +158,36 @@ static struct sk_buff *sja1105_imprecise_xmit(struct sk_buff *skb, return dsa_8021q_xmit(skb, netdev, sja1105_xmit_tpid(dp->priv), tx_vid); } +/* Transform untagged control packets into pvid-tagged control packets so that + * all packets sent by this tagger are VLAN-tagged and we can configure the + * switch to drop untagged packets coming from the DSA master. + */ +static struct sk_buff *sja1105_pvid_tag_control_pkt(struct dsa_port *dp, + struct sk_buff *skb, u8 pcp) +{ + __be16 xmit_tpid = htons(sja1105_xmit_tpid(dp->priv)); + struct vlan_ethhdr *hdr; + + /* If VLAN tag is in hwaccel area, move it to the payload + * to deal with both cases uniformly and to ensure that + * the VLANs are added in the right order. + */ + if (skb_vlan_tag_present(skb)) { + skb = __vlan_hwaccel_push_inside(skb); + if (!skb) + return NULL; + } + + hdr = (struct vlan_ethhdr *)skb_mac_header(skb); + + /* If skb is already VLAN-tagged, leave that VLAN ID in place */ + if (hdr->h_vlan_proto == xmit_tpid) + return skb; + + return vlan_insert_tag(skb, xmit_tpid, (pcp << VLAN_PRIO_SHIFT) | + SJA1105_DEFAULT_VLAN); +} + static struct sk_buff *sja1105_xmit(struct sk_buff *skb, struct net_device *netdev) { @@ -173,8 +203,13 @@ static struct sk_buff *sja1105_xmit(struct sk_buff *skb, * but instead SPI-installed management routes. Part 2 of this * is the .port_deferred_xmit driver callback. */ - if (unlikely(sja1105_is_link_local(skb))) + if (unlikely(sja1105_is_link_local(skb))) { + skb = sja1105_pvid_tag_control_pkt(dp, skb, pcp); + if (!skb) + return NULL; + return sja1105_defer_xmit(dp->priv, skb); + } return dsa_8021q_xmit(skb, netdev, sja1105_xmit_tpid(dp->priv), ((pcp << VLAN_PRIO_SHIFT) | tx_vid)); @@ -204,6 +239,10 @@ static struct sk_buff *sja1110_xmit(struct sk_buff *skb, return dsa_8021q_xmit(skb, netdev, sja1105_xmit_tpid(dp->priv), ((pcp << VLAN_PRIO_SHIFT) | tx_vid)); + skb = sja1105_pvid_tag_control_pkt(dp, skb, pcp); + if (!skb) + return NULL; + skb_push(skb, SJA1110_HEADER_LEN); /* Move Ethernet header to the left, making space for DSA tag */