From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14660C4360F for ; Thu, 28 Feb 2019 06:59:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CAB2221850 for ; Thu, 28 Feb 2019 06:59:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=Mellanox.com header.i=@Mellanox.com header.b="h+FB3Vm7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731236AbfB1G7c (ORCPT ); Thu, 28 Feb 2019 01:59:32 -0500 Received: from mail-eopbgr150072.outbound.protection.outlook.com ([40.107.15.72]:44354 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730961AbfB1G73 (ORCPT ); Thu, 28 Feb 2019 01:59:29 -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=SZoD6/gBQHaK9ykJXRTAtoArON/q3L3SkoaRPlswKNM=; b=h+FB3Vm7uDr3XB8L1M9the86Jmx7UHzTTVEXBKmeqrXO8NH/fFy7OXplopfU10znVH4xQrFmLjAEXomIgNdWzsrIa014oHAb50DqohZsX/IAB/nHGIOcsbks4gZdeRHSg/WYG2ljCWQkGFqv+Tm+JsYf0Wc79Ye5klakUNq1jt8= Received: from AM6PR05MB5240.eurprd05.prod.outlook.com (20.177.196.214) by AM6PR05MB4168.eurprd05.prod.outlook.com (52.135.160.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.15; Thu, 28 Feb 2019 06:59:20 +0000 Received: from AM6PR05MB5240.eurprd05.prod.outlook.com ([fe80::458c:8deb:ca54:1327]) by AM6PR05MB5240.eurprd05.prod.outlook.com ([fe80::458c:8deb:ca54:1327%2]) with mapi id 15.20.1665.015; Thu, 28 Feb 2019 06:59:20 +0000 From: Ido Schimmel To: "netdev@vger.kernel.org" CC: "davem@davemloft.net" , Jiri Pirko , mlxsw , Ido Schimmel Subject: [PATCH net-next 05/14] mlxsw: spectrum_acl: Push code start/end from mlxsw_sp_acl_tcam_vregion_migrate() Thread-Topic: [PATCH net-next 05/14] mlxsw: spectrum_acl: Push code start/end from mlxsw_sp_acl_tcam_vregion_migrate() Thread-Index: AQHUzzMg68Ulq4gNY0Ss+43z8CYUdQ== Date: Thu, 28 Feb 2019 06:59:19 +0000 Message-ID: <20190228065850.7471-6-idosch@mellanox.com> References: <20190228065850.7471-1-idosch@mellanox.com> In-Reply-To: <20190228065850.7471-1-idosch@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6PR08CA0025.eurprd08.prod.outlook.com (2603:10a6:20b:c0::13) To AM6PR05MB5240.eurprd05.prod.outlook.com (2603:10a6:20b:64::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=idosch@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6cb7b8ff-8f6c-46d8-01dd-08d69d4a4309 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020);SRVR:AM6PR05MB4168; x-ms-traffictypediagnostic: AM6PR05MB4168: x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1;AM6PR05MB4168;23:f/idReJQ+CzRSOxX/197MiJ+Q7jpyWvBtUOy6/o?= =?iso-8859-1?Q?+L9hPtq9u6UAUszf+K05B/InvAsBlIlA3UPUe0KJtj0LkL2HX6yDIyxcS6?= =?iso-8859-1?Q?xeDMHOeRwvEXw3D1SUQsxHKQrwFRyO+8kHFf2FuNqOzBrJ8733MC5XUP2W?= =?iso-8859-1?Q?+scfRZNV+w10DCgv4YmUzfygMzmqFyUsUUfJ0Sk7Y2rsASNsi6NfI63QzL?= =?iso-8859-1?Q?+QRCixmofPC1mRqOLQUUM9zYeY+2v43xygYj6x0zWr1/HylLW39D37KOVR?= =?iso-8859-1?Q?vt0AZOYyBfDnh/l2Zi8FWANGIJU53Rvbj+15Rccd+cbZBkb2aao5FvJlpB?= =?iso-8859-1?Q?M3e+kgQSm8oGeyC2CYz2lx53FvL/CQqN3+QS+4TmFPKftplHVXrwmYQ8J9?= =?iso-8859-1?Q?k/9nABAvdLxAK3KHgwkZzKpxmpgZ8D1BlGLi1qX9cx9BX5rqSIJH6xF2/o?= =?iso-8859-1?Q?gTKrxFinPVcYaJmbJAfKDdLwjrTgdVO9bIE7skT3CGsLbVk7BEoxZinVJA?= =?iso-8859-1?Q?VLkm27wh4LZnn4MuN2lNkfywwWqTMSMmeUrsN+oZeGE61unwOpqDgry/kO?= =?iso-8859-1?Q?nTYtG9xoaBmJdPlNK//Bf1hX2HuaWhYLi+oyAN3MEWutwjCota7qQHqjA2?= =?iso-8859-1?Q?vJRmHqxd/62brnb9otgzHoRm4PwCAxNcZU41MyS6L9SoH0kecj6JKQFlOm?= =?iso-8859-1?Q?M+hAQtB0y0kDTiJBgI9gfOr+oF1wiE9gWWWrOG+BU5HoNP7fCFAA+oGoxi?= =?iso-8859-1?Q?tr4wWHkre6yjw4ixgqN7yiN5zYyrxlGFGImea3RBQLlim2Ks4NvmoxqVl7?= =?iso-8859-1?Q?IuMY9sUZR57UvV9auZBoGwzTQ6N5a13vUN9e1HqOeGYkZxQN8aFcQqo+rn?= =?iso-8859-1?Q?BD6qDQ1PfEDkVvqYFKumgI7EFhGBWJMv8zubW6l2A42/ioP+4LOP1HmadT?= =?iso-8859-1?Q?kNeWKuQA2g0LJg/EfOUh5dSnma2Jbqftov9zF5Bww6LKjOAgXFpAcYsa2A?= =?iso-8859-1?Q?lb9DKPOvnfBkgPDbBCsnqeIRfzQ0ogKpu44je9rHPIdLTU8FhqtCXvXntr?= =?iso-8859-1?Q?CNYHUdD47XjCyLBuySYPW0Sy+AyM+Gqn+stoWYOYUm+fZ3EnifT35aNwc5?= =?iso-8859-1?Q?tK4tvm/dV8t1+wwuZui4AYROlu6vn66FIhVe4XTDWuRWgp9wDQM/Z7Xz+f?= =?iso-8859-1?Q?UeeW5WGuxOXHaRf2r82pJkVHkdeTxr8kL1d7f4kC1/ZGdjPmGZUKZziMO5?= =?iso-8859-1?Q?K3BjSInhX9iTwkn7rjMUaf4pZkeYTB6kwaaUyc3xRXLBHv6iziw57jGmf3?= =?iso-8859-1?Q?mBWhYkfCvZ4raFX1EzgJ9/dQicPLShMjEy1i26yVtEOqeO7a/YettJcx/c?= =?iso-8859-1?Q?EeVc2jcPAx2rVS5wPMllUrOdCsg9Ps6sm04lxzHIobKLQS4jfZg=3D=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 0962D394D2 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(346002)(39860400002)(376002)(366004)(136003)(396003)(189003)(199004)(97736004)(86362001)(478600001)(99286004)(8676002)(2906002)(5660300002)(1730700003)(54906003)(81156014)(81166006)(2616005)(476003)(6512007)(1076003)(11346002)(4326008)(316002)(446003)(105586002)(50226002)(66066001)(8936002)(106356001)(25786009)(76176011)(107886003)(53936002)(6436002)(68736007)(2351001)(2501003)(486006)(5640700003)(6486002)(7736002)(6916009)(14454004)(305945005)(102836004)(26005)(36756003)(6116002)(3846002)(6506007)(386003)(14444005)(5024004)(186003)(256004)(52116002)(71200400001)(71190400001);DIR:OUT;SFP:1101;SCL:1;SRVR:AM6PR05MB4168;H:AM6PR05MB5240.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-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Jri0EOvj63GSvtazJ5WB+Ua77LIwWttC2pQH6WLNH7u15NcCxHXAf6h4zBMeZbAnnAU+waqh5XP+ls7EQB6Wg5CiFVfK+3uQwQcVB0QzUWsR5riPCcnC8N4YyQPA1Bulz6Q4rPhnHda7Vsf1V8mSsjwu92UVIPYse053TO+2DQAyJY5ixjM+tlWPUYhqf/zsLZ4wiYNLbKZ6Z/9lwHlpslIosjsI/B/WSI4dM9SPJW/ma4Xr/FhICYofR2GyrBDxdjXq7Zqf+t6AA9WQe5j+Ackj7fdNJAZsqGaRZqkKwIlRAylBYZrHG1DUPFkNdNHJ7tOZif/ytjLXaJszyI7ksaL7qoBR4RD4fqHfJn4bIC98Qk4Sy/3hem6UXq5l/gvJUKPVEyZxwSnMiUk4olaqJIISBUYj+PHDl3Pc3wLycLo= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6cb7b8ff-8f6c-46d8-01dd-08d69d4a4309 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Feb 2019 06:59:20.0290 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR05MB4168 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jiri Pirko Push code from the beginning and end of function mlxsw_sp_acl_tcam_vregion_migrate() into rehash_start()/end() functions. Then all the things needed to be done before and after the actual migration process will be grouped together. Signed-off-by: Jiri Pirko Signed-off-by: Ido Schimmel --- .../mellanox/mlxsw/spectrum_acl_tcam.c | 74 +++++++++---------- 1 file changed, 35 insertions(+), 39 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c b/driv= ers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c index fa204003bc84..cf901a1504c4 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c @@ -1277,59 +1277,24 @@ mlxsw_sp_acl_tcam_vregion_migrate(struct mlxsw_sp *= mlxsw_sp, struct mlxsw_sp_acl_tcam_vregion *vregion, struct mlxsw_sp_acl_tcam_rehash_ctx *ctx) { - unsigned int priority =3D mlxsw_sp_acl_tcam_vregion_prio(vregion); - struct mlxsw_sp_acl_tcam_region *region2, *unused_region; int err; =20 trace_mlxsw_sp_acl_tcam_vregion_migrate(mlxsw_sp, vregion); - - region2 =3D mlxsw_sp_acl_tcam_region_create(mlxsw_sp, vregion->tcam, - vregion, ctx->hints_priv); - if (IS_ERR(region2)) { - err =3D PTR_ERR(region2); - goto out; - } - - vregion->region2 =3D region2; - err =3D mlxsw_sp_acl_tcam_group_region_attach(mlxsw_sp, - vregion->region->group, - region2, priority, - vregion->region); - if (err) - goto err_group_region_attach; - mutex_lock(&vregion->lock); =20 err =3D mlxsw_sp_acl_tcam_vchunk_migrate_all(mlxsw_sp, vregion); if (!vregion->failed_rollback) { if (!err) { /* In case of successful migration, region2 is used and - * the original is unused. - */ - unused_region =3D vregion->region; - vregion->region =3D vregion->region2; - } else { - /* In case of failure during migration, the original - * region is still used. + * the original is unused. So swap them. */ - unused_region =3D vregion->region2; + swap(vregion->region, vregion->region2); } - mutex_unlock(&vregion->lock); - vregion->region2 =3D NULL; - mlxsw_sp_acl_tcam_group_region_detach(mlxsw_sp, unused_region); - mlxsw_sp_acl_tcam_region_destroy(mlxsw_sp, unused_region); - } else { - mutex_unlock(&vregion->lock); + /* vregion->region2 contains pointer to unused region now. */ } =20 - goto out; - -err_group_region_attach: - vregion->region2 =3D NULL; - mlxsw_sp_acl_tcam_region_destroy(mlxsw_sp, region2); -out: + mutex_unlock(&vregion->lock); trace_mlxsw_sp_acl_tcam_vregion_migrate_end(mlxsw_sp, vregion); - return err; } =20 @@ -1339,7 +1304,10 @@ mlxsw_sp_acl_tcam_vregion_rehash_start(struct mlxsw_= sp *mlxsw_sp, struct mlxsw_sp_acl_tcam_rehash_ctx *ctx) { const struct mlxsw_sp_acl_tcam_ops *ops =3D mlxsw_sp->acl_tcam_ops; + unsigned int priority =3D mlxsw_sp_acl_tcam_vregion_prio(vregion); + struct mlxsw_sp_acl_tcam_region *region2; void *hints_priv; + int err; =20 trace_mlxsw_sp_acl_tcam_vregion_rehash(mlxsw_sp, vregion); if (vregion->failed_rollback) @@ -1349,9 +1317,31 @@ mlxsw_sp_acl_tcam_vregion_rehash_start(struct mlxsw_= sp *mlxsw_sp, if (IS_ERR(hints_priv)) return PTR_ERR(hints_priv); =20 + region2 =3D mlxsw_sp_acl_tcam_region_create(mlxsw_sp, vregion->tcam, + vregion, hints_priv); + if (IS_ERR(region2)) { + err =3D PTR_ERR(region2); + goto err_region_create; + } + + vregion->region2 =3D region2; + err =3D mlxsw_sp_acl_tcam_group_region_attach(mlxsw_sp, + vregion->region->group, + region2, priority, + vregion->region); + if (err) + goto err_group_region_attach; + ctx->hints_priv =3D hints_priv; =20 return 0; + +err_group_region_attach: + vregion->region2 =3D NULL; + mlxsw_sp_acl_tcam_region_destroy(mlxsw_sp, region2); +err_region_create: + ops->region_rehash_hints_put(hints_priv); + return err; } =20 static void @@ -1359,8 +1349,14 @@ mlxsw_sp_acl_tcam_vregion_rehash_end(struct mlxsw_sp= *mlxsw_sp, struct mlxsw_sp_acl_tcam_vregion *vregion, struct mlxsw_sp_acl_tcam_rehash_ctx *ctx) { + struct mlxsw_sp_acl_tcam_region *unused_region =3D vregion->region2; const struct mlxsw_sp_acl_tcam_ops *ops =3D mlxsw_sp->acl_tcam_ops; =20 + if (!vregion->failed_rollback) { + vregion->region2 =3D NULL; + mlxsw_sp_acl_tcam_group_region_detach(mlxsw_sp, unused_region); + mlxsw_sp_acl_tcam_region_destroy(mlxsw_sp, unused_region); + } ops->region_rehash_hints_put(ctx->hints_priv); ctx->hints_priv =3D NULL; } --=20 2.20.1