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 2BFB045628; Tue, 16 Jul 2024 14:02:28 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DAD6140A71; Tue, 16 Jul 2024 14:02:27 +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 A7473402AD for ; Tue, 16 Jul 2024 14:02:25 +0200 (CEST) Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02lp2040.outbound.protection.outlook.com [104.47.11.40]) by mx-outbound46-60.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 16 Jul 2024 12:02:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yIKPcs1qtOMI4weezTePhC74URln2zMCoHKbsO8YTvrzH9iPLBlm3WE29TfVk52hdl3vUKuhynkGJWZFDtSlVIVoX2ZIEdAeVwBSENPxirCTtFYdPXbBBvpzNl7HKTmyw0qzRwuz90UMFBcs1Kdw7YIlBRlHjCRWcVPQwrltKiqYqam5r7oIPYcXfiUa2rLiLJm1aCe+3w/m55pmi0B716UjIvBkaz95OH28oYABchJfRrUzVUAbrvfg8TlE0GIvsOVzoCXums/4bMmg94Bs6U+nmt+Pg2jahBpWfSrcloajoGGFWluziuNRnnmBdXiA/he9h9pXWtFaLsd3vM6KZg== 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=R1cR1EujMHQqHpCQ41aQqTDx0j9vIAxgfUmUTDEVAbU=; b=jClMwNJ2RUHoV0hKTH8Z9kpM16u5x47az9vErsS0bTsaKmgNPRh1+Ij5Bbz1KUMheJT8j/LerLBuAxoDOfq7z/CzxSAu2IL1eQyPMg/p/wfgzRxEGhFFk0VNd6/hq4+GBFHW4NrprWmnbk2oSK53mapP2FN7TcXvAMfDQoUaAWe+L4MNjRikWyANa/PUXruiRNsJ0jGEI9f4TqX2G4t2l5zOm2IU8A4hp8GwTWIQr8h3AWQMIfmwFzlD0uxD6AZ5jVBFEq1eIxRmSHB+Jk9h6nyFbyzgrjLEi6OWpc73p/ebpF0e/Pun6fgWor2lxzlm1vp2rokgTCY8D+VbuE0log== 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=R1cR1EujMHQqHpCQ41aQqTDx0j9vIAxgfUmUTDEVAbU=; b=n7dVFmO/+CE7P31JbbGxO60i79I9mo2BENoFItCMq2xpdgBfIT0QghOZSgccXpWpCn82UxWOhPWaQDboMS4/GP2SfQpDegJcGoNuNw5f9bmAVo97IyNFFs6dGj3+pBSAWkXQ3f2eC/4f2aD9PHrDRIZfZC7JM2bD4GwzcxFDXtg= Received: from DU7P195CA0016.EURP195.PROD.OUTLOOK.COM (2603:10a6:10:54d::23) by DB9P190MB1148.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:220::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.23; Tue, 16 Jul 2024 12:02:22 +0000 Received: from DU6PEPF0000A7DD.eurprd02.prod.outlook.com (2603:10a6:10:54d:cafe::1f) by DU7P195CA0016.outlook.office365.com (2603:10a6:10:54d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.14 via Frontend Transport; Tue, 16 Jul 2024 12:02:22 +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 DU6PEPF0000A7DD.mail.protection.outlook.com (10.167.8.37) with Microsoft SMTP Server id 15.20.7784.11 via Frontend Transport; Tue, 16 Jul 2024 12:02:22 +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 v9 04/21] net/ntnic: add NT utilities implementation Date: Tue, 16 Jul 2024 14:01:53 +0200 Message-ID: <20240716120216.3032484-4-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240716120216.3032484-1-sil-plv@napatech.com> References: <20240530144929.4127931-1-sil-plv@napatech.com> <20240716120216.3032484-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU6PEPF0000A7DD:EE_|DB9P190MB1148:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 3db7981e-eaef-49bd-5b11-08dca58f26b2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Ant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L5sSI7ZWXxLvGU15YORLE7NzfSJsG65orFay1Xu7gdigMed?= =?us-ascii?Q?bLJKZ5fppl0bprAEePbjInNrdnUuM/M4ggq8Tiwg/3/rXEXa2jQxPXgpOVA4?= =?us-ascii?Q?Ux0qgrP1Nt+7DZrfCejffXQ/5t3F9ar9zPIuzSdYjZe/Hr1MgaArXy5eXvIN?= =?us-ascii?Q?srCnxecMiY3UpDIenh4ZvPTuB0VI3rK+a/l6p7j1Tmap5NgrAlPYgBOHnLdG?= =?us-ascii?Q?LHXP4+82NBDJA4L3kJGiBeL2BeJzor8D1FbgU/jp6M1EVKBDD92HE1obD3ja?= =?us-ascii?Q?thn1fZvFkzDXaRqsn9ofWKH12AY0rwusVWr+r4LviEeWUiQ3HIu/p2pr8ZSM?= =?us-ascii?Q?l3Yb422mZQUw5IoLphMelTGCZ3PLiAeB1kKpnR1f911jWQDrNRLvFm/qUg9J?= =?us-ascii?Q?OYFbTG//LlDhuy/abJ+Krf8qgz9BSrgTCaKwD02vc0WWTHKLEqpE4wtndzLS?= =?us-ascii?Q?Moc9neDj+pqIlJiBORpDG26JWVNjlDjRoS8IK+Jx82VP2v83rK6VNJbasTNl?= =?us-ascii?Q?cj2H1uP4/hC+Ob/qHtq2zpYNvS06wC2GAC3u9uqPtGpVoHJqd+dFV8AfBUof?= =?us-ascii?Q?bJCf27NSWddvGzvMsxP6IWwsbpmI/fLK?= 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: CIGaa/WvecEIuGCekp7LbdB30cy8Y2A+CNH6aTm9u5b6lvikL361uylUaKJqWMYORc5wJP0BaIXt5u7/X+ZDSY4HU2N926Mcurl19CSkd9maXTk4qQnKr4Uf+uVLHRAMzABg1BP2eQ9Dbgg4qSfz8pFynOny0B5H0LjLGmC3AHkuo+FVyujbdRBxoLAhNWTx26H2qoxCTFrlnM0efz6ZIDNEzAcCDexQAX1O58yL+KBx2fK4Kf8X+ZSucuY1pm/uQAOjjuzgA+8NlB2cV1qnLGMSgMNG5aWU94qtwAPla69wLc0DzRcPLXytXaX/P7/Lain/sFCTc5zW1l9mYWZiTTIR9z4CAMz+92R26DzRd8w8bSOD8778grgAgQsDOnbFfqDpAfFQvM5qEhHsmgr5KOtLfs8INw8tEwi9TGHACp7jbjNDLH5qVFQbBPCM2Q4HNQSgCHwg1jZpTNR73Oefxf2SxoK9LrSGiRpZXuHCOuAXyxLDE+Xw5LgsOjQyp3qaJtYQVj8i8GSeJNFNa8KyIPeWyvreFL9VCFw3tcvxfiG78aGgANiogo2Wu2snGf3JzTKh3QkNc8EQZqAmH9jIbQIYdPClM7qXaRaRvUs/8zwVAhkhNEyc3SNbQ8r8PS0QtxIhy1Cx1vxJfCNiCLklhS/Lg04fSgrr0uJzucLSb0w= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2024 12:02:22.5084 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3db7981e-eaef-49bd-5b11-08dca58f26b2 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: DU6PEPF0000A7DD.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P190MB1148 X-BESS-ID: 1721131344-311836-12660-23654-1 X-BESS-VER: 2019.1_20240702.1505 X-BESS-Apparent-Source-IP: 104.47.11.40 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVsbmpsZAVgZQMM3c0CTZ0DwpxT jR2MQ0xdAwzdQk2SwpKckyxSQp2dRUqTYWAF13qxZBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.257662 [from cloudscan16-150.eu-central-1b.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 --- v6 * NT utils header file was moved --- 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 d5983cd0f8..02b55e2780 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