From patchwork Thu Nov 22 23:28:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 1002048 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="qX4jWYZ4"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 431Fy42Rfbz9s0t for ; Fri, 23 Nov 2018 10:29:00 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439100AbeKWKKl (ORCPT ); Fri, 23 Nov 2018 05:10:41 -0500 Received: from mail-eopbgr130087.outbound.protection.outlook.com ([40.107.13.87]:34336 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726200AbeKWKKk (ORCPT ); Fri, 23 Nov 2018 05:10:40 -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=lOHpHO5tXNQnE3OVSehoRPxnaCiGibyu9W17SqXK/sA=; b=qX4jWYZ4TM3BDGAtS8jjEvkfN7ru7qtKp2mWmFIz91cBz7f0ONcNArLeuYs+pL9CYZ3DP7ideGcTtmbXtbN4Ih05jpSDJsj02HWEBo4PJnf/LG9GDaU2H+7eUjUQi/6jaBfIYt+WRUe6kBsymrTPHinF1Sp0jhmrdLMsajgPGsw= Received: from VI1PR05MB4191.eurprd05.prod.outlook.com (10.171.183.17) by VI1PR05MB4494.eurprd05.prod.outlook.com (52.133.13.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.23; Thu, 22 Nov 2018 23:28:07 +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:28:07 +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 01/12] switchdev: SWITCHDEV_OBJ_PORT_{VLAN, MDB}(): Sanitize Thread-Topic: [PATCH net-next 01/12] switchdev: SWITCHDEV_OBJ_PORT_{VLAN, MDB}(): Sanitize Thread-Index: AQHUgrsGFaL6Rk0Chk+k8KGolIYH0w== Date: Thu, 22 Nov 2018 23:28:07 +0000 Message-ID: <43fe6eadb8be98a68cee20a415aede08e1147acf.1542927590.git.petrm@mellanox.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: CWLP265CA0104.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:51::20) 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; VI1PR05MB4494; 6:nQ/H5+9zLACOm8OJFgPFLMDma58Qfq5eKd8T3pAfoy+6CMeEzs8DzSNKiYrdGcmAved92+nsdZpMGEkJOYK+DlM7y2OC3sEZySxPWj73PG689X98fiLyRO6UZq3gnmMeTYR1zKDapja3+n5AuTn26Jaw0K9YJfNJFU+X5yWEAhd8nymf/KX0eGhVJ7hOwKZzZo6uSikme3/PkKl+ihsrOOF8teeiFuG+wzIuiF+ZeQt/OWizhI6GbOXrKnRtgQi2hWm88JJcuLWJfxatC/tFuO9pJjXloABMCDVZUMgAbWPVgiMo8f9P4YH+CbpCiydtrQNcaqc8aHpH16xl925W5kln4sKjI5OtSw6mvJ/k6uPKSWEKEFEmcGq+NjkHnHptGfNMoG0Zk2Da/o0XbUXXHVGc2dErlP+8SLjjQYPMyOorMbACx9xMcsaA0I6qXs8YlwdswZyi5qmFFaMUILKVwg==; 5:ExRlOyOQmBhxhvobeQkQdzKi7O65KYlSq2P2a25XPgpaYnyCpRAjzrC+jsx5aaQu/AysHzdvNJArdnDh8y1ptmP2sQBCq2nIJ+ww+neR2dCxgwhHDXKwM8wFju5pVG/VaenHEjv9ST8zAC4UF3YUPkVojvbSApKm6gwSCCBiaUg=; 7:1xzRtoS2/RHd3Z9Xb8k8MtgNfe1d4IhyBsRQcwcp7Q7bswLi/F3aTQk7s4GawCOHqldcO8ElTGJjmmx0WBjdHsZ0vOTNaqFAheYXPQ3qvssGoZ/i4V0zEarob4GYLjkkC5v+dHiWRE8bSFJFyYPqKw== x-ms-office365-filtering-correlation-id: 9085c072-0d2e-45f1-6b9c-08d650d22864 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:VI1PR05MB4494; x-ms-traffictypediagnostic: VI1PR05MB4494: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231442)(944501410)(52105112)(3002001)(10201501046)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(20161123564045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:VI1PR05MB4494; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB4494; x-forefront-prvs: 0864A36BBF x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(366004)(396003)(346002)(39860400002)(376002)(199004)(189003)(305945005)(7736002)(39060400002)(4326008)(478600001)(25786009)(2906002)(97736004)(118296001)(316002)(2900100001)(66066001)(68736007)(3846002)(6116002)(7416002)(14454004)(54906003)(110136005)(2501003)(81156014)(8936002)(186003)(102836004)(476003)(71190400001)(71200400001)(6436002)(6506007)(386003)(26005)(105586002)(86362001)(36756003)(256004)(11346002)(2616005)(8676002)(106356001)(446003)(14444005)(81166006)(52116002)(6512007)(76176011)(5660300001)(53936002)(6486002)(486006)(99286004); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB4494; H:VI1PR05MB4191.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-microsoft-antispam-message-info: lZL8qXq7n1A/TnyTXOhDfbWl7jw7YwTNcSb1EHf8teMLti8V8jzF6grnO+EKVVLBFpvCngednbQFDw1Ji1T3jiU2Ozo59nVa6nmMIZAdn21jM3B5DNlPuMR4jNnv6DfQ1j4IbuOKsR+su+6VqCYSWWXeJgu4dZH0BaZY0BFAsZIhxQK/VA3HRweFBmdS82hzQsuYgiWQRDHvr6sXd/AgJ1zngVbC5Ibd1zGj8IclumLVzsjmNgW3ZACvMoVxBA94jDR3gcodLWHjUPCxvi2KOESnp/L/baAeeLiR5YyEI9koNovghZmfBLZKsQ0bUFb87rRVNddWCmAXzF5dBO71qPJ6hDHFyfl5D+6imOoqd/0= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9085c072-0d2e-45f1-6b9c-08d650d22864 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Nov 2018 23:28:07.3099 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4494 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The two macros SWITCHDEV_OBJ_PORT_VLAN() and SWITCHDEV_OBJ_PORT_MDB() expand to a container_of() call, yielding an appropriate container of their sole argument. However, due to a name collision, the first argument, i.e. the contained object pointer, is not the only one to get expanded. The third argument, which is a structure member name, and should be kept literal, gets expanded as well. The only safe way to use these two macros is therefore to name the local variable passed to them "obj". To fix this, rename the sole argument of the two macros from "obj" (which collides with the member name) to "OBJ". Additionally, instead of passing "OBJ" to container_of() verbatim, parenthesize it, so that a comma in the passed-in expression doesn't pollute the container_of() invocation. Signed-off-by: Petr Machata Acked-by: Jiri Pirko Reviewed-by: Ido Schimmel --- include/net/switchdev.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/net/switchdev.h b/include/net/switchdev.h index 7b371e7c4bc6..dd969224a9b9 100644 --- a/include/net/switchdev.h +++ b/include/net/switchdev.h @@ -95,8 +95,8 @@ struct switchdev_obj_port_vlan { u16 vid_end; }; -#define SWITCHDEV_OBJ_PORT_VLAN(obj) \ - container_of(obj, struct switchdev_obj_port_vlan, obj) +#define SWITCHDEV_OBJ_PORT_VLAN(OBJ) \ + container_of((OBJ), struct switchdev_obj_port_vlan, obj) /* SWITCHDEV_OBJ_ID_PORT_MDB */ struct switchdev_obj_port_mdb { @@ -105,8 +105,8 @@ struct switchdev_obj_port_mdb { u16 vid; }; -#define SWITCHDEV_OBJ_PORT_MDB(obj) \ - container_of(obj, struct switchdev_obj_port_mdb, obj) +#define SWITCHDEV_OBJ_PORT_MDB(OBJ) \ + container_of((OBJ), struct switchdev_obj_port_mdb, obj) void switchdev_trans_item_enqueue(struct switchdev_trans *trans, void *data, void (*destructor)(void const *), From patchwork Thu Nov 22 23:28:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 1002049 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="D2Yz9Pog"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 431Fy51tr6z9s3q for ; Fri, 23 Nov 2018 10:29:01 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439105AbeKWKKm (ORCPT ); Fri, 23 Nov 2018 05:10:42 -0500 Received: from mail-eopbgr40084.outbound.protection.outlook.com ([40.107.4.84]:13662 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2439035AbeKWKKl (ORCPT ); Fri, 23 Nov 2018 05:10:41 -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=5bdypcnRaUOYB2e3mst5JyleeefSmLaECsowPGwkziY=; b=D2Yz9PogVZnE+IwxShWvXe6SNSPIROTE7HVwWD2NoBohhPkbQfbP5KRJKg+knhCJTg6v8CEAaQa/6GAbhK/Ttnf7NS2yKq7UOA/uIIBv+aUCJyNcLf0P+HZoBXf6aTyE+4wZGpImkkdVoF3uNk66zRlvwCGOLhlR1zP5xMOi9iE= Received: from VI1PR05MB4191.eurprd05.prod.outlook.com (10.171.183.17) by VI1PR05MB4494.eurprd05.prod.outlook.com (52.133.13.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.23; Thu, 22 Nov 2018 23:28:25 +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:28:25 +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 02/12] switchdev: Add a blocking notifier chain Thread-Topic: [PATCH net-next 02/12] switchdev: Add a blocking notifier chain Thread-Index: AQHUgrsQRiyNppz1nEm6ku08AzOa3A== Date: Thu, 22 Nov 2018 23:28:25 +0000 Message-ID: <1bcd3a8b796807c7385252fdf7e36e48aeb5256d.1542927590.git.petrm@mellanox.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: CWLP123CA0094.GBRP123.PROD.OUTLOOK.COM (2603:10a6:401:5b::34) 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; VI1PR05MB4494; 6:azcg9UOBFuQxPvTF6vl7Eqd7jjDk8SWq0+yIQeEejOqMj728jvVGgWMe3yROD/42OvKPYB+TyDEtI4smUusG6Minsv8rhKX41QHgWDtS+aDIJCSsSVl8yLv92tPhODdDAzOzQGLLrkEB3ILd7F436m2ipbfo3SmQ/JiJS1KTD49shCrPQRi/pEbZR4Ff5aTH5U9n12uKvcd43wJZKD3QoIALNwrCtQHJRTjRft8apBzdCsOsMRk50gWuLRBOHA8D8lUjWSfGafGGUtTMfahXjm/93bnsoKoiEJ3UlUQxLuxAcMJHkjyktkOCV2iE5fP2nrdRKTlwWE43Z9rIx/HjIxl9+3MYY7/5yLJooyKAQQbeUjut9cBIsQQIMMKG+X0a7hy2cRm52PT0t3bm8Bh8g/t5Dj4C6/bHCGasLuVOl3fO4aw1f5egPmXzaDTmSWa+dh2/pXlTpRfDlpeKsF3K3Q==; 5:+h6Tgv+JNOnRxVSOw1jY7iIZl0Z4+wZXXrodgybXBjC6yJmFliesoJPP8Q10oGKUUzyHYwwjLb1Bq+VMERtCwoHC+cljt6+0u0gpnc2TrDrOxfqfMyEeFBpz8NnYbyULalbQiDeYCSghFU2rEbl0IkSIsk13HMaQ+0imZ3Vr+dw=; 7:1dMaRSF+jU60KnJt/58BzFhCQpUJqn2CiKVQDhFzjdLa0uGIlhhVrvBlrh9ty73V8dbRJQ8EK1Q6Q9ZWgcGu2Wk+Q4+/HAXxssRMdkiSc4A5qNmINfW6apm/Rfxf8my4kl0nlImbeQNW8v8BV7JZeg== x-ms-office365-filtering-correlation-id: 430913ff-0061-4f54-6521-08d650d232fb 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:VI1PR05MB4494; x-ms-traffictypediagnostic: VI1PR05MB4494: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231442)(944501410)(52105112)(3002001)(10201501046)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(20161123564045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:VI1PR05MB4494; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB4494; x-forefront-prvs: 0864A36BBF x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(366004)(396003)(346002)(39860400002)(376002)(199004)(189003)(305945005)(7736002)(39060400002)(4326008)(478600001)(25786009)(2906002)(97736004)(118296001)(316002)(2900100001)(66066001)(68736007)(3846002)(6116002)(7416002)(14454004)(54906003)(110136005)(2501003)(81156014)(8936002)(186003)(102836004)(476003)(71190400001)(71200400001)(6436002)(6506007)(386003)(26005)(105586002)(86362001)(36756003)(256004)(11346002)(2616005)(8676002)(106356001)(446003)(14444005)(81166006)(52116002)(6512007)(76176011)(5660300001)(53936002)(6486002)(486006)(99286004); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB4494; H:VI1PR05MB4191.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-microsoft-antispam-message-info: k3xp8zmU631VpAw/ZJBqUjydCgGS2SQM1K9Co/jgSz9/9Sxds1UqhU2HuSRYtUH9gNwZR1nKaMDctv2dxwo2fou0rvaBZONO/Zn6D1uG3sMedJ2pbW8wrnZYxBlc+8IW0CEpbqXd9niZpWFvo/rDtMSgZII4GApbMjRyLwRTPdLfdXNd18rPiSCy3VOBs8kBRxdED6vxcJJtRnvpd5dfBwPvdjuOUutstXffoBJxDPUhtuUyrFoLx8k66TdprgHm/xIOo+UH7p8WOdk84nRu7ot32lHQP8dG1XDQZbv/OiYPI9yP+DrayiG8tbtpjl0Q1++nGR3lFJo4TO3vgrPiyS3NR7AwqxPf93w5xDjfOK4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 430913ff-0061-4f54-6521-08d650d232fb X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Nov 2018 23:28:25.1086 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4494 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In general one can't assume that a switchdev notifier is called in a non-atomic context, and correspondingly, the switchdev notifier chain is an atomic one. However, port object addition and deletion messages are delivered from a process context. Even the MDB addition messages, whose delivery is scheduled from atomic context, are queued and the delivery itself takes place in blocking context. For VLAN messages in particular, keeping the blocking nature is important for error reporting. Therefore introduce a blocking notifier chain and related service functions to distribute the notifications for which a blocking context can be assumed. Signed-off-by: Petr Machata Reviewed-by: Jiri Pirko Reviewed-by: Ido Schimmel --- include/net/switchdev.h | 27 +++++++++++++++++++++++++++ net/switchdev/switchdev.c | 26 ++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/include/net/switchdev.h b/include/net/switchdev.h index dd969224a9b9..e021b67b9b32 100644 --- a/include/net/switchdev.h +++ b/include/net/switchdev.h @@ -182,10 +182,17 @@ int switchdev_port_obj_add(struct net_device *dev, const struct switchdev_obj *obj); int switchdev_port_obj_del(struct net_device *dev, const struct switchdev_obj *obj); + 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, struct switchdev_notifier_info *info); + +int register_switchdev_blocking_notifier(struct notifier_block *nb); +int unregister_switchdev_blocking_notifier(struct notifier_block *nb); +int call_switchdev_blocking_notifiers(unsigned long val, struct net_device *dev, + struct switchdev_notifier_info *info); + void switchdev_port_fwd_mark_set(struct net_device *dev, struct net_device *group_dev, bool joining); @@ -241,6 +248,26 @@ static inline int call_switchdev_notifiers(unsigned long val, return NOTIFY_DONE; } +static inline int +register_switchdev_blocking_notifier(struct notifier_block *nb) +{ + return 0; +} + +static inline int +unregister_switchdev_blocking_notifier(struct notifier_block *nb) +{ + return 0; +} + +static inline int +call_switchdev_blocking_notifiers(unsigned long val, + struct net_device *dev, + struct switchdev_notifier_info *info) +{ + return NOTIFY_DONE; +} + static inline bool switchdev_port_same_parent_id(struct net_device *a, struct net_device *b) { diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c index 74b9d916a58b..e109bb97ce3f 100644 --- a/net/switchdev/switchdev.c +++ b/net/switchdev/switchdev.c @@ -535,6 +535,7 @@ int switchdev_port_obj_del(struct net_device *dev, EXPORT_SYMBOL_GPL(switchdev_port_obj_del); static ATOMIC_NOTIFIER_HEAD(switchdev_notif_chain); +static BLOCKING_NOTIFIER_HEAD(switchdev_blocking_notif_chain); /** * register_switchdev_notifier - Register notifier @@ -576,6 +577,31 @@ int call_switchdev_notifiers(unsigned long val, struct net_device *dev, } EXPORT_SYMBOL_GPL(call_switchdev_notifiers); +int register_switchdev_blocking_notifier(struct notifier_block *nb) +{ + struct blocking_notifier_head *chain = &switchdev_blocking_notif_chain; + + return blocking_notifier_chain_register(chain, nb); +} +EXPORT_SYMBOL_GPL(register_switchdev_blocking_notifier); + +int unregister_switchdev_blocking_notifier(struct notifier_block *nb) +{ + struct blocking_notifier_head *chain = &switchdev_blocking_notif_chain; + + return blocking_notifier_chain_unregister(chain, nb); +} +EXPORT_SYMBOL_GPL(unregister_switchdev_blocking_notifier); + +int call_switchdev_blocking_notifiers(unsigned long val, struct net_device *dev, + struct switchdev_notifier_info *info) +{ + info->dev = dev; + return blocking_notifier_call_chain(&switchdev_blocking_notif_chain, + val, info); +} +EXPORT_SYMBOL_GPL(call_switchdev_blocking_notifiers); + bool switchdev_port_same_parent_id(struct net_device *a, struct net_device *b) { From patchwork Thu Nov 22 23:28:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 1002050 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="lu39QnG7"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 431Fy70ZTTz9s47 for ; Fri, 23 Nov 2018 10:29:03 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439115AbeKWKKo (ORCPT ); Fri, 23 Nov 2018 05:10:44 -0500 Received: from mail-eopbgr130087.outbound.protection.outlook.com ([40.107.13.87]:34336 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2439095AbeKWKKn (ORCPT ); Fri, 23 Nov 2018 05:10:43 -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=T6bwJ6MU1PaSlUmaZbOxMmgALf0vwxUPQGl9rfHenNA=; b=lu39QnG7Mlw146CFWXFGM5HlVPFefN0DjRnCEdl4JsSIaNspXPmSuIgaykY1+XxrbH+g9Z89N8yYfxmAr6HsNrMCR3J0Jq1XL/SY3ammf0NwYu0Wjc/OSeqeHpK1VfLBSogSt0tLrNXKWuzcXY1oUJUvPj3PyZza48Y5tOK/fTU= Received: from VI1PR05MB4191.eurprd05.prod.outlook.com (10.171.183.17) by VI1PR05MB4494.eurprd05.prod.outlook.com (52.133.13.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.23; Thu, 22 Nov 2018 23:28:38 +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:28:38 +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 03/12] switchdev: Add SWITCHDEV_PORT_OBJ_ADD, SWITCHDEV_PORT_OBJ_DEL Thread-Topic: [PATCH net-next 03/12] switchdev: Add SWITCHDEV_PORT_OBJ_ADD, SWITCHDEV_PORT_OBJ_DEL Thread-Index: AQHUgrsYsfU3FfsK9UeV7bq34+/03Q== Date: Thu, 22 Nov 2018 23:28:38 +0000 Message-ID: <757794c93c686a2733ff2007b68f0e61524f5d7e.1542927590.git.petrm@mellanox.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: CWLP123CA0089.GBRP123.PROD.OUTLOOK.COM (2603:10a6:401:5b::29) 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; VI1PR05MB4494; 6:9rBbNshZ1Jw+pcYABvFKgqbUBgbxhhn615HEwMs5wT/r2wQaHC4tnYH9sn21wtHe42jUoC5sG7WzdMQ8UznbsWbEz4rHu3Nz688FJWvlGLNnADR17IxOB8lPKq3hklX5N1NfdFwVlIFT5o9+32rqM3Lw3Kp7A+kEkTvAClZ7bZVdfQtETTHF+HGTZZ8gAYNu4ienOVXFmuJBFTTLUrHbOXxeNqUw1fV7ojV8ycsbWm+96JmP9GNr1CKMpNoIJKduWPPJ26s5Qg3wBn0jS+tSDZZ7r7Id4Foix1Gql2MbT1StfQqyo86rgTHbCDsJAECYjSUeTDBCwwWsMA37hAmAsSF1fTYrFATDIypOaEuStPRed6TXHJ2v7Xt6wlTfpPIKTHOYMLY3EFhVUMnl94XW3TmULxW/nBzX9w9h2yJ3SIgDwHL49LYIG/9w5b8Goa7a3JM2qEqj/nWvXpBRBiaU5Q==; 5:/bo/8vFAhnNbRL4txoJ+xtHDUbepNHZ7uViF3n8pSqjlGi4vuK4NM62IXepJuWE4Vli1J0cKqWmsgTr2Kh9V7CFzhf0/OVLXGFTGODid5OvCNMFmPQ7Bf71Mu2j3eeBYvnTCm0iPOrXNh9VIoYWi0GGJh+BovA0itDKVMUH4RuU=; 7:cB7ae0XAAuk1qt2zzrI0NX/QzO/Lw+0pRxNbqSaSzdupkHa3wv+skcWd3l0z32tPCEiUW/oCeP/wOsEQENsT6BafTkmYwBJRqjc/vbmrk4FIdZu5F2CiGuW/ajYZhpcysF0NQgQzaeTqOcHRWaA7hQ== x-ms-office365-filtering-correlation-id: 5d53236d-ca9c-49c4-e2c2-08d650d23b1b 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:VI1PR05MB4494; x-ms-traffictypediagnostic: VI1PR05MB4494: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231442)(944501410)(52105112)(3002001)(10201501046)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(20161123564045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:VI1PR05MB4494; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB4494; x-forefront-prvs: 0864A36BBF x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(366004)(396003)(346002)(39860400002)(376002)(199004)(189003)(305945005)(7736002)(39060400002)(4326008)(478600001)(25786009)(2906002)(97736004)(118296001)(316002)(2900100001)(66066001)(68736007)(3846002)(6116002)(7416002)(14454004)(54906003)(110136005)(2501003)(81156014)(8936002)(186003)(102836004)(476003)(71190400001)(71200400001)(6436002)(6506007)(386003)(26005)(105586002)(86362001)(36756003)(256004)(11346002)(2616005)(8676002)(106356001)(5024004)(446003)(14444005)(81166006)(52116002)(6512007)(76176011)(5660300001)(53936002)(6486002)(486006)(99286004); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB4494; H:VI1PR05MB4191.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-microsoft-antispam-message-info: ebdKV0vJZCXzv68jBAQXo8hhiSpjBdNWXFGlXDnbbfujCRUXztLhPfYWwqip/xzz91oED8LuH8RvYsMdEysA6Gs42pTXPkiWRA9Wp4F8DrAw0cKsVDAFPTlRrf+Yg746oop2E0GoZDSZhDMtUPV+0S40cJzRuxNPgYt7t/AuRwO6ZE+J1aH/duIhL3gpITxI6BxOfb2fJDv0wFzJxfToN11KvddozhCNOm8hxP6iq7A2MsnnswkIDbiZKRJW8gbi/QcjwdcM+VFXPI5r+Iv2oFYK3+/v9Mu7cgSgc7EEUrAaxgZCGi8si6N92i3/ojXhC+7Aif8/y05+0ATUksX3KY2t0cH3I/2meS1y+WqGhJk= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d53236d-ca9c-49c4-e2c2-08d650d23b1b X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Nov 2018 23:28:38.7013 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4494 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org An offloading driver may need to have access to switchdev events on ports that aren't directly under its control. An example is a VXLAN port attached to a bridge offloaded by a driver. The driver needs to know about VLANs configured on the VXLAN device. However the VXLAN device isn't stashed between the bridge and a front-panel-port device (such as is the case e.g. for LAG devices), so the usual switchdev ops don't reach the driver. VXLAN is likely not the only device type like this: in theory any L2 tunnel device that needs offloading will prompt requirement of this sort. This falsifies the assumption that only the lower devices of a front panel port need to be notified to achieve flawless offloading. A way to fix this is to give up the notion of port object addition / deletion as a switchdev operation, which assumes somewhat tight coupling between the message producer and consumer. And instead send the message over a notifier chain. To that end, introduce two new switchdev notifier types, SWITCHDEV_PORT_OBJ_ADD and SWITCHDEV_PORT_OBJ_DEL. These notifier types communicate the same event as the corresponding switchdev op, except in a form of a notification. struct switchdev_notifier_port_obj_info was added to carry the fields that the switchdev op carries. An additional field, handled, will be used to communicate back to switchdev that the event has reached an interested party, which will be important for the two-phase commit. The two switchdev operations themselves are kept in place. Following patches first convert individual clients to the notifier protocol, and only then are the operations removed. Signed-off-by: Petr Machata Acked-by: Jiri Pirko Reviewed-by: Ido Schimmel --- include/net/switchdev.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/net/switchdev.h b/include/net/switchdev.h index e021b67b9b32..a2f3ebf39301 100644 --- a/include/net/switchdev.h +++ b/include/net/switchdev.h @@ -146,6 +146,9 @@ enum switchdev_notifier_type { SWITCHDEV_FDB_DEL_TO_DEVICE, SWITCHDEV_FDB_OFFLOADED, + SWITCHDEV_PORT_OBJ_ADD, /* Blocking. */ + SWITCHDEV_PORT_OBJ_DEL, /* Blocking. */ + SWITCHDEV_VXLAN_FDB_ADD_TO_BRIDGE, SWITCHDEV_VXLAN_FDB_DEL_TO_BRIDGE, SWITCHDEV_VXLAN_FDB_ADD_TO_DEVICE, @@ -165,6 +168,13 @@ struct switchdev_notifier_fdb_info { offloaded:1; }; +struct switchdev_notifier_port_obj_info { + struct switchdev_notifier_info info; /* must be first */ + const struct switchdev_obj *obj; + struct switchdev_trans *trans; + bool handled; +}; + static inline struct net_device * switchdev_notifier_info_to_dev(const struct switchdev_notifier_info *info) { From patchwork Thu Nov 22 23:28:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 1002051 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="d+ZcG6bL"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 431Fy90yHZz9s3C for ; Fri, 23 Nov 2018 10:29:05 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439110AbeKWKKo (ORCPT ); Fri, 23 Nov 2018 05:10:44 -0500 Received: from mail-eopbgr40084.outbound.protection.outlook.com ([40.107.4.84]:13662 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726200AbeKWKKn (ORCPT ); Fri, 23 Nov 2018 05:10:43 -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=Xq7/sp/FWYjd+YOqm8Sc4550Pyt57nmuS+ve+0MB1lE=; b=d+ZcG6bLn8qx4Su1dqfJfUUYVLgZ/zh62ThhfiEfDPiPAwbUGu4833qSd6vvT+CUQhJlkwRZkxPj3tkILiDU1Ukrax1OuudUS5aZPvLPtYHdNvZkb39ZIMgKOUOjSrjaFb1Nn1BK487703S7Zy55WbRtpD6xyzG7kKpXf8ZMAyk= Received: from VI1PR05MB4191.eurprd05.prod.outlook.com (10.171.183.17) by VI1PR05MB4494.eurprd05.prod.outlook.com (52.133.13.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.23; Thu, 22 Nov 2018 23:28:52 +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:28:52 +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 04/12] rocker: Handle SWITCHDEV_PORT_OBJ_ADD/_DEL Thread-Topic: [PATCH net-next 04/12] rocker: Handle SWITCHDEV_PORT_OBJ_ADD/_DEL Thread-Index: AQHUgrsgdndYoGMKJ069JxyhIcQ/Tw== Date: Thu, 22 Nov 2018 23:28:51 +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: CWLP123CA0085.GBRP123.PROD.OUTLOOK.COM (2603:10a6:401:5b::25) 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; VI1PR05MB4494; 6:UF/tKCHdj+rkoH0qnCfDsH01h1GUndeftIskRzQ/qW05vVvPIgSL+eRjPF5dhH26EYAo+sPSdFTuGqmvbDW1/W8CvQ+OCUebNFEYOZC7s4MlaJNtHHohsROkXcqf9uvI1/4GCMSVNXzcekC4dDJYFhSK40+f9+9leFZBYJ0Z3R6fdyP4eRkJO2u17cW9qN8lTqovfvZp/eGERPIee5LC6x3eeYEmk5zOp5xYqOltYs9G+BPgXBf2UMllAdTkWYpFMOhmoNdebiMYc6zicqDfbqyC+Wl0RWGrqP+ehpEdOXTaek7DLZaJv9qtoHAnGN7o8AOwhKrtenJo7maJMZpZXiVx4CX+FIOuXvDrFyz+tpQ4FX32j93v/2fO/jO87aEzG0X+1IQ8TV5Q+yAgyiNFhu0jifLUMyJyafQCFFsL+3MhvzoB1fnahZWTbUfjLXING3KHFejZKisrqQmSynR0DA==; 5:KaMnpLEJ2gt8870WDlgOEaQH9XFdCo9zJdu6t5PrlfrKKHsJecjn5JsOyLPnpbcABYZKxftf7pyOU+mltakcDv2eHzEjVcxqFiS33gWRrG5wBqRrDkif5ArxlmUGgZi0+b8E6a+WWZPcoK0lZ+realmDF13fDKdOmIoFFaZPUBQ=; 7:58sEi8ZOvV1KbYwLHtpMZ2hn4BdIS4hbkzzLdmbYQFAzjCdqVu+LIZLI2Jb2zRUlxUrkmptvcRi4PvqdpBjXW6DCZ5Hej0WQNSpn8xOHZ8uZxRUKGTzQXZeLZ4STo0ZuZR1OrhmXuIYoVB2VnrhbXA== x-ms-office365-filtering-correlation-id: dec8d695-3e14-4f60-1385-08d650d242fe 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:VI1PR05MB4494; x-ms-traffictypediagnostic: VI1PR05MB4494: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231442)(944501410)(52105112)(3002001)(10201501046)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(20161123564045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:VI1PR05MB4494; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB4494; x-forefront-prvs: 0864A36BBF x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(366004)(396003)(346002)(39860400002)(376002)(199004)(189003)(305945005)(7736002)(39060400002)(4326008)(478600001)(25786009)(2906002)(97736004)(118296001)(316002)(2900100001)(66066001)(68736007)(3846002)(6116002)(7416002)(14454004)(54906003)(110136005)(2501003)(81156014)(8936002)(186003)(102836004)(476003)(71190400001)(71200400001)(6436002)(6506007)(386003)(26005)(105586002)(86362001)(36756003)(256004)(11346002)(2616005)(8676002)(106356001)(446003)(14444005)(81166006)(52116002)(6512007)(76176011)(5660300001)(53936002)(6486002)(486006)(99286004); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB4494; H:VI1PR05MB4191.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-microsoft-antispam-message-info: uRwI5BuEBXmsS3L40gfL6PzLWkFj3ckuhAuT0jndPAKHBnNlZ67b7NekOvtGxn4R9sKRHycAArh96Qkr+UwuEuCM8r/4J1M+lhV0ba1U+d53dCZSgIuRR+BHKoE2ooIqG+g9gzhEpmyXdqspabjjJ6odEBfmPQ4+wAmtwD2ev2GGvS6q4yjbh97gKF1Ugqvb6x8torMvDA2VwlYahOqUvTdUfIRnhvkJqe53ocCH+3luXh+oijzLKusE9L598/TzPXKimLfBQucdDfmy4PeDH5LUy4rq6G87sKSbLB45rbkhZ1KjaMHJtxt6fFnP19wJ9uZoHIVg+wCPX6GZ3sYiaDzqd94JUL0f39Qp7zUxNv4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: dec8d695-3e14-4f60-1385-08d650d242fe X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Nov 2018 23:28:51.9507 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4494 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Following patches will change the way of distributing port object changes from a switchdev operation to a switchdev notifier. The switchdev code currently recursively descends through layers of lower devices, eventually calling the op on a front-panel port device. The notifier will instead be sent referencing the bridge port device, which may be a stacking device that's one of front-panel ports uppers, or a completely unrelated device. rocker currently doesn't support any uppers other than bridge. Thus the only case that a stacked device could be validly referenced by port object notifications are bridge notifications for VLAN objects added to the bridge itself. But the driver explicitly rejects such notifications in rocker_world_port_obj_vlan_add(). It is therefore safe to assume that the only interesting case is that the notification is on a front-panel port netdevice. Subscribe to the blocking notifier chain. In the handler, filter out notifications on any foreign netdevices. Dispatch the new notifiers to rocker_port_obj_add() resp. _del() to maintain the behavior that the switchdev operation based code currently has. Signed-off-by: Petr Machata Acked-by: Jiri Pirko --- drivers/net/ethernet/rocker/rocker_main.c | 55 +++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/drivers/net/ethernet/rocker/rocker_main.c b/drivers/net/ethernet/rocker/rocker_main.c index beb06628f22d..806ffe1d906e 100644 --- a/drivers/net/ethernet/rocker/rocker_main.c +++ b/drivers/net/ethernet/rocker/rocker_main.c @@ -2812,12 +2812,54 @@ static int rocker_switchdev_event(struct notifier_block *unused, return NOTIFY_DONE; } +static int +rocker_switchdev_port_obj_event(unsigned long event, struct net_device *netdev, + struct switchdev_notifier_port_obj_info *port_obj_info) +{ + int err = -EOPNOTSUPP; + + switch (event) { + case SWITCHDEV_PORT_OBJ_ADD: + err = rocker_port_obj_add(netdev, port_obj_info->obj, + port_obj_info->trans); + break; + case SWITCHDEV_PORT_OBJ_DEL: + err = rocker_port_obj_del(netdev, port_obj_info->obj); + break; + } + + port_obj_info->handled = true; + return notifier_from_errno(err); +} + +static int rocker_switchdev_blocking_event(struct notifier_block *unused, + unsigned long event, void *ptr) +{ + struct net_device *dev = switchdev_notifier_info_to_dev(ptr); + + if (!rocker_port_dev_check(dev)) + return NOTIFY_DONE; + + switch (event) { + case SWITCHDEV_PORT_OBJ_ADD: + case SWITCHDEV_PORT_OBJ_DEL: + return rocker_switchdev_port_obj_event(event, dev, ptr); + } + + return NOTIFY_DONE; +} + static struct notifier_block rocker_switchdev_notifier = { .notifier_call = rocker_switchdev_event, }; +static struct notifier_block rocker_switchdev_blocking_notifier = { + .notifier_call = rocker_switchdev_blocking_event, +}; + static int rocker_probe(struct pci_dev *pdev, const struct pci_device_id *id) { + struct notifier_block *nb; struct rocker *rocker; int err; @@ -2933,6 +2975,13 @@ static int rocker_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto err_register_switchdev_notifier; } + nb = &rocker_switchdev_blocking_notifier; + err = register_switchdev_blocking_notifier(nb); + if (err) { + dev_err(&pdev->dev, "Failed to register switchdev blocking notifier\n"); + goto err_register_switchdev_blocking_notifier; + } + rocker->hw.id = rocker_read64(rocker, SWITCH_ID); dev_info(&pdev->dev, "Rocker switch with id %*phN\n", @@ -2940,6 +2989,8 @@ static int rocker_probe(struct pci_dev *pdev, const struct pci_device_id *id) return 0; +err_register_switchdev_blocking_notifier: + unregister_switchdev_notifier(&rocker_switchdev_notifier); err_register_switchdev_notifier: unregister_fib_notifier(&rocker->fib_nb); err_register_fib_notifier: @@ -2971,6 +3022,10 @@ static int rocker_probe(struct pci_dev *pdev, const struct pci_device_id *id) static void rocker_remove(struct pci_dev *pdev) { struct rocker *rocker = pci_get_drvdata(pdev); + struct notifier_block *nb; + + nb = &rocker_switchdev_blocking_notifier; + unregister_switchdev_blocking_notifier(nb); unregister_switchdev_notifier(&rocker_switchdev_notifier); unregister_fib_notifier(&rocker->fib_nb); From patchwork Thu Nov 22 23:29:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 1002052 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="e+2Cyw0Z"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 431FyH1Jznz9s0t for ; Fri, 23 Nov 2018 10:29:11 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439118AbeKWKKw (ORCPT ); Fri, 23 Nov 2018 05:10:52 -0500 Received: from mail-eopbgr150088.outbound.protection.outlook.com ([40.107.15.88]:7296 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2439095AbeKWKKw (ORCPT ); Fri, 23 Nov 2018 05:10:52 -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=M7DVT59N8k8vVI2hDOVkZSfzVOzaCgf0uPelp59Ai5E=; b=e+2Cyw0ZbgR2RZ70+QlVyymCGjWGwLgVmXMRHaC06GD1ZhpJ98bGN2cMUWxcQSXPgcv8qTYT/GxIFTLA9xCwVwxPqCofS5DlfrE9ky2slNI5GJ7I0UvLX1cIkR21GfeyPlO5u1Ym+vDSge4ABzY/BUrJRYiSe6VH8y/iUjN9/V4= Received: from VI1PR05MB4191.eurprd05.prod.outlook.com (10.171.183.17) by VI1PR05MB4494.eurprd05.prod.outlook.com (52.133.13.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.23; Thu, 22 Nov 2018 23:29:05 +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:29:05 +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 05/12] net: dsa: slave: Handle SWITCHDEV_PORT_OBJ_ADD/_DEL Thread-Topic: [PATCH net-next 05/12] net: dsa: slave: Handle SWITCHDEV_PORT_OBJ_ADD/_DEL Thread-Index: AQHUgrsoQKdqLZfKhU2TEqJc5pIDWg== Date: Thu, 22 Nov 2018 23:29:05 +0000 Message-ID: <192c63bd29f2cd69b419b76e2c64199f4f5f2733.1542927590.git.petrm@mellanox.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: CWLP123CA0065.GBRP123.PROD.OUTLOOK.COM (2603:10a6:401:59::29) 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; VI1PR05MB4494; 6:4fTT8regoH3zL+DkSdghOpateoq6qBeL8eM9XB8afDkGOmxjal1hi+tH/oMbjmmxGsEAbG0Sbqj4sfzu/nh6YMzNpRWODj5+qpyhXo9rtHHn+FWCBNDt4BQ4d2EbV/WDd8salX8t2XT9RuHlJrhjFv93Ma6w8TglCUHfYKtuwt2mjlQ741nitsll61jPstb9tw3bXENWceYTYG2BT0FZE2ZqVVEUHmuIw/EaRumcMX9lT4H7IpEN5B0qUtCQ0UurPVF9HV1TOVtZTqTgbfeTWa98hFQjCDuPnPNcJC2EgrXktrBMXM9nEm328lM4O3tCvn8dqKMgpkRz5uN8WfO3oKP8AiL1hHQUq9sRN21EH35CCLAwDfhy8u2ZyQSll3JmQVFBuNr+z0+IYTJdO2NvOI0/t8TosgZyjJrU2slAictHzoHt/84oQBDj3KXYiKBMKR+a8YVUR8KW8Xrd5WVhGw==; 5:t5V9da6ra0c2RS4S9fBUaxPG4KzvoHJAMVAxJpE3VQY/tor5tfAyDbSU28Ut3Yn5NTRE2tZuLJbZBiMlqEV6KJMUUU8bZvBazA3TIoMT1tKk0T45ZU0Pg4ndX2peNOcoaCKw4sTAMJtT5jVWHLKK9WAMDHpanBhgzuTyIHYZhQc=; 7:TdpeuxSYkx1EXgltf5E+X2DAvP+WsudYiUXUiyIMuXFmtg2oW2MBOaL+humauQOnzxTMXBSb1WueAYLoC8HlVcGPjZit6M+ZccpBDr3uZ7mKOqx46X7sYEStHzhJeYoWA+CPvjEcyJ4SNVywm2AT6Q== x-ms-office365-filtering-correlation-id: ccb7ba23-7ba9-4642-aef3-08d650d24afa 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:VI1PR05MB4494; x-ms-traffictypediagnostic: VI1PR05MB4494: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231442)(944501410)(52105112)(3002001)(10201501046)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(20161123564045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:VI1PR05MB4494; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB4494; x-forefront-prvs: 0864A36BBF x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(366004)(396003)(346002)(39860400002)(376002)(199004)(189003)(305945005)(7736002)(39060400002)(4326008)(478600001)(25786009)(2906002)(97736004)(118296001)(316002)(2900100001)(66066001)(68736007)(3846002)(6116002)(7416002)(14454004)(54906003)(110136005)(2501003)(81156014)(8936002)(186003)(102836004)(476003)(71190400001)(71200400001)(6436002)(6506007)(386003)(26005)(105586002)(86362001)(36756003)(256004)(575784001)(11346002)(2616005)(8676002)(106356001)(446003)(14444005)(81166006)(52116002)(6512007)(76176011)(5660300001)(53936002)(6486002)(486006)(99286004); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB4494; H:VI1PR05MB4191.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-microsoft-antispam-message-info: oTUURqN9dv3XdI6sBVr14uOcb/JE2HbJkuyfej9a0BSf8iALfRVZf8eCaR543RLMcRt3AZNZGWWlp0lrd2+Tto4aaDgpiCV88RxrV5+cb5qDpXNUc4rlt7Lz/0+Y3qulSiR7XHmzA9C0HacU5NiHM2QkuLmtZQKFxlFFzV+wn2ci7Ki2SrZvaV5cxqgZcc9ZqW9liBRjMc2XOSNW5cBDBN24JDxua4JGD9UmeHJEmGsJvVA8MBzPSZSWKw0lrjJgwrhU1LSCvOfvRYct5bbdagAOMUsWLXZl2RY+JD7wIIYOTT5HEeriDWVncmiDsMGM3Wkrdy4zaaQcUDsT/2BywmztL49ReEBhWLDjW/MRp2U= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: ccb7ba23-7ba9-4642-aef3-08d650d24afa X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Nov 2018 23:29:05.3402 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4494 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Following patches will change the way of distributing port object changes from a switchdev operation to a switchdev notifier. The switchdev code currently recursively descends through layers of lower devices, eventually calling the op on a front-panel port device. The notifier will instead be sent referencing the bridge port device, which may be a stacking device that's one of front-panel ports uppers, or a completely unrelated device. DSA currently doesn't support any other uppers than bridge. SWITCHDEV_OBJ_ID_HOST_MDB and _PORT_MDB objects are always notified on the bridge port device. Thus the only case that a stacked device could be validly referenced by port object notifications are bridge notifications for VLAN objects added to the bridge itself. But the driver explicitly rejects such notifications in dsa_port_vlan_add(). It is therefore safe to assume that the only interesting case is that the notification is on a front-panel port netdevice. Therefore keep the filtering by dsa_slave_dev_check() in place. To handle SWITCHDEV_PORT_OBJ_ADD and _DEL, subscribe to the blocking notifier chain. Dispatch to rocker_port_obj_add() resp. _del() to maintain the behavior that the switchdev operation based code currently has. Signed-off-by: Petr Machata Acked-by: Jiri Pirko --- net/dsa/slave.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 7d0c19e7edcf..d00a0b6d4ce0 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1557,6 +1557,44 @@ static int dsa_slave_switchdev_event(struct notifier_block *unused, return NOTIFY_BAD; } +static int +dsa_slave_switchdev_port_obj_event(unsigned long event, + struct net_device *netdev, + struct switchdev_notifier_port_obj_info *port_obj_info) +{ + int err = -EOPNOTSUPP; + + switch (event) { + case SWITCHDEV_PORT_OBJ_ADD: + err = dsa_slave_port_obj_add(netdev, port_obj_info->obj, + port_obj_info->trans); + break; + case SWITCHDEV_PORT_OBJ_DEL: + err = dsa_slave_port_obj_del(netdev, port_obj_info->obj); + break; + } + + port_obj_info->handled = true; + return notifier_from_errno(err); +} + +static int dsa_slave_switchdev_blocking_event(struct notifier_block *unused, + unsigned long event, void *ptr) +{ + struct net_device *dev = switchdev_notifier_info_to_dev(ptr); + + if (!dsa_slave_dev_check(dev)) + return NOTIFY_DONE; + + switch (event) { + case SWITCHDEV_PORT_OBJ_ADD: /* fall through */ + case SWITCHDEV_PORT_OBJ_DEL: + return dsa_slave_switchdev_port_obj_event(event, dev, ptr); + } + + return NOTIFY_DONE; +} + static struct notifier_block dsa_slave_nb __read_mostly = { .notifier_call = dsa_slave_netdevice_event, }; @@ -1565,8 +1603,13 @@ static struct notifier_block dsa_slave_switchdev_notifier = { .notifier_call = dsa_slave_switchdev_event, }; +static struct notifier_block dsa_slave_switchdev_blocking_notifier = { + .notifier_call = dsa_slave_switchdev_blocking_event, +}; + int dsa_slave_register_notifier(void) { + struct notifier_block *nb; int err; err = register_netdevice_notifier(&dsa_slave_nb); @@ -1577,8 +1620,15 @@ int dsa_slave_register_notifier(void) if (err) goto err_switchdev_nb; + nb = &dsa_slave_switchdev_blocking_notifier; + err = register_switchdev_blocking_notifier(nb); + if (err) + goto err_switchdev_blocking_nb; + return 0; +err_switchdev_blocking_nb: + unregister_switchdev_notifier(&dsa_slave_switchdev_notifier); err_switchdev_nb: unregister_netdevice_notifier(&dsa_slave_nb); return err; @@ -1586,8 +1636,14 @@ int dsa_slave_register_notifier(void) void dsa_slave_unregister_notifier(void) { + struct notifier_block *nb; int err; + nb = &dsa_slave_switchdev_blocking_notifier; + err = unregister_switchdev_blocking_notifier(nb); + if (err) + pr_err("DSA: failed to unregister switchdev blocking notifier (%d)\n", err); + err = unregister_switchdev_notifier(&dsa_slave_switchdev_notifier); if (err) pr_err("DSA: failed to unregister switchdev notifier (%d)\n", err); From patchwork Thu Nov 22 23:29:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 1002053 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="FDn+Fo3T"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 431FyX0zFKz9s0t for ; Fri, 23 Nov 2018 10:29:24 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439120AbeKWKLG (ORCPT ); Fri, 23 Nov 2018 05:11:06 -0500 Received: from mail-eopbgr00049.outbound.protection.outlook.com ([40.107.0.49]:53088 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731347AbeKWKLF (ORCPT ); Fri, 23 Nov 2018 05:11:05 -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=WByuRW3EL98yr0JCzS0e0yUQIP2Sy0m3+ccor0IlDI4=; b=FDn+Fo3TAGT065xl5H7VTbzuTVgD0e7dN+My+Dv1XMUQOz2IlSdZITMb/E51YHDcWzyeIZqhCv0XNefbeW993Cf2KgS+kspMcmdRvoQWJ7doIxmhFszCK4/IOENmvxca7o8VNBrJazK/MPY9PHZu3jzad8eGyc+3duAwTBRQSlg= 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:29:18 +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:29:18 +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 06/12] staging: fsl-dpaa2: ethsw: Introduce ethsw_port_dev_check() Thread-Topic: [PATCH net-next 06/12] staging: fsl-dpaa2: ethsw: Introduce ethsw_port_dev_check() Thread-Index: AQHUgrswvdsdJjOyVkanFivmbVtT8A== Date: Thu, 22 Nov 2018 23:29:18 +0000 Message-ID: <885703ee30700904ff1be266cabf161f9aecb1c3.1542927590.git.petrm@mellanox.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: CWLP123CA0080.GBRP123.PROD.OUTLOOK.COM (2603:10a6:401:5b::20) 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:8OUD0ZcuvSA9xOwFPlURSNttZQ/X8cj+Ihyxf4uqcw0DP1p2+CzOcBI3u25VNhtF0AnaDuHqNIDba6PIRtdXQg3mM70hoNw0YdN6kpJkEgft15xOXXuLhoMs+aeRfqgAz8eprzyS1kRmC0Zvk0v6p0qPs8hZFcM59i0Nj7eyhJMp9TKVxcnTh6ppMbwTH63dx0g0y3kGiA3QFFyuqTKIJT3xieMPrbR/T1ub5Yavp6wg5+jRyHTOe8FKWb4IKK6lqjVCIN5lbfny6E6LWE++5SPWcJ4JBdU81fpY1CHEZsk+AZneXg9/tVHm+s/aQdcp3scoBrhegQNHBSLPlQFyGG0IBzPbpycHw9ZCiH36pOIgfydMcTgSCBv+W5vUamGO3BLBln2qcE4rEhzmjK+3ZcXWKdYiw1vtYSW1DMA87vpFKP77IKQQUQVi7NVbrLF0j5p2UfvR+M8Q5G2utKd0GI41i4fPskZEwLHdehhJPU8=; 5:mTS7QCaQyEmoUKIptHfDgDWviZPcmlXMm4UhpRUzU7saglKwSb1LV8UJ+qlzkcVFWnI0ox4iAVvWnJDXWTMCOqbZIUcUa+NUdtQEb/JlOxTA2ggh+ul7CHxRtPPA4VFZAseo9TXpPNO0to+Zm3sus3HduVm1CvnNCP5EYaN/XsM=; 7:NjoG1mmpkh1csipa1feWLPu1SCMFpstnqjvanGVCJUcpnTZvJ6XNVdM07vT20SaLlVafK21NSEOGgqCBclrH4GgXca9mArbrkvnSNcAlDci52eQzv2H6kfXbRRwmo7GAe/kN3aW7QKVe/FOcWCEw0A== x-ms-office365-filtering-correlation-id: cf1bafcd-e865-44aa-5721-08d650d252b3 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)(376002)(136003)(396003)(39860400002)(366004)(346002)(189003)(199004)(76176011)(26005)(39060400002)(36756003)(6436002)(14454004)(102836004)(6506007)(4326008)(66066001)(105586002)(575784001)(386003)(86362001)(8936002)(71190400001)(256004)(118296001)(186003)(106356001)(2906002)(6116002)(7736002)(2616005)(6486002)(316002)(11346002)(8676002)(476003)(446003)(25786009)(54906003)(97736004)(305945005)(478600001)(486006)(5660300001)(3846002)(81166006)(53936002)(81156014)(68736007)(110136005)(2501003)(2900100001)(6512007)(14444005)(7416002)(71200400001)(99286004)(52116002); 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: D/PDHBzJ8DPmynQ3KhXdPEa1BmMdvNNqk13pIc+no056/HXBcYlRb5eBUI9ej1maCyzLxwOxR/HZd69b20apStoI6GOinRQ8ChGz3EkAs8Yo2oZZIbWHuJPd7iAgopSKxVxKLklhZhuPUG+WTrgNGRFJgNYMMYg10AR3g24BkJyHexgELwKR/vcNf7ZZwVr9Phvk/tI8DdpftxizqsicqJySCzsJGld9OOSkAfji/FtYhN4sq12wlHcLh3Z5LXNUyDDgEJQr/j9A+XwarIIypUzV0cfisCfnSp+VmGQb0DnyKP2maqoeLH939lFzH4I/WvWeoloUAw6v1oJnVt8S5FYjZfwwANIGHkS8BpPI2NA= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: cf1bafcd-e865-44aa-5721-08d650d252b3 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Nov 2018 23:29:18.2084 (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 ethsw currently uses an open-coded comparison of netdev_ops to determine whether whether a device represents a front panel port. Wrap this into a named function to simplify reuse. Signed-off-by: Petr Machata Acked-by: Jiri Pirko --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index 7a7ca67822c5..e379b0fa936f 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -972,6 +972,11 @@ static int port_bridge_leave(struct net_device *netdev) return err; } +static bool ethsw_port_dev_check(const struct net_device *netdev) +{ + return netdev->netdev_ops == ðsw_port_ops; +} + static int port_netdevice_event(struct notifier_block *unused, unsigned long event, void *ptr) { @@ -980,7 +985,7 @@ static int port_netdevice_event(struct notifier_block *unused, struct net_device *upper_dev; int err = 0; - if (netdev->netdev_ops != ðsw_port_ops) + if (!ethsw_port_dev_check(netdev)) return NOTIFY_DONE; /* Handle just upper dev link/unlink for the moment */ From patchwork Thu Nov 22 23:29:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 1002054 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="CckcCKUH"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 431Fyn0Fwlz9s0t for ; Fri, 23 Nov 2018 10:29:37 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439126AbeKWKLS (ORCPT ); Fri, 23 Nov 2018 05:11:18 -0500 Received: from mail-eopbgr10075.outbound.protection.outlook.com ([40.107.1.75]:38592 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731347AbeKWKLS (ORCPT ); Fri, 23 Nov 2018 05:11:18 -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=kBxurGm8rgpdONzfnikWxdG2K4XMkHj+PWr33aeL3u4=; b=CckcCKUHv2F30lcieM3uLOBC1sroki+9pessr8+5l7iHbcoKi2XNYbEY7Qz3qteq0WGbc8ch0O4VFGaHW2pw4FmChtthVZBlkJuCxXLbSH0s7MqzguaZIDbmh1G1cwioE64iDocakR3p1iTpJT8cabXKhVt6R3qndKZ8oXG5wXs= 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:29:31 +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:29:31 +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 07/12] staging: fsl-dpaa2: ethsw: Handle SWITCHDEV_PORT_OBJ_ADD/_DEL Thread-Topic: [PATCH net-next 07/12] staging: fsl-dpaa2: ethsw: Handle SWITCHDEV_PORT_OBJ_ADD/_DEL Thread-Index: AQHUgrs3seP5YMWYYkuXbWBZnDFjgw== Date: Thu, 22 Nov 2018 23:29:30 +0000 Message-ID: <31ee71464d0f818ee8c1a5f07e8d701f958522b0.1542927590.git.petrm@mellanox.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: CWLP265CA0234.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:4f::30) 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:7jme3nTAqkSLUzFY0Q4I0HyJX3OLXU1qOknpdw4okRSkbjU5i0E3KNcFwlZ39SzTeEM2ju8rNQOrku+05YL5Hk5v1rKtaR3ZZNx5pJGwGD4vZxog3nlcbKpO3u41b5GRC+uHCe9e8AMdf6Tg7mZjEDA+48E+Tue2e9jceCd7Gp2uUnkUJQFnKVNR7EC6jsntSA3SucX6PTcYUyaxlZxNfN48bJmm5dhyACc0pvcBEPx3CCvk40aR/pUz9HUKf+q6DhF2dbj+euNjtkRjxE9N5R3ZemoTQE78nLCLyIGUtK7YClpoDFVs6eA4CmU+bEpzQXqpIVAcZGnI1WqLY+S6tPMVW3Ykq95+LQfH6vY4Ev0eu4Lsm5O3VTxYfxn5PLvMdAscwa5lNN0bpXNdHPUwwJRjXA38GcrHcJ8OHCh3+Pj88NIL8xTQaZ9FneXGX2XRSsvzxMb/WdDF6SR7iNdnVA==; 5:WnFpTUI9SMoiDLsHZz2t30NDRjKc8TcItN8aoJY1V1MFbcXEqnp+QiNOG4B30xaZVbH1gXvxE7hzUGCMWDdd4dqgguYyeOXXWEt6R+IQS5vDUyYlu/ProHrpkscqoHqqM+Ei3YROp4d9PMrfLBSBiNZctUO9wZ3p5hUEjHlhlFw=; 7:ld5jsRfEXIAadeXrqP9Zdoch4Qf/1elDwfwD1kZL98tfoD8l1V+Jz5WhFEL82NDMrfVVzhede0EtP+lIqCQ9QneyxdvXDAuerewnZB+U2OxJYb1UO/x6W6SpQI7unkH0Lhrxq8yjhgRl+M4nRoJr2g== x-ms-office365-filtering-correlation-id: 47d19d72-0ec2-4e98-bafb-08d650d25a3d 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)(376002)(136003)(396003)(39860400002)(366004)(346002)(189003)(199004)(76176011)(26005)(39060400002)(36756003)(6436002)(14454004)(102836004)(6506007)(4326008)(66066001)(105586002)(575784001)(386003)(86362001)(8936002)(71190400001)(256004)(118296001)(186003)(106356001)(2906002)(6116002)(7736002)(2616005)(6486002)(316002)(11346002)(8676002)(476003)(446003)(25786009)(54906003)(97736004)(305945005)(478600001)(486006)(5660300001)(3846002)(81166006)(53936002)(81156014)(68736007)(110136005)(2501003)(2900100001)(6512007)(14444005)(7416002)(71200400001)(99286004)(52116002); 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: +NY17aDHh1hizmAZkvVTQLQcNqlaM5KVlZ2xMfCwfD4ewG9lhCq8s6orHuZzMHtOrW/49pHSePQiipuNKjkbIhmrWG/VulmklUxlu5L9lSsftktH93sIzU89WtgGe3qvZ/v/m/hg74cWoK2nlWC3Ny/S2V2YEeYH0FpguHkxQWxgIxFjEAJSTPxcp+JyJxzSKcRtwTJQWB92xHCtTA5rXHckwLcVV/jokPE5BYHMFIrfB3YrxdWqLJ5vlPrR7YAsxY/hLVv1iWW/Yvj0xsRzJrRJBK6vGVQYoJqOwjpmRB3olDvCEBCkBLqNjhe2o1cbpUz4nkPEIkl69lf/eUL9p2PMyDEWlSGOIinEty9Qq4E= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 47d19d72-0ec2-4e98-bafb-08d650d25a3d X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Nov 2018 23:29:30.9014 (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 Following patches will change the way of distributing port object changes from a switchdev operation to a switchdev notifier. The switchdev code currently recursively descends through layers of lower devices, eventually calling the op on a front-panel port device. The notifier will instead be sent referencing the bridge port device, which may be a stacking device that's one of front-panel ports uppers, or a completely unrelated device. ethsw currently doesn't support any uppers other than bridge. SWITCHDEV_OBJ_ID_HOST_MDB and _PORT_MDB objects are always notified on the bridge port device. Thus the only case that a stacked device could be validly referenced by port object notifications are bridge notifications for VLAN objects added to the bridge itself. But the driver explicitly rejects such notifications in port_vlans_add(). It is therefore safe to assume that the only interesting case is that the notification is on a front-panel port netdevice. To handle SWITCHDEV_PORT_OBJ_ADD and _DEL, subscribe to the blocking notifier chain. Dispatch to swdev_port_obj_add() resp. _del() to maintain the behavior that the switchdev operation based code currently has. Signed-off-by: Petr Machata Acked-by: Jiri Pirko --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 56 +++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index e379b0fa936f..83e1d92dc7f3 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -1088,10 +1088,51 @@ static int port_switchdev_event(struct notifier_block *unused, return NOTIFY_BAD; } +static int +ethsw_switchdev_port_obj_event(unsigned long event, struct net_device *netdev, + struct switchdev_notifier_port_obj_info *port_obj_info) +{ + int err = -EOPNOTSUPP; + + switch (event) { + case SWITCHDEV_PORT_OBJ_ADD: + err = swdev_port_obj_add(netdev, port_obj_info->obj, + port_obj_info->trans); + break; + case SWITCHDEV_PORT_OBJ_DEL: + err = swdev_port_obj_del(netdev, port_obj_info->obj); + break; + } + + port_obj_info->handled = true; + return notifier_from_errno(err); +} + +static int port_switchdev_blocking_event(struct notifier_block *unused, + unsigned long event, void *ptr) +{ + struct net_device *dev = switchdev_notifier_info_to_dev(ptr); + + if (!ethsw_port_dev_check(dev)) + return NOTIFY_DONE; + + switch (event) { + case SWITCHDEV_PORT_OBJ_ADD: /* fall through */ + case SWITCHDEV_PORT_OBJ_DEL: + return ethsw_switchdev_port_obj_event(event, dev, ptr); + } + + return NOTIFY_DONE; +} + static struct notifier_block port_switchdev_nb = { .notifier_call = port_switchdev_event, }; +static struct notifier_block port_switchdev_blocking_nb = { + .notifier_call = port_switchdev_blocking_event, +}; + static int ethsw_register_notifier(struct device *dev) { int err; @@ -1108,8 +1149,16 @@ static int ethsw_register_notifier(struct device *dev) goto err_switchdev_nb; } + err = register_switchdev_blocking_notifier(&port_switchdev_blocking_nb); + if (err) { + dev_err(dev, "Failed to register switchdev blocking notifier\n"); + goto err_switchdev_blocking_nb; + } + return 0; +err_switchdev_blocking_nb: + unregister_switchdev_notifier(&port_switchdev_nb); err_switchdev_nb: unregister_netdevice_notifier(&port_nb); return err; @@ -1296,8 +1345,15 @@ static int ethsw_port_init(struct ethsw_port_priv *port_priv, u16 port) static void ethsw_unregister_notifier(struct device *dev) { + struct notifier_block *nb; int err; + nb = &port_switchdev_blocking_nb; + err = unregister_switchdev_blocking_notifier(nb); + if (err) + dev_err(dev, + "Failed to unregister switchdev blocking notifier (%d)\n", err); + err = unregister_switchdev_notifier(&port_switchdev_nb); if (err) dev_err(dev, From patchwork Thu Nov 22 23:29:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 1002055 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="Kj61woCn"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 431Fz25bSYz9s0t for ; Fri, 23 Nov 2018 10:29:50 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392671AbeKWKLc (ORCPT ); Fri, 23 Nov 2018 05:11:32 -0500 Received: from mail-eopbgr00043.outbound.protection.outlook.com ([40.107.0.43]:12096 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731347AbeKWKLc (ORCPT ); Fri, 23 Nov 2018 05:11:32 -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=9Sds8YmOeaHcA/Q2tbhaBc1qHaW2fgBW9djUwWMehmQ=; b=Kj61woCndCX+Lpb8RUJtY58ppPIuj3wQ1+e3RLaRvNvOwoXxoBvgyvpr9xos8sHyF81D7Kk4TBRmE2KjrBORjmjuXUtq7vs5MXLaKoXd73EKA7fqhYVu8V6Q0PpniWwZos5JmMXvOdd5Y5VQ8ic5JLicNhvkrtjcGL+/blzqHZ8= 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:29:44 +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:29:44 +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 08/12] switchdev: Add helpers to aid traversal through lower devices Thread-Topic: [PATCH net-next 08/12] switchdev: Add helpers to aid traversal through lower devices Thread-Index: AQHUgrs/4zBLlt5EE0axB1HwYVdWFQ== Date: Thu, 22 Nov 2018 23:29:44 +0000 Message-ID: <72165b1625a174bdc3c8b0b91177a60450d89bb0.1542927590.git.petrm@mellanox.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: CWLP123CA0095.GBRP123.PROD.OUTLOOK.COM (2603:10a6:401:5b::35) 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:mo+pmSl8TVxdpKiFL2AlGGz+h6CVfNjB+HmV9WbG1qV0eClx8HCtHEkxj6QqbzkTNZehjAtV/64GQNenikF0u0gaow6hF1BuW3jFkfaff4cbGpf9ueSCtqbsE1jKc2/9bvGOXbSXcQxLpPoq58gCTTUhxTdStAecm2yXDKxyETBrBIhqY/SF38ycY57gxaosF8ysqV97Gqc/YX7Cnh+VoqlWpAfjdbQur04bMT8vKFtopAktdZYyWU6N7GXldbDpYi5fFU5xYYXsPWW7EcKWOCSpHPe8MVTsiVkYFefzaW/+CdsSVXsvFtpCsTQtlTnpxjEy0xyMg+rTJjh5Ja27gZm2rO0gqgVyiwXvvkIit/X62f7849aoInno88qac+LGnTmt58gwXXCRv+BDnJGkww+tZvhjmiwkR2diRbXQ9Sz3KiHRgYIWmLS/PIEGtWMmownoHjOfWU7SE20D4weCvOawhpeAK0uoQXo0aL9adrA=; 5:VBYRyQ//JgIy82H4Jekh4JDUTMkQwjSXKvJST34ui5Ke4i9zahy6KySGE1M+b+gt56DMiuGvCw+KKMJxjkZgmJ/xsT0BPw7s5auvEsNHhBLNubEkRrfNYxY4rvuDXKCrvKYNlavYUlf52QJmuk2gAh+0zgUVxrilywuy4QXzhTA=; 7:oiM135giZz1tw5wyLPX0u6u5nNFWVfnVkNlXirnQE0uWgKSQSPOaCcM7xyd4IyN1FmdImE4gz4Wm/264KOpg4QxRvnkUxkvgNMw7r07VbDkClMid4FyB+o3Rh5kfdyUx5TRxUFHLg0uxzM32YX8rcA== x-ms-office365-filtering-correlation-id: f7a222b4-b3ee-422d-aab6-08d650d26241 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)(376002)(136003)(396003)(39860400002)(366004)(346002)(189003)(199004)(76176011)(26005)(39060400002)(36756003)(6436002)(14454004)(102836004)(6506007)(4326008)(66066001)(105586002)(386003)(86362001)(8936002)(71190400001)(256004)(118296001)(186003)(106356001)(2906002)(6116002)(7736002)(2616005)(6486002)(316002)(11346002)(8676002)(476003)(446003)(25786009)(54906003)(97736004)(305945005)(478600001)(486006)(5660300001)(3846002)(81166006)(53936002)(81156014)(68736007)(110136005)(2501003)(2900100001)(6512007)(7416002)(71200400001)(99286004)(52116002); 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: 4X21RNrylzEfnLRIuB0a2TEqoClid06Oqaa8RZ4TGQ1uWNGCFUd+I9CgH6DtVlG2UgDz3ivfWSiLChlklqkM6Vj356tUDmHDwsx2Li97fGb+obgJQ/IcE0qtgIZ9OjsVOaLIif1yApJs2TJNyucDrBe1e/qYVJHy0ADyksfTPtGNImW2UuLNnL7ZGooPKnWxgw36HGkP4AXNhhRwd/wPwtDoUA6ITnYuWJlR8bk4WYJYNt8OSAUtIQyXYIJBHfxqDtGqxbFuQRExZNLO1MT4759WqrCyJXM5STgde+DncrCUWXDgdX27ZFvzYwl97MrrXyjknX/jHFnzgMTmi6HDcb+vgbdicXTzeneFKGaT9c0= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: f7a222b4-b3ee-422d-aab6-08d650d26241 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Nov 2018 23:29:44.3200 (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 After the transition from switchdev operations to notifier chain (which will take place in following patches), the onus is on the driver to find its own devices below possible layer of LAG or other uppers. The logic to do so is fairly repetitive: each driver is looking for its own devices among the lowers of the notified device. For those that it finds, it calls a handler. To indicate that the event was handled, struct switchdev_notifier_port_obj_info.handled is set. The differences lie only in what constitutes an "own" device and what handler to call. Therefore abstract this logic into two helpers, switchdev_handle_port_obj_add() and switchdev_handle_port_obj_del(). If a driver only supports physical ports under a bridge device, it will simply avoid this layer of indirection. One area where this helper diverges from the current switchdev behavior is the case of mixed lowers, some of which are switchdev ports and some of which are not. Previously, such scenario would fail with -EOPNOTSUPP. The helper could do that for lowers for which the passed-in predicate doesn't hold. That would however break the case that switchdev ports from several different drivers are stashed under one master, a scenario that switchdev currently happily supports. Therefore tolerate any and all unknown netdevices, whether they are backed by a switchdev driver or not. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- include/net/switchdev.h | 33 +++++++++++++++ net/switchdev/switchdev.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+) diff --git a/include/net/switchdev.h b/include/net/switchdev.h index a2f3ebf39301..6dc7de576167 100644 --- a/include/net/switchdev.h +++ b/include/net/switchdev.h @@ -210,6 +210,18 @@ void switchdev_port_fwd_mark_set(struct net_device *dev, bool switchdev_port_same_parent_id(struct net_device *a, struct net_device *b); +int switchdev_handle_port_obj_add(struct net_device *dev, + struct switchdev_notifier_port_obj_info *port_obj_info, + bool (*check_cb)(const struct net_device *dev), + int (*add_cb)(struct net_device *dev, + const struct switchdev_obj *obj, + struct switchdev_trans *trans)); +int switchdev_handle_port_obj_del(struct net_device *dev, + struct switchdev_notifier_port_obj_info *port_obj_info, + bool (*check_cb)(const struct net_device *dev), + int (*del_cb)(struct net_device *dev, + const struct switchdev_obj *obj)); + #define SWITCHDEV_SET_OPS(netdev, ops) ((netdev)->switchdev_ops = (ops)) #else @@ -284,6 +296,27 @@ static inline bool switchdev_port_same_parent_id(struct net_device *a, return false; } +static inline int +switchdev_handle_port_obj_add(struct net_device *dev, + struct switchdev_notifier_port_obj_info *port_obj_info, + bool (*check_cb)(const struct net_device *dev), + int (*add_cb)(struct net_device *dev, + const struct switchdev_obj *obj, + struct switchdev_trans *trans)) +{ + return 0; +} + +static inline int +switchdev_handle_port_obj_del(struct net_device *dev, + struct switchdev_notifier_port_obj_info *port_obj_info, + bool (*check_cb)(const struct net_device *dev), + int (*del_cb)(struct net_device *dev, + const struct switchdev_obj *obj)) +{ + return 0; +} + #define SWITCHDEV_SET_OPS(netdev, ops) do {} while (0) #endif diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c index e109bb97ce3f..099434ec7996 100644 --- a/net/switchdev/switchdev.c +++ b/net/switchdev/switchdev.c @@ -621,3 +621,103 @@ bool switchdev_port_same_parent_id(struct net_device *a, return netdev_phys_item_id_same(&a_attr.u.ppid, &b_attr.u.ppid); } EXPORT_SYMBOL_GPL(switchdev_port_same_parent_id); + +static int __switchdev_handle_port_obj_add(struct net_device *dev, + struct switchdev_notifier_port_obj_info *port_obj_info, + bool (*check_cb)(const struct net_device *dev), + int (*add_cb)(struct net_device *dev, + const struct switchdev_obj *obj, + struct switchdev_trans *trans)) +{ + struct net_device *lower_dev; + struct list_head *iter; + int err = -EOPNOTSUPP; + + if (check_cb(dev)) { + /* This flag is only checked if the return value is success. */ + port_obj_info->handled = true; + return add_cb(dev, port_obj_info->obj, port_obj_info->trans); + } + + /* Switch ports might be stacked under e.g. a LAG. Ignore the + * unsupported devices, another driver might be able to handle them. But + * 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 = __switchdev_handle_port_obj_add(lower_dev, port_obj_info, + check_cb, add_cb); + if (err && err != -EOPNOTSUPP) + return err; + } + + return err; +} + +int switchdev_handle_port_obj_add(struct net_device *dev, + struct switchdev_notifier_port_obj_info *port_obj_info, + bool (*check_cb)(const struct net_device *dev), + int (*add_cb)(struct net_device *dev, + const struct switchdev_obj *obj, + struct switchdev_trans *trans)) +{ + int err; + + err = __switchdev_handle_port_obj_add(dev, port_obj_info, check_cb, + add_cb); + if (err == -EOPNOTSUPP) + err = 0; + return err; +} +EXPORT_SYMBOL_GPL(switchdev_handle_port_obj_add); + +static int __switchdev_handle_port_obj_del(struct net_device *dev, + struct switchdev_notifier_port_obj_info *port_obj_info, + bool (*check_cb)(const struct net_device *dev), + int (*del_cb)(struct net_device *dev, + const struct switchdev_obj *obj)) +{ + struct net_device *lower_dev; + struct list_head *iter; + int err = -EOPNOTSUPP; + + if (check_cb(dev)) { + /* This flag is only checked if the return value is success. */ + port_obj_info->handled = true; + return del_cb(dev, port_obj_info->obj); + } + + /* Switch ports might be stacked under e.g. a LAG. Ignore the + * unsupported devices, another driver might be able to handle them. But + * 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 = __switchdev_handle_port_obj_del(lower_dev, port_obj_info, + check_cb, del_cb); + if (err && err != -EOPNOTSUPP) + return err; + } + + return err; +} + +int switchdev_handle_port_obj_del(struct net_device *dev, + struct switchdev_notifier_port_obj_info *port_obj_info, + bool (*check_cb)(const struct net_device *dev), + int (*del_cb)(struct net_device *dev, + const struct switchdev_obj *obj)) +{ + int err; + + err = __switchdev_handle_port_obj_del(dev, port_obj_info, check_cb, + del_cb); + if (err == -EOPNOTSUPP) + err = 0; + return err; +} +EXPORT_SYMBOL_GPL(switchdev_handle_port_obj_del); From patchwork Thu Nov 22 23:29: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: 1002056 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="lzqX9/jF"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 431FzH4Ph1z9s3C for ; Fri, 23 Nov 2018 10:30:03 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439132AbeKWKLp (ORCPT ); Fri, 23 Nov 2018 05:11:45 -0500 Received: from mail-eopbgr00077.outbound.protection.outlook.com ([40.107.0.77]:13120 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731347AbeKWKLp (ORCPT ); Fri, 23 Nov 2018 05:11:45 -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=LkRU/aL11NSAGCYF8dPix4JzjPQi6yKbXulVawE9ebU=; b=lzqX9/jFMyMa2zHL3VpQi900FBJ1eR2oVlhwdUfD6mq+rQZFsalYMJ8z6CzZlhfinaSbFw2Ie/s2Goio5iFDJRI/RevrmJRP91/Gb6hSmUMkaiY0phr4cTghVk3PSYnRLHoZG5nSnCB9bVLK1M15m98ZwURXstniZBtfH5FejQA= 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:29:57 +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:29:57 +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 09/12] mlxsw: spectrum_switchdev: Handle SWITCHDEV_PORT_OBJ_ADD/_DEL Thread-Topic: [PATCH net-next 09/12] mlxsw: spectrum_switchdev: Handle SWITCHDEV_PORT_OBJ_ADD/_DEL Thread-Index: AQHUgrtHVOKinudiqEKAtdkN0uSZKw== Date: Thu, 22 Nov 2018 23:29:57 +0000 Message-ID: <4a702bbc647469cfbc7041a085ba2a135d7c3ee9.1542927590.git.petrm@mellanox.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: LO2P265CA0184.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a::28) 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:YHCnhgKVrD7c3MNetuX8OublYC81YQyu3UxDVX8BEqfX/xAxvusrDmMfbrKs6Dc1G3JWOrhlJbWTHGOylGfBvjNoYabVNLc6Bsq6zpbtkD+3ygfdS2RG3WOjBDMm1S0VT40WSpglF9Gm5WbakHZU0ByPWfJa67BQVCxhLlliX2bc8nhuVFMY6d8GdtStwVmWuEkvcwexn1FWGXI2cS4RMOAGUluNZh7cEwB3tLe+sBKgqt1gb28F3GSqmrKueAwFHw0oqZr3+Bwg1jsRHW+/ay5cMH4jn0e2anNHxLx8zLq3c0WuzlE5/R8YwHtm0tzkjqruclyYkLDecwlDKD/c1CBIEoCbaLlBSphy4ZjRWiWWDIKuj4lXAjArzP6F5qIs8OLQcaEJddeinslsnoizwqy/0mRysyGoj7QiXoyzx3uuEA/tokdNvjJJ/uH8nb2M8I8kO9ZrrFf/MA8MS9BDRA==; 5:l/Dj1n/7RkfEJt7RM8mePktzO9ddynwpofCU1hGQGSj9kJ8MVRqamhG8xsg7/56m/oNoreWM/dBHvM9+EMVsaGyI8BlXG+dil6U9oE9SysdmTOkQ5sGFvebVWk8bdpD/7JLu8urlboOXUgSCilBIyVPlNsqs50xGJCYSyA6EX30=; 7:D7OEANejRSyTe3UhF0SXY21Obh12AIBP6LgnWxXVUuvqacF+2kktSaMzqUHo9laCvF0SXZiD61UxSc88DWxWBCDA4AV/CCsiU1X8e7lkCi6NjwU+kxHHZG6OgmRJ9FS27xXHhhri6xVddPGV6V4HXg== x-ms-office365-filtering-correlation-id: ddd5695d-e856-4de7-ed1d-08d650d26a24 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)(376002)(136003)(396003)(39860400002)(366004)(346002)(189003)(199004)(76176011)(26005)(39060400002)(36756003)(6436002)(14454004)(102836004)(6506007)(4326008)(66066001)(105586002)(386003)(86362001)(8936002)(71190400001)(256004)(118296001)(186003)(106356001)(2906002)(6116002)(7736002)(2616005)(6486002)(316002)(11346002)(8676002)(476003)(446003)(25786009)(54906003)(97736004)(305945005)(478600001)(486006)(5660300001)(3846002)(81166006)(53936002)(81156014)(68736007)(110136005)(2501003)(2900100001)(6512007)(14444005)(7416002)(71200400001)(99286004)(52116002); 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: KN2iJWPuRqls2y67XMXDuT90egZW/YbBMpJ7UWjWXXNIzVB/07ejvEeR0YLyNAKDrFtCIIdaGuZrxjCDGFgdcev/2ak/gZ2OBveKrjE0oefrEcVQ+EauDyckOTix7xCw/6MQKQELobqmXnnUfOb6w80zDR6IGBkJkC6hH0zVtDK+/lMB4VQN6in/ZN4wXPK6L2CY+AGfy5kcwXZ8yHEdUutV1c/9B4gC4Bz1KYBPXsBj+YJJAJGfk82TYzFYRjEO7RcxOhbWb9HIDQ1cCHxVObgdZd7FdU/C1pWBa2IeN2aAAwWkbgMFuPXUP442j/4nvIWCaO5CHPtcocEZT/GsGNbmPZZDAkjWIdkHooPkDW8= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: ddd5695d-e856-4de7-ed1d-08d650d26a24 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Nov 2018 23:29:57.5334 (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 Following patches will change the way of distributing port object changes from a switchdev operation to a switchdev notifier. The switchdev code currently recursively descends through layers of lower devices, eventually calling the op on a front-panel port device. The notifier will instead be sent referencing the bridge port device, which may be a stacking device that's one of front-panel ports uppers, or a completely unrelated device. To handle SWITCHDEV_PORT_OBJ_ADD and _DEL, subscribe to the blocking notifier chain. Dispatch to mlxsw_sp_port_obj_add() resp. _del() to maintain the behavior that the switchdev operation based code currently has. Defer to switchdev_handle_port_obj_add() / _del() to handle the recursive descend, because mlxsw supports a number of upper types. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- .../ethernet/mellanox/mlxsw/spectrum_switchdev.c | 45 +++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c index b32a5ee57fb9..3756aaecd39c 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c @@ -3118,6 +3118,32 @@ static struct notifier_block mlxsw_sp_switchdev_notifier = { .notifier_call = mlxsw_sp_switchdev_event, }; +static int mlxsw_sp_switchdev_blocking_event(struct notifier_block *unused, + unsigned long event, void *ptr) +{ + struct net_device *dev = switchdev_notifier_info_to_dev(ptr); + int err; + + switch (event) { + case SWITCHDEV_PORT_OBJ_ADD: + err = switchdev_handle_port_obj_add(dev, ptr, + mlxsw_sp_port_dev_check, + mlxsw_sp_port_obj_add); + return notifier_from_errno(err); + case SWITCHDEV_PORT_OBJ_DEL: + err = switchdev_handle_port_obj_del(dev, ptr, + mlxsw_sp_port_dev_check, + mlxsw_sp_port_obj_del); + return notifier_from_errno(err); + } + + return NOTIFY_DONE; +} + +static struct notifier_block mlxsw_sp_switchdev_blocking_notifier = { + .notifier_call = mlxsw_sp_switchdev_blocking_event, +}; + u8 mlxsw_sp_bridge_port_stp_state(struct mlxsw_sp_bridge_port *bridge_port) { @@ -3127,6 +3153,7 @@ mlxsw_sp_bridge_port_stp_state(struct mlxsw_sp_bridge_port *bridge_port) static int mlxsw_sp_fdb_init(struct mlxsw_sp *mlxsw_sp) { struct mlxsw_sp_bridge *bridge = mlxsw_sp->bridge; + struct notifier_block *nb; int err; err = mlxsw_sp_ageing_set(mlxsw_sp, MLXSW_SP_DEFAULT_AGEING_TIME); @@ -3141,17 +3168,33 @@ static int mlxsw_sp_fdb_init(struct mlxsw_sp *mlxsw_sp) return err; } + nb = &mlxsw_sp_switchdev_blocking_notifier; + err = register_switchdev_blocking_notifier(nb); + if (err) { + dev_err(mlxsw_sp->bus_info->dev, "Failed to register switchdev blocking notifier\n"); + goto err_register_switchdev_blocking_notifier; + } + INIT_DELAYED_WORK(&bridge->fdb_notify.dw, mlxsw_sp_fdb_notify_work); bridge->fdb_notify.interval = MLXSW_SP_DEFAULT_LEARNING_INTERVAL; mlxsw_sp_fdb_notify_work_schedule(mlxsw_sp); return 0; + +err_register_switchdev_blocking_notifier: + unregister_switchdev_notifier(&mlxsw_sp_switchdev_notifier); + return err; } static void mlxsw_sp_fdb_fini(struct mlxsw_sp *mlxsw_sp) { + struct notifier_block *nb; + cancel_delayed_work_sync(&mlxsw_sp->bridge->fdb_notify.dw); - unregister_switchdev_notifier(&mlxsw_sp_switchdev_notifier); + nb = &mlxsw_sp_switchdev_blocking_notifier; + unregister_switchdev_blocking_notifier(nb); + + unregister_switchdev_notifier(&mlxsw_sp_switchdev_notifier); } int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp) From patchwork Thu Nov 22 23:30:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 1002057 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="yhi+sd7V"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 431FzY5rWVz9s0t for ; Fri, 23 Nov 2018 10:30:17 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439134AbeKWKMA (ORCPT ); Fri, 23 Nov 2018 05:12:00 -0500 Received: from mail-eopbgr00043.outbound.protection.outlook.com ([40.107.0.43]:65311 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731347AbeKWKL7 (ORCPT ); Fri, 23 Nov 2018 05:11:59 -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=6wr594bvNgNbhena51s15/sDHzlRA+6K4QWCbZsBRlM=; b=yhi+sd7V4M43jVlU48POQ+nSVcoT3dqJ274WbYre/80So6VhOOv5WCA0Ok0hylZL9aoqMUFmVXCKhxFuSLuKGJJW5vNvsA1NWz+7q1pv6sKJ3rE94BK+9Hdr8FW35Y932Fj8s4dyixdDeDn9UDXWXc5xiqX3WgvYNFx3WyXaPRA= 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:30:11 +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:30:11 +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 10/12] ocelot: Handle SWITCHDEV_PORT_OBJ_ADD/_DEL Thread-Topic: [PATCH net-next 10/12] ocelot: Handle SWITCHDEV_PORT_OBJ_ADD/_DEL Thread-Index: AQHUgrtPxfpQJp8mQ0Kwps8RPzffEQ== Date: Thu, 22 Nov 2018 23:30:11 +0000 Message-ID: <5b7f1fccfb6c771fd5d02157342993fdf80af6a5.1542927590.git.petrm@mellanox.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: LO2P265CA0320.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a4::20) 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:eaXjEf9ZW9bNHm6syWD7Rin5GA6PA24q5l/rk7h35/BfGb9BniYmiAsmU6vS9J42M+HHamcYu2lCqJEfDrJ0HHQvrUgdAK7uIj8ksiQ1UfmNd3Bu6S0ByF2U1N5UMllrtgKACoVPXUTLZVBM+hvfRmsX6R7qvl3/5R4/iVV899DFRFdPL4PavWWUydaOlZngpySLetiVxL1t7BRvj2k6TevhXdF9h3WBwi9PLKAIfxzz0Z5vYehP2Mm2F7FQjM1ExKJvcOiETJ6/G4A9kVcgnFcSFPYQq3ia7CDSqzQnlKAMxNfQIp+ZG1TT++w2QHk+1CniuwJ/SgxKE7ldAMP3WSi+ObaafZ8B/4dSFEUZ0SFjt7u/PEnkyjdf7lkGct7OLBl6OySRjdF90qYduVaK6YGergVBg2RiPby5HgTxBzG/b7+nPV4C/PTTWbh749NNE6/ZRVewDDgnHCwMmr7AHQ==; 5:whv8cPoZcEpsFszKe77AIpREMo61LogEevEo45N0xNK+ZtkiC9sdPBPYoYhhbAQJGEH/8zGWnNb2aQHRNp42kiADQ2VV7oTczIX+EAtueKfVqXIptt5lXhtCA67ntSvWiaC2Wh7svCxzAsDThTtuTLSgLw42ChDqFw35nP1OTXU=; 7:V8TkWlWpOMyatDN9JX/PeYXMTPdAuXr7Hz224MwacxBK6N3tzR2UViQmo+oCqqIXm2CM7wwQscnA2qoDs+macma5+yuJ7ILPOtTfe0fQU+r3mSJAj8MA2mnulUg52o8EB92eKt7vueh/8VOh5887RA== x-ms-office365-filtering-correlation-id: e75d8cd2-b7ed-4c69-21dc-08d650d27238 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)(376002)(136003)(396003)(39860400002)(366004)(346002)(189003)(199004)(76176011)(26005)(39060400002)(36756003)(6436002)(14454004)(102836004)(6506007)(4326008)(66066001)(105586002)(386003)(86362001)(8936002)(71190400001)(256004)(118296001)(186003)(106356001)(2906002)(6116002)(7736002)(2616005)(6486002)(316002)(11346002)(8676002)(476003)(446003)(25786009)(54906003)(97736004)(305945005)(478600001)(486006)(5660300001)(3846002)(81166006)(53936002)(81156014)(68736007)(110136005)(2501003)(2900100001)(6512007)(7416002)(71200400001)(99286004)(52116002); 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: EE5bqFX89AmDtStkEf7aA2J6cGBTI6YAsvOxS9h2B2vhODjfGLOJFX1RFwbKSBI09q3r4ISijJw/UADj/B3KjNhuKEgurA+m5L9W4PCyiLHp8CfMicS+cnEIXsmEUyY8FMQXbqRcT4a9y0KVvNY8BOuzeHeu+GdaPYT0DKjitJKSZq8z63DSCi4j74Zxi0VTEVUon53yh8EP7eFwbdGfY/+627dPGgTkkGKu9OpUaA6RhueHHXEHcWAE+o/8cpomeeb7sbh5yfltrz/Rqa61MMv+uaw0ANsbxVtq/dh2JqvybpZJGS0jL2cZ8NEjmHaCRuR3zTIopsHZWuswWCDSbSbOtETsLawEbLrK+ew/A5w= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: e75d8cd2-b7ed-4c69-21dc-08d650d27238 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Nov 2018 23:30:11.1901 (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 Following patches will change the way of distributing port object changes from a switchdev operation to a switchdev notifier. The switchdev code currently recursively descends through layers of lower devices, eventually calling the op on a front-panel port device. The notifier will instead be sent referencing the bridge port device, which may be a stacking device that's one of front-panel ports uppers, or a completely unrelated device. Dispatch the new events to ocelot_port_obj_add() resp. _del() to maintain the same behavior that the switchdev operation based code currently has. Pass through switchdev_handle_port_obj_add() / _del() to handle the recursive descend, because Ocelot supports LAG uppers. Register to the new switchdev blocking notifier chain to get the new events when they start getting distributed. Signed-off-by: Petr Machata Acked-by: Jiri Pirko --- drivers/net/ethernet/mscc/ocelot.c | 28 ++++++++++++++++++++++++++++ drivers/net/ethernet/mscc/ocelot.h | 1 + drivers/net/ethernet/mscc/ocelot_board.c | 3 +++ 3 files changed, 32 insertions(+) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 3238b9ee42f3..01403b530522 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1595,6 +1595,34 @@ struct notifier_block ocelot_netdevice_nb __read_mostly = { }; EXPORT_SYMBOL(ocelot_netdevice_nb); +static int ocelot_switchdev_blocking_event(struct notifier_block *unused, + unsigned long event, void *ptr) +{ + struct net_device *dev = switchdev_notifier_info_to_dev(ptr); + int err; + + switch (event) { + /* Blocking events. */ + case SWITCHDEV_PORT_OBJ_ADD: + err = switchdev_handle_port_obj_add(dev, ptr, + ocelot_netdevice_dev_check, + ocelot_port_obj_add); + return notifier_from_errno(err); + case SWITCHDEV_PORT_OBJ_DEL: + err = switchdev_handle_port_obj_del(dev, ptr, + ocelot_netdevice_dev_check, + ocelot_port_obj_del); + return notifier_from_errno(err); + } + + return NOTIFY_DONE; +} + +struct notifier_block ocelot_switchdev_blocking_nb __read_mostly = { + .notifier_call = ocelot_switchdev_blocking_event, +}; +EXPORT_SYMBOL(ocelot_switchdev_blocking_nb); + int ocelot_probe_port(struct ocelot *ocelot, u8 port, void __iomem *regs, struct phy_device *phy) diff --git a/drivers/net/ethernet/mscc/ocelot.h b/drivers/net/ethernet/mscc/ocelot.h index 62c7c8eb00d9..086775f7b52f 100644 --- a/drivers/net/ethernet/mscc/ocelot.h +++ b/drivers/net/ethernet/mscc/ocelot.h @@ -499,5 +499,6 @@ int ocelot_probe_port(struct ocelot *ocelot, u8 port, struct phy_device *phy); extern struct notifier_block ocelot_netdevice_nb; +extern struct notifier_block ocelot_switchdev_blocking_nb; #endif diff --git a/drivers/net/ethernet/mscc/ocelot_board.c b/drivers/net/ethernet/mscc/ocelot_board.c index 4c23d18bbf44..ca3ea2fbfcd0 100644 --- a/drivers/net/ethernet/mscc/ocelot_board.c +++ b/drivers/net/ethernet/mscc/ocelot_board.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "ocelot.h" @@ -328,6 +329,7 @@ static int mscc_ocelot_probe(struct platform_device *pdev) } register_netdevice_notifier(&ocelot_netdevice_nb); + register_switchdev_blocking_notifier(&ocelot_switchdev_blocking_nb); dev_info(&pdev->dev, "Ocelot switch probed\n"); @@ -342,6 +344,7 @@ static int mscc_ocelot_remove(struct platform_device *pdev) struct ocelot *ocelot = platform_get_drvdata(pdev); ocelot_deinit(ocelot); + unregister_switchdev_blocking_notifier(&ocelot_switchdev_blocking_nb); unregister_netdevice_notifier(&ocelot_netdevice_nb); return 0; 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, From patchwork Thu Nov 22 23:48:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 1002076 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="ZFTqWHt0"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 431GNK6HJjz9s1x for ; Fri, 23 Nov 2018 10:48:17 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392631AbeKWKaC (ORCPT ); Fri, 23 Nov 2018 05:30:02 -0500 Received: from mail-eopbgr30080.outbound.protection.outlook.com ([40.107.3.80]:36896 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389089AbeKWKaC (ORCPT ); Fri, 23 Nov 2018 05:30:02 -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=O02fLjbutH4UnIQ5H2Ve+mPoFUrxN6nxGHYXhiWqhR8=; b=ZFTqWHt0CF9gc/Hker4ksdJV+KlPvDjlHLpZWNWeCDclPdwELPRtswh9Rsw89k4dVYtv6dbNLxPoReSUJc4MjcKVy/MhDegJIX+5Gsjy8cvLItXigR7Nctj7Kmvnj9xAFIct49Eu9JJJEcm9BkiEjpu7yi0OO5U5I3+anT/8rh4= Received: from VI1PR05MB4191.eurprd05.prod.outlook.com (10.171.183.17) by VI1PR05MB1213.eurprd05.prod.outlook.com (10.162.15.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.37; Thu, 22 Nov 2018 23:48:05 +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:48:05 +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 12/12] rocker, dsa, ethsw: Don't filter VLAN events on bridge itself Thread-Topic: [PATCH net-next 12/12] rocker, dsa, ethsw: Don't filter VLAN events on bridge itself Thread-Index: AQHUgr3QHSHthJkWq0Si6x4JpY01dA== Date: Thu, 22 Nov 2018 23:48:05 +0000 Message-ID: <204cb0f410475e86c3495d9aac08b661be82a210.1542927590.git.petrm@mellanox.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: CWLP265CA0280.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:5c::28) 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; VI1PR05MB1213; 6:hQdWKQ3i4iSn+mHrZoJ5RlVRi7m6vLKHXpSjy40I+odBl+ebKNwdfwiWtcWZV4ivi4cT5JEtXj8cSyzTWu9ZOAEvh/sGNJ5HAXGs1Dsq6eoE20por0hLLpWpcEAwGI8fGnSj+rOVziC0rMP4FQc5VN/V38fEN6IAB6r9gOpBXXxfB5bE3msPFaNvYeK/vm8Xd+8ghHMhLkp35rcwTr3TxwzN3z5075de9hrqu3uPg7P2Tth3lcPqS9Sl199BMX+Cj9UJswBQ20GU5LvtPmgFqmZCz0E8qlXXzcxm6A8oPCzRemHs85acFxHjcRvjTAXUQFs0PQn2BJaxFMY2p1y4rEZnKPybM/EZQfK9iGzLvcSJf9gopK1OpCasdZDK0iaOUwEi3cyCIvcwCsbeDCvmXNZ8iIkXgX59Hl/VfvhASDMw9sPa1o6z0WKSvf3kkuOK9MhtiXdZHe3jSWL4xenswUzwI10VEst+TsEyh9KcQos=; 5:OmGT0whKD5dXxKFNE65SUrIHpi9sEbruGAW8iNmngmAnGlG8DijA7oN1WCHiQrnVF+E/k9g5dqsteDxSwSfLH84MfLFT8WwXXVq1o3ZeqWL59kTluu15Hs1ycnNYxvxAmfRqiahiYaeIj1GTNXYrT1Tg8zDnAhnKEOG/aUCWhrA=; 7:meSiC1TCP+Bi/nj0VdnjDrT8x3+FJgI7jy7qQ+9WS07mJQKKRX8vphcFBJu81z0sQ+3Zcr2wpPrKUn4Dq5eCFYWd6j1N9M699dyM07WTilKKB+gwnuvDlVCNsqSBOH+b3yGYaUdBUpDCBn8oItO/kQ== x-ms-office365-filtering-correlation-id: 79cfa1df-5152-4509-90e0-08d650d4f2a2 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:VI1PR05MB1213; x-ms-traffictypediagnostic: VI1PR05MB1213: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3231442)(944501410)(52105112)(3002001)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(201708071742011)(7699051)(76991095); SRVR:VI1PR05MB1213; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB1213; x-forefront-prvs: 0864A36BBF x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(39860400002)(366004)(346002)(396003)(376002)(189003)(199004)(486006)(81156014)(386003)(478600001)(7736002)(36756003)(6512007)(118296001)(53936002)(305945005)(81166006)(4326008)(446003)(66066001)(8676002)(54906003)(2616005)(316002)(97736004)(11346002)(5660300001)(2906002)(2501003)(6486002)(86362001)(7416002)(476003)(2900100001)(6506007)(99286004)(256004)(25786009)(6116002)(71190400001)(71200400001)(3846002)(105586002)(110136005)(6436002)(39060400002)(106356001)(26005)(186003)(14454004)(8936002)(68736007)(52116002)(76176011)(102836004); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB1213; 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: r1Q6d4d7AOct7hXZ2GwlBgBQppSdBxT+DRo8kwdnEjchlmUuyk7c8AdMXhomqBLavjuDy4O7mG6mU6mrM8MiMGPhSa24VUuflo1IOurINUbsvTyaAbFOJ3xT1bzzUYVt38E45/EYyE51PKgxKXuE3jXti0LMLNPl0PEuxe3PHKeA7BANaxGI4dBAXyrc9ilIazg9xoPNzG5jpwV/k27b0gaKurwSni7DmmLctESDZ9p80Bi4uIoLagd9VUfZ03JEiZfQzk0vaJ+7MZQBh1sxZepsfDN6tUiEBszy0kRjDsq2F1vIg35lq64cpS254rsyscN6wGesJuNeBsPn7o2niLRmenWgIRCl3s9e1CMRxsU= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 79cfa1df-5152-4509-90e0-08d650d4f2a2 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Nov 2018 23:48:05.6294 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB1213 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Due to an explicit check in rocker_world_port_obj_vlan_add(), dsa_slave_switchdev_event() resp. port_switchdev_event(), VLAN objects that are added to a device that is not a front-panel port device are ignored. Therefore this check is immaterial. Signed-off-by: Petr Machata Acked-by: Jiri Pirko --- drivers/net/ethernet/rocker/rocker_main.c | 3 --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 3 --- net/dsa/port.c | 3 --- 3 files changed, 9 deletions(-) diff --git a/drivers/net/ethernet/rocker/rocker_main.c b/drivers/net/ethernet/rocker/rocker_main.c index f05d5c1341b6..6213827e3956 100644 --- a/drivers/net/ethernet/rocker/rocker_main.c +++ b/drivers/net/ethernet/rocker/rocker_main.c @@ -1632,9 +1632,6 @@ rocker_world_port_obj_vlan_add(struct rocker_port *rocker_port, { struct rocker_world_ops *wops = rocker_port->rocker->wops; - if (netif_is_bridge_master(vlan->obj.orig_dev)) - return -EOPNOTSUPP; - if (!wops->port_obj_vlan_add) return -EOPNOTSUPP; diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index 06a233c7cdd3..4fa37d6e598b 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -719,9 +719,6 @@ static int port_vlans_add(struct net_device *netdev, struct ethsw_port_priv *port_priv = netdev_priv(netdev); int vid, err = 0; - if (netif_is_bridge_master(vlan->obj.orig_dev)) - return -EOPNOTSUPP; - if (switchdev_trans_ph_prepare(trans)) return 0; diff --git a/net/dsa/port.c b/net/dsa/port.c index ed0595459df1..2d7e01b23572 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -252,9 +252,6 @@ int dsa_port_vlan_add(struct dsa_port *dp, .vlan = vlan, }; - if (netif_is_bridge_master(vlan->obj.orig_dev)) - return -EOPNOTSUPP; - if (br_vlan_enabled(dp->bridge_dev)) return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_ADD, &info);