Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp2399020imc; Sat, 23 Feb 2019 02:34:48 -0800 (PST) X-Google-Smtp-Source: AHgI3IYYXo7r4Y6F0gLQHP1TxTsyItuypbNWKXIbJtYWoA9Z4olupa84+Mcnup6a5kJHWDIZgPNW X-Received: by 2002:a62:6303:: with SMTP id x3mr9009528pfb.110.1550918088692; Sat, 23 Feb 2019 02:34:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550918088; cv=none; d=google.com; s=arc-20160816; b=XFJ/9n451g87CG+Wc0YB9PINFfsPIqHhoeY8JSi5u1JK3l5+XTzFg80ubp77cLxxHW ceHTt7TmRCVU/BmFSNAtElAQ6u4jKMRVdTR8Uka3ZFYi4UAGI/k8T2FRcHzGwpLTyelF AVCfN1z2bLJtrGlBPdyjKN1P8flRM6W81dVUWloBIXQCaNXd0hDIY1qMgJkjIJxuBGKU 1X6jkky3hPBRtu9/U9IA8YiMQp1fJYheZYi8sSZfeQGOp5ETB/fM/aFinT4pT7n+mXNV 7DEPEE8ZGAsRjtHxBjWKVJ39y2Fb6VNQEv1abMBmW7tfZP0Q0hMgt6YiajCQ1hBnULI2 WtRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature; bh=LJdUX5TVkw2YUqFe6Nabrlkt7RTF8zxyqMMO3IV+3H8=; b=KD3FCzGsus6whTFNz5TI1rSj4ZCtdxtj9iiyAY3zaWntXom98CtVc465D1/N5ysodx LeR41/qFruEyFxzA8lVP+8WZ2w+o3SAUhFYKaG2TRXh7APgYqqa6kiv4F1d1D/q4VGu9 ID8vchYdW1IKKxak5cd1bt9c2hg3V8QEWkf0OrSo1VcGhB3SO2cpUH1CBXdzCNP/aG70 zCwfxkjnbwlOxc7omOCj7Zi5RYUBxhH5vZIJ2vEiPacvls/m0YTHu9L9C63K4QKJiuVV W0nu3+7m0eGlfbgwaXr3FZVrJ/p+qp+n4xIB63Muan+CNjFq0SGm6RfADThXX2ZKCzGw yXyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@Mellanox.com header.s=selector1 header.b=uIiUuimy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x2si3432039plo.360.2019.02.23.02.34.33; Sat, 23 Feb 2019 02:34:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@Mellanox.com header.s=selector1 header.b=uIiUuimy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727827AbfBWKdx (ORCPT + 99 others); Sat, 23 Feb 2019 05:33:53 -0500 Received: from mail-eopbgr150074.outbound.protection.outlook.com ([40.107.15.74]:43769 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726214AbfBWKdx (ORCPT ); Sat, 23 Feb 2019 05:33:53 -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=LJdUX5TVkw2YUqFe6Nabrlkt7RTF8zxyqMMO3IV+3H8=; b=uIiUuimyAKCDSQb+kEFdn4QUjkw0d7md9nlTH1qwHCMAKVQLHrNxjmH7wzyGMMaWzX+KqwPXQd7NHAyf5TOes39znUXhO5Zbn37uAOCZUqmiUgyslwQkOaBp3/+jFN/KthHgtHhM0a2UPgef3TlGLGQv2Doq7A6sK6Se1shfIDo= Received: from AM6PR05MB5240.eurprd05.prod.outlook.com (20.177.196.214) by AM6PR05MB4392.eurprd05.prod.outlook.com (52.135.164.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.14; Sat, 23 Feb 2019 10:33:48 +0000 Received: from AM6PR05MB5240.eurprd05.prod.outlook.com ([fe80::3542:889c:3a85:3866]) by AM6PR05MB5240.eurprd05.prod.outlook.com ([fe80::3542:889c:3a85:3866%5]) with mapi id 15.20.1643.014; Sat, 23 Feb 2019 10:33:48 +0000 From: Ido Schimmel To: Florian Fainelli CC: "netdev@vger.kernel.org" , "David S. Miller" , open list , "open list:STAGING SUBSYSTEM" , "moderated list:ETHERNET BRIDGE" , Jiri Pirko , "andrew@lunn.ch" , "vivien.didelot@gmail.com" Subject: Re: [PATCH net-next 1/8] switchdev: Add SWITCHDEV_PORT_ATTR_SET Thread-Topic: [PATCH net-next 1/8] switchdev: Add SWITCHDEV_PORT_ATTR_SET Thread-Index: AQHUywrMZ8R9SsxL80GeRl7GH2mZyaXtMFoA Date: Sat, 23 Feb 2019 10:33:48 +0000 Message-ID: <20190223103330.GB13070@splinter> References: <20190222235927.10295-1-f.fainelli@gmail.com> <20190222235927.10295-2-f.fainelli@gmail.com> In-Reply-To: <20190222235927.10295-2-f.fainelli@gmail.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM5PR0601CA0026.eurprd06.prod.outlook.com (2603:10a6:203:68::12) To AM6PR05MB5240.eurprd05.prod.outlook.com (2603:10a6:20b:64::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=idosch@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [79.176.7.115] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 41130a83-b74d-4c4f-42ea-08d6997a651b x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600110)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:AM6PR05MB4392; x-ms-traffictypediagnostic: AM6PR05MB4392: x-microsoft-exchange-diagnostics: =?us-ascii?Q?1;AM6PR05MB4392;23:+q6E+SdzDL3fUDlr4evTpfCT4rFY1huVE+mBVahER?= =?us-ascii?Q?ZTWodWmjN/F0fKRCTdUOWjHrFppj+SWTrOwZgWkSheLgwZuOZ4viFKxQAfo9?= =?us-ascii?Q?SBPUnTLrp6h846JWAGMEabPqaYhkmsJ7E70dCdbnagbO3vT/GFSejV0EWZ84?= =?us-ascii?Q?zP8MGRxJNgBAizRQTtI7Dm8BEhtsIqAasA1DUQ1fsNm5/QolodTuv5uSzizU?= =?us-ascii?Q?XgeaKuOsQVKj89DDGEHBeCRQe9PqzVHVKrLGst+0zQRmjLoTskEu8irpo2LD?= =?us-ascii?Q?MmatNQEfp4xcll1D49kKxqA1QPD6ARJdc/Tu+ifDuQ8/R4zGn60K9ri2fRx1?= =?us-ascii?Q?/1mcWp51woIXiXzDmuVuZpJnKEsfYDeyieQwnSpGC5YyUsFI6ECIHBY9lewK?= =?us-ascii?Q?JQ6ydfVs4noFdZCBTXVAHOmFjrrC2TRhedkUhtX/q19q1iQuwzXX86yTfuqK?= =?us-ascii?Q?tBDvZ2wSS+6gWdEDFM2CFKjKLdEdA9kdzDmZFJjljuGWABEJGvzy7QRtzk5I?= =?us-ascii?Q?xkQovxEm10s4gz5LbQIJdqaJjvd8f+XRm/hqrNlzsAtR1Nk8Bp44yK0k8qpi?= =?us-ascii?Q?yt30Pv6iF2T5FBUCRNgF+nv+fxoPkVVe4A3q4irPRDkFIXjdZUmc/wfoWQqb?= =?us-ascii?Q?jDnZpV8BTrTPJ5Gb7QK+iQJnXWZa877h15ZnRzNdKTdi/bGcAy0o55o6kkAJ?= =?us-ascii?Q?gmGDpanuqsIV9V09eFb2BROMHIDc+Amxjb0WL3PTVr/HZISyfETI/Hy0IlBQ?= =?us-ascii?Q?JAS86lhsgtjfYu9npHczSQd7jIRXNqR6yQS8Uhrv841YqhKBIWqgdIvdZMw2?= =?us-ascii?Q?4ss9YorPET40nNIazeBoV2opcIJL/EC79tpAYVmsw0d2Hi42nxkA4e3WqrK6?= =?us-ascii?Q?JYPLD/FgC5bl7bep42vQyn9yjeH9OxUYzckP+VwX5+23u4lq1W8MnZih9ft9?= =?us-ascii?Q?m0Wu4sEg5Vq7Bzz+18MdGpAcnMCuUu6b/QgXdlp6kSek+wKgCm5X38zpbuJJ?= =?us-ascii?Q?BEVIcnsAQK7tsPlO0TkkguuSqPnmSspx1WvM8EP0tooiXFmjyzWxsoWqRMJV?= =?us-ascii?Q?AdmZv+gg5Sa+W3fzodyYwItRTwKzS396tZ0/iPaY7KcqzdYML4tvbz3Nvoun?= =?us-ascii?Q?nDm6NLeNA3RG5YyRqUwpkphkpQNHc94QJ+7wx8wC9iPAY7amTrNdLZwo5yim?= =?us-ascii?Q?VQRGoMqhpAcyNMglkpYhCL9k9L4afRGszrsZ3EnnAO2OeRoOeyH5RtVTf5r8?= =?us-ascii?Q?J5aRR0xTb61iqJ/Im1fDtBXMNU2lu6opZc4pWngkM1+lYDwwPd0HX1VL9Hou?= =?us-ascii?B?dz09?= x-microsoft-antispam-prvs: x-forefront-prvs: 0957AD37A0 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(7916004)(346002)(376002)(136003)(396003)(39860400002)(366004)(199004)(189003)(76176011)(25786009)(316002)(99286004)(4326008)(81166006)(8676002)(66066001)(5660300002)(2906002)(486006)(8936002)(81156014)(86362001)(53936002)(6436002)(6486002)(9686003)(14454004)(6512007)(54906003)(14444005)(256004)(229853002)(52116002)(6246003)(478600001)(305945005)(33656002)(476003)(6506007)(386003)(97736004)(102836004)(33716001)(186003)(1076003)(26005)(6916009)(3846002)(7736002)(6116002)(68736007)(71200400001)(71190400001)(106356001)(446003)(11346002)(105586002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM6PR05MB4392;H:AM6PR05MB5240.eurprd05.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: I/0vQm4VUdyy+JHm+532JfrY3FBOf8ZMDt5jg104IVz/5p2HOBAxKDhY4V1dKlCUxSwLGIuFQrTDQJQ4bWqy7ijmVWJBsJkPFMkVxqJj28XHt6Joxgc+Xs/g55KeCEBZr5MS4xob41/WgU4ivGsXF8+LR2Mhp+q3Vx3mkK/Y+enQSB9cjU6E+x+BIZZIL1qiKw2H4rqP+rsiCHRSRQf/XfOswqNEiAzG0XLACD7lzYUA8at1/SfNTqMcsGowgO1EruvcFdv2Qs47Ouasz1TljI8JJBgiJMVwkNAVpqleUHQB+OkWd1qjBpqa8s6VWI3BxKFo2PxnWhyVmFc1XhIMIiMjKK6xYq2zpv8on5UUmwFx9JRFxnDIr2+TyKuAs4OzcnQC7tLaCv0O3zo4quRAezubh2AocTDafqAbEhv7i00= Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 41130a83-b74d-4c4f-42ea-08d6997a651b X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Feb 2019 10:33:47.7476 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR05MB4392 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 22, 2019 at 03:59:19PM -0800, Florian Fainelli wrote: > In preparation for allowing switchdev enabled drivers to veto specific > attribute settings from within the context of the caller, introduce a > new switchdev notifier type for port attributes. >=20 > Suggested-by: Ido Schimmel > Signed-off-by: Florian Fainelli > --- > include/net/switchdev.h | 27 +++++++++++++++++++++ > net/switchdev/switchdev.c | 51 +++++++++++++++++++++++++++++++++++++++ > 2 files changed, 78 insertions(+) >=20 > diff --git a/include/net/switchdev.h b/include/net/switchdev.h > index 45310ddf2d7e..ca56b7487540 100644 > --- a/include/net/switchdev.h > +++ b/include/net/switchdev.h > @@ -136,6 +136,7 @@ enum switchdev_notifier_type { > =20 > SWITCHDEV_PORT_OBJ_ADD, /* Blocking. */ > SWITCHDEV_PORT_OBJ_DEL, /* Blocking. */ > + SWITCHDEV_PORT_ATTR_SET, /* May be blocking . */ See my comment on 7/8. IIUC, this is always blocking, so comment needs to be changed. > =20 > SWITCHDEV_VXLAN_FDB_ADD_TO_BRIDGE, > SWITCHDEV_VXLAN_FDB_DEL_TO_BRIDGE, > @@ -164,6 +165,13 @@ struct switchdev_notifier_port_obj_info { > bool handled; > }; > =20 > +struct switchdev_notifier_port_attr_info { > + struct switchdev_notifier_info info; /* must be first */ > + const struct switchdev_attr *attr; > + struct switchdev_trans *trans; > + bool handled; > +}; > + > static inline struct net_device * > switchdev_notifier_info_to_dev(const struct switchdev_notifier_info *inf= o) > { > @@ -216,7 +224,15 @@ int switchdev_handle_port_obj_del(struct net_device = *dev, > int (*del_cb)(struct net_device *dev, > const struct switchdev_obj *obj)); > =20 > +int switchdev_handle_port_attr_set(struct net_device *dev, > + struct switchdev_notifier_port_attr_info *port_attr_info, > + bool (*check_cb)(const struct net_device *dev), > + int (*set_cb)(struct net_device *dev, > + const struct switchdev_attr *attr, > + struct switchdev_trans *trans)); > + > #define SWITCHDEV_SET_OPS(netdev, ops) ((netdev)->switchdev_ops =3D (ops= )) > + > #else > =20 > static inline void switchdev_deferred_process(void) > @@ -303,6 +319,17 @@ switchdev_handle_port_obj_del(struct net_device *dev= , > return 0; > } > =20 > +static inline int > +switchdev_handle_port_attr_set(struct net_device *dev, > + struct switchdev_notifier_port_attr_info *port_attr_info, > + bool (*check_cb)(const struct net_device *dev), > + int (*set_cb)(struct net_device *dev, > + const struct switchdev_attr *attr, > + struct switchdev_trans *trans)) > +{ > + return 0; > +} > + > #define SWITCHDEV_SET_OPS(netdev, ops) do {} while (0) > =20 > #endif > diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c > index 7e1357db33d7..94400f5b8e07 100644 > --- a/net/switchdev/switchdev.c > +++ b/net/switchdev/switchdev.c > @@ -697,3 +697,54 @@ int switchdev_handle_port_obj_del(struct net_device = *dev, > return err; > } > EXPORT_SYMBOL_GPL(switchdev_handle_port_obj_del); > + > +static int __switchdev_handle_port_attr_set(struct net_device *dev, > + struct switchdev_notifier_port_attr_info *port_attr_info, > + bool (*check_cb)(const struct net_device *dev), > + int (*set_cb)(struct net_device *dev, > + const struct switchdev_attr *attr, > + struct switchdev_trans *trans)) > +{ > + struct net_device *lower_dev; > + struct list_head *iter; > + int err =3D -EOPNOTSUPP; > + > + if (check_cb(dev)) { > + port_attr_info->handled =3D true; > + return set_cb(dev, port_attr_info->attr, > + port_attr_info->trans); > + } > + > + /* Switch ports might be stacked under e.g. a LAG. Ignore the > + * unsupported devices, another driver might be able to handle them. Bu= t > + * propagate to the callers any hard errors. > + * > + * If the driver does its own bookkeeping of stacked ports, it's not > + * necessary to go through this helper. > + */ > + netdev_for_each_lower_dev(dev, lower_dev, iter) { > + err =3D __switchdev_handle_port_attr_set(lower_dev, port_attr_info, > + check_cb, set_cb); > + if (err && err !=3D -EOPNOTSUPP) > + return err; > + } > + > + return err; > +} > + > +int switchdev_handle_port_attr_set(struct net_device *dev, > + struct switchdev_notifier_port_attr_info *port_attr_info, > + bool (*check_cb)(const struct net_device *dev), > + int (*set_cb)(struct net_device *dev, > + const struct switchdev_attr *attr, > + struct switchdev_trans *trans)) > +{ > + int err; > + > + err =3D __switchdev_handle_port_attr_set(dev, port_attr_info, check_cb, > + set_cb); > + if (err =3D=3D -EOPNOTSUPP) > + err =3D 0; > + return err; > +} > +EXPORT_SYMBOL_GPL(switchdev_handle_port_attr_set); > --=20 > 2.17.1 >=20