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 B0580C00319 for ; Sun, 24 Feb 2019 06:46:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6A89720663 for ; Sun, 24 Feb 2019 06:46:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=Mellanox.com header.i=@Mellanox.com header.b="t1c5eNMk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727823AbfBXGql (ORCPT ); Sun, 24 Feb 2019 01:46:41 -0500 Received: from mail-eopbgr80045.outbound.protection.outlook.com ([40.107.8.45]:34201 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725928AbfBXGqk (ORCPT ); Sun, 24 Feb 2019 01:46:40 -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=5kmLn8Q+pwhFQl+VvxFvZeB8vfUJqoyjNqggI4YL4gg=; b=t1c5eNMkI07HZYd4v/Hn0+VZgsUZ2ExHXCh+vBoIEKrSroqwVt6yJjNQxPIX4UtdczAwrX0YgtZoQTAndYKHsLcLqzcACDSDB8xApc9sxpiGUER/+mmJJuKOzPCY6QaUMKL+OU++CpMc1PpLhfVBUY5OIY1VD0KzM20IP6MTK+c= Received: from AM6PR05MB5240.eurprd05.prod.outlook.com (20.177.196.214) by AM6PR05MB4343.eurprd05.prod.outlook.com (52.135.162.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.18; Sun, 24 Feb 2019 06:46:23 +0000 Received: from AM6PR05MB5240.eurprd05.prod.outlook.com ([fe80::3542:889c:3a85:3866]) by AM6PR05MB5240.eurprd05.prod.outlook.com ([fe80::3542:889c:3a85:3866%5]) with mapi id 15.20.1643.019; Sun, 24 Feb 2019 06:46:23 +0000 From: Ido Schimmel To: "netdev@vger.kernel.org" CC: "davem@davemloft.net" , Jiri Pirko , mlxsw , Ido Schimmel Subject: [PATCH net-next 02/15] mlxsw: spectrum_acl: Split TCAM group structure into two Thread-Topic: [PATCH net-next 02/15] mlxsw: spectrum_acl: Split TCAM group structure into two Thread-Index: AQHUzAyodz4Z6cKPQUOqDrFz6Y4sEw== Date: Sun, 24 Feb 2019 06:46:23 +0000 Message-ID: <20190224064525.14913-3-idosch@mellanox.com> References: <20190224064525.14913-1-idosch@mellanox.com> In-Reply-To: <20190224064525.14913-1-idosch@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6P194CA0033.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:90::46) To AM6PR05MB5240.eurprd05.prod.outlook.com (2603:10a6:20b:64::22) 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: 314d1170-52e2-48fd-40c4-08d69a23ca91 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600110)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:AM6PR05MB4343; x-ms-traffictypediagnostic: AM6PR05MB4343: x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1;AM6PR05MB4343;23:cVH6Do14q9gQ5bcxD+H3L6xLRjkKGrsFxkC5mSc?= =?iso-8859-1?Q?EwrXAHeIS9DNEJoOL0tDim58NcY6JM2s2nFgblnuz0nMtXpOzxEAmA/kBz?= =?iso-8859-1?Q?EY77Mibgx3FeIB/oZMiegT3kMMa/PJrsIBEvsTr030MzNej8kMNtTtvwvo?= =?iso-8859-1?Q?gCxICHOlw1Yrq++Xb1fJD7X/1G0CpuV8S/qb4MUD72qe80bFk39Yn9sdAQ?= =?iso-8859-1?Q?KZZc16+l7CaqcsGh1Y1mlsq4mjCbG/DOwO0rDetnzAgL99EHobG5fMS7Y1?= =?iso-8859-1?Q?7glWXSKXsE4BaAxGWT353CVUn32J14qZjAjA65+uCBKofphX/AvuBGyK9V?= =?iso-8859-1?Q?j9mk+VEcj75YTfAiw3i0RHsh7ZdIW9Ycv03HmF7OtJXaTQU/+AJ3tAJZge?= =?iso-8859-1?Q?N5J5ixSSpR50f3+N0jS1X3M0GcvKehhNStqwcgOBhiWzobmZWg07ryVgij?= =?iso-8859-1?Q?dsvtgVnaWmGnOxCGlgs8pEkTITNEUHE/dtXPO8B9nvWWm0atfo99VF0j8I?= =?iso-8859-1?Q?CNhTW6TPSLGbazV/3kPwAqPWYEepNIMl/XJd1wiXZEleE+4Ve+BMGz8QN7?= =?iso-8859-1?Q?NoSXYCwJ/Ysi6fxTX7w/A3NUI/X5QaTnUr/a7f60NCYrp/iJbMbp4vYKvy?= =?iso-8859-1?Q?XHBpIKZ7StYmmS9OuIPHBi6cYTjvFNUjV7gLTHEUbL4+6G5Pbs1wIxPD5O?= =?iso-8859-1?Q?Wa4+6qR46PAeQ9xJdOAWG6MCINAYNtTm+1h3m1BQKN5O/qrYjIjQOty3MD?= =?iso-8859-1?Q?ddkg3iCbqPgNiKCN2Yvxe+vYFGxBMulSeaxfNTzTVB1capWMBK5O4ebNN1?= =?iso-8859-1?Q?OZkRnRTKH157Aw5YRF12EQiEMs8JRY999LQaHWFMtancYrpg/unCSWd9K1?= =?iso-8859-1?Q?d0QSjsPn0ELC3s/ZBHHKok8MjJ3g4PQlz6R4sAf0GcgY+4SgPWRMOPtFWf?= =?iso-8859-1?Q?FBI0AL/dA7mDBuTdqQoulVVVnzECVtoSUVbB8sgPsLGoKfYMgaQB6oIEko?= =?iso-8859-1?Q?rGmhXgNjtTCHLjmHr36JNxfl7HGheGhjiZEUYQ+A/ZlPw98gexAmOqwxAQ?= =?iso-8859-1?Q?klAl2XdmyES3bHOqS18lBbLia2lIPdFmqu8ly1oZ3Nmw8Nfcy/sBmLZHW3?= =?iso-8859-1?Q?k7kMb3I/CIFNTEN9Dkbn0b3rKCJu/JC4HA9P2oL6Nin7evxJDJy6qIDNbv?= =?iso-8859-1?Q?7XgSQUQ6P7cus4sthf3AsRdFGBly79qwyHxP+FFKUNjnrcnKUE6mnOKaoT?= =?iso-8859-1?Q?4ijYKtlDxfmYFae0yU+vGacO82rq+08/4TZT4QMYqFwENe/c8q2yz6Kkl9?= =?iso-8859-1?Q?LotWgjwFppWospQKzNyikjHWcwn4AddXgZOvTMIUtsQ9yxAvT+44hpkLHz?= =?iso-8859-1?Q?Gu+tSH8PF2uvJms1zWUW6xl4dKahIgniWM43mfMorcaBM0K3qL7L0H4NFU?= =?iso-8859-1?Q?WuAguqqSTU6O3/b8IZL+DcA/l2MNzbsIDDAauWRSoALxs48rGNFJM/ugA?= =?iso-8859-1?Q?=3D=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 09583628E0 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(396003)(136003)(376002)(346002)(39850400004)(199004)(189003)(102836004)(53946003)(5660300002)(3846002)(14444005)(8936002)(6116002)(5640700003)(256004)(6506007)(386003)(30864003)(1076003)(71200400001)(71190400001)(14454004)(6512007)(6436002)(81166006)(2351001)(81156014)(1730700003)(6346003)(50226002)(26005)(6916009)(5024004)(107886003)(2906002)(99286004)(86362001)(2501003)(486006)(2616005)(4326008)(11346002)(54906003)(66066001)(316002)(476003)(446003)(53936002)(68736007)(52116002)(7736002)(6486002)(8676002)(478600001)(106356001)(305945005)(105586002)(25786009)(186003)(36756003)(76176011)(97736004)(579004);DIR:OUT;SFP:1101;SCL:1;SRVR:AM6PR05MB4343;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) authentication-results: spf=none (sender IP is ) smtp.mailfrom=idosch@mellanox.com; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Zf7g1133p2mmkQtEVvIkM033iVCAznpTDhbbcJ3tylSNdA9MbsKlbZ1GAB5mvsqsIoDYPMUedCYOHs2vgBMWMkLY2pDlA2VKfREJKX/ZFU9mWkE3Ct45UwPW9rpBEZQwW2G9fnYxcnSup/q/phWoobEGqr9KT6DuLl56z1zx5lcVQh8P7CeZT2HFCLZu1TJgMcMEu2Ea555uIBTk3v1f7w1rnB0KXRmiXZABmB7HIQyy4aOZ8YubvExTJiqT+X7vfSTaeVOEI1P8II16BKpGjWmEeeAWMsJA+G2MT6qZFtalikUgRBwhdOD9v4My5VgiZ2hJtUfj4EnsQL20+VIW+zuXhY9yhHu2RnGbQFJqA002Boc0yQK3NgEHYIAIU/l6qUD96oTiFqFwINVbqOfnlYxHzQzF5TOzXX4Wp0r5Y2o= 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: 314d1170-52e2-48fd-40c4-08d69a23ca91 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Feb 2019 06:46:22.7990 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR05MB4343 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jiri Pirko Make the existing group structure to contain fields needed for HW region list manipulations. Move the rest of the fields into new vgroup struct. This makes layering cleaner as the vgroup struct is on higher level than low-level group struct. Also, this makes it possible to introduce fine-grained locking. Signed-off-by: Jiri Pirko Signed-off-by: Ido Schimmel --- .../mellanox/mlxsw/spectrum_acl_tcam.c | 260 +++++++++++------- .../mellanox/mlxsw/spectrum_acl_tcam.h | 2 + 2 files changed, 161 insertions(+), 101 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 80bf0a510203..922f17adcee7 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c @@ -161,8 +161,13 @@ struct mlxsw_sp_acl_tcam_pattern { struct mlxsw_sp_acl_tcam_group { struct mlxsw_sp_acl_tcam *tcam; u16 id; - struct list_head vregion_list; + struct list_head region_list; unsigned int region_count; +}; + +struct mlxsw_sp_acl_tcam_vgroup { + struct mlxsw_sp_acl_tcam_group group; + struct list_head vregion_list; struct rhashtable vchunk_ht; const struct mlxsw_sp_acl_tcam_pattern *patterns; unsigned int patterns_count; @@ -176,7 +181,6 @@ struct mlxsw_sp_acl_tcam_vregion { struct list_head list; /* Member of a TCAM group */ struct list_head tlist; /* Member of a TCAM */ struct list_head vchunk_list; /* List of vchunks under this vregion */ - struct mlxsw_sp_acl_tcam_group *group; struct mlxsw_afk_key_info *key_info; struct mlxsw_sp_acl_tcam *tcam; struct delayed_work rehash_dw; @@ -200,7 +204,7 @@ struct mlxsw_sp_acl_tcam_vchunk { struct rhash_head ht_node; /* Member of a chunk HT */ struct list_head ventry_list; unsigned int priority; /* Priority within the vregion and group */ - struct mlxsw_sp_acl_tcam_group *group; + struct mlxsw_sp_acl_tcam_vgroup *vgroup; struct mlxsw_sp_acl_tcam_vregion *vregion; unsigned int ref_count; }; @@ -229,46 +233,73 @@ static const struct rhashtable_params mlxsw_sp_acl_tc= am_vchunk_ht_params =3D { static int mlxsw_sp_acl_tcam_group_update(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_tcam_group *group) { - struct mlxsw_sp_acl_tcam_vregion *vregion; + struct mlxsw_sp_acl_tcam_region *region; char pagt_pl[MLXSW_REG_PAGT_LEN]; int acl_index =3D 0; =20 mlxsw_reg_pagt_pack(pagt_pl, group->id); - list_for_each_entry(vregion, &group->vregion_list, list) { - if (vregion->region2) - mlxsw_reg_pagt_acl_id_pack(pagt_pl, acl_index++, - vregion->region2->id, true); + list_for_each_entry(region, &group->region_list, list) { + bool multi =3D false; + + /* Check if the next entry in the list has the same vregion. */ + if (region->list.next !=3D &group->region_list && + list_next_entry(region, list)->vregion =3D=3D region->vregion) + multi =3D true; mlxsw_reg_pagt_acl_id_pack(pagt_pl, acl_index++, - vregion->region->id, false); + region->id, multi); } mlxsw_reg_pagt_size_set(pagt_pl, acl_index); return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pagt), pagt_pl); } =20 static int -mlxsw_sp_acl_tcam_group_add(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_acl_tcam *tcam, - struct mlxsw_sp_acl_tcam_group *group, - const struct mlxsw_sp_acl_tcam_pattern *patterns, - unsigned int patterns_count, - struct mlxsw_afk_element_usage *tmplt_elusage) +mlxsw_sp_acl_tcam_group_add(struct mlxsw_sp_acl_tcam *tcam, + struct mlxsw_sp_acl_tcam_group *group) { int err; =20 group->tcam =3D tcam; - group->patterns =3D patterns; - group->patterns_count =3D patterns_count; + INIT_LIST_HEAD(&group->region_list); + + err =3D mlxsw_sp_acl_tcam_group_id_get(tcam, &group->id); + if (err) + return err; + + return 0; +} + +static void mlxsw_sp_acl_tcam_group_del(struct mlxsw_sp_acl_tcam_group *gr= oup) +{ + struct mlxsw_sp_acl_tcam *tcam =3D group->tcam; + + mlxsw_sp_acl_tcam_group_id_put(tcam, group->id); + WARN_ON(!list_empty(&group->region_list)); +} + +static int +mlxsw_sp_acl_tcam_vgroup_add(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_tcam *tcam, + struct mlxsw_sp_acl_tcam_vgroup *vgroup, + const struct mlxsw_sp_acl_tcam_pattern *patterns, + unsigned int patterns_count, + struct mlxsw_afk_element_usage *tmplt_elusage) +{ + int err; + + vgroup->patterns =3D patterns; + vgroup->patterns_count =3D patterns_count; if (tmplt_elusage) { - group->tmplt_elusage_set =3D true; - memcpy(&group->tmplt_elusage, tmplt_elusage, - sizeof(group->tmplt_elusage)); + vgroup->tmplt_elusage_set =3D true; + memcpy(&vgroup->tmplt_elusage, tmplt_elusage, + sizeof(vgroup->tmplt_elusage)); } - INIT_LIST_HEAD(&group->vregion_list); - err =3D mlxsw_sp_acl_tcam_group_id_get(tcam, &group->id); + INIT_LIST_HEAD(&vgroup->vregion_list); + + err =3D mlxsw_sp_acl_tcam_group_add(tcam, &vgroup->group); if (err) return err; =20 - err =3D rhashtable_init(&group->vchunk_ht, + err =3D rhashtable_init(&vgroup->vchunk_ht, &mlxsw_sp_acl_tcam_vchunk_ht_params); if (err) goto err_rhashtable_init; @@ -276,18 +307,16 @@ mlxsw_sp_acl_tcam_group_add(struct mlxsw_sp *mlxsw_sp= , return 0; =20 err_rhashtable_init: - mlxsw_sp_acl_tcam_group_id_put(tcam, group->id); + mlxsw_sp_acl_tcam_group_del(&vgroup->group); return err; } =20 -static void mlxsw_sp_acl_tcam_group_del(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_acl_tcam_group *group) +static void +mlxsw_sp_acl_tcam_vgroup_del(struct mlxsw_sp_acl_tcam_vgroup *vgroup) { - struct mlxsw_sp_acl_tcam *tcam =3D group->tcam; - - rhashtable_destroy(&group->vchunk_ht); - mlxsw_sp_acl_tcam_group_id_put(tcam, group->id); - WARN_ON(!list_empty(&group->vregion_list)); + rhashtable_destroy(&vgroup->vchunk_ht); + mlxsw_sp_acl_tcam_group_del(&vgroup->group); + WARN_ON(!list_empty(&vgroup->vregion_list)); } =20 static int @@ -353,52 +382,78 @@ mlxsw_sp_acl_tcam_vregion_max_prio(struct mlxsw_sp_ac= l_tcam_vregion *vregion) =20 static int mlxsw_sp_acl_tcam_group_region_attach(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_acl_tcam_region *region) + struct mlxsw_sp_acl_tcam_group *group, + struct mlxsw_sp_acl_tcam_region *region, + struct mlxsw_sp_acl_tcam_region *next_region) { - struct mlxsw_sp_acl_tcam_group *group =3D region->vregion->group; + struct mlxsw_sp_acl_tcam_region *region2; + struct list_head *pos; int err; =20 if (group->region_count =3D=3D group->tcam->max_group_size) return -ENOBUFS; =20 + if (next_region) { + /* If the next region is defined, place the new one + * before it. The next one is a sibling. + */ + pos =3D &next_region->list; + } else { + /* Position the region inside the list according to priority */ + list_for_each(pos, &group->region_list) { + region2 =3D list_entry(pos, typeof(*region2), list); + if (mlxsw_sp_acl_tcam_vregion_prio(region2->vregion) > + mlxsw_sp_acl_tcam_vregion_prio(region->vregion)) + break; + } + } + list_add_tail(®ion->list, pos); + region->group =3D group; + err =3D mlxsw_sp_acl_tcam_group_update(mlxsw_sp, group); if (err) - return err; + goto err_group_update; =20 group->region_count++; return 0; + +err_group_update: + list_del(®ion->list); + return err; } =20 static void mlxsw_sp_acl_tcam_group_region_detach(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_tcam_region *region) { - struct mlxsw_sp_acl_tcam_group *group =3D region->vregion->group; + struct mlxsw_sp_acl_tcam_group *group =3D region->group; =20 + list_del(®ion->list); group->region_count--; mlxsw_sp_acl_tcam_group_update(mlxsw_sp, group); } =20 static int -mlxsw_sp_acl_tcam_group_vregion_attach(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_acl_tcam_group *group, - struct mlxsw_sp_acl_tcam_vregion *vregion) +mlxsw_sp_acl_tcam_vgroup_vregion_attach(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_tcam_vgroup *vgroup, + struct mlxsw_sp_acl_tcam_vregion *vregion) { struct mlxsw_sp_acl_tcam_vregion *vregion2; struct list_head *pos; int err; =20 /* Position the vregion inside the list according to priority */ - list_for_each(pos, &group->vregion_list) { + list_for_each(pos, &vgroup->vregion_list) { vregion2 =3D list_entry(pos, typeof(*vregion2), list); if (mlxsw_sp_acl_tcam_vregion_prio(vregion2) > - mlxsw_sp_acl_tcam_vregion_prio(vregion)) + mlxsw_sp_acl_tcam_vregion_prio(vregion)) { break; + } } list_add_tail(&vregion->list, pos); - vregion->group =3D group; =20 - err =3D mlxsw_sp_acl_tcam_group_region_attach(mlxsw_sp, vregion->region); + err =3D mlxsw_sp_acl_tcam_group_region_attach(mlxsw_sp, &vgroup->group, + vregion->region, NULL); if (err) goto err_region_attach; =20 @@ -410,8 +465,8 @@ mlxsw_sp_acl_tcam_group_vregion_attach(struct mlxsw_sp = *mlxsw_sp, } =20 static void -mlxsw_sp_acl_tcam_group_vregion_detach(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_acl_tcam_vregion *vregion) +mlxsw_sp_acl_tcam_vgroup_vregion_detach(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_tcam_vregion *vregion) { list_del(&vregion->list); if (vregion->region2) @@ -421,22 +476,22 @@ mlxsw_sp_acl_tcam_group_vregion_detach(struct mlxsw_s= p *mlxsw_sp, } =20 static struct mlxsw_sp_acl_tcam_vregion * -mlxsw_sp_acl_tcam_group_vregion_find(struct mlxsw_sp_acl_tcam_group *group= , - unsigned int priority, - struct mlxsw_afk_element_usage *elusage, - bool *p_need_split) +mlxsw_sp_acl_tcam_vgroup_vregion_find(struct mlxsw_sp_acl_tcam_vgroup *vgr= oup, + unsigned int priority, + struct mlxsw_afk_element_usage *elusage, + bool *p_need_split) { struct mlxsw_sp_acl_tcam_vregion *vregion, *vregion2; struct list_head *pos; bool issubset; =20 - list_for_each(pos, &group->vregion_list) { + list_for_each(pos, &vgroup->vregion_list) { vregion =3D list_entry(pos, typeof(*vregion), list); =20 /* First, check if the requested priority does not rather belong * under some of the next vregions. */ - if (pos->next !=3D &group->vregion_list) { /* not last */ + if (pos->next !=3D &vgroup->vregion_list) { /* not last */ vregion2 =3D list_entry(pos->next, typeof(*vregion2), list); if (priority >=3D @@ -477,9 +532,9 @@ mlxsw_sp_acl_tcam_group_vregion_find(struct mlxsw_sp_ac= l_tcam_group *group, } =20 static void -mlxsw_sp_acl_tcam_group_use_patterns(struct mlxsw_sp_acl_tcam_group *group= , - struct mlxsw_afk_element_usage *elusage, - struct mlxsw_afk_element_usage *out) +mlxsw_sp_acl_tcam_vgroup_use_patterns(struct mlxsw_sp_acl_tcam_vgroup *vgr= oup, + struct mlxsw_afk_element_usage *elusage, + struct mlxsw_afk_element_usage *out) { const struct mlxsw_sp_acl_tcam_pattern *pattern; int i; @@ -487,14 +542,14 @@ mlxsw_sp_acl_tcam_group_use_patterns(struct mlxsw_sp_= acl_tcam_group *group, /* In case the template is set, we don't have to look up the pattern * and just use the template. */ - if (group->tmplt_elusage_set) { - memcpy(out, &group->tmplt_elusage, sizeof(*out)); + if (vgroup->tmplt_elusage_set) { + memcpy(out, &vgroup->tmplt_elusage, sizeof(*out)); WARN_ON(!mlxsw_afk_element_usage_subset(elusage, out)); return; } =20 - for (i =3D 0; i < group->patterns_count; i++) { - pattern =3D &group->patterns[i]; + for (i =3D 0; i < vgroup->patterns_count; i++) { + pattern =3D &vgroup->patterns[i]; mlxsw_afk_element_usage_fill(out, pattern->elements, pattern->elements_count); if (mlxsw_afk_element_usage_subset(elusage, out)) @@ -627,7 +682,7 @@ mlxsw_sp_acl_tcam_region_destroy(struct mlxsw_sp *mlxsw= _sp, ops->region_fini(mlxsw_sp, region->priv); mlxsw_sp_acl_tcam_region_disable(mlxsw_sp, region); mlxsw_sp_acl_tcam_region_free(mlxsw_sp, region); - mlxsw_sp_acl_tcam_region_id_put(region->vregion->group->tcam, + mlxsw_sp_acl_tcam_region_id_put(region->group->tcam, region->id); kfree(region); } @@ -763,7 +818,7 @@ int mlxsw_sp_acl_tcam_vregion_rehash_intrvl_set(struct = mlxsw_sp *mlxsw_sp, =20 static int mlxsw_sp_acl_tcam_vchunk_assoc(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_acl_tcam_group *group, + struct mlxsw_sp_acl_tcam_vgroup *vgroup, unsigned int priority, struct mlxsw_afk_element_usage *elusage, struct mlxsw_sp_acl_tcam_vchunk *vchunk) @@ -773,8 +828,8 @@ mlxsw_sp_acl_tcam_vchunk_assoc(struct mlxsw_sp *mlxsw_s= p, bool need_split; int err; =20 - vregion =3D mlxsw_sp_acl_tcam_group_vregion_find(group, priority, elusage= , - &need_split); + vregion =3D mlxsw_sp_acl_tcam_vgroup_vregion_find(vgroup, priority, + elusage, &need_split); if (vregion && need_split) { /* According to priority, the vchunk should belong to an * existing vregion. However, this vchunk needs elements @@ -787,10 +842,10 @@ mlxsw_sp_acl_tcam_vchunk_assoc(struct mlxsw_sp *mlxsw= _sp, if (!vregion) { struct mlxsw_afk_element_usage vregion_elusage; =20 - mlxsw_sp_acl_tcam_group_use_patterns(group, elusage, - &vregion_elusage); + mlxsw_sp_acl_tcam_vgroup_use_patterns(vgroup, elusage, + &vregion_elusage); vregion =3D mlxsw_sp_acl_tcam_vregion_create(mlxsw_sp, - group->tcam, + vgroup->group.tcam, &vregion_elusage); if (IS_ERR(vregion)) return PTR_ERR(vregion); @@ -803,13 +858,14 @@ mlxsw_sp_acl_tcam_vchunk_assoc(struct mlxsw_sp *mlxsw= _sp, if (!vregion_created) return 0; =20 - err =3D mlxsw_sp_acl_tcam_group_vregion_attach(mlxsw_sp, group, vregion); + err =3D mlxsw_sp_acl_tcam_vgroup_vregion_attach(mlxsw_sp, vgroup, + vregion); if (err) - goto err_group_vregion_attach; + goto err_vgroup_vregion_attach; =20 return 0; =20 -err_group_vregion_attach: +err_vgroup_vregion_attach: mlxsw_sp_acl_tcam_vregion_destroy(mlxsw_sp, vregion); return err; } @@ -822,7 +878,7 @@ mlxsw_sp_acl_tcam_vchunk_deassoc(struct mlxsw_sp *mlxsw= _sp, =20 list_del(&vchunk->list); if (list_empty(&vregion->vchunk_list)) { - mlxsw_sp_acl_tcam_group_vregion_detach(mlxsw_sp, vregion); + mlxsw_sp_acl_tcam_vgroup_vregion_detach(mlxsw_sp, vregion); mlxsw_sp_acl_tcam_vregion_destroy(mlxsw_sp, vregion); } } @@ -857,7 +913,7 @@ mlxsw_sp_acl_tcam_chunk_destroy(struct mlxsw_sp *mlxsw_= sp, =20 static struct mlxsw_sp_acl_tcam_vchunk * mlxsw_sp_acl_tcam_vchunk_create(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_acl_tcam_group *group, + struct mlxsw_sp_acl_tcam_vgroup *vgroup, unsigned int priority, struct mlxsw_afk_element_usage *elusage) { @@ -872,15 +928,15 @@ mlxsw_sp_acl_tcam_vchunk_create(struct mlxsw_sp *mlxs= w_sp, return ERR_PTR(-ENOMEM); INIT_LIST_HEAD(&vchunk->ventry_list); vchunk->priority =3D priority; - vchunk->group =3D group; + vchunk->vgroup =3D vgroup; vchunk->ref_count =3D 1; =20 - err =3D mlxsw_sp_acl_tcam_vchunk_assoc(mlxsw_sp, group, priority, + err =3D mlxsw_sp_acl_tcam_vchunk_assoc(mlxsw_sp, vgroup, priority, elusage, vchunk); if (err) goto err_vchunk_assoc; =20 - err =3D rhashtable_insert_fast(&group->vchunk_ht, &vchunk->ht_node, + err =3D rhashtable_insert_fast(&vgroup->vchunk_ht, &vchunk->ht_node, mlxsw_sp_acl_tcam_vchunk_ht_params); if (err) goto err_rhashtable_insert; @@ -895,7 +951,7 @@ mlxsw_sp_acl_tcam_vchunk_create(struct mlxsw_sp *mlxsw_= sp, return vchunk; =20 err_chunk_create: - rhashtable_remove_fast(&group->vchunk_ht, &vchunk->ht_node, + rhashtable_remove_fast(&vgroup->vchunk_ht, &vchunk->ht_node, mlxsw_sp_acl_tcam_vchunk_ht_params); err_rhashtable_insert: mlxsw_sp_acl_tcam_vchunk_deassoc(mlxsw_sp, vchunk); @@ -908,12 +964,12 @@ static void mlxsw_sp_acl_tcam_vchunk_destroy(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_tcam_vchunk *vchunk) { - struct mlxsw_sp_acl_tcam_group *group =3D vchunk->group; + struct mlxsw_sp_acl_tcam_vgroup *vgroup =3D vchunk->vgroup; =20 if (vchunk->chunk2) mlxsw_sp_acl_tcam_chunk_destroy(mlxsw_sp, vchunk->chunk2); mlxsw_sp_acl_tcam_chunk_destroy(mlxsw_sp, vchunk->chunk); - rhashtable_remove_fast(&group->vchunk_ht, &vchunk->ht_node, + rhashtable_remove_fast(&vgroup->vchunk_ht, &vchunk->ht_node, mlxsw_sp_acl_tcam_vchunk_ht_params); mlxsw_sp_acl_tcam_vchunk_deassoc(mlxsw_sp, vchunk); kfree(vchunk); @@ -921,13 +977,13 @@ mlxsw_sp_acl_tcam_vchunk_destroy(struct mlxsw_sp *mlx= sw_sp, =20 static struct mlxsw_sp_acl_tcam_vchunk * mlxsw_sp_acl_tcam_vchunk_get(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_acl_tcam_group *group, + struct mlxsw_sp_acl_tcam_vgroup *vgroup, unsigned int priority, struct mlxsw_afk_element_usage *elusage) { struct mlxsw_sp_acl_tcam_vchunk *vchunk; =20 - vchunk =3D rhashtable_lookup_fast(&group->vchunk_ht, &priority, + vchunk =3D rhashtable_lookup_fast(&vgroup->vchunk_ht, &priority, mlxsw_sp_acl_tcam_vchunk_ht_params); if (vchunk) { if (WARN_ON(!mlxsw_afk_key_info_subset(vchunk->vregion->key_info, @@ -936,7 +992,7 @@ mlxsw_sp_acl_tcam_vchunk_get(struct mlxsw_sp *mlxsw_sp, vchunk->ref_count++; return vchunk; } - return mlxsw_sp_acl_tcam_vchunk_create(mlxsw_sp, group, + return mlxsw_sp_acl_tcam_vchunk_create(mlxsw_sp, vgroup, priority, elusage); } =20 @@ -1010,14 +1066,14 @@ mlxsw_sp_acl_tcam_entry_activity_get(struct mlxsw_s= p *mlxsw_sp, } =20 static int mlxsw_sp_acl_tcam_ventry_add(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_acl_tcam_group *group, + struct mlxsw_sp_acl_tcam_vgroup *vgroup, struct mlxsw_sp_acl_tcam_ventry *ventry, struct mlxsw_sp_acl_rule_info *rulei) { struct mlxsw_sp_acl_tcam_vchunk *vchunk; int err; =20 - vchunk =3D mlxsw_sp_acl_tcam_vchunk_get(mlxsw_sp, group, rulei->priority, + vchunk =3D mlxsw_sp_acl_tcam_vchunk_get(mlxsw_sp, vgroup, rulei->priority= , &rulei->values.elusage); if (IS_ERR(vchunk)) return PTR_ERR(vchunk); @@ -1183,7 +1239,9 @@ mlxsw_sp_acl_tcam_vregion_migrate(struct mlxsw_sp *ml= xsw_sp, return PTR_ERR(region2); =20 vregion->region2 =3D region2; - err =3D mlxsw_sp_acl_tcam_group_region_attach(mlxsw_sp, region2); + err =3D mlxsw_sp_acl_tcam_group_region_attach(mlxsw_sp, + vregion->region->group, + region2, vregion->region); if (err) goto err_group_region_attach; =20 @@ -1297,7 +1355,7 @@ static const struct mlxsw_sp_acl_tcam_pattern mlxsw_s= p_acl_tcam_patterns[] =3D { ARRAY_SIZE(mlxsw_sp_acl_tcam_patterns) =20 struct mlxsw_sp_acl_tcam_flower_ruleset { - struct mlxsw_sp_acl_tcam_group group; + struct mlxsw_sp_acl_tcam_vgroup vgroup; }; =20 struct mlxsw_sp_acl_tcam_flower_rule { @@ -1312,10 +1370,10 @@ mlxsw_sp_acl_tcam_flower_ruleset_add(struct mlxsw_s= p *mlxsw_sp, { struct mlxsw_sp_acl_tcam_flower_ruleset *ruleset =3D ruleset_priv; =20 - return mlxsw_sp_acl_tcam_group_add(mlxsw_sp, tcam, &ruleset->group, - mlxsw_sp_acl_tcam_patterns, - MLXSW_SP_ACL_TCAM_PATTERNS_COUNT, - tmplt_elusage); + return mlxsw_sp_acl_tcam_vgroup_add(mlxsw_sp, tcam, &ruleset->vgroup, + mlxsw_sp_acl_tcam_patterns, + MLXSW_SP_ACL_TCAM_PATTERNS_COUNT, + tmplt_elusage); } =20 static void @@ -1324,7 +1382,7 @@ mlxsw_sp_acl_tcam_flower_ruleset_del(struct mlxsw_sp = *mlxsw_sp, { struct mlxsw_sp_acl_tcam_flower_ruleset *ruleset =3D ruleset_priv; =20 - mlxsw_sp_acl_tcam_group_del(mlxsw_sp, &ruleset->group); + mlxsw_sp_acl_tcam_vgroup_del(&ruleset->vgroup); } =20 static int @@ -1335,7 +1393,7 @@ mlxsw_sp_acl_tcam_flower_ruleset_bind(struct mlxsw_sp= *mlxsw_sp, { struct mlxsw_sp_acl_tcam_flower_ruleset *ruleset =3D ruleset_priv; =20 - return mlxsw_sp_acl_tcam_group_bind(mlxsw_sp, &ruleset->group, + return mlxsw_sp_acl_tcam_group_bind(mlxsw_sp, &ruleset->vgroup.group, mlxsw_sp_port, ingress); } =20 @@ -1347,7 +1405,7 @@ mlxsw_sp_acl_tcam_flower_ruleset_unbind(struct mlxsw_= sp *mlxsw_sp, { struct mlxsw_sp_acl_tcam_flower_ruleset *ruleset =3D ruleset_priv; =20 - mlxsw_sp_acl_tcam_group_unbind(mlxsw_sp, &ruleset->group, + mlxsw_sp_acl_tcam_group_unbind(mlxsw_sp, &ruleset->vgroup.group, mlxsw_sp_port, ingress); } =20 @@ -1356,7 +1414,7 @@ mlxsw_sp_acl_tcam_flower_ruleset_group_id(void *rules= et_priv) { struct mlxsw_sp_acl_tcam_flower_ruleset *ruleset =3D ruleset_priv; =20 - return mlxsw_sp_acl_tcam_group_id(&ruleset->group); + return mlxsw_sp_acl_tcam_group_id(&ruleset->vgroup.group); } =20 static int @@ -1367,7 +1425,7 @@ mlxsw_sp_acl_tcam_flower_rule_add(struct mlxsw_sp *ml= xsw_sp, struct mlxsw_sp_acl_tcam_flower_ruleset *ruleset =3D ruleset_priv; struct mlxsw_sp_acl_tcam_flower_rule *rule =3D rule_priv; =20 - return mlxsw_sp_acl_tcam_ventry_add(mlxsw_sp, &ruleset->group, + return mlxsw_sp_acl_tcam_ventry_add(mlxsw_sp, &ruleset->vgroup, &rule->ventry, rulei); } =20 @@ -1413,7 +1471,7 @@ static const struct mlxsw_sp_acl_profile_ops mlxsw_sp= _acl_tcam_flower_ops =3D { =20 struct mlxsw_sp_acl_tcam_mr_ruleset { struct mlxsw_sp_acl_tcam_vchunk *vchunk; - struct mlxsw_sp_acl_tcam_group group; + struct mlxsw_sp_acl_tcam_vgroup vgroup; }; =20 struct mlxsw_sp_acl_tcam_mr_rule { @@ -1429,10 +1487,10 @@ mlxsw_sp_acl_tcam_mr_ruleset_add(struct mlxsw_sp *m= lxsw_sp, struct mlxsw_sp_acl_tcam_mr_ruleset *ruleset =3D ruleset_priv; int err; =20 - err =3D mlxsw_sp_acl_tcam_group_add(mlxsw_sp, tcam, &ruleset->group, - mlxsw_sp_acl_tcam_patterns, - MLXSW_SP_ACL_TCAM_PATTERNS_COUNT, - tmplt_elusage); + err =3D mlxsw_sp_acl_tcam_vgroup_add(mlxsw_sp, tcam, &ruleset->vgroup, + mlxsw_sp_acl_tcam_patterns, + MLXSW_SP_ACL_TCAM_PATTERNS_COUNT, + tmplt_elusage); if (err) return err; =20 @@ -1443,7 +1501,7 @@ mlxsw_sp_acl_tcam_mr_ruleset_add(struct mlxsw_sp *mlx= sw_sp, * is initialized. */ ruleset->vchunk =3D mlxsw_sp_acl_tcam_vchunk_get(mlxsw_sp, - &ruleset->group, 1, + &ruleset->vgroup, 1, tmplt_elusage); if (IS_ERR(ruleset->vchunk)) { err =3D PTR_ERR(ruleset->vchunk); @@ -1453,7 +1511,7 @@ mlxsw_sp_acl_tcam_mr_ruleset_add(struct mlxsw_sp *mlx= sw_sp, return 0; =20 err_chunk_get: - mlxsw_sp_acl_tcam_group_del(mlxsw_sp, &ruleset->group); + mlxsw_sp_acl_tcam_vgroup_del(&ruleset->vgroup); return err; } =20 @@ -1463,7 +1521,7 @@ mlxsw_sp_acl_tcam_mr_ruleset_del(struct mlxsw_sp *mlx= sw_sp, void *ruleset_priv) struct mlxsw_sp_acl_tcam_mr_ruleset *ruleset =3D ruleset_priv; =20 mlxsw_sp_acl_tcam_vchunk_put(mlxsw_sp, ruleset->vchunk); - mlxsw_sp_acl_tcam_group_del(mlxsw_sp, &ruleset->group); + mlxsw_sp_acl_tcam_vgroup_del(&ruleset->vgroup); } =20 static int @@ -1488,7 +1546,7 @@ mlxsw_sp_acl_tcam_mr_ruleset_group_id(void *ruleset_p= riv) { struct mlxsw_sp_acl_tcam_mr_ruleset *ruleset =3D ruleset_priv; =20 - return mlxsw_sp_acl_tcam_group_id(&ruleset->group); + return mlxsw_sp_acl_tcam_group_id(&ruleset->vgroup.group); } =20 static int @@ -1499,7 +1557,7 @@ mlxsw_sp_acl_tcam_mr_rule_add(struct mlxsw_sp *mlxsw_= sp, void *ruleset_priv, struct mlxsw_sp_acl_tcam_mr_ruleset *ruleset =3D ruleset_priv; struct mlxsw_sp_acl_tcam_mr_rule *rule =3D rule_priv; =20 - return mlxsw_sp_acl_tcam_ventry_add(mlxsw_sp, &ruleset->group, + return mlxsw_sp_acl_tcam_ventry_add(mlxsw_sp, &ruleset->vgroup, &rule->ventry, rulei); } =20 diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h b/driv= ers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h index 96bd42a9fbc3..77de76647ede 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h @@ -78,6 +78,8 @@ struct mlxsw_sp_acl_tcam_vregion; =20 struct mlxsw_sp_acl_tcam_region { struct mlxsw_sp_acl_tcam_vregion *vregion; + struct mlxsw_sp_acl_tcam_group *group; + struct list_head list; /* Member of a TCAM group */ enum mlxsw_reg_ptar_key_type key_type; u16 id; /* ACL ID and region ID - they are same */ char tcam_region_info[MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN]; --=20 2.20.1