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 0BA7045ACC; Sun, 6 Oct 2024 22:40:59 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6411E40E0B; Sun, 6 Oct 2024 22:38:18 +0200 (CEST) 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 3817140A72 for ; Sun, 6 Oct 2024 22:37:55 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2105.outbound.protection.outlook.com [104.47.17.105]) by mx-outbound22-159.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 06 Oct 2024 20:37:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wBaH2QkMoHO/Hy/pyhlBk2ZyD1JThg8zh15KYCXmivTVDOE0LUR75ovq1197Bh9h5e92DMErIxFPnPc5Z5vchqYz1DH7FK4SH93RCIoT7U2HJ1+qalHP6DnWIXIi2kx9PuhG6A1UglfW8UF6qhZxin7MOYt9s6TPpTV+vfpWebj+jvw314rsKJh5peXtay9KaGXF+ZJ3ZqzXu1jj4SJQr4vGBE3eOz5XmRxTlAasITh7vSZujU6T9toZ8tHi9SSn8Z3D00GPRjl1yjVzwo9xV0eQFbqpv8m4uvL3UCGcMquhcYIFpmhj6/g0yaYN9Mb5KMAUjHVCPUR53Z2lbDA8Rw== 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=VAAQmsL0Xr8mDnXFvKQjmWbX1D4zhGJa39Bu5wcbjis=; b=mlEU11JFKna/9RKyre05L4YlOHhxZDcMqyZPwgET3l6mtIWyMt/RwLBveUWDdx4XeyJVQBo0JZPWVmIz0uZdPF8YAdImhnH/+s+HkMHxOq+ZnBMeeGyu0wuqxXDymTKWy9hQH8zChJ0ug/C6Yqu85e2r1seR6Hmf0s9jo+Qv1crhRtcllwVvTILVsueyjaAadsXCIcxkMU6iVaxRgiss3F0Z5XO3YK4jSioeGBfRINDirWs+FpOqmofVE5uOVuAZ5MWwMIDp/vek2oBgLoIpBBt/nJZCiPlYv+18ypILJWVBOhz9shKfm4XHg7efVH1d7pVQGHSTvEuOl0nBwCffKA== 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=VAAQmsL0Xr8mDnXFvKQjmWbX1D4zhGJa39Bu5wcbjis=; b=S6GAwMClza5/zhIfVK6udKtopD9Bd/wYhJIdh3KInCdElAxED7YPpHUgybu9I8IGQWlhC5gY1jtiZ9gesEuGD0joQ9RDYiMrRGsQmJzTejmpseMqf5JpwclpBUDcsufuZniPn/jJNJ8fIDjta693wWbQ9Yp+ObrNH0BDQT++/Sw= Received: from AM6PR04CA0008.eurprd04.prod.outlook.com (2603:10a6:20b:92::21) by AM9P190MB1330.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:265::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.21; Sun, 6 Oct 2024 20:37:52 +0000 Received: from AMS0EPF00000190.eurprd05.prod.outlook.com (2603:10a6:20b:92:cafe::e) by AM6PR04CA0008.outlook.office365.com (2603:10a6:20b:92::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.20 via Frontend Transport; Sun, 6 Oct 2024 20:37:52 +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 AMS0EPF00000190.mail.protection.outlook.com (10.167.16.213) with Microsoft SMTP Server id 15.20.7918.13 via Frontend Transport; Sun, 6 Oct 2024 20:37:52 +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, Oleksandr Kolomeiets Subject: [PATCH v1 27/50] net/ntnic: add base init and deinit the NT flow backend Date: Sun, 6 Oct 2024 22:36:54 +0200 Message-ID: <20241006203728.330792-28-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241006203728.330792-1-sil-plv@napatech.com> References: <20241006203728.330792-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF00000190:EE_|AM9P190MB1330:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 812516d8-8ca2-41fe-c928-08dce646c05f 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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gFdYs6CkQZYCzhNw?= =?us-ascii?Q?8TelE9yOHK3kv35/HWJkgnz/rs4Ssw7MVpFwPOoVAysuYysEJPrIxflv29Wa?= =?us-ascii?Q?OXuIxESZZNoTp6S1iYfXN4IbwT0FKwPFcykBFDiPP54nI3yMtIHcDSa0GsV3?= =?us-ascii?Q?Yk416kOrG3Xtvlv0cOe/7AKFdfgTEOJcmiOlb5OXLHWbNd14Hy5rYbHR+hSN?= =?us-ascii?Q?28J3aWFOkCl0dVwPypEexoDy3Y3iNSowfjuiCJM3IvUo30fVzIJrbhriMhaJ?= =?us-ascii?Q?7sn9Z7X3Qh8PxbEo9B3YjG0yO5bAnFKXkUpmopU1iUuUrf6PymDgSVuY/Li0?= =?us-ascii?Q?72dbDloPda7Lmdu42QOQ8ceGj+ocAsvwyxrf1Ass5jFv6u0vjD5qB6R8mwlj?= =?us-ascii?Q?6eMV7CxZQKodLhr2lF5BS2KSA6NlzQ9f3GEtJNw4vrxUHk1ofzoDarCBOzIc?= =?us-ascii?Q?mWd7UKKouuUtEBGPXgYHX8eZ2bZCocBXZ/mUgoISXZaow+MeQTzNV+OzOn55?= =?us-ascii?Q?Q7YRFN6969ziiONmBz0zueYUW1rW?= 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: 6K4DMCjiBZiDJD7TnsjqCvG/GAW5Hi2L+h1vSquAS4NxWPdtCZHtalMenOj4gLSw4QtLKN9x+0RYY+ERpAKKxfgly/K0tiPJVY+eEMA/7uHLc8aM4ptQ5A2Qwy2GZI1YnnpYAmFbdhLgy9ac1dWVApnbLOoYWpzylBEFhKWLvbSgJkZqtfIX08Q0TJJgdqQnlBFOwZLG+7HJivFjcQNOyDK+rhpc4jWIvSfibubC/oXj6cTJ3fP/dYXw4KkuYOvSFL/Z6uC8pPS7RmnDCHbKfipacw1dWHGN2+DUg3V6wEGPq3IKaXG5XljPMEcjrF1oX30omOwHNhAwY1PTO4zzxWKoYKRqwtcE1DnZrHNckyzts7v20MpdAu4k2yRbFOjx+aMtrhJEBKpuUrJmGofJWqR3VMcdxi3hoi5cXrigiUl/vZKCCod0j+35VUlgZCR+1hruq3vlaF6Hd0AD+6hUh7xV0mvHEvfU28DUdFbsV80fzBdz7XWUygjvABzGgSzXePtPSPpq6ygpj0l2erK9fLwT1t2XQjZZAobawjSTRQs2wg+UL0EMt8xYJeIPPVZ0v/liNh5N2i04ZKK/2ONGnC7QGgFJzmoRwU1P5l9/g8t4uugi2efo/5t3/wszpXkjAtOaLUXKReCneB4w/q/ThA== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2024 20:37:52.7963 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 812516d8-8ca2-41fe-c928-08dce646c05f 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: AMS0EPF00000190.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9P190MB1330 X-BESS-ID: 1728247074-305791-12642-147798-1 X-BESS-VER: 2019.1_20240924.1654 X-BESS-Apparent-Source-IP: 104.47.17.105 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmbm5qZAVgZQ0CI1xcI8xdIiJd XSxCIx2cTYItHEMNnYLNnU1NzCNCVJqTYWAMqFdQpBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259547 [from cloudscan23-175.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 From: Oleksandr Kolomeiets Add basic implementation of the NT flow backend API Signed-off-by: Oleksandr Kolomeiets --- drivers/net/ntnic/include/flow_api.h | 3 + drivers/net/ntnic/include/flow_api_engine.h | 5 ++ drivers/net/ntnic/include/hw_mod_backend.h | 12 ++++ drivers/net/ntnic/meson.build | 1 + drivers/net/ntnic/nthw/flow_api/flow_api.c | 64 +++++++++++++++++++ .../nthw/flow_api/hw_mod/hw_mod_backend.c | 28 ++++++++ 6 files changed, 113 insertions(+) create mode 100644 drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_backend.c diff --git a/drivers/net/ntnic/include/flow_api.h b/drivers/net/ntnic/include/flow_api.h index bad1f72868..b5194ffa8d 100644 --- a/drivers/net/ntnic/include/flow_api.h +++ b/drivers/net/ntnic/include/flow_api.h @@ -46,6 +46,9 @@ struct flow_eth_dev { /* registered NIC backends */ struct flow_nic_dev { + uint8_t adapter_no; /* physical adapter no in the host system */ + uint16_t ports; /* number of in-ports addressable on this NIC */ + struct hw_mod_resource_s res[RES_COUNT];/* raw NIC resource allocation table */ void *km_res_handle; void *kcc_res_handle; diff --git a/drivers/net/ntnic/include/flow_api_engine.h b/drivers/net/ntnic/include/flow_api_engine.h index 724b68c3e8..db5e6fe09d 100644 --- a/drivers/net/ntnic/include/flow_api_engine.h +++ b/drivers/net/ntnic/include/flow_api_engine.h @@ -6,6 +6,11 @@ #ifndef _FLOW_API_ENGINE_H_ #define _FLOW_API_ENGINE_H_ +/* + * Resource management + */ +#define BIT_CONTAINER_8_ALIGN(x) (((x) + 7) / 8) + /* * Resource management * These are free resources in FPGA diff --git a/drivers/net/ntnic/include/hw_mod_backend.h b/drivers/net/ntnic/include/hw_mod_backend.h index 3c6c15c896..f47153cbb6 100644 --- a/drivers/net/ntnic/include/hw_mod_backend.h +++ b/drivers/net/ntnic/include/hw_mod_backend.h @@ -278,6 +278,18 @@ struct flow_api_backend_ops { struct flow_api_backend_s { void *be_dev; const struct flow_api_backend_ops *iface; + + /* NIC attributes */ + unsigned int num_phy_ports; + unsigned int num_rx_ports; + + /* flow filter resource capacities */ + unsigned int max_categories; + unsigned int max_queues; }; +int flow_api_backend_init(struct flow_api_backend_s *dev, const struct flow_api_backend_ops *iface, + void *be_dev); +int flow_api_backend_done(struct flow_api_backend_s *dev); + #endif /* _HW_MOD_BACKEND_H_ */ diff --git a/drivers/net/ntnic/meson.build b/drivers/net/ntnic/meson.build index 15549e1c94..57d1ded2a7 100644 --- a/drivers/net/ntnic/meson.build +++ b/drivers/net/ntnic/meson.build @@ -48,6 +48,7 @@ sources = files( 'nthw/flow_api/flow_filter.c', 'nthw/flow_api/flow_kcc.c', 'nthw/flow_api/flow_km.c', + 'nthw/flow_api/hw_mod/hw_mod_backend.c', 'nthw/flow_filter/flow_nthw_cat.c', 'nthw/flow_filter/flow_nthw_csu.c', 'nthw/flow_filter/flow_nthw_flm.c', diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c b/drivers/net/ntnic/nthw/flow_api/flow_api.c index 92b8d083e0..4bab8983c9 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -175,6 +175,24 @@ int flow_delete_eth_dev(struct flow_eth_dev *eth_dev) * Flow backend creation function - register and initialize common backend API to FPA modules */ +static int init_resource_elements(struct flow_nic_dev *ndev, enum res_type_e res_type, + uint32_t count) +{ + assert(ndev->res[res_type].alloc_bm == NULL); + /* allocate bitmap and ref counter */ + ndev->res[res_type].alloc_bm = + calloc(1, BIT_CONTAINER_8_ALIGN(count) + count * sizeof(uint32_t)); + + if (ndev->res[res_type].alloc_bm) { + ndev->res[res_type].ref = + (uint32_t *)&ndev->res[res_type].alloc_bm[BIT_CONTAINER_8_ALIGN(count)]; + ndev->res[res_type].resource_count = count; + return 0; + } + + return -1; +} + static void done_resource_elements(struct flow_nic_dev *ndev, enum res_type_e res_type) { assert(ndev); @@ -183,6 +201,14 @@ static void done_resource_elements(struct flow_nic_dev *ndev, enum res_type_e re free(ndev->res[res_type].alloc_bm); } +static void list_insert_flow_nic(struct flow_nic_dev *ndev) +{ + pthread_mutex_lock(&base_mtx); + ndev->next = dev_base; + dev_base = ndev; + pthread_mutex_unlock(&base_mtx); +} + static int list_remove_flow_nic(struct flow_nic_dev *ndev) { pthread_mutex_lock(&base_mtx); @@ -232,7 +258,44 @@ struct flow_nic_dev *flow_api_create(uint8_t adapter_no, const struct flow_api_b */ be_if->set_debug_mode(be_dev, FLOW_BACKEND_DEBUG_MODE_NONE); + if (flow_api_backend_init(&ndev->be, be_if, be_dev) != 0) + goto err_exit; + + ndev->adapter_no = adapter_no; + + ndev->ports = (uint16_t)((ndev->be.num_rx_ports > 256) ? 256 : ndev->be.num_rx_ports); + + /* + * Free resources in NIC must be managed by this module + * Get resource sizes and create resource manager elements + */ + if (init_resource_elements(ndev, RES_QUEUE, ndev->be.max_queues)) + goto err_exit; + + if (init_resource_elements(ndev, RES_CAT_COT, ndev->be.max_categories)) + goto err_exit; + + if (init_resource_elements(ndev, RES_SLC_LR_RCP, ndev->be.max_categories)) + goto err_exit; + + /* may need IPF, COR */ + + /* check all defined has been initialized */ + for (int i = 0; i < RES_COUNT; i++) + assert(ndev->res[i].alloc_bm); + + pthread_mutex_init(&ndev->mtx, NULL); + list_insert_flow_nic(ndev); + return ndev; + +err_exit: + + if (ndev) + flow_api_done(ndev); + + NT_LOG(DBG, FILTER, "ERR: %s\n", __func__); + return NULL; } int flow_api_done(struct flow_nic_dev *ndev) @@ -246,6 +309,7 @@ int flow_api_done(struct flow_nic_dev *ndev) for (int i = 0; i < RES_COUNT; i++) done_resource_elements(ndev, i); + flow_api_backend_done(&ndev->be); list_remove_flow_nic(ndev); free(ndev); } diff --git a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_backend.c b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_backend.c new file mode 100644 index 0000000000..5966dc6e8c --- /dev/null +++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_backend.c @@ -0,0 +1,28 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#include "hw_mod_backend.h" + +int flow_api_backend_init(struct flow_api_backend_s *dev, + const struct flow_api_backend_ops *iface, + void *be_dev) +{ + assert(dev); + dev->iface = iface; + dev->be_dev = be_dev; + dev->num_phy_ports = iface->get_nb_phy_port(be_dev); + dev->num_rx_ports = iface->get_nb_rx_port(be_dev); + dev->max_categories = iface->get_nb_categories(be_dev); + dev->max_queues = iface->get_nb_queues(be_dev); + + return 0; +} + +int flow_api_backend_done(struct flow_api_backend_s *dev) +{ + (void)dev; + + return 0; +} -- 2.45.0