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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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 *------------------------------------------------------------------
18 #include <vlib/vlib.h>
19 #include <vlib/unix/unix.h>
20 #include <vlib/pci/pci.h>
21 #include <vnet/ethernet/ethernet.h>
26 format_avf_device_name (u8 * s, va_list * args)
28 vlib_main_t *vm = vlib_get_main ();
29 u32 i = va_arg (*args, u32);
30 avf_main_t *am = &avf_main;
31 avf_device_t *ad = vec_elt_at_index (am->devices, i);
32 vlib_pci_addr_t *addr = vlib_pci_get_addr (vm, ad->pci_dev_handle);
34 s = format (s, "avf-%x/%x/%x/%x",
35 addr->domain, addr->bus, addr->slot, addr->function);
40 format_avf_device_flags (u8 * s, va_list * args)
42 avf_device_t *ad = va_arg (*args, avf_device_t *);
45 #define _(a, b, c) if (ad->flags & (1 << a)) \
46 t = format (t, "%s%s", t ? " ":"", c);
47 foreach_avf_device_flags
49 s = format (s, "%v", t);
55 format_avf_vf_cap_flags (u8 * s, va_list * args)
57 u32 flags = va_arg (*args, u32);
60 #define _(a, b, c) if (flags & (1 << a)) \
61 t = format (t, "%s%s", t ? " ":"", c);
62 foreach_avf_vf_cap_flag;
64 s = format (s, "%v", t);
70 format_virtchnl_link_speed (u8 * s, va_list * args)
72 virtchnl_link_speed_t speed = va_arg (*args, virtchnl_link_speed_t);
75 return format (s, "unknown");
77 else if (speed == VIRTCHNL_LINK_SPEED_##b) \
79 foreach_virtchnl_link_speed;
85 format_avf_device (u8 * s, va_list * args)
87 u32 i = va_arg (*args, u32);
88 avf_main_t *am = &avf_main;
89 avf_device_t *ad = vec_elt_at_index (am->devices, i);
90 u32 indent = format_get_indent (s);
93 s = format (s, "flags: %U", format_avf_device_flags, ad);
94 s = format (s, "\n%Uoffload features: %U", format_white_space, indent,
95 format_avf_vf_cap_flags, ad->feature_bitmap);
97 s = format (s, "\n%Unum-queue-pairs %d max-vectors %u max-mtu %u "
98 "rss-key-size %u rss-lut-size %u", format_white_space, indent,
99 ad->num_queue_pairs, ad->max_vectors, ad->max_mtu,
100 ad->rss_key_size, ad->rss_lut_size);
101 s = format (s, "\n%Uspeed %U", format_white_space, indent,
102 format_virtchnl_link_speed, ad->link_speed);
104 s = format (s, "\n%Uerror %U", format_white_space, indent,
105 format_clib_error, ad->error);
107 #define _(c) if (ad->eth_stats.c) \
108 a = format (a, "\n%U%-20U %u", format_white_space, indent + 2, \
109 format_c_identifier, #c, ad->eth_stats.c);
110 foreach_virtchnl_eth_stats;
113 s = format (s, "\n%Ustats:%v", format_white_space, indent, a);
120 format_avf_input_trace (u8 * s, va_list * args)
122 vlib_main_t *vm = va_arg (*args, vlib_main_t *);
123 vlib_node_t *node = va_arg (*args, vlib_node_t *);
124 avf_input_trace_t *t = va_arg (*args, avf_input_trace_t *);
125 vnet_main_t *vnm = vnet_get_main ();
126 vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, t->hw_if_index);
127 u32 indent = format_get_indent (s);
128 avf_rx_vector_entry_t *rxve = &t->rxve;
130 s = format (s, "avf: %v (%d) next-node %U",
131 hi->name, t->hw_if_index, format_vlib_next_node_name, vm,
132 node->index, t->next_index);
133 s = format (s, "\n%Ustatus 0x%x error 0x%x ptype 0x%x length %u",
134 format_white_space, indent + 2, rxve->status, rxve->error,
135 rxve->ptype, rxve->length);
141 * fd.io coding-style-patch-verification: ON
144 * eval: (c-set-style "gnu")