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 7250045501; Wed, 26 Jun 2024 21:56:15 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B288040651; Wed, 26 Jun 2024 21:56:06 +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 BFAAF4026E for ; Wed, 26 Jun 2024 21:56:02 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2169.outbound.protection.outlook.com [104.47.17.169]) by mx-outbound42-4.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 26 Jun 2024 19:56:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mo/nUpoO9pHvxgabytA83LGdEI4tBFXrDgeuBSMPa1cTBG8gaWZf05bNARnB8I+C1elO+7samhqAmzXo0sx/9uivEzIoHRAUcQjUvy3sDfR6s6kmo+eocghVMkyTVvm6qUdXSLBIc2haKNvCrYJRlFvFiQyIrDACrC6aVfog2qZL07uo4L2c/MLsMCXiufQmra28diw1FzpVhPf36LqDUkRTQQ5UjvJOZXcyCD7PlRJS1mGa5/cs5MPvlju1Muy83zzzW2ttxUyOewUi4cdEEEmA/WxKWV8IPQpTdZR3eCtFFnVAit92XNvAVSxqyKrv11IqLGr9bkyI925cXjohCA== 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=jsqqfrbquehcwKIPcdYKzr7NfCI47KhABTU6W+XK3v6ZTHzkGpeEM2PlxnJUCfdudbsWcbtE/WG7Vl37+UbN3nMtALflyyO6Y1uGc698TTzZ7/0T9IJYpluAs8lVtoJ5w9lAk4J9DOHD8w3dLgkiEW3my8J+aRg+nFVcH6HB8aIz/xUe+RIkd6ZyJsoSizh7F3IfpE8IL/prpc0pBbzHhgW+OOFtCZVm7c4vdmvvuvXvZzEGp1UNs6CTJJQLDV37cjZNZAUo8lxxHztyywE2VppevVAFIh5uTDmdz8SNKoiN7ueT828QVGMk3cHHq6tFFtS6ZdZsHqVAZwhVmoWpGg== 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=M2QG0yD6AOEKMf+yKYcAlBm5byXfObdKAK7e5WzO8qkt6ryC58pSAN4XYJ/6cRjHhphZSaB8Mx225fOH7qzRXql3c73cBQsOA/t2sfvO2tHZ6KsXSFnUebSIv4kg8b9EhJCuNPIMRLfhCyX0J1lqGZo9+T+ToUPKpf6U/VycN8g= Received: from AS4P250CA0024.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:5e3::17) by PR3P190MB0876.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:92::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.35; Wed, 26 Jun 2024 19:56:00 +0000 Received: from AMS0EPF000001AC.eurprd05.prod.outlook.com (2603:10a6:20b:5e3:cafe::68) by AS4P250CA0024.outlook.office365.com (2603:10a6:20b:5e3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.22 via Frontend Transport; Wed, 26 Jun 2024 19:56:00 +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 AMS0EPF000001AC.mail.protection.outlook.com (10.167.16.152) with Microsoft SMTP Server id 15.20.7677.15 via Frontend Transport; Wed, 26 Jun 2024 19:55:59 +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 v4 04/23] net/ntnic: add NT utilities implementation Date: Wed, 26 Jun 2024 21:55:14 +0200 Message-ID: <20240626195545.1793419-4-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240626195545.1793419-1-sil-plv@napatech.com> References: <20240530144929.4127931-1-sil-plv@napatech.com> <20240626195545.1793419-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF000001AC:EE_|PR3P190MB0876:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: cc6ecd20-e29c-47de-6c06-08dc961a0071 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230038|1800799022|82310400024|376012|36860700011; X-Microsoft-Antispam-Message-Info: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38jWqZEJ6iRXHPOU?= =?us-ascii?Q?9RPvaYjSLhZc1IhNikfJQtQCyHiQAmG1fAKqPsa0l4Irqk/1As08hfSKe1bW?= =?us-ascii?Q?zCuxlMWSNT+AHKzgCt3VHVnonwGis4910WJpoYehygZsXz+zk5q1d1dgIGkk?= =?us-ascii?Q?7bkBqxU9sqxrs93VwoudTyVbAb4AQk9Fhsk8JiOQgtK9Mm5WtHjCZDQNQWWD?= =?us-ascii?Q?0K3bhKtBvZ5F45eWB1IsYIc9kZi3j25nrpGQ6MZ2n0UOBtpwAxrzXaIUxtVF?= =?us-ascii?Q?ieTDI0uHEBYPnKdIz3D5ymSlqYiuIOX1Z/cdjRPNsc55RPXIf3JGvgu6Eem9?= =?us-ascii?Q?wicBsyxY5QtNe5Nnn+JJTl7ctA3Y2QbIzhKGGf4km0wUKK8wJ1uUBTZtGJ94?= =?us-ascii?Q?tnvQNn6682gfF5NCf9pPR72vK6yTIgW01vCM+ZRpHXKFIsU4IDvBrVRyOAjq?= =?us-ascii?Q?St8WmBsiVCZnaAkrZPI53ibrqegajl3XLfWcwpGoCL0RLz9mxHplUpcWNaBl?= =?us-ascii?Q?ftQk2ff1PylQx5df1BvXCS1uYrFJNjYtGl8HNEmef3X4Ti1RFUlPn5T7Y2r2?= =?us-ascii?Q?qh0PeR4g+lHacBDieFifJXltwwfebNvI?= 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:(13230038)(1800799022)(82310400024)(376012)(36860700011); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: KfoXtGvukxPpRuurTVvY6l9wG81QjJI5Szos/pC14/9tUBmrUDwjNJkUsig5+XzwqWbfTtV/uY0BcbPSZRbXAQ75fP4MJQflptj8osITVlsWU80nogwKICc/w35GalNcitu/dbG4/WxZBD9yPY5GKwyF/YCHIBWxHkqjj3Ktpn4HaKQHzI8D6dhzw+XKjHehdUWtpipqFXXGkHVorP5jfdJsc4g/y0vCdyXvJd9yZGOf/imEp8HlwGG1Kts1UhHE3SfQATR945WB9AJBYnyP0uRK+7l2qHmL9BcsPW0bp917AbxSTgUiiVkdwI/qWIguy+ytPLafbVRD3y2l9eyFdKFSiEFnXk66767n9UUv3COBJYuHTG/mLm7iL5UjWAl6Heug11LCLnWAbyOhNpUl+mb9rN/y2ru8kANLfXehhKeW4WbdUaai5X03IGySDhPTDGUEY3No00DxoDXkt54G9hBOjFJFas1PKik+w4gY+mJkeZ10md0SbHmL5oxcxqxnfY3B9zBDA01OXlT8BtZuaoOAivSpYIrwdC6lV/NXceS3h2+oJQuGMvXaIcvAB0Mo/+Vf8XUBMnaiXeD7WsCCz1rfLXgNCzcKVdZXx5IXbh9wWYz1Q5IscpHjlbFwjWaBKMez0fsEIKpaw0OesZ68lA== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2024 19:55:59.9110 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cc6ecd20-e29c-47de-6c06-08dc961a0071 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: AMS0EPF000001AC.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P190MB0876 X-BESS-ID: 1719431761-310756-12112-19503-1 X-BESS-VER: 2019.1_20240620.2317 X-BESS-Apparent-Source-IP: 104.47.17.169 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.257218 [from cloudscan19-163.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 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