aboutsummaryrefslogtreecommitdiffstats
path: root/vnet
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2016-08-24 14:32:39 +0200
committerOle Trøan <otroan@employees.org>2016-08-25 07:42:37 +0000
commit78c7daaf6d866e7c5ad01e5d7251cd0955b8f745 (patch)
treed6cedfa9b15488ac616d96d10585dffedf9966fc /vnet
parent8b66c7792010f5fffc864c2bcf72f977ba072ecd (diff)
Fix issues with vhost-user when dpdk vhost-user is disabled, fixes VPP-347, VPP-349
Change-Id: I774bab98e43d55678a67a7708ca50edbbd4cbb06 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'vnet')
-rw-r--r--vnet/Makefile.am2
-rw-r--r--vnet/vnet/devices/dpdk/vhost_user.c14
-rw-r--r--vnet/vnet/devices/virtio/vhost-user.c50
-rw-r--r--vnet/vnet/devices/virtio/vhost-user.h4
4 files changed, 61 insertions, 9 deletions
diff --git a/vnet/Makefile.am b/vnet/Makefile.am
index 72bdd11f54b..a763291c2af 100644
--- a/vnet/Makefile.am
+++ b/vnet/Makefile.am
@@ -626,13 +626,11 @@ endif
# virtio
########################################
-if WITH_DPDK
libvnet_la_SOURCES += \
vnet/devices/virtio/vhost-user.c
nobase_include_HEADERS += \
vnet/devices/virtio/vhost-user.h
-endif WITH_DPDK
########################################
# ssvm ethernet
diff --git a/vnet/vnet/devices/dpdk/vhost_user.c b/vnet/vnet/devices/dpdk/vhost_user.c
index c153e2ede78..03f84921551 100644
--- a/vnet/vnet/devices/dpdk/vhost_user.c
+++ b/vnet/vnet/devices/dpdk/vhost_user.c
@@ -1787,6 +1787,7 @@ dpdk_vhost_user_process_if (vlib_main_t * vm, dpdk_device_t * xd, void *ctx)
}
return 0;
}
+#endif
/*
* CLI functions
@@ -1797,6 +1798,7 @@ dpdk_vhost_user_connect_command_fn (vlib_main_t * vm,
unformat_input_t * input,
vlib_cli_command_t * cmd)
{
+#if DPDK_VHOST_USER
dpdk_main_t *dm = &dpdk_main;
unformat_input_t _line_input, *line_input = &_line_input;
u8 *sock_filename = NULL;
@@ -1810,7 +1812,9 @@ dpdk_vhost_user_connect_command_fn (vlib_main_t * vm,
if (dm->conf->use_virtio_vhost)
{
+#endif
return vhost_user_connect_command_fn (vm, input, cmd);
+#if DPDK_VHOST_USER
}
/* Get a line of input. */
@@ -1851,6 +1855,7 @@ dpdk_vhost_user_connect_command_fn (vlib_main_t * vm,
vlib_cli_output (vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main (),
sw_if_index);
return 0;
+#endif
}
/* *INDENT-OFF* */
@@ -1899,7 +1904,11 @@ dpdk_vhost_user_delete_command_fn (vlib_main_t * vm,
vnet_main_t *vnm = vnet_get_main ();
+#if DPDK_VHOST_USER
dpdk_vhost_user_delete_if (vnm, vm, sw_if_index);
+#else
+ vhost_user_delete_if (vnm, vm, sw_if_index);
+#endif
return 0;
}
@@ -1922,6 +1931,7 @@ show_dpdk_vhost_user_command_fn (vlib_main_t * vm,
unformat_input_t * input,
vlib_cli_command_t * cmd)
{
+#if DPDK_VHOST_USER
clib_error_t *error = 0;
dpdk_main_t *dm = &dpdk_main;
vnet_main_t *vnm = vnet_get_main ();
@@ -1949,7 +1959,9 @@ show_dpdk_vhost_user_command_fn (vlib_main_t * vm,
if (dm->conf->use_virtio_vhost)
{
+#endif
return show_vhost_user_command_fn (vm, input, cmd);
+#if DPDK_VHOST_USER
}
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
@@ -2086,6 +2098,7 @@ show_dpdk_vhost_user_command_fn (vlib_main_t * vm,
done:
vec_free (hw_if_indices);
return error;
+#endif
}
/* *INDENT-OFF* */
@@ -2095,7 +2108,6 @@ VLIB_CLI_COMMAND (show_vhost_user_command, static) = {
.function = show_dpdk_vhost_user_command_fn,
};
/* *INDENT-ON* */
-#endif
/*
* fd.io coding-style-patch-verification: ON
diff --git a/vnet/vnet/devices/virtio/vhost-user.c b/vnet/vnet/devices/virtio/vhost-user.c
index 51b0c409d2a..6fa1c652c8f 100644
--- a/vnet/vnet/devices/virtio/vhost-user.c
+++ b/vnet/vnet/devices/virtio/vhost-user.c
@@ -293,7 +293,7 @@ vhost_user_log_dirty_pages (vhost_user_intf_t * vui, u64 addr, u64 len)
#define vhost_user_log_dirty_ring(vui, vq, member) \
if (PREDICT_FALSE(vq->log_used)) { \
- vhost_user_log_dirty_pages(vui, vq->log_guest_addr + offsetof(vring_used_t, member), \
+ vhost_user_log_dirty_pages(vui, vq->log_guest_addr + STRUCT_OFFSET_OF(vring_used_t, member), \
sizeof(vq->used->member)); \
}
@@ -1210,19 +1210,25 @@ vhost_user_input (vlib_main_t * vm,
vlib_node_runtime_t * node, vlib_frame_t * f)
{
vhost_user_main_t *vum = &vhost_user_main;
+#if DPDK > 0
dpdk_main_t *dm = &dpdk_main;
+ u32 cpu_index = os_get_cpu_number ();
+#endif
vhost_user_intf_t *vui;
uword n_rx_packets = 0;
- u32 cpu_index = os_get_cpu_number ();
int i;
for (i = 0; i < vec_len (vum->vhost_user_interfaces); i++)
{
vui = vec_elt_at_index (vum->vhost_user_interfaces, i);
- if (vui->is_up &&
- (i % dm->input_cpu_count) ==
- (cpu_index - dm->input_cpu_first_index))
- n_rx_packets += vhost_user_if_input (vm, vum, vui, node);
+ if (vui->is_up)
+ {
+#if DPDK > 0
+ if ((i % dm->input_cpu_count) ==
+ (cpu_index - dm->input_cpu_first_index))
+#endif
+ n_rx_packets += vhost_user_if_input (vm, vum, vui, node);
+ }
}
return n_rx_packets;
}
@@ -1813,9 +1819,11 @@ static void
vhost_user_vui_register (vlib_main_t * vm, vhost_user_intf_t * vui)
{
vhost_user_main_t *vum = &vhost_user_main;
+#if DPDK > 0
dpdk_main_t *dm = &dpdk_main;
int cpu_index;
vlib_thread_main_t *tm = vlib_get_thread_main ();
+#endif
hash_set (vum->vhost_user_interface_index_by_listener_fd, vui->unix_fd,
vui - vum->vhost_user_interfaces);
@@ -1823,15 +1831,19 @@ vhost_user_vui_register (vlib_main_t * vm, vhost_user_intf_t * vui)
vui - vum->vhost_user_interfaces);
/* start polling */
+#if DPDK > 0
cpu_index = dm->input_cpu_first_index +
(vui - vum->vhost_user_interfaces) % dm->input_cpu_count;
if (tm->n_vlib_mains == 1)
+#endif
vlib_node_set_state (vm, vhost_user_input_node.index,
VLIB_NODE_STATE_POLLING);
+#if DPDK > 0
else
vlib_node_set_state (vlib_mains[cpu_index], vhost_user_input_node.index,
VLIB_NODE_STATE_POLLING);
+#endif
/* tell process to start polling for sockets */
vlib_process_signal_event (vm, vhost_user_process_node.index, 0, 0);
@@ -2221,6 +2233,32 @@ done:
return error;
}
+/*
+ * CLI functions
+ */
+
+#if DPDK == 0
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (vhost_user_connect_command, static) = {
+ .path = "create vhost-user",
+ .short_help = "create vhost-user socket <socket-filename> [server] [feature-mask <hex>] [renumber <dev_instance>]",
+ .function = vhost_user_connect_command_fn,
+};
+
+VLIB_CLI_COMMAND (vhost_user_delete_command, static) = {
+ .path = "delete vhost-user",
+ .short_help = "delete vhost-user sw_if_index <nn>",
+ .function = vhost_user_delete_command_fn,
+};
+
+VLIB_CLI_COMMAND (show_vhost_user_command, static) = {
+ .path = "show vhost-user",
+ .short_help = "show vhost-user interface",
+ .function = show_vhost_user_command_fn,
+};
+/* *INDENT-ON* */
+#endif
+
static clib_error_t *
vhost_user_config (vlib_main_t * vm, unformat_input_t * input)
{
diff --git a/vnet/vnet/devices/virtio/vhost-user.h b/vnet/vnet/devices/virtio/vhost-user.h
index fc413609362..4934a8c0c1e 100644
--- a/vnet/vnet/devices/virtio/vhost-user.h
+++ b/vnet/vnet/devices/virtio/vhost-user.h
@@ -31,6 +31,10 @@
#define VHOST_VRING_F_LOG 0
#define VHOST_USER_F_PROTOCOL_FEATURES 30
+#if DPDK == 0
+#define RTE_VERSION_NUM(a,b,c,d) 1
+#define RTE_VERSION 0
+#endif
#if RTE_VERSION >= RTE_VERSION_NUM(16, 4, 0, 0)
#define VHOST_USER_PROTOCOL_FEATURES ((1ULL << VHOST_USER_PROTOCOL_F_MQ) | \
(1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD))