From patchwork Wed Aug 18 12:01:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 499564 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16921C4338F for ; Wed, 18 Aug 2021 12:03:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EB40A6108B for ; Wed, 18 Aug 2021 12:03:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235845AbhHRMDs (ORCPT ); Wed, 18 Aug 2021 08:03:48 -0400 Received: from mail-eopbgr00067.outbound.protection.outlook.com ([40.107.0.67]:52143 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233833AbhHRMDb (ORCPT ); Wed, 18 Aug 2021 08:03:31 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ti+LMbXDC4YESf8LrmVObVmjE9/+I0oEddS4mEz8n8sImSl7Oy/ma69rxV8tN8nWZKAh+zMlh0f3Ff2rqxDBGjead1dqyc5ugojUvP3M+86EMmw9MLjaGehrVZ08DHJGAVMbJnysN5Uo9nQ4eD/4qsIl05Y7n5JoqHVxsIsfgwSZ7eTVnXPRa8EInZCNWHoPk61g9As+Ce2N7rM5TsB6cRnnM4mfeMnSvq5rW2K6kZKliiQWDakHjQOOwUq+wnEaYXU1N/oLloxjkkNWdbNEMhRYUqhBdexU0XqymltAOm4Mt9uTEJimt6VfYDawcXUkF2VpKNtFd+tisdIS2Z5RAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AchM5qEWGpob9zgSD03vrGypRQHFtJDK1++b6gW7VP8=; b=hBlY0T8J3cykEhIV/lzLn8c3RgRaZAo2Z+MTqCrpYW4RmAyc2Aw+MGyn+TAd+ZJNKHVdfEVhrRUXZBYm1TfRY+bnNCPKqryZpygVBV7kGvj4qbMcu8ZLygi0PaIrHdKExcWj01nLjfoTdc3Q9TJnq7muU3/ZeiZZm3A3HK8g5S48OHo/BgweOhEK4kOMnYsY073OmAOwl5YFBP7jfJ5l1oLoa5BlcvlFrjC3kcKSzGLFsJJmNCFlkcwB8EIvn+EX0JI1E8+W2jlHafhEKcUVOzFm7E5xELa5f+FB7DJZpWRcKafpvF/hXSUKd439KaR/cwzMfk0uv9dTaGst2qCYbg== 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=AchM5qEWGpob9zgSD03vrGypRQHFtJDK1++b6gW7VP8=; b=BvFjPE+ff7QgzaiXPzpRLcxaPpSjxff7FaJI43+RhJRFkdLl7xjEG3vb4k7e4kHOIpN9OHOFSIq8C94QPUBvXS4TuJhKcHIzp/C37FyWwwEk4g4MzI/fza5UtniWFMCr3bm13XxsH8SlIJLY/23ju3VqEVySxOs5ElXhyBnoRKg= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB3839.eurprd04.prod.outlook.com (2603:10a6:803:21::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17; Wed, 18 Aug 2021 12:02:52 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4415.024; Wed, 18 Aug 2021 12:02:51 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Roopa Prabhu , Nikolay Aleksandrov , Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean , Vadym Kochan , Taras Chornyi , Jiri Pirko , Ido Schimmel , UNGLinuxDriver@microchip.com, Grygorii Strashko , Marek Behun , DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Claudiu Manoil , Alexandre Belloni , George McCollister , Ioana Ciornei , Saeed Mahameed , Leon Romanovsky , Lars Povlsen , Steen Hegelund , Julian Wiedmann , Karsten Graul , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Ivan Vecera , Vlad Buslov , Jianbo Liu , Mark Bloch , Roi Dayan , Tobias Waldekranz , Vignesh Raghavendra , Jesse Brandeburg , Peter Ujfalusi Subject: [RFC PATCH net-next 01/20] net: dsa: track unique bridge numbers across all DSA switch trees Date: Wed, 18 Aug 2021 15:01:31 +0300 Message-Id: <20210818120150.892647-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818120150.892647-1-vladimir.oltean@nxp.com> References: <20210818120150.892647-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 18 Aug 2021 12:02:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d8688ba6-08e9-436f-d370-08d962401a8d X-MS-TrafficTypeDiagnostic: VI1PR0402MB3839: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fcxLvl0Oxqvx2YFDmqtwo30ZKRxRjYpZSTZ1ltc7Te2M5/a/LIm+GSM23adgRIsz/IXEB8d9eQq4EhlRSMuzYgObqd8IVV9DULwFPWJ3osSRbOBCmmTRFFmDbliCLmOArIBkOs9n73q3AgOjmxSFRdLr2L8OERff9Psx4gq6nD0cu8WfeiYp/lJrg+aA048ujERSZE3vrL/mNWHo+epAc9y7LZXqQjMOvH0qqczmD1+LKnle/HNuJFE73LRmdAxtuVOEhpfMYcHQo00+RFYnjyOBbOnyc5FkX9yypPz+YBQqHKYWtueL2JDEFpIrNA6VlX0ytwxPALDUhH3dIH8ehWonu3fLde5efyvtCaPo+g6Txab8FbXP8oiaxf72JbUccwQv0hTHo1doFs7QHyFq3bEzcbP9Cp3i9DrvFynJO1pB9sC7TuzqC2WHDoYbZXzvC7tVSinfWU+IJqMbhRVweZCpJvEdKmkDokHmwvDGVMZmKi1vGej7rPUl+wsGBnTig2Je49SLr7zc4SCweAJfN+5xTGxPMMzvlxFGxb/f5G3BWWAq+qfKOoLCZ2ey0HM1nwMLhM4Jx7Veyr4UQa34xNUsAmHBP6H0Ph2mXjnfypNVhOkuqO5GfOACT5cWs1pUTV7intcnhObmcAOYo9igaw6yjOYyrjb1vSGM4oGEJ2aMZ+IJR4d3/whrqGeBxDeJPzPYu32xEsofwcurr9eXLg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(346002)(136003)(39840400004)(366004)(376002)(66476007)(2906002)(66556008)(8936002)(6506007)(186003)(7406005)(7416002)(52116002)(26005)(86362001)(66946007)(6486002)(44832011)(36756003)(5660300002)(1076003)(110136005)(54906003)(6512007)(8676002)(316002)(6666004)(38350700002)(38100700002)(956004)(478600001)(83380400001)(2616005)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OvH3aC7SzufJYmHZ8DVTiMUFaOtlDgNjKI3M9UOQe0QFhaLC91wTDM7DVW4/pDCKpDZjgOkwWBGHhV/DspOGEMRDlH5RkDBCILJU1+rqvQY0f00gK/Yz2dEO4j8y/oqxuN5Z4V3jVbxbCUX4luw5oYvON43Jc9jVUFKzZIWKrk8zgHZPRpP/oaYHm6zldbI9820OxQtIT+QyYUxICAMd6RdgNZ5h679XtUr0beA3l3rp4qvjnw4VE817mQiy7bibN1ajB6i7saL7pO3qd4o+Ntof1UopjmrkV1kGgFrJ2WNtg8PjGrRD2nUkgw6hEp/mQEwvEZsBqFRGBTIh5G3ck4uKm5QICOzy80wjlnSjlS60l4GZu17AB6apWN3zuruQnP6f6XxNhktzMPQJtzq52IQyxuV3KreQiGbBuJoelza4IfIPKN++dfRry5SNfveQGtGXgG9mZfa/iGU7ybQ73W4RNY1QlvLq7fkcF4G5wSV3ipG6OdMPDi/whL8iKgMr3OCJ4tHzCSfxhSvhJ6iOkmESsQVGd/r0bx/CIZkUx3S6FeiM1vGch8TBqS7DTNZswB81u3t5SxcWOmzxRdCF8EP6Lwe4iQVIoxVejJiWACevJ2y+sHWiQINyih78b1F7ZDQ+HnOdmk1/QxXHsR/eUuPDrdaNPi7hn8FR5WhtKTJmgFskj0UClQwsQ9bTR6n3skg19Exej+rdAQlhMkaoTogIeAk6XCrr4jqKYfsO4K/llq7ZK5vfKDrPn6OMdy/6eJCB4CZ5JbSrycB7HShmHARDshbWSY+JtjQ8T7cV0xkT/rzsLMeKs2B1FQLstVmza7wIlEfeTCl+4UVXTrYYXfJYOVqdX+eqQnL2PN+QAtiMdnlxEpOe/TgP96YQEfLUVhK5RskvM+uOjgKqzfs3s4btNOkv88VftwjxhURLNmaJKdMo9oKwkoh/wutCyrSrjnNrmB2yPHo4COYLO+8DDlqr8U9SMmDWppoxCK3IHlDhoqQ8rpO18sw0NFwFSuiM5jm9G/5B35j2lNrOOfc/RkDLV44gQHjfcVw1ZxFt46M09nHWzyeGS2AzuJg0+4wNp52t4YMCMzTdY0JTLIMVINXrIpXubx/XVaSOxwSuLwiaIIKi9w4HCY3+evzJt+ITwhaiN2eRTH2NKB2qIsAeA0VzjMXubtXHQUO7yZljhR638jvuKJX9xU2EcBsk7yXf8k1xhutzRMlsvr79sREK4PnbfDUt65P1GhEghwEy5mQ678rabfogg3E77m0rT+ZzaBS6ctVFwK+AO3su47qNrRZp+hbfEUiPg8TlaS0/BpM8mfoGG7bj6gsO1m3htIxf X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d8688ba6-08e9-436f-d370-08d962401a8d X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2021 12:02:51.5515 (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: zvH0sSG/32hL9R+bVhhIfJrS+1Mw3qxhSlwkkxEtfEUHMnCPDGGxFx1jSD4WaRQLocsw988xUg4oCoZm8UF1jA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3839 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Right now, cross-tree bridging setups work somewhat by mistake. In the case of cross-tree bridging with sja1105, all switch instances need to agree upon a common VLAN ID for forwarding a packet that belongs to a certain bridging domain. With TX forwarding offload, the VLAN ID is the bridge VLAN for VLAN-aware bridging, and the tag_8021q TX forwarding offload VID (a VLAN which has non-zero VBID bits) for VLAN-unaware bridging. The VBID for VLAN-unaware bridging is derived from the dp->bridge_num value calculated by DSA independently for each switch tree. If ports from one tree join one bridge, and ports from another tree join another bridge, DSA will assign them the same bridge_num, even though the bridges are different. If cross-tree bridging is supported, this is an issue. Modify DSA to calculate the bridge_num globally across all switch trees. This has the implication for a driver that the dp->bridge_num value that DSA will assign to its ports might not be contiguous, if there are boards with multiple DSA drivers instantiated. Additionally, all bridge_num values eat up towards each switch's ds->num_fwd_offloading_bridges maximum, which is potentially unfortunate, and can be seen as a limitation introduced by this patch. However, that is the lesser evil for now. Signed-off-by: Vladimir Oltean --- include/net/dsa.h | 8 +++----- net/dsa/dsa2.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++ net/dsa/dsa_priv.h | 2 ++ net/dsa/port.c | 39 +++++-------------------------------- 4 files changed, 58 insertions(+), 39 deletions(-) diff --git a/include/net/dsa.h b/include/net/dsa.h index 0c2cba45fa79..c7ea0f61056f 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -155,9 +155,6 @@ struct dsa_switch_tree { /* Track the largest switch index within a tree */ unsigned int last_switch; - - /* Track the bridges with forwarding offload enabled */ - unsigned long fwd_offloading_bridges; }; #define dsa_lags_foreach_id(_id, _dst) \ @@ -411,8 +408,9 @@ struct dsa_switch { unsigned int num_lag_ids; /* Drivers that support bridge forwarding offload should set this to - * the maximum number of bridges spanning the same switch tree that can - * be offloaded. + * the maximum number of bridges spanning the same switch tree (or all + * trees, in the case of cross-tree bridging support) that can be + * offloaded. */ unsigned int num_fwd_offloading_bridges; diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index dcd67801eca4..1b2b25d7bd02 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -21,6 +21,9 @@ static DEFINE_MUTEX(dsa2_mutex); LIST_HEAD(dsa_tree_list); +/* Track the bridges with forwarding offload enabled */ +static unsigned long dsa_fwd_offloading_bridges; + /** * dsa_tree_notify - Execute code for all switches in a DSA switch tree. * @dst: collection of struct dsa_switch devices to notify. @@ -126,6 +129,51 @@ void dsa_lag_unmap(struct dsa_switch_tree *dst, struct net_device *lag) } } +static int dsa_bridge_num_find(const struct net_device *bridge_dev) +{ + struct dsa_switch_tree *dst; + struct dsa_port *dp; + + /* When preparing the offload for a port, it will have a valid + * dp->bridge_dev pointer but a not yet valid dp->bridge_num. + * However there might be other ports having the same dp->bridge_dev + * and a valid dp->bridge_num, so just ignore this port. + */ + list_for_each_entry(dst, &dsa_tree_list, list) + list_for_each_entry(dp, &dst->ports, list) + if (dp->bridge_dev == bridge_dev && + dp->bridge_num != -1) + return dp->bridge_num; + + return -1; +} + +int dsa_bridge_num_get(const struct net_device *bridge_dev, int max) +{ + int bridge_num = dsa_bridge_num_find(bridge_dev); + + if (bridge_num < 0) { + /* First port that offloads TX forwarding for this bridge */ + bridge_num = find_first_zero_bit(&dsa_fwd_offloading_bridges, + DSA_MAX_NUM_OFFLOADING_BRIDGES); + if (bridge_num >= max) + return -1; + + set_bit(bridge_num, &dsa_fwd_offloading_bridges); + } + + return bridge_num; +} + +void dsa_bridge_num_put(const struct net_device *bridge_dev, int bridge_num) +{ + /* Check if the bridge is still in use, otherwise it is time + * to clean it up so we can reuse this bridge_num later. + */ + if (!dsa_bridge_num_find(bridge_dev)) + clear_bit(bridge_num, &dsa_fwd_offloading_bridges); +} + struct dsa_switch *dsa_switch_find(int tree_index, int sw_index) { struct dsa_switch_tree *dst; diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index b7a269e0513f..88aaf43b2da4 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h @@ -543,6 +543,8 @@ 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); +int dsa_bridge_num_get(const struct net_device *bridge_dev, int max); +void dsa_bridge_num_put(const struct net_device *bridge_dev, int bridge_num); /* tag_8021q.c */ int dsa_tag_8021q_bridge_join(struct dsa_switch *ds, diff --git a/net/dsa/port.c b/net/dsa/port.c index 979042a64d1a..4fbe81ffb1ce 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -270,27 +270,9 @@ static void dsa_port_switchdev_unsync_attrs(struct dsa_port *dp) */ } -static int dsa_tree_find_bridge_num(struct dsa_switch_tree *dst, - struct net_device *bridge_dev) -{ - struct dsa_port *dp; - - /* When preparing the offload for a port, it will have a valid - * dp->bridge_dev pointer but a not yet valid dp->bridge_num. - * However there might be other ports having the same dp->bridge_dev - * and a valid dp->bridge_num, so just ignore this port. - */ - list_for_each_entry(dp, &dst->ports, list) - if (dp->bridge_dev == bridge_dev && dp->bridge_num != -1) - return dp->bridge_num; - - return -1; -} - static void dsa_port_bridge_tx_fwd_unoffload(struct dsa_port *dp, struct net_device *bridge_dev) { - struct dsa_switch_tree *dst = dp->ds->dst; int bridge_num = dp->bridge_num; struct dsa_switch *ds = dp->ds; @@ -300,11 +282,7 @@ static void dsa_port_bridge_tx_fwd_unoffload(struct dsa_port *dp, dp->bridge_num = -1; - /* Check if the bridge is still in use, otherwise it is time - * to clean it up so we can reuse this bridge_num later. - */ - if (!dsa_tree_find_bridge_num(dst, bridge_dev)) - clear_bit(bridge_num, &dst->fwd_offloading_bridges); + dsa_bridge_num_put(bridge_dev, bridge_num); /* Notify the chips only once the offload has been deactivated, so * that they can update their configuration accordingly. @@ -316,23 +294,16 @@ static void dsa_port_bridge_tx_fwd_unoffload(struct dsa_port *dp, static bool dsa_port_bridge_tx_fwd_offload(struct dsa_port *dp, struct net_device *bridge_dev) { - struct dsa_switch_tree *dst = dp->ds->dst; struct dsa_switch *ds = dp->ds; int bridge_num, err; if (!ds->ops->port_bridge_tx_fwd_offload) return false; - bridge_num = dsa_tree_find_bridge_num(dst, bridge_dev); - if (bridge_num < 0) { - /* First port that offloads TX forwarding for this bridge */ - bridge_num = find_first_zero_bit(&dst->fwd_offloading_bridges, - DSA_MAX_NUM_OFFLOADING_BRIDGES); - if (bridge_num >= ds->num_fwd_offloading_bridges) - return false; - - set_bit(bridge_num, &dst->fwd_offloading_bridges); - } + bridge_num = dsa_bridge_num_get(bridge_dev, + ds->num_fwd_offloading_bridges); + if (bridge_num < 0) + return false; dp->bridge_num = bridge_num; From patchwork Wed Aug 18 12:01:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 500295 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FF75C4338F for ; Wed, 18 Aug 2021 12:03:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6A41D60EBC for ; Wed, 18 Aug 2021 12:03:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236025AbhHRMEI (ORCPT ); Wed, 18 Aug 2021 08:04:08 -0400 Received: from mail-eopbgr00079.outbound.protection.outlook.com ([40.107.0.79]:39586 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235777AbhHRMDo (ORCPT ); Wed, 18 Aug 2021 08:03:44 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Dsv5FQ+98jAjm1ktTocAIrxFX4gcRBYfi+DQurP9G+aQpqgkJ89w39XLvFz4y50Cs+Te0v6mWRhU424rZBU5vywGfXZxl/slXW4pypAoYCDyUUrhZcxarLsfKYlH4riRCiInoLqA9kT4RXAua3iSt3AU+EErCSp2sMj4lLkJZTLZo+wVe8nDisRyD8OHs8WMuc9lJ+L0WMThaqWlYZQ3edu5au2icFnUJbCOhu0/mU9LXzHpZR3wru/rPVGYkXRGUxwOMItjWPSo2NNwqtehv33/TSBCvQFuqvr+FYT1G+VMvXGumTjRpfAudfpaVG/LSDQh8jSG16+D5//D7q464A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=q2C0LH09hsXzxGRxuaytrvCmbbtpof6I8gmWjDQZVuE=; b=fSTPIzWtnxVvIqS9yfcGCbqTRTLVTeinFY5HPMra/4EtLkEejK1C6wZbhfwBSEV5IuMSkmANCN/vIzc6B0CP3/QW07Slz4TAJ9EWrEvDqBjoF0tBmgdbIsbBreTBQ4BjYDEbTYzEZ0VXv6HlvoJvUeSuuUbkq6K+rHxU/TJS0Ge8rJ0mxiSTmlCKcPXcuF45AAP9IakDUKK1eqXaHgw/m89jYO8mAHjCCDg9AsMIMCrnnr4ddPTamaRTRLdeWAMR9INYPQhG/aIb2c2kneXgdw4/sqsgwdACKCklTsAFcJLlY4rm5XCIesovb3JOR9JqhmSiUhewaibRsEqYs6QlUQ== 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=q2C0LH09hsXzxGRxuaytrvCmbbtpof6I8gmWjDQZVuE=; b=fjdu9UktEzktXoPs0vDN9onwuetT1Y6SlWUtMGBaK+23hYmOqXFZwjf0ZGtsK3T/KnkF9tpTsYyK6H63B8sU+TIAUCJM4TBNfw72nW4RcyDjVbbNpaMlR+KZbU2UlYoA/UrDjxDqy9YF7CGvxVCbBA2lWsLFpHnsk2n9UlsqXHI= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB3839.eurprd04.prod.outlook.com (2603:10a6:803:21::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17; Wed, 18 Aug 2021 12:02:53 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4415.024; Wed, 18 Aug 2021 12:02:53 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Roopa Prabhu , Nikolay Aleksandrov , Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean , Vadym Kochan , Taras Chornyi , Jiri Pirko , Ido Schimmel , UNGLinuxDriver@microchip.com, Grygorii Strashko , Marek Behun , DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Claudiu Manoil , Alexandre Belloni , George McCollister , Ioana Ciornei , Saeed Mahameed , Leon Romanovsky , Lars Povlsen , Steen Hegelund , Julian Wiedmann , Karsten Graul , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Ivan Vecera , Vlad Buslov , Jianbo Liu , Mark Bloch , Roi Dayan , Tobias Waldekranz , Vignesh Raghavendra , Jesse Brandeburg , Peter Ujfalusi Subject: [RFC PATCH net-next 02/20] net: dsa: assign a bridge number even without TX forwarding offload Date: Wed, 18 Aug 2021 15:01:32 +0300 Message-Id: <20210818120150.892647-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818120150.892647-1-vladimir.oltean@nxp.com> References: <20210818120150.892647-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 18 Aug 2021 12:02:51 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dc12eadb-e423-4bcc-1a8d-08d962401b74 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3839: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iIq4AwQqu8bpZP0cT/UXaqL5DkuvoRncO4SRqDcBSE/cqeRtynpcBtQPkHb//vsSCNBy0ZnNiTVtcZ6v5EwXgpppPalsi4b47maAcZOShxdQBh7zMCPIUnySL/KcXrN3vOZLBEvVp1QezknhWtjF/EELYgt0yII0fNA1ioYucvmQul1GvFpjanbr/3t4SDoqP8N53NfnOQqwpyShkiZqbi6fDwnKXRu6w5lRKfHdVG8702cxEhazmC9kQ1heKHq6NOOlkpxW/NH/x4/jU0t3xGUK3MgjrXAd8KJPq1MLFcTdHbdZS4mJNgoXxKVMlpJ8do3n44JOtpTJmjDLjlSDzOvS0dYE2XgqS+MViiOXPSEyC6JDukFqpkUOZDM5An5GFQKumEYxDUjn5dNkljNCNWfZp0AiAgnj/MdP1b0ekBNjJQGSvq3M411Dl0GPI7J5+U8xFZAGBOUlze3xv0TBDiNqTR8c3d4RNz5YoXssYYn1cLC9jbWTGLDmiVq0bVE4bxQTZyiiLSbD31CW9YzrqP6LW5CZUA0HPM7D1FK124aSmKsVKS68E+3Fb288kb/Kac+FWUWx5AkOvDPtQpTOys/CdrRtCNHHqTK7726GyQp3D5/4KOOMpqPPupp3VaiGKVU6+MLG02UVijqV1MjMOsMO2ShD9+gzq0hQTQGX17XeXIu7b5bb2YvGexXI1wTx3NqM3g83aQCgqQsfR3UiJQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(346002)(136003)(39840400004)(366004)(376002)(66476007)(2906002)(66556008)(8936002)(6506007)(186003)(7406005)(7416002)(52116002)(26005)(86362001)(66946007)(6486002)(44832011)(36756003)(5660300002)(1076003)(110136005)(54906003)(6512007)(8676002)(316002)(6666004)(38350700002)(38100700002)(956004)(478600001)(83380400001)(2616005)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: az1i81GXDQ/ebqA9zmXQnkcfYCtE2we7kJBqn4MfTDOnegdXzvROujBbNydvjFniNmtTibPhaq8gbcTsOlRkiYwKqu4Vz0HAEe7gFgJ2VENV25jEUd+m/IiYxvyNjV3ozq8YtDAzm+BhjGtFSsLk126JZxTBeqXUCv/E6F2I+Tl3VtGTW56cHVHpHfJ0QIUFKVuOawUIDDxtD9SDe1LYpJ+kPN1gIibC6j0RjXTo+Eh49T13ZUBAF85HuH3u4vxb72j0OfmhrvNiUouliXNbyLlU/jOuFwCWa5g4WVjztoEMq2LMeGW++rnlhSTk5oK6MhegvGtNWP5A//f/mxaoMSCulm94Rc3128xt+kYWErA1lYtf0Rz8zbdoh58CPHeNrKgwtjqKM2ePDNSQkctxokGpcjoDCl9yotlHd/zWnK5O6u0gZCbHwwbFy0RMgpSaNGB1jqqKfiyL0uM10AQkgYeJRq4j7MBp51y7+KTV3j+oSVhXZMlKRh+evLKfP4fUap7N4iaqS5ETTW5M1uMGa55qyEDrXLmLI+FCCdEhcCPaS0RjOn1SPQP7NTvi1r9cOKWTOO7ldw29Y6zDojM+HyLGDdiG1FKSDoOanyfibLNF+MQjUtPe7CtG3NV4gt9aQirFqbXoe8fVrHLNR+co0sZM2vFGLfKyFdRGxd+gpDgXLxHj2jXOO4su9woAWfezke60Z2OZYsc+YEho7nCdqqO8aD6O8VVBQEW7TjvPUl9WBgDAS4k0e0JYIl/jOg0FWu7EUncO/o2yN/Tq0npPnUOnzVji1GO6UmDi7psvdTFmtBERieI5Hkjh6xXdc8SwuTn+ERUWoJ0damWiwFF+kgwhlUbX8QTHtSptYsY31yc86l9myjz3vjWrAlXmSYcwUqD8E6voFue513lGHuAg7vsHDzOz/uE7p+2K7QHZrAfB+8O61CcB2eqLeS+cE3Id6oHVcE6kBC4YGbfjdQpwQBqpErrtKw0lFZJKJaoRNzcFPBLTjjaxRJ3DhS0+1+unjRHag5QhKNUhxBIYYzogDhQFo93wCN2ZDR+J4YOkh4oHc/hR6ELvzIYwMRMl7DViULf46dG7iVejZNJXtTYy3HBvMdhEjltshf/GyXwEeya5bDhN2J3/L94FRAGCysgnKhYELVnA+KYGf+QWv9ifaE1xK017qW1ZJKVkGNGakmbYUYPBjbsXUv7AEqW17dmXjQ/7eEw9BBH/SS4LLppqLBa6R+1lKw8yYN/UwbgsBbWxjSg+MXwSWckq3pJCSq/BnckRqeN2d31ylDEgwvMK119/tmGpXHk6q/I2ng4gkalC1p4J8L7VMwIKs8pJy6Hz X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc12eadb-e423-4bcc-1a8d-08d962401b74 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2021 12:02:53.0457 (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: Wx2ZGjxp3GFpCCJLDjZNfKxDSQFZso8/CPHqAcSF24s8m/n0sb3/oKLZ0ryJSc7DVTx1+co2X1CcG039iyq1+w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3839 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The service where DSA assigns a unique bridge number for each forwarding domain is useful even for drivers which do not implement the TX forwarding offload feature. For example, drivers might use the dp->bridge_num for FDB isolation. So rename ds->num_fwd_offloading_bridges to ds->max_num_bridges, and calculate a unique bridge_num for all drivers that set this value. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/mv88e6xxx/chip.c | 4 +- drivers/net/dsa/sja1105/sja1105_main.c | 2 +- include/net/dsa.h | 10 ++-- net/dsa/port.c | 81 ++++++++++++++++++-------- 4 files changed, 65 insertions(+), 32 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index c45ca2473743..32fd657a325a 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -3090,8 +3090,8 @@ static int mv88e6xxx_setup(struct dsa_switch *ds) * time. */ if (mv88e6xxx_has_pvt(chip)) - ds->num_fwd_offloading_bridges = MV88E6XXX_MAX_PVT_SWITCHES - - ds->dst->last_switch - 1; + ds->max_num_bridges = MV88E6XXX_MAX_PVT_SWITCHES - + ds->dst->last_switch - 1; mv88e6xxx_reg_lock(chip); diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 05ba65042b5f..715557c20cb5 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -3055,7 +3055,7 @@ static int sja1105_setup(struct dsa_switch *ds) ds->vlan_filtering_is_global = true; ds->untag_bridge_pvid = true; /* tag_8021q has 3 bits for the VBID, and the value 0 is reserved */ - ds->num_fwd_offloading_bridges = 7; + ds->max_num_bridges = 7; /* Advertise the 8 egress queues */ ds->num_tx_queues = SJA1105_NUM_TC; diff --git a/include/net/dsa.h b/include/net/dsa.h index c7ea0f61056f..62820bd1d00d 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -407,12 +407,12 @@ struct dsa_switch { */ unsigned int num_lag_ids; - /* Drivers that support bridge forwarding offload should set this to - * the maximum number of bridges spanning the same switch tree (or all - * trees, in the case of cross-tree bridging support) that can be - * offloaded. + /* Drivers that support bridge forwarding offload or FDB isolation + * should set this to the maximum number of bridges spanning the same + * switch tree (or all trees, in the case of cross-tree bridging + * support) that can be offloaded. */ - unsigned int num_fwd_offloading_bridges; + unsigned int max_num_bridges; size_t num_ports; }; diff --git a/net/dsa/port.c b/net/dsa/port.c index 4fbe81ffb1ce..605c6890e53b 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -271,19 +271,15 @@ static void dsa_port_switchdev_unsync_attrs(struct dsa_port *dp) } static void dsa_port_bridge_tx_fwd_unoffload(struct dsa_port *dp, - struct net_device *bridge_dev) + struct net_device *bridge_dev, + int bridge_num) { - int bridge_num = dp->bridge_num; struct dsa_switch *ds = dp->ds; /* No bridge TX forwarding offload => do nothing */ - if (!ds->ops->port_bridge_tx_fwd_unoffload || dp->bridge_num == -1) + if (!ds->ops->port_bridge_tx_fwd_unoffload || bridge_num == -1) return; - dp->bridge_num = -1; - - dsa_bridge_num_put(bridge_dev, bridge_num); - /* Notify the chips only once the offload has been deactivated, so * that they can update their configuration accordingly. */ @@ -292,32 +288,65 @@ static void dsa_port_bridge_tx_fwd_unoffload(struct dsa_port *dp, } static bool dsa_port_bridge_tx_fwd_offload(struct dsa_port *dp, - struct net_device *bridge_dev) + struct net_device *bridge_dev, + int bridge_num) { struct dsa_switch *ds = dp->ds; - int bridge_num, err; - - if (!ds->ops->port_bridge_tx_fwd_offload) - return false; + int err; - bridge_num = dsa_bridge_num_get(bridge_dev, - ds->num_fwd_offloading_bridges); - if (bridge_num < 0) + /* FDB isolation is required for TX forwarding offload */ + if (!ds->ops->port_bridge_tx_fwd_offload || bridge_num == -1) return false; - dp->bridge_num = bridge_num; - /* Notify the driver */ err = ds->ops->port_bridge_tx_fwd_offload(ds, dp->index, bridge_dev, bridge_num); - if (err) { - dsa_port_bridge_tx_fwd_unoffload(dp, bridge_dev); + if (err) return false; - } return true; } +static int dsa_port_assign_bridge(struct dsa_port *dp, + struct net_device *br, + struct netlink_ext_ack *extack) +{ + struct dsa_switch *ds = dp->ds; + int bridge_num; + + dp->bridge_dev = br; + + if (!ds->max_num_bridges) + return 0; + + bridge_num = dsa_bridge_num_get(br, ds->max_num_bridges); + + if (bridge_num < 0) { + NL_SET_ERR_MSG_MOD(extack, + "Range of offloadable bridges exceeded"); + return -EOPNOTSUPP; + } + + dp->bridge_num = bridge_num; + + return 0; +} + +static void dsa_port_unassign_bridge(struct dsa_port *dp, + const struct net_device *br) +{ + struct dsa_switch *ds = dp->ds; + + dp->bridge_dev = NULL; + + if (ds->max_num_bridges) { + int bridge_num = dp->bridge_num; + + dp->bridge_num = -1; + dsa_bridge_num_put(br, bridge_num); + } +} + int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br, struct netlink_ext_ack *extack) { @@ -335,7 +364,9 @@ int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br, /* Here the interface is already bridged. Reflect the current * configuration so that drivers can program their chips accordingly. */ - dp->bridge_dev = br; + err = dsa_port_assign_bridge(dp, br, extack); + if (err) + return err; brport_dev = dsa_port_to_bridge_port(dp); @@ -343,7 +374,8 @@ int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br, if (err) goto out_rollback; - tx_fwd_offload = dsa_port_bridge_tx_fwd_offload(dp, br); + tx_fwd_offload = dsa_port_bridge_tx_fwd_offload(dp, br, + dp->bridge_num); err = switchdev_bridge_port_offload(brport_dev, dev, dp, &dsa_slave_switchdev_notifier, @@ -386,14 +418,15 @@ void dsa_port_bridge_leave(struct dsa_port *dp, struct net_device *br) .port = dp->index, .br = br, }; + int bridge_num = dp->bridge_num; int err; /* Here the port is already unbridged. Reflect the current configuration * so that drivers can program their chips accordingly. */ - dp->bridge_dev = NULL; + dsa_port_unassign_bridge(dp, br); - dsa_port_bridge_tx_fwd_unoffload(dp, br); + dsa_port_bridge_tx_fwd_unoffload(dp, br, bridge_num); err = dsa_broadcast(DSA_NOTIFIER_BRIDGE_LEAVE, &info); if (err) From patchwork Wed Aug 18 12:01:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 500297 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C27DAC4338F for ; Wed, 18 Aug 2021 12:03:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9C26160F39 for ; Wed, 18 Aug 2021 12:03:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235481AbhHRMDq (ORCPT ); Wed, 18 Aug 2021 08:03:46 -0400 Received: from mail-vi1eur05on2074.outbound.protection.outlook.com ([40.107.21.74]:54881 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231476AbhHRMDb (ORCPT ); Wed, 18 Aug 2021 08:03:31 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eaTQ9nWEhPRnlGoCasTr7b6cv69Unik6pLWw+mOxLgeK1+Vsom24uFLXVHfq7xJYbRjOtD+kPwUbefC/R0gqCplLMTXEsZLl20aROwN5kJKQU4Z1/Cc+fCHaXHthnrdW0p33PqHhQK2vlvdGk1RDFat3ES/I7EYVGVl2++wVNafdWHsJHBDDE61YPu/H75nVgkZFDnWZiM9lF009lBSbnE/PwTg6DTTEoUX3NVpFDlvTNBzbkrEjYvDukSW6uidtAe3PLaxD9Bm6rmKpDsFnD73HB/V73cNs8LMLVBmBi7mfoozout7MgpxHNV3xdeeA5ogz1guZUXJOlekZKEFtOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BOlI1pFu88wHvrSjom9afx0Xd1HuttK75WyO46AuYeM=; b=bZ347bf75OAq8nGvbmFatbPfMvTIEuJBBad3tDLqEV0H+BpPjJ/VfWNRlBVGSWXjX8VgmyP38DSEE3vxRS7qWSG9ifdyilSpAzMvK5g3lwSG4paf2BTx9hZu8t75sIp2dFBCJ5LR02vX+o8AVu0xDi/R+2Ixg9+hOym+8S/5pmGLSS/INqnTWYPIKnZRG1WPUs0xJP/WaXd0m1TnanIX+TGqP2a8Yi3oRWAFenWWPY+O39J1a/PZROIAjYI7Qv7G4gKUvUeGzhiA5LVu9ZKLrQjKXlkMJiTih0ArphT9n5OksjE3wD5X682oaeXCuAYMbpmtiUaD1y8vrc2yGr1MkQ== 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=BOlI1pFu88wHvrSjom9afx0Xd1HuttK75WyO46AuYeM=; b=IfkSicghmlhc85O9l59E9kxomzCd5qjBgga3Pg90i1ljqZiT8F+/EB5vNcvvrarDqkv+Ob1gfKLhlpyCakdEf+Np3rrKTJhfWz2F57U4LyQWqd9GNXmDfK5PtwQRRooa2p2Wced+7h6+sGnbjkj4bnUQ7bdZ1entQ48Bye0wGPc= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR04MB4222.eurprd04.prod.outlook.com (2603:10a6:803:46::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.18; Wed, 18 Aug 2021 12:02:54 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4415.024; Wed, 18 Aug 2021 12:02:54 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Roopa Prabhu , Nikolay Aleksandrov , Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean , Vadym Kochan , Taras Chornyi , Jiri Pirko , Ido Schimmel , UNGLinuxDriver@microchip.com, Grygorii Strashko , Marek Behun , DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Claudiu Manoil , Alexandre Belloni , George McCollister , Ioana Ciornei , Saeed Mahameed , Leon Romanovsky , Lars Povlsen , Steen Hegelund , Julian Wiedmann , Karsten Graul , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Ivan Vecera , Vlad Buslov , Jianbo Liu , Mark Bloch , Roi Dayan , Tobias Waldekranz , Vignesh Raghavendra , Jesse Brandeburg , Peter Ujfalusi Subject: [RFC PATCH net-next 03/20] net: dsa: propagate the bridge_num to driver .port_bridge_{join, leave} methods Date: Wed, 18 Aug 2021 15:01:33 +0300 Message-Id: <20210818120150.892647-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818120150.892647-1-vladimir.oltean@nxp.com> References: <20210818120150.892647-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 18 Aug 2021 12:02:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 392a4594-09ae-4eb4-59ed-08d962401c4c X-MS-TrafficTypeDiagnostic: VI1PR04MB4222: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1265; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tgZGLxLTb4mUcvrscUdQ7K5U+PIy8wSI9KHfWa/p5B0TrEegMbT/TFCnPjGdEUzBdAh9YqfNEHW2i3tN3bPRBbNGSomdGwZwx4llsgfae7Rjc8tiO/8U9lYCd+skBpY6/5pYXICHQ0P5VdG61ta76hmM0+g7xfgu6HEN1kHb9Ibguk8N7ecAR7CRlNRbhW0pWW0Fcy2tBiZ07sbGcU4zqeEOruzsut4l+ail9pJGLRw6N0OSsxZpdijwb0PrIowvlNYV7J27Bqddrr42PMZUWZGq5KM78QbMuug8bE31HzxtSbdMKSnJZ1X7TilyHMa/Dx4ln67yI4k+OACW+oJRiXoeMsPREZCDYXXpQmbmLpbR5lQI1yvEjiKZ/rP8lY0rp6QmwsqV7/XUFJ2Lwhr82WXOCTgFislsX3rEQmKMuwzbAod5cHV887BkT1y7LTVqjzxoPNV8kL+PN4Ottgio1Q5klFMd3ES8bGJDUtwhl3LP/PjKxQ/ySIZ3lnyXO+gNpg1IaPD2h0l95JDWBMYLWhxl1VrMT1kuFDpHp8fcyqgpGuaRmW7ISHxnchLJlxn+J11lY36TOYTGQ2eANAJjPyz1u0NT/9ZGZWn7HX+sxDEuTbGLQEF4UHLeZiQw8ov888++T7oGQIDo6OKmlgqVwx0kVMPozJyNMQINbHg428GfGRd2iujhV21Y04joc9Si/A2Nc9KTc1UoIcDQzTjlM2i+TLPPX9VH//I+w/2MgVk= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(396003)(136003)(39860400002)(366004)(376002)(6486002)(52116002)(2616005)(44832011)(4326008)(5660300002)(26005)(1076003)(6666004)(54906003)(956004)(6512007)(6506007)(186003)(38350700002)(30864003)(38100700002)(86362001)(36756003)(110136005)(316002)(83380400001)(8936002)(478600001)(8676002)(66476007)(7416002)(7406005)(66946007)(66556008)(2906002)(142923001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cFEuvJ6EKJJtILmL7KSXLZMbCnuLdAaOybycBXDFx5VRvSs8XHA5r0fb8O1RmZXZcQEIqJYhw58O2AxVcOjBTiNtmLnu916i9FEDYkKi4hrvafDXIVUJCAjQkvIoiesyzFhG4+WTqL437ghao2N3BC5EZmQE8/B12Dk6Wmxx91Gsebm6Aa1UF/sO2DuiCDu8di2h1Fkxej3/TQ3VHFFSJszOVac7S2GCyrJuI0107GIvE5Ua6cxUcgSSNok6kjGMn9rrsC0n28MaQjEugQrXHPJ55teiMWI8DEUndqoeRKqf/U+ADVIZ2CvwWaUXY0tnmBSrnQvHsjhP4hjmDKE17AYjRD4JQnZ8JMqrPGCBfyCt/2O04NK4rkWSvkoPwhczwSiBMAlNpFDG9ZlP5P6WqhhRoLaDZBhoAci1KMUHt7gP4qCSWR3PSErmNZXnfb985FbyZAYv7YK6O+Zwb8mUSv4/yMrCg+EdRpLZ7q2YoK2+r8DXj7+IlE27az51ACwE0Yg0GDxZvsvh/v0kx0qwcRsvSC/TGFPugvAtYVJzNwRZ6T/NLM8L/0nN8CshZ6uQmSTCDKghT7QYkye7/Hm7GMFVfSAH4f9lykIFlW7njRD00aqkU5s1vGP2IQmYhBlEmUHUYdUS1EbTyqadDh0LKwzQUhsz0H2P8/f2wFxdOyyx39qx7zRJ+AuHEJ4suyDdOOlbTxdtx4YGXPI+sBFFLc6Tec/BM0A0Gkw1sNnmcnJZACT5NRkjdUjG0IrDauCGdWCEhS/0ChmWea4sfEPF0ekY7k6jAhAGduJbjpbXbxpvgBpOIl5Gd6H8F8NOLhgM3A1I/K5y3QHe2iiRzaR/g1O66krda/s5h8DbvksjAR5v2jnYjbGk9e7IeTsbg519ChiJrWVYqJ+fvCkmYkBU64zdEVHybMNuQVGLoeJolxHLvQ62WTUKykmBwnLVXwIbmYKpyS7Qk9Zj+MENRn+/ot0a1EOy4W8YZzCCuZDXY8AUllr+3BWkvJ4qn22lPJ9LwTv/jZ6ksVkj/qdGtX5XyyxPyv/dYyNEFs/NL5huzjlijiXngHm45AtgraMfAsgb5Z1irKLTvQegDE13nG2HN3AYsF066hKgJh7QyhrIafRsMoO7AZunW9ICFOsB2sPJvHimAnuzH1prYv1F4Gaz04UGUvh9d1zpTEEhJ48D23ipocgWyO0tIZhkrWNWwPIW4USv2Q3RMpAbs1rEydsgiMdFfGIJcVaMcn6JV3++V0NHvmth8mwyFehumiUEX94O2BFPYw+YxYOquH9XcxsJ3h9Q+dNafuqwPgvfNfv5QEiEPMGAyaFlMuy3JK4PE7rC X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 392a4594-09ae-4eb4-59ed-08d962401c4c X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2021 12:02:54.4439 (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: rf4NHuCO/WwViLScfoltLARiiig0vDtTmN2veYVUcL+sPuTaGIL5S7eWKVOfwngQFU8/e3mQ5XEXhidjABH3Xw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4222 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org If the driver needs to do something to isolate FDBs of different bridges, it must be able to reliably get a FDB identifier for each bridge. So one might ask: why is the driver not able to call something like dsa_bridge_num_find(bridge_dev) and find the associated FDB identifier already provided by the DSA core if it needs to, and not change anything if it doesn't? The issue is that drivers might need to do something with the FDB identifier on .port_bridge_leave too, and the dsa_bridge_num_find function is stateful: it only retrieves a valid bridge_num if there is at least one port which has dp->bridge_dev == br. But the dsa_port_bridge_leave() method first clears dp->bridge_dev and dp->bridge_num, and only then notifies the driver. The bridge that the port just left is only present inside the cross-chip notifier attribute, and is passed by value to the switch driver. So the bridge_num of the bridge we just left needs to be passed by value too, just like the bridge_dev itself. And from there, .port_bridge_join follows the same prototype mostly for symmetry. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/b53/b53_common.c | 6 ++++-- drivers/net/dsa/b53/b53_priv.h | 6 ++++-- drivers/net/dsa/dsa_loop.c | 6 ++++-- drivers/net/dsa/hirschmann/hellcreek.c | 6 ++++-- drivers/net/dsa/lan9303-core.c | 4 ++-- drivers/net/dsa/lantiq_gswip.c | 4 ++-- drivers/net/dsa/microchip/ksz_common.c | 4 ++-- drivers/net/dsa/microchip/ksz_common.h | 4 ++-- drivers/net/dsa/mt7530.c | 4 ++-- drivers/net/dsa/mv88e6xxx/chip.c | 12 ++++++++---- drivers/net/dsa/ocelot/felix.c | 4 ++-- drivers/net/dsa/qca8k.c | 6 ++++-- drivers/net/dsa/sja1105/sja1105_main.c | 4 ++-- drivers/net/dsa/xrs700x/xrs700x.c | 4 ++-- include/net/dsa.h | 8 ++++---- net/dsa/dsa_priv.h | 1 + net/dsa/port.c | 3 +++ net/dsa/switch.c | 11 +++++++---- 18 files changed, 59 insertions(+), 38 deletions(-) diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index bd1417a66cbf..d0f00cb0a235 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c @@ -1847,7 +1847,8 @@ int b53_mdb_del(struct dsa_switch *ds, int port, } EXPORT_SYMBOL(b53_mdb_del); -int b53_br_join(struct dsa_switch *ds, int port, struct net_device *br) +int b53_br_join(struct dsa_switch *ds, int port, struct net_device *br, + int bridge_num) { struct b53_device *dev = ds->priv; s8 cpu_port = dsa_to_port(ds, port)->cpu_dp->index; @@ -1898,7 +1899,8 @@ int b53_br_join(struct dsa_switch *ds, int port, struct net_device *br) } EXPORT_SYMBOL(b53_br_join); -void b53_br_leave(struct dsa_switch *ds, int port, struct net_device *br) +void b53_br_leave(struct dsa_switch *ds, int port, struct net_device *br, + int bridge_num) { struct b53_device *dev = ds->priv; struct b53_vlan *vl = &dev->vlans[0]; diff --git a/drivers/net/dsa/b53/b53_priv.h b/drivers/net/dsa/b53/b53_priv.h index 9bf8319342b0..e3f1e9ff1b50 100644 --- a/drivers/net/dsa/b53/b53_priv.h +++ b/drivers/net/dsa/b53/b53_priv.h @@ -318,8 +318,10 @@ void b53_get_strings(struct dsa_switch *ds, int port, u32 stringset, void b53_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *data); int b53_get_sset_count(struct dsa_switch *ds, int port, int sset); void b53_get_ethtool_phy_stats(struct dsa_switch *ds, int port, uint64_t *data); -int b53_br_join(struct dsa_switch *ds, int port, struct net_device *bridge); -void b53_br_leave(struct dsa_switch *ds, int port, struct net_device *bridge); +int b53_br_join(struct dsa_switch *ds, int port, struct net_device *bridge, + int bridge_num); +void b53_br_leave(struct dsa_switch *ds, int port, struct net_device *bridge, + int bridge_num); void b53_br_set_stp_state(struct dsa_switch *ds, int port, u8 state); void b53_br_fast_age(struct dsa_switch *ds, int port); int b53_br_flags_pre(struct dsa_switch *ds, int port, diff --git a/drivers/net/dsa/dsa_loop.c b/drivers/net/dsa/dsa_loop.c index bfdf3324aac3..c9fefdede1d1 100644 --- a/drivers/net/dsa/dsa_loop.c +++ b/drivers/net/dsa/dsa_loop.c @@ -167,7 +167,8 @@ static int dsa_loop_phy_write(struct dsa_switch *ds, int port, } static int dsa_loop_port_bridge_join(struct dsa_switch *ds, int port, - struct net_device *bridge) + struct net_device *bridge, + int bridge_num) { dev_dbg(ds->dev, "%s: port: %d, bridge: %s\n", __func__, port, bridge->name); @@ -176,7 +177,8 @@ static int dsa_loop_port_bridge_join(struct dsa_switch *ds, int port, } static void dsa_loop_port_bridge_leave(struct dsa_switch *ds, int port, - struct net_device *bridge) + struct net_device *bridge, + int bridge_num) { dev_dbg(ds->dev, "%s: port: %d, bridge: %s\n", __func__, port, bridge->name); diff --git a/drivers/net/dsa/hirschmann/hellcreek.c b/drivers/net/dsa/hirschmann/hellcreek.c index 5c54ae1be62c..732fff99bfb2 100644 --- a/drivers/net/dsa/hirschmann/hellcreek.c +++ b/drivers/net/dsa/hirschmann/hellcreek.c @@ -674,7 +674,8 @@ static int hellcreek_bridge_flags(struct dsa_switch *ds, int port, } static int hellcreek_port_bridge_join(struct dsa_switch *ds, int port, - struct net_device *br) + struct net_device *br, + int bridge_num) { struct hellcreek *hellcreek = ds->priv; @@ -691,7 +692,8 @@ static int hellcreek_port_bridge_join(struct dsa_switch *ds, int port, } static void hellcreek_port_bridge_leave(struct dsa_switch *ds, int port, - struct net_device *br) + struct net_device *br, + int bridge_num) { struct hellcreek *hellcreek = ds->priv; diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index d7ce281570b5..4e72fd04eb5f 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -1103,7 +1103,7 @@ static void lan9303_port_disable(struct dsa_switch *ds, int port) } static int lan9303_port_bridge_join(struct dsa_switch *ds, int port, - struct net_device *br) + struct net_device *br, int bridge_num) { struct lan9303 *chip = ds->priv; @@ -1117,7 +1117,7 @@ static int lan9303_port_bridge_join(struct dsa_switch *ds, int port, } static void lan9303_port_bridge_leave(struct dsa_switch *ds, int port, - struct net_device *br) + struct net_device *br, int bridge_num) { struct lan9303 *chip = ds->priv; diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c index e78026ef6d8c..2ce4da567106 100644 --- a/drivers/net/dsa/lantiq_gswip.c +++ b/drivers/net/dsa/lantiq_gswip.c @@ -1128,7 +1128,7 @@ static int gswip_vlan_remove(struct gswip_priv *priv, } static int gswip_port_bridge_join(struct dsa_switch *ds, int port, - struct net_device *bridge) + struct net_device *bridge, int bridge_num) { struct gswip_priv *priv = ds->priv; int err; @@ -1148,7 +1148,7 @@ static int gswip_port_bridge_join(struct dsa_switch *ds, int port, } static void gswip_port_bridge_leave(struct dsa_switch *ds, int port, - struct net_device *bridge) + struct net_device *bridge, int bridge_num) { struct gswip_priv *priv = ds->priv; diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 1542bfb8b5e5..4f821933e291 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -173,7 +173,7 @@ void ksz_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *buf) EXPORT_SYMBOL_GPL(ksz_get_ethtool_stats); int ksz_port_bridge_join(struct dsa_switch *ds, int port, - struct net_device *br) + struct net_device *br, int bridge_num) { struct ksz_device *dev = ds->priv; @@ -190,7 +190,7 @@ int ksz_port_bridge_join(struct dsa_switch *ds, int port, EXPORT_SYMBOL_GPL(ksz_port_bridge_join); void ksz_port_bridge_leave(struct dsa_switch *ds, int port, - struct net_device *br) + struct net_device *br, int bridge_num) { struct ksz_device *dev = ds->priv; diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index 1597c63988b4..3e905059374b 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -159,9 +159,9 @@ void ksz_mac_link_down(struct dsa_switch *ds, int port, unsigned int mode, int ksz_sset_count(struct dsa_switch *ds, int port, int sset); void ksz_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *buf); int ksz_port_bridge_join(struct dsa_switch *ds, int port, - struct net_device *br); + struct net_device *br, int bridge_num); void ksz_port_bridge_leave(struct dsa_switch *ds, int port, - struct net_device *br); + struct net_device *br, int bridge_num); void ksz_port_fast_age(struct dsa_switch *ds, int port); int ksz_port_fdb_dump(struct dsa_switch *ds, int port, dsa_fdb_dump_cb_t *cb, void *data); diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index d757d9dcba51..751e477691f4 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -1192,7 +1192,7 @@ mt7530_port_bridge_flags(struct dsa_switch *ds, int port, static int mt7530_port_bridge_join(struct dsa_switch *ds, int port, - struct net_device *bridge) + struct net_device *bridge, int bridge_num) { struct mt7530_priv *priv = ds->priv; u32 port_bitmap = BIT(MT7530_CPU_PORT); @@ -1305,7 +1305,7 @@ mt7530_port_set_vlan_aware(struct dsa_switch *ds, int port) static void mt7530_port_bridge_leave(struct dsa_switch *ds, int port, - struct net_device *bridge) + struct net_device *bridge, int bridge_num) { struct mt7530_priv *priv = ds->priv; int i; diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 32fd657a325a..37878ccf499c 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -2387,7 +2387,8 @@ static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip, } static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port, - struct net_device *br) + struct net_device *br, + int bridge_num) { struct mv88e6xxx_chip *chip = ds->priv; int err; @@ -2400,7 +2401,8 @@ static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port, } static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port, - struct net_device *br) + struct net_device *br, + int bridge_num) { struct mv88e6xxx_chip *chip = ds->priv; @@ -2413,7 +2415,8 @@ static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port, static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int tree_index, int sw_index, - int port, struct net_device *br) + int port, struct net_device *br, + int bridge_num) { struct mv88e6xxx_chip *chip = ds->priv; int err; @@ -2430,7 +2433,8 @@ static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int tree_index, int sw_index, - int port, struct net_device *br) + int port, struct net_device *br, + int bridge_num) { struct mv88e6xxx_chip *chip = ds->priv; diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index cbe23b20f3fa..3ab7cf2f0f50 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -695,7 +695,7 @@ static int felix_bridge_flags(struct dsa_switch *ds, int port, } static int felix_bridge_join(struct dsa_switch *ds, int port, - struct net_device *br) + struct net_device *br, int bridge_num) { struct ocelot *ocelot = ds->priv; @@ -705,7 +705,7 @@ static int felix_bridge_join(struct dsa_switch *ds, int port, } static void felix_bridge_leave(struct dsa_switch *ds, int port, - struct net_device *br) + struct net_device *br, int bridge_num) { struct ocelot *ocelot = ds->priv; diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c index 1f63f50f73f1..9addf99ceead 100644 --- a/drivers/net/dsa/qca8k.c +++ b/drivers/net/dsa/qca8k.c @@ -1505,7 +1505,8 @@ qca8k_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) } static int -qca8k_port_bridge_join(struct dsa_switch *ds, int port, struct net_device *br) +qca8k_port_bridge_join(struct dsa_switch *ds, int port, struct net_device *br, + int bridge_num) { struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv; int port_mask = BIT(QCA8K_CPU_PORT); @@ -1534,7 +1535,8 @@ qca8k_port_bridge_join(struct dsa_switch *ds, int port, struct net_device *br) } static void -qca8k_port_bridge_leave(struct dsa_switch *ds, int port, struct net_device *br) +qca8k_port_bridge_leave(struct dsa_switch *ds, int port, struct net_device *br, + int bridge_num) { struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv; int i; diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 715557c20cb5..12a92deb5e5b 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -1985,13 +1985,13 @@ static void sja1105_bridge_stp_state_set(struct dsa_switch *ds, int port, } static int sja1105_bridge_join(struct dsa_switch *ds, int port, - struct net_device *br) + struct net_device *br, int bridge_num) { return sja1105_bridge_member(ds, port, br, true); } static void sja1105_bridge_leave(struct dsa_switch *ds, int port, - struct net_device *br) + struct net_device *br, int bridge_num) { sja1105_bridge_member(ds, port, br, false); } diff --git a/drivers/net/dsa/xrs700x/xrs700x.c b/drivers/net/dsa/xrs700x/xrs700x.c index 130abb0f1438..230dbbcc48f3 100644 --- a/drivers/net/dsa/xrs700x/xrs700x.c +++ b/drivers/net/dsa/xrs700x/xrs700x.c @@ -542,13 +542,13 @@ static int xrs700x_bridge_common(struct dsa_switch *ds, int port, } static int xrs700x_bridge_join(struct dsa_switch *ds, int port, - struct net_device *bridge) + struct net_device *bridge, int bridge_num) { return xrs700x_bridge_common(ds, port, bridge, true); } static void xrs700x_bridge_leave(struct dsa_switch *ds, int port, - struct net_device *bridge) + struct net_device *bridge, int bridge_num) { xrs700x_bridge_common(ds, port, bridge, false); } diff --git a/include/net/dsa.h b/include/net/dsa.h index 62820bd1d00d..b2aaef292c6d 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -694,9 +694,9 @@ struct dsa_switch_ops { */ int (*set_ageing_time)(struct dsa_switch *ds, unsigned int msecs); int (*port_bridge_join)(struct dsa_switch *ds, int port, - struct net_device *bridge); + struct net_device *bridge, int bridge_num); void (*port_bridge_leave)(struct dsa_switch *ds, int port, - struct net_device *bridge); + struct net_device *bridge, int bridge_num); /* Called right after .port_bridge_join() */ int (*port_bridge_tx_fwd_offload)(struct dsa_switch *ds, int port, struct net_device *bridge, @@ -776,10 +776,10 @@ struct dsa_switch_ops { */ int (*crosschip_bridge_join)(struct dsa_switch *ds, int tree_index, int sw_index, int port, - struct net_device *br); + struct net_device *br, int bridge_num); void (*crosschip_bridge_leave)(struct dsa_switch *ds, int tree_index, int sw_index, int port, - struct net_device *br); + struct net_device *br, int bridge_num); int (*crosschip_lag_change)(struct dsa_switch *ds, int sw_index, int port); int (*crosschip_lag_join)(struct dsa_switch *ds, int sw_index, diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index 88aaf43b2da4..c5caa2d975d2 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h @@ -53,6 +53,7 @@ struct dsa_notifier_ageing_time_info { /* DSA_NOTIFIER_BRIDGE_* */ struct dsa_notifier_bridge_info { struct net_device *br; + int bridge_num; int tree_index; int sw_index; int port; diff --git a/net/dsa/port.c b/net/dsa/port.c index 605c6890e53b..3ef55bd6eb40 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -368,6 +368,8 @@ int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br, if (err) return err; + info.bridge_num = dp->bridge_num; + brport_dev = dsa_port_to_bridge_port(dp); err = dsa_broadcast(DSA_NOTIFIER_BRIDGE_JOIN, &info); @@ -417,6 +419,7 @@ void dsa_port_bridge_leave(struct dsa_port *dp, struct net_device *br) .sw_index = dp->ds->index, .port = dp->index, .br = br, + .bridge_num = dp->bridge_num, }; int bridge_num = dp->bridge_num; int err; diff --git a/net/dsa/switch.c b/net/dsa/switch.c index fd1a1c6bf9cf..44d40a267632 100644 --- a/net/dsa/switch.c +++ b/net/dsa/switch.c @@ -94,7 +94,8 @@ static int dsa_switch_bridge_join(struct dsa_switch *ds, if (dst->index == info->tree_index && ds->index == info->sw_index && ds->ops->port_bridge_join) { - err = ds->ops->port_bridge_join(ds, info->port, info->br); + err = ds->ops->port_bridge_join(ds, info->port, info->br, + info->bridge_num); if (err) return err; } @@ -103,7 +104,8 @@ static int dsa_switch_bridge_join(struct dsa_switch *ds, ds->ops->crosschip_bridge_join) { err = ds->ops->crosschip_bridge_join(ds, info->tree_index, info->sw_index, - info->port, info->br); + info->port, info->br, + info->bridge_num); if (err) return err; } @@ -121,13 +123,14 @@ static int dsa_switch_bridge_leave(struct dsa_switch *ds, if (dst->index == info->tree_index && ds->index == info->sw_index && ds->ops->port_bridge_leave) - ds->ops->port_bridge_leave(ds, info->port, info->br); + ds->ops->port_bridge_leave(ds, info->port, info->br, + info->bridge_num); if ((dst->index != info->tree_index || ds->index != info->sw_index) && ds->ops->crosschip_bridge_leave) ds->ops->crosschip_bridge_leave(ds, info->tree_index, info->sw_index, info->port, - info->br); + info->br, info->bridge_num); /* If the bridge was vlan_filtering, the bridge core doesn't trigger an * event for changing vlan_filtering setting upon slave ports leaving From patchwork Wed Aug 18 12:01:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 499563 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86775C4338F for ; Wed, 18 Aug 2021 12:03:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6530E60F35 for ; Wed, 18 Aug 2021 12:03:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235809AbhHRMEA (ORCPT ); Wed, 18 Aug 2021 08:04:00 -0400 Received: from mail-eopbgr00067.outbound.protection.outlook.com ([40.107.0.67]:52143 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235775AbhHRMDo (ORCPT ); Wed, 18 Aug 2021 08:03:44 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PuuL7Ghw7xgR+mWEGMw5m/BK4xbymTJbmpqcuihwfMi1ludz2zXDYXtNS9AyYszXJwTmPjzRPNzSkrQDdqlwbnanb1dtrD3qGr1m5yJSf2uw6DH8L8ke8B43URf60I8pN7otoEe5tpq/wPUQhNTp2Il+xRxq9SOHk1mXKznKRj+aOgj3Zyalc/ivQffChMBkK2IN7D0pH2d+Hke2Pzo+fNkR9+Dgs/LYoAcBJO/idbotSbw+celKSbzJNSs7qqI8AetoeM9coxg/mHPyCVyHfH+xsWgFk8a6YGpl91du7W+96fMUHwF89DONFq+958Wl07D0FIuLCbjWVOo5Qng0Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XRIcbky/+LcdkEqbG9KlQXO5Fqrx1ryRnkHrQO74wCY=; b=bkl/KVkeqSWuw0dAtAWVtPrGgDO6O4jewx3BvhLpYOA3tIDmVPpZAukqO1FiF7l8yCuE1yFMUAqfKnMmEW0UYpCYdV+EbSXuXEEjYI6TFq8ZBaRR/dqusZxFyUmQfe94qmD6fz83td4cuU6ta0LUM0uljZtmFwIsnQ+mVRFFRXs9/CbhJREq3+BqTsZafN8P3Q3lnJoY7mCNV3R8aZ0avkfQtYEox1eUNqvj413zYBbIt4m7v8sPZXql8qv8hgj908Y3RhIWu8IAc9cdrDJZK5oMMkzVIk9YW28oaLydplwTQqXryEo5HmMqVcyxRNTI6RypoSvlFqT1hfoCgvm1HQ== 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=XRIcbky/+LcdkEqbG9KlQXO5Fqrx1ryRnkHrQO74wCY=; b=G14zvpXuE7iIRAYu2qudEEd+wV3x8X5MUcTw1IsDGqoqqZMaZ1zVxagCIT4TOkbCKsG9cBJEZH+fimR1ScOd5woarMm/DCVucce0VG9fWp0B0neQ+jM2deVVV5MwbNxKFg2sSlQhOzQu4h59gwNWyXNitL97oBZTcmXYyZ07UVA= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB3839.eurprd04.prod.outlook.com (2603:10a6:803:21::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17; Wed, 18 Aug 2021 12:02:56 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4415.024; Wed, 18 Aug 2021 12:02:56 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Roopa Prabhu , Nikolay Aleksandrov , Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean , Vadym Kochan , Taras Chornyi , Jiri Pirko , Ido Schimmel , UNGLinuxDriver@microchip.com, Grygorii Strashko , Marek Behun , DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Claudiu Manoil , Alexandre Belloni , George McCollister , Ioana Ciornei , Saeed Mahameed , Leon Romanovsky , Lars Povlsen , Steen Hegelund , Julian Wiedmann , Karsten Graul , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Ivan Vecera , Vlad Buslov , Jianbo Liu , Mark Bloch , Roi Dayan , Tobias Waldekranz , Vignesh Raghavendra , Jesse Brandeburg , Peter Ujfalusi Subject: [RFC PATCH net-next 04/20] net: switchdev: move SWITCHDEV_FDB_{ADD, DEL}_TO_DEVICE to the blocking notifier chain Date: Wed, 18 Aug 2021 15:01:34 +0300 Message-Id: <20210818120150.892647-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818120150.892647-1-vladimir.oltean@nxp.com> References: <20210818120150.892647-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 18 Aug 2021 12:02:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 663aec4a-0af0-4374-1fb3-08d962401d26 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3839: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1TvvElrJZu5dfocyFPMuWSwotjX9hsrtpr+S4zgjZNm1302baL2cwCYOM0+ohQUWQ7JJZAiIlhF7loQDY1A0w/z/zjAtdQPUTAAKsPwFnj56RgPZopYarZc280fnmsIFiDT2dgMcqI/ywvFl6ib/Bol+3IryTQnoy1sABsO5pxRg/+7Kgc8/ZQ4wIJdahZ39bpSnYxetY057TKe4iqGSqm/BzuUcsutKodvogxnGJ9lK1AKr6NXX5Tdul6QcD8IFj9HKRNa8CElqpQcu2YbhgH+cUCwL3wh/yiDBf3Wp3PW+pCATRXXtY8BjyLDHrFa+7y898ZKf9FxVmyAmWqRNJ/OhRcuy+4CilD3Do9CHTWIW1AogEYs3ZoBUjv5w7TLCyfoRhutdK6yW7Z7B+Qkba2iZ02lVTWoeyoZLxBfb9N1SbmoRs1fXaodbkxJ47v0LXUk/UHq7jlY3n11RQrRY8WzrQCVeHQIhvDBiBr5Kdo1x8N8Di6wc1QE58My6Fq8z9SluHFubXK43jgXl5VuVBE5ph7BEO5BGEuLpnjBRiWS3UsDpP9o98+MLeHNrcM0V+gj6OKcKkJ6TxO7IlUzAo7O9FnVBHX0SLs49prZEnHR/ldzj71CsuBujb7+9Q8yeJfDAQEKASPilYn0++7q+BHBteHHBhnTuFH/e8AI0BCnnrJsWfWzDgwH+C3UENdWynvBwiRuuempPXW+ym6HxYw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(346002)(136003)(39840400004)(366004)(376002)(66476007)(2906002)(66556008)(8936002)(6506007)(186003)(7406005)(7416002)(52116002)(26005)(86362001)(66946007)(6486002)(44832011)(36756003)(30864003)(5660300002)(1076003)(110136005)(54906003)(6512007)(8676002)(316002)(6666004)(38350700002)(38100700002)(956004)(478600001)(83380400001)(2616005)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /hPJOapbxgXYRdzLnMwDM8W2U5ggPZhx5DVMw8jeqjtOfKEYCPSofFvFW1StXNXebierjTKK3WWNMziRAQmeHGnwQfPIcsXexDYQrYGM+Dr4oQkPU9AMQr7mEhDF9EZQiplEJIpFOznNaWZr32ZNxhFIGaOxHudrOfbsaNy8N+T95wcSGyuNCZZI5gATTTUzadP8CyhS7Tk2qrbEYmGWYh/YEJAH+GtRWsgLm3rANegDuSE8pEX4J+OCWIZXuIXcpiv7XLotl10xDAk6kF6dz+VA3CFuiv33sFtadnpao2Avdn8ea8WpkiunR2SGwiTlmsIB4aWVdBSbLUB8+mh0pusJs/WInRWdxFLsv8rReB0+kya8TAljO6haLJ2U4xh7503gqrfPihZwZFZRRqdWxh2WOW68Lnh7sLzHquuieqU0tJCaj0LcxFIA74LL/WIs+U2wxFmqYJgfaTVZEWFNewuQP1RrLS+LG92rPnPl8bfHyHbXdTVt2+m+nCh04ryJ09+69tSHJ8xHCc9jA7XJNyXFDA+qp1jJg7spJfH9SHG2SXBaYslmrBhZdX23tTdF1w26Hn0zu0NQ4LpR+nJ6kwkI8iBMiqjttm7fQIXZdVa8cEaceFM0WzeTTl4Blyo7o+sJ5e9vN/N4c8PFsZA/7uKeM7hvs3i1jTd1L2x2h55rF5ldwLnDUYut9C05KE/HpS7jcgmD88VHx91qZ85ld6tizMCjD3yqFqAo86Xihb3NH1xgRFTC1e4gBI79LC0UfIiEdYjBMcDLomXHyxdp+tDjdzX4cU8oeNgRLXcLNmLRZgx6RIIMTxaYit+2fkGlWtGN4NC4dN/CNAPW1ptaaaAn+lubb/fvY6g7VRNIdyhggOzsllU8qlLNsN/G149gfgQFAvZzvDURhsoGfJI3u8kzqSc2PgfqAFlYwZpczIquF9mM9Xl+TMKI+vCeSz3lqc3hmO63ehkQVaJBGG+9oo0L0dCWftzdK/AAIdU1KClP89vIg9INJIHInhRUKgDxvOgOXiGbTOdv13M+YbXKfv9MVqUf+Rt1wIkQebOKEN7xN747g9xzCuy/8d9KUer7eX8F5TVduxtj1TDpVCuT5cIOFDlXMCpdlq/AQ7aTQcxHibDPL1wHdLArX0W3PKXInspuBupESoCsgHS8Y571FhyqOcTohovf3xJU4NPsmE3R0fkWWxyqUx9aWgION1czdKZ9w+sOKGVm+eAn9IOjKHnbyHsRU04osrgUySieQFKVPtWX2JGiIw7Hrxgkc6xmX06S3uZ6bKH+dNuT2/H9SQVJ5bGb1lsK+zpYpjzPalRW9MRwjcV9dZK4OSL0Kr5r X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 663aec4a-0af0-4374-1fb3-08d962401d26 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2021 12:02:55.8741 (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: APc/A+cQKe1sU7a0cvwzRkITWwYjSvueaT1wqzROGkA1SB8jj9DYvk8Wyzt8nUV5kMnQn2XffDkuVdEOQvHVLw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3839 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Currently, br_switchdev_fdb_notify() uses call_switchdev_notifiers (and br_fdb_replay() open-codes the same thing). This means that drivers handle the SWITCHDEV_FDB_{ADD,DEL}_TO_DEVICE events on the atomic switchdev notifier block. Most existing switchdev drivers either talk to firmware, or to a device over a bus where the I/O is sleepable (SPI, I2C, MDIO etc). So there exists an (anti)pattern where drivers make a sleepable context for offloading the given FDB entry by registering an ordered workqueue and scheduling work items on it, and doing all the work from there. The problem is the inherent limitation that this design imposes upon what a switchdev driver can do with those FDB entries. For example, a switchdev driver might want to perform FDB isolation, i.e. associate each FDB entry with the bridge it belongs to. Maybe the driver associates each bridge with a number, allocating that number when the first port of the driver joins that bridge, and freeing it when the last port leaves it. And this is where the problem is. When user space deletes a bridge and all the ports leave, the bridge will notify us of the deletion of all FDB entries in atomic context, and switchdev drivers will schedule their private work items on their private workqueue. The FDB entry deletion notifications will succeed, the bridge will then finish deleting itself, but the switchdev work items have not run yet. When they will eventually get scheduled, the aforementioned association between the bridge_dev and a number will have already been broken by the switchdev driver. All ports are standalone now, the bridge is a foreign interface! One might say "why don't you cache all your associations while you're still in the atomic context and they're still valid, pass them by value through your switchdev_work and work with the cached values as opposed to the current ones?" This option smells of poor design, because instead of fixing a central problem, we add tens of lateral workarounds to avoid it. It should be easier to use switchdev, not harder, and we should look at the common patterns which lead to code duplication and eliminate them. In this case, we must notice that (a) switchdev already has the concept of notifiers emitted from the fast path that are still processed by drivers from blocking context. This is accomplished through the SWITCHDEV_F_DEFER flag which is used by e.g. SWITCHDEV_OBJ_ID_HOST_MDB. (b) the bridge del_nbp() function already calls switchdev_deferred_process(). So if we could hook into that, we could have a chance that the bridge simply waits for our FDB entry offloading procedure to finish before it calls netdev_upper_dev_unlink() - which is almost immediately afterwards, and also when switchdev drivers typically break their stateful associations between the bridge upper and private data. So it is in fact possible to use switchdev's generic switchdev_deferred_enqueue mechanism to get a sleepable callback, and from there we can call_switchdev_blocking_notifiers(). In the case of br_fdb_replay(), the only code path is from switchdev_bridge_port_offload(), which is already in blocking context. So we don't need to go through switchdev_deferred_enqueue, and we can just call the blocking notifier block directly. To preserve the same behavior as before, all drivers need to have their SWITCHDEV_FDB_{ADD,DEL}_TO_DEVICE handlers moved from their switchdev atomic notifier blocks to the blocking ones. This patch attempts to make that trivial movement. Note that now they might schedule a work item for nothing (since they are now called from a work item themselves), but I don't have the energy or hardware to test all of them, so this will have to do. Note that previously, we were under rcu_read_lock() but now we're not. I have eyeballed the drivers that make any sort of RCU assumption and enclosed them between a private rcu_read_lock()/rcu_read_unlock(). This can be dropped when the drivers themselves are reworked. Signed-off-by: Vladimir Oltean --- .../ethernet/freescale/dpaa2/dpaa2-switch.c | 84 +++++++------- .../marvell/prestera/prestera_switchdev.c | 106 +++++++++--------- .../mellanox/mlx5/core/en/rep/bridge.c | 59 +++++++++- .../mellanox/mlxsw/spectrum_switchdev.c | 57 +++++++++- .../microchip/sparx5/sparx5_switchdev.c | 74 ++++++------ drivers/net/ethernet/rocker/rocker_main.c | 74 ++++++------ drivers/net/ethernet/ti/am65-cpsw-switchdev.c | 59 +++++----- drivers/net/ethernet/ti/cpsw_switchdev.c | 62 +++++----- drivers/s390/net/qeth_l2_main.c | 4 +- include/net/switchdev.h | 21 ++++ net/bridge/br_fdb.c | 2 + net/bridge/br_switchdev.c | 10 +- net/dsa/slave.c | 32 +++--- net/switchdev/switchdev.c | 47 ++++++++ 14 files changed, 443 insertions(+), 248 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c index d260993ab2dc..5de475927958 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c @@ -2254,52 +2254,11 @@ static int dpaa2_switch_port_event(struct notifier_block *nb, unsigned long event, void *ptr) { struct net_device *dev = switchdev_notifier_info_to_dev(ptr); - struct ethsw_port_priv *port_priv = netdev_priv(dev); - struct ethsw_switchdev_event_work *switchdev_work; - struct switchdev_notifier_fdb_info *fdb_info = ptr; - struct ethsw_core *ethsw = port_priv->ethsw_data; if (event == SWITCHDEV_PORT_ATTR_SET) return dpaa2_switch_port_attr_set_event(dev, ptr); - if (!dpaa2_switch_port_dev_check(dev)) - return NOTIFY_DONE; - - switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC); - if (!switchdev_work) - return NOTIFY_BAD; - - INIT_WORK(&switchdev_work->work, dpaa2_switch_event_work); - switchdev_work->dev = dev; - switchdev_work->event = event; - - switch (event) { - case SWITCHDEV_FDB_ADD_TO_DEVICE: - case SWITCHDEV_FDB_DEL_TO_DEVICE: - memcpy(&switchdev_work->fdb_info, ptr, - sizeof(switchdev_work->fdb_info)); - switchdev_work->fdb_info.addr = kzalloc(ETH_ALEN, GFP_ATOMIC); - if (!switchdev_work->fdb_info.addr) - goto err_addr_alloc; - - ether_addr_copy((u8 *)switchdev_work->fdb_info.addr, - fdb_info->addr); - - /* Take a reference on the device to avoid being freed. */ - dev_hold(dev); - break; - default: - kfree(switchdev_work); - return NOTIFY_DONE; - } - - queue_work(ethsw->workqueue, &switchdev_work->work); - return NOTIFY_DONE; - -err_addr_alloc: - kfree(switchdev_work); - return NOTIFY_BAD; } static int dpaa2_switch_port_obj_event(unsigned long event, @@ -2324,6 +2283,46 @@ static int dpaa2_switch_port_obj_event(unsigned long event, return notifier_from_errno(err); } +static int dpaa2_switch_fdb_event(unsigned long event, + struct net_device *dev, + struct switchdev_notifier_fdb_info *fdb_info) +{ + struct ethsw_port_priv *port_priv = netdev_priv(dev); + struct ethsw_switchdev_event_work *switchdev_work; + struct ethsw_core *ethsw = port_priv->ethsw_data; + + if (!dpaa2_switch_port_dev_check(dev)) + return NOTIFY_DONE; + + switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC); + if (!switchdev_work) + return NOTIFY_BAD; + + INIT_WORK(&switchdev_work->work, dpaa2_switch_event_work); + switchdev_work->dev = dev; + switchdev_work->event = event; + + memcpy(&switchdev_work->fdb_info, fdb_info, + sizeof(switchdev_work->fdb_info)); + switchdev_work->fdb_info.addr = kzalloc(ETH_ALEN, GFP_ATOMIC); + if (!switchdev_work->fdb_info.addr) + goto err_addr_alloc; + + ether_addr_copy((u8 *)switchdev_work->fdb_info.addr, + fdb_info->addr); + + /* Take a reference on the device to avoid being freed. */ + dev_hold(dev); + + queue_work(ethsw->workqueue, &switchdev_work->work); + + return NOTIFY_DONE; + +err_addr_alloc: + kfree(switchdev_work); + return NOTIFY_BAD; +} + static int dpaa2_switch_port_blocking_event(struct notifier_block *nb, unsigned long event, void *ptr) { @@ -2335,6 +2334,9 @@ static int dpaa2_switch_port_blocking_event(struct notifier_block *nb, return dpaa2_switch_port_obj_event(event, dev, ptr); case SWITCHDEV_PORT_ATTR_SET: return dpaa2_switch_port_attr_set_event(dev, ptr); + case SWITCHDEV_FDB_ADD_TO_DEVICE: + case SWITCHDEV_FDB_DEL_TO_DEVICE: + return dpaa2_switch_fdb_event(event, dev, ptr); } return NOTIFY_DONE; diff --git a/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c b/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c index 3ce6ccd0f539..3f574a69c244 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c @@ -845,10 +845,6 @@ static int prestera_switchdev_event(struct notifier_block *unused, unsigned long event, void *ptr) { struct net_device *dev = switchdev_notifier_info_to_dev(ptr); - struct switchdev_notifier_fdb_info *fdb_info; - struct switchdev_notifier_info *info = ptr; - struct prestera_fdb_event_work *swdev_work; - struct net_device *upper; int err; if (event == SWITCHDEV_PORT_ATTR_SET) { @@ -858,54 +854,7 @@ static int prestera_switchdev_event(struct notifier_block *unused, return notifier_from_errno(err); } - if (!prestera_netdev_check(dev)) - return NOTIFY_DONE; - - upper = netdev_master_upper_dev_get_rcu(dev); - if (!upper) - return NOTIFY_DONE; - - if (!netif_is_bridge_master(upper)) - return NOTIFY_DONE; - - swdev_work = kzalloc(sizeof(*swdev_work), GFP_ATOMIC); - if (!swdev_work) - return NOTIFY_BAD; - - swdev_work->event = event; - swdev_work->dev = dev; - - switch (event) { - case SWITCHDEV_FDB_ADD_TO_DEVICE: - case SWITCHDEV_FDB_DEL_TO_DEVICE: - fdb_info = container_of(info, - struct switchdev_notifier_fdb_info, - info); - - INIT_WORK(&swdev_work->work, prestera_fdb_event_work); - memcpy(&swdev_work->fdb_info, ptr, - sizeof(swdev_work->fdb_info)); - - swdev_work->fdb_info.addr = kzalloc(ETH_ALEN, GFP_ATOMIC); - if (!swdev_work->fdb_info.addr) - goto out_bad; - - ether_addr_copy((u8 *)swdev_work->fdb_info.addr, - fdb_info->addr); - dev_hold(dev); - break; - - default: - kfree(swdev_work); - return NOTIFY_DONE; - } - - queue_work(swdev_wq, &swdev_work->work); return NOTIFY_DONE; - -out_bad: - kfree(swdev_work); - return NOTIFY_BAD; } static int @@ -1101,6 +1050,53 @@ static int prestera_port_obj_del(struct net_device *dev, const void *ctx, } } +static int prestera_switchdev_fdb_event(struct net_device *dev, + unsigned long event, + struct switchdev_notifier_info *info) +{ + struct switchdev_notifier_fdb_info *fdb_info; + struct prestera_fdb_event_work *swdev_work; + struct net_device *upper; + + if (!prestera_netdev_check(dev)) + return 0; + + upper = netdev_master_upper_dev_get_rcu(dev); + if (!upper) + return 0; + + if (!netif_is_bridge_master(upper)) + return 0; + + swdev_work = kzalloc(sizeof(*swdev_work), GFP_ATOMIC); + if (!swdev_work) + return -ENOMEM; + + swdev_work->event = event; + swdev_work->dev = dev; + + fdb_info = container_of(info, struct switchdev_notifier_fdb_info, + info); + + INIT_WORK(&swdev_work->work, prestera_fdb_event_work); + memcpy(&swdev_work->fdb_info, fdb_info, sizeof(swdev_work->fdb_info)); + + swdev_work->fdb_info.addr = kzalloc(ETH_ALEN, GFP_ATOMIC); + if (!swdev_work->fdb_info.addr) + goto out_bad; + + ether_addr_copy((u8 *)swdev_work->fdb_info.addr, + fdb_info->addr); + dev_hold(dev); + + queue_work(swdev_wq, &swdev_work->work); + return 0; + +out_bad: + kfree(swdev_work); + return -ENOMEM; +} + static int prestera_switchdev_blk_event(struct notifier_block *unused, unsigned long event, void *ptr) { @@ -1123,8 +1119,12 @@ static int prestera_switchdev_blk_event(struct notifier_block *unused, prestera_netdev_check, prestera_port_obj_attr_set); break; - default: - err = -EOPNOTSUPP; + case SWITCHDEV_FDB_ADD_TO_DEVICE: + case SWITCHDEV_FDB_DEL_TO_DEVICE: + rcu_read_lock(); + err = prestera_switchdev_fdb_event(dev, event, ptr); + rcu_read_unlock(); + break; } return notifier_from_errno(err); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c index 0c38c2e319be..ea7c3f07f6fe 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c @@ -276,6 +276,55 @@ mlx5_esw_bridge_port_obj_attr_set(struct net_device *dev, return err; } +static struct mlx5_bridge_switchdev_fdb_work * +mlx5_esw_bridge_init_switchdev_fdb_work(struct net_device *dev, bool add, + struct switchdev_notifier_fdb_info *fdb_info, + struct mlx5_esw_bridge_offloads *br_offloads); + +static int +mlx5_esw_bridge_fdb_event(struct net_device *dev, unsigned long event, + struct switchdev_notifier_info *info, + struct mlx5_esw_bridge_offloads *br_offloads) +{ + struct switchdev_notifier_fdb_info *fdb_info; + struct mlx5_bridge_switchdev_fdb_work *work; + struct mlx5_eswitch *esw = br_offloads->esw; + u16 vport_num, esw_owner_vhca_id; + struct net_device *upper, *rep; + + upper = netdev_master_upper_dev_get_rcu(dev); + if (!upper) + return 0; + if (!netif_is_bridge_master(upper)) + return 0; + + rep = mlx5_esw_bridge_rep_vport_num_vhca_id_get(dev, esw, + &vport_num, + &esw_owner_vhca_id); + if (!rep) + return 0; + + /* only handle the event on peers */ + if (mlx5_esw_bridge_is_local(dev, rep, esw)) + return 0; + + fdb_info = container_of(info, struct switchdev_notifier_fdb_info, info); + + work = mlx5_esw_bridge_init_switchdev_fdb_work(dev, + event == SWITCHDEV_FDB_ADD_TO_DEVICE, + fdb_info, + br_offloads); + if (IS_ERR(work)) { + WARN_ONCE(1, "Failed to init switchdev work, err=%ld", + PTR_ERR(work)); + return PTR_ERR(work); + } + + queue_work(br_offloads->wq, &work->work); + + return 0; +} + static int mlx5_esw_bridge_event_blocking(struct notifier_block *nb, unsigned long event, void *ptr) { @@ -295,6 +344,12 @@ static int mlx5_esw_bridge_event_blocking(struct notifier_block *nb, case SWITCHDEV_PORT_ATTR_SET: err = mlx5_esw_bridge_port_obj_attr_set(dev, ptr, br_offloads); break; + case SWITCHDEV_FDB_ADD_TO_DEVICE: + case SWITCHDEV_FDB_DEL_TO_DEVICE: + rcu_read_lock(); + err = mlx5_esw_bridge_fdb_event(dev, event, ptr, br_offloads); + rcu_read_unlock(); + break; default: err = 0; } @@ -415,9 +470,7 @@ static int mlx5_esw_bridge_switchdev_event(struct notifier_block *nb, /* only handle the event on peers */ if (mlx5_esw_bridge_is_local(dev, rep, esw)) break; - fallthrough; - case SWITCHDEV_FDB_ADD_TO_DEVICE: - case SWITCHDEV_FDB_DEL_TO_DEVICE: + fdb_info = container_of(info, struct switchdev_notifier_fdb_info, info); diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c index 22fede5cb32c..791a165fe3aa 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c @@ -3247,8 +3247,6 @@ static int mlxsw_sp_switchdev_event(struct notifier_block *unused, switchdev_work->event = event; switch (event) { - case SWITCHDEV_FDB_ADD_TO_DEVICE: - case SWITCHDEV_FDB_DEL_TO_DEVICE: case SWITCHDEV_FDB_ADD_TO_BRIDGE: case SWITCHDEV_FDB_DEL_TO_BRIDGE: fdb_info = container_of(info, @@ -3513,6 +3511,55 @@ mlxsw_sp_switchdev_handle_vxlan_obj_del(struct net_device *vxlan_dev, } } +static int mlxsw_sp_switchdev_fdb_event(struct net_device *dev, unsigned long event, + struct switchdev_notifier_info *info) +{ + struct mlxsw_sp_switchdev_event_work *switchdev_work; + struct switchdev_notifier_fdb_info *fdb_info; + struct net_device *br_dev; + + /* Tunnel devices are not our uppers, so check their master instead */ + br_dev = netdev_master_upper_dev_get_rcu(dev); + if (!br_dev) + return 0; + if (!netif_is_bridge_master(br_dev)) + return 0; + if (!mlxsw_sp_port_dev_lower_find_rcu(br_dev)) + return 0; + + switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC); + if (!switchdev_work) + return -ENOMEM; + + switchdev_work->dev = dev; + switchdev_work->event = event; + + fdb_info = container_of(info, struct switchdev_notifier_fdb_info, + info); + INIT_WORK(&switchdev_work->work, + mlxsw_sp_switchdev_bridge_fdb_event_work); + memcpy(&switchdev_work->fdb_info, fdb_info, + sizeof(switchdev_work->fdb_info)); + switchdev_work->fdb_info.addr = kzalloc(ETH_ALEN, GFP_ATOMIC); + if (!switchdev_work->fdb_info.addr) + goto err_addr_alloc; + ether_addr_copy((u8 *)switchdev_work->fdb_info.addr, + fdb_info->addr); + /* Take a reference on the device. This can be either + * upper device containig mlxsw_sp_port or just a + * mlxsw_sp_port + */ + dev_hold(dev); + + mlxsw_core_schedule_work(&switchdev_work->work); + + return 0; + +err_addr_alloc: + kfree(switchdev_work); + return NOTIFY_BAD; +} + static int mlxsw_sp_switchdev_blocking_event(struct notifier_block *unused, unsigned long event, void *ptr) { @@ -3541,6 +3588,12 @@ static int mlxsw_sp_switchdev_blocking_event(struct notifier_block *unused, mlxsw_sp_port_dev_check, mlxsw_sp_port_attr_set); return notifier_from_errno(err); + case SWITCHDEV_FDB_ADD_TO_DEVICE: + case SWITCHDEV_FDB_DEL_TO_DEVICE: + rcu_read_lock(); + err = mlxsw_sp_switchdev_fdb_event(dev, event, ptr); + rcu_read_unlock(); + return notifier_from_errno(err); } return NOTIFY_DONE; diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c b/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c index 649ca609884a..7fb9f59d43e0 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c @@ -268,9 +268,6 @@ static int sparx5_switchdev_event(struct notifier_block *unused, unsigned long event, void *ptr) { struct net_device *dev = switchdev_notifier_info_to_dev(ptr); - struct sparx5_switchdev_event_work *switchdev_work; - struct switchdev_notifier_fdb_info *fdb_info; - struct switchdev_notifier_info *info = ptr; int err; switch (event) { @@ -279,39 +276,9 @@ static int sparx5_switchdev_event(struct notifier_block *unused, sparx5_netdevice_check, sparx5_port_attr_set); return notifier_from_errno(err); - case SWITCHDEV_FDB_ADD_TO_DEVICE: - fallthrough; - case SWITCHDEV_FDB_DEL_TO_DEVICE: - switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC); - if (!switchdev_work) - return NOTIFY_BAD; - - switchdev_work->dev = dev; - switchdev_work->event = event; - - fdb_info = container_of(info, - struct switchdev_notifier_fdb_info, - info); - INIT_WORK(&switchdev_work->work, - sparx5_switchdev_bridge_fdb_event_work); - memcpy(&switchdev_work->fdb_info, ptr, - sizeof(switchdev_work->fdb_info)); - switchdev_work->fdb_info.addr = kzalloc(ETH_ALEN, GFP_ATOMIC); - if (!switchdev_work->fdb_info.addr) - goto err_addr_alloc; - - ether_addr_copy((u8 *)switchdev_work->fdb_info.addr, - fdb_info->addr); - dev_hold(dev); - - sparx5_schedule_work(&switchdev_work->work); - break; } return NOTIFY_DONE; -err_addr_alloc: - kfree(switchdev_work); - return NOTIFY_BAD; } static void sparx5_sync_port_dev_addr(struct sparx5 *sparx5, @@ -459,6 +426,43 @@ static int sparx5_handle_port_obj_del(struct net_device *dev, return err; } +static int sparx5_switchdev_fdb_event(struct net_device *dev, unsigned long event, + struct switchdev_notifier_info *info) +{ + struct sparx5_switchdev_event_work *switchdev_work; + struct switchdev_notifier_fdb_info *fdb_info; + + switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC); + if (!switchdev_work) + return -ENOMEM; + + switchdev_work->dev = dev; + switchdev_work->event = event; + + fdb_info = container_of(info, + struct switchdev_notifier_fdb_info, + info); + INIT_WORK(&switchdev_work->work, + sparx5_switchdev_bridge_fdb_event_work); + memcpy(&switchdev_work->fdb_info, fdb_info, + sizeof(switchdev_work->fdb_info)); + switchdev_work->fdb_info.addr = kzalloc(ETH_ALEN, GFP_ATOMIC); + if (!switchdev_work->fdb_info.addr) + goto err_addr_alloc; + + ether_addr_copy((u8 *)switchdev_work->fdb_info.addr, + fdb_info->addr); + dev_hold(dev); + + sparx5_schedule_work(&switchdev_work->work); + + return 0; + +err_addr_alloc: + kfree(switchdev_work); + return -ENOMEM; +} + static int sparx5_switchdev_blocking_event(struct notifier_block *nb, unsigned long event, void *ptr) @@ -478,6 +482,10 @@ static int sparx5_switchdev_blocking_event(struct notifier_block *nb, sparx5_netdevice_check, sparx5_port_attr_set); return notifier_from_errno(err); + case SWITCHDEV_FDB_ADD_TO_DEVICE: + case SWITCHDEV_FDB_DEL_TO_DEVICE: + err = sparx5_switchdev_fdb_event(dev, event, ptr); + return notifier_from_errno(err); } return NOTIFY_DONE; diff --git a/drivers/net/ethernet/rocker/rocker_main.c b/drivers/net/ethernet/rocker/rocker_main.c index 3364b6a56bd1..3132573f5363 100644 --- a/drivers/net/ethernet/rocker/rocker_main.c +++ b/drivers/net/ethernet/rocker/rocker_main.c @@ -2767,9 +2767,6 @@ static int rocker_switchdev_event(struct notifier_block *unused, unsigned long event, void *ptr) { struct net_device *dev = switchdev_notifier_info_to_dev(ptr); - struct rocker_switchdev_event_work *switchdev_work; - struct switchdev_notifier_fdb_info *fdb_info = ptr; - struct rocker_port *rocker_port; if (!rocker_port_dev_check(dev)) return NOTIFY_DONE; @@ -2777,38 +2774,6 @@ static int rocker_switchdev_event(struct notifier_block *unused, if (event == SWITCHDEV_PORT_ATTR_SET) return rocker_switchdev_port_attr_set_event(dev, ptr); - rocker_port = netdev_priv(dev); - switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC); - if (WARN_ON(!switchdev_work)) - return NOTIFY_BAD; - - INIT_WORK(&switchdev_work->work, rocker_switchdev_event_work); - switchdev_work->rocker_port = rocker_port; - switchdev_work->event = event; - - switch (event) { - case SWITCHDEV_FDB_ADD_TO_DEVICE: - case SWITCHDEV_FDB_DEL_TO_DEVICE: - memcpy(&switchdev_work->fdb_info, ptr, - sizeof(switchdev_work->fdb_info)); - switchdev_work->fdb_info.addr = kzalloc(ETH_ALEN, GFP_ATOMIC); - if (unlikely(!switchdev_work->fdb_info.addr)) { - kfree(switchdev_work); - return NOTIFY_BAD; - } - - ether_addr_copy((u8 *)switchdev_work->fdb_info.addr, - fdb_info->addr); - /* Take a reference on the rocker device */ - dev_hold(dev); - break; - default: - kfree(switchdev_work); - return NOTIFY_DONE; - } - - queue_work(rocker_port->rocker->rocker_owq, - &switchdev_work->work); return NOTIFY_DONE; } @@ -2831,6 +2796,42 @@ rocker_switchdev_port_obj_event(unsigned long event, struct net_device *netdev, return notifier_from_errno(err); } +static int +rocker_switchdev_fdb_event(unsigned long event, struct net_device *dev, + struct switchdev_notifier_fdb_info *fdb_info) +{ + struct rocker_switchdev_event_work *switchdev_work; + struct switchdev_notifier_fdb_info *fdb_info = ptr; + struct rocker_port *rocker_port; + + rocker_port = netdev_priv(dev); + switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC); + if (WARN_ON(!switchdev_work)) + return NOTIFY_BAD; + + INIT_WORK(&switchdev_work->work, rocker_switchdev_event_work); + switchdev_work->rocker_port = rocker_port; + switchdev_work->event = event; + + memcpy(&switchdev_work->fdb_info, ptr, + sizeof(switchdev_work->fdb_info)); + switchdev_work->fdb_info.addr = kzalloc(ETH_ALEN, GFP_ATOMIC); + if (unlikely(!switchdev_work->fdb_info.addr)) { + kfree(switchdev_work); + return NOTIFY_BAD; + } + + ether_addr_copy((u8 *)switchdev_work->fdb_info.addr, + fdb_info->addr); + /* Take a reference on the rocker device */ + dev_hold(dev); + + queue_work(rocker_port->rocker->rocker_owq, + &switchdev_work->work); + + return NOTIFY_DONE; +} + static int rocker_switchdev_blocking_event(struct notifier_block *unused, unsigned long event, void *ptr) { @@ -2845,6 +2846,9 @@ static int rocker_switchdev_blocking_event(struct notifier_block *unused, return rocker_switchdev_port_obj_event(event, dev, ptr); case SWITCHDEV_PORT_ATTR_SET: return rocker_switchdev_port_attr_set_event(dev, ptr); + case SWITCHDEV_FDB_ADD_TO_DEVICE: + case SWITCHDEV_FDB_DEL_TO_DEVICE: + return rocker_switchdev_fdb_event(event, dev, ptr); } return NOTIFY_DONE; diff --git a/drivers/net/ethernet/ti/am65-cpsw-switchdev.c b/drivers/net/ethernet/ti/am65-cpsw-switchdev.c index 599708a3e81d..c1627e261948 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-switchdev.c +++ b/drivers/net/ethernet/ti/am65-cpsw-switchdev.c @@ -424,9 +424,6 @@ static int am65_cpsw_switchdev_event(struct notifier_block *unused, unsigned long event, void *ptr) { struct net_device *ndev = switchdev_notifier_info_to_dev(ptr); - struct am65_cpsw_switchdev_event_work *switchdev_work; - struct am65_cpsw_port *port = am65_ndev_to_port(ndev); - struct switchdev_notifier_fdb_info *fdb_info = ptr; int err; if (event == SWITCHDEV_PORT_ATTR_SET) { @@ -436,47 +433,49 @@ static int am65_cpsw_switchdev_event(struct notifier_block *unused, return notifier_from_errno(err); } + return NOTIFY_DONE; +} + +static struct notifier_block cpsw_switchdev_notifier = { + .notifier_call = am65_cpsw_switchdev_event, +}; + +static int am65_cpsw_switchdev_fdb_event(struct net_device *ndev, + unsigned long event, + struct switchdev_notifier_fdb_info *fdb_info) +{ + struct am65_cpsw_switchdev_event_work *switchdev_work; + struct am65_cpsw_port *port = am65_ndev_to_port(ndev); + if (!am65_cpsw_port_dev_check(ndev)) - return NOTIFY_DONE; + return 0; switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC); if (WARN_ON(!switchdev_work)) - return NOTIFY_BAD; + return -ENOMEM; INIT_WORK(&switchdev_work->work, am65_cpsw_switchdev_event_work); switchdev_work->port = port; switchdev_work->event = event; - switch (event) { - case SWITCHDEV_FDB_ADD_TO_DEVICE: - case SWITCHDEV_FDB_DEL_TO_DEVICE: - memcpy(&switchdev_work->fdb_info, ptr, - sizeof(switchdev_work->fdb_info)); - switchdev_work->fdb_info.addr = kzalloc(ETH_ALEN, GFP_ATOMIC); - if (!switchdev_work->fdb_info.addr) - goto err_addr_alloc; - ether_addr_copy((u8 *)switchdev_work->fdb_info.addr, - fdb_info->addr); - dev_hold(ndev); - break; - default: - kfree(switchdev_work); - return NOTIFY_DONE; - } + memcpy(&switchdev_work->fdb_info, ptr, + sizeof(switchdev_work->fdb_info)); + switchdev_work->fdb_info.addr = kzalloc(ETH_ALEN, GFP_ATOMIC); + if (!switchdev_work->fdb_info.addr) + goto err_addr_alloc; + ether_addr_copy((u8 *)switchdev_work->fdb_info.addr, + fdb_info->addr); + dev_hold(ndev); queue_work(system_long_wq, &switchdev_work->work); - return NOTIFY_DONE; + return 0; err_addr_alloc: kfree(switchdev_work); - return NOTIFY_BAD; + return -ENOMEM; } -static struct notifier_block cpsw_switchdev_notifier = { - .notifier_call = am65_cpsw_switchdev_event, -}; - static int am65_cpsw_switchdev_blocking_event(struct notifier_block *unused, unsigned long event, void *ptr) { @@ -499,8 +498,10 @@ static int am65_cpsw_switchdev_blocking_event(struct notifier_block *unused, am65_cpsw_port_dev_check, am65_cpsw_port_attr_set); return notifier_from_errno(err); - default: - break; + case SWITCHDEV_FDB_ADD_TO_DEVICE: + case SWITCHDEV_FDB_DEL_TO_DEVICE: + err = am65_cpsw_switchdev_fdb_event(dev, event, ptr); + return notifier_from_errno(err); } return NOTIFY_DONE; diff --git a/drivers/net/ethernet/ti/cpsw_switchdev.c b/drivers/net/ethernet/ti/cpsw_switchdev.c index a7d97d429e06..cb047bc8d9d6 100644 --- a/drivers/net/ethernet/ti/cpsw_switchdev.c +++ b/drivers/net/ethernet/ti/cpsw_switchdev.c @@ -434,9 +434,6 @@ static int cpsw_switchdev_event(struct notifier_block *unused, unsigned long event, void *ptr) { struct net_device *ndev = switchdev_notifier_info_to_dev(ptr); - struct switchdev_notifier_fdb_info *fdb_info = ptr; - struct cpsw_switchdev_event_work *switchdev_work; - struct cpsw_priv *priv = netdev_priv(ndev); int err; if (event == SWITCHDEV_PORT_ATTR_SET) { @@ -446,47 +443,50 @@ static int cpsw_switchdev_event(struct notifier_block *unused, return notifier_from_errno(err); } - if (!cpsw_port_dev_check(ndev)) - return NOTIFY_DONE; + return NOTIFY_DONE; +} + +static struct notifier_block cpsw_switchdev_notifier = { + .notifier_call = cpsw_switchdev_event, +}; + +static int cpsw_switchdev_fdb_event(struct net_device *dev, unsigned long event, + struct switchdev_notifier_fdb_info *fdb_info) +{ + struct cpsw_switchdev_event_work *switchdev_work; + struct cpsw_priv *priv; + + if (!cpsw_port_dev_check(dev)) + return 0; + + priv = netdev_priv(dev); switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC); if (WARN_ON(!switchdev_work)) - return NOTIFY_BAD; + return -ENOMEM; INIT_WORK(&switchdev_work->work, cpsw_switchdev_event_work); switchdev_work->priv = priv; switchdev_work->event = event; - switch (event) { - case SWITCHDEV_FDB_ADD_TO_DEVICE: - case SWITCHDEV_FDB_DEL_TO_DEVICE: - memcpy(&switchdev_work->fdb_info, ptr, - sizeof(switchdev_work->fdb_info)); - switchdev_work->fdb_info.addr = kzalloc(ETH_ALEN, GFP_ATOMIC); - if (!switchdev_work->fdb_info.addr) - goto err_addr_alloc; - ether_addr_copy((u8 *)switchdev_work->fdb_info.addr, - fdb_info->addr); - dev_hold(ndev); - break; - default: - kfree(switchdev_work); - return NOTIFY_DONE; - } + memcpy(&switchdev_work->fdb_info, fdb_info, + sizeof(switchdev_work->fdb_info)); + switchdev_work->fdb_info.addr = kzalloc(ETH_ALEN, GFP_ATOMIC); + if (!switchdev_work->fdb_info.addr) + goto err_addr_alloc; + ether_addr_copy((u8 *)switchdev_work->fdb_info.addr, + fdb_info->addr); + dev_hold(dev); queue_work(system_long_wq, &switchdev_work->work); - return NOTIFY_DONE; + return 0; err_addr_alloc: kfree(switchdev_work); - return NOTIFY_BAD; + return -ENOMEM; } -static struct notifier_block cpsw_switchdev_notifier = { - .notifier_call = cpsw_switchdev_event, -}; - static int cpsw_switchdev_blocking_event(struct notifier_block *unused, unsigned long event, void *ptr) { @@ -509,8 +509,10 @@ static int cpsw_switchdev_blocking_event(struct notifier_block *unused, cpsw_port_dev_check, cpsw_port_attr_set); return notifier_from_errno(err); - default: - break; + case SWITCHDEV_FDB_ADD_TO_DEVICE: + case SWITCHDEV_FDB_DEL_TO_DEVICE: + err = cpsw_switchdev_fdb_event(dev, event, ptr); + return notifier_from_errno(err); } return NOTIFY_DONE; diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c index 72e84ff9fea5..367d15937eae 100644 --- a/drivers/s390/net/qeth_l2_main.c +++ b/drivers/s390/net/qeth_l2_main.c @@ -904,7 +904,7 @@ static void qeth_l2_br2dev_get(void) int rc; if (!refcount_inc_not_zero(&qeth_l2_switchdev_notify_refcnt)) { - rc = register_switchdev_notifier(&qeth_l2_sw_notifier); + rc = register_switchdev_blocking_notifier(&qeth_l2_sw_notifier); if (rc) { QETH_DBF_MESSAGE(2, "failed to register qeth_l2_sw_notifier: %d\n", @@ -924,7 +924,7 @@ static void qeth_l2_br2dev_put(void) int rc; if (refcount_dec_and_test(&qeth_l2_switchdev_notify_refcnt)) { - rc = unregister_switchdev_notifier(&qeth_l2_sw_notifier); + rc = unregister_switchdev_blocking_notifier(&qeth_l2_sw_notifier); if (rc) { QETH_DBF_MESSAGE(2, "failed to unregister qeth_l2_sw_notifier: %d\n", diff --git a/include/net/switchdev.h b/include/net/switchdev.h index 60d806b6a5ae..ff61df255142 100644 --- a/include/net/switchdev.h +++ b/include/net/switchdev.h @@ -283,6 +283,13 @@ int switchdev_port_obj_add(struct net_device *dev, int switchdev_port_obj_del(struct net_device *dev, const struct switchdev_obj *obj); +int +switchdev_fdb_add_to_device(struct net_device *dev, + const struct switchdev_notifier_fdb_info *fdb_info); +int +switchdev_fdb_del_to_device(struct net_device *dev, + const struct switchdev_notifier_fdb_info *fdb_info); + int register_switchdev_notifier(struct notifier_block *nb); int unregister_switchdev_notifier(struct notifier_block *nb); int call_switchdev_notifiers(unsigned long val, struct net_device *dev, @@ -386,6 +393,20 @@ static inline int switchdev_port_obj_del(struct net_device *dev, return -EOPNOTSUPP; } +static inline int +switchdev_fdb_add_to_device(struct net_device *dev, + const struct switchdev_notifier_fdb_info *fdb_info) +{ + return -EOPNOTSUPP; +} + +static inline int +switchdev_fdb_del_to_device(struct net_device *dev, + const struct switchdev_notifier_fdb_info *fdb_info) +{ + return -EOPNOTSUPP; +} + static inline int register_switchdev_notifier(struct notifier_block *nb) { return 0; diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c index 46812b659710..0bdbcfc53914 100644 --- a/net/bridge/br_fdb.c +++ b/net/bridge/br_fdb.c @@ -763,6 +763,8 @@ int br_fdb_replay(const struct net_device *br_dev, const void *ctx, bool adding, if (!nb) return 0; + ASSERT_RTNL(); + if (!netif_is_bridge_master(br_dev)) return -EINVAL; diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c index 6bf518d78f02..cd413b010567 100644 --- a/net/bridge/br_switchdev.c +++ b/net/bridge/br_switchdev.c @@ -138,12 +138,10 @@ br_switchdev_fdb_notify(struct net_bridge *br, switch (type) { case RTM_DELNEIGH: - call_switchdev_notifiers(SWITCHDEV_FDB_DEL_TO_DEVICE, - dev, &info.info, NULL); + switchdev_fdb_del_to_device(dev, &info); break; case RTM_NEWNEIGH: - call_switchdev_notifiers(SWITCHDEV_FDB_ADD_TO_DEVICE, - dev, &info.info, NULL); + switchdev_fdb_add_to_device(dev, &info); break; } } @@ -287,7 +285,7 @@ static int nbp_switchdev_sync_objs(struct net_bridge_port *p, const void *ctx, if (err && err != -EOPNOTSUPP) return err; - err = br_fdb_replay(br_dev, ctx, true, atomic_nb); + err = br_fdb_replay(br_dev, ctx, true, blocking_nb); if (err && err != -EOPNOTSUPP) return err; @@ -306,7 +304,7 @@ static void nbp_switchdev_unsync_objs(struct net_bridge_port *p, br_mdb_replay(br_dev, dev, ctx, false, blocking_nb, NULL); - br_fdb_replay(br_dev, ctx, false, atomic_nb); + br_fdb_replay(br_dev, ctx, false, blocking_nb); } /* Let the bridge know that this port is offloaded, so that it can assign a diff --git a/net/dsa/slave.c b/net/dsa/slave.c index eb9d9e53c536..249303ac3c3c 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -2454,20 +2454,6 @@ static int dsa_slave_switchdev_event(struct notifier_block *unused, dsa_slave_dev_check, dsa_slave_port_attr_set); return notifier_from_errno(err); - case SWITCHDEV_FDB_ADD_TO_DEVICE: - err = switchdev_handle_fdb_add_to_device(dev, ptr, - dsa_slave_dev_check, - dsa_foreign_dev_check, - dsa_slave_fdb_add_to_device, - NULL); - return notifier_from_errno(err); - case SWITCHDEV_FDB_DEL_TO_DEVICE: - err = switchdev_handle_fdb_del_to_device(dev, ptr, - dsa_slave_dev_check, - dsa_foreign_dev_check, - dsa_slave_fdb_del_to_device, - NULL); - return notifier_from_errno(err); default: return NOTIFY_DONE; } @@ -2497,6 +2483,24 @@ static int dsa_slave_switchdev_blocking_event(struct notifier_block *unused, dsa_slave_dev_check, dsa_slave_port_attr_set); return notifier_from_errno(err); + case SWITCHDEV_FDB_ADD_TO_DEVICE: + rcu_read_lock(); + err = switchdev_handle_fdb_add_to_device(dev, ptr, + dsa_slave_dev_check, + dsa_foreign_dev_check, + dsa_slave_fdb_add_to_device, + NULL); + rcu_read_unlock(); + return notifier_from_errno(err); + case SWITCHDEV_FDB_DEL_TO_DEVICE: + rcu_read_lock(); + err = switchdev_handle_fdb_del_to_device(dev, ptr, + dsa_slave_dev_check, + dsa_foreign_dev_check, + dsa_slave_fdb_del_to_device, + NULL); + rcu_read_unlock(); + return notifier_from_errno(err); } return NOTIFY_DONE; diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c index 0b2c18efc079..c34c6abceec6 100644 --- a/net/switchdev/switchdev.c +++ b/net/switchdev/switchdev.c @@ -378,6 +378,53 @@ int call_switchdev_blocking_notifiers(unsigned long val, struct net_device *dev, } EXPORT_SYMBOL_GPL(call_switchdev_blocking_notifiers); +static void switchdev_fdb_add_deferred(struct net_device *dev, const void *data) +{ + const struct switchdev_notifier_fdb_info *fdb_info = data; + struct switchdev_notifier_fdb_info tmp = *fdb_info; + int err; + + ASSERT_RTNL(); + err = call_switchdev_blocking_notifiers(SWITCHDEV_FDB_ADD_TO_DEVICE, + dev, &tmp.info, NULL); + err = notifier_to_errno(err); + if (err && err != -EOPNOTSUPP) + netdev_err(dev, "failed to add FDB entry: %pe\n", ERR_PTR(err)); +} + +static void switchdev_fdb_del_deferred(struct net_device *dev, const void *data) +{ + const struct switchdev_notifier_fdb_info *fdb_info = data; + struct switchdev_notifier_fdb_info tmp = *fdb_info; + int err; + + ASSERT_RTNL(); + err = call_switchdev_blocking_notifiers(SWITCHDEV_FDB_DEL_TO_DEVICE, + dev, &tmp.info, NULL); + err = notifier_to_errno(err); + if (err && err != -EOPNOTSUPP) + netdev_err(dev, "failed to delete FDB entry: %pe\n", + ERR_PTR(err)); +} + +int +switchdev_fdb_add_to_device(struct net_device *dev, + const struct switchdev_notifier_fdb_info *fdb_info) +{ + return switchdev_deferred_enqueue(dev, fdb_info, sizeof(*fdb_info), + switchdev_fdb_add_deferred); +} +EXPORT_SYMBOL_GPL(switchdev_fdb_add_to_device); + +int +switchdev_fdb_del_to_device(struct net_device *dev, + const struct switchdev_notifier_fdb_info *fdb_info) +{ + return switchdev_deferred_enqueue(dev, fdb_info, sizeof(*fdb_info), + switchdev_fdb_del_deferred); +} +EXPORT_SYMBOL_GPL(switchdev_fdb_del_to_device); + struct switchdev_nested_priv { bool (*check_cb)(const struct net_device *dev); bool (*foreign_dev_check_cb)(const struct net_device *dev, From patchwork Wed Aug 18 12:01:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 500289 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CE94C4338F for ; Wed, 18 Aug 2021 12:05:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1AE0C60F39 for ; Wed, 18 Aug 2021 12:05:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236138AbhHRMEK (ORCPT ); Wed, 18 Aug 2021 08:04:10 -0400 Received: from mail-eopbgr00085.outbound.protection.outlook.com ([40.107.0.85]:55044 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235875AbhHRMDy (ORCPT ); Wed, 18 Aug 2021 08:03:54 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W4b2YfSJGu4ODDMbQsxuwqoo46+5OCbUwTvpOOfy/4U4UjGR8Ni3G6raEwQ6EZA1eizlN1qnfAxX8gcJ2h3FX8Ff1h0Po6gwhoRlIltlmV6s/81SWqS5VqNgYxY1fNfIrLELWTOP26M7h0oWsNmi4TmqgW2Jy/EqDnCZM7qdNNCxsf4co4qScoyQu6P6o7JnstWEPjub6CUNFpjgGgaPxBy8A+PspQ4kyn350uwgKKUuJwPZHKSs5xDypGABeOy5AN28VKOHzVmIsjTj44knJAjRI4Yy9rMRmmM86ByBBPWoIv5GlavHRjuENxhmn6dPk9NA1WDzza6KsRonA2zFzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BhSeQrhhCbH++pHC+OWvYkhnt60HoMDgsU19qU8cy/8=; b=JCZdRm0Q/SbMDG0N7PRy2ev3YVo3Uo3SkCwMvT2qtIbH/hEjL7DCQnl8dJ5oTXiyTZn5HlpX5BUaqNfq5e8rIH4mPvT7vRyApI4x02nHgCc2nljOyoKZskYYEhl6b251g0UyvdZTF39DgxS1xKnXd0v/t+4xcILalqUkc4bPtJ8qLWR11QFU/l9wGEU7rbYFozC/1DU62gpJ/yErnxTMDdWnkjrfPfsGmRZ5LOo8rbUlMGW32M7imfNpwBm563egqexyqYagHFpQfTd731RiRe0PeTZ5K6ZgApjCoKXyUz6yHM2sJ4dqNTLJnOKvd2DBLRtNeGW5Ur74mkX3Zp7Rsg== 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=BhSeQrhhCbH++pHC+OWvYkhnt60HoMDgsU19qU8cy/8=; b=fXjuPRVvjoniT2szr0uRQSOEhjszcYaLTLByK39J1ayRI9GxjIvjbJFVMilo+3p9Aduv/+su9e3AErAg4O/sPE1GUmXJKAbHbgqKZeHilvj6A6kQBMq2b5zHdyBW4IjnDw8jo9mTghExesAczfMx+Vx9m5I+1w5vB3NEc/xfc+I= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB3839.eurprd04.prod.outlook.com (2603:10a6:803:21::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17; Wed, 18 Aug 2021 12:02:57 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4415.024; Wed, 18 Aug 2021 12:02:57 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Roopa Prabhu , Nikolay Aleksandrov , Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean , Vadym Kochan , Taras Chornyi , Jiri Pirko , Ido Schimmel , UNGLinuxDriver@microchip.com, Grygorii Strashko , Marek Behun , DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Claudiu Manoil , Alexandre Belloni , George McCollister , Ioana Ciornei , Saeed Mahameed , Leon Romanovsky , Lars Povlsen , Steen Hegelund , Julian Wiedmann , Karsten Graul , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Ivan Vecera , Vlad Buslov , Jianbo Liu , Mark Bloch , Roi Dayan , Tobias Waldekranz , Vignesh Raghavendra , Jesse Brandeburg , Peter Ujfalusi Subject: [RFC PATCH net-next 05/20] net: bridge: switchdev: make br_fdb_replay offer sleepable context to consumers Date: Wed, 18 Aug 2021 15:01:35 +0300 Message-Id: <20210818120150.892647-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818120150.892647-1-vladimir.oltean@nxp.com> References: <20210818120150.892647-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 18 Aug 2021 12:02:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2da69ab7-ecb4-4730-a43b-08d962401e02 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3839: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TvF8ZRomPvLGwax3yQP0sEbGfzBXltakdR1F6njcAMBLvV8N0fmckxgUTmc7ew6d5IQ/BcdkJi6fRIFHUMlMZIx9iJA7dSIVsTSXnfJkzm4sJbKustkxP50jNGsDLNO0zLFfJYnmPNnQtqp2oP4fqlNS7WA8Pfy+dGGyUqURSN1qFmnfYF5Pm/4nJ1RZcilhmypFj+FY/82T99YJJESrNqNt7SGSXZ63BmjyYeAchTNX7XJAZ2oqph9+xKdYsxTY/XIXKjG+jG1hW81W2TKATzOzQ0AkF+za7eCDkVh57NxvkzyVI7qEHTyENOfYpQLyXDNAzXJiUGS47YMuiKDpMpw4g9gC963nlxU7j/6uJh8TA56VvXGjPkEWZNjQ789ygI3ub6Cq7fp+cGk1Ygj2ILiEhwx3vyJmrladksR9jQYHSG22XpQcC0jFUAyBVRohLzRrgEd8EhAyyA/B71J/BudSLEt84IVehKUy2w/K7UKj9bklGUU3c2dHkXEmhlGRP4i8e1hDfqNOI0iwROYBDME6cBHseQand+MrMjrVV0Jwa+YjqI7sFoaFdRUrkDliXPJMIRerg2UaX3FlMWLd/erDMCZV1DrEYnBF7AIspQjZyp9qKtS01aJDfXgZ9T58MDR+Oas+YUtaf/oNsAIc+VQy6IyyqjUah3Y/vYAeboa68wrGW55YMsh5OlnGfCrNVNGF1iqm6JXXyE09mWHINQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(346002)(136003)(39840400004)(366004)(376002)(66476007)(2906002)(66556008)(8936002)(6506007)(186003)(7406005)(7416002)(52116002)(26005)(86362001)(66946007)(6486002)(44832011)(36756003)(5660300002)(1076003)(110136005)(54906003)(6512007)(8676002)(316002)(6666004)(38350700002)(38100700002)(956004)(478600001)(83380400001)(2616005)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vSrZ0Fn7lhucB5x22F1aWDoA9qj5A2kRtPfTP0GxHNInW+NcgoFrugBcb74/Xoh102loOObbIt+r1F+D6RfvZKNAo/tpKVjU6TsV+MVdt+u08hrZDol6SRaSoRBs6MlZ/rTU4BY1flj6zo/4Y9JGWXT490iS48fobcN5/e5BwuSfQaEocuGrq8ra9qwFFsH12stznvTJwdlI7cVLvw2XOGM5jYQHREmaQ6gJ34t+v9qWivi25UPfGrGi0uQdYPWxqHWRlvmebisBmiC18BNXIUef6q1K3ApoSQaN91xxYomyQtiB4pgI8rZ1degkVQbZUFff218/PMGZ3gEOeMg5AekribDfK7ruyzajLVUaMc7/ryd+sy+zlvjkrWSOb0L3gOGarfotCpxE9e0tAj0JD6G4/4eNztkDIoXWnyf6CGJCtTdjLxHHazLCY5yaEEOt2JSI8s1LWKTK84QHfyDQovvIz23uA4FMLBAsaEc/K3YrDPCVPiw7vLFf9mjkIO9JnZk/0gOAlBY6D18sj8P+IERRVk74ket8Gx7sdEVDO+CIET7i/hqF46O1e9np6B9Ven2ojFW7uhsLBTSy8PYFAC+w2oTEzioDfa7BCELuRPLif/Fx6IFPFgIfN6vbbf2vkKIkyhFRhb0Sor5kWsqQGSf2MrR9tLcabsCmNZyeUKml0FoU9KgDklxCzFxhNKDORRkxAUvQkgPM0WIQ3m+nm0RyhTQQUFxDC/9rJHZUZ5V63PIvrcsmx0eunnN/mjbEu4xQdUNo5fC/pLlUQ+lnFXEWkgFhgM4GwqczAGPnQXeO8cU+a6WM+UTtKTc6uIsBKW5249Ib1BAmgzafyeGURuQRmG0kUvUyxUdURnuoGGvpo+Vns/ZKlwd3UqsqOYOV6ZWz0wsxOMzVxIGyHuSUSgMUarz3tbbKueG4z7R/bSWiqbWAnVWIfE6qfalw3EJyDVZOQpqvSjNXye96XQpiKghV1H6ig0Sg7AsnGYtiyItSnWpO1Y/aODrvUf9vXbzHVO94PXr7v0/XCdlf0W8QMkfuaiXjdIlRg+Fk7GgfeJjQNbu836yS1R1xohGdRVcH/SgmJ0NLxl0EFMRNcNbwRSLhvXCalfhe+DEWnLmLQ2DdyE9FSFqpKkaQZiSBR7jDYTcjEoUN8z5MJwC7EM8EQRx5SHH4VJuEFfOqBq5Vh/WwdY25GVD83D4cyTqyasOfKmBvYcQYod5VWmNSmjT0M6MkebOFaeT3IkgCCZoplp2adHrAdc11R/pdzY62veTOdH3+tSqxl/6yrr6PSO7gRqjO/5puJtBklqNT6pgPKBIiWr6k8I5Aa9RI8B7YKYF4 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2da69ab7-ecb4-4730-a43b-08d962401e02 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2021 12:02:57.2803 (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: 5py9AdncG7p4R9pJYbaKwuj4Loz3j10/7Db9+JlmyJGrybJCUJuyCWb/PI25a+Q82Qm6r12HIa6VnetS7N0RIg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3839 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Now that the SWITCHDEV_FDB_{ADD,DEL}_TO_DEVICE events are notified on the blocking chain, it would be nice if we could also drop the rcu_read_lock() atomic context from br_fdb_replay() so that drivers can actually benefit from the blocking context and simplify their logic. Do something similar to what is done in br_mdb_queue_one/br_mdb_replay_one, except the fact that FDB entries are held in a hash list. Signed-off-by: Vladimir Oltean --- net/bridge/br_fdb.c | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c index 0bdbcfc53914..36f4e3b8d21b 100644 --- a/net/bridge/br_fdb.c +++ b/net/bridge/br_fdb.c @@ -752,12 +752,28 @@ static int br_fdb_replay_one(struct net_bridge *br, struct notifier_block *nb, return notifier_to_errno(err); } +static int br_fdb_queue_one(struct hlist_head *fdb_list, + const struct net_bridge_fdb_entry *fdb) +{ + struct net_bridge_fdb_entry *fdb_new; + + fdb_new = kmemdup(fdb, sizeof(*fdb), GFP_ATOMIC); + if (!fdb_new) + return -ENOMEM; + + hlist_add_head_rcu(&fdb_new->fdb_node, fdb_list); + + return 0; +} + int br_fdb_replay(const struct net_device *br_dev, const void *ctx, bool adding, struct notifier_block *nb) { struct net_bridge_fdb_entry *fdb; + struct hlist_node *tmp; struct net_bridge *br; unsigned long action; + HLIST_HEAD(fdb_list); int err = 0; if (!nb) @@ -770,20 +786,34 @@ int br_fdb_replay(const struct net_device *br_dev, const void *ctx, bool adding, br = netdev_priv(br_dev); + rcu_read_lock(); + + hlist_for_each_entry_rcu(fdb, &br->fdb_list, fdb_node) { + err = br_fdb_queue_one(&fdb_list, fdb); + if (err) { + rcu_read_unlock(); + goto out_free_fdb; + } + } + + rcu_read_unlock(); + if (adding) action = SWITCHDEV_FDB_ADD_TO_DEVICE; else action = SWITCHDEV_FDB_DEL_TO_DEVICE; - rcu_read_lock(); - - hlist_for_each_entry_rcu(fdb, &br->fdb_list, fdb_node) { + hlist_for_each_entry(fdb, &fdb_list, fdb_node) { err = br_fdb_replay_one(br, nb, fdb, action, ctx); if (err) break; } - rcu_read_unlock(); +out_free_fdb: + hlist_for_each_entry_safe(fdb, tmp, &fdb_list, fdb_node) { + hlist_del_rcu(&fdb->fdb_node); + kfree(fdb); + } return err; } From patchwork Wed Aug 18 12:01:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 499562 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E9F9C4338F for ; Wed, 18 Aug 2021 12:03:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 11C0C60F39 for ; Wed, 18 Aug 2021 12:03:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235891AbhHRMET (ORCPT ); Wed, 18 Aug 2021 08:04:19 -0400 Received: from mail-eopbgr00067.outbound.protection.outlook.com ([40.107.0.67]:52143 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235738AbhHRMEA (ORCPT ); Wed, 18 Aug 2021 08:04:00 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i/CFkVg+6MqidlD2uvQK2Uow5IP6jSRB1ae1vkFkfgkHCtjkvz9d3Dy1yrnxoKe8HP4zkx7wAdeFB6Zf0wRuDtzyF2ikoKgVAexApX8PHAgbI+bHObrLm9CaudfQuJYJYuxXDdn7LTBJR65WVRLlXz5RLS0OI7uoZOMS1c6cN3zqdj3b+nTNdYwb4O9SlXYC96fNob8mz8Nit0+0kGUvYYkNjNIEUJ5LKQ/CiWOXIK3am4+Em9ckSOBNJEzxn0HXQZGXJU6r2iOkblMqw5jjisCwGl772NvF0Yrfmd7/byWVr0b/mKdNgB4K7D+P7hwJUGSWgyeDuNV1BKoFPREc8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xN+qd67Skj3T1WnSi5unbqEgKdX6/OG2sCxeO8TB/xM=; b=GcsPbDLvQvSunasc2d57UAhQPYMRCcO0umD1hW3VXjuVhBgNkk1DOBedySMbo9f3jYNlaDvngs0GNxJKmOJPgGcjTjHwI8jKTJ1EK3oMjeZkra9o4OJwq22xgYFon87/ll8E1IOro1av3q0AfHAqV0iQ02SddMtZwgVCZdGYjGW3RfupoiDByA2ixfC1lj8uVqeT6hYbm4CAX+oExZI1Opqdd/BPN3PB1xFrZIKUEN7M4hv0vZyas3FL7c5V75KROUaWRbU/dTnssO3RhIfw408bLy8O4qX+9+vhs+cPUZJ5afPdSaB6xmqXSP7U3c+LPUxDkNTMDo/ci/CVEkL3GA== 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=xN+qd67Skj3T1WnSi5unbqEgKdX6/OG2sCxeO8TB/xM=; b=ZMa8iCjKexg2z7TZDAQHWrJPkOAIUTieMP3pvG2HbvWoGCBXjURd39bOau/NXbLoXBTwu2PPjEGLGqczAfCAq1d4Is+Jch3jjcN92dYIKBlNzO/J1R3TzjEJ1wMD+TI1UQt6Melkbdw9JXZUQrKoPUhI6tzQ6Dj0GslN7312qhA= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB3839.eurprd04.prod.outlook.com (2603:10a6:803:21::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17; Wed, 18 Aug 2021 12:02:58 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4415.024; Wed, 18 Aug 2021 12:02:58 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Roopa Prabhu , Nikolay Aleksandrov , Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean , Vadym Kochan , Taras Chornyi , Jiri Pirko , Ido Schimmel , UNGLinuxDriver@microchip.com, Grygorii Strashko , Marek Behun , DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Claudiu Manoil , Alexandre Belloni , George McCollister , Ioana Ciornei , Saeed Mahameed , Leon Romanovsky , Lars Povlsen , Steen Hegelund , Julian Wiedmann , Karsten Graul , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Ivan Vecera , Vlad Buslov , Jianbo Liu , Mark Bloch , Roi Dayan , Tobias Waldekranz , Vignesh Raghavendra , Jesse Brandeburg , Peter Ujfalusi Subject: [RFC PATCH net-next 06/20] net: switchdev: drop the atomic notifier block from switchdev_bridge_port_{, un}offload Date: Wed, 18 Aug 2021 15:01:36 +0300 Message-Id: <20210818120150.892647-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818120150.892647-1-vladimir.oltean@nxp.com> References: <20210818120150.892647-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 18 Aug 2021 12:02:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7e5b8cda-d6de-42dd-4811-08d962401ed1 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3839: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uhROQpPvzDYk4G9T/ZkHp/lRxrG1PSdE5wFLU6PCkvW9cujWW+Teo39MAvt/kGH5INMIKU3YnV1zDSLov5F+PUv6iVHl09CVOnKUGwrLwFnDTGmmAzhzKCX+2itOvj1MPaL575Kr6OroWFN/EA9Bj43Py9Pptrz5vsgUsewr8g0vCmX33fYUKYA3jhU8lhWeaS430eVvQJqlz1h4gcYdF+GA3GDirCQHt8gt2i49Eh13vV7eTHXTY9QTw/gF7wS7vzP8VwI+ulm1p2YHmiDdDINcPhMF2C+l6D2zeuYgFLwKEMtd7Q+U8QpPRt5NvK2VPqIkreRO9TUwrDLlf+oZOoNEOOK/+8kFZa2UaZyhDvoN/O718EzNsVFrVcVvLARu9KU5c8qxgDsQSKV+7B6SzkXRK+UtZFE/WvWUPWnqIAX5JMjUcaSXpaFIgeSiY1Yi2Exg1Q2yg5gFsYurCrcUlrGatHwTmr7IejIfgm1Fnbe6YVAvV46/avsZbu0jCD3g+yAj+Mxvzg2Mk6aHOZ3Jjm7mZuYuDb4CXfY0MlnymhzbHTxVr5dAjgSUPDoZTidN X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(346002)(136003)(39840400004)(366004)(376002)(66476007)(2906002)(66556008)(8936002)(6506007)(186003)(7406005)(7416002)(52116002)(26005)(86362001)(66946007)(6486002)(44832011)(36756003)(30864003)(5660300002)(1076003)(110136005)(54906003)(6512007)(8676002)(316002)(6666004)(38350700002)(38100700002)(956004)(478600001)(83380400001)(2616005)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: njbbwQhTO5/TxMpjsUvyynWqoY9bPggnymcyuyermTaN7D6TRzeJ+EBdgP08FOU9KCVODESWyF492ohSOADw3M2iV8FS3TojgJkPWfJIgtSF+A60//yP+yP+zfaElmTDEzI/H2BeypXBAw24ZHfT0Z8tNcxGEDzRDKSPBxo/kr+K7FPDjwAdsCaFoirOQ5L12UfmCiuk7KSq5jhsh8c8eJSxfWOZcdLne36T/3xyTzT+xmP3EP6+2OKpBNjkwqKiF+TNV0uesK0aR/z5x7J345yqCaT4IurVigbb1LJ0Nq02XXYyWERVdpYzA44FFW82Oo/HhLk4YqYzsKdhvvoB0prLEUh/dNIn/niK1u7ZD8A0PQfP9wG0C4H9eROVSYopZSv/MX0fbrDj6lQ2n6UMOcAp8J6LXA9QVUYnSlzX3WA1kje2iAwKH3J3vY6gX/yTieZgW6rJcyo5rbizkU/TpDh6vhghBfsEcA/ZLV3T6hwK/GDiSDxmrKkSgCwxKtnFgXvgqv7mmXFV0xXq0VfYeAxxhh0LronGiO4umkdaYmCU6sSm4GNQDBnytdkSb18nmmZiDdWS9kv2kFPXJltCbIDRPPpkKSc6Q2fjUQJ/AKKTO8IP7qsQREgrxf+l0Vp6QEXdb9DIZN+Flj4LzQz2pNEsWk16NGZzRMmRTVQY4tLJ2VYU8DpIkSpmqJsYydAaFB6RJ5hbWEiSXLcLTkt2Dp46Y6Ho56phx+GCiyZyIT8PrsoDbFULcp8sCx8alFCb7iucsC9Esv4niyA8y+jNroYmqUg5crd3bAi702anUz1XUJoY8dZJOoYHVQVWmob/Vdvf/aNp/e3C8VtF9a74LCagwBiAphhqgGWwtnu+uYSbd10yH7B2LLHFKZdygNp7DlRp9W2NSnYNyTbiSN2Mp2fgjczyL8iRNC7INQJvHPUsBNMexYXnac5BeOH7qiHAw0tQy8Iu/xOGso/zctRN3lOTJJaKsHXjJH1zsMOmrxnSwqzzW7+JQAQkIHmjJzYab87mi90NY96WqRTgcVpTHUaviwtf3dmtWxqtjC6jr2SA+mdVEdUsixOKepXa1ROrmcVnw269LXwea04HlZsRX4OxLVLCZZ62FdMwh+7Iu5n53+IJZYAZ5l1D6NzFPsYXsMOyabGHpoGHuHGf1WsCX8hsMbgSrmvGb/L02HBvjyD673LzkjO2seqHz8TWqSzW/LTKkppB4p9wW5UnxvPZc/+z/HhzgO1YxpfpGFLt6kUa2CGLEd6pm0tNQR7miJTMFKO6Napu53t/NoExBZm5Kr8SDUiLHsudOWwSZqehybPGNYC8eAHzK6SQu+AUQZDf X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e5b8cda-d6de-42dd-4811-08d962401ed1 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2021 12:02:58.6115 (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: oGfKUX2ZYDqTmwHnRF7bTAgockFZYfceI+zvkUnjfRkT7uGNsbaZkLBHv/XroS/I2GAuGBoyUtIGKcWAs1ZFsg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3839 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Now that br_fdb_replay() uses the blocking_nb, there is no point in passing the atomic nb anymore. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 2 -- .../net/ethernet/marvell/prestera/prestera_switchdev.c | 6 +++--- drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 4 ++-- drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c | 4 ++-- drivers/net/ethernet/mscc/ocelot_net.c | 3 --- drivers/net/ethernet/rocker/rocker_ofdpa.c | 4 ++-- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 4 ++-- drivers/net/ethernet/ti/cpsw_new.c | 4 ++-- include/net/switchdev.h | 5 ----- net/bridge/br.c | 5 ++--- net/bridge/br_private.h | 4 ---- net/bridge/br_switchdev.c | 8 ++------ net/dsa/port.c | 3 --- net/switchdev/switchdev.c | 4 ---- 14 files changed, 17 insertions(+), 43 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c index 5de475927958..82f31e9f41a9 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c @@ -2016,7 +2016,6 @@ static int dpaa2_switch_port_bridge_join(struct net_device *netdev, goto err_egress_flood; err = switchdev_bridge_port_offload(netdev, netdev, NULL, - &dpaa2_switch_port_switchdev_nb, &dpaa2_switch_port_switchdev_blocking_nb, false, extack); if (err) @@ -2053,7 +2052,6 @@ static int dpaa2_switch_port_restore_rxvlan(struct net_device *vdev, int vid, vo static void dpaa2_switch_port_pre_bridge_leave(struct net_device *netdev) { switchdev_bridge_port_unoffload(netdev, NULL, - &dpaa2_switch_port_switchdev_nb, &dpaa2_switch_port_switchdev_blocking_nb); } diff --git a/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c b/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c index 3f574a69c244..a1c51656eb42 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c @@ -502,7 +502,7 @@ int prestera_bridge_port_join(struct net_device *br_dev, } err = switchdev_bridge_port_offload(br_port->dev, port->dev, NULL, - NULL, NULL, false, extack); + NULL, false, extack); if (err) goto err_switchdev_offload; @@ -516,7 +516,7 @@ int prestera_bridge_port_join(struct net_device *br_dev, return 0; err_port_join: - switchdev_bridge_port_unoffload(br_port->dev, NULL, NULL, NULL); + switchdev_bridge_port_unoffload(br_port->dev, NULL, NULL); err_switchdev_offload: prestera_bridge_port_put(br_port); err_brport_create: @@ -592,7 +592,7 @@ void prestera_bridge_port_leave(struct net_device *br_dev, else prestera_bridge_1d_port_leave(br_port); - switchdev_bridge_port_unoffload(br_port->dev, NULL, NULL, NULL); + switchdev_bridge_port_unoffload(br_port->dev, NULL, NULL); prestera_hw_port_learning_set(port, false); prestera_hw_port_flood_set(port, BR_FLOOD | BR_MCAST_FLOOD, 0); diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c index 791a165fe3aa..1a2fa8b2fa58 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c @@ -362,7 +362,7 @@ mlxsw_sp_bridge_port_create(struct mlxsw_sp_bridge_device *bridge_device, bridge_port->ref_count = 1; err = switchdev_bridge_port_offload(brport_dev, mlxsw_sp_port->dev, - NULL, NULL, NULL, false, extack); + NULL, NULL, false, extack); if (err) goto err_switchdev_offload; @@ -377,7 +377,7 @@ mlxsw_sp_bridge_port_create(struct mlxsw_sp_bridge_device *bridge_device, static void mlxsw_sp_bridge_port_destroy(struct mlxsw_sp_bridge_port *bridge_port) { - switchdev_bridge_port_unoffload(bridge_port->dev, NULL, NULL, NULL); + switchdev_bridge_port_unoffload(bridge_port->dev, NULL, NULL); list_del(&bridge_port->list); WARN_ON(!list_empty(&bridge_port->vlans_list)); kfree(bridge_port); diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c b/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c index 7fb9f59d43e0..eb957c323669 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c @@ -112,7 +112,7 @@ static int sparx5_port_bridge_join(struct sparx5_port *port, set_bit(port->portno, sparx5->bridge_mask); - err = switchdev_bridge_port_offload(ndev, ndev, NULL, NULL, NULL, + err = switchdev_bridge_port_offload(ndev, ndev, NULL, NULL, false, extack); if (err) goto err_switchdev_offload; @@ -134,7 +134,7 @@ static void sparx5_port_bridge_leave(struct sparx5_port *port, { struct sparx5 *sparx5 = port->sparx5; - switchdev_bridge_port_unoffload(port->ndev, NULL, NULL, NULL); + switchdev_bridge_port_unoffload(port->ndev, NULL, NULL); clear_bit(port->portno, sparx5->bridge_mask); if (bitmap_empty(sparx5->bridge_mask, SPX5_PORTS)) diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index 5e8965be968a..04ca55ff0fd0 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -1162,7 +1162,6 @@ static int ocelot_netdevice_bridge_join(struct net_device *dev, ocelot_port_bridge_join(ocelot, port, bridge); err = switchdev_bridge_port_offload(brport_dev, dev, priv, - &ocelot_netdevice_nb, &ocelot_switchdev_blocking_nb, false, extack); if (err) @@ -1176,7 +1175,6 @@ static int ocelot_netdevice_bridge_join(struct net_device *dev, err_switchdev_sync: switchdev_bridge_port_unoffload(brport_dev, priv, - &ocelot_netdevice_nb, &ocelot_switchdev_blocking_nb); err_switchdev_offload: ocelot_port_bridge_leave(ocelot, port, bridge); @@ -1189,7 +1187,6 @@ static void ocelot_netdevice_pre_bridge_leave(struct net_device *dev, struct ocelot_port_private *priv = netdev_priv(dev); switchdev_bridge_port_unoffload(brport_dev, priv, - &ocelot_netdevice_nb, &ocelot_switchdev_blocking_nb); } diff --git a/drivers/net/ethernet/rocker/rocker_ofdpa.c b/drivers/net/ethernet/rocker/rocker_ofdpa.c index 3e1ca7a8d029..c09f2a93337c 100644 --- a/drivers/net/ethernet/rocker/rocker_ofdpa.c +++ b/drivers/net/ethernet/rocker/rocker_ofdpa.c @@ -2598,7 +2598,7 @@ static int ofdpa_port_bridge_join(struct ofdpa_port *ofdpa_port, if (err) return err; - return switchdev_bridge_port_offload(dev, dev, NULL, NULL, NULL, + return switchdev_bridge_port_offload(dev, dev, NULL, NULL, false, extack); } @@ -2607,7 +2607,7 @@ static int ofdpa_port_bridge_leave(struct ofdpa_port *ofdpa_port) struct net_device *dev = ofdpa_port->dev; int err; - switchdev_bridge_port_unoffload(dev, NULL, NULL, NULL); + switchdev_bridge_port_unoffload(dev, NULL, NULL); err = ofdpa_port_vlan_del(ofdpa_port, OFDPA_UNTAGGED_VID, 0); if (err) diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index 130346f74ee8..3a7fde2bf861 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -2109,7 +2109,7 @@ static int am65_cpsw_netdevice_port_link(struct net_device *ndev, return -EOPNOTSUPP; } - err = switchdev_bridge_port_offload(ndev, ndev, NULL, NULL, NULL, + err = switchdev_bridge_port_offload(ndev, ndev, NULL, NULL, false, extack); if (err) return err; @@ -2126,7 +2126,7 @@ static void am65_cpsw_netdevice_port_unlink(struct net_device *ndev) struct am65_cpsw_common *common = am65_ndev_to_common(ndev); struct am65_cpsw_ndev_priv *priv = am65_ndev_to_priv(ndev); - switchdev_bridge_port_unoffload(ndev, NULL, NULL, NULL); + switchdev_bridge_port_unoffload(ndev, NULL, NULL); common->br_members &= ~BIT(priv->port->port_id); diff --git a/drivers/net/ethernet/ti/cpsw_new.c b/drivers/net/ethernet/ti/cpsw_new.c index 85d05b9be2b8..239ccdd6bc48 100644 --- a/drivers/net/ethernet/ti/cpsw_new.c +++ b/drivers/net/ethernet/ti/cpsw_new.c @@ -1518,7 +1518,7 @@ static int cpsw_netdevice_port_link(struct net_device *ndev, return -EOPNOTSUPP; } - err = switchdev_bridge_port_offload(ndev, ndev, NULL, NULL, NULL, + err = switchdev_bridge_port_offload(ndev, ndev, NULL, NULL, false, extack); if (err) return err; @@ -1535,7 +1535,7 @@ static void cpsw_netdevice_port_unlink(struct net_device *ndev) struct cpsw_priv *priv = netdev_priv(ndev); struct cpsw_common *cpsw = priv->cpsw; - switchdev_bridge_port_unoffload(ndev, NULL, NULL, NULL); + switchdev_bridge_port_unoffload(ndev, NULL, NULL); cpsw->br_members &= ~BIT(priv->emac_port); diff --git a/include/net/switchdev.h b/include/net/switchdev.h index ff61df255142..210a6786229f 100644 --- a/include/net/switchdev.h +++ b/include/net/switchdev.h @@ -183,7 +183,6 @@ typedef int switchdev_obj_dump_cb_t(struct switchdev_obj *obj); struct switchdev_brport { struct net_device *dev; const void *ctx; - struct notifier_block *atomic_nb; struct notifier_block *blocking_nb; bool tx_fwd_offload; }; @@ -264,13 +263,11 @@ switchdev_fdb_is_dynamically_learned(const struct switchdev_notifier_fdb_info *f int switchdev_bridge_port_offload(struct net_device *brport_dev, struct net_device *dev, const void *ctx, - struct notifier_block *atomic_nb, struct notifier_block *blocking_nb, bool tx_fwd_offload, struct netlink_ext_ack *extack); void switchdev_bridge_port_unoffload(struct net_device *brport_dev, const void *ctx, - struct notifier_block *atomic_nb, struct notifier_block *blocking_nb); void switchdev_deferred_process(void); @@ -353,7 +350,6 @@ int switchdev_handle_port_attr_set(struct net_device *dev, static inline int switchdev_bridge_port_offload(struct net_device *brport_dev, struct net_device *dev, const void *ctx, - struct notifier_block *atomic_nb, struct notifier_block *blocking_nb, bool tx_fwd_offload, struct netlink_ext_ack *extack) @@ -364,7 +360,6 @@ switchdev_bridge_port_offload(struct net_device *brport_dev, static inline void switchdev_bridge_port_unoffload(struct net_device *brport_dev, const void *ctx, - struct notifier_block *atomic_nb, struct notifier_block *blocking_nb) { } diff --git a/net/bridge/br.c b/net/bridge/br.c index d3a32c6813e0..ef92f57b14e6 100644 --- a/net/bridge/br.c +++ b/net/bridge/br.c @@ -222,7 +222,7 @@ static int br_switchdev_blocking_event(struct notifier_block *nb, b = &brport_info->brport; err = br_switchdev_port_offload(p, b->dev, b->ctx, - b->atomic_nb, b->blocking_nb, + b->blocking_nb, b->tx_fwd_offload, extack); err = notifier_from_errno(err); break; @@ -230,8 +230,7 @@ static int br_switchdev_blocking_event(struct notifier_block *nb, brport_info = ptr; b = &brport_info->brport; - br_switchdev_port_unoffload(p, b->ctx, b->atomic_nb, - b->blocking_nb); + br_switchdev_port_unoffload(p, b->ctx, b->blocking_nb); break; } diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 21b292eb2b3e..a7ea4ef0d9e3 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -1948,13 +1948,11 @@ static inline void br_sysfs_delbr(struct net_device *dev) { return; } #ifdef CONFIG_NET_SWITCHDEV int br_switchdev_port_offload(struct net_bridge_port *p, struct net_device *dev, const void *ctx, - struct notifier_block *atomic_nb, struct notifier_block *blocking_nb, bool tx_fwd_offload, struct netlink_ext_ack *extack); void br_switchdev_port_unoffload(struct net_bridge_port *p, const void *ctx, - struct notifier_block *atomic_nb, struct notifier_block *blocking_nb); bool br_switchdev_frame_uses_tx_fwd_offload(struct sk_buff *skb); @@ -1988,7 +1986,6 @@ static inline void br_switchdev_frame_unmark(struct sk_buff *skb) static inline int br_switchdev_port_offload(struct net_bridge_port *p, struct net_device *dev, const void *ctx, - struct notifier_block *atomic_nb, struct notifier_block *blocking_nb, bool tx_fwd_offload, struct netlink_ext_ack *extack) @@ -1998,7 +1995,6 @@ br_switchdev_port_offload(struct net_bridge_port *p, static inline void br_switchdev_port_unoffload(struct net_bridge_port *p, const void *ctx, - struct notifier_block *atomic_nb, struct notifier_block *blocking_nb) { } diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c index cd413b010567..8ff0d2d341d7 100644 --- a/net/bridge/br_switchdev.c +++ b/net/bridge/br_switchdev.c @@ -269,7 +269,6 @@ static void nbp_switchdev_del(struct net_bridge_port *p) } static int nbp_switchdev_sync_objs(struct net_bridge_port *p, const void *ctx, - struct notifier_block *atomic_nb, struct notifier_block *blocking_nb, struct netlink_ext_ack *extack) { @@ -294,7 +293,6 @@ static int nbp_switchdev_sync_objs(struct net_bridge_port *p, const void *ctx, static void nbp_switchdev_unsync_objs(struct net_bridge_port *p, const void *ctx, - struct notifier_block *atomic_nb, struct notifier_block *blocking_nb) { struct net_device *br_dev = p->br->dev; @@ -312,7 +310,6 @@ static void nbp_switchdev_unsync_objs(struct net_bridge_port *p, */ int br_switchdev_port_offload(struct net_bridge_port *p, struct net_device *dev, const void *ctx, - struct notifier_block *atomic_nb, struct notifier_block *blocking_nb, bool tx_fwd_offload, struct netlink_ext_ack *extack) @@ -328,7 +325,7 @@ int br_switchdev_port_offload(struct net_bridge_port *p, if (err) return err; - err = nbp_switchdev_sync_objs(p, ctx, atomic_nb, blocking_nb, extack); + err = nbp_switchdev_sync_objs(p, ctx, blocking_nb, extack); if (err) goto out_switchdev_del; @@ -341,10 +338,9 @@ int br_switchdev_port_offload(struct net_bridge_port *p, } void br_switchdev_port_unoffload(struct net_bridge_port *p, const void *ctx, - struct notifier_block *atomic_nb, struct notifier_block *blocking_nb) { - nbp_switchdev_unsync_objs(p, ctx, atomic_nb, blocking_nb); + nbp_switchdev_unsync_objs(p, ctx, blocking_nb); nbp_switchdev_del(p); } diff --git a/net/dsa/port.c b/net/dsa/port.c index 3ef55bd6eb40..270624e88358 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -380,7 +380,6 @@ int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br, dp->bridge_num); err = switchdev_bridge_port_offload(brport_dev, dev, dp, - &dsa_slave_switchdev_notifier, &dsa_slave_switchdev_blocking_notifier, tx_fwd_offload, extack); if (err) @@ -394,7 +393,6 @@ int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br, out_rollback_unoffload: switchdev_bridge_port_unoffload(brport_dev, dp, - &dsa_slave_switchdev_notifier, &dsa_slave_switchdev_blocking_notifier); out_rollback_unbridge: dsa_broadcast(DSA_NOTIFIER_BRIDGE_LEAVE, &info); @@ -408,7 +406,6 @@ void dsa_port_pre_bridge_leave(struct dsa_port *dp, struct net_device *br) struct net_device *brport_dev = dsa_port_to_bridge_port(dp); switchdev_bridge_port_unoffload(brport_dev, dp, - &dsa_slave_switchdev_notifier, &dsa_slave_switchdev_blocking_notifier); } diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c index c34c6abceec6..d09e8e9df5b6 100644 --- a/net/switchdev/switchdev.c +++ b/net/switchdev/switchdev.c @@ -859,7 +859,6 @@ EXPORT_SYMBOL_GPL(switchdev_handle_port_attr_set); int switchdev_bridge_port_offload(struct net_device *brport_dev, struct net_device *dev, const void *ctx, - struct notifier_block *atomic_nb, struct notifier_block *blocking_nb, bool tx_fwd_offload, struct netlink_ext_ack *extack) @@ -868,7 +867,6 @@ int switchdev_bridge_port_offload(struct net_device *brport_dev, .brport = { .dev = dev, .ctx = ctx, - .atomic_nb = atomic_nb, .blocking_nb = blocking_nb, .tx_fwd_offload = tx_fwd_offload, }, @@ -886,13 +884,11 @@ EXPORT_SYMBOL_GPL(switchdev_bridge_port_offload); void switchdev_bridge_port_unoffload(struct net_device *brport_dev, const void *ctx, - struct notifier_block *atomic_nb, struct notifier_block *blocking_nb) { struct switchdev_notifier_brport_info brport_info = { .brport = { .ctx = ctx, - .atomic_nb = atomic_nb, .blocking_nb = blocking_nb, }, }; From patchwork Wed Aug 18 12:01:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 500296 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 276A8C4338F for ; Wed, 18 Aug 2021 12:03:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F3ED260EBC for ; Wed, 18 Aug 2021 12:03:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235731AbhHRMD6 (ORCPT ); Wed, 18 Aug 2021 08:03:58 -0400 Received: from mail-vi1eur05on2074.outbound.protection.outlook.com ([40.107.21.74]:54881 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235729AbhHRMDl (ORCPT ); Wed, 18 Aug 2021 08:03:41 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b0twTGIlBtR0/uW8Ghzun00qGdeli17E7QVTXTXjGpZjqm0wF+QxdfCf69LTr1cwzInODLkfa94B0I7yhNS9Q9kRGg8Vd2G8t34OpReZepxdmi9DLL35W1Zdn+uJ4kuB8UGo9AjYpFhfsM1ZM4WKBwtEkIUcR8WutW3RJw0EKmixPF02Jz6V4b6VGDtad9uzwVzDRz4jAN5TkphBlS+/XEmGcb0sDFU86nvvFoQGZdv28l4ZhhoQpryZAD1xC8qfcMI3rRZSr7eFMayK2yboIjZYzdDtYh7Wxc4+Q3t+Fjfp9UJPp6tXyH4qI0sh2XGbJDlvPjezle2x918gwuwscg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dVQpy1oOJ+mMQy9S87HfuBemalvNB9Cw/G5QXKhHIFo=; b=IdMr/smtwuVuEXi460ITn08/pbyApzV2lwY6oLscvvz7Dl+r6IqJwrnDMUZrAjA2tLyDxnmL8swPZVAu+qqs9hvmxbJQxM6dMVZqKfMix9fgsGQGovvCAmuITPuKmCjHQfVTHCAXzsY+FPhnIh5teuzdF8VQdLWzqFBQAv0N3Vtmua4NRG3gL8MJNbSZcR+4J9pAu74xRmcJUqwmDmOVQ1p18Ciplqj0nIGrWlX8IdLC1H0jMVo/raFDVQA9Vf8Viv7u8NW5JLCIGvEm03loSO36oapza2mafYrmTMtgqmXqHfYILD4605JepCDP0Zd8mcpHVHgCxDmDGP2ioOrLpw== 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=dVQpy1oOJ+mMQy9S87HfuBemalvNB9Cw/G5QXKhHIFo=; b=rcWd1wZYRuXvjsepwObm39kltDQcnnBFs2w+JZ29AhK1ztf9Mwt8W7Q0mNHtFD8Ts+e7Ox8qNEfBvrymZeUfvkCV70JXRilUAqcUldu7/D3XWBRH9MZGp8qqi9Lji+KHBtUO+FhDpsmy6OIw8FN06yrlClQab/xqfr724EOEkkc= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR04MB4222.eurprd04.prod.outlook.com (2603:10a6:803:46::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.18; Wed, 18 Aug 2021 12:03:00 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4415.024; Wed, 18 Aug 2021 12:03:00 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Roopa Prabhu , Nikolay Aleksandrov , Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean , Vadym Kochan , Taras Chornyi , Jiri Pirko , Ido Schimmel , UNGLinuxDriver@microchip.com, Grygorii Strashko , Marek Behun , DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Claudiu Manoil , Alexandre Belloni , George McCollister , Ioana Ciornei , Saeed Mahameed , Leon Romanovsky , Lars Povlsen , Steen Hegelund , Julian Wiedmann , Karsten Graul , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Ivan Vecera , Vlad Buslov , Jianbo Liu , Mark Bloch , Roi Dayan , Tobias Waldekranz , Vignesh Raghavendra , Jesse Brandeburg , Peter Ujfalusi Subject: [RFC PATCH net-next 07/20] net: switchdev: don't assume RCU context in switchdev_handle_fdb_{add, del}_to_device Date: Wed, 18 Aug 2021 15:01:37 +0300 Message-Id: <20210818120150.892647-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818120150.892647-1-vladimir.oltean@nxp.com> References: <20210818120150.892647-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 18 Aug 2021 12:02:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2af72954-871d-4e7e-1fb3-08d962401fa3 X-MS-TrafficTypeDiagnostic: VI1PR04MB4222: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tt9tsZTo4JmOdqDmw2GANy/YrnO47pz/SDTsFVNDU7RHPKJ7BIdATBdcvtqMU0fiqOQYzN83xmyaZmSulooGouaBq3yPbaRbbsLhVeMkz5/GzNbs7rjUy8uJ5PfrmszQ+q4dlqr9n9NfgJNyyVyV4lWXKQccFOzG+lx0IuPfnILb2Dye8cktvzwBUNGSUTMj3Il8a7FY34WvFCYbgYxIp4P9Pou3AY0cNmJlAXtwRtZmvaLjQwCpDhYzv9DbLuwp21uQqUXC0FthXO+gsASK4M2jINbUgS3mb0CQykWojy554vVPexK9e1wqCYOePhJjTZdcnRuxOv6mOaj1ccX660sRBba1zPdh939RreqQerMuhpyDrj/Gg9hxhd19bwEbWaJzNr1q7R8genk7ym5Z84FGxUo9GZ5DVhmt8V3204E4HiThhVh3cvBYOhciZAzGHwszXLxXsU73ntH2VCE0cvr77uc3yTaPMR73ATnHMfhnj2gqrLX8vYq7w924HcMzC+rFCPItSXWxGV5YFJ4NLDCgJ2olg693xTj8t/RT7+qhmIghV72v0MDDtuHOAKG3ObAfLHZI5oyBiin7a8pj+1NA9KKv5JrJA+8ssr4Z4I/byC/+dgqGh0tw/avPdA+O0i2FQeU34LXdu9AiDp6XAn+n/mDaH12B2w499wBJXEQS2SIWpRYUdVjB04MPRg8bTp8OaM3NyZXfz6pjQxnUnw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(396003)(136003)(39860400002)(366004)(376002)(6486002)(52116002)(2616005)(44832011)(4326008)(5660300002)(26005)(1076003)(6666004)(54906003)(956004)(6512007)(6506007)(186003)(38350700002)(38100700002)(86362001)(36756003)(110136005)(316002)(83380400001)(8936002)(478600001)(8676002)(66476007)(7416002)(7406005)(66946007)(66556008)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0W10RtLgWjHYkzWxp/g+x/g0DoRC31MPvPDQ7AJFwPl591oLjJcm8aT8vp6F8/4IRwMfYeCLRp0ccg2y7FBJltHG+6fHx7xUa5jO/SW80CYyvKw2BAmvF3u9wPkUxVluosP1DU7mRAgCvILnJJvoPDR+n2RR6c7QxcqXeEV4y1Ik7O4qR9x6KB8WlxAWWJ62NbWz4xQGhJfH+gzc3I9y7zyofCQ3/4jQqpV3jIVuj2S9m4OEhu0RhHvm8FEZ0Lh02nDGaJeo3ulHepjYLwqn353cQgx5BfpVbj1MVgOoO1bwdcfu5Jh3i9l/yzH/pcK4t9wEekzG6M0vrdmrREiv2q5fpkHf7sl2UKXXYKsDZQ+xHx33ralqkGBSiHOxAJ03rV7FKS15GpMp2vxJHflw2OrTEIfoP5A8pXkQT6x9KtV2iNAfKmCKJFxLdK8CGD8/DuIUPLu7iNusR8PrYLUkxaN08rSU6Q20ZLLMkEeb+Id2iVQcZiV2biUyBRg94LVi2QcU+PSG+bvK3bhmcNa2pbF6Ou59sLpLNDpBkzBILSzsyx44PpcR9jFvQ21Y3V3DcOywy3aOd9U5Y9205i5z+eSQxOLD7qIuuPriZrIlqL4m7oE6NsTqtLtNLywlDGrXHTDLVTP0ozB99YgccPnDTZ5klE/uBkR5dax5snzsHIYVoNZEz6GWr5gk+V6c3G2XXTE7vfkfHVsKjOvaBtrr33XYOkmzHpnfjbrkeFT3brSNwvepS+bwuC8uTZH3gRgiAy3YZOzOtZbjbBg+FqqnISLGC/uKBOxXiug3qBc1l1qHyd+ne2H0QbNDdMgmQSjMj0qdkrgjUx7G3KTrmMIeLOtIPJ2WhGfDtp03UE4JrefRYKalGk4PHrkH/DDB+B5+bJjNcf8UhLLltwf4dUsjpc1J2CjrxZlFIIpCULYCz3ryLnnlyDFrv1ezmZzuAtB3NlIaBvQ2RAYSPcpW4m+T5TJedykOKcyJZ+B+2X6Idjz93Ugz7JYYF1qN7bF3mOo4r9g2aC5ZgKZPhDPIRWeyN/mxlHqk+1vm+piAb/bVkF8jICEs7Cp5cQp/T8jCy/+h59R+LWxyiDfl4W274y+xqRNXm+aBvgfSy0QyTsejc1uND280Mbud8MBI7lpVK9fguAhe9q04Q7IKzbfs1uH8YLLcXtrgz/f9oox9Ikn9b26m8/pPZFjaQh1lK1Z5I04l179nVIEh7kviBRJZpLURAKFs2JRwmYAt31fdNf6ZHH1MNNX/saWqYN6SbydutbzllqE7gCD4TKcNimWOBS8QTmYw/WmtUT3FUmqydKFJB27RD/Fs3DFdl3/vSpPEfETP X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2af72954-871d-4e7e-1fb3-08d962401fa3 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2021 12:02:59.9967 (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: 4XCRzuVjWe4/c9QzM9WX67vR05B660pa4IViehc1CbyaytjhDHsgBIfEIEoeqzw6I7+UwP6nc24Kt2CIKT9fyQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4222 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Now that the SWITCHDEV_FDB_{ADD,DEL}_TO_DEVICE events are blocking, it would be nice if callers of the fan-out helper functions (i.e. DSA) could benefit from that blocking context. But at the moment, switchdev_handle_fdb_{add,del}_to_device use some netdev adjacency list checking functions that assume RCU protection. Switch over to their rtnl_mutex equivalents, since we are also running with that taken, and drop the surrounding rcu_read_lock from the callers. Signed-off-by: Vladimir Oltean --- net/dsa/slave.c | 4 ---- net/switchdev/switchdev.c | 10 +++++++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 249303ac3c3c..b6a94861cddd 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -2484,22 +2484,18 @@ static int dsa_slave_switchdev_blocking_event(struct notifier_block *unused, dsa_slave_port_attr_set); return notifier_from_errno(err); case SWITCHDEV_FDB_ADD_TO_DEVICE: - rcu_read_lock(); err = switchdev_handle_fdb_add_to_device(dev, ptr, dsa_slave_dev_check, dsa_foreign_dev_check, dsa_slave_fdb_add_to_device, NULL); - rcu_read_unlock(); return notifier_from_errno(err); case SWITCHDEV_FDB_DEL_TO_DEVICE: - rcu_read_lock(); err = switchdev_handle_fdb_del_to_device(dev, ptr, dsa_slave_dev_check, dsa_foreign_dev_check, dsa_slave_fdb_del_to_device, NULL); - rcu_read_unlock(); return notifier_from_errno(err); } diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c index d09e8e9df5b6..fdbb73439f37 100644 --- a/net/switchdev/switchdev.c +++ b/net/switchdev/switchdev.c @@ -470,7 +470,7 @@ switchdev_lower_dev_find(struct net_device *dev, .data = &switchdev_priv, }; - netdev_walk_all_lower_dev_rcu(dev, switchdev_lower_dev_walk, &priv); + netdev_walk_all_lower_dev(dev, switchdev_lower_dev_walk, &priv); return switchdev_priv.lower_dev; } @@ -543,7 +543,7 @@ static int __switchdev_handle_fdb_add_to_device(struct net_device *dev, /* Event is neither on a bridge nor a LAG. Check whether it is on an * interface that is in a bridge with us. */ - br = netdev_master_upper_dev_get_rcu(dev); + br = netdev_master_upper_dev_get(dev); if (!br || !netif_is_bridge_master(br)) return 0; @@ -569,6 +569,8 @@ int switchdev_handle_fdb_add_to_device(struct net_device *dev, { int err; + ASSERT_RTNL(); + err = __switchdev_handle_fdb_add_to_device(dev, dev, fdb_info, check_cb, foreign_dev_check_cb, @@ -648,7 +650,7 @@ static int __switchdev_handle_fdb_del_to_device(struct net_device *dev, /* Event is neither on a bridge nor a LAG. Check whether it is on an * interface that is in a bridge with us. */ - br = netdev_master_upper_dev_get_rcu(dev); + br = netdev_master_upper_dev_get(dev); if (!br || !netif_is_bridge_master(br)) return 0; @@ -674,6 +676,8 @@ int switchdev_handle_fdb_del_to_device(struct net_device *dev, { int err; + ASSERT_RTNL(); + err = __switchdev_handle_fdb_del_to_device(dev, dev, fdb_info, check_cb, foreign_dev_check_cb, From patchwork Wed Aug 18 12:01:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 500294 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9BDAC4338F for ; Wed, 18 Aug 2021 12:03:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C260760F35 for ; Wed, 18 Aug 2021 12:03:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236050AbhHRMEZ (ORCPT ); Wed, 18 Aug 2021 08:04:25 -0400 Received: from mail-eopbgr00079.outbound.protection.outlook.com ([40.107.0.79]:39586 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235754AbhHRMEA (ORCPT ); Wed, 18 Aug 2021 08:04:00 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cDqFpnm2S2dlSltG3oLYYxas8+3gLe36YeidnLYoBsR0D+Ka7LPhbOUHAB8f4xDfo32txtJvTqcHk2qzsIddPxRTsAfh8JigocymMvYS70bm0dU7rpfhEOptN3NvO5levg+TyVzS6/nzxasDGQOJ8Yi43WDeK8AKMAPFpNkFcI1lKlokvlBHYRW+Vab119W69D7GYP7l3nZkRKQyEgvRP5ET8JFUot3c21FKe6Ej6XWsUWmHbl3hqulIF0pJxXwBI+zJMn/BS+Z8viuHohDVqiQ1CPEPh14BXS2fQIj3iPMmC8WTyXOeB2ZIxE3pbYEb3PbsTgnslXoV88oLfgUpyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tCpUQUmQgGpNqgld2DAKPLAKwjHwH5ZZhkv0wV6lR0Y=; b=Y9Dk7wSfr40JLXmM00htvd+VEW22h4L8ULY5tS+iihB6g13gnjLSXHemO1EVooA3L4shiocxrKuwCMAutTRqABZ4RSPtjdenBssNFcW573qMZOYOvFJSvxrHWR4LixltbnA6s0pjbdL6/C1INucnFwicd1LgvgdA6BtP0BjoaV8mgYao+TWqTRU1bKTaVSYvx/Gh0hDjsGqSy/FcSYSNGxcJj1X1BF9lABZC59B9nSrnWnO68dErfkJ4DpmQrLgzE2nfhqjY81LTC7/2rVE4SrauIfsKZcvb4gMfnPrh90o5kwItX0i+EKQ46hmDFLqUWcerNjQRap2oadFI16nfLg== 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=tCpUQUmQgGpNqgld2DAKPLAKwjHwH5ZZhkv0wV6lR0Y=; b=JW934LK9BssrcH3pwxHxjrIPj+QyQClyNPcLet6paF7W9+ka5he4x0GwlTl5RsXc51sWPu/o/zkL3cCFA2N0b8HRr5DeB+C+Ssg5qmnFmRynL988YW7wELgBwKoUnx8H2vZSb+H/2SICZY0BEjt9cCSCllH4zwim+iCCMfPgxoI= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB3839.eurprd04.prod.outlook.com (2603:10a6:803:21::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17; Wed, 18 Aug 2021 12:03:01 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4415.024; Wed, 18 Aug 2021 12:03:01 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Roopa Prabhu , Nikolay Aleksandrov , Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean , Vadym Kochan , Taras Chornyi , Jiri Pirko , Ido Schimmel , UNGLinuxDriver@microchip.com, Grygorii Strashko , Marek Behun , DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Claudiu Manoil , Alexandre Belloni , George McCollister , Ioana Ciornei , Saeed Mahameed , Leon Romanovsky , Lars Povlsen , Steen Hegelund , Julian Wiedmann , Karsten Graul , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Ivan Vecera , Vlad Buslov , Jianbo Liu , Mark Bloch , Roi Dayan , Tobias Waldekranz , Vignesh Raghavendra , Jesse Brandeburg , Peter Ujfalusi Subject: [RFC PATCH net-next 08/20] net: dsa: handle SWITCHDEV_FDB_{ADD, DEL}_TO_DEVICE synchronously Date: Wed, 18 Aug 2021 15:01:38 +0300 Message-Id: <20210818120150.892647-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818120150.892647-1-vladimir.oltean@nxp.com> References: <20210818120150.892647-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 18 Aug 2021 12:03:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b57fb7b8-c7c0-4fc9-4572-08d962402075 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3839: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2657; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1PM1m9Q8pgftAAG+z0ZZetNT5nIilCwA5WTSzNT8JdF0rDSo9Z15IjbMAiZRaW3KOgBX/wfYprSmP1NpQO8RlzqNVAxuRsZ29/5ffJz1Ln11cpQ3mt5qfxfPiY0AgFwxZVL3Fa+n5ObLOKkg4TwZ14ySyhdbLZ7WCsDfAv5FtopyLs6KkXSH8TJMzc74EhXDPDDVHO3DVpBeJNFtxg/NhysTD1JHfq/D9EwinrYi/UpOOVj7H61sZUXlgrlEI3C7VF18DSOJEb7SKH6rYk+3yO8nJpdey/U1QzNuvqz5PigkOcOYb6vB4vP5X0tHzbN/mZOXNtiSKN0QM3PQVesClj48KBIGDdy9melD947Un4gOlD2BQ1Xx5NgKy8nqOJ9UYF8swq91UnJnmDv5+K7/KohbZA6WxgVvM6irBFqJbuZNB7p12EAqniP2OLeGqihuAEmYee6B5iqPWe2DvgakXmvJJd1WmmDVzJS00q5RpllxPt8v9xTTbiSKOckiQLeNu4Lctme9PfnCeJCqnR3iFqzemzmHx6/QPNgqk8VT5nZcxKJu/aYO0aqn6U0NVW//2GxHB+B9/JHhUbfA0IvV1slCwKUPQVOBLtvFbRRlb3eASiUUjrFif+QiNi5aR2Q1srJn7RHiBIHuylEYTl+zZsLhITxd7AQApij2yTI+9zc7WG1X8fSvyzEzRIjvZtqXSezCMy5G7wevUI9yG67p9A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(346002)(136003)(39840400004)(366004)(376002)(66476007)(2906002)(66556008)(8936002)(6506007)(186003)(7406005)(7416002)(52116002)(26005)(86362001)(66946007)(6486002)(44832011)(36756003)(5660300002)(1076003)(110136005)(54906003)(6512007)(8676002)(316002)(6666004)(38350700002)(38100700002)(956004)(478600001)(83380400001)(2616005)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: l2HB76Z3TSzLPRyaBoxqLPZKyx7ZNpkBoHcdVb5ytsOtld6sESlam7V75J1XPYUSDrUwwQPeuURvtGp5h5Qtrs1bNHj4SYCJDaOR+U4JZbfsti2N7WZeqomhdLDtQHX6J021822G2sU79jbYg+I88V+fiX7aG3LQCUdHypMsxiBRnJ8JLrrsNcafDHrU23cj2xq6E4wXCB3J+JxJAfU8baWma2BztLhLDho1pTrRjMuWTBi3H8r6IbNX+D/hZkzDhHFVAvZG90Iytoy3ss2bJ5ri4cuhfG726YVj0Y3tFVRuWKXkZcWrHAC33eFj8PBt7A/yTaSb+mSnhQL5cusyFMW1woM55lwtyYzV/2B+t5PhsdBuTyDn3n9D+0hjUJmk+PmHU5g7I4or0atpyZ+U4sCdCqg1vyIY+ZlKfTw97oEU2xYmgxFSPchSGUrzTamk+nDGP2IrvZnknCr7azSv9+jrhBeUpQFuVZN7U6W6Foz48n3kY1wFHbkMgaeM6v1JSyahxyrnMhKs2791TnQAjdUBYjfah3A0oqqLloDl1g6aqexxldtw+G2GTLGqgitRLuow26Z9qkttgmvoL153ooNpjNIoH0ihmeAtqFZz+nIFUvBZMyYFcmuzQrCrDvroEW0G3qwUkq6ANu5ZOGRQu0OgpnN2xkMofhmCLTNfLqxAeYZHhSpgvTHGIzhvaDGKgohmc7p28P/yIFzLLEZgwyJTvXPjtoIC066hbDaiW+lJSHAX/p9IXK5bG44LIgr1hq6wdeYrd56RZflmoG/goowe/JF5J4gBWsscv8E9ke2gAgVLeF55YO70SYk66r0rPCpjATWgh4lZckPHYpQm1UErvGgTQbYR0HZ7Cr3axr/GONkBvApwKui8ilpjohgvnY6pf9FRBLmxR7vuv7++/MAx9tTDqCvHns1ol3cdToadIPgabwW9E8488oq7jg55M4YqUz+OWZTKEGi2TFtRFBMKhnTKaPDGeaKK23aDS2u1RinqJGc5ofuSaNvFgdCSBngUO0ir6cI0WjT8le4QSPDqsI9SfTRyfjyI23t7bS5Sp+EFcTVSGJMXfjEC/JK45+9GjqEe61KhS+2bO9n7Ze38M+632AVWOEAo4gQgT0AIWF0dlrGxabJO6uni/ZdTQqn/vS11Nj3kwoCQEPj0/Iha9j/92Br5fIQAZ28RnzuEadNw5ITp0evqEZ99FzyQzZbom55XB5vPfLgky7QOYgc9h2SHTFYsJq+lEOvZJ8/ty96yWof7bGsIVc+6OFNofz+dzJsuZbJL33npjB6NKPsrbsdPlacU/5R+9sRvj4jA+mC9uJ50Oyt7QaxzZDf7 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b57fb7b8-c7c0-4fc9-4572-08d962402075 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2021 12:03:01.4069 (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: 1xn2FPhkq72Zmyqrl2VPv/dSvFY+72b0vRbqScfBKg2I2Hd2G46zNDTJP1L/bXtK8E8J+bmH2YVQFZkSRpEWDQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3839 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Since the switchdev FDB entry notifications are now blocking and deferred by switchdev and not by us, switchdev will also wait for us to finish, which means we can proceed with our FDB isolation mechanism based on dp->bridge_num. It also means that the ordered workqueue is no longer needed, drop it and simply call the driver. Signed-off-by: Vladimir Oltean --- net/dsa/dsa.c | 15 ------- net/dsa/dsa_priv.h | 15 ------- net/dsa/slave.c | 110 ++++++++++++--------------------------------- 3 files changed, 28 insertions(+), 112 deletions(-) diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 1dc45e40f961..b2126334387f 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c @@ -338,13 +338,6 @@ static struct packet_type dsa_pack_type __read_mostly = { .func = dsa_switch_rcv, }; -static struct workqueue_struct *dsa_owq; - -bool dsa_schedule_work(struct work_struct *work) -{ - return queue_work(dsa_owq, work); -} - int dsa_devlink_param_get(struct devlink *dl, u32 id, struct devlink_param_gset_ctx *ctx) { @@ -465,11 +458,6 @@ static int __init dsa_init_module(void) { int rc; - dsa_owq = alloc_ordered_workqueue("dsa_ordered", - WQ_MEM_RECLAIM); - if (!dsa_owq) - return -ENOMEM; - rc = dsa_slave_register_notifier(); if (rc) goto register_notifier_fail; @@ -482,8 +470,6 @@ static int __init dsa_init_module(void) return 0; register_notifier_fail: - destroy_workqueue(dsa_owq); - return rc; } module_init(dsa_init_module); @@ -494,7 +480,6 @@ static void __exit dsa_cleanup_module(void) dsa_slave_unregister_notifier(); dev_remove_pack(&dsa_pack_type); - destroy_workqueue(dsa_owq); } module_exit(dsa_cleanup_module); diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index c5caa2d975d2..55b908f588ac 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h @@ -126,20 +126,6 @@ struct dsa_notifier_tag_8021q_vlan_info { u16 vid; }; -struct dsa_switchdev_event_work { - struct dsa_switch *ds; - int port; - struct net_device *dev; - struct work_struct work; - unsigned long event; - /* Specific for SWITCHDEV_FDB_ADD_TO_DEVICE and - * SWITCHDEV_FDB_DEL_TO_DEVICE - */ - unsigned char addr[ETH_ALEN]; - u16 vid; - bool host_addr; -}; - /* DSA_NOTIFIER_HSR_* */ struct dsa_notifier_hsr_info { struct net_device *hsr; @@ -170,7 +156,6 @@ const struct dsa_device_ops *dsa_tag_driver_get(int tag_protocol); void dsa_tag_driver_put(const struct dsa_device_ops *ops); const struct dsa_device_ops *dsa_find_tagger_by_name(const char *buf); -bool dsa_schedule_work(struct work_struct *work); const char *dsa_tag_protocol_to_str(const struct dsa_device_ops *ops); static inline int dsa_tag_protocol_overhead(const struct dsa_device_ops *ops) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index b6a94861cddd..faa08e6d8651 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -2278,73 +2278,18 @@ static int dsa_slave_netdevice_event(struct notifier_block *nb, return NOTIFY_DONE; } -static void -dsa_fdb_offload_notify(struct dsa_switchdev_event_work *switchdev_work) +static void dsa_fdb_offload_notify(struct net_device *dev, + const unsigned char *addr, + u16 vid) { struct switchdev_notifier_fdb_info info = {}; - struct dsa_switch *ds = switchdev_work->ds; - struct dsa_port *dp; - - if (!dsa_is_user_port(ds, switchdev_work->port)) - return; - info.addr = switchdev_work->addr; - info.vid = switchdev_work->vid; + info.addr = addr; + info.vid = vid; info.offloaded = true; - dp = dsa_to_port(ds, switchdev_work->port); - call_switchdev_notifiers(SWITCHDEV_FDB_OFFLOADED, - dp->slave, &info.info, NULL); -} - -static void dsa_slave_switchdev_event_work(struct work_struct *work) -{ - struct dsa_switchdev_event_work *switchdev_work = - container_of(work, struct dsa_switchdev_event_work, work); - struct dsa_switch *ds = switchdev_work->ds; - struct dsa_port *dp; - int err; - - dp = dsa_to_port(ds, switchdev_work->port); - - rtnl_lock(); - switch (switchdev_work->event) { - case SWITCHDEV_FDB_ADD_TO_DEVICE: - if (switchdev_work->host_addr) - err = dsa_port_host_fdb_add(dp, switchdev_work->addr, - switchdev_work->vid); - else - err = dsa_port_fdb_add(dp, switchdev_work->addr, - switchdev_work->vid); - if (err) { - dev_err(ds->dev, - "port %d failed to add %pM vid %d to fdb: %d\n", - dp->index, switchdev_work->addr, - switchdev_work->vid, err); - break; - } - dsa_fdb_offload_notify(switchdev_work); - break; - - case SWITCHDEV_FDB_DEL_TO_DEVICE: - if (switchdev_work->host_addr) - err = dsa_port_host_fdb_del(dp, switchdev_work->addr, - switchdev_work->vid); - else - err = dsa_port_fdb_del(dp, switchdev_work->addr, - switchdev_work->vid); - if (err) { - dev_err(ds->dev, - "port %d failed to delete %pM vid %d from fdb: %d\n", - dp->index, switchdev_work->addr, - switchdev_work->vid, err); - } - - break; - } - rtnl_unlock(); - dev_put(switchdev_work->dev); - kfree(switchdev_work); + call_switchdev_notifiers(SWITCHDEV_FDB_OFFLOADED, dev, &info.info, + NULL); } static bool dsa_foreign_dev_check(const struct net_device *dev, @@ -2369,10 +2314,12 @@ static int dsa_slave_fdb_event(struct net_device *dev, const struct switchdev_notifier_fdb_info *fdb_info, unsigned long event) { - struct dsa_switchdev_event_work *switchdev_work; struct dsa_port *dp = dsa_slave_to_port(dev); + const unsigned char *addr = fdb_info->addr; bool host_addr = fdb_info->is_local; struct dsa_switch *ds = dp->ds; + u16 vid = fdb_info->vid; + int err; if (ctx && ctx != dp) return 0; @@ -2397,30 +2344,29 @@ static int dsa_slave_fdb_event(struct net_device *dev, if (dsa_foreign_dev_check(dev, orig_dev)) host_addr = true; - switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC); - if (!switchdev_work) - return -ENOMEM; - netdev_dbg(dev, "%s FDB entry towards %s, addr %pM vid %d%s\n", event == SWITCHDEV_FDB_ADD_TO_DEVICE ? "Adding" : "Deleting", - orig_dev->name, fdb_info->addr, fdb_info->vid, - host_addr ? " as host address" : ""); - - INIT_WORK(&switchdev_work->work, dsa_slave_switchdev_event_work); - switchdev_work->ds = ds; - switchdev_work->port = dp->index; - switchdev_work->event = event; - switchdev_work->dev = dev; + orig_dev->name, addr, vid, host_addr ? " as host address" : ""); - ether_addr_copy(switchdev_work->addr, fdb_info->addr); - switchdev_work->vid = fdb_info->vid; - switchdev_work->host_addr = host_addr; + switch (event) { + case SWITCHDEV_FDB_ADD_TO_DEVICE: + if (host_addr) + err = dsa_port_host_fdb_add(dp, addr, vid); + else + err = dsa_port_fdb_add(dp, addr, vid); + if (!err) + dsa_fdb_offload_notify(dev, addr, vid); + break; - /* Hold a reference for dsa_fdb_offload_notify */ - dev_hold(dev); - dsa_schedule_work(&switchdev_work->work); + case SWITCHDEV_FDB_DEL_TO_DEVICE: + if (host_addr) + err = dsa_port_host_fdb_del(dp, addr, vid); + else + err = dsa_port_fdb_del(dp, addr, vid); + break; + } - return 0; + return err; } static int From patchwork Wed Aug 18 12:01:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 499561 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F1D9C4338F for ; Wed, 18 Aug 2021 12:03:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 771FB60F35 for ; Wed, 18 Aug 2021 12:03:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236298AbhHRME2 (ORCPT ); Wed, 18 Aug 2021 08:04:28 -0400 Received: from mail-eopbgr00085.outbound.protection.outlook.com ([40.107.0.85]:55044 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235795AbhHRMEB (ORCPT ); Wed, 18 Aug 2021 08:04:01 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QsTFkwSMGZlktYgJFyfR9dgz16T/ZVFhtV7TQ76ZXdS/g6K9BfgSOPDibFTnAxaNLO/uQbZLf2B+i/k3DHWtB82kLC32RDkSetvBd1eK4JbQHDjywfpH25E3IRGpI2TiPng7kQcgoNjq/ajyoYMCqK8Pm9P7VhN7tPe2C8VhEGSk7+TvhCLIWcoqyUeV7aPY1UnOac3rkKb4vlh5cLrBwwHhFh7i6R3x64oMnjwaF1QkGgUG4XepGmQ1whijC8ASQKOcBzScW8Ey2FTusYHW1KI59UWuh1KlIoujDugWf8BKYv0b/MnCncQRnikG7UvvEx08EtcWmL9xh2kNSEY81g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XdEYQBUdStvxn6GWF9wwdHiFppBHaOQSo6eu+z3rmzQ=; b=gpVj5AxOsljDMYhQ0KU7hfmqeew0D+U+vgAcwbeRIQuS48GP+n/RBJZRwkZxGcIpuRrYjeZoMIUga9ydPYxWljUgEbzbyz09BQuCDbPQtzBymI/T6DMx1bSAoIaXsfrFSQgwVxf+aR4M32TydEcfpFZfZy/gEid8puZGalwx+5XPreFUPwVBPdncpS/w8pKVWd0t2d1IXda/OhTOlcyn0BOU//H+NVnVvO0qM0Ep7EI4uOlaEcE2ay1pKlOjkuUEwk0egQ0l49DbQlNamkf9JvaoTm8RLmIUuODW08RLBOEFctftHigxMJRUTE6jlh7zgSejZnTnqcBSaCX4Grxzaw== 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=XdEYQBUdStvxn6GWF9wwdHiFppBHaOQSo6eu+z3rmzQ=; b=rmmN/yjmZHsmBjiB8MK0If9B1LaJAEFLRP752w6y02yudGRd5QyyNHZB6Vn6WXuMdELVHEpq8mCk/+y1xeQxMuy/GsyItkdNctldonTZ8sUEJJl3+z8L9e6qidSp5ha5hMhIOmqKthpOZYd+4lXus0bLRqUtAHN3rmY+a3i2/7s= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB3839.eurprd04.prod.outlook.com (2603:10a6:803:21::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17; Wed, 18 Aug 2021 12:03:03 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4415.024; Wed, 18 Aug 2021 12:03:03 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Roopa Prabhu , Nikolay Aleksandrov , Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean , Vadym Kochan , Taras Chornyi , Jiri Pirko , Ido Schimmel , UNGLinuxDriver@microchip.com, Grygorii Strashko , Marek Behun , DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Claudiu Manoil , Alexandre Belloni , George McCollister , Ioana Ciornei , Saeed Mahameed , Leon Romanovsky , Lars Povlsen , Steen Hegelund , Julian Wiedmann , Karsten Graul , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Ivan Vecera , Vlad Buslov , Jianbo Liu , Mark Bloch , Roi Dayan , Tobias Waldekranz , Vignesh Raghavendra , Jesse Brandeburg , Peter Ujfalusi Subject: [RFC PATCH net-next 09/20] net: dsa: tag_8021q: replace the SVL bridging with VLAN-unaware IVL bridging Date: Wed, 18 Aug 2021 15:01:39 +0300 Message-Id: <20210818120150.892647-10-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818120150.892647-1-vladimir.oltean@nxp.com> References: <20210818120150.892647-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 18 Aug 2021 12:03:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 919ce048-d7a7-4bf6-0b3e-08d96240214f X-MS-TrafficTypeDiagnostic: VI1PR0402MB3839: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RuNJlNHxBXZf3PyudjagJv+jTprhYeA+YyxicyW7jzmGz+6W3Uk0Zn1MZFLc0PPQbLTtWWTFHCZOZOW8zKXQ0Q6CYGZClet+OuLT47IfDSB/QHE2SGQ0xusW67VNd0r4Fk75/65cPYSFjoncLuW/QHkqau3e99gt/HQ7CFUDb8XbEMUjOszZyrDf76PCtLjSjUHUNFGQ6MeUeRHH9jKv9Y4dEsfiuUhOOAlsjgrIFvdryEvTrDa1DFXUnrc5SG48kdbTEGalbPVhLadKWmJtZSqHewgVQq+NHkP0LUcVyqNRbiUUPJ0tjHy3tlSvYhc9rGvvojuWGU8DJxTLvuQ6H/cOVk9H4R89YOUhlXXhfcQKIrrcLktlhOs94MCMylOQjPoAu4CDlozGSonmj2tMNpGuDbJOJzUCp0yeshTvQWZsBAFAAeA8O41u/4SaAp0tEmpU3EwDMit/BCgXCwclh+YV3sFnDlktSdBsNKGtf9uR3YdGweKhutW01cN5r9W7wNijf3chbv0M2ML7q7+1IjolevmEOfFlTVSvqwFO3yAPfhvnK7qfuZu/YEPBm5xTVVqV39suSNZG123UuXacfphgvNPVOZJ1EufCCIzlaB23d/hvHj7MzdnocgQdmO4lEmPypQ31/Dk1pIlNWgYKtIZYZTirkbuxbQnnL9VPaMlib4ANL1Rew+d8o4s6Xs2F9njamn4obm5MICMsoFMywQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(346002)(136003)(39850400004)(366004)(376002)(66476007)(2906002)(66556008)(8936002)(6506007)(186003)(7406005)(7416002)(52116002)(26005)(86362001)(66946007)(6486002)(44832011)(36756003)(30864003)(5660300002)(1076003)(110136005)(54906003)(6512007)(8676002)(316002)(6666004)(38350700002)(38100700002)(956004)(478600001)(83380400001)(2616005)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OKdzoZvoXXDT6CiWRmLQ/JqQ13H0YDTI1T8+ItiNReUvf1hZNkZqOVDhxKWviB0sUIUwqEFYBAaf5nIWHjyM3baZwz3akifhMi9wIpdwkjiGNYdQuvl/8vomQCcHxQQMM7m17MBLM2zQesOrQyVGrSRtoSmyPK0KUPoIYSN5PfU3qhlZ/PjRBkpQYHaWgbrVLQGKJonACNpVDY9D0itfsE23D6dYddG0nVIP4sJ3pG6UwW6bIa3yDaMg0HPp7RkA6f/zVT5HpGvlkuuwqmwT3m78t+UX5OD2sBkNRjmG814km5hJqxcb4pDCdX8DROZVg3RrMBA0qQVO9c96z+7xubTETovHmQI/5ORmwaertZZuhn/A7j+Rgpnejo37sfB49rwP2rac3+d0rBWXOVa0zB6csIoK0gCDl9upS6bOHkQk/Z5+MagDlD3zzxI7wmZXxDFmKbwUF62cmYXCcUeXnhnt32TYZyp8B+Q2XTx3sY23FXa/RMH22M4X76hrIrdW1U7Rthu66ut9ONO1Xn7eJxHflN6kXQnz9tsU4dUHBW2CMhWPAdoH1pos6L3F5SS9E67NOb+f3GRWTSY3y7jMasKyYOQza44+YcNFG9DUtulz2CIikiirSclTeUUvtys3V8POo3xwgsWBaJJgKYgX9P3vNUC79XI88izV4imi/Iax67TGVlITmeBM1M9RbZ/D3udvE4OEb56sly6ZQoo8OdnohPM2/uwvkYQbzLJw9dpiT4TSDm7fHWQx6/fH0XXeCFS2LWcZAoQ8hS6pmMi59lCJ2CfvCyD85oI2MUM5C0F9yXxIVzkEfa77f43Nvyt6WPttspdXq03Hbr+ikXTZ6s3DrZDXp/BkvN2fCyuhVl9yMViInvHwfN+Ct2neZComVQGozxcqnNLdsPGGi6GZyo9oDLc/yNBwjparNbf04MhXVW4VqOz2NFpBaGM6NS2GeiF4IFvv4RUBghKXmsa3MLp4hH5zI8aW1dHiWJ7rytpuEW2XNBARn/tCkrnmQ/7WZJWKow+dYUrK7S5ivb2mpP7R7o6DSbVvY3S7LHvtppPxbryE8WMUvhOeH67aolHvztsMgOyqC0CHl6CFHfE/zmui99QH/b8EkDE61L9S4lvC6l6WnyizzXUv73irEcLR9O5/v284Y18aRLL2y29UCfdm9xe3zJ/9azpTCkn81rYa7Ix5wKGvIiBCIKmi4C5x84psoRIlJ89U6LphEmo2r3ky46Tk9JuR7xHYXQuxQqv9etIRA5ikmLepUPPypLyq16VHQ9Vm3c0WqZ/5N2KyC+xM8gDWG/5SpsyOY6a7S/NRfHp4TUa4DTSoXEkPh8Av X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 919ce048-d7a7-4bf6-0b3e-08d96240214f X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2021 12:03:02.8711 (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: 6T50gS6V/x/skZIeJU0SACGMxj+PZIdlIrN8BsnazMLIBlpC34y6klvbTdI/VzZ7mSqlYfgEjFKzX4Hwl1SgHQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3839 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org For VLAN-unaware bridging, tag_8021q uses something perhaps a bit too tied with the sja1105 switch: each port uses the same pvid which is also used for standalone operation (a unique one from which the source port and device ID can be retrieved when packets from that port are forwarded to the CPU). Since each port has a unique pvid when performing autonomous forwarding, the switch must be configured for Shared VLAN Learning (SVL) such that the VLAN ID itself is ignored when performing FDB lookups. Without SVL, packets would always be flooded. First of all, to make tag_8021q more palatable to switches which might not support Shared VLAN Learning, let's just use a common VLAN for all ports that are under a bridge. Secondly, using Shared VLAN Learning means that FDB isolation can never be enforced. But now, when all ports under the same VLAN-unaware bridge share the same VLAN ID, it can. The disadvantage is that the CPU port can no longer perform precise source port identification for these packets. But at least we have a mechanism which has proven to be adequate for that situation: imprecise RX, which is what we use for VLAN-aware bridging. The VLAN ID that VLAN-unaware bridges will use with tag_8021q is the same one as we were previously using for imprecise TX (bridge TX forwarding offload). It is already allocated, it is just a matter of using it. Note that because now all ports under the same bridge share the same VLAN, the complexity of performing a tag_8021q bridge join decreases dramatically. We no longer have to install the RX VLAN of a newly joining port into the port membership of the existing bridge ports. The newly joining port just becomes a member of the VLAN corresponding to that bridge, and the other ports are already members of it. So forwarding works properly. This means that we can unhook dsa_tag_8021q_bridge_{join,leave} from the cross-chip notifier level dsa_switch_bridge_{join,leave}. We can put these calls directly into the sja1105 driver. With this new mode of operation, a port controlled by tag_8021q can have two pvids whereas before it could only have one. The pvid for standalone operation is different from the pvid used for VLAN-unaware bridging. This is done, again, so that FDB isolation can be enforced. Let tag_8021q manage this by deleting the standalone pvid when a port joins a bridge, and restoring it when it leaves it. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/sja1105/sja1105_main.c | 32 +++++- include/linux/dsa/8021q.h | 14 ++- net/dsa/dsa_priv.h | 4 - net/dsa/switch.c | 4 +- net/dsa/tag_8021q.c | 137 +++++++++---------------- 5 files changed, 85 insertions(+), 106 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 12a92deb5e5b..1d05a6234a6d 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -1987,13 +1987,24 @@ static void sja1105_bridge_stp_state_set(struct dsa_switch *ds, int port, static int sja1105_bridge_join(struct dsa_switch *ds, int port, struct net_device *br, int bridge_num) { - return sja1105_bridge_member(ds, port, br, true); + int rc; + + rc = dsa_tag_8021q_bridge_join(ds, port, br, bridge_num); + if (rc) + return rc; + + rc = sja1105_bridge_member(ds, port, br, true); + if (rc) + dsa_tag_8021q_bridge_leave(ds, port, br, bridge_num); + + return rc; } static void sja1105_bridge_leave(struct dsa_switch *ds, int port, struct net_device *br, int bridge_num) { sja1105_bridge_member(ds, port, br, false); + dsa_tag_8021q_bridge_leave(ds, port, br, bridge_num); } #define BYTES_PER_KBIT (1000LL / 8) @@ -2915,6 +2926,21 @@ static int sja1105_port_bridge_flags(struct dsa_switch *ds, int port, return 0; } +static int sja1105_bridge_tx_fwd_offload(struct dsa_switch *ds, int port, + struct net_device *br, + int bridge_num) +{ + /* Nothing to do, tag_8021q took care of everything */ + return 0; +} + +static void sja1105_bridge_tx_fwd_unoffload(struct dsa_switch *ds, int port, + struct net_device *br, + int bridge_num) +{ + /* Nothing to do, tag_8021q took care of everything */ +} + static void sja1105_teardown_ports(struct sja1105_private *priv) { struct dsa_switch *ds = priv->ds; @@ -3144,8 +3170,8 @@ const struct dsa_switch_ops sja1105_switch_ops = { .tag_8021q_vlan_add = sja1105_dsa_8021q_vlan_add, .tag_8021q_vlan_del = sja1105_dsa_8021q_vlan_del, .port_prechangeupper = sja1105_prechangeupper, - .port_bridge_tx_fwd_offload = dsa_tag_8021q_bridge_tx_fwd_offload, - .port_bridge_tx_fwd_unoffload = dsa_tag_8021q_bridge_tx_fwd_unoffload, + .port_bridge_tx_fwd_offload = sja1105_bridge_tx_fwd_offload, + .port_bridge_tx_fwd_unoffload = sja1105_bridge_tx_fwd_unoffload, }; EXPORT_SYMBOL_GPL(sja1105_switch_ops); diff --git a/include/linux/dsa/8021q.h b/include/linux/dsa/8021q.h index c7fa4a3498fe..29b9c0e195ae 100644 --- a/include/linux/dsa/8021q.h +++ b/include/linux/dsa/8021q.h @@ -30,19 +30,17 @@ int dsa_tag_8021q_register(struct dsa_switch *ds, __be16 proto); void dsa_tag_8021q_unregister(struct dsa_switch *ds); +int dsa_tag_8021q_bridge_join(struct dsa_switch *ds, int port, + struct net_device *br, int bridge_num); + +void dsa_tag_8021q_bridge_leave(struct dsa_switch *ds, int port, + struct net_device *br, int bridge_num); + struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev, u16 tpid, u16 tci); void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id); -int dsa_tag_8021q_bridge_tx_fwd_offload(struct dsa_switch *ds, int port, - struct net_device *br, - int bridge_num); - -void dsa_tag_8021q_bridge_tx_fwd_unoffload(struct dsa_switch *ds, int port, - struct net_device *br, - int bridge_num); - u16 dsa_8021q_bridge_tx_fwd_offload_vid(int bridge_num); u16 dsa_8021q_tx_vid(struct dsa_switch *ds, int port); diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index 55b908f588ac..417fac51c6e8 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h @@ -533,10 +533,6 @@ int dsa_bridge_num_get(const struct net_device *bridge_dev, int max); void dsa_bridge_num_put(const struct net_device *bridge_dev, int bridge_num); /* tag_8021q.c */ -int dsa_tag_8021q_bridge_join(struct dsa_switch *ds, - struct dsa_notifier_bridge_info *info); -int dsa_tag_8021q_bridge_leave(struct dsa_switch *ds, - struct dsa_notifier_bridge_info *info); int dsa_switch_tag_8021q_vlan_add(struct dsa_switch *ds, struct dsa_notifier_tag_8021q_vlan_info *info); int dsa_switch_tag_8021q_vlan_del(struct dsa_switch *ds, diff --git a/net/dsa/switch.c b/net/dsa/switch.c index 44d40a267632..26dbd70ebb5e 100644 --- a/net/dsa/switch.c +++ b/net/dsa/switch.c @@ -110,7 +110,7 @@ static int dsa_switch_bridge_join(struct dsa_switch *ds, return err; } - return dsa_tag_8021q_bridge_join(ds, info); + return 0; } static int dsa_switch_bridge_leave(struct dsa_switch *ds, @@ -162,7 +162,7 @@ static int dsa_switch_bridge_leave(struct dsa_switch *ds, return err; } - return dsa_tag_8021q_bridge_leave(ds, info); + return 0; } /* Matches for all upstream-facing ports (the CPU port and all upstream-facing diff --git a/net/dsa/tag_8021q.c b/net/dsa/tag_8021q.c index f8f7b7c34e7d..ae94c684961d 100644 --- a/net/dsa/tag_8021q.c +++ b/net/dsa/tag_8021q.c @@ -109,6 +109,15 @@ int dsa_8021q_rx_source_port(u16 vid) } EXPORT_SYMBOL_GPL(dsa_8021q_rx_source_port); +/* Returns the decoded VBID from the RX VID. */ +static int dsa_tag_8021q_rx_vbid(u16 vid) +{ + u16 vbid_hi = (vid & DSA_8021Q_VBID_HI_MASK) >> DSA_8021Q_VBID_HI_SHIFT; + u16 vbid_lo = (vid & DSA_8021Q_VBID_LO_MASK) >> DSA_8021Q_VBID_LO_SHIFT; + + return (vbid_hi << 2) | vbid_lo; +} + bool vid_is_dsa_8021q_rxvlan(u16 vid) { return (vid & DSA_8021Q_DIR_MASK) == DSA_8021Q_DIR_RX; @@ -239,11 +248,17 @@ int dsa_switch_tag_8021q_vlan_add(struct dsa_switch *ds, if (dsa_is_user_port(ds, port)) flags |= BRIDGE_VLAN_INFO_UNTAGGED; + /* Standalone VLANs are PVIDs */ if (vid_is_dsa_8021q_rxvlan(info->vid) && dsa_8021q_rx_switch_id(info->vid) == ds->index && dsa_8021q_rx_source_port(info->vid) == port) flags |= BRIDGE_VLAN_INFO_PVID; + /* And bridging VLANs are PVIDs too on user ports */ + if (dsa_tag_8021q_rx_vbid(info->vid) && + dsa_is_user_port(ds, port)) + flags |= BRIDGE_VLAN_INFO_PVID; + err = dsa_switch_do_tag_8021q_vlan_add(ds, port, info->vid, flags); @@ -322,111 +337,55 @@ int dsa_switch_tag_8021q_vlan_del(struct dsa_switch *ds, * +-+-----+-+-----+-+-----+-+-----+-+ +-+-----+-+-----+-+-----+-+-----+-+ * swp0 swp1 swp2 swp3 swp0 swp1 swp2 swp3 */ -static bool dsa_tag_8021q_bridge_match(struct dsa_switch *ds, int port, - struct dsa_notifier_bridge_info *info) +int dsa_tag_8021q_bridge_join(struct dsa_switch *ds, int port, + struct net_device *br, int bridge_num) { struct dsa_port *dp = dsa_to_port(ds, port); + u16 standalone_vid, bridge_vid; + int err; - /* Don't match on self */ - if (ds->dst->index == info->tree_index && - ds->index == info->sw_index && - port == info->port) - return false; - - if (dsa_port_is_user(dp)) - return dp->bridge_dev == info->br; - - return false; -} - -int dsa_tag_8021q_bridge_join(struct dsa_switch *ds, - struct dsa_notifier_bridge_info *info) -{ - struct dsa_switch *targeted_ds; - struct dsa_port *targeted_dp; - u16 targeted_rx_vid; - int err, port; - - if (!ds->tag_8021q_ctx) - return 0; - - targeted_ds = dsa_switch_find(info->tree_index, info->sw_index); - targeted_dp = dsa_to_port(targeted_ds, info->port); - targeted_rx_vid = dsa_8021q_rx_vid(targeted_ds, info->port); - - for (port = 0; port < ds->num_ports; port++) { - struct dsa_port *dp = dsa_to_port(ds, port); - u16 rx_vid = dsa_8021q_rx_vid(ds, port); - - if (!dsa_tag_8021q_bridge_match(ds, port, info)) - continue; + /* Delete the standalone VLAN of the port and replace it with a + * bridging VLAN + */ + standalone_vid = dsa_8021q_rx_vid(ds, port); + bridge_vid = dsa_8021q_bridge_tx_fwd_offload_vid(bridge_num); - /* Install the RX VID of the targeted port in our VLAN table */ - err = dsa_port_tag_8021q_vlan_add(dp, targeted_rx_vid, true); - if (err) - return err; + dsa_port_tag_8021q_vlan_del(dp, standalone_vid, false); - /* Install our RX VID into the targeted port's VLAN table */ - err = dsa_port_tag_8021q_vlan_add(targeted_dp, rx_vid, true); - if (err) - return err; + err = dsa_port_tag_8021q_vlan_add(dp, bridge_vid, true); + if (err) { + dsa_port_tag_8021q_vlan_add(dp, standalone_vid, false); + return err; } return 0; } +EXPORT_SYMBOL_GPL(dsa_tag_8021q_bridge_join); -int dsa_tag_8021q_bridge_leave(struct dsa_switch *ds, - struct dsa_notifier_bridge_info *info) +void dsa_tag_8021q_bridge_leave(struct dsa_switch *ds, int port, + struct net_device *br, int bridge_num) { - struct dsa_switch *targeted_ds; - struct dsa_port *targeted_dp; - u16 targeted_rx_vid; - int port; - - if (!ds->tag_8021q_ctx) - return 0; - - targeted_ds = dsa_switch_find(info->tree_index, info->sw_index); - targeted_dp = dsa_to_port(targeted_ds, info->port); - targeted_rx_vid = dsa_8021q_rx_vid(targeted_ds, info->port); - - for (port = 0; port < ds->num_ports; port++) { - struct dsa_port *dp = dsa_to_port(ds, port); - u16 rx_vid = dsa_8021q_rx_vid(ds, port); + struct dsa_port *dp = dsa_to_port(ds, port); + u16 standalone_vid, bridge_vid; + int err; - if (!dsa_tag_8021q_bridge_match(ds, port, info)) - continue; + /* Delete the bridging VLAN of the port and replace it with a + * standalone VLAN + */ + standalone_vid = dsa_8021q_rx_vid(ds, port); + bridge_vid = dsa_8021q_bridge_tx_fwd_offload_vid(bridge_num); - /* Remove the RX VID of the targeted port from our VLAN table */ - dsa_port_tag_8021q_vlan_del(dp, targeted_rx_vid, true); + dsa_port_tag_8021q_vlan_del(dp, bridge_vid, true); - /* Remove our RX VID from the targeted port's VLAN table */ - dsa_port_tag_8021q_vlan_del(targeted_dp, rx_vid, true); + err = dsa_port_tag_8021q_vlan_add(dp, standalone_vid, false); + if (err) { + dev_err(ds->dev, + "Failed to delete tag_8021q standalone VLAN %d from port %d: %pe\n", + standalone_vid, port, ERR_PTR(err)); + dsa_port_tag_8021q_vlan_add(dp, bridge_vid, true); } - - return 0; -} - -int dsa_tag_8021q_bridge_tx_fwd_offload(struct dsa_switch *ds, int port, - struct net_device *br, - int bridge_num) -{ - u16 tx_vid = dsa_8021q_bridge_tx_fwd_offload_vid(bridge_num); - - return dsa_port_tag_8021q_vlan_add(dsa_to_port(ds, port), tx_vid, - true); -} -EXPORT_SYMBOL_GPL(dsa_tag_8021q_bridge_tx_fwd_offload); - -void dsa_tag_8021q_bridge_tx_fwd_unoffload(struct dsa_switch *ds, int port, - struct net_device *br, - int bridge_num) -{ - u16 tx_vid = dsa_8021q_bridge_tx_fwd_offload_vid(bridge_num); - - dsa_port_tag_8021q_vlan_del(dsa_to_port(ds, port), tx_vid, true); } -EXPORT_SYMBOL_GPL(dsa_tag_8021q_bridge_tx_fwd_unoffload); +EXPORT_SYMBOL_GPL(dsa_tag_8021q_bridge_leave); /* Set up a port's tag_8021q RX and TX VLAN for standalone mode operation */ static int dsa_tag_8021q_port_setup(struct dsa_switch *ds, int port) From patchwork Wed Aug 18 12:01:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 499560 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28F60C4338F for ; Wed, 18 Aug 2021 12:04:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1135B60F35 for ; Wed, 18 Aug 2021 12:04:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236528AbhHRMEe (ORCPT ); Wed, 18 Aug 2021 08:04:34 -0400 Received: from mail-eopbgr00067.outbound.protection.outlook.com ([40.107.0.67]:52143 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236286AbhHRMEM (ORCPT ); Wed, 18 Aug 2021 08:04:12 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nrl8Lp8OzJPj7ljKhCzkQP3sXWG6iuaXZ9zlPS5ax8qSnX5AOPo98u6tLlKk+eYioDC4YgzhFqHXvey9YhHWnLWBboFMwsZM8BsNrp+vxauE04kaDuZvYBP5A/zW4IEx93a40Yj+eJ5eqOU01vOExBS1AsmtJho8b8rSCUi4FpjVplHOeoRcijOmpqJVHlkv0qTYrmQZfVqyTDmx3vKE+N6WnpTI4gusaYzp5Yk7CkNXKkZnmrFpZZGESeivI4kfnEZmbJnzhvtuHV4RxOvqnot290Z05hIRrZUdt0XPOw4f/+bSksOco3pGhH3SsyNdQAGTT+ylLGMvfl0/AqyYOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ib6lpp6wQMl+qbN+dlEZgpJNaZnPswQqpEVfJXtZ2wk=; b=hzhun4kS8qzouELneBS7rbj1JbaL3y+/bEhFnsSCi00JNaCMyjThYH/l5VMdZJF7Zx/L+SNjWHAcXOFXuM/IIPlyZII1MSPC3LRX1L9mSDKHqvYPwYkrprW2glZNVUp/RNgsk6ZAN/k4oh8qCPkHI/UEEFkpMEJ/IdAIu2RclO6Ww/Ca0ZBACjpfnC033/XNI4nVsnDPWjW7euPrr2ZT98kC3JqjsR+3h0Jfyox0W9HniNGE2wNan1NwJ/27BTfgCf8GQToR7rzmbRMCsWcy2vfgca68gRx3KbAaniTcrr0CrGLa8JL3cmVgp2Awq2SL8fukRei9uZf1sE5JRp74fg== 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=Ib6lpp6wQMl+qbN+dlEZgpJNaZnPswQqpEVfJXtZ2wk=; b=BcZCI+9s0poN5qoLsPbizeGlqyeOdcRyMCJMFRRWned4TNJwKggNOs9hFpt87LsBrkDtCy/F2gwvgYJD6BD7T5dThqzZdqleDVnv1W5Ah5oaXPEi91WpVLWU3mDDSAt3sCbAB+FZScQ0R3kP6t/N+PtEIevjBB/g1XEIWYYWJ6o= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB3839.eurprd04.prod.outlook.com (2603:10a6:803:21::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17; Wed, 18 Aug 2021 12:03:05 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4415.024; Wed, 18 Aug 2021 12:03:05 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Roopa Prabhu , Nikolay Aleksandrov , Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean , Vadym Kochan , Taras Chornyi , Jiri Pirko , Ido Schimmel , UNGLinuxDriver@microchip.com, Grygorii Strashko , Marek Behun , DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Claudiu Manoil , Alexandre Belloni , George McCollister , Ioana Ciornei , Saeed Mahameed , Leon Romanovsky , Lars Povlsen , Steen Hegelund , Julian Wiedmann , Karsten Graul , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Ivan Vecera , Vlad Buslov , Jianbo Liu , Mark Bloch , Roi Dayan , Tobias Waldekranz , Vignesh Raghavendra , Jesse Brandeburg , Peter Ujfalusi Subject: [RFC PATCH net-next 10/20] net: dsa: tag_8021q: add support for imprecise RX based on the VBID Date: Wed, 18 Aug 2021 15:01:40 +0300 Message-Id: <20210818120150.892647-11-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818120150.892647-1-vladimir.oltean@nxp.com> References: <20210818120150.892647-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 18 Aug 2021 12:03:03 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fe4681f5-c0c5-41ae-bf1b-08d962402230 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3839: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bttw9si0LNrKM5FeSBhYJmaMrKN0mIN1ZnLBmt+u3Y8xEWdHEx3Ax1DfLe4VE5rGp1FuoMU/wOvJHf1YdQjvvwxhwaU5+O//4CQ2Ex3A/59wWDH7vP8SlLx7/e3mWoygNwVlAxPEzIGjaaRDS4cyHartSQcSlsEXSnca3txUvIajT7ePswAP7pv/eVujQRCrcG9P6urqDZzjPJKdibJ11VruwaA7JwUzBhByb14TXKpQWky8et5F15bJIuWSzuBkAH70E5mh6RCSFWgP9nuHdoSEQG4ThTh/t2DBUK+jZp/1CSkd8ZNupIPjCi2MCp8q7ptOlgqtR7OC+G1hGRHbO7q5dG4nnkE+l+NgqExbLuQdyBK7B81RgrFhmUD7Bon83YaKGe+hRYcKO4SONfBTiB7oEgB/b2okE5m0Lf/r6EpndiYB50SWlXgVUybOA/VS4HHzszEGFIN3RsBWffpoqh/rZHy9mQ0OpO4eoSJVgZ1KIQg6I5J/gw4NVOdcxfyIPFJYC80WSwMD2f2VlwzB9O9II7WMnmWJD2YTo2KUog8uwf1dcFo0GwcHbvenjRxT8gZdoJItmT7+eX6F5DzAFpVuZGkLaQZ4zAR8Rh6PTtrAXFuESe8oPqwRArcIYBu5ySVzlzpqtVZO3GfSBaY+cGtl+s9iMh77QqtKrY9TEHfIsevozYheQgSIWJTUpKPN X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(346002)(136003)(39850400004)(366004)(376002)(66476007)(2906002)(66556008)(8936002)(6506007)(186003)(7406005)(7416002)(52116002)(26005)(86362001)(66946007)(6486002)(44832011)(36756003)(5660300002)(1076003)(110136005)(54906003)(6512007)(8676002)(316002)(6666004)(38350700002)(38100700002)(956004)(478600001)(83380400001)(2616005)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VVcMN8zq4Pt9qdMS8/coVkRFNU6ey5Q0Eq3DtK0c67uF0T9VWt5Z3MFL/iv+g3GwQKsZlk1Oc4YMeQDpE3G9bArg8OQRtSHvysJXJ4L1if6NymMlrffeHbc6s6lmRFFwecsT461gZLtL1QvKbAtQ5jgUGI1CpU7+jFWoVdyV30Y7CR61cgoF1aOPzxsWGTRCo77iltnm3IBK0PASZt13O0BZZOVDRLV1HbKA7U4FEI7WaKfkcLFrYHIaBVzG94lsmg32LTlEXVe9MCaaBJvd5t2hDEYLsWvFa46XziGHRut3+qhHTjooqDTztTL9seUxICc/ObhPYMbYvR1qdpxPe1P5yfie3xLtS+qImAWkkVASmqVgPMhdvsYDhVnEGMRuM8YTITRwShMzlz/Wouk/Al1SvyvqJ+HUAg6p48HMjPxWtjA0ujAx8Ypa5DQzIDJ75cHz6ScTL8XS67HRw2Y7gQ1jiSSXyDS9Ab9VSnwN1PqDjVqvosRgLNUqEhA3gHl+pxC5EU4DGQy6WrVKG0gKV1l+jie+BFa9DGBMYU4FPHkityNNdZcmOo01ELC/PPo3R6v1MLk3O7135hPSKJH2Llk/DawJ5AwXMuSICYnk5SU414WTBidlfkMpeG4rNbJy/k/Y0Ekv7UdkzTCLxtz4B7L3aIMOaS5YyWp9WTXQMP3al0627uAftm/VZ2blj32usYQpZeFm/+fVavg1Py5LUFzbEXMeH6XVXy5z/I3QrUQpMBAsd5BZUObC418x9u8IeY7usFmNv2i2ChRQp6PLLdPjPEjzl+D/iiFocF0AoDZojCemXJYJOnrT9RWH0GTAKN1TXp4+OdSHGb9cFxsB78JyS179F4fzxkOLcLGIXR4sxmpvedRgJNEKNUeeMh+yIHtOJCzFL+XYBzoaxR8NBAgjq+GzS8IMlqTllWL2G8W/8aFdDIFyqzxBC2GkMz28Wagp+NJm5mNu3nAtB12cjhwnRe6vgyY0bdvbOqRPUB8DRSiY9b+Rvak8/zLj+/sYYZkWQya9dvx27I8mrvMVeApojJkL6gQwA6GeZ1JJg9qlMnVG0H8huLGjkjcvKJ48yvi2sCodTLIIXHzzRt5f4GaS2CwRpMQ1Av3EMD8LFFejM6bqqxDJSAoYEpaKHIzDqWAWM7yv5nq/rpF0+lm7maLuN0zWz3lY9YY+n1qMpHGjkUymliFuleBC9xJ+I0QLBVdT7v3qH2g9mGDPBcC5BXBy8NWMhyqCp6tCyiQzFwpZmzjAWuH0DHNhOpmVlFEVabNQjuy+DCQL5E/OQXBvV0CcoEBz1jlQ4o+JBJZB8ORZjCEYsx+vXJWCvnrvZf9z X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fe4681f5-c0c5-41ae-bf1b-08d962402230 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2021 12:03:04.3113 (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: eRx0dchh9ijqkOlg8uIWqdtXtMBL+PZOcSVtDWu4KbLucDprvPnBc/P9UQswiZQKUQfwgHoMYrlKdsikAU6grw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3839 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Similar to dsa_find_designated_bridge_port_by_vid() which performs imprecise RX for VLAN-aware bridges, let's introduce a helper in tag_8021q for performing imprecise RX based on the VLAN that it has allocated for a VLAN-unaware bridge. Make the sja1105 driver use this. Signed-off-by: Vladimir Oltean --- include/linux/dsa/8021q.h | 6 +++++- net/dsa/tag_8021q.c | 39 +++++++++++++++++++++++++++++++++++++- net/dsa/tag_ocelot_8021q.c | 2 +- net/dsa/tag_sja1105.c | 22 ++++++++++++--------- 4 files changed, 57 insertions(+), 12 deletions(-) diff --git a/include/linux/dsa/8021q.h b/include/linux/dsa/8021q.h index 29b9c0e195ae..ac537d983fee 100644 --- a/include/linux/dsa/8021q.h +++ b/include/linux/dsa/8021q.h @@ -39,7 +39,11 @@ void dsa_tag_8021q_bridge_leave(struct dsa_switch *ds, int port, struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev, u16 tpid, u16 tci); -void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id); +void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id, + int *vbid); + +struct net_device *dsa_tag_8021q_find_port_by_vbid(struct net_device *master, + int vbid); u16 dsa_8021q_bridge_tx_fwd_offload_vid(int bridge_num); diff --git a/net/dsa/tag_8021q.c b/net/dsa/tag_8021q.c index ae94c684961d..b47a4f7a67bb 100644 --- a/net/dsa/tag_8021q.c +++ b/net/dsa/tag_8021q.c @@ -532,7 +532,40 @@ struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev, } EXPORT_SYMBOL_GPL(dsa_8021q_xmit); -void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id) +struct net_device *dsa_tag_8021q_find_port_by_vbid(struct net_device *master, + int vbid) +{ + struct dsa_port *cpu_dp = master->dsa_ptr; + struct dsa_switch_tree *dst = cpu_dp->dst; + struct dsa_port *dp; + + if (WARN_ON(!vbid)) + return NULL; + + list_for_each_entry(dp, &dst->ports, list) { + if (dp->type != DSA_PORT_TYPE_USER) + continue; + + if (!dp->bridge_dev) + continue; + + if (dp->stp_state != BR_STATE_LEARNING && + dp->stp_state != BR_STATE_FORWARDING) + continue; + + if (dp->cpu_dp != cpu_dp) + continue; + + if (dp->bridge_num + 1 == vbid) + return dp->slave; + } + + return NULL; +} +EXPORT_SYMBOL_GPL(dsa_tag_8021q_find_port_by_vbid); + +void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id, + int *vbid) { u16 vid, tci; @@ -549,6 +582,10 @@ void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id) *source_port = dsa_8021q_rx_source_port(vid); *switch_id = dsa_8021q_rx_switch_id(vid); + + if (vbid) + *vbid = dsa_tag_8021q_rx_vbid(vid); + skb->priority = (tci & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT; } EXPORT_SYMBOL_GPL(dsa_8021q_rcv); diff --git a/net/dsa/tag_ocelot_8021q.c b/net/dsa/tag_ocelot_8021q.c index 3038a257ba05..5bf848446106 100644 --- a/net/dsa/tag_ocelot_8021q.c +++ b/net/dsa/tag_ocelot_8021q.c @@ -42,7 +42,7 @@ static struct sk_buff *ocelot_rcv(struct sk_buff *skb, { int src_port, switch_id; - dsa_8021q_rcv(skb, &src_port, &switch_id); + dsa_8021q_rcv(skb, &src_port, &switch_id, NULL); skb->dev = dsa_master_find_slave(netdev, switch_id, src_port); if (!skb->dev) diff --git a/net/dsa/tag_sja1105.c b/net/dsa/tag_sja1105.c index 5b80a9049e2c..088709ef877a 100644 --- a/net/dsa/tag_sja1105.c +++ b/net/dsa/tag_sja1105.c @@ -383,7 +383,7 @@ static bool sja1110_skb_has_inband_control_extension(const struct sk_buff *skb) * packet. */ static void sja1105_vlan_rcv(struct sk_buff *skb, int *source_port, - int *switch_id, u16 *vid) + int *switch_id, int *vbid, u16 *vid) { struct vlan_ethhdr *hdr = (struct vlan_ethhdr *)skb_mac_header(skb); u16 vlan_tci; @@ -393,8 +393,8 @@ static void sja1105_vlan_rcv(struct sk_buff *skb, int *source_port, else vlan_tci = ntohs(hdr->h_vlan_TCI); - if (vid_is_dsa_8021q_rxvlan(vlan_tci & VLAN_VID_MASK)) - return dsa_8021q_rcv(skb, source_port, switch_id); + if (vid_is_dsa_8021q(vlan_tci & VLAN_VID_MASK)) + return dsa_8021q_rcv(skb, source_port, switch_id, vbid); /* Try our best with imprecise RX */ *vid = vlan_tci & VLAN_VID_MASK; @@ -403,7 +403,7 @@ static void sja1105_vlan_rcv(struct sk_buff *skb, int *source_port, static struct sk_buff *sja1105_rcv(struct sk_buff *skb, struct net_device *netdev) { - int source_port = -1, switch_id = -1; + int source_port = -1, switch_id = -1, vbid = -1; struct sja1105_meta meta = {0}; struct ethhdr *hdr; bool is_link_local; @@ -416,7 +416,7 @@ static struct sk_buff *sja1105_rcv(struct sk_buff *skb, if (sja1105_skb_has_tag_8021q(skb)) { /* Normal traffic path. */ - sja1105_vlan_rcv(skb, &source_port, &switch_id, &vid); + sja1105_vlan_rcv(skb, &source_port, &switch_id, &vbid, &vid); } else if (is_link_local) { /* Management traffic path. Switch embeds the switch ID and * port ID into bytes of the destination MAC, courtesy of @@ -435,7 +435,9 @@ static struct sk_buff *sja1105_rcv(struct sk_buff *skb, return NULL; } - if (source_port == -1 || switch_id == -1) + if (vbid >= 1) + skb->dev = dsa_tag_8021q_find_port_by_vbid(netdev, vbid); + else if (source_port == -1 || switch_id == -1) skb->dev = dsa_find_designated_bridge_port_by_vid(netdev, vid); else skb->dev = dsa_master_find_slave(netdev, switch_id, source_port); @@ -555,7 +557,7 @@ static struct sk_buff *sja1110_rcv_inband_control_extension(struct sk_buff *skb, static struct sk_buff *sja1110_rcv(struct sk_buff *skb, struct net_device *netdev) { - int source_port = -1, switch_id = -1; + int source_port = -1, switch_id = -1, vbid = -1; bool host_only = false; u16 vid = 0; @@ -569,9 +571,11 @@ static struct sk_buff *sja1110_rcv(struct sk_buff *skb, /* Packets with in-band control extensions might still have RX VLANs */ if (likely(sja1105_skb_has_tag_8021q(skb))) - sja1105_vlan_rcv(skb, &source_port, &switch_id, &vid); + sja1105_vlan_rcv(skb, &source_port, &switch_id, &vbid, &vid); - if (source_port == -1 || switch_id == -1) + if (vbid >= 1) + skb->dev = dsa_tag_8021q_find_port_by_vbid(netdev, vbid); + else if (source_port == -1 || switch_id == -1) skb->dev = dsa_find_designated_bridge_port_by_vid(netdev, vid); else skb->dev = dsa_master_find_slave(netdev, switch_id, source_port); From patchwork Wed Aug 18 12:01:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 500288 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F5E6C4338F for ; Wed, 18 Aug 2021 12:05:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 84C5160EBC for ; Wed, 18 Aug 2021 12:05:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235854AbhHRMGL (ORCPT ); Wed, 18 Aug 2021 08:06:11 -0400 Received: from mail-eopbgr00079.outbound.protection.outlook.com ([40.107.0.79]:39586 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236306AbhHRMEM (ORCPT ); Wed, 18 Aug 2021 08:04:12 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c7N1af6VsnxG20YbC2QSz8i2hvkK/XWFfRl8bcZ+slBGsxUmsSIb8NElSwcIb4hxvzDZadzelTo9axXkx0MiquQgFuhhP9dkMYmSPw01UDvXDUo26y6jiuLGlJjGO3boIhZ0NFsw/Dnvo1r1XqXB53GC+QqtEuRUHcCLOS0jUCY1u6ppxyJlSOhWMdFk76jeQx3o7bdopeuNFu24rmwJPqqbkCo5QjEl6MAEgU72YanQWy/xIb/CLdHJji75bDWHZKWBTdvmjo6AC4lPEvdlQSEfmOR5l1FLgtF751ME+qR6e0Qk+WBPbgexffzhYPx0fJcCS4vtBPiWe0tz6tFgdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xZ7Auj+q1GvxQeA1+Iku1NmwjvTWzxagiNBvPaQMEZA=; b=CzOYcfcShRgiSvG5npYrmP23I9jTfi9Vob4KoFGR1kxVDVBXwOECN9xqCH76FjkR8TwOF8cgnOShPuTYoEKmgdqthRNeXL6q8Qkf3ToiUBa8I2W/AFOR8RZ6f7HrrhHofexSp0flvn5Ck53H0VLhA+lvr/+Wrek/TNLgLOo0Kr7uGKorOIuhfB6dByWFZCstNUma0KFerkAZajP2+pzI4sWTu8qbgdNoJ6nF9/s5KAGAatVcDqabsnmRvqW/POcQNfVY8Q0kut6yYeTVbp7z/gvYWVCXm8cPSQPcmyFXkJ7Y6MrUN6rKWZga7/u2fZYDz70Aewou9zPfZbvHSk8ByA== 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=xZ7Auj+q1GvxQeA1+Iku1NmwjvTWzxagiNBvPaQMEZA=; b=UbezpKq31ufJ7bWnSUO50MujoyCKxVcOQToc0KeF9/L/WmvkmSHe7LCjOSpc/DROUvUIEAcnnPHuzavfpjnCQWVE3h5RXCez7VLA1mrQ4E7/p/oouEkyKOEojPCcdKuhiXsO7HaANKxkjRSB3I7AJxRIfyfXmLayexIi/1m2wuc= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB3839.eurprd04.prod.outlook.com (2603:10a6:803:21::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17; Wed, 18 Aug 2021 12:03:06 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4415.024; Wed, 18 Aug 2021 12:03:05 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Roopa Prabhu , Nikolay Aleksandrov , Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean , Vadym Kochan , Taras Chornyi , Jiri Pirko , Ido Schimmel , UNGLinuxDriver@microchip.com, Grygorii Strashko , Marek Behun , DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Claudiu Manoil , Alexandre Belloni , George McCollister , Ioana Ciornei , Saeed Mahameed , Leon Romanovsky , Lars Povlsen , Steen Hegelund , Julian Wiedmann , Karsten Graul , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Ivan Vecera , Vlad Buslov , Jianbo Liu , Mark Bloch , Roi Dayan , Tobias Waldekranz , Vignesh Raghavendra , Jesse Brandeburg , Peter Ujfalusi Subject: [RFC PATCH net-next 11/20] net: dsa: felix: delete workarounds present due to SVL tag_8021q bridging Date: Wed, 18 Aug 2021 15:01:41 +0300 Message-Id: <20210818120150.892647-12-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818120150.892647-1-vladimir.oltean@nxp.com> References: <20210818120150.892647-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 18 Aug 2021 12:03:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d219f2a1-0d54-48d4-e43d-08d96240230b X-MS-TrafficTypeDiagnostic: VI1PR0402MB3839: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6TnrEwF8lWgcvVzxEAYBMbbZGUc/F4C6dyp9qHgqnZufEu03SeNew6GiuZVzRbgOFSdOPonJVgQluvGIfURB5JZU5yk0E0cAgREPLVZhBKacuyKdEarU4+ZD+7GD3ebZKYloYEXuSO1ushUkhB/tWeHuSP0EqViNpBarmMN3ACPX7yuDsCGHCjpX5wn6S7cAXa09IsMssSUz5W7AnOaVyLRSDpxbe9mrHIGHrg/9Piz2dstqrpEHGAKujDramEUFkVn3PxGm1lyVhBN1RO4AeD7uORDijUM3+yx2qRhbwqr96yt6RrQpBC92MTuaKyR5bs8SjvfeQVrUZ0knq/1dfiQpwTgxcuuNoh2sTLSoosXa2P5nbcxqPcU8pld/UT/Rql67+NCWHMEhyGL0ssCKeBCbUDRub0+WMhw4pytiAHVAKp68ImJpopVbxLk2DYqjNvEiqb4clwSZcCtmjJYIWB/nCD1m1j3K0FGJpk53lSNrj/WYbcGCJvcgDvVnq094VnvFWP1smELm6vCrS39nN95BYFj0nkKFySSEJchb4JQ4ykvg4QloVja8SWBRotJ9IazGgto0x7dkwLqZSrZ4wHFVbzy29lyKtmvXFCALhzMfI9eyxN9EhYmTyCHn8Oz/a70ygULzeS10wgcnhVnlC943RjTdPADkDQ1hX3+yIU159ZaDxomBtNzbDvR9K1lnGy09/ztWGaQfAar9tF7Q/g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(346002)(136003)(39850400004)(366004)(376002)(66476007)(2906002)(66556008)(8936002)(6506007)(186003)(7406005)(7416002)(52116002)(26005)(86362001)(66946007)(6486002)(44832011)(36756003)(5660300002)(1076003)(110136005)(54906003)(6512007)(8676002)(316002)(6666004)(38350700002)(38100700002)(956004)(478600001)(83380400001)(2616005)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RcyupGXC/nleNISZI5KfF3aboeGWaF7XTYvNu2wWonu+j38rjEPg1n38iSpytse8oWnqQM4cEZ3U18cms0ocO51I+PjfodXLHOq4j5cdJhyNrjavFn6zavRmcHwPAgncmW0avDIGjNOGPtmdSsYeyK1YY9kGpcvPSwvI4NjDCnbSPC3oWp5hRj66NWLiEaxyAPCUF4W7WH3l7hAwXgJAXxGSeTLUyy2sBNRcsaKQysXf/ZjWkZnLhN8SBGAZG1hprr004VZsxD0xa3IjPcofvyFT8Gn9YWwByoUFl0QmEqgOYHVWXogfae9cmgipKVpDKGQK9V0tQdoBRxNO7c70B5U0jX+I8as0HrUap0xaKHl3iUerHCu7b2oFeHOfqBtcBVI8agPlWvpRFs3NgxLvmvNVa5Svi93674W7FbNC0XF5eUhaa1FF0N2nKd8wjn80KOELdDl+VK3LM3+eyqj6jpK7WARnu3FPlkW6TW4BylKx+WMc/xBNUK+XQk34C8RRfz6GnhIru6s47MGVpFCOV/WYqLYUetmZsdWmBxtaX6M90VOXyPZBH96oixRaQdcl2bi/iVTU+FNFvuUSKpV/06A5Gy3uQzW6BxX8+GVdF8DpWZLl+rLRsxqVDc+m6utpNEoDhBim8+JaoRVoCGQ68ZsVK05VCvQeN9Z1M3z/afGHFynJduqiGLyuiAI/VzzKEfR4z3oeHRcmBJ6MkjQi60rfdsh3DnmbBcndj0H73LDT8wAXLGAmnbTD8O/bZ1NytVO9IolktvV78n7shvemmzaTHtH64GDiKeDTR70ErY59AnzAAtHzSvokcUl0i/ICHgXd62yU+XgP349SaArL3NRYpmOxJRJ3EoIP/XLA/OTuQJklVjlMFCGGWfme0oMUUmHhPbRQERY5WaIyY+LL8Z3JroXA52KjoNKuI2VLhn06awVjc46gOHrgENvJqhIy8hDJHTJcG/JtiaePn4W75CIxe4XDvVhnZg60qMyo7KZjzFAQN5H1oFC1S/mtAsW5NI/P6CydcdcwX/PIOGOeF9iZfMOcvkDIPDaUKv/saxychS4DSAHApCvmB8r2aVuW+NHNpIoGzMFyWvG4AT+94wQXPcJAdbIzpmWsfge5oI0AIQv75GqMkE7nVxyJ6TkQYOFlbmbSnkl46Y3Vcwkp3HKSW5RDDobiJgN/ti7Rryb3TeCYIyGNE1+BCL77eu6xw+i3eeqPxoOTxMalgz4uGdJO8PiSmrnnKqIhHXusghezqNAQRIU0lStlg0vTo7IiCPhsWkmNDnIesEnh2YcLSZrhC4orWLo8idTP8SZlMqA3apdoPzclqro2bZwUu5Vq X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d219f2a1-0d54-48d4-e43d-08d96240230b X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2021 12:03:05.7555 (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: ZoHM52sd/ULhAO7cH363b4o8NvgNd2C2HtC6Kjq7KGsE70cBvwnsLgVINBeRb85b74GgDpSBkfOsDz7TrfdQIQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3839 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The felix driver, which also has a tagging protocol implementation based on tag_8021q, does not care about adding the RX VLAN that is pvid on one port on the other ports that are in the same bridge with it. It simply doesn't need that, because in its implementation, the RX VLAN that is pvid of a port is only used to install a TCAM rule that pushes that VLAN ID towards the CPU port. Now that tag_8021q no longer performs Shared VLAN Learning based forwarding, the RX VLANs are actually segregated into two types: standalone VLANs and VLAN-unaware bridging VLANs. Since you actually have to call dsa_tag_8021q_bridge_join() to get a bridging VLAN from tag_8021q, and felix does not do that because it doesn't need it, it means that it only gets standalone port VLANs from tag_8021q. Which is perfect because this means it can drop its workarounds that avoid the VLANs it does not need. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/ocelot/felix.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 3ab7cf2f0f50..d86015c59c5f 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -34,13 +34,6 @@ static int felix_tag_8021q_rxvlan_add(struct felix *felix, int port, u16 vid, struct dsa_switch *ds = felix->ds; int key_length, upstream, err; - /* We don't need to install the rxvlan into the other ports' filtering - * tables, because we're just pushing the rxvlan when sending towards - * the CPU - */ - if (!pvid) - return 0; - key_length = ocelot->vcap[VCAP_ES0].keys[VCAP_ES0_IGR_PORT].length; upstream = dsa_upstream_port(ds, port); @@ -171,16 +164,8 @@ static int felix_tag_8021q_rxvlan_del(struct felix *felix, int port, u16 vid) outer_tagging_rule = ocelot_vcap_block_find_filter_by_id(block_vcap_es0, port, false); - /* In rxvlan_add, we had the "if (!pvid) return 0" logic to avoid - * installing outer tagging ES0 rules where they weren't needed. - * But in rxvlan_del, the API doesn't give us the "flags" anymore, - * so that forces us to be slightly sloppy here, and just assume that - * if we didn't find an outer_tagging_rule it means that there was - * none in the first place, i.e. rxvlan_del is called on a non-pvid - * port. This is most probably true though. - */ if (!outer_tagging_rule) - return 0; + return -ENOENT; return ocelot_vcap_filter_del(ocelot, outer_tagging_rule); } @@ -202,7 +187,7 @@ static int felix_tag_8021q_txvlan_del(struct felix *felix, int port, u16 vid) untagging_rule = ocelot_vcap_block_find_filter_by_id(block_vcap_is1, port, false); if (!untagging_rule) - return 0; + return -ENOENT; err = ocelot_vcap_filter_del(ocelot, untagging_rule); if (err) From patchwork Wed Aug 18 12:01:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 500293 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCC3BC4320A for ; Wed, 18 Aug 2021 12:03:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A639F60F35 for ; Wed, 18 Aug 2021 12:03:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236463AbhHRMEa (ORCPT ); Wed, 18 Aug 2021 08:04:30 -0400 Received: from mail-eopbgr00085.outbound.protection.outlook.com ([40.107.0.85]:55044 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236326AbhHRMEN (ORCPT ); Wed, 18 Aug 2021 08:04:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nwNi5LcE1dYSWeSmAZONNw+R3hgNlOADi0LrEOxXJEpSfyqVKtCbHXoA/ZwTjF3NVq6PoGpJkg5f5Al5uqGYMOl36vEL6ElSKBxgnZOAmp/HXojCMO1V0JihpvKOl5/TbSjatrSK+2hyzrs5Y8Oj2rBbFQr4rrShHO7hqS9AD4vcaElGKKiS+8Pzi3Hff0hpxWPRNO1Yaj9fROPay09GPW4Vq9bmqIh3TZgroAagrYIDk239u209cmAuSBmz7XGeqnon0Jh/Ka86YTqWeV1guk9vafwklrAmp7nLk81nD2JJHhqNsj+XaiQ9EN9oMVTBYWc9srtgGUScxhRzODDXYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PnGXCCI4DnYnFkfuZ/jHpuN7dP1j0nlyKwMmmtgKBmQ=; b=XiwlBslLrHsRJuPKQBUUqW8757BsXChphLs8O3O4PZ5f5Jcmj0N8QhBv58Y4GZCBimyE+BwB2o3RaFjRGBG5aGYWVontptUusJ3gMJ5oc4GhjNpUJIaRv1JG1dbFA91Yi8SHi2IruFl93Iyz5+K0cSC1/bfZ7mSA7BGzRc9TYhwlZ1DgxgvwB0nWOWcYaUTI6p8nREW3y0UNn1BYVmlsx3dqzstEL0mZdWY+9Gb6eFzg8NVy6/kW/Nxmno+eGvSwE6P5dlPhkUh7AISBwNWv3nTqXP2LXkTP2t75wEHDvOlpgbH+yWqjdQCz6+mtxZ0f8VFSk4IxO9EIMlXXX3J3Ng== 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=PnGXCCI4DnYnFkfuZ/jHpuN7dP1j0nlyKwMmmtgKBmQ=; b=cQunoFazeRzYCOkqDAierPcTU6j+prPevGSDnWXzsfg78pl3IDFU+d0IbDhye6SGcioJy5sADN0p5Hb4+PuZHfSNuPo+4TEfYWm/VCU+DPFPmoXcC8unG3yW9zuTyGr25jGBoeW9xh2jNUUY4yMxqh3+Jdibf6QA2tf/xOfM+P4= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB3839.eurprd04.prod.outlook.com (2603:10a6:803:21::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17; Wed, 18 Aug 2021 12:03:07 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4415.024; Wed, 18 Aug 2021 12:03:07 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Roopa Prabhu , Nikolay Aleksandrov , Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean , Vadym Kochan , Taras Chornyi , Jiri Pirko , Ido Schimmel , UNGLinuxDriver@microchip.com, Grygorii Strashko , Marek Behun , DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Claudiu Manoil , Alexandre Belloni , George McCollister , Ioana Ciornei , Saeed Mahameed , Leon Romanovsky , Lars Povlsen , Steen Hegelund , Julian Wiedmann , Karsten Graul , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Ivan Vecera , Vlad Buslov , Jianbo Liu , Mark Bloch , Roi Dayan , Tobias Waldekranz , Vignesh Raghavendra , Jesse Brandeburg , Peter Ujfalusi Subject: [RFC PATCH net-next 12/20] net: dsa: tag_8021q: merge RX and TX VLANs Date: Wed, 18 Aug 2021 15:01:42 +0300 Message-Id: <20210818120150.892647-13-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818120150.892647-1-vladimir.oltean@nxp.com> References: <20210818120150.892647-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 18 Aug 2021 12:03:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b50aa3b6-2b7f-4d2b-f39e-08d9624023e7 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3839: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Dy5GGNKPeARXvt6pyTK44yoFYmr1sUv074dk706J4ypEv23hgT9sybpj/fHR4VKF0UDRKL+BTkx8b8S2vWmm58Y1d+TkzFcjfPC5U+unKg64rKtQjodReA4sc/lzNkvogX5I/EHf9V5ogU8fSHbWspEGLiLwikole0EM8tfan/7JqqSbbAcZlbnMPU8tgbyMcDqPWZF5kElPmYG/Wj9A+U18++CwoXrTvNiEQD1jzduJvS0TYDZajPIgXEHy1Lzh5kJZ9yMoPea96eAdm8uekivfl5AtSVFL90h8CFEcyrW90PXmIRh4s2Jz83B/TGgAOcKWcRGGTgNKO90NibLx6axwneb7HkYMFgJfbXlCAp2V2gPGlPzORxM15pgiqh9IfyNaqJ3woJ2kpH9FgbvkuIumVQ9TAXy6/cs1J5qY8w0uyHctdmhSVHGfR6wBczu9qOBWfpIGEkqpwNvI3phTqWL123PkYWpzicnnoWdvyUeaTpLIqztvXPu9hvAopbZCVy9Xg2jWZTD1mJ1xB4KzMLpXnxGhPXBEV4+NxFpxKuQ3AkEC06Y3pVJtZv90eXiGdvQhtocm+NQHmoXCFLL3O0sud97HTjbo/uZN5NsgilkZhshneTJeIHsXMkQDkd75gpnAw6aC3uGp9L/4XkOrSLn1UwUtHyufwsXWNEKxakLYKFn3xcjrkZ5z0ZwYcX06uF6EgRXyookCeOuc8iTFCw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(346002)(136003)(39850400004)(366004)(376002)(66476007)(2906002)(66556008)(8936002)(6506007)(186003)(7406005)(7416002)(52116002)(26005)(86362001)(66946007)(6486002)(44832011)(36756003)(30864003)(5660300002)(1076003)(110136005)(54906003)(6512007)(8676002)(316002)(6666004)(38350700002)(38100700002)(956004)(478600001)(83380400001)(2616005)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 17+K6FyxsmA5EZVcyLU7cVzvoe69FUfzEz9KKK87cBZ0iLM/RLoZg/Fxc1r/ydoKYMsJMAR+EJR0b1JEidN1aXc2dFuiRLksIAZvteoIy7fIthdCP3FGi7eVNKztqXbfew7pKfhydGvAABWK5hlQe3V7IvdoWYySdceArC9G6RRwsQU4f+aBayZSrh2LOKxcKgyhFF+vP1rlT3SFc3o0JpkLC1C8f6Mh1U9mymqbv1xgxpzNGuZ0ROEBqY7rI+2XmYUufsGQutCCzLKkRYH0lYGoBAF5FCkbfvV9Wn0jP18dCdy2eYK6V57jC+F6tSuqCxtT0htqPreWyWrOeLXudo2EgSaNtjxVuF2hqcXLlAhz7XB/Hi2zafL1IDSTw3NxSKYf2VP4n4PsPRZ3biNl3Un1R5NfMidjkOWOpfGSR2c/lur4J9f+ZyyhYu0wDt4L5WvwWfy7Ailwg7KSnQHX5EK0eLhQaWwttNgbXEgDHA05PvUNmf27F88yMRneAXDDHIce9bTF2ON1waXG35DABmRs1po1S3ddGvi8L36nGPImc+PQys4gpNkBS0uPp1G7WN77FD9hGMvDVED/NzZb6y/Lj6Lqgma+t6tkxw2v9cYwEE1dSIYlh0+dMTTErq0OIbfkYfnqRjAFlnxgOX7QS07EEUitLroncg8C5Z9I5oEe+GxXaTYGHWFuHaTGeRMrastS8hOz71NNF7ovP3W0PmhaP+Jzh/b6YQCwLYdc5x2kTs5esTL0telZf9OhF0Ei6KZ5Df0V/aFKrsS3BNP0z8umhaUqqHVPVX6TBWwZmywDoArU9hQcvWlslgSWcFmkCxOJmkFXVA96D8Fi5iYPuRSjkYoo9TPYFx8wjldh/FDNO+eKZTjAXFtfJzO+Z4GU5xGT4tgDzZG9W+iekODhw0UHOQ4G+SKAsIBKkWBZeEodlrctHW2zRmelBTAiEEGbQlfqiyNLXmbABjxQtndbd+cMxAoyZGgYuqRrxDDOQVD8EJxa/topYpv50GnLLBYnAjgUACbONRahxEgzetkekQCUdoZe65dMP6nD/2OQXQ7ESmP3mZ0zNwQZSnbqxKey1nxkY1LXhySlM4om4kmbfLHLfo7NLOY9+3DBlsUFg2AZKVbAMbIFqNnOCK7ExSus1Ew0kYqzz6WLQnI83dkl3Sg/c7MUAtTYh2D4m9Gx5NhcfbG1GjoDEzkMPyFozx+DR9tBu8OF1kg2SQ+y/8HNhgWhh5aEAiiqSA6fWwS8SyAK8B5OodZR5Yd0ny1yLz5UYlx2m3y1yg+zSMbcsGqKLf+D/wxrgyR6Fq3aN9MsOADcyONOaSrnuLQxwZJYZQXt X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b50aa3b6-2b7f-4d2b-f39e-08d9624023e7 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2021 12:03:07.1627 (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: 47VVng3lvV3wkzhkksoSveXgm2JSG5CNKwaZyHS2gE9YGpsxC+LVxuuUjQUrm5ge+iS21yrgtfDnukphUWmU+Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3839 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In the old Shared VLAN Learning mode of operation that tag_8021q previously used for forwarding, we needed to have distinct concepts for an RX and a TX VLAN. An RX VLAN could be installed on all ports that were members of a given bridge, so that autonomous forwarding could still work, while a TX VLAN was dedicated for precise packet steering, so it just contained the CPU port and one egress port. Now that tag_8021q uses Independent VLAN Learning and imprecise RX/TX all over, those lines have been blurred and we no longer have the need to do precise TX towards a port that is in a bridge. As for standalone ports, it is fine to use the same VLAN ID for both RX and TX. This patch changes the tag_8021q format by shifting the VLAN range it reserves, and halving it. Previously, our DIR bits were encoding the VLAN direction (RX/TX) and were set to either 1 or 2. This meant that tag_8021q reserved 2K VLANs, or 50% of the available range. Change the DIR bits to a hardcoded value of 3 now, which makes tag_8021q reserve only 1K VLANs, and a different range now (the last 1K). This is done so that we leave the old format in place in case we need to return to it. In terms of code, the vid_is_dsa_8021q_rxvlan and vid_is_dsa_8021q_txvlan functions go away. Any vid_is_dsa_8021q is both a TX and an RX VLAN, and they are no longer distinct. For example, felix which did different things for different VLAN types, now needs to handle the RX and the TX logic for the same VLAN. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/ocelot/felix.c | 120 +++++++++++++------------ drivers/net/dsa/sja1105/sja1105_main.c | 2 +- drivers/net/dsa/sja1105/sja1105_vl.c | 4 +- include/linux/dsa/8021q.h | 9 +- net/dsa/tag_8021q.c | 113 +++++++---------------- net/dsa/tag_ocelot_8021q.c | 2 +- net/dsa/tag_sja1105.c | 4 +- 7 files changed, 103 insertions(+), 151 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index d86015c59c5f..747dd739f533 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -26,8 +26,10 @@ #include #include "felix.h" -static int felix_tag_8021q_rxvlan_add(struct felix *felix, int port, u16 vid, - bool pvid, bool untagged) +/* Set up VCAP ES0 rules for pushing a tag_8021q VLAN towards the CPU such that + * the tagger can perform RX source port identification. + */ +static int felix_tag_8021q_vlan_add_rx(struct felix *felix, int port, u16 vid) { struct ocelot_vcap_filter *outer_tagging_rule; struct ocelot *ocelot = &felix->ocelot; @@ -65,21 +67,32 @@ static int felix_tag_8021q_rxvlan_add(struct felix *felix, int port, u16 vid, return err; } -static int felix_tag_8021q_txvlan_add(struct felix *felix, int port, u16 vid, - bool pvid, bool untagged) +static int felix_tag_8021q_vlan_del_rx(struct felix *felix, int port, u16 vid) +{ + struct ocelot_vcap_filter *outer_tagging_rule; + struct ocelot_vcap_block *block_vcap_es0; + struct ocelot *ocelot = &felix->ocelot; + + block_vcap_es0 = &ocelot->block[VCAP_ES0]; + + outer_tagging_rule = ocelot_vcap_block_find_filter_by_id(block_vcap_es0, + port, false); + if (!outer_tagging_rule) + return -ENOENT; + + return ocelot_vcap_filter_del(ocelot, outer_tagging_rule); +} + +/* Set up VCAP IS1 rules for stripping the tag_8021q VLAN on TX and VCAP IS2 + * rules for steering those tagged packets towards the correct destination port + */ +static int felix_tag_8021q_vlan_add_tx(struct felix *felix, int port, u16 vid) { struct ocelot_vcap_filter *untagging_rule, *redirect_rule; struct ocelot *ocelot = &felix->ocelot; struct dsa_switch *ds = felix->ds; int upstream, err; - /* tag_8021q.c assumes we are implementing this via port VLAN - * membership, which we aren't. So we don't need to add any VCAP filter - * for the CPU port. - */ - if (ocelot->ports[port]->is_dsa_8021q_cpu) - return 0; - untagging_rule = kzalloc(sizeof(struct ocelot_vcap_filter), GFP_KERNEL); if (!untagging_rule) return -ENOMEM; @@ -136,41 +149,7 @@ static int felix_tag_8021q_txvlan_add(struct felix *felix, int port, u16 vid, return 0; } -static int felix_tag_8021q_vlan_add(struct dsa_switch *ds, int port, u16 vid, - u16 flags) -{ - bool untagged = flags & BRIDGE_VLAN_INFO_UNTAGGED; - bool pvid = flags & BRIDGE_VLAN_INFO_PVID; - struct ocelot *ocelot = ds->priv; - - if (vid_is_dsa_8021q_rxvlan(vid)) - return felix_tag_8021q_rxvlan_add(ocelot_to_felix(ocelot), - port, vid, pvid, untagged); - - if (vid_is_dsa_8021q_txvlan(vid)) - return felix_tag_8021q_txvlan_add(ocelot_to_felix(ocelot), - port, vid, pvid, untagged); - - return 0; -} - -static int felix_tag_8021q_rxvlan_del(struct felix *felix, int port, u16 vid) -{ - struct ocelot_vcap_filter *outer_tagging_rule; - struct ocelot_vcap_block *block_vcap_es0; - struct ocelot *ocelot = &felix->ocelot; - - block_vcap_es0 = &ocelot->block[VCAP_ES0]; - - outer_tagging_rule = ocelot_vcap_block_find_filter_by_id(block_vcap_es0, - port, false); - if (!outer_tagging_rule) - return -ENOENT; - - return ocelot_vcap_filter_del(ocelot, outer_tagging_rule); -} - -static int felix_tag_8021q_txvlan_del(struct felix *felix, int port, u16 vid) +static int felix_tag_8021q_vlan_del_tx(struct felix *felix, int port, u16 vid) { struct ocelot_vcap_filter *untagging_rule, *redirect_rule; struct ocelot_vcap_block *block_vcap_is1; @@ -178,9 +157,6 @@ static int felix_tag_8021q_txvlan_del(struct felix *felix, int port, u16 vid) struct ocelot *ocelot = &felix->ocelot; int err; - if (ocelot->ports[port]->is_dsa_8021q_cpu) - return 0; - block_vcap_is1 = &ocelot->block[VCAP_IS1]; block_vcap_is2 = &ocelot->block[VCAP_IS2]; @@ -196,22 +172,54 @@ static int felix_tag_8021q_txvlan_del(struct felix *felix, int port, u16 vid) redirect_rule = ocelot_vcap_block_find_filter_by_id(block_vcap_is2, port, false); if (!redirect_rule) - return 0; + return -ENOENT; return ocelot_vcap_filter_del(ocelot, redirect_rule); } +static int felix_tag_8021q_vlan_add(struct dsa_switch *ds, int port, u16 vid, + u16 flags) +{ + struct ocelot *ocelot = ds->priv; + int err; + + /* tag_8021q.c assumes we are implementing this via port VLAN + * membership, which we aren't. So we don't need to add any VCAP filter + * for the CPU port. + */ + if (!dsa_is_user_port(ds, port)) + return 0; + + err = felix_tag_8021q_vlan_add_rx(ocelot_to_felix(ocelot), port, vid); + if (err) + return err; + + err = felix_tag_8021q_vlan_add_tx(ocelot_to_felix(ocelot), port, vid); + if (err) { + felix_tag_8021q_vlan_del_rx(ocelot_to_felix(ocelot), port, vid); + return err; + } + + return 0; +} + static int felix_tag_8021q_vlan_del(struct dsa_switch *ds, int port, u16 vid) { struct ocelot *ocelot = ds->priv; + int err; + + if (!dsa_is_user_port(ds, port)) + return 0; - if (vid_is_dsa_8021q_rxvlan(vid)) - return felix_tag_8021q_rxvlan_del(ocelot_to_felix(ocelot), - port, vid); + err = felix_tag_8021q_vlan_del_rx(ocelot_to_felix(ocelot), port, vid); + if (err) + return err; - if (vid_is_dsa_8021q_txvlan(vid)) - return felix_tag_8021q_txvlan_del(ocelot_to_felix(ocelot), - port, vid); + err = felix_tag_8021q_vlan_del_tx(ocelot_to_felix(ocelot), port, vid); + if (err) { + felix_tag_8021q_vlan_add_rx(ocelot_to_felix(ocelot), port, vid); + return err; + } return 0; } diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 1d05a6234a6d..3c319114e292 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -2440,7 +2440,7 @@ static int sja1105_bridge_vlan_add(struct dsa_switch *ds, int port, */ if (vid_is_dsa_8021q(vlan->vid)) { NL_SET_ERR_MSG_MOD(extack, - "Range 1024-3071 reserved for dsa_8021q operation"); + "Range 3072-4095 reserved for dsa_8021q operation"); return -EBUSY; } diff --git a/drivers/net/dsa/sja1105/sja1105_vl.c b/drivers/net/dsa/sja1105/sja1105_vl.c index ec7b65daec20..5bc6df63137a 100644 --- a/drivers/net/dsa/sja1105/sja1105_vl.c +++ b/drivers/net/dsa/sja1105/sja1105_vl.c @@ -394,7 +394,9 @@ static int sja1105_init_virtual_links(struct sja1105_private *priv, vl_lookup[k].vlanid = rule->key.vl.vid; vl_lookup[k].vlanprior = rule->key.vl.pcp; } else { - u16 vid = dsa_8021q_rx_vid(priv->ds, port); + /* FIXME */ + struct dsa_port *dp = dsa_to_port(priv->ds, port); + u16 vid = dsa_tag_8021q_standalone_vid(dp); vl_lookup[k].vlanid = vid; vl_lookup[k].vlanprior = 0; diff --git a/include/linux/dsa/8021q.h b/include/linux/dsa/8021q.h index ac537d983fee..5c67ac422282 100644 --- a/include/linux/dsa/8021q.h +++ b/include/linux/dsa/8021q.h @@ -9,6 +9,7 @@ #include struct dsa_switch; +struct dsa_port; struct sk_buff; struct net_device; @@ -47,18 +48,12 @@ struct net_device *dsa_tag_8021q_find_port_by_vbid(struct net_device *master, u16 dsa_8021q_bridge_tx_fwd_offload_vid(int bridge_num); -u16 dsa_8021q_tx_vid(struct dsa_switch *ds, int port); - -u16 dsa_8021q_rx_vid(struct dsa_switch *ds, int port); +u16 dsa_tag_8021q_standalone_vid(struct dsa_port *dp); int dsa_8021q_rx_switch_id(u16 vid); int dsa_8021q_rx_source_port(u16 vid); -bool vid_is_dsa_8021q_rxvlan(u16 vid); - -bool vid_is_dsa_8021q_txvlan(u16 vid); - bool vid_is_dsa_8021q(u16 vid); #endif /* _NET_DSA_8021Q_H */ diff --git a/net/dsa/tag_8021q.c b/net/dsa/tag_8021q.c index b47a4f7a67bb..76e4b99ecd89 100644 --- a/net/dsa/tag_8021q.c +++ b/net/dsa/tag_8021q.c @@ -17,15 +17,11 @@ * * | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | * +-----------+-----+-----------------+-----------+-----------------------+ - * | DIR | VBID| SWITCH_ID | VBID | PORT | + * | RSV | VBID| SWITCH_ID | VBID | PORT | * +-----------+-----+-----------------+-----------+-----------------------+ * - * DIR - VID[11:10]: - * Direction flags. - * * 1 (0b01) for RX VLAN, - * * 2 (0b10) for TX VLAN. - * These values make the special VIDs of 0, 1 and 4095 to be left - * unused by this coding scheme. + * RSV - VID[11:10]: + * Reserved. Must be set to 3 (0b11). * * SWITCH_ID - VID[8:6]: * Index of switch within DSA tree. Must be between 0 and 7. @@ -39,12 +35,11 @@ * Index of switch port. Must be between 0 and 15. */ -#define DSA_8021Q_DIR_SHIFT 10 -#define DSA_8021Q_DIR_MASK GENMASK(11, 10) -#define DSA_8021Q_DIR(x) (((x) << DSA_8021Q_DIR_SHIFT) & \ - DSA_8021Q_DIR_MASK) -#define DSA_8021Q_DIR_RX DSA_8021Q_DIR(1) -#define DSA_8021Q_DIR_TX DSA_8021Q_DIR(2) +#define DSA_8021Q_RSV_VAL 3 +#define DSA_8021Q_RSV_SHIFT 10 +#define DSA_8021Q_RSV_MASK GENMASK(11, 10) +#define DSA_8021Q_RSV ((DSA_8021Q_RSV_VAL << DSA_8021Q_RSV_SHIFT) & \ + DSA_8021Q_RSV_MASK) #define DSA_8021Q_SWITCH_ID_SHIFT 6 #define DSA_8021Q_SWITCH_ID_MASK GENMASK(8, 6) @@ -71,29 +66,19 @@ u16 dsa_8021q_bridge_tx_fwd_offload_vid(int bridge_num) { /* The VBID value of 0 is reserved for precise TX */ - return DSA_8021Q_DIR_TX | DSA_8021Q_VBID(bridge_num + 1); + return DSA_8021Q_RSV | DSA_8021Q_VBID(bridge_num + 1); } EXPORT_SYMBOL_GPL(dsa_8021q_bridge_tx_fwd_offload_vid); -/* Returns the VID to be inserted into the frame from xmit for switch steering - * instructions on egress. Encodes switch ID and port ID. - */ -u16 dsa_8021q_tx_vid(struct dsa_switch *ds, int port) -{ - return DSA_8021Q_DIR_TX | DSA_8021Q_SWITCH_ID(ds->index) | - DSA_8021Q_PORT(port); -} -EXPORT_SYMBOL_GPL(dsa_8021q_tx_vid); - /* Returns the VID that will be installed as pvid for this switch port, sent as * tagged egress towards the CPU port and decoded by the rcv function. */ -u16 dsa_8021q_rx_vid(struct dsa_switch *ds, int port) +u16 dsa_tag_8021q_standalone_vid(struct dsa_port *dp) { - return DSA_8021Q_DIR_RX | DSA_8021Q_SWITCH_ID(ds->index) | - DSA_8021Q_PORT(port); + return DSA_8021Q_RSV | DSA_8021Q_SWITCH_ID(dp->ds->index) | + DSA_8021Q_PORT(dp->index); } -EXPORT_SYMBOL_GPL(dsa_8021q_rx_vid); +EXPORT_SYMBOL_GPL(dsa_tag_8021q_standalone_vid); /* Returns the decoded switch ID from the RX VID. */ int dsa_8021q_rx_switch_id(u16 vid) @@ -118,21 +103,11 @@ static int dsa_tag_8021q_rx_vbid(u16 vid) return (vbid_hi << 2) | vbid_lo; } -bool vid_is_dsa_8021q_rxvlan(u16 vid) -{ - return (vid & DSA_8021Q_DIR_MASK) == DSA_8021Q_DIR_RX; -} -EXPORT_SYMBOL_GPL(vid_is_dsa_8021q_rxvlan); - -bool vid_is_dsa_8021q_txvlan(u16 vid) -{ - return (vid & DSA_8021Q_DIR_MASK) == DSA_8021Q_DIR_TX; -} -EXPORT_SYMBOL_GPL(vid_is_dsa_8021q_txvlan); - bool vid_is_dsa_8021q(u16 vid) { - return vid_is_dsa_8021q_rxvlan(vid) || vid_is_dsa_8021q_txvlan(vid); + u16 rsv = (vid & DSA_8021Q_RSV_MASK) >> DSA_8021Q_RSV_SHIFT; + + return rsv == DSA_8021Q_RSV_VAL; } EXPORT_SYMBOL_GPL(vid_is_dsa_8021q); @@ -246,18 +221,8 @@ int dsa_switch_tag_8021q_vlan_add(struct dsa_switch *ds, u16 flags = 0; if (dsa_is_user_port(ds, port)) - flags |= BRIDGE_VLAN_INFO_UNTAGGED; - - /* Standalone VLANs are PVIDs */ - if (vid_is_dsa_8021q_rxvlan(info->vid) && - dsa_8021q_rx_switch_id(info->vid) == ds->index && - dsa_8021q_rx_source_port(info->vid) == port) - flags |= BRIDGE_VLAN_INFO_PVID; - - /* And bridging VLANs are PVIDs too on user ports */ - if (dsa_tag_8021q_rx_vbid(info->vid) && - dsa_is_user_port(ds, port)) - flags |= BRIDGE_VLAN_INFO_PVID; + flags |= BRIDGE_VLAN_INFO_UNTAGGED | + BRIDGE_VLAN_INFO_PVID; err = dsa_switch_do_tag_8021q_vlan_add(ds, port, info->vid, @@ -347,7 +312,7 @@ int dsa_tag_8021q_bridge_join(struct dsa_switch *ds, int port, /* Delete the standalone VLAN of the port and replace it with a * bridging VLAN */ - standalone_vid = dsa_8021q_rx_vid(ds, port); + standalone_vid = dsa_tag_8021q_standalone_vid(dp); bridge_vid = dsa_8021q_bridge_tx_fwd_offload_vid(bridge_num); dsa_port_tag_8021q_vlan_del(dp, standalone_vid, false); @@ -372,7 +337,7 @@ void dsa_tag_8021q_bridge_leave(struct dsa_switch *ds, int port, /* Delete the bridging VLAN of the port and replace it with a * standalone VLAN */ - standalone_vid = dsa_8021q_rx_vid(ds, port); + standalone_vid = dsa_tag_8021q_standalone_vid(dp); bridge_vid = dsa_8021q_bridge_tx_fwd_offload_vid(bridge_num); dsa_port_tag_8021q_vlan_del(dp, bridge_vid, true); @@ -387,13 +352,12 @@ void dsa_tag_8021q_bridge_leave(struct dsa_switch *ds, int port, } EXPORT_SYMBOL_GPL(dsa_tag_8021q_bridge_leave); -/* Set up a port's tag_8021q RX and TX VLAN for standalone mode operation */ +/* Set up a port's standalone tag_8021q VLAN */ static int dsa_tag_8021q_port_setup(struct dsa_switch *ds, int port) { struct dsa_8021q_context *ctx = ds->tag_8021q_ctx; struct dsa_port *dp = dsa_to_port(ds, port); - u16 rx_vid = dsa_8021q_rx_vid(ds, port); - u16 tx_vid = dsa_8021q_tx_vid(ds, port); + u16 vid = dsa_tag_8021q_standalone_vid(dp); struct net_device *master; int err; @@ -405,30 +369,16 @@ static int dsa_tag_8021q_port_setup(struct dsa_switch *ds, int port) master = dp->cpu_dp->master; - /* Add this user port's RX VID to the membership list of all others - * (including itself). This is so that bridging will not be hindered. - * L2 forwarding rules still take precedence when there are no VLAN - * restrictions, so there are no concerns about leaking traffic. - */ - err = dsa_port_tag_8021q_vlan_add(dp, rx_vid, false); + err = dsa_port_tag_8021q_vlan_add(dp, vid, false); if (err) { dev_err(ds->dev, - "Failed to apply RX VID %d to port %d: %pe\n", - rx_vid, port, ERR_PTR(err)); + "Failed to apply standalone VID %d to port %d: %pe\n", + vid, port, ERR_PTR(err)); return err; } - /* Add @rx_vid to the master's RX filter. */ - vlan_vid_add(master, ctx->proto, rx_vid); - - /* Finally apply the TX VID on this port and on the CPU port */ - err = dsa_port_tag_8021q_vlan_add(dp, tx_vid, false); - if (err) { - dev_err(ds->dev, - "Failed to apply TX VID %d on port %d: %pe\n", - tx_vid, port, ERR_PTR(err)); - return err; - } + /* Add the VLAN to the master's RX filter. */ + vlan_vid_add(master, ctx->proto, vid); return err; } @@ -437,8 +387,7 @@ static void dsa_tag_8021q_port_teardown(struct dsa_switch *ds, int port) { struct dsa_8021q_context *ctx = ds->tag_8021q_ctx; struct dsa_port *dp = dsa_to_port(ds, port); - u16 rx_vid = dsa_8021q_rx_vid(ds, port); - u16 tx_vid = dsa_8021q_tx_vid(ds, port); + u16 vid = dsa_tag_8021q_standalone_vid(dp); struct net_device *master; /* The CPU port is implicitly configured by @@ -449,11 +398,9 @@ static void dsa_tag_8021q_port_teardown(struct dsa_switch *ds, int port) master = dp->cpu_dp->master; - dsa_port_tag_8021q_vlan_del(dp, rx_vid, false); - - vlan_vid_del(master, ctx->proto, rx_vid); + dsa_port_tag_8021q_vlan_del(dp, vid, false); - dsa_port_tag_8021q_vlan_del(dp, tx_vid, false); + vlan_vid_del(master, ctx->proto, vid); } static int dsa_tag_8021q_setup(struct dsa_switch *ds) diff --git a/net/dsa/tag_ocelot_8021q.c b/net/dsa/tag_ocelot_8021q.c index 5bf848446106..df0fae88ab7a 100644 --- a/net/dsa/tag_ocelot_8021q.c +++ b/net/dsa/tag_ocelot_8021q.c @@ -17,9 +17,9 @@ static struct sk_buff *ocelot_xmit(struct sk_buff *skb, struct net_device *netdev) { struct dsa_port *dp = dsa_slave_to_port(netdev); - u16 tx_vid = dsa_8021q_tx_vid(dp->ds, dp->index); u16 queue_mapping = skb_get_queue_mapping(skb); u8 pcp = netdev_txq_to_tc(netdev, queue_mapping); + u16 tx_vid = dsa_tag_8021q_standalone_vid(dp); struct ocelot *ocelot = dp->ds->priv; int port = dp->index; u32 rew_op = 0; diff --git a/net/dsa/tag_sja1105.c b/net/dsa/tag_sja1105.c index 088709ef877a..52002aa2a045 100644 --- a/net/dsa/tag_sja1105.c +++ b/net/dsa/tag_sja1105.c @@ -172,9 +172,9 @@ static struct sk_buff *sja1105_xmit(struct sk_buff *skb, struct net_device *netdev) { struct dsa_port *dp = dsa_slave_to_port(netdev); - u16 tx_vid = dsa_8021q_tx_vid(dp->ds, dp->index); u16 queue_mapping = skb_get_queue_mapping(skb); u8 pcp = netdev_txq_to_tc(netdev, queue_mapping); + u16 tx_vid = dsa_tag_8021q_standalone_vid(dp); if (skb->offload_fwd_mark) return sja1105_imprecise_xmit(skb, netdev); @@ -195,9 +195,9 @@ static struct sk_buff *sja1110_xmit(struct sk_buff *skb, { struct sk_buff *clone = SJA1105_SKB_CB(skb)->clone; struct dsa_port *dp = dsa_slave_to_port(netdev); - u16 tx_vid = dsa_8021q_tx_vid(dp->ds, dp->index); u16 queue_mapping = skb_get_queue_mapping(skb); u8 pcp = netdev_txq_to_tc(netdev, queue_mapping); + u16 tx_vid = dsa_tag_8021q_standalone_vid(dp); __be32 *tx_trailer; __be16 *tx_header; int trailer_pos; From patchwork Wed Aug 18 12:01:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 499559 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5500C4338F for ; Wed, 18 Aug 2021 12:04:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8499B60EBC for ; Wed, 18 Aug 2021 12:04:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236025AbhHRMEv (ORCPT ); Wed, 18 Aug 2021 08:04:51 -0400 Received: from mail-eopbgr00079.outbound.protection.outlook.com ([40.107.0.79]:39586 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236417AbhHRMEO (ORCPT ); Wed, 18 Aug 2021 08:04:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e7uxa5vqDtZXmzi4nTuyuv4lCfwcMq1rhKtnkwqEQ58uzXVFIjpOw+5wQsZzLkQQ74R6gDg041O6eAAxPbg3Wr9E+XhUAj7/nUbVgh+yJKpQI/c9sJPnbyTDS9jiKQ4mtwkoWxPvkI3Ytw6mXk5N2JHnY2iJ5sgUrdpHJZEwrS4F/XfXQxDrMwPk9x+tjVlyg459VoYkqo+1CZtWVKDfOyYh9fBDyUCYGzzV6Am/+Y3uU4JAG9c8l0oR68Ow+aqTPzz7i98eU2GW4ZHs9qEr916a1idmraBwWnu7LYr6iaOkEHmrWUuPEnyHi35HdbH+2Uh/IdbXaeZdRSMhH2n6Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=42qOyEGqyDcrl0xp2CU/fZoXQV6Xj6iwz8MeoQA8PPM=; b=ddOcqrnDxq+fEAnzEBUKdWNFwuBiG/OFyrBbd5N5iE5A1wOMynR2guSYJzm/cGYGRCD1zIUTM1/z2xmrGq8GD7Zvay5t4mK8B+Cb4OhAXM/qEtK4O2/tNrY4YKgX9L8gPSjAR3VHwOYwbqYqS903gSuMM7AgCnBwId+jon8wuS9bbxF4qa7LbQfWEhtcehcICH/Jf6agVivRRppOHGufnXlSYhY4RgbEKzuikBXrVfV7+As1tBJR3qHKNbmBml5qSR41zodvsIzkbNmebJIOKTs0yds0E2HNuMJAj+15sF3yZUwrO0v7HUh7lzLyludngfNiQN0Uzp0yQIyYa9j0+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=42qOyEGqyDcrl0xp2CU/fZoXQV6Xj6iwz8MeoQA8PPM=; b=Q3re+qF/Fv6oAa8mdJH9H8umUIMpAnWW3s1NaK5DddUVTDuCmWlK/Aqz/sxF10CCEDyj0WibrBpP0ZqXObALMxM/mh4O9z+w5OSHVIrQOYlRRl/VOfgNyr7dsXkHwuGGgEjQyz8GoCeWYtTPJKMKThW8vPM3GOrmJjg/6wYwuTA= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB3839.eurprd04.prod.outlook.com (2603:10a6:803:21::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17; Wed, 18 Aug 2021 12:03:08 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4415.024; Wed, 18 Aug 2021 12:03:08 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Roopa Prabhu , Nikolay Aleksandrov , Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean , Vadym Kochan , Taras Chornyi , Jiri Pirko , Ido Schimmel , UNGLinuxDriver@microchip.com, Grygorii Strashko , Marek Behun , DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Claudiu Manoil , Alexandre Belloni , George McCollister , Ioana Ciornei , Saeed Mahameed , Leon Romanovsky , Lars Povlsen , Steen Hegelund , Julian Wiedmann , Karsten Graul , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Ivan Vecera , Vlad Buslov , Jianbo Liu , Mark Bloch , Roi Dayan , Tobias Waldekranz , Vignesh Raghavendra , Jesse Brandeburg , Peter Ujfalusi Subject: [RFC PATCH net-next 13/20] net: dsa: tag_8021q: rename dsa_8021q_bridge_tx_fwd_offload_vid Date: Wed, 18 Aug 2021 15:01:43 +0300 Message-Id: <20210818120150.892647-14-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818120150.892647-1-vladimir.oltean@nxp.com> References: <20210818120150.892647-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 18 Aug 2021 12:03:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3fdef58b-a08b-4cb4-6769-08d9624024ba X-MS-TrafficTypeDiagnostic: VI1PR0402MB3839: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pUKTSoVZ9LiCS5SmQs0P2m1OQvGpJrsnsjutkalpxhVH8B4U/e0ZDx3FDxLUssM1ZcJuh+2rkt2hoytKuaJ6Xq7YrmsBz4H+aJhUCcY54jyyyayGd3GfKpOFscvJp8EbWjXrf9LKg+EAy/wa5zXEQcqcxMHSDH5D2ZQRsE/vaqSavQuWNwfBfi+qVCKP6A83Xf7emNZ2YTBCj+KVyEdddDHVt83baY+L4cA71eHc3x3ZJjc2tHi4dsRh96LzuvmsNVerC2tg85qLXfAZXeTRdYZUrNhFJDvCLu0PX8SW7x7WmkFPg1Tu4QyQnU8CKhIF82YIliPha+3Yfw72SYiTNTRse0OUyXNA9r/rTl+BXqo+rx5hvmw8ysOKXiKaoUSSBV78g3gIHSGCWYL2l8DOGJJVPEYqJGsRvOoOBIVs7DmtyYrv8ldMuJV1JXeGfP7TGekxRadOanr40yr0prVRx+8H7darFk+SynN/VgEZoydwx6Wg1YNcctC8go1Xx8S2H5uktkBLwBImTEirjvk2ewzgKkzxrkJ9WlDAPw60mFM6E+Bs6RQKib8UKmAlwmJ/rmbat3sWFK+y4tzj0gN+fBqoP7i1UvoJlVhca6F2MHqvflkVurRriSoKip5f9cYjPC2T39Mt+CIHncqH5yklBY0JROiUQSEVtE9AzZu2wnz1Uka9ly4wLd880uSZrcqC X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(346002)(136003)(39850400004)(366004)(376002)(66476007)(2906002)(66556008)(8936002)(6506007)(186003)(7406005)(7416002)(52116002)(26005)(86362001)(66946007)(6486002)(44832011)(36756003)(5660300002)(1076003)(110136005)(54906003)(6512007)(8676002)(316002)(6666004)(38350700002)(38100700002)(956004)(478600001)(83380400001)(2616005)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: neo91Z9+8OhFoU8tsP3hnIHPiDj+pc/C1Rm9BmbMVeFwne32avUs/4TGt3aB/dmrtijytp3DeE/VTLLZviwecG2/fS8dTZdSo1+h0JZN4yCRrEHbwTX9Ifo0c0HCuIfaicfnhzdx+EXaF9cDT0sY1RIMavM2wUkEZenJrUb/qNjlC7jM9kbKSpki8i12GV3+ZXJOKU5p8z/sKc86WXNrv/VapKlpMxEws5XuUE1Eh4b5ea8Neyp7AxqEP1tftbIDTo96qKYSC8GL8U/kuPL1JbtUUdDb7TKAZ9zwqaacMxJ+YlHksnJkAqnuzF4CNM4HfcB/FRMQB3RvRYVvQA9jhKGXhcxSys9kf/5qU076FxyX1Q35vI2gbVSVvA1LhT+F0UVqS3P8IhnsQeFnjWUf2gpGeYTyHjE4NaPawbTg7XeCrnSedtJPpOeOP6ienR8vRytonok9xzFBPFQRFkejNj6GtRjCvvBySEGuntkoBh1IobfTNMV+Vyg/h/PhsKLWNkPWWhn4y+9Buhzr5F/E37+dBuqvC207dQyo8FqMcATOF/QmXCThSBBZrf0fNaM9OqT9suUefvE8BcgvA8fSvokp1/cG4VCrRe/MEI44Gp9AxYg/YgDKUifLcqzabu/oEdShh5189hTzQE5SsDnFFMnH/iH4UE4tSQB2SvTk4lKD5zKGQvLrVxo0iWXLwzZdkgdpGecH3QLflkbHDpSvfjmJ2mHU7XJkOQjbtH9myeC0DCucVvVrzk/srEh8sPNEsgdU3K/fBQ2TVc4GrRrtBuFhtz+bleLBgQU6Is7ZnMliKOSN6gpEj9pQxSGe8EJlWEAvcQWiTnA5lJjTSL3Gso/jVKTi3xXno9Zmj4cMY1kKPBkMHuf3AeHKubniuF1/ldJditAlncXmvLSUqP8Bu0Zy5RC93eqS7URoLH5qe6TbWLHy92dpXHPxwz7x2u9fU7qNr/8ncUlFCdV/2KIp3N27UmUfQZwhqgphffnZg414S5Irh/CzEeiPqUid4M6jB5Y9JaFazEPhU7PLTMYKfTBVWdojnpw5fjsQR85RnNfBuKw8wJtUHrdx0WUBL9VJw2aDFzbMm53iT+B/du+1hjUqLdB9nI07P57z7pg8XPTLaZMfBE1LdYJAmc1tO/YO1jG34kr0LYULKWyYo3V2CUZTN9eBwpjGULka36k1UJ6hzfhLl3tLZ3rWLt89wUrbwI2W9XD2czsNcGi7cNmvpSrOpiHtccTCT+92RCawoQ1bMcAklLjI6zjq2OcCpTkoaACDan3U7i4CseVINIuEbNJ2AxF8B+xd8f4IBRfTiD5vKhXdl6/Ayq3S14Bh/Ytn X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3fdef58b-a08b-4cb4-6769-08d9624024ba X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2021 12:03:08.5599 (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: s7lnBn9E7ykgquX5Z9egW4OF6/qJ3xjMhBL8frwA1SlmXXAPB30YlkJNGuawhVsbWg5DN6eQGLtkvBQMA9TIyA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3839 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The dsa_8021q_bridge_tx_fwd_offload_vid is no longer used just for bridge TX forwarding offload, it is the private VLAN reserved for VLAN-unaware bridging in a way that is compatible with FDB isolation. So just rename it dsa_tag_8021q_bridge_vid. Signed-off-by: Vladimir Oltean --- include/linux/dsa/8021q.h | 2 +- net/dsa/tag_8021q.c | 8 ++++---- net/dsa/tag_sja1105.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/dsa/8021q.h b/include/linux/dsa/8021q.h index 5c67ac422282..c114663cd687 100644 --- a/include/linux/dsa/8021q.h +++ b/include/linux/dsa/8021q.h @@ -46,7 +46,7 @@ void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id, struct net_device *dsa_tag_8021q_find_port_by_vbid(struct net_device *master, int vbid); -u16 dsa_8021q_bridge_tx_fwd_offload_vid(int bridge_num); +u16 dsa_tag_8021q_bridge_vid(int bridge_num); u16 dsa_tag_8021q_standalone_vid(struct dsa_port *dp); diff --git a/net/dsa/tag_8021q.c b/net/dsa/tag_8021q.c index 76e4b99ecd89..e7890aa79df8 100644 --- a/net/dsa/tag_8021q.c +++ b/net/dsa/tag_8021q.c @@ -63,12 +63,12 @@ #define DSA_8021Q_PORT(x) (((x) << DSA_8021Q_PORT_SHIFT) & \ DSA_8021Q_PORT_MASK) -u16 dsa_8021q_bridge_tx_fwd_offload_vid(int bridge_num) +u16 dsa_tag_8021q_bridge_vid(int bridge_num) { /* The VBID value of 0 is reserved for precise TX */ return DSA_8021Q_RSV | DSA_8021Q_VBID(bridge_num + 1); } -EXPORT_SYMBOL_GPL(dsa_8021q_bridge_tx_fwd_offload_vid); +EXPORT_SYMBOL_GPL(dsa_tag_8021q_bridge_vid); /* Returns the VID that will be installed as pvid for this switch port, sent as * tagged egress towards the CPU port and decoded by the rcv function. @@ -313,7 +313,7 @@ int dsa_tag_8021q_bridge_join(struct dsa_switch *ds, int port, * bridging VLAN */ standalone_vid = dsa_tag_8021q_standalone_vid(dp); - bridge_vid = dsa_8021q_bridge_tx_fwd_offload_vid(bridge_num); + bridge_vid = dsa_tag_8021q_bridge_vid(bridge_num); dsa_port_tag_8021q_vlan_del(dp, standalone_vid, false); @@ -338,7 +338,7 @@ void dsa_tag_8021q_bridge_leave(struct dsa_switch *ds, int port, * standalone VLAN */ standalone_vid = dsa_tag_8021q_standalone_vid(dp); - bridge_vid = dsa_8021q_bridge_tx_fwd_offload_vid(bridge_num); + bridge_vid = dsa_tag_8021q_bridge_vid(bridge_num); dsa_port_tag_8021q_vlan_del(dp, bridge_vid, true); diff --git a/net/dsa/tag_sja1105.c b/net/dsa/tag_sja1105.c index 52002aa2a045..0902e7334cf3 100644 --- a/net/dsa/tag_sja1105.c +++ b/net/dsa/tag_sja1105.c @@ -163,7 +163,7 @@ static struct sk_buff *sja1105_imprecise_xmit(struct sk_buff *skb, * TX VLAN that targets the bridge's entire broadcast domain, * instead of just the specific port. */ - tx_vid = dsa_8021q_bridge_tx_fwd_offload_vid(dp->bridge_num); + tx_vid = dsa_tag_8021q_bridge_vid(dp->bridge_num); return dsa_8021q_xmit(skb, netdev, sja1105_xmit_tpid(dp), tx_vid); } From patchwork Wed Aug 18 12:01:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 500291 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A14C7C4338F for ; Wed, 18 Aug 2021 12:04:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8969B60F35 for ; Wed, 18 Aug 2021 12:04:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236797AbhHRME5 (ORCPT ); Wed, 18 Aug 2021 08:04:57 -0400 Received: from mail-eopbgr00067.outbound.protection.outlook.com ([40.107.0.67]:52143 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236420AbhHRMEO (ORCPT ); Wed, 18 Aug 2021 08:04:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZSHmbYMT5oNQQnSsNqJhI1npi0UYChTvHLtjKkqOXVRM/jOKEHFUbLlRHUGCAncyD3+wuqn/meymo7idAe5qeGBvXprZxgXO2IQrVHlH8oRkSdDTS7ERf31K92moTWEl51RdxLmR8xPp+6euCJ24Zg/uNthwdIbEzt9C+udL3EbBRBtgTaIbgSrzb7DGfeBbY6iSR3zJh7CqlTZ/bed3sNFBp3oukTOCXfAwk+9i0dROCLZ/8GOw0C+6g1rOHBNBd4NvKTGhllHL5ZRXmyJanK4FscEptBg5eo2b9i0gTbqfDxuMIK2rLF0ZtSWYD8LD1nKXXJAP7MSyW4ynUzjtHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Vf3+O7tUQaJn6O4WmHb3hFm/Vvw7RaSJB+jVPnqm3t8=; b=njP4Bpj4GuH1KYABhvpNeXIEQnsuNoFAoP44qO4Q9fiYr1Iy29Fe6ZbhMaxfFwDf+SNCo8NXffx8kLnsW6Kal1t+Cf4L1/az87QyrxXyZguVb8IVFjftSrF+FEE4TMY2x7lW5A8UFfpl+4yFL8A48Hoh7bU/YRbmI/Cc2e7SoIb9OKqLeM+uloC8l33YYGa05o3DlhHDgIBdQ+xdFl9lpCZmAEWL9PUGigS93QLz7ob+S5U0RxPnUmnnaIr8YwDeCzZocGDalCg86sFaex47WnFHC27hFMNOxJkfEApnY5g3zja8/OdGhaw7gk/FCyQybg+SLBXMLa+zTFWu72AjIA== 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=Vf3+O7tUQaJn6O4WmHb3hFm/Vvw7RaSJB+jVPnqm3t8=; b=hleKJRxVCZWAIFUnRNLL4a25QFcRVLH5UymuYNXnk/t0RW1Wd8tSW28FZuC+dJUH3Zf9bKv0CCX7FkS5WEFQJ+AatuRCmuKVpSQAvqJSeUTZqDdbaowkSaag9oqRz5PuJRQ8ysmdAPGPBB6UF66ZJ40Q+iWX8WpmEdVwHoDkdwo= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB3839.eurprd04.prod.outlook.com (2603:10a6:803:21::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17; Wed, 18 Aug 2021 12:03:10 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4415.024; Wed, 18 Aug 2021 12:03:10 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Roopa Prabhu , Nikolay Aleksandrov , Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean , Vadym Kochan , Taras Chornyi , Jiri Pirko , Ido Schimmel , UNGLinuxDriver@microchip.com, Grygorii Strashko , Marek Behun , DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Claudiu Manoil , Alexandre Belloni , George McCollister , Ioana Ciornei , Saeed Mahameed , Leon Romanovsky , Lars Povlsen , Steen Hegelund , Julian Wiedmann , Karsten Graul , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Ivan Vecera , Vlad Buslov , Jianbo Liu , Mark Bloch , Roi Dayan , Tobias Waldekranz , Vignesh Raghavendra , Jesse Brandeburg , Peter Ujfalusi Subject: [RFC PATCH net-next 14/20] net: dsa: pass extack to .port_bridge_join driver methods Date: Wed, 18 Aug 2021 15:01:44 +0300 Message-Id: <20210818120150.892647-15-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818120150.892647-1-vladimir.oltean@nxp.com> References: <20210818120150.892647-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 18 Aug 2021 12:03:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bc3cf240-e099-47e7-da9d-08d962402595 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3839: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1284; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Gv0NAGn3l0P10SYKRXxPZ1+En1DQCy0UIfA07zNNvrahHjsOa5xqoCAhF8N23GThTHRxmtAzCTbjV9XH+hTBQ+ZDhUr3ix+dsRr+Q8oF7yYOaEXFHAtzM/EwCU0mBDCmva6kq7CsCV7KQmcCL7F+rChMGvKAs4R7Gc6OK1ows15K8lnEd/XLyEuyxxomnJt1Q2WZfSx7guCqjtZiv9gfI4QVjj1NY1c4ECMAeyBawSLRY7OAwwJm9//VzOg1muq9svptxcTOu4amb3FrXY9zcVqIoYVPT/GyXuEUSNo/7ktfbyPcBRf7u4lffbOdNHewyU6nH4CA00jk+dTdjrD9eyrVO7K+HDLpgW3Ya2uihmIm1ZzcRlV6KJkLVny6OcO5xSXcrwst0urqw+fpLGFOvMnWbtC11Z4bLnKdOAWclsp35/htjJfY5dSeobQOAFkw1KBcANBTuKdA3P3HOEeDdtmTKePsL6htvJd18kj9ovnJ3j+4Jg16VLnuyRJOgVqVyDiEGoee7mxWvG1kS/RX/n+lLBM5QMQIXVqheMgW0DG1UehRtsexvo8cE5B+QWBzBSGwR1uW4oQ51hTLC8OaSS2DoOBOgbfMaGzBvignioleHBygPwFqymXK2uXugsVkqfS4/E63Jjb60NPoJy7SIx8hGzLyh+lCt7E9BSID0yJ8cTRqrwn4pc3IeZlkR7T539iD/jxOw+orfYgNm2y/bXoqu2d8lkk22TPxkawLo3U= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(346002)(136003)(39850400004)(366004)(376002)(66476007)(2906002)(66556008)(8936002)(6506007)(186003)(7406005)(7416002)(52116002)(26005)(86362001)(66946007)(6486002)(44832011)(36756003)(30864003)(5660300002)(1076003)(110136005)(54906003)(6512007)(8676002)(316002)(6666004)(38350700002)(38100700002)(956004)(478600001)(83380400001)(2616005)(4326008)(142923001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +8zip0GunMv3PR1OqotzvpxOszn3yCeuCxdGVTFZKcX4YJpZdBsvirSqh7VbmeDTvZVXBfWoz0WoDmhT4sb9BdpurGX22T8rMYtI4NX0fzIhLunTiW1V5rGK9BsBifnWZLyPgudBa58EITTuj/5TzUNJuSDOBQ3SJme5DopzlpFVUdPt8oC6QiTkAKA2h1MrdOXOUlnNiqiRzkcXHqGab84r9I11LgL1leaIBA+MmbDo8aY4uaKSoX0XhMOgPnQCRbxpmZL1QvU7eo9JunF2qJwYps86vLuN5rXTbRCHLvsJD4bJgEDKPwYsEMNwVEE4fyQZqhILNZXp5+JW778hAPttkFClFloU38kClYtQ5A1UN/qgPwClVZxiaZDV3ryNTsK3NPA2Sf8ZaJS3lbp8rR6+EF+FPMn4VgZgBLjP5JwM5lIo2WhvBc5/HLc51Qy3s2UKU/6aq5lZyy3Bj1xsw+Kl6xRVTvGubpbVcYRX/yujL3JSua5JaSLCHbf9bjfyGnqcLZBFGfodclyRRoV2yCGogNIjhID8YkWhZk3nF26e3ICwWOtx1f8MTxdWYwuWY/hnltOWfIH18AclwRJ6dS1QaFTQgB/1DLCcKD3Ifm7qQoBI+dQ+/l7sYe8qL6XfUFm0KshjMHlSV2xHr1kip3kxQHfi/MG+nDhYSUp+eCfxsrdOgQovQPIeJJughbqksRMdWET/rUyqMUnDfdQqSL2sDGT7wDxgp3nFwvpQfi+yOS1wF2+ETc6ECkOBymP32ABlS3z7w73QiOQtH04WzgJp3c4P3HUyy2a8V8BfokrHr6ZuISxArfXSjVgXn70PgXumbOXC7qvWrz9Ajr6qO2xTUup7OxXWBeL/Xvu5BnCmW49LPCIDQ0fRZc1JBSWU40bQt06yJAGNlV5P70McXS+WekQ/UNAo5dnsoBJLe68UOG4PqSUrpkd6IAy5LBn74mdEQ+CUCofm5RTpCWr0ov+9cAWX3+UXbfdVVaAM4XOrshni49xulSKToxJvv0egAWRZiLSkIB0B7pHGJByRt6PtWrFewjEeYa/Fv6UNCUy7r8/AOppQ7ancRVxuEucPzIqzMGGIRJUuxEYXdQfDlgCozvci63o01x/df0i2tKRZT6nvQzzgE4wD6+lW9G2IjMcZHAwqyCeukE7//RA8Kwx0LG/oVpHDki4YjxVa6mpV2ohzriNNbnw/JxlRofqLeSyO/Wr7KkhsQojTYUWmLEThIqkt62h6CqcRjYZ08MGwgIdbVS4+SNDs2hr0cgT5RrX15PkReobWqYhFAS8PVC0U5l6wm0Hj2DjzQrYewzmsz21orwRyOEBYJVCDh0h3 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bc3cf240-e099-47e7-da9d-08d962402595 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2021 12:03:09.9981 (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: sdxzVnze9jmqJcOlthq61ZzKqzSQJ4jj8j35JeVZQMOfgRHnurYPwXS9uWE6Oe7wOYu3bWim4P4G1y0uniIibw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3839 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org As FDB isolation cannot be enforced between VLAN-aware bridges in lack of hardware assistance like extra FID bits, it seems plausible that many DSA switches cannot do it. Therefore, they need to reject configurations with multiple VLAN-aware bridges from the two code paths that can transition towards that state: - joining a VLAN-aware bridge - toggling VLAN awareness on an existing bridge The .port_vlan_filtering method already propagates the netlink extack to the driver, let's propagate it from .port_bridge_join too, to make sure that the driver can use the same function for both. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/b53/b53_common.c | 2 +- drivers/net/dsa/b53/b53_priv.h | 2 +- drivers/net/dsa/dsa_loop.c | 3 ++- drivers/net/dsa/hirschmann/hellcreek.c | 3 ++- drivers/net/dsa/lan9303-core.c | 3 ++- drivers/net/dsa/lantiq_gswip.c | 3 ++- drivers/net/dsa/microchip/ksz_common.c | 3 ++- drivers/net/dsa/microchip/ksz_common.h | 3 ++- drivers/net/dsa/mt7530.c | 3 ++- drivers/net/dsa/mv88e6xxx/chip.c | 6 ++++-- drivers/net/dsa/ocelot/felix.c | 3 ++- drivers/net/dsa/qca8k.c | 2 +- drivers/net/dsa/sja1105/sja1105_main.c | 3 ++- drivers/net/dsa/xrs700x/xrs700x.c | 3 ++- include/net/dsa.h | 6 ++++-- net/dsa/dsa_priv.h | 1 + net/dsa/port.c | 1 + net/dsa/switch.c | 5 +++-- 18 files changed, 36 insertions(+), 19 deletions(-) diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index d0f00cb0a235..55bfcec2b204 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c @@ -1848,7 +1848,7 @@ int b53_mdb_del(struct dsa_switch *ds, int port, EXPORT_SYMBOL(b53_mdb_del); int b53_br_join(struct dsa_switch *ds, int port, struct net_device *br, - int bridge_num) + int bridge_num, struct netlink_ext_ack *extack) { struct b53_device *dev = ds->priv; s8 cpu_port = dsa_to_port(ds, port)->cpu_dp->index; diff --git a/drivers/net/dsa/b53/b53_priv.h b/drivers/net/dsa/b53/b53_priv.h index e3f1e9ff1b50..4e9b05008524 100644 --- a/drivers/net/dsa/b53/b53_priv.h +++ b/drivers/net/dsa/b53/b53_priv.h @@ -319,7 +319,7 @@ void b53_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *data); int b53_get_sset_count(struct dsa_switch *ds, int port, int sset); void b53_get_ethtool_phy_stats(struct dsa_switch *ds, int port, uint64_t *data); int b53_br_join(struct dsa_switch *ds, int port, struct net_device *bridge, - int bridge_num); + int bridge_num, struct netlink_ext_ack *extack); void b53_br_leave(struct dsa_switch *ds, int port, struct net_device *bridge, int bridge_num); void b53_br_set_stp_state(struct dsa_switch *ds, int port, u8 state); diff --git a/drivers/net/dsa/dsa_loop.c b/drivers/net/dsa/dsa_loop.c index c9fefdede1d1..658c23195b05 100644 --- a/drivers/net/dsa/dsa_loop.c +++ b/drivers/net/dsa/dsa_loop.c @@ -168,7 +168,8 @@ static int dsa_loop_phy_write(struct dsa_switch *ds, int port, static int dsa_loop_port_bridge_join(struct dsa_switch *ds, int port, struct net_device *bridge, - int bridge_num) + int bridge_num, + struct netlink_ext_ack *extack) { dev_dbg(ds->dev, "%s: port: %d, bridge: %s\n", __func__, port, bridge->name); diff --git a/drivers/net/dsa/hirschmann/hellcreek.c b/drivers/net/dsa/hirschmann/hellcreek.c index 732fff99bfb2..fdae74313eb7 100644 --- a/drivers/net/dsa/hirschmann/hellcreek.c +++ b/drivers/net/dsa/hirschmann/hellcreek.c @@ -675,7 +675,8 @@ static int hellcreek_bridge_flags(struct dsa_switch *ds, int port, static int hellcreek_port_bridge_join(struct dsa_switch *ds, int port, struct net_device *br, - int bridge_num) + int bridge_num, + struct netlink_ext_ack *extack) { struct hellcreek *hellcreek = ds->priv; diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index 4e72fd04eb5f..d1148ab2f66e 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -1103,7 +1103,8 @@ static void lan9303_port_disable(struct dsa_switch *ds, int port) } static int lan9303_port_bridge_join(struct dsa_switch *ds, int port, - struct net_device *br, int bridge_num) + struct net_device *br, int bridge_num, + struct netlink_ext_ack *extack) { struct lan9303 *chip = ds->priv; diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c index 2ce4da567106..64a22652cc75 100644 --- a/drivers/net/dsa/lantiq_gswip.c +++ b/drivers/net/dsa/lantiq_gswip.c @@ -1128,7 +1128,8 @@ static int gswip_vlan_remove(struct gswip_priv *priv, } static int gswip_port_bridge_join(struct dsa_switch *ds, int port, - struct net_device *bridge, int bridge_num) + struct net_device *bridge, int bridge_num, + struct netlink_ext_ack *extack) { struct gswip_priv *priv = ds->priv; int err; diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 4f821933e291..202fd93caae3 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -173,7 +173,8 @@ void ksz_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *buf) EXPORT_SYMBOL_GPL(ksz_get_ethtool_stats); int ksz_port_bridge_join(struct dsa_switch *ds, int port, - struct net_device *br, int bridge_num) + struct net_device *br, int bridge_num, + struct netlink_ext_ack *extack) { struct ksz_device *dev = ds->priv; diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index 3e905059374b..59c42cc1000b 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -159,7 +159,8 @@ void ksz_mac_link_down(struct dsa_switch *ds, int port, unsigned int mode, int ksz_sset_count(struct dsa_switch *ds, int port, int sset); void ksz_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *buf); int ksz_port_bridge_join(struct dsa_switch *ds, int port, - struct net_device *br, int bridge_num); + struct net_device *br, int bridge_num, + struct netlink_ext_ack *extack); void ksz_port_bridge_leave(struct dsa_switch *ds, int port, struct net_device *br, int bridge_num); void ksz_port_fast_age(struct dsa_switch *ds, int port); diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 751e477691f4..3f3b4d3a36e4 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -1192,7 +1192,8 @@ mt7530_port_bridge_flags(struct dsa_switch *ds, int port, static int mt7530_port_bridge_join(struct dsa_switch *ds, int port, - struct net_device *bridge, int bridge_num) + struct net_device *bridge, int bridge_num, + struct netlink_ext_ack *extack) { struct mt7530_priv *priv = ds->priv; u32 port_bitmap = BIT(MT7530_CPU_PORT); diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 37878ccf499c..92c2833a25a4 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -2388,7 +2388,8 @@ static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip, static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port, struct net_device *br, - int bridge_num) + int bridge_num, + struct netlink_ext_ack *extack) { struct mv88e6xxx_chip *chip = ds->priv; int err; @@ -2416,7 +2417,8 @@ static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port, static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int tree_index, int sw_index, int port, struct net_device *br, - int bridge_num) + int bridge_num, + struct netlink_ext_ack *extack) { struct mv88e6xxx_chip *chip = ds->priv; int err; diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 747dd739f533..cccbd33d5ac5 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -688,7 +688,8 @@ static int felix_bridge_flags(struct dsa_switch *ds, int port, } static int felix_bridge_join(struct dsa_switch *ds, int port, - struct net_device *br, int bridge_num) + struct net_device *br, int bridge_num, + struct netlink_ext_ack *extack) { struct ocelot *ocelot = ds->priv; diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c index 9addf99ceead..4254fbd84432 100644 --- a/drivers/net/dsa/qca8k.c +++ b/drivers/net/dsa/qca8k.c @@ -1506,7 +1506,7 @@ qca8k_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) static int qca8k_port_bridge_join(struct dsa_switch *ds, int port, struct net_device *br, - int bridge_num) + int bridge_num, struct netlink_ext_ack *extack) { struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv; int port_mask = BIT(QCA8K_CPU_PORT); diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 3c319114e292..8580ca2e88df 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -1985,7 +1985,8 @@ static void sja1105_bridge_stp_state_set(struct dsa_switch *ds, int port, } static int sja1105_bridge_join(struct dsa_switch *ds, int port, - struct net_device *br, int bridge_num) + struct net_device *br, int bridge_num, + struct netlink_ext_ack *extack) { int rc; diff --git a/drivers/net/dsa/xrs700x/xrs700x.c b/drivers/net/dsa/xrs700x/xrs700x.c index 230dbbcc48f3..2b6806610a89 100644 --- a/drivers/net/dsa/xrs700x/xrs700x.c +++ b/drivers/net/dsa/xrs700x/xrs700x.c @@ -542,7 +542,8 @@ static int xrs700x_bridge_common(struct dsa_switch *ds, int port, } static int xrs700x_bridge_join(struct dsa_switch *ds, int port, - struct net_device *bridge, int bridge_num) + struct net_device *bridge, int bridge_num, + struct netlink_ext_ack *extack) { return xrs700x_bridge_common(ds, port, bridge, true); } diff --git a/include/net/dsa.h b/include/net/dsa.h index b2aaef292c6d..5ecba358889a 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -694,7 +694,8 @@ struct dsa_switch_ops { */ int (*set_ageing_time)(struct dsa_switch *ds, unsigned int msecs); int (*port_bridge_join)(struct dsa_switch *ds, int port, - struct net_device *bridge, int bridge_num); + struct net_device *bridge, int bridge_num, + struct netlink_ext_ack *extack); void (*port_bridge_leave)(struct dsa_switch *ds, int port, struct net_device *bridge, int bridge_num); /* Called right after .port_bridge_join() */ @@ -776,7 +777,8 @@ struct dsa_switch_ops { */ int (*crosschip_bridge_join)(struct dsa_switch *ds, int tree_index, int sw_index, int port, - struct net_device *br, int bridge_num); + struct net_device *br, int bridge_num, + struct netlink_ext_ack *extack); void (*crosschip_bridge_leave)(struct dsa_switch *ds, int tree_index, int sw_index, int port, struct net_device *br, int bridge_num); diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index 417fac51c6e8..3a9d81ca3e64 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h @@ -57,6 +57,7 @@ struct dsa_notifier_bridge_info { int tree_index; int sw_index; int port; + struct netlink_ext_ack *extack; }; /* DSA_NOTIFIER_FDB_* */ diff --git a/net/dsa/port.c b/net/dsa/port.c index 270624e88358..07c57287ac3e 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -355,6 +355,7 @@ int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br, .sw_index = dp->ds->index, .port = dp->index, .br = br, + .extack = extack, }; struct net_device *dev = dp->slave; struct net_device *brport_dev; diff --git a/net/dsa/switch.c b/net/dsa/switch.c index 26dbd70ebb5e..b1c38eee2cac 100644 --- a/net/dsa/switch.c +++ b/net/dsa/switch.c @@ -95,7 +95,7 @@ static int dsa_switch_bridge_join(struct dsa_switch *ds, if (dst->index == info->tree_index && ds->index == info->sw_index && ds->ops->port_bridge_join) { err = ds->ops->port_bridge_join(ds, info->port, info->br, - info->bridge_num); + info->bridge_num, info->extack); if (err) return err; } @@ -105,7 +105,8 @@ static int dsa_switch_bridge_join(struct dsa_switch *ds, err = ds->ops->crosschip_bridge_join(ds, info->tree_index, info->sw_index, info->port, info->br, - info->bridge_num); + info->bridge_num, + info->extack); if (err) return err; } From patchwork Wed Aug 18 12:01:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 499558 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCF38C4338F for ; Wed, 18 Aug 2021 12:04:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 999FF60EBC for ; Wed, 18 Aug 2021 12:04:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235682AbhHRMFD (ORCPT ); Wed, 18 Aug 2021 08:05:03 -0400 Received: from mail-eopbgr00085.outbound.protection.outlook.com ([40.107.0.85]:55044 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236429AbhHRMEO (ORCPT ); Wed, 18 Aug 2021 08:04:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GPh0i477QIW1AczL8N+o6Aj3FaJbyGQKATU7/zCWQ2ODZXokE1ArqHHojCc4PJSFpk19ScyaPzwpGtIj4/H02DCUU7NbKgegGDjgkGsoK6J9rs5ULFIZSKNwwMcwWu0UzNz2Pf+Sq6yZCyaBufZRgKKkK80UOMVEzoxOl6CXBs5iYyJypgpH6jvCtLJLhxD7SyV13NSqTgFGmiqIJR08OpxKsxHjEIY/r/vIFZ8J4mvt2YvZUilbF3ZyVShX3DY0Tk8NE5zVveZDyPNfXj9Bx73hJXNCjPaU6Pv4P29SdieRWGhQ/VXI1w7E5mzM56I4Z8zR5aOF9tT7AZDfJ1Rptg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2GNw2doj2mneTs9MCg88u3o7d0vmR9sCmO2rWru6r70=; b=AhAfx3RuFNHYHXpewtWH6EfKYKxZvJzx8vGHNYVTAy3w2dH/JzD6omcq/5ZFdVQIDOxh9IMupwAg2osKj3wZeBkoNarE9/vSFfst1NVlhNqLIqtxOmngurPn90Uky08kfOlMBqok0XAS5RuMEESz8biAJQHxOtvlQVeRaDsMTJIIyFaVn1y9vPzSY2KK/XShMTnU4QebKXTyqA1bybSY9+E4EWu4dyFTWQFTCzIpPArNLpv8LDGoxSgu4qU+oU9mhNhA1/Jrw1LJTTAoy4EDZJro/YbahmVBOQ4SB2JQCUaG2bXY5En37ofPZAlpsesz9Og4/y080Lk7gOMEpydOHQ== 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=2GNw2doj2mneTs9MCg88u3o7d0vmR9sCmO2rWru6r70=; b=JwzLT1jM1r4rRVl8DgKLmb1CBG461k6k79jk1x3oByOB3T1ht5kH+8CZ8dJExQeOYqRSjjJ9EnbdBaOPu6CywMtsd0D6mqmQ+2NPrALGlRO0ypMfX1Vcg3QSzeZGm/79lHjGndPszp6XvSWHr4JeQZyNDaEwvbi1KZHuK9XQPd0= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB3839.eurprd04.prod.outlook.com (2603:10a6:803:21::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17; Wed, 18 Aug 2021 12:03:11 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4415.024; Wed, 18 Aug 2021 12:03:11 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Roopa Prabhu , Nikolay Aleksandrov , Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean , Vadym Kochan , Taras Chornyi , Jiri Pirko , Ido Schimmel , UNGLinuxDriver@microchip.com, Grygorii Strashko , Marek Behun , DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Claudiu Manoil , Alexandre Belloni , George McCollister , Ioana Ciornei , Saeed Mahameed , Leon Romanovsky , Lars Povlsen , Steen Hegelund , Julian Wiedmann , Karsten Graul , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Ivan Vecera , Vlad Buslov , Jianbo Liu , Mark Bloch , Roi Dayan , Tobias Waldekranz , Vignesh Raghavendra , Jesse Brandeburg , Peter Ujfalusi Subject: [RFC PATCH net-next 15/20] net: dsa: request drivers to perform FDB isolation Date: Wed, 18 Aug 2021 15:01:45 +0300 Message-Id: <20210818120150.892647-16-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818120150.892647-1-vladimir.oltean@nxp.com> References: <20210818120150.892647-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 18 Aug 2021 12:03:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 10539c05-65ec-449b-b1ab-08d962402670 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3839: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MmzDKevEAgKoM+8hf0xDETO5/fm82CrvB8/ilyTrRTfezYgo2NzJFx8FWgfnCqNxMO7kp1tQgbGVFGAwNjxXIAQi38+qvJ1tkWH+1f9P/ZRGeDSArGRJ1HiUe8ogtMjvNPHFU8Zic3Y0Uurfie0oMrBIJYfTQnwYDvcgCaqCpTHJxnJXSzXXGoFC0hxqU1la5A+d1gKkFnLVOYg8mHmHhVy7ueFMiVZj36Rgfi6SsQ5av9N9UUVoCAUgQhzVGcLhXd238KVMGdEuIfN6mF+J1ElCtb8X2Xbc0IEBYoZv6gv5lFwkSqdr3rl9yMfKx0qF9P784ih+bI4T3C/KBgl6xgGnqaKEtVYS5gzxNqoUtrTgpXkOlsJmPxiX/3gr1lhe81H2MSEJbeDtAgWg66qzUfa2RPeUzvMEyCQVFvpPmR7TQa2t5doE6lAFP92537cBBO2zTrxmxpY+S1iyhi8vS7a8vS5STAyPVdetjgFlLk/0wzKfVis7eZx6uE3M2S90JCr14PaB4EvT7D6HTFJhipHn6GtU45/SNb65Thfmb9mj7JYbp8BhgHfEJRML7SEms0X8BfcecXLL6RwkXdK/Fj1jUv72bQn0Hfi1E+oP1jmCiu5MSbdPUBwmNkpKeyXY6QJRPX4kcJsana/vRp7awPgYZT9AOdrQjM3LG7gjkDIkuMe38iNV2Cx0fpd2OoExSWsKAzip4HEdS8ueUlpzgw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(346002)(136003)(39850400004)(366004)(376002)(66476007)(2906002)(66556008)(8936002)(6506007)(186003)(7406005)(7416002)(52116002)(26005)(86362001)(66946007)(6486002)(44832011)(36756003)(30864003)(5660300002)(1076003)(110136005)(54906003)(6512007)(8676002)(316002)(6666004)(38350700002)(38100700002)(956004)(478600001)(83380400001)(2616005)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kEcoKjF6pVLuD/oq1iIiCNJBvGoIPu+1rAwxJlDWCXZsSx2xHyqTJk0xE36vBlAEYeXMh7D4SYSVentiehVz+UPmUAQuwpm5QNq9EDBwz4xFn9pDT95G818O5bly3CFTNmrqsOTgK9hZMsp9N7Ubr8XgBEgJtZpCM9Rp4i/9PQGzOiKRpinxPKvgp4YVeXC7UGroKoWyJgWiBzzUSPg379H7ckiiyAROkG+wXH1A+QPF+SavCFxL2u71rxgcv6MF9vunOZxvlaVYqKi/8bvlCjKxWOeW3ff7kylwUXfNJFDOmoslu58gccatJFHRbWJ/PsGCVuSeARHLG6v9Lc8bnj1rT6LMAZRvTC0sus7pmKm7ku7KFv5B1Jn4pPVbX3BZmxhjccfOAZnDy7HKKHucWraSRjJnA2waqE3DudtHrqQosfjamU5ecamHmZ1OOSb40u7yE1xdAcMovcXlFBnLsg/MDnLJYF2NXjOsc03vbLi8mK+Hag5/pZqancUs/1a1ryeBNRLDyTNZBAd0TXQcp7sRS8xug1r37K8l+wLZVl/nRtg5cBTzJyFtkc6NahCPpl+idA/3Awadq0sDsDGM8ELEI9YPaM6TALTFNNBo7FMR52P7ndyYFzugfFyJweBU0bCWBGs6f9nLh2nOzz+mVTIrhDOHUlQ3mHVyrPTI383JijBgFCHe6CuDLPQPnLL7/FIQXjnZM5ANVim1BilRepaf7GYcw0PmRrX/2TkoFGztnW/gIUa6/vAQlED5o/lfAJhLWmuS+NReoYlpE++TKO9xRisREB88XzMtZWaASj9a6YQIogY/H+pMrrjd8HVsmHvR1MTuiTc+ANi3TlNYzOyRGaMFoGBafiQUATh3KlG9EI8gZsBGAYMVxVtvVhi3RGWUDi7TaUB5CvwcNfDnb/d8/iFyUhB2ozg2ZckbkZdkWvkXOFSs0ggHo8QdOvV7o6zx0aPdV6ssRSLx1gwUM0XqcZ7qfwoSRYc7EeSoxwPe2xfgjycOALSJPpTlmQ/DlK0in5rhYgPl5n8tdyAUryLeb1B9LVgeoEPlOY0EiErXPV8U654oHMwkuSoZuCCIgCSM/Qn1SoU7wSPFVaiP42OtestnTfWa3q2bokw5puwN26dOX1e5lt/J+ku5TmoA89yRGOXybw3XxUhXFAwVKf63AoSYS9ijDGUY/7tTuVz5/C0yryLuRUJtw4iXnoA8M5EW+dEgu+kI9vr6Wlo99uwrNpdX6vMS3JnQtMqOQspr0c6DO1/JHTobdPuAFT4Qzyh6HzbTOx9UAc2HLbpocr9Ls/go/dT9pOtjPGwgJhU22WQMhLJjY7nznLvglCbX X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 10539c05-65ec-449b-b1ab-08d962402670 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2021 12:03:11.4633 (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: wQBg6YYnbtTyDInaFHmD1LikxcYtUOp8prwxXXcFizkaIPGeW4cZYU7JrZGGX8kKRqZPPjrClvj4zU7rT/vfqw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3839 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org For DSA, to encourage drivers to perform FDB isolation simply means to track which bridge does each FDB and MDB entry belong to. It then becomes the driver responsibility to use something that makes the FDB entry from one bridge not match the FDB lookup of ports from other bridges. The top-level functions where the bridge is determined are: - dsa_port_fdb_{add,del} - dsa_port_host_fdb_{add,del} - dsa_port_mdb_{add,del} - dsa_port_host_mdb_{add,del} aka the pre-crosschip-notifier functions. One might obviously ask: why do you pass the bridge_dev all the way to drivers, can't they just look at dsa_to_port(ds, port)->bridge_dev?! Well, no. While that might work for user ports, it does not work for CPU and DSA ports. Those service multiple bridges, of course. When dsa_port_host_fdb_add(dp) is called, the driver is notified on dp->cpu_dp. So it loses the information about the original dp, so it cannot access dp->bridge_dev. But notice that at least we don't explicitly pass the bridge_num to it. Drivers can call dsa_bridge_num_find(bridge_dev), sure, but it is optional and if they have a better tracking scheme, they should be free to use it. DSA must perform refcounting on the CPU and DSA ports by also taking into account the bridge number. So if two bridges request the same local address, DSA must notify the driver twice, once for each bridge. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/b53/b53_common.c | 12 +++-- drivers/net/dsa/b53/b53_priv.h | 12 +++-- drivers/net/dsa/hirschmann/hellcreek.c | 6 ++- drivers/net/dsa/lan9303-core.c | 13 ++++-- drivers/net/dsa/lantiq_gswip.c | 6 ++- drivers/net/dsa/microchip/ksz9477.c | 12 +++-- drivers/net/dsa/microchip/ksz_common.c | 6 ++- drivers/net/dsa/microchip/ksz_common.h | 6 ++- drivers/net/dsa/mt7530.c | 12 +++-- drivers/net/dsa/mv88e6xxx/chip.c | 12 +++-- drivers/net/dsa/ocelot/felix.c | 12 +++-- drivers/net/dsa/qca8k.c | 6 ++- drivers/net/dsa/sja1105/sja1105_main.c | 19 +++++--- include/net/dsa.h | 13 ++++-- net/dsa/dsa_priv.h | 2 + net/dsa/port.c | 9 +++- net/dsa/switch.c | 63 +++++++++++++++----------- 17 files changed, 143 insertions(+), 78 deletions(-) diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index 55bfcec2b204..bec55bf0efeb 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c @@ -1712,7 +1712,8 @@ static int b53_arl_op(struct b53_device *dev, int op, int port, } int b53_fdb_add(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid) + const unsigned char *addr, u16 vid, + const struct net_device *br) { struct b53_device *priv = ds->priv; @@ -1727,7 +1728,8 @@ int b53_fdb_add(struct dsa_switch *ds, int port, EXPORT_SYMBOL(b53_fdb_add); int b53_fdb_del(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid) + const unsigned char *addr, u16 vid, + const struct net_device *br) { struct b53_device *priv = ds->priv; @@ -1819,7 +1821,8 @@ int b53_fdb_dump(struct dsa_switch *ds, int port, EXPORT_SYMBOL(b53_fdb_dump); int b53_mdb_add(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb) + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *br) { struct b53_device *priv = ds->priv; @@ -1834,7 +1837,8 @@ int b53_mdb_add(struct dsa_switch *ds, int port, EXPORT_SYMBOL(b53_mdb_add); int b53_mdb_del(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb) + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *br) { struct b53_device *priv = ds->priv; int ret; diff --git a/drivers/net/dsa/b53/b53_priv.h b/drivers/net/dsa/b53/b53_priv.h index 4e9b05008524..6124d0f0d62b 100644 --- a/drivers/net/dsa/b53/b53_priv.h +++ b/drivers/net/dsa/b53/b53_priv.h @@ -358,15 +358,19 @@ int b53_vlan_add(struct dsa_switch *ds, int port, int b53_vlan_del(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan); int b53_fdb_add(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid); + const unsigned char *addr, u16 vid, + const struct net_device *br); int b53_fdb_del(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid); + const unsigned char *addr, u16 vid, + const struct net_device *br); int b53_fdb_dump(struct dsa_switch *ds, int port, dsa_fdb_dump_cb_t *cb, void *data); int b53_mdb_add(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb); + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *br); int b53_mdb_del(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb); + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *br); int b53_mirror_add(struct dsa_switch *ds, int port, struct dsa_mall_mirror_tc_entry *mirror, bool ingress); enum dsa_tag_protocol b53_get_tag_protocol(struct dsa_switch *ds, int port, diff --git a/drivers/net/dsa/hirschmann/hellcreek.c b/drivers/net/dsa/hirschmann/hellcreek.c index fdae74313eb7..f4de182a091b 100644 --- a/drivers/net/dsa/hirschmann/hellcreek.c +++ b/drivers/net/dsa/hirschmann/hellcreek.c @@ -826,7 +826,8 @@ static int hellcreek_fdb_get(struct hellcreek *hellcreek, } static int hellcreek_fdb_add(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid) + const unsigned char *addr, u16 vid, + const struct net_device *br) { struct hellcreek_fdb_entry entry = { 0 }; struct hellcreek *hellcreek = ds->priv; @@ -871,7 +872,8 @@ static int hellcreek_fdb_add(struct dsa_switch *ds, int port, } static int hellcreek_fdb_del(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid) + const unsigned char *addr, u16 vid, + const struct net_device *br) { struct hellcreek_fdb_entry entry = { 0 }; struct hellcreek *hellcreek = ds->priv; diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index d1148ab2f66e..311d8f5e3c87 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -1181,7 +1181,8 @@ static void lan9303_port_fast_age(struct dsa_switch *ds, int port) } static int lan9303_port_fdb_add(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid) + const unsigned char *addr, u16 vid, + const struct net_device *br) { struct lan9303 *chip = ds->priv; @@ -1193,8 +1194,8 @@ static int lan9303_port_fdb_add(struct dsa_switch *ds, int port, } static int lan9303_port_fdb_del(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid) - + const unsigned char *addr, u16 vid, + const struct net_device *br) { struct lan9303 *chip = ds->priv; @@ -1238,7 +1239,8 @@ static int lan9303_port_mdb_prepare(struct dsa_switch *ds, int port, } static int lan9303_port_mdb_add(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb) + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *br) { struct lan9303 *chip = ds->priv; int err; @@ -1253,7 +1255,8 @@ static int lan9303_port_mdb_add(struct dsa_switch *ds, int port, } static int lan9303_port_mdb_del(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb) + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *br) { struct lan9303 *chip = ds->priv; diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c index 64a22652cc75..7dd9d9752a17 100644 --- a/drivers/net/dsa/lantiq_gswip.c +++ b/drivers/net/dsa/lantiq_gswip.c @@ -1364,13 +1364,15 @@ static int gswip_port_fdb(struct dsa_switch *ds, int port, } static int gswip_port_fdb_add(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid) + const unsigned char *addr, u16 vid, + const struct net_device *br) { return gswip_port_fdb(ds, port, addr, vid, true); } static int gswip_port_fdb_del(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid) + const unsigned char *addr, u16 vid, + const struct net_device *br) { return gswip_port_fdb(ds, port, addr, vid, false); } diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c index 854e25f43fa7..1cc6ab1dfef8 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -583,7 +583,8 @@ static int ksz9477_port_vlan_del(struct dsa_switch *ds, int port, } static int ksz9477_port_fdb_add(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid) + const unsigned char *addr, u16 vid, + const struct net_device *br) { struct ksz_device *dev = ds->priv; u32 alu_table[4]; @@ -640,7 +641,8 @@ static int ksz9477_port_fdb_add(struct dsa_switch *ds, int port, } static int ksz9477_port_fdb_del(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid) + const unsigned char *addr, u16 vid, + const struct net_device *br) { struct ksz_device *dev = ds->priv; u32 alu_table[4]; @@ -782,7 +784,8 @@ static int ksz9477_port_fdb_dump(struct dsa_switch *ds, int port, } static int ksz9477_port_mdb_add(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb) + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *br) { struct ksz_device *dev = ds->priv; u32 static_table[4]; @@ -857,7 +860,8 @@ static int ksz9477_port_mdb_add(struct dsa_switch *ds, int port, } static int ksz9477_port_mdb_del(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb) + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *br) { struct ksz_device *dev = ds->priv; u32 static_table[4]; diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 202fd93caae3..96b4cd6f7daa 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -246,7 +246,8 @@ int ksz_port_fdb_dump(struct dsa_switch *ds, int port, dsa_fdb_dump_cb_t *cb, EXPORT_SYMBOL_GPL(ksz_port_fdb_dump); int ksz_port_mdb_add(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb) + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *br) { struct ksz_device *dev = ds->priv; struct alu_struct alu; @@ -291,7 +292,8 @@ int ksz_port_mdb_add(struct dsa_switch *ds, int port, EXPORT_SYMBOL_GPL(ksz_port_mdb_add); int ksz_port_mdb_del(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb) + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *br) { struct ksz_device *dev = ds->priv; struct alu_struct alu; diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index 59c42cc1000b..31653e1ae15f 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -167,9 +167,11 @@ void ksz_port_fast_age(struct dsa_switch *ds, int port); int ksz_port_fdb_dump(struct dsa_switch *ds, int port, dsa_fdb_dump_cb_t *cb, void *data); int ksz_port_mdb_add(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb); + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *br); int ksz_port_mdb_del(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb); + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *br); int ksz_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy); /* Common register access functions */ diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 3f3b4d3a36e4..08a5e5ef75e6 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -1348,7 +1348,8 @@ mt7530_port_bridge_leave(struct dsa_switch *ds, int port, static int mt7530_port_fdb_add(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid) + const unsigned char *addr, u16 vid, + const struct net_device *br) { struct mt7530_priv *priv = ds->priv; int ret; @@ -1364,7 +1365,8 @@ mt7530_port_fdb_add(struct dsa_switch *ds, int port, static int mt7530_port_fdb_del(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid) + const unsigned char *addr, u16 vid, + const struct net_device *br) { struct mt7530_priv *priv = ds->priv; int ret; @@ -1415,7 +1417,8 @@ mt7530_port_fdb_dump(struct dsa_switch *ds, int port, static int mt7530_port_mdb_add(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb) + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *br) { struct mt7530_priv *priv = ds->priv; const u8 *addr = mdb->addr; @@ -1441,7 +1444,8 @@ mt7530_port_mdb_add(struct dsa_switch *ds, int port, static int mt7530_port_mdb_del(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb) + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *br) { struct mt7530_priv *priv = ds->priv; const u8 *addr = mdb->addr; diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 92c2833a25a4..1b46641052a6 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -2241,7 +2241,8 @@ static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, } static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid) + const unsigned char *addr, u16 vid, + const struct net_device *br) { struct mv88e6xxx_chip *chip = ds->priv; int err; @@ -2255,7 +2256,8 @@ static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port, } static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid) + const unsigned char *addr, u16 vid, + const struct net_device *br) { struct mv88e6xxx_chip *chip = ds->priv; int err; @@ -5682,7 +5684,8 @@ static int mv88e6xxx_change_tag_protocol(struct dsa_switch *ds, int port, } static int mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb) + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *br) { struct mv88e6xxx_chip *chip = ds->priv; int err; @@ -5696,7 +5699,8 @@ static int mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port, } static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb) + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *br) { struct mv88e6xxx_chip *chip = ds->priv; int err; diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index cccbd33d5ac5..e764d8646d0b 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -628,7 +628,8 @@ static int felix_fdb_dump(struct dsa_switch *ds, int port, } static int felix_fdb_add(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid) + const unsigned char *addr, u16 vid, + const struct net_device *br) { struct ocelot *ocelot = ds->priv; @@ -636,7 +637,8 @@ static int felix_fdb_add(struct dsa_switch *ds, int port, } static int felix_fdb_del(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid) + const unsigned char *addr, u16 vid, + const struct net_device *br) { struct ocelot *ocelot = ds->priv; @@ -644,7 +646,8 @@ static int felix_fdb_del(struct dsa_switch *ds, int port, } static int felix_mdb_add(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb) + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *br) { struct ocelot *ocelot = ds->priv; @@ -652,7 +655,8 @@ static int felix_mdb_add(struct dsa_switch *ds, int port, } static int felix_mdb_del(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb) + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *br) { struct ocelot *ocelot = ds->priv; diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c index 4254fbd84432..b4893b179289 100644 --- a/drivers/net/dsa/qca8k.c +++ b/drivers/net/dsa/qca8k.c @@ -1619,7 +1619,8 @@ qca8k_port_fdb_insert(struct qca8k_priv *priv, const u8 *addr, static int qca8k_port_fdb_add(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid) + const unsigned char *addr, u16 vid, + const struct net_device *br) { struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv; u16 port_mask = BIT(port); @@ -1629,7 +1630,8 @@ qca8k_port_fdb_add(struct dsa_switch *ds, int port, static int qca8k_port_fdb_del(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid) + const unsigned char *addr, u16 vid, + const struct net_device *br) { struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv; u16 port_mask = BIT(port); diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 8580ca2e88df..667e698b5ae8 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -1731,7 +1731,8 @@ int sja1105pqrs_fdb_del(struct dsa_switch *ds, int port, } static int sja1105_fdb_add(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid) + const unsigned char *addr, u16 vid, + const struct net_device *br) { struct sja1105_private *priv = ds->priv; @@ -1739,7 +1740,8 @@ static int sja1105_fdb_add(struct dsa_switch *ds, int port, } static int sja1105_fdb_del(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid) + const unsigned char *addr, u16 vid, + const struct net_device *br) { struct sja1105_private *priv = ds->priv; @@ -1796,6 +1798,7 @@ static int sja1105_fdb_dump(struct dsa_switch *ds, int port, static void sja1105_fast_age(struct dsa_switch *ds, int port) { + const struct net_device *br = dsa_to_port(ds, port)->bridge_dev; struct sja1105_private *priv = ds->priv; int i; @@ -1824,7 +1827,7 @@ static void sja1105_fast_age(struct dsa_switch *ds, int port) u64_to_ether_addr(l2_lookup.macaddr, macaddr); - rc = sja1105_fdb_del(ds, port, macaddr, l2_lookup.vlanid); + rc = sja1105_fdb_del(ds, port, macaddr, l2_lookup.vlanid, br); if (rc) { dev_err(ds->dev, "Failed to delete FDB entry %pM vid %lld: %pe\n", @@ -1835,15 +1838,17 @@ static void sja1105_fast_age(struct dsa_switch *ds, int port) } static int sja1105_mdb_add(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb) + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *br) { - return sja1105_fdb_add(ds, port, mdb->addr, mdb->vid); + return sja1105_fdb_add(ds, port, mdb->addr, mdb->vid, br); } static int sja1105_mdb_del(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb) + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *br) { - return sja1105_fdb_del(ds, port, mdb->addr, mdb->vid); + return sja1105_fdb_del(ds, port, mdb->addr, mdb->vid, br); } /* Common function for unicast and broadcast flood configuration. diff --git a/include/net/dsa.h b/include/net/dsa.h index 5ecba358889a..103b738bd773 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -305,6 +305,7 @@ struct dsa_link { struct dsa_mac_addr { unsigned char addr[ETH_ALEN]; u16 vid; + const struct net_device *br; refcount_t refcount; struct list_head list; }; @@ -731,9 +732,11 @@ struct dsa_switch_ops { * Forwarding database */ int (*port_fdb_add)(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid); + const unsigned char *addr, u16 vid, + const struct net_device *br); int (*port_fdb_del)(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid); + const unsigned char *addr, u16 vid, + const struct net_device *br); int (*port_fdb_dump)(struct dsa_switch *ds, int port, dsa_fdb_dump_cb_t *cb, void *data); @@ -741,9 +744,11 @@ struct dsa_switch_ops { * Multicast database */ int (*port_mdb_add)(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb); + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *br); int (*port_mdb_del)(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb); + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *br); /* * RXNFC */ diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index 3a9d81ca3e64..ffdec05e1530 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h @@ -66,6 +66,7 @@ struct dsa_notifier_fdb_info { int port; const unsigned char *addr; u16 vid; + const struct net_device *br; }; /* DSA_NOTIFIER_MDB_* */ @@ -73,6 +74,7 @@ struct dsa_notifier_mdb_info { const struct switchdev_obj_port_mdb *mdb; int sw_index; int port; + const struct net_device *br; }; /* DSA_NOTIFIER_LAG_* */ diff --git a/net/dsa/port.c b/net/dsa/port.c index 07c57287ac3e..0c904525a95b 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -739,6 +739,7 @@ int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr, .port = dp->index, .addr = addr, .vid = vid, + .br = dp->bridge_dev, }; return dsa_port_notify(dp, DSA_NOTIFIER_FDB_ADD, &info); @@ -752,7 +753,7 @@ int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr, .port = dp->index, .addr = addr, .vid = vid, - + .br = dp->bridge_dev, }; return dsa_port_notify(dp, DSA_NOTIFIER_FDB_DEL, &info); @@ -766,6 +767,7 @@ int dsa_port_host_fdb_add(struct dsa_port *dp, const unsigned char *addr, .port = dp->index, .addr = addr, .vid = vid, + .br = dp->bridge_dev, }; struct dsa_port *cpu_dp = dp->cpu_dp; int err; @@ -785,6 +787,7 @@ int dsa_port_host_fdb_del(struct dsa_port *dp, const unsigned char *addr, .port = dp->index, .addr = addr, .vid = vid, + .br = dp->bridge_dev, }; struct dsa_port *cpu_dp = dp->cpu_dp; int err; @@ -814,6 +817,7 @@ int dsa_port_mdb_add(const struct dsa_port *dp, .sw_index = dp->ds->index, .port = dp->index, .mdb = mdb, + .br = dp->bridge_dev, }; return dsa_port_notify(dp, DSA_NOTIFIER_MDB_ADD, &info); @@ -826,6 +830,7 @@ int dsa_port_mdb_del(const struct dsa_port *dp, .sw_index = dp->ds->index, .port = dp->index, .mdb = mdb, + .br = dp->bridge_dev, }; return dsa_port_notify(dp, DSA_NOTIFIER_MDB_DEL, &info); @@ -838,6 +843,7 @@ int dsa_port_host_mdb_add(const struct dsa_port *dp, .sw_index = dp->ds->index, .port = dp->index, .mdb = mdb, + .br = dp->bridge_dev, }; struct dsa_port *cpu_dp = dp->cpu_dp; int err; @@ -856,6 +862,7 @@ int dsa_port_host_mdb_del(const struct dsa_port *dp, .sw_index = dp->ds->index, .port = dp->index, .mdb = mdb, + .br = dp->bridge_dev, }; struct dsa_port *cpu_dp = dp->cpu_dp; int err; diff --git a/net/dsa/switch.c b/net/dsa/switch.c index b1c38eee2cac..d0fda69104f9 100644 --- a/net/dsa/switch.c +++ b/net/dsa/switch.c @@ -188,20 +188,22 @@ static bool dsa_switch_host_address_match(struct dsa_switch *ds, int port, } static struct dsa_mac_addr *dsa_mac_addr_find(struct list_head *addr_list, - const unsigned char *addr, - u16 vid) + const unsigned char *addr, u16 vid, + const struct net_device *br) { struct dsa_mac_addr *a; list_for_each_entry(a, addr_list, list) - if (ether_addr_equal(a->addr, addr) && a->vid == vid) + if (ether_addr_equal(a->addr, addr) && a->vid == vid && + a->br == br) return a; return NULL; } static int dsa_switch_do_mdb_add(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb) + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *br) { struct dsa_port *dp = dsa_to_port(ds, port); struct dsa_mac_addr *a; @@ -209,9 +211,9 @@ static int dsa_switch_do_mdb_add(struct dsa_switch *ds, int port, /* No need to bother with refcounting for user ports */ if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp))) - return ds->ops->port_mdb_add(ds, port, mdb); + return ds->ops->port_mdb_add(ds, port, mdb, br); - a = dsa_mac_addr_find(&dp->mdbs, mdb->addr, mdb->vid); + a = dsa_mac_addr_find(&dp->mdbs, mdb->addr, mdb->vid, br); if (a) { refcount_inc(&a->refcount); return 0; @@ -221,7 +223,7 @@ static int dsa_switch_do_mdb_add(struct dsa_switch *ds, int port, if (!a) return -ENOMEM; - err = ds->ops->port_mdb_add(ds, port, mdb); + err = ds->ops->port_mdb_add(ds, port, mdb, br); if (err) { kfree(a); return err; @@ -229,6 +231,7 @@ static int dsa_switch_do_mdb_add(struct dsa_switch *ds, int port, ether_addr_copy(a->addr, mdb->addr); a->vid = mdb->vid; + a->br = br; refcount_set(&a->refcount, 1); list_add_tail(&a->list, &dp->mdbs); @@ -236,7 +239,8 @@ static int dsa_switch_do_mdb_add(struct dsa_switch *ds, int port, } static int dsa_switch_do_mdb_del(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_mdb *mdb) + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *br) { struct dsa_port *dp = dsa_to_port(ds, port); struct dsa_mac_addr *a; @@ -244,16 +248,16 @@ static int dsa_switch_do_mdb_del(struct dsa_switch *ds, int port, /* No need to bother with refcounting for user ports */ if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp))) - return ds->ops->port_mdb_del(ds, port, mdb); + return ds->ops->port_mdb_del(ds, port, mdb, br); - a = dsa_mac_addr_find(&dp->mdbs, mdb->addr, mdb->vid); + a = dsa_mac_addr_find(&dp->mdbs, mdb->addr, mdb->vid, br); if (!a) return -ENOENT; if (!refcount_dec_and_test(&a->refcount)) return 0; - err = ds->ops->port_mdb_del(ds, port, mdb); + err = ds->ops->port_mdb_del(ds, port, mdb, br); if (err) { refcount_inc(&a->refcount); return err; @@ -266,7 +270,8 @@ static int dsa_switch_do_mdb_del(struct dsa_switch *ds, int port, } static int dsa_switch_do_fdb_add(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid) + const unsigned char *addr, u16 vid, + const struct net_device *br) { struct dsa_port *dp = dsa_to_port(ds, port); struct dsa_mac_addr *a; @@ -274,9 +279,9 @@ static int dsa_switch_do_fdb_add(struct dsa_switch *ds, int port, /* No need to bother with refcounting for user ports */ if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp))) - return ds->ops->port_fdb_add(ds, port, addr, vid); + return ds->ops->port_fdb_add(ds, port, addr, vid, br); - a = dsa_mac_addr_find(&dp->fdbs, addr, vid); + a = dsa_mac_addr_find(&dp->fdbs, addr, vid, br); if (a) { refcount_inc(&a->refcount); return 0; @@ -286,7 +291,7 @@ static int dsa_switch_do_fdb_add(struct dsa_switch *ds, int port, if (!a) return -ENOMEM; - err = ds->ops->port_fdb_add(ds, port, addr, vid); + err = ds->ops->port_fdb_add(ds, port, addr, vid, br); if (err) { kfree(a); return err; @@ -294,6 +299,7 @@ static int dsa_switch_do_fdb_add(struct dsa_switch *ds, int port, ether_addr_copy(a->addr, addr); a->vid = vid; + a->br = br; refcount_set(&a->refcount, 1); list_add_tail(&a->list, &dp->fdbs); @@ -301,7 +307,8 @@ static int dsa_switch_do_fdb_add(struct dsa_switch *ds, int port, } static int dsa_switch_do_fdb_del(struct dsa_switch *ds, int port, - const unsigned char *addr, u16 vid) + const unsigned char *addr, u16 vid, + const struct net_device *br) { struct dsa_port *dp = dsa_to_port(ds, port); struct dsa_mac_addr *a; @@ -309,16 +316,16 @@ static int dsa_switch_do_fdb_del(struct dsa_switch *ds, int port, /* No need to bother with refcounting for user ports */ if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp))) - return ds->ops->port_fdb_del(ds, port, addr, vid); + return ds->ops->port_fdb_del(ds, port, addr, vid, br); - a = dsa_mac_addr_find(&dp->fdbs, addr, vid); + a = dsa_mac_addr_find(&dp->fdbs, addr, vid, br); if (!a) return -ENOENT; if (!refcount_dec_and_test(&a->refcount)) return 0; - err = ds->ops->port_fdb_del(ds, port, addr, vid); + err = ds->ops->port_fdb_del(ds, port, addr, vid, br); if (err) { refcount_inc(&a->refcount); return err; @@ -343,7 +350,7 @@ static int dsa_switch_host_fdb_add(struct dsa_switch *ds, if (dsa_switch_host_address_match(ds, port, info->sw_index, info->port)) { err = dsa_switch_do_fdb_add(ds, port, info->addr, - info->vid); + info->vid, info->br); if (err) break; } @@ -365,7 +372,7 @@ static int dsa_switch_host_fdb_del(struct dsa_switch *ds, if (dsa_switch_host_address_match(ds, port, info->sw_index, info->port)) { err = dsa_switch_do_fdb_del(ds, port, info->addr, - info->vid); + info->vid, info->br); if (err) break; } @@ -382,7 +389,7 @@ static int dsa_switch_fdb_add(struct dsa_switch *ds, if (!ds->ops->port_fdb_add) return -EOPNOTSUPP; - return dsa_switch_do_fdb_add(ds, port, info->addr, info->vid); + return dsa_switch_do_fdb_add(ds, port, info->addr, info->vid, info->br); } static int dsa_switch_fdb_del(struct dsa_switch *ds, @@ -393,7 +400,7 @@ static int dsa_switch_fdb_del(struct dsa_switch *ds, if (!ds->ops->port_fdb_del) return -EOPNOTSUPP; - return dsa_switch_do_fdb_del(ds, port, info->addr, info->vid); + return dsa_switch_do_fdb_del(ds, port, info->addr, info->vid, info->br); } static int dsa_switch_hsr_join(struct dsa_switch *ds, @@ -463,7 +470,7 @@ static int dsa_switch_mdb_add(struct dsa_switch *ds, if (!ds->ops->port_mdb_add) return -EOPNOTSUPP; - return dsa_switch_do_mdb_add(ds, port, info->mdb); + return dsa_switch_do_mdb_add(ds, port, info->mdb, info->br); } static int dsa_switch_mdb_del(struct dsa_switch *ds, @@ -474,7 +481,7 @@ static int dsa_switch_mdb_del(struct dsa_switch *ds, if (!ds->ops->port_mdb_del) return -EOPNOTSUPP; - return dsa_switch_do_mdb_del(ds, port, info->mdb); + return dsa_switch_do_mdb_del(ds, port, info->mdb, info->br); } static int dsa_switch_host_mdb_add(struct dsa_switch *ds, @@ -489,7 +496,8 @@ static int dsa_switch_host_mdb_add(struct dsa_switch *ds, for (port = 0; port < ds->num_ports; port++) { if (dsa_switch_host_address_match(ds, port, info->sw_index, info->port)) { - err = dsa_switch_do_mdb_add(ds, port, info->mdb); + err = dsa_switch_do_mdb_add(ds, port, info->mdb, + info->br); if (err) break; } @@ -510,7 +518,8 @@ static int dsa_switch_host_mdb_del(struct dsa_switch *ds, for (port = 0; port < ds->num_ports; port++) { if (dsa_switch_host_address_match(ds, port, info->sw_index, info->port)) { - err = dsa_switch_do_mdb_del(ds, port, info->mdb); + err = dsa_switch_do_mdb_del(ds, port, info->mdb, + info->br); if (err) break; } From patchwork Wed Aug 18 12:01:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 499557 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AA07C4338F for ; Wed, 18 Aug 2021 12:04:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D87B60F35 for ; Wed, 18 Aug 2021 12:04:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236554AbhHRMFT (ORCPT ); Wed, 18 Aug 2021 08:05:19 -0400 Received: from mail-eopbgr00079.outbound.protection.outlook.com ([40.107.0.79]:39586 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236514AbhHRMEe (ORCPT ); Wed, 18 Aug 2021 08:04:34 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lRUMeQUu6dzd8mMZzzMZwr/AgyjK4jpJysDe8+HSmtGltXGaX0YmKsIIIVHMaLfmCGXdTJYklA4ChTjswSy86a77DMymyJUxqApWylLzywkESqz2TZ7WXWfJIG8fSnbdhwX2EfKaxsy487CaTEPrs0IsEfTkFUsNcA+auJ+F7nFSBm0sn4VvxjIfNw8GhvXYrbJoP5mOWmra5/qhm2i7y3StR3lDM8sgxYQ3H/dVqhvgSXh9OAEBdEjqMDE+aJ8mAxgqUnawSWbpz+8kIEffLVz2UldY0hFKt5GVQeSwUcA11UhFoknLExg8H7JEPOaghbx98NlF7fjp9aHdDqT1zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+gYMrjC734w41a+FENTyateW6BDOP9qXfJuiGdkGxu0=; b=btO33jVeZBQ+8RVEl6uNb48KVuv8WqRIJ2GkJ3hV+dZn0nYOCLh8hnlR/xELB9wubp+LWbb8781qIfpXwoc5eD8s0Io7cOUnAYXoNnRqt3AyJK2wvrLhFY3nrtodi2rzzSD3bNsWOFjuoalsC0BJfCbWWSnSzi4QUmucfAJAnvv0bhlGYG6K2vmP0YkdNgB1VTeGtS7leqKOx63mR4hXPUIwPGbDB1g+bOHeMH265OMy9N66Ankp2nuMTrv3Xkrg/4QEND8g8m8q/7xtR98y0h39ChDsHk74y2uThXi1AHpyd7tNmTpM6ecjZpTht3g4JtpYsU+SqLaPpEBPOIXlGQ== 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=+gYMrjC734w41a+FENTyateW6BDOP9qXfJuiGdkGxu0=; b=H+U5p9JCKGP8ZyMY0wBLfLLXoddqlW/kmie/L+2CXjQjoKCJtee3BHr8BdLZh2h6c9h00ns8KPTVlno9s+PsjGvxTQILPoaAgDZW2tpwXLgoY4dCHoBxdjqKxrvSIvxEozPK1xfURyppuGSuetBc04wJEda8I30MOQFSmfeBMzw= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB3839.eurprd04.prod.outlook.com (2603:10a6:803:21::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17; Wed, 18 Aug 2021 12:03:14 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4415.024; Wed, 18 Aug 2021 12:03:13 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Roopa Prabhu , Nikolay Aleksandrov , Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean , Vadym Kochan , Taras Chornyi , Jiri Pirko , Ido Schimmel , UNGLinuxDriver@microchip.com, Grygorii Strashko , Marek Behun , DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Claudiu Manoil , Alexandre Belloni , George McCollister , Ioana Ciornei , Saeed Mahameed , Leon Romanovsky , Lars Povlsen , Steen Hegelund , Julian Wiedmann , Karsten Graul , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Ivan Vecera , Vlad Buslov , Jianbo Liu , Mark Bloch , Roi Dayan , Tobias Waldekranz , Vignesh Raghavendra , Jesse Brandeburg , Peter Ujfalusi Subject: [RFC PATCH net-next 16/20] net: dsa: sja1105: enforce FDB isolation Date: Wed, 18 Aug 2021 15:01:46 +0300 Message-Id: <20210818120150.892647-17-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818120150.892647-1-vladimir.oltean@nxp.com> References: <20210818120150.892647-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 18 Aug 2021 12:03:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b4e7e361-475d-4f1a-a24e-08d962402751 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3839: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t79XLDclmAKI97AEkFbSTV62zPUcts2rjFWf+Gz9ex6ytg5CzvjGX95ENaPiuIK5c97eUTSv0P86N4FWlL9uRpby32xSk+ZedySVI+2ArBgZllh7EnZuQJ5QeDK7I+dWnhXd10IK8miMTmQKXGZO7lMatiJPUs0uAjjIgn4d4zv5ubA/wYbQAoLyzF2zASaejPehkD0X9qugDYV5RnOACjyVbQDa3JAbO3zB9V0p7fXT31kf731O2icRk11tZDjXFrSY/PQ4BNGrKxlHgoL8/CsKOwsTMnVf10Rh3AHGAx+3vvfssKZpbwUovvcmI2h3TVTHjbOAz0sMMl1ozdT0xd2Tq8LD0eS6CdWLOHMUfiY61Py7AD3E+JJgOEyiS6eevrk59XFaQT3UsLbTu67ipo2jTr4Llh9OCuNTYB/5HHUhwpgAYLje9sbmN+erq3lq+AZH3zD1NxZ9h61gb//7ixSfRBIqg77n+QAT0Ah8zZ5ENDXtrekRwvANBQRWL1XMHwoUiZyy3yS/YNUL1pVn3yNmiPz4AKJ+wwNuiwrabaMzHM35PezFxu5npR22UTRQGD61diHjOBmDcFIBT4Cz+LSXzA3VVXWsbuHQh2z0xlo1HuA3fTQ8kGEBKbQLHBctOBRzLacup3sUs6M1JhLcHPT7N9JtSh/c4vcS5RpMPoSwS5ieJGSmQHT5Ngz5YNhCHv0fZsbhOlfOjRnQ/W0QgA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(346002)(136003)(39850400004)(366004)(376002)(66476007)(2906002)(66556008)(8936002)(6506007)(186003)(7406005)(7416002)(52116002)(26005)(86362001)(66946007)(6486002)(44832011)(36756003)(5660300002)(1076003)(110136005)(54906003)(6512007)(8676002)(316002)(6666004)(38350700002)(38100700002)(956004)(478600001)(83380400001)(2616005)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zz0IhX+bjIM8t/52tySATmGztEcAaEGCweFDSVA8MTWU9Rp7VJWSWE9ZuiAFCrs14XpGQCodTD7cezcEzYGiTqsiBeykjYtLmvgtXjZEoFjG8uiQWscaREmaoXS2Pz4VTlxhl+O/IU8F+yhl3MDUQtISlMNc0zc/cLd95Q7AMmGQviJISkq5rV3L3XAb5UPCYsXFChnegVyddJmia24ujwlH8Z35hdbUifjhxoHWJrNS3OvzoDjC0Hj7XNLzl7bCHFlC2SEbg2j2T4kWUAH6HaZF9pA09aQ9l7gZXPi4nMQUW9p0Sd55onls1EW+GyrXC42o9I3xdNbnLDwAo3lV8ZTDBILP2n+fbjocn9O8qyBvoDJv6Vy7t9+mWyi3sNdEiV2/lpwhK8MZHInNY/xdcsXo2GxPP+MV+uxHfA5IGeYc6AELfAO6f9+Rp5u77qFlW1h12S9uK6RG2WrHeguSILd2rRv0rF7WhRDPQ8VhJSL9FDy4i+hC8RObcLsQ8Y+NgE3Cy9rJI+1aQzWC6co24YoVIN5dQN0dXJcPJ6pw886ZntP7LyyjWybm+vJM5ODd5XbxSAht57sEDV4MCfjXgioSI/tXwHjdnIAFxMGxGUQCydAEWW/rGedJzjF3DO+m18Z73Fz9THTo239CW3rsKJApsI5MXf9nNFwyrC1wf86zGKYxMqzd9fJdtR9Bl47tUB/m4PSZmvZgaVeIf67UwDGXsww0K2/KC/IDb8xJFjaKLtwaUKe84/ghRTgq4BL+RiXPemM066MODWecQRbU4tiltUeST3XTwVK2BrUmJI8wu2rLajeoDwGr9rAd8CqMF3OFxI+U+Iv2euW4/Ax7hUu+qzUFzOqyaqdSFryAiWIh0swW1/vpmFONx11IqnezKx6Cpi0EqT731FpI1CQsYlM7rhDOzcVlpF3Ld0Z7TuLaL5Xp/p7ezbOSV9SVKdqvRIqCgODWjm9+QQMrBNSkWLedfPeQ2CMx/krW6yNA/OI2Rxvy4YsPLMpBGC1M6v6LGGFoAqJ2M8jmxwUTXnd5JQnysqutlk/Qv+hpJL5Fk9RAJUGXUAlbD8gH+wttuFdEajRienM9rLqSEZQEPE7LC7ulbOZjpdDCFln3SFadj2j8daNtc0cj1HdjZH2BxYOUOXBDJoSCdfuyk2j7IAApA1nyuU6AIT2avFRxZ1gtJJZEQrlbXfKXSEeb7OesO2XyGSi4mOrewTjZVFiVzyrXyfrhORSGw0reHlIFIL0Fr5b2lu9HC6HNv7lfDxTCxavqKqhGpndsnvcj+sdc0GlHFiju+LsDwdPCgxQpKPgHKVLcjNdO9H7Wtxcljr9+Lq6A X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b4e7e361-475d-4f1a-a24e-08d962402751 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2021 12:03:12.9284 (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: kzueV/2TV5ZbsjUJ8EZ7Esp7Ylr1M/Pc3buhM1i6vw6A7N5aRLBPElB3DPhv4m4axB6uYUNahKQvk1hushzqhQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3839 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org For sja1105, to enforce FDB isolation simply means to turn on Independent VLAN Learning unconditionally, and to remap VLAN-unaware FDB and MDB entries towards the private VLAN allocated by tag_8021q for each bridge. Standalone ports each have their own standalone tag_8021q VLAN. No learning happens in that VLAN due to: - learning being disabled on standalone user ports - learning being disabled on the CPU port (we use assisted_learning_on_cpu_port which only installs bridge FDBs) VLAN-aware ports learn FDB entries with the bridge VLANs. VLAN-unaware bridge ports learn with the tag_8021q VLAN for bridging. Since sja1105 is the first driver to use the dsa_bridge_num_find() helper, we need to export it. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/sja1105/sja1105_main.c | 38 +++++++------------------- include/net/dsa.h | 1 + net/dsa/dsa2.c | 3 +- 3 files changed, 13 insertions(+), 29 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 667e698b5ae8..bc0d89b96353 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -361,10 +361,8 @@ static int sja1105_init_l2_lookup_params(struct sja1105_private *priv) .start_dynspc = 0, /* 2^8 + 2^5 + 2^3 + 2^2 + 2^1 + 1 in Koopman notation */ .poly = 0x97, - /* This selects between Independent VLAN Learning (IVL) and - * Shared VLAN Learning (SVL) - */ - .shared_learn = true, + /* Always use Independent VLAN Learning (IVL) */ + .shared_learn = false, /* Don't discard management traffic based on ENFPORT - * we don't perform SMAC port enforcement anyway, so * what we are setting here doesn't matter. @@ -1736,6 +1734,9 @@ static int sja1105_fdb_add(struct dsa_switch *ds, int port, { struct sja1105_private *priv = ds->priv; + if (!vid) + vid = dsa_tag_8021q_bridge_vid(dsa_bridge_num_find(br)); + return priv->info->fdb_add_cmd(ds, port, addr, vid); } @@ -1745,6 +1746,9 @@ static int sja1105_fdb_del(struct dsa_switch *ds, int port, { struct sja1105_private *priv = ds->priv; + if (!vid) + vid = dsa_tag_8021q_bridge_vid(dsa_bridge_num_find(br)); + return priv->info->fdb_del_cmd(ds, port, addr, vid); } @@ -1787,8 +1791,9 @@ static int sja1105_fdb_dump(struct dsa_switch *ds, int port, u64_to_ether_addr(l2_lookup.macaddr, macaddr); /* We need to hide the dsa_8021q VLANs from the user. */ - if (!priv->vlan_aware) + if (vid_is_dsa_8021q(l2_lookup.vlanid)) l2_lookup.vlanid = 0; + rc = cb(macaddr, l2_lookup.vlanid, l2_lookup.lockeds, data); if (rc) return rc; @@ -2269,7 +2274,6 @@ sja1105_get_tag_protocol(struct dsa_switch *ds, int port, int sja1105_vlan_filtering(struct dsa_switch *ds, int port, bool enabled, struct netlink_ext_ack *extack) { - struct sja1105_l2_lookup_params_entry *l2_lookup_params; struct sja1105_general_params_entry *general_params; struct sja1105_private *priv = ds->priv; struct sja1105_table *table; @@ -2321,28 +2325,6 @@ int sja1105_vlan_filtering(struct dsa_switch *ds, int port, bool enabled, general_params->incl_srcpt1 = enabled; general_params->incl_srcpt0 = enabled; - /* VLAN filtering => independent VLAN learning. - * No VLAN filtering (or best effort) => shared VLAN learning. - * - * In shared VLAN learning mode, untagged traffic still gets - * pvid-tagged, and the FDB table gets populated with entries - * containing the "real" (pvid or from VLAN tag) VLAN ID. - * However the switch performs a masked L2 lookup in the FDB, - * effectively only looking up a frame's DMAC (and not VID) for the - * forwarding decision. - * - * This is extremely convenient for us, because in modes with - * vlan_filtering=0, dsa_8021q actually installs unique pvid's into - * each front panel port. This is good for identification but breaks - * learning badly - the VID of the learnt FDB entry is unique, aka - * no frames coming from any other port are going to have it. So - * for forwarding purposes, this is as though learning was broken - * (all frames get flooded). - */ - table = &priv->static_config.tables[BLK_IDX_L2_LOOKUP_PARAMS]; - l2_lookup_params = table->entries; - l2_lookup_params->shared_learn = !priv->vlan_aware; - for (port = 0; port < ds->num_ports; port++) { if (dsa_is_unused_port(ds, port)) continue; diff --git a/include/net/dsa.h b/include/net/dsa.h index 103b738bd773..5bf8d3a85106 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -1046,6 +1046,7 @@ static inline int dsa_ndo_eth_ioctl(struct net_device *dev, struct ifreq *ifr, void dsa_unregister_switch(struct dsa_switch *ds); int dsa_register_switch(struct dsa_switch *ds); struct dsa_switch *dsa_switch_find(int tree_index, int sw_index); +int dsa_bridge_num_find(const struct net_device *bridge_dev); #ifdef CONFIG_PM_SLEEP int dsa_switch_suspend(struct dsa_switch *ds); int dsa_switch_resume(struct dsa_switch *ds); diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index 1b2b25d7bd02..0d07a44eeecf 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -129,7 +129,7 @@ void dsa_lag_unmap(struct dsa_switch_tree *dst, struct net_device *lag) } } -static int dsa_bridge_num_find(const struct net_device *bridge_dev) +int dsa_bridge_num_find(const struct net_device *bridge_dev) { struct dsa_switch_tree *dst; struct dsa_port *dp; @@ -147,6 +147,7 @@ static int dsa_bridge_num_find(const struct net_device *bridge_dev) return -1; } +EXPORT_SYMBOL_GPL(dsa_bridge_num_find); int dsa_bridge_num_get(const struct net_device *bridge_dev, int max) { From patchwork Wed Aug 18 12:01:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 499556 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D228AC4338F for ; Wed, 18 Aug 2021 12:05:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A8DD66104F for ; Wed, 18 Aug 2021 12:05:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235700AbhHRMGJ (ORCPT ); Wed, 18 Aug 2021 08:06:09 -0400 Received: from mail-vi1eur05on2074.outbound.protection.outlook.com ([40.107.21.74]:54881 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235979AbhHRMD5 (ORCPT ); Wed, 18 Aug 2021 08:03:57 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GQEDaNK8UlqR3fGkpNwuKr3/CGjL7CLQjJcoMUdTde7QKZE2JOt0KINDSBto9khX/txQ9oWb92QElafAPNFfrVRIl+cZSuqU7ah9a89JNb/oWMC3/SAqatwvud+ymryn/RNs9O1sJgO4s9j8fbXd7+ppaMpqBwAZfQKFcFEPDmrGkdmrKOBHKgXdvEQPFNdWkI55ibrYRfX9Y/hrmU56rBuR/f9SLZtBLMLInnb9ftZNkwV/DMFgQZv+sWUnTZNlgsw9jysprqb5VBKziP49OPPkbgMC9nI1jr0yQPERBkh57ZC24Qzi0SO5dffscVhZmXYI9vRhV41DUIX6/e34FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3WQCwH5GbFPvs5E2VGIWrR+dDYLsA6Qori/cPxi4Lqo=; b=crY2ccXAEJNfsuDESqKVIWwIiweIMEwRn3So4HPvCXb2rSzI9z2K70GpwOq1NdmMivSFgIyP0X7hc0iGkanHdhlh9te62Hdnh0Rl9MYLLXnZlJ7zREFxKfvkVWcyw4w33k7iPC6+F+ycp8PBbwkyqhSjATZIxyrSkzMlKh1LtTTRyBE8N4XhH5gWuDMmwkFkyJcquSplVb2egTT/8HkRjHN8DLL0TBdjmNOynNeROM+IZjA2GR5jUH8FVkQfXItkyCxuzzDzUqEIKzwSeBBgFw2xo963avp56ENYxMdlFj4ZWp2Yo9ZV2Uq01RWq7FuPIvOvQqbiyrdO13hzRtD43g== 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=3WQCwH5GbFPvs5E2VGIWrR+dDYLsA6Qori/cPxi4Lqo=; b=qIkmTYrt5wdO94G6kPQgFsFRL6huGM1rx+4kuzXV9el+Ze6SjbHiJFNfHfG6KmO2B6hzGjxpP4Vhv3XzTN91nUOAa4WHPfrJSZEwOz3rn/YlEvebeZXg3aOvm6Rle7TpAf2SbpHM9dMEzRU2p3b7wc+vsUS9ycZMShUtrSB6arc= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR04MB4222.eurprd04.prod.outlook.com (2603:10a6:803:46::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.18; Wed, 18 Aug 2021 12:03:15 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4415.024; Wed, 18 Aug 2021 12:03:15 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Roopa Prabhu , Nikolay Aleksandrov , Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean , Vadym Kochan , Taras Chornyi , Jiri Pirko , Ido Schimmel , UNGLinuxDriver@microchip.com, Grygorii Strashko , Marek Behun , DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Claudiu Manoil , Alexandre Belloni , George McCollister , Ioana Ciornei , Saeed Mahameed , Leon Romanovsky , Lars Povlsen , Steen Hegelund , Julian Wiedmann , Karsten Graul , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Ivan Vecera , Vlad Buslov , Jianbo Liu , Mark Bloch , Roi Dayan , Tobias Waldekranz , Vignesh Raghavendra , Jesse Brandeburg , Peter Ujfalusi Subject: [RFC PATCH net-next 17/20] net: mscc: ocelot: transmit the "native VLAN" error via extack Date: Wed, 18 Aug 2021 15:01:47 +0300 Message-Id: <20210818120150.892647-18-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818120150.892647-1-vladimir.oltean@nxp.com> References: <20210818120150.892647-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 18 Aug 2021 12:03:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: aee6f6a7-3ad7-4cfa-a952-08d962402828 X-MS-TrafficTypeDiagnostic: VI1PR04MB4222: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1x0rOXuaNSjATNW91O1Xcw2ftV75uMjcpS6EPVWdfqd2lA5N2UEfo422ynrosueej1Hr37bBt5jjZTTvvL5NskdcC17UtHaIf04Qv6ILjTlZ1FrWPRrDkOXmjnetmN1AtbAMAdKpHYtONX5aV25sILOCHgD74d9blafy8KWA4s9FPEsEx8ZFPRq9Ebpe0r/fDeUyqGzKXMrkQAkaNRCVFi8vFH4GIU4gu7zX/i4fCfDddPpsAOPiKVSdZT0GXcxrB8zBI3yvb+Q1RKeDHcNLFlqFWOMf1/om3H+vc8tGfFvE+QjofAvWncBe7JaGJgGdO8U+UK1B50qpFfw03TLtq3GZlNjdGrKKURFRvyx0Ebt6BL316JH6JrZkPBV2/rPpUS5JxbXUjf5Ba6U8INYL2ZhkwekN5Tsl46kckC49Ns0jJ6qiNcsq4+Bnkqu32RnBz/bivTw+BdCCWVj732Xne/DMTAwbhO89ilzbG39Qw/tIHjPaYq43h2zS9/HeOWMvRRXRchM9Y5e6RLkZ6Nj25H/y7+BPheqCA4sbRiT+zfHeIqPPQzN6gXg/WIZjf5vtT6rpZYErbPmsjikM/08Sm/UlzrAbeeTu4mk/u0FHLfVb8YGA93GaoKDY+fnhx4EwrYhzOCSVCLOo2aFx7FlFx7GqN3qFqCOUIjsUQAduXUMA+lrOQWicxTf7m8Q0hgjS9LSlBFJrZARfvpJZySNopg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(396003)(136003)(39860400002)(366004)(376002)(6486002)(52116002)(2616005)(44832011)(4326008)(5660300002)(26005)(1076003)(6666004)(54906003)(956004)(6512007)(6506007)(186003)(38350700002)(38100700002)(86362001)(36756003)(110136005)(316002)(83380400001)(8936002)(478600001)(8676002)(66476007)(7416002)(7406005)(66946007)(66556008)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vkm6QxaSYXwxHB/zZmsAxqI3hyAYaYm0E0ld/OZuoHf7X0IhDLtpRNzIvbNp3jez7j8zSc/CkI6ARDOWVqrcBJZiR3CjJ2CKJS4Yx8ms1PmdCXNd9t2MEx9nITbvjQpfGlSYzbsPw6LKei2T7HXpw4hyoXHjvTjpHBgz5xZ8RnhpU1x+vLXuq4BV6J9mT9Uu981zHsGwwS52+rJ1Bsx383u0QQNTJsDApXcnWsJKOcPVnHABNfZQD/OsIy6L7YKmn22qXG9pTz73aDN/lwoOJ3aEbfMA7oZdJMX4d//9QtdNjFmCxf++mytxKUvY/Tp48tkXgbF//hEHzwoOmfu9eONajUpd3dhrE/p5yZcEbIu7YkJKNj1lQAx1YP5H0qKM18+9KNQ8aoRDZQkD+MokwUOHyXnNlGxyrd3l6IdgiS8duaczkdAKaqvUnHOtGHghlt9wd6UsBO541A2V3K7Cefm2HT2MFjz4cT2z3dprWvFL+c/C00s8ynSqYVeRzAX9gv6RJUvQAE3C+eOy9M5tUAsUJ72UBFnm2/2CXFeXQj3dubrz11+7pXlTWX4h1XiY/d2vJ69jhkLBQXQ0wTzLkMDLVs2ivm4ANVrhHyzkTKoctMexi2Ak/+vTCuXD5sdoG79ErVC+dJVBnWzcrxK89P5ioBjTSUvmZz8JGr94kUKobcl49B8ciJWS1VwRJHeezDSL3uyHLQN40LA7ov0ONSIGqxbdOTu7Skyjiq8cvzd/swWF2o/0a1Myk1iGMw8NR8rqk09HJ7NGFaVMkbJULtaQ/VKxV/7W26mRDr6J/DICSNLMc0gdODKLu+oP/gQ0jpThsinT3KhI2kIo69XkRzEzs5ozvnJq+5/R740ueqIyvASRZYcINA9bpL48ycl1Qlg2rzHRnMaKD/5sM6kYpgx+aCDJ0bRCW8vz5BfrPKI1DJeLd+LLUKw2woRIvKD/I5A9qwXVtBtzhLBCkHd/Esn6NLq2oQvXRp6T13tUG2MsAOq8S8rGiQBTK7pi9DooDgNmJiKqglOnC2rS2FeJxeZL8Z1JSn1KKdIfYGKvIplJs9Y6+HZuMMJMMq/cCpshRaF5LZGUKPSsfb1WKM0/HTy5C/iYAbr6K0XT3vXBzlYI71GFV3AiAzMUC1NauYtA8x4De7FAdrswT6bigH+EyRJlfDoDc5pbe/EE6HXXpOg21jaIHny7NrTcn1PcXaRWja0nF7kSs+Tx335UL9ziPs01CWyPikH39bDNec+gncDsMrePG2kpdXivUL6lVuCVGMYeqVbK91mCVMqXpVBZ/hDrv6Jbxjd1FRElJMjNwst4rDTCS8XRQbx442lbTOaU X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: aee6f6a7-3ad7-4cfa-a952-08d962402828 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2021 12:03:14.3076 (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: waFRrkcPU65M/yRdgvFpHNS48wTlSSxJd9k7Z9F2/jlfUvd2vTq+nqlEEFNVl7ZqkAttFnKnms9mK6NzpmWUSQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4222 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We need to reject some more configurations in future patches, convert the existing one to netlink extack. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/ocelot/felix.c | 8 ++++--- drivers/net/ethernet/mscc/ocelot.c | 7 +++--- drivers/net/ethernet/mscc/ocelot_net.c | 30 ++++++++++++++------------ include/soc/mscc/ocelot.h | 2 +- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index e764d8646d0b..0b3f7345d13d 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -740,7 +740,8 @@ static int felix_lag_change(struct dsa_switch *ds, int port) } static int felix_vlan_prepare(struct dsa_switch *ds, int port, - const struct switchdev_obj_port_vlan *vlan) + const struct switchdev_obj_port_vlan *vlan, + struct netlink_ext_ack *extack) { struct ocelot *ocelot = ds->priv; u16 flags = vlan->flags; @@ -758,7 +759,8 @@ static int felix_vlan_prepare(struct dsa_switch *ds, int port, return ocelot_vlan_prepare(ocelot, port, vlan->vid, flags & BRIDGE_VLAN_INFO_PVID, - flags & BRIDGE_VLAN_INFO_UNTAGGED); + flags & BRIDGE_VLAN_INFO_UNTAGGED, + extack); } static int felix_vlan_filtering(struct dsa_switch *ds, int port, bool enabled, @@ -777,7 +779,7 @@ static int felix_vlan_add(struct dsa_switch *ds, int port, u16 flags = vlan->flags; int err; - err = felix_vlan_prepare(ds, port, vlan); + err = felix_vlan_prepare(ds, port, vlan, extack); if (err) return err; diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 8ec194178aa2..ccb8a9863890 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -259,16 +259,15 @@ int ocelot_port_vlan_filtering(struct ocelot *ocelot, int port, EXPORT_SYMBOL(ocelot_port_vlan_filtering); int ocelot_vlan_prepare(struct ocelot *ocelot, int port, u16 vid, bool pvid, - bool untagged) + bool untagged, struct netlink_ext_ack *extack) { struct ocelot_port *ocelot_port = ocelot->ports[port]; /* Deny changing the native VLAN, but always permit deleting it */ if (untagged && ocelot_port->native_vlan.vid != vid && ocelot_port->native_vlan.valid) { - dev_err(ocelot->dev, - "Port already has a native VLAN: %d\n", - ocelot_port->native_vlan.vid); + NL_SET_ERR_MSG_MOD(extack, + "Port already has a native VLAN"); return -EBUSY; } diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index 04ca55ff0fd0..133634852ecf 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -385,17 +385,6 @@ static int ocelot_setup_tc(struct net_device *dev, enum tc_setup_type type, return 0; } -static int ocelot_vlan_vid_prepare(struct net_device *dev, u16 vid, bool pvid, - bool untagged) -{ - struct ocelot_port_private *priv = netdev_priv(dev); - struct ocelot_port *ocelot_port = &priv->port; - struct ocelot *ocelot = ocelot_port->ocelot; - int port = priv->chip_port; - - return ocelot_vlan_prepare(ocelot, port, vid, pvid, untagged); -} - static int ocelot_vlan_vid_add(struct net_device *dev, u16 vid, bool pvid, bool untagged) { @@ -943,14 +932,26 @@ static int ocelot_port_attr_set(struct net_device *dev, const void *ctx, return err; } +static int ocelot_vlan_vid_prepare(struct net_device *dev, u16 vid, bool pvid, + bool untagged, struct netlink_ext_ack *extack) +{ + struct ocelot_port_private *priv = netdev_priv(dev); + struct ocelot_port *ocelot_port = &priv->port; + struct ocelot *ocelot = ocelot_port->ocelot; + int port = priv->chip_port; + + return ocelot_vlan_prepare(ocelot, port, vid, pvid, untagged, extack); +} + static int ocelot_port_obj_add_vlan(struct net_device *dev, - const struct switchdev_obj_port_vlan *vlan) + const struct switchdev_obj_port_vlan *vlan, + struct netlink_ext_ack *extack) { bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID; int ret; - ret = ocelot_vlan_vid_prepare(dev, vlan->vid, pvid, untagged); + ret = ocelot_vlan_vid_prepare(dev, vlan->vid, pvid, untagged, extack); if (ret) return ret; @@ -1038,7 +1039,8 @@ static int ocelot_port_obj_add(struct net_device *dev, const void *ctx, switch (obj->id) { case SWITCHDEV_OBJ_ID_PORT_VLAN: ret = ocelot_port_obj_add_vlan(dev, - SWITCHDEV_OBJ_PORT_VLAN(obj)); + SWITCHDEV_OBJ_PORT_VLAN(obj), + extack); break; case SWITCHDEV_OBJ_ID_PORT_MDB: ret = ocelot_port_obj_add_mdb(dev, SWITCHDEV_OBJ_PORT_MDB(obj)); diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index fb5681f7e61b..ac072303dadf 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -825,7 +825,7 @@ int ocelot_fdb_add(struct ocelot *ocelot, int port, int ocelot_fdb_del(struct ocelot *ocelot, int port, const unsigned char *addr, u16 vid); int ocelot_vlan_prepare(struct ocelot *ocelot, int port, u16 vid, bool pvid, - bool untagged); + bool untagged, struct netlink_ext_ack *extack); int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid, bool untagged); int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid); From patchwork Wed Aug 18 12:01:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 499555 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACE2EC4338F for ; Wed, 18 Aug 2021 12:05:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E61260EBC for ; Wed, 18 Aug 2021 12:05:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236025AbhHRMGR (ORCPT ); Wed, 18 Aug 2021 08:06:17 -0400 Received: from mail-vi1eur05on2074.outbound.protection.outlook.com ([40.107.21.74]:54881 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236248AbhHRMEM (ORCPT ); Wed, 18 Aug 2021 08:04:12 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=btmjwkRE1MVeEehMA4kVtNOL9WNv+kvbG0T+lKkvxRPbXEAVkSUEqwo9cr5+WKroEoxjVPmsJNzP4MvrPiC8Kur5u+hFXUgEOw9ASECkpAqSfib+VnW4ZqOov4x3f0nCNKVLuNIUzRYoAJrLwqCtbUsMiRLLwIsStChIzJw7wcAfdOGE3ns0CSXqhTYlH67QGiOF7f3aJxErf29+ftueCnm7lbC1ppilxH+lkQxh6AnavD5lyBOFSvYPFAfOw2J8U/ZA8UNNNIwStQjWQDLKTg0Pz5xbCxp/Hbx0In0En1YvDonGezZTfM9oEgTmyr45STuhNkX7lpVIVQqU9xGbeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6zQmhdGJjvGc6x8W/0H/J8I4/NgGniuyPBzRA12vOmA=; b=c0fA02wQxJxcc1q8cuEXA68LFjx98D+8Kn3nnL2JOghBIuzZVOqSxGNg5SIj1a0ODUrpt2oVPgypSyVENJLhAWf/GBlwBGo1XgrLPzj1NCdZxsbLLslSqR+zan7ttfuF1ulN4TAOLDNwAMGLP3X/sZfJtJMPPpPppJZML9Ker1IP0nD31/1n8wUsaJzuTZ4ARop7F2EEZnSc8JUDUMbuKso4mcEFeW5o3og3CZmyYPCl3BuZNScwF4MBugUBBLPtQNC7eUbv4X81gUQNAi5Bi9KvZlvVw7QT6yvvLavGqyGEwn1a3s5bR5kw1jPK7DQ+UbjHmW+zdYuLlNfR7OgJKg== 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=6zQmhdGJjvGc6x8W/0H/J8I4/NgGniuyPBzRA12vOmA=; b=jkDMlFxa8Toi7a3KcX4t+WYe71MkBQl0NqYCKUJSV+/xDdFMKLtsVqkw8pA/O6feLywlYoNnfJf4i5CxCec9gaSZJ/QI4j7iTUrvlFEDYhjM6OongYdxei50lXm//bzDn8gPmp/UJDX9qaMg1fmmVrRREG4JMKFpoCDwcUPW9ag= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR04MB4222.eurprd04.prod.outlook.com (2603:10a6:803:46::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.18; Wed, 18 Aug 2021 12:03:15 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4415.024; Wed, 18 Aug 2021 12:03:15 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Roopa Prabhu , Nikolay Aleksandrov , Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean , Vadym Kochan , Taras Chornyi , Jiri Pirko , Ido Schimmel , UNGLinuxDriver@microchip.com, Grygorii Strashko , Marek Behun , DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Claudiu Manoil , Alexandre Belloni , George McCollister , Ioana Ciornei , Saeed Mahameed , Leon Romanovsky , Lars Povlsen , Steen Hegelund , Julian Wiedmann , Karsten Graul , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Ivan Vecera , Vlad Buslov , Jianbo Liu , Mark Bloch , Roi Dayan , Tobias Waldekranz , Vignesh Raghavendra , Jesse Brandeburg , Peter Ujfalusi Subject: [RFC PATCH net-next 18/20] net: mscc: ocelot: transmit the VLAN filtering restrictions via extack Date: Wed, 18 Aug 2021 15:01:48 +0300 Message-Id: <20210818120150.892647-19-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818120150.892647-1-vladimir.oltean@nxp.com> References: <20210818120150.892647-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 18 Aug 2021 12:03:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 41bbb013-16ca-4398-a7fc-08d9624028fa X-MS-TrafficTypeDiagnostic: VI1PR04MB4222: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:281; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TxVa12mlbLg3Sr+aSIr1/cxsrWIY3/hczEuL9q1bUNumKjL9h3lDDBPuFz24uJ5OMYmj6Lp/Yic7bI2VbuwlUCfZaK/dt+lF2bLW1AXvzJYRpr7297aU1uVLxfGE9vp/f9EdvVb9aZW9b9bVl+uGc6NwRqx31lLgx5l+rOwpEIUuN6Gbx/sfzypTjb+mIij24K7pcocCX81KKi2+1l+EOgFs60e5YOxQup7B46LxuBI/MErbkb2NmbEEWJ8P7L4O10jxkgQODxBIFTRmHRYThcfxEx8g2gAHFsnTeGM+edICW5z97DCrX5f7c+7zJO4UOtqt9j1kcoM1uMloZCJOKywW2p4jzuJ1ntoA8PHlFUXtupuVMdBXJCGCqUJOoXnVowlhBNGDgfeykPV50oVZs0+PiNstAy8fHIUHTNl9JFHQv38y/dp9oYyf+mpgWtjg6TICppt+WPK+33UQb4VPo7LAX8b5NvKXINKWzKfkvv0ZFgB3+zYP0nF+3bdFtHXxyT3bjrztDrTGUQ0cUGX7d1BAhnYhN8xI1l32kQ8EXZ9090cj+EKP0ld1JOyDKApX7bju8If/dUHYmePTjSg8oAApgqH3BAdHTNKHoJnoPT1UVCYHHvCN24nL3/WnXTK4831bvMxGYb8Yq69IakV2Fxo/PpNAWvOEdcnUHkCrCtmh6uIBIsB1RV7PqFyTW+GZr25mECs2p1weDtlPrp7BZg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(396003)(136003)(39860400002)(366004)(376002)(6486002)(52116002)(2616005)(44832011)(4326008)(5660300002)(26005)(1076003)(6666004)(54906003)(956004)(6512007)(6506007)(186003)(38350700002)(38100700002)(86362001)(36756003)(110136005)(316002)(83380400001)(8936002)(478600001)(8676002)(66476007)(7416002)(7406005)(66946007)(66556008)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ibzk1qe7zv/2DbQ6mJAJF+ypMi4MlsifLSCFqL2rjbzNJ0/qxXq7e2qHdX/VXTNtOmDYSDGpuZC8ALNCmDDaDr/nFBs841MUE7FM5PeYkGSgeb43bsRwLlYHcK5FksqcmmdGMPVE/azlUtaoOCbpF5zwE9kUUBdQVX+nLLm9OHjgtOvx5JikXDZyy+WD2zXs0sKAF/Q1DrN+QRD6gwMwo+VOc6Qs7I4kpwlSHdLwrCE+pcTLxV/Ar02evwrYzcImAdcCiEAO5CzphZme6TlbQR4psi84va2JzdRGNcKZ8V42ca516xDWgiIR40MgiQ94SO6mFkJosNRyB0vyfpGITqijvXLU1xQM9uoDuQDyLMGb62DZyZZh+dlsCZKOkCnotXBZLKLwuKgJYKw8b22Xfc8jpajfx1XO1PAzvZyXe5w0tSQUTrnj4FSZkN954rNxZ72k3aXUdvC9SBg0ENYb93LUDJlX4p2slpcP52xfjROihqSb+snKCbD2hBbHVuAE7gOWhcVqMzospreo/RIFuIhgEPvOo/a8FGj2/vqLczL8VSpKJyNHv4VmdYyDfUM9gAV1xjMNzW32Z9YBXsZnBFa3MOw0qdE0fSIR9P49G+MPWvFERDJYV1KOdEsy1ME6paICBEDTZztE3eVMDHQidQLubC0TX5Q+qhytpL9DYAA3ezo37BeNEaGdSUA1Te2bL8pbSueFyluLCxJPEZ4Bj3Vmkb+aQ9NtyzMrxh8dNvMr0pLh2SoywRL9hWXQ2CgKrtRT75k2OajZkBy1MmUcD/RA50H68Z+x6DbGqq5XuvAasGlwQWFAmH/uYM4BqzLg/UGnhCigtbDWBqjZnTGfMF5JkyqoTwEiILg+YjyrPcDnG9XVqGXkvwaqhMbKuHnMAvjwi/bMbB+1/PJq5oHqYVwsO5ASrgZu9gctc7B7KQ9Glqx/fEH1PpyyeFhIdjHvCVweh6dAkRQusKvY0336z0R5WsSzoKV2syU1sOVUX/KewjZT9R8iUwIjWjk2GMTaYH/i8AVvsjoBYds2DKnNGTS5pXpKG6CduLRyHnZHh4oWvCu8tWCz+3XXy7i3fiK+pJlIcdqz9fL1FTiBOAkGZrX10SX6+ZfG+qx/cF4IMCQ1bAjOKLZPXJqmYT/yGe/OmZAuPUNx7jXhuG7f/JJa9fDzsIZsJcDI3HU55aTV/iLuN0CDAN79YhgenfVRxZFoaly7SzS8H5YD1uWE0dMGiMMMvw1bxLfnPBJJmERkZAlSuLag0HTFBG9U/tuqU/RgdzePBbHcUdXkgnmrkoLo8Z02avvdxddjQhTg4XqVVDQWMf2wjzGlW32CzJP1GAnq X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 41bbb013-16ca-4398-a7fc-08d9624028fa X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2021 12:03:15.6849 (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: xBXAYdgim6oBg6IXjLAldAbq6FbwgjP/eUuu17s7jAJAC+q8vKgXw63E7LzCMnl+sh0ObgPzCk0VOib3GDVARA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4222 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We need to transmit more restrictions in future patches, convert this one to netlink extack. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/ocelot/felix.c | 2 +- drivers/net/ethernet/mscc/ocelot.c | 6 +++--- drivers/net/ethernet/mscc/ocelot_net.c | 8 +++++--- include/soc/mscc/ocelot.h | 3 ++- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 0b3f7345d13d..fdfb7954b203 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -768,7 +768,7 @@ static int felix_vlan_filtering(struct dsa_switch *ds, int port, bool enabled, { struct ocelot *ocelot = ds->priv; - return ocelot_port_vlan_filtering(ocelot, port, enabled); + return ocelot_port_vlan_filtering(ocelot, port, enabled, extack); } static int felix_vlan_add(struct dsa_switch *ds, int port, diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index ccb8a9863890..e848e0379b5a 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -223,7 +223,7 @@ static void ocelot_port_set_pvid(struct ocelot *ocelot, int port, } int ocelot_port_vlan_filtering(struct ocelot *ocelot, int port, - bool vlan_aware) + bool vlan_aware, struct netlink_ext_ack *extack) { struct ocelot_vcap_block *block = &ocelot->block[VCAP_IS1]; struct ocelot_port *ocelot_port = ocelot->ports[port]; @@ -233,8 +233,8 @@ int ocelot_port_vlan_filtering(struct ocelot *ocelot, int port, list_for_each_entry(filter, &block->rules, list) { if (filter->ingress_port_mask & BIT(port) && filter->action.vid_replace_ena) { - dev_err(ocelot->dev, - "Cannot change VLAN state with vlan modify rules active\n"); + NL_SET_ERR_MSG_MOD(extack, + "Cannot change VLAN state with vlan modify rules active"); return -EBUSY; } } diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index 133634852ecf..d255ab2c2848 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -912,7 +912,8 @@ static int ocelot_port_attr_set(struct net_device *dev, const void *ctx, ocelot_port_attr_ageing_set(ocelot, port, attr->u.ageing_time); break; case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING: - ocelot_port_vlan_filtering(ocelot, port, attr->u.vlan_filtering); + ocelot_port_vlan_filtering(ocelot, port, attr->u.vlan_filtering, + extack); break; case SWITCHDEV_ATTR_ID_BRIDGE_MC_DISABLED: ocelot_port_attr_mc_set(ocelot, port, !attr->u.mc_disabled); @@ -1132,14 +1133,15 @@ static int ocelot_switchdev_sync(struct ocelot *ocelot, int port, ocelot_port_attr_ageing_set(ocelot, port, ageing_time); return ocelot_port_vlan_filtering(ocelot, port, - br_vlan_enabled(bridge_dev)); + br_vlan_enabled(bridge_dev), + extack); } static int ocelot_switchdev_unsync(struct ocelot *ocelot, int port) { int err; - err = ocelot_port_vlan_filtering(ocelot, port, false); + err = ocelot_port_vlan_filtering(ocelot, port, false, NULL); if (err) return err; diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index ac072303dadf..06706a9fd5b1 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -807,7 +807,8 @@ int ocelot_get_sset_count(struct ocelot *ocelot, int port, int sset); int ocelot_get_ts_info(struct ocelot *ocelot, int port, struct ethtool_ts_info *info); void ocelot_set_ageing_time(struct ocelot *ocelot, unsigned int msecs); -int ocelot_port_vlan_filtering(struct ocelot *ocelot, int port, bool enabled); +int ocelot_port_vlan_filtering(struct ocelot *ocelot, int port, bool enabled, + struct netlink_ext_ack *extack); void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state); void ocelot_apply_bridge_fwd_mask(struct ocelot *ocelot); int ocelot_port_pre_bridge_flags(struct ocelot *ocelot, int port, From patchwork Wed Aug 18 12:01:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 500292 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FD46C4338F for ; Wed, 18 Aug 2021 12:04:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3FF6561058 for ; Wed, 18 Aug 2021 12:04:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236646AbhHRMEk (ORCPT ); Wed, 18 Aug 2021 08:04:40 -0400 Received: from mail-vi1eur05on2074.outbound.protection.outlook.com ([40.107.21.74]:54881 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236394AbhHRMEO (ORCPT ); Wed, 18 Aug 2021 08:04:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cl+/V1hSsgff6Jmnn1FfO3K7/A8ZBlkXxlQge+mwFCdZlMQBq313b5V4efTvD8y44WmRqZ53uR9y7MaTi9vcJ3X2in8b8j4lDt0pbfAmMZhnO0reuS6c/fAZbFx5bu4aYGK2wMdunRFuUxvVsXFIaSjWDEnTSV5zj9p4jjZc5fSvK5y/xcTiVZ7xzZURULv+ggcqx5lEejVekU2wOsfVt4AVGNUUxxDemynEG24eIHyTYdNaSl2iUaUSiqB+ODeXaLpDe76WMwdtmM7sryOMh3wOY8Jr8yulC2B3CCxToNYXxzRZ3B3//5I4zE1v/81BdAm/k0XOJdVrQCJUzjKL6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zhImt1syFqdWJrYlFm96xbsLOURwpTwXQrNslGfzI0M=; b=OWKXfKVaUkzfARlUAPfW9xmVksqmQsqfQIIPgt95X+8Li1yjngnQ5TbXtzNlO9eAXcm5Hn390XIZi36hEq+rS7RMzQjOn496igPe+fB4Zx2o3ibRptLBX+ffwWuNnC49TLhCNpfT0//k4EMhZEgTjBuuRW32CTC51satUwEEVCHzF+Hqbr3annSZ3iwqKZFwXVBDQW6SY38+Q6CkMBva6ylsOzTnkZQ2afKedwPSK9zMsLvergKba/gu7b766pdT4iZg9aiEUP1P+vrw1XjmAmzGjpR9LhFfKGfo9cbKkSBLjekuC/6DdseTrNeMsUe5i/0/VqWwI2v9sTCjFsn9Sg== 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=zhImt1syFqdWJrYlFm96xbsLOURwpTwXQrNslGfzI0M=; b=HpNSFZTLFdEQtRrsQ7BECWwhbSK//zeGzwscmt8LOdXyUAbhGTMFtUyRD2F3LVk4pIc7hhnnDj12fEPhhcsO/qU3T9hQfYf6RGjxwCGGQHV3xwFk15vRWFu6bS0LUKYLVY1PdDlYnMZXE85zPSX+2JKPaJNEBZzX4GmoEcXgAb4= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR04MB4222.eurprd04.prod.outlook.com (2603:10a6:803:46::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.18; Wed, 18 Aug 2021 12:03:17 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4415.024; Wed, 18 Aug 2021 12:03:17 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Roopa Prabhu , Nikolay Aleksandrov , Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean , Vadym Kochan , Taras Chornyi , Jiri Pirko , Ido Schimmel , UNGLinuxDriver@microchip.com, Grygorii Strashko , Marek Behun , DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Claudiu Manoil , Alexandre Belloni , George McCollister , Ioana Ciornei , Saeed Mahameed , Leon Romanovsky , Lars Povlsen , Steen Hegelund , Julian Wiedmann , Karsten Graul , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Ivan Vecera , Vlad Buslov , Jianbo Liu , Mark Bloch , Roi Dayan , Tobias Waldekranz , Vignesh Raghavendra , Jesse Brandeburg , Peter Ujfalusi Subject: [RFC PATCH net-next 19/20] net: mscc: ocelot: use helpers for port VLAN membership Date: Wed, 18 Aug 2021 15:01:49 +0300 Message-Id: <20210818120150.892647-20-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818120150.892647-1-vladimir.oltean@nxp.com> References: <20210818120150.892647-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 18 Aug 2021 12:03:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4f765e2f-5379-4342-f04a-08d9624029ce X-MS-TrafficTypeDiagnostic: VI1PR04MB4222: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lGfJWDnifx8XooR3gBBdD5dSLz3UkZ5cxisbJSmhaQKk1es9daN9n1SKkr3I8Fve1q+iK929vnSlxN70zzV+X9GiWti0MhzZCILww6tV2E5FyxaH6MR1LIVVOjn26dFUT0e23l0Qx9uBzYNigmrm1y1q7t9NhOnvJHiUTjymP9hkZ0spFGpmphvnhDd4b/sh3+E4EbQLS+lCL2A02wXxGsm12D+dJOq11KRv+yGexooiNUGOn+zrAGTa/257BH77hLZIw+n1BzAF+YR1Q5GjnXM51ONr+INsx2uQWi2J2cgqXxleEfv0MEgj5mHIa0oeiiPyoQ7KdSGMOE9lQ4ss2EFqLsIMJtxvEGo68bWXeVzU9fM4RvwITqjYHecvFXjyYTqI7ERfdOw4mypGkiRtkFKOUPZOvdgJ3nkvnIl8icT0RdtIqn+jUYsRgNT94WSOp0m7kNw9HlgBSAq25hqMneUmQOV1pxVThIOhphXkSE61G/z5aGSIzitoVMZXI14NVr45DtwvKUGGfuZiPz0MezrUmIuME4pjKdvbyH7ygfEhDd9nI9f3MQf67ukatLap X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(396003)(136003)(39860400002)(366004)(376002)(6486002)(52116002)(2616005)(44832011)(4326008)(5660300002)(26005)(1076003)(6666004)(54906003)(956004)(6512007)(6506007)(186003)(38350700002)(38100700002)(86362001)(36756003)(110136005)(316002)(83380400001)(8936002)(478600001)(8676002)(66476007)(7416002)(7406005)(66946007)(66556008)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: o8LSPcHDKtnEnxG/Iv28xKRPBD0xqQpCAuZH1BTQAqBzm9iGJ5UN1h0Iaipn8ggxP1faCK7+FQEEfBlAcPrckJMaLcbz5hobRjMlADJK+OP9V0EQga7rd8cpD2aNDMHEl4Q01q8CQ1IXsOdd6TQPjvhPtwDwWzRC4DCk9rGp9uPlsllsAzU2YBM4reVyMe4aAyDTpUL3XPjV8Gd3qfrpDTty/WGBulhkAj9InKnk/6JVvFhOrkwq1s7ZVf3PVGeKSGzKHkzFG18ki2rwic+4tpcG++IAObYbW154aKd8CdCS46ATobI3+sImgmlRwx+Zob20oi9vW5a9xfA3e7HmugHmNCUJBwxtaKURQ7jjvJGoMEdJ9EeQHOWQE6mwvCrw+qQDqsNon5+K+qX0fv0xdi1N3Yf65Or0IN20aTVLRSCl0RSU2lTMQQPxBYemYfsITtZkj8QCFNcRH+Im1gzfQnAq+sXpkiLfG/fXRf12d448QJxACkr3JvRo+vmFlOtYTaYFTZBbtOiMI0FgBl9cPZyJ2S3QVproy3z3Q9p6gpzLOHBOTcxHNt9/YwKeExzbws0BmbJWiX250ipLHhKJ6nnzrZrvU8hPHUu6Ro/9hbBPdct9xuaiTHwnzvQfngzc/TR1oPkTcbuBKWJInYY/o2aCbQsiUUR/RpcOL18LoGI6BdZjUmulTTOckz6H+Az5c5YOeMRx5+SVvhax8030QStDDIR94CT9Shyu0iV3iBPrF+gKNwXcy6vBANLAM2O/Xz/0vAStCSqBMTZq5NONXrw755wuUtPLCnEYiNmytZthGHj2BwipssgagWf7xtbSlEtBDMD8ypKGiTm/xCL41Gn12JMo8WGip80gu7eJxElFPr5d8IAZrkiOGU0vQR8QNG05G8Y+7eDfJqeu1h30MoUi8hdvBVVb+Lo7SYVS2HKQ1TD3t74Mg+HVXMN31LmsNjTrwIqdHnnAZBW9o3zOH20PumSjYHJgDQgj336rbwUGOTYCChoHBGkTKqXqHwzCkqf4zpyDC0751UaT7MTscjpZACSaCaT1rzg6z7ZAGxQ1EzPjLNphXzwrlP49bhgMyE8WkBN2CANtOMM6m1fEXk0XMu0MfwV3RDwQdyYT8n9WoIRDqyROYg5MBOjNqATGI4olIKgvjeI91f9pbpaNKIfNKPRqhfb/2nZl8Vpl+Z5oHyf8fMVbALH5zQL9LOeVAV0mHpFelZd73UFJ6bTYzSIItOOtXWq/yGZ7H3Ux90eLOu3DS6HE2djU4aUxQkPHilXFkHakhMOL4S8UZvXAJTOSRWO0DKbe6+DqrpgsXtmC/TbjJSfgZGrZeyjLE0An X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4f765e2f-5379-4342-f04a-08d9624029ce X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2021 12:03:17.0681 (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: zZVHarSzFubO0ibHVvEo5pApl/AaVx0+sFsx5UdJugUOM2817u8TJAx9YM2JCrCMC7yg0WNkIgvHJiYLHY75BA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4222 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This is a mostly cosmetic patch that creates some helpers for accessing the VLAN table. These helpers are also a bit more careful in that they do not modify the ocelot->vlan_mask unless the hardware operation succeeded. Not all callers check the return value (the init code doesn't), but anyway. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/mscc/ocelot.c | 60 ++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index e848e0379b5a..c581b955efb3 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -222,6 +222,33 @@ static void ocelot_port_set_pvid(struct ocelot *ocelot, int port, ANA_PORT_DROP_CFG, port); } +static int ocelot_vlan_member_set(struct ocelot *ocelot, u32 vlan_mask, u16 vid) +{ + int err; + + err = ocelot_vlant_set_mask(ocelot, vid, vlan_mask); + if (err) + return err; + + ocelot->vlan_mask[vid] = vlan_mask; + + return 0; +} + +static int ocelot_vlan_member_add(struct ocelot *ocelot, int port, u16 vid) +{ + return ocelot_vlan_member_set(ocelot, + ocelot->vlan_mask[vid] | BIT(port), + vid); +} + +static int ocelot_vlan_member_del(struct ocelot *ocelot, int port, u16 vid) +{ + return ocelot_vlan_member_set(ocelot, + ocelot->vlan_mask[vid] & ~BIT(port), + vid); +} + int ocelot_port_vlan_filtering(struct ocelot *ocelot, int port, bool vlan_aware, struct netlink_ext_ack *extack) { @@ -278,13 +305,11 @@ EXPORT_SYMBOL(ocelot_vlan_prepare); int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid, bool untagged) { - int ret; + int err; - /* Make the port a member of the VLAN */ - ocelot->vlan_mask[vid] |= BIT(port); - ret = ocelot_vlant_set_mask(ocelot, vid, ocelot->vlan_mask[vid]); - if (ret) - return ret; + err = ocelot_vlan_member_add(ocelot, port, vid); + if (err) + return err; /* Default ingress vlan classification */ if (pvid) { @@ -311,13 +336,11 @@ EXPORT_SYMBOL(ocelot_vlan_add); int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid) { struct ocelot_port *ocelot_port = ocelot->ports[port]; - int ret; + int err; - /* Stop the port from being a member of the vlan */ - ocelot->vlan_mask[vid] &= ~BIT(port); - ret = ocelot_vlant_set_mask(ocelot, vid, ocelot->vlan_mask[vid]); - if (ret) - return ret; + err = ocelot_vlan_member_del(ocelot, port, vid); + if (err) + return err; /* Ingress */ if (ocelot_port->pvid_vlan.vid == vid) { @@ -339,6 +362,7 @@ EXPORT_SYMBOL(ocelot_vlan_del); static void ocelot_vlan_init(struct ocelot *ocelot) { + unsigned long all_ports = GENMASK(ocelot->num_phys_ports - 1, 0); u16 port, vid; /* Clear VLAN table, by default all ports are members of all VLANs */ @@ -347,23 +371,19 @@ static void ocelot_vlan_init(struct ocelot *ocelot) ocelot_vlant_wait_for_completion(ocelot); /* Configure the port VLAN memberships */ - for (vid = 1; vid < VLAN_N_VID; vid++) { - ocelot->vlan_mask[vid] = 0; - ocelot_vlant_set_mask(ocelot, vid, ocelot->vlan_mask[vid]); - } + for (vid = 1; vid < VLAN_N_VID; vid++) + ocelot_vlan_member_set(ocelot, 0, vid); /* Because VLAN filtering is enabled, we need VID 0 to get untagged * traffic. It is added automatically if 8021q module is loaded, but * we can't rely on it since module may be not loaded. */ - ocelot->vlan_mask[0] = GENMASK(ocelot->num_phys_ports - 1, 0); - ocelot_vlant_set_mask(ocelot, 0, ocelot->vlan_mask[0]); + ocelot_vlan_member_set(ocelot, all_ports, 0); /* Set vlan ingress filter mask to all ports but the CPU port by * default. */ - ocelot_write(ocelot, GENMASK(ocelot->num_phys_ports - 1, 0), - ANA_VLANMASK); + ocelot_write(ocelot, all_ports, ANA_VLANMASK); for (port = 0; port < ocelot->num_phys_ports; port++) { ocelot_write_gix(ocelot, 0, REW_PORT_VLAN_CFG, port); From patchwork Wed Aug 18 12:01:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 500290 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BDDFC432BE for ; Wed, 18 Aug 2021 12:04:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1192A60EBC for ; Wed, 18 Aug 2021 12:04:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235981AbhHRMFG (ORCPT ); Wed, 18 Aug 2021 08:05:06 -0400 Received: from mail-vi1eur05on2074.outbound.protection.outlook.com ([40.107.21.74]:54881 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235777AbhHRMEY (ORCPT ); Wed, 18 Aug 2021 08:04:24 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JRWxYJAYKm7saRXfdLOKWK807gvk5ESGdv883Q2yuEcSP0pu97Tdpg+ra0lEnBxZwkbGKmaEIG9ESK0JYqelnEbm+k8gMhDKzyJdLFuzYGpPQW/q9aT5SDncOeSOE/M9MFBliCwqIOM28xn0om2pQklUkWIXXfvKhYsvCz5XD1QF3K2Eez3x2b+wb/muW9XVIyvQRGnub8LeopnxE9IiWLecz8V2jm+3KN+roBfni45DKiFkXq0U7DTuz4vq2p6f1OdiVlZrl+6vcsaWpi9C0No80nSOerzAE3C+crufCWSRIwk+D95tlaG6Km5EgDZi6/fvFYvdDfp8CXFns+JJAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6ODo0JS0elqK4hPdj/V22l/lGLA3U+49yyxv0r757FQ=; b=nNVd74nDZV7RnghOilipkmANXSiJvbiWWW4vwF6WuUOet0y8gtSElKhcfxUAHZ+8SsT0S1GphmyBgCylNh2/xBjI5SRghMxYnKsEZ5C/Qgm6LgAfHREj7JiaGjOYlHJlgfJtHCq/IPJ7jHwdSlv5ngcUODnc8qt6cUCUvu0IPPmmDsjmqgGEgC8f4SU4CJG6Rg7fsKvKB2ItrJRXaHtiiJCG/efwx9TqM/1cug6LXTbkEMqljut6q1IEmo/V8LDJeHHvwLa6NmPYqNLWBVY8G9iCDBV5+dNqV+dxDxBRhv1DQKycF80jO3QtSPI6m58ANa36Z6g48Jt15zkNO2a74g== 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=6ODo0JS0elqK4hPdj/V22l/lGLA3U+49yyxv0r757FQ=; b=hVFU3GpzTBbk7RE3LDb82MLEWyuqPX1kP3sOIQ59+P6B4XMvVjpiudZkG3Y5l9+scMh1GrcU12OKTvyOSo5RnW+uSMZ4V3RhXfQccdLci924N9HnZpu/CC53ZLnBLj8q+L3TEcO3zXORovfKRwHm7Bqgiy5Cu492rLYWWdmfRNg= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR04MB4222.eurprd04.prod.outlook.com (2603:10a6:803:46::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.18; Wed, 18 Aug 2021 12:03:19 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4415.024; Wed, 18 Aug 2021 12:03:19 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Roopa Prabhu , Nikolay Aleksandrov , Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean , Vadym Kochan , Taras Chornyi , Jiri Pirko , Ido Schimmel , UNGLinuxDriver@microchip.com, Grygorii Strashko , Marek Behun , DENG Qingfang , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , Sean Wang , Landen Chao , Claudiu Manoil , Alexandre Belloni , George McCollister , Ioana Ciornei , Saeed Mahameed , Leon Romanovsky , Lars Povlsen , Steen Hegelund , Julian Wiedmann , Karsten Graul , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Ivan Vecera , Vlad Buslov , Jianbo Liu , Mark Bloch , Roi Dayan , Tobias Waldekranz , Vignesh Raghavendra , Jesse Brandeburg , Peter Ujfalusi Subject: [RFC PATCH net-next 20/20] net: mscc: ocelot: enforce FDB isolation when VLAN-unaware Date: Wed, 18 Aug 2021 15:01:50 +0300 Message-Id: <20210818120150.892647-21-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818120150.892647-1-vladimir.oltean@nxp.com> References: <20210818120150.892647-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.144.60) by VI1PR08CA0134.eurprd08.prod.outlook.com (2603:10a6:800:d5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 18 Aug 2021 12:03:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 15523605-49cc-4895-657c-08d962402acc X-MS-TrafficTypeDiagnostic: VI1PR04MB4222: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AIrq/9GpBwm76SPGyLlIMtdyPpZ5/+zMZms3045dbjM0dAIU/lRdZ2sv62vC5WlhG0gVhrzVYWphYsA/XCAiJUkEfuh8Vn+MQLjtJePM7WGFVCaSO8rJBTLDrMvjZkVuMESDWMDzKSam1tYFjhIJekbeNJ+DkWvTzV4I83bJcyg71h5f2DpdgmUcWwZR98/Tvh7euxos9z5Dy6wZNaHRo8wK+31OwTb9FSI73m+o7LM9GCcn4dAMt9Nn7TlgrqzeBaOI1dqS7iRa6QqTmYO5LIWxmYYyrf/7J9lWnoFMxB/9Y0OMC3iHtTvUt1g0bMPAHSN8XHMxK55X7AfRBV/NGoOSYCrN4MOU+GNnZrHxNfmJEYJbNkqK8Buu0XGbOTa5koWXW3YdqUGBuaRtMf4GAfTr9aGqPwv1ZyedNgo16uiVrHWc2aNIvQEJS6QMHGa/u8+kcDIgzewVJ2V27UOi3PyFKKWGj1HWyQIXZFZqHO9anBscsIK80e7FKBvXaFjRX4XTRmm45iJawfi8ejMyqcIVXUhRKsjtIvzaPuUlPj9nDwQSQ2NYkXj02G+nHZDkCyTX37zgcysR0w/MObr1DFQT1c/6zZQZV7j78ugyLMgV3WS+OOkDxo5vu4vFGTmj5khR6Z715FkGuXTagUSc366cxLSz+mpn77p/ii+wXzdw5aqLZR/jtIOR1bF0TnVLVABJGAD5rPpzl0ygtlmPaA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(396003)(136003)(39860400002)(366004)(376002)(6486002)(52116002)(2616005)(44832011)(4326008)(5660300002)(26005)(1076003)(6666004)(54906003)(956004)(6512007)(6506007)(186003)(38350700002)(30864003)(38100700002)(86362001)(36756003)(110136005)(316002)(83380400001)(8936002)(478600001)(8676002)(66476007)(7416002)(7406005)(66946007)(66556008)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: x1x2oF0fST3JmFvRtJXnZqPu4bnmE4T7TMBJKfKcuC29Znkn4lEv6T/fR1iQfGagYi95OhCnI3mR3nLqrIzzEKzoOG4jIK4Ofbsyvch3Vrs6r770FdSd51xROLWBL9TFH7273/4AWLq+uiSK3AMa87HpVLF9Y3VeaAEpbWqXKrbQyHxgLfNpXa+h/Vnycf203LNREUKVjnIZTFgvnfSc5PVpdJxu+SJyBfG/Zqt5Rr6SYWrJmooL67bfpdMRt+GT3kMI5M+7Y91wrNW95n+JCbRBpEu1EVrSs6DZ5/luxV4husl9N66/gT/7HDNi7g1unkN5M0wmuUXWAYWYcSotflkBNsqXz4aK4m5Zi2Oox80D4uGU8Y38Jk7+DS7SDXv2XC8KNkvnnYlDF/Y+xvoSv0r9IurUftXAexO2qc6r/9d/NVXK74D5snypXea0t91ClVTDeYrfScgosai27iuB85DN5KH5NEeyb/rNZiuGOxq++fvj2ndtOgbMaxNEL/FjlHjsl6GuhqJvjqmwWkPrW8+EoJUUC2w1oL5Sz7EvN29Of6178ZLzSzNxvTddMMJWvCqTQVxQxgcVVDgfGEhTFB4fQGngasPG+bf5PKQyqU+47hkx6yRl1SO7FQbWiuycjAbLjwx/WyTgbIycsc5+ZtZHsrMxUgWHwO14paFTJIy0dZ8MAcUlu+Q0dZ1hidGXRukv+3j9RDK1dGoxzteFvvd+/3zChyr7ZXcUfRn1pQHy/8zVIHQIku1wKTe9i34k09C1TQxA2yHVqzF7edxkTVgLRFybc0fTtXOPyXWCoh8j1I2hUhmDos9sK5eizIvrMGpyMszzN+6G5oz7/N5r7dpcCRRSxQNWEV3rxD7D8rMKVAGEUK3fsH6vmJrUbe/slIIEmYYScdUDpaCc4Hlot44tFnciLSpYNzvyt7SUZt6amtwBbB0hbKaRN9UiTMW33dKCUivBkob/aPdLl88tVJIirTSIPRb316xk2HXcl1odcIgIQFGVJExkvgWyzy/wSv01uBDYRhIyplRHp0kqxb8hUxK4QdqtrVC9PIwLrVoqFj0h+zgbJ8tH2PEnH0OTcyTnZHksw5+HAF2MLoA48mmLSOV8p3w2RNU8tOOFF1rJntl1cTns4KpLlboJfDfwbYM/bAikbewcIQ564jQkoePtKeA9mcOlZlh5V1VvTj3b037q+wS1pciKtX5x2PR8DenaO6InqrffdGfbSG+9DQzQVofMPI0fHLPqXuwHUU8IpQsorCCEAKjffddkHnHPO05Jp/J6XVqEbF+GSyqMIvpJLTkI1SbrMzPIQWgefEO6GhQC+LlXM/U4f7Sw8D6b X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 15523605-49cc-4895-657c-08d962402acc X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2021 12:03:18.8151 (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: ZVceol8OtYi23CIgSFoWljc3wd7E6JqbUpTaHgmGgVjM7tpS60iFR2chumm3J3oOJazCAxi03+ZYmFoDFtVR0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4222 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Currently ocelot uses a pvid of 0 for standalone ports and ports under a VLAN-unaware bridge, and the pvid of the bridge for ports under a VLAN-aware bridge. Standalone ports do not perform learning, but packets received on them are still subject to FDB lookups. So if the MAC DA that a standalone port receives has been also learned on a VLAN-unaware bridge port, ocelot will attempt to forward to that port, even though it can't, so it will drop packets. So there is a desire to avoid that, and isolate the FDBs of different bridges from one another, and from standalone ports. The ocelot switch library has two distinct entry points: the felix DSA driver and the ocelot switchdev driver. We need to code up a minimal bridge_num allocation in the ocelot switchdev driver too, this is copied from DSA with the exception that ocelot does not care about DSA trees, cross-chip bridging etc. So it only looks at its own ports that are already in the same bridge. The ocelot switchdev driver uses the bridge_num it has allocated itself, while the felix driver uses the bridge_num allocated by DSA. They are both stored inside ocelot_port->bridge_num by the common function ocelot_port_bridge_join() which receives the bridge_num passed by value. Once we have a bridge_num, we can only use it to enforce isolation between VLAN-unaware bridges. As far as I can see, ocelot does not have anything like a FID that further makes VLAN 100 from a port be different to VLAN 100 from another port with regard to FDB lookup. So we simply deny multiple VLAN-aware bridges. For VLAN-unaware bridges, we crop the 4000-4095 VLAN region and we allocate a VLAN for each bridge_num. This will be used as the pvid of each port that is under that VLAN-unaware bridge, for as long as that bridge is VLAN-unaware. VID 0 remains only for standalone ports. It is okay if all standalone ports use the same VID 0, since they perform no address learning, the FDB will contain no entry in VLAN 0, so the packets will always be flooded to the only possible destination, the CPU port. The CPU port module doesn't need to be member of the VLANs to receive packets, but if we use the DSA tag_8021q protocol, those packets are part of the data plane as far as ocelot is concerned, so there it needs to. Just ensure that the DSA tag_8021q CPU port is a member of all reserved VLANs when it is created, and is removed when it is deleted. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/ocelot/felix.c | 16 +-- drivers/net/ethernet/mscc/ocelot.c | 182 +++++++++++++++++++++++-- drivers/net/ethernet/mscc/ocelot.h | 3 + drivers/net/ethernet/mscc/ocelot_net.c | 54 ++++++-- include/soc/mscc/ocelot.h | 25 ++-- 5 files changed, 244 insertions(+), 36 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index fdfb7954b203..f9eb4c628a59 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -233,7 +233,7 @@ static int felix_tag_8021q_vlan_del(struct dsa_switch *ds, int port, u16 vid) */ static void felix_8021q_cpu_port_init(struct ocelot *ocelot, int port) { - ocelot->ports[port]->is_dsa_8021q_cpu = true; + ocelot_port_set_dsa_8021q_cpu(ocelot, port); ocelot->npi = -1; /* Overwrite PGID_CPU with the non-tagging port */ @@ -245,6 +245,7 @@ static void felix_8021q_cpu_port_init(struct ocelot *ocelot, int port) static void felix_8021q_cpu_port_deinit(struct ocelot *ocelot, int port) { ocelot->ports[port]->is_dsa_8021q_cpu = false; + ocelot_port_unset_dsa_8021q_cpu(ocelot, port); /* Restore PGID_CPU */ ocelot_write_rix(ocelot, BIT(ocelot->num_phys_ports), ANA_PGID_PGID, @@ -633,7 +634,7 @@ static int felix_fdb_add(struct dsa_switch *ds, int port, { struct ocelot *ocelot = ds->priv; - return ocelot_fdb_add(ocelot, port, addr, vid); + return ocelot_fdb_add(ocelot, port, addr, vid, br); } static int felix_fdb_del(struct dsa_switch *ds, int port, @@ -642,7 +643,7 @@ static int felix_fdb_del(struct dsa_switch *ds, int port, { struct ocelot *ocelot = ds->priv; - return ocelot_fdb_del(ocelot, port, addr, vid); + return ocelot_fdb_del(ocelot, port, addr, vid, br); } static int felix_mdb_add(struct dsa_switch *ds, int port, @@ -651,7 +652,7 @@ static int felix_mdb_add(struct dsa_switch *ds, int port, { struct ocelot *ocelot = ds->priv; - return ocelot_port_mdb_add(ocelot, port, mdb); + return ocelot_port_mdb_add(ocelot, port, mdb, br); } static int felix_mdb_del(struct dsa_switch *ds, int port, @@ -660,7 +661,7 @@ static int felix_mdb_del(struct dsa_switch *ds, int port, { struct ocelot *ocelot = ds->priv; - return ocelot_port_mdb_del(ocelot, port, mdb); + return ocelot_port_mdb_del(ocelot, port, mdb, br); } static void felix_bridge_stp_state_set(struct dsa_switch *ds, int port, @@ -697,9 +698,7 @@ static int felix_bridge_join(struct dsa_switch *ds, int port, { struct ocelot *ocelot = ds->priv; - ocelot_port_bridge_join(ocelot, port, br); - - return 0; + return ocelot_port_bridge_join(ocelot, port, br, bridge_num, extack); } static void felix_bridge_leave(struct dsa_switch *ds, int port, @@ -1128,6 +1127,7 @@ static int felix_setup(struct dsa_switch *ds) ds->mtu_enforcement_ingress = true; ds->assisted_learning_on_cpu_port = true; + ds->max_num_bridges = ds->num_ports; return 0; diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index c581b955efb3..150b3d6d506a 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -13,6 +13,7 @@ #define TABLE_UPDATE_SLEEP_US 10 #define TABLE_UPDATE_TIMEOUT_US 100000 +#define OCELOT_RSV_VLAN_RANGE_START 4000 struct ocelot_mact_entry { u8 mac[ETH_ALEN]; @@ -132,6 +133,35 @@ static void ocelot_vcap_enable(struct ocelot *ocelot, int port) REW_PORT_CFG, port); } +static int ocelot_single_vlan_aware_bridge(struct ocelot *ocelot, + struct netlink_ext_ack *extack) +{ + struct net_device *bridge = NULL; + int port; + + for (port = 0; port < ocelot->num_phys_ports; port++) { + struct ocelot_port *ocelot_port = ocelot->ports[port]; + + if (!ocelot_port || !ocelot_port->bridge || + !br_vlan_enabled(ocelot_port->bridge)) + continue; + + if (!bridge) { + bridge = ocelot_port->bridge; + continue; + } + + if (bridge == ocelot_port->bridge) + continue; + + NL_SET_ERR_MSG_MOD(extack, + "Only one VLAN-aware bridge is supported"); + return -EBUSY; + } + + return 0; +} + static inline u32 ocelot_vlant_read_vlanaccess(struct ocelot *ocelot) { return ocelot_read(ocelot, ANA_TABLES_VLANACCESS); @@ -190,6 +220,39 @@ static void ocelot_port_set_native_vlan(struct ocelot *ocelot, int port, REW_TAG_CFG, port); } +int ocelot_bridge_num_find(struct ocelot *ocelot, + const struct net_device *bridge) +{ + int port; + + for (port = 0; port < ocelot->num_phys_ports; port++) { + struct ocelot_port *ocelot_port = ocelot->ports[port]; + + if (ocelot_port && ocelot_port->bridge == bridge) + return ocelot_port->bridge_num; + } + + return -1; +} +EXPORT_SYMBOL_GPL(ocelot_bridge_num_find); + +static u16 ocelot_vlan_unaware_pvid(struct ocelot *ocelot, + const struct net_device *bridge) +{ + int bridge_num; + + /* Standalone ports use VID 0 */ + if (!bridge) + return 0; + + bridge_num = ocelot_bridge_num_find(ocelot, bridge); + if (WARN_ON(bridge_num < 0)) + return 0; + + /* VLAN-unaware bridges use a reserved VID going from 4095 downwards */ + return VLAN_N_VID - bridge_num - 1; +} + /* Default vlan to clasify for untagged frames (may be zero) */ static void ocelot_port_set_pvid(struct ocelot *ocelot, int port, struct ocelot_vlan pvid_vlan) @@ -200,7 +263,8 @@ static void ocelot_port_set_pvid(struct ocelot *ocelot, int port, ocelot_port->pvid_vlan = pvid_vlan; if (!ocelot_port->vlan_aware) - pvid_vlan.vid = 0; + pvid_vlan.vid = ocelot_vlan_unaware_pvid(ocelot, + ocelot_port->bridge); ocelot_rmw_gix(ocelot, ANA_PORT_VLAN_CFG_VLAN_VID(pvid_vlan.vid), @@ -249,12 +313,29 @@ static int ocelot_vlan_member_del(struct ocelot *ocelot, int port, u16 vid) vid); } +static int ocelot_add_vlan_unaware_pvid(struct ocelot *ocelot, int port, + const struct net_device *bridge) +{ + u16 vid = ocelot_vlan_unaware_pvid(ocelot, bridge); + + return ocelot_vlan_member_add(ocelot, port, vid); +} + +static int ocelot_del_vlan_unaware_pvid(struct ocelot *ocelot, int port, + const struct net_device *bridge) +{ + u16 vid = ocelot_vlan_unaware_pvid(ocelot, bridge); + + return ocelot_vlan_member_del(ocelot, port, vid); +} + int ocelot_port_vlan_filtering(struct ocelot *ocelot, int port, bool vlan_aware, struct netlink_ext_ack *extack) { struct ocelot_vcap_block *block = &ocelot->block[VCAP_IS1]; struct ocelot_port *ocelot_port = ocelot->ports[port]; struct ocelot_vcap_filter *filter; + int err; u32 val; list_for_each_entry(filter, &block->rules, list) { @@ -266,6 +347,19 @@ int ocelot_port_vlan_filtering(struct ocelot *ocelot, int port, } } + err = ocelot_single_vlan_aware_bridge(ocelot, extack); + if (err) + return err; + + if (vlan_aware) + err = ocelot_del_vlan_unaware_pvid(ocelot, port, + ocelot_port->bridge); + else + err = ocelot_add_vlan_unaware_pvid(ocelot, port, + ocelot_port->bridge); + if (err) + return err; + ocelot_port->vlan_aware = vlan_aware; if (vlan_aware) @@ -298,6 +392,12 @@ int ocelot_vlan_prepare(struct ocelot *ocelot, int port, u16 vid, bool pvid, return -EBUSY; } + if (vid > OCELOT_RSV_VLAN_RANGE_START) { + NL_SET_ERR_MSG_MOD(extack, + "VLAN range 4000-4095 reserved for VLAN-unaware bridging"); + return -EBUSY; + } + return 0; } EXPORT_SYMBOL(ocelot_vlan_prepare); @@ -374,9 +474,9 @@ static void ocelot_vlan_init(struct ocelot *ocelot) for (vid = 1; vid < VLAN_N_VID; vid++) ocelot_vlan_member_set(ocelot, 0, vid); - /* Because VLAN filtering is enabled, we need VID 0 to get untagged - * traffic. It is added automatically if 8021q module is loaded, but - * we can't rely on it since module may be not loaded. + /* We need VID 0 to get traffic on standalone ports. + * It is added automatically if the 8021q module is loaded, but we + * can't rely on that since it might not be. */ ocelot_vlan_member_set(ocelot, all_ports, 0); @@ -965,21 +1065,27 @@ void ocelot_drain_cpu_queue(struct ocelot *ocelot, int grp) } EXPORT_SYMBOL(ocelot_drain_cpu_queue); -int ocelot_fdb_add(struct ocelot *ocelot, int port, - const unsigned char *addr, u16 vid) +int ocelot_fdb_add(struct ocelot *ocelot, int port, const unsigned char *addr, + u16 vid, const struct net_device *bridge) { int pgid = port; if (port == ocelot->npi) pgid = PGID_CPU; + if (!vid) + vid = ocelot_vlan_unaware_pvid(ocelot, bridge); + return ocelot_mact_learn(ocelot, pgid, addr, vid, ENTRYTYPE_LOCKED); } EXPORT_SYMBOL(ocelot_fdb_add); -int ocelot_fdb_del(struct ocelot *ocelot, int port, - const unsigned char *addr, u16 vid) +int ocelot_fdb_del(struct ocelot *ocelot, int port, const unsigned char *addr, + u16 vid, const struct net_device *bridge) { + if (!vid) + vid = ocelot_vlan_unaware_pvid(ocelot, bridge); + return ocelot_mact_forget(ocelot, addr, vid); } EXPORT_SYMBOL(ocelot_fdb_del); @@ -1098,6 +1204,12 @@ int ocelot_fdb_dump(struct ocelot *ocelot, int port, is_static = (entry.type == ENTRYTYPE_LOCKED); + /* Hide the reserved VLANs used for + * VLAN-unaware bridging. + */ + if (entry.vid > OCELOT_RSV_VLAN_RANGE_START) + entry.vid = 0; + ret = cb(entry.mac, entry.vid, is_static, data); if (ret) return ret; @@ -1396,6 +1508,28 @@ void ocelot_apply_bridge_fwd_mask(struct ocelot *ocelot) } EXPORT_SYMBOL(ocelot_apply_bridge_fwd_mask); +void ocelot_port_set_dsa_8021q_cpu(struct ocelot *ocelot, int port) +{ + u16 vid; + + ocelot->ports[port]->is_dsa_8021q_cpu = true; + + for (vid = OCELOT_RSV_VLAN_RANGE_START; vid < VLAN_N_VID; vid++) + ocelot_vlan_member_add(ocelot, port, vid); +} +EXPORT_SYMBOL_GPL(ocelot_port_set_dsa_8021q_cpu); + +void ocelot_port_unset_dsa_8021q_cpu(struct ocelot *ocelot, int port) +{ + u16 vid; + + ocelot->ports[port]->is_dsa_8021q_cpu = false; + + for (vid = OCELOT_RSV_VLAN_RANGE_START; vid < VLAN_N_VID; vid++) + ocelot_vlan_member_del(ocelot, port, vid); +} +EXPORT_SYMBOL_GPL(ocelot_port_unset_dsa_8021q_cpu); + void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state) { struct ocelot_port *ocelot_port = ocelot->ports[port]; @@ -1536,7 +1670,8 @@ static void ocelot_encode_ports_to_mdb(unsigned char *addr, } int ocelot_port_mdb_add(struct ocelot *ocelot, int port, - const struct switchdev_obj_port_mdb *mdb) + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *bridge) { unsigned char addr[ETH_ALEN]; struct ocelot_multicast *mc; @@ -1546,6 +1681,9 @@ int ocelot_port_mdb_add(struct ocelot *ocelot, int port, if (port == ocelot->npi) port = ocelot->num_phys_ports; + if (!vid) + vid = ocelot_vlan_unaware_pvid(ocelot, bridge); + mc = ocelot_multicast_get(ocelot, mdb->addr, vid); if (!mc) { /* New entry */ @@ -1592,7 +1730,8 @@ int ocelot_port_mdb_add(struct ocelot *ocelot, int port, EXPORT_SYMBOL(ocelot_port_mdb_add); int ocelot_port_mdb_del(struct ocelot *ocelot, int port, - const struct switchdev_obj_port_mdb *mdb) + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *bridge) { unsigned char addr[ETH_ALEN]; struct ocelot_multicast *mc; @@ -1602,6 +1741,9 @@ int ocelot_port_mdb_del(struct ocelot *ocelot, int port, if (port == ocelot->npi) port = ocelot->num_phys_ports; + if (!vid) + vid = ocelot_vlan_unaware_pvid(ocelot, bridge); + mc = ocelot_multicast_get(ocelot, mdb->addr, vid); if (!mc) return -ENOENT; @@ -1635,14 +1777,26 @@ int ocelot_port_mdb_del(struct ocelot *ocelot, int port, } EXPORT_SYMBOL(ocelot_port_mdb_del); -void ocelot_port_bridge_join(struct ocelot *ocelot, int port, - struct net_device *bridge) +int ocelot_port_bridge_join(struct ocelot *ocelot, int port, + struct net_device *bridge, int bridge_num, + struct netlink_ext_ack *extack) { struct ocelot_port *ocelot_port = ocelot->ports[port]; + int err; + + err = ocelot_single_vlan_aware_bridge(ocelot, extack); + if (err) + return err; ocelot_port->bridge = bridge; + ocelot_port->bridge_num = bridge_num; ocelot_apply_bridge_fwd_mask(ocelot); + + if (br_vlan_enabled(bridge)) + return 0; + + return ocelot_add_vlan_unaware_pvid(ocelot, port, bridge); } EXPORT_SYMBOL(ocelot_port_bridge_join); @@ -1652,7 +1806,11 @@ void ocelot_port_bridge_leave(struct ocelot *ocelot, int port, struct ocelot_port *ocelot_port = ocelot->ports[port]; struct ocelot_vlan pvid = {0}, native_vlan = {0}; + if (!br_vlan_enabled(bridge)) + ocelot_del_vlan_unaware_pvid(ocelot, port, bridge); + ocelot_port->bridge = NULL; + ocelot_port->bridge_num = -1; ocelot_port_set_pvid(ocelot, port, pvid); ocelot_port_set_native_vlan(ocelot, port, native_vlan); diff --git a/drivers/net/ethernet/mscc/ocelot.h b/drivers/net/ethernet/mscc/ocelot.h index 1952d6a1b98a..d90153f112a6 100644 --- a/drivers/net/ethernet/mscc/ocelot.h +++ b/drivers/net/ethernet/mscc/ocelot.h @@ -90,6 +90,9 @@ struct ocelot_multicast { struct ocelot_pgid *pgid; }; +int ocelot_bridge_num_find(struct ocelot *ocelot, + const struct net_device *bridge); + int ocelot_port_fdb_do_dump(const unsigned char *addr, u16 vid, bool is_static, void *data); int ocelot_mact_learn(struct ocelot *ocelot, int port, diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index d255ab2c2848..15b26fbfe227 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -654,10 +654,11 @@ static int ocelot_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], struct netlink_ext_ack *extack) { struct ocelot_port_private *priv = netdev_priv(dev); - struct ocelot *ocelot = priv->port.ocelot; + struct ocelot_port *ocelot_port = &priv->port; + struct ocelot *ocelot = ocelot_port->ocelot; int port = priv->chip_port; - return ocelot_fdb_add(ocelot, port, addr, vid); + return ocelot_fdb_add(ocelot, port, addr, vid, ocelot_port->bridge); } static int ocelot_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], @@ -665,10 +666,11 @@ static int ocelot_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], const unsigned char *addr, u16 vid) { struct ocelot_port_private *priv = netdev_priv(dev); - struct ocelot *ocelot = priv->port.ocelot; + struct ocelot_port *ocelot_port = &priv->port; + struct ocelot *ocelot = ocelot_port->ocelot; int port = priv->chip_port; - return ocelot_fdb_del(ocelot, port, addr, vid); + return ocelot_fdb_del(ocelot, port, addr, vid, ocelot_port->bridge); } static int ocelot_port_fdb_dump(struct sk_buff *skb, @@ -967,7 +969,7 @@ static int ocelot_port_obj_add_mdb(struct net_device *dev, struct ocelot *ocelot = ocelot_port->ocelot; int port = priv->chip_port; - return ocelot_port_mdb_add(ocelot, port, mdb); + return ocelot_port_mdb_add(ocelot, port, mdb, ocelot_port->bridge); } static int ocelot_port_obj_del_mdb(struct net_device *dev, @@ -978,7 +980,7 @@ static int ocelot_port_obj_del_mdb(struct net_device *dev, struct ocelot *ocelot = ocelot_port->ocelot; int port = priv->chip_port; - return ocelot_port_mdb_del(ocelot, port, mdb); + return ocelot_port_mdb_del(ocelot, port, mdb, ocelot_port->bridge); } static int ocelot_port_obj_mrp_add(struct net_device *dev, @@ -1152,6 +1154,33 @@ static int ocelot_switchdev_unsync(struct ocelot *ocelot, int port) return 0; } +static int ocelot_bridge_num_get(struct ocelot *ocelot, + const struct net_device *bridge_dev) +{ + int bridge_num = ocelot_bridge_num_find(ocelot, bridge_dev); + + if (bridge_num < 0) { + /* First port that offloads this bridge */ + bridge_num = find_first_zero_bit(&ocelot->bridges, + ocelot->num_phys_ports); + + set_bit(bridge_num, &ocelot->bridges); + } + + return bridge_num; +} + +static void ocelot_bridge_num_put(struct ocelot *ocelot, + const struct net_device *bridge_dev, + int bridge_num) +{ + /* Check if the bridge is still in use, otherwise it is time + * to clean it up so we can reuse this bridge_num later. + */ + if (!ocelot_bridge_num_find(ocelot, bridge_dev)) + clear_bit(bridge_num, &ocelot->bridges); +} + static int ocelot_netdevice_bridge_join(struct net_device *dev, struct net_device *brport_dev, struct net_device *bridge, @@ -1161,9 +1190,14 @@ static int ocelot_netdevice_bridge_join(struct net_device *dev, struct ocelot_port *ocelot_port = &priv->port; struct ocelot *ocelot = ocelot_port->ocelot; int port = priv->chip_port; - int err; + int bridge_num, err; - ocelot_port_bridge_join(ocelot, port, bridge); + bridge_num = ocelot_bridge_num_get(ocelot, bridge); + + err = ocelot_port_bridge_join(ocelot, port, bridge, bridge_num, + extack); + if (err) + goto err_join; err = switchdev_bridge_port_offload(brport_dev, dev, priv, &ocelot_switchdev_blocking_nb, @@ -1182,6 +1216,8 @@ static int ocelot_netdevice_bridge_join(struct net_device *dev, &ocelot_switchdev_blocking_nb); err_switchdev_offload: ocelot_port_bridge_leave(ocelot, port, bridge); +err_join: + ocelot_bridge_num_put(ocelot, bridge, bridge_num); return err; } @@ -1201,6 +1237,7 @@ static int ocelot_netdevice_bridge_leave(struct net_device *dev, struct ocelot_port_private *priv = netdev_priv(dev); struct ocelot_port *ocelot_port = &priv->port; struct ocelot *ocelot = ocelot_port->ocelot; + int bridge_num = ocelot_port->bridge_num; int port = priv->chip_port; int err; @@ -1209,6 +1246,7 @@ static int ocelot_netdevice_bridge_leave(struct net_device *dev, return err; ocelot_port_bridge_leave(ocelot, port, bridge); + ocelot_bridge_num_put(ocelot, bridge, bridge_num); return 0; } diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 06706a9fd5b1..d825ac4c01d5 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -620,6 +620,7 @@ struct ocelot_port { u16 mrp_ring_id; struct net_device *bridge; + int bridge_num; u8 stp_state; }; @@ -661,6 +662,8 @@ struct ocelot { enum ocelot_tag_prefix npi_inj_prefix; enum ocelot_tag_prefix npi_xtr_prefix; + unsigned long bridges; + struct list_head multicast; struct list_head pgids; @@ -800,6 +803,9 @@ void ocelot_deinit(struct ocelot *ocelot); void ocelot_init_port(struct ocelot *ocelot, int port); void ocelot_deinit_port(struct ocelot *ocelot, int port); +void ocelot_port_set_dsa_8021q_cpu(struct ocelot *ocelot, int port); +void ocelot_port_unset_dsa_8021q_cpu(struct ocelot *ocelot, int port); + /* DSA callbacks */ void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data); void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data); @@ -815,16 +821,17 @@ int ocelot_port_pre_bridge_flags(struct ocelot *ocelot, int port, struct switchdev_brport_flags val); void ocelot_port_bridge_flags(struct ocelot *ocelot, int port, struct switchdev_brport_flags val); -void ocelot_port_bridge_join(struct ocelot *ocelot, int port, - struct net_device *bridge); +int ocelot_port_bridge_join(struct ocelot *ocelot, int port, + struct net_device *bridge, int bridge_num, + struct netlink_ext_ack *extack); void ocelot_port_bridge_leave(struct ocelot *ocelot, int port, struct net_device *bridge); int ocelot_fdb_dump(struct ocelot *ocelot, int port, dsa_fdb_dump_cb_t *cb, void *data); -int ocelot_fdb_add(struct ocelot *ocelot, int port, - const unsigned char *addr, u16 vid); -int ocelot_fdb_del(struct ocelot *ocelot, int port, - const unsigned char *addr, u16 vid); +int ocelot_fdb_add(struct ocelot *ocelot, int port, const unsigned char *addr, + u16 vid, const struct net_device *bridge); +int ocelot_fdb_del(struct ocelot *ocelot, int port, const unsigned char *addr, + u16 vid, const struct net_device *bridge); int ocelot_vlan_prepare(struct ocelot *ocelot, int port, u16 vid, bool pvid, bool untagged, struct netlink_ext_ack *extack); int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid, @@ -848,9 +855,11 @@ int ocelot_cls_flower_destroy(struct ocelot *ocelot, int port, int ocelot_cls_flower_stats(struct ocelot *ocelot, int port, struct flow_cls_offload *f, bool ingress); int ocelot_port_mdb_add(struct ocelot *ocelot, int port, - const struct switchdev_obj_port_mdb *mdb); + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *bridge); int ocelot_port_mdb_del(struct ocelot *ocelot, int port, - const struct switchdev_obj_port_mdb *mdb); + const struct switchdev_obj_port_mdb *mdb, + const struct net_device *bridge); int ocelot_port_lag_join(struct ocelot *ocelot, int port, struct net_device *bond, struct netdev_lag_upper_info *info);