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

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

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Howard Wang Oct. 28, 2024, 7:30 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   | 46 ++++++++++++++++++++++++++++++++
 2 files changed, 55 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 1f90a142c5..a5de322c9a 100644
--- a/drivers/net/r8169/r8169_ethdev.c
+++ b/drivers/net/r8169/r8169_ethdev.c
@@ -176,3 +176,12 @@  static struct rte_pci_driver rte_r8169_pmd = {
 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..09e78c191b
--- /dev/null
+++ b/drivers/net/r8169/r8169_logs.h
@@ -0,0 +1,46 @@ 
+/* 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, ...) \
+	RTE_LOG_LINE(level, R8169_INIT, "%s(): " fmt, __func__, ##__VA_ARGS__)
+
+#define PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, " >>")
+
+#ifdef RTE_ETHDEV_DEBUG_RX
+#define PMD_RX_LOG(level, fmt, ...) \
+	RTE_LOG_DP_LINE(level, R8169_RX, "%s(): " fmt, __func__, ##__VA_ARGS__)
+#else
+#define PMD_RX_LOG(level, fmt, args...) do { } while (0)
+#endif
+
+#ifdef RTE_ETHDEV_DEBUG_TX
+#define PMD_TX_LOG(level, fmt, ...) \
+	RTE_LOG_DP_LINE(level, R8169_TX, "%s(): " fmt, __func__, ##__VA_ARGS__)
+#else
+#define PMD_TX_LOG(level, fmt, args...) do { } while (0)
+#endif
+
+#define PMD_DRV_LOG(level, fmt, ...) \
+	RTE_LOG_LINE(level, R8169_DRIVER, "%s(): " fmt, __func__, ##__VA_ARGS__)
+
+#endif /* _R8169_LOGS_H_ */