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>
23 #include <vmxnet3/vmxnet3.h>
26 format_vmxnet3_device_name (u8 * s, va_list * args)
28 vlib_main_t *vm = vlib_get_main ();
29 u32 i = va_arg (*args, u32);
30 vmxnet3_main_t *vmxm = &vmxnet3_main;
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);
34 s = format (s, "vmxnet3-%x/%x/%x/%x",
35 addr->domain, addr->bus, addr->slot, addr->function);
40 format_vmxnet3_device_flags (u8 * s, va_list * args)
42 vmxnet3_device_t *vd = va_arg (*args, vmxnet3_device_t *);
45 #define _(a, b, c) if (vd->flags & (1 << a)) \
46 t = format (t, "%s%s", t ? " ":"", c);
47 foreach_vmxnet3_device_flags
49 s = format (s, "%v", t);
55 format_vmxnet3_device (u8 * s, va_list * args)
57 u32 i = va_arg (*args, u32);
58 vmxnet3_main_t *vmxm = &vmxnet3_main;
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);
65 s = format (s, "flags: %U", format_vmxnet3_device_flags, vd);
66 s = format (s, "\n%Uspeed %u", format_white_space, indent, vd->link_speed);
67 s = format (s, "\n%Urx queues %u, rx desc %u, tx queues %u, tx desc %u",
68 format_white_space, indent,
69 vd->num_rx_queues, rxq->size, vd->num_tx_queues, txq->size);
71 s = format (s, "\n%Uerror %U", format_white_space, indent,
72 format_clib_error, vd->error);
74 vmxnet3_reg_write (vd, 1, VMXNET3_REG_CMD, VMXNET3_CMD_GET_STATS);
76 s = format (s, "\n%UTX:", format_white_space, indent);
77 s = format (s, "\n%U TSO packets %llu",
78 format_white_space, indent,
79 q->tx.stats.tso_pkts - vd->tx_stats.tso_pkts);
80 s = format (s, "\n%U TSO bytes %llu",
81 format_white_space, indent,
82 q->tx.stats.tso_bytes - vd->tx_stats.tso_bytes);
83 s = format (s, "\n%U ucast packets %llu",
84 format_white_space, indent,
85 q->tx.stats.ucast_pkts - vd->tx_stats.ucast_pkts);
86 s = format (s, "\n%U ucast bytes %llu",
87 format_white_space, indent,
88 q->tx.stats.ucast_bytes - vd->tx_stats.ucast_bytes);
89 s = format (s, "\n%U mcast packets %llu",
90 format_white_space, indent,
91 q->tx.stats.mcast_pkts - vd->tx_stats.mcast_pkts);
92 s = format (s, "\n%U mcast bytes %llu",
93 format_white_space, indent,
94 q->tx.stats.mcast_bytes - vd->tx_stats.mcast_bytes);
95 s = format (s, "\n%U bcast packets %llu",
96 format_white_space, indent,
97 q->tx.stats.bcast_pkts - vd->tx_stats.bcast_pkts);
98 s = format (s, "\n%U bcast bytes %llu",
99 format_white_space, indent,
100 q->tx.stats.bcast_bytes - vd->tx_stats.bcast_bytes);
101 s = format (s, "\n%U Errors packets %llu",
102 format_white_space, indent,
103 q->tx.stats.error_pkts - vd->tx_stats.error_pkts);
104 s = format (s, "\n%U Discard packets %llu",
105 format_white_space, indent,
106 q->tx.stats.discard_pkts - vd->tx_stats.discard_pkts);
108 s = format (s, "\n%URX:", format_white_space, indent);
109 s = format (s, "\n%U LRO packets %llu",
110 format_white_space, indent,
111 q->rx.stats.lro_pkts - vd->rx_stats.lro_pkts);
112 s = format (s, "\n%U LRO bytes %llu",
113 format_white_space, indent,
114 q->rx.stats.lro_bytes - vd->rx_stats.lro_bytes);
115 s = format (s, "\n%U ucast packets %llu",
116 format_white_space, indent,
117 q->rx.stats.ucast_pkts - vd->rx_stats.ucast_pkts);
118 s = format (s, "\n%U ucast bytes %llu",
119 format_white_space, indent,
120 q->rx.stats.ucast_bytes - vd->rx_stats.ucast_bytes);
121 s = format (s, "\n%U mcast packets %llu",
122 format_white_space, indent,
123 q->rx.stats.mcast_pkts - vd->rx_stats.mcast_pkts);
124 s = format (s, "\n%U mcast bytes %llu",
125 format_white_space, indent,
126 q->rx.stats.mcast_bytes - vd->rx_stats.mcast_bytes);
127 s = format (s, "\n%U bcast packets %llu",
128 format_white_space, indent,
129 q->rx.stats.bcast_pkts - vd->rx_stats.bcast_pkts);
130 s = format (s, "\n%U bcast bytes %llu",
131 format_white_space, indent,
132 q->rx.stats.bcast_bytes - vd->rx_stats.bcast_bytes);
133 s = format (s, "\n%U No Bufs %llu",
134 format_white_space, indent,
135 q->rx.stats.nobuf_pkts - vd->rx_stats.nobuf_pkts);
136 s = format (s, "\n%U Error packets %llu",
137 format_white_space, indent,
138 q->rx.stats.error_pkts - vd->rx_stats.error_pkts);
143 format_vmxnet3_input_trace (u8 * s, va_list * args)
145 vlib_main_t *vm = va_arg (*args, vlib_main_t *);
146 vlib_node_t *node = va_arg (*args, vlib_node_t *);
147 vmxnet3_input_trace_t *t = va_arg (*args, vmxnet3_input_trace_t *);
148 vnet_main_t *vnm = vnet_get_main ();
149 vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, t->hw_if_index);
151 s = format (s, "vmxnet3: %v (%d) next-node %U",
152 hi->name, t->hw_if_index, format_vlib_next_node_name, vm,
153 node->index, t->next_index);
154 s = format (s, "\n buffer %U", format_vlib_buffer, &t->buffer);
160 * fd.io coding-style-patch-verification: ON
163 * eval: (c-set-style "gnu")