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 5259D45BB4; Wed, 23 Oct 2024 19:01:34 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 685E942EFD; Wed, 23 Oct 2024 19:00:59 +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 591C042EE7 for ; Wed, 23 Oct 2024 19:00:53 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2173.outbound.protection.outlook.com [104.47.17.173]) by mx-outbound21-18.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 23 Oct 2024 17:00:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nX3pWaTjhZXa65ArMAYKl1Z/JU/DL/hpAMcp5waZloYAFfL/iubmP2j1Mc+AE1AHtJsEVl3QHxFF16izwitvxNfkQGjYhJrhAdF8ncre5Z7VlAMwxnT4I6MWmT2okqOKjwSS42QnyVsqlDM/5WBWWdnGlnoYRDXbVapQ8WV6qp3QoaIDSgx/+2h/jCtHPBmu2wL8f80rNtgQ50g1buDLoM2ICySd6EQWdtQX4mYg6/+gKBJ8F0mIZryr5zMykG+drRobTdQd92PrvE18vuEa4E8QqtLQxFD4SS/lzQjDVUV2RxSj/MWz54MrQvT8bI5XM2F9QuOhuZGyHrDAa6+o5w== 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=QNRp1hBT2O+sReccUjRdntC3KggQNsmiXEPLgbw075p60Lb7wQevgirFMhc3PuwWGuvZkB7Nk/89GpcBQbYVE92dw11AY79tX+W4entrT08s0ZeSwqePzQAKPxNln/umlA0lVDb532vgCbV/yfTw6XMtUSIcouAu2kVVcxsoDgpdR0gwITwC8pb2VfAn9QIW/nl5Eb8ySSHxtWA1FWH7Gk95u0I9x3YoLJ39oIUTfNcn5eoqZ+xOedJxI7IXMsFpxgteq7S9I7AYx10uGKSK9F74pecofWmgOYoC851FVLQf5QU0QOxvar59SMBx13SFA4MDGTuJ3YedaXAmSs9y5Q== 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=evHkQDspvu1MdFy72uZJNqInYHGgcn4u4sO8M5fXatxTqaT5co382C9Dr1O7TZNwFpwRfTChS9zpM9ZOMi+tXIh9AvfFyQtYZKpAANQi/e2SHyVCevsOImQKErxPMB/pn9xjLU5dy0sXWv7lA1x0vZXIWQ7PR+oDbGOyFEMQB7I= Received: from DU7PR01CA0002.eurprd01.prod.exchangelabs.com (2603:10a6:10:50f::24) by VE1P190MB0893.EURP190.PROD.OUTLOOK.COM (2603:10a6:800:1ad::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Wed, 23 Oct 2024 17:00:47 +0000 Received: from DB5PEPF00014B9E.eurprd02.prod.outlook.com (2603:10a6:10:50f:cafe::e7) by DU7PR01CA0002.outlook.office365.com (2603:10a6:10:50f::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17 via Frontend Transport; Wed, 23 Oct 2024 17:00:47 +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:00:46 +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 v3 07/73] net/ntnic: add NT flow profile management implementation Date: Wed, 23 Oct 2024 18:59:15 +0200 Message-ID: <20241023170032.314155-8-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_|VE1P190MB0893:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 0bca680a-04ea-4981-1f3a-08dcf3843d73 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?23YUxvdUlp1oYXBjmsLQ2Oi/u/jcJLBEzNlPG5pfQh8Lq7C3OwS17mXGSZnI?= =?us-ascii?Q?9XzPhVZSnxHh/EA+mB+KiOH09R19+NbaVzcxxtNBE94wBnHRriB268DehKxA?= =?us-ascii?Q?WZyTgVbfvV5PZ7+hg701A8yi+UvOM6JaG9Ik3HnmIMWW2ThW9z7c2p+y5z4u?= =?us-ascii?Q?4by6XoBjIfmIhtZS8g1VqWAn+/pxl7OeuQdcNlDscpbdCyiuLWKiMCXgdn+l?= =?us-ascii?Q?/IHk1ndGCyGTdexFxl5gxVVEZXqdSY/tB74g6A3pynOxTei+nFXOViakQMCs?= =?us-ascii?Q?ymyjS+4ZcKH8O2H4jmIEnYFqfI/jnk+5G+cHGY01D5jI1sSefYSmlLwPiMMM?= =?us-ascii?Q?ZgwoTye1ysN9cJWWHOHpMRZSEpuOyIAiJQ+X+jKx5dnyL679H+heGa6MKdz+?= =?us-ascii?Q?ihwnLMd38h9bmhn1NM1LqRS62Teh1PDgsRXYYW9L5MwmY1Wcy5VSDSgQkH5d?= =?us-ascii?Q?uA7+zQ/L00QcWlAYWuZVEQavLxJxIGZDKFBbFuhpsROCZtRvs64RDBMAsb+d?= =?us-ascii?Q?AL/q7pmB2d/yYFTcCa1jJ3HBgEGPoeBErYqBU8yLiwoWfbOD/slMu+1YochD?= =?us-ascii?Q?/M3oue6WoewVEBpPLsf5rYdWI6UikONmy+bWtl9AyCoBqCP0gp4H549VPSyK?= =?us-ascii?Q?+ZGZOKXjy0nWOm9pemeTflxXh1jr2UW8Y+OvwxzpsH2AKGe6ZLmSevZFtxGX?= =?us-ascii?Q?4cnmQLzbMgSTSKNR0seZMKbZ+Xe74aKGWt19tPZ0Z2FYOvGrUKl97SmVeaVr?= =?us-ascii?Q?F2r6InFm8yDncJvCsu645HwLRoDtF07t4K4hoYSKtC2VE+Ixr/mAE8pWeQpI?= =?us-ascii?Q?iZDyWFwr9o4pmWl9SUwmDkcK8SS0d5YXym4isswaM2y6xugMRb5oyjolxHB2?= =?us-ascii?Q?Y4SZDBvnjKSfIapVTBh4Se58hrYHdps0Dm2n2Op9JfWYuiMA+N26I5nvN2WK?= =?us-ascii?Q?hrT7IRYkvawp6yKE+9U1E1h55p5mmYRCYJgZOLlA8wU1etO24PZHNOfos5iJ?= =?us-ascii?Q?BjWpwsSehtprXySJpm7JvySUiH3gnlzDfOOuACrD0bndUGjKfumBHDmte8Ng?= =?us-ascii?Q?BTfkfJTzqBDMpWEZUy0ABX12XXe0gE+iEwkbP5ojY6dGWfKdPNjcgDrQ3mls?= =?us-ascii?Q?34UeGKz64HIEMiT6MN9Z9mmsEw2O8VxYZNMVv8CPUC+gENTut2ohQfHRThJ2?= =?us-ascii?Q?oDXcmbPD4YRdG3JGoUKuVD6RGi2FPGuOPX6jhg1UPuMZqn2gTYh7B9TSyYXb?= =?us-ascii?Q?BUMSAESjkhGGCd/uJgI1TfsdbKFK2/v3x8rn9smVqKRQztYbNEs+DpHwOu3B?= =?us-ascii?Q?K+x8zT7etWNotkhhwoL9jOGV68sGpKmPMFvbiYbtfILhzC+XGdXsS2r+UzEP?= =?us-ascii?Q?3HRlwRNq7efiCRv6pIs1AONZNGnPv94dvZFbcRdjSS8+hzho3A=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: 0/Wt4xQibtuLUELEhbOOWwKMgY7NWNO8B2wjXKA73CdNf7fAcq1J3EdDzXpVOBnaQAhoVSMnz1Nnh7DItc1rHQBXmO5mTUFRma9sESYq7u0WXpYk+hXHB8KKUcbfirFOU0LTgCuX7yxsppvU0vqcANNSQhLIW1MJHVfs8Il+XiX9ySJGb18texxex6hr54mXmjQCgc6c6yWj4504AGtlA7WDo2sibs8FInhuYpUbWg+/Ukwiwn5er+79fbn3PD4ZnOlYHpLVJ+UGU1rgmvvSOZggf8nzlJbfMnXvYHhy5rUURj4TJUoQJs6KguXKxIRS8iqi1Olxms/pmpv9d3msPZepxBRrVQsIU7i5NVtkJj8+eV/pjDhD10f59XZBNRf5/wzS/TZ7rYF8sRilFWxCPmX4XzYB5pMBg8+GFmHvVrpNQiANufni53VOUPWD+1cASLPAkPsPe6zO7H0oAop/9idctF+mAiPXj3/IHwBwbnl2cRiq4WG1pognoY/yd6sJZsN3WSvAm0WOOO8PJiRNVMgFousvhyva3lbKk5lCJ2TVe6Bo0BBqpnyrefQmXeVP3Nu00TlAZZhjGVO8zHOCBGoDon+TficA5SKvUyMSpZ2RRoc1jnoXTnw1oSOvMv0dbB610joJflFzXZqYUGIpn4kkes86kmet8g3b5+ZHXtc= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2024 17:00:46.9611 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0bca680a-04ea-4981-1f3a-08dcf3843d73 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: VE1P190MB0893 X-BESS-ID: 1729702850-305394-16206-13614-2 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.173 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.259925 [from cloudscan22-191.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