event/sw: support dynamic logging
authorHarry van Haaren <harry.van.haaren@intel.com>
Thu, 25 Jan 2018 09:46:22 +0000 (09:46 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 31 Jan 2018 09:11:48 +0000 (10:11 +0100)
This commit enables dynamic logging with the SW pmd.
The string "pmd.event.sw" is used to change the verbosity
of the logging output, as per the newly defined log naming.

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
config/common_base
drivers/event/sw/sw_evdev.c
drivers/event/sw/sw_evdev.h
drivers/event/sw/sw_evdev_log.h [new file with mode: 0644]

index c560b73..751ba43 100644 (file)
@@ -584,7 +584,6 @@ CONFIG_RTE_LIBRTE_PMD_SKELETON_EVENTDEV_DEBUG=n
 # Compile PMD for software event device
 #
 CONFIG_RTE_LIBRTE_PMD_SW_EVENTDEV=y
-CONFIG_RTE_LIBRTE_PMD_SW_EVENTDEV_DEBUG=n
 
 #
 # Compile PMD for octeontx sso event device
index f9daf4f..6672fd8 100644 (file)
@@ -929,3 +929,15 @@ static struct rte_vdev_driver evdev_sw_pmd_drv = {
 RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_SW_PMD, evdev_sw_pmd_drv);
 RTE_PMD_REGISTER_PARAM_STRING(event_sw, NUMA_NODE_ARG "=<int> "
                SCHED_QUANTA_ARG "=<int>" CREDIT_QUANTA_ARG "=<int>");
+
+/* declared extern in header, for access from other .c files */
+int eventdev_sw_log_level;
+
+RTE_INIT(evdev_sw_init_log);
+static void
+evdev_sw_init_log(void)
+{
+       eventdev_sw_log_level = rte_log_register("pmd.event.sw");
+       if (eventdev_sw_log_level >= 0)
+               rte_log_set_level(eventdev_sw_log_level, RTE_LOG_NOTICE);
+}
index d4c534e..d90b96d 100644 (file)
@@ -5,6 +5,7 @@
 #ifndef _SW_EVDEV_H_
 #define _SW_EVDEV_H_
 
+#include "sw_evdev_log.h"
 #include <rte_eventdev.h>
 #include <rte_eventdev_pmd_vdev.h>
 #include <rte_atomic.h>
@@ -64,26 +65,6 @@ static const uint8_t sw_qe_flag_map[] = {
                QE_FLAG_VALID | QE_FLAG_COMPLETE | QE_FLAG_NOT_EOP,
 };
 
-#ifdef RTE_LIBRTE_PMD_SW_EVENTDEV_DEBUG
-#define SW_LOG_INFO(fmt, args...) \
-       RTE_LOG(INFO, EVENTDEV, "[%s] %s() line %u: " fmt "\n", \
-                       SW_PMD_NAME, \
-                       __func__, __LINE__, ## args)
-
-#define SW_LOG_DBG(fmt, args...) \
-       RTE_LOG(DEBUG, EVENTDEV, "[%s] %s() line %u: " fmt "\n", \
-                       SW_PMD_NAME, \
-                       __func__, __LINE__, ## args)
-#else
-#define SW_LOG_INFO(fmt, args...)
-#define SW_LOG_DBG(fmt, args...)
-#endif
-
-#define SW_LOG_ERR(fmt, args...) \
-       RTE_LOG(ERR, EVENTDEV, "[%s] %s() line %u: " fmt "\n", \
-                       SW_PMD_NAME, \
-                       __func__, __LINE__, ## args)
-
 /* Records basic event stats at a given point. Used in port and qid structs */
 struct sw_point_stats {
        uint64_t rx_pkts;
diff --git a/drivers/event/sw/sw_evdev_log.h b/drivers/event/sw/sw_evdev_log.h
new file mode 100644 (file)
index 0000000..f76825a
--- /dev/null
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Intel Corporation
+ */
+
+#ifndef _SW_EVDEV_LOG_H_
+#define _SW_EVDEV_LOG_H_
+
+extern int eventdev_sw_log_level;
+
+#define SW_LOG_IMPL(level, fmt, args...) \
+       rte_log(RTE_LOG_ ## level, eventdev_sw_log_level, "%s" fmt "\n", \
+                       __func__, ##args)
+
+#define SW_LOG_INFO(fmt, args...) \
+       SW_LOG_IMPL(INFO, fmt, ## args)
+
+#define SW_LOG_DBG(fmt, args...) \
+       SW_LOG_IMPL(DEBUG, fmt, ## args)
+
+#define SW_LOG_ERR(fmt, args...) \
+       SW_LOG_IMPL(ERR, fmt, ## args)
+
+#endif /* _SW_EVDEV_LOG_H_ */