From patchwork Tue Apr 24 23:08:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10361181 X-Patchwork-Delegate: idosch@idosch.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2B4FE6038F for ; Tue, 24 Apr 2018 23:08:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1845328D53 for ; Tue, 24 Apr 2018 23:08:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B3D428E86; Tue, 24 Apr 2018 23:08:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, MAILING_LIST_MULTI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EA93E28D53 for ; Tue, 24 Apr 2018 23:08:40 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40VzXQ2bMYzF24Y for ; Wed, 25 Apr 2018 09:08:38 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="ibuWvCpW"; dkim-atps=neutral X-Original-To: linux-mlxsw@lists.ozlabs.org Delivered-To: linux-mlxsw@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=mellanox.com (client-ip=104.47.0.58; helo=eur01-he1-obe.outbound.protection.outlook.com; envelope-from=petrm@mellanox.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="ibuWvCpW"; dkim-atps=neutral Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0058.outbound.protection.outlook.com [104.47.0.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40VzXJ4hGDzDqRk for ; Wed, 25 Apr 2018 09:08:31 +1000 (AEST) 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; bh=HEelJYq8Fp7v5+QFe18XLe+YSZRSqbtI0p+luDfGKv4=; b=ibuWvCpWFZ5Y4+YLMLjkl2myFIp+6eIFS1VrqA29P+EiZT4hud3w0RvycbSPYEnRXvuwpnWQWpL7bVwKY1rpH0WU+GvxKgWibcKLtRksNQ7B0riscv29h9cQG0HzDg80vbb+HximoTJXAqE3A1RAhy8q+49tn0nKz782TRaj0l0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (89.177.127.115) by DB7PR05MB4186.eurprd05.prod.outlook.com (2603:10a6:5:18::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.17; Tue, 24 Apr 2018 23:08:23 +0000 From: Petr Machata To: Subject: [PATCH net-next mlxsw v2 6/7] mlxsw: Respin SPAN on switchdev events In-Reply-To: References: Message-Id: <948a334a17b35e6ec03de5513fc8bd9dc27a9bb2.1524610426.git.petrm@mellanox.com> Date: Wed, 25 Apr 2018 01:08:17 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [89.177.127.115] X-ClientProxiedBy: AM5PR0602CA0008.eurprd06.prod.outlook.com (2603:10a6:203:a3::18) To DB7PR05MB4186.eurprd05.prod.outlook.com (2603:10a6:5:18::27) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(2017052603328)(7153060)(7193020); SRVR:DB7PR05MB4186; X-Microsoft-Exchange-Diagnostics: 1; DB7PR05MB4186; 3:bJwp+41R7OyKhLitU2C83JRDfw+g9c5nlW4lA/WrduoHZ3bbh6YPwB7GJ3Q+BWWAqHut9slyxe6QTn+miVXEAb4SYrz2+b+p1lDTJvYbCaJ3NHebjudkMZd/xxD8m0dR5XPdMkipyFyAucvh9uKt/NpZCzqJd9yfE8n9ZNROCgFRcDZAFGdOLdKa/cC9NB3VY/gE3DVkpcvhSrl1Itknhnhfu43dcAgYRvNToImSyK3m1oNsBPvWiC+rRyrUeUhb; 25:dCV3vwM4IT2SVzPUs1Uz5bKmkq6sELsaRHz7yK60Q09j43nTFpEw2qjV0C0JnVRP5SeRBkMB5xkMMYaqQ7i/QfmLY3TgAXie5kUu1+KQMJaTOev5dufaGNE7FwB0zNlWdbI8312KWIlV0Ad8oVWcolDuoRKBNWKhKmfiafCtmfIMlcScw4o2dAm1/RAdhlmsnZZiJNhWtpkdhtn5V42QaAWsjNE4kKNcpgUae93+f91D+0Tw/Xuwi93XNcAWoECuwUoCveSKO2+w+gdGsoBmt05pz4SrbvvcAxtSwbtyohoUrxaLlG+ehGqOIMRh/6eNKFHJLQHeqUSTjI89f9j0bQ==; 31:IxDOvbn9buUik+cvJgYEGidPp46CbnXdjpI4oemY5FgCJ3uu86NPviOpDAt6/Qp6yjWPyam2N8wlONR5apJjUYhf7I9JfBri3gCy5nPF+b0t1VXoqy/oCmsZR3menHh89hgBP6PLNQIddcLqKY4avHvam1T3p+iP/DSlDVukV63b8aohckFblVgLXsZewbZAHzo16Pd6qZ8oIhTmr0gRq7ovhNiRGO7dVNjAHqhktMs= X-MS-TrafficTypeDiagnostic: DB7PR05MB4186: X-Microsoft-Exchange-Diagnostics: 1; DB7PR05MB4186; 20:aEO6q7ffjOe0gDR8UoWVHDYnrG1gsxhljsPCVroCHmFwRKOqa/7+JzYk9wM/fnu24g3Pwnb9tc4OW5+RQvl5Oie0/IRm6Hhm+ogRcWQdTB8LR5AxMk0R3pCBrfYQRY08eJn43tFYxqfHe0hkWUsXtsXt93V4wkRza0oKnGrPoT3Xmpo99vxGg1guhCotQch8RDzGwLdNuzmrZIhZihfuzTUq5J6EzDl1NjqEGRXoL8SlyGV9uSRm+Twn2MjcyIYY+S6P99nfd28bEJLRPnvWJHmkCk6WpQCNkqnYgz2KeWGoqD+uGQnLygh4XxXupl24/HwKqNDF6imWhXJHQl6C55wsJFh16PLeG2yG2VDunGmpQNhs8V9ZJdzt7IB/eHtLJxODfvFMiWdgNeNL9M9PE9aCwgzz1IJI9UImuhmnMkw9mrnE2hlcoHb+p1jKs6u7CRFeMIPyS01Wgd06Das83A94H/dOlbp8J+spWp/g4whRO4mwOieFpGZlxWD8Cco4; 4:PUONHqInrJf6+fsY03APOEoBiTb4HVraIrOWLbHrx/cJeAc0+12p7liYDwoyQ2MiR8o9Of0YvADxg8HEP7Ck6tDspWj2le3lIxlQcMo2+7FPFDScmsJZrn5G874EQvwidk1W9qEqJM+CFsmpkq9IYXsSeaselPced6TBRyfu/xUGPao5EMAilq2t08XtLO7qxoigvkt7IL8ZGL8twja7UM20kbClHY743xmBtoUSZN8DEKiNpYZkjOA7fvTdc1snfMqMIhdE+6z8ZOJ8ktbp5g== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231232)(944501410)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(20161123560045)(20161123558120)(6072148)(201708071742011); SRVR:DB7PR05MB4186; BCL:0; PCL:0; RULEID:; SRVR:DB7PR05MB4186; X-Forefront-PRVS: 0652EA5565 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(376002)(39860400002)(366004)(346002)(39380400002)(199004)(189003)(6116002)(25786009)(2906002)(11346002)(81166006)(81156014)(7736002)(6916009)(36756003)(8676002)(478600001)(97736004)(6666003)(53936002)(86362001)(476003)(5660300001)(16586007)(486006)(956004)(3846002)(2616005)(8936002)(316002)(305945005)(446003)(58126008)(68736007)(26005)(47776003)(6486002)(4326008)(107886003)(118296001)(59450400001)(386003)(16526019)(66066001)(48376002)(2351001)(50466002)(52116002)(76176011)(6496006)(51416003)(106356001)(105586002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR05MB4186; H:t540p; 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-Exchange-Diagnostics: =?us-ascii?Q?1; DB7PR05MB4186; 23:+iNRVX43i1TRznlRci6dqMvZJUFtQ+SM5YMD7D64+?= =?us-ascii?Q?nh2sGqEU+xtrmbX14yiefVbL/UGl01leZwAqDLH0OH7c5scW/iLa2n6sR3Y+?= =?us-ascii?Q?qyfghUhjFsjmUt0pLnO/KlUG0sw3dSFGFoxhYzvu+VxoelaRjKcS9+F/a7rZ?= =?us-ascii?Q?mp+iVCb61SBEG9haaED19p5sQC7iiXt2VZtKnF7pVOO1YrJA32LWfu8x8onp?= =?us-ascii?Q?XR+vrjS0hOmWvMtya1gqFeMxKZaUtC6PgqvEY9pd/kC1FiLKqlY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aq1L9KkICGYZ1rnJ7e346XOjnOMZO79uEZMcdUlfnNK3gf2A6ZnFE?= =?us-ascii?Q?xMsb+ZsM23KrhTwJmuAwbJ34XZNrQw8FArhCAEApZWODI/93rOcDorOxQ=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Antispam-Message-Info: e0iYSEn/5gH9dk/R/raUc2Tke1A99K7U3U3WBLo2tLpchY9aviT8MwXpLwYE28tXH0rXkpk+wyrQOSyyTL6fycbUV7PEqQ0qxkag+quOzsivxYkda5pB4YWoylpmhCowQCYoFyQf/RQerL85ebH8F0Zx/QA4SJAOoPGN2Qsjuz8PVp05NvtIbrPjpSPev4F1 X-Microsoft-Exchange-Diagnostics: 1; DB7PR05MB4186; 6:GyOYoB5/BEpfmR0FIIiQa32pGsonw7p0yqt7skiu5EvfSzWtmWDw7Lc6cDZe3zcTId1i7umDNHxppLCFSLML5QNf9pIDhRIi98l2SEdArDLhHvbaUeXURkXlllhK9HBEoQqZtiCiStyRS8y1AQfbe+LBWHzHYvTzLTkCx2TGabehk91MHTFlhEGqp7QiP+RqoQbzDG4f9rXdwA7gEgyUQpgToFf0cGS7wTt/3cion6colBzDhxDcRLfSXB7agfNc1firJhBcCbmMp+SAjXTb8ia1yR5Du22+HyvNVwmYVO2dzSad68ymec/fZNJ+HK6zQ5eN4vXEWBU9GIURhjghZ1uWs0Qv9sfCbbUKZKPe3/4YJnSav2FafqwWVfuKEDhi6L9IoPwWogVu8762rBsLV+47PDYtHQAK3koxM/2oD1qPfpXU+FYUSiVWrZRxWbsB0rH260A6EuMWOojipScu6A==; 5:RiSkyigCNY/g9sGM1Q7WOJ/usrIrwQrolhoaS1DuPTSOMoxHF7BP+fM74JGU4hnwQ8Tj8Oq4LJ/iKvwJgUEVNbjQj7lMq9JxCWm79jiiWAoZaRoqC08I2La7APwXZKhACP1keQiosHgoHQTI34Or8he8uzqHSc0wT21SBZhaTbA=; 24:c8z96JjVSKyVx6n1cwZYQ/DTCAr7LrNk0z/RdyTWFcprfgYo50xQQm2E6ht2o8REbCehybqy2F0CvJL6dWaTakgv0u4ZrlNRbF9BzvH/s08= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB7PR05MB4186; 7:Qr3+kR83AM8rp8o7vx2Xt+R15yNVzZty1ADQlyr0G2m8xeHDwYDH80nTQAgxZPCbIpXiVQ9WMTLwTzp/kyPtwGCM8DoAkLi3Bog70QVJeqa8txYl4yhIRB89/h2MZS+uJ9p0FXZkpIBHd1oTL4Zcl5DMl0FyUtsFtU4O63PayhF/9i+hwPT6Sem1SV9jSoIzpx2SYf81vzt1I/Ke/mHYmNVyzCssugtEiWAfvPhm4+MVtU1ZuYM1jFn5puJ8Jkf3 X-MS-Office365-Filtering-Correlation-Id: cd74e8ce-3d7a-4cbb-5149-08d5aa3847b2 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2018 23:08:23.8052 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cd74e8ce-3d7a-4cbb-5149-08d5aa3847b2 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR05MB4186 X-BeenThere: linux-mlxsw@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: mlxsw driver development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-internal@mellanox.com Errors-To: linux-mlxsw-bounces+patchwork-linux-mlxsw=patchwork.kernel.org@lists.ozlabs.org Sender: "Linux-mlxsw" X-Virus-Scanned: ClamAV using ClamSMTP Changes to switchdev artifact can make a SPAN entry offloadable or unoffloadable. To that end: - Listen to SWITCHDEV_FDB_*_TO_BRIDGE notifications in addition to the *_TO_DEVICE ones, to catch whatever activity is sent to the bridge (likely by mlxsw itself). On each FDB notification, respin SPAN to reconcile it with the FDB changes. - Also respin on switchdev port attribute changes (which currently covers changes to STP state of ports) and port object additions and removals. Signed-off-by: Petr Machata --- Notes: Changes from v1 to v2: - In mlxsw_sp_switchdev_event_work(), add SWITCHDEV_FDB_*_TO_BRIDGE with a do-nothing handler to make it clear that these events expected. - Don't respin unless the switchdev event in question is a commit (as opposed to prepare). - Respin in mlxsw_sp_port_obj_add() and mlxsw_sp_port_obj_del(). .../ethernet/mellanox/mlxsw/spectrum_switchdev.c | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c index db4aea0..a6bfbfe 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c @@ -49,6 +49,7 @@ #include #include +#include "spectrum_span.h" #include "spectrum_router.h" #include "spectrum_switchdev.h" #include "spectrum.h" @@ -923,6 +924,9 @@ static int mlxsw_sp_port_attr_set(struct net_device *dev, break; } + if (switchdev_trans_ph_commit(trans)) + mlxsw_sp_span_respin(mlxsw_sp_port->mlxsw_sp, NULL); + return err; } @@ -1652,13 +1656,15 @@ static int mlxsw_sp_port_obj_add(struct net_device *dev, struct switchdev_trans *trans) { struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); + const struct switchdev_obj_port_vlan *vlan; int err = 0; switch (obj->id) { case SWITCHDEV_OBJ_ID_PORT_VLAN: - err = mlxsw_sp_port_vlans_add(mlxsw_sp_port, - SWITCHDEV_OBJ_PORT_VLAN(obj), - trans); + vlan = SWITCHDEV_OBJ_PORT_VLAN(obj); + err = mlxsw_sp_port_vlans_add(mlxsw_sp_port, vlan, trans); + if (switchdev_trans_ph_commit(trans)) + mlxsw_sp_span_respin(mlxsw_sp_port->mlxsw_sp, vlan); break; case SWITCHDEV_OBJ_ID_PORT_MDB: err = mlxsw_sp_port_mdb_add(mlxsw_sp_port, @@ -1809,6 +1815,8 @@ static int mlxsw_sp_port_obj_del(struct net_device *dev, break; } + mlxsw_sp_span_respin(mlxsw_sp_port->mlxsw_sp, NULL); + return err; } @@ -2236,8 +2244,13 @@ static void mlxsw_sp_switchdev_event_work(struct work_struct *work) fdb_info = &switchdev_work->fdb_info; mlxsw_sp_port_fdb_set(mlxsw_sp_port, fdb_info, false); break; + case SWITCHDEV_FDB_ADD_TO_BRIDGE: /* fall through */ + case SWITCHDEV_FDB_DEL_TO_BRIDGE: + break; } + mlxsw_sp_span_respin(mlxsw_sp_port->mlxsw_sp, NULL); + out: rtnl_unlock(); kfree(switchdev_work->fdb_info.addr); @@ -2266,7 +2279,9 @@ static int mlxsw_sp_switchdev_event(struct notifier_block *unused, switch (event) { case SWITCHDEV_FDB_ADD_TO_DEVICE: /* fall through */ - case SWITCHDEV_FDB_DEL_TO_DEVICE: + case SWITCHDEV_FDB_DEL_TO_DEVICE: /* fall through */ + case SWITCHDEV_FDB_ADD_TO_BRIDGE: /* fall through */ + case SWITCHDEV_FDB_DEL_TO_BRIDGE: memcpy(&switchdev_work->fdb_info, ptr, sizeof(switchdev_work->fdb_info)); switchdev_work->fdb_info.addr = kzalloc(ETH_ALEN, GFP_ATOMIC);