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 87F8C45BC0; Tue, 29 Oct 2024 17:47:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5904442F95; Tue, 29 Oct 2024 17:44:20 +0100 (CET) Received: from egress-ip42b.ess.de.barracuda.com (egress-ip42b.ess.de.barracuda.com [18.185.115.246]) by mails.dpdk.org (Postfix) with ESMTP id 508D942ECF for ; Tue, 29 Oct 2024 17:43:32 +0100 (CET) Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02lp2109.outbound.protection.outlook.com [104.47.11.109]) by mx-outbound17-86.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 16:43:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=T0XCRSWatsmNBJMHUvyzS2dknp67c2ybT1ZNptcr/Hie0oRXC1jAtOr/bc3NCpjUTSO9v3SHw6CCQIsJfuSupWhlMQogLBH5757FwLSzO/mv5HZyDPfFpUxMr13fACvT1GvhqDlHrAChzGYNbdG08SPKXgqOpb3vA2QAd8Ge21au5MeciXkevPKP5aQ6nuiuSxoMO3EOcYpA9Epn/OyNKXS1epCBBWdps/4I780znbRn140dneu07o/2A2DRp/ByRScJ4fpbJpPsDnEPctkLXEtvr/xWvegf2WAGpJhhyGByd4wvtjyoRsufw4JgaOMQVh8JaOnMhtW6Bi94ShrnmQ== 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=yc4GcvUnNlo/3FkHVCCKTfxipegYTuPVfB7PWxp6zKY=; b=qEc0lWy/Zb+4E57RJzsE9+Tzza3E7EWjjgp+az2PrLgTUy5udidcut2ezakGgs2G2xaB+inMIZ48UHMeJar8QHFTpiXpjhHpUDKa+GvkJJYV9ygxWnoPf3itGg0QbJdRpsEVnCEbhAk1LHwtw7hf66yr23XHu+d39V/1euwvtNqLSZ8ZttUvADkciA67awcnEnrURb+n3r/qdOtWuqCkBH+/ZyBZcLVXxDr4bmoG2Dh9B4sF1oyiN62TrF2WWrBY4bYqHp1oIyby77RGE4BNYPzebItIamEMByeu+Ei0ZmKGM99oWIosHu3QYEPOkXgKtlbz17LDmeDPCb6ttkBX4Q== 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=yc4GcvUnNlo/3FkHVCCKTfxipegYTuPVfB7PWxp6zKY=; b=JRH6loWtJegoai+2PQFEE4Cikxjf9he3lFXoYbEyh8RVC0UwfDF+Lmr7jOsVqtFc/Nd9BgUxRmrsrFq5cz/qdFOzpNNJY9mopT71hix4YN3L3xZAfz/GOoc2QiiVk7L0sn9ji1mPM/WRsio1m+XqHrs90hmaIR38W5nAr4JrvKI= Received: from DUZPR01CA0203.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::16) by AM9P190MB1188.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:261::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Tue, 29 Oct 2024 16:43:26 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::5c) by DUZPR01CA0203.outlook.office365.com (2603:10a6:10:4b6::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.29 via Frontend Transport; Tue, 29 Oct 2024 16:43:26 +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 DU2PEPF00028D06.mail.protection.outlook.com (10.167.242.166) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 16:43:26 +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, stephen@networkplumber.org, Danylo Vodopianov Subject: [PATCH v4 34/86] net/ntnic: add flm rcp module Date: Tue, 29 Oct 2024 17:41:38 +0100 Message-ID: <20241029164243.1648775-35-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241029164243.1648775-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241029164243.1648775-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|AM9P190MB1188:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 709a050b-e567-4230-6024-08dcf838cfca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?3Wcea3+jC02BlIsl5gTYhGuPKxxxF5TynLqSYlPTi/TS62Aimd3ePjjkWowJ?= =?us-ascii?Q?/miwFVCoVPoM/H1kqgvJhSCSqN3NFJjhujM0bFzn/gEIa/oxHlbYMiESidJ+?= =?us-ascii?Q?OP/5i7LKqkE9OYVFaDCQvvrJB7qeOCd47Ufl2goc6EbZgHQf1JcVjYIh7WcE?= =?us-ascii?Q?HUvlP4T+W+8pU0uoRyi1QNYmS4kCqj0habr0NRbjpEBQ48HBbMNuBqQOyUjh?= =?us-ascii?Q?9KoWXZe3QB/hyiz/7vuZ9K94CgM6UqfQZLwKpOLLNEEUu1AnNIvOdvbGctPm?= =?us-ascii?Q?595a82awJDwj1a8KSkxETdU5UJVK/9ZduMOvTuHnZJPx0dNpmRbSDKIr4XH9?= =?us-ascii?Q?XRyZU+gYIv+0MdqkMSMZ1pc8d6xsLmsaGxQS3nnG6MCcG7l6D9rk2krzrLox?= =?us-ascii?Q?qUNXn6OXdcfFBjHJF/cUrwsYHs3ZPIK9qdWZIsa8E+toxP9xyhRjOi8fhgDU?= =?us-ascii?Q?6d2BuVVHXiaZA9xKFGvFHmL7cWu+eKAAqzACMGhsezEn7EPmKR0n+zDH1FMS?= =?us-ascii?Q?oc5wOkumZgmaCKqYdAuPQMyKdiU4JlqU8x3Cbuv0xJmIIZj28X0qA9orRYJy?= =?us-ascii?Q?XuUzYqFvZuxRxObw2pKzijEJ1al2K2fvkdR7n0JdJVgHF1YfB6QYYUthtBLB?= =?us-ascii?Q?HyROjxWtpoJZdvQNfMD7UctIkXPFS2C1TE1UDdcAtSPClk3gdnRHAV64/L6u?= =?us-ascii?Q?qBiYePi7IJ5rH+VHTb4ECse0koJikYMh3iZJ2UaU7Xq0Pf5kxBD/FPM7IA79?= =?us-ascii?Q?AUPdKetr6+GfaWvwabyOaaP8kFCukOV4xkjubu7rtDlzbi0z/nwZP17iktTk?= =?us-ascii?Q?6ZUKKIvmlfVDI3WSpB8N3WBsQpYSivrdRg8lPPjC6JvzLAFur+1BPHd5rCvi?= =?us-ascii?Q?Yl9fVUHebkrCBfDoglXdd/1IiOJ4Kko0JTXysjt3wke58OFzYpfyGYevW+OL?= =?us-ascii?Q?Gzu4gP0cA9Ulhad5YjUnQBUfGB9HVPmNGu60mTV8se98feIdiER7fzxqJ19Q?= =?us-ascii?Q?oK1Wx7F6dT/9MeeCk0lyjs38ULg6b5HcujTKApf3Nit0wVmyuxtll9swVWh8?= =?us-ascii?Q?0GTvimWMGj6rH8L+stjwzNns4Fd/lHkMOKbHuuicPfpbi6KI3cVzAMVwJxr0?= =?us-ascii?Q?Dnk69aB9Ay6emyagjs404FmXwJIMo35gTgp7SUkM/DIJ2uXZmoOG1beCzWJW?= =?us-ascii?Q?/OduQf2klfIT7mMzgKxkpszXMoBPluUVPRKKF3s6xSj4dymXOJ3HBGGdbYWO?= =?us-ascii?Q?DT7A3MzjDyMBIBnUNL38Sa9dpAHfZB4rzjSsFrZumidCr0426NhTCZYe9h5m?= =?us-ascii?Q?cRpGATjGWZsKPM48ukYkN4qDo5/VbbkFpERfrRvm5YTxrsMB67fjOnPE/pjt?= =?us-ascii?Q?zGhmmTt3xoHxjzlpdnmEueiS0lWdupG40ZtRlfnOxqRHoyzMFw=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)(376014)(36860700013)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: HdcW5Lhys8H/QYwMiGBaAp0MDi6a7Bj4iZqbr9jd7rx5jVH7LbU1mgv64Pp1KF97IrjE48eE3zeUYmXU6gaELx3d9KC41m9z8oQlN3yBI5/ecpADC3iV3KCNEukA+JzsE/wAqkHjKmzaQrbIQM+RC3vPT7Z3NefMlQ2SfTxSZAVFivp0uZWbefmHs4vMz9947sCRp8TDhgk9F9smjEhsTPOW97UXnwt6kGKSKRVd7fQn8SQ097MkjE6TfUKVaKn17BY74vKt7IYxOrvhOJdV2PcuXTrD8ATva3YmngtKCazc1WfQ/dfhK9vqCjMdfdm6OzRsRZImXLll2ZI6ua6zPCXFHgtANlVDq5hFEJP7gTm7a8IS64y6K/8iF8VzZ9gdqWjGgIKlxi8T4DPPtvH2d8/DpO/zTLTncQM2C380QY3wc+zhNUUq2xSJI44UVEbxULIm7AHtpmy33iU6ZUbhxtBh1/+ctIksTMcsPK4P1JXo7HT4cg6VchaiIaZLVI71vhtHjEmV1bURMAkH0z3SQluywd+rDcsi5zhogya5LZb/gkFkJVjYYiztnqYLynqm6tX98vMCR8c9tYEj3DFDZsQqtv+DWQCH8oyIRma2U+ry8By41Fv5Z1lqWUghlr3adg0QgZQV8lMZk2Py/qwQTUHKtzVWH1pU/vq8heWKuww= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:26.4802 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 709a050b-e567-4230-6024-08dcf838cfca 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: DU2PEPF00028D06.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9P190MB1188 X-BESS-ID: 1730220208-304438-12707-30038-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.109 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYWFiZmQGYGUNTMwDLFKNHUIt HY1DjJPNEw0QzISk5KMjI0tgQyLZVqYwFRG8SUQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260063 [from cloudscan15-223.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 85adcbb2d9..94635d7aaf 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; @@ -2657,8 +2662,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)); @@ -2691,6 +2696,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; @@ -2703,7 +2733,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); @@ -3275,6 +3305,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