LCOV - code coverage report
Current view: top level - plugins/avf - format.c (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 0 128 0.0 %
Date: 2023-07-05 22:20:52 Functions: 0 10 0.0 %

          Line data    Source code
       1             : /*
       2             :  *------------------------------------------------------------------
       3             :  * Copyright (c) 2018 Cisco and/or its affiliates.
       4             :  * Licensed under the Apache License, Version 2.0 (the "License");
       5             :  * you may not use this file except in compliance with the License.
       6             :  * You may obtain a copy of the License at:
       7             :  *
       8             :  *     http://www.apache.org/licenses/LICENSE-2.0
       9             :  *
      10             :  * Unless required by applicable law or agreed to in writing, software
      11             :  * distributed under the License is distributed on an "AS IS" BASIS,
      12             :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      13             :  * See the License for the specific language governing permissions and
      14             :  * limitations under the License.
      15             :  *------------------------------------------------------------------
      16             :  */
      17             : 
      18             : #include <vlib/vlib.h>
      19             : #include <vlib/unix/unix.h>
      20             : #include <vlib/pci/pci.h>
      21             : #include <vnet/ethernet/ethernet.h>
      22             : 
      23             : #include <avf/avf.h>
      24             : 
      25             : u8 *
      26           0 : format_avf_device_name (u8 * s, va_list * args)
      27             : {
      28           0 :   vlib_main_t *vm = vlib_get_main ();
      29           0 :   u32 i = va_arg (*args, u32);
      30           0 :   avf_device_t *ad = avf_get_device (i);
      31           0 :   vlib_pci_addr_t *addr = vlib_pci_get_addr (vm, ad->pci_dev_handle);
      32             : 
      33           0 :   if (ad->name)
      34           0 :     return format (s, "%s", ad->name);
      35             : 
      36           0 :   s = format (s, "avf-%x/%x/%x/%x",
      37           0 :               addr->domain, addr->bus, addr->slot, addr->function);
      38           0 :   return s;
      39             : }
      40             : 
      41             : u8 *
      42           0 : format_avf_device_flags (u8 * s, va_list * args)
      43             : {
      44           0 :   avf_device_t *ad = va_arg (*args, avf_device_t *);
      45           0 :   u8 *t = 0;
      46             : 
      47             : #define _(a, b, c) if (ad->flags & (1 << a)) \
      48             : t = format (t, "%s%s", t ? " ":"", c);
      49           0 :   foreach_avf_device_flags
      50             : #undef _
      51           0 :     s = format (s, "%v", t);
      52           0 :   vec_free (t);
      53           0 :   return s;
      54             : }
      55             : 
      56             : u8 *
      57           0 : format_avf_vf_cap_flags (u8 * s, va_list * args)
      58             : {
      59           0 :   u32 flags = va_arg (*args, u32);
      60           0 :   int not_first = 0;
      61             : 
      62           0 :   char *strs[32] = {
      63             : #define _(a, b, c) [a] = c,
      64             :     foreach_avf_vf_cap_flag
      65             : #undef _
      66             :   };
      67             : 
      68           0 :   for (int i = 0; i < 32; i++)
      69             :     {
      70           0 :       if ((flags & (1 << i)) == 0)
      71           0 :         continue;
      72           0 :       if (not_first)
      73           0 :         s = format (s, " ");
      74           0 :       if (strs[i])
      75           0 :         s = format (s, "%s", strs[i]);
      76             :       else
      77           0 :         s = format (s, "unknown(%u)", i);
      78           0 :       not_first = 1;
      79             :     }
      80           0 :   return s;
      81             : }
      82             : 
      83             : static u8 *
      84           0 : format_virtchnl_link_speed (u8 * s, va_list * args)
      85             : {
      86           0 :   virtchnl_link_speed_t speed = va_arg (*args, virtchnl_link_speed_t);
      87             : 
      88           0 :   if (speed == 0)
      89           0 :     return format (s, "unknown");
      90             : #define _(a, b, c) \
      91             :   else if (speed == VIRTCHNL_LINK_SPEED_##b) \
      92             :     return format (s, c);
      93           0 :   foreach_virtchnl_link_speed;
      94             : #undef _
      95           0 :   return s;
      96             : }
      97             : 
      98             : u8 *
      99           0 : format_avf_device (u8 * s, va_list * args)
     100             : {
     101           0 :   u32 i = va_arg (*args, u32);
     102           0 :   avf_device_t *ad = avf_get_device (i);
     103           0 :   u32 indent = format_get_indent (s);
     104           0 :   u8 *a = 0;
     105           0 :   avf_rxq_t *rxq = vec_elt_at_index (ad->rxqs, 0);
     106           0 :   avf_txq_t *txq = vec_elt_at_index (ad->txqs, 0);
     107             : 
     108           0 :   s = format (s, "rx: queues %u, desc %u (min %u max %u)", ad->n_rx_queues,
     109           0 :               rxq->size, AVF_QUEUE_SZ_MIN, AVF_QUEUE_SZ_MAX);
     110           0 :   s = format (s, "\n%Utx: queues %u, desc %u (min %u max %u)",
     111           0 :               format_white_space, indent, ad->n_tx_queues, txq->size,
     112             :               AVF_QUEUE_SZ_MIN, AVF_QUEUE_SZ_MAX);
     113           0 :   s = format (s, "\n%Uflags: %U", format_white_space, indent,
     114             :               format_avf_device_flags, ad);
     115           0 :   s = format (s, "\n%Ucapability flags: %U", format_white_space, indent,
     116             :               format_avf_vf_cap_flags, ad->cap_flags);
     117             : 
     118           0 :   s = format (s, "\n%Unum-queue-pairs %d max-vectors %u max-mtu %u "
     119             :               "rss-key-size %u rss-lut-size %u", format_white_space, indent,
     120           0 :               ad->num_queue_pairs, ad->max_vectors, ad->max_mtu,
     121             :               ad->rss_key_size, ad->rss_lut_size);
     122           0 :   s = format (s, "\n%Uspeed %U", format_white_space, indent,
     123           0 :               format_virtchnl_link_speed, ad->link_speed);
     124           0 :   if (ad->error)
     125           0 :     s = format (s, "\n%Uerror %U", format_white_space, indent,
     126             :                 format_clib_error, ad->error);
     127             : 
     128             : #define _(c) if (ad->eth_stats.c - ad->last_cleared_eth_stats.c) \
     129             :   a = format (a, "\n%U%-20U %u", format_white_space, indent + 2, \
     130             :               format_c_identifier, #c,                           \
     131             :               ad->eth_stats.c - ad->last_cleared_eth_stats.c);
     132           0 :   foreach_virtchnl_eth_stats;
     133             : #undef _
     134           0 :   if (a)
     135           0 :     s = format (s, "\n%Ustats:%v", format_white_space, indent, a);
     136             : 
     137           0 :   vec_free (a);
     138           0 :   return s;
     139             : }
     140             : 
     141             : u8 *
     142           0 : format_avf_input_trace (u8 * s, va_list * args)
     143             : {
     144           0 :   vlib_main_t *vm = va_arg (*args, vlib_main_t *);
     145           0 :   vlib_node_t *node = va_arg (*args, vlib_node_t *);
     146           0 :   avf_input_trace_t *t = va_arg (*args, avf_input_trace_t *);
     147           0 :   vnet_main_t *vnm = vnet_get_main ();
     148           0 :   vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, t->hw_if_index);
     149           0 :   u32 indent = format_get_indent (s);
     150           0 :   int i = 0;
     151             : 
     152           0 :   s = format (s, "avf: %v (%d) qid %u next-node %U flow-id %u", hi->name,
     153           0 :               t->hw_if_index, t->qid, format_vlib_next_node_name, vm,
     154           0 :               node->index, t->next_index, t->flow_id);
     155             : 
     156             :   do
     157             :     {
     158           0 :       s = format (s, "\n%Udesc %u: status 0x%x error 0x%x ptype 0x%x len %u",
     159             :                   format_white_space, indent + 2, i,
     160           0 :                   t->qw1s[i] & pow2_mask (19),
     161           0 :                   (t->qw1s[i] >> AVF_RXD_ERROR_SHIFT) & pow2_mask (8),
     162           0 :                   (t->qw1s[i] >> AVF_RXD_PTYPE_SHIFT) & pow2_mask (8),
     163           0 :                   (t->qw1s[i] >> AVF_RXD_LEN_SHIFT));
     164             :     }
     165           0 :   while ((t->qw1s[i++] & AVF_RXD_STATUS_EOP) == 0 &&
     166           0 :          i < AVF_RX_MAX_DESC_IN_CHAIN);
     167             : 
     168           0 :   return s;
     169             : }
     170             : 
     171             : u8 *
     172           0 : format_avf_vlan_support (u8 *s, va_list *args)
     173             : {
     174           0 :   virtchnl_vlan_support_t v = va_arg (*args, u32);
     175           0 :   int not_first = 0;
     176             : 
     177           0 :   char *strs[32] = {
     178             : #define _(a, b, c) [a] = c,
     179             :     foreach_virtchnl_vlan_support_bit
     180             : #undef _
     181             :   };
     182             : 
     183           0 :   if (v == VIRTCHNL_VLAN_UNSUPPORTED)
     184           0 :     return format (s, "unsupported");
     185             : 
     186           0 :   for (int i = 0; i < 32; i++)
     187             :     {
     188           0 :       if ((v & (1 << i)) == 0)
     189           0 :         continue;
     190           0 :       if (not_first)
     191           0 :         s = format (s, " ");
     192           0 :       if (strs[i])
     193           0 :         s = format (s, "%s", strs[i]);
     194             :       else
     195           0 :         s = format (s, "unknown(%u)", i);
     196           0 :       not_first = 1;
     197             :     }
     198           0 :   return s;
     199             : }
     200             : 
     201             : u8 *
     202           0 : format_avf_vlan_supported_caps (u8 *s, va_list *args)
     203             : {
     204           0 :   virtchnl_vlan_supported_caps_t *sc =
     205             :     va_arg (*args, virtchnl_vlan_supported_caps_t *);
     206           0 :   u32 indent = format_get_indent (s);
     207             : 
     208           0 :   s = format (s, "outer: %U", format_avf_vlan_support, sc->outer);
     209           0 :   s = format (s, "\n%Uinner: %U", format_white_space, indent,
     210             :               format_avf_vlan_support, sc->inner);
     211           0 :   return s;
     212             : }
     213             : 
     214             : u8 *
     215           0 : format_avf_vlan_caps (u8 *s, va_list *args)
     216             : {
     217           0 :   virtchnl_vlan_caps_t *vc = va_arg (*args, virtchnl_vlan_caps_t *);
     218           0 :   u32 indent = format_get_indent (s);
     219             : 
     220           0 :   s = format (s, "filtering:");
     221           0 :   s = format (s, "\n%Usupport:", format_white_space, indent + 2);
     222             :   s =
     223           0 :     format (s, "\n%U%U", format_white_space, indent + 4,
     224             :             format_avf_vlan_supported_caps, &vc->filtering.filtering_support);
     225           0 :   s = format (s, "\n%Uethertype-init: 0x%x", format_white_space, indent + 4,
     226             :               vc->filtering.ethertype_init);
     227           0 :   s = format (s, "\n%Umax-filters: %u", format_white_space, indent + 4,
     228           0 :               vc->filtering.max_filters);
     229           0 :   s = format (s, "\n%Uoffloads:", format_white_space, indent);
     230           0 :   s = format (s, "\n%Ustripping support:", format_white_space, indent + 2);
     231           0 :   s = format (s, "\n%U%U", format_white_space, indent + 4,
     232             :               format_avf_vlan_supported_caps, &vc->offloads.stripping_support);
     233           0 :   s = format (s, "\n%Uinserion support:", format_white_space, indent + 2);
     234           0 :   s = format (s, "\n%U%U", format_white_space, indent + 4,
     235             :               format_avf_vlan_supported_caps, &vc->offloads.insertion_support);
     236           0 :   s = format (s, "\n%Uethertype-init: 0x%x", format_white_space, indent + 4,
     237             :               vc->offloads.ethertype_init);
     238           0 :   s = format (s, "\n%Uethertype-match: 0x%x", format_white_space, indent + 4,
     239           0 :               vc->offloads.ethertype_match);
     240           0 :   return s;
     241             : }
     242             : 
     243             : u8 *
     244           0 : format_avf_eth_stats (u8 *s, va_list *args)
     245             : {
     246           0 :   virtchnl_eth_stats_t *es = va_arg (*args, virtchnl_eth_stats_t *);
     247           0 :   u32 indent = format_get_indent (s);
     248           0 :   u8 *v = 0;
     249             : 
     250             : #define _(st)                                                                 \
     251             :   if (v)                                                                      \
     252             :     v = format (v, "\n%U", format_white_space, indent);                       \
     253             :   v = format (v, "%-20s = %lu", #st, es->st);
     254           0 :   foreach_virtchnl_eth_stats
     255             : #undef _
     256             : 
     257           0 :     s = format (s, "%v", v);
     258           0 :   vec_free (v);
     259           0 :   return s;
     260             : }

Generated by: LCOV version 1.14