From patchwork Thu Nov 22 23:32:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 1002058 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="PplRIjhh"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 431G442gp9z9s0t for ; Fri, 23 Nov 2018 10:34:12 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405081AbeKWKOy (ORCPT ); Fri, 23 Nov 2018 05:14:54 -0500 Received: from mail-eopbgr00047.outbound.protection.outlook.com ([40.107.0.47]:58929 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730074AbeKWKOy (ORCPT ); Fri, 23 Nov 2018 05:14:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jtiRAGWZKVBaVUW/x5dN8mOa8EX3WWycXQYG99LUWSs=; b=PplRIjhhbmB6EuygtW5mSxoO2g2V9+v9adrzs9MR9d2fkn/Ma1oKWrXG2rhQ/+E58dD9Fp1vb/SRn4NhA4vIJw3yc/YmCCJZDYQocTeq+sO1daWC2vaw49on7bcvUVhqcUyJk45SR23hzCS18Mepm/nkfwoHR1kYStmEhbIvnrs= Received: from VI1PR05MB4191.eurprd05.prod.outlook.com (10.171.183.17) by VI1PR05MB1198.eurprd05.prod.outlook.com (10.162.15.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.21; Thu, 22 Nov 2018 23:32:58 +0000 Received: from VI1PR05MB4191.eurprd05.prod.outlook.com ([fe80::b077:5f75:8a9a:8d51]) by VI1PR05MB4191.eurprd05.prod.outlook.com ([fe80::b077:5f75:8a9a:8d51%3]) with mapi id 15.20.1339.027; Thu, 22 Nov 2018 23:32:58 +0000 From: Petr Machata To: "netdev@vger.kernel.org" , "devel@driverdev.osuosl.org" CC: Jiri Pirko , Ido Schimmel , "davem@davemloft.net" , "alexandre.belloni@bootlin.com" , "ruxandra.radulescu@nxp.com" , "ioana.ciornei@nxp.com" , "gregkh@linuxfoundation.org" , "ivecera@redhat.com" , "andrew@lunn.ch" , "vivien.didelot@savoirfairelinux.com" , "f.fainelli@gmail.com" Subject: [PATCH net-next 11/12] switchdev: Replace port obj add/del SDO with a notification Thread-Topic: [PATCH net-next 11/12] switchdev: Replace port obj add/del SDO with a notification Thread-Index: AQHUgruz9a74POM1ikajf+l6QUEekA== Date: Thu, 22 Nov 2018 23:32:57 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: CWLP265CA0314.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:57::14) To VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [37.142.13.130] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR05MB1198; 6:w4/Y5zlXwbFemLDyVvUQBJb/6Em4rVGhyp1NNziuG/cUpqRRuMzGmwVQHQ4ZPSk2NVzBRnbZeHwzb/fYizXsTubb0Rcjiz+oMQ6idl75ywtt8OWFZrm0LTunOlx7DnAQuIfhb/tjCM6d7XUgArihLcYAdqJdtYTGkJ3z9JRi71qQ2ThfbCVTnx8UFaIhCk6xl2+xx4acps+MfWSrZt3k4lpeYdC0ficjvETXmUQ1+18Xqg9ZUiou7YFj41F382HmQnGYxLXRixqbrZu7HVeFeVVZGkXiycIGzMdJqm2ddIT+CAXnJGQFa1bkmuy1LluxpTsrYCedf60HSmvTh8KUrVrduA7Az3RfBfMffWXEGD9oGhclyvppoLl83nK4Ph93vPBfnSoQcf+ZF+WErwSf1fY79N+YudO808J3OIHxa79cEXrck98EpDu0Bb1c0EFiKrhIYXy9/AHXQtkgDRonQp/rvsUDtFz2I71XrADXemA=; 5:ryyWsCiUgTXxWP3fMpTyfZIK8NeTP8y/X5cNn/SkbP+bmbQrzxr1McL0/ApFmtQguLiOIk8EuPANo1/8pB0wHTZ7cpib7vYrs2SDZnT/yvaxNZG3NVWvtN6MF6prlNQDC95NYgerqK7iTjx6tEK4kMTqVSrjKZJ+WTTXFJkhZvo=; 7:vOeOjP80aX+iEl0a6DMTtKW0K/AOe+AkVFfYkBaKa8j6d+lE4uGw6NbZbREl1kx3jdumbSOYOEtzvub6DV7h+kmHLT47Pn3SspNc3O5YmnFMVfx8TQXkhITu6ruj3D/Z2Ce2UphsineHoTrpMQK9bA== x-ms-office365-filtering-correlation-id: 332dfd62-d0b8-4ed7-34a3-08d650d2d5a3 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:VI1PR05MB1198; x-ms-traffictypediagnostic: VI1PR05MB1198: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231442)(944501410)(52105112)(93006095)(93001095)(3002001)(10201501046)(6055026)(148016)(149066)(150057)(6041310)(20161123560045)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:VI1PR05MB1198; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB1198; x-forefront-prvs: 0864A36BBF x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(366004)(39860400002)(136003)(396003)(376002)(189003)(199004)(478600001)(551934003)(486006)(305945005)(97736004)(81166006)(3846002)(110136005)(53936002)(81156014)(68736007)(5660300001)(7736002)(2616005)(6116002)(25786009)(54906003)(446003)(476003)(6486002)(11346002)(8676002)(316002)(7416002)(14444005)(99286004)(52116002)(71200400001)(2900100001)(2501003)(6512007)(36756003)(39060400002)(6506007)(4326008)(102836004)(6436002)(14454004)(76176011)(26005)(256004)(118296001)(71190400001)(2906002)(186003)(106356001)(575784001)(105586002)(66066001)(15650500001)(86362001)(386003)(8936002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB1198; H:VI1PR05MB4191.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: bRnJqKX5FNRWoOiLsD5dvtgBWsfMZX09OUttK68TJqZoEWFMiQRcd1dwmILoLypVuo/HmKTiAA8wnLroiCD6SmuypYWHXovOdcUW5/Ck1ujTcQx6Bso5w/CWdodFiEid4vJ87pnzjq9daVmRirouDqOUCWjWkFxL/ukPR/rN8n+AI+o8bqHt3GqOzJNYQ2I98ptcAKFnlP/YrhR89pDB7IWMufMsqiPsCTyGGz5gfbofC5p9jhAqmMGa8dLez0wmFE5lZBkHq3+0x1L13QMoZHGgS4zJCXiCAoVYL2kb+yhlbYFo7c4xMLU29fBpQk2voA5XRP/LhkyDNrrJ+SvmqSYgoajDunxVqrIdJoxy8sA= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 332dfd62-d0b8-4ed7-34a3-08d650d2d5a3 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Nov 2018 23:32:57.9312 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB1198 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Drop switchdev_ops.switchdev_port_obj_add and _del. Drop the uses of this field from all clients, which were migrated to use switchdev notification in the previous patches. Add a new function switchdev_port_obj_notify() that sends the switchdev notifications SWITCHDEV_PORT_OBJ_ADD and _DEL. Update switchdev_port_obj_del_now() to dispatch to this new function. Drop __switchdev_port_obj_add() and update switchdev_port_obj_add() likewise. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- .../ethernet/mellanox/mlxsw/spectrum_switchdev.c | 2 - drivers/net/ethernet/mscc/ocelot.c | 2 - drivers/net/ethernet/rocker/rocker_main.c | 2 - drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 2 - include/net/switchdev.h | 9 --- net/dsa/slave.c | 2 - net/switchdev/switchdev.c | 67 ++++++++-------------- 7 files changed, 25 insertions(+), 61 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c index 3756aaecd39c..73e5db176d7e 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c @@ -1968,8 +1968,6 @@ static struct mlxsw_sp_port *mlxsw_sp_lag_rep_port(struct mlxsw_sp *mlxsw_sp, static const struct switchdev_ops mlxsw_sp_port_switchdev_ops = { .switchdev_port_attr_get = mlxsw_sp_port_attr_get, .switchdev_port_attr_set = mlxsw_sp_port_attr_set, - .switchdev_port_obj_add = mlxsw_sp_port_obj_add, - .switchdev_port_obj_del = mlxsw_sp_port_obj_del, }; static int diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 01403b530522..7f8da8873a96 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1337,8 +1337,6 @@ static int ocelot_port_obj_del(struct net_device *dev, static const struct switchdev_ops ocelot_port_switchdev_ops = { .switchdev_port_attr_get = ocelot_port_attr_get, .switchdev_port_attr_set = ocelot_port_attr_set, - .switchdev_port_obj_add = ocelot_port_obj_add, - .switchdev_port_obj_del = ocelot_port_obj_del, }; static int ocelot_port_bridge_join(struct ocelot_port *ocelot_port, diff --git a/drivers/net/ethernet/rocker/rocker_main.c b/drivers/net/ethernet/rocker/rocker_main.c index 806ffe1d906e..f05d5c1341b6 100644 --- a/drivers/net/ethernet/rocker/rocker_main.c +++ b/drivers/net/ethernet/rocker/rocker_main.c @@ -2145,8 +2145,6 @@ static int rocker_port_obj_del(struct net_device *dev, static const struct switchdev_ops rocker_port_switchdev_ops = { .switchdev_port_attr_get = rocker_port_attr_get, .switchdev_port_attr_set = rocker_port_attr_set, - .switchdev_port_obj_add = rocker_port_obj_add, - .switchdev_port_obj_del = rocker_port_obj_del, }; struct rocker_fib_event_work { diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index 83e1d92dc7f3..06a233c7cdd3 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -930,8 +930,6 @@ static int swdev_port_obj_del(struct net_device *netdev, static const struct switchdev_ops ethsw_port_switchdev_ops = { .switchdev_port_attr_get = swdev_port_attr_get, .switchdev_port_attr_set = swdev_port_attr_set, - .switchdev_port_obj_add = swdev_port_obj_add, - .switchdev_port_obj_del = swdev_port_obj_del, }; /* For the moment, only flood setting needs to be updated */ diff --git a/include/net/switchdev.h b/include/net/switchdev.h index 6dc7de576167..866b6d148b77 100644 --- a/include/net/switchdev.h +++ b/include/net/switchdev.h @@ -121,10 +121,6 @@ typedef int switchdev_obj_dump_cb_t(struct switchdev_obj *obj); * @switchdev_port_attr_get: Get a port attribute (see switchdev_attr). * * @switchdev_port_attr_set: Set a port attribute (see switchdev_attr). - * - * @switchdev_port_obj_add: Add an object to port (see switchdev_obj_*). - * - * @switchdev_port_obj_del: Delete an object from port (see switchdev_obj_*). */ struct switchdev_ops { int (*switchdev_port_attr_get)(struct net_device *dev, @@ -132,11 +128,6 @@ struct switchdev_ops { int (*switchdev_port_attr_set)(struct net_device *dev, const struct switchdev_attr *attr, struct switchdev_trans *trans); - int (*switchdev_port_obj_add)(struct net_device *dev, - const struct switchdev_obj *obj, - struct switchdev_trans *trans); - int (*switchdev_port_obj_del)(struct net_device *dev, - const struct switchdev_obj *obj); }; enum switchdev_notifier_type { diff --git a/net/dsa/slave.c b/net/dsa/slave.c index d00a0b6d4ce0..268119cf7117 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1050,8 +1050,6 @@ static const struct net_device_ops dsa_slave_netdev_ops = { static const struct switchdev_ops dsa_slave_switchdev_ops = { .switchdev_port_attr_get = dsa_slave_port_attr_get, .switchdev_port_attr_set = dsa_slave_port_attr_set, - .switchdev_port_obj_add = dsa_slave_port_obj_add, - .switchdev_port_obj_del = dsa_slave_port_obj_del, }; static struct device_type dsa_type = { diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c index 099434ec7996..fe23fac4dc4b 100644 --- a/net/switchdev/switchdev.c +++ b/net/switchdev/switchdev.c @@ -353,30 +353,29 @@ static size_t switchdev_obj_size(const struct switchdev_obj *obj) return 0; } -static int __switchdev_port_obj_add(struct net_device *dev, - const struct switchdev_obj *obj, - struct switchdev_trans *trans) +static int switchdev_port_obj_notify(enum switchdev_notifier_type nt, + struct net_device *dev, + const struct switchdev_obj *obj, + struct switchdev_trans *trans) { - const struct switchdev_ops *ops = dev->switchdev_ops; - struct net_device *lower_dev; - struct list_head *iter; - int err = -EOPNOTSUPP; - - if (ops && ops->switchdev_port_obj_add) - return ops->switchdev_port_obj_add(dev, obj, trans); + int rc; + int err; - /* Switch device port(s) may be stacked under - * bond/team/vlan dev, so recurse down to add object on - * each port. - */ + struct switchdev_notifier_port_obj_info obj_info = { + .obj = obj, + .trans = trans, + .handled = false, + }; - netdev_for_each_lower_dev(dev, lower_dev, iter) { - err = __switchdev_port_obj_add(lower_dev, obj, trans); - if (err) - break; + rc = call_switchdev_blocking_notifiers(nt, dev, &obj_info.info); + err = notifier_to_errno(rc); + if (err) { + WARN_ON(!obj_info.handled); + return err; } - - return err; + if (!obj_info.handled) + return -EOPNOTSUPP; + return 0; } static int switchdev_port_obj_add_now(struct net_device *dev, @@ -397,7 +396,8 @@ static int switchdev_port_obj_add_now(struct net_device *dev, */ trans.ph_prepare = true; - err = __switchdev_port_obj_add(dev, obj, &trans); + err = switchdev_port_obj_notify(SWITCHDEV_PORT_OBJ_ADD, + dev, obj, &trans); if (err) { /* Prepare phase failed: abort the transaction. Any * resources reserved in the prepare phase are @@ -416,7 +416,8 @@ static int switchdev_port_obj_add_now(struct net_device *dev, */ trans.ph_prepare = false; - err = __switchdev_port_obj_add(dev, obj, &trans); + err = switchdev_port_obj_notify(SWITCHDEV_PORT_OBJ_ADD, + dev, obj, &trans); WARN(err, "%s: Commit of object (id=%d) failed.\n", dev->name, obj->id); switchdev_trans_items_warn_destroy(dev, &trans); @@ -471,26 +472,8 @@ EXPORT_SYMBOL_GPL(switchdev_port_obj_add); static int switchdev_port_obj_del_now(struct net_device *dev, const struct switchdev_obj *obj) { - const struct switchdev_ops *ops = dev->switchdev_ops; - struct net_device *lower_dev; - struct list_head *iter; - int err = -EOPNOTSUPP; - - if (ops && ops->switchdev_port_obj_del) - return ops->switchdev_port_obj_del(dev, obj); - - /* Switch device port(s) may be stacked under - * bond/team/vlan dev, so recurse down to delete object on - * each port. - */ - - netdev_for_each_lower_dev(dev, lower_dev, iter) { - err = switchdev_port_obj_del_now(lower_dev, obj); - if (err) - break; - } - - return err; + return switchdev_port_obj_notify(SWITCHDEV_PORT_OBJ_DEL, + dev, obj, NULL); } static void switchdev_port_obj_del_deferred(struct net_device *dev,