tap: multiqueue support
Type: feature Change-Id: I7dcc8c6911d02729b3bda1b3a21a211c82c3b949 Signed-off-by: Damjan Marion <damarion@cisco.com>
This commit is contained in:

committed by
Florin Coras

parent
0b6c9c485f
commit
7c6102b1aa
@ -42,6 +42,7 @@ tap_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
|
||||
args.id = ~0;
|
||||
args.tap_flags = 0;
|
||||
args.rv = -1;
|
||||
args.num_rx_queues = 1;
|
||||
|
||||
/* Get a line of input. */
|
||||
if (unformat_user (input, unformat_line_input, line_input))
|
||||
@ -74,6 +75,8 @@ tap_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
|
||||
else if (unformat (line_input, "host-ip6-gw %U",
|
||||
unformat_ip6_address, &args.host_ip6_gw))
|
||||
args.host_ip6_gw_set = 1;
|
||||
else if (unformat (line_input, "num-rx-queues %d", &tmp))
|
||||
args.num_rx_queues = tmp;
|
||||
else if (unformat (line_input, "rx-ring-size %d", &tmp))
|
||||
args.rx_ring_sz = tmp;
|
||||
else if (unformat (line_input, "tx-ring-size %d", &tmp))
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -27,6 +27,7 @@ typedef struct
|
||||
u32 id;
|
||||
u8 mac_addr_set;
|
||||
u8 mac_addr[6];
|
||||
u8 num_rx_queues;
|
||||
u16 rx_ring_sz;
|
||||
u16 tx_ring_sz;
|
||||
u32 tap_flags;
|
||||
|
@ -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;
|
||||
|
||||
@ -87,7 +83,7 @@ virtio_vring_init (vlib_main_t * vm, virtio_if_t * vif, u16 idx, u16 sz)
|
||||
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 > 1)
|
||||
if (thm->n_vlib_mains > vif->num_txqs)
|
||||
clib_spinlock_init (&vring->lockp);
|
||||
}
|
||||
else
|
||||
@ -119,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;
|
||||
@ -128,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
|
||||
@ -313,6 +291,7 @@ virtio_show (vlib_main_t * vm, u32 * hw_if_indices, u8 show_descr, u32 type)
|
||||
}
|
||||
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)
|
||||
@ -320,7 +299,11 @@ virtio_show (vlib_main_t * vm, u32 * hw_if_indices, u8 show_descr, u32 type)
|
||||
if (vif->host_mtu_size)
|
||||
vlib_cli_output (vm, " host-mtu-size \"%d\"",
|
||||
vif->host_mtu_size);
|
||||
vlib_cli_output (vm, " fd %d", vif->fd);
|
||||
|
||||
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);
|
||||
|
@ -148,16 +148,10 @@ typedef struct
|
||||
pci_addr_t pci_addr;
|
||||
};
|
||||
u32 per_interface_next_index;
|
||||
union
|
||||
{
|
||||
int fd;
|
||||
u32 msix_enabled;
|
||||
};
|
||||
union
|
||||
{
|
||||
int tap_fd;
|
||||
u32 pci_dev_handle;
|
||||
};
|
||||
int *vhost_fds;
|
||||
int tap_fd;
|
||||
u32 msix_enabled;
|
||||
u32 pci_dev_handle;
|
||||
virtio_vring_t *rxq_vrings;
|
||||
virtio_vring_t *txq_vrings;
|
||||
u64 features, remote_features;
|
||||
|
Reference in New Issue
Block a user