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 9349845BCC; Wed, 30 Oct 2024 22:40:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 00C374340B; Wed, 30 Oct 2024 22:40:17 +0100 (CET) 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 2ADE74327C for ; Wed, 30 Oct 2024 22:40:04 +0100 (CET) Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02lp2233.outbound.protection.outlook.com [104.47.11.233]) by mx-outbound11-85.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 21:40:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=e7h+l/zrdhE4uVS2L7tuFHfxUwmOKPZsd571QYVV6p+xstB9gIEaOdRwA52MMtRnBs7kG0a/K3QMBeUX57/ssm6ZUWt5B5NvVMPFXJod3zyy4OaUvEQk4l6cVSil37+fy3KDq0lZOQOxLJuAUHgfj6F+SzvBmBcO5AsXI5ivAkH731XEkOPayqzwuGJck3ZQv4CvAdP7l/aQ/HjNKdgLuy3UaOW9wKErmaVsueVJsfCxR1H9K1htUX8ak3wQijdFrEgP0KWFYmXvFrKzChLkWzEPlPZNjxpVPyZU7bSL6eVLxSmjfjsnU0JIXKMb1UXzizTwmrC3K/22zhvuGOnEnQ== 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=su7QfxwqiqbkaQnJ7l2jY85tPmuFOVoigppT2GjQJLo=; b=nxo9ka9Yl5lXhcDKCUrztVEZBL/GqfioMbd84vFOSzJvy5AOf1inZibruwNyODs2XbaXCKRKg5/C63B4OjdGlzlXgoALln9XM0Ba8yYgi9Md4uGvPr2T6ekuqVdOtqjcuQbn4BSOKUSKd66qkQU3+x/pHIilXKkHuVCWssIdPGRjgso6LxEzp3HX0xcstoP9cijg/nWOk0+Mn5pED/VwHAWIs2axHan+33hawfHt2JdN/dPqpww3RAlDa/cX8gaqGkZGq3pGzpxxfdo13XvFwwpZMJ5KzBwnQtJ4aGe5WmQ5q1PT/tQeOJZtA4C3o2WbnwTjsDMoo9UzWJjEs+dfzA== 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=su7QfxwqiqbkaQnJ7l2jY85tPmuFOVoigppT2GjQJLo=; b=ZE4rfYWA4d1eLHt6BXMjU8fMTQrujIM9BTtVZexITzxIBb1+8jaUbXrf9+xMPoQiVCJStfJb8xenRfSSFAK+ZhZ3egU+ZSd6h7dpaBPd6XA8BW9Yxl57c6NIQyI7YGa29UeIT3Tx8R2ZotHiUsm2hBq0pqMuVXKtjLSb2nuHjsA= Received: from DUZPR01CA0008.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::17) by PA4P190MB1167.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:bd::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.18; Wed, 30 Oct 2024 21:39:59 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::81) by DUZPR01CA0008.outlook.office365.com (2603:10a6:10:3c3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.22 via Frontend Transport; Wed, 30 Oct 2024 21:39:59 +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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:39:58 +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 v5 07/80] net/ntnic: add NT flow profile management implementation Date: Wed, 30 Oct 2024 22:38:14 +0100 Message-ID: <20241030213940.3470062-8-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|PA4P190MB1167:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: b5be47cd-8e02-49d8-c9ac-08dcf92b6739 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?/DF5QyWPcG+5qOAsR2cjj09vTvB9IND754CZkUlSdb29QpF0xaY82juBXTnE?= =?us-ascii?Q?eHTfNQRy3Pso9Q6v+/hris9yN01ryEp4ciPq43TChsiy4PkvkoIftRWolYv/?= =?us-ascii?Q?sbgSqxIJNtg7RtY0E0MhoYRv+sfrNBDWijf8otEcq5k42HUFjeBMrRq1xJOp?= =?us-ascii?Q?7fzLhFkmg7uND3GaVgWhG9CqMfqLCQEbe95zGbDkt4QO5ygeWQ3PkVNfq2Zc?= =?us-ascii?Q?2pLyUm2iPidJ5lWSw2NeoV6qel8xj+Yfn0s358/qXsTDUYVwQAg5Cpg3xx/W?= =?us-ascii?Q?7m/p3PyOfIQuddHyue1bvuEaFToYjQXSd/9itOmbwXHbzbM3cn2x9aw8WjhW?= =?us-ascii?Q?vmS6VuEZKUUga+lbSkRxgJGRrqZIuwGq1QMo0MNRt6WYEA0Msz/JxHJbrjLW?= =?us-ascii?Q?RNE8r91DDlo9B+MZLqzTogtDdsgB4/xAeBOqfVrcRiiBfUJLyw4za3biL1WP?= =?us-ascii?Q?tr9cTXz4lknOjJ8VKMNNHs2Y2m6mBBAIldM81lPPFwXLw35YzV8JgdQsoeyl?= =?us-ascii?Q?R3cBWgYU1XU7jBh5iSGrFVqsbbLZoGVbZ/J3dsLM3WwMTQTrBOBnJSOtR3rG?= =?us-ascii?Q?N9lZUVu0KKnwZ55QUNohqF8S44lMpN247nu4PSzsi013p2osTdjzvBY4p17s?= =?us-ascii?Q?iyf12U1CLds4eUpKyBurHvq0R3boirblDA5aut9aDwFo//R8QX5yT/WZDrew?= =?us-ascii?Q?pna1sq1kDn+rXWaQ2lmm4D+mAGLdFpZ6OE8MtWAPyFnf0Yj1XgULBdQBtgQH?= =?us-ascii?Q?Nuht3f7J2T3k4RNI+A70M/eOtr6uQhrdKupds4CtmgTF+6AqEx9B3+/DeykJ?= =?us-ascii?Q?2ge+tKgzbxMVFditqNERcHN/kJzzt9hfPN2Y0k8Vpr760Z8q4l2tYIgOy7rN?= =?us-ascii?Q?5HM3X+q6zR88PdP1lRELJQVcC2qJpSOiVeQQK6FcxGjKdl1ikdVqo+O+y2+C?= =?us-ascii?Q?qb49oIkNQQQmu/DX6eEhjg7UCBokJUgmcLE4q4RxgEwln9xPa2ht2Ptqc2jW?= =?us-ascii?Q?nRYbcrkyxKpcd7RHCpGAm0lbPHKi8MeVW1FuhYCuZ+EK8M1C0oEuaU+gq32y?= =?us-ascii?Q?oKfHLRixMyoh09GYRYr+pVs7Gq2cJiynmZeBegJEj4M69VzDXMfbL3Sw+d+e?= =?us-ascii?Q?7r+JYf2fW21GHrFD0FelKSZkGmublahquwFQCHMcAginKmn3mhFffTFWZPRD?= =?us-ascii?Q?+CylLvys68YhAbEJgNUCSSvCwpzkSG2xQZu0kAdwVQEismXNrTa95RWq2pAf?= =?us-ascii?Q?+NOAyIl+TO04XQ77Uj6s860MwhXs0x4v1I+l0voBPraXFjFzyXDas7gc3Mej?= =?us-ascii?Q?qmUh0PSebGM1mnvMyx1qOVw8GfzpNTZVKDJ0AwZuACgMxtdvcXaxYnesq9ot?= =?us-ascii?Q?YNf3rtxS0Vv4uXmcqXNwv8Qdq45aujRLOZnPBMZ2/vOJUr0Sjw=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)(36860700013)(376014)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: AsOjFd23PkhfPo5Gu7o4u2K1LqoocrkFliQCrkHJMheJMhjO14/PMQ81FQUrNPqeiUKoClJyZU74+K8CjKmFBrW1LcP5Wndg+Z6BI3t/LXWTPsjSuG0UeCQPRlip7tY4SRvRkEtbC7kEoyP2WYZu/9kXYp4+R0m0NXe+OArzg5OrBsdUz0uqR6Ptq6EsQzMuS39nZuYgr7U4kOrKjzGI+/oNh464QU4v7mi1GK5DmeEWPuoRUa4qxFsYAeQ03NIaNCyrn7o80hlIV7swVCZiHA89pIMhqfQN7QkjBwJGPxQz36Xz3pn74aNemJDfjtXoiKnlW8JQx13ysKQVV1+OQhzWqmle95FVlRWb5FCj7dtDVDmyQlk3L65n+U5qH14cs5BVxxaVOveIAdrJZ4FxcReNcjEAkMhcFzt6z/ERmwKUPyorsbv/9Q71L0WD2RoCkLhsxRf+Ctsu6h2CjRxHAU7xaLa4LwDqB2sV6gxNWzqkxBVyhcCBCAREh2Z2MzltrC8JWK/4JOfcVrDDjY2F1bDcL7SvYrQTmdEtw/zW0TG0SIZ7A6NvmF65r7mVVoZ0VHqGdhS84GJP9psPkWCvU1XZSwA64Sz0/ECnMHkIsNk1ugCWvw81VStoAdHddHa8NjSj7dlcGfiXXkcPmPxLLtg+9AsjexD6t3xkfQ5zJdY= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:39:58.7862 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b5be47cd-8e02-49d8-c9ac-08dcf92b6739 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: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4P190MB1167 X-BESS-ID: 1730324401-302901-12794-43448-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.233 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoaGphZGQGYGUDTFINXU3MLIxC w1LdXINC0tzdTUNNHIyNI40QCozMhQqTYWAAHxXkxCAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260091 [from cloudscan15-25.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 | 56 +++++++++++++++++- 9 files changed, 280 insertions(+), 2 deletions(-) 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 0400527197..6d91678c56 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" @@ -12,13 +15,62 @@ * Public functions */ -int initialize_flow_management_of_ndev_profile_inline(struct flow_nic_dev *ndev __rte_unused) +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 __rte_unused) +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