[v3,02/18] net/r8169: add logging structure

Message ID 20241023033328.191827-3-howard_wang@realsil.com.cn (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series Modify some code as suggested by the maintainer. |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Howard Wang Oct. 23, 2024, 3:33 a.m. UTC
Implement logging macros for debug purposes.

Signed-off-by: Howard Wang <howard_wang@realsil.com.cn>
---
 drivers/net/r8169/r8169_ethdev.c |  9 ++++++
 drivers/net/r8169/r8169_logs.h   | 47 ++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)
 create mode 100644 drivers/net/r8169/r8169_logs.h
  

Patch

diff --git a/drivers/net/r8169/r8169_ethdev.c b/drivers/net/r8169/r8169_ethdev.c
index ec26bd2594..203907da3e 100644
--- a/drivers/net/r8169/r8169_ethdev.c
+++ b/drivers/net/r8169/r8169_ethdev.c
@@ -177,3 +177,12 @@  RTE_PMD_REGISTER_PCI(net_r8169, rte_r8169_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_r8169, pci_id_r8169_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_r8169, "* igb_uio | uio_pci_generic | vfio-pci");
 
+RTE_LOG_REGISTER_SUFFIX(r8169_logtype_init, init, NOTICE)
+RTE_LOG_REGISTER_SUFFIX(r8169_logtype_driver, driver, NOTICE)
+#ifdef RTE_ETHDEV_DEBUG_RX
+RTE_LOG_REGISTER_SUFFIX(r8169_logtype_rx, rx, DEBUG)
+#endif
+#ifdef RTE_ETHDEV_DEBUG_TX
+RTE_LOG_REGISTER_SUFFIX(r8169_logtype_tx, tx, DEBUG)
+#endif
+
diff --git a/drivers/net/r8169/r8169_logs.h b/drivers/net/r8169/r8169_logs.h
new file mode 100644
index 0000000000..4641089882
--- /dev/null
+++ b/drivers/net/r8169/r8169_logs.h
@@ -0,0 +1,47 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 Realtek Corporation. All rights reserved
+ */
+
+#ifndef _R8169_LOGS_H_
+#define _R8169_LOGS_H_
+
+#include <rte_log.h>
+
+extern int r8169_logtype_init;
+extern int r8169_logtype_driver;
+#ifdef RTE_ETHDEV_DEBUG_RX
+extern int r8169_logtype_rx;
+#endif
+#ifdef RTE_ETHDEV_DEBUG_TX
+extern int r8169_logtype_tx;
+#endif
+
+#define RTE_LOGTYPE_R8169_INIT   r8169_logtype_init
+#define RTE_LOGTYPE_R8169_RX     r8169_logtype_rx
+#define RTE_LOGTYPE_R8169_TX     r8169_logtype_tx
+#define RTE_LOGTYPE_R8169_DRIVER r8169_logtype_driver
+
+#define PMD_INIT_LOG(level, fmt, args...) \
+	RTE_LOG_DP(level, R8169_INIT, "%s(): " fmt "\n", __func__, ## args)
+
+#define PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, " >>")
+
+#ifdef RTE_ETHDEV_DEBUG_RX
+#define PMD_RX_LOG(level, fmt, args...) \
+	RTE_LOG_DP_LINE(level, R8169_RX, "%s(): " fmt "\n", __func__, ## args)
+#else
+#define PMD_RX_LOG(level, fmt, args...) do { } while (0)
+#endif
+
+#ifdef RTE_ETHDEV_DEBUG_TX
+#define PMD_TX_LOG(level, fmt, args...) \
+	RTE_LOG_DP_LINE(level, R8169_TX, "%s(): " fmt "\n", __func__, ## args)
+#else
+#define PMD_TX_LOG(level, fmt, args...) do { } while (0)
+#endif
+
+#define PMD_DRV_LOG(level, fmt, args...) \
+	RTE_LOG_DP_LINE(level, R8169_DRIVER, "%s(): " fmt, __func__, ## args)
+
+#endif /* _R8169_LOGS_H_ */
+