#include <vnet/ethernet/ethernet.h>
#include <vnet/devices/devices.h>
#include <vnet/feature/feature.h>
+#include <vnet/interface/rx_queue_funcs.h>
#include <vnet/devices/virtio/vhost_user.h>
#include <vnet/devices/virtio/vhost_user_inline.h>
ASSERT ((qid & 1) == 1); // should be odd
// Assign new queue mappings for the interface
- vnet_hw_interface_set_input_node (vnm, vui->hw_if_index,
- vhost_user_input_node.index);
- vnet_hw_interface_assign_rx_thread (vnm, vui->hw_if_index, q, ~0);
+ vnet_hw_if_set_input_node (vnm, vui->hw_if_index,
+ vhost_user_input_node.index);
+ txvq->queue_index = vnet_hw_if_register_rx_queue (vnm, vui->hw_if_index, q,
+ VNET_HW_IF_RXQ_THREAD_ANY);
if (txvq->mode == VNET_HW_IF_RX_MODE_UNKNOWN)
/* Set polling as the default */
txvq->mode = VNET_HW_IF_RX_MODE_POLLING;
txvq->qid = q;
- rv = vnet_hw_interface_set_rx_mode (vnm, vui->hw_if_index, q, txvq->mode);
+ rv = vnet_hw_if_set_rx_queue_mode (vnm, txvq->queue_index, txvq->mode);
if (rv)
vu_log_warn (vui, "unable to set rx mode for interface %d, "
"queue %d: rc=%d", vui->hw_if_index, q, rv);
+ vnet_hw_if_update_runtime_data (vnm, vui->hw_if_index);
}
/** @brief Returns whether at least one TX and one RX vring are enabled */
{
u32 qid;
vnet_main_t *vnm = vnet_get_main ();
+ vhost_user_vring_t *txvq;
qid = ifq & 0xff;
if ((qid & 1) == 0)
/* Only care about the odd number, or TX, virtqueue */
return;
- if (vhost_user_intf_ready (vui))
- // qid >> 1 is to convert virtqueue number to vring queue index
- vnet_device_input_set_interrupt_pending (vnm, vui->hw_if_index, qid >> 1);
+ // qid >> 1 is to convert virtqueue number to vring queue index
+ qid >>= 1;
+ txvq = &vui->vrings[VHOST_VRING_IDX_TX (qid)];
+ if (vhost_user_intf_ready (vui) &&
+ ((txvq->mode == VNET_HW_IF_RX_MODE_ADAPTIVE) ||
+ (txvq->mode == VNET_HW_IF_RX_MODE_INTERRUPT)))
+ vnet_hw_if_rx_queue_set_int_pending (vnm, txvq->queue_index);
}
static clib_error_t *
if (vui->enable_gso &&
((vui->features & FEATURE_VIRTIO_NET_F_HOST_GUEST_TSO_FEATURE_BITS)
== FEATURE_VIRTIO_NET_F_HOST_GUEST_TSO_FEATURE_BITS))
- hw->flags |=
- (VNET_HW_INTERFACE_FLAG_SUPPORTS_GSO |
- VNET_HW_INTERFACE_FLAG_SUPPORTS_TX_L4_CKSUM_OFFLOAD);
+ {
+ hw->caps |= (VNET_HW_INTERFACE_CAP_SUPPORTS_TCP_GSO |
+ VNET_HW_INTERFACE_CAP_SUPPORTS_TX_TCP_CKSUM |
+ VNET_HW_INTERFACE_CAP_SUPPORTS_TX_UDP_CKSUM);
+ }
else
- hw->flags &= ~(VNET_HW_INTERFACE_FLAG_SUPPORTS_GSO |
- VNET_HW_INTERFACE_FLAG_SUPPORTS_TX_L4_CKSUM_OFFLOAD);
+ {
+ hw->caps &= ~(VNET_HW_INTERFACE_CAP_SUPPORTS_TCP_GSO |
+ VNET_HW_INTERFACE_CAP_SUPPORTS_L4_TX_CKSUM);
+ }
vnet_hw_interface_set_flags (vnm, vui->hw_if_index, 0);
vui->is_ready = 0;
vhost_user_update_iface_state (vui);
sun.sun_family = AF_UNIX;
template.read_function = vhost_user_socket_read;
template.error_function = vhost_user_socket_error;
- template.description = format (0, "vhost user process");
while (1)
{
template.file_descriptor = sockfd;
template.private_data =
vui - vhost_user_main.vhost_user_interfaces;
+ template.description = format (0, "vhost user process");
vui->clib_file_index = clib_file_add (&file_main, &template);
vui->num_qid = 2;
for (q = 0; q < vui->num_qid; q++)
{
- // Remove existing queue mapping for the interface
- if (q & 1)
- {
- int rv;
- vnet_main_t *vnm = vnet_get_main ();
- vhost_user_vring_t *txvq = &vui->vrings[q];
-
- if (txvq->qid != -1)
- {
- rv = vnet_hw_interface_unassign_rx_thread (vnm,
- vui->hw_if_index,
- q >> 1);
- if (rv)
- vu_log_warn (vui, "unable to unassign interface %d, "
- "queue %d: rc=%d", vui->hw_if_index, q >> 1, rv);
- }
- }
-
clib_spinlock_free (&vui->vrings[q].vring_lock);
}
* Create ethernet interface for vhost user interface.
*/
static void
-vhost_user_create_ethernet (vnet_main_t * vnm, vlib_main_t * vm,
- vhost_user_intf_t * vui, u8 * hwaddress)
+vhost_user_create_ethernet (vnet_main_t *vnm, vlib_main_t *vm,
+ vhost_user_intf_t *vui,
+ vhost_user_create_if_args_t *args)
{
vhost_user_main_t *vum = &vhost_user_main;
u8 hwaddr[6];
clib_error_t *error;
/* create hw and sw interface */
- if (hwaddress)
+ if (args->use_custom_mac)
{
- clib_memcpy (hwaddr, hwaddress, 6);
+ clib_memcpy (hwaddr, args->hwaddr, 6);
}
else
{
for (q = 0; q < vec_len (vui->vrings); q++)
vhost_user_vring_init (vui, q);
- hw->flags |= VNET_HW_INTERFACE_FLAG_SUPPORTS_INT_MODE;
+ hw->caps |= VNET_HW_INTERFACE_CAP_SUPPORTS_INT_MODE;
vnet_hw_interface_set_flags (vnm, vui->hw_if_index, 0);
if (sw_if_index)
/* Protect the uninitialized vui from being dispatched by rx/tx */
vlib_worker_thread_barrier_sync (vm);
pool_get (vhost_user_main.vhost_user_interfaces, vui);
- vhost_user_create_ethernet (vnm, vm, vui, args->hwaddr);
+ vhost_user_create_ethernet (vnm, vm, vui, args);
vlib_worker_thread_barrier_release (vm);
vhost_user_vui_init (vnm, vui, server_sock_fd, args, &sw_if_idx);
;
else if (unformat (line_input, "hwaddr %U", unformat_ethernet_address,
args.hwaddr))
- ;
+ args.use_custom_mac = 1;
else if (unformat (line_input, "renumber %d",
&args.custom_dev_instance))
args.renumber = 1;
{
vnet_main_t *vnm = vnet_get_main ();
uword thread_index;
- vnet_hw_if_rx_mode mode;
vhost_user_vring_t *txvq = &vui->vrings[qid];
if (txvq->qid == -1)
continue;
thread_index =
- vnet_get_device_input_thread_index (vnm, vui->hw_if_index,
- qid >> 1);
- vnet_hw_interface_get_rx_mode (vnm, vui->hw_if_index, qid >> 1,
- &mode);
- vlib_cli_output (vm, " thread %d on vring %d, %U\n",
- thread_index, qid,
- format_vnet_hw_if_rx_mode, mode);
+ vnet_hw_if_get_rx_queue_thread_index (vnm, txvq->queue_index);
+ vlib_cli_output (vm, " thread %d on vring %d, %U\n", thread_index,
+ qid, format_vnet_hw_if_rx_mode, txvq->mode);
}
vlib_cli_output (vm, " tx placement: %s\n",