From: "WanRenyong" <wanry@yunsilicon.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@amd.com>, <thomas@monjalon.net>,
"WanRenyong" <wanry@yunsilicon.com>
Subject: [PATCH v2 02/19] net/xsc: add log macro
Date: Wed, 11 Sep 2024 10:07:23 +0800 [thread overview]
Message-ID: <20240911020740.3950704-3-wanry@yunsilicon.com> (raw)
Add log macro to print runtime messages and trace functions.
Signed-off-by: WanRenyong <wanry@yunsilicon.com>
---
drivers/net/xsc/xsc_ethdev.c | 11 +++++++++
drivers/net/xsc/xsc_log.h | 44 ++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+)
create mode 100644 drivers/net/xsc/xsc_log.h
diff --git a/drivers/net/xsc/xsc_ethdev.c b/drivers/net/xsc/xsc_ethdev.c
index 0e48cb76fa..58ceaa3940 100644
--- a/drivers/net/xsc/xsc_ethdev.c
+++ b/drivers/net/xsc/xsc_ethdev.c
@@ -1,3 +1,14 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright 2024 Yunsilicon Technology Co., Ltd.
*/
+
+#include "xsc_log.h"
+
+RTE_LOG_REGISTER_SUFFIX(xsc_logtype_init, init, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(xsc_logtype_driver, driver, NOTICE);
+#ifdef RTE_ETHDEV_DEBUG_RX
+RTE_LOG_REGISTER_SUFFIX(xsc_logtype_rx, rx, DEBUG);
+#endif
+#ifdef RTE_ETHDEV_DEBUG_TX
+RTE_LOG_REGISTER_SUFFIX(xsc_logtype_tx, tx, DEBUG);
+#endif
diff --git a/drivers/net/xsc/xsc_log.h b/drivers/net/xsc/xsc_log.h
new file mode 100644
index 0000000000..163145ff09
--- /dev/null
+++ b/drivers/net/xsc/xsc_log.h
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2024 Yunsilicon Technology Co., Ltd.
+ */
+
+#ifndef _XSC_LOG_H_
+#define _XSC_LOG_H_
+
+#include <rte_log.h>
+
+extern int xsc_logtype_init;
+extern int xsc_logtype_driver;
+
+#define PMD_INIT_LOG(level, fmt, ...) \
+ rte_log(RTE_LOG_ ## level, xsc_logtype_init, "%s(): " fmt "\n", \
+ __func__, ##__VA_ARGS__)
+
+#define PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, " >>")
+
+#ifdef RTE_ETHDEV_DEBUG_RX
+extern int xsc_logtype_rx;
+#define PMD_RX_LOG(level, fmt, ...) \
+ rte_log(RTE_LOG_ ## level, xsc_logtype_rx, \
+ "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
+#else
+#define PMD_RX_LOG(level, fmt, ...) do { } while (0)
+#endif
+
+#ifdef RTE_ETHDEV_DEBUG_TX
+extern int xsc_logtype_tx;
+#define PMD_TX_LOG(level, fmt, ...) \
+ rte_log(RTE_LOG_ ## level, xsc_logtype_tx, \
+ "%s(): " fmt "\n", __func__, ##__VA_ARGS__)
+#else
+#define PMD_TX_LOG(level, fmt, ...) do { } while (0)
+#endif
+
+#define PMD_DRV_LOG_RAW(level, fmt, ...) \
+ rte_log(RTE_LOG_ ## level, xsc_logtype_driver, "%s(): " fmt, \
+ __func__, ##__VA_ARGS__)
+
+#define PMD_DRV_LOG(level, fmt, ...) \
+ PMD_DRV_LOG_RAW(level, fmt "\n", ##__VA_ARGS__)
+
+#endif /* _XSC_LOG_H_ */
--
2.25.1
next reply other threads:[~2024-09-11 2:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-11 2:07 WanRenyong [this message]
2024-09-11 7:40 ` David Marchand
2024-09-12 1:22 ` WanRenyong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240911020740.3950704-3-wanry@yunsilicon.com \
--to=wanry@yunsilicon.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).