From patchwork Tue Jul 24 14:29:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10542309 X-Patchwork-Delegate: jiri@resnulli.us Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B65DB112E for ; Tue, 24 Jul 2018 14:43:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A336028C66 for ; Tue, 24 Jul 2018 14:43:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 967D528C86; Tue, 24 Jul 2018 14:43:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 631AB28C66 for ; Tue, 24 Jul 2018 14:43:21 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41Zh1M4g0NzDsG1 for ; Wed, 25 Jul 2018 00:43:19 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="Nm6oUtDK"; dkim-atps=neutral X-Original-To: linux-mlxsw@lists.ozlabs.org Delivered-To: linux-mlxsw@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=mellanox.com (client-ip=104.47.0.88; helo=eur01-he1-obe.outbound.protection.outlook.com; envelope-from=idosch@mellanox.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="Nm6oUtDK"; dkim-atps=neutral Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0088.outbound.protection.outlook.com [104.47.0.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41ZgkT6f6YzDsMm for ; Wed, 25 Jul 2018 00:30:25 +1000 (AEST) 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=uk2oAL5JA1JKCDb0IusDHWyniMtMDcFaTi9CLTsteN8=; b=Nm6oUtDKLYLn4Y7DV6AiKoLDGblrRe4+eWaXjxfy0NFXkEhv9Ect+aO/ONshjUDp5nx5aPVPd5ds7lND9nPS6U00E5nOhE5RBM0yPuo9I5WM2pfTeMNzBvMP3uXBFIKGvI3+Umne+pG+iVfLFr6zBO4pkkWvblp7HMPRI8O5KXM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=idosch@mellanox.com; Received: from splinter.mtl.com (193.47.165.251) by AM4PR0501MB2322.eurprd05.prod.outlook.com (2603:10a6:200:53::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.16; Tue, 24 Jul 2018 14:30:10 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH net-next mlxsw v4 17/18] mlxsw: spectrum_acl: Start using A-TCAM Date: Tue, 24 Jul 2018 17:29:25 +0300 Message-Id: <20180724142926.13033-18-idosch@mellanox.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180724142926.13033-1-idosch@mellanox.com> References: <20180724142926.13033-1-idosch@mellanox.com> MIME-Version: 1.0 X-Originating-IP: [193.47.165.251] X-ClientProxiedBy: VI1P189CA0018.EURP189.PROD.OUTLOOK.COM (2603:10a6:802:2a::31) To AM4PR0501MB2322.eurprd05.prod.outlook.com (2603:10a6:200:53::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 59b2a01d-b557-4a23-0234-08d5f171f665 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600073)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM4PR0501MB2322; X-Microsoft-Exchange-Diagnostics: 1; AM4PR0501MB2322; 3:apaaTA1loIS8sbeQSCfj0gCwm+JEv1/OJNXpIOEVVaApD54Sucz00gKI53UjupMQwQOdZ8vuNasKk/6IXJsYynEpA/v/IkoMvMphiy4ysRdeSd7VGqCQGKR2SqdrfWpLCpHh5tgI308R735CiTzx1I4LRahyRGnfI7DzoMDf9I24RizDnvI/XgrotGpQbL/KfCKo3WmhfepqvOsAafg+HLYnjzx/n4ibx3djHnqEw7hb1MyuRkMvhYGD1OPsu+fD; 25:QuHQAS1jh6ydBIvnGAMUTTfPXO4myH2xiqYRZcB4w7Z9onXAZYfn50aUt2j6c6KRGYz5f1oIR/6C6tTyqWqGauj9w2BxVr7QRYRljsH65GzEn0bixJ8+HgK9eggdZk6v7MBlkKFIhZWIH8lg7vlxPLhzU7IuJFPq0X9wzLubgubDjwHd1A0O6hpweC2H9cuV/6zd6Gqvmdf+HwqhbtgK45A3pD1ayDA9DS3Ed50jJOIpMs6KwbBUZ0d5CXRgJgMKiTRAicorTTwtgmH680gSMX0zIUr3Be94q9huMKrg+N15gbFIP3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ti77Gbk9kGhsQuERkZBpdzvj1ftkQB9KZnTHVquwnUgIfh8DuSY5tJWamKqgC2ZvhJVqjAZepsAYOofJc0dCw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:AM4PR0501MB2322; BCL:0; PCL:0; RULEID:; SRVR:AM4PR0501MB2322; X-Forefront-PRVS: 0743E8D0A6 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(1496009)(346002)(396003)(376002)(39860400002)(366004)(136003)(199004)(189003)(53936002)(97736004)(7736002)(305945005)(446003)(34206002)(107886003)(575784001)(6512007)(486006)(4326008)(25786009)(26005)(478600001)(6486002)(11346002)(16526019)(6116002)(105586002)(2616005)(956004)(16586007)(53416004)(316002)(3846002)(66066001)(1076002)(47776003)(2361001)(5660300001)(68736007)(51416003)(50226002)(2906002)(76176011)(8936002)(37006003)(106356001)(81156014)(86362001)(8676002)(386003)(36756003)(81166006)(6636002)(48376002)(2351001)(52116002)(6666003)(476003)(50466002)(6506007); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR0501MB2322; H:splinter.mtl.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-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM4PR0501MB2322; 23:3Mgn4P44wsJ4shcOtdVW9wsDd7fcIJUltKPyvEU?= IBE7uOHVt34/MacZIejDIlQGmYJ1RHNdgxZMGOuiFmK4AXwZDTn0kcTtq/IkTdgGBRqQ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dPQDMdni6Juiqf8LhVWnLDuYTL9Y2Ivl5VoW46wZSiGkR0bwNy8JgJd+8c0j56JBxcHNEtiBueQhWdFxNQo9c3LE5i/sY/r9PRiSN+WtRFyDh2RkVP3C9XMPGsxKLOqUXSSsyr/qUdsVfu0Sf/G0QW4iGMJOijc0Ts=; 7:iMu0VNgd+rHJzfBV3UH7BKbS5TvIXYOooM13+XFj8yeAtzO0TaitTQKCAXB7COei8gcn8NBbs8qH/060NPnJ/65yZk0I/eX5UlcyuXjF47Uqa3WiHFGtExbQKPrYf3sR1JUS3PvlLmgMQYMzQ6MDb5VGgLykWDWBXtYCeCa+fKPqNHoWlOp0QkOqN9BQO+gjBne5wuL3P+jCJgnSgQB5QIJ+V4HWGH3et7QCU0YBVYTd50dS62SNCGIdui2Y2k3B SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2018 14:30:10.4112 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 59b2a01d-b557-4a23-0234-08d5f171f665 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0501MB2322 X-BeenThere: linux-mlxsw@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: mlxsw driver development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-mlxsw-bounces+patchwork-linux-mlxsw=patchwork.kernel.org@lists.ozlabs.org X-Virus-Scanned: ClamAV using ClamSMTP Now that all the pieces are in place we can start using the A-TCAM instead of only using the C-TCAM. This allows for much higher scale and better performance (to be improved further by follow-up patch sets). Perform the integration with the A-TCAM and the eRP core by reverting the changes introduced by "mlxsw: spectrum_acl: Enable C-TCAM only mode in eRP core" and add calls from the C-TCAM code into the eRP core. Signed-off-by: Ido Schimmel Reviewed-by: Jiri Pirko --- Notes: v3: * Spill to C-TCAM from A-TCAM code instead of Spectrum-2 code, that only calls mlxsw_sp_acl_atcam_entry_add() v2: * Do not break lines at 80 chars where cure is worse than the disease drivers/net/ethernet/mellanox/mlxsw/reg.h | 1 - .../mellanox/mlxsw/spectrum1_acl_tcam.c | 23 +++++++- .../mellanox/mlxsw/spectrum2_acl_tcam.c | 58 ++++++++++++++++--- .../mellanox/mlxsw/spectrum_acl_atcam.c | 12 ++-- .../mellanox/mlxsw/spectrum_acl_ctcam.c | 14 ++++- .../mellanox/mlxsw/spectrum_acl_erp.c | 13 +---- .../mellanox/mlxsw/spectrum_acl_tcam.h | 39 ++++++++++--- 7 files changed, 124 insertions(+), 36 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h index 5acef249e776..fd2e3dd166d2 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/reg.h +++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h @@ -2868,7 +2868,6 @@ static inline void mlxsw_reg_percr_pack(char *payload, u16 region_id) mlxsw_reg_percr_atcam_ignore_prune_set(payload, false); mlxsw_reg_percr_ctcam_ignore_prune_set(payload, false); mlxsw_reg_percr_bf_bypass_set(payload, true); - memset(payload + 0x20, 0xff, 96); } /* PERERP - Policy-Engine Region eRP Register diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c index 926483434e99..5c8956573632 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c @@ -58,6 +58,26 @@ struct mlxsw_sp1_acl_tcam_entry { struct mlxsw_sp_acl_ctcam_entry centry; }; +static int +mlxsw_sp1_acl_ctcam_region_entry_insert(struct mlxsw_sp_acl_ctcam_region *cregion, + struct mlxsw_sp_acl_ctcam_entry *centry, + const char *mask) +{ + return 0; +} + +static void +mlxsw_sp1_acl_ctcam_region_entry_remove(struct mlxsw_sp_acl_ctcam_region *cregion, + struct mlxsw_sp_acl_ctcam_entry *centry) +{ +} + +static const struct mlxsw_sp_acl_ctcam_region_ops +mlxsw_sp1_acl_ctcam_region_ops = { + .entry_insert = mlxsw_sp1_acl_ctcam_region_entry_insert, + .entry_remove = mlxsw_sp1_acl_ctcam_region_entry_remove, +}; + static int mlxsw_sp1_acl_tcam_init(struct mlxsw_sp *mlxsw_sp, void *priv, struct mlxsw_sp_acl_tcam *tcam) { @@ -129,7 +149,8 @@ mlxsw_sp1_acl_tcam_region_init(struct mlxsw_sp *mlxsw_sp, void *region_priv, int err; err = mlxsw_sp_acl_ctcam_region_init(mlxsw_sp, ®ion->cregion, - _region); + _region, + &mlxsw_sp1_acl_ctcam_region_ops); if (err) return err; err = mlxsw_sp1_acl_ctcam_region_catchall_add(mlxsw_sp, region); diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c index aef366148cc3..22c876496379 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c @@ -50,7 +50,7 @@ struct mlxsw_sp2_acl_tcam_region { }; struct mlxsw_sp2_acl_tcam_chunk { - struct mlxsw_sp_acl_ctcam_chunk cchunk; + struct mlxsw_sp_acl_atcam_chunk achunk; }; struct mlxsw_sp2_acl_tcam_entry { @@ -58,6 +58,45 @@ struct mlxsw_sp2_acl_tcam_entry { struct mlxsw_afa_block *act_block; }; +static int +mlxsw_sp2_acl_ctcam_region_entry_insert(struct mlxsw_sp_acl_ctcam_region *cregion, + struct mlxsw_sp_acl_ctcam_entry *centry, + const char *mask) +{ + struct mlxsw_sp_acl_atcam_region *aregion; + struct mlxsw_sp_acl_atcam_entry *aentry; + struct mlxsw_sp_acl_erp *erp; + + aregion = mlxsw_sp_acl_tcam_cregion_aregion(cregion); + aentry = mlxsw_sp_acl_tcam_centry_aentry(centry); + + erp = mlxsw_sp_acl_erp_get(aregion, mask, true); + if (IS_ERR(erp)) + return PTR_ERR(erp); + aentry->erp = erp; + + return 0; +} + +static void +mlxsw_sp2_acl_ctcam_region_entry_remove(struct mlxsw_sp_acl_ctcam_region *cregion, + struct mlxsw_sp_acl_ctcam_entry *centry) +{ + struct mlxsw_sp_acl_atcam_region *aregion; + struct mlxsw_sp_acl_atcam_entry *aentry; + + aregion = mlxsw_sp_acl_tcam_cregion_aregion(cregion); + aentry = mlxsw_sp_acl_tcam_centry_aentry(centry); + + mlxsw_sp_acl_erp_put(aregion, aentry->erp); +} + +static const struct mlxsw_sp_acl_ctcam_region_ops +mlxsw_sp2_acl_ctcam_region_ops = { + .entry_insert = mlxsw_sp2_acl_ctcam_region_entry_insert, + .entry_remove = mlxsw_sp2_acl_ctcam_region_entry_remove, +}; + static int mlxsw_sp2_acl_tcam_init(struct mlxsw_sp *mlxsw_sp, void *priv, struct mlxsw_sp_acl_tcam *_tcam) { @@ -139,7 +178,8 @@ mlxsw_sp2_acl_tcam_region_init(struct mlxsw_sp *mlxsw_sp, void *region_priv, region->region = _region; return mlxsw_sp_acl_atcam_region_init(mlxsw_sp, &tcam->atcam, - ®ion->aregion, _region); + ®ion->aregion, _region, + &mlxsw_sp2_acl_ctcam_region_ops); } static void @@ -163,7 +203,7 @@ static void mlxsw_sp2_acl_tcam_chunk_init(void *region_priv, void *chunk_priv, struct mlxsw_sp2_acl_tcam_region *region = region_priv; struct mlxsw_sp2_acl_tcam_chunk *chunk = chunk_priv; - mlxsw_sp_acl_ctcam_chunk_init(®ion->aregion.cregion, &chunk->cchunk, + mlxsw_sp_acl_atcam_chunk_init(®ion->aregion, &chunk->achunk, priority); } @@ -171,7 +211,7 @@ static void mlxsw_sp2_acl_tcam_chunk_fini(void *chunk_priv) { struct mlxsw_sp2_acl_tcam_chunk *chunk = chunk_priv; - mlxsw_sp_acl_ctcam_chunk_fini(&chunk->cchunk); + mlxsw_sp_acl_atcam_chunk_fini(&chunk->achunk); } static int mlxsw_sp2_acl_tcam_entry_add(struct mlxsw_sp *mlxsw_sp, @@ -184,9 +224,9 @@ static int mlxsw_sp2_acl_tcam_entry_add(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp2_acl_tcam_entry *entry = entry_priv; entry->act_block = rulei->act_block; - return mlxsw_sp_acl_ctcam_entry_add(mlxsw_sp, ®ion->aregion.cregion, - &chunk->cchunk, - &entry->aentry.centry, rulei, true); + return mlxsw_sp_acl_atcam_entry_add(mlxsw_sp, ®ion->aregion, + &chunk->achunk, &entry->aentry, + rulei); } static void mlxsw_sp2_acl_tcam_entry_del(struct mlxsw_sp *mlxsw_sp, @@ -197,8 +237,8 @@ static void mlxsw_sp2_acl_tcam_entry_del(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp2_acl_tcam_chunk *chunk = chunk_priv; struct mlxsw_sp2_acl_tcam_entry *entry = entry_priv; - mlxsw_sp_acl_ctcam_entry_del(mlxsw_sp, ®ion->aregion.cregion, - &chunk->cchunk, &entry->aentry.centry); + mlxsw_sp_acl_atcam_entry_del(mlxsw_sp, ®ion->aregion, &chunk->achunk, + &entry->aentry); } static int diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c index d551f0431248..3a05e0b3f730 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_atcam.c @@ -344,10 +344,12 @@ mlxsw_sp_acl_atcam_region_type_init(struct mlxsw_sp_acl_atcam_region *aregion) aregion->ops = mlxsw_sp_acl_atcam_region_ops_arr[region_type]; } -int mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_acl_atcam *atcam, - struct mlxsw_sp_acl_atcam_region *aregion, - struct mlxsw_sp_acl_tcam_region *region) +int +mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_atcam *atcam, + struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_tcam_region *region, + const struct mlxsw_sp_acl_ctcam_region_ops *ops) { int err; @@ -366,7 +368,7 @@ int mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, if (err) goto err_erp_region_init; err = mlxsw_sp_acl_ctcam_region_init(mlxsw_sp, &aregion->cregion, - region); + region, ops); if (err) goto err_ctcam_region_init; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c index 7ff31247cac7..7440a1189250 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c @@ -98,6 +98,10 @@ mlxsw_sp_acl_ctcam_region_entry_insert(struct mlxsw_sp *mlxsw_sp, mlxsw_afk_encode(afk, region->key_info, &rulei->values, key, mask, 0, blocks_count - 1); + err = cregion->ops->entry_insert(cregion, centry, mask); + if (err) + return err; + /* Only the first action set belongs here, the rest is in KVD */ act_set = mlxsw_afa_block_first_set(rulei->act_block); mlxsw_reg_ptce2_flex_action_set_memcpy_to(ptce2_pl, act_set); @@ -116,6 +120,7 @@ mlxsw_sp_acl_ctcam_region_entry_remove(struct mlxsw_sp *mlxsw_sp, cregion->region->tcam_region_info, centry->parman_item.index, 0); mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ptce2), ptce2_pl); + cregion->ops->entry_remove(cregion, centry); } static int mlxsw_sp_acl_ctcam_region_parman_resize(void *priv, @@ -153,11 +158,14 @@ static const struct parman_ops mlxsw_sp_acl_ctcam_region_parman_ops = { .algo = PARMAN_ALGO_TYPE_LSORT, }; -int mlxsw_sp_acl_ctcam_region_init(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_acl_ctcam_region *cregion, - struct mlxsw_sp_acl_tcam_region *region) +int +mlxsw_sp_acl_ctcam_region_init(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_ctcam_region *cregion, + struct mlxsw_sp_acl_tcam_region *region, + const struct mlxsw_sp_acl_ctcam_region_ops *ops) { cregion->region = region; + cregion->ops = ops; cregion->parman = parman_create(&mlxsw_sp_acl_ctcam_region_parman_ops, cregion); if (!cregion->parman) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c index bb07723a0577..463590bbb348 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c @@ -1048,11 +1048,8 @@ mlxsw_sp_acl_erp_master_mask_init(struct mlxsw_sp_acl_atcam_region *aregion) { struct mlxsw_sp *mlxsw_sp = aregion->region->mlxsw_sp; char percr_pl[MLXSW_REG_PERCR_LEN]; - char *master_mask; mlxsw_reg_percr_pack(percr_pl, aregion->region->id); - master_mask = mlxsw_reg_percr_master_mask_data(percr_pl); - memset(master_mask, 0, MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN); return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(percr), percr_pl); } @@ -1062,7 +1059,7 @@ mlxsw_sp_acl_erp_region_param_init(struct mlxsw_sp_acl_atcam_region *aregion) struct mlxsw_sp *mlxsw_sp = aregion->region->mlxsw_sp; char pererp_pl[MLXSW_REG_PERERP_LEN]; - mlxsw_reg_pererp_pack(pererp_pl, aregion->region->id, true, true, 0, + mlxsw_reg_pererp_pack(pererp_pl, aregion->region->id, false, false, 0, 0, 0); return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pererp), pererp_pl); } @@ -1077,16 +1074,12 @@ int mlxsw_sp_acl_erp_region_init(struct mlxsw_sp_acl_atcam_region *aregion) return PTR_ERR(erp_table); aregion->erp_table = erp_table; - /* Initialize the region's master mask to all ones for C-TCAM - * only mode - */ + /* Initialize the region's master mask to all zeroes */ err = mlxsw_sp_acl_erp_master_mask_init(aregion); if (err) goto err_erp_master_mask_init; - /* Initialize the region to use the eRP table and enable C-TCAM - * lookup - */ + /* Initialize the region to not use the eRP table */ err = mlxsw_sp_acl_erp_region_param_init(aregion); if (err) goto err_erp_region_param_init; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h index fb6f9a521ddb..881ade760ace 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h @@ -112,6 +112,7 @@ struct mlxsw_sp_acl_tcam_region { struct mlxsw_sp_acl_ctcam_region { struct parman *parman; + const struct mlxsw_sp_acl_ctcam_region_ops *ops; struct mlxsw_sp_acl_tcam_region *region; }; @@ -123,9 +124,19 @@ struct mlxsw_sp_acl_ctcam_entry { struct parman_item parman_item; }; -int mlxsw_sp_acl_ctcam_region_init(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_acl_ctcam_region *cregion, - struct mlxsw_sp_acl_tcam_region *region); +struct mlxsw_sp_acl_ctcam_region_ops { + int (*entry_insert)(struct mlxsw_sp_acl_ctcam_region *cregion, + struct mlxsw_sp_acl_ctcam_entry *centry, + const char *mask); + void (*entry_remove)(struct mlxsw_sp_acl_ctcam_region *cregion, + struct mlxsw_sp_acl_ctcam_entry *centry); +}; + +int +mlxsw_sp_acl_ctcam_region_init(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_ctcam_region *cregion, + struct mlxsw_sp_acl_tcam_region *region, + const struct mlxsw_sp_acl_ctcam_region_ops *ops); void mlxsw_sp_acl_ctcam_region_fini(struct mlxsw_sp_acl_ctcam_region *cregion); void mlxsw_sp_acl_ctcam_chunk_init(struct mlxsw_sp_acl_ctcam_region *cregion, struct mlxsw_sp_acl_ctcam_chunk *cchunk, @@ -190,12 +201,26 @@ struct mlxsw_sp_acl_atcam_entry { struct mlxsw_sp_acl_erp *erp; }; +static inline struct mlxsw_sp_acl_atcam_region * +mlxsw_sp_acl_tcam_cregion_aregion(struct mlxsw_sp_acl_ctcam_region *cregion) +{ + return container_of(cregion, struct mlxsw_sp_acl_atcam_region, cregion); +} + +static inline struct mlxsw_sp_acl_atcam_entry * +mlxsw_sp_acl_tcam_centry_aentry(struct mlxsw_sp_acl_ctcam_entry *centry) +{ + return container_of(centry, struct mlxsw_sp_acl_atcam_entry, centry); +} + int mlxsw_sp_acl_atcam_region_associate(struct mlxsw_sp *mlxsw_sp, u16 region_id); -int mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, - struct mlxsw_sp_acl_atcam *atcam, - struct mlxsw_sp_acl_atcam_region *aregion, - struct mlxsw_sp_acl_tcam_region *region); +int +mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_atcam *atcam, + struct mlxsw_sp_acl_atcam_region *aregion, + struct mlxsw_sp_acl_tcam_region *region, + const struct mlxsw_sp_acl_ctcam_region_ops *ops); void mlxsw_sp_acl_atcam_region_fini(struct mlxsw_sp_acl_atcam_region *aregion); void mlxsw_sp_acl_atcam_chunk_init(struct mlxsw_sp_acl_atcam_region *aregion, struct mlxsw_sp_acl_atcam_chunk *achunk,