DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] vhost: use dynamic log type
@ 2019-11-12 21:47 Stephen Hemminger
  2020-01-09 14:44 ` Maxime Coquelin
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2019-11-12 21:47 UTC (permalink / raw)
  To: maxime.coquelin; +Cc: dev, Stephen Hemminger

Rather than overloading USER1 and USER2 logtypes,
use a DPDK dynamic log type.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_vhost/vhost.c | 12 ++++++++++++
 lib/librte_vhost/vhost.h |  5 +++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
index 1cbe948f7470..9149770a16f5 100644
--- a/lib/librte_vhost/vhost.c
+++ b/lib/librte_vhost/vhost.c
@@ -27,6 +27,8 @@
 
 struct virtio_net *vhost_devices[MAX_VHOST_DEVICE];
 
+int vhost_logtype_config, vhost_logtype_data;
+
 /* Called with iotlb_lock read-locked */
 uint64_t
 __vhost_iova_to_vva(struct virtio_net *dev, struct vhost_virtqueue *vq,
@@ -1457,3 +1459,13 @@ int rte_vhost_extern_callback_register(int vid,
 	dev->extern_data = ctx;
 	return 0;
 }
+
+RTE_INIT(rte_vhost_init_log)
+{
+	vhost_logtype_config = rte_log_register("lib.vhost.config");
+	if (vhost_logtype_config >= 0)
+		rte_log_set_level(vhost_logtype_config, RTE_LOG_NOTICE);
+	vhost_logtype_data = rte_log_register("lib.vhost.data");
+	if (vhost_logtype_data >= 0)
+		rte_log_set_level(vhost_logtype_data, RTE_LOG_NOTICE);
+}
diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
index 9f11b28a31bf..87ce24991c26 100644
--- a/lib/librte_vhost/vhost.h
+++ b/lib/librte_vhost/vhost.h
@@ -499,8 +499,9 @@ vhost_log_write_iova(struct virtio_net *dev, struct vhost_virtqueue *vq,
 }
 
 /* Macros for printing using RTE_LOG */
-#define RTE_LOGTYPE_VHOST_CONFIG RTE_LOGTYPE_USER1
-#define RTE_LOGTYPE_VHOST_DATA   RTE_LOGTYPE_USER1
+extern int vhost_logtype_config, vhost_logtype_data;
+#define RTE_LOGTYPE_VHOST_CONFIG vhost_logtype_config
+#define RTE_LOGTYPE_VHOST_DATA   vhost_logtype_data
 
 #ifdef RTE_LIBRTE_VHOST_DEBUG
 #define VHOST_MAX_PRINT_BUFF 6072
-- 
2.20.1


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

end of thread, other threads:[~2020-01-09 14:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-12 21:47 [dpdk-dev] [PATCH] vhost: use dynamic log type Stephen Hemminger
2020-01-09 14:44 ` Maxime Coquelin

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).