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 E6CCA45614; Fri, 12 Jul 2024 17:48:05 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 06BA442EF5; Fri, 12 Jul 2024 17:47:47 +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 B908E42EF4 for ; Fri, 12 Jul 2024 17:47:44 +0200 (CEST) Received: from outbound.mail.protection.outlook.com (mail-am6eur05lp2112.outbound.protection.outlook.com [104.47.18.112]) by mx-outbound45-239.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 12 Jul 2024 15:47:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=l6tfRyQWkDn6vardjDwn5MM7yvfReoMFWXVjY1nlG1extHtSs57m3UEeZJUwHXm7eD7LqCdEw6yQhzzeUmnfl2nx+6pByDqmg9Ns7jjtoZy20Vjp6j/r1Z55+VqxW39Ql6Vw1Zc5sdTtynjTj3EBolCMpHOspnfGXhYXDMw5YVvyPZNhJwXfcaSIEhnrnjFzPtIgYmMt/UWoXkl9ufBm2P7hC9LJVsSp55xHqx8Nwg7p9HmoTzg77MqeonzSSSTl494VhIOyYrcKW+7/eVkOA4hL4i1J1cnfjKCoihJPbi5QN3KX8h0c8mMGXqL67iK6ogiFTpnEVFUkyk5jcROYWw== 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=BO1nHvt4u5NdL7QDHorO5OJguUkqISsMTljFaf0V/wLhHSX4TClCgtUg2sEeNvC8s9g7TX7FBl2bBUzFvNDkVKNtv8ro/rqh3DRZnR8tN8HQxdeOXmz2BNnurlMPtCX79o/7eIq4Coqbk7BBUNPj2yi2OTiPtB4W6u+Sw5+xRMbjgRC667QZEkYb2DZXYnhFuqG83Nf+fexLVPHtfEFRIvFx1vl77OAikOYDlNA4zuwJDibkvwaBU5J13IZrFlR7wgZzTHn5iJ6PBvfugGhz1naSf8h9spQthkT8rz4MbHCLhN3sqUqWsnAHC7br/FzZcCXsrbhRKwmFxfMifwlVzg== 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=VTXCV7rwE+LZiLTX4WN730EP8u1Cg9mcnkD2MM4rSX6d2cJBZnq1pgwXvaSlAfzR6fymGnN9LPoGDMmxRSOa9w9h7nAYCK6G82mciClq9GjUyhPRe3sFMerHw1AE+8C7Xf/C3og9hKCtMJ19/6v/woLiXcjtW4o3nm7DmE7fPM8= Received: from DU7PR01CA0002.eurprd01.prod.exchangelabs.com (2603:10a6:10:50f::24) by PA4P190MB1037.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:bd::17) 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:42 +0000 Received: from DU2PEPF00028D0C.eurprd03.prod.outlook.com (2603:10a6:10:50f:cafe::68) 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:42 +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:41 +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 02/21] net/ntnic: add logging implementation Date: Fri, 12 Jul 2024 17:47:12 +0200 Message-ID: <20240712154737.1339646-2-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_|PA4P190MB1037:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 2f8119ec-5a7a-4ed3-0a80-08dca289f73a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info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gZCyBBTApDS0dzlZftwxx7G9c47z?= =?us-ascii?Q?WoYPqlUGYO5K+TKUFtHfMjC9Eykk3f7cmiyJuVD5kLY2TFDfyyAje/4PBUx6?= =?us-ascii?Q?DhgeURmZd7IqBXhdAwFgUNoFjlWW8EwTiAs55kSCPNowGXxszIzEqxIBuAul?= =?us-ascii?Q?ns933QgKyqjx4SFxsB6RZOJuwB69o4ZcrsoQouzIx18U9ozl/LxLZk+VM0Wa?= =?us-ascii?Q?frYFjEdYB0/B2+eq6AxRLRmS0sf16tHczG82iOyKBWxlazQ1cxtnb3S5xEwB?= =?us-ascii?Q?ng9SUtU3YOHkEWRtOVQ/K4MjNs7h7WK+sr6tiauqp2awJPAcv5Zi3Yce0A2y?= =?us-ascii?Q?g7DCKiC1NTghhew6WUsOx9iAzhyHhFVVbhDzneBqS3nn07kijDv13Yfd65wj?= =?us-ascii?Q?75H5gahzJjG8jAGOekGPF/mdHnUpRAdBvIyG6IHjcB38fuRkPEoFcMklzY5g?= =?us-ascii?Q?r5syZnYyqzd6g78DxX9WcHVIAlpNZhlteEN3X5CAFojxLa+qvqNUlqKE1nOJ?= =?us-ascii?Q?W1URkZ9FZLV1iWEkYvaU68b+COVWh9aUtUuAZBU3TuqtZUwyZ7YO65XXW4Uq?= =?us-ascii?Q?xCj6v27KG9rPCCy2TYZ8okX7jGmlgqO3?= 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)(376014)(1800799024)(82310400026)(36860700013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: NMBKJVh4HN3w+rDPM/0zXSI7gcy3nYltguO0iuFhEK2U3zqU89F2g82NRlIRoFP3PC6h4ScegG/TPwrVpTwZ+EAsL5VugfA45cNNSaod9EZMfY/y0k+eDcw576YZbq8SYRd7rIp8+U5ZFasqQ6Y3HgC+cvYxoySYODSaRh0SJS3UPb4CZ/L/2b1eFuyNMJKk8R3g2NasqjP4TsVN81KUmI0fU171WIGsdUw2sQO1ZezvZZk8Fex9rOkp7qJ2nFz/WbfM2wmnn3lV0g+bQqsl/7wlV4pG+qTi232KlatHYbSDtQgiUm/jQS+jb79L2aX0kbRLegzbnyyzpD7VAEmRejtRT8dJXoKE9PgZ4gkHyk1DpraOpvLFYyXilmF0m5IdEz3RSHvRV0yG98ZdVmCqVxOdGB7/0lSMAT0Z3V1QAIlaf29XbK/Z4txfG/b70kfuFR9D821YJFRrX1NdK9QCztKKvZxlKU7Pyc9HP2K6At0CHOSJMPHlLeCgfISJRNJ2XW+U8eDXK6CJYWVUmqvnK9W9xJ4q8S3d6/5CNMAKwQKuPUsDponmN2Fqhzk3lVA2n3/IcjUioIgFHmtzhB4tksSzXxwtzvPAlqY7GzOADH4VWssKYk7kSYrzsmyUfXDLYUD83Kxo88t3tXfxp+l+xg== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2024 15:47:41.8638 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2f8119ec-5a7a-4ed3-0a80-08dca289f73a 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: PA4P190MB1037 X-BESS-ID: 1720799263-311759-12664-32373-1 X-BESS-VER: 2019.1_20240702.1505 X-BESS-Apparent-Source-IP: 104.47.18.112 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.257575 [from cloudscan11-194.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 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