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 3B37345628; Tue, 16 Jul 2024 14:02:55 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4E38D43300; Tue, 16 Jul 2024 14:02:32 +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 49842432DC for ; Tue, 16 Jul 2024 14:02:29 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2104.outbound.protection.outlook.com [104.47.17.104]) by mx-outbound21-91.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 16 Jul 2024 12:02:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uAh52NC6B2ONo9NM6kfIXKUPT9H98B2r6qr1pt0AfYrXa7ErblyjGn0GVdlEdpm3aK6NkkFPOey6oqQ2HR5AZaKvQ+OW57m/dwhLgcYlpFN/MaHZ7R8ucjvkOFoOzr5u1EM1Qlp/1kVOW8BOw9SBsBZXVfmBUD+FCz7kyjo1kbzMKNLr+ZJmgzslGx7C/ObC/jKnBQoGQSZmmwok5uaG7P/5RR9TC5FSDUHsmoJvff/zbcoHtCybRz/WQPtP8GkZKkDn00NSDG2JQM71vxR12vkyYNY6yWJ3CdIAGr708yJfuLzzoy6FR30vfUhE/YB9rSlr2EMPeVZBnq92JwohlA== 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=qxrNq0HyqD0J4S5/O9dsynupsJdpGe2GsQBC1DRMzqgGkH/3MDl9YI/ivdhDwaqrUdDc49O9dCS8OkfHJlMRosQWJH9AaU9zdsnT23Sx+zFJa2FUq+9LWwOez4kLTFvlvipIyjzQGL5Slnqs4+mrInZDyrL0sUDW7KUoXfz4evYqc2EuGm4gAX8S34e+hrDc0UZcKv1OZSAUM+CVl/Di2YMddKe1QHCdWH5GoVEHkjbaWRG9yuANGh7xTyhhlJxIU/eDWu47PP/8EPfv20Q1M4nnf9YAfilZ4JkS4nulrQqGuAk525dJBT7Y7rx2O61eLGIBspJndQ8ZgLPHy0o+bA== 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=hS5o1FliC1rQSC+YAKCryzR7jR8NN1ce9Lchhw2WBAdchhBArS+jDjt5814BabIePFzPIjBUluh/Y7SoJoqWuVXfU0hmg7hXzY74yO+uC6jDNRVcPEW8L7g389SSKodQan68QzgUeJ0JcuVARYbSlMYk5Yhrm8WNxCpthe2/CGE= Received: from DU7P195CA0012.EURP195.PROD.OUTLOOK.COM (2603:10a6:10:54d::22) by GVXP190MB2153.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:1f8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29; Tue, 16 Jul 2024 12:02:20 +0000 Received: from DU6PEPF0000A7DD.eurprd02.prod.outlook.com (2603:10a6:10:54d:cafe::73) by DU7P195CA0012.outlook.office365.com (2603:10a6:10:54d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29 via Frontend Transport; Tue, 16 Jul 2024 12:02:20 +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 DU6PEPF0000A7DD.mail.protection.outlook.com (10.167.8.37) with Microsoft SMTP Server id 15.20.7784.11 via Frontend Transport; Tue, 16 Jul 2024 12:02:20 +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 v9 02/21] net/ntnic: add logging implementation Date: Tue, 16 Jul 2024 14:01:51 +0200 Message-ID: <20240716120216.3032484-2-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240716120216.3032484-1-sil-plv@napatech.com> References: <20240530144929.4127931-1-sil-plv@napatech.com> <20240716120216.3032484-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU6PEPF0000A7DD:EE_|GVXP190MB2153:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 0e64653f-8539-4349-cc3b-08dca58f255f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-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gYAZ8nmx0A6XVD1O1ap+1dDCJdwd/Fzb8hdd31GHXc?= =?us-ascii?Q?ZL5GQmmb5vPkIBO6jtPw9QfGRn0165SRZM0mqKGlhBTI9w7mB6kw3zOGQsJX?= =?us-ascii?Q?M/cCIW1nnqVz2hHvqEGaMUIodA7RkSxOE5mhoCu2j3eSGjBay5b2mJYlW+rt?= =?us-ascii?Q?UVMV2hP3w5F05NBXT/f/E16/khzRa+QZPGsuVLCpCnkYSD0/DQqTw0lXvAE5?= =?us-ascii?Q?S+ELvC/mMvqnBhwt76vUvhGgXLuPctLElLjWqys5Fvt1aNYliFC43rHvjiNQ?= =?us-ascii?Q?26g/mg7W+v+8ibreYGfmNqWjWRNTpzgvQ8FsApXc6h+4K3vd4VtyY+ucCdy2?= =?us-ascii?Q?7fZ87ZYWqgKBsGpq9iGh+123tzvKgcw4ftgXCtTXdSFGwENN7zRg57vD1OYY?= =?us-ascii?Q?g/Wnf0mQRD0R9N/vOa9YBsnpmfDBlipWb6+1ks6XRIG36Eom/EqRO9D6azRW?= =?us-ascii?Q?xoIIgcnlPXW8/Wogc667gCM5B1gfQE8/GG2CBC/g8sdNOmF4buhF0MSCeLPE?= =?us-ascii?Q?H7EJqHzA9AbdLIvfsmHLd/3OurErw03O0h3JnNXjMX2vim1D2vQV/0lsEHq7?= =?us-ascii?Q?YRKnymfpHMpvwIwN0kEQx/7PxCAMYGHs?= 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)(376014)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 0MSWyTjnaC63ynN3dfpPknZwEPq1BQdEjA8V1BXK4p+HDB4rLAp8p7dvIDGBA7xuaPXbGycYoUteU8q8KDFFTl5ot8a+1am83gRk/ClPKN8tfX7sismOtu1TFuFpnqVQKaUZMam6ZM+fVsIwJSXeEzpMyTv5g41sbRibfxOhCJcF+s0SgtpRbwclGxyOso2icrJBMoJvfoO0oA/VoWo7w7Kx2JprlyNtvAdM2K9HyqWbpEeGNUEDq9uRBUC2oWOgkv2jM2/WwgfcbdTMa2gHeiBFMJ02NjDNSCaajqu7az7uUTT2LhM/GStl85FCldgYB14oTRQy/Ae7D8SR+C6LBqc2VKxd8mNl0cHC0lIwFcwsvylCrQbP3nn89XE9we8AAWOyxCZqm7dX0qFa559M5S0GOG4awwWPwf+OAohQywPg7V+2+LGintXGiO5RJJDeyv4XNzPsydn10mQef24bt84rEUKY3zymVXdvJrP7UUNGadCMpwV2psfaikp91+WxQHJFMN4DVpJY7puAn+jajelxI5bVyqbyvOXwMqxBiVz9vvlpJwkHyUU8ZXekQPz0DjR7WWu8RbndjhzK5ym8mD+5Sfrxisa9UZ0LyvgvW56mYvWh/i9QlpOFrUzhH4G3il6nVdOH52Xa6nn3fnI22DltjfjEwBj9lM3RwQ7rt+8= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2024 12:02:20.2896 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0e64653f-8539-4349-cc3b-08dca58f255f 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: DU6PEPF0000A7DD.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXP190MB2153 X-BESS-ID: 1721131345-305467-20588-17412-2 X-BESS-VER: 2019.1_20240702.1505 X-BESS-Apparent-Source-IP: 104.47.17.104 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.257662 [from cloudscan16-26.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