[RFC,04/29] net/qdma: add logging support

Message ID 20220706075219.517046-5-aman.kumar@vvdntech.in (mailing list archive)
State Changes Requested, archived
Delegated to: Thomas Monjalon
Headers
Series cover letter for net/qdma PMD |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Aman Kumar July 6, 2022, 7:51 a.m. UTC
define macro for logging across PMD files

Signed-off-by: Aman Kumar <aman.kumar@vvdntech.in>
---
 drivers/net/qdma/qdma_ethdev.c |  1 +
 drivers/net/qdma/qdma_log.h    | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)
 create mode 100644 drivers/net/qdma/qdma_log.h
  

Comments

Stephen Hemminger July 6, 2022, 3:27 p.m. UTC | #1
On Wed,  6 Jul 2022 13:21:54 +0530
Aman Kumar <aman.kumar@vvdntech.in> wrote:

> +extern int qdma_logtype_pmd;
> +#define PMD_DRV_LOG(level, fmt, args...) \
> +	rte_log(RTE_LOG_ ## level, qdma_logtype_pmd, "%s(): " \
> +		fmt "\n", __func__, ## args)

Did  you test this. Looks like your log messages are going
to end up double spaced. Because many of the later calls put a
newline on the message. Example:

+	PMD_DRV_LOG(INFO, "QDMA devargs desc_prefetch is: %s\n", value);
  
Aman Kumar July 7, 2022, 2:32 a.m. UTC | #2
On 06/07/22 8:57 pm, Stephen Hemminger wrote:
> On Wed,  6 Jul 2022 13:21:54 +0530
> Aman Kumar <aman.kumar@vvdntech.in> wrote:
>
>> +extern int qdma_logtype_pmd;
>> +#define PMD_DRV_LOG(level, fmt, args...) \
>> +	rte_log(RTE_LOG_ ## level, qdma_logtype_pmd, "%s(): " \
>> +		fmt "\n", __func__, ## args)
> Did  you test this. Looks like your log messages are going
> to end up double spaced. Because many of the later calls put a
> newline on the message. Example:
>
> +	PMD_DRV_LOG(INFO, "QDMA devargs desc_prefetch is: %s\n", value);

Additional lines did not bother us during feature testing. I'll fix this 
in v2.
Thanks for pointing this.
  

Patch

diff --git a/drivers/net/qdma/qdma_ethdev.c b/drivers/net/qdma/qdma_ethdev.c
index 35d7c88658..8dbc7c4ac1 100644
--- a/drivers/net/qdma/qdma_ethdev.c
+++ b/drivers/net/qdma/qdma_ethdev.c
@@ -105,3 +105,4 @@  static struct rte_pci_driver rte_qdma_pmd = {
 
 RTE_PMD_REGISTER_PCI(net_qdma, rte_qdma_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_qdma, qdma_pci_id_tbl);
+RTE_LOG_REGISTER_DEFAULT(qdma_logtype_pmd, NOTICE);
diff --git a/drivers/net/qdma/qdma_log.h b/drivers/net/qdma/qdma_log.h
new file mode 100644
index 0000000000..e65b0a5d8c
--- /dev/null
+++ b/drivers/net/qdma/qdma_log.h
@@ -0,0 +1,16 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2017-2022 Xilinx, Inc. All rights reserved.
+ * Copyright(c) 2022 VVDN Technologies Private Limited. All rights reserved.
+ */
+
+#ifndef __QDMA_LOG_H__
+#define __QDMA_LOG_H__
+
+#include <rte_log.h>
+
+extern int qdma_logtype_pmd;
+#define PMD_DRV_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, qdma_logtype_pmd, "%s(): " \
+		fmt "\n", __func__, ## args)
+
+#endif /* ifndef __QDMA_LOG_H__ */