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,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 F08CCC43381 for ; Thu, 28 Feb 2019 06:59:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B38FE21850 for ; Thu, 28 Feb 2019 06:59:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=Mellanox.com header.i=@Mellanox.com header.b="TYNKmz8F" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731250AbfB1G7f (ORCPT ); Thu, 28 Feb 2019 01:59:35 -0500 Received: from mail-eopbgr150075.outbound.protection.outlook.com ([40.107.15.75]:47522 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731184AbfB1G7e (ORCPT ); Thu, 28 Feb 2019 01:59:34 -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=zwRxJYXeHOXXg3a6G2QFvf6IM0rD9I66pkYAoCTWm/w=; b=TYNKmz8F7uN8KH5hrORN0XkzFwVHcCD+e+yrM1T4NZ6AAPPgCwMlNq2ufLwD2qoEUNFKFL0f4kpz6KopKJzsbySV2ro3rECrv3ByhiIZPcyP6Z1O2YNG0+PPvm+LAJ6KXKRQgUe4+TlE29pltgqBOEEJOAl6DR3+YsoyOkD8H3M= 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:21 +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 06/14] mlxsw: spectrum_acl: assign vregion->region by the newly created region Thread-Topic: [PATCH net-next 06/14] mlxsw: spectrum_acl: assign vregion->region by the newly created region Thread-Index: AQHUzzMh9Yq0IBytuEWR1TlA8+brFA== Date: Thu, 28 Feb 2019 06:59:20 +0000 Message-ID: <20190228065850.7471-7-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: 7d247295-790a-499f-73a5-08d69d4a4385 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:tMYDJ+VSnQztT8aKRDvhbzEhz6dgrnAjt1Bg62h?= =?iso-8859-1?Q?yNndHk1T2O9kBu1juHOkgYgNVjLhE7RXjUDpTtg2gU1qJ98YRskOwME2yl?= =?iso-8859-1?Q?b9eEcn9X7LU3NCH0oxiJNjxdv/I2nd0JJruNP1mzm0Tj+11nWGnkzL8e+A?= =?iso-8859-1?Q?GVsvHqKDc8sIs8G0ET8Eegfpn6O47JWmQ5PuX97CGagwz6BBqiOrdx0MQN?= =?iso-8859-1?Q?2ozKgP6cmBOan9IPqw5ysyPMIBQ8AHdw0FnPI06DSVy5L2Jp/NlkTKNnhC?= =?iso-8859-1?Q?Uh81jYwzrI3s4hce8l7yxe6SObxEvGHyKpHmp/PD5RnoaUzePQvkUiXstZ?= =?iso-8859-1?Q?SHeUZIB/UfuIKniZazKhn/OeccqpsyS6XvcGPSOAgfqCfbhXavOWeJrQ+n?= =?iso-8859-1?Q?VkXi9w26g8KeLPJ/gZfIsU5fEJXQCytRQw9bdKbM/jtuAncIuA0vLWmPdD?= =?iso-8859-1?Q?WIFDj1Rn+SaVVN6/nOXk++zXP/+f4ZL/DSuVV6P+ZGVSV1GXHFKgMlZ37w?= =?iso-8859-1?Q?Bw0Lvm6RyHJ+bOlYkA5j+2HVqeaprMtpeTb/Lm8PjGFM9bq/3gj36CJtZJ?= =?iso-8859-1?Q?gjdP3apsoxl46/zbv0uHyVbZN38GksZjc7z96efnfSLyZ+UFCJ+WRABPj3?= =?iso-8859-1?Q?dp2D0u5qlgH6AnjYGoSOszoMBvSTQdXM304vEeFmWVWXjGyWWYkxArEsL6?= =?iso-8859-1?Q?cTWSTpj3ZMWH5Q8xKylnO+YUk/9BJ6MGT2SOjvyq6u6FrgocOBXujXcMor?= =?iso-8859-1?Q?rslvGef//PD3qrNYhIssubsF+axLWQlAFfM8aKfcyIkT1cXmZHicbinZ+S?= =?iso-8859-1?Q?xJtw430NeV/Nqfu+A+wmsYxq3ERKjzjiesexST14d0JuKgl4uNsG/qMfdt?= =?iso-8859-1?Q?2b61157lY7tnqhFDnsKRKMNEdse6Bahk7L1f+KRZYsd9CN7wjWFoVw+W0C?= =?iso-8859-1?Q?cfcu8bqXB70LfC+2nt1P/exYw+qbNoAftd0WCeWsVSbqhOHpSYsMyq3ILY?= =?iso-8859-1?Q?sp9cgO7zA2zhAiti7SyUPLTe6xc+96e2mNV6sQjXQEnXarwbJDI9ZNtJYL?= =?iso-8859-1?Q?8XGklB3jAb8NaSrCerV3+89MLnqZX4fQcMzPOw36Ogo95vZG+ckPr5suPq?= =?iso-8859-1?Q?TCD8Hj492LndJQI+0aauYRwGhAzNy+1uVy0K6UhV7L8mmmzL4uRA1GSF3z?= =?iso-8859-1?Q?IN4pI4C0MeFW9Cy2QsT/IoWu+n1+8GS6If34D+Jt+9mOLXHDNQSSmoG+ye?= =?iso-8859-1?Q?4QKj5oXRzXwJ4txpgo2865QP26Emr4uhO0M/dlonunTxTUq/C5m2aAnPK1?= =?iso-8859-1?Q?jpe7py6GlsXDUPlGC1F5yXlZr6/KQVIYCbQniwOy9xkxNrUdrFu8JkSaWe?= =?iso-8859-1?Q?XIpD5z6bi2RXkrcvQZk2f9t9t9PSWCOUiWfsnA+0YxOTMgaZhwg=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: Z8gaSFXUVrJNABhFhHS0XHEBS/q3WsYrSaY6YMPdKEXCJHImyF/fw4RnldbvOi38Cp7DDe2zo0n3xmxvBtIRo1x9I/YXsUV7M/yaBHWGxo220c3OUSP5wlL9PHD+ehX8WX9cHc5FTiTKOt+R/xQtB1mb88BJ3rggeRKRmC05FcEG1/jl1Dl9xXF/l1H8wEBvrh6Jo7kbi8BK8hWx9ndViQM6WEzOv92v2r/4H2TOFgEN3j1TT4Ns0NET4mwmjU40XAa6YaITxatOaqziw52gUSuCIAI1Tsf88BvElDdSzpphZujc6g2EBRmTZ31+tCAWbzskegk3cVgWrvlBlnqFGjHxV41Tsqz+L0sZU/AdDG5mL4z+LuZUyn5jqJxHnQ5L5LziGIypYp86xlv6xK9nieCs5ouU5Qe6YTVXTdz0Wos= 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: 7d247295-790a-499f-73a5-08d69d4a4385 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Feb 2019 06:59:20.8816 (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 Make the vregion->region contain pointer of a new region we migrate to. In case of a rollback, it contains the original region. Signed-off-by: Jiri Pirko Signed-off-by: Ido Schimmel --- .../mellanox/mlxsw/spectrum_acl_tcam.c | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 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 cf901a1504c4..72734ee60a1e 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c @@ -1256,7 +1256,7 @@ mlxsw_sp_acl_tcam_vchunk_migrate_all(struct mlxsw_sp = *mlxsw_sp, =20 list_for_each_entry(vchunk, &vregion->vchunk_list, list) { err =3D mlxsw_sp_acl_tcam_vchunk_migrate_one(mlxsw_sp, vchunk, - vregion->region2, + vregion->region, false); if (err) goto rollback; @@ -1264,6 +1264,10 @@ mlxsw_sp_acl_tcam_vchunk_migrate_all(struct mlxsw_sp= *mlxsw_sp, return 0; =20 rollback: + /* In case migration was not successful, we need to swap + * so the original region pointer is assigned again to vregion->region. + */ + swap(vregion->region, vregion->region2); list_for_each_entry_continue_reverse(vchunk, &vregion->vchunk_list, list) { mlxsw_sp_acl_tcam_vchunk_migrate_one(mlxsw_sp, vchunk, @@ -1281,18 +1285,7 @@ mlxsw_sp_acl_tcam_vregion_migrate(struct mlxsw_sp *m= lxsw_sp, =20 trace_mlxsw_sp_acl_tcam_vregion_migrate(mlxsw_sp, vregion); mutex_lock(&vregion->lock); - 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. So swap them. - */ - swap(vregion->region, vregion->region2); - } - /* vregion->region2 contains pointer to unused region now. */ - } - mutex_unlock(&vregion->lock); trace_mlxsw_sp_acl_tcam_vregion_migrate_end(mlxsw_sp, vregion); return err; @@ -1305,7 +1298,7 @@ mlxsw_sp_acl_tcam_vregion_rehash_start(struct mlxsw_s= p *mlxsw_sp, { 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; + struct mlxsw_sp_acl_tcam_region *new_region; void *hints_priv; int err; =20 @@ -1317,18 +1310,22 @@ 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); + new_region =3D mlxsw_sp_acl_tcam_region_create(mlxsw_sp, vregion->tcam, + vregion, hints_priv); + if (IS_ERR(new_region)) { + err =3D PTR_ERR(new_region); goto err_region_create; } =20 - vregion->region2 =3D region2; + /* vregion->region contains the pointer to the new region + * we are going to migrate to. + */ + vregion->region2 =3D vregion->region; + vregion->region =3D new_region; err =3D mlxsw_sp_acl_tcam_group_region_attach(mlxsw_sp, - vregion->region->group, - region2, priority, - vregion->region); + vregion->region2->group, + new_region, priority, + vregion->region2); if (err) goto err_group_region_attach; =20 @@ -1337,8 +1334,9 @@ mlxsw_sp_acl_tcam_vregion_rehash_start(struct mlxsw_s= p *mlxsw_sp, return 0; =20 err_group_region_attach: + vregion->region =3D vregion->region2; vregion->region2 =3D NULL; - mlxsw_sp_acl_tcam_region_destroy(mlxsw_sp, region2); + mlxsw_sp_acl_tcam_region_destroy(mlxsw_sp, new_region); err_region_create: ops->region_rehash_hints_put(hints_priv); return err; --=20 2.20.1