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 A0A4C45B04; Thu, 10 Oct 2024 16:18:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8304F40A6D; Thu, 10 Oct 2024 16:15:15 +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 5D83940DCB for ; Thu, 10 Oct 2024 16:14:57 +0200 (CEST) Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03lp2107.outbound.protection.outlook.com [104.47.30.107]) by mx-outbound20-48.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 10 Oct 2024 14:14:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SKSdQ4plYATktN9MmlihPzJpkkUsFeuHuvwhdCysSb5zG6cTLLoprGiMgq7sZ38cw6LiaiYEDkVCFJ2+Pf4g0Ry1nCNSR2j6ds6K8tGZHgcolSlmjJ/kk1EBAPiJ0k11Q6W2UoIY3hKccUltgou6cWhWx38TZ9IXYF+CYaG66gbw9V/AjnO/4MjioSMq4I8OVHdd2R6MvdYvbCfDnh8tgOUHwjxhPpirvMa4GfAtgEQqgIFBj/Joep3j9e4OWT96o8OaAQll8IYY3kZ20WOELTo9Yk4h5JxL5jrZBV3yEONqLIqQdi29Gl3trS9KszaGFXfeNV6PZIJDUVjAuNvtrg== 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=I8BPu5t04dqctfFlpWqsbVx/DVgI1tbMjJKu6CQcIPU=; b=Ktk2dcp+fTisLDGbd9XY2De6KEO+Alpm++P8MauGccHmai5yvnqw7RHL4V8VXC5IUdCTSngaz27JE54x7UONruVjiJx+SEaVHhWaGicv0FpgMPlrGukji0IdGvj8hlqtYe2qS2ni6XpAKMfRfRdufdE+pjsL95QCW6BkVifTIEgBraCDFTYjsIAZE4Zr4jDx3UC+olMG7wZM2C0k3w+v+gMPZDT8PTbME9WilSgmFIVVFxhiA4cSi8AMBUcan9plh9NzreHWkdj0GGJzCmmOXSq1EPJJgx2IV8IgiCWykUBu0Hy1UWB4A4CnVxRKgQZMOe7eoS6LJFtL0AVt9a2Qig== 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=I8BPu5t04dqctfFlpWqsbVx/DVgI1tbMjJKu6CQcIPU=; b=YlNBJIUud7M1rgSO7ioQqJBwAIA8Sho6rXn2iR0lu9AiP3K0EwZrJ+ZshZOuWze18uy9PC5xeszBqo8SS1RIBd/cDLyQt74H25fTGg4CtWM/9XJtYLjha/6lET3zBCuFTM4oDj7vJK7aNtFlZFPcceEwjk043TJ5iaZ1IVZPq/A= Received: from DU2PR04CA0086.eurprd04.prod.outlook.com (2603:10a6:10:232::31) by GV1P190MB1993.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:58::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.18; Thu, 10 Oct 2024 14:14:49 +0000 Received: from DU6PEPF0000B61B.eurprd02.prod.outlook.com (2603:10a6:10:232:cafe::29) by DU2PR04CA0086.outlook.office365.com (2603:10a6:10:232::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.17 via Frontend Transport; Thu, 10 Oct 2024 14:14:49 +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 DU6PEPF0000B61B.mail.protection.outlook.com (10.167.8.132) with Microsoft SMTP Server id 15.20.8048.13 via Frontend Transport; Thu, 10 Oct 2024 14:14:49 +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 v3 27/50] net/ntnic: add base init and deinit the NT flow backend Date: Thu, 10 Oct 2024 16:13:42 +0200 Message-ID: <20241010141416.4063591-28-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241010141416.4063591-1-sil-plv@napatech.com> References: <20241006203728.330792-2-sil-plv@napatech.com> <20241010141416.4063591-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU6PEPF0000B61B:EE_|GV1P190MB1993:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 2a317f1c-f337-4efa-0461-08dce935e6d2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|1800799024|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?uwxppOtMKyDJnNtzj7RFDDPrIoWdhPn6Q+yIe0qHj+19SeEFGKAT9JHi3BZ1?= =?us-ascii?Q?ny9Cm57R6iiOegsiGiWGvtEatA6I92FDLbJBcvIzmX/uCqsHbDnblTl6Hxrf?= =?us-ascii?Q?s1LTKVthjW1EUsveyJEYplT/iFlfyi/oGpy36wMPm+V3HYZbmmNxd3KQhpKH?= =?us-ascii?Q?mUkmQ1fpktqElhwA0FyIMlHhGlpsDywIxDs28NvKYACWcwXsfkDvLdnaa4g9?= =?us-ascii?Q?vDTAMq0LcYIoi3/650dGs5IzOjkTgt31VBBnqgMH60DZeFxokYKAOwGy6fiA?= =?us-ascii?Q?ta8SEJxIzNrLzh8rSOR5TmU5odfm44nnlv01/NLkwy7I2AkoXhdvJL7dodKc?= =?us-ascii?Q?cWGPzGM7Z/L+rYPvOOrxyIGBvvLysscarxb8u46tOMnGjZCM7sd4afTw4ELk?= =?us-ascii?Q?i6oCrBZaqp5GY2DssRKI+sm4BQJSiODGXijLmk8V8pCK8bxgPwHSefJs19QM?= =?us-ascii?Q?CqzrrSBNSfe75u/Pz0QVYclHq2UculU0HkjAUmD8tEca6Bc2OMjlv7QFnCCN?= =?us-ascii?Q?yP+nTyhzr5YUdkJ4gkmMf91nl9k2ReiMmC+nI/CkHjqNgavMXCAD2aqPcdWf?= =?us-ascii?Q?tcanAYwpX/CAOHuYHkLAso6ZSRR5gQrFgN1IV3TjIKm89B52IsRXiL4eCKp+?= =?us-ascii?Q?slq/QxMSeNi5JAsjQh5ksVBQbVFZLaNXLNXAXQ5Og/AqQKz/+dES6TZX1H/x?= =?us-ascii?Q?2TR8uEs9WsLu0Nnpmjvcix6sJIT/8d0qynVmNfpV/CGR3V44iPXhwYZOdQfd?= =?us-ascii?Q?hsmexgTzxUiFAFsCbjwgw6DfXvLGC0JNy+lh6stAav645dCxczVgwgDP7zRt?= =?us-ascii?Q?I7cJH4+orr+n0bIq/gpmfUy2O6KWFdGkxhG4+m2rYQP1azSRJ7ftYN/EuD82?= =?us-ascii?Q?OSNg3SLrGbzaWwjDcreiiDLitWyKGmcN5lTOsXzarMBP/ZnLTrBttGVnKNlx?= =?us-ascii?Q?Hv3eWL5tH+q4k7izkIxwyFkjTNxITr1J7P9n41MDhoYOvpkWqzLM0lFrmha+?= =?us-ascii?Q?hViK5ufgqDxfZnA9R8xdUmlKeMMc1Cgk92M70sk3xKTd+fXTc0mDk2LD+HHf?= =?us-ascii?Q?1duNRyvl5i1uz1kZJBI20hjI7BbG82jt6rv2+2P1TqqOs/kz3uy38F6grXIJ?= =?us-ascii?Q?a0BqPWAb+lUGKRxf6qk0cFZFOGhxYd3DFaMDdMULtKyqr/S67bX6zheSPFHW?= =?us-ascii?Q?zotrY7V0Yvkb7E9Zk8fPJ0zNLoeOUHlTdc7Gb+GydjFGyQEAEIkJ0HEqYRdH?= =?us-ascii?Q?2MTnCMwdClEq+E4anTgZnsxwqhf5Y0LMfg0WXYT82qYi8jjfCJrhayXJJG8w?= =?us-ascii?Q?q8nVDvpxKDduNj2zYv7epqAYzizGGQuEpR/MDYktKYEPBttis//5jow+qOnN?= =?us-ascii?Q?7RQEFLffBia+f8S4OC1CkHLat6Y8?= 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)(1800799024)(376014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: lCjKOHqzrYu9VyEdKx2NiaCvIuhugxNPz2bgfgYDzxa71Pazw0BGbrw+DDsDUyYA0vDy5Uu54/Is+sHYbTfUTfxc/tyMhFyPUFBKY+6URMgK7Xou5vwK9bL1olbMAPBPbTFjhWqUreXaV+4Umq+9I2FwPugnOEz+StLDAfgdcE68C5+ma54jqufoG9zPwuOOadG9HyqAWbZyTKPo1PSO/Xsq7Q/W7j0LzUbKN7ZNQy4qc+oe4TZT8+1bvmQFUgU103YzhDJmDVltHd5oU3n+L3zfl2nvFxaG3+b0WWNLWuPtQRVvDKnq8hliJ96OUT9kYExrJjzF8KblRpyDMPAFLt4oXR9r9vJew4AAFjnMdgTLG+dK/iJOGd2TehyogV7AVMEpiSEvO2m5IE1Pt8GXDTXYn2ldANcrMzuOS2kG2rY426mW9Yab21XLW7155sX13OjHDeG12SQ/u1ZuAXUGHSU9183J94SAgZ0azg17htHnzo+hoZuaX+MvXIaH0aV+iY8MJ6rOP6bwkEuWQ4/3RPNMBlmVgV8iLG4R0TsfytD3om1RgFGvrWF+RHzOsvOwizgAeDF0dbxsLCBJxSFEqtgZ8FRy2N5pK8KC8Z+W+S1xZXPEMu49iB86UhDwMOtirhgFHoWa5NafkSRSuqAWheC7ysXGaImbQUUbnT5Fzfc= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2024 14:14:49.1860 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2a317f1c-f337-4efa-0461-08dce935e6d2 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: DU6PEPF0000B61B.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1P190MB1993 X-BESS-ID: 1728569693-305168-12634-25882-2 X-BESS-VER: 2019.1_20241004.2057 X-BESS-Apparent-Source-IP: 104.47.30.107 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmYWhpZAVgZQ0MwgxdTUPMUyMT k5KS3NIsXYwtLY0Dg1LdnQMC3J3DhVqTYWANFUsFNBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259630 [from cloudscan22-12.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 --- v3 * Remove newline characters from logs. --- 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 aaa79ebe05..984450afdc 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 2e11ca9a29..93ea09afd7 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", __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