avf: print stats in separate log class 69/32369/1
authorDamjan Marion <damarion@cisco.com>
Wed, 19 May 2021 08:35:10 +0000 (10:35 +0200)
committerDamjan Marion <damarion@cisco.com>
Wed, 19 May 2021 08:35:32 +0000 (10:35 +0200)
Type: improvement
Change-Id: Ia1a4b1b1acad989cbd47a805b900160ba0071071
Signed-off-by: Damjan Marion <damarion@cisco.com>
src/plugins/avf/avf.h
src/plugins/avf/device.c
src/plugins/avf/format.c

index c03a7c2..10297e6 100644 (file)
@@ -85,6 +85,7 @@
 
 
 extern vlib_log_class_registration_t avf_log;
+extern vlib_log_class_registration_t avf_stats_log;
 
 #define avf_log_err(dev, f, ...)                        \
   vlib_log (VLIB_LOG_LEVEL_ERR, avf_log.class, "%U: " f, \
@@ -101,6 +102,10 @@ extern vlib_log_class_registration_t avf_log;
             format_vlib_pci_addr, &dev->pci_addr, \
             ## __VA_ARGS__)
 
+#define avf_stats_log_debug(dev, f, ...)                                      \
+  vlib_log (VLIB_LOG_LEVEL_DEBUG, avf_stats_log.class, "%U: " f,              \
+           format_vlib_pci_addr, &dev->pci_addr, ##__VA_ARGS__)
+
 #define foreach_avf_device_flags                                              \
   _ (0, INITIALIZED, "initialized")                                           \
   _ (1, ERROR, "error")                                                       \
@@ -356,6 +361,7 @@ format_function_t format_avf_vf_cap_flags;
 format_function_t format_avf_vlan_supported_caps;
 format_function_t format_avf_vlan_caps;
 format_function_t format_avf_vlan_support;
+format_function_t format_avf_eth_stats;
 vnet_flow_dev_ops_function_t avf_flow_ops_fn;
 
 static_always_inline avf_device_t *
index 28fe0a4..09dafa3 100644 (file)
 #define PCI_DEVICE_ID_INTEL_X710_VF            0x154c
 #define PCI_DEVICE_ID_INTEL_X722_VF            0x37cd
 
-/* *INDENT-OFF* */
 VLIB_REGISTER_LOG_CLASS (avf_log) = {
   .class_name = "avf",
 };
-/* *INDENT-ON* */
+
+VLIB_REGISTER_LOG_CLASS (avf_stats_log) = {
+  .class_name = "avf",
+  .subclass_name = "stats",
+};
 
 avf_main_t avf_main;
 void avf_delete_if (vlib_main_t * vm, avf_device_t * ad, int with_barrier);
@@ -815,13 +818,17 @@ avf_op_get_stats (vlib_main_t * vm, avf_device_t * ad,
                  virtchnl_eth_stats_t * es)
 {
   virtchnl_queue_select_t qs = { 0 };
+  clib_error_t *err;
   qs.vsi_id = ad->vsi_id;
 
-  avf_log_debug (ad, "get_stats: vsi_id %u", ad->vsi_id);
+  err = avf_send_to_pf (vm, ad, VIRTCHNL_OP_GET_STATS, &qs,
+                       sizeof (virtchnl_queue_select_t), es,
+                       sizeof (virtchnl_eth_stats_t));
 
-  return avf_send_to_pf (vm, ad, VIRTCHNL_OP_GET_STATS,
-                        &qs, sizeof (virtchnl_queue_select_t),
-                        es, sizeof (virtchnl_eth_stats_t));
+  avf_stats_log_debug (ad, "get_stats: vsi_id %u\n  %U", ad->vsi_id,
+                      format_avf_eth_stats, es);
+
+  return err;
 }
 
 clib_error_t *
index 2615780..0a153a0 100644 (file)
@@ -239,3 +239,22 @@ format_avf_vlan_caps (u8 *s, va_list *args)
              vc->offloads.ethertype_match);
   return s;
 }
+
+u8 *
+format_avf_eth_stats (u8 *s, va_list *args)
+{
+  virtchnl_eth_stats_t *es = va_arg (*args, virtchnl_eth_stats_t *);
+  u32 indent = format_get_indent (s);
+  u8 *v = 0;
+
+#define _(st)                                                                 \
+  if (v)                                                                      \
+    v = format (v, "\n%U", format_white_space, indent);                       \
+  v = format (v, "%-20s = %lu", #st, es->st);
+  foreach_virtchnl_eth_stats
+#undef _
+
+    s = format (s, "%v", v);
+  vec_free (v);
+  return s;
+}