dpdk: make dpdk global debug level configurable 25/6825/3
authorDamjan Marion <damarion@cisco.com>
Mon, 22 May 2017 13:32:04 +0000 (15:32 +0200)
committerDave Barach <openvpp@barachs.net>
Mon, 22 May 2017 16:10:07 +0000 (16:10 +0000)
Adds startup.conf knob:

dpdk {
log-level debug
}

Change-Id: I80dfbc00559528d7b0970958fba9f08d97aa7118
Signed-off-by: Damjan Marion <damarion@cisco.com>
src/plugins/dpdk/device/dpdk.h
src/plugins/dpdk/device/format.c
src/plugins/dpdk/device/init.c

index 6364d16..ab5da56 100644 (file)
@@ -432,7 +432,7 @@ format_function_t format_dpdk_tx_dma_trace;
 format_function_t format_dpdk_rx_dma_trace;
 format_function_t format_dpdk_rte_mbuf;
 format_function_t format_dpdk_rx_rte_mbuf;
-unformat_function_t unformat_socket_mem;
+unformat_function_t unformat_dpdk_log_level;
 clib_error_t *unformat_rss_fn (unformat_input_t * input, uword * rss_fn);
 clib_error_t *unformat_hqos (unformat_input_t * input,
                             dpdk_device_config_hqos_t * hqos);
index 0b67eae..8fe6689 100644 (file)
   foreach_dpdk_pkt_rx_offload_flag              \
   foreach_dpdk_pkt_tx_offload_flag
 
+#define foreach_dpdk_log_level \
+  _ (EMERG, "emergency")       \
+  _ (ALERT, "alert")           \
+  _ (CRIT, "critical")         \
+  _ (ERR, "error")             \
+  _ (WARNING, "warning")       \
+  _ (NOTICE, "notice")         \
+  _ (INFO, "info")             \
+  _ (DEBUG, "debug")
+
 u8 *
 format_dpdk_device_name (u8 * s, va_list * args)
 {
@@ -704,36 +714,6 @@ format_dpdk_rte_mbuf (u8 * s, va_list * va)
   return s;
 }
 
-/* FIXME is this function used? */
-#if 0
-uword
-unformat_socket_mem (unformat_input_t * input, va_list * va)
-{
-  uword **r = va_arg (*va, uword **);
-  int i = 0;
-  u32 mem;
-
-  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
-    {
-      if (unformat (input, ","))
-       hash_set (*r, i, 1024);
-      else if (unformat (input, "%u,", &mem))
-       hash_set (*r, i, mem);
-      else if (unformat (input, "%u", &mem))
-       hash_set (*r, i, mem);
-      else
-       {
-         unformat_put_input (input);
-         goto done;
-       }
-      i++;
-    }
-
-done:
-  return 1;
-}
-#endif
-
 clib_error_t *
 unformat_rss_fn (unformat_input_t * input, uword * rss_fn)
 {
@@ -757,6 +737,20 @@ unformat_rss_fn (unformat_input_t * input, uword * rss_fn)
   return 0;
 }
 
+uword
+unformat_dpdk_log_level (unformat_input_t * input, va_list * args)
+{
+  u32 *r = va_arg (*args, u32 *);
+
+  if (0);
+#define _(v,s) else if (unformat (input, s)) *r = RTE_LOG_##v;
+  foreach_dpdk_log_level
+#undef _
+    else
+    return 0;
+  return 1;
+}
+
 clib_error_t *
 unformat_hqos (unformat_input_t * input, dpdk_device_config_hqos_t * hqos)
 {
index 545a15e..a972394 100755 (executable)
@@ -810,6 +810,7 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input)
   dpdk_device_config_t *devconf;
   vlib_pci_addr_t pci_addr;
   unformat_input_t sub_input;
+  uword x;
   u8 *s, *tmp = 0;
   u8 *rte_cmd = 0, *ethname = 0;
   u32 log_level;
@@ -822,6 +823,7 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input)
   u8 *socket_mem = 0;
 
   conf->device_config_index_by_pci_addr = hash_create (0, sizeof (uword));
+  log_level = RTE_LOG_NOTICE;
 
   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
     {
@@ -838,6 +840,9 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input)
       else if (unformat (input, "decimal-interface-names"))
        conf->interface_name_format_decimal = 1;
 
+      else if (unformat (input, "log-level %U", unformat_dpdk_log_level, &x))
+       log_level = x;
+
       else if (unformat (input, "no-multi-seg"))
        conf->no_multi_seg = 1;
 
@@ -1175,8 +1180,6 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input)
 
   /* Set up DPDK eal and packet mbuf pool early. */
 
-  log_level = (CLIB_DEBUG > 0) ? RTE_LOG_DEBUG : RTE_LOG_NOTICE;
-
 #if RTE_VERSION >= RTE_VERSION_NUM(17, 5, 0, 0)
   rte_log_set_global_level (log_level);
 #else