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 90FE745BA3; Tue, 22 Oct 2024 18:56:52 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1D46040A8A; Tue, 22 Oct 2024 18:56:18 +0200 (CEST) Received: from egress-ip11b.ess.de.barracuda.com (egress-ip11b.ess.de.barracuda.com [18.185.115.215]) by mails.dpdk.org (Postfix) with ESMTP id 8F49A40272 for ; Tue, 22 Oct 2024 18:56:10 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2111.outbound.protection.outlook.com [104.47.18.111]) by mx-outbound19-119.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 22 Oct 2024 16:56:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nEiQXeCmSx2Y+JGrl/nUqc/ZTJa7PKbLVwBM+puZKYjSEDVrsF6lFIZP5PQfrI0jdTFSQa2ss+5jqTr3IRVahPFG5vP9RMerxEKFOCh9QKIbER/Wvwog5tnSw0n5vmxPLt28qVfzWjdw6CR8xPQkNKygFsKUz6bAww8+oWwnPmIatnrYwP/2/vL7jjrFNRa5M2dzlVmBBttq+CDDd9DLFwKaHxisHLqitLkZGg1Bp1569VLSAocpIpj+3ggE7EIbCdMJSnZ2TQxz0hphaf2WQ29dbBjq3MsnrSC+qPkBYz3fwd7FuubVcx/FFDyCMJjUUqesTv01m6rp2NfKkBPM9Q== 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=IhrZ4zgA7X23xhXCFfXW0YGqvGjQN+UQGRVVjincnOQ=; b=qSDXdoXC77qI+mwNqrLf+ntHqEVxO3kgg47YaB8hi5jJKVYd692LUi3ZjdwSuNi6z2bbY7H5TQZ2ea+I7Tgehe1KIjP+Mh4ByeMLea7YEjwHUtbsvnjY+veurXyNVfGYzWp0t3/aEpewZb7Qi8gaL4KliGY90QfuVcZtOomiMwdidCNEvaRmAprIvM6i020P7Ho82cjPW+hGAi7BfH11HU14eqWo5U749KnaSf0/oY/ChdSfz/abibemTSLxBVs+PWbA4ZTVISyDse7iFvuRurW4NEcCQ2whaW0WSDdYm7J2xr6khM7WQJAvaVN+cGiE98yyoQHlY1ubgi/udqUH/Q== 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=IhrZ4zgA7X23xhXCFfXW0YGqvGjQN+UQGRVVjincnOQ=; b=TizsWttzGu5rvn52Vq5DIKvB6fL0X5iP8X/UdAnHdKz+oTR0D301iHAvx8dd6U+gu4XST+RMjNGOiuEkJ5eu6aHLudbB8sp/D/UgRk24xRct7Gsy6ORAtvrp96/vb8wYiR7ztlATkvabQ4Pj/kMxksya7Jh+w4ErKiLwKLNGS7I= Received: from DB9PR06CA0002.eurprd06.prod.outlook.com (2603:10a6:10:1db::7) by AS8P190MB1174.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2ea::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16; Tue, 22 Oct 2024 16:56:04 +0000 Received: from DU2PEPF0001E9C2.eurprd03.prod.outlook.com (2603:10a6:10:1db:cafe::81) by DB9PR06CA0002.outlook.office365.com (2603:10a6:10:1db::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16 via Frontend Transport; Tue, 22 Oct 2024 16:56:04 +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 DU2PEPF0001E9C2.mail.protection.outlook.com (10.167.8.71) with Microsoft SMTP Server id 15.20.8093.14 via Frontend Transport; Tue, 22 Oct 2024 16:56:04 +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 Subject: [PATCH v2 07/73] net/ntnic: add NT flow profile management implementation Date: Tue, 22 Oct 2024 18:54:24 +0200 Message-ID: <20241022165541.3186140-8-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241022165541.3186140-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241022165541.3186140-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF0001E9C2:EE_|AS8P190MB1174:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 0146ca04-b35c-4a57-5d09-08dcf2ba6a6c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?cFdFZqemWafzvPv0KB15JEDjao1wit5Vlxot03QwodAaf60/qYoWuym0EeD2?= =?us-ascii?Q?6NKEEwkeBYbfACiwU0i9VMcZQXKlFtMLldyJug+4LlRRKFj0m5/9MOhIdmQj?= =?us-ascii?Q?zJGD03gwM2C6k+cxRIBqk3Vql5+aRWmsEYUOiUgYE1Yhg0jwsCQPoa+oqkbf?= =?us-ascii?Q?eQooX1D8Bfrum3dcD46wq2oM+vVlpquZtMlfLhYPG6klb8mHydJOYu5ZVDbh?= =?us-ascii?Q?QelHKypvugo1BcXTlx4t2bQrdNH2SgqYJNMcxPsgJ7m8LK9dO2ezvzuM6DEm?= =?us-ascii?Q?lPbwQQxu0k+FJw438GVtrfLB0CzlvO6Ugt/BjKI8EFUnyGiR9vEZEscfOsPC?= =?us-ascii?Q?1U9qcRsX+4eRlhYdAiYrOfoeQhnqxnqujVsWT3o2BrmuBoLqg84YR5OpHQAp?= =?us-ascii?Q?NqzC5Fdj7tXXkp58wxYMXhbKctOa7CyFKekf90m/ajJPLg8ZAdOHGqeW9/RV?= =?us-ascii?Q?BFnxFk0wRJbVvEG/pz/CBMRWgU5iPjMwSucSjIOGTZH+kUKbsKVVdCZHo4ho?= =?us-ascii?Q?pd9sttitw9yts3j6dskIrhwffdSpgv2xYWHNIH9BOI/oaYxFKfOkD1u76ZpY?= =?us-ascii?Q?Ye1jK+FGHKbAkb8Tgsz+blEVOQp4mJ6exBtD8I2aPqW7XT5MO2tgDE4mqvOm?= =?us-ascii?Q?bom4b3ZCWaDgwYPbIQIAOS9BsTuRhnNCxpaU5wVC2sgTjBkLNdgOkz9z2IAM?= =?us-ascii?Q?RUUkBOOdxjpnFTp5kiWQiAKLHeQJ2CsIbTYT2N7HGGoYhL0K96USLDiWD6uH?= =?us-ascii?Q?7apw8/5lzcMkQlQDvW69uZbglwH5bqOPoJs5Dy+D6iPd2k5h8HZWABasUgSO?= =?us-ascii?Q?rVIxaBK0PHXM1XBlFjyfrSnbK4DZofFngA11C3bYXQpZM/pEpSd3/FOnB6DV?= =?us-ascii?Q?3bEo1PFAu+eKwyfl5Z0q7SGFYBJ9kPHxjO7+Nc+2J83J5bniN5mVJFCfYUvh?= =?us-ascii?Q?Xgs4w1f/0ExGn3YVJn0oHuXgvvgZVhU9gQvB0lc3i5fXOZZNMcOCpajVsWd9?= =?us-ascii?Q?A1saBdzfxh5eirUta3q1wCUqI1ON5SGzp6wGdTafjmrOraJTS5qnzAsJCgRY?= =?us-ascii?Q?5lOafmhFToFdgpRm0niGEU8O7NBFahLqt3vNkef6U1KarL3yeNA5mRW8mpms?= =?us-ascii?Q?JCYrdfEqhgSstq0RYuL5Vw/6kB9K29GDhs8fDOrXxZPX1AuUNAdeHt+5WVBd?= =?us-ascii?Q?pnSoMbUwsJDuJHdNIzS5Aky+3kP8hhJVoDb1SDzv1h3NW+3jTUbTDq+Ijg+h?= =?us-ascii?Q?RSYQ/KNrJI/PG9Eo0I7DVNtMs+wZ9T8cusxP1RsHvSp2dM7HfN5lLMGBXwlr?= =?us-ascii?Q?tCw5HYpN/P86+1d7+2U1gAXV5uxzf9hq/AYJXKB21UAQD3zAK9McxBHPYlGb?= =?us-ascii?Q?nbkKHW7G05GxpHfXUMPbkXTuMtZPnV2y4CGOXipvPjOZuHKDZg=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)(1800799024)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: JxKo6a0eujiiYE8KWtcLPVn4pXPkrM0jOxO656TSsmvX4hdNYAktkoVd4+8FPxhe7RWpeVsutoyOk8pV/BTAJ0Xs8QlPZhl2Fkkj1zlxej96uGCEneU2rRf26I821Mk/UmmFBk6+XgJDLnkjdfAPpSSUOHIqHgjbf52x8UHJ+uqyeFtZ34cmNCNq7oIxQWyYiOX7tZejV/JOxyDEey2wR0cnuzq2AqhY6tKOJFXgxDaTVF0LEGGQIoyfAXn8Wf25LwnlCdWvSImjIF+UVJOlklOH5r9SPdp02oA0vbl0QsGnd0hX0lEKcztPzvBTL4lUm3KzEce6NdxYgvSi36QvRw22d2Zd3oa5TrpjDeQlR/jc8nkEE5nnTIaVaeKZ2BylV263nosai1LlVfYuw9DbbdkH/23e0whDASmlf9P7WLJIURVJAIF1KG9d4NsnXAaoBxwesrGOEa9cSDuuikapg8YZbmVWM3OtA6oXgQmNG3V3wM+nrGgBlkQcGGksR8c3SAwqLWsVX5r0r15SpwH2GtGxJFVNmIqR33a7cPfTPIp2Rdy5qaiag3MsEz/Xl9NZrgVxRjzfOlz4reycsC+64p+wwqurf3q9QIvsXdeaSEgXkCH/RKSP6STHu6UwX7qBKZG5fDTIj8vFet6gTRtYtiZW6xMBQnqMsy7JAD3+3mw= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 16:56:04.0436 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0146ca04-b35c-4a57-5d09-08dcf2ba6a6c 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: DU2PEPF0001E9C2.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P190MB1174 X-BESS-ID: 1729616167-304983-12655-14380-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.18.111 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoaGxqYmQGYGUNTQyNjSPMnAzN TELMXA0tzSzMzAIiUl0dI42dI4xdQ4Uak2FgA7bYCzQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259902 [from cloudscan12-62.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 Implements functions required for (re)set NT flow dev Signed-off-by: Serhii Iliushyk --- drivers/net/ntnic/include/flow_api.h | 4 ++ drivers/net/ntnic/include/flow_api_engine.h | 10 ++++ drivers/net/ntnic/meson.build | 4 ++ drivers/net/ntnic/nthw/flow_api/flow_group.c | 55 +++++++++++++++++ .../net/ntnic/nthw/flow_api/flow_id_table.c | 52 ++++++++++++++++ .../net/ntnic/nthw/flow_api/flow_id_table.h | 19 ++++++ .../profile_inline/flow_api_hw_db_inline.c | 59 +++++++++++++++++++ .../profile_inline/flow_api_hw_db_inline.h | 23 ++++++++ .../profile_inline/flow_api_profile_inline.c | 52 ++++++++++++++++ 9 files changed, 278 insertions(+) create mode 100644 drivers/net/ntnic/nthw/flow_api/flow_group.c create mode 100644 drivers/net/ntnic/nthw/flow_api/flow_id_table.c create mode 100644 drivers/net/ntnic/nthw/flow_api/flow_id_table.h create mode 100644 drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c create mode 100644 drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h diff --git a/drivers/net/ntnic/include/flow_api.h b/drivers/net/ntnic/include/flow_api.h index 790b2f6b03..748da89262 100644 --- a/drivers/net/ntnic/include/flow_api.h +++ b/drivers/net/ntnic/include/flow_api.h @@ -61,6 +61,10 @@ struct flow_nic_dev { void *km_res_handle; void *kcc_res_handle; + void *group_handle; + void *hw_db_handle; + void *id_table_handle; + uint32_t flow_unique_id_counter; /* linked list of all flows created on this NIC */ struct flow_handle *flow_base; diff --git a/drivers/net/ntnic/include/flow_api_engine.h b/drivers/net/ntnic/include/flow_api_engine.h index 52ff3cb865..2497c31a08 100644 --- a/drivers/net/ntnic/include/flow_api_engine.h +++ b/drivers/net/ntnic/include/flow_api_engine.h @@ -6,6 +6,8 @@ #ifndef _FLOW_API_ENGINE_H_ #define _FLOW_API_ENGINE_H_ +#include + /* * Resource management */ @@ -46,6 +48,9 @@ enum res_type_e { */ #define MAX_OUTPUT_DEST (128) +#define MAX_CPY_WRITERS_SUPPORTED 8 + + struct flow_handle { struct flow_eth_dev *dev; struct flow_handle *next; @@ -55,4 +60,9 @@ void km_free_ndev_resource_management(void **handle); void kcc_free_ndev_resource_management(void **handle); +/* + * Group management + */ +int flow_group_handle_create(void **handle, uint32_t group_count); +int flow_group_handle_destroy(void **handle); #endif /* _FLOW_API_ENGINE_H_ */ diff --git a/drivers/net/ntnic/meson.build b/drivers/net/ntnic/meson.build index f5605e81cb..f7292144ac 100644 --- a/drivers/net/ntnic/meson.build +++ b/drivers/net/ntnic/meson.build @@ -18,6 +18,7 @@ includes = [ include_directories('nthw/supported'), include_directories('nthw/model'), include_directories('nthw/flow_filter'), + include_directories('nthw/flow_api'), include_directories('nim/'), ] @@ -47,7 +48,10 @@ sources = files( 'nthw/core/nthw_sdc.c', 'nthw/core/nthw_si5340.c', 'nthw/flow_api/flow_api.c', + 'nthw/flow_api/flow_group.c', + 'nthw/flow_api/flow_id_table.c', 'nthw/flow_api/profile_inline/flow_api_profile_inline.c', + 'nthw/flow_api/profile_inline/flow_api_hw_db_inline.c', 'nthw/flow_api/flow_backend/flow_backend.c', 'nthw/flow_api/flow_filter.c', 'nthw/flow_api/flow_kcc.c', diff --git a/drivers/net/ntnic/nthw/flow_api/flow_group.c b/drivers/net/ntnic/nthw/flow_api/flow_group.c new file mode 100644 index 0000000000..a7371f3aad --- /dev/null +++ b/drivers/net/ntnic/nthw/flow_api/flow_group.c @@ -0,0 +1,55 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#include +#include + +#include "flow_api_engine.h" + +#define OWNER_ID_COUNT 256 +#define PORT_COUNT 8 + +struct group_lookup_entry_s { + uint64_t ref_counter; + uint32_t *reverse_lookup; +}; + +struct group_handle_s { + uint32_t group_count; + + uint32_t *translation_table; + + struct group_lookup_entry_s *lookup_entries; +}; + +int flow_group_handle_create(void **handle, uint32_t group_count) +{ + struct group_handle_s *group_handle; + + *handle = calloc(1, sizeof(struct group_handle_s)); + group_handle = *handle; + + group_handle->group_count = group_count; + group_handle->translation_table = + calloc((uint32_t)(group_count * PORT_COUNT * OWNER_ID_COUNT), sizeof(uint32_t)); + group_handle->lookup_entries = calloc(group_count, sizeof(struct group_lookup_entry_s)); + + return *handle != NULL ? 0 : -1; +} + +int flow_group_handle_destroy(void **handle) +{ + if (*handle) { + struct group_handle_s *group_handle = (struct group_handle_s *)*handle; + + free(group_handle->translation_table); + free(group_handle->lookup_entries); + + free(*handle); + *handle = NULL; + } + + return 0; +} diff --git a/drivers/net/ntnic/nthw/flow_api/flow_id_table.c b/drivers/net/ntnic/nthw/flow_api/flow_id_table.c new file mode 100644 index 0000000000..9b46848e59 --- /dev/null +++ b/drivers/net/ntnic/nthw/flow_api/flow_id_table.c @@ -0,0 +1,52 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2024 Napatech A/S + */ + +#include +#include +#include + +#include "flow_id_table.h" + +#define NTNIC_ARRAY_BITS 14 +#define NTNIC_ARRAY_SIZE (1 << NTNIC_ARRAY_BITS) + +struct ntnic_id_table_element { + union flm_handles handle; + uint8_t caller_id; + uint8_t type; +}; + +struct ntnic_id_table_data { + struct ntnic_id_table_element *arrays[NTNIC_ARRAY_SIZE]; + pthread_mutex_t mtx; + + uint32_t next_id; + + uint32_t free_head; + uint32_t free_tail; + uint32_t free_count; +}; + +void *ntnic_id_table_create(void) +{ + struct ntnic_id_table_data *handle = calloc(1, sizeof(struct ntnic_id_table_data)); + + pthread_mutex_init(&handle->mtx, NULL); + handle->next_id = 1; + + return handle; +} + +void ntnic_id_table_destroy(void *id_table) +{ + struct ntnic_id_table_data *handle = id_table; + + for (uint32_t i = 0; i < NTNIC_ARRAY_SIZE; ++i) + free(handle->arrays[i]); + + pthread_mutex_destroy(&handle->mtx); + + free(id_table); +} diff --git a/drivers/net/ntnic/nthw/flow_api/flow_id_table.h b/drivers/net/ntnic/nthw/flow_api/flow_id_table.h new file mode 100644 index 0000000000..13455f1165 --- /dev/null +++ b/drivers/net/ntnic/nthw/flow_api/flow_id_table.h @@ -0,0 +1,19 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2024 Napatech A/S + */ + +#ifndef _FLOW_ID_TABLE_H_ +#define _FLOW_ID_TABLE_H_ + +#include + +union flm_handles { + uint64_t idx; + void *p; +}; + +void *ntnic_id_table_create(void); +void ntnic_id_table_destroy(void *id_table); + +#endif /* FLOW_ID_TABLE_H_ */ 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 new file mode 100644 index 0000000000..5fda11183c --- /dev/null +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c @@ -0,0 +1,59 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + + +#include "flow_api_hw_db_inline.h" + +/******************************************************************************/ +/* Handle */ +/******************************************************************************/ + +struct hw_db_inline_resource_db { + /* Actions */ + struct hw_db_inline_resource_db_cot { + struct hw_db_inline_cot_data data; + int ref; + } *cot; + + uint32_t nb_cot; + + /* Hardware */ + + struct hw_db_inline_resource_db_cfn { + uint64_t priority; + int cfn_hw; + int ref; + } *cfn; +}; + +int hw_db_inline_create(struct flow_nic_dev *ndev, void **db_handle) +{ + /* Note: calloc is required for functionality in the hw_db_inline_destroy() */ + struct hw_db_inline_resource_db *db = calloc(1, sizeof(struct hw_db_inline_resource_db)); + + if (db == NULL) + return -1; + + db->nb_cot = ndev->be.cat.nb_cat_funcs; + db->cot = calloc(db->nb_cot, sizeof(struct hw_db_inline_resource_db_cot)); + + if (db->cot == NULL) { + hw_db_inline_destroy(db); + return -1; + } + + *db_handle = db; + return 0; +} + +void hw_db_inline_destroy(void *db_handle) +{ + struct hw_db_inline_resource_db *db = (struct hw_db_inline_resource_db *)db_handle; + + free(db->cot); + + free(db->cfn); + + free(db); +} 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 new file mode 100644 index 0000000000..23caf73cf3 --- /dev/null +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#ifndef _FLOW_API_HW_DB_INLINE_H_ +#define _FLOW_API_HW_DB_INLINE_H_ + +#include + +#include "flow_api.h" + +struct hw_db_inline_cot_data { + uint32_t matcher_color_contrib : 4; + uint32_t frag_rcp : 4; + uint32_t padding : 24; +}; + +/**/ + +int hw_db_inline_create(struct flow_nic_dev *ndev, void **db_handle); +void hw_db_inline_destroy(void *db_handle); + +#endif /* _FLOW_API_HW_DB_INLINE_H_ */ 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 c9e4008b7e..986196b408 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 @@ -4,6 +4,9 @@ */ #include "ntlog.h" +#include "flow_api_engine.h" +#include "flow_api_hw_db_inline.h" +#include "flow_id_table.h" #include "flow_api_profile_inline.h" #include "ntnic_mod_reg.h" @@ -14,11 +17,60 @@ int initialize_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) { + if (!ndev->flow_mgnt_prepared) { + /* Check static arrays are big enough */ + assert(ndev->be.tpe.nb_cpy_writers <= MAX_CPY_WRITERS_SUPPORTED); + + ndev->id_table_handle = ntnic_id_table_create(); + + if (ndev->id_table_handle == NULL) + goto err_exit0; + + if (flow_group_handle_create(&ndev->group_handle, ndev->be.flm.nb_categories)) + goto err_exit0; + + if (hw_db_inline_create(ndev, &ndev->hw_db_handle)) + goto err_exit0; + + ndev->flow_mgnt_prepared = 1; + } + + return 0; + +err_exit0: + done_flow_management_of_ndev_profile_inline(ndev); return -1; } int done_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev) { +#ifdef FLOW_DEBUG + ndev->be.iface->set_debug_mode(ndev->be.be_dev, FLOW_BACKEND_DEBUG_MODE_WRITE); +#endif + + if (ndev->flow_mgnt_prepared) { + flow_nic_free_resource(ndev, RES_KM_FLOW_TYPE, 0); + flow_nic_free_resource(ndev, RES_KM_CATEGORY, 0); + + flow_group_handle_destroy(&ndev->group_handle); + ntnic_id_table_destroy(ndev->id_table_handle); + + flow_nic_free_resource(ndev, RES_CAT_CFN, 0); + + hw_mod_tpe_reset(&ndev->be); + flow_nic_free_resource(ndev, RES_TPE_RCP, 0); + flow_nic_free_resource(ndev, RES_TPE_EXT, 0); + flow_nic_free_resource(ndev, RES_TPE_RPL, 0); + + hw_db_inline_destroy(ndev->hw_db_handle); + +#ifdef FLOW_DEBUG + ndev->be.iface->set_debug_mode(ndev->be.be_dev, FLOW_BACKEND_DEBUG_MODE_NONE); +#endif + + ndev->flow_mgnt_prepared = 0; + } + return 0; } -- 2.45.0