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 C13AD45501; Wed, 26 Jun 2024 21:56:08 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BAD5540616; Wed, 26 Jun 2024 21:56:04 +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 28DAC4027B for ; Wed, 26 Jun 2024 21:56:02 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2105.outbound.protection.outlook.com [104.47.17.105]) by mx-outbound42-4.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 26 Jun 2024 19:56:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RrHWMigcBlVjIXfNTACaCS9d1Fqalx+ll6gftZvAvbYB4roSsNJ1fENBA2otTe+GxPL0/zjWaIzw7Kj92PvKTy5OoK4xef26udQt+EHpIRyIXUjJyYFurHd1L9TVhb/Xe6s305ZaBaNMfuPtc0MiJl7mGk+IHz2uEE7PlaVBtOExysRGJ1JrOZm8GTl/1/+6qEduyqcFydQixaI9OKc6jeb4UeRA5CbLuY0o+S/F35g9AqrYTLGgwjHOXxUFs3vaaCQiNeB8Z0CVHfRyA1BIfHoYMk8XE0hQiDuvzMfn66KJiLFTYp666KMZpKqxOJx2CuqYA4KX3n4Ha5LVH0qUkw== 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=SjQhWyPtm/5Nboy7eP4h9tmlsQTpYUzj0bAmN4tyeXMJt+OWptK8RN5rG8OQHk/s1uGlWjxCqF2u4dUNilxj1xr6VYyEyX3A0EtGkvawtK4xRt8nEgvBcequeB0qj6Gn/fZePMompo46rWe4vXIMjQJgda2hty7Ng25Sjc+sXjulE1LMvF8KSiRhwXYUSbl61ypHR6l1VAzE8xZmc4d9m/CtkVYuS3P5Wpgm89GvTSg/SgxDP9YA9kFjn+oypC2lrK8BOswEKx6AbHcIDaXUNWZG/gslgCxu4LTeIjwtd8WCsscimh4AsBkAhEU9w9gLqBAiyxIq0dusA7KdMJIYdA== 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=Hkd01E0XBYlO7WGory+HvWmO5rfOiwgBJOZXPfjDNrg4l/v/DN1LG3N/0KON6OxAo6I0pAkkd0Go84ZbdliStTnLL+e8H7LUDvhy0+KHStPIbQ0YHJep8KB0Nk6AjRqjEcmPUmHC0d95Q6Ify66AyZpAEZlsyBbDwNDJkEB/Nik= Received: from AS4P250CA0026.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:5e3::14) by DB8P190MB0620.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:123::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.32; Wed, 26 Jun 2024 19:55:58 +0000 Received: from AMS0EPF000001AC.eurprd05.prod.outlook.com (2603:10a6:20b:5e3::4) by AS4P250CA0026.outlook.office365.com (2603:10a6:20b:5e3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.22 via Frontend Transport; Wed, 26 Jun 2024 19:55:58 +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 AMS0EPF000001AC.mail.protection.outlook.com (10.167.16.152) with Microsoft SMTP Server id 15.20.7677.15 via Frontend Transport; Wed, 26 Jun 2024 19:55:58 +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 v4 02/23] net/ntnic: add logging implementation Date: Wed, 26 Jun 2024 21:55:12 +0200 Message-ID: <20240626195545.1793419-2-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240626195545.1793419-1-sil-plv@napatech.com> References: <20240530144929.4127931-1-sil-plv@napatech.com> <20240626195545.1793419-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF000001AC:EE_|DB8P190MB0620:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 2e7b7141-3f5e-40c7-3a84-08dc9619ff9d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230038|1800799022|36860700011|82310400024|376012; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?31mKMJcIh5wSNxBCaDUXj8zcejefOOwI+BPTCKCS0kABuNfWWLBqQEmBaVzZ?= =?us-ascii?Q?ejZOw3CQC0FpXZmL5qgHh9BvpOxYudcmfsr5eWVuWfWCEkgjjP+PFpzKpuHb?= =?us-ascii?Q?LNDe54dMeW/+mBDENvm0cztXi9dJIkTdwWF/IUDK84j6rmtEdnUfcFFGBVtI?= =?us-ascii?Q?j88O13prO764plHRcW+sKwNGKwMowLr9HGHgL/NBUGnYg7YcEm+RH5dM9sIe?= =?us-ascii?Q?LW0bAxGY3G+oMgFtpQSvgSyzkKaa8jcXte14BlOP9idMgYh2LFdfp3HXIJoL?= =?us-ascii?Q?t4THuro6Tit06WZSSza9WRzQqhzLNbs3lQh+Pmhohcb2wbCy/UFosluxQFjo?= =?us-ascii?Q?ju3O0E0042MlxuFiUiygLaUOVL82PQsAeB4eshUYZvPSYHebgDvrRliokFx4?= =?us-ascii?Q?gLd1NWRrG1nPR957v+MTFRI8dFUPLchbqRp8LWc3zVRoFTuiyIKMl0cHqGGq?= =?us-ascii?Q?mhs+T0Q9tEdLy/wb8/pTfTCf8OGnbQ4KoDD9ULMGJJY6tKpqHfkyf8o6OJva?= =?us-ascii?Q?dOk+WHb2Xak+uVaZen5y3e78GJWGhvgDca75XMXnLanTVRd6YKbc74ooDsoX?= =?us-ascii?Q?335+ypjv94tUoLe3huc2pFbWoCuR21Pw6rYaO1O4QO7tgxMbMUSNBrsFOu3D?= =?us-ascii?Q?WQoJ2beXIdZIWvVCHYKeQLBrobTMHN/ODi2tmuO6lYMJFIUy3fk0wwLQiPTY?= =?us-ascii?Q?JgIaJSZ2l8oKedrQ+seaqo4pn8mlYGR/6ylHgV1NzwlRkzRQs2yTfHspvZRZ?= =?us-ascii?Q?rAI1ihN+qd+F3z37BPxITh6SX4CAh/eZFPIIWGtWatb16G6ebblkddYZ7X1X?= =?us-ascii?Q?doGwZkDdnN08ndJJ+fYt+3jrlBvvDud6EYQfxxdsYWuS09WW0tl/xOv/mN1Q?= =?us-ascii?Q?jNnPXiZ6dQR77djm0H5WxEoL+g/0dyjhpEnaGfiyoknF5qp7UaxGJXNqrNbA?= =?us-ascii?Q?lqn5wxnHpuexE1sIVBsqTeByIIeyZODvWh7EAY3R3WWW/BdRUf5Oaf24z/si?= =?us-ascii?Q?VdMhj7wff+tCLiLxsHgahLYtFjUvkcwIlyi06ugTMYOTZ9DUVBCEC0ehMtFO?= =?us-ascii?Q?KGGeiZdCkyjKRZV6aHVumKDJYUgVtqePsDY/96KeyfgthP1fiIMvJLw874Ih?= =?us-ascii?Q?496l8gVgKQMdmbKDKqgWbRogFIv047suvKqPWY1ohovD72IvNgzxVcGol5+z?= =?us-ascii?Q?jjaWXCYxQB+auNYosGSBzy9q9y+jXyQWk3Wn8RTlnqbEmTOY0ZQjKURYFdVg?= =?us-ascii?Q?o5PiNrK7tzYh8EUQGH3KSkO+0rMEDdPaQnyXIgAFxd1/FUGrCxBrHiOD5/Py?= =?us-ascii?Q?qLmjI7T1Hcdng/hsEjXtR+gwl1lyvO8rH7RLIXcNjnhPW87vY+htif+cr32d?= =?us-ascii?Q?0Bqt0MxOTRjXEEp2kDfkMAIQig3TyhLzLQL1SQr84P8GL0YY6QdXe/BWQ4Wj?= =?us-ascii?Q?VgKPzOPFE1PFfSOxfU6Oo2HrbhNR65vN?= 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:(13230038)(1800799022)(36860700011)(82310400024)(376012); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: EoGQg2sKpHrEl9nsOwGTT8gprux3A+GtuvKylUdx6qIHWbvstnlZiKdexC7bPL8bjAuThdt4o4LiXc+GJM6w71z2xLyUR48TtJBjdxi8hhpqEBwAVzoYIHQ5VT9KcUrsSUEE3q5ha2BRg4qBpF12CPk5zTV7Pw8ma1aqOr3MhofVYNTRKm51eoGkxNaU9eMW5TYaQDWi4KeGstflJsMqj6WD9FnDx5vwtmwJH/f415rEG48zLgTkHvZ06aKIIKXwEhQNFwQYgk86ZECtDesncwy5/iDaWpHS1kSk9IEDJ6vhWcAhA95BAN3XCATWpz8/C3IJ2dvGLjUyEBJmOJ/WdNUxXUDMPHgBNiiS37QTZxmvcJmXB+UmVyjOxRj3U2iYfd3Ifv6w/f7YJ6a6edYd3T6nqhnZ8KlwoLlHsVotkENc8fNJiZ0XgtavI3FCiGVLzwl2cLONz706PKoXCzjO337CzXz66YjIJi7OfPUAXo4torGtvwBERkcakxBC+1CeXMdMSobAwBDeJdgxHLM2Dn7wav02pcG8drLOv74i8bonDGomLpXJSnTGKI4RK4E9ksjW1NRrdjaaF1fmyw7A8A8pjaK9/23gpd3tzm9v5lBhmkQlDE/KBPgLVWG7NbaDfEWek3KKbKULGqM+u/GBBA== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2024 19:55:58.5204 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2e7b7141-3f5e-40c7-3a84-08dc9619ff9d 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: AMS0EPF000001AC.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8P190MB0620 X-BESS-ID: 1719431760-310756-12112-19502-1 X-BESS-VER: 2019.1_20240620.2317 X-BESS-Apparent-Source-IP: 104.47.17.105 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.257218 [from cloudscan19-172.eu-central-1b.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