From patchwork Fri Oct 4 15:34:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 145088 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D9B1245AAF; Fri, 4 Oct 2024 17:50:44 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 84C30427B4; Fri, 4 Oct 2024 17:50:43 +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 D978042795 for ; Fri, 4 Oct 2024 17:50:40 +0200 (CEST) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03lp2232.outbound.protection.outlook.com [104.47.51.232]) by mx-outbound8-201.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 04 Oct 2024 15:50:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=e5SsLYBOmbg7VehmqQWO/2IOBgr+QVajy/AENI0yErsWJ3qwFldTfzL5CNT4r+pZgFTt+Z6yaBpz8JU6nZK05EtLRm68qce1V3A823KrMD8OR035VQO8whYqYQWGkacx54tegCXevodhH91Jc1mTo20fEBSN14UXqpbSLAve16EyU21trdh6AarlzwA1voZBH+DqOKy5pnTS8tVy+DTwb5WyFyjgVd917aN/5pFTjHjRd56vFG2jxWg7QFUtcnX67c8vz83crpUZHncyDjvw3+Lyop/Zu80mvkN9XCbajfhbONOS7ciLhK8dABkNrdd7BJZP4Lj0E+RxYuW4F05oRQ== 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=Im+RNZaqZ/Nuc3C2OXNi1OCtuaeqATlVj0st3m4aMDX4ofbc6K5vq2GSVh+R/TSY3bry+SeEBlIAA/DhwuXs1ZSoRvo4cyfhD+SPyDW3QqP4Ct2001MbfZp6Be5N4vBLpPtKCjUWHil359qi82pzJmsvSCRD/pH6zi961kPZKstW+oZFI+xrXIByGhSd55lgG12hSQBErGGuAS5ndVZS26hiANAkFQL6U72Mn89r+SzID9giBmJJ5mbz+hDKUPV3pDRg0a+s/mjfcJ4miwcXalxVm7GjJAQM6hJnYhxycBga6vKOSzW6SWCuwhnAV4zHF4TITLouk0Jda/+LN8SrvQ== 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=RyehPj/3K1bHLR7iSv/9MaAXDOz1kVtjOZ+3WRrAcT6gysuRY0RsIWYLd5XC6Qi0FexNHHz7A75ahZP5Mars2qmxJEVaYCcbeIqgX3H2+uupvILQl+YNLLddBSNUqIwzu294LAGGpBudsuDGibo7Suhi/e+HX+NGmYarYxbGD3M= Received: from AM0PR10CA0100.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:e6::17) by DB9P190MB1940.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:397::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18; Fri, 4 Oct 2024 15:36:22 +0000 Received: from AM2PEPF0001C715.eurprd05.prod.outlook.com (2603:10a6:208:e6:cafe::a6) by AM0PR10CA0100.outlook.office365.com (2603:10a6:208:e6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Fri, 4 Oct 2024 15:36:21 +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 AM2PEPF0001C715.mail.protection.outlook.com (10.167.16.185) with Microsoft SMTP Server id 15.20.7918.13 via Frontend Transport; Fri, 4 Oct 2024 15:36:21 +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 22/31] net/ntnic: add base init and deinit the NT flow backend Date: Fri, 4 Oct 2024 17:34:45 +0200 Message-ID: <20241004153551.267935-28-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241004153551.267935-1-sil-plv@napatech.com> References: <20241004153551.267935-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM2PEPF0001C715:EE_|DB9P190MB1940:EE_ X-MS-Office365-Filtering-Correlation-Id: a7875738-c447-42d0-7c24-08dce48a4c68 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: qnyVkGJy9EU8FaF7RqP32UkJMdM7sqgUT6j7G3/Dym3MBG//cDVbrv0ysXx5+AQx3y3DmA/M+wkrlICvxmUqhk5kUI+j2GOBSkY+wMdcdOSnh8ZDPvJziR+s9iZ4z9qWhRtDN0ymP9ua+psAO2xvJJQ0GoJtQAiCAzypZ1hmhHTHT7r+Hooas+iiLr0Q6Pcc4jokAS+jXtm8AO8a1Sg4s2TqkY9hIkyTGS0RCS6pkNgZCnfu7wfVrPQvDcenKvo1kgZXfSMe026Ay/Ap33hivBykCHJF572zqAMMTvCXzJ2rz6axGfpE8B2qCZ/1W9g6WEF2JsBCDmbOz5yCpLxSZzFX2rkWd/xHr0EJ0U6n9/YQFeRvY8kBaMMDBnb/UTryheYwA5FglVH7Ftug1Q6lnXT1Y4hzTr3wYzpd2LcWsMJjL/yt17AXHGQbPt8whVb+BAAabfheaihlc2FBP9/Qkd0/1cmKbvsDVOEjEM/mz6Fr1httdxo+mC0kReL99yADW3cWqL04BnnWmnqV7fugGr8aOnKEYhSGtxkeHQGE9vwsAno58gvJs7i9bwSq42EfJ3f9ZoYJWKyC976GqJ4GvicKVecaaCyOOUCXTFUi0MYHeakQvDatCL0CCGRl7vwzE3ZTCr5UVFeJscmxWXGQOvEdrWeICKaonZaCgzkPNDwG4VNEuv7QgP4f31jyMSrUvqrcnMYZZuiRIdfvMk0t7TEy2AawIz5B7UiAImWQjsWfpLwGXRvoDCZK4f3cmXqTnCkJIamqPwUFRTgyPXGNGoOpD+gxKOzdgWLPtbtUHwKoInuft+TuhO08vmCWz7AhoKAbPmEiXZL+yGPXq7pvEbJrPr8/ap1NTtnZm1VrBDRqINKa4hzOolxzFeqOXCYE+r9ZiToNbrCkBhsC3fMyiTfoyyRtOS6fclCAXlL2KJ6rLhf2CFhyuNPAbJlQbqfXyyyAwF40PiCAi8fyA97RAfml+DMBycWgSKL566bz9gyreZxMI612QeiEbm1EL+gVULwEJ+wnAo24xG4tKvAKu0wfCBTKjiPUkLxWw++YcgmT/KKZ0HU4FLQQX7WWweFHIQWuDYjKINWEbARuQqluIcl5BOUmFjpHqkaQkv6VjSSYL8J3rSESKDy/nikPuoHcq9ks0uRK3hAdVMuWaFOullUVNLO7Ny0tLFejPBzJYFpl9e6NRbqlbAHXoUN45QrlFnLTuOvLl72Ppes06mwjpA177l3NsiQsdwDJeAUrTH/Z8qM9nD6UcF6fCV1wKIpT+05zmsW487CTFwiDDgluuucl53kZsNz2o4gyHOcN7XOS/JXZdwYriF162iqnb8swP+idmZxLq9WyZIa5c/Mk6VvK7FIVpepv68fOpy0o8hTLLd75sVo2LQ3gKnhdOgX4 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: Cmj1VbfnGJJKoRLo/660ujd7Gb/CagWpAxcZ18KXyfjjkpw43sch6uET/1upDXsifvcU6zQinfEhwPg603kZZIJXkOWUVtyOxR+px0jNyZfiG+0hSSC4TwWBtD28OCHUPHIXI4MuCaDly7hZuHZ6lERWpSda43BQfmhy0GmC0vYfyC1KFsrnVPX3SY4r4TqFQs8kmpfm+6zFxhQaKak7f+ccrevIyuIReCkUeV1LIagr+oAHVrQvjM/vRr9FPyYWayhaGIJ03rdNfTvyGiC810SeTJ5cGoEifeh0b1/2vO2Cc/Uu8n6DPZ5mYXMhlllIMKv7wkXOLG3+JyfHL2ZmpYAqetGBL3LNc4Z3HPG38uHTH6bEEg3nYEUNXPlj02V85kTrIRkn04oLccgAitII/GuCNOogDRoN97/Hf0Qr8sow28ORTD2/kSNOG+9vxfL7hZtd9Qc6h/HJGdbAwk0Xo39Ow89yGh1qCEY7W2OQvr+Q1FDJTI+gxFR/4TFhmZLIoCWqaLVcrMq6QWW+LzxUWeDCgJmjkuzU8EFOp3Y/aPVf29XiZK5OBIWRvRlvgZyDb8vB+W9Rp8FiWJgGQL2tdqSv29f41lJ0PWlk9GDa8MIKwLbMnPvaNCp3oZ6gStWGiUgGtBc2BBFGql4f2LNy0g== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2024 15:36:21.6428 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a7875738-c447-42d0-7c24-08dce48a4c68 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: AM2PEPF0001C715.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P190MB1940 X-OriginatorOrg: napatech.com X-BESS-ID: 1728057039-302249-12644-33726-1 X-BESS-VER: 2019.1_20240924.1654 X-BESS-Apparent-Source-IP: 104.47.51.232 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.259494 [from cloudscan20-43.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; +}