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 1E65E4560F; Fri, 12 Jul 2024 11:49:03 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BF1E242ECA; Fri, 12 Jul 2024 11:48:47 +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 01E4342E89 for ; Fri, 12 Jul 2024 11:48:42 +0200 (CEST) Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02lp2040.outbound.protection.outlook.com [104.47.11.40]) by mx-outbound8-179.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 12 Jul 2024 09:48:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Elh1Gzx7BEI7N40evAyXPyQxoJDOFQL/4RLxIzqKc8TFFNiuz1+ONXkrH65ygBTsPWiwT4BgHMK0j3v9MwMlGasEsVm00EcEI4wejg8Otj6uXpM1BxeskuHaPLFsm9RD0QtVZvrgnjRnSiisErYYQVLn2hv++atv4HM5WMiWwapSYCWLdybgtBt4gak1Wm1MgwiX9I55UccgJFojyla5JNOHSFI17bNWp+w+DhlYoo2yuPa1JAUTf7ZpN5elGXYFmSmcE3+b8M3ZjomB3z4zmrTOhHwn1bkO2ErYDy/oni/KERMqDaVrhnep1Sgiz2+PpDJ4xZiC4TmjlVLSDTHXxA== 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=fAnwtMr4xDN6eelHsEXl/i41MCixWSCJoVbZzwI8Dys=; b=ZHSE3L6iSbjlY8707hhtfFBV7gG6GPK0gpY5n3xHoRS4OZAj0jdLyLuwX16mepCzbeybdYdPYrW2J2Erc2Ej82oOgCQJpkVE+NSgdWjXsXP9gCQh9UuBycnh99/dYO8kIC55izCsi9+wzH2wvd1CcQrUnpupwKnpBNEI6WOgdpP5P99ojKA4Dwegsds+9tr5rBtF6326jfvAhS1dc/OgoRl40w1IXz7nH8EIWjJQTzr1NN6b2YEyZdu93kJbVA+HfDCrh+DIHT1UssNScGq0VaNahBaXEmiwfDvXyBw/Ax6NOyHOy+Fgu/7eXqvB2ySM8oFVkaPS2CtScKqrAoqtUg== 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=fAnwtMr4xDN6eelHsEXl/i41MCixWSCJoVbZzwI8Dys=; b=To1JCit5cx+hpWB+5QS+YKRP1uRiJg3BB/E5Uajo5QRnMrY+XAsKdAuIzM74XJu+R1vv1XdgacofwzCCBOLmMPCkXZaYyN01zeNB81K6ZW+F+beM7NS2s3E92okf4cLYqFyh4KLQl3334xfsn3Z8ZI+jbZfVXRqWY3lwdrAfVWw= Received: from AS9PR06CA0528.eurprd06.prod.outlook.com (2603:10a6:20b:49d::15) by PA4P190MB1294.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:10a::14) 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 09:48:36 +0000 Received: from AM1PEPF000252DD.eurprd07.prod.outlook.com (2603:10a6:20b:49d:cafe::46) by AS9PR06CA0528.outlook.office365.com (2603:10a6:20b:49d::15) 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 09:48:36 +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 AM1PEPF000252DD.mail.protection.outlook.com (10.167.16.55) with Microsoft SMTP Server id 15.20.7762.17 via Frontend Transport; Fri, 12 Jul 2024 09:48:36 +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 v7 02/21] net/ntnic: add logging implementation Date: Fri, 12 Jul 2024 11:48:07 +0200 Message-ID: <20240712094831.861260-2-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240712094831.861260-1-sil-plv@napatech.com> References: <20240530144929.4127931-1-sil-plv@napatech.com> <20240712094831.861260-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM1PEPF000252DD:EE_|PA4P190MB1294:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: bdbd874b-5a7c-41f4-86ae-08dca257ccd6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info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NsDSn4py0hcFoHjChEJSS2QxKm6?= =?us-ascii?Q?SkUL0MG4E8AAHcNXXXaoUS3/NL/7TUU4yjl9ZfGr6C6d844IIYtgF+MjilM9?= =?us-ascii?Q?wEAOL3Z3iXN1mSFgtaXs6rboQr47K5ikWAGYvhVW1wcxJM/kr8SkbsBe4xTq?= =?us-ascii?Q?edzQHnpQwkaBKj+Ne4e6JSUGzQUA4Bzc92DZYfC+P7xS3oNKj6styjeQCCUb?= =?us-ascii?Q?9wAcbHFwDg/+96a8y9vimiPYWURAKcpzc6IjCode5sq6yspFhYUIe5RbH+I0?= =?us-ascii?Q?z76CAqvNQnCt0jxHvb+AVA+LFeXI6I3v9oWp15M9bq7mF2CZwKQO90f69RAS?= =?us-ascii?Q?Qc+Lgp3eMMcTb996PLvceETTxSlHeJ4WKzlUX9jjjm1wi70IxJkkeWHAOBCz?= =?us-ascii?Q?Niu0xv0wndwQZTukhnKFkVk3Gr4yP0ZNI+VA9ms5GgDXjBnwikNwTEdTu7gU?= =?us-ascii?Q?XNw6q2LlBeBejtcOg5nXFy7MLC8Rr5GxZTwP0q/F9pPGJ8iDfClQBR02fRd2?= =?us-ascii?Q?p1JGN4LAcyseD78cdFD7Oc8WLYvy1EZpKZtpvCaBKz+6vrjt/cG2ipiBV1rS?= =?us-ascii?Q?e6tR7lftra91Yh+UcT1CO+y6q6j0Xh0z?= 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)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: qMYTv1OYxqZM49GC+L6cTtvbSlVqBoqJCi4RDfeLLG4lrQEJGE31LNNC/YH//y4yKIj4cJPEih9cIYsYxdb+EgzzBw9tctNVs2bKzI91TO13xPnEnxRrgxtHLF9Scoley4ofTIKFJjctsQS6tzoK4yA70Uz5fkh512SueLkCvoO9oVMk261EDdIlyrp4q+XeIZ3Zhj3TYkUTJyKOqRil0ass357gjoiJ3E4+QixPscRmQJuTScV2dN/DCzJxkje9ZDvGeYkmGGfv0ACH4XaPVQ1rBSM7tyfyjdJDFUxBRlPd9BBB3bHakcM501/yezzQ1kUnOEbnQy8KJ68MmarwLrOZY2HM7jOzJa4qEkvhTnQ70FFJiztZO+Xgv+JFD6UqqL1eo0ZFJXImPOWjKI9MVv/hdmoXaPdsRdg0VYepwbBhseh0p4BbzRWOY7HnE+m3FDZ76Qq7aHbO3UltHTHNwPgAFtcKI0ORvLMa7kH/Iy8FOHsIaCE+QYTdk2rPz+bu/DWxcSCwYEo70K0sxAwTz1tCffdvul86nSGWXJDNzDSRewiRkgqPAXm0e+0hd7Kt0HHlnR446tCMM0EQpDq+ap4SykXDnbApx8h/eVuETbZk3u+7/xJPNSOy/tVy0fivplXs444cjdM7V832cWnkbA== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2024 09:48:36.0827 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bdbd874b-5a7c-41f4-86ae-08dca257ccd6 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: AM1PEPF000252DD.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4P190MB1294 X-BESS-ID: 1720777719-302227-12678-8263-2 X-BESS-VER: 2019.1_20240702.1505 X-BESS-Apparent-Source-IP: 104.47.11.40 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKViaGFpZAVgZQMNEyySDRwDglyT gpxczQ0MjEKNUwKSXF2Mg4LdHMMtFSqTYWAJecQ+1BAAAA X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.257571 [from cloudscan18-124.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 --- 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