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 <vmxnet3/vmxnet3.h>
24 :
25 : u8 *
26 0 : format_vmxnet3_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 : vmxnet3_main_t *vmxm = &vmxnet3_main;
31 0 : vmxnet3_device_t *vd = vec_elt_at_index (vmxm->devices, i);
32 0 : vlib_pci_addr_t *addr = vlib_pci_get_addr (vm, vd->pci_dev_handle);
33 :
34 0 : s = format (s, "vmxnet3-%x/%x/%x/%x",
35 0 : addr->domain, addr->bus, addr->slot, addr->function);
36 0 : return s;
37 : }
38 :
39 : u8 *
40 0 : format_vmxnet3_device_flags (u8 * s, va_list * args)
41 : {
42 0 : vmxnet3_device_t *vd = va_arg (*args, vmxnet3_device_t *);
43 0 : u8 *t = 0;
44 :
45 : #define _(a, b, c) if (vd->flags & (1 << a)) \
46 : t = format (t, "%s%s", t ? " ":"", c);
47 0 : foreach_vmxnet3_device_flags
48 : #undef _
49 0 : s = format (s, "%v", t);
50 0 : vec_free (t);
51 0 : return s;
52 : }
53 :
54 : u8 *
55 0 : format_vmxnet3_device (u8 * s, va_list * args)
56 : {
57 0 : u32 i = va_arg (*args, u32);
58 0 : vmxnet3_main_t *vmxm = &vmxnet3_main;
59 0 : vmxnet3_device_t *vd = vec_elt_at_index (vmxm->devices, i);
60 0 : u32 indent = format_get_indent (s);
61 0 : vmxnet3_rxq_t *rxq = vec_elt_at_index (vd->rxqs, 0);
62 0 : vmxnet3_txq_t *txq = vec_elt_at_index (vd->txqs, 0);
63 0 : vmxnet3_tx_queue *tx = VMXNET3_TX_START (vd);
64 0 : vmxnet3_rx_queue *rx = VMXNET3_RX_START (vd);
65 : u16 qid;
66 :
67 0 : s = format (s, "flags: %U", format_vmxnet3_device_flags, vd);
68 0 : s = format (s, "\n%Urx queues %u, rx desc %u, tx queues %u, tx desc %u",
69 : format_white_space, indent,
70 0 : vd->num_rx_queues, rxq->size, vd->num_tx_queues, txq->size);
71 0 : if (vd->error)
72 0 : s = format (s, "\n%Uerror %U", format_white_space, indent,
73 : format_clib_error, vd->error);
74 :
75 0 : vmxnet3_reg_write (vd, 1, VMXNET3_REG_CMD, VMXNET3_CMD_GET_STATS);
76 :
77 0 : vec_foreach_index (qid, vd->txqs)
78 : {
79 0 : vmxnet3_tx_stats *txs = vec_elt_at_index (vd->tx_stats, qid);
80 :
81 0 : s = format (s, "\n%UTX Queue %u:", format_white_space, indent, qid);
82 0 : s = format (s, "\n%U TSO packets %llu",
83 : format_white_space, indent,
84 0 : tx->stats.tso_pkts - txs->tso_pkts);
85 0 : s = format (s, "\n%U TSO bytes %llu",
86 : format_white_space, indent,
87 0 : tx->stats.tso_bytes - txs->tso_bytes);
88 0 : s = format (s, "\n%U ucast packets %llu",
89 : format_white_space, indent,
90 0 : tx->stats.ucast_pkts - txs->ucast_pkts);
91 0 : s = format (s, "\n%U ucast bytes %llu",
92 : format_white_space, indent,
93 0 : tx->stats.ucast_bytes - txs->ucast_bytes);
94 0 : s = format (s, "\n%U mcast packets %llu",
95 : format_white_space, indent,
96 0 : tx->stats.mcast_pkts - txs->mcast_pkts);
97 0 : s = format (s, "\n%U mcast bytes %llu",
98 : format_white_space, indent,
99 0 : tx->stats.mcast_bytes - txs->mcast_bytes);
100 0 : s = format (s, "\n%U bcast packets %llu",
101 : format_white_space, indent,
102 0 : tx->stats.bcast_pkts - txs->bcast_pkts);
103 0 : s = format (s, "\n%U bcast bytes %llu",
104 : format_white_space, indent,
105 0 : tx->stats.bcast_bytes - txs->bcast_bytes);
106 0 : s = format (s, "\n%U Errors packets %llu",
107 : format_white_space, indent,
108 0 : tx->stats.error_pkts - txs->error_pkts);
109 0 : s = format (s, "\n%U Discard packets %llu",
110 : format_white_space, indent,
111 0 : tx->stats.discard_pkts - txs->discard_pkts);
112 0 : tx++;
113 : }
114 :
115 0 : vec_foreach_index (qid, vd->rxqs)
116 : {
117 0 : vmxnet3_rx_stats *rxs = vec_elt_at_index (vd->rx_stats, qid);
118 :
119 0 : s = format (s, "\n%URX Queue %u:", format_white_space, indent, qid);
120 0 : s = format (s, "\n%U LRO packets %llu",
121 : format_white_space, indent,
122 0 : rx->stats.lro_pkts - rxs->lro_pkts);
123 0 : s = format (s, "\n%U LRO bytes %llu",
124 : format_white_space, indent,
125 0 : rx->stats.lro_bytes - rxs->lro_bytes);
126 0 : s = format (s, "\n%U ucast packets %llu",
127 : format_white_space, indent,
128 0 : rx->stats.ucast_pkts - rxs->ucast_pkts);
129 0 : s = format (s, "\n%U ucast bytes %llu",
130 : format_white_space, indent,
131 0 : rx->stats.ucast_bytes - rxs->ucast_bytes);
132 0 : s = format (s, "\n%U mcast packets %llu",
133 : format_white_space, indent,
134 0 : rx->stats.mcast_pkts - rxs->mcast_pkts);
135 0 : s = format (s, "\n%U mcast bytes %llu",
136 : format_white_space, indent,
137 0 : rx->stats.mcast_bytes - rxs->mcast_bytes);
138 0 : s = format (s, "\n%U bcast packets %llu",
139 : format_white_space, indent,
140 0 : rx->stats.bcast_pkts - rxs->bcast_pkts);
141 0 : s = format (s, "\n%U bcast bytes %llu",
142 : format_white_space, indent,
143 0 : rx->stats.bcast_bytes - rxs->bcast_bytes);
144 0 : s = format (s, "\n%U No Bufs %llu",
145 : format_white_space, indent,
146 0 : rx->stats.nobuf_pkts - rxs->nobuf_pkts);
147 0 : s = format (s, "\n%U Error packets %llu",
148 : format_white_space, indent,
149 0 : rx->stats.error_pkts - rxs->error_pkts);
150 0 : rx++;
151 : }
152 0 : return s;
153 : }
154 :
155 : u8 *
156 0 : format_vmxnet3_input_trace (u8 * s, va_list * args)
157 : {
158 0 : vlib_main_t *vm = va_arg (*args, vlib_main_t *);
159 0 : vlib_node_t *node = va_arg (*args, vlib_node_t *);
160 0 : vmxnet3_input_trace_t *t = va_arg (*args, vmxnet3_input_trace_t *);
161 0 : vnet_main_t *vnm = vnet_get_main ();
162 0 : vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, t->hw_if_index);
163 :
164 0 : s = format (s, "vmxnet3: %v (%d) next-node %U",
165 : hi->name, t->hw_if_index, format_vlib_next_node_name, vm,
166 : node->index, t->next_index);
167 0 : s = format (s, "\n buffer %U", format_vnet_buffer_no_chain, &t->buffer);
168 :
169 0 : return s;
170 : }
171 :
172 : /*
173 : * fd.io coding-style-patch-verification: ON
174 : *
175 : * Local Variables:
176 : * eval: (c-set-style "gnu")
177 : * End:
178 : */
|