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 4D17E455F3; Thu, 11 Jul 2024 14:08:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E1DA342E6A; Thu, 11 Jul 2024 14:07:54 +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 98AE142E5A for ; Thu, 11 Jul 2024 14:07:52 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2104.outbound.protection.outlook.com [104.47.17.104]) by mx-outbound41-230.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 11 Jul 2024 12:07:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=keZLdtlaE80mMdqLlsS3ngxK1H5EFs9k1lWdorgfdlCRuMaICpoAiCSO2MK2ZiU9vjmA5wRvhh9fbR8OfnaGhI3qiZ1fJMTgh4MmnzvHZ69kDfX2jw9m6+37sXszwImsNY5owWq7HZOdLonUHCNmj0Hy/nfk/3jLLPcNW8sz2w0LRQZveHqxKF9DLqoq6mAAhBpnbFlaf6clrj5jfcsDLMjwVdDk5IhLSZ+tq4YbWTbyrYPHlsCshju9KJtPntRy27HzyIJveoJyhJjeAZoj4j1iFZIfOvazhEvJZBEDoGsyLVftah00ulLGzlgP/88rsUlBw9utY70I0c8lKtz9Rg== 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=3vDWGpLMIzjIQAfJiCRZ7/GVVED1Za/KHuSVwMJiRqY=; b=iv4rGhY79pe/JXMdVmLG9KDVPcJz74YvltalDDlGlIHCo0Kg5IFNKhYF1SykQj3yYuDWSOD7zMEICg7+92yXvKVtoYqRuPGBoAFW9IxceO6p/eSgkGaEkQv4cMfbWP3kho9e/QpID/e4xfawiS938H12w+LcLrK4JdCZMXQoUxyYWlubinbwE/CqKxWpT0pqSGVrRgIWxaNTHo1tB9j/r4D5M4NH6PwKxW0kpA9F6ziR41Km09aEg5T/xMjIn7S+67YY3MwWlnGgOTtkRx5DeLdSXD8K/v2y7znNQbVc3Z//XMLE25/0NK9EcN6gqSHWJKrKE+ELIzdtl7WIcV4m0w== 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=3vDWGpLMIzjIQAfJiCRZ7/GVVED1Za/KHuSVwMJiRqY=; b=OlXOjgJWaowICdrZ0mVH7C51HPtuB2qaPWY+iqphvjLb6wFc0oZz0DPzsYnaRedJNx07wCfGsXAzwh/NqUqPXaQVSYpZ5NHBR9E92S6d6ENctsWUnSfng3yry+GZ+XlPoACAJxfradI4sfrHrkA3q6cXF+qwzCwoalxjYxL2QWE= Received: from AS9PR04CA0103.eurprd04.prod.outlook.com (2603:10a6:20b:50e::14) by PRAP190MB1713.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:29b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.22; Thu, 11 Jul 2024 12:07:46 +0000 Received: from AMS0EPF0000019F.eurprd05.prod.outlook.com (2603:10a6:20b:50e:cafe::ea) by AS9PR04CA0103.outlook.office365.com (2603:10a6:20b:50e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.22 via Frontend Transport; Thu, 11 Jul 2024 12:07:46 +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 AMS0EPF0000019F.mail.protection.outlook.com (10.167.16.251) with Microsoft SMTP Server id 15.20.7762.17 via Frontend Transport; Thu, 11 Jul 2024 12:07:46 +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 v6 04/21] net/ntnic: add NT utilities implementation Date: Thu, 11 Jul 2024 14:07:15 +0200 Message-ID: <20240711120737.698176-4-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240711120737.698176-1-sil-plv@napatech.com> References: <20240530144929.4127931-1-sil-plv@napatech.com> <20240711120737.698176-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF0000019F:EE_|PRAP190MB1713:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: c64d2639-f3bf-41e0-32a9-08dca1a2138e 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-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OlDuHUmf0WIT6hZDAZUHd8BOHEcZQ?= =?us-ascii?Q?nTzLx2hmkk+E8QhijJ10Kp77muP8IG8BBJOsRwRj5HD3GN1uiyJa09A5GLAB?= =?us-ascii?Q?G0DmhJUia6fk2hWmh3mJWO8VHzI6hdjui87wglPZcYCVv/XUEAfgCRDlUfo+?= =?us-ascii?Q?6dmUTFMFtjKUpXBzBki2jfcxbvh3HK4RLtf9wdbswkF/WX2MDXACSMPJTywg?= =?us-ascii?Q?yuzkyGgpT2FOwRboEWZRif2COibShSDbrxeKg96cG/xdybVFOPqmSFOOmqfq?= =?us-ascii?Q?LYAmjUn6eZGl8j79SrI08/nIiE20hTXt6mZ1A4rWYSlZZ+elxhExgy8TH/qh?= =?us-ascii?Q?vafoXIV9U4LGSqpel+Dxr4ZxPfPV2ySXLeT41OBjsjYXcp+a+3H0xUdDwdkq?= =?us-ascii?Q?c5cK0WyDSmlSNrNQc9DOkmkfw1zGSGcGduhPu2y6QFRiypGg8XnnTQwpMg4t?= =?us-ascii?Q?WHCU3lEtPFLFplXYRbpQW629gy6W5fBTHNIK66m88AuCgE3DHx8hbHaerIX0?= =?us-ascii?Q?1XuIBAUG+FGl+DTWqZMtlGGMPhzLKH3gO2bHNj7Pe2CPN8wuHwaCAuOZDBkS?= =?us-ascii?Q?18hRf5ET1r58eplou1jeKXtTL19bi/WV?= 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: rEcVSwlzhNx+OYKhXMy/TqjZ+OJNpJVeAA3YGAZRFRWttyUKHQbpWZZqlG36ak63rOb9OeWmm5WMt4XByUV4VMe34tKcrV4TFMfzB8cD5Xld8iv6VvdfchBYCs9+pr6ZJUm5or0aziMfqpYNNp6S5kos/aY2xEYPerLE0obkRF4R4wqXgZlAFXqq8/8fTlMHaTAOb3LyuJrhPlhp7SyBKe+ZlHHmfFBeIxOiR9h38azQ0PfDh+HaGFMSYFy9nqSMOLyaTCZGx4WkbS6azNCQMf/tmhO7PYeH4/39orr9jTUFhl6+Gf8+rpfmLe9nDpmXpgkjLRe0o7FqPS1qi544UExbp7gXfRmid+n9oGctBbeV6Dv9PMdyWF6PSuu1+RN0ewZ3/ESm+AloAD2iS7hE0d59idSS2pyceYf7Vd6Z4n/3AKd39yq2HI+B7OjMB3OsIVbXK0qhohZySOZCUNr9VeDA1pNyypIazygcRVIgLhimVxzQno+gQ6jvkmEkXUwJtVYYXRZqG9logItvFg8TNAQAl7mwNWRFk8V9wjUxIQk3YIfTqE7yRlUwwAWUN/hy4ZPaECCHqMIvVljt1ZgY4tdEp4MfUC73Z6RVc02Axi47X/Pjw9uEvKnAyDxe2dB+dHpDK9xlbAjTBGfxa9PmU02MOt/YCwk9sksp019kKe8= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2024 12:07:46.3221 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c64d2639-f3bf-41e0-32a9-08dca1a2138e 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: AMS0EPF0000019F.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PRAP190MB1713 X-BESS-ID: 1720699671-310726-12654-23688-1 X-BESS-VER: 2019.1_20240702.1505 X-BESS-Apparent-Source-IP: 104.47.17.104 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVsbmpsZAVgZQ0MDEOMU8KdXCMM XC3CA1zdDY0NIkNc3UJMUw2cjS1NxAqTYWAN54/7lBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.257551 [from cloudscan21-175.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 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