X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fdevices%2Fvirtio%2Fvirtio.c;h=6504b2ae762677e53437c0fbaf4ca8883318fb6f;hb=6d4af8918;hp=90acb75fa6db74a588bc840d723c632dc7b7b934;hpb=aea0df3d54d90eac3b8085ab8023c502b96bdbf0;p=vpp.git diff --git a/src/vnet/devices/virtio/virtio.c b/src/vnet/devices/virtio/virtio.c index 90acb75fa6d..6504b2ae762 100644 --- a/src/vnet/devices/virtio/virtio.c +++ b/src/vnet/devices/virtio/virtio.c @@ -64,11 +64,7 @@ call_read_ready (clib_file_t * uf) clib_error_t * virtio_vring_init (vlib_main_t * vm, virtio_if_t * vif, u16 idx, u16 sz) { - clib_error_t *err = 0; virtio_vring_t *vring; - struct vhost_vring_state state = { 0 }; - struct vhost_vring_addr addr = { 0 }; - struct vhost_vring_file file = { 0 }; clib_file_t t = { 0 }; int i; @@ -83,9 +79,12 @@ virtio_vring_init (vlib_main_t * vm, virtio_if_t * vif, u16 idx, u16 sz) if (idx % 2) { + vlib_thread_main_t *thm = vlib_get_thread_main (); vec_validate_aligned (vif->txq_vrings, TX_QUEUE_ACCESS (idx), CLIB_CACHE_LINE_BYTES); vring = vec_elt_at_index (vif->txq_vrings, TX_QUEUE_ACCESS (idx)); + if (thm->n_vlib_mains > vif->num_txqs) + clib_spinlock_init (&vring->lockp); } else { @@ -116,7 +115,9 @@ virtio_vring_init (vlib_main_t * vm, virtio_if_t * vif, u16 idx, u16 sz) vring->size = sz; vring->call_fd = eventfd (0, EFD_NONBLOCK | EFD_CLOEXEC); - vring->kick_fd = eventfd (0, EFD_CLOEXEC); + vring->kick_fd = eventfd (0, EFD_NONBLOCK | EFD_CLOEXEC); + virtio_log_debug (vif, "vring %u size %u call_fd %d kick_fd %d", idx, + vring->size, vring->call_fd, vring->kick_fd); t.read_function = call_read_ready; t.file_descriptor = vring->call_fd; @@ -125,27 +126,7 @@ virtio_vring_init (vlib_main_t * vm, virtio_if_t * vif, u16 idx, u16 sz) vif->dev_instance, idx); vring->call_file_index = clib_file_add (&file_main, &t); - state.index = idx; - state.num = sz; - _IOCTL (vif->fd, VHOST_SET_VRING_NUM, &state); - - addr.index = idx; - addr.flags = 0; - addr.desc_user_addr = pointer_to_uword (vring->desc); - addr.avail_user_addr = pointer_to_uword (vring->avail); - addr.used_user_addr = pointer_to_uword (vring->used); - _IOCTL (vif->fd, VHOST_SET_VRING_ADDR, &addr); - - file.index = idx; - file.fd = vring->kick_fd; - _IOCTL (vif->fd, VHOST_SET_VRING_KICK, &file); - file.fd = vring->call_fd; - _IOCTL (vif->fd, VHOST_SET_VRING_CALL, &file); - file.fd = vif->tap_fd; - _IOCTL (vif->fd, VHOST_NET_SET_BACKEND, &file); - -error: - return err; + return 0; } inline void @@ -230,6 +211,7 @@ virtio_vring_free_tx (vlib_main_t * vm, virtio_if_t * vif, u32 idx) if (vring->avail) clib_mem_free (vring->avail); vec_free (vring->buffers); + clib_spinlock_free (&vring->lockp); return 0; } @@ -306,17 +288,27 @@ virtio_show (vlib_main_t * vm, u32 * hw_if_indices, u8 show_descr, u32 type) { vlib_cli_output (vm, " PCI Address: %U", format_vlib_pci_addr, &vif->pci_addr); + vlib_cli_output (vm, " csum-enabled %d", + vif->csum_offload_enabled); } if (type == VIRTIO_IF_TYPE_TAP) { + u8 *str = 0; if (vif->host_if_name) vlib_cli_output (vm, " name \"%s\"", vif->host_if_name); if (vif->net_ns) vlib_cli_output (vm, " host-ns \"%s\"", vif->net_ns); - vlib_cli_output (vm, " fd %d", vif->fd); + if (vif->host_mtu_size) + vlib_cli_output (vm, " host-mtu-size \"%d\"", + vif->host_mtu_size); + + vec_foreach_index (i, vif->vhost_fds) + str = format (str, " %d", vif->vhost_fds[i]); + vlib_cli_output (vm, " vhost-fds%v", str); + vec_free (str); vlib_cli_output (vm, " tap-fd %d", vif->tap_fd); - vlib_cli_output (vm, " gso-enabled %d", vif->gso_enabled); } + vlib_cli_output (vm, " gso-enabled %d", vif->gso_enabled); vlib_cli_output (vm, " Mac Address: %U", format_ethernet_address, vif->mac_addr); vlib_cli_output (vm, " Device instance: %u", vif->dev_instance); @@ -467,6 +459,20 @@ virtio_show (vlib_main_t * vm, u32 * hw_if_indices, u8 show_descr, u32 type) } +static clib_error_t * +virtio_init (vlib_main_t * vm) +{ + virtio_main_t *vim = &virtio_main; + clib_error_t *error = 0; + + vim->log_default = vlib_log_register_class ("virtio", 0); + vlib_log_debug (vim->log_default, "initialized"); + + return error; +} + +VLIB_INIT_FUNCTION (virtio_init); + /* * fd.io coding-style-patch-verification: ON *