From patchwork Fri Aug 20 11:57: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: 500902 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=unavailable 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 801C7C4320A for ; Fri, 20 Aug 2021 11:58:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 66F26610C8 for ; Fri, 20 Aug 2021 11:58:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239680AbhHTL6q (ORCPT ); Fri, 20 Aug 2021 07:58:46 -0400 Received: from mail-db8eur05on2089.outbound.protection.outlook.com ([40.107.20.89]:42303 "EHLO EUR05-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238099AbhHTL6m (ORCPT ); Fri, 20 Aug 2021 07:58:42 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z0k+dhEsFu1/SDDiWRuJIyQRUiVAj6biJrIkV9bJojj67F8qWdf5avFPRUFaVg7B4Th/2mm2vDjd3M3diWYTkB9dDHgsaNIb7vGU6RtOH5su/hD24TUp0/mhe2XMrjIWg+ZznxTww5MXw57J4z5tyvVD8WS+dlYWUzxKS50kFWbM/J+B8ehseqBqAl7vcnuR0St5lbBTvFvaNFi+N/lEMCDHgu4uAk9KIGIWJRwo/118NbSIZBXx2hvq6Nu8K/XI0i7x3MLeJ5JztfmDcsAJNKCdvvzWJbRniLEpgTrHkQVpFbzd+takTBRpI8rTIUb2NlwOA2o279aaf+VEdnHBFg== 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=8Rhfy9Vmf2/2QzcvnqXC0SU84qWd5kqBquHYJ1jEOho=; b=FgSJ2OSSsA/YkHZziiPL4A1oizdf1bQNjTZl6Omp5bNAFYcSuLOyTC7dKYhrnhhDOmfuv2jX0AOw4McmbzuNhX8m66OBkVaODpqaTJ1ng9Nk7uMeqo9VOoJbMUyGIpw2Bkb1Rn8qKNR9a6yFXXQjPjk/u0MIZGyTJHV3VHT5Ei4NTVTh9drEc8h+SnTrJ/IgioWpy34mnCC+TedEHLqTe0uQVY4k9SpQCM3a7M3GV8Ong9Fzdchbei4vh/0FQqHgm0LrI3omTuB9cAcNSNKho65bWNCVkyurG6YbUV02Pex5FW0dlDqKKo9lqtVjyhRaQ891WSqrLnPFr/gGreyHtA== 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=8Rhfy9Vmf2/2QzcvnqXC0SU84qWd5kqBquHYJ1jEOho=; b=Al/SS9IHRuvaE0Kd04LPtVk8Wua4qOUJTx5CNDrUtes5No7XJ7iR1CgA4CNmOLdHObCvcBN531MOv6e9yeym5vdolhwcLx7JoJyIgrKQbpwT7G13W0i0AtGOLVsdTNgPNdxEZWFGx3sT1jN4JW4EsQQihOl/rhfIeiUsu1hPVC0= 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.4436.19; Fri, 20 Aug 2021 11:58: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.4436.019; Fri, 20 Aug 2021 11:58: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 , Alexandra Winter , Karsten Graul , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Ivan Vecera , Vlad Buslov , Jianbo Liu , Mark Bloch , Roi Dayan , Tobias Waldekranz , Vignesh Raghavendra , Jesse Brandeburg , linux-s390@vger.kernel.org Subject: [PATCH v3 net-next 1/7] net: bridge: move br_fdb_replay inside br_switchdev.c Date: Fri, 20 Aug 2021 14:57:40 +0300 Message-Id: <20210820115746.3701811-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210820115746.3701811-1-vladimir.oltean@nxp.com> References: <20210820115746.3701811-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR04CA0010.eurprd04.prod.outlook.com (2603:10a6:208:122::23) 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 AM0PR04CA0010.eurprd04.prod.outlook.com (2603:10a6:208:122::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Fri, 20 Aug 2021 11:57:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: acd89728-a121-4d53-c227-08d963d1c358 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: x6KOUNlIwubgrGcd26R5R0nppTRQKxe9pcM5Ay11HgAqazcG2lZKPM2+x5GvD8sC0nX4WYBuLFXi2QN+MlqJf7WbaqoulqeTTQKHLrJ4pmvMib8R+8aqTwTMny4p63XWKvzcz26zfO0Jxn1o4wzEMqzYL15mhQ+wf9Y0wE9AnvEx087SxGPE2VFinC9FOQdwJY8vjscKlvSDoTiCl7SfP7kn3EITSdDIrwNRThJFppAuEeV1ByddkheDO2p8/0STdzLSE0hEbm4ySBSHi14JOz/g8IuNWtHCsRT7stw91zEcfMbEqWxMko65KcmdtT2CrgfNFGhnQNeMmtrlXucIwQIBClA9u9JaokupFahHauGX2XxbMZSpFrDBbqHfv7lNOyk9vZ5vZKzk0N+I/vRkEMWc6pz57pNZyLHA+nuql21mAA11gzXvX5pR23gFPaoeSEaXUHL8tetzJ8W1sc5KX6SkJK7cl5XmMyebmXWANvHY8AAx9XnycNI9/2Zqf/L/FU+LHsAH1e1Dc7UHzZd/9XmyEKbKVNqMaAvR6zoghdAYshSKCIg3vjTN36X9Wb9Y/pA5N9GQY0ECj5QYjhmjm028FeM8SfvD4sS5K8+83fvpp0BXtkimv765+0epD27PozsKj5LXLYZw3o2IpxLZjHkMtGXwIUwcyCApYq2blpSVOONW2I8luofdFbgJrFm3bVIv9rlMxVz+Ed8jsOVTWQ== 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)(136003)(366004)(346002)(376002)(39860400002)(8936002)(8676002)(26005)(6506007)(6486002)(38350700002)(38100700002)(5660300002)(66476007)(66556008)(83380400001)(1076003)(6512007)(66946007)(52116002)(7416002)(7406005)(186003)(110136005)(36756003)(54906003)(478600001)(316002)(956004)(2616005)(44832011)(6666004)(2906002)(4326008)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AYnuraXQdVpgT2oEJAs0fQp/TOppRG3hWUWton+ebbpUv73uPKDuEsJ3FzkMZPIu1/66t6BYVO7oDH/dcDwqjoREqm3aCGw+67kMomp/7pjUGXCcCM8LvHTHCZEzjtNsUkUc27nxO4Ybnjyyrx9IO4eZ+9vKBtjg7eqOaj9IM4/ROQZEp7zJMrFYMeDDPQsTWVhyI7owGQynwS9qoXAYLG1XUajJsk+eYkpLyCJsqRi5RyPs/vswd0Ek3EhmmTdFluJhI8V2JnXgd42f60MxvVW6aHsPU+as2yESKD4mw8CBV35ZPUF504TjJt9CAp6qUg3zwmXBMM9Kydh/nPldEAoc1TFxeiD/0DOKYG+VNUduVYgc7QhGo01UZ0PF9wVvfr4rgz0PuA2xhla78kHEOnXjMyRMyuvFWWAgg+U6c+pL825iIgTDCbkDk+vVp5ohJHxsjdXWmW1b1x2xdxfP/XMkYDp44ivTUNshJuKOrhA++9T/RKYXnedqVXtPnFV9bpREDufqL77Y4ZUgN1IFo8wJ7oSeoik0dIQV36Kzczgt8cTkXg6GQVQanqEHfyey/urUBNhzZ4Q73sbFdqPuH+pOOsuivsb9U9cAcGTYf/JGf5GW5dos/JJ6L30mv4+/Gd6g4QqbuBYfziG7246TkFeUGvwdPeqjmaXJuw6bRWblH0TFZM4VmOnJ4y/ANDHPkceaUsiX4sm4oT+KfN2SbpVuA7GsFPonKphiKhs4MgfQ6iueFdOiLqtHoJ3i09C+1Hx22yUzVmvPDMZqC4K0wW32f5/pt2KSKdRh1G/q6riZd8lqMhMdsonHH+njnb+v6qpGFqV4Fgc6t4JOrOrqq6HpYApFtgDDrzHXjHntG+YMmSaUgq7Rj5oDRRVCxhmSNfSWPNs0uqAYesjwTDaDzaRSjGubxYvUoHXXOQfydHQpJUQn4NkYFV3It3QRe54qHjUsw1rngp/octESLyMqGQtnJIiK9LWueZs8yr3h37wTa302Ij4xJTjpRzmDx40vD2tL0pFjsYLcFo0kSG5O6DzQP+M29s1/eLY2Q10JWzX5XOi30WNmS4gwqQPp/apXO5VFvMDNVP2pIvqSRnQYSAKaQk/e7dhHPeySniFALQDoP7OSYN4ndaMVg7DeGz0oQDokHjujPqb/H/QkZrXpiKzizaoVXjy/e0DZNQTWuUyJNwiZNcI4C+enTiuljfiAhbJzK7gV/3FWK7w1621qcxdanMYW2UhRkHjmOSkzHgH3SlDUgYALE7n46DwoOkjgaf8ba9wf3VIUSl0Xalev98Y+U7FlS5NGCWavxIcOU+8+1xiaXHkjOg76wn9IFcui X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: acd89728-a121-4d53-c227-08d963d1c358 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2021 11:58:02.8783 (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: NpnxFukSgOU+DkfZbrXaMg8GW0DX+I3j+/YiXG35p2aqOYqre6qTMxh561zReJWwcwPxl5Af63e7/Mq3HaOtmg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3839 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org br_fdb_replay is only called from switchdev code paths, so it makes sense to be disabled if switchdev is not enabled in the first place. As opposed to br_mdb_replay and br_vlan_replay which might be turned off depending on bridge support for multicast and VLANs, FDB support is always on. So moving br_mdb_replay and br_vlan_replay inside br_switchdev.c would mean adding some #ifdef's in br_switchdev.c, so we keep those where they are. The reason for the movement is that in future changes there will be some code reuse between br_switchdev_fdb_notify and br_fdb_replay. Signed-off-by: Vladimir Oltean --- v2->v3: patch is new net/bridge/br_fdb.c | 54 --------------------------------------- net/bridge/br_private.h | 2 -- net/bridge/br_switchdev.c | 54 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 56 deletions(-) diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c index 46812b659710..c6e51701bc37 100644 --- a/net/bridge/br_fdb.c +++ b/net/bridge/br_fdb.c @@ -732,60 +732,6 @@ static inline size_t fdb_nlmsg_size(void) + nla_total_size(sizeof(u8)); /* NFEA_ACTIVITY_NOTIFY */ } -static int br_fdb_replay_one(struct net_bridge *br, struct notifier_block *nb, - const struct net_bridge_fdb_entry *fdb, - unsigned long action, const void *ctx) -{ - const struct net_bridge_port *p = READ_ONCE(fdb->dst); - struct switchdev_notifier_fdb_info item; - int err; - - item.addr = fdb->key.addr.addr; - item.vid = fdb->key.vlan_id; - item.added_by_user = test_bit(BR_FDB_ADDED_BY_USER, &fdb->flags); - item.offloaded = test_bit(BR_FDB_OFFLOADED, &fdb->flags); - item.is_local = test_bit(BR_FDB_LOCAL, &fdb->flags); - item.info.dev = (!p || item.is_local) ? br->dev : p->dev; - item.info.ctx = ctx; - - err = nb->notifier_call(nb, action, &item); - return notifier_to_errno(err); -} - -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 net_bridge *br; - unsigned long action; - int err = 0; - - if (!nb) - return 0; - - if (!netif_is_bridge_master(br_dev)) - return -EINVAL; - - br = netdev_priv(br_dev); - - 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) { - err = br_fdb_replay_one(br, nb, fdb, action, ctx); - if (err) - break; - } - - rcu_read_unlock(); - - return err; -} - static void fdb_notify(struct net_bridge *br, const struct net_bridge_fdb_entry *fdb, int type, bool swdev_notify) diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 21b292eb2b3e..390c807d1c7c 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -778,8 +778,6 @@ int br_fdb_external_learn_del(struct net_bridge *br, struct net_bridge_port *p, bool swdev_notify); void br_fdb_offloaded_set(struct net_bridge *br, struct net_bridge_port *p, const unsigned char *addr, u16 vid, bool offloaded); -int br_fdb_replay(const struct net_device *br_dev, const void *ctx, bool adding, - struct notifier_block *nb); /* br_forward.c */ enum br_pkt_type { diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c index 6bf518d78f02..8a45b1cfe06f 100644 --- a/net/bridge/br_switchdev.c +++ b/net/bridge/br_switchdev.c @@ -270,6 +270,60 @@ static void nbp_switchdev_del(struct net_bridge_port *p) } } +static int br_fdb_replay_one(struct net_bridge *br, struct notifier_block *nb, + const struct net_bridge_fdb_entry *fdb, + unsigned long action, const void *ctx) +{ + const struct net_bridge_port *p = READ_ONCE(fdb->dst); + struct switchdev_notifier_fdb_info item; + int err; + + item.addr = fdb->key.addr.addr; + item.vid = fdb->key.vlan_id; + item.added_by_user = test_bit(BR_FDB_ADDED_BY_USER, &fdb->flags); + item.offloaded = test_bit(BR_FDB_OFFLOADED, &fdb->flags); + item.is_local = test_bit(BR_FDB_LOCAL, &fdb->flags); + item.info.dev = (!p || item.is_local) ? br->dev : p->dev; + item.info.ctx = ctx; + + err = nb->notifier_call(nb, action, &item); + return notifier_to_errno(err); +} + +static 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 net_bridge *br; + unsigned long action; + int err = 0; + + if (!nb) + return 0; + + if (!netif_is_bridge_master(br_dev)) + return -EINVAL; + + br = netdev_priv(br_dev); + + 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) { + err = br_fdb_replay_one(br, nb, fdb, action, ctx); + if (err) + break; + } + + rcu_read_unlock(); + + return err; +} + static int nbp_switchdev_sync_objs(struct net_bridge_port *p, const void *ctx, struct notifier_block *atomic_nb, struct notifier_block *blocking_nb, From patchwork Fri Aug 20 11:57: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: 500901 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=unavailable 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 B05CFC4320A for ; Fri, 20 Aug 2021 11:58:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 94058610C8 for ; Fri, 20 Aug 2021 11:58:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239788AbhHTL6y (ORCPT ); Fri, 20 Aug 2021 07:58:54 -0400 Received: from mail-db8eur05on2049.outbound.protection.outlook.com ([40.107.20.49]:31328 "EHLO EUR05-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239997AbhHTL6u (ORCPT ); Fri, 20 Aug 2021 07:58:50 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q2xUM3OK0LztiwoIjoSds3VYnxaEBKmrr0dRqGtKlI2NK6Ayot37hYhVRPY0w/dDBjBr/1I6oiSWPKNzJwx2wyT+nc/s8mUgBDk+G3it7P6GaPYRL38tqDUY4t3Rl5sb+5RU6KAqdgbEWhbVGP09b4NiuKkIggLj943jDcmAUdCw8YNQL3P1NKYwc25dvSzaBE8o6XDYiFpBQr0k7YQUCZvny7BM8Jy77+Lc4WSYxEqq+N0ZByAOjEwtnhuE2+karMCrTStXWK8qaCJqRkD+Ubj/tnKecyoewsCqLDh5dP5fdivEolKziJLBJ+Ogmf6/Xma+0lx3HBPnov5GpBq/aA== 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=dXkiAOwqt4AUK/lRlHaBAiN+1fYb8ux9rZPb/qOGpuM=; b=Sgy27IfObNxQaTLba2bCNsulYkPj0uqZgrNsOQubnr570n4qRlyF+zV3S/VjmU4vO5k7AvIDcVHbkYPSQnog7Au37i/V23HWCUreoZ6ERJYNvbb6PEbFHtutufcrQtxAMz7lePY7fdv72iT0ngmrWhUyyOo0aY/R2Ri35H6UuLp0Px0yUJjo0Y75W3hjWbZBM7ysknP+rUtF7VBZChM8jRYtaRgyUp8njyakQnq7WEx1CaCMR3P9EY6M0RxfYBH+Qhk7bjCnlN8gO+/gjfkjPpoUk54cY9Ya4OtU71pPpkfTbSYqy5epGUntEjuL6CtXyZK3OH8OX5O2IiCFQCRVzg== 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=dXkiAOwqt4AUK/lRlHaBAiN+1fYb8ux9rZPb/qOGpuM=; b=pSzOqkFoD982yvHn5XhJRZnLhmDeR9W9falxwU3yvaklq7xL5d+ywQxE9049KkgzUJ0gFlnzCmOzaIJ45TYKxA+FpjMpH1vX5+e7sdoTralQUHB20uY8R/eQoo8YL2hS+AWsd45NIAOcZFpApgr2Yv/HLo8LfUzT5vx/xF+Ayek= 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.4436.19; Fri, 20 Aug 2021 11:58:09 +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.4436.019; Fri, 20 Aug 2021 11:58:09 +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 , Alexandra Winter , Karsten Graul , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Ivan Vecera , Vlad Buslov , Jianbo Liu , Mark Bloch , Roi Dayan , Tobias Waldekranz , Vignesh Raghavendra , Jesse Brandeburg , linux-s390@vger.kernel.org Subject: [PATCH v3 net-next 3/7] net: switchdev: move SWITCHDEV_FDB_{ADD, DEL}_TO_DEVICE to the blocking notifier chain Date: Fri, 20 Aug 2021 14:57:42 +0300 Message-Id: <20210820115746.3701811-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210820115746.3701811-1-vladimir.oltean@nxp.com> References: <20210820115746.3701811-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR04CA0010.eurprd04.prod.outlook.com (2603:10a6:208:122::23) 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 AM0PR04CA0010.eurprd04.prod.outlook.com (2603:10a6:208:122::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Fri, 20 Aug 2021 11:58:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cb461de4-d4e8-4093-9f74-08d963d1c72f 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: 6AQFKKUUmNKYLKf8QIhTRm1+lAqogCISY/z7bjQvL2d0aRc2BjCudid+NW9aJvRHDYDIEmQ7pwkiGOgy49TjMy3+FvUorIp+9pDltpketHH1g/3r8a0ma2H+8FiqGen/rlds1cJZrlrCc73WgFYNOsd5wh3um7tcOom+o2i2VGVpxmkrVZJKuYaKjImpUK5Oq8RtvHkl7ZABpWx7dV/Lh/tkkxxGUC6uW1tTdjoAmC8hQtMoaD5TRJk/mVf0lIC5G5FWeZvHfTde0/nGWj//HYZntRANKIkiR0Yr81MIO92B9zexy4MfW8dsr64v8h9PFl8a2ZNI6q16OIbaJp5qXG0QxYHsUDHGLon6CaavzoyCLYfoQYFm7Ji3ztqEWAe/IIJyFoMHBmAPr1oJGyxNw6BSlPeecuUEoupE0EBqLg4ZOTFNX5oAYCORCQyPbDKSJxsAVAL62fY5lVgIDxL/AH4FY1/Ya5ppUT7PaJi16jFhTJ2Gp1gB2uMuJBfW2id4hh1mzV1hHlPxrvEKJQi0klXjR2VYrxbyXgCagauv/mjQL48XIcVRl6FNEteG0ZZvq7atuBl0ywhhpSEW02lBxlPWGHoqVlf63zvgzygswF5Q4BYfFkTPzQtlhW4JHVBKlDeWeKxGvT+uNdi2He5TrYPk9+Nsa9BLmy7wFvtB5MVWj9Pk0l2hDEj798EKd4hHeeACTVO3dNHwA8J/etunAA== 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)(136003)(366004)(346002)(376002)(39860400002)(8936002)(8676002)(26005)(6506007)(6486002)(30864003)(38350700002)(38100700002)(5660300002)(66476007)(66556008)(83380400001)(1076003)(6512007)(66946007)(52116002)(7416002)(7406005)(186003)(110136005)(36756003)(54906003)(478600001)(316002)(956004)(2616005)(44832011)(6666004)(2906002)(4326008)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3vdm+EtSuXv3C/NiTKdsl1lA0fXFyAgcu+XW4AKW4e2dJX0M5PqusblmMZLtmHHo57bjrVxxrVXP2h8YpM9tWTXEk5Cu5ep99i2GGiNDDD8OBcUz1iCALVOZ9/6EeFcsNffXmxjOYj1FiV6+XCi3LA4j0cHtUqptcLg8WUA/wwKW6WZOOz2pNsZ9yz/PwwjA4Rc4WgYZFsA5d9ziuvtIoCKnRA4Aqo2sLrd01blSces7AXg8UwYh8MeSxe9mqFprQX7i1NDhAXIEvAOIehzwmhmzhLJEV+tphm6+v3vOB5gHg9tXsvjkMrpR84ad3yLWzc7o/+RnbqDMhRZweP1bnnJeyxTdBFoDoPxB032RWE+4ICplp+tOKd3fhOCdsYethZIvya7TltLQ4lNT/JP57hCN0g1ybI6zOrYhFWcr31VmmejLJXouDzhxQ8yj2GO+hoRMG0q0slWx7I5n/m7lUZjD3W6J4sXXgGlX5j6Ay/PsQ0kElOWZxuDFLi6nZhu4twcEOd+i88DSYwHg0IQG4jQaWr88TJioD3aXsQWh1H1GOFJdm8uHmzITyatgdSKRk+8fbQcLZgE1ZUCjEnV1/jdm7wWeT1Dj0NKhTTTmTG7CXtWhOUlwnznbYQaXE5/d7lk/ITTPWu5vkf2FpDinEWCOg55HD7iYW47Suyd8uRvHKICxCMJGQHsI6pmsEea2utC2HZSrEc2U2VG7TX7JeDvVgn85bkLo60np/9BbENE7IUX7NgY9f8Pa+ca+4GeXiUNVUiPrhICfb1B7ae/Lnj2CcM8nf8gB1lDhNbmsx7TeuG6wmj/0r6xjpr8j4RmlUty/Rgq5dsnl4+QwMjTbhPOkEIJkRtyETXnCDWVo+OMIeWYM8xd3+dyCwNLFLkJz81O/3Wm+2sv6MIuS+rMlxld1qJEz+LD6eVvISUkztsZx+seEo9GDYRYvyOcSV/fbnJhygh+AsN6JcUlX4DkwgvDdVredS3q4rOm9j3+lIALLkGb6t0Jsa4XV/cqSyNXtQXGw4ZHpmnlbKccHNPg0XBaMwBQvmVMY49F58EX5b/Kxh/o0UkDNV6CviTIASFihtnDMDzbl92WCfsXlfqsYIYwWRHxuA1oZmz+H8yEK3XxLlyne9SKz9VADTN/SNeiYggfwstgzsSvTNQlN185Bd5bHX4oXlFuFXZHVMaE8X5FPb5lbptvk0EGYK5u732KcJp+zN2ZyVDqNUBeRwa3zQzITVp/S62+bodrIn0T3H37RVNKl2d8fNQ0Zk0DvRP01qUtlQ96ix+WBA356CHiaXvljUgOCPJUeeBx1p7Suq6IZDP8gcJT22YiC5f/TGI2m X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cb461de4-d4e8-4093-9f74-08d963d1c72f X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2021 11:58:09.3605 (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: avNkssdxBhkX/lpVo+XhZ14+NaY1yqZj9VSyjhhf3nQpB52IMSmUeg7bcBlj3GsoXBGuHdINZeAXGmqmfyIPBA== 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 for the most part, enclosed them between a private pair of rcu_read_lock() and rcu_read_unlock(). The RCU protection can be dropped from the other drivers when they are reworked to stop scheduling. Signed-off-by: Vladimir Oltean --- v2->v3: - make sure that a shallow memcpy is enough to not have dangling bridge memory inside struct switchdev_notifier_fdb_info. - removed a bogus mlx5_esw_bridge_is_local (suggested by Vlad Buslov) - actually compile-tested the S/390 qeth driver .../ethernet/freescale/dpaa2/dpaa2-switch.c | 61 +++++++------- .../marvell/prestera/prestera_switchdev.c | 82 ++++++++++--------- .../mellanox/mlx5/core/en/rep/bridge.c | 55 ++++++++++++- .../mellanox/mlxsw/spectrum_switchdev.c | 47 ++++++++++- .../microchip/sparx5/sparx5_switchdev.c | 58 +++++++------ drivers/net/ethernet/rocker/rocker_main.c | 56 +++++++------ drivers/net/ethernet/ti/am65-cpsw-switchdev.c | 42 +++++----- drivers/net/ethernet/ti/cpsw_switchdev.c | 45 +++++----- drivers/s390/net/qeth_l2_main.c | 15 +++- include/net/switchdev.h | 25 +++++- net/bridge/br_switchdev.c | 12 +-- net/dsa/slave.c | 32 ++++---- net/switchdev/switchdev.c | 47 +++++++++++ 13 files changed, 385 insertions(+), 192 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c index dd0096cc3221..d0d63da7f01f 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c @@ -2253,40 +2253,10 @@ 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, fdb_info, - sizeof(switchdev_work->fdb_info)); - /* 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; } @@ -2312,6 +2282,34 @@ 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(*fdb_info)); + + /* Take a reference on the device to avoid being freed. */ + dev_hold(dev); + + queue_work(ethsw->workqueue, &switchdev_work->work); + + return NOTIFY_DONE; +} + static int dpaa2_switch_port_blocking_event(struct notifier_block *nb, unsigned long event, void *ptr) { @@ -2323,6 +2321,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 236b07c42df0..a89cda394685 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c @@ -844,10 +844,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) { @@ -857,42 +853,6 @@ 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, fdb_info, - sizeof(swdev_work->fdb_info)); - dev_hold(dev); - break; - - default: - kfree(swdev_work); - return NOTIFY_DONE; - } - - queue_work(swdev_wq, &swdev_work->work); return NOTIFY_DONE; } @@ -1089,6 +1049,42 @@ 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(*fdb_info)); + dev_hold(dev); + + queue_work(swdev_wq, &swdev_work->work); + return 0; +} + static int prestera_switchdev_blk_event(struct notifier_block *unused, unsigned long event, void *ptr) { @@ -1111,6 +1107,12 @@ static int prestera_switchdev_blk_event(struct notifier_block *unused, prestera_netdev_check, prestera_port_obj_attr_set); break; + 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; default: err = -EOPNOTSUPP; } 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 3e11420d8057..06bb8bb8e39e 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,51 @@ 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; + + 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 +340,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; } @@ -405,9 +456,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 78e5059beafa..fbaed9de3929 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c @@ -3246,8 +3246,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, @@ -3506,6 +3504,45 @@ 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(*fdb_info)); + /* 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; +} + static int mlxsw_sp_switchdev_blocking_event(struct notifier_block *unused, unsigned long event, void *ptr) { @@ -3534,6 +3571,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 5c5eb557a19c..0d19f2be0895 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c @@ -267,9 +267,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) { @@ -278,27 +275,6 @@ 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, fdb_info, - sizeof(switchdev_work->fdb_info)); - dev_hold(dev); - - sparx5_schedule_work(&switchdev_work->work); - break; } return NOTIFY_DONE; @@ -449,6 +425,36 @@ 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(*fdb_info)); + 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) @@ -468,6 +474,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 d490d006cc98..f6facbf4dc2c 100644 --- a/drivers/net/ethernet/rocker/rocker_main.c +++ b/drivers/net/ethernet/rocker/rocker_main.c @@ -2766,9 +2766,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; @@ -2776,30 +2773,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, fdb_info, - sizeof(switchdev_work->fdb_info)); - /* 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; } @@ -2822,6 +2795,32 @@ 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 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, fdb_info, sizeof(*fdb_info)); + /* 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) { @@ -2836,6 +2835,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 860214e1a8ca..5087d529c93e 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-switchdev.c +++ b/drivers/net/ethernet/ti/am65-cpsw-switchdev.c @@ -423,9 +423,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) { @@ -435,38 +432,39 @@ 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, fdb_info, - sizeof(switchdev_work->fdb_info)); - dev_hold(ndev); - break; - default: - kfree(switchdev_work); - return NOTIFY_DONE; - } + memcpy(&switchdev_work->fdb_info, fdb_info, sizeof(*fdb_info)); + dev_hold(ndev); queue_work(system_long_wq, &switchdev_work->work); return NOTIFY_DONE; } -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) { @@ -489,6 +487,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); + 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); default: break; } diff --git a/drivers/net/ethernet/ti/cpsw_switchdev.c b/drivers/net/ethernet/ti/cpsw_switchdev.c index 786bb848ddeb..8d463d1283f9 100644 --- a/drivers/net/ethernet/ti/cpsw_switchdev.c +++ b/drivers/net/ethernet/ti/cpsw_switchdev.c @@ -433,9 +433,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) { @@ -445,38 +442,40 @@ 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, fdb_info, - sizeof(switchdev_work->fdb_info)); - dev_hold(ndev); - break; - default: - kfree(switchdev_work); - return NOTIFY_DONE; - } + memcpy(&switchdev_work->fdb_info, fdb_info, sizeof(*fdb_info)); + dev_hold(dev); queue_work(system_long_wq, &switchdev_work->work); return NOTIFY_DONE; } -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) { @@ -499,6 +498,10 @@ static int cpsw_switchdev_blocking_event(struct notifier_block *unused, cpsw_port_dev_check, cpsw_port_attr_set); return notifier_from_errno(err); + 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); default: break; } diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c index de98f79c11ab..98678dc9d054 100644 --- a/drivers/s390/net/qeth_l2_main.c +++ b/drivers/s390/net/qeth_l2_main.c @@ -863,10 +863,15 @@ static int qeth_l2_switchdev_event(struct notifier_block *unused, event == SWITCHDEV_FDB_DEL_TO_DEVICE)) return NOTIFY_DONE; + rcu_read_lock(); + dstdev = switchdev_notifier_info_to_dev(info); brdev = netdev_master_upper_dev_get_rcu(dstdev); - if (!brdev || !netif_is_bridge_master(brdev)) + if (!brdev || !netif_is_bridge_master(brdev)) { + rcu_read_unlock(); return NOTIFY_DONE; + } + fdb_info = container_of(info, struct switchdev_notifier_fdb_info, info); @@ -881,11 +886,15 @@ static int qeth_l2_switchdev_event(struct notifier_block *unused, fdb_info->addr); if (rc) { QETH_CARD_TEXT(card, 2, "b2dqwerr"); + rcu_read_unlock(); return NOTIFY_BAD; } } lowerdev = netdev_next_lower_dev_rcu(brdev, &iter); } + + rcu_read_unlock(); + return NOTIFY_DONE; } @@ -901,7 +910,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", @@ -921,7 +930,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 6764fb7692e2..e27da5bd665f 100644 --- a/include/net/switchdev.h +++ b/include/net/switchdev.h @@ -191,8 +191,8 @@ struct switchdev_brport { enum switchdev_notifier_type { SWITCHDEV_FDB_ADD_TO_BRIDGE = 1, SWITCHDEV_FDB_DEL_TO_BRIDGE, - SWITCHDEV_FDB_ADD_TO_DEVICE, - SWITCHDEV_FDB_DEL_TO_DEVICE, + SWITCHDEV_FDB_ADD_TO_DEVICE, /* Blocking. */ + SWITCHDEV_FDB_DEL_TO_DEVICE, /* Blocking. */ SWITCHDEV_FDB_OFFLOADED, SWITCHDEV_FDB_FLUSH_TO_BRIDGE, @@ -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_switchdev.c b/net/bridge/br_switchdev.c index 7e62904089c8..c7c8e23c2147 100644 --- a/net/bridge/br_switchdev.c +++ b/net/bridge/br_switchdev.c @@ -140,12 +140,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; } } @@ -303,6 +301,8 @@ static int br_fdb_replay(const struct net_device *br_dev, const void *ctx, if (!nb) return 0; + ASSERT_RTNL(); + if (!netif_is_bridge_master(br_dev)) return -EINVAL; @@ -343,7 +343,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; @@ -362,7 +362,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 7bc88767db9d..6601224f6a5a 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 Fri Aug 20 11:57: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: 500900 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=unavailable 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 11171C4320A for ; Fri, 20 Aug 2021 11:58:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EE3AA6108F for ; Fri, 20 Aug 2021 11:58:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240303AbhHTL7A (ORCPT ); Fri, 20 Aug 2021 07:59:00 -0400 Received: from mail-db8eur05on2067.outbound.protection.outlook.com ([40.107.20.67]:24941 "EHLO EUR05-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239997AbhHTL6z (ORCPT ); Fri, 20 Aug 2021 07:58:55 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k8N02FXOzByW9XsVYjE240vhqhN4vrXUQt5wwsFcKqkJOg0WDVxdMP6/BQ1qUqwRW9IlPUNmmndygxXYT9wxMsGTXajFTFfpN0D0YwXCbuBaDtOGkg5a/RK195yP6JdcCYLjNjCL9YnKvPU6jXSxKpu80b+9UYDWxjiSiDR/M8H86OxqRYV/aBrdj+a3UEFSVN3cah4tD5ZIiTvp4N5btj5x9XsIoaRHmd6X9zJRCsuWYHg+Scr3TOFbP6/ifU62GGozTkWjbphlTg1EJM+hdKo5/TKeDlNR/apabWeXJ9VEiXh4GW1Oh3KKwXpQ81lJAUnYq0JfTbnQCCXLNlT/Fw== 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=4aJqu6u/UZewrkImwycUMT8plxn8G27ySqfvO+skJ0g=; b=lrO+0lYegJMz+zG+aQby6haImnD1HGvWnDAWdgpJkBmLFLDfNcz4aE416dlBl2VSQwnQ/cQAcg9OwLHMSabOjCJ/pw8jqWFL94YiJwVOAYplgRkz8Nfa6EtdL4ErZQgHG7nmKgPNGp7OFVihdWXRUPGDmY10C4/BT3SxlBlzDWlsVezXWxdRCrBMXVGj7oiuahlVv5/76eVuArtkqM3j7z00aqpQosRWlF6b1yu4M4kqeW0/yHOOvmFCSQ6JXzO9ak7Cny3RVORnl82Zq4b9XXHyJm5PlRI4uXZTxVR3lNqO9YUaKeK0eDrz7ROp7yJkAvYTk/r7ZwzRtPvHmo/3OA== 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=4aJqu6u/UZewrkImwycUMT8plxn8G27ySqfvO+skJ0g=; b=HYpdSS7lVqLP7xlFd4eROIEQYIUtKRGc1f1A2e3SsdMlpPJs3eRnyfID0AKK+ED0YKbPwDVZSCVpFqWB8tMuzI3NNHWTdCiHAlDRQDsKmwYp50DHjNsPnPaKMyuXLkt/ZHBmRlylC6WTMAnB28oa7g2E4CFyB3inNvLeO1bRYNY= 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.4436.19; Fri, 20 Aug 2021 11:58:16 +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.4436.019; Fri, 20 Aug 2021 11:58:16 +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 , Alexandra Winter , Karsten Graul , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Ivan Vecera , Vlad Buslov , Jianbo Liu , Mark Bloch , Roi Dayan , Tobias Waldekranz , Vignesh Raghavendra , Jesse Brandeburg , linux-s390@vger.kernel.org Subject: [PATCH v3 net-next 5/7] net: switchdev: drop the atomic notifier block from switchdev_bridge_port_{, un}offload Date: Fri, 20 Aug 2021 14:57:44 +0300 Message-Id: <20210820115746.3701811-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210820115746.3701811-1-vladimir.oltean@nxp.com> References: <20210820115746.3701811-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR04CA0010.eurprd04.prod.outlook.com (2603:10a6:208:122::23) 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 AM0PR04CA0010.eurprd04.prod.outlook.com (2603:10a6:208:122::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Fri, 20 Aug 2021 11:58:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 18ed7d0f-c81e-45ae-4c22-08d963d1cb13 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: QJD3ZWhm7uFpYevGD9VXz0ys4hZAv/V7oqu8hnLyq2Y1ts2f3qzV6bwXvVEeSAxR2vnUyxwae+EjuseYJE2HjbIwaDTI2ked5jhSiUpR3zNiHOMExtRCft70kkQ8hZY7UQywfvYgndLcFiOjDLybNZ3GoD5dQcm9pz4eWlYG4LlibGTjPL/vK+PUmh0c0nCoYSrResv5Y0fbGNzQ728TkQk0L1lxUSyM97WWZL6SJz6yrdi2KUw8FAok9GTbLqfkKjCQTdLhMAeu7R+ay0Zh4oInLFBZvXz+8YH6XF+POlqJqUf0RyaTvb5zLY3RrKOOw/HvYrxx/bD0aC+qOe0qzMLULhikvzw9PV80yKZ4PTJw5k1Um/WXmz0D06YPiV/NpFiz13B2YvTF/geBhW4UIr5BULjtY0dKnftuXd/1k2EXzhPICfG5L6tiKCw1iiB+om6l84wiZwHz3MjHwfDrBDJLtB0AzdHwJD+N7JHoLQExsEQ0aHNQ5t5jLv4yobvAukpPk9cmzHufYaOZEJtYvirtlRaQ9OXHd7TRxhvw6sY3h51uV6dX1zDjkijnzQPMMUAKKOdBCNqD0oIVzMtMduVU1PzER+os9MGb1Tqf4SFa6UwmObZucnNSsFyensrcxkqXOF2eBtN4Q61TJ27Ze8aqvempmVXeL0FsPbWhZdeSiXhYJy3qRzKXj1ETz5iPBJK2hyLmeh4vjv7wJc8HlQ== 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)(136003)(366004)(346002)(376002)(39860400002)(8936002)(8676002)(26005)(6506007)(6486002)(30864003)(38350700002)(38100700002)(5660300002)(66476007)(66556008)(83380400001)(1076003)(6512007)(66946007)(52116002)(7416002)(7406005)(186003)(110136005)(36756003)(54906003)(478600001)(316002)(956004)(2616005)(44832011)(6666004)(2906002)(4326008)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: znJsrbpiDzTINWTzQ6w9He0RKwe+usjuRSHHhUequmFJWdtIf2NIIJ/JTn/cAb+XNEbrHCfdvlCEaBhlNIFC9ZEEQUVcMaS4khXwWn2MwDuTbSzAF90qfcMYGjfPgcWFns2h1cACTyeJoNN38oV7PwUMuodVOMyG99nMAaCXxJS0p9sZo9EdvchjD3eBxDaMh5/NXH8ozPPCngvoboEpkUxZEB3KtwXMKvQQ7NbjVIIVN6t5RGLQKWEB/Ta7qNTmCu2hdYvrJb8kuK8w++A1kUd/ABWA+qA85zf/8H6neLAX0339s49hjxGOeSZZIuvspx8vUpTxmfVUj+TmfTuNPQVdhnBTMwu0XmaQvW1d/q7XgpsC3fdPjI0szGKjSUyvVjYmn5WzKDsgnRKTrwKuchzV4jx2WmySvV2iru9MjmCzNLXvdwa0RIUgC5dKHLPGC07Y0ORMBzoAPi1cf3wGOqXOnHcFGndkHIvrSogp19IN7cd4+NDOrjAEQA373SJ+NSYyAsJKOZ7T+8cFdDosiWLAbY9MP535oKEczHDq3SWQmU+YFOvWeeOXuNnqs9qpm5v0GVgnMELz2qFOv4Nw7xx+XfJFUt016CKpuZNxRZVL1SVEoO7X9p/f3CxMiH3DJnHhkZdJWo8vQHIQkIiYhNOBZGYdbjruPPwm430DxqFMPtXIeJDrHmA/1wc8gdKW9BO7U/Mbrtlo0ZyniF9n3JSNUgw05RVWD6GbKIUj7KpHjpEns8ax+9Dhget3I2YHrJQm+O+vaEZ26oJvl3xF653xzl/84h6oG6Or6GNzPIyPstyzLKzBEuzQ2Rx5BFq/IaZgzpO5cYd/9/S94Rix8pBkRPQ/r1xLXqDxIR/qgg3udmBGKeYnuqmWHsFQ/UJilS/ZfKe3X5/Ak2OsleJ/mhrJi6FTKHkxdJUoqSZQauyoq1rTn+RdPD0K5FXEAN+xbmO55zmMU846nwoKWd/pJylbQfwNN6mn0JTGf4XG2q2asYDONDMFaOAdM8l/j+UtEBN7nFZ3IJuUc4iwDySyGZjdNDFzocg+Mq9d9D0TWfFPMHx+rlh5PDvW8g0RtVU5n/4p+s6JJ9e6YmhKaqVYutkhUBoqxh/RE4amE5e8VKsQN0B3hosIvATTeYOUdCjMfR0PauwVHT7uhjzULiqhdMrKYULaKxYb1ZDri159ZM61D4G5/ddRj1bIALO9grTvpcfocUW66kJWocs/Tq0+DZTBxTdGzq9pzzgxvaYHwKPIGvMbFFK3DMbnsNjUzatcSAZJ14bqrLRm+iVWojScZjuyJl3O0jsvsxNDlG1R0HUyIJzjNjTQSUK3k8YJ7qkE X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18ed7d0f-c81e-45ae-4c22-08d963d1cb13 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2021 11:58:15.8508 (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: 3nlSHr22MN+hlJnMfvLp31DzrHyTuwFW0RjLl1QGposXmvA/n8yD24FcX225YfDgKRuajVZMIscjhqR7p+mrxg== 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 --- v2->v3: none 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 d0d63da7f01f..f6fec0e7590c 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 a89cda394685..5a9f26d5ddd6 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 fbaed9de3929..589563a93cf2 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 0d19f2be0895..dbc2a5560004 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 abdb4b49add1..5790180fee07 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 5570df4d9b76..f6f200b77986 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; }; @@ -265,13 +264,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); @@ -354,7 +351,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) @@ -365,7 +361,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 390c807d1c7c..0320fe816a97 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -1946,13 +1946,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); @@ -1986,7 +1984,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) @@ -1996,7 +1993,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 f2cb066e3ebb..659793fcb4ed 100644 --- a/net/bridge/br_switchdev.c +++ b/net/bridge/br_switchdev.c @@ -361,7 +361,6 @@ static int br_fdb_replay(const struct net_device *br_dev, const void *ctx, } 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) { @@ -386,7 +385,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; @@ -404,7 +402,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) @@ -420,7 +417,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; @@ -433,10 +430,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 979042a64d1a..30071da45403 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -375,7 +375,6 @@ int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br, tx_fwd_offload = dsa_port_bridge_tx_fwd_offload(dp, br); err = switchdev_bridge_port_offload(brport_dev, dev, dp, - &dsa_slave_switchdev_notifier, &dsa_slave_switchdev_blocking_notifier, tx_fwd_offload, extack); if (err) @@ -389,7 +388,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); @@ -403,7 +401,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 Fri Aug 20 11:57: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: 500899 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=unavailable 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 4748BC432BE for ; Fri, 20 Aug 2021 11:58:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3175460ED5 for ; Fri, 20 Aug 2021 11:58:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240308AbhHTL7K (ORCPT ); Fri, 20 Aug 2021 07:59:10 -0400 Received: from mail-db8eur05on2067.outbound.protection.outlook.com ([40.107.20.67]:24941 "EHLO EUR05-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240246AbhHTL7B (ORCPT ); Fri, 20 Aug 2021 07:59:01 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PK59jCD5+GOgVaEuEGjA6yAiu/Jc5G50CmMq/DjuNMxmv/apP+cCEtW7CrtzxV5ad2dW9xK11knKxRVH9L+Z8/Szw2iiv8Ye/1ShSJ70mp7mt3mr/wSFCjZdeuyyVlerzCujezlslN8ZXvEnGwlEjBOwXh3wYznyZ4z83WonCvYz9rxrLZe18dtHyCP7MqZF0OvZX3rY6uUCcOikKtudkiZHngWa2NM/eJ185Ujn6ZM3VCpYf3TnvLURaC3RU+fhiu591AvW0l0FoOHHrp9jGmBp19VkKkwVbJMOcloRyn0fhiB2IkINFqy7SSCvX/cI/smhata55CEAhyRlE+UnLA== 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=EsvhRXyjwA+2KLhO2a/FBMdoDr5VRwW5ZoPNvj6BOnw=; b=FnH4bfh9huNusL4inZXqRmWaxHefXK5KPiLiwwGTnLg+adFhnJmLuzRAnwJZVPsonsb0nsKWml3fB3vD8vC1H2aSjpknWxYEzsvkq74Nz5YiVHW5TBTtLJFFS1VpwaWM20eBgQZ8ZtNeXWHkWANpvRrUBSjKtHIN4bQytT92WnC9UpEU8kj42e9b+AA205ryRXiUeMCNYVC6VJJqQ8N8Bp5ac5x4DKOVXBzDgdSD9bAHgFuqph+ZUWQkBbFTjxGpDr/qZJKmtgPEmRQP8VUkAiqPl+sD+aByRD1Q6P/fZa4KCNLBwsl3XeLWCSYxOj5SXUUdykVCQQQKOuPDe8lBZg== 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=EsvhRXyjwA+2KLhO2a/FBMdoDr5VRwW5ZoPNvj6BOnw=; b=bfe8YUXeKLnIon9/kRcRb6M4cD2Ei2xsQRDkCdghLVmziq51us36XbVBJT+n9LN2cMF1YeixDSNhqvNjxfHKssAj9hiiOIaMzgPSPBW3cn5T3l1yKzMyqaK6QSrm2zb7p9NOM6QIHbybl6zE8KDDIBBC+l3Gm6ziq65pKHgrAlg= 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.4436.19; Fri, 20 Aug 2021 11:58:22 +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.4436.019; Fri, 20 Aug 2021 11:58:22 +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 , Alexandra Winter , Karsten Graul , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Ivan Vecera , Vlad Buslov , Jianbo Liu , Mark Bloch , Roi Dayan , Tobias Waldekranz , Vignesh Raghavendra , Jesse Brandeburg , linux-s390@vger.kernel.org Subject: [PATCH v3 net-next 7/7] net: dsa: handle SWITCHDEV_FDB_{ADD, DEL}_TO_DEVICE synchronously Date: Fri, 20 Aug 2021 14:57:46 +0300 Message-Id: <20210820115746.3701811-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210820115746.3701811-1-vladimir.oltean@nxp.com> References: <20210820115746.3701811-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR04CA0010.eurprd04.prod.outlook.com (2603:10a6:208:122::23) 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 AM0PR04CA0010.eurprd04.prod.outlook.com (2603:10a6:208:122::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Fri, 20 Aug 2021 11:58:19 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1d8a81cd-6390-4e5f-5dea-08d963d1cee4 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: rXPSq7a5OUykutD3LNQEXC6VN4o6DBwi22o9ozi2vXXQ6AqCHR/p3OaoPE570o3Wkzp6vCL5/1Y9ckhahjRpJLcVXUGeZEBml+rlCaHGa8COhZINom3en4K9BBn1fsJVi2PD4P6u1vdzNgckNghLUZNN318z8JMknYDzNCDYUap8Uwr7QNApIdZ9d+IJxkU4UR6rKkgF/T7CrICuLkF9rdQlrYceMYiKHlndK1Osb461bUKjUpx+1K17MK0EHIVHWzJ5j95NHFqYBGTe4FHyrM+eLtb+VKn7THx+QOYHcSSn9QIp4kb9kpgUmQYgvAB2bIswA8g9k8DjZJ/Esaqe3r2AY7iT7lTogtQj0+p3c8jxUOB0eeOm5zAW2YTlxbvdSJaJTiAXq2fBnRIDUT46wQipU3PQgwvOeCwU83NgAgdrTCC7meLGuVqbqzzxUp8OzCKcDKf8YGmPWy4owhfxt5az4BX1D5DLvViZdf7hJLAlf2IHKA3ieJTsHcAbXglRllkpSaJCl16dZzv01Vh6Sdtaxwzgzp/2dJ0InhQOfDUdfrxCS+S4at46DvbjiNS+/6vGEVMrf/MRSwjK+bQb0ZZrTKOrFS6lncgv98vzEA+4H2lvEnklFZ8Hmqw9fzFLprcRVWNS1chKFf/sprWEJPnt5PgrfT8l87GkYW4xuQ3Qmzcitt+Pd6xE4YUzU93klryCPHRpahBVNQokWLXQKw== 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)(136003)(366004)(346002)(376002)(39860400002)(8936002)(8676002)(26005)(6506007)(6486002)(38350700002)(38100700002)(5660300002)(66476007)(66556008)(83380400001)(1076003)(6512007)(66946007)(52116002)(7416002)(7406005)(186003)(110136005)(36756003)(54906003)(478600001)(316002)(956004)(2616005)(44832011)(6666004)(2906002)(4326008)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WSmjlx3Sm0ugfpl54esyuN/iaMq6y9x210n+syI3QvlNUt7Ea/5Ah6Fv92zvavbSbJ7UQgUGurrA3jLGXQJco/bKV+k5WShSNg68kCykozaXUfPwJVd2zY7KTgqDbwh19nRih5fr3b8AiH3X17tYpfKkyvJ6pzUX9DirNedWVjexwiZxjhQ7jtIUoXnU5WkYTyPNl3+3prQqjKDvo5pkuGzzh7mGmJRlr7c62iRxZtmnrtc83PjIRgjZABSN8Q8SFOQ4OdEX2kqG28DNCUysCL3lVOb/8uBmgOO6ZEJa9W5Ikxu8ZBtcE02GwtpWXe4JJ8eYkqni+X3HzQVqhOWN2pzzwbPljxJjKjG9Fy5XSu3lpYH+xsWqo7d/8GkNwQDlNmb5W62m/jh5GEcEzVxdNViwTBLkpvwR4UxH8xyKgvUgq3s0Zs0mIzukxmTt44N2qm8Y7oj/Gz4Ejs9pgLSjsySGHUniZTDktGTxoIxrLHPGOIWFw93VrDzMsb21vLmTTcmJMHDTArZa1mHqXnrpFWXf2ceeYalVaEUFDNcryEWTR3/69rrYbL69SsmlMrw8Q55E40iD2tYfqgwm6qGbzSmldU2OJvVeV460QE7aRe8H9wJm0WT5T7x6t0T/CEXOJBikMJVHPmA6igXVXBkwj5Ev8SC5pxwxCYoXRMfbgjxjoTRZye/1GfwQgun00DSuYrPs15kNBEmd3OhsI4YP8oCOzKwHiHEj7wQMeHyqOrw5vHqqadxijxJQdEHJo0tHXB7gscFieXqJsP6I4NgHJfKqzC0UQzgoSgC6nrIHXlFG1j91sRQXZ7/r9kEDvm4ZgwLLEEkAd+2e8dV+vaZWF65A83WtJBtuZGUMYc20+1Qh4ZwAtoSpwpBus7G+raOZliglFc3o3MnbyEPSLVwDShPj4xtp9vi+nd4K3P2qfw17vNaJ7u6Le+HBQc1Ez0SYPfb9CF6ZXohExHdxYcNVQKH5r3+Gd4hE5BmcpNEI0pnpUeMnEOaqdQB38uRxL2FLL9htPKiP2VMBfxhiWnz/1FF0SPVRiKYF8MnzIJFss9U0VHKSud/Z81/VGgMZDoJ7UYiws7MbIM+7M0R6OA95984bn4OAwMH1YSEgSPkbcYsZ7O6YMiz1STtv9PBFlzR/58xy0nmXq1IiIS94hvingY0NtcfqKhSBv5xXs3/fRRTiCBB5ceQ4c5T00jOsEpIfIaZyjZsVjIwQM25tFl93s4s9Lgw5jUOsnysGVaBp1gZCvavlW1fpHFD16MPLC7221VjbBHGCkfHDARrHcXdvMjahXCidhTjKApEi2VPUYXYrj+AcYOpKwG3LjUZd4vqI X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d8a81cd-6390-4e5f-5dea-08d963d1cee4 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2021 11:58:22.2421 (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: HbYBGjee99xRlkTYa1YNQwQHvkflYHTDJDyiW5bbR0e/bvacT0AeTSREF+ksB+ah+xDoGLMU4griOnLtZJQARw== 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 --- v2->v3: none 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 b7a269e0513f..f759abceeb18 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h @@ -125,20 +125,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; @@ -169,7 +155,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 196a0e1f4294..8507e0cd2b9e 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; - ether_addr_copy(info.addr, switchdev_work->addr); - info.vid = switchdev_work->vid; + ether_addr_copy(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