FD.io VPP  v19.01.3-6-g70449b9b9
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 <vmxnet3/vmxnet3.h>
24 
25 u8 *
26 format_vmxnet3_device_name (u8 * s, va_list * args)
27 {
29  u32 i = va_arg (*args, u32);
31  vmxnet3_device_t *vd = vec_elt_at_index (vmxm->devices, i);
32  vlib_pci_addr_t *addr = vlib_pci_get_addr (vm, vd->pci_dev_handle);
33 
34  s = format (s, "vmxnet3-%x/%x/%x/%x",
35  addr->domain, addr->bus, addr->slot, addr->function);
36  return s;
37 }
38 
39 u8 *
40 format_vmxnet3_device_flags (u8 * s, va_list * args)
41 {
42  vmxnet3_device_t *vd = va_arg (*args, vmxnet3_device_t *);
43  u8 *t = 0;
44 
45 #define _(a, b, c) if (vd->flags & (1 << a)) \
46  t = format (t, "%s%s", t ? " ":"", c);
48 #undef _
49  s = format (s, "%v", t);
50  vec_free (t);
51  return s;
52 }
53 
54 u8 *
55 format_vmxnet3_device (u8 * s, va_list * args)
56 {
57  u32 i = va_arg (*args, u32);
59  vmxnet3_device_t *vd = vec_elt_at_index (vmxm->devices, i);
60  u32 indent = format_get_indent (s);
61  vmxnet3_queues *q = &vd->dma->queues;
62  vmxnet3_rxq_t *rxq = vec_elt_at_index (vd->rxqs, 0);
63  vmxnet3_txq_t *txq = vec_elt_at_index (vd->txqs, 0);
64 
65  s = format (s, "flags: %U", format_vmxnet3_device_flags, vd);
66  s = format (s, "\n%Urx queues %u, rx desc %u, tx queues %u, tx desc %u",
67  format_white_space, indent,
68  vd->num_rx_queues, rxq->size, vd->num_tx_queues, txq->size);
69  if (vd->error)
70  s = format (s, "\n%Uerror %U", format_white_space, indent,
72 
73  vmxnet3_reg_write (vd, 1, VMXNET3_REG_CMD, VMXNET3_CMD_GET_STATS);
74 
75  s = format (s, "\n%UTX:", format_white_space, indent);
76  s = format (s, "\n%U TSO packets %llu",
77  format_white_space, indent,
78  q->tx.stats.tso_pkts - vd->tx_stats.tso_pkts);
79  s = format (s, "\n%U TSO bytes %llu",
80  format_white_space, indent,
81  q->tx.stats.tso_bytes - vd->tx_stats.tso_bytes);
82  s = format (s, "\n%U ucast packets %llu",
83  format_white_space, indent,
84  q->tx.stats.ucast_pkts - vd->tx_stats.ucast_pkts);
85  s = format (s, "\n%U ucast bytes %llu",
86  format_white_space, indent,
87  q->tx.stats.ucast_bytes - vd->tx_stats.ucast_bytes);
88  s = format (s, "\n%U mcast packets %llu",
89  format_white_space, indent,
90  q->tx.stats.mcast_pkts - vd->tx_stats.mcast_pkts);
91  s = format (s, "\n%U mcast bytes %llu",
92  format_white_space, indent,
93  q->tx.stats.mcast_bytes - vd->tx_stats.mcast_bytes);
94  s = format (s, "\n%U bcast packets %llu",
95  format_white_space, indent,
96  q->tx.stats.bcast_pkts - vd->tx_stats.bcast_pkts);
97  s = format (s, "\n%U bcast bytes %llu",
98  format_white_space, indent,
99  q->tx.stats.bcast_bytes - vd->tx_stats.bcast_bytes);
100  s = format (s, "\n%U Errors packets %llu",
101  format_white_space, indent,
102  q->tx.stats.error_pkts - vd->tx_stats.error_pkts);
103  s = format (s, "\n%U Discard packets %llu",
104  format_white_space, indent,
105  q->tx.stats.discard_pkts - vd->tx_stats.discard_pkts);
106 
107  s = format (s, "\n%URX:", format_white_space, indent);
108  s = format (s, "\n%U LRO packets %llu",
109  format_white_space, indent,
110  q->rx.stats.lro_pkts - vd->rx_stats.lro_pkts);
111  s = format (s, "\n%U LRO bytes %llu",
112  format_white_space, indent,
113  q->rx.stats.lro_bytes - vd->rx_stats.lro_bytes);
114  s = format (s, "\n%U ucast packets %llu",
115  format_white_space, indent,
116  q->rx.stats.ucast_pkts - vd->rx_stats.ucast_pkts);
117  s = format (s, "\n%U ucast bytes %llu",
118  format_white_space, indent,
119  q->rx.stats.ucast_bytes - vd->rx_stats.ucast_bytes);
120  s = format (s, "\n%U mcast packets %llu",
121  format_white_space, indent,
122  q->rx.stats.mcast_pkts - vd->rx_stats.mcast_pkts);
123  s = format (s, "\n%U mcast bytes %llu",
124  format_white_space, indent,
125  q->rx.stats.mcast_bytes - vd->rx_stats.mcast_bytes);
126  s = format (s, "\n%U bcast packets %llu",
127  format_white_space, indent,
128  q->rx.stats.bcast_pkts - vd->rx_stats.bcast_pkts);
129  s = format (s, "\n%U bcast bytes %llu",
130  format_white_space, indent,
131  q->rx.stats.bcast_bytes - vd->rx_stats.bcast_bytes);
132  s = format (s, "\n%U No Bufs %llu",
133  format_white_space, indent,
134  q->rx.stats.nobuf_pkts - vd->rx_stats.nobuf_pkts);
135  s = format (s, "\n%U Error packets %llu",
136  format_white_space, indent,
137  q->rx.stats.error_pkts - vd->rx_stats.error_pkts);
138  return s;
139 }
140 
141 u8 *
142 format_vmxnet3_input_trace (u8 * s, va_list * args)
143 {
144  vlib_main_t *vm = va_arg (*args, vlib_main_t *);
145  vlib_node_t *node = va_arg (*args, vlib_node_t *);
146  vmxnet3_input_trace_t *t = va_arg (*args, vmxnet3_input_trace_t *);
147  vnet_main_t *vnm = vnet_get_main ();
149 
150  s = format (s, "vmxnet3: %v (%d) next-node %U",
152  node->index, t->next_index);
153  s = format (s, "\n buffer %U", format_vlib_buffer, &t->buffer);
154 
155  return s;
156 }
157 
158 /*
159  * fd.io coding-style-patch-verification: ON
160  *
161  * Local Variables:
162  * eval: (c-set-style "gnu")
163  * End:
164  */
vmrglw vmrglh hi
u8 * format_clib_error(u8 *s, va_list *va)
Definition: error.c:191
vnet_main_t * vnet_get_main(void)
Definition: misc.c:47
format_function_t format_vlib_buffer
Definition: buffer_funcs.h:962
vlib_pci_dev_handle_t pci_dev_handle
Definition: vmxnet3.h:471
u32 index
Definition: node.h:304
vmxnet3_tx_stats tx_stats
Definition: vmxnet3.h:492
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
vmxnet3_main_t vmxnet3_main
Definition: vmxnet3.c:28
int i
static u32 format_get_indent(u8 *s)
Definition: format.h:72
u8 * format_vmxnet3_device_flags(u8 *s, va_list *args)
Definition: format.c:40
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
vmxnet3_dma * dma
Definition: vmxnet3.h:489
vhost_vring_addr_t addr
Definition: vhost_user.h:121
unsigned char u8
Definition: types.h:56
static_always_inline void vmxnet3_reg_write(vmxnet3_device_t *vd, u8 bar, u32 addr, u32 val)
Definition: vmxnet3.h:554
vmxnet3_rxq_t * rxqs
Definition: vmxnet3.h:476
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:113
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
format_function_t format_vlib_next_node_name
Definition: node_funcs.h:1142
unsigned int u32
Definition: types.h:88
#define VMXNET3_REG_CMD
Definition: vmxnet3.h:72
vlib_main_t * vm
Definition: buffer.c:301
vlib_buffer_t buffer
Definition: vmxnet3.h:521
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:341
vmxnet3_txq_t * txqs
Definition: vmxnet3.h:477
clib_error_t * error
Definition: vmxnet3.h:487
vlib_pci_addr_t * vlib_pci_get_addr(vlib_main_t *vm, vlib_pci_dev_handle_t h)
Definition: pci.c:163
u8 * format_vmxnet3_device_name(u8 *s, va_list *args)
Definition: format.c:26
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
u8 * format_vmxnet3_input_trace(u8 *s, va_list *args)
Definition: format.c:142
vmxnet3_rx_stats rx_stats
Definition: vmxnet3.h:493
vmxnet3_device_t * devices
Definition: vmxnet3.h:498
u8 * format_vmxnet3_device(u8 *s, va_list *args)
Definition: format.c:55