memif: add severity to counters 07/31607/3
authorOle Troan <ot@cisco.com>
Wed, 10 Mar 2021 11:52:53 +0000 (12:52 +0100)
committerDamjan Marion <dmarion@me.com>
Thu, 6 May 2021 11:10:55 +0000 (11:10 +0000)
Also rename counters in stat segment to make them more filesystem friendly.

Type: improvement
Signed-off-by: Ole Troan <ot@cisco.com>
Change-Id: I8a3f3ec318931f5475fcb181f8b4a079a1fa4b9c
Signed-off-by: Ole Troan <ot@cisco.com>
src/plugins/memif/device.c
src/plugins/memif/node.c
src/vlib/error.c
src/vnet/interface.c
src/vnet/interface.h

index 101c3f7..8726603 100644 (file)
 #include <memif/memif.h>
 #include <memif/private.h>
 
-#define foreach_memif_tx_func_error           \
-_(NO_FREE_SLOTS, "no free tx slots")           \
-_(ROLLBACK, "no enough space in tx buffers")
+#define foreach_memif_tx_func_error                                           \
+  _ (NO_FREE_SLOTS, no_free_slots, ERROR, "no free tx slots")                 \
+  _ (ROLLBACK, rollback, ERROR, "no enough space in tx buffers")
 
 typedef enum
 {
-#define _(f,s) MEMIF_TX_ERROR_##f,
+#define _(f, n, s, d) MEMIF_TX_ERROR_##f,
   foreach_memif_tx_func_error
 #undef _
     MEMIF_TX_N_ERROR,
 } memif_tx_func_error_t;
 
-static char *memif_tx_func_error_strings[] = {
-#define _(n,s) s,
+static vl_counter_t memif_tx_func_error_counters[] = {
+#define _(f, n, s, d) { #n, d, VL_COUNTER_SEVERITY_##s },
   foreach_memif_tx_func_error
 #undef _
 };
@@ -490,7 +490,7 @@ VNET_DEVICE_CLASS (memif_device_class) = {
   .format_device = format_memif_device,
   .format_tx_trace = format_memif_tx_trace,
   .tx_function_n_errors = MEMIF_TX_N_ERROR,
-  .tx_function_error_strings = memif_tx_func_error_strings,
+  .tx_function_error_counters = memif_tx_func_error_counters,
   .rx_redirect_to_node = memif_set_interface_next_node,
   .clear_counters = memif_clear_hw_interface_counters,
   .admin_up_down_function = memif_interface_admin_up_down,
index b2422f9..84bc63f 100644 (file)
 #include <memif/private.h>
 
 #define foreach_memif_input_error                                             \
-  _ (BUFFER_ALLOC_FAIL, "buffer allocation failed")                           \
-  _ (BAD_DESC, "bad descriptor")                                              \
-  _ (NOT_IP, "not ip packet")
+  _ (BUFFER_ALLOC_FAIL, buffer_alloc, ERROR, "buffer allocation failed")      \
+  _ (BAD_DESC, bad_desc, ERROR, "bad descriptor")                             \
+  _ (NOT_IP, not_ip, INFO, "not ip packet")
 
 typedef enum
 {
-#define _(f,s) MEMIF_INPUT_ERROR_##f,
+#define _(f, n, s, d) MEMIF_INPUT_ERROR_##f,
   foreach_memif_input_error
 #undef _
     MEMIF_INPUT_N_ERROR,
 } memif_input_error_t;
 
-static __clib_unused char *memif_input_error_strings[] = {
-#define _(n,s) s,
+static vl_counter_t memif_input_error_counters[] = {
+#define _(f, n, s, d) { #n, d, VL_COUNTER_SEVERITY_##s },
   foreach_memif_input_error
 #undef _
 };
@@ -937,7 +937,7 @@ VLIB_REGISTER_NODE (memif_input_node) = {
   .type = VLIB_NODE_TYPE_INPUT,
   .state = VLIB_NODE_STATE_INTERRUPT,
   .n_errors = MEMIF_INPUT_N_ERROR,
-  .error_strings = memif_input_error_strings,
+  .error_counters = memif_input_error_counters,
 };
 
 /* *INDENT-ON* */
index 1a84e7e..f93b9a3 100644 (file)
@@ -144,7 +144,7 @@ vlib_register_errors (vlib_main_t * vm,
       int i;
       for (i = 0; i < n_errors; i++)
        {
-         counters[i].name = error_strings[i];  // XXX Make name saner
+         counters[i].name = error_strings[i];
          counters[i].desc = error_strings[i];
          counters[i].severity = VL_COUNTER_SEVERITY_ERROR;
        }
index 32fb1f2..1d59a96 100644 (file)
@@ -792,10 +792,9 @@ setup_tx_node (vlib_main_t * vm,
 
   n->format_trace = dev_class->format_tx_trace;
 
-  /// XXX: Update this to use counter structure
-  vlib_register_errors (vm, node_index,
-                       dev_class->tx_function_n_errors,
-                       dev_class->tx_function_error_strings, 0);
+  vlib_register_errors (vm, node_index, dev_class->tx_function_n_errors,
+                       dev_class->tx_function_error_strings,
+                       dev_class->tx_function_error_counters);
 }
 
 static void
index 70f51cd..744496c 100644 (file)
@@ -229,6 +229,7 @@ typedef struct _vnet_device_class
 
   /* Error strings indexed by error code for this node. */
   char **tx_function_error_strings;
+  vl_counter_t *tx_function_error_counters;
 
   /* Number of error codes used by this node. */
   u32 tx_function_n_errors;