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 BDDDF45B96; Mon, 21 Oct 2024 23:06:17 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4395540A67; Mon, 21 Oct 2024 23:05:48 +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 5AACE40615 for ; Mon, 21 Oct 2024 23:05:39 +0200 (CEST) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03lp2169.outbound.protection.outlook.com [104.47.51.169]) by mx-outbound8-87.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 21 Oct 2024 21:05:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HHmXaXCUIR81oeMyy9+eWxgj4UNvGBDjYQZpbvHUEpGMdK4f0493JmVLHCbKB5gxIoBhhsxhGNNBwNwjveBFa9Z78zF3IxFqcYp8sKJVnQKrN01YO/zZzWSfUu4gyUhyeoUkZdGS9wCZlpPx6pR3DJf4EhsqER5iiywj5EtsOvSF+N629IjSFZr8wrhEt6IjOHfcmriceyaHYQZH0Ez9eM7qIGemnrZasxjtlaveARPiDotp+ALa6SvKoIKuXHOLj7EEhqOWr9LIYUmj2pf7wZtFxNbrvTcreSjiZhta8YxKHhML/bCkagnqtpMExcM3deo2Sl6doP7FPv7v2T3fCw== 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=ADIYFKFuwWKx/cKZ63GVObjXHUPiStkFgUfUlcNz3xGEnX98vsSYDoT7j39zzFkWtZ3qOmcydxtqK5o3YYxHKoyvdYBoPZkEgFi2wL+IOspwF7EyzW8GcPnL408SriocvnrbgsVLRCU4u2Mt9qMZZLUkADFve4P8ic4Zf3cuiByU19aSpI08f89npNcvGOsjBluwgxJ+0ZIKr68UnUKU39R8o9rduNJerHYqwVVr3nUneHj5HpHeg0V1utveMDhjr7mh+koxyWgUVDNHteMIKqA6kWlbHX+rNn4T3ba86Iy7IqUcTiBz00yswvMKNqmgjws+EMEFvpWPth4cL7n20g== 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=HpN7GKn5/BRh4oJxALtdqJDK4hjsicSia/RqIpFimhQnflN50zzNUGrCIs3jJ4jQGUak2k7dd9UKxsmx3JJjKYCALuQV18Ul5bYvUpRnVWCbjP4SYIPMMws0N7h9MPfaKkSxjLtryJRuJFxoZunmQ26a4/A1LITyXQS7Wj8Zd9s= Received: from AS9PR04CA0133.eurprd04.prod.outlook.com (2603:10a6:20b:48a::6) by AS8P190MB1207.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2e2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Mon, 21 Oct 2024 21:05:36 +0000 Received: from AMS0EPF000001A8.eurprd05.prod.outlook.com (2603:10a6:20b:48a:cafe::84) by AS9PR04CA0133.outlook.office365.com (2603:10a6:20b:48a::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28 via Frontend Transport; Mon, 21 Oct 2024 21:05:36 +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 AMS0EPF000001A8.mail.protection.outlook.com (10.167.16.148) with Microsoft SMTP Server id 15.20.8093.14 via Frontend Transport; Mon, 21 Oct 2024 21:05:36 +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 Subject: [PATCH v1 07/73] net/ntnic: add NT flow profile management implementation Date: Mon, 21 Oct 2024 23:04:09 +0200 Message-ID: <20241021210527.2075431-8-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241021210527.2075431-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF000001A8:EE_|AS8P190MB1207:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 79d06618-1dd8-4c9d-60fb-08dcf2141c03 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?6YKsICsvde/U+/6+xyJY7qPiQ/+LOnrhsEYDeVceyvVA3gzbqKibd7fhSVsf?= =?us-ascii?Q?0WiPzkAZ3Pi4tFRt0oiW502uLFTjBi0QyPWBW0dauLz4mIXRoT1i3HFAnwZ/?= =?us-ascii?Q?fp18NGHlPTwpav3jzo5NeJ3/EseZVxokRuhL/kuxJ8tUchEAWAGgEaiiUHAA?= =?us-ascii?Q?yFm0z5lYaL1TAFAUGCZ/KGP2/80rLei6WyfdCk3F33iF/7RvbWuswLkmykA0?= =?us-ascii?Q?RKK7PMjdYTbHh+6Spfgh4x7SEg0Kuta82QTQMLPm0Qb0eGMyjHeb9i1zPm6E?= =?us-ascii?Q?mw+1tkcO+bS7kypbwpcNUA3mGTxa3IdrGLdX11AmMR7W+dP7nAP6WEbhD8CR?= =?us-ascii?Q?cUV112ftRf/K4gh6L5cx6sC4rYUGYrtfBYY8ZcsTGdLT/flRT1Brp6avi1oC?= =?us-ascii?Q?fwhEwLUTmuVyNkrQUuflyDhhmhPQcftaaoPV5m6p/P+jDLLonPpqNJL4I/kM?= =?us-ascii?Q?yBWAMJSPWu6hQr/xvZrQTW4pvubmB3czyB0ByJJq1ph4IE5eXGfuPoFYv9DZ?= =?us-ascii?Q?YZZGVhW9HskjkyGHe+iqKgknZwi3vTVRECeKUkt8g5AWY76+Ytfg1Isivhz1?= =?us-ascii?Q?or8HnemeM97iC/YFBU4cwS7dz4Rk6l3pVkv6QiZ3YkW3z6E5q8bqu08sQAbg?= =?us-ascii?Q?HuNGdy9LIzYzEon4LKS23AYXq7TLqf3MUnlGSmrwA5gKNUqf4ClGPYKYQI36?= =?us-ascii?Q?F54WG+m/cD7OlyOTEbElUXu+Pajc17hd4nCuyaSaK8yu8xXBW7RSTW9csHTp?= =?us-ascii?Q?c6QJVt0xryEFSJEjyDKZYCoABXql+9uEL8eLISIT8Mm3+IvUqU1Voxjy/LXo?= =?us-ascii?Q?lsmcxx/ceGqeecfOT1KJt6nmh9c3LohD7C1J/2xIvh79MhZxqfMtGknufn5v?= =?us-ascii?Q?zmZsce4+DAasl+deycAGrmRL1XroVbjREJbceiRASR312NwR+gNoc+iCD9tm?= =?us-ascii?Q?YIfEUbU4oC7x1SWltTM/KYEZv7r2/FOJJNGfa5a1ASQYaeYB2b8qqkq6LgVk?= =?us-ascii?Q?VODdWeazgTve0Zjv9OUag/gG5DUzbJrNrq/6mPXvZ/afUOnQXi2btJ8twBQD?= =?us-ascii?Q?2n0/FZEzrA7TbOviFROMq/BMcvgDvDkutQtNh4BCRuYbNkON8i2KQNQG6R0K?= =?us-ascii?Q?YRqJXE0UqutDf/cTuuSKLBtM0wnAwmTVKt5iFurpOavzG6CKBMSBjVpgbteq?= =?us-ascii?Q?f7VlqAb4u0958S5+03bWnPSRPI6phEm3e6x6GTjv8hzMGQ9RWc1ypIYriZBm?= =?us-ascii?Q?c00JWqZeJ70IAtvl133fioZkGRZL+J0ZpuKCdD0IIxaWgW0JEupLPtvvgdhf?= =?us-ascii?Q?ZmR+SJOZPiX/33r48SfD5yAyubB4NpvZESKc2U1eMYKhp0q6HPWTDr3MJsD7?= =?us-ascii?Q?StkRkZ1jlLCCjV2Peat74jZPnU+xdoXQl1cl9zJzQwptYFYrtw=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)(36860700013)(376014)(82310400026)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 6OyAhzvWjIkfgyQN+jaMGQcKfpjKYSm3UACwbvkpflqNJ7JWSEm6yi0CGItMXP/Q8LE0tnTcErEDFbu6zeMugD02FVBX1zEFKGY0Ui9B3H7VTq7hkCBlaZ7s3FP5X1z885H+MTP7AyxYZLNWOqYTmlgIwednHl6Q5uoysEhEBzWSXX/y+ejKEnq8r6fbzbCq6R38Ghk0gUZItIuL9/2UbPaAI8iMQLMEzR72UCusiptNuUvCRJmRQeVHl3KgPV/aUF0jO3Bp2zyTBb6M/MKYz8kH7JGUCLehOtEUc0qc8xZrK4r2oGMf+XAcvi5JX8UT015j5ENaG/66SOU3Nr5qOoNrYhoagNwgCYDrSPlsJThIUKFMGFvfidSiZRaGbz2QBvplEad+Gc7onE/uAZ4f0GSXpTDB01mLN7PuEY0R8Y4oEOmJdjQUjcI1tiBB+JVhF5IZ4O0h3DxaPWwACH5oU4Tahr1pIp8BzFPHHwV/D10A1SrBV6aiLZO/Gslh9MogC8VXfD9os3ZM4kxLVTt3AXHSuJYaqi2T8NLsnvtUi7tUvANDKog8o3VVdBJCJ8+ZJ2qVTRsQYsd1pVolXGwzVjebMk2fps8V4/2EdJhxBWa86pbXJ/Ilr2x0glg1caCMH5HkKOMpskaQCnAK8DZG69WLdnv0jwnA1lHHJBk6MIg= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 21:05:36.1612 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 79d06618-1dd8-4c9d-60fb-08dcf2141c03 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: AMS0EPF000001A8.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P190MB1207 X-BESS-ID: 1729544738-302135-12910-43219-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.51.169 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.259883 [from cloudscan17-111.eu-central-1b.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