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 12D5145509; Thu, 27 Jun 2024 09:39:54 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 24C6A40BA5; Thu, 27 Jun 2024 09:39:36 +0200 (CEST) Received: from egress-ip42b.ess.de.barracuda.com (egress-ip42b.ess.de.barracuda.com [18.185.115.246]) by mails.dpdk.org (Postfix) with ESMTP id 2A754406B7 for ; Thu, 27 Jun 2024 09:39:29 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2104.outbound.protection.outlook.com [104.47.17.104]) by mx-outbound22-108.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 27 Jun 2024 07:39:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MiqXmDh2Z2wKV0313ogI2C2Ex/bizGW5BfGDPz1lqZ/KO/ohEFfhCUJkaQ+j40vBGY5qPDRphXPX+rVmHRk8O1noU4gy4PJxLRrP2boqiorYyeXASodiOqMfVrJN3s6F/HOpE5X+5et+cd+AlVt3pTeRIvMVbynDXjL3nQqdPbRDogobnbgIzFWSOL0TG5Hqw83KYDEhAFlo8Nkhp3xc499djaHMzBwZnwPPAcx7fmjtb6ymDn8CtIBws7CUNWN6KCga5BeEztf5ACd5xPp22ROOgLecwaLLFhA4QJ9+ejFxipEBnhxAcnZ2dvDZtg8MZ6EJncrQGKuEqnzkVeWaFg== 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=R3nXIinyW3cqyjlzO2D3Ou6vzKyA9Bxl22sdF/TotSA=; b=PaWFIrMhoiQaRxwaSTgWwA5b3vS1E8ZSDGjWu0TVZ0+dWGqwP0qcI9sVbR45fVNAJV+E1uvBOnVC7n1pjcstjGjDoyZAmnlB2dWpviQ8hVuAOdpzxSewt+/k7bX20E38hC2KBmrXuELPo58AIyMUKCmJlTOhQE7pR3fPxmUI/UgdmR509b0bWNp5+AiiVthQeSwqKjLK1Cv3tvHejemlwspjxK4+YlDkK3XA/F2rZCmPVlLXOGuhoAg4ZhNtt8IZz9qGoJqc2u1O630BrYsrt0gigHEzkzHXPUzJpir7ABvqp8T6z0965evNzrz2hEauHpIdaEN3pTv5Cm2A/s58qQ== 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=R3nXIinyW3cqyjlzO2D3Ou6vzKyA9Bxl22sdF/TotSA=; b=qN8Zv2A0YBsU2RBhX0yrXZDTKHXnGvR+DikuBH4ifV/WQZnyzzwaKMfqsOQI0jOPtAThYDVIjDOCPE4tFbn7fONNygHPf/bsdhoYmShWRFBs0yu73PQejDXk+jUq0RmDTO1dTim8niquQxEJQrVYSWZoDnjKT2vBAza9sDJ8r00= Received: from DUZPR01CA0334.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b8::25) by PR3P190MB0970.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:84::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.35; Thu, 27 Jun 2024 07:39:23 +0000 Received: from DB1PEPF000509E2.eurprd03.prod.outlook.com (2603:10a6:10:4b8:cafe::7c) by DUZPR01CA0334.outlook.office365.com (2603:10a6:10:4b8::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.25 via Frontend Transport; Thu, 27 Jun 2024 07:39:23 +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 DB1PEPF000509E2.mail.protection.outlook.com (10.167.242.52) with Microsoft SMTP Server id 15.20.7677.15 via Frontend Transport; Thu, 27 Jun 2024 07:39:23 +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 v5 02/23] net/ntnic: add logging implementation Date: Thu, 27 Jun 2024 09:38:43 +0200 Message-ID: <20240627073918.2039719-2-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240627073918.2039719-1-sil-plv@napatech.com> References: <20240530144929.4127931-1-sil-plv@napatech.com> <20240627073918.2039719-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB1PEPF000509E2:EE_|PR3P190MB0970:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: cb25bdfa-d60f-471b-16cb-08dc967c43e5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-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8/euhz6G2NX+/eTsnUw1k4Urk+YuDkyo4gP?= =?us-ascii?Q?YbI4+MgRvhWv7eaEnT7tGATzM/V0XL/mydGkTKkLzVp8lCkQPuzgrRYnqDIW?= =?us-ascii?Q?mmzELhRrufIxzdFLmyBeMWASPWcNabkx1KuLm8S+MidJxaG3md56ztExHJyB?= =?us-ascii?Q?pWjIK7PptffjYX6nDGJ2DV1sWNg5OV8szhCjvYApv3HpXO03OY5oVaZ2zDHm?= =?us-ascii?Q?SmWSActIW53P0ILIJCkEe3GB8Y1Ckxm1zU33eOvOeoD0kqWQKbhIGgtQVLYm?= =?us-ascii?Q?FezHwIAk8sSpSKcofJ7g5Qr+p8nbOOeI+Mw59GQW7g9w+OrKFHuV1hGL4WPD?= =?us-ascii?Q?dkFKpBLWnSUQBB/pD7hpqHiKqZE+tINouTPXo/SzZf0RgdAvsh+xYW4EJFNq?= =?us-ascii?Q?XpmFI+8yDSX4eanplw2RVaE1U4pbYEKrRnMPxg5me6XZDBSievfmGsjRIQ+Y?= =?us-ascii?Q?quybK34+KD6S8Qb+TsRy1GCnwI/afw1E6KjSy3TXEVAh+sT+SDUCNCy/8kRO?= =?us-ascii?Q?B1uuPLfWumtr7DiR/rhOfl1i8VVZlSYk+KlVQ8AcWarzkFkWYen5dbLe/mfz?= =?us-ascii?Q?fUdL3ZGHwmWvPDiOZh8HgwsRmbLciK6+?= 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)(36860700013)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: K3RLjZINsFzx+mamJ5q2MMEJIUPOTd5lQrRJQugXqJT1eDvacuS1NNnwe0X0iSTU4EHcS4oYGSOP5jSrMdmz9+tV2YEbAb54XKZo7fILFJXPrcBUj/4UwPEPbkpHKWYKRUsHdveO6+U1R+h8AWkPZzsh2TiKBXlDR0xsCWIwKcb8vmmDvQLT24QTRGDXBddIRdP4sxHTvghlBb9n1PI9vV2pTJpF9DuE39YpOSn8vVqMiBOfYmmATyfxoXsXNmMSYKJ7iVZurOyTf7Hi3QxqqS3W1irLAiPn/MyfyYj1gczaY0qmVnmTPqTPprH34+KaX/Y7a9t3GaflUAllfNXv9MFMS5YuECjkqfnSO5qrd792K2mVdS5V+oIq7NlGvhuHTq8aUo6EOo0JChJHyy4rWv12SyRpPORxSrSp/wlsYVWN4pMMOxC89GVfyqwKkmzB8WX0c/ka2nOPUKlSk6VstmY0lP2tlgimhvqZhs4qvxXzK4jiRc9EfDhlGpw2OsC0M1CJYQ/mjWMg/p1fzvAyMPOA875gufCJaBmOe7UuiAi9xt3U4/8kxJzAAg0PCI2dphIbit595AcOvp+CFGtRfVohcU3mzqUMBX/49RQKnASfaupS/FQCWobknr73AUE9qH5Z7eLkY7Q6XmmkI7dGWA== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2024 07:39:23.6153 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cb25bdfa-d60f-471b-16cb-08dc967c43e5 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: DB1PEPF000509E2.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P190MB0970 X-BESS-ID: 1719473965-305740-12657-2597-2 X-BESS-VER: 2019.1_20240620.2317 X-BESS-Apparent-Source-IP: 104.47.17.104 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKViYGFiZAVgZQMDXFyMDIPM3YOM kkxSAtxdIYiI1MzcxMEk0sU41MjJVqYwHISwvkQQAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.257231 [from cloudscan8-153.eu-central-1a.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 specific implementation for logging Signed-off-by: Serhii Iliushyk --- drivers/net/ntnic/meson.build | 2 + drivers/net/ntnic/ntlog/include/ntlog.h | 49 +++++++++++++++++++++++ drivers/net/ntnic/ntlog/ntlog.c | 53 +++++++++++++++++++++++++ drivers/net/ntnic/ntnic_ethdev.c | 2 + 4 files changed, 106 insertions(+) create mode 100644 drivers/net/ntnic/ntlog/include/ntlog.h create mode 100644 drivers/net/ntnic/ntlog/ntlog.c diff --git a/drivers/net/ntnic/meson.build b/drivers/net/ntnic/meson.build index 227949eacb..b1ba8a860f 100644 --- a/drivers/net/ntnic/meson.build +++ b/drivers/net/ntnic/meson.build @@ -15,10 +15,12 @@ cflags += [ # includes includes = [ include_directories('.'), + include_directories('ntlog/include'), ] # all sources sources = files( + 'ntlog/ntlog.c', 'ntnic_ethdev.c', ) # END diff --git a/drivers/net/ntnic/ntlog/include/ntlog.h b/drivers/net/ntnic/ntlog/include/ntlog.h new file mode 100644 index 0000000000..58dcce0580 --- /dev/null +++ b/drivers/net/ntnic/ntlog/include/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/ntlog/ntlog.c b/drivers/net/ntnic/ntlog/ntlog.c new file mode 100644 index 0000000000..2732a9e857 --- /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, INFO) + +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/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c index 9cc727ac4b..3079bd98e4 100644 --- a/drivers/net/ntnic/ntnic_ethdev.c +++ b/drivers/net/ntnic/ntnic_ethdev.c @@ -12,6 +12,8 @@ #include #include +#include "ntlog.h" + /* Global static variables: */ static int -- 2.45.0