From patchwork Fri Aug 19 17:48:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12949050 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9FE97C28B2B for ; Fri, 19 Aug 2022 18:02:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349712AbiHSSCg (ORCPT ); Fri, 19 Aug 2022 14:02:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350480AbiHSSCH (ORCPT ); Fri, 19 Aug 2022 14:02:07 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70089.outbound.protection.outlook.com [40.107.7.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 506A861716 for ; Fri, 19 Aug 2022 10:48:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CLCteqJ3GvYfi1srfVtJLAi3EZw4j21ULa7LuEqI6SwBx2V6UpUr3JLZvSYiGjOIHQRGvmCl9TRy59yt/3HroZOAXH00GUIHRaEE/9uH/+643s5YSByOc8ejkbQbd/D0Dt12gbxqc/le0dZqTy+JfvWcgoLUGkpkP6tUd660/n5kxsVnjJPA/Njv97KDQaO/ITZREczzN+0xFK8pAo8UIFuUSk/dklsi1WCttWxZ3NsIiGmhfWgcHe9VzmbMSPRfrUMw3ngdtjwemCfGvVxr3aajcSnShZxaAM66PXKgBsO0jo9LLZ8j/7GVhLWDVYag6IRh7sgjn6m9btOZLuMc8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cRRxhoK4/GKcrJnPbk+kjossqjK7OMsto7APf5cpwkU=; b=nBtlGFencILI/bT4+HNn5rniKobCoWQol3ZCRO2KjKUCb0DydnfiVzqiOw4m7LMkuPMF8mKxoeWbLCYiPcyMNT0Hmz6dgWlLgend9qwdhPaagykjxhLZ4xJMLQxjvVDVuY8OxxcVAGkbg4MRy3j3eAwyjPWisax0yhedgBfLoElM/jJVgS4Ntm8SxWvGAAiM+25foMlP/+/vodhab2ptflBuKCt9ZxdCa0YHWJ7O+nFwjEgbQx6K+AahAZrahLO5LhOQ5rWU0fnE3Wr8GLCpBcQeIc0sErIlpz3GIaovbkwGHWIxKP4FrnwL5eH73F7zds1s7uOHSL3O7VwxaUZotw== 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=cRRxhoK4/GKcrJnPbk+kjossqjK7OMsto7APf5cpwkU=; b=fzHw+0UtCEPGUQ0ZQuiEJGDFaKz04it2dH2/u9wz/oh8pckPcQc+K2oqnpNPS9ag29FbEFDFbh7uBIyrzDm08efb07YJMrlzfrZd4LdbWsTSPbLtWhqAqd+JtUNQgD+gEyjCtyTgrKJQi8G9KDRt9+GUE7LOJl4hAqOS7Dj6zjU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by GV1PR04MB9088.eurprd04.prod.outlook.com (2603:10a6:150:23::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Fri, 19 Aug 2022 17:48:32 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857%4]) with mapi id 15.20.5546.016; Fri, 19 Aug 2022 17:48:31 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Fainelli , Vivien Didelot , Andrew Lunn , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Colin Foster , Roopa Prabhu , Nikolay Aleksandrov Subject: [PATCH v3 net-next 1/9] net: dsa: walk through all changeupper notifier functions Date: Fri, 19 Aug 2022 20:48:12 +0300 Message-Id: <20220819174820.3585002-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220819174820.3585002-1-vladimir.oltean@nxp.com> References: <20220819174820.3585002-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM4PR0501CA0044.eurprd05.prod.outlook.com (2603:10a6:200:68::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7cf2cbf0-ff11-4aae-4e09-08da820b0811 X-MS-TrafficTypeDiagnostic: GV1PR04MB9088:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VgfePTBaa2nLvD1tkFmejTuHzoQL74IsStsidTeN0ZRe29dsvZx0ENg2ERL2K6rO+SGn05Y3o9YTvTtrOVk1SQnjrbyeYjFhNzLTokX8UqecNLkCMN5OvGOmIUljLxa61VVR544z3nJInaQ1XQop0DhcmnF2kwHgoyDF8k5Hp/7n4wgg8ZuZilbOvTpEzLOa5qbPo5YZuQ94r7yo8LwCVlWJB3xt9qbNk+3qjb495ggiMzLGczLqKmj4xHrdTJwrnZj20lUbst0Jal7PRplJc4cHsQg2jiYtNHv/udqd/VaA8DnarmcNtwfLHseDgj71bZgcWi02e5/0fGQgaUhl8AxaGDOSYu1+CTssl07SOleEYM5FkCxaGSa37SZI01OuuKbFktQ4M/1v31UJPYBeExj2wuT7SWw94uEXWOK8JboZtzKQDTnDKEG21Syc7GGcjA+hPsRk4wGut1XXktgqYOvUUGAa1d9UbixZ8UZWzfMpGTCtdusW36Z8mVR5N3ffKVNCTaSfG+P2p4p1dgkkA69tlEUwnDzZkYEfAZfeEPtvjVZnE8qYMIQeKHVumP6RtKHN0TcsgUlOrMkp0r8UHxacQnvpkM0aNjRwR9+7HbA4B38TUqdkhp8AWfBK44lwsa0L9GCm4BrAGMtfU6+38g5v4QvanOjXq8UHOh+5BnBgo9Z4H9XLAoay8AgBt7E7ssFeB77QYSGiG0Ogug/MQKW//Z4jt3rTlDYp0q58IcfQ4MvFhfrpZvBdTJ/H9JvE7XpfFiqtLn+aUIGgIuVm3A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(366004)(346002)(396003)(376002)(39860400002)(2906002)(2616005)(6916009)(186003)(1076003)(54906003)(316002)(83380400001)(38350700002)(38100700002)(4326008)(66946007)(66556008)(66476007)(8676002)(36756003)(6486002)(478600001)(26005)(86362001)(41300700001)(8936002)(6666004)(6512007)(6506007)(52116002)(5660300002)(7416002)(44832011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lGYB5+Wd3dJ4RzYWSRn3rrsXBG3u4Qiepmr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DTEPwC4JCtulRKAsyY+uAT6epzF4q2UCklQ2kTg0E9P/c9pH266xu3O1G/r/T/5nq2dpW+k76Qv5DJDKvPX94uONhq9QtqKcJ/1FioZjEc/HMbATzVansIKqKuESyD6SoaR/UpewuWkDn9CWzmlm15tzM9KDzsmZxJP+GHmgrDamlsa81sE9a89I5e121DXZv4WCQOcSN5GNi8Os4zSENpMluTnawz3d1U9Wrx1vAnWcfXYFU8d/bI+u5+EfYAPWbuHAKxHKXIIXtTpLxtHXrVzgs5ZVLM8gyu/CIzN2Qome3RvvF6gdp1Yr5mLQ4wYaM6AFPg04K+/ajE8lOqpJJzdUElGUzgonyXbdgPDireAZwIMpOlkLerFcwQVvpM/5OmgJt5RqOynWWhAB4lwQ9kfEhLUkB+JIDghOxNLA8E/vraUa/N1vn2dmmw33ue/Jlovv9fLOvQ0F8GFf59DS2HaBNTSl5p+/nZXdV/EIuxQqD/ofWt/wzS1UV6xFWQgsD7GzSOyPB/+1FYrg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7cf2cbf0-ff11-4aae-4e09-08da820b0811 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Aug 2022 17:48:31.9511 (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: IQ41gaisUK4iMm/iTfZu0NxkUWastX7NqC/umsQujPGGL3Qm58y0Wm9xT6uDxkf+9IkSOaUzcqqVafJ61ZqI0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB9088 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Traditionally, DSA has had a single netdev notifier handling function for each device type. For the sake of code cleanliness, we would like to introduce more handling functions which do one thing, but the conditions for entering these functions start to overlap. Example: a handling function which tracks whether any bridges contain both DSA and non-DSA interfaces. Either this is placed before dsa_slave_changeupper(), case in which it will prevent that function from executing, or we place it after dsa_slave_changeupper(), case in which we will prevent it from executing. The other alternative is to ignore errors from the new handling function (not ideal). To support this usage, we need to change the pattern. In the new model, we enter all notifier handling sub-functions, and exit with NOTIFY_DONE if there is nothing to do. This allows the sub-functions to be relatively free-form and independent from each other. Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- v1->v3: none net/dsa/slave.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index ad6a6663feeb..2f0400a696fc 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -2476,6 +2476,9 @@ static int dsa_slave_changeupper(struct net_device *dev, struct netlink_ext_ack *extack; int err = NOTIFY_DONE; + if (!dsa_slave_dev_check(dev)) + return err; + extack = netdev_notifier_info_to_extack(&info->info); if (netif_is_bridge_master(info->upper_dev)) { @@ -2531,6 +2534,9 @@ static int dsa_slave_prechangeupper(struct net_device *dev, { struct dsa_port *dp = dsa_slave_to_port(dev); + if (!dsa_slave_dev_check(dev)) + return NOTIFY_DONE; + if (netif_is_bridge_master(info->upper_dev) && !info->linking) dsa_port_pre_bridge_leave(dp, info->upper_dev); else if (netif_is_lag_master(info->upper_dev) && !info->linking) @@ -2551,6 +2557,9 @@ dsa_slave_lag_changeupper(struct net_device *dev, int err = NOTIFY_DONE; struct dsa_port *dp; + if (!netif_is_lag_master(dev)) + return err; + netdev_for_each_lower_dev(dev, lower, iter) { if (!dsa_slave_dev_check(lower)) continue; @@ -2580,6 +2589,9 @@ dsa_slave_lag_prechangeupper(struct net_device *dev, int err = NOTIFY_DONE; struct dsa_port *dp; + if (!netif_is_lag_master(dev)) + return err; + netdev_for_each_lower_dev(dev, lower, iter) { if (!dsa_slave_dev_check(lower)) continue; @@ -2701,22 +2713,29 @@ static int dsa_slave_netdevice_event(struct notifier_block *nb, if (err != NOTIFY_DONE) return err; - if (dsa_slave_dev_check(dev)) - return dsa_slave_prechangeupper(dev, ptr); + err = dsa_slave_prechangeupper(dev, ptr); + if (notifier_to_errno(err)) + return err; - if (netif_is_lag_master(dev)) - return dsa_slave_lag_prechangeupper(dev, ptr); + err = dsa_slave_lag_prechangeupper(dev, ptr); + if (notifier_to_errno(err)) + return err; break; } - case NETDEV_CHANGEUPPER: - if (dsa_slave_dev_check(dev)) - return dsa_slave_changeupper(dev, ptr); + case NETDEV_CHANGEUPPER: { + int err; + + err = dsa_slave_changeupper(dev, ptr); + if (notifier_to_errno(err)) + return err; - if (netif_is_lag_master(dev)) - return dsa_slave_lag_changeupper(dev, ptr); + err = dsa_slave_lag_changeupper(dev, ptr); + if (notifier_to_errno(err)) + return err; break; + } case NETDEV_CHANGELOWERSTATE: { struct netdev_notifier_changelowerstate_info *info = ptr; struct dsa_port *dp; From patchwork Fri Aug 19 17:48:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12949049 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C078C3F6B0 for ; Fri, 19 Aug 2022 18:02:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350525AbiHSSCe (ORCPT ); Fri, 19 Aug 2022 14:02:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349825AbiHSSCF (ORCPT ); Fri, 19 Aug 2022 14:02:05 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80059.outbound.protection.outlook.com [40.107.8.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE6184D166 for ; Fri, 19 Aug 2022 10:48:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A0rPzAnzla9kQe5g1h5obrdZxqQDNruJhWnLzyg3M6I1VFndyzLodL4A85So8irGJYkwBDVxshBwTJqqF9cFiFSA2CBaiDKWyTOdAqDrYSiq+Ke1iC+BV326M8m05oT27nY5vr+g9MRAUUC3G3kfu3OIaKauHTA9dBk1VFJzhCFn8ESLaOO8ians6sS+linPwaxKalTOyqSR0WDqegvDin8ciOJGLSjFB1tEN2//9YwNltOOZAQsBKnu0vtloh0GoBXuH/sAYo8mCPHFcsXq1bBZGlNwj65RyKpO/y+XJ4ft1PCuPu/JGrPf05pJa+8daNb2KE2cgSfusIRzJb95tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kt0w5qRtSmIbRwMcTIzBsR4NX5JOD+QHCYUTvGUdrMA=; b=YpbY/ycHyoHvYzp4e3R1YKmmoJfCc+7KOd53/suhxTUDXB4zTkU1msnZgaURF1j16CaIB4KTw5yqXzOAULkhue2v4QJWfmODB8iTHZdcUlnF2gTLC0ku8dxTOuyXRODkLhxfINQmJqdcUlE5BQe4Q6YIHCcCF7mWUnX0Ot1GKuBUeSe1Vtq1Zmk3y/ShjNwHCY6fssOEwRb85l6IkBuHeDYXwWln37AyYbWyI80LMMHSnCC5gvN8KzuYUuu0biz9RyapttofulHc3zlayVFn7y3jhKDQll+humYcGQ1OrpwBSO55rN92aDHN88hSh3GE6a9Z5cuaQUWIyLg5/HY5bg== 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=kt0w5qRtSmIbRwMcTIzBsR4NX5JOD+QHCYUTvGUdrMA=; b=AqYqZlk15j2NpaVQy2JuZCUlsQDx3fMf31waeXBPxzQT2OBlVg0BB1QfdMZcxb1MZWcpny4rnxrkXymqw0nIIEZTW4r4JNlAtKVYrAXdoHjQT1KaTvrJKDvWRyl9ghaNXZQ0b2/TFqWWKRc8nEV7oQA9rtn6G0V0lu07UmGbuAc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DU2PR04MB8551.eurprd04.prod.outlook.com (2603:10a6:10:2d6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.18; Fri, 19 Aug 2022 17:48:33 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857%4]) with mapi id 15.20.5546.016; Fri, 19 Aug 2022 17:48:33 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Fainelli , Vivien Didelot , Andrew Lunn , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Colin Foster , Roopa Prabhu , Nikolay Aleksandrov Subject: [PATCH v3 net-next 2/9] net: dsa: don't stop at NOTIFY_OK when calling ds->ops->port_prechangeupper Date: Fri, 19 Aug 2022 20:48:13 +0300 Message-Id: <20220819174820.3585002-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220819174820.3585002-1-vladimir.oltean@nxp.com> References: <20220819174820.3585002-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM4PR0501CA0044.eurprd05.prod.outlook.com (2603:10a6:200:68::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d6db3609-fc6c-40f4-2da1-08da820b08d7 X-MS-TrafficTypeDiagnostic: DU2PR04MB8551:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yUMJO+dR5kfkllKJlYeNA9USkGJzJB0hoU7X5XrdeDL7FSiB5SRHAcUBiZcQ2RBPi0f4g3SXt1HF4fNKjwVF2RBu+kX0X5HSlN0RGyja+JaAMy8GsFXDNNMMDeX8m4d1AXq14vluNY00Jok+dZ//LjnGxsG2abv4vqWEJGq7E3kAbhFsq027OE/9qTqpp6r+TQJh6DcbUUSraGqkw2yF/5f8aq6pyzM7He+3WObbu7JnaognYbVuVDay9rePYozd5NYzNkmWWayrJ/u3Y2W/WKzYL/5PlYR03HtvjB4ktbwrxHyY+ThRYSRkgjt8VIorqkj3i3SqU2rsVf6bF0WYslUzVK6XMVw4YFT9fXtS1V8CGZiRVXVuITGtwsOnvE8RtCufW4fRuzDTdvVpXmmKsf8b06garzRAUwJw152VDkuuepNMeH2rn8dGVSKP569fBWZPqQyr4JWnRoh+PbLiMnMLo9dbQUqXW9BfBJhpww0pouXJA8SEioLdEw9LW1Ht18CwaW+UQp94klOfHaKwc23LUuaDCbw38feGDbcMsjxv0mN+DYcME+tmPVLr+b/FhBvQdSxuJzqZ45OPHytJP3W5jl4eEs5wMKTpkr+cbQ3sVleXb4iwCu69VOk3tQ7Olic9K6WBqUqWNkvJcOymCLoMvyutvCm2lgKq7jlR4m+jELf/4eeUKFm2OT8npZUVJzuWCqyDwmeZvOSc8AD2BVE5Mi8eHSv2GbKIc9cxh2u4C2GVEkpHMt0amqdI1Q64Gh9e7e3Z6JLSteOQdpsUOQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(376002)(396003)(346002)(39860400002)(366004)(66556008)(8676002)(4326008)(7416002)(44832011)(66946007)(66476007)(316002)(6916009)(54906003)(5660300002)(36756003)(8936002)(2906002)(478600001)(6486002)(41300700001)(6506007)(6666004)(26005)(52116002)(6512007)(2616005)(86362001)(83380400001)(1076003)(38350700002)(38100700002)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nD9+PTwHZUXQIv+71/iPKDXSw2JD6Rc9Z5PcVOphXosghXVJRkBP01TS7mAgAdBZcfNfKVeZ2FPyALU1ed/WFqWUkGY4LMhwWZNT+H8nKD4jl38B12rje5TpHM4xf9kHRnNnVpfVbTVVdYDBAGQa08MM08SE1gAFNZL6lRAkDsI0oh8nK4PQHDfEieQkTOCSLFqphvaz2ZYroLQEKcjdys5xOeRysfD7Rplgz05w4YWHOykl4NjWxmeUoh8GgQxIIYa3g5CuOsXq8Gx5KhHENjcP2rJiGHy5ISvzhtzV2jQi54BQc69MlIPSdcE8HdEQg3vgPNBYHynYYQongnDBLyP0MKVBVOoW2CCEjy5xqXNqKL1hnCNZ6CJntMFH5z/rbBhmhey9JOjzGveJ93Zljtuoae0CSzRZzVBm6+u3QLUcFs51R+fCwxhIyDUA+++nWDaXgxrSG/Z36q6zp90nagUEdAW2vWmiEu74JkLq68avuhGe0X6oCrzO5k4Jtq6TQjNZFJPpYH5ZMH6HQdKGm2p/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XA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d6db3609-fc6c-40f4-2da1-08da820b08d7 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Aug 2022 17:48:33.2635 (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: 6Z9UO/xy9RG3dFHpxO4pCAOMJ3+ZI5RUxlX2/AHFKA5i8mWF31jbtji6fQHETJ7sL7mEEwO7vdSPvteG3A30CA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8551 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org dsa_slave_prechangeupper_sanity_check() is supposed to enforce some adjacency restrictions, and calls ds->ops->port_prechangeupper if the driver implements it. We convert the error code from the port_prechangeupper() call to a notifier code, and 0 is converted to NOTIFY_OK, but the caller of dsa_slave_prechangeupper_sanity_check() stops at any notifier code different from NOTIFY_DONE. Avoid this by converting back the notifier code to an error code, so that both NOTIFY_OK and NOTIFY_DONE will be seen as 0. This allows more parallel sanity check functions to be added. Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- v1->v3: none net/dsa/slave.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 2f0400a696fc..008bbe1c0285 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -2710,7 +2710,7 @@ static int dsa_slave_netdevice_event(struct notifier_block *nb, int err; err = dsa_slave_prechangeupper_sanity_check(dev, info); - if (err != NOTIFY_DONE) + if (notifier_to_errno(err)) return err; err = dsa_slave_prechangeupper(dev, ptr); From patchwork Fri Aug 19 17:48:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12949051 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6842DC32772 for ; Fri, 19 Aug 2022 18:02:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350083AbiHSSCi (ORCPT ); Fri, 19 Aug 2022 14:02:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350078AbiHSSCI (ORCPT ); Fri, 19 Aug 2022 14:02:08 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80059.outbound.protection.outlook.com [40.107.8.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5054661104 for ; Fri, 19 Aug 2022 10:48:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UfZ2j91S4RvGrc4o81v9CpAUWGpY5rnV0KTVH37fR5H40jfVziNL7I4RUNlsojaFiFuN0FtDgIYD1c/UN5PqwSa+GlZsqHHEuJjZ0pBIuv4fKMIfR7yb2E5L5vVmyXP5DZ7L4w9zbs9ot+IqwP0zz/CjQkddFUGg05N9esx/QWIcALoLhd/HHmh4s6KuFBDUmcuVNtVTW9P6LGDQILtomTm4tbhFGAhKySujm6F4YyrHe9MJZU7ewlDBedLFDRSqsdAk9astciWJbi3yIXoTkMzGxGCb6NQ3RPvbDuiZRYK33QEezxJhf7S58qb2/qXn8wmIDc9berXs751g3xs6Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=c05nCBatA6p8JbJ2xNUWh+NBPqn32UhSKRjurn5BHOE=; b=A0CLSF6Cam2Wa44ieRmT4s/ZHXmEt4sPHnxSnH0suiAfFUSfeozpp7KCzZ6tkwsGwVoQ7rJCeEuwhiJv/iSihVX2ygHWRpXioZOVXWdfZYmu0NmM87x5CuFfuGwqLPwUdZkFg6TePifNeWer0MC3wwa2iXDcLxQ6/WbDhvpb3uKKARfTzDz1gnxw2ArIvCj6SWg0eh9f0zHRtViZGLogfbLAsTBRKf/5F7kFFdXfubjIRpzkdlTjuWXYvfdXNunP3JOzpmEDfSJPXRMmmZ6QR/qkg7hFH2LWqSBd6S3R00uUSUZHBpuq8VDllCtR88ywiNjPcYShVuprYx41O0RKHg== 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=c05nCBatA6p8JbJ2xNUWh+NBPqn32UhSKRjurn5BHOE=; b=phDnKynKIsocrQJVgKClWkIe3vHg3cGEk3OshvAZx+qic16UYozZpz77nQNbdj8u2ff110IDPg0IUhi8CbdhlrHGrC7VhdqOPyDUl29SsSytwWXvR6odyXAre5MMR64yzkMD5uhYZ0lcj8MAGjSrhbDyGozrm+/by4HwWdmOn1I= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DU2PR04MB8551.eurprd04.prod.outlook.com (2603:10a6:10:2d6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.18; Fri, 19 Aug 2022 17:48:34 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857%4]) with mapi id 15.20.5546.016; Fri, 19 Aug 2022 17:48:34 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Fainelli , Vivien Didelot , Andrew Lunn , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Colin Foster , Roopa Prabhu , Nikolay Aleksandrov Subject: [PATCH v3 net-next 3/9] net: bridge: move DSA master bridging restriction to DSA Date: Fri, 19 Aug 2022 20:48:14 +0300 Message-Id: <20220819174820.3585002-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220819174820.3585002-1-vladimir.oltean@nxp.com> References: <20220819174820.3585002-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM4PR0501CA0044.eurprd05.prod.outlook.com (2603:10a6:200:68::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3b0ad3b3-6668-4898-3427-08da820b09a4 X-MS-TrafficTypeDiagnostic: DU2PR04MB8551:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4iTxDIzc6argDsCySURA0eumYCVieRp3LbeT/TKFH9wkOdEMSO4Ibzp56IF+iqOpGzpmabAmi36Gm+kSRegWJPFX8+TUct0K/3jsATlDTE+KN1jVcOWhrV9e8Dnj+OHFOf++plC4mCiqCSRgp+ZX9Ft0tseN4MyvJH9AfKixSgy0CpB2k6AI7aRO8owsr4uLeiJ7kNbGmk7oWC1WRNsvuoYN9xHpiT3kXlG2Upirrxa/HR4f32pnjcT3EyMUXkAUg/n8OaPZgSbRWa+hyJt0rJn8tVFPkpNStjgL3KDMTeOFqUStIgG/h35IBjm9i6E9m9wnxLxhesHH5yve3CeQCAFhgOX75nMgWov8Kfhr3RRScvFlfe50tmALrO/3jFJ+JHF2UuCFuIW8YNSt7FbENyeS3N/gsLxUa+iylZcbD1UAzLjlDt//XrRXblS6US440JMSFbtThAPq9gNpVVn9zYHFSBuHblFL2pn0ICykUFwI7K6b4XhwA934iSqsuCu3ff774T3v+BkE8hjNRecW1Dnj+5Ochpr5mCuahuDlgfwkN74E/dAwULAjGwH7rjw3y+BQMLzdoKDKINLdjDfPOVo68w/agO8W0QHgRwga0j5XcTgFUyG4jxxu1QLpMzppHzIumzPS1EZorOib3eHjcXnP34URjxzqBYXNk0ApjJWCNvUirWLv2TaRg809jgzFho5moFTgm4yHNxjBTbcGgO8jbP7hJDA6JpMakZMpWWxWqDbYhwVCMqNeXFbOLOlLkdQ+T9VD61bIoXHEkP75RA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(376002)(396003)(346002)(39860400002)(366004)(66556008)(8676002)(4326008)(7416002)(44832011)(66946007)(66476007)(316002)(6916009)(54906003)(5660300002)(36756003)(8936002)(2906002)(478600001)(6486002)(41300700001)(6506007)(6666004)(26005)(52116002)(6512007)(2616005)(86362001)(83380400001)(1076003)(38350700002)(38100700002)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0P7oG3kupAkiX+SrJpvQY0D3d/FXM1+q58FkCpIWaoYxv9K5lqQK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tFM71aDm7Yx+TcW2z6d/uQv/MX9V6qre/uTAoqHc1lakeDT4qetOB9iiGsZ04uc740sFNg46OYAEHMZw/A2PInd9srPyMiie4rhHutgGjHbpD9ZgawInVntwO6SNlkg4Wwz34Slg/X+v7ZKnKhH7Az8T4srm8z2EUpycmG/2fbA6EK9nqe0+SXBhJIEKkv/duztbq1jaq2PmvI55mct7J2DLZxZp/L6M7rR7CeFsBVjQDQclpsMIXXodUXs2ddddKN2IQvUmbre+ep1T64Sesjbrpic1pGyqJNGyHpEPNETxPFBdm+kf+DXxapNhlhfNX/Ve8jfbaoPYBgUvVbmCcucZiTlTqE263glaIrRO9ig+schOwK7lV9FYotZC4+b7PlhigWcy8G90yipNGnuLfwVSynE9MvhX9a2ZQdTr8+waFlnAmt5Eb2h/o38KsJquOxp0Fl2TdjSzm5DjOmvNTMmPSZn/KQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3b0ad3b3-6668-4898-3427-08da820b09a4 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Aug 2022 17:48:34.6853 (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: QYwVswIOI1U7UplB69WZC7Q1InONmWURJLrDHPX0dDAn8MpjDNtqgTfroEh6uMq3l2wVCeOJiu0XWVic5xZ/lA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8551 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org When DSA gains support for multiple CPU ports in a LAG, it will become mandatory to monitor the changeupper events for the DSA master. In fact, there are already some restrictions to be imposed in that area, namely that a DSA master cannot be a bridge port except in some special circumstances. Centralize the restrictions at the level of the DSA layer as a preliminary step. Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli Acked-by: Nikolay Aleksandrov --- v1->v3: none net/bridge/br_if.c | 20 -------------------- net/dsa/slave.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 20 deletions(-) diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index a84a7cfb9d6d..efbd93e92ce2 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c @@ -568,26 +568,6 @@ int br_add_if(struct net_bridge *br, struct net_device *dev, !is_valid_ether_addr(dev->dev_addr)) return -EINVAL; - /* Also don't allow bridging of net devices that are DSA masters, since - * the bridge layer rx_handler prevents the DSA fake ethertype handler - * to be invoked, so we don't get the chance to strip off and parse the - * DSA switch tag protocol header (the bridge layer just returns - * RX_HANDLER_CONSUMED, stopping RX processing for these frames). - * The only case where that would not be an issue is when bridging can - * already be offloaded, such as when the DSA master is itself a DSA - * or plain switchdev port, and is bridged only with other ports from - * the same hardware device. - */ - if (netdev_uses_dsa(dev)) { - list_for_each_entry(p, &br->port_list, list) { - if (!netdev_port_same_parent_id(dev, p->dev)) { - NL_SET_ERR_MSG(extack, - "Cannot do software bridging with a DSA master"); - return -EINVAL; - } - } - } - /* No bridging of bridges */ if (dev->netdev_ops->ndo_start_xmit == br_dev_xmit) { NL_SET_ERR_MSG(extack, diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 008bbe1c0285..09767f4b3b37 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -2699,6 +2699,46 @@ dsa_slave_prechangeupper_sanity_check(struct net_device *dev, return NOTIFY_DONE; } +/* Don't allow bridging of DSA masters, since the bridge layer rx_handler + * prevents the DSA fake ethertype handler to be invoked, so we don't get the + * chance to strip off and parse the DSA switch tag protocol header (the bridge + * layer just returns RX_HANDLER_CONSUMED, stopping RX processing for these + * frames). + * The only case where that would not be an issue is when bridging can already + * be offloaded, such as when the DSA master is itself a DSA or plain switchdev + * port, and is bridged only with other ports from the same hardware device. + */ +static int +dsa_bridge_prechangelower_sanity_check(struct net_device *new_lower, + struct netdev_notifier_changeupper_info *info) +{ + struct net_device *br = info->upper_dev; + struct netlink_ext_ack *extack; + struct net_device *lower; + struct list_head *iter; + + if (!netif_is_bridge_master(br)) + return NOTIFY_DONE; + + if (!info->linking) + return NOTIFY_DONE; + + extack = netdev_notifier_info_to_extack(&info->info); + + netdev_for_each_lower_dev(br, lower, iter) { + if (!netdev_uses_dsa(new_lower) && !netdev_uses_dsa(lower)) + continue; + + if (!netdev_port_same_parent_id(lower, new_lower)) { + NL_SET_ERR_MSG(extack, + "Cannot do software bridging with a DSA master"); + return notifier_from_errno(-EINVAL); + } + } + + return NOTIFY_DONE; +} + static int dsa_slave_netdevice_event(struct notifier_block *nb, unsigned long event, void *ptr) { @@ -2713,6 +2753,10 @@ static int dsa_slave_netdevice_event(struct notifier_block *nb, if (notifier_to_errno(err)) return err; + err = dsa_bridge_prechangelower_sanity_check(dev, info); + if (notifier_to_errno(err)) + return err; + err = dsa_slave_prechangeupper(dev, ptr); if (notifier_to_errno(err)) return err; From patchwork Fri Aug 19 17:48:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12949052 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D60FC28B2B for ; Fri, 19 Aug 2022 18:03:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349694AbiHSSDB (ORCPT ); Fri, 19 Aug 2022 14:03:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349887AbiHSSCP (ORCPT ); Fri, 19 Aug 2022 14:02:15 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2079.outbound.protection.outlook.com [40.107.21.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD5E36CD2D for ; Fri, 19 Aug 2022 10:48:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mSWDxQCb9o2bauUm94OXMRBxSAoFrqbPJ63kaemJzIvRrrKFJpLZ9t1OzGk746zLfYXT37ZZXWFspqVDDr0PE0V+g+H5vFiBk85pcXrYMbkpA1l5FS4eFkT6U+3tDv1GHthKHJ+SjTzh5eQQzqgBXRKrQ3mIf2PXoQU5vWHTHPoGF4xsTjDtvgBGySahjIdC1iuEVNOaLz8pF8ZCafyLYvb6hgWRPZocIF+me3HANGtx+64LKCsThYrwYUdYwy9CX/D89eUSK5+s6O7n5eDG6NWQWaIkpEN/L/JxSJLeAJ6aBZ3k4idSql4xJm/eyCRLfhlq+s8JI5GSXa+D5r/8nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4OvO3wa6bR/AgHehVOsFXXBld4+fzXk1BBq1LF5kjGM=; b=cUqFmVj3SDpe0OkYQiDxJ+fvcnOjLj0CaptJlG9EaA2o/X+rulOIFVnMs1jKKbwcK1gfwjgpIXZMN4DNlj7GXR6dWx6sRkIGqXFK+s0AUDbM+SJDBodFs4TiJbiwdmQpo7b+3/1BOWXwQMHryp+5pgS06W3WASVOgnBmtDJ0P964u+Gkj/cbLkXEIAW/m2rYuEQ+0CBpVhFTYOdnd8ZVVpgpRoILB+TIezFyxeVdYo232fVH+hF10y99hRJT5DNjgDK5uTzcXcF+e9MavYfmZLo1b8rakSVk7Ij0fkcIBIwZCdhvjDj80WfK9MzkbCEd8OWUUWUmsGG1AY1v1Shcrw== 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=4OvO3wa6bR/AgHehVOsFXXBld4+fzXk1BBq1LF5kjGM=; b=UeNofxMNu5tdUxFExpRTicb0K2j4b9lRtOpeIL2M+wr/Bk4kfvhFnpDng6NhiLr69UiCbQrT0sgfdYpZxpWUE6hYwY7CWTEW3GpxsmKP44cZMIx7KHp1wUiV2aeqFDN2UBELGoJPyQhLhoz4YVtaA9uwCYx7nfMPY8OOp9BRjAA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DU2PR04MB8551.eurprd04.prod.outlook.com (2603:10a6:10:2d6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.18; Fri, 19 Aug 2022 17:48:36 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857%4]) with mapi id 15.20.5546.016; Fri, 19 Aug 2022 17:48:36 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Fainelli , Vivien Didelot , Andrew Lunn , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Colin Foster , Roopa Prabhu , Nikolay Aleksandrov Subject: [PATCH v3 net-next 4/9] net: dsa: existing DSA masters cannot join upper interfaces Date: Fri, 19 Aug 2022 20:48:15 +0300 Message-Id: <20220819174820.3585002-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220819174820.3585002-1-vladimir.oltean@nxp.com> References: <20220819174820.3585002-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM4PR0501CA0044.eurprd05.prod.outlook.com (2603:10a6:200:68::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 477ec443-d616-4beb-ead0-08da820b0a81 X-MS-TrafficTypeDiagnostic: DU2PR04MB8551:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wJdaZKbwe/w3lAtboKmfqZackkSnigcOYiEkSSDja85TBfMHN2rvY8oqEqpsOc9JYk5NXl488aAAkpdoAAILbCSwgFCBeq6ZDP0G+b9+Zbu9hFj/TXeiTFeAeT7PLGKlVG1f3e22KgzY90PGn7H2AgBZqPpLoajbNsfWWK/gq4wvp7g/mDAmKAsXIKA084HtiMpRirdlZwVuWn9PlZzsXyCeixlgPr/ZFl4/4pRqJIwoTTsICoQgDbqdrQppmPbm8Jr6HxVA70IKGTq7TtLgqyvTTQi0jn5jyATS0PK0bLnlsxXsUAcKnOQY6G3tO+YG7OhUg3x7VpEXwjCQwhZmG1N0xVZmdWGnRaXc+7jhn5qy47RUx1fXIrWIrSxREBMSy7U2mjFCPBRjQnvDsfFJ5yuLoG+m2arPqDBRq5MFQJiuyRYisMQs5SlJoFodwCeSUYK9okVEFvhq5g/5mTj2fSVsjFaPF3zMTCGR/KP2/p7uSJvr2cdO7AzSl+UFOlOWqPr7WApcwT+OYyhmrPaI+EvdBsOJUalrQf9lW7mxc3uB6mGtNYWO/QEwIM9dc6jgwP7tA6CtOgu3GjUe2wMYlIfhHr9NESfCQxJtQfdCeIfPxL0Mo+oXFMHU8dvOmeGS0kEQMgd5bhZH5+12YV17Wda4IFUldq6hCplCBN+zBrdu8GQIdHk2K9me8jRD0WnbfMtaGafaJFmKjE8jyfJzutKnO1qqB+eiKGWKfCp9eoIaYCJNPLp09vZv2DT9Jw4CChnBrJoEXB4Zic6+2Dj1KA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(376002)(396003)(346002)(39860400002)(366004)(66556008)(8676002)(4326008)(7416002)(44832011)(66946007)(66476007)(316002)(6916009)(54906003)(5660300002)(36756003)(8936002)(2906002)(478600001)(6486002)(41300700001)(6506007)(6666004)(26005)(52116002)(6512007)(2616005)(86362001)(83380400001)(1076003)(38350700002)(38100700002)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ovaORIFrS8I7PHtZ1xNIs6MiJaqjmJwjKXXnfMUcrmcstjI6gmUP+mf2UvKplmkaL5j69X4wB5ztBKJbL9+UsdexL++OqYpDs6LCtb43iUMWKma0Z1JIbnJeIHSkW+ZIfaHPynYaHRCjmQBUDvrvdCpzhaOHJeBzCXwm39uYtFOKKz4hSI9nR5TsdR0+2DffNTgRp4K6UPpdAYxlvKUig6YUqHmCnbzlK9kgwMBaVks18FCgwN5H1Y6CWtWWWCSyFLGNsM6YjBs2wCDIZg/UObrroBZWUklRF0aNPIB5dtYGzIg6oxhF1PywUjWjvhSY1gUk8+ZBqX7KmXepxOlAX219nr/FGRrFpuJIRHKzNCAx4tfoeKayX6aKnIox2bXzllcl8oqQVs7/48dMgFVZnFVH300huy9DXYzi7PNtJwRdgGOgzdjsH/2u7RMz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bc4p1yCGsvvLUrba2pHvGF0NXbYqcbV0RUocIC/hzcKoFpw9ibcPe0HZWY7hAxL8m+X13Fy5d2QFQ7XTYmGJoUpt/I/ua5Q== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 477ec443-d616-4beb-ead0-08da820b0a81 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Aug 2022 17:48:36.0602 (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: vGtp+lMNiGJkEdt1tcLN8l0m51oXeb9i6x3bJpzDxZxoojB2yXRlROK5n6/yFrlbSMRaZGsy4lQ0SdCSkVN7Vw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8551 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org All the traffic to/from a DSA master is supposed to be distributed among its DSA switch upper interfaces, so we should not allow other upper device kinds. An exception to this is DSA_TAG_PROTO_NONE (switches with no DSA tags), and in that case it is actually expected to create e.g. VLAN interfaces on the master. But for those, netdev_uses_dsa(master) returns false, so the restriction doesn't apply. The motivation for this change is to allow LAG interfaces of DSA masters to be DSA masters themselves. We want to restrict the user's degrees of freedom by 1: the LAG should already have all DSA masters as lowers, and while lower ports of the LAG can be removed, none can be added after the fact. Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- v1->v3: none net/dsa/slave.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 09767f4b3b37..5b2e8f90ee2c 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -2699,6 +2699,35 @@ dsa_slave_prechangeupper_sanity_check(struct net_device *dev, return NOTIFY_DONE; } +static int +dsa_master_prechangeupper_sanity_check(struct net_device *master, + struct netdev_notifier_changeupper_info *info) +{ + struct netlink_ext_ack *extack; + + if (!netdev_uses_dsa(master)) + return NOTIFY_DONE; + + if (!info->linking) + return NOTIFY_DONE; + + /* Allow DSA switch uppers */ + if (dsa_slave_dev_check(info->upper_dev)) + return NOTIFY_DONE; + + /* Allow bridge uppers of DSA masters, subject to further + * restrictions in dsa_bridge_prechangelower_sanity_check() + */ + if (netif_is_bridge_master(info->upper_dev)) + return NOTIFY_DONE; + + extack = netdev_notifier_info_to_extack(&info->info); + + NL_SET_ERR_MSG_MOD(extack, + "DSA master cannot join unknown upper interfaces"); + return notifier_from_errno(-EBUSY); +} + /* Don't allow bridging of DSA masters, since the bridge layer rx_handler * prevents the DSA fake ethertype handler to be invoked, so we don't get the * chance to strip off and parse the DSA switch tag protocol header (the bridge @@ -2753,6 +2782,10 @@ static int dsa_slave_netdevice_event(struct notifier_block *nb, if (notifier_to_errno(err)) return err; + err = dsa_master_prechangeupper_sanity_check(dev, info); + if (notifier_to_errno(err)) + return err; + err = dsa_bridge_prechangelower_sanity_check(dev, info); if (notifier_to_errno(err)) return err; From patchwork Fri Aug 19 17:48:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12949053 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1B39C32772 for ; Fri, 19 Aug 2022 18:03:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349930AbiHSSDD (ORCPT ); Fri, 19 Aug 2022 14:03:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349917AbiHSSCQ (ORCPT ); Fri, 19 Aug 2022 14:02:16 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80059.outbound.protection.outlook.com [40.107.8.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF2F06112C for ; Fri, 19 Aug 2022 10:48:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CXgufXWkcS/V9ROhM6azU/u/cEOtKP6PHSgtXvi2Usd5g1nQ+1Vertuw1QWOGn5ihz+jrYpc0PWMnfZF81T3WgTYoixAJJRUuA4P8EeyFtO9Byy9lBh86gZOLc2TiI36bUtFN+xN2HPyH5qQ3DaRAq+5TBesgmsnEH3FpbAtG38tGY1xn5NjKA4d94xIW/yG+exmdvNgp6Jrfe9DaY9Nft2cOpYbfYAhCWh+qRaf04hTff776WF9Zk3fsU6gVbbM/MsdSEg2SAcPoWmvp0wkahXkvz4hNwCWDsv2V9WxTlBqe1HpuRhrNy+n3NsjWUWZbDnVlu9k5kIU4KU00PUMaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mF07jgnWJtKVHThmWo1HxIg+r5h+Jy3bAD+dyfIOQD4=; b=Crd8uvn2bz3tpE84loOOHUE2b1Sp1Pvl81pSCDgpANCKtlDVQcYi3KOIZQoGBeZ5Hw4UpQHMVWmiBmJCnCQ3E+Z53rNW+JkL2FVfJQ2/g8+q93MbUJRr9JbvMvcjjMvwkg4jdBRlkUrcLaTF310DdVNujdiyC+u/bvM2fiWtVInrJdzLV0AVi31U2O7QL2q+rl58gufdDHb0JRhsV2Sy2t67/N352OLsBaZ11O2+8OFKrlrhy3vibYA3hBMaVc8EaCqJ8Xr+4fezYa7a4NxKahTStkaxiyi9QvDB0JVa3r4udwk+u08uJ1LEiVLmRKXnY/ldEXlcDRhTQCdpXCthQA== 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=mF07jgnWJtKVHThmWo1HxIg+r5h+Jy3bAD+dyfIOQD4=; b=LltqTFLpCQj2Hg6lUsY5G0e0qlPR22zYRa+P1HQ/roRb6eswUse4u+hhifUNxZouuutEp7GPd946sCpOq+ZdyHlGs78V7QN16KDI7ml11z6HzbdD/kghVIiTQBnNnVDn8hUBWRdWD6CFjBdSyUBerRkBkWKWpi0Y+Fsbjo0H6Zs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DU2PR04MB8551.eurprd04.prod.outlook.com (2603:10a6:10:2d6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.18; Fri, 19 Aug 2022 17:48:37 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857%4]) with mapi id 15.20.5546.016; Fri, 19 Aug 2022 17:48:37 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Fainelli , Vivien Didelot , Andrew Lunn , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Colin Foster , Roopa Prabhu , Nikolay Aleksandrov Subject: [PATCH v3 net-next 5/9] net: dsa: only bring down user ports assigned to a given DSA master Date: Fri, 19 Aug 2022 20:48:16 +0300 Message-Id: <20220819174820.3585002-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220819174820.3585002-1-vladimir.oltean@nxp.com> References: <20220819174820.3585002-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM4PR0501CA0044.eurprd05.prod.outlook.com (2603:10a6:200:68::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4cedce49-e779-45a6-8f08-08da820b0b4c X-MS-TrafficTypeDiagnostic: DU2PR04MB8551:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9s4QIJXV0ibAxsQhI+HlxBdQi8m7Cc5UsZweus5tnBUji67q4Iq5F4E8wu3pbjWC50DjsVcEIptRBAun/V/wHwPqsIwc/aL+SxhV8OZfuiqu/hX1DJ5qD6jlZ7ogjOo1/WcpCchOgk42J3JcASEFPqTkz+Wyc+yiv+nt09r2kVqX1hXzYh2fWWi1Zar1EeotV+FR5dmqTOf1EtBRCjKiz+05scT7imJPZX52f4JzKz1IZRThbJxsMsO1tYal7Wznn6ef2qvHsDiEAzIz82uIA9+tOMshcfe1kCM0HXvYbG9NsIRNrqXP9koOaqctbdUnAdoxkgJqfPIMGevwr/2v6rVZKmNJEv2FCPsyI8vhSgnWQ+csZIWnK4sNdmbj3y+pbcT2zZzmQdW+PM0I6qMi+CxmwMGpdyu93eU/LZH3y7sGVticOLYqP1ZV4D+GGFC3pNIflZ+era+/bRofEy3VPlsdTAn/4cwh8td9NpM6kthCSMbGmBd80z7quDW7d/vqF2hh0iGCrnubsCFg2evkK+QGMuuPgwwWm5ot7N3TQtFCYhBK1mta0mwuOxWNckH7RzuVXfpGBc8wN0KwYutp75p2JfnHQ7LTEcG+iWH0JQuun2rlAaqXI8UFnDHX0QgZTngNl4abrhklue5ESkC/crqOtGLsolS7f/hZM6m4AHCkHFh6if4sMo8JpoFG8D0YfN/JO4AB2NTMpN5wE9PFfi+0sNx3b1I1FIVsIRGWuzbD6inYI8h1hHlIyO3jyNlG1vq9cVv4vury2Ih/h2Siqg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(376002)(396003)(346002)(39860400002)(366004)(66556008)(8676002)(4326008)(7416002)(44832011)(66946007)(66476007)(4744005)(316002)(6916009)(54906003)(5660300002)(36756003)(8936002)(2906002)(478600001)(6486002)(41300700001)(6506007)(6666004)(26005)(52116002)(6512007)(2616005)(86362001)(83380400001)(1076003)(38350700002)(38100700002)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LeMgw8d7i83EGbM0dBXPLPue+kaPz4VC1NPO6UcTV9FO/0ahv9QDFSAQhsEa6ykObF/T+lsykI+ZkGmBFFx4XFw9KlXBNBQrilxD7oN9btkeFNmRHddENcfipujm9OwQHzGUE/9aAzRqXg1fHTubDENpSvrNsO0SOmgGQwasPxfZeyrw0djrAiULTuA96ytl09PIIQCdSQTQQIZs2lqohXX8pYc98UXjQwyBjAVIpy+fIORU77zDyMzznW/5Tad8UftOGt7i01OGMeyLbU4s21YOgvIgOjJ3COGYOVNVG+ztK7+DcnScjXbK6/PtdcNRXmYyTBHdLDKm92lVnecfZiAkoY3ON9x4287iXjxgJyrYgyEKOIjn4E17lQHvVE0C6CoWD1NRys3UOBk2QAqJEXs+yT/vE2oz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aLJuwgw/SAPwykAPb4fcO6WWp2pFdFB/bltbKWz7RLxK5vxGyo4y8OTwI/cEqNN5FYIpepNaghEkkXbtxmJI/wwWMSuOx4yMSJOU6ckufkZteuJmLnnOQw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4cedce49-e779-45a6-8f08-08da820b0b4c X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Aug 2022 17:48:37.3882 (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: ODKtNbINseBs5zAnJ6qAbmJfTWAjH237fCA0cBPJTyrTzVWIMO3UhLxTauH3Jz2CIPWEYR3m4xUG9e0RMQMQuA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8551 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This is an adaptation of commit c0a8a9c27493 ("net: dsa: automatically bring user ports down when master goes down") for multiple DSA masters. When a DSA master goes down, only the user ports under its control should go down too, the others can still send/receive traffic. Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- v1->v3: none net/dsa/slave.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 5b2e8f90ee2c..c548b969b083 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -2873,6 +2873,9 @@ static int dsa_slave_netdevice_event(struct notifier_block *nb, if (!dsa_port_is_user(dp)) continue; + if (dp->cpu_dp != cpu_dp) + continue; + list_add(&dp->slave->close_list, &close_list); } From patchwork Fri Aug 19 17:48:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12949054 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5F2FC28B2B for ; Fri, 19 Aug 2022 18:03:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349302AbiHSSDE (ORCPT ); Fri, 19 Aug 2022 14:03:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349992AbiHSSCR (ORCPT ); Fri, 19 Aug 2022 14:02:17 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2079.outbound.protection.outlook.com [40.107.21.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB6556C775 for ; Fri, 19 Aug 2022 10:48:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=leLTrNTf2jyQ8iohz472yMwrEYgpVhJcZFWbAuRC1LftIFq/mGZPOVpv3cPT+HVQO8ROCSZSQMrd9nywZ1piAO1fKBFkmNZ7i2ViP17hD4KNXYBSTG9uwKa3KJ2v4lu8PPh8SMqSV6y9icweXhlJF2jgy/f9MECl09+UWSDW2b9LvrrOPMnS1koC8c7QwmSZf4ld/nBwU63pqz3m97FubBEXQHN3bZjOU/YLfvpAivSe8ejt1AmZXnDEVJgtlNhJaHB5NS5VyL6Y4AMzGB+Oawl64vO30PyfQpQbf1InDswODMoRMtuiMxXNJRUGAsvuU+SpKXzD7sDf60UqVnN2Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nvDJwk52VI0HJLiHARNEAQJ2uUenwFexjDBMdN1Lpos=; b=T0B3J55Vod2MGI1pWGH7bQRie5KlXwOmY45jN34por9+rHnhaI78MJkPvV+NZiaUkTJEHhD25Ko8z/FmauaoL9YTG6cU6FQvTzdvW+2fvkV+uoJMdFnYdbGgtIMIipvEohmCmEsTdROuf4fXWgs9vKpog2fQ8Gwc70D4iJCoRBkxtVAtxYqOYuzJ93PjG7usPpK1XLj7qQHNRdWfYfgadNm+Ee6ZCn8F8KhefBLK839uqg3CF7BYdAx8xDsiD95NZaVh1YX29BKQVQJrHN507MkYiqs6uUB09MlhvLR/sMtR1Vt6KQp3xS3+NcitqVCQIWscxdRsb1D4CQnZCFOuUw== 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=nvDJwk52VI0HJLiHARNEAQJ2uUenwFexjDBMdN1Lpos=; b=FgfyFyJQEwnwqRf4cl/IL6WWwi1EC4EDraMijy88/mSsyOdiA71+25Hkob+VI28/pNaOzGc2/QV5c4vCEHfQ3j7aEFN3wyoYdnDqZ+rAXaO536bftoSRl1WQDwG8ZRO2P+tp5mKQmfILRWa06VGEV3FiXVhbvtv6/Jw+w6k8rg4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DU2PR04MB8551.eurprd04.prod.outlook.com (2603:10a6:10:2d6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.18; Fri, 19 Aug 2022 17:48:38 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857%4]) with mapi id 15.20.5546.016; Fri, 19 Aug 2022 17:48:38 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Fainelli , Vivien Didelot , Andrew Lunn , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Colin Foster , Roopa Prabhu , Nikolay Aleksandrov Subject: [PATCH v3 net-next 6/9] net: dsa: all DSA masters must be down when changing the tagging protocol Date: Fri, 19 Aug 2022 20:48:17 +0300 Message-Id: <20220819174820.3585002-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220819174820.3585002-1-vladimir.oltean@nxp.com> References: <20220819174820.3585002-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM4PR0501CA0044.eurprd05.prod.outlook.com (2603:10a6:200:68::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 932bd53c-6ceb-42a6-f7dc-08da820b0c1b X-MS-TrafficTypeDiagnostic: DU2PR04MB8551:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CCYN9AaymEev9ynCFT+rojVHxGL35917WzNTwSYQ93GeeX4wp92vmmYrKBN0LNQFOxQfQybdN6nWZX4hsh515PlIEZpdhxAWsBxCMDz4phWimB9YwowVcWcDlHAvawKOsqsO4F7Xc6DAYtt5nzWV4T6trq5gI9ugK8Zz8lY3w9QxAMOLwCROUtmCciGm8dK0khbk82Vk7JsjAkk8WKmIUF8/pwsnjJwYO7wOE6zBrAkOPKoidQb/Huw+Dt8GmW2HZDcupewojhTHCGcLqXEjceu8+jvQ4Mwx/8wIcWpQd4TDu+jvFPktg1GJgxKoajb3yo+TGrrAxRjgMrr3EkIYSvmSqEOfeK+RxlfULID4zdJWctcVw8mS/BSkQ2enScn/67BwlSLqCaX3djJxTiv9Ek82ZJIuS4IbJx0QvOsydhG5pcHacg510wtK6BzqKgReqgAGsAAPSUiJ/cX3cLVs2063oicg1AGxdhlvdfEec0hywb0SU13f6evxCKElaTcrKD4+cdc2ZR0iOB8UL2Pyc1AD/gyEIuahutQWuy/6XJpiaCRqTAR+nMoKWAdBgNp46rPKL80itRCdxEFG6Yg//ISgfiEtcz1bh93Bm3aqRTB8jub2p9hV246iwJIGkoNyTZRXana+es1NpDIcQWl6Sy1+2CrGvxiGeDObsgmc5KJH7irANEHeW9Qn4Un35hD5ScXZDOxXQTUhZSoU8XT4ECtjnevVpq9XJ8rDE1RhcczrbchmocTvidOuwzr1WY0Zy8wkCSwGSBMEeKXxtd/lRg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(376002)(396003)(346002)(39860400002)(366004)(66556008)(8676002)(4326008)(7416002)(44832011)(66946007)(66476007)(316002)(6916009)(54906003)(5660300002)(36756003)(8936002)(2906002)(478600001)(6486002)(41300700001)(6506007)(6666004)(26005)(52116002)(6512007)(2616005)(86362001)(83380400001)(1076003)(38350700002)(38100700002)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DHTi6uWImou7AhwvJF4fLMUVAh2//ro6dVxvxvQS0oT9+bmjFUsaTHnHsdtlPdrYC7OmVsZdnKnE13TyD8vnswMW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m5NIYahBL0s/uQVtnI0wS+WEcJRgMs8iGRdZcnETGtkjg8uWuBYeFVuQHdim2DM8rvyVw7yuN/vW4oHC3lWsGL27ejCeFXLrAKy+7sRwPOtXx63KKglA+lKmMC/Rv9jDUXgoXs4izxlCd5I3zRK1gv13JmcUavha+yFgfGDZI0moO+IoUbF//jTutUkhnikLnU6AyvR/qrVshl36d7R8ULern9DF2IDbT67MVa6sRhRyXBD8ZOsmR2rLyVmm8bjIqW41BZR+R8i72bKZtlOhPJttPUGc8LYxLuaLmN05UTCD899rlqvfW1XWnwBDKf315w9UF/XpTaJxtevv4Aa6eMnzqeeCN7YNEhiF1lzRlF32RHNZ3AFmYQhvUXex06S8HXFPmEjc8AaN6CyUYQUbwx9Oynb4UGvPskrtwtKXv0jsSWXAIAkOTqicQ5v4wAaTmqhmbFxIPwh7spWGN/fA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 932bd53c-6ceb-42a6-f7dc-08da820b0c1b X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Aug 2022 17:48:38.7163 (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: mE6zTSu0JRGqJ1o0UR7AI7feL4AdqNvqpTHny0BuXzYZzc5qtAmcNtsz7G91rwGCsQXMsdXj8t37h2spHANJyw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8551 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The fact that the tagging protocol is set and queried from the /sys/class/net//dsa/tagging file is a bit of a quirk from the single CPU port days which isn't aging very well now that DSA can have more than a single CPU port. This is because the tagging protocol is a switch property, yet in the presence of multiple CPU ports it can be queried and set from multiple sysfs files, all of which are handled by the same implementation. The current logic ensures that the net device whose sysfs file we're changing the tagging protocol through must be down. That net device is the DSA master, and this is fine for single DSA master / CPU port setups. But exactly because the tagging protocol is per switch [ tree, in fact ] and not per DSA master, this isn't fine any longer with multiple CPU ports, and we must iterate through the tree and find all DSA masters, and make sure that all of them are down. Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- v1->v3: none net/dsa/dsa2.c | 10 +++------- net/dsa/dsa_priv.h | 1 - net/dsa/master.c | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index cac48a741f27..b2fe62bfe8dd 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -1238,7 +1238,6 @@ static int dsa_tree_bind_tag_proto(struct dsa_switch_tree *dst, * they would have formed disjoint trees (different "dsa,member" values). */ int dsa_tree_change_tag_proto(struct dsa_switch_tree *dst, - struct net_device *master, const struct dsa_device_ops *tag_ops, const struct dsa_device_ops *old_tag_ops) { @@ -1254,14 +1253,11 @@ int dsa_tree_change_tag_proto(struct dsa_switch_tree *dst, * attempts to change the tagging protocol. If we ever lift the IFF_UP * restriction, there needs to be another mutex which serializes this. */ - if (master->flags & IFF_UP) - goto out_unlock; - list_for_each_entry(dp, &dst->ports, list) { - if (!dsa_port_is_user(dp)) - continue; + if (dsa_port_is_cpu(dp) && (dp->master->flags & IFF_UP)) + goto out_unlock; - if (dp->slave->flags & IFF_UP) + if (dsa_port_is_user(dp) && (dp->slave->flags & IFF_UP)) goto out_unlock; } diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index d9722e49864b..cc1cc866dc42 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h @@ -545,7 +545,6 @@ struct dsa_lag *dsa_tree_lag_find(struct dsa_switch_tree *dst, int dsa_tree_notify(struct dsa_switch_tree *dst, unsigned long e, void *v); int dsa_broadcast(unsigned long e, void *v); int dsa_tree_change_tag_proto(struct dsa_switch_tree *dst, - struct net_device *master, const struct dsa_device_ops *tag_ops, const struct dsa_device_ops *old_tag_ops); void dsa_tree_master_admin_state_change(struct dsa_switch_tree *dst, diff --git a/net/dsa/master.c b/net/dsa/master.c index 2851e44c4cf0..32c0a00a8b92 100644 --- a/net/dsa/master.c +++ b/net/dsa/master.c @@ -307,7 +307,7 @@ static ssize_t tagging_store(struct device *d, struct device_attribute *attr, */ goto out; - err = dsa_tree_change_tag_proto(cpu_dp->ds->dst, dev, new_tag_ops, + err = dsa_tree_change_tag_proto(cpu_dp->ds->dst, new_tag_ops, old_tag_ops); if (err) { /* On failure the old tagger is restored, so we don't need the From patchwork Fri Aug 19 17:48:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12949055 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE310C32772 for ; Fri, 19 Aug 2022 18:03:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350156AbiHSSDG (ORCPT ); Fri, 19 Aug 2022 14:03:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350132AbiHSSCU (ORCPT ); Fri, 19 Aug 2022 14:02:20 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80059.outbound.protection.outlook.com [40.107.8.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C23C86C3C for ; Fri, 19 Aug 2022 10:48:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j6Y0BC2CeAFdfAgYP+ARAmGjm22xcZKe8ZDQK/CTBf/R9a/HQUb93CZqPtd9tM08/wuxnCYj8m0alBZNUfQYTHlZkcevc4vDgpRjC4SOofgnMgaPI0s8xbCMBt4PmkAYYDXzR4c+jFuENpPFo4yky2huZQIQACv+1s7IwZbx9f7MIBSC9iQkkE/cl2cKNYOYTFFpUjY4noAw7eidlj/Ui4KK1U5LqGYlLDph4B4IFEeXYY6ub/DL3XAp9fD01mECenz9+sjGA9hnNFcJ1JimNxyErQ2mFjr9Eci1zPJu1TNXXD5I1UePOVc5AceCCORtZM13QtdN3IQdt+nxdubJ9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MdQR//DUOxlX2QBpnshR9I6snM/J1/oxylG9ai0vAgU=; b=YH84yCVlphEJB1lcRGL0JgSmO8a7NljgT2R2DJ7gf5loZsSf50opgdvAeX3iFQqKaCK2DzFrbWHLg5Z+Mn0MyxUeV6uCaX0Bw7TbaCSvaldSkzduHjsZ7bb/6eF2JKhVYnWMLhOjlgGj9wCKleq+tYcDGYSX6dK5Nrt041Fls3Y4tjiZQApoEn20FEQKNqyrYbEbw52Js9SnATKh2O4FoevbLxc+XCAjhR/YIumXXWXeUGxdKPYgmCceHBda7EgJrPmP7Q+n1N1VbZvBsZC9jyG8uCqTsia9bDajVcQLhnBaeCOzPHBAwi60h8XNT2mAleUZjsxIswUjL3UGJwPvbA== 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=MdQR//DUOxlX2QBpnshR9I6snM/J1/oxylG9ai0vAgU=; b=LHRb98lh4Ps0BGKvjtmHFXbtaZITNkvO/QL13Gzz/Gi0pfPmwK7gvloZZVWdzZzQXBG7OEsIourQN/5iFLzzLOZiHuRWvKDwDnpxTgPijowCCUWEfIDALkqk1umYs0Rqw6W2JNX1jsWcteogfUx+9t0qDFdDKCDBold9Ubjhiko= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DU2PR04MB8551.eurprd04.prod.outlook.com (2603:10a6:10:2d6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.18; Fri, 19 Aug 2022 17:48:40 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857%4]) with mapi id 15.20.5546.016; Fri, 19 Aug 2022 17:48:40 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Fainelli , Vivien Didelot , Andrew Lunn , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Colin Foster , Roopa Prabhu , Nikolay Aleksandrov Subject: [PATCH v3 net-next 7/9] net: dsa: use dsa_tree_for_each_cpu_port in dsa_tree_{setup,teardown}_master Date: Fri, 19 Aug 2022 20:48:18 +0300 Message-Id: <20220819174820.3585002-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220819174820.3585002-1-vladimir.oltean@nxp.com> References: <20220819174820.3585002-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM4PR0501CA0044.eurprd05.prod.outlook.com (2603:10a6:200:68::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5d9bd0af-8d06-4388-d767-08da820b0ce1 X-MS-TrafficTypeDiagnostic: DU2PR04MB8551:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k0mY0VsMVGM5x+3wNzFArVIHyiajbl2R3TV5LcxXB+lfLH5fM3aCZUvVpJ5F2x2CObPErxNBWBFp+7VwTNFcCSwL3oCTjP5bOSlhaXKFC7Aqdr1V5J7a4ThYtkZVRLwqiQIBDfRjnOYX3+/YsyAKeLpnaNwa9tzgA3MI3/LhTmE4Clba1mZvY/x7eieUqF8DDFf7i2YgnL/lb96kfwS7H0YqIvd07RT00rrhzoWzckPj6dQS8E3TVdEnHseHrv66w76XuDP0JgOhvgxfTV52eIOBCsyTDFwljIwqDHoYfZow0WEevEXEtEO59FQyXeiRo9FSNm5HHjDboDUdmoznh/pMT4z3hsc0O6w988UoBsmBPNYCiEix5cqxVWP7kow/juk8inPM00NhJx86vCIkrbh5ASvnbnu+8PYuFlETnaugevNaczFoS0x50+w7otA2ILiUMcTBBDWGIeZaFtWX573urVjabrKYUHzCLthFu6sviMyRYzMjYW91epV/0v+zuouYpdC4dE+OhoulWK79+Xbx3QP85ZBzZn2Zrt/cdvb+gl8LpipIg1MHW7qoPC7LcPbHn7NSpvqY0lmQO0RSaiTgg0k1HMlq15hSKieHOKfd3ZAt+xk/SS4W6UdGH9Yg4/uHcfPU8IZgmayQYkhR0zF1n8B/QelBGMj2IGMKq40jW+nuzg7e8EVxEDXpMS9GAunjxOAq7zYR+kTAheddJuKuZbD5ScFwGCCD5jfngqpZSZCmOlaCbz+gc6rr/DZ2Fm0hjQQPO9gcEHb/r6AGfg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(376002)(396003)(346002)(39860400002)(366004)(66556008)(8676002)(4326008)(7416002)(44832011)(66946007)(66476007)(316002)(6916009)(54906003)(5660300002)(36756003)(8936002)(2906002)(478600001)(6486002)(41300700001)(6506007)(6666004)(26005)(52116002)(6512007)(2616005)(86362001)(83380400001)(1076003)(38350700002)(38100700002)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Me8cjPuM8Ov2TIvrM5ursMXTm2jApRY7KKjQSvvK0P230W/Eij4t1LYM0r5EosTSEY74+tEZuDpOk5rt3d5i9Kl2fFZYtZI/kYomrQDPDB94yMwc/yUGm0DlGKrvQln8mT/Sq9Xi9B6eh0qPI9Wc/92kYl0F36Lm2P2DA7MO/2hSQsPVrdolibIwHhaYqvDVo62V1iJb/ljIdI90drGij3Su0KHFetQr5Q2qnLQL8oQX2teKb7sS2RZVP9r5Dl6lnsacGaLyoTh1DS9JU6Sh+W7s/dfAUC6kOugQ5P8vmJWJreePtIrs2TZzEgiXUULFysq3uOnSD1JNlUmRXi7gB+kDWAM2q+wROOgBeVomFvyOSP4pnI+c3+IlESsNDHw4Q013ZRtxYcb5fS8LRQw9Jaipen94F60okmT/y8JCP5ZwG9Z3Fxn89eQu3CvjdWY4DufW2GEnV5r5ogRvhi4Clt6VYjAyMrS5SuVS6a+gItiiOmmRWtRPmqjUEj06bSGMyoeHoxLpJEfNCDpWQv+bO7KQSdc/XBYEemBCo5/LhCmDDTAUprg1f6nAoagd8ZaUerD+hoZgxW16Y7E/zbBxD1RYlWHd4sEYfbrr57xaCdUGYM4ZTXSL0EI597gFsv2ZBZXfHBRmxUrXVdvoErOf0Vu+jWJ+64kRMn59KARjwEmf17OsoK5x1PI1/jKaGrOzigXFUD3p+PHEzoVxclxz4UOhvQWEkCzxEoUjPRLAGGQKcE+UHNlMJIDbrFIDYgU/CuvHzPGH1znkubu5Ceskk71DKalcl8SByEiwUk+03X4EzDstkfV0vZSioEuJQUaGfJZbr6avEQ4nfngxyzS29voXlE/CQTlzDwbOGiUDieO3O1FeDvK58NYLsEQd3WD70/NRVRXoAPhTbKnzb+x02NbD1/PQ6AcDVEuCW9EoiurOIG2EhmuDAJukegvk4rFS0eT9fBs4zgfPjaJu2dU9u/PdCPhC4NpnyBbUFqJqizKBmKEpKvd8ajQTtGKp6yM7Ixw6GWw1FjxYYA7W2aBUb9K4JjIvxWpWgMXMSgQyi6DfGoHnkGUyVISAyQZg98/TJzBOlJlqwwM5O0M9CD86JQzI26CzEqJ+QJ7Qga+gj6VZI/f87hbOGyaKCUqKLPQqMJl03H1FVjscl0EFUTvDRP2nDrCzSBc1xYsuUWVA9X5ha7EbmPAyuLWBWa4XCfMwY7HZ6uJ4z84BqYSBz7F6U174+wvYjTNpmLqp3HBkTJpOWvfgrE6msEgW01sQUL9i394AhdzXOMpg3D24wAxhpUYC22h5NMxkM3ZIA8TrkY0F0Ytk4nJzqqfOmNrtO2yDyyPYbI07luvHqxfDjcpb23z8ji++BeCFgNuZIvieYeyMuNPRXipqz16JgvAMFYImbmTUY1fFkHHFGlJQP3/iQO8bRPo//dGPYaDW2hbweEOjruilmfG7QzyIZXAjJmn4quOBWh61SxTFoz6DFjJxu83OcsvTwxZ3SSj0qwgyZ77GKolVMVzjLdx+SPXFoRzC79gC4k92PxLTu7/aeFJR064P7GRsBxzH9r3lQOqQOda5nyg1+TG5SS3YBpYkhO96drlcil05mRP/imy0I55JmQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d9bd0af-8d06-4388-d767-08da820b0ce1 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Aug 2022 17:48:40.0131 (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: OOkGTzcqkk58sXw8jr3HvNCXGouDKtp/uqCYopQTxaw+2pWc+xxwhNkf54Z37Dx5zp5xGpsfWWphNNTCqZ05Mg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8551 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org More logic will be added to dsa_tree_setup_master() and dsa_tree_teardown_master() in upcoming changes. Reduce the indentation by one level in these functions by introducing and using a dedicated iterator for CPU ports of a tree. Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- v1->v3: none include/net/dsa.h | 4 ++++ net/dsa/dsa2.c | 46 +++++++++++++++++++++------------------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/include/net/dsa.h b/include/net/dsa.h index b902b31bebce..f2ce12860546 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -559,6 +559,10 @@ static inline bool dsa_is_user_port(struct dsa_switch *ds, int p) list_for_each_entry((_dp), &(_dst)->ports, list) \ if (dsa_port_is_user((_dp))) +#define dsa_tree_for_each_cpu_port(_dp, _dst) \ + list_for_each_entry((_dp), &(_dst)->ports, list) \ + if (dsa_port_is_cpu((_dp))) + #define dsa_switch_for_each_port(_dp, _ds) \ list_for_each_entry((_dp), &(_ds)->dst->ports, list) \ if ((_dp)->ds == (_ds)) diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index b2fe62bfe8dd..6c46c3b414e2 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -1046,26 +1046,24 @@ static int dsa_tree_setup_switches(struct dsa_switch_tree *dst) static int dsa_tree_setup_master(struct dsa_switch_tree *dst) { - struct dsa_port *dp; + struct dsa_port *cpu_dp; int err = 0; rtnl_lock(); - list_for_each_entry(dp, &dst->ports, list) { - if (dsa_port_is_cpu(dp)) { - struct net_device *master = dp->master; - bool admin_up = (master->flags & IFF_UP) && - !qdisc_tx_is_noop(master); + dsa_tree_for_each_cpu_port(cpu_dp, dst) { + struct net_device *master = cpu_dp->master; + bool admin_up = (master->flags & IFF_UP) && + !qdisc_tx_is_noop(master); - err = dsa_master_setup(master, dp); - if (err) - break; + err = dsa_master_setup(master, cpu_dp); + if (err) + break; - /* Replay master state event */ - dsa_tree_master_admin_state_change(dst, master, admin_up); - dsa_tree_master_oper_state_change(dst, master, - netif_oper_up(master)); - } + /* Replay master state event */ + dsa_tree_master_admin_state_change(dst, master, admin_up); + dsa_tree_master_oper_state_change(dst, master, + netif_oper_up(master)); } rtnl_unlock(); @@ -1075,22 +1073,20 @@ static int dsa_tree_setup_master(struct dsa_switch_tree *dst) static void dsa_tree_teardown_master(struct dsa_switch_tree *dst) { - struct dsa_port *dp; + struct dsa_port *cpu_dp; rtnl_lock(); - list_for_each_entry(dp, &dst->ports, list) { - if (dsa_port_is_cpu(dp)) { - struct net_device *master = dp->master; + dsa_tree_for_each_cpu_port(cpu_dp, dst) { + struct net_device *master = cpu_dp->master; - /* Synthesizing an "admin down" state is sufficient for - * the switches to get a notification if the master is - * currently up and running. - */ - dsa_tree_master_admin_state_change(dst, master, false); + /* Synthesizing an "admin down" state is sufficient for + * the switches to get a notification if the master is + * currently up and running. + */ + dsa_tree_master_admin_state_change(dst, master, false); - dsa_master_teardown(master); - } + dsa_master_teardown(master); } rtnl_unlock(); From patchwork Fri Aug 19 17:48:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12949056 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8733C28B2B for ; Fri, 19 Aug 2022 18:03:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349893AbiHSSDI (ORCPT ); Fri, 19 Aug 2022 14:03:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350136AbiHSSCU (ORCPT ); Fri, 19 Aug 2022 14:02:20 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2079.outbound.protection.outlook.com [40.107.21.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96E66876B7 for ; Fri, 19 Aug 2022 10:48:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tl10Xpabv/Wh+sJyW/NCv+qF2DOqpY3mYF7S2KaVX2ViA9cULYVpuNk8EYkKD7L5HYgksp3sOZZAanXckGueLqXt9mS/pGZCcz8Iu3lwPGbYU4dBL4S+ewl0Rbf2NgRo9GRB6IMiX+x5D00vf909CEGoywglJ/NagsrwcHscTldR0G+euZ/twPEMKUR+WffCFfBIxvde4Hc1IbOUnaInZ8OhOn/fTY8h2hxtwd6LAOWFVaX/as1V5qGLOqcAVvR/RkLdjIRhnufyzF7yF1VHXpORy0vARHLDVg0PBnUPiR0+btIVsp60CofaynmHNHusEljtsEcRuWQBbRbkW0OzYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+w/zSZBEIt6ji8H/DzJt45Xq+vmJnhIMDFeU0gZwEOA=; b=bg0jwO0DMpJSOkra6ldWk1psHICTQUxpyRPWzi0ncqwude0p3BvwiM8Qp7KguGVS8NJC23mnG8QdvJoEadqQ+rSnP0MEdiVaaVHMgkCx+Qfxp7+onm4D4djL7Ej6kCtCiO8aMSzVyRgzjitvxd00aS3BwqEvtJ9VepIixIaDEZP/py3NYnupAkwQUY2RtYYn31pAJaK5vyoALDFd8FJYn8zPP0amQTqPMb21psfCrBSC7oadiHpcXYYdmPpv+dEtA1n0nOV2DOXvPzLmqL0zbsAkzy4ZXutWg/NySEt1HbA0JnvcJ8O1xABN8sh8gH18ZBfgp0+Xpo9Dus+XqigfGg== 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=+w/zSZBEIt6ji8H/DzJt45Xq+vmJnhIMDFeU0gZwEOA=; b=AhrZZClo+QQ3ECUrgQcx59nJk1Ip18Qz54IsDQZWROJ62MpT1g9QmXGKSRBcfDEIAfmljsHb9xKKu7e03q1NCbZJs0HZUENJVZNxqYMKxje4b9bkVUwumR1l/aqXc4sVsM2AI0Z2eoNjGVgNj00JthPmDZwqSX/Wk4emYDPXjwU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DU2PR04MB8551.eurprd04.prod.outlook.com (2603:10a6:10:2d6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.18; Fri, 19 Aug 2022 17:48:41 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857%4]) with mapi id 15.20.5546.016; Fri, 19 Aug 2022 17:48:41 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Fainelli , Vivien Didelot , Andrew Lunn , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Colin Foster , Roopa Prabhu , Nikolay Aleksandrov Subject: [PATCH v3 net-next 8/9] net: mscc: ocelot: set up tag_8021q CPU ports independent of user port affinity Date: Fri, 19 Aug 2022 20:48:19 +0300 Message-Id: <20220819174820.3585002-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220819174820.3585002-1-vladimir.oltean@nxp.com> References: <20220819174820.3585002-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM4PR0501CA0044.eurprd05.prod.outlook.com (2603:10a6:200:68::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a61a9ae1-20c9-495b-b6ff-08da820b0da7 X-MS-TrafficTypeDiagnostic: DU2PR04MB8551:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c3HcwaDdzKwKppFVKAYggp+iIrubpYO1FZy5LZzSUg72PV3cxCB14aEppQx3ttGVLIqjLABH9gF2rt9Y03Usp7ZqzidXmcbI+xBRpCt6SZu227v81ljsOvJ/cDVfVcWh6qefKxjjVGyp2XgRwuGZ/GmQoJDf5IKyELPuGONAu64Nq4TwbaIXEuUegcrSQDLXvGNYDaPrpSkeVzWtfadRJdAKueLL3nzBVO+FLCMqp73p0coCOYCx8Fr+sczI4oQJZuvATeb5EYIFVAX6uDNO1HPD1m0WSR25wtzrjWjmAaq2768LmJj77cAKzENKIXTW25HVPIDxSqkCx4hf8LsulDcqcRjKeaAbcp4SbkqKL+J5CXJQLNL7JAK6CbMrlYi8GaPeU2BfCEwKkfNGKpO5ZZDddEHhm0okVKLAw9VLzqQF0UryazsDjZM/PF0x6N8RFIPD18PVaWDOiyTpj30278N6wmCMKpxI22glCuh97ui2z1nEdLjAwDPfo+J3rowvv9CHCxtoH9ID/0vvy3L907D6EUDpzXRYqB6MWj0cND3bykgNVgNmHLuvZBZMTOnRhcY+S3Ezhf+EgDuwlAT7xylsu6kb+5PuKniqZrdcPc5OC56dT1ehsgs71jJ5WXnbTvHGQhn5W8FVRknoFmrVLbPVOqOzxJr+dmznauJ/vDwVmz7WXWn9JYoS0cZYHYCXtq9rgbjrTkNSh4lhdblGXtRsU0zBDfGbueLTpubc0AWVNH+6fXkxRkdWsJ8oO3uDV+rfUL5eHCGx1Rq4xQUpXA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(376002)(396003)(346002)(39860400002)(366004)(66556008)(8676002)(4326008)(7416002)(44832011)(66946007)(66476007)(316002)(6916009)(54906003)(5660300002)(36756003)(8936002)(2906002)(478600001)(6486002)(41300700001)(6506007)(6666004)(26005)(52116002)(6512007)(2616005)(86362001)(83380400001)(1076003)(38350700002)(38100700002)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QweDGFG6xylO87RJ2SINw0HE7ZJEICNxbw+R1ZALYENgEFI6OIuisb1WfiAfNL7Oq0IzC5A793HxgKg32boHf3vPDqc9Qee7ljZqGvgQfQpk364hEPPDi6Zar558Lb4IXhQZlvbNxrN/+7aJvUr3asqcHxEpjhPaTE3bVyrEXdDzGqHHqvZQMvAcieK6MBMrhuOIta7Py9o0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LG6zr4X9w/r2s0zivYB4JfcMPS0yvwl9naFLB174+dfciukHaZWWfXMpvI4llOn0I4Y5WrhqruCxgFkZH1tcQiizFwniIiYgRMU//YS2IVab6hvBFyC0f1t46+acld/gMrKdZnA+jHse2b/Hz7+5OPpVCjy3i5wOBU9U6oRU/vk5W2r1xENC/wMhUEh8Ncpz0PNeoItjNaK+lFM5tHhMillHWUcMlmM3lJLKnPyQ35vgj/hfHBSjTGlDhtAoDz/9xG1SxZD8nkEWgKkfOQgeqYNSOPiw7NeMjTZSpRPguQ37uQTUfNu20Zgu8VXbNTcNkdJ9D0POyUR4gm9aSd9N0DA98g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a61a9ae1-20c9-495b-b6ff-08da820b0da7 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Aug 2022 17:48:41.3255 (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: STaJqneH9zWr40a/z2UvYT0NJgzMydUb2RbCp5ZGEzW7COmdQNlIhGcuy7Xb8MhOyIvDCiLy6129SNBUka9NOg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8551 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This is a partial revert of commit c295f9831f1d ("net: mscc: ocelot: switch from {,un}set to {,un}assign for tag_8021q CPU ports"), because as it turns out, this isn't how tag_8021q CPU ports under a LAG are supposed to work. Under that scenario, all user ports are "assigned" to the single tag_8021q CPU port represented by the logical port corresponding to the bonding interface. So one CPU port in a LAG would have is_dsa_8021q_cpu set to true (the one whose physical port ID is equal to the logical port ID), and the other one to false. In turn, this makes 2 undesirable things happen: (1) PGID_CPU contains only the first physical CPU port, rather than both (2) only the first CPU port will be added to the private VLANs used by ocelot for VLAN-unaware bridging To make the driver behave in the same way for both bonded CPU ports, we need to bring back the old concept of setting up a port as a tag_8021q CPU port, and this is what deals with VLAN membership and PGID_CPU updating. But we also need the CPU port "assignment" (the user to CPU port affinity), and this is what updates the PGID_SRC forwarding rules. All DSA CPU ports are statically configured for tag_8021q mode when the tagging protocol is changed to ocelot-8021q. User ports are "assigned" to one CPU port or the other dynamically (this will be handled by a future change). Signed-off-by: Vladimir Oltean --- v1->v2: patch is new v2->v3: export the ocelot_port_teardown_dsa_8021q_cpu() symbol drivers/net/dsa/ocelot/felix.c | 6 +++ drivers/net/ethernet/mscc/ocelot.c | 64 +++++++++++++++--------------- include/soc/mscc/ocelot.h | 2 + 3 files changed, 40 insertions(+), 32 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index aadb0bd7c24f..ee19ed96f284 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -445,6 +445,9 @@ static int felix_tag_8021q_setup(struct dsa_switch *ds) if (err) return err; + dsa_switch_for_each_cpu_port(dp, ds) + ocelot_port_setup_dsa_8021q_cpu(ocelot, dp->index); + dsa_switch_for_each_user_port(dp, ds) ocelot_port_assign_dsa_8021q_cpu(ocelot, dp->index, dp->cpu_dp->index); @@ -493,6 +496,9 @@ static void felix_tag_8021q_teardown(struct dsa_switch *ds) dsa_switch_for_each_user_port(dp, ds) ocelot_port_unassign_dsa_8021q_cpu(ocelot, dp->index); + dsa_switch_for_each_cpu_port(dp, ds) + ocelot_port_teardown_dsa_8021q_cpu(ocelot, dp->index); + dsa_tag_8021q_unregister(ds); } diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index d4649e4ee0e7..8468f0d4aa88 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -2196,61 +2196,61 @@ static void ocelot_update_pgid_cpu(struct ocelot *ocelot) ocelot_write_rix(ocelot, pgid_cpu, ANA_PGID_PGID, PGID_CPU); } -void ocelot_port_assign_dsa_8021q_cpu(struct ocelot *ocelot, int port, - int cpu) +void ocelot_port_setup_dsa_8021q_cpu(struct ocelot *ocelot, int cpu) { struct ocelot_port *cpu_port = ocelot->ports[cpu]; u16 vid; mutex_lock(&ocelot->fwd_domain_lock); - ocelot->ports[port]->dsa_8021q_cpu = cpu_port; + cpu_port->is_dsa_8021q_cpu = true; - if (!cpu_port->is_dsa_8021q_cpu) { - cpu_port->is_dsa_8021q_cpu = true; + for (vid = OCELOT_RSV_VLAN_RANGE_START; vid < VLAN_N_VID; vid++) + ocelot_vlan_member_add(ocelot, cpu, vid, true); - for (vid = OCELOT_RSV_VLAN_RANGE_START; vid < VLAN_N_VID; vid++) - ocelot_vlan_member_add(ocelot, cpu, vid, true); - - ocelot_update_pgid_cpu(ocelot); - } - - ocelot_apply_bridge_fwd_mask(ocelot, true); + ocelot_update_pgid_cpu(ocelot); mutex_unlock(&ocelot->fwd_domain_lock); } -EXPORT_SYMBOL_GPL(ocelot_port_assign_dsa_8021q_cpu); +EXPORT_SYMBOL_GPL(ocelot_port_setup_dsa_8021q_cpu); -void ocelot_port_unassign_dsa_8021q_cpu(struct ocelot *ocelot, int port) +void ocelot_port_teardown_dsa_8021q_cpu(struct ocelot *ocelot, int cpu) { - struct ocelot_port *cpu_port = ocelot->ports[port]->dsa_8021q_cpu; - bool keep = false; + struct ocelot_port *cpu_port = ocelot->ports[cpu]; u16 vid; - int p; mutex_lock(&ocelot->fwd_domain_lock); - ocelot->ports[port]->dsa_8021q_cpu = NULL; + cpu_port->is_dsa_8021q_cpu = false; - for (p = 0; p < ocelot->num_phys_ports; p++) { - if (!ocelot->ports[p]) - continue; + for (vid = OCELOT_RSV_VLAN_RANGE_START; vid < VLAN_N_VID; vid++) + ocelot_vlan_member_del(ocelot, cpu_port->index, vid); - if (ocelot->ports[p]->dsa_8021q_cpu == cpu_port) { - keep = true; - break; - } - } + ocelot_update_pgid_cpu(ocelot); - if (!keep) { - cpu_port->is_dsa_8021q_cpu = false; + mutex_unlock(&ocelot->fwd_domain_lock); +} +EXPORT_SYMBOL_GPL(ocelot_port_teardown_dsa_8021q_cpu); - for (vid = OCELOT_RSV_VLAN_RANGE_START; vid < VLAN_N_VID; vid++) - ocelot_vlan_member_del(ocelot, cpu_port->index, vid); +void ocelot_port_assign_dsa_8021q_cpu(struct ocelot *ocelot, int port, + int cpu) +{ + struct ocelot_port *cpu_port = ocelot->ports[cpu]; - ocelot_update_pgid_cpu(ocelot); - } + mutex_lock(&ocelot->fwd_domain_lock); + ocelot->ports[port]->dsa_8021q_cpu = cpu_port; + ocelot_apply_bridge_fwd_mask(ocelot, true); + + mutex_unlock(&ocelot->fwd_domain_lock); +} +EXPORT_SYMBOL_GPL(ocelot_port_assign_dsa_8021q_cpu); + +void ocelot_port_unassign_dsa_8021q_cpu(struct ocelot *ocelot, int port) +{ + mutex_lock(&ocelot->fwd_domain_lock); + + ocelot->ports[port]->dsa_8021q_cpu = NULL; ocelot_apply_bridge_fwd_mask(ocelot, true); mutex_unlock(&ocelot->fwd_domain_lock); diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index ac151ecc7f19..4c8818576437 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -875,6 +875,8 @@ void ocelot_deinit(struct ocelot *ocelot); void ocelot_init_port(struct ocelot *ocelot, int port); void ocelot_deinit_port(struct ocelot *ocelot, int port); +void ocelot_port_setup_dsa_8021q_cpu(struct ocelot *ocelot, int cpu); +void ocelot_port_teardown_dsa_8021q_cpu(struct ocelot *ocelot, int cpu); void ocelot_port_assign_dsa_8021q_cpu(struct ocelot *ocelot, int port, int cpu); void ocelot_port_unassign_dsa_8021q_cpu(struct ocelot *ocelot, int port); u32 ocelot_port_assigned_dsa_8021q_cpu_mask(struct ocelot *ocelot, int port); From patchwork Fri Aug 19 17:48:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12949057 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85DB3C28B2B for ; Fri, 19 Aug 2022 18:03:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350168AbiHSSDM (ORCPT ); Fri, 19 Aug 2022 14:03:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350324AbiHSSC0 (ORCPT ); Fri, 19 Aug 2022 14:02:26 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80059.outbound.protection.outlook.com [40.107.8.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D707A346F for ; Fri, 19 Aug 2022 10:49:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OA+vwkP35wcJllP1BbPkMfMH1U8jiJXAlyfd2ayc4aTDspK4f+kK/h/iPQYLlOCo0lx0rBIOgo0JgfQtW2BsvuPD7YiF7Vt1LxPE/Pb4hzZnlzPzkLnEXbuVgaoWLtEy7bqJkUAViaDDJ5iHanmVZV7uz5Pb6afFafWh58sy7YFI+6Vol+9cLFEnMKKsmmld2qDmriXPXiNi1w4dqAiIuCvn2QiH1OuIW806yoPE5XISRWFyj5qKUOfBLhsXlbsC0o9/pIDiphoCxgBeYbbS2cbyx2hYa6+0fvdmCNEtHdQeKG0CaQcDLPTSeTDGXPAZjP3rdZlX6na6DE5ZO7WrYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sJ9Iwy9XnaLcbayLGnYCeLzzozX1Ij2tnOHj5x7Xa8s=; b=eUwE6bBeU83CBz91tY1djAH0w+7dnTOtJLY4bSK5IgUuZJHb472EvA2RNaRKk0Xgc45UTNIu694TkS+OgMWAbTD4wG8zDRlw7vYK4pqmPtQeSBvZz7+8AWWCvvsf/V3SyvUz7JlggdR8OpXjA4Td5q2QpCbKJNwCX9101KinSHc+kCcSObVUMGziRX0Lmb2uQzXH1KSozQVL1lW9y2clTjd2Y37GJliW1nFayps4rToOa39tvrUn2uipZApiyH421qPfLkbS4c5t+Rik0kf4hvrcKJgB9Eo6zITNdr/94VyOwtJ2XDkFaCFbbKaB3UcL0lboIo1m+T+WuAM2o4ABfg== 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=sJ9Iwy9XnaLcbayLGnYCeLzzozX1Ij2tnOHj5x7Xa8s=; b=VIBPbLZuelbyKjXZLN4NHdMuzx3Hg8qGpbxBTbKb7rnA8zU2ZAVfmyZe0bx3TEw0WqadAOCPEsR+JWaoJ712BSU8P0yzWoXVMfWaunTbZZsQD/PYLF9FhrC2z2e4dExj2BUOmSE9olXG/lL2IytiH09Q71ee+ezbFP/oAugSi6s= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DU2PR04MB8551.eurprd04.prod.outlook.com (2603:10a6:10:2d6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.18; Fri, 19 Aug 2022 17:48:42 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857%4]) with mapi id 15.20.5546.016; Fri, 19 Aug 2022 17:48:42 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Fainelli , Vivien Didelot , Andrew Lunn , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Colin Foster , Roopa Prabhu , Nikolay Aleksandrov Subject: [PATCH v3 net-next 9/9] net: mscc: ocelot: adjust forwarding domain for CPU ports in a LAG Date: Fri, 19 Aug 2022 20:48:20 +0300 Message-Id: <20220819174820.3585002-10-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220819174820.3585002-1-vladimir.oltean@nxp.com> References: <20220819174820.3585002-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM4PR0501CA0044.eurprd05.prod.outlook.com (2603:10a6:200:68::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 060a7bea-7212-4078-968d-08da820b0e6d X-MS-TrafficTypeDiagnostic: DU2PR04MB8551:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wtU8+gyk/J/AtjqHOYRB1dGCMyhA1/8ANvHa2rSpAkBOKQHwp2rxffzimTpOs6wuq9Y3qmVR7p+RKAdgf6bwj3vEnLM0lUk4CC4Jtb/6OOW1g7ojHtEQhG66GguaKKqN9ExHtItKSRFvDlFu3SRdGJ/DZz8npcy+R1sYOVI631zbtZ9eOGrCNbVnEMOJN6uPrTVnHHtnm80Snd+iau2oy/jSX/vpYUwQZ8+DtOpSrByPJhHWCdaDI+0+jTXeN4JCUvKKyCEE2w8x+ieNUAgxylUa1bTnebDP2V9yuzyEMXt+TsdMVJW48Hy65DHdDIXZTVWfVAGM79EGMQ3Yk9OGTHL2OOm6kd5iLV8kqGSqajlZUXlmQU6U7Ls2CFQqJjdSaSfzZghaDdRCR0ZddL2VnfGlvoBVgNmilNhC0BfxYt0ecXaDSB6HE9YOnjyqshlPwgNn2UGKFYss6XCPpVwDEuyImWpbUSGOxCKVkFTVLoXdcQHi+/+SLVDHCdijKGxENQvCJtqom+2d2Yiuxj1nvfMdvQad8C8i08CcKnKjmAR5YneYmqMFuiGtMUnVnB2mdkEz7TfkjS33P4KFlNXXBf7VxU0oBkxKvEklQmT2tW0cguLWlifBx3F640K3xYnr28z7QiTk8BgO8m2qu3Refdm4bTZdZ1/C/Y1yStamva4wdZ5cKTCaJyyc7XYkQpux3YlmiY1OEdo02hxSAnea5idblMFJVhPJO32NvRkKXjWRD2HVlKjdQauhpJifauhjby4jEaq+QZscVnvvrMprlA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(376002)(396003)(346002)(39860400002)(366004)(66556008)(8676002)(4326008)(7416002)(44832011)(66946007)(66476007)(316002)(6916009)(54906003)(5660300002)(36756003)(8936002)(2906002)(478600001)(6486002)(41300700001)(6506007)(6666004)(26005)(52116002)(6512007)(2616005)(86362001)(83380400001)(1076003)(38350700002)(38100700002)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-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w1Z1dYJ2dVsrM0VE4oJB58oGA4bbLNCZkajbRQAgRnhLxXxM4QzaRKWLSbNpZ4hnUrxiCgo6vAlnbPRbRIhtx8sFa+rdxb6VDmqc8hbyZ4aLwLy9VqJuXJ4erJW41w/UZ9K4Q+41HsJnwiCNOacLpdAgfErYAVKJHwyxuFw4e95aG6L992LUP8TJq62cbHS/Fa/E+bmsXJmaBWaJaHd2P2EZgGVHZ2nNvgtum+njMohjQDy5TsnQ2Y1i00hbDybC3qEx8U0dZv3nzmVZOQvGIhMJ7QUPFZgowtZ2c9LktHozc2P60zJYwLHnXgJK0B7MeP9XoKVd6dFHksHQ7kK//ma6M8+uGbnIgep0zCBbZgOZt83PTM1PMuCWbIUi3wzwwNqBqDFktoS2OUC1Q8FQo4wgovTkBrxYz6neNTl079kIzulIdx/k7rWPy43ioHFrhyj6DJgm0XbjE+tKPC3tpPw2XDNMgU+3rGIFR5XNTuIgyO0VqiTAVlyWiImHztMv6z4FzrBXozBYolIp/4WN2IN9wSaekKtIfpunuQf8bKJTvPga56MDJyl5E9cJClXNNEgCiaZUJhJg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 060a7bea-7212-4078-968d-08da820b0e6d X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Aug 2022 17:48:42.6066 (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: q5WJ1wLJnW7cwZdMDbNnXHx281F+SpSeKgWa3MF856K3ZShPwwo9YoYJWvBLzfrcX1y89xb7OeUqktLoqAT/hg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8551 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Currently when we have 2 CPU ports configured for DSA tag_8021q mode and we put them in a LAG, a PGID dump looks like this: PGID_SRC[0] = ports 4, PGID_SRC[1] = ports 4, PGID_SRC[2] = ports 4, PGID_SRC[3] = ports 4, PGID_SRC[4] = ports 0, 1, 2, 3, 4, 5, PGID_SRC[5] = no ports (ports 0-3 are user ports, ports 4 and 5 are CPU ports) There are 2 problems with the configuration above: - user ports should enable forwarding towards both CPU ports, not just 4, and the aggregation PGIDs should prune one CPU port or the other from the destination port mask, based on a hash computed from packet headers. - CPU ports should not be allowed to forward towards themselves and also not towards other ports in the same LAG as themselves The first problem requires fixing up the PGID_SRC of user ports, when ocelot_port_assigned_dsa_8021q_cpu_mask() is called. We need to say that when a user port is assigned to a tag_8021q CPU port and that port is in a LAG, it should forward towards all ports in that LAG. The second problem requires fixing up the PGID_SRC of port 4, to remove ports 4 and 5 (in a LAG) from the allowed destinations. After this change, the PGID source masks look as follows: PGID_SRC[0] = ports 4, 5, PGID_SRC[1] = ports 4, 5, PGID_SRC[2] = ports 4, 5, PGID_SRC[3] = ports 4, 5, PGID_SRC[4] = ports 0, 1, 2, 3, PGID_SRC[5] = no ports Note that PGID_SRC[5] still looks weird (it should say "0, 1, 2, 3" just like PGID_SRC[4] does), but I've tested forwarding through this CPU port and it doesn't seem like anything is affected (it appears that PGID_SRC[4] is being looked up on forwarding from the CPU, since both ports 4 and 5 have logical port ID 4). The reason why it looks weird is because we've never called ocelot_port_assign_dsa_8021q_cpu() for any user port towards port 5 (all user ports are assigned to port 4 which is in a LAG with 5). Since things aren't broken, I'm willing to leave it like that for now and just document the oddity. Signed-off-by: Vladimir Oltean --- v1->v3: patch is new drivers/net/ethernet/mscc/ocelot.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 8468f0d4aa88..efb6eca24c7b 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -2046,6 +2046,16 @@ static int ocelot_bond_get_id(struct ocelot *ocelot, struct net_device *bond) return __ffs(bond_mask); } +/* Returns the mask of user ports assigned to this DSA tag_8021q CPU port. + * Note that when CPU ports are in a LAG, the user ports are assigned to the + * 'primary' CPU port, the one whose physical port number gives the logical + * port number of the LAG. + * + * We leave PGID_SRC poorly configured for the 'secondary' CPU port in the LAG + * (to which no user port is assigned), but it appears that forwarding from + * this secondary CPU port looks at the PGID_SRC associated with the logical + * port ID that it's assigned to, which *is* configured properly. + */ static u32 ocelot_dsa_8021q_cpu_assigned_ports(struct ocelot *ocelot, struct ocelot_port *cpu) { @@ -2062,9 +2072,15 @@ static u32 ocelot_dsa_8021q_cpu_assigned_ports(struct ocelot *ocelot, mask |= BIT(port); } + if (cpu->bond) + mask &= ~ocelot_get_bond_mask(ocelot, cpu->bond); + return mask; } +/* Returns the DSA tag_8021q CPU port that the given port is assigned to, + * or the bit mask of CPU ports if said CPU port is in a LAG. + */ u32 ocelot_port_assigned_dsa_8021q_cpu_mask(struct ocelot *ocelot, int port) { struct ocelot_port *ocelot_port = ocelot->ports[port]; @@ -2073,6 +2089,9 @@ u32 ocelot_port_assigned_dsa_8021q_cpu_mask(struct ocelot *ocelot, int port) if (!cpu_port) return 0; + if (cpu_port->bond) + return ocelot_get_bond_mask(ocelot, cpu_port->bond); + return BIT(cpu_port->index); } EXPORT_SYMBOL_GPL(ocelot_port_assigned_dsa_8021q_cpu_mask);