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 28C9645614; Fri, 12 Jul 2024 17:48:30 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2998642F8F; Fri, 12 Jul 2024 17:47:52 +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 5A20842F6D for ; Fri, 12 Jul 2024 17:47:48 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2104.outbound.protection.outlook.com [104.47.17.104]) by mx-outbound8-179.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 12 Jul 2024 15:47:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IsP0eQPhHkrVZ+n2vGADGXw20cTctu1OYmDi/PMSm8MKR1iUyHTCkMTOYo6mb7Qwd/b9pu/6HWYDKD27uKf3RcbVo8vn78R0q/snNZOA7TmHXtfLJE6xo44A3ho7LUBrRmu+kTodjgp0XvT9Rv33Q8EcoF5335qtV6+rAf3SyAizJsSibC3GlFSDA8dk0cro8uFOonez2K4iH3FyION8T5ydAP1Vg6Qn8SM4sFSlZBmyVGchTi+ukRlGl1h5LBtr420NL2nX+mnPSF8OcJxzGQnzK374vlVNF13FkDWmLSgP2+2/pstguhcfTDrN80MYKUFXUh4FKYLpSXWwwBsewg== 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=YOeE79xCHhlWevKZi1w41587xx9xXjIR8XXHhG3hyCLItzlaUCo00SGaXvfXrRiXZE4Ly4heCD+6I2TnQA6z962iqokMw1HcWlb1WSYrPIYvg52vlrcyb5yNkE22Xcn3ViuZtlHyLN2FkcwcWARUSyvcxTFN1+woT+5VIt2hOFD8doAuz2OVY6R6G/wUqifghEZo3lNkXjBTqSA4qX2isvUg/9mxvH/QxgZYrxThWMvNilp0Ai+5KzDlffBKJZlrOR50if2NKZhnKBZTdaxAy4GEE8Th+xu+XEyo8I/3dxI4SyIh6FwKi8EvuAqMqmZzXcAAPGDjYqDKqnZCDCMX+w== 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=Kd8ZgH0hhzpUcxrZLRHaYmJiXROuZO7MZrEOTRrX+RMUfwalQo5qImvApLBlqYEtKvFR44+B4oH3oseAGf5CaRs007Yjp08dahpAJp1QqffnJjVVZTk4qxP8ZxUBvSid4BBltN4ctNlbx+vQr2bMqz7O5Uft8ShNmghfp9C70So= Received: from DU7PR01CA0002.eurprd01.prod.exchangelabs.com (2603:10a6:10:50f::24) by DB9P190MB1130.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:22c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.23; Fri, 12 Jul 2024 15:47:43 +0000 Received: from DU2PEPF00028D0C.eurprd03.prod.outlook.com (2603:10a6:10:50f:cafe::9a) by DU7PR01CA0002.outlook.office365.com (2603:10a6:10:50f::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.23 via Frontend Transport; Fri, 12 Jul 2024 15:47:43 +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 DU2PEPF00028D0C.mail.protection.outlook.com (10.167.242.20) with Microsoft SMTP Server id 15.20.7762.17 via Frontend Transport; Fri, 12 Jul 2024 15:47:43 +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 v8 04/21] net/ntnic: add NT utilities implementation Date: Fri, 12 Jul 2024 17:47:14 +0200 Message-ID: <20240712154737.1339646-4-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240712154737.1339646-1-sil-plv@napatech.com> References: <20240530144929.4127931-1-sil-plv@napatech.com> <20240712154737.1339646-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D0C:EE_|DB9P190MB1130:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 6a79c517-c235-4645-74d0-08dca289f847 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?us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7GCdN+AfcJ3EBnqM+NyqogkDDKN9NGPSajcYJ?= =?us-ascii?Q?xs2F+IT/I469K9DDTTUfsDnkIKUGTfReB24d3xOFbOKTzgL3EM+9AIqgQfw+?= =?us-ascii?Q?/nT7HVyEokVARDa0vrAR12Ys6zIJ8PZUqpstH4nm0bsdDu0rn+X+C5T7XlaF?= =?us-ascii?Q?rp3TjcyJwIeTvpx3duoHjPvrgiRrlz5aU7P7jv2zFflmll6vdOqMS1l4Asvy?= =?us-ascii?Q?RCHR3+zIpnZNQnEIxhWNfE6zsm6PP2bcINjU85JX9MrpeVx0YKCtdKQjcXPt?= =?us-ascii?Q?cu4sCQoNMhsoJn6vhqCJk6v7WELcZJPYG+7Hqxmhf5u5FPG61PyDDmGZ7jq4?= =?us-ascii?Q?QHWKFk6nsOIq7LkFCv4aPU9n6JnbHsJHLMtJG8LOKVbBAiM3+8i6B1eMgagp?= =?us-ascii?Q?t19aLNMfCo2QV8mvRC5IozBq2hFOKi3NE4F4+ISHfFeZqhU/poLtQZIki99u?= =?us-ascii?Q?IYQLDa+7OFR+Z6cxqc8b3jWAyl1VWpXlSdktERfqyeHjSb5Kjp5CLrlksNrj?= =?us-ascii?Q?xWd+CIkcZQis6pRB0bDzdxFHNS0hy9kn77ivUXhK1iO/5YF3b/cDDoGwDK3C?= =?us-ascii?Q?EFx06qxUk6eYJg45tm9JoRAQ/myXCoHi?= 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)(82310400026)(376014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ISzs5DYJIVQbmyr6LTRwCFoaTYwnj+d2HbyfF54R0vWxmhPpOneCXEnSAUbcpt6zukbQZCrsB/RuwBgbv+B4ArELj+PvbzHF2mX/J2qc5BGCYbONXBdoRMeWXrsflHxG8Wb1C1O4kunQw+m4DKFYTQfsm8ONKvpNwM6ZgKHsfGcHcIykMUVasnD909ND8Jw/dErlDIso8ZXNHTf8ZxrMMmEJgngiWXp4FEpY/cuX8mslzqotgC5BUfqzzmR3YCsMEIMISc8K2lFPz4nXZzC4CoJ4roT5GJGNxM75vnJN9FwZ64iW549QPsWh7ImeBwiBXdSHfksbVWG+pVHCpSR9xZ5AbxrqaXocqgXUBt7N+7wRd3c7jO7Ts19KbknkmrCH67omHlNfcr9HdF6+JmuXSeRbqYkT2Qf/b8iUNTe9J2IGSdXM07dtlbTbpelcO63SMr4PU+8oMsSz312KPBFZ4BL3owBU512ZzON0imiEZP3WPpL2h82BfewioXrXja/ecSVnwy5wECx/I1ADRNtZ3GTQD0ndGyFIcdCSFbYMyfm/cAHVGF72c34JPcB8z5Ugpix31fY4gZSdp9EQ0kGEXO6j0jBZ0iparkNa01JJepkisIWqFPC75pfsXu15lT/1AF7Dz1UmIB3DH1k5wZ30hw== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2024 15:47:43.6607 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6a79c517-c235-4645-74d0-08dca289f847 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: DU2PEPF00028D0C.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P190MB1130 X-BESS-ID: 1720799265-302227-12701-34407-2 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.257575 [from cloudscan9-80.eu-central-1a.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