FD.io VPP  v21.01.1
Vector Packet Processing
format.c
Go to the documentation of this file.
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 format_avf_device_name (u8 * s, va_list * args)
27 {
29  u32 i = va_arg (*args, u32);
30  avf_device_t *ad = avf_get_device (i);
31  vlib_pci_addr_t *addr = vlib_pci_get_addr (vm, ad->pci_dev_handle);
32 
33  if (ad->name)
34  return format (s, "%s", ad->name);
35 
36  s = format (s, "avf-%x/%x/%x/%x",
37  addr->domain, addr->bus, addr->slot, addr->function);
38  return s;
39 }
40 
41 u8 *
42 format_avf_device_flags (u8 * s, va_list * args)
43 {
44  avf_device_t *ad = va_arg (*args, avf_device_t *);
45  u8 *t = 0;
46 
47 #define _(a, b, c) if (ad->flags & (1 << a)) \
48 t = format (t, "%s%s", t ? " ":"", c);
50 #undef _
51  s = format (s, "%v", t);
52  vec_free (t);
53  return s;
54 }
55 
56 u8 *
57 format_avf_vf_cap_flags (u8 * s, va_list * args)
58 {
59  u32 flags = va_arg (*args, u32);
60  u8 *t = 0;
61 
62 #define _(a, b, c) if (flags & (1 << a)) \
63  t = format (t, "%s%s", t ? " ":"", c);
65 #undef _
66  s = format (s, "%v", t);
67  vec_free (t);
68  return s;
69 }
70 
71 static u8 *
72 format_virtchnl_link_speed (u8 * s, va_list * args)
73 {
74  virtchnl_link_speed_t speed = va_arg (*args, virtchnl_link_speed_t);
75 
76  if (speed == 0)
77  return format (s, "unknown");
78 #define _(a, b, c) \
79  else if (speed == VIRTCHNL_LINK_SPEED_##b) \
80  return format (s, c);
82 #undef _
83  return s;
84 }
85 
86 u8 *
87 format_avf_device (u8 * s, va_list * args)
88 {
89  u32 i = va_arg (*args, u32);
90  avf_device_t *ad = avf_get_device (i);
91  u32 indent = format_get_indent (s);
92  u8 *a = 0;
93  avf_rxq_t *rxq = vec_elt_at_index (ad->rxqs, 0);
94  avf_txq_t *txq = vec_elt_at_index (ad->txqs, 0);
95 
96  s = format (s, "rx: queues %u, desc %u (min %u max %u)", ad->n_rx_queues,
98  s = format (s, "\n%Utx: queues %u, desc %u (min %u max %u)",
99  format_white_space, indent, ad->n_tx_queues, txq->size,
101  s = format (s, "\n%Uflags: %U", format_white_space, indent,
103  s = format (s, "\n%Uoffload features: %U", format_white_space, indent,
105 
106  s = format (s, "\n%Unum-queue-pairs %d max-vectors %u max-mtu %u "
107  "rss-key-size %u rss-lut-size %u", format_white_space, indent,
108  ad->num_queue_pairs, ad->max_vectors, ad->max_mtu,
109  ad->rss_key_size, ad->rss_lut_size);
110  s = format (s, "\n%Uspeed %U", format_white_space, indent,
112  if (ad->error)
113  s = format (s, "\n%Uerror %U", format_white_space, indent,
114  format_clib_error, ad->error);
115 
116 #define _(c) if (ad->eth_stats.c - ad->last_cleared_eth_stats.c) \
117  a = format (a, "\n%U%-20U %u", format_white_space, indent + 2, \
118  format_c_identifier, #c, \
119  ad->eth_stats.c - ad->last_cleared_eth_stats.c);
121 #undef _
122  if (a)
123  s = format (s, "\n%Ustats:%v", format_white_space, indent, a);
124 
125  vec_free (a);
126  return s;
127 }
128 
129 u8 *
130 format_avf_input_trace (u8 * s, va_list * args)
131 {
132  vlib_main_t *vm = va_arg (*args, vlib_main_t *);
133  vlib_node_t *node = va_arg (*args, vlib_node_t *);
134  avf_input_trace_t *t = va_arg (*args, avf_input_trace_t *);
135  vnet_main_t *vnm = vnet_get_main ();
137  u32 indent = format_get_indent (s);
138  int i = 0;
139 
140  s = format (s, "avf: %v (%d) qid %u next-node %U",
142  vm, node->index, t->next_index);
143 
144  do
145  {
146  s = format (s, "\n%Udesc %u: status 0x%x error 0x%x ptype 0x%x len %u",
147  format_white_space, indent + 2, i,
148  t->qw1s[i] & pow2_mask (19),
149  (t->qw1s[i] >> AVF_RXD_ERROR_SHIFT) & pow2_mask (8),
150  (t->qw1s[i] >> AVF_RXD_PTYPE_SHIFT) & pow2_mask (8),
151  (t->qw1s[i] >> AVF_RXD_LEN_SHIFT));
152  }
153  while ((t->qw1s[i++] & AVF_RXD_STATUS_EOP) == 0 &&
155 
156  return s;
157 }
158 
159 /*
160  * fd.io coding-style-patch-verification: ON
161  *
162  * Local Variables:
163  * eval: (c-set-style "gnu")
164  * End:
165  */
#define AVF_RXD_ERROR_SHIFT
Definition: avf.h:47
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105
a
Definition: bitmap.h:544
u8 * format_avf_device_name(u8 *s, va_list *args)
Definition: format.c:26
u8 * format_avf_input_trace(u8 *s, va_list *args)
Definition: format.c:130
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
clib_error_t * error
Definition: avf.h:231
u32 index
Definition: node.h:280
#define foreach_virtchnl_eth_stats
Definition: virtchnl.h:357
virtchnl_link_speed_t link_speed
Definition: avf.h:223
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
static u32 format_get_indent(u8 *s)
Definition: format.h:72
vlib_main_t * vm
Definition: in2out_ed.c:1580
u8 * format_avf_vf_cap_flags(u8 *s, va_list *args)
Definition: format.c:57
virtchnl_link_speed_t
Definition: virtchnl.h:205
vhost_vring_addr_t addr
Definition: vhost_user.h:111
unsigned char u8
Definition: types.h:56
static uword pow2_mask(uword x)
Definition: clib.h:238
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:129
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
u64 qw1s[AVF_RX_MAX_DESC_IN_CHAIN]
Definition: avf.h:392
u8 * format_avf_device_flags(u8 *s, va_list *args)
Definition: format.c:42
format_function_t format_vlib_next_node_name
Definition: node_funcs.h:1223
unsigned int u32
Definition: types.h:88
vlib_pci_dev_handle_t pci_dev_handle
Definition: avf.h:192
u16 next_index
Definition: avf.h:390
u32 hw_if_index
Definition: avf.h:391
u8 * name
Definition: avf.h:195
__clib_export u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
#define AVF_QUEUE_SZ_MAX
Definition: avf.h:32
#define AVF_RXD_LEN_SHIFT
Definition: avf.h:49
#define AVF_RXD_STATUS_EOP
Definition: avf.h:46
u16 n_rx_queues
Definition: avf.h:201
u8 * format_avf_device(u8 *s, va_list *args)
Definition: format.c:87
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:317
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:380
Definition: avf.h:156
static_always_inline avf_device_t * avf_get_device(u32 dev_instance)
Definition: avf.h:311
vlib_main_t vlib_node_runtime_t * node
Definition: in2out_ed.c:1580
vlib_pci_addr_t * vlib_pci_get_addr(vlib_main_t *vm, vlib_pci_dev_handle_t h)
Definition: pci.c:163
u32 feature_bitmap
Definition: avf.h:215
Definition: avf.h:169
#define AVF_RXD_PTYPE_SHIFT
Definition: avf.h:48
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
vl_api_ip4_address_t hi
Definition: arp.api:37
u16 num_queue_pairs
Definition: avf.h:217
u32 rss_lut_size
Definition: avf.h:222
u16 n_tx_queues
Definition: avf.h:200
#define AVF_QUEUE_SZ_MIN
Definition: avf.h:33
u16 size
Definition: avf.h:161
avf_rxq_t * rxqs
Definition: avf.h:198
u16 size
Definition: avf.h:174
#define AVF_RX_MAX_DESC_IN_CHAIN
Definition: avf.h:50
static u8 * format_virtchnl_link_speed(u8 *s, va_list *args)
Definition: format.c:72
__clib_export u8 * format_clib_error(u8 *s, va_list *va)
Definition: error.c:191
avf_txq_t * txqs
Definition: avf.h:199
u16 max_vectors
Definition: avf.h:218
u32 rss_key_size
Definition: avf.h:221
u16 max_mtu
Definition: avf.h:220