Soft Patch Panel
 help / color / mirror / Atom feed
* [spp] [PATCH 0/3] Add utility functions for debug log
@ 2018-12-21  4:10 ogawa.yasufumi
  2018-12-21  4:10 ` [spp] [PATCH 1/3] shared: add util functions to set log level ogawa.yasufumi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: ogawa.yasufumi @ 2018-12-21  4:10 UTC (permalink / raw)
  To: ferruh.yigit, spp, ogawa.yasufumi

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

Hi,

Dynamic logging of DPDK is useful to configure log level only for
required modules. However, it is a little complex to use, for example,
for changing log level of type of `user*` simply to RTE_LOG_DEBUG.

This update is to add utility functions to change the log level of
`user*` in more simple way. If you change the level of RTE_LOGTYPE_USER1
to RTE_LOG_DEBUG, simply call `set_user_log_debug(1)`. You are also able
to change to any of log level like as
`set_user_log_level(1, RTE_LOG_INFO)`.

Default global log level is RTE_LOG_INFO, so you should change global
level with `--log-level` option of EAL from command line or call
`rte_log_set_global_level()` from inside of your program. 

Thanks,
Yasufumi

Yasufumi Ogawa (3):
  shared: add util functions to set log level
  primary: change dynamic log level to RTE_LOG_DEBUG
  spp_nfv: change dynamic log level to RTE_LOG_DEBUG

 src/nfv/nfv.c       |  2 ++
 src/primary/main.c  |  2 ++
 src/shared/common.c | 37 ++++++++++++++++++++++++++++++++++++-
 src/shared/common.h |  6 ++++++
 4 files changed, 46 insertions(+), 1 deletion(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [spp] [PATCH 1/3] shared: add util functions to set log level
  2018-12-21  4:10 [spp] [PATCH 0/3] Add utility functions for debug log ogawa.yasufumi
@ 2018-12-21  4:10 ` ogawa.yasufumi
  2018-12-21  4:10 ` [spp] [PATCH 2/3] primary: change dynamic log level to RTE_LOG_DEBUG ogawa.yasufumi
  2018-12-21  4:10 ` [spp] [PATCH 3/3] spp_nfv: " ogawa.yasufumi
  2 siblings, 0 replies; 4+ messages in thread
From: ogawa.yasufumi @ 2018-12-21  4:10 UTC (permalink / raw)
  To: ferruh.yigit, spp, ogawa.yasufumi

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

This update is to add utility functions to change the log level of
`user*` in more simple way. If you change the level of RTE_LOGTYPE_USER1
to RTE_LOG_DEBUG, simply call `set_user_log_debug(1)`. You can also
change to any of log level like as `set_user_log_level(1, RTE_LOG_INFO)`.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/shared/common.c | 37 ++++++++++++++++++++++++++++++++++++-
 src/shared/common.h |  6 ++++++
 2 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/src/shared/common.c b/src/shared/common.c
index 0e32fa6..8837ff9 100644
--- a/src/shared/common.c
+++ b/src/shared/common.c
@@ -66,6 +66,41 @@ check_all_ports_link_status(struct port_info *ports, uint16_t port_num,
 }
 
 /**
+ * Set log level of type RTE_LOGTYPE_USER* to given level, for instance,
+ * RTE_LOG_INFO or RTE_LOG_DEBUG.
+ *
+ * This function is typically used to output debug log as following.
+ *
+ *   #define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1
+ *   ...
+ *   set_user_log_level(1, RTE_LOG_DEBUG);
+ *   ...
+ *   RTE_LOG(APP, DEBUG, "Your debug log...");
+ */
+int
+set_user_log_level(int num_user_log, uint32_t log_level)
+{
+	char userlog[8];
+
+	if (num_user_log < 1 || num_user_log > 8)
+		return -1;
+
+	memset(userlog, '\0', sizeof(userlog));
+	sprintf(userlog, "user%d", num_user_log);
+
+	rte_log_set_level(rte_log_register(userlog), log_level);
+	return 0;
+}
+
+/* Set log level of type RTE_LOGTYPE_USER* to RTE_LOG_DEBUG. */
+int
+set_user_log_debug(int num_user_log)
+{
+	set_user_log_level(num_user_log, RTE_LOG_DEBUG);
+	return 0;
+}
+
+/**
  * Initialise an individual port:
  * - configure number of rx and tx rings
  * - set up each rx ring, to pull from the main mbuf pool
@@ -538,7 +573,7 @@ dev_detach_by_port_id(uint16_t port_id)
 
 	if (rte_eth_devices[port_id].data == NULL) {
 		RTE_LOG(INFO, APP,
-			"rte_eth_devices[%d].data is  NULL\n", port_id);
+			"rte_eth_devices[%"PRIu16"].data is  NULL\n", port_id);
 		return 0;
 	}
 	dev_flags = rte_eth_devices[port_id].data->dev_flags;
diff --git a/src/shared/common.h b/src/shared/common.h
index 09dbf8a..326343e 100644
--- a/src/shared/common.h
+++ b/src/shared/common.h
@@ -188,6 +188,12 @@ get_null_pmd_name(int id)
 	return buffer;
 }
 
+/* Set log level of type RTE_LOGTYPE_USER* to given level. */
+int set_user_log_level(int num_user_log, uint32_t log_level);
+
+/* Set log level of type RTE_LOGTYPE_USER* to RTE_LOG_DEBUG. */
+int set_user_log_debug(int num_user_log);
+
 void check_all_ports_link_status(struct port_info *ports, uint16_t port_num,
 		uint32_t port_mask);
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [spp] [PATCH 2/3] primary: change dynamic log level to RTE_LOG_DEBUG
  2018-12-21  4:10 [spp] [PATCH 0/3] Add utility functions for debug log ogawa.yasufumi
  2018-12-21  4:10 ` [spp] [PATCH 1/3] shared: add util functions to set log level ogawa.yasufumi
@ 2018-12-21  4:10 ` ogawa.yasufumi
  2018-12-21  4:10 ` [spp] [PATCH 3/3] spp_nfv: " ogawa.yasufumi
  2 siblings, 0 replies; 4+ messages in thread
From: ogawa.yasufumi @ 2018-12-21  4:10 UTC (permalink / raw)
  To: ferruh.yigit, spp, ogawa.yasufumi

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

Change dynamic log level to RTE_LOG_DEBUG to be enable to output debug
log if it is launched with `--log-level 8`.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/primary/main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/primary/main.c b/src/primary/main.c
index d991bca..825a8bf 100644
--- a/src/primary/main.c
+++ b/src/primary/main.c
@@ -393,6 +393,8 @@ main(int argc, char *argv[])
 	if (init(argc, argv) < 0)
 		return -1;
 
+	set_user_log_debug(1);
+
 	RTE_LOG(INFO, APP, "Finished Process Init.\n");
 
 	/* clear statistics */
-- 
2.7.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [spp] [PATCH 3/3] spp_nfv: change dynamic log level to RTE_LOG_DEBUG
  2018-12-21  4:10 [spp] [PATCH 0/3] Add utility functions for debug log ogawa.yasufumi
  2018-12-21  4:10 ` [spp] [PATCH 1/3] shared: add util functions to set log level ogawa.yasufumi
  2018-12-21  4:10 ` [spp] [PATCH 2/3] primary: change dynamic log level to RTE_LOG_DEBUG ogawa.yasufumi
@ 2018-12-21  4:10 ` ogawa.yasufumi
  2 siblings, 0 replies; 4+ messages in thread
From: ogawa.yasufumi @ 2018-12-21  4:10 UTC (permalink / raw)
  To: ferruh.yigit, spp, ogawa.yasufumi

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

Change dynamic log level to RTE_LOG_DEBUG to be enable to output debug
log if it is launched with `--log-level 8`.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/nfv/nfv.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/nfv/nfv.c b/src/nfv/nfv.c
index c74ebe5..e2160da 100644
--- a/src/nfv/nfv.c
+++ b/src/nfv/nfv.c
@@ -959,6 +959,8 @@ main(int argc, char *argv[])
 		ports = mz->addr;
 	}
 
+	set_user_log_debug(1);
+
 	RTE_LOG(INFO, APP, "Number of Ports: %d\n", nb_ports);
 
 	/* update port_forward_array with active port */
-- 
2.7.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-12-21  4:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-21  4:10 [spp] [PATCH 0/3] Add utility functions for debug log ogawa.yasufumi
2018-12-21  4:10 ` [spp] [PATCH 1/3] shared: add util functions to set log level ogawa.yasufumi
2018-12-21  4:10 ` [spp] [PATCH 2/3] primary: change dynamic log level to RTE_LOG_DEBUG ogawa.yasufumi
2018-12-21  4:10 ` [spp] [PATCH 3/3] spp_nfv: " ogawa.yasufumi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).