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 2706845635; Wed, 17 Jul 2024 15:33:29 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 47D13406B8; Wed, 17 Jul 2024 15:33:24 +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 8010040261 for ; Wed, 17 Jul 2024 15:33:20 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2104.outbound.protection.outlook.com [104.47.17.104]) by mx-outbound40-186.eu-central-1c.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 17 Jul 2024 13:33:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=O8Ui2edBSwp/up5iFZH3FhXxdWcyKHX/Vxs2BHqS6ufggliQLrZ7IscOlmh2Pdzgkd2KufdNyLQbKIWoGOac+jwk00059LOZZ5O4UL0MYipLMjpKGDz65uSKJr9D9QT38gm2iFx1hRF6Bn3wlBkZc0mlSDHITH1PjAQnas1vKcVHyh5Jhy2qx7Hmv9rfHx3LoP+fxHElICBzqGSmHlyMbUqPgjzLSmkLrx+TkDbHb+iaAYUeMraHnSM9gV8I9jThdX9sVX/i3IPwK5daEjk7f3kwf6lgitjLeB+/PNF1hyDJnqX21Kmxg3QQ2NiBFZ9ZwTKjDg8rgfrMJ2GlWP2JvA== 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=/U7TT34zBJLbpzhRVqqH8qvYI/2pWeADSasihaN5/Q8=; b=hMr+qQfB8E4zuE68yWmURE4IzSOf1u9J+Yv8iOStJn6MRC18BsdBpJaGY7YBkxddOQN+rLye6PUB4Ihk4hsci6KoIp6ExjFiX8ocsom+NblYL6ab9uAhc/ZGq25KP2M6/kr6ajZDsIt+gbYz3ahAzXlMZ3HlX+obt6SiD8j1jPsEcETYbCtf6zsky6VY405pzM/V0I09Wip4VYGJHB8Tkw5QscOhf/dMrWZ/mws6jkM9+Ox7MSvW83f0I4mz55Uz1ZkhUuI7fG7NP0Ft2gh+6KALGUloqNyXKandcfjypfbF3Msdm9Sp1wOz/77Wnl0c5EyvtBGc3YYk5A+e3/0u4g== 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=/U7TT34zBJLbpzhRVqqH8qvYI/2pWeADSasihaN5/Q8=; b=jiEL0ewdT0asNeiDIp+SYTm+1Ohfg1sb6CsJaUN0flkp3c0sPdS80YBfZz3zYOkCL+lvPNIEHI/Stdn0BPcN+SiL10wbzFZjRg+23bbriv4WJYwvQ+9wN2a1FWHtouu1dCdSNk0NvcTblO4BKLfQHc3rISUIoCo0SXqnWaj4dac= Received: from AM0PR04CA0087.eurprd04.prod.outlook.com (2603:10a6:208:be::28) by AM9P190MB1170.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:26a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.16; Wed, 17 Jul 2024 13:33:17 +0000 Received: from AM3PEPF0000A799.eurprd04.prod.outlook.com (2603:10a6:208:be:cafe::d1) by AM0PR04CA0087.outlook.office365.com (2603:10a6:208:be::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.16 via Frontend Transport; Wed, 17 Jul 2024 13:33:17 +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 AM3PEPF0000A799.mail.protection.outlook.com (10.167.16.104) with Microsoft SMTP Server id 15.20.7784.11 via Frontend Transport; Wed, 17 Jul 2024 13:33:17 +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 v10 02/21] net/ntnic: add logging implementation Date: Wed, 17 Jul 2024 15:32:49 +0200 Message-ID: <20240717133313.3104239-2-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240717133313.3104239-1-sil-plv@napatech.com> References: <20240530144929.4127931-1-sil-plv@napatech.com> <20240717133313.3104239-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM3PEPF0000A799:EE_|AM9P190MB1170:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: a767fb09-b592-41fa-47c7-08dca665049c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|82310400026|1800799024|376014; X-Microsoft-Antispam-Message-Info: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2sNVpTtYPZeE3YW97knOBHVr?= =?us-ascii?Q?qEvQklDT02CO+KQTkA0lx2ypVuuS8k0b04wnZABiyqIXlbrXMSqL7FOpqjW/?= =?us-ascii?Q?I7bBdi+2U4ZZeFDT10cuyFcyfheK0W1a2Bx5TZK3PmsjKLGR8DMAL6Avd1aZ?= =?us-ascii?Q?wIGq5aTEu95TBu9wzzw5sAYJOckUwRsYHD6JQrAgZzWZeDonNtr70L+fvPfC?= =?us-ascii?Q?N1vweVa6DLodIiSWdgwzk4Nik4FUVZR8gjPJmcrJ/2/gWlucbNB0VVSfdVN/?= =?us-ascii?Q?06cDcjJt+KUsDrx+J7oi457SYmuvLi76XNWgYzl9CXLSPZDWDc7qNRntjAlM?= =?us-ascii?Q?QXNnPatdhSWxu3PhV6ZsYdqCfDRG5kU9kvvSlDjMqL1xrmSDIw+umfEyNAEa?= =?us-ascii?Q?ftj852qg5oM9HTDWgKNRSfNGlPVeU0penNuBx2qjoX6WVlELHxppQJK0dVuk?= =?us-ascii?Q?66hPTLdZ8/cIJdAqXDLRu/DvxJWGjQ24VUIzZX9jWkgBivc67q0O1H/tWbXS?= =?us-ascii?Q?iNfOXh40N2scIMoloa7kM5Bn2z9oOkhdoMMw1Wt95kceJaGQn2y8K9YqOpIs?= =?us-ascii?Q?fgw913B8wPExhSA/tNdDt55Z32dvD0AD?= 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)(36860700013)(82310400026)(1800799024)(376014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Ukjawarj3m7/xQUCPr8vxa5ptbNmZlrQkKpof/U6ze9zbadQz47b/Mo0bvJxUOMaon9DPLUEjQTY610AfSj3ZlXpWHBgYX4zs4oEcgH3baC46BpenRkCTZkZGtws6B7yGwjrONkyq9/PKl/qZ/KsD/pTF+LP+oKvPMJSq9p+H2c4n6bbxNfgYz+PK0+H3E3xZ0ib6cMPsS9Tbt9Hlxghkz8fUr107K7uhl8AV9pi2Qf+Uq8sesLSs+jZ0ckJ/C97otrSJ9/6uu/wU47TyDyt0Gi2p8h1d+aMzdO4Qfk9a9wnPJfI9TE++NhJSq+CYgDiDplHBeTsX4+bSWny+JlkDHGyeXn1du0wnYacLOnMyAWyigHzyMD1x3pRibYE8rn4gpc9PnK3MSu3RbLU7n/R3f47Mr7kQDKkpI7WEjYflisxlwYUNdzOeH/vhaabmpoete2eV9Z1dG9QE8DERMqIZrldM29LKkDtBNg5f0y44N9Fk8B/57YN+coEehljimhStGXT1A28+jcMOGprfftJwoAtqHEYr/GgyYZsshYcSW5xMiCTqTgOk48Rt2AiGU1mqhXdR21UtAZrqf3+Sqf6J00i2CEZibMCwyJsdXSZMKPxz8n48MKnA1TCsay5uRwA95xCFhWPDm8TUqUJdFREqA== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2024 13:33:17.6995 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a767fb09-b592-41fa-47c7-08dca665049c 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: AM3PEPF0000A799.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9P190MB1170 X-BESS-ID: 1721223199-310426-12657-15008-1 X-BESS-VER: 2019.1_20240716.1757 X-BESS-Apparent-Source-IP: 104.47.17.104 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVibGRiZAVgZQMDXZMNnQwsjM0s Aw0dLQwNQg1TjV0szU3DDN3DDJLDVRqTYWAOWNSYRBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.257687 [from cloudscan13-15.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 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 v10 * Use 8 spaces as indentation in meson --- 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 368fffa81b..44d59c34ae 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.43.0