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 D8836C43381 for ; Thu, 28 Feb 2019 06:59:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9C01521850 for ; Thu, 28 Feb 2019 06:59:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=Mellanox.com header.i=@Mellanox.com header.b="XuBz2+RG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731257AbfB1G7m (ORCPT ); Thu, 28 Feb 2019 01:59:42 -0500 Received: from mail-eopbgr130081.outbound.protection.outlook.com ([40.107.13.81]:53176 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731241AbfB1G7l (ORCPT ); Thu, 28 Feb 2019 01:59: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=EKf+3CjrtfodH5rohqJ1Vx034zF1ia+G3bTw8FQPQIs=; b=XuBz2+RGIqkBearW+z7ic0HpiJa7CpkbYxPW1sIlhJYv0ysuktmOwsUlBx7mcRAuGFdmaQ08BFgxXQrEvYo4Qoad1CCFzGi8NBO0orFWt8K5Rq4sqM2m9AapYXGIy1Yvo6hsg6mn5kRHq9p6+u+Mo5tHQp+onSTI3CoySiANkcE= Received: from AM6PR05MB5240.eurprd05.prod.outlook.com (20.177.196.214) by AM6PR05MB5411.eurprd05.prod.outlook.com (20.177.189.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.16; Thu, 28 Feb 2019 06:59:25 +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:25 +0000 From: Ido Schimmel To: "netdev@vger.kernel.org" CC: "davem@davemloft.net" , Jiri Pirko , mlxsw , Ido Schimmel Subject: [PATCH net-next 11/14] mlxsw: spectrum_acl: Do rollback as another call to mlxsw_sp_acl_tcam_vchunk_migrate_all() Thread-Topic: [PATCH net-next 11/14] mlxsw: spectrum_acl: Do rollback as another call to mlxsw_sp_acl_tcam_vchunk_migrate_all() Thread-Index: AQHUzzMjKeoft5hZQ0CKDX5wb1/i2w== Date: Thu, 28 Feb 2019 06:59:24 +0000 Message-ID: <20190228065850.7471-12-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: b669d0bb-9c02-43d8-d394-08d69d4a45f3 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:AM6PR05MB5411; x-ms-traffictypediagnostic: AM6PR05MB5411: x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1;AM6PR05MB5411;23:1zAi5r3Gcp8vq+wduGLRA6/EUObV1dMNDT2ErE2?= =?iso-8859-1?Q?MKuu4bUJEYv9FRWV0C4ugq0CQBST23SoYjCD4O0Q1tqgJ8oKodyg/g0u53?= =?iso-8859-1?Q?fhupH58hXwuftsH24i8pyJPb4rK8zEgXwhpnoDfNyjhapt9QEKNUzQ5fpf?= =?iso-8859-1?Q?FNztxetpyUUonpflYddRuLzEisEu3A1e2ThLQ2ypADaaN4IDzfGtsIPLUj?= =?iso-8859-1?Q?uIquK8i1KhCp7VLDM8Rvj6vkFo5PoEzSkOiuHTAo5Fhuvb0gFTxOHcXS0f?= =?iso-8859-1?Q?l60m/OEU5ZMfxs4rcpq6LvEl52M6eOmH1HIVkqjxAFrgmqpzOOGFj3IHCD?= =?iso-8859-1?Q?bfDrISQEmkUfnQd4AbilNswZkxDnburaaX+bGnUi/PS2sFGFNqTZzTZ6PP?= =?iso-8859-1?Q?20wm4t/eGlAz5MobMSqDOBk6kN5dQRVISMa1LiZG7tkQKRNvaYkrB5J5pV?= =?iso-8859-1?Q?eLOsxojX4DwFRnJI0Ctqg+wNQe/r12e3Hz5aYqyd9IIr4tBOwiJHuYUeNj?= =?iso-8859-1?Q?IK3H5NNeQz9HAa2jjXauMnsI6Afll39lxsgTLYL4WNp+GLsfkj+fT3lMbK?= =?iso-8859-1?Q?vO9H/pKDirB2y0/rJy26iSAqZx9eHN3gR8wAEEpwuXmCDYxSWx+WPdy5vU?= =?iso-8859-1?Q?3gf4k8+QTxoR4Lo9KrTDJduj+UfUUwFCdwRJ2A2nqOIBgaCt0QLmaeIz6O?= =?iso-8859-1?Q?c9a5ap4eTtK3q8gAKF9yV/+FaXRsla/ORuuf0Cvoy2Ebm9IfKuMEQZS+Nt?= =?iso-8859-1?Q?fqq2SXyOeNnQ0qxGNixWCJjdpF8ujRMKjRKUGCkaHg1n4ECPSYLJQJrP/b?= =?iso-8859-1?Q?QN0GuDHOe1wJf7BRcQtqNCxOmDsotTmN+Ms3W9xmQlyuYGAd2y3Y6MSbV4?= =?iso-8859-1?Q?o1QgZBuNWZ9CAt/oiaoHpEDUnLULM2hSpgl//OjiByEYOMrg0e2Ypez7B4?= =?iso-8859-1?Q?s3qcT+cVUfeBHUaaSca215r+MNPnc59XiOfA7DmD/3sLwz815JXhuIWl2f?= =?iso-8859-1?Q?Ek09RULOD4qXmRRbOro7BGJAqzQi1pLtjYIVmEbYxmP2nr1PEjRNhzXEzq?= =?iso-8859-1?Q?3Vz28S3oNg3QanrdO5DzddY8CPvJmZh2Orf0b/Y3n9sV8llzFE0UZ2FOYA?= =?iso-8859-1?Q?U4r18CseR0nSpxoUWhCEWkZbcaDjWdstfxn1eczrx+DjocJ6y5h76aA8UM?= =?iso-8859-1?Q?56aVrii1/coY/Vw6im7vW1eCaKt5Zqz9FGxe0jrN7J0Fw6PO5x2ICNixIo?= =?iso-8859-1?Q?91vSRxbZwpWRswhy3d8/QdAHb3wBSy+8aH8lWrYyBd/vzHmRsfZUxNLpqb?= =?iso-8859-1?Q?CfOKAJaqK6SW4KFD666eiZNNtTLYktNuyXrbhChrok+krn3jroWqwopxgB?= =?iso-8859-1?Q?lzO1GhoDgdbpsCfoHLnUPgYTRdHxh?= x-microsoft-antispam-prvs: x-forefront-prvs: 0962D394D2 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(376002)(366004)(39860400002)(136003)(396003)(346002)(199004)(189003)(5640700003)(6486002)(6436002)(14454004)(478600001)(2351001)(107886003)(4326008)(68736007)(25786009)(97736004)(386003)(6506007)(11346002)(446003)(2616005)(26005)(102836004)(486006)(476003)(186003)(2501003)(14444005)(256004)(5660300002)(1076003)(71190400001)(71200400001)(76176011)(52116002)(8936002)(1730700003)(8676002)(81156014)(81166006)(50226002)(6916009)(99286004)(36756003)(6512007)(86362001)(6116002)(3846002)(105586002)(106356001)(54906003)(53936002)(66066001)(7736002)(316002)(305945005)(2906002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM6PR05MB5411;H:AM6PR05MB5240.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-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: HlxNWwNu7MBzI0S/YZTS872wbelru3uwR8w6Ywl1dTcNdWSZ1DfIGfcp2oI5urz0flI3FPFanWAu11rjtAb2was8x2WSr4dY+uX/eSn5fUF2DA8rPhA2EjvyvLSHs5ITsD8CwxqapRwl2bjI/IAjSmEPSfABnTP1gzO6P/PMMNRorIC32B7FlQoalkht4xFuh/WWOjmR+EyramCObWL5xKhvVaeN1tehgeIl1JRX1+Sg+Hu3G3pbfIpZeMAhRNjEqD2AuzaZAWW2EBtBOfubJHG7v84Yng2TyJHVfYsuocVxqnAAWvLph6U4/FPK9nxRb+Zp8cdcTe9G0MSirJkUGZGVmEeSl212J56/cQ9L24uOe5LRtD81Uku3IDIQ7ZCeYXy8Qli25W7BP71iECbcwjVq5nGYDFPtPbs1HdJ0vEc= 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: b669d0bb-9c02-43d8-d394-08d69d4a45f3 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Feb 2019 06:59:24.9944 (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: AM6PR05MB5411 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jiri Pirko In order to simplify the code and to prepare it for interrupted/continued migration process, do the rollback in case of migration error as another call to mlxsw_sp_acl_tcam_vchunk_migrate_all(). It can be understood as "migrate all back". Signed-off-by: Jiri Pirko Signed-off-by: Ido Schimmel --- .../mellanox/mlxsw/spectrum_acl_tcam.c | 75 +++++++------------ 1 file changed, 29 insertions(+), 46 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 1f308ad4b635..9dc83815644e 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c @@ -1227,48 +1227,34 @@ mlxsw_sp_acl_tcam_vchunk_migrate_one(struct mlxsw_s= p *mlxsw_sp, { struct mlxsw_sp_acl_tcam_ventry *ventry; int err; - int err2; =20 - err =3D mlxsw_sp_acl_tcam_vchunk_migrate_start(mlxsw_sp, vchunk, - region, ctx); - if (err) - return err; + if (vchunk->chunk->region !=3D region) { + err =3D mlxsw_sp_acl_tcam_vchunk_migrate_start(mlxsw_sp, vchunk, + region, ctx); + if (err) + return err; + } else if (!vchunk->chunk2) { + /* The chunk is already as it should be, nothing to do. */ + return 0; + } =20 list_for_each_entry(ventry, &vchunk->ventry_list, list) { err =3D mlxsw_sp_acl_tcam_ventry_migrate(mlxsw_sp, ventry, vchunk->chunk); if (err) { - if (ctx->this_is_rollback) { - vchunk->vregion->failed_rollback =3D true; + if (ctx->this_is_rollback) return err; - } - goto rollback; + /* Swap the chunk and chunk2 pointers so the follow-up + * rollback call will see the original chunk pointer + * in vchunk->chunk. + */ + swap(vchunk->chunk, vchunk->chunk2); + return err; } } =20 mlxsw_sp_acl_tcam_vchunk_migrate_end(mlxsw_sp, vchunk); return 0; - -rollback: - /* Migrate the entries back to the original chunk. If some entry - * migration fails, there's no good way how to proceed. Set the - * vregion with "failed_rollback" flag. - */ - swap(vchunk->chunk, vchunk->chunk2); - list_for_each_entry_continue_reverse(ventry, &vchunk->ventry_list, - list) { - err2 =3D mlxsw_sp_acl_tcam_ventry_migrate(mlxsw_sp, ventry, - vchunk->chunk); - if (err2) { - vchunk->vregion->failed_rollback =3D true; - goto err_rollback; - } - } - - mlxsw_sp_acl_tcam_vchunk_migrate_end(mlxsw_sp, vchunk); - -err_rollback: - return err; } =20 static int @@ -1284,23 +1270,9 @@ mlxsw_sp_acl_tcam_vchunk_migrate_all(struct mlxsw_sp= *mlxsw_sp, vregion->region, ctx); if (err) - goto rollback; + return err; } return 0; - -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); - ctx->this_is_rollback =3D true; - list_for_each_entry_continue_reverse(vchunk, &vregion->vchunk_list, - list) { - mlxsw_sp_acl_tcam_vchunk_migrate_one(mlxsw_sp, vchunk, - vregion->region, - ctx); - } - return err; } =20 static int @@ -1308,11 +1280,22 @@ 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) { - int err; + int err, err2; =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, ctx); + if (err) { + /* 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); + ctx->this_is_rollback =3D true; + err2 =3D mlxsw_sp_acl_tcam_vchunk_migrate_all(mlxsw_sp, vregion, ctx); + if (err2) + vregion->failed_rollback =3D true; + } mutex_unlock(&vregion->lock); trace_mlxsw_sp_acl_tcam_vregion_migrate_end(mlxsw_sp, vregion); return err; --=20 2.20.1