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 CC44745509; Thu, 27 Jun 2024 09:40:01 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 634D640DCE; Thu, 27 Jun 2024 09:39:37 +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 3AA7B40A7D for ; Thu, 27 Jun 2024 09:39:30 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2106.outbound.protection.outlook.com [104.47.18.106]) by mx-outbound11-228.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 27 Jun 2024 07:39:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YOOCHb6WfX6x28tekJKPUGE8EKWHFGdZ9/Jr/2e4p6zK8NcFkwAzZjxbEYqWs0z/IC63qaU5/1r7pqFx3nFc14vmC/ZydqF61ro1SGgt0qN5LUT6Z7KNLQCu3gbhSRRv6G4qCjIXKwoNhPcn8WpsDwjHxC3jrXXtZt5fA8MwtCZA/BUJl+vDvGiewwNCM+Ol/ERGZR1u3URSuuB1eQRVXzyRKtL9gUc++col5XD2m+dn2ExDUStRhz8IGjbptIaUaNGsOrnl5RU81hFCGFAfVmPdZVR9KG6Gi3L0/9SD0SKVOIbKGctWOGvOeq4ay9O8LbjIrXM0949QqYBFjQiFjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=i6SguDCJE+L/td/o5dFQ7vY7vNVKfNmTgBGdIN78gQU=; b=EyWjvS7oCPnRqXwLhyqNE67P4s3RF8RRaxOlXeDzDOqygZ8cBXLcm6lEEYoY+YMC3FdCj2Rv6WgSQxvASH9vooiwObRRm2xG7hjJY7/fUUWB5kpaXgL9BFkMlFrijRutPbaAWbuuu76S2ef8gyUicK4l2e2oXdpxltMrZ8ZvmH00/J/G/RLZwZhtGjGrKtQGRDu+78kGKp5z5pjJHJ3D1tiuTYP9OWOYSlEwGaPGRZTES86xiMzUu/plMJgMnOc/z66jj0pmufw23gG4xqN7wuylaT0kpkW3P57I6+mGss4lgy3nP6QwjpVimO4YCR9ybUwpINt6AI4oWhFO3s1/2w== 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=i6SguDCJE+L/td/o5dFQ7vY7vNVKfNmTgBGdIN78gQU=; b=gpxd3OmUG57PnDxUF9gHq4P+FZbgJRLa2ziZu+PctxX6u0TKqGRm2meE2lLyv+5mR9pK3jT+unnXjB9JUJyJGv51R0LRtgXVYSjRgBnE3tFjBRAla2qBOpbKJ+PT1F0AbzkHoDYf1IOE8aIhyrCkC33T9xZmMvb1RUV7nWLfiYo= Received: from DUZPR01CA0336.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b8::21) by AS4P190MB2021.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:519::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.32; Thu, 27 Jun 2024 07:39:25 +0000 Received: from DB1PEPF000509E2.eurprd03.prod.outlook.com (2603:10a6:10:4b8:cafe::21) by DUZPR01CA0336.outlook.office365.com (2603:10a6:10:4b8::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.25 via Frontend Transport; Thu, 27 Jun 2024 07:39: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 DB1PEPF000509E2.mail.protection.outlook.com (10.167.242.52) with Microsoft SMTP Server id 15.20.7677.15 via Frontend Transport; Thu, 27 Jun 2024 07:39: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 Subject: [PATCH v5 04/23] net/ntnic: add NT utilities implementation Date: Thu, 27 Jun 2024 09:38:45 +0200 Message-ID: <20240627073918.2039719-4-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240627073918.2039719-1-sil-plv@napatech.com> References: <20240530144929.4127931-1-sil-plv@napatech.com> <20240627073918.2039719-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB1PEPF000509E2:EE_|AS4P190MB2021:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 47bbb8e0-224d-41e6-3477-08dc967c44c5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|376014|36860700013; X-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?Q?z/PXtGjyBIikbW1XlueoJoNklIvPLFcIIXlU16I6q4arLQzd4WrKIL1tAeYY?= =?us-ascii?Q?1RXk537+7iJ7lJSPA1lDUgqPy4ad87ruWXY7ExbjTsLPYFiHBJ3L9QNFtDSi?= =?us-ascii?Q?eOBlWXwPdA3QAUDZyUSDN1S68I4iPfaPUkBZ5GIg2szsEecmP9TWiBR0k8P8?= =?us-ascii?Q?bivOe1e7CkJD8OdyHeTWRJH7xLW96dAS95owFDjY8mfTsjACUF8V6SuPNR/c?= =?us-ascii?Q?vgIZmMz4mxGN60IyYDJCDjg56FMA1NPy5W3tI/HdZRQ5SaPpOJUgsH05g2F9?= =?us-ascii?Q?CZBLBNVUolCOr43HNgwXExwT3FrJSK4V9TCZuQQzHxTjRcPs5jIlg4YgtKFg?= =?us-ascii?Q?X1urc1Q58ikznw/xbuG9tyF+FtLfBQgIqJlYRhrRs22BohPStkK/i57IsFGD?= =?us-ascii?Q?GZFhg+sImwUgsKb9+eJ0wQf6s3UlVHfqn6xyQVW68h5Aojm8/KVHKrkCHBgJ?= =?us-ascii?Q?wHu8FBTNugVQwtmPDvTU064i//8YRvL2CBS6Ly5PzobQcQnEBIQCNGVvLOnA?= =?us-ascii?Q?VKn1ttAGPEujW1AbDBZ1LL+OMOw7Hf+77dLRI+bolgjj09eHVbqH6CrcmgU9?= =?us-ascii?Q?dugFZlzJhzbCveEt1eF7vx5owecs6/o7?= 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)(82310400026)(376014)(36860700013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 6y79NaNyJaB2qytux1XzIRiYnLJTZ8W+plieSDEpdNmha0gTZTci7xaW/bUxwTUHJAaGxHWq8j5VkfuCpsNZ+DadkoAdqS6MQr/9GEqX4xoALYtvRynJFt+7yNnqFBmdTdDCrhWXM4Y8HEC8fHF2pZXURHjMB92uGzU1Vtft268RrXETG9NX85+erCYjC3JaxDGn6TbNrGq5ZXsgmIBWIyTrqMuDFWsq6zsDPAjkWsjA6Cio6hwj3Pjt/CrytjpTqbA/cBryvaeZTS0hwzIlbVvtZ0IQcFsOw0BAiQw45+r3nFdxFqRdglBDNu529GzmbwQS3vPQ/eTM+2xdtooV7ts8Mk+SAxayixDn0inY4dkOUSobLzCnfRWYLhsU1yrw/Bp1jIq/yi6GcdXQwPQ0NkMrxYIfzCmcDkEIM3EUs4VaDIkr97O20JEoSZMHGXW69tQ9qfB2EZV00J/JnnViF1M+nglAS2x/5+fogjoTsgKRF7MBRiPJUTHv2YLIR/M4jKss+x3Jmvcb6H4LxDK6LI22upxoT4iPri8pTRxHQyO+MqEK0RCSf43S2BXIKFJ5LTcRMXxEwiy5MFACRySqyaukmGy4gSExlm6L8Bx3jywx+Qhp0idON2Kl2NN3yP/8BOKyOaEqbb8Qs60Qv8LIRg== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2024 07:39:25.0841 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 47bbb8e0-224d-41e6-3477-08dc967c44c5 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: DB1PEPF000509E2.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4P190MB2021 X-BESS-ID: 1719473967-303044-12647-2694-2 X-BESS-VER: 2019.1_20240620.2317 X-BESS-Apparent-Source-IP: 104.47.18.106 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVsZGlmZAVgZQMMnQ0DzRxCLFPC U12cIoxdjcNNHM1NTCxCzJxCTV3MRYqTYWAAsaMc9BAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.257231 [from cloudscan14-182.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 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/include/nt_util.h | 28 ++++++++++++++++++ drivers/net/ntnic/ntutil/nt_util.c | 33 ++++++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 drivers/net/ntnic/ntutil/include/nt_util.h create mode 100644 drivers/net/ntnic/ntutil/nt_util.c diff --git a/drivers/net/ntnic/meson.build b/drivers/net/ntnic/meson.build index b1ba8a860f..d364cf8621 100644 --- a/drivers/net/ntnic/meson.build +++ b/drivers/net/ntnic/meson.build @@ -16,11 +16,13 @@ cflags += [ includes = [ include_directories('.'), include_directories('ntlog/include'), + include_directories('ntutil/include'), ] # all sources sources = files( 'ntlog/ntlog.c', + 'ntutil/nt_util.c', 'ntnic_ethdev.c', ) # END diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c index e9a584877f..c9726343a1 100644 --- a/drivers/net/ntnic/ntnic_ethdev.c +++ b/drivers/net/ntnic/ntnic_ethdev.c @@ -14,6 +14,8 @@ #include "ntlog.h" +#include "nt_util.h" + /* Global static variables: */ static int diff --git a/drivers/net/ntnic/ntutil/include/nt_util.h b/drivers/net/ntnic/ntutil/include/nt_util.h new file mode 100644 index 0000000000..3c7b6cfce4 --- /dev/null +++ b/drivers/net/ntnic/ntutil/include/nt_util.h @@ -0,0 +1,28 @@ +/* + * 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); + + +#endif /* NTOSS_SYSTEM_NT_UTIL_H */ 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); +} -- 2.45.0