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 3FEA645635; Wed, 17 Jul 2024 15:33:39 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 63DB140E17; Wed, 17 Jul 2024 15:33:26 +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 B18DE40671 for ; Wed, 17 Jul 2024 15:33:21 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2168.outbound.protection.outlook.com [104.47.17.168]) by mx-outbound13-209.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 17 Jul 2024 13:33:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JmPhTE6dLroq4ZMeEL+2iRf0uesqNBQfqU9Y+HMXDjpXdYgSjimcnxwNB+0PMnpaKxMTsUExTRqY4m52l8TMBD1tyEVjfrSrq0fi54kMjzApi6kyuOtKfercsll1uzl0HKUgIejDBIVA+mT5mgvOoOerv8xIBc/+b8MQEEBLiSnfly2ghosXHuAYnyhPuHLxsSgoTAUqbxH8ZoJ5/wqa4fyjQDTxD2yExEBogV99QIuib7Vr5pv7LSFp1PUdX0B1Jti4BdxQtm9wTW0IRm/2oEntm2aehtUTNkSKGYbaPqIjLh/t7Z+DVVgmeVgSs8Z9cMXtVUvP0lOGKmlKP5Pbgg== 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=UdqN5sKseydqwHmITiYLuaEgbtfpwriUdmfobpthXyY=; b=lWgs1erK9ajPOef3TpBSfn27Ye+BGhZpR/mtcH4YHTMrLYj2nVqxmFrRssmDJQcH8s8Z3GNYSfSf6HkIP+Wh6Sx6d4UpU/e3c9joH/Lqlhs5TzblcfhcUIwDW12Jfga2mkWv7D0fy7wPk/hFre4LBF5R+8CZGdMuaqDNFTvRhbuPRaSFB78aBi4Gez8NPRddPoFHotIPlK26SdzJDQeh10JurHoOzSQXeoYgm6ArYDmpgIO+7n1VpimP7hvsZrCwo0pGcLAjCMPO97+4T1sYnVIRpHR7xyqOeoHTAZJpUGGq/BFy7QNby9nk7PJakhfdNT//o2DwFEpWR3ITLhCIYQ== 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=UdqN5sKseydqwHmITiYLuaEgbtfpwriUdmfobpthXyY=; b=KixLkUblgcFh3dKq9UoDS5WTc7agBo1f3TEoXBYnxSfGNMxf6HgrVLFg4RIYK837V7SwRXo1jHZtIq7va6FnzXmIYD+QrJZRatX3stMTXUefhkyotGc0fqfwCHHCxC1vepOCvwxxwKyndAmzjIy5TbOPaBDbPJkeLLyHgymKZKc= Received: from AM0PR04CA0080.eurprd04.prod.outlook.com (2603:10a6:208:be::21) by AM0P190MB0706.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:1a1::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.16; Wed, 17 Jul 2024 13:33:19 +0000 Received: from AM3PEPF0000A799.eurprd04.prod.outlook.com (2603:10a6:208:be:cafe::f0) by AM0PR04CA0080.outlook.office365.com (2603:10a6:208:be::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.16 via Frontend Transport; Wed, 17 Jul 2024 13:33:19 +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 AM3PEPF0000A799.mail.protection.outlook.com (10.167.16.104) with Microsoft SMTP Server id 15.20.7784.11 via Frontend Transport; Wed, 17 Jul 2024 13:33:18 +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 v10 04/21] net/ntnic: add utilities implementation Date: Wed, 17 Jul 2024 15:32:51 +0200 Message-ID: <20240717133313.3104239-4-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240717133313.3104239-1-sil-plv@napatech.com> References: <20240530144929.4127931-1-sil-plv@napatech.com> <20240717133313.3104239-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM3PEPF0000A799:EE_|AM0P190MB0706:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 4bd57cb9-6fd3-4d42-2ca1-08dca6650543 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =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7jkfTbZT7uwAmk+SYoaouDYnoaIzr?= =?us-ascii?Q?NHHhSpuWnaX/uoZIAYlqt2NqNrTx6BOhfmVsL2K2BBxfSc+D1xuXFKYqmQe+?= =?us-ascii?Q?Z4Boi11k2UWNvbK8FfO+CWtLvlwBuwBSnjlsu17piYh6JzQdxFOghvOBtLWH?= =?us-ascii?Q?xgDVJBIBsHRM8UriA/29ouiUSOO6kFyNLQp7jBSFuuJYxxis7a8Jtf+lHuKD?= =?us-ascii?Q?cSdgKNmMaXgf3qCdIbFrINvTLBg8mj8cTnFZalXgBEcHMzNi7+8rOuLR1i2d?= =?us-ascii?Q?cv8KlIVNeYiSiY4kJDs29S0M7tOwcfSvfe4V5hzK3CP6G02NV7rKUp43LgJM?= =?us-ascii?Q?mptkpsl87tcnADAHbef1prmfGp6D/E43VZ5pTv7WCy9EnusgA2n6gnf5+XNw?= =?us-ascii?Q?3Sl0Vki52CKtsr9sBzRpoc5Y22/wmpdP7GsKXsrIZIp6ePqx6YaqJC+3tsU/?= =?us-ascii?Q?jlsfkm4tiCv2kutqVRy4d/BvE6Dvgb7IFYZ5iBUXeIs2K8fbk3ZZKYG0LP6J?= =?us-ascii?Q?lccPwvubL5KIFhWHtk3kgSJz/gYURtqN5rtTqSaIhyHUY1ayBxI5jWjxMJDt?= =?us-ascii?Q?4y0DqflhvZaX3mxWwQuXX5utoMuFytMk?= 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)(376014)(1800799024)(36860700013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: DbSQh34SEl6ZlJGKLxQpJ4VU0ek54TeAeoJw06wbWztqG4+mdcQGtgaJ14FGuqUGbT4Hnb66xSHqByVqf9gB8FkyAY4rp73r3S7wT/qOyyNhxKGa2DL9gy0zlvoYcVPi1sx46OSi7CIO6y1yj3cm3w1pi3bydEBG4kpDmn+Zl702IotUYGAwI1zXkYluAGQWqpz2MHFSLJqgAwLkFsn6Fp1J9UyKtRmL8JgyQjAtIQrYOTVa9d/wkRWIvAnI01OdbekpFJ9Kfys8iVGroPOLXPNxrkDvbMIhgXyt7EQ7qfwAal6QI5SiAEq1TydzH0/9JV51dLVizGm2GOhC7eFUecsAGmnW3tb8U6FNOeOPcZOKvQDZ6BcT7/SKwdYpRriUI4q5i65f84xzy4VFSk09LOcWYDKAWyl53jypKojHJmUdVSyhb5gpRrXVFyT/OsfXjn7Yp8tgGhv07sMa6WLdBfLQBIzgKyceyYO8tL44uJ7iB4m2SzxNP/eMB8aCLzfnjnX/LPoKcdJooqpY2xbDN/q1wUt87Y9SibJ3aJ5PbkC8tkD+IdeMYgSHLbtJM9ChcdyLziF7fVYGEbKQgPCsEsQ7jx6A6088tp72MheyDMSuzHg8wPn9nqMEv7RefcZvWX6HabmPYA6IiuAjR1wKeA== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2024 13:33:18.8401 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4bd57cb9-6fd3-4d42-2ca1-08dca6650543 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: AM3PEPF0000A799.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0P190MB0706 X-BESS-ID: 1721223200-303537-12646-15870-1 X-BESS-VER: 2019.1_20240716.1757 X-BESS-Apparent-Source-IP: 104.47.17.168 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVsYWZiZAVgZQ0NAoJcU81dDEIN Ey1Tw1KSnZ2MLczDDJ0tjQMNEsyTBNqTYWAEWYUYZBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.257687 [from cloudscan16-51.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 v10 * Remove "NT" from the commit message title * Use 8 spaces as indentation in meson --- 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 44d59c34ae..6f645320b9 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.43.0