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 02738C43381 for ; Thu, 28 Feb 2019 06:59:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B9AA921850 for ; Thu, 28 Feb 2019 06:59:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=Mellanox.com header.i=@Mellanox.com header.b="l0xpM98z" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731273AbfB1G7w (ORCPT ); Thu, 28 Feb 2019 01:59:52 -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 S1731258AbfB1G7q (ORCPT ); Thu, 28 Feb 2019 01:59:46 -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=tkFRd0d2xp36/cWGKzBTWHfNp7/MP3qva8ww6NPApY8=; b=l0xpM98zmH8Axtu9c0DIwH+wiufbuEmNGLSzdJyO3wTfxTCohkE1+MxojM5WsY58362kO7Y12pYybg5mq5vCfY+w6CKuIjaGekliD23rmpSoS/SORInvY3dIbZjCI9Vdi+J5w+Gi0psasAluwDd7xOtVVrotAob8KBoKeTLuDEs= 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:27 +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:26 +0000 From: Ido Schimmel To: "netdev@vger.kernel.org" CC: "davem@davemloft.net" , Jiri Pirko , mlxsw , Ido Schimmel Subject: [PATCH net-next 13/14] mlxsw: spectrum_acl: Remember where to continue rehash migration Thread-Topic: [PATCH net-next 13/14] mlxsw: spectrum_acl: Remember where to continue rehash migration Thread-Index: AQHUzzMkPu6AWpqRfEWuUZhWyd1TCg== Date: Thu, 28 Feb 2019 06:59:26 +0000 Message-ID: <20190228065850.7471-14-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: 6a3b92e4-36e6-4d39-3282-08d69d4a46f4 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:UzWYVUEtAruDNz/MCMo0vJElI8yP0lP7nblpDnF?= =?iso-8859-1?Q?W6KYud9Pg13UhVuNBaKBZkW9KaN5Tq2M7VMc9w1IpMr007BMq3MjAS7Q0M?= =?iso-8859-1?Q?ypaCkcJ3KhUlFgR8TyY0NpKZ+WVp+siaDJbH+hMZ+Q4/UqKHEjjOpOFEUF?= =?iso-8859-1?Q?xJC6kP+eXRk3sTsH5XUR2kN3ahQrMDCZJafEpZsNA9F1m9N4acTHhXySo7?= =?iso-8859-1?Q?FNIneTXIOJQ1RG6rZML/hXlwpe+SVPHSSaI3DD4wxjh+jXma6ukhWHR23n?= =?iso-8859-1?Q?i7eNGNYYHmY0FdMmdvVmIVNhQD9pAZAtQNOqRqJ8w2P0f8jVuVk4xIou/u?= =?iso-8859-1?Q?ZLozjq6jfjCTyn2lioH5qXDNN4DsWHvP0g1EfYI8+1P+ziLT5XLYCe2JyN?= =?iso-8859-1?Q?B6tcXoPYM/3snZoSPDbtC4XTa27RglE2RXGDwmxQLgqsueVkNvjhAx/gG2?= =?iso-8859-1?Q?e6cF+Qj1bD7lTYnf+upyfQYvDW0g4/eGnUE6aodhSsinnQHCN5LfqfV8cy?= =?iso-8859-1?Q?jzmGqd7zaKSI2y4aqxyvw8Xfq+6Se5WfPnmbH81mAIb9qG9Lf7u+yLAv7B?= =?iso-8859-1?Q?TdtfzQlZmq6ByvD1vj5fYhR0OWh4F+ofjZNSj/QZfXGNhV10+N02RJ/RTP?= =?iso-8859-1?Q?A7Y7toPg5/WrFDbMmJcz+NqGjnsy69JMUkT17o8WMKF5VhdUY4tPl9FJs+?= =?iso-8859-1?Q?ZF3EKyxTPD9Kj13jjgc3xUAK+tM22X/Mum/TNlYKNfLa9ZtmK15Ukkk4IK?= =?iso-8859-1?Q?qBR+VfD5dbs+Vs0Mh1SlfdxIVDaGvpJUuAHmD527686ibJI986KFpaFdgx?= =?iso-8859-1?Q?XO//3hNT2P+z8OUSH9tOjMPMHoC8huAF6mqglBhazhfWftMk3dEylXXRge?= =?iso-8859-1?Q?ovxXWzmNh9SVg9aAIAtUWJ9oWNjS85stWvPmBCUhJtPpj4UrGRdzNfCNps?= =?iso-8859-1?Q?UIYqGd4j9mEnD3fmxXCHHePie5VenS62v6pxAEIlmVS5vXxHqd5oSHFsBP?= =?iso-8859-1?Q?7PRbeefhdi3Ex5Lr2E/voe8k2DG1UP+5pi96Hs445GfeErW8qIXVtR1GWY?= =?iso-8859-1?Q?KkBkrg/prBhflZIZnsT5XKhP7GtG2ay81+wxcPzw/ysEM3cEYccGHPpSZ4?= =?iso-8859-1?Q?yOZaA5fgmMPfkYMYV3zE/6pFR2YaMvoV2i5xZ8StL3iRKry06Go6xzhrBf?= =?iso-8859-1?Q?a5NVOx+NlHEGafMZj9/PRv9hJfz3c5JoNB+LubdSHP8RRmoMIYvKeN4HLK?= =?iso-8859-1?Q?EVA/yAMzB0xF6FGOhl+v6izHzgx4l2Tbr8RhaPuKrg5+oLouYg3k3eAcau?= =?iso-8859-1?Q?fGy9N39buZj9JLqfQMpH8bmKoGV/lqfmCXflbnqomYKlJe9Y/sKaY5Ilik?= =?iso-8859-1?Q?mayioedj8mVK4PNcNAfAb+/ykVVVB?= 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: g3vCdflIqwvlpp4bdHJlfQPIzVsAi/bfXcDxTF+zpXidhz3b4qrRpacTAZSZvo6ZSyyIeJmopeUrIMMpxzUD6LGO16ZAmzaOmuMf+Rf3IGz6krdi9Z7q/JdKOMUIMSvkSa5qi4Y5zeNLzUc2sRlmZdpG2B3BNhmKIG2QHPcAJZU91ju4I/UDNJtl4qD3mI6XfC1KRcxFzOdJqu7Nv0VdWYTQ7mzEe9QQUNGm9KikPD8lQHEzQ3MPeWIuzyAR828D47XC5+ON1IOzKdOuXUxw4LBaoPa31MQaHkoGzAZLRIvKeKeywPGsLJAK+K6RNQjJI59Q06MRdOU0F3vWTdGd06wGQ+p4cRL45q2ApobBclfOdntpqOeH3wD5TCnw3TNB28+4mXwmCz7o88pXC6MwC1iiLUxvhtcGqRSKYtBmPr8= 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: 6a3b92e4-36e6-4d39-3282-08d69d4a46f4 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Feb 2019 06:59:26.8297 (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 Store pointer to vchunk where the migration was interrupted, as well as ventry pointer to start from and to stop at (during rollback). This saved pointers need to be forgotten in case of ventries list or vchunk list changes, which is done by couple of "changed" helpers. Signed-off-by: Jiri Pirko Signed-off-by: Ido Schimmel --- .../mellanox/mlxsw/spectrum_acl_tcam.c | 91 ++++++++++++++++++- 1 file changed, 86 insertions(+), 5 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 cfd05af3f0f6..dc118ed714b2 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c @@ -184,6 +184,19 @@ struct mlxsw_sp_acl_tcam_vgroup { struct mlxsw_sp_acl_tcam_rehash_ctx { void *hints_priv; bool this_is_rollback; + struct mlxsw_sp_acl_tcam_vchunk *current_vchunk; /* vchunk being + * currently migrated. + */ + struct mlxsw_sp_acl_tcam_ventry *start_ventry; /* ventry to start + * migration from in + * a vchunk being + * currently migrated. + */ + struct mlxsw_sp_acl_tcam_ventry *stop_ventry; /* ventry to stop + * migration at + * a vchunk being + * currently migrated. + */ }; =20 struct mlxsw_sp_acl_tcam_vregion { @@ -755,6 +768,31 @@ static void mlxsw_sp_acl_tcam_vregion_rehash_work(stru= ct work_struct *work) mlxsw_sp_acl_tcam_vregion_rehash_work_schedule(vregion); } =20 +static void +mlxsw_sp_acl_tcam_rehash_ctx_vchunk_changed(struct mlxsw_sp_acl_tcam_vchun= k *vchunk) +{ + struct mlxsw_sp_acl_tcam_vregion *vregion =3D vchunk->vregion; + + /* If a rule was added or deleted from vchunk which is currently + * under rehash migration, we have to reset the ventry pointers + * to make sure all rules are properly migrated. + */ + if (vregion->rehash.ctx.current_vchunk =3D=3D vchunk) { + vregion->rehash.ctx.start_ventry =3D NULL; + vregion->rehash.ctx.stop_ventry =3D NULL; + } +} + +static void +mlxsw_sp_acl_tcam_rehash_ctx_vregion_changed(struct mlxsw_sp_acl_tcam_vreg= ion *vregion) +{ + /* If a chunk was added or deleted from vregion we have to reset + * the current chunk pointer to make sure all chunks + * are properly migrated. + */ + vregion->rehash.ctx.current_vchunk =3D NULL; +} + static struct mlxsw_sp_acl_tcam_vregion * mlxsw_sp_acl_tcam_vregion_create(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_tcam_vgroup *vgroup, @@ -989,6 +1027,7 @@ mlxsw_sp_acl_tcam_vchunk_create(struct mlxsw_sp *mlxsw= _sp, goto err_chunk_create; } =20 + mlxsw_sp_acl_tcam_rehash_ctx_vregion_changed(vregion); list_add_tail(&vchunk->list, &vregion->vchunk_list); mutex_unlock(&vregion->lock); =20 @@ -1012,6 +1051,7 @@ mlxsw_sp_acl_tcam_vchunk_destroy(struct mlxsw_sp *mlx= sw_sp, struct mlxsw_sp_acl_tcam_vgroup *vgroup =3D vchunk->vgroup; =20 mutex_lock(&vregion->lock); + mlxsw_sp_acl_tcam_rehash_ctx_vregion_changed(vregion); list_del(&vchunk->list); if (vchunk->chunk2) mlxsw_sp_acl_tcam_chunk_destroy(mlxsw_sp, vchunk->chunk2); @@ -1141,6 +1181,7 @@ static int mlxsw_sp_acl_tcam_ventry_add(struct mlxsw_= sp *mlxsw_sp, } =20 list_add_tail(&ventry->list, &vchunk->ventry_list); + mlxsw_sp_acl_tcam_rehash_ctx_vchunk_changed(vchunk); mutex_unlock(&vregion->lock); =20 return 0; @@ -1157,6 +1198,7 @@ static void mlxsw_sp_acl_tcam_ventry_del(struct mlxsw= _sp *mlxsw_sp, struct mlxsw_sp_acl_tcam_vregion *vregion =3D vchunk->vregion; =20 mutex_lock(&vregion->lock); + mlxsw_sp_acl_tcam_rehash_ctx_vchunk_changed(vchunk); list_del(&ventry->list); mlxsw_sp_acl_tcam_entry_destroy(mlxsw_sp, ventry->entry); mutex_unlock(&vregion->lock); @@ -1223,15 +1265,20 @@ mlxsw_sp_acl_tcam_vchunk_migrate_start(struct mlxsw= _sp *mlxsw_sp, } vchunk->chunk2 =3D vchunk->chunk; vchunk->chunk =3D new_chunk; + ctx->current_vchunk =3D vchunk; + ctx->start_ventry =3D NULL; + ctx->stop_ventry =3D NULL; return 0; } =20 static void mlxsw_sp_acl_tcam_vchunk_migrate_end(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_acl_tcam_vchunk *vchunk) + struct mlxsw_sp_acl_tcam_vchunk *vchunk, + struct mlxsw_sp_acl_tcam_rehash_ctx *ctx) { mlxsw_sp_acl_tcam_chunk_destroy(mlxsw_sp, vchunk->chunk2); vchunk->chunk2 =3D NULL; + ctx->current_vchunk =3D NULL; } =20 static int @@ -1254,7 +1301,22 @@ mlxsw_sp_acl_tcam_vchunk_migrate_one(struct mlxsw_sp= *mlxsw_sp, return 0; } =20 - list_for_each_entry(ventry, &vchunk->ventry_list, list) { + /* If the migration got interrupted, we have the ventry to start from + * stored in context. + */ + if (ctx->start_ventry) + ventry =3D ctx->start_ventry; + else + ventry =3D list_first_entry(&vchunk->ventry_list, + typeof(*ventry), list); + + list_for_each_entry_from(ventry, &vchunk->ventry_list, list) { + /* During rollback, once we reach the ventry that failed + * to migrate, we are done. + */ + if (ventry =3D=3D ctx->stop_ventry) + break; + err =3D mlxsw_sp_acl_tcam_ventry_migrate(mlxsw_sp, ventry, vchunk->chunk, credits); if (err) { @@ -1265,16 +1327,25 @@ mlxsw_sp_acl_tcam_vchunk_migrate_one(struct mlxsw_s= p *mlxsw_sp, * in vchunk->chunk. */ swap(vchunk->chunk, vchunk->chunk2); + /* The rollback has to be done from beginning of the + * chunk, that is why we have to null the start_ventry. + * However, we know where to stop the rollback, + * at the current ventry. + */ + ctx->start_ventry =3D NULL; + ctx->stop_ventry =3D ventry; return err; } else if (*credits < 0) { /* We are out of credits, the rest of the ventries - * will be migrated later. + * will be migrated later. Save the ventry + * which we ended with. */ + ctx->start_ventry =3D ventry; return 0; } } =20 - mlxsw_sp_acl_tcam_vchunk_migrate_end(mlxsw_sp, vchunk); + mlxsw_sp_acl_tcam_vchunk_migrate_end(mlxsw_sp, vchunk, ctx); return 0; } =20 @@ -1287,7 +1358,16 @@ mlxsw_sp_acl_tcam_vchunk_migrate_all(struct mlxsw_sp= *mlxsw_sp, struct mlxsw_sp_acl_tcam_vchunk *vchunk; int err; =20 - list_for_each_entry(vchunk, &vregion->vchunk_list, list) { + /* If the migration got interrupted, we have the vchunk + * we are working on stored in context. + */ + if (ctx->current_vchunk) + vchunk =3D ctx->current_vchunk; + else + vchunk =3D list_first_entry(&vregion->vchunk_list, + typeof(*vchunk), list); + + list_for_each_entry_from(vchunk, &vregion->vchunk_list, list) { err =3D mlxsw_sp_acl_tcam_vchunk_migrate_one(mlxsw_sp, vchunk, vregion->region, ctx, credits); @@ -1315,6 +1395,7 @@ mlxsw_sp_acl_tcam_vregion_migrate(struct mlxsw_sp *ml= xsw_sp, * to vregion->region. */ swap(vregion->region, vregion->region2); + ctx->current_vchunk =3D NULL; ctx->this_is_rollback =3D true; err2 =3D mlxsw_sp_acl_tcam_vchunk_migrate_all(mlxsw_sp, vregion, ctx, credits); --=20 2.20.1