From patchwork Fri Apr 27 23:01:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10369989 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 B0AEF6038F for ; Fri, 27 Apr 2018 23:01:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B1A92959A for ; Fri, 27 Apr 2018 23:01:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89D0D2959B; Fri, 27 Apr 2018 23:01:51 +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 40155295B2 for ; Fri, 27 Apr 2018 23:01:39 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40XqDx4gfBzF25s for ; Sat, 28 Apr 2018 09:01:37 +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="TIqnR0fV"; 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=40.107.4.89; helo=eur03-db5-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="TIqnR0fV"; dkim-atps=neutral Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40089.outbound.protection.outlook.com [40.107.4.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40XqDp524ZzF24m for ; Sat, 28 Apr 2018 09:01:30 +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=A3f8uj+mw9XNzQ2WKEgiNpOn5yyhKxfbfyuecEeyu64=; b=TIqnR0fVZxx50M3Z/qhd+puVXO/+jqmuw1t3sVX1rk1/BRIkSyG9ckoINEZ512siMm8W3NlcUlWgGv3IVM8fVHbzNhqIkJd8f2QuNSP4zNhgshrmUuYqfRNhX3l9P/LWbtj8hr0PiX4xzQLHkfB1QtRO+ZM+8YEru4ymzGY//Jc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (89.176.83.59) by VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.15; Fri, 27 Apr 2018 23:01:26 +0000 From: Petr Machata To: Subject: [PATCH net-next mlxsw v3 5/6] mlxsw: Respin SPAN on switchdev events In-Reply-To: References: Message-Id: Date: Sat, 28 Apr 2018 01:01:24 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [89.176.83.59] X-ClientProxiedBy: AM3PR04CA0131.eurprd04.prod.outlook.com (2603:10a6:207::15) To VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) 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:VI1PR05MB4191; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 3:dgh0FcaDg7J2TSuVRnHLv9nam0BqyFnA8Brg38wTokEpnbc+ONPZHirCQ1rLJ5AVXvNhWyJgksOR5tbJd7PqO1ISspoZo3DMUKVm4wtLa/l+bXp/uuqAtoAqf9w6V3MNWrgKgKyvJfvHEbpWYkVhgesrmEX94SMI1gzS1CFDBv9TO6sGUBXnD/pRx/ETOcF0emyVxOLB1zGrZ+6/hpbqJbImTeiFw05Wt89ybBiPnyaG5Fjd86uK4kNgVzwF3fGp; 25:NTDNUEXDqGiP3v82KDYwBs261Uu9DsO7qcfxnvQZPYfuIfCliT/C4uBkEBru96mMI5J0hc/I08CQ8Mq1biMWyYWRg5gqJUO8q4DIHHfQ8XjAB+2vz8WkV0/zr0m4KonS5Rw/ozJl9/Eb/MP6ulXXg820FAfoFN5a56A/QF9kVlkXz07jzMxEoc124GpcTEcQeV723U0z2AP2lEeUutdqkMv7XmCFXmnPo4Vsg8mRlKNvbRvGpxsfMWjrnsPlDOeylHy0M1XPgp9Zq+WM1LQaNSKi6OsNBVKhDIN0Rs1IsmoLEqC9MHiqg1TR17maqoaqocb9K7tUgvYGljfig8L+aw==; 31:vrbgHU026dV8VT0hTJZ/XqVvYDy68UBtpgvh3jNSwywI0jrJpqeq6p4ygEYFe40FYYi0z2GNEcNYSLUdQYibbdVO+Ky++OFhEv3cVnxzqLPEQF7NrBiMXvPRcM+qR2FQE0o6tXPPvQZSssD0sdVlJJZ8s9JBFuomEAjmpv7ydrwgMTB68lPCO3X7o93d3gneu4doe3MKj1xzeQCq3RCySrDvQP7CbBrCbyZdkHOkGNQ= X-MS-TrafficTypeDiagnostic: VI1PR05MB4191: X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 20:t5dganIhkNLMkGwF9/8tn/tK9uczDyt4mFQ8NOhNwCXm+mAZM6/zJXr5e4qLwCfUkMIBEg4EoDDLrw3CtumFwHx6Ln7zEE7WkdGHw2b+/dqrurvXpFj4k6CYJjnmPU/S0qq9zOVVe9s5JsQSLSUUEklpe6ksoLZ1n4qmwyQCozAcBojGPanbkjiRexihoQWJYW08ARbWl2l+d12DrbQpIOPfCydUwp4stoukheqgXWjjMgsrt4Ah4UvOFt0O7DZG+HEgW5uwJfje21XimMYs/JaO1RXRmekMVcI7+udL5zpHJXI5u5/wlStVXmZ3CuUrVDTfZFEYGJV83eGrnAQnseWHLjE4wWOOt+dCocOgtxHkQBNffe/2yCrIiU+p0LFBfuuxE63wSrELhFx6Pz8UOfmFp93wHvc2y9zWbcI51xyUyP6Tcv++cVx6CY6NNv9OXF8j6OzgjJ/MgjcN3+XOH1aC9qJAes+I9ifuS+1BlQsFODXrbXpCgAsipqmR3eab; 4:CzxPWTjQAwte6lo7CwSVUPb9M6ueF5Sjta69uTP/hrNYnyprMHX2+ZmksjpRg6gJkOJbION1lb7Fe+jT19qHz9oFfx+l5UfBmNxl7YFfJtmPPnWTiA7C02wjqpRU2DPl15o3jbAE+DEzlMUBhM+Z6gWCDf3m2N50zc/Nmtj7iNRFBSmWhbWE9COpIS6Z01qvcBt6GhxFBKMEAXFzeaIGtFGusnY5rggjeQ7ZesZ0pBW75tKio9KoHP9Ef80h4UjMoexqU7anJWavf9v4ziv3mA== 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)(93006095)(93001095)(10201501046)(3231243)(944501410)(52105095)(3002001)(6055026)(6041310)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(6072148)(201708071742011); SRVR:VI1PR05MB4191; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB4191; X-Forefront-PRVS: 0655F9F006 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(39860400002)(39380400002)(396003)(346002)(366004)(189003)(199004)(476003)(2616005)(5660300001)(6486002)(53936002)(66066001)(486006)(86362001)(97736004)(6916009)(305945005)(26005)(48376002)(105586002)(107886003)(50466002)(106356001)(956004)(11346002)(6496006)(446003)(16586007)(2351001)(478600001)(2906002)(4326008)(6116002)(25786009)(51416003)(8936002)(81156014)(36756003)(68736007)(8676002)(118296001)(58126008)(81166006)(59450400001)(386003)(316002)(52116002)(47776003)(7736002)(76176011)(3846002)(16526019); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB4191; H:t540p; 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-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR05MB4191; 23:lffJtGRDQ7M7eHNKh/aYWTV5JwOD/HomTsf044Lrl?= =?us-ascii?Q?30yCPlOLLbU9FUu0I3ycjfFkZT3EFlbPVmvsnlvLRC4FdcfkzXFVBiGfy/Ko?= =?us-ascii?Q?Z9muG2yLyHONJUHmopIa97i1y77WrnBY7hovIJYGVrBckhRA7Vmvq4zXiz6X?= =?us-ascii?Q?6COvacqcfSMGY/l+XFDwVGNMloL2Duz+LihWVtbm+76K7b+uLALBWjWlMefz?= =?us-ascii?Q?XuAOZXulcL88Kezlbs3T1TgNpYXa5Ommv7SxCgLdo2/N1rfsWMjuYwafJBGB?= =?us-ascii?Q?v0XJ+PQPjC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3SU7U= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 7:EI9p2uuHP7XU7/FVKcORkN5bWrTXiIAnNlr/aEubEES6NFbukwZaDTwjlYg8eP6wzw2lZvxWUc77hU14Y4zQ1z/WZTX1tl1Xbz5F6M8xxBu0sfHt3y4lS7bPmXQHqeewG7itY9cuvIPE470kJqCLZYO9jclMuQRACJR91Vq5Dq3Jb9ngkrldNoq5yExPcDSvhHCyJdPys8AlXZQVenUkDvvf+TDbxQu3YWT0DX5JRyWoWWAYVn2dLt18kJPug7BZ X-MS-Office365-Filtering-Correlation-Id: 2ccb463f-0cd9-4adc-7ce4-08d5ac92ce6d X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Apr 2018 23:01:26.8465 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2ccb463f-0cd9-4adc-7ce4-08d5ac92ce6d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4191 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 --- .../ethernet/mellanox/mlxsw/spectrum_switchdev.c | 63 ++++++++++++++++++++-- 1 file changed, 59 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..1af99fe 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); + return err; } @@ -1647,18 +1651,57 @@ mlxsw_sp_port_mrouter_update_mdb(struct mlxsw_sp_port *mlxsw_sp_port, } } +struct mlxsw_sp_span_respin_work { + struct work_struct work; + struct mlxsw_sp *mlxsw_sp; +}; + +static void mlxsw_sp_span_respin_work(struct work_struct *work) +{ + struct mlxsw_sp_span_respin_work *respin_work = + container_of(work, struct mlxsw_sp_span_respin_work, work); + + rtnl_lock(); + mlxsw_sp_span_respin(respin_work->mlxsw_sp); + rtnl_unlock(); + kfree(respin_work); +} + +static void mlxsw_sp_span_respin_schedule(struct mlxsw_sp *mlxsw_sp) +{ + struct mlxsw_sp_span_respin_work *respin_work; + + respin_work = kzalloc(sizeof(*respin_work), GFP_ATOMIC); + if (!respin_work) + return; + + INIT_WORK(&respin_work->work, mlxsw_sp_span_respin_work); + respin_work->mlxsw_sp = mlxsw_sp; + + mlxsw_core_schedule_work(&respin_work->work); +} + static int mlxsw_sp_port_obj_add(struct net_device *dev, const struct switchdev_obj *obj, 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)) { + /* The event is emitted before the changes are actually + * applied to the bridge. Therefore schedule the respin + * call for later, so that the respin logic sees the + * updated bridge state. + */ + mlxsw_sp_span_respin_schedule(mlxsw_sp_port->mlxsw_sp); + } break; case SWITCHDEV_OBJ_ID_PORT_MDB: err = mlxsw_sp_port_mdb_add(mlxsw_sp_port, @@ -1809,6 +1852,8 @@ static int mlxsw_sp_port_obj_del(struct net_device *dev, break; } + mlxsw_sp_span_respin(mlxsw_sp_port->mlxsw_sp); + return err; } @@ -2236,8 +2281,16 @@ 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: + /* These events are only used to potentially update an existing + * SPAN mirror. + */ + break; } + mlxsw_sp_span_respin(mlxsw_sp_port->mlxsw_sp); + out: rtnl_unlock(); kfree(switchdev_work->fdb_info.addr); @@ -2266,7 +2319,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);