From patchwork Mon Oct 7 19:34:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhii Iliushyk X-Patchwork-Id: 145340 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 B748945AD8; Mon, 7 Oct 2024 21:38:52 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B48BA40E8A; Mon, 7 Oct 2024 21:35:47 +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 2F7AD40A8B for ; Mon, 7 Oct 2024 21:35:28 +0200 (CEST) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03lp2175.outbound.protection.outlook.com [104.47.51.175]) by mx-outbound43-193.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 07 Oct 2024 19:35:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VaD5wVi+ezJnYIzK6NTD5Fs6KJFrXfKKCBZHSAY1JCdv5vZAEKPNkeIPx5lSq2oPkY0RaEuc3Q5W4cOjasUW9xJRW65yQlG9x5dFScr72xNw+nZYeIBZhQw7Ug6JaI6gEpLMwmyd1l7vGtO7qyWsTg/8Tu5YZrcVxKVzC2pXQmCERPeONFg7U7YOmlmUhdYYA8Q/ER/WXcO5XBi4LIxYwQn3mz7Di9P/hNAXNC2jRvkKL3IKtrxNt87m/daSJjNzaFhnPVzHnRQzI4D/jI69NMcLPa/Gej5XFNKaFnFFGzplgrlGYWilptZBZ2StStXEJtYgjefJf071F9Jn/qJ9mw== 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=zR8DoyZOiCMgpQZ060zHvsyUgzCGxZQ/MV8HbSq+bJGwjB4AZdMSyaIQWHuZ10SXt2xoO9NCF5oyVriqIeJU+kB8X66T8eLL72Ozp7hFEBcGEdLEmGS+6JwII9f+M1RV3RDvzelC0swfM+cWeWWc2C8gmRZ64J2e6fPw0NsiQIYLsLGQSXV4IYRB4zYoZn4Q2fLkWf8QK+ca8ZcYWrIXp8KQvrrizztb4JC0Nx+7wG6Tu1I/DdBXEnnSFSmhZPb+kbCakldG2VTRyYoR8LDphuPVolPT5h6vjyRXOS+n+zNK6cgBaX5Pl1LSwosj3KxdkGhj2V565Ubo8S3CowP6EQ== 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=L7jiXm8tFOL7QoJLu4scJeVP63ZQvFoKyWJPsHNG0sBKZQvDe9XKc4qTZih699TU/qrtTZNwQURyDf8ZYfVUqa1KSOwXudNipE14k8Ie7MQllCe+QJHHoS1AdxpEdJ/zNUs239I05Xr4s2BiAKJQRlIKiH3gDyjuTybyI51BlGc= Received: from DB9PR05CA0024.eurprd05.prod.outlook.com (2603:10a6:10:1da::29) by AM8P190MB0932.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:1d2::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.23; Mon, 7 Oct 2024 19:35:25 +0000 Received: from DB1PEPF000509EC.eurprd03.prod.outlook.com (2603:10a6:10:1da:cafe::ca) by DB9PR05CA0024.outlook.office365.com (2603:10a6:10:1da::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.34 via Frontend Transport; Mon, 7 Oct 2024 19:35:25 +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 DB1PEPF000509EC.mail.protection.outlook.com (10.167.242.70) with Microsoft SMTP Server id 15.20.8048.13 via Frontend Transport; Mon, 7 Oct 2024 19:35:25 +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 v2 27/50] net/ntnic: add base init and deinit the NT flow backend Date: Mon, 7 Oct 2024 21:34:03 +0200 Message-ID: <20241007193436.675785-28-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241007193436.675785-1-sil-plv@napatech.com> References: <20241006203728.330792-2-sil-plv@napatech.com> <20241007193436.675785-1-sil-plv@napatech.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB1PEPF000509EC:EE_|AM8P190MB0932:EE_ X-MS-Office365-Filtering-Correlation-Id: b5aaa7d6-9182-45a4-636a-08dce7073108 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|376014|1800799024; X-Microsoft-Antispam-Message-Info: oLHt8DP4faeI6rropo7HH6m9OzqhO29uBXHaRBt0bHcy9dP2se1lnSsV8pn5iRKzWZv43ipZg34QddjV6nx136TscillupzmN8qMhukF3+yJM2O2XoDwJ32j8yo9IPYo2QsbcSAPa0FQZrjky4uDqJtEVrR0drd4Wh9JkpYCm7JFmw7P+O9ekU6OtzRjZZRDmo16ek1LfVlyxXS45OPWKiIHoz9unk9DCVrHh8EFyTTKr8gkdLXXOimBNJ6p2te8mwI2kYJHiIIendIRDI1w0LjBKvi1ujhyYD3efO6O6ViZ0WAcaJ3VrvSNt58OjYfRjQonJ3yiyMEJgDpCuKVafjLlDU8ZNZ78rhleryzb0WpJh+mmx12vGg+AFdskXy29Aj/ax1OqavwjZB85M/hQYfRAsvcUTNRphNfSqv1tCIFtz1dUL7BFLraY7p1xlJm++wbkK72ShI+j2V/nDMavBu/GuA3WFdhxipIyYhneinkmsdtiarNE6ZHAGcVxYV7fNahBdw7hEjRkeibd/SlmIP5ZW/JPrm20tFzKlOPvM9XB2URyINWWn2GEVL6F2mCyf5Dq3C0gAVuyb2JNY2u+UMuULsioIhzjP7bfZU6292Pg9GYdKWe7JO1urGUZfiT0Fd8dZBa2Ob4sP92YP1eWjIsaP7E9XXXRefa+86c4TbrLFEV29ZoXXUPuSxBsWEs/66wXj10yrAPXZV1osm3AOBDFKJrdZTBAZK2hXuFaofxAqFje48nzjusCvM9NbjRscUEvBn95e8iNxYuBd7niJ3JatOoRhmROeAlKDyyCL1k11NXPtMELmGkg0JNN4NzX0riHZYMWREQlvhMvR5LIvWJ3TtfNxfOLuJ2y8qwDqz/gcLSvwNeWCN1m+7pnsOoVPmZbQtWblwWrJ3EXsDMR2Gmv2OaozqoWfxT5A/zdBKtZ5igqYlAy6kVC/e4r/5pA7zNzQaCgjEuRCCJEtNcTunaDkc5NuyowNdyVyQqJ5JW+lBQqxHiBlV3vYKWe6saEf9tRizJr5vzrKUtx46uoIIckeSpR9tsY0q8nOYVHHLYHQB+2IJMGVZ2gLfOM88lw5jdSBzodP4MDIDGW9EVf2lVin5PRCMJBYJSiAySWAc4Bo2snUt0UdROQFcRM0kI2uVGasMTuBjlr6dVl7LG4OkAgV4IkNEJRbBYVQuj21yoL8IjWLKlnOb7/gRLTxu49s1Wi9z4qtgVAUULpvyhNPiUPvSPbgk8C+i1OuFppIAl7ORSZlmYco4tueLAWdCUD4VpUiIad3A6p/XMksr8AxX2uq4vQjTQFPskfhCoXwbKtD9OftlN4P/BqrY0YK/sp7lh+Ck5pLI2EWR3ZH0NBM6EpgbYKKaQwYW1FBr9hLs3rg4B0imvCzbA/sQL7uk16 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)(82310400026)(36860700013)(376014)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: QC0SLtKgir+QN0EHpaNLa+yuVWLNvqGFXlogPUo3wRWQZ5mBIFfM+WQ+fc3vwjCEqnkt1T+0xNbmRCxs9Vnc5G5C32oH3ncc5Sod/JhwIbX0gl5pqppIi8hL0r3GEw53XE4ulQPMELcg0AyIgGH65xt1JaqjPpj6MGC3D8HJtuARMqzc7JFr6Fz9rRTNm/AUA4wqKWKGX41Ho1unpd7P+rOBxfFaXSuIK59CTIEVKeqJLZZViVKxsFNGlsDosBSrK68te0aAf0dmyIIKfPRIFE15sERV2NXiSC+zunQn/Iu/1IeRNnYqynbSgTCPdpy6Xrknb8+QCWgVatL2jt84lS2A786dZ5kBMEWKrdMAeTreSsAvelye4MfhzF4Iimnn177JLXqh1erBQYXANPHLj1uw8BPKHj0G0kf/Mmg2OJ6unglc50VCxuIqgct0yHoQoWWapvxWxp3U1jaFpuSj8yEAZBTPk21/Ommy8psdS6NL+pwpxau5EuwxggfVP2912eXBhUjU/PSjOspeME5uNEzW+64I0xxn1AwRyvUiSzSuFYeS2N2iPag+GdAARTrLWdjGxtSsfb+Z2hg/w1woFoe/CWYgEwG175BT2YvG87KYnWX+trdlS1CFKwklj0NXRJVcsUQUxS9SavV5NlREKg== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Oct 2024 19:35:25.0375 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b5aaa7d6-9182-45a4-636a-08dce7073108 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: DB1PEPF000509EC.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8P190MB0932 X-BESS-ID: 1728329727-311201-2747-3519-1 X-BESS-VER: 2019.1_20241004.2057 X-BESS-Apparent-Source-IP: 104.47.51.175 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.259566 [from cloudscan9-218.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 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; +}