On 11/12/2024 9:57 AM, Howard Wang wrote:
> Implement logging macros for debug purposes.
>
> Signed-off-by: Howard Wang <howard_wang@realsil.com.cn>
>
<...>
> +
> +#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)
>
There is a checkpatch warning [1], that is to remove compiler extensions.
For this case it is basically replacing 'args...' with '...', in all
occurrences in the file. As else part of the macro just ignores the
arguments, this does not make any difference practically.
btw, you can run checkpatch on each patch by following command:
`./devtools/checkpatches.sh -n1`
The checkpatch results can be seen in the patchwork, like [2],
unfortunately in some patches 'Avoid CamelCase' causing too much noise,
locally you can disable them [3] to focus on the other warnings.
[1]
Warning in drivers/net/r8169/r8169_logs.h:
Do not use variadic argument pack in macros
[2]
https://mails.dpdk.org/archives/test-report/2024-November/823933.html
[3]
DPDK_CHECKPATCH_OPTIONS="--ignore=CAMELCASE" ./devtools/checkpatches.sh -n1
@@ -145,3 +145,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
new file mode 100644
@@ -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_ */