blob: 17fbd7920da17878a69593b24fb8b75f565787cf [file] [log] [blame]
Damjan Marion8389fb92017-10-13 18:29:53 +02001/*
2 *------------------------------------------------------------------
3 * Copyright (c) 2017 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 <sys/types.h>
19#include <sys/stat.h>
20#include <fcntl.h>
21#include <net/if.h>
22#include <linux/if_tun.h>
23#include <sys/ioctl.h>
24#include <linux/virtio_net.h>
25#include <linux/vhost.h>
26#include <sys/eventfd.h>
27
28#include <vlib/vlib.h>
Mohsin Kazmid6c15af2018-10-23 18:00:47 +020029#include <vlib/pci/pci.h>
Damjan Marion8389fb92017-10-13 18:29:53 +020030#include <vlib/unix/unix.h>
31#include <vnet/ethernet/ethernet.h>
Milan Lenco73e7f422017-12-14 10:04:25 +010032#include <vnet/ip/ip4_packet.h>
33#include <vnet/ip/ip6_packet.h>
Damjan Marion8389fb92017-10-13 18:29:53 +020034#include <vnet/devices/virtio/virtio.h>
Mohsin Kazmid6c15af2018-10-23 18:00:47 +020035#include <vnet/devices/virtio/pci.h>
Damjan Marion8389fb92017-10-13 18:29:53 +020036
37virtio_main_t virtio_main;
38
39#define _IOCTL(fd,a,...) \
40 if (ioctl (fd, a, __VA_ARGS__) < 0) \
41 { \
42 err = clib_error_return_unix (0, "ioctl(" #a ")"); \
43 goto error; \
44 }
45
46static clib_error_t *
47call_read_ready (clib_file_t * uf)
48{
49 virtio_main_t *nm = &virtio_main;
50 vnet_main_t *vnm = vnet_get_main ();
51 u16 qid = uf->private_data & 0xFFFF;
52 virtio_if_t *vif =
53 vec_elt_at_index (nm->interfaces, uf->private_data >> 16);
54 u64 b;
55
56 CLIB_UNUSED (ssize_t size) = read (uf->file_descriptor, &b, sizeof (b));
57 if ((qid & 1) == 0)
Mohsin Kazmi04f4d912020-05-26 14:34:34 +020058 vnet_device_input_set_interrupt_pending (vnm, vif->hw_if_index,
59 RX_QUEUE_ACCESS (qid));
Damjan Marion8389fb92017-10-13 18:29:53 +020060
61 return 0;
62}
63
64
65clib_error_t *
66virtio_vring_init (vlib_main_t * vm, virtio_if_t * vif, u16 idx, u16 sz)
67{
Damjan Marion8389fb92017-10-13 18:29:53 +020068 virtio_vring_t *vring;
Damjan Marion8389fb92017-10-13 18:29:53 +020069 clib_file_t t = { 0 };
70 int i;
71
72 if (!is_pow2 (sz))
73 return clib_error_return (0, "ring size must be power of 2");
74
75 if (sz > 32768)
76 return clib_error_return (0, "ring size must be 32768 or lower");
77
78 if (sz == 0)
79 sz = 256;
80
Mohsin Kazmi09a3bc52019-04-02 11:45:08 +000081 if (idx % 2)
82 {
Mohsin Kazmi3f340172019-05-27 15:53:25 +020083 vlib_thread_main_t *thm = vlib_get_thread_main ();
Mohsin Kazmi09a3bc52019-04-02 11:45:08 +000084 vec_validate_aligned (vif->txq_vrings, TX_QUEUE_ACCESS (idx),
85 CLIB_CACHE_LINE_BYTES);
86 vring = vec_elt_at_index (vif->txq_vrings, TX_QUEUE_ACCESS (idx));
Damjan Marion7c6102b2019-11-08 17:59:56 +010087 if (thm->n_vlib_mains > vif->num_txqs)
Mohsin Kazmi3f340172019-05-27 15:53:25 +020088 clib_spinlock_init (&vring->lockp);
Mohsin Kazmi09a3bc52019-04-02 11:45:08 +000089 }
90 else
91 {
92 vec_validate_aligned (vif->rxq_vrings, RX_QUEUE_ACCESS (idx),
93 CLIB_CACHE_LINE_BYTES);
94 vring = vec_elt_at_index (vif->rxq_vrings, RX_QUEUE_ACCESS (idx));
95 }
Damjan Marion8389fb92017-10-13 18:29:53 +020096 i = sizeof (struct vring_desc) * sz;
97 i = round_pow2 (i, CLIB_CACHE_LINE_BYTES);
98 vring->desc = clib_mem_alloc_aligned (i, CLIB_CACHE_LINE_BYTES);
Dave Barachb7b92992018-10-17 10:38:51 -040099 clib_memset (vring->desc, 0, i);
Damjan Marion8389fb92017-10-13 18:29:53 +0200100
101 i = sizeof (struct vring_avail) + sz * sizeof (vring->avail->ring[0]);
102 i = round_pow2 (i, CLIB_CACHE_LINE_BYTES);
103 vring->avail = clib_mem_alloc_aligned (i, CLIB_CACHE_LINE_BYTES);
Dave Barachb7b92992018-10-17 10:38:51 -0400104 clib_memset (vring->avail, 0, i);
Damjan Marion8389fb92017-10-13 18:29:53 +0200105 // tell kernel that we don't need interrupt
106 vring->avail->flags = VIRTIO_RING_FLAG_MASK_INT;
107
108 i = sizeof (struct vring_used) + sz * sizeof (struct vring_used_elem);
109 i = round_pow2 (i, CLIB_CACHE_LINE_BYTES);
110 vring->used = clib_mem_alloc_aligned (i, CLIB_CACHE_LINE_BYTES);
Dave Barachb7b92992018-10-17 10:38:51 -0400111 clib_memset (vring->used, 0, i);
Damjan Marion8389fb92017-10-13 18:29:53 +0200112
Mohsin Kazmi09a3bc52019-04-02 11:45:08 +0000113 vring->queue_id = idx;
Damjan Marion8389fb92017-10-13 18:29:53 +0200114 ASSERT (vring->buffers == 0);
Damjan Marionc58408c2018-01-18 14:54:04 +0100115 vec_validate_aligned (vring->buffers, sz, CLIB_CACHE_LINE_BYTES);
Damjan Marion8389fb92017-10-13 18:29:53 +0200116
Mohsin Kazmi7f6d1452020-02-27 11:49:21 +0100117 if (idx & 1)
118 {
119 clib_memset_u32 (vring->buffers, ~0, sz);
120 }
121
Damjan Marion8389fb92017-10-13 18:29:53 +0200122 vring->size = sz;
123 vring->call_fd = eventfd (0, EFD_NONBLOCK | EFD_CLOEXEC);
Damjan Marion7c6102b2019-11-08 17:59:56 +0100124 vring->kick_fd = eventfd (0, EFD_NONBLOCK | EFD_CLOEXEC);
125 virtio_log_debug (vif, "vring %u size %u call_fd %d kick_fd %d", idx,
126 vring->size, vring->call_fd, vring->kick_fd);
Damjan Marion8389fb92017-10-13 18:29:53 +0200127
128 t.read_function = call_read_ready;
129 t.file_descriptor = vring->call_fd;
130 t.private_data = vif->dev_instance << 16 | idx;
Damjan Marionceab7882018-01-19 20:56:12 +0100131 t.description = format (0, "%U vring %u", format_virtio_device_name,
132 vif->dev_instance, idx);
Damjan Marion8389fb92017-10-13 18:29:53 +0200133 vring->call_file_index = clib_file_add (&file_main, &t);
134
Damjan Marion7c6102b2019-11-08 17:59:56 +0100135 return 0;
Damjan Marion8389fb92017-10-13 18:29:53 +0200136}
137
Mohsin Kazmid6c15af2018-10-23 18:00:47 +0200138inline void
Stevena624dbe2018-01-09 11:13:29 -0800139virtio_free_rx_buffers (vlib_main_t * vm, virtio_vring_t * vring)
Damjan Marion8389fb92017-10-13 18:29:53 +0200140{
Stevena624dbe2018-01-09 11:13:29 -0800141 u16 used = vring->desc_in_use;
Steven074f6982018-03-30 22:18:11 -0700142 u16 last = vring->last_used_idx;
Stevena624dbe2018-01-09 11:13:29 -0800143 u16 mask = vring->size - 1;
144
145 while (used)
146 {
Steven074f6982018-03-30 22:18:11 -0700147 vlib_buffer_free (vm, &vring->buffers[last & mask], 1);
148 last++;
Stevena624dbe2018-01-09 11:13:29 -0800149 used--;
150 }
151}
152
153clib_error_t *
Mohsin Kazmi09a3bc52019-04-02 11:45:08 +0000154virtio_vring_free_rx (vlib_main_t * vm, virtio_if_t * vif, u32 idx)
Stevena624dbe2018-01-09 11:13:29 -0800155{
Mohsin Kazmi09a3bc52019-04-02 11:45:08 +0000156 virtio_vring_t *vring =
157 vec_elt_at_index (vif->rxq_vrings, RX_QUEUE_ACCESS (idx));
Stevena624dbe2018-01-09 11:13:29 -0800158
159 clib_file_del_by_index (&file_main, vring->call_file_index);
160 close (vring->kick_fd);
161 close (vring->call_fd);
162 if (vring->used)
163 {
Mohsin Kazmi09a3bc52019-04-02 11:45:08 +0000164 virtio_free_rx_buffers (vm, vring);
Stevena624dbe2018-01-09 11:13:29 -0800165 clib_mem_free (vring->used);
166 }
Damjan Marion8389fb92017-10-13 18:29:53 +0200167 if (vring->desc)
168 clib_mem_free (vring->desc);
169 if (vring->avail)
170 clib_mem_free (vring->avail);
Mohsin Kazmi09a3bc52019-04-02 11:45:08 +0000171 vec_free (vring->buffers);
Mohsin Kazmi09a3bc52019-04-02 11:45:08 +0000172 return 0;
173}
174
Mohsin Kazmiaea0df32019-05-23 14:32:58 +0200175inline void
176virtio_free_used_desc (vlib_main_t * vm, virtio_vring_t * vring)
177{
178 u16 used = vring->desc_in_use;
179 u16 sz = vring->size;
180 u16 mask = sz - 1;
181 u16 last = vring->last_used_idx;
182 u16 n_left = vring->used->idx - last;
183
184 if (n_left == 0)
185 return;
186
187 while (n_left)
188 {
189 struct vring_used_elem *e = &vring->used->ring[last & mask];
190 u16 slot = e->id;
191
192 vlib_buffer_free (vm, &vring->buffers[slot], 1);
193 used--;
194 last++;
195 n_left--;
196 }
197 vring->desc_in_use = used;
198 vring->last_used_idx = last;
199}
200
Mohsin Kazmi09a3bc52019-04-02 11:45:08 +0000201clib_error_t *
202virtio_vring_free_tx (vlib_main_t * vm, virtio_if_t * vif, u32 idx)
203{
204 virtio_vring_t *vring =
205 vec_elt_at_index (vif->txq_vrings, TX_QUEUE_ACCESS (idx));
206
207 clib_file_del_by_index (&file_main, vring->call_file_index);
208 close (vring->kick_fd);
209 close (vring->call_fd);
210 if (vring->used)
Mohsin Kazmid6c15af2018-10-23 18:00:47 +0200211 {
Mohsin Kazmi09a3bc52019-04-02 11:45:08 +0000212 virtio_free_used_desc (vm, vring);
213 clib_mem_free (vring->used);
Mohsin Kazmid6c15af2018-10-23 18:00:47 +0200214 }
Mohsin Kazmi09a3bc52019-04-02 11:45:08 +0000215 if (vring->desc)
216 clib_mem_free (vring->desc);
217 if (vring->avail)
218 clib_mem_free (vring->avail);
Damjan Marion8389fb92017-10-13 18:29:53 +0200219 vec_free (vring->buffers);
Mohsin Kazmi3f340172019-05-27 15:53:25 +0200220 clib_spinlock_free (&vring->lockp);
Damjan Marion8389fb92017-10-13 18:29:53 +0200221 return 0;
222}
223
Mohsin Kazmi80659b42019-01-31 13:18:00 +0000224void
225virtio_vring_set_numa_node (vlib_main_t * vm, virtio_if_t * vif, u32 idx)
226{
227 vnet_main_t *vnm = vnet_get_main ();
228 u32 thread_index;
Mohsin Kazmi09a3bc52019-04-02 11:45:08 +0000229 virtio_vring_t *vring =
230 vec_elt_at_index (vif->rxq_vrings, RX_QUEUE_ACCESS (idx));
Mohsin Kazmi80659b42019-01-31 13:18:00 +0000231 thread_index =
232 vnet_get_device_input_thread_index (vnm, vif->hw_if_index,
Mohsin Kazmi09a3bc52019-04-02 11:45:08 +0000233 RX_QUEUE_ACCESS (idx));
Mohsin Kazmi80659b42019-01-31 13:18:00 +0000234 vring->buffer_pool_index =
235 vlib_buffer_pool_get_default_for_numa (vm,
236 vlib_mains
237 [thread_index]->numa_node);
238}
239
Mohsin Kazmid6c15af2018-10-23 18:00:47 +0200240inline void
241virtio_set_net_hdr_size (virtio_if_t * vif)
242{
243 if (vif->features & VIRTIO_FEATURE (VIRTIO_NET_F_MRG_RXBUF) ||
244 vif->features & VIRTIO_FEATURE (VIRTIO_F_VERSION_1))
245 vif->virtio_net_hdr_sz = sizeof (struct virtio_net_hdr_v1);
246 else
247 vif->virtio_net_hdr_sz = sizeof (struct virtio_net_hdr);
248}
249
250inline void
251virtio_show (vlib_main_t * vm, u32 * hw_if_indices, u8 show_descr, u32 type)
252{
253 u32 i, j, hw_if_index;
254 virtio_if_t *vif;
255 vnet_main_t *vnm = &vnet_main;
256 virtio_main_t *mm = &virtio_main;
257 virtio_vring_t *vring;
258 struct feat_struct
259 {
260 u8 bit;
261 char *str;
262 };
263 struct feat_struct *feat_entry;
264
265 static struct feat_struct feat_array[] = {
266#define _(s,b) { .str = #s, .bit = b, },
267 foreach_virtio_net_features
268#undef _
269 {.str = NULL}
270 };
271
272 struct feat_struct *flag_entry;
273 static struct feat_struct flags_array[] = {
274#define _(b,e,s) { .bit = b, .str = s, },
275 foreach_virtio_if_flag
276#undef _
277 {.str = NULL}
278 };
279
280 if (!hw_if_indices)
281 return;
282
283 for (hw_if_index = 0; hw_if_index < vec_len (hw_if_indices); hw_if_index++)
284 {
285 vnet_hw_interface_t *hi =
286 vnet_get_hw_interface (vnm, hw_if_indices[hw_if_index]);
287 vif = pool_elt_at_index (mm->interfaces, hi->dev_instance);
288 if (vif->type != type)
289 continue;
290 vlib_cli_output (vm, "Interface: %U (ifindex %d)",
291 format_vnet_hw_if_index_name, vnm,
292 hw_if_indices[hw_if_index], vif->hw_if_index);
293 if (type == VIRTIO_IF_TYPE_PCI)
294 {
295 vlib_cli_output (vm, " PCI Address: %U", format_vlib_pci_addr,
296 &vif->pci_addr);
297 }
Mohsin Kazmi206acf82020-04-06 14:19:54 +0200298 if (type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_TUN))
Mohsin Kazmid6c15af2018-10-23 18:00:47 +0200299 {
Damjan Marion7c6102b2019-11-08 17:59:56 +0100300 u8 *str = 0;
Mohsin Kazmid6c15af2018-10-23 18:00:47 +0200301 if (vif->host_if_name)
302 vlib_cli_output (vm, " name \"%s\"", vif->host_if_name);
303 if (vif->net_ns)
304 vlib_cli_output (vm, " host-ns \"%s\"", vif->net_ns);
Mohsin Kazmi97d54ed2019-06-10 11:20:15 +0200305 if (vif->host_mtu_size)
306 vlib_cli_output (vm, " host-mtu-size \"%d\"",
307 vif->host_mtu_size);
Mohsin Kazmi206acf82020-04-06 14:19:54 +0200308 if (type == VIRTIO_IF_TYPE_TAP)
309 vlib_cli_output (vm, " host-mac-addr: %U",
310 format_ethernet_address, vif->host_mac_addr);
Damjan Marion7c6102b2019-11-08 17:59:56 +0100311
312 vec_foreach_index (i, vif->vhost_fds)
313 str = format (str, " %d", vif->vhost_fds[i]);
314 vlib_cli_output (vm, " vhost-fds%v", str);
315 vec_free (str);
Aloys Augustin2857e782020-03-16 17:29:52 +0100316 vec_foreach_index (i, vif->tap_fds)
317 str = format (str, " %d", vif->tap_fds[i]);
318 vlib_cli_output (vm, " tap-fds%v", str);
319 vec_free (str);
Mohsin Kazmid6c15af2018-10-23 18:00:47 +0200320 }
Chenmin Sun7c615ae2019-07-18 23:19:28 +0800321 vlib_cli_output (vm, " gso-enabled %d", vif->gso_enabled);
Mohsin Kazmiba0061f2019-12-18 17:08:54 +0100322 vlib_cli_output (vm, " csum-enabled %d", vif->csum_offload_enabled);
Mohsin Kazmi206acf82020-04-06 14:19:54 +0200323 if (type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_PCI))
324 vlib_cli_output (vm, " Mac Address: %U", format_ethernet_address,
325 vif->mac_addr);
Mohsin Kazmid6c15af2018-10-23 18:00:47 +0200326 vlib_cli_output (vm, " Device instance: %u", vif->dev_instance);
327 vlib_cli_output (vm, " flags 0x%x", vif->flags);
328 flag_entry = (struct feat_struct *) &flags_array;
329 while (flag_entry->str)
330 {
331 if (vif->flags & (1ULL << flag_entry->bit))
332 vlib_cli_output (vm, " %s (%d)", flag_entry->str,
333 flag_entry->bit);
334 flag_entry++;
335 }
336 if (type == VIRTIO_IF_TYPE_PCI)
337 {
338 device_status (vm, vif);
339 }
340 vlib_cli_output (vm, " features 0x%lx", vif->features);
341 feat_entry = (struct feat_struct *) &feat_array;
342 while (feat_entry->str)
343 {
344 if (vif->features & (1ULL << feat_entry->bit))
345 vlib_cli_output (vm, " %s (%d)", feat_entry->str,
346 feat_entry->bit);
347 feat_entry++;
348 }
349 vlib_cli_output (vm, " remote-features 0x%lx", vif->remote_features);
350 feat_entry = (struct feat_struct *) &feat_array;
351 while (feat_entry->str)
352 {
353 if (vif->remote_features & (1ULL << feat_entry->bit))
354 vlib_cli_output (vm, " %s (%d)", feat_entry->str,
355 feat_entry->bit);
356 feat_entry++;
357 }
Mohsin Kazmi09a3bc52019-04-02 11:45:08 +0000358 vlib_cli_output (vm, " Number of RX Virtqueue %u", vif->num_rxqs);
359 vlib_cli_output (vm, " Number of TX Virtqueue %u", vif->num_txqs);
360 if (vif->cxq_vring != NULL
361 && vif->features & VIRTIO_FEATURE (VIRTIO_NET_F_CTRL_VQ))
362 vlib_cli_output (vm, " Number of CTRL Virtqueue 1");
363 vec_foreach_index (i, vif->rxq_vrings)
Mohsin Kazmid6c15af2018-10-23 18:00:47 +0200364 {
Mohsin Kazmi09a3bc52019-04-02 11:45:08 +0000365 vring = vec_elt_at_index (vif->rxq_vrings, i);
366 vlib_cli_output (vm, " Virtqueue (RX) %d", vring->queue_id);
Mohsin Kazmid6c15af2018-10-23 18:00:47 +0200367 vlib_cli_output (vm,
368 " qsz %d, last_used_idx %d, desc_next %d, desc_in_use %d",
369 vring->size, vring->last_used_idx, vring->desc_next,
370 vring->desc_in_use);
371 vlib_cli_output (vm,
372 " avail.flags 0x%x avail.idx %d used.flags 0x%x used.idx %d",
373 vring->avail->flags, vring->avail->idx,
374 vring->used->flags, vring->used->idx);
Mohsin Kazmi206acf82020-04-06 14:19:54 +0200375 if (type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_TUN))
Mohsin Kazmid6c15af2018-10-23 18:00:47 +0200376 {
377 vlib_cli_output (vm, " kickfd %d, callfd %d", vring->kick_fd,
378 vring->call_fd);
379 }
380 if (show_descr)
381 {
382 vlib_cli_output (vm, "\n descriptor table:\n");
383 vlib_cli_output (vm,
384 " id addr len flags next user_addr\n");
385 vlib_cli_output (vm,
386 " ===== ================== ===== ====== ===== ==================\n");
Mohsin Kazmid6c15af2018-10-23 18:00:47 +0200387 for (j = 0; j < vring->size; j++)
388 {
389 struct vring_desc *desc = &vring->desc[j];
390 vlib_cli_output (vm,
391 " %-5d 0x%016lx %-5d 0x%04x %-5d 0x%016lx\n",
392 j, desc->addr,
393 desc->len,
394 desc->flags, desc->next, desc->addr);
395 }
396 }
397 }
Mohsin Kazmi09a3bc52019-04-02 11:45:08 +0000398 vec_foreach_index (i, vif->txq_vrings)
399 {
400 vring = vec_elt_at_index (vif->txq_vrings, i);
401 vlib_cli_output (vm, " Virtqueue (TX) %d", vring->queue_id);
402 vlib_cli_output (vm,
403 " qsz %d, last_used_idx %d, desc_next %d, desc_in_use %d",
404 vring->size, vring->last_used_idx, vring->desc_next,
405 vring->desc_in_use);
406 vlib_cli_output (vm,
407 " avail.flags 0x%x avail.idx %d used.flags 0x%x used.idx %d",
408 vring->avail->flags, vring->avail->idx,
409 vring->used->flags, vring->used->idx);
Mohsin Kazmi206acf82020-04-06 14:19:54 +0200410 if (type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_TUN))
Mohsin Kazmi09a3bc52019-04-02 11:45:08 +0000411 {
412 vlib_cli_output (vm, " kickfd %d, callfd %d", vring->kick_fd,
413 vring->call_fd);
414 }
415 if (show_descr)
416 {
417 vlib_cli_output (vm, "\n descriptor table:\n");
418 vlib_cli_output (vm,
419 " id addr len flags next user_addr\n");
420 vlib_cli_output (vm,
421 " ===== ================== ===== ====== ===== ==================\n");
422 for (j = 0; j < vring->size; j++)
423 {
424 struct vring_desc *desc = &vring->desc[j];
425 vlib_cli_output (vm,
426 " %-5d 0x%016lx %-5d 0x%04x %-5d 0x%016lx\n",
427 j, desc->addr,
428 desc->len,
429 desc->flags, desc->next, desc->addr);
430 }
431 }
432 }
433 if (vif->cxq_vring != NULL
434 && vif->features & VIRTIO_FEATURE (VIRTIO_NET_F_CTRL_VQ))
435 {
436 vring = vif->cxq_vring;
437 vlib_cli_output (vm, " Virtqueue (CTRL) %d", vring->queue_id);
438 vlib_cli_output (vm,
439 " qsz %d, last_used_idx %d, desc_next %d, desc_in_use %d",
440 vring->size, vring->last_used_idx,
441 vring->desc_next, vring->desc_in_use);
442 vlib_cli_output (vm,
443 " avail.flags 0x%x avail.idx %d used.flags 0x%x used.idx %d",
444 vring->avail->flags, vring->avail->idx,
445 vring->used->flags, vring->used->idx);
Mohsin Kazmi206acf82020-04-06 14:19:54 +0200446 if (type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_TUN))
Mohsin Kazmi09a3bc52019-04-02 11:45:08 +0000447 {
448 vlib_cli_output (vm, " kickfd %d, callfd %d", vring->kick_fd,
449 vring->call_fd);
450 }
451 if (show_descr)
452 {
453 vlib_cli_output (vm, "\n descriptor table:\n");
454 vlib_cli_output (vm,
455 " id addr len flags next user_addr\n");
456 vlib_cli_output (vm,
457 " ===== ================== ===== ====== ===== ==================\n");
458 for (j = 0; j < vring->size; j++)
459 {
460 struct vring_desc *desc = &vring->desc[j];
461 vlib_cli_output (vm,
462 " %-5d 0x%016lx %-5d 0x%04x %-5d 0x%016lx\n",
463 j, desc->addr,
464 desc->len,
465 desc->flags, desc->next, desc->addr);
466 }
467 }
468 }
469
Mohsin Kazmid6c15af2018-10-23 18:00:47 +0200470 }
471
472}
473
Damjan Marionf41244f2019-11-08 17:41:06 +0100474static clib_error_t *
475virtio_init (vlib_main_t * vm)
476{
477 virtio_main_t *vim = &virtio_main;
478 clib_error_t *error = 0;
479
480 vim->log_default = vlib_log_register_class ("virtio", 0);
481 vlib_log_debug (vim->log_default, "initialized");
482
483 return error;
484}
485
486VLIB_INIT_FUNCTION (virtio_init);
487
Damjan Marion8389fb92017-10-13 18:29:53 +0200488/*
489 * fd.io coding-style-patch-verification: ON
490 *
491 * Local Variables:
492 * eval: (c-set-style "gnu")
493 * End:
494 */