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

Message ID 20241025033529.15581-3-howard_wang@realsil.com.cn (mailing list archive)
State Superseded, 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. 25, 2024, 3:35 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
  

Comments

Stephen Hemminger Oct. 28, 2024, 2:28 a.m. UTC | #1
On Fri, 25 Oct 2024 11:35:13 +0800
Howard Wang <howard_wang@realsil.com.cn> wrote:

> Implement logging macros for debug purposes.
> 
> Signed-off-by: Howard Wang <howard_wang@realsil.com.cn>

Did you see this from checkpatch? Probably not because it was buried
in all the CamelCase warnings.

Warning in drivers/net/r8169/r8169_logs.h:
Prefer RTE_LOG_LINE/RTE_LOG_DP_LINE
Warning in drivers/net/r8169/r8169_logs.h:
Do not use variadic argument pack in macros
  

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..9bef517176
--- /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, 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, __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, __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_ */