From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DF3E445BB4; Wed, 23 Oct 2024 19:04:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1983642FC5; Wed, 23 Oct 2024 19:01:39 +0200 (CEST) Received: from egress-ip42a.ess.de.barracuda.com (egress-ip42a.ess.de.barracuda.com [18.185.115.201]) by mails.dpdk.org (Postfix) with ESMTP id 2628942ED7 for ; Wed, 23 Oct 2024 19:01:16 +0200 (CEST) Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02lp2234.outbound.protection.outlook.com [104.47.11.234]) by mx-outbound42-14.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 23 Oct 2024 17:01:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=N8JFq0eIfDnHEsCc0RRdRSSixUvIEsiwiv4JMRK9rsoLd5Kfa9RyMpHfgmPk9TeTeYCKdKJpx+2Vxvln5OPBMyn+p6adQcbEP7qEh1R8ys84THH38lhsXQ5awDxca1vBAm203D30+rdrIi5DTi468XERMqz1y7dSSS/EEEmrcfX54Eij+pClBr8hLpHWfrSQ7UVAw3fsgvrV2oq3bUXwyM45PPxW/aBcwl5KXaU4gD33yVbNvNI3JX29/I1Df94/jcnishuQsSRXLEa9/y/DNYTFmsJpr9I7owTpJFYvtNx1sp1VYBbnnFKKzS9V6ZDMmMIF3GvPKOeHMZ/9WGGB0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3yyGfXSfojzc0Hx+MApuV8g38/qZQxDF4ocVB+9hpIc=; b=Zbfr253TWSojQfnnLxzs1zU4RpM9EuPEeAGyx+frfi0E/U4HlS3GN/Dygdp1KpNl4omtwaERoLXpG9xSWZU3PM1okT7B/GQmr20UkZI2i+RFERVFkbLCrjwBA7UQd5voKTTfEwOFhVlR7WvbuBcc/ciAYCsnwZF8DRcAhkFxwFyKZqyygupMiCdOHaVn57U2sZH24FAS/8eofZ0uBcf1lyo4QsuCq8wnPFcAa94bU/pIUhC2ruHlDcvlWViTvhsd7QgWCbC12QD5H+1ZBJHHUdP3tx8c6EnpIfUVFj0OISSsHw3kaFh79cFHQUe7AvyJCqAhc5BBNQxwYruVmZHyaw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 178.72.21.4) smtp.rcpttodomain=dpdk.org smtp.mailfrom=napatech.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=napatech.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=napatech.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3yyGfXSfojzc0Hx+MApuV8g38/qZQxDF4ocVB+9hpIc=; b=Gm7yHPjvaNOJOx97l8rjr9K4lwSOB/iElGHVAr1SiPKHaRbCIWCe0fb3iULWA5qgOwUvhNGh9y17qATtA4pBFoKvDrB5nOYZ0mpIAPgvyGwCen9cgBq1BNrmGfelpJIWbeQsGb7tJHKcJEMbv2zy/BuPWEh2cpjIWDhjBao7ZTU= Received: from DU7PR01CA0013.eurprd01.prod.exchangelabs.com (2603:10a6:10:50f::8) by AM7P190MB0712.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:121::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17; Wed, 23 Oct 2024 17:01:12 +0000 Received: from DB5PEPF00014B9E.eurprd02.prod.outlook.com (2603:10a6:10:50f:cafe::32) by DU7PR01CA0013.outlook.office365.com (2603:10a6:10:50f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.18 via Frontend Transport; Wed, 23 Oct 2024 17:01:12 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 178.72.21.4) smtp.mailfrom=napatech.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=napatech.com; Received-SPF: Fail (protection.outlook.com: domain of napatech.com does not designate 178.72.21.4 as permitted sender) receiver=protection.outlook.com; client-ip=178.72.21.4; helo=localhost.localdomain; Received: from localhost.localdomain (178.72.21.4) by DB5PEPF00014B9E.mail.protection.outlook.com (10.167.8.171) with Microsoft SMTP Server id 15.20.8093.14 via Frontend Transport; Wed, 23 Oct 2024 17:01:12 +0000 From: Serhii Iliushyk To: dev@dpdk.org Cc: mko-plv@napatech.com, sil-plv@napatech.com, ckm@napatech.com, andrew.rybchenko@oktetlabs.ru, ferruh.yigit@amd.com, Danylo Vodopianov Subject: [PATCH v3 34/73] net/ntnic: add flm rcp module Date: Wed, 23 Oct 2024 18:59:42 +0200 Message-ID: <20241023170032.314155-35-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241023170032.314155-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241023170032.314155-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB5PEPF00014B9E:EE_|AM7P190MB0712:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 3eb89326-1afa-48a6-c1cc-08dcf3844ca3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|1800799024|36860700013|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Sp5QSZtvj7UoBioxvy4GVRcgoJ684XSSRmrjXYAsUkThabSyNK5DUkdnZW4A?= =?us-ascii?Q?MK/RtxUqtlIOYmUlVJKdOMRAADdFPY65CfbNnDhfKurQ0M1xOCE4qwzyU6T9?= =?us-ascii?Q?U5WMMX9HSAeqbQdp/Lnh5Wik3amfS38sn793AaxptgyypAhd6Znk1tJgT5PP?= =?us-ascii?Q?xDZb6ymVUomHqE2tXk7Cwv+tTKXlK7j6UW/YvRzF7U4bFYAey/sZFSSSerdM?= =?us-ascii?Q?ZQl86hzHP9XU85NqWI8lRhSsFQkx6g4GOyepJm54F9ZIac9Al5D7DkMwzzMG?= =?us-ascii?Q?myJn8nW//2liXg9lUbGPLOVUzKh17qlwKnp3YeojCPLrVZUfQhNjmhg3X0Af?= =?us-ascii?Q?VLnfhQUq1CyEZljyQeFqhwsFVs4XBUW3orupEP4HQbY0cWJXmp7fd37ltRac?= =?us-ascii?Q?anf8cKerxcIp3/KHF7ip4azEhgYjcXB28xcNtfQL8Zg9rTNcbyDGBQWcMWrg?= =?us-ascii?Q?fNol/Tk8wpvCPq0dTB5fSz1XsGodqM71svbaJySuE97rFgpX7rAGcZWObD8C?= =?us-ascii?Q?mCRNCGJHVa/vmtmezQQ1HNWS7iUXcOlGq1KMN6V61Id0JvLf8xfxN/OP0om0?= =?us-ascii?Q?+R8TiTHDmyVFwAju/P5Wnrs4qk0ira80XLFdEJxOPxRfjbTFZd3BqSsiGpg4?= =?us-ascii?Q?WSMzFWH2+9y/9htOI2vOcSBvTZwKClhirClR949GGOANGP9udbufSmyCl7Gl?= =?us-ascii?Q?xPV7+9X2vtWncQAXV7eqN3DouH7ziMC2M3K5nJPLY0FBg6BqaoHvKOG+05zf?= =?us-ascii?Q?GHa3nXkAxodWki5GxrsU8/Y0o6pIagH7YhfF2RJRd10LQBrl/KaEqgFLQLHW?= =?us-ascii?Q?yJtHvS0bQX+n5o5G1xQJixegI9vXbvRKiXdP+xJmPnep6fymIinYdGKfGCV7?= =?us-ascii?Q?gsonvEKCALD2aUqw8UVLTVp6rKyjGeI2Zvt5pwsx4BJnx2WBRSQdW302M/GZ?= =?us-ascii?Q?uz8QLr1mdapiN2feTSeR/H1ytHFvlQbi8DbHYV4wppFizZ9zMbW/hb1aDixO?= =?us-ascii?Q?7cYaE1M5ldNGupenEGfafXCUj5GiGSYcyecXOwnoeR599XDhipE+FmR4iyP8?= =?us-ascii?Q?ypcXZIMofhEsoNQ7Y04xk4fRglvhjFaPNPSEytvQYLhXeoeCF4SuQWZw/zl3?= =?us-ascii?Q?YYR/B72JSKES4lkarselbdHysiN+6iYiJ0iJv+mq0dlXRBmIW9Rx1LIKl2vW?= =?us-ascii?Q?oUqznvIf6LbZX3ZJY5Dp/bOxy0VQcHiXYO4FdJ9jYh1pogfGkmTyCtQD3xeE?= =?us-ascii?Q?QcIjmpIT05qtIY9T/Sqi6DEVOcGfdRrK5Hg9CtP7CuetR+WqpKrTG2XjQHl+?= =?us-ascii?Q?rwVVsWo0csz/HXoOhrzgiZV71EJ9b+kLF/okn3NWLtOD9afJn6UOUTZjJQPw?= =?us-ascii?Q?jLvVjHoPaVcT7f1LRWY5A9J2k80L6w9Y+tUebY7os8IyV1NG5g=3D=3D?= X-Forefront-Antispam-Report: CIP:178.72.21.4; CTRY:DK; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:localhost.localdomain; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(1800799024)(36860700013)(376014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 4zt6bKaDbvgwQ7ZM8mOYvKajIYKdrR8vA1x57/S7sdOXf4XqQurhOXp7c8KGd0gU9Vd3L0sEsFma2h2ODiXWhWBHgoKLWqfNkgjkx2qVxxylPZ/4iLd4q0RxED/KDc0pyVfggzerJAm7/Le/QDEyML7qaXraAUTr6GM0TdfJCaIbkjEs9yHl51zJNtrSGcJfaUqIiqjsoDgsE3JWfMu06EIjAe2oqPn0OUR+0OR+vn7bhMwp+qnlgf3UFLIyNjcEszZ8A4d5KDj3MH5T4ApdyyOvQ2wBh4HvUyrCVRXLk/gGLbBEm+nc1W6+dNbJx+F545CjJWS7JICsYM4h6pLhmfy5f7Pj/iMISTPM7j58Kkt5dlNQ+nTSVBUrH3HvSkmJf0AeA3gxhJCL1pwe804mV5n6z3fn+pC2txvdtVd+lPoOcghlbFDvod44uYxhve9rkx0EMrZbMLda8GhFmwwKx/UzrzR6XMO9wSCBJTl/hoJmXuoVx2nOoNBjUYTmE1FWi6hyw8qPzpxS77oDVaX9faaJQUK4gyD4AjDap0ABmPPXjGtdvn9iKoAfht8klLLSClUqFbqoxm7FzgiAeXLDuIgNTe1aSqsc0PfctW6P6bVwBgntPhpf9IToF1qG6Kv0o6d/Qyh1uhzhJyylAiZcitFIph3PH0yK+EmAOP8XM60= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2024 17:01:12.4144 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3eb89326-1afa-48a6-c1cc-08dcf3844ca3 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DB5PEPF00014B9E.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7P190MB0712 X-BESS-ID: 1729702874-310766-12792-42105-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.234 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYWFiZmQGYGUNQg2TIx0dDEKN XU2MTCLNXcIM3U0MDC2NA4zcjSwsTcUqk2FgBM34eOQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259925 [from cloudscan15-19.eu-central-1a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Danylo Vodopianov The Flow Matcher module is a high-performance stateful SDRAM lookup and programming engine which supported exact match lookup in line-rate of up to hundreds of millions of flows. Signed-off-by: Danylo Vodopianov --- drivers/net/ntnic/include/hw_mod_backend.h | 4 + .../ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c | 133 ++++++++++++ .../profile_inline/flow_api_hw_db_inline.c | 195 +++++++++++++++++- .../profile_inline/flow_api_hw_db_inline.h | 20 ++ .../profile_inline/flow_api_profile_inline.c | 42 +++- 5 files changed, 390 insertions(+), 4 deletions(-) diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index de662c4ed1..13722c30a9 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -683,6 +683,10 @@ int hw_mod_flm_pst_set(struct flow_api_backend_s *be, enum hw_flm_e field, int i uint32_t value); int hw_mod_flm_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); +int hw_mod_flm_rcp_set_mask(struct flow_api_backend_s *be, enum hw_flm_e field, int index, + uint32_t *value); +int hw_mod_flm_rcp_set(struct flow_api_backend_s *be, enum hw_flm_e field, int index, + uint32_t value); int hw_mod_flm_scrub_flush(struct flow_api_backend_s *be, int start_idx, int count); diff --git a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c index f5eaea7c4e..0a7e90c04f 100644 --- a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c +++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c @@ -579,3 +579,136 @@ int hw_mod_flm_scrub_flush(struct flow_api_backend_s *be, int start_idx, int cou } return be->iface->flm_scrub_flush(be->be_dev, &be->flm, start_idx, count); } + +static int hw_mod_flm_rcp_mod(struct flow_api_backend_s *be, enum hw_flm_e field, int index, + uint32_t *value, int get) +{ + switch (_VER_) { + case 25: + switch (field) { + case HW_FLM_RCP_PRESET_ALL: + if (get) { + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + memset(&be->flm.v25.rcp[index], (uint8_t)*value, + sizeof(struct flm_v25_rcp_s)); + break; + + case HW_FLM_RCP_LOOKUP: + GET_SET(be->flm.v25.rcp[index].lookup, value); + break; + + case HW_FLM_RCP_QW0_DYN: + GET_SET(be->flm.v25.rcp[index].qw0_dyn, value); + break; + + case HW_FLM_RCP_QW0_OFS: + GET_SET(be->flm.v25.rcp[index].qw0_ofs, value); + break; + + case HW_FLM_RCP_QW0_SEL: + GET_SET(be->flm.v25.rcp[index].qw0_sel, value); + break; + + case HW_FLM_RCP_QW4_DYN: + GET_SET(be->flm.v25.rcp[index].qw4_dyn, value); + break; + + case HW_FLM_RCP_QW4_OFS: + GET_SET(be->flm.v25.rcp[index].qw4_ofs, value); + break; + + case HW_FLM_RCP_SW8_DYN: + GET_SET(be->flm.v25.rcp[index].sw8_dyn, value); + break; + + case HW_FLM_RCP_SW8_OFS: + GET_SET(be->flm.v25.rcp[index].sw8_ofs, value); + break; + + case HW_FLM_RCP_SW8_SEL: + GET_SET(be->flm.v25.rcp[index].sw8_sel, value); + break; + + case HW_FLM_RCP_SW9_DYN: + GET_SET(be->flm.v25.rcp[index].sw9_dyn, value); + break; + + case HW_FLM_RCP_SW9_OFS: + GET_SET(be->flm.v25.rcp[index].sw9_ofs, value); + break; + + case HW_FLM_RCP_MASK: + if (get) { + memcpy(value, be->flm.v25.rcp[index].mask, + sizeof(((struct flm_v25_rcp_s *)0)->mask)); + + } else { + memcpy(be->flm.v25.rcp[index].mask, value, + sizeof(((struct flm_v25_rcp_s *)0)->mask)); + } + + break; + + case HW_FLM_RCP_KID: + GET_SET(be->flm.v25.rcp[index].kid, value); + break; + + case HW_FLM_RCP_OPN: + GET_SET(be->flm.v25.rcp[index].opn, value); + break; + + case HW_FLM_RCP_IPN: + GET_SET(be->flm.v25.rcp[index].ipn, value); + break; + + case HW_FLM_RCP_BYT_DYN: + GET_SET(be->flm.v25.rcp[index].byt_dyn, value); + break; + + case HW_FLM_RCP_BYT_OFS: + GET_SET(be->flm.v25.rcp[index].byt_ofs, value); + break; + + case HW_FLM_RCP_TXPLM: + GET_SET(be->flm.v25.rcp[index].txplm, value); + break; + + case HW_FLM_RCP_AUTO_IPV4_MASK: + GET_SET(be->flm.v25.rcp[index].auto_ipv4_mask, value); + break; + + default: + UNSUP_FIELD_LOG; + return UNSUP_FIELD; + } + + break; + + default: + UNSUP_VER_LOG; + return UNSUP_VER; + } + + return 0; +} + +int hw_mod_flm_rcp_set_mask(struct flow_api_backend_s *be, enum hw_flm_e field, int index, + uint32_t *value) +{ + if (field != HW_FLM_RCP_MASK) + return UNSUP_VER; + + return hw_mod_flm_rcp_mod(be, field, index, value, 0); +} + +int hw_mod_flm_rcp_set(struct flow_api_backend_s *be, enum hw_flm_e field, int index, + uint32_t value) +{ + if (field == HW_FLM_RCP_MASK) + return UNSUP_VER; + + return hw_mod_flm_rcp_mod(be, field, index, &value, 0); +} diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c index 61492090ce..0ae058b91e 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c @@ -68,6 +68,9 @@ struct hw_db_inline_resource_db { } *cat; struct hw_db_inline_resource_db_flm_rcp { + struct hw_db_inline_flm_rcp_data data; + int ref; + struct hw_db_inline_resource_db_flm_ft { struct hw_db_inline_flm_ft_data data; struct hw_db_flm_ft idx; @@ -96,6 +99,7 @@ struct hw_db_inline_resource_db { uint32_t nb_cat; uint32_t nb_flm_ft; + uint32_t nb_flm_rcp; uint32_t nb_km_ft; uint32_t nb_km_rcp; @@ -164,6 +168,42 @@ int hw_db_inline_create(struct flow_nic_dev *ndev, void **db_handle) return -1; } + + db->nb_flm_ft = ndev->be.cat.nb_flow_types; + db->nb_flm_rcp = ndev->be.flm.nb_categories; + db->flm = calloc(db->nb_flm_rcp, sizeof(struct hw_db_inline_resource_db_flm_rcp)); + + if (db->flm == NULL) { + hw_db_inline_destroy(db); + return -1; + } + + for (uint32_t i = 0; i < db->nb_flm_rcp; ++i) { + db->flm[i].ft = + calloc(db->nb_flm_ft, sizeof(struct hw_db_inline_resource_db_flm_ft)); + + if (db->flm[i].ft == NULL) { + hw_db_inline_destroy(db); + return -1; + } + + db->flm[i].match_set = + calloc(db->nb_cat, sizeof(struct hw_db_inline_resource_db_flm_match_set)); + + if (db->flm[i].match_set == NULL) { + hw_db_inline_destroy(db); + return -1; + } + + db->flm[i].cfn_map = calloc(db->nb_cat * db->nb_flm_ft, + sizeof(struct hw_db_inline_resource_db_flm_cfn_map)); + + if (db->flm[i].cfn_map == NULL) { + hw_db_inline_destroy(db); + return -1; + } + } + db->nb_km_ft = ndev->be.cat.nb_flow_types; db->nb_km_rcp = ndev->be.km.nb_categories; db->km = calloc(db->nb_km_rcp, sizeof(struct hw_db_inline_resource_db_km_rcp)); @@ -222,6 +262,16 @@ void hw_db_inline_destroy(void *db_handle) free(db->cat); + if (db->flm) { + for (uint32_t i = 0; i < db->nb_flm_rcp; ++i) { + free(db->flm[i].ft); + free(db->flm[i].match_set); + free(db->flm[i].cfn_map); + } + + free(db->flm); + } + if (db->km) { for (uint32_t i = 0; i < db->nb_km_rcp; ++i) free(db->km[i].ft); @@ -268,6 +318,10 @@ void hw_db_inline_deref_idxs(struct flow_nic_dev *ndev, void *db_handle, struct *(struct hw_db_tpe_ext_idx *)&idxs[i]); break; + case HW_DB_IDX_TYPE_FLM_RCP: + hw_db_inline_flm_deref(ndev, db_handle, *(struct hw_db_flm_idx *)&idxs[i]); + break; + case HW_DB_IDX_TYPE_FLM_FT: hw_db_inline_flm_ft_deref(ndev, db_handle, *(struct hw_db_flm_ft *)&idxs[i]); @@ -324,6 +378,9 @@ const void *hw_db_inline_find_data(struct flow_nic_dev *ndev, void *db_handle, case HW_DB_IDX_TYPE_TPE_EXT: return &db->tpe_ext[idxs[i].ids].data; + case HW_DB_IDX_TYPE_FLM_RCP: + return &db->flm[idxs[i].id1].data; + case HW_DB_IDX_TYPE_FLM_FT: return NULL; /* FTs can't be easily looked up */ @@ -481,6 +538,20 @@ int hw_db_inline_setup_mbr_filter(struct flow_nic_dev *ndev, uint32_t cat_hw_id, return 0; } +static void hw_db_inline_setup_default_flm_rcp(struct flow_nic_dev *ndev, int flm_rcp) +{ + uint32_t flm_mask[10]; + memset(flm_mask, 0xff, sizeof(flm_mask)); + + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_PRESET_ALL, flm_rcp, 0x0); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_LOOKUP, flm_rcp, 1); + hw_mod_flm_rcp_set_mask(&ndev->be, HW_FLM_RCP_MASK, flm_rcp, flm_mask); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_KID, flm_rcp, flm_rcp + 2); + + hw_mod_flm_rcp_flush(&ndev->be, flm_rcp, 1); +} + + /******************************************************************************/ /* COT */ /******************************************************************************/ @@ -1268,10 +1339,17 @@ void hw_db_inline_km_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_d void hw_db_inline_km_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_km_idx idx) { (void)ndev; - (void)db_handle; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; if (idx.error) return; + + db->flm[idx.id1].ref -= 1; + + if (db->flm[idx.id1].ref <= 0) { + memset(&db->flm[idx.id1].data, 0x0, sizeof(struct hw_db_inline_km_rcp_data)); + db->flm[idx.id1].ref = 0; + } } /******************************************************************************/ @@ -1359,6 +1437,121 @@ void hw_db_inline_km_ft_deref(struct flow_nic_dev *ndev, void *db_handle, struct km_rcp->ft[cat_offset + idx.id1].ref = 0; } } + +/******************************************************************************/ +/* FLM RCP */ +/******************************************************************************/ + +static int hw_db_inline_flm_compare(const struct hw_db_inline_flm_rcp_data *data1, + const struct hw_db_inline_flm_rcp_data *data2) +{ + if (data1->qw0_dyn != data2->qw0_dyn || data1->qw0_ofs != data2->qw0_ofs || + data1->qw4_dyn != data2->qw4_dyn || data1->qw4_ofs != data2->qw4_ofs || + data1->sw8_dyn != data2->sw8_dyn || data1->sw8_ofs != data2->sw8_ofs || + data1->sw9_dyn != data2->sw9_dyn || data1->sw9_ofs != data2->sw9_ofs || + data1->outer_prot != data2->outer_prot || data1->inner_prot != data2->inner_prot) { + return 0; + } + + for (int i = 0; i < 10; ++i) + if (data1->mask[i] != data2->mask[i]) + return 0; + + return 1; +} + +struct hw_db_flm_idx hw_db_inline_flm_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_flm_rcp_data *data, int group) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + struct hw_db_flm_idx idx = { .raw = 0 }; + + idx.type = HW_DB_IDX_TYPE_FLM_RCP; + idx.id1 = group; + + if (group == 0) + return idx; + + if (db->flm[idx.id1].ref > 0) { + if (!hw_db_inline_flm_compare(data, &db->flm[idx.id1].data)) { + idx.error = 1; + return idx; + } + + hw_db_inline_flm_ref(ndev, db, idx); + return idx; + } + + db->flm[idx.id1].ref = 1; + memcpy(&db->flm[idx.id1].data, data, sizeof(struct hw_db_inline_flm_rcp_data)); + + { + uint32_t flm_mask[10] = { + data->mask[0], /* SW9 */ + data->mask[1], /* SW8 */ + data->mask[5], data->mask[4], data->mask[3], data->mask[2], /* QW4 */ + data->mask[9], data->mask[8], data->mask[7], data->mask[6], /* QW0 */ + }; + + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_PRESET_ALL, idx.id1, 0x0); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_LOOKUP, idx.id1, 1); + + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_QW0_DYN, idx.id1, data->qw0_dyn); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_QW0_OFS, idx.id1, data->qw0_ofs); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_QW0_SEL, idx.id1, 0); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_QW4_DYN, idx.id1, data->qw4_dyn); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_QW4_OFS, idx.id1, data->qw4_ofs); + + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_SW8_DYN, idx.id1, data->sw8_dyn); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_SW8_OFS, idx.id1, data->sw8_ofs); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_SW8_SEL, idx.id1, 0); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_SW9_DYN, idx.id1, data->sw9_dyn); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_SW9_OFS, idx.id1, data->sw9_ofs); + + hw_mod_flm_rcp_set_mask(&ndev->be, HW_FLM_RCP_MASK, idx.id1, flm_mask); + + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_KID, idx.id1, idx.id1 + 2); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_OPN, idx.id1, data->outer_prot ? 1 : 0); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_IPN, idx.id1, data->inner_prot ? 1 : 0); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_BYT_DYN, idx.id1, 0); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_BYT_OFS, idx.id1, -20); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_TXPLM, idx.id1, UINT32_MAX); + + hw_mod_flm_rcp_flush(&ndev->be, idx.id1, 1); + } + + return idx; +} + +void hw_db_inline_flm_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_flm_idx idx) +{ + (void)ndev; + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (!idx.error) + db->flm[idx.id1].ref += 1; +} + +void hw_db_inline_flm_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_flm_idx idx) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + if (idx.error) + return; + + if (idx.id1 > 0) { + db->flm[idx.id1].ref -= 1; + + if (db->flm[idx.id1].ref <= 0) { + memset(&db->flm[idx.id1].data, 0x0, + sizeof(struct hw_db_inline_flm_rcp_data)); + db->flm[idx.id1].ref = 0; + + hw_db_inline_setup_default_flm_rcp(ndev, idx.id1); + } + } +} + /******************************************************************************/ /* FLM FT */ /******************************************************************************/ diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h index a520ae1769..9820225ffa 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h @@ -138,6 +138,7 @@ enum hw_db_idx_type { HW_DB_IDX_TYPE_TPE, HW_DB_IDX_TYPE_TPE_EXT, + HW_DB_IDX_TYPE_FLM_RCP, HW_DB_IDX_TYPE_KM_RCP, HW_DB_IDX_TYPE_FLM_FT, HW_DB_IDX_TYPE_KM_FT, @@ -165,6 +166,22 @@ struct hw_db_inline_cat_data { uint8_t ip_prot_tunnel; }; +struct hw_db_inline_flm_rcp_data { + uint64_t qw0_dyn : 5; + uint64_t qw0_ofs : 8; + uint64_t qw4_dyn : 5; + uint64_t qw4_ofs : 8; + uint64_t sw8_dyn : 5; + uint64_t sw8_ofs : 8; + uint64_t sw9_dyn : 5; + uint64_t sw9_ofs : 8; + uint64_t outer_prot : 1; + uint64_t inner_prot : 1; + uint64_t padding : 10; + + uint32_t mask[10]; +}; + struct hw_db_inline_qsl_data { uint32_t discard : 1; uint32_t drop : 1; @@ -300,7 +317,10 @@ void hw_db_inline_km_ft_deref(struct flow_nic_dev *ndev, void *db_handle, struct /**/ +struct hw_db_flm_idx hw_db_inline_flm_add(struct flow_nic_dev *ndev, void *db_handle, + const struct hw_db_inline_flm_rcp_data *data, int group); void hw_db_inline_flm_ref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_flm_idx idx); +void hw_db_inline_flm_deref(struct flow_nic_dev *ndev, void *db_handle, struct hw_db_flm_idx idx); struct hw_db_flm_ft hw_db_inline_flm_ft_default(struct flow_nic_dev *ndev, void *db_handle, const struct hw_db_inline_flm_ft_data *data); diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c index 5ad2ceb4ca..719f5fcdec 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c @@ -101,6 +101,11 @@ static int flm_sdram_reset(struct flow_nic_dev *ndev, int enable) hw_mod_flm_control_set(&ndev->be, HW_FLM_CONTROL_ENABLE, 0x0); hw_mod_flm_control_flush(&ndev->be); + for (uint32_t i = 1; i < ndev->be.flm.nb_categories; ++i) + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_PRESET_ALL, i, 0x0); + + hw_mod_flm_rcp_flush(&ndev->be, 1, ndev->be.flm.nb_categories - 1); + /* Wait for FLM to enter Idle state */ for (uint32_t i = 0; i < 1000000; ++i) { uint32_t value = 0; @@ -2658,8 +2663,8 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n uint16_t forced_vlan_vid __rte_unused, uint16_t caller_id, struct rte_flow_error *error, uint32_t port_id, uint32_t num_dest_port, uint32_t num_queues, - uint32_t *packet_data, uint32_t *packet_mask __rte_unused, - struct flm_flow_key_def_s *key_def __rte_unused) + uint32_t *packet_data, uint32_t *packet_mask, + struct flm_flow_key_def_s *key_def) { struct flow_handle *fh = calloc(1, sizeof(struct flow_handle)); @@ -2692,6 +2697,31 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n * Flow for group 1..32 */ + /* Setup FLM RCP */ + struct hw_db_inline_flm_rcp_data flm_data = { + .qw0_dyn = key_def->qw0_dyn, + .qw0_ofs = key_def->qw0_ofs, + .qw4_dyn = key_def->qw4_dyn, + .qw4_ofs = key_def->qw4_ofs, + .sw8_dyn = key_def->sw8_dyn, + .sw8_ofs = key_def->sw8_ofs, + .sw9_dyn = key_def->sw9_dyn, + .sw9_ofs = key_def->sw9_ofs, + .outer_prot = key_def->outer_proto, + .inner_prot = key_def->inner_proto, + }; + memcpy(flm_data.mask, packet_mask, sizeof(uint32_t) * 10); + struct hw_db_flm_idx flm_idx = + hw_db_inline_flm_add(dev->ndev, dev->ndev->hw_db_handle, &flm_data, + attr->group); + fh->db_idxs[fh->db_idx_counter++] = flm_idx.raw; + + if (flm_idx.error) { + NT_LOG(ERR, FILTER, "Could not reference FLM RPC resource"); + flow_nic_set_error(ERR_MATCH_RESOURCE_EXHAUSTION, error); + goto error_out; + } + /* Setup Actions */ uint16_t flm_rpl_ext_ptr = 0; uint32_t flm_ft = 0; @@ -2704,7 +2734,7 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n } /* Program flow */ - convert_fh_to_fh_flm(fh, packet_data, 2, flm_ft, flm_rpl_ext_ptr, + convert_fh_to_fh_flm(fh, packet_data, flm_idx.id1 + 2, flm_ft, flm_rpl_ext_ptr, flm_scrub, attr->priority & 0x3); flm_flow_programming(fh, NT_FLM_OP_LEARN); @@ -3276,6 +3306,12 @@ int done_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) flow_nic_free_resource(ndev, RES_KM_FLOW_TYPE, 0); flow_nic_free_resource(ndev, RES_KM_CATEGORY, 0); + hw_mod_flm_rcp_set(&ndev->be, HW_FLM_RCP_PRESET_ALL, 0, 0); + hw_mod_flm_rcp_flush(&ndev->be, 0, 1); + flow_nic_free_resource(ndev, RES_FLM_FLOW_TYPE, 0); + flow_nic_free_resource(ndev, RES_FLM_FLOW_TYPE, 1); + flow_nic_free_resource(ndev, RES_FLM_RCP, 0); + flow_group_handle_destroy(&ndev->group_handle); ntnic_id_table_destroy(ndev->id_table_handle); -- 2.45.0