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 0DDC1455F3; Thu, 11 Jul 2024 14:07:51 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CFDB14065B; Thu, 11 Jul 2024 14:07:50 +0200 (CEST) Received: from egress-ip11b.ess.de.barracuda.com (egress-ip11b.ess.de.barracuda.com [18.185.115.215]) by mails.dpdk.org (Postfix) with ESMTP id E2EB14021F for ; Thu, 11 Jul 2024 14:07:47 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2168.outbound.protection.outlook.com [104.47.17.168]) by mx-outbound17-202.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 11 Jul 2024 12:07:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=boDrIYXXti9BAPVgl0g07h4nIvRSGpte1ftyD4LWjgEN96IoesYhvT89F65UQpjawCYck5YGjKV6U8Odr4oOOiPH0QCtkIe5n7g43HUdKdxdckqBw9cNuXRhJoKooOwdFVZrXIa+QwIUo5iIH0qaF60bx5l2DaIHkRCWl7XpYPkleh3ZXsqNAF1y6EiJdiROTCH03VdVm8BZMI8i8j/Alt8QDfZvq2fIMkXPYTCNC5q+bBy1ey7Qq9FXd7Jdwx1zJF1Wp2lxqojLyqTLiRx9Jd61viPoGxZL17sZAOqQYk8CVfm9kwTcbnBtbTvN3tNfWcelKXoDv+a6pglGiF/05Q== 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=5ghj/LBj7rT90IH9+6+PX3ZAFoVIClTniQNYNquC9yw=; b=am7ToJtmHLNPe7NSOr9cgQEjYizePI07hQQtjqKKb/CcrYB0+wqpfHZlCtj/A7HEep8vopJYwFDZMEh2cWtmAIOWEs6vwgLFOg4M6P0CYxOajjKCSTWEslno5esZIgtop575kW4kzXWNMNvmRGqmUYNNmcACo4S2ABMt2aBqRbO7KHEn/67riVSPTcj7gb/6DhfBJM+bbT0iAH5498InCsCCmEGNiHkSqdp7QtXhLOZYkIsICqS+asC4S7nVhFecSNA4+FT5ri8/dDhQ2VJyPEX2RfVuWcdRFeABiu5qj0LFvfMAvMYwou99b99PuQ3LBVo/OpGXiqVwzuI7DkNFpA== 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=5ghj/LBj7rT90IH9+6+PX3ZAFoVIClTniQNYNquC9yw=; b=Fbbstijszy50FAHGnWmuR/6odp+xn+Xk2Zx3jKJh6EJ87eSs03lJiscFtn71f0oTdOSHOo4Jk8uclKvlWGfYnDJ0oL5VHavhYru5YSKBm69lRHZqG351LmJQO/v5EDBHfaVvlYepVDPoFvdmWXKwVmUIqGL4UvXzIe55REyI5kY= Received: from AS9PR04CA0093.eurprd04.prod.outlook.com (2603:10a6:20b:50e::21) by DB8P190MB0700.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:123::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.20; Thu, 11 Jul 2024 12:07:45 +0000 Received: from AMS0EPF0000019F.eurprd05.prod.outlook.com (2603:10a6:20b:50e:cafe::c7) by AS9PR04CA0093.outlook.office365.com (2603:10a6:20b:50e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.20 via Frontend Transport; Thu, 11 Jul 2024 12:07:45 +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:44 +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 02/21] net/ntnic: add logging implementation Date: Thu, 11 Jul 2024 14:07:13 +0200 Message-ID: <20240711120737.698176-2-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_|DB8P190MB0700:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: d17fe03f-2346-4ce1-63c9-08dca1a212bc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?7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=?us-ascii?Q?xFpAwzoIWfHfMDZ2ENJ6MOBaWvO4nSN0zn+ZGwtP/kFCgIC9xQ2w2YChonQw?= =?us-ascii?Q?IflkWcEMdeltjdhqodi1GgBbbZKJmPMLM8XociV/O2CL1RbClXAicTUWv7fo?= =?us-ascii?Q?TizC/Ad3fMdULL8m9xsz1rVyX5mapB8scgbpWvyDiRe4YxBpT6GnbgnqbO/4?= =?us-ascii?Q?G50ig///0ZoVrk2JRID3E9DRV/ci/1CkKB5MNtr5qM++C09HX00W54Lx9Bbm?= =?us-ascii?Q?dCWqlmkMTb6UWttwXdeX9GAGgUHcrZ0Wq9O7XlsLmXO6dvhKlVU1yTm7NDYw?= =?us-ascii?Q?5v4E/N4/vf7zI1cH44WX85TCyz68zchjKV6DKMTclJex9R3knQNuhSgNR5Te?= =?us-ascii?Q?V7mzwPPiQO4nL0A2jmqA63uskA8Dk70tNXXP+2O6DqC3Lt9ihRy5SMglKet2?= =?us-ascii?Q?DY/Ohy4wnquOEuD2qJrDcqD8tI2kgzr8Dc4QRUot/v2nppWQxegWzoIwhwh0?= =?us-ascii?Q?sUFUbma3wNRN7LHr9I+WD3/ftDSouLkCjIX1dbEZteLbo43zQao4L+swH442?= =?us-ascii?Q?9Qz/60HpeQIOzzRcOrqV78D9OrB+afD0?= 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)(36860700013)(376014)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: /vqyLQ4T7DfxvTxg2ej4We/zMY7c++cqDIY6gpSKbQZbI4nzkls1DX1dwSL1qdwkkqxFXiV6FhNDMjQoUxsufEpoVQjwCNnGPtNb+9D6ETCTLtHGpC6kOz6Wtd5n6BhJ0lX+VsU4vUzyM/yBa/n8BlbU49JkFBDqfcbD8KY30k2ME5UY7m1j26RHtkWs1cPTE2itKmcfVnUJk+4C8V1SUwP8XntufW8p38UDg/E+3LG8827J8sCA4uvjJAWgveJYTnRo0tMUqDcyFys/y810GXOmVkGWoQbDCEl48ve9ra6T0ElgDzVEdqWmHPg/xC9h2Lu4REC6TSVderBB1y9NZXKSUg3uKmEE0KS31O8FU9EZ1Y4hc4EygSb5U3bvjbjGIXTHMtZbpLrJ+cILpdVklvESsMV4nmbFA0gVii6qQRFqfGH9ttJzSNZLre+FoB73gKYUmKyK4rkskIPvcnXh/snyHsQl3G2QRKAbewy5nQrwAy2z8q3ywqIxNiEre02dYyu0ORB5ZD7VxWw9Av/miH81+vEnabDpZZd1zbA5M5s3b7I5xbAw12iTCRb1cZWKWQSHqP5LUEh5SX5hgK6zLvP+qcwSJ6SXcoz2lfRqouFKMFy/eNRWUqrHqdiP0ISjg81R6tWxRwWE9y2gLvtO4yFqB+tHpSvIG3WmGKl8+Dk= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2024 12:07:44.9471 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d17fe03f-2346-4ce1-63c9-08dca1a212bc 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: DB8P190MB0700 X-BESS-ID: 1720699666-304554-12687-23890-1 X-BESS-VER: 2019.1_20240702.1505 X-BESS-Apparent-Source-IP: 104.47.17.168 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKViZGZqZAVgZQ0DTVINE0xTg10c LcOCk5zTLNKDXV1MzUwjwpzTQ5Jc1IqTYWAA4bYgtBAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.257551 [from cloudscan17-213.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 Adds ntnic specific implementation for logging. NT NIC uses this logging abstraction layer to ensure that FPGA module implementations function both within and outside in DPDK environment Signed-off-by: Serhii Iliushyk --- v6 * Logging header file was moved * Default log type was set to NOTICE --- drivers/net/ntnic/meson.build | 2 ++ drivers/net/ntnic/ntlog/ntlog.c | 53 ++++++++++++++++++++++++++++++++ drivers/net/ntnic/ntlog/ntlog.h | 49 +++++++++++++++++++++++++++++ drivers/net/ntnic/ntnic_ethdev.c | 2 ++ 4 files changed, 106 insertions(+) create mode 100644 drivers/net/ntnic/ntlog/ntlog.c create mode 100644 drivers/net/ntnic/ntlog/ntlog.h diff --git a/drivers/net/ntnic/meson.build b/drivers/net/ntnic/meson.build index 194353230b..80f0f3eecf 100644 --- a/drivers/net/ntnic/meson.build +++ b/drivers/net/ntnic/meson.build @@ -10,9 +10,11 @@ endif # includes includes = [ include_directories('.'), + include_directories('ntlog'), ] # all sources sources = files( + 'ntlog/ntlog.c', 'ntnic_ethdev.c', ) diff --git a/drivers/net/ntnic/ntlog/ntlog.c b/drivers/net/ntnic/ntlog/ntlog.c new file mode 100644 index 0000000000..2e4fba799d --- /dev/null +++ b/drivers/net/ntnic/ntlog/ntlog.c @@ -0,0 +1,53 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#include "ntlog.h" + +#include +#include +#include +#include +#include + +#include +#include + +#define NTLOG_HELPER_STR_SIZE_MAX (1024) + +RTE_LOG_REGISTER_DEFAULT(nt_logtype, NOTICE) + +char *ntlog_helper_str_alloc(const char *sinit) +{ + char *s = malloc(NTLOG_HELPER_STR_SIZE_MAX); + + if (!s) + return NULL; + + if (sinit) + snprintf(s, NTLOG_HELPER_STR_SIZE_MAX, "%s", sinit); + + else + s[0] = '\0'; + + return s; +} + +__rte_format_printf(2, 0) +void ntlog_helper_str_add(char *s, const char *format, ...) +{ + if (!s) + return; + + va_list args; + va_start(args, format); + int len = strlen(s); + vsnprintf(&s[len], (NTLOG_HELPER_STR_SIZE_MAX - 1 - len), format, args); + va_end(args); +} + +void ntlog_helper_str_free(char *s) +{ + free(s); +} diff --git a/drivers/net/ntnic/ntlog/ntlog.h b/drivers/net/ntnic/ntlog/ntlog.h new file mode 100644 index 0000000000..58dcce0580 --- /dev/null +++ b/drivers/net/ntnic/ntlog/ntlog.h @@ -0,0 +1,49 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Napatech A/S + */ + +#ifndef NTOSS_SYSTEM_NTLOG_H +#define NTOSS_SYSTEM_NTLOG_H + +#include +#include +#include + +extern int nt_logtype; + +#define NT_DRIVER_NAME "ntnic" + +#define NT_PMD_DRV_LOG(level, ...) \ + rte_log(RTE_LOG_ ## level, nt_logtype, \ + RTE_FMT(NT_DRIVER_NAME ": " \ + RTE_FMT_HEAD(__VA_ARGS__, ""), \ + RTE_FMT_TAIL(__VA_ARGS__, ""))) + + +#define NT_LOG_ERR(...) NT_PMD_DRV_LOG(ERR, __VA_ARGS__) +#define NT_LOG_WRN(...) NT_PMD_DRV_LOG(WARNING, __VA_ARGS__) +#define NT_LOG_INF(...) NT_PMD_DRV_LOG(INFO, __VA_ARGS__) +#define NT_LOG_DBG(...) NT_PMD_DRV_LOG(DEBUG, __VA_ARGS__) + +#define NT_LOG(level, module, ...) \ + NT_LOG_##level(#module ": " #level ":" __VA_ARGS__) + +#define NT_LOG_DBGX(level, module, ...) \ + rte_log(RTE_LOG_ ##level, nt_logtype, \ + RTE_FMT(NT_DRIVER_NAME #module ": [%s:%u]" \ + RTE_FMT_HEAD(__VA_ARGS__, ""), __func__, __LINE__, \ + RTE_FMT_TAIL(__VA_ARGS__, ""))) +/* + * nt log helper functions + * to create a string for NT_LOG usage to output a one-liner log + * to use when one single function call to NT_LOG is not optimal - that is + * you do not know the number of parameters at programming time or it is variable + */ +char *ntlog_helper_str_alloc(const char *sinit); + +void ntlog_helper_str_add(char *s, const char *format, ...); + +void ntlog_helper_str_free(char *s); + +#endif /* NTOSS_SYSTEM_NTLOG_H */ diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c index 7e5231d2c1..68df9be2ff 100644 --- a/drivers/net/ntnic/ntnic_ethdev.c +++ b/drivers/net/ntnic/ntnic_ethdev.c @@ -7,6 +7,8 @@ #include #include +#include "ntlog.h" + static const struct rte_pci_id nthw_pci_id_map[] = { { .vendor_id = 0, -- 2.45.0