From patchwork Tue Jul 17 15:36:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10529879 X-Patchwork-Delegate: idosch@idosch.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 525486020A for ; Tue, 17 Jul 2018 15:41:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21E5B29702 for ; Tue, 17 Jul 2018 15:41:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1FDF52970B; Tue, 17 Jul 2018 15:41:32 +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 DCA87296E2 for ; Tue, 17 Jul 2018 15:41:30 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41VPdj1DyjzF3Jb for ; Wed, 18 Jul 2018 01:41:29 +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="J38EFJLl"; 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=2a01:111:f400:fe07::603; helo=eur02-am5-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="J38EFJLl"; dkim-atps=neutral Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-am5eur02on0603.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe07::603]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41VPYY2VQFzF3Hh for ; Wed, 18 Jul 2018 01:37:53 +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=P4yMrMy5WufJfW58PZqBYJ4OwNzgUu+wf1XOGDJ69HQ=; b=J38EFJLlIaRpZNfMsthn1czB5ttMtndHfFJYe5r4xe0s1PLl3+16y7BugFqS3Y6GQtW+LwOF2jMYI4eXFiARz22txckxsE0hBejSaxQfmiA7vIyNrtTR9LMcuFBsGDPmoM8Xd+hIdSIcrVbyQtrSr/6qhO7EN/t5PgLTsa9AExs= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=idosch@mellanox.com; Received: from splinter.mtl.com (193.47.165.251) by HE1PR0501MB2330.eurprd05.prod.outlook.com (2603:10a6:3:27::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.952.21; Tue, 17 Jul 2018 15:37:42 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH RESEND net-next mlxsw 17/18] mlxsw: spectrum_acl: Start using A-TCAM Date: Tue, 17 Jul 2018 18:36:56 +0300 Message-Id: <20180717153657.16324-18-idosch@mellanox.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180717153657.16324-1-idosch@mellanox.com> References: <20180717153657.16324-1-idosch@mellanox.com> MIME-Version: 1.0 X-Originating-IP: [193.47.165.251] X-ClientProxiedBy: AM0PR02CA0020.eurprd02.prod.outlook.com (2603:10a6:208:3e::33) To HE1PR0501MB2330.eurprd05.prod.outlook.com (2603:10a6:3:27::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7da2144d-1e15-4e97-36db-08d5ebfb3cae X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(48565401081)(2017052603328)(7153060)(7193020); SRVR:HE1PR0501MB2330; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2330; 3:Sz4ISZLSzvZCm2W+BcpwyqtuyUQ6obodZFfmOc+8KHykoM27HCvrPaTuCLuGlFswjLGo19PjPhGuJ9PJZ7xxZCP5+xEuZifMdKYttQ57fBTMX6qq7MEMYuHQMIiYevWfyBtnFJP6Onnz2JxhtgRZ1ft+cOEiEA8KJNJ8bNVXjwj6uw16EtdQQNPSH/tv/tmPLOT59Sz/oKUV95xcg1JE0OVxKhaz/Hd2sqxu0de8uJhCMZDGafYrg/Ej0E6A7UiE; 25:Nd/W7d5P11O2geZeMa/8GzEN5Zb3XP+dk0hWar+bqd8GNGjhMC0GZj4oiz4gHsACzC3G4dlIG7OmM+3z23XAVyEMsXvvkpQ0fR0oICytLEe2JJ5HbRvfxcjQwCnc6IGpqFJ8Yp6QMwlngvrmD1T//uvOdPRKZdsQ6+fzXIFMSE5QcsQzZUcCEBpHzxeUVBHdp7FdWviwoaCBSO/+HUn9crYnHRa4kN+8mtRGSXvWmzEiKqhF67ug0KWhkDYviS5+HXYlGtioz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YIRPC0aXeFYDH+UkvgM7TECciVc9OExqGRe08a/RBT7vtTi41rNDZQhhUCVTrXyHrnbXy9ovL52mnIKBm0Gw0sEKMZ2kicnbOABKk6qA6zrA== 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)(8121501046)(5005006)(3231311)(944501410)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(149027)(150027)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:HE1PR0501MB2330; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0501MB2330; X-Forefront-PRVS: 073631BD3D X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(1496009)(396003)(39860400002)(346002)(136003)(376002)(366004)(189003)(199004)(51416003)(2906002)(8676002)(476003)(8936002)(6506007)(956004)(81156014)(2616005)(6486002)(2351001)(26005)(386003)(81166006)(16526019)(107886003)(53416004)(486006)(105586002)(446003)(4326008)(11346002)(34206002)(106356001)(66066001)(53936002)(47776003)(76176011)(68736007)(478600001)(6512007)(316002)(50226002)(50466002)(52116002)(7736002)(2361001)(3846002)(16586007)(305945005)(37006003)(97736004)(86362001)(6116002)(36756003)(217873002)(575784001)(1076002)(48376002)(6636002)(5660300001)(6666003)(25786009); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0501MB2330; H:splinter.mtl.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-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0501MB2330; 23:4FlL5fPE/SHRscQhtpLzSW0UIfMKZQwLCnfKrbY?= =?us-ascii?Q?z/JVSpvFUpYt9BjaHuTWUYDgVNoW+OD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2qRiIS44+r+TH/t84lACeXSsTTalrulq3infSw0l5QGvrECq9A1gIR?= =?us-ascii?Q?L7hlHmY1ovclyomROQPV9E3v4EqRYK6Oemy7GCGZ0r6ZVO/zAN9YJoaIOdxy?= =?us-ascii?Q?h2vOzlvAhcjaFzHYP9EwrVfq6lIQLCVrr9wl8v6tSRs/DttGBqp629943V7V?= =?us-ascii?Q?4koK7w5tH2pLtHxbKuLmC96FHEzVeVKgIdvPf5cZpjitlcncvlfT50oDuoi7?= =?us-ascii?Q?VKY0Vprrs4NfMMBQbQaVXVP3TFV8R48dGteH60buIz2pOqWHDZBjtZyM/3kS?= =?us-ascii?Q?gb0RRxCxpdvyoqlMziXy/acJwcMVb9TXx+nOYvd0ZyyhrQ9bu/ew8OsMxPhV?= =?us-ascii?Q?FU8wLkZvy4q9pRvNbzDqiBDG7KfUru225PGcE4uy4q8fqrNvysfpW+o6Fppb?= =?us-ascii?Q?GB8z6pQ=3D=3D?= X-Microsoft-Antispam-Message-Info: Gl10zJuynOxeU24GozzXDm86miaGnwZvRL2BXDau37BAIbLI9A4Z6/GLGJ8rZENXEKoH2N715a/69+9hKZuFckdLB64ZZSczfQza9eUeMeqyC+QdGqqPKpT2I7GwcUTl3FDVrz37JG8GOZXAym/99HJAzJTff+4CZ26nialJCIcVziRJAtdhUwDwMhUFkWIpLpANozDXuYdXOldTVZT4N6DkJPxoDp6Rkgqzw797K/Fe3XSQ/or2oiHkEQ0d6zUTSnMWZ8Ob9AAsuS7bN8rwRCoojIL7ff7ed4xJsEjwmD/H8imyHWj1k2iOXVAmOkDLn98UUiJwisGEyxFIxY+TebEOU19Ed3EZrGuSVGgQWUw= X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2330; 6:3FWl/6953A50rfhKI7QKGmkhfp+8Gn5m46WtG+GurAZN/pe9axkremFu/Rt5UXNTq+ofD9EzyXrhNhQ2rvWcXJt4Jn8qyelxIo9TlzDtBYR/dNOP4lA28TvS0sImNw5c57qI/1YBhu1PohG1XR2SiXCmLjNfDGNIS+Bc8J6l8FKpzsTLgVzs201d9/H3onlhIUtrGXyFPr+AVCtnlhdBgyKXbsHzwHhhUSm0x6zvmTxigf9b8HGBFh/j7krvro7fuictXiKx8OHbDtEmlCKO52jR/yTosQ5terz42fln9OaB6sDZ7axzg4j7ay+w80DdopgPajm5nprP5dahec/nWvYGs1O2J3Q+y7lhhzsZh+6rjLWVtUzbWeVf+NabIp+/0Qy5RZIT9S8Ue0I28UtBmrZQFO9n9qjkgIy2DLmhChGgGEXMxyMGhF/Xwo4hBi0S72lf0jk7kENfoEhn8ZWLGQ==; 5:3+84Me6wsxnXzQdFwIgc6uEBdohTm8Sg1mJPz/WXF/F1tA3Mz3/GX5o/ZU3XHUTFCg+6f746mkdUXSnetWTN3lndOvgYFuZc07huCH2WjoRCXsbTcjDfF39eq/LOo6+4Cgb2Ixsslmwg7z1JFzYEsEzEaeN84/Pc9NB/ujV6IuI=; 24:rjsFCbJjsrJKSvXhMrdCJzmq4wgt9JRB/CXuWu8aDntC8lYFzNWcBPxMktUzZayN9/YGeq/LBngGCSrzVaYlalQgO36ZTJNpMernW+74NTU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2330; 7:75k3tGG3KX4A9srmR0/D8qeCDEXfBMoxZ65MX9ilN5VPtOjhxlHuJtFcVni6X1uwmHBdkAjDkk7hcX8aTdJPHMO/ZBNKDP0v8okTB5Auf6cWJ9wMyZvqNwKKoKG/5GMNwaZ95pRiaF5pylw/RPEnnVLCYOd7XqUzHWNxnqZLW7n3cr/40fv7f08vpzG1GzqCKkIXpbupn7iMRl2icS3ffiUBDqu5Mw6+eACmQ/DiZ54+iq1aq1UHxldVnJIkeda2 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2018 15:37:42.4380 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7da2144d-1e15-4e97-36db-08d5ebfb3cae X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0501MB2330 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 --- drivers/net/ethernet/mellanox/mlxsw/reg.h | 1 - .../ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c | 25 ++++- .../ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c | 101 +++++++++++++++++++-- .../ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c | 14 ++- .../net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c | 13 +-- .../ethernet/mellanox/mlxsw/spectrum_acl_tcam.h | 30 +++++- 6 files changed, 159 insertions(+), 25 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..5e6ebcd03be2 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c @@ -58,6 +58,28 @@ 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 +151,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 c2d52d6fe312..bf6116f9c933 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum2_acl_tcam.c @@ -54,8 +54,53 @@ struct mlxsw_sp2_acl_tcam_chunk { }; struct mlxsw_sp2_acl_tcam_entry { - struct mlxsw_sp_acl_ctcam_entry centry; + struct mlxsw_sp_acl_atcam_entry aentry; struct mlxsw_afa_block *act_block; + void (*destructor)(struct mlxsw_sp2_acl_tcam_entry *entry, + struct mlxsw_sp2_acl_tcam_region *region, + struct mlxsw_sp2_acl_tcam_chunk *chunk); +}; + +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, @@ -145,7 +190,8 @@ mlxsw_sp2_acl_tcam_region_init(struct mlxsw_sp *mlxsw_sp, void *region_priv, return err; err = mlxsw_sp_acl_ctcam_region_init(mlxsw_sp, ®ion->aregion.cregion, - _region); + _region, + &mlxsw_sp2_acl_ctcam_region_ops); if (err) goto err_ctcam_region_init; @@ -189,6 +235,30 @@ static void mlxsw_sp2_acl_tcam_chunk_fini(void *chunk_priv) mlxsw_sp_acl_ctcam_chunk_fini(&chunk->cchunk); } +static void +mlxsw_sp2_acl_atcam_entry_del(struct mlxsw_sp2_acl_tcam_entry *entry, + struct mlxsw_sp2_acl_tcam_region *region, + struct mlxsw_sp2_acl_tcam_chunk *chunk) +{ + struct mlxsw_sp_acl_tcam_region *_region = region->region; + struct mlxsw_sp *mlxsw_sp = _region->mlxsw_sp; + + mlxsw_sp_acl_atcam_entry_del(mlxsw_sp, ®ion->aregion, + &entry->aentry); +} + +static void +mlxsw_sp2_acl_ctcam_entry_del(struct mlxsw_sp2_acl_tcam_entry *entry, + struct mlxsw_sp2_acl_tcam_region *region, + struct mlxsw_sp2_acl_tcam_chunk *chunk) +{ + struct mlxsw_sp_acl_tcam_region *_region = region->region; + struct mlxsw_sp *mlxsw_sp = _region->mlxsw_sp; + + mlxsw_sp_acl_ctcam_entry_del(mlxsw_sp, ®ion->aregion.cregion, + &chunk->cchunk, &entry->aentry.centry); +} + static int mlxsw_sp2_acl_tcam_entry_add(struct mlxsw_sp *mlxsw_sp, void *region_priv, void *chunk_priv, void *entry_priv, @@ -197,11 +267,29 @@ static int mlxsw_sp2_acl_tcam_entry_add(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp2_acl_tcam_region *region = region_priv; struct mlxsw_sp2_acl_tcam_chunk *chunk = chunk_priv; struct mlxsw_sp2_acl_tcam_entry *entry = entry_priv; + int err; entry->act_block = rulei->act_block; - return mlxsw_sp_acl_ctcam_entry_add(mlxsw_sp, ®ion->aregion.cregion, - &chunk->cchunk, &entry->centry, - rulei, true); + + err = mlxsw_sp_acl_atcam_entry_add(mlxsw_sp, ®ion->aregion, + &entry->aentry, rulei); + if (!err) { + entry->destructor = mlxsw_sp2_acl_atcam_entry_del; + return 0; + } + + /* It is possible we failed to add the rule to the A-TCAM due to + * exceeded number of masks. Try to spill into C-TCAM. + */ + err = mlxsw_sp_acl_ctcam_entry_add(mlxsw_sp, ®ion->aregion.cregion, + &chunk->cchunk, + &entry->aentry.centry, rulei, true); + if (!err) { + entry->destructor = mlxsw_sp2_acl_ctcam_entry_del; + return 0; + } + + return err; } static void mlxsw_sp2_acl_tcam_entry_del(struct mlxsw_sp *mlxsw_sp, @@ -212,8 +300,7 @@ 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->centry); + entry->destructor(entry, region, chunk); } static int diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c index a4b0a286384e..5c1bcd97473e 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c @@ -96,6 +96,10 @@ mlxsw_sp_acl_ctcam_region_entry_insert(struct mlxsw_sp *mlxsw_sp, mask = mlxsw_reg_ptce2_mask_data(ptce2_pl); mlxsw_afk_encode(afk, region->key_info, &rulei->values, key, mask); + 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); @@ -115,6 +119,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, @@ -152,11 +157,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 509d755804cb..9cd69f00cd5d 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c @@ -1035,11 +1035,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); } @@ -1049,7 +1046,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); } @@ -1064,16 +1061,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 6d904c1dbdc2..036b94ff01df 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h @@ -111,6 +111,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; }; @@ -122,9 +123,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, @@ -180,10 +191,23 @@ struct mlxsw_sp_acl_atcam_entry_ht_key { struct mlxsw_sp_acl_atcam_entry { struct rhash_head ht_node; struct mlxsw_sp_acl_atcam_entry_ht_key ht_key; + struct mlxsw_sp_acl_ctcam_entry centry; struct mlxsw_sp_acl_atcam_lkey_id *lkey_id; 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,