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 1AD0F4560F; Fri, 12 Jul 2024 11:48:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5C48642EC6; Fri, 12 Jul 2024 11:48:46 +0200 (CEST) Received: from egress-ip11a.ess.de.barracuda.com (egress-ip11a.ess.de.barracuda.com [18.184.203.234]) by mails.dpdk.org (Postfix) with ESMTP id D29524042C for ; Fri, 12 Jul 2024 11:48:42 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2104.outbound.protection.outlook.com [104.47.17.104]) by mx-outbound8-179.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 12 Jul 2024 09:48:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J83WX1tmX0gvIj6Qt/izOv8t+bwaPmTJvHj/z2BZdsrpgQJYZSyrsN2cUGcf09ithJNoqYMGpcVWX/Q1SWT9LQvzNEFXrBM3e4qAGvnGqV6iV1SkwU2Tay8ku07pNEtBBy4NpbVm7ZaFhzrhs3tC3bCddYX5Y3qDrJdp+F3upNx4G/E/J1yaO7B3ekJ7U8TUdTCChnqR08GXhDXgPpeQgxM3tXXeYkM/rZtcII64a7XKMcGQ/hQgGSEv3UygMYhtv7kZg9SoaiHX3YaVgNacgDJdTeHMHqVdQxvrFDu+kKb/B/VEA/EmHUOWYfKr9q7oeazTojj7DHvUfJDMSJThCA== 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=vvmpNrzKATimuAcYRh46m2YhAFOhS+G4OvDMbcks65Y=; b=FElWtOiiLvCgAW2/v93KkW5QMtLYxidl6Euvm1+615Sy/0FJexBBN6GYzvEnC2Yjc+f9/eTQOFy9VkgOVOip2eWtgWEV+rkXW/WhAOo7q3tXo15By+C5rPEAmRnhRdBsJkmnHZPTU21rRUcsPjJPs6ImOlOJpGvY8fzvokoWvG3pta/To3xWSJ8G+K11kVoudXpGIGHojztNsA81cvJFzvHX86fG6N1r8hskCpYf+VTrMFIp774PRwhnxfphk/YbHP4w6NODt8fm8stFX1lEdwov59qLNivf1B4e9k7HEqqIWT98JscqO2DLJEuAXkY/ke63whd6O831cR9yldsbEg== 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=vvmpNrzKATimuAcYRh46m2YhAFOhS+G4OvDMbcks65Y=; b=YTcbyPRouGnIXaUXQYonr9Wd2gYfn0w+6kE9YAP8WpmXpYGcofeykecJf4cirbHRyop94mCm8BldU0vuVX9dDcMerL84iIjlpqXRZ1Kul4WGJpfmoVtojTZEr0yzef8dwKBF5H+PNEB+4zXb7UhIlFJYuI6aVG9gc68aqiPrXOE= Received: from AS9PR06CA0516.eurprd06.prod.outlook.com (2603:10a6:20b:49d::10) by GVXP190MB2115.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:1b1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.37; Fri, 12 Jul 2024 09:48:38 +0000 Received: from AM1PEPF000252DD.eurprd07.prod.outlook.com (2603:10a6:20b:49d:cafe::e2) by AS9PR06CA0516.outlook.office365.com (2603:10a6:20b:49d::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.23 via Frontend Transport; Fri, 12 Jul 2024 09:48:38 +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 AM1PEPF000252DD.mail.protection.outlook.com (10.167.16.55) with Microsoft SMTP Server id 15.20.7762.17 via Frontend Transport; Fri, 12 Jul 2024 09:48:37 +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 Subject: [PATCH v7 04/21] net/ntnic: add NT utilities implementation Date: Fri, 12 Jul 2024 11:48:09 +0200 Message-ID: <20240712094831.861260-4-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240712094831.861260-1-sil-plv@napatech.com> References: <20240530144929.4127931-1-sil-plv@napatech.com> <20240712094831.861260-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM1PEPF000252DD:EE_|GVXP190MB2115:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 42d2be5c-643d-426e-658e-08dca257cdf9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?n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wVA/yA3aNFEeGW2JYmHdl?= =?us-ascii?Q?qsn1Y4WM60RQrPz8c9KyfmFv4B7exjn8Przb4KhMZDct9r5JAwVHasid0lQh?= =?us-ascii?Q?hUQjsO+MO7g83nkMIacVEiqRIx/XJtmJr10L+KaNRUYwSMPaUgHg/LF7Jk16?= =?us-ascii?Q?3rWGS0NMaRUe7WukhXGIbbAeDPieh7dWWGrkcrAUX2S90W05mZLXTRtJe9hf?= =?us-ascii?Q?178i9s7TmL9JzkBRZS69FTI1MNDXgwSA7K0Yb1kkHSBTuOqAV+aYXcNL7WpQ?= =?us-ascii?Q?tE9qynmD3cMcM6LAPcVK8X23rKwvSHrTiFGWRrOnX2yo8flKLmzZLEL6xGiU?= =?us-ascii?Q?PqtwYd09HyHxqxuJB0b84IeozoZj/jFtQtqzzPbwbawrdLm4jxWOgLo3OysD?= =?us-ascii?Q?8LERTFX2agcPwkmxECYLr5yuvpZ133fgL9j5V5ZtMbjBi0frB3DKkM2uVWnV?= =?us-ascii?Q?ZL3dO8zZ/cWIiW7l2A9D9CvEViYd1fCMMgDP8tJ6I1BwjnlGgAU+vRnubia0?= =?us-ascii?Q?VmrIyG4o92UmyfwlMf6Ua78Ebv2wcwuaR/yDnobGH21lCIz4rypF6OI6KLv0?= =?us-ascii?Q?RzCek1K0T5D03K71nqnbLqpKeckU6NDa?= 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)(1800799024)(376014)(36860700013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: opfrgfy1K7FENyVybGYgMHl1txjZ7nMzH1d6WXKsDEo3Vjp+ezOWyLdBlXQKempIwl8OAGvy2j5aHTUgYfAhcLbsA1z8SP0/qWAUv614I8+fh196OpBRbGLL4cdwByy5a+RY+Y7m5rFrdX5/vpJPyGWSW5HTGBjQktVucewsw+NwZ+kq5hnaaXk9PW5W8Y/FtQwRXa0/j6Jg0Ug2i5g3GqEgNadLYKlLfPTx3RS5HedU3ixzpRaKxc3llqNOjlGZtCtl2My5S2CulzrFIVYuM3QdekRSXpOq8lSA2Y6+IWqvmg98qKkKrhAPEfl4fr8L/WeS1AVlwayqguWKaY130Z3zdTkG6PG/jIkscRhmEi+7SLdBZbH80QuCTuGUjxikBglrzWYvzl/GAtGaEUno1WkzfFcrUvSzF93MkNgSUvMZuP/g+fPIDa+7lLF4fyoG9pFmOiu/rKslZQWew+Pg50SHDG188L8ipZZcYa8ZrHVfQBZpC7b9gt2IwkXlFrVJoNGpAMVhfjb53MUI9gC/HsshQq0n84NboZfioqD/yKybEBO4O3PIsLQRN1zJVedQy53dWbrgaAq3xpjMv4BoB3w9DfRd/6mOd8vJ5VLAayMwh1OOgJpn2YfpJd8rgLL17QgHAEvww6vPrnzg2RFGSQ== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2024 09:48:37.9889 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 42d2be5c-643d-426e-658e-08dca257cdf9 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: AM1PEPF000252DD.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXP190MB2115 X-BESS-ID: 1720777721-302227-12701-8268-1 X-BESS-VER: 2019.1_20240702.1505 X-BESS-Apparent-Source-IP: 104.47.17.104 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVsbmhsZAVgZQMMXIwMDA2CgxMd XENC3JyCjVwsDQyMAwMSXZyDjNJNFMqTYWANhgvCJBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.257571 [from cloudscan15-209.eu-central-1a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE7568M META: Custom Rule 7568M 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.50 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_RULE7568M, 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 Add ntnic utilities. Signed-off-by: Serhii Iliushyk --- drivers/net/ntnic/meson.build | 2 ++ drivers/net/ntnic/ntnic_ethdev.c | 2 ++ drivers/net/ntnic/ntutil/nt_util.c | 33 +++++++++++++++++++++++ drivers/net/ntnic/ntutil/nt_util.h | 43 ++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 drivers/net/ntnic/ntutil/nt_util.c create mode 100644 drivers/net/ntnic/ntutil/nt_util.h diff --git a/drivers/net/ntnic/meson.build b/drivers/net/ntnic/meson.build index 80f0f3eecf..c7f5a4efc7 100644 --- a/drivers/net/ntnic/meson.build +++ b/drivers/net/ntnic/meson.build @@ -11,10 +11,12 @@ endif includes = [ include_directories('.'), include_directories('ntlog'), + include_directories('ntutil'), ] # all sources sources = files( 'ntlog/ntlog.c', + 'ntutil/nt_util.c', 'ntnic_ethdev.c', ) diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c index a744f78adb..26700eba6c 100644 --- a/drivers/net/ntnic/ntnic_ethdev.c +++ b/drivers/net/ntnic/ntnic_ethdev.c @@ -10,6 +10,8 @@ #include "ntlog.h" +#include "nt_util.h" + static const struct rte_pci_id nthw_pci_id_map[] = { { .vendor_id = 0, diff --git a/drivers/net/ntnic/ntutil/nt_util.c b/drivers/net/ntnic/ntutil/nt_util.c new file mode 100644 index 0000000000..5395bf6993 --- /dev/null +++ b/drivers/net/ntnic/ntutil/nt_util.c @@ -0,0 +1,33 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include "ntlog.h" +#include "nt_util.h" + +/* uses usleep which schedules out the calling thread */ +void nt_os_wait_usec(int val) +{ + rte_delay_us_sleep(val); +} + +uint64_t nt_os_get_time_monotonic_counter(void) +{ + return rte_get_timer_cycles(); +} + +/* Allocation size matching minimum alignment of specified size */ +uint64_t nt_util_align_size(uint64_t size) +{ + return 1 << rte_log2_u64(size); +} diff --git a/drivers/net/ntnic/ntutil/nt_util.h b/drivers/net/ntnic/ntutil/nt_util.h new file mode 100644 index 0000000000..6dfd7428e1 --- /dev/null +++ b/drivers/net/ntnic/ntutil/nt_util.h @@ -0,0 +1,43 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#ifndef NTOSS_SYSTEM_NT_UTIL_H +#define NTOSS_SYSTEM_NT_UTIL_H + +#include + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(arr) RTE_DIM(arr) +#endif + +#define PCIIDENT_TO_DOMAIN(pci_ident) ((uint16_t)(((unsigned int)(pci_ident) >> 16) & 0xFFFFU)) +#define PCIIDENT_TO_BUSNR(pci_ident) ((uint8_t)(((unsigned int)(pci_ident) >> 8) & 0xFFU)) +#define PCIIDENT_TO_DEVNR(pci_ident) ((uint8_t)(((unsigned int)(pci_ident) >> 3) & 0x1FU)) +#define PCIIDENT_TO_FUNCNR(pci_ident) ((uint8_t)(((unsigned int)(pci_ident) >> 0) & 0x7U)) +#define PCIIDENT_PRINT_STR "%04x:%02x:%02x.%x" +#define BDF_TO_PCIIDENT(dom, bus, dev, fnc) (((dom) << 16) | ((bus) << 8) | ((dev) << 3) | (fnc)) + +uint64_t nt_os_get_time_monotonic_counter(void); +void nt_os_wait_usec(int val); + +uint64_t nt_util_align_size(uint64_t size); + +struct nt_dma_s { + uint64_t iova; + uint64_t addr; + uint64_t size; +}; + +struct nt_dma_s *nt_dma_alloc(uint64_t size, uint64_t align, int numa); +void nt_dma_free(struct nt_dma_s *vfio_addr); + +struct nt_util_vfio_impl { + int (*vfio_dma_map)(int vf_num, void *virt_addr, uint64_t *iova_addr, uint64_t size); + int (*vfio_dma_unmap)(int vf_num, void *virt_addr, uint64_t iova_addr, uint64_t size); +}; + +void nt_util_vfio_init(struct nt_util_vfio_impl *impl); + +#endif /* NTOSS_SYSTEM_NT_UTIL_H */ -- 2.45.0