# 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
}
return 0;
}
+#endif
/*
* CLI functions
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;
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. */
vlib_cli_output (vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main (),
sw_if_index);
return 0;
+#endif
}
/* *INDENT-OFF* */
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;
}
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 ();
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)
done:
vec_free (hw_if_indices);
return error;
+#endif
}
/* *INDENT-OFF* */
.function = show_dpdk_vhost_user_command_fn,
};
/* *INDENT-ON* */
-#endif
/*
* fd.io coding-style-patch-verification: ON
#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)); \
}
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;
}
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);
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);
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)
{
#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))
#include <vnet/ipsec/ipsec.h>
#include <vnet/ipsec/ikev2.h>
#endif /* IPSEC */
-#if DPDK > 0
#include <vnet/devices/virtio/vhost-user.h>
-#endif
#include <stats/stats.h>
#include <oam/oam.h>
{
int rv = 0;
vl_api_create_vhost_user_if_reply_t *rmp;
-#if DPDK > 0
u32 sw_if_index = (u32) ~ 0;
vnet_main_t *vnm = vnet_get_main ();
vlib_main_t *vm = vlib_get_main ();
- rv = vhost_user_create_if (vnm, vm, (char *) mp->sock_filename,
- mp->is_server, &sw_if_index, (u64) ~ 0,
- mp->renumber, ntohl (mp->custom_dev_instance),
- (mp->use_custom_mac) ? mp->mac_address : NULL);
+#if DPDK > 0 && DPDK_VHOST_USER
+ rv = dpdk_vhost_user_create_if (
+#else
+ rv = vhost_user_create_if (
+#endif
+ vnm, vm, (char *) mp->sock_filename,
+ mp->is_server, &sw_if_index, (u64) ~ 0,
+ mp->renumber, ntohl (mp->custom_dev_instance),
+ (mp->use_custom_mac) ? mp->mac_address : NULL);
/* *INDENT-OFF* */
REPLY_MACRO2(VL_API_CREATE_VHOST_USER_IF_REPLY,
rmp->sw_if_index = ntohl (sw_if_index);
}));
/* *INDENT-ON* */
-#else
- rv = VNET_API_ERROR_UNIMPLEMENTED;
- REPLY_MACRO (VL_API_CREATE_VHOST_USER_IF_REPLY);
-#endif
}
static void
{
int rv = 0;
vl_api_modify_vhost_user_if_reply_t *rmp;
-#if DPDK > 0 && DPDK_VHOST_USER
u32 sw_if_index = ntohl (mp->sw_if_index);
vnet_main_t *vnm = vnet_get_main ();
vlib_main_t *vm = vlib_get_main ();
- rv = dpdk_vhost_user_modify_if (vnm, vm, (char *) mp->sock_filename,
- mp->is_server, sw_if_index, (u64) ~ 0,
- mp->renumber,
- ntohl (mp->custom_dev_instance));
+#if DPDK > 0 && DPDK_VHOST_USER
+ rv = dpdk_vhost_user_modify_if (
#else
- rv = VNET_API_ERROR_UNIMPLEMENTED;
+ rv = vhost_user_modify_if (
#endif
+ vnm, vm, (char *) mp->sock_filename,
+ mp->is_server, sw_if_index, (u64) ~ 0,
+ mp->renumber, ntohl (mp->custom_dev_instance));
REPLY_MACRO (VL_API_MODIFY_VHOST_USER_IF_REPLY);
}
{
int rv = 0;
vl_api_delete_vhost_user_if_reply_t *rmp;
-#if DPDK > 0 && DPDK_VHOST_USER
vpe_api_main_t *vam = &vpe_api_main;
u32 sw_if_index = ntohl (mp->sw_if_index);
vnet_main_t *vnm = vnet_get_main ();
vlib_main_t *vm = vlib_get_main ();
+#if DPDK > 0 && DPDK_VHOST_USER
rv = dpdk_vhost_user_delete_if (vnm, vm, sw_if_index);
+#else
+ rv = vhost_user_delete_if (vnm, vm, sw_if_index);
+#endif
REPLY_MACRO (VL_API_DELETE_VHOST_USER_IF_REPLY);
if (!rv)
send_sw_interface_flags_deleted (vam, q, sw_if_index);
}
-#else
- rv = VNET_API_ERROR_UNIMPLEMENTED;
- REPLY_MACRO (VL_API_DELETE_VHOST_USER_IF_REPLY);
-#endif
}
static void
clib_warning ("BUG");
}
-#if DPDK > 0 && DPDK_VHOST_USER
static void
send_sw_interface_vhost_user_details (vpe_api_main_t * am,
unix_shared_memory_queue_t * q,
vl_msg_api_send_shmem (q, (u8 *) & mp);
}
-#endif
static void
vl_api_sw_interface_vhost_user_dump_t_handler
(vl_api_sw_interface_vhost_user_dump_t * mp)
{
-#if DPDK > 0 && DPDK_VHOST_USER
int rv = 0;
vpe_api_main_t *am = &vpe_api_main;
vnet_main_t *vnm = vnet_get_main ();
if (q == 0)
return;
+#if DPDK > 0 && DPDK_VHOST_USER
rv = dpdk_vhost_user_dump_ifs (vnm, vm, &ifaces);
+#else
+ rv = vhost_user_dump_ifs (vnm, vm, &ifaces);
+#endif
if (rv)
return;
send_sw_interface_vhost_user_details (am, q, vuid, mp->context);
}
vec_free (ifaces);
-#endif
}
static void