summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2016-09-20 23:21:02 +0200
committerDave Barach <openvpp@barachs.net>2016-09-22 12:03:19 +0000
commit0dafaa78dffa7cbd82559a94b0c9a8f8144f6f72 (patch)
treee0206d29bb8acef0f4c83be33d4d073090e95e64
parent90f52bf990791ea73479ffc50fc1eb3450de443a (diff)
vhost-user: remove dependency on dpdk code
Change-Id: I48908e0fa010570aefc43dd552ee81ee69fc2796 Signed-off-by: Damjan Marion <damarion@cisco.com>
-rw-r--r--vnet/vnet/devices/virtio/vhost-user.c34
-rw-r--r--vnet/vnet/devices/virtio/vhost-user.h6
2 files changed, 24 insertions, 16 deletions
diff --git a/vnet/vnet/devices/virtio/vhost-user.c b/vnet/vnet/devices/virtio/vhost-user.c
index 2ca5aa89ace..046a02e35c6 100644
--- a/vnet/vnet/devices/virtio/vhost-user.c
+++ b/vnet/vnet/devices/virtio/vhost-user.c
@@ -804,6 +804,8 @@ vhost_user_init (vlib_main_t * vm)
clib_error_t *error;
vhost_user_main_t *vum = &vhost_user_main;
vlib_thread_main_t *tm = vlib_get_thread_main ();
+ vlib_thread_registration_t *tr;
+ uword *p;
error = vlib_call_init_function (vm, ip4_init);
if (error)
@@ -821,6 +823,18 @@ vhost_user_init (vlib_main_t * vm)
vec_validate_aligned (vum->rx_buffers, tm->n_vlib_mains - 1,
CLIB_CACHE_LINE_BYTES);
+ /* find out which cpus will be used for input */
+ vum->input_cpu_first_index = 0;
+ vum->input_cpu_count = 1;
+ p = hash_get_mem (tm->thread_registrations_by_name, "workers");
+ tr = p ? (vlib_thread_registration_t *) p[0] : 0;
+
+ if (tr && tr->count > 0)
+ {
+ vum->input_cpu_first_index = tr->first_index;
+ vum->input_cpu_count = tr->count;
+ }
+
return 0;
}
@@ -1256,10 +1270,7 @@ 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;
int i;
@@ -1269,10 +1280,8 @@ vhost_user_input (vlib_main_t * vm,
vui = vec_elt_at_index (vum->vhost_user_interfaces, i);
if (vui->is_up)
{
-#if DPDK > 0
- if ((i % dm->input_cpu_count) ==
- (cpu_index - dm->input_cpu_first_index))
-#endif
+ if ((i % vum->input_cpu_count) ==
+ (cpu_index - vum->input_cpu_first_index))
n_rx_packets += vhost_user_if_input (vm, vum, vui, node);
}
}
@@ -1907,11 +1916,8 @@ 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);
@@ -1919,19 +1925,15 @@ 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;
+ cpu_index = vum->input_cpu_first_index +
+ (vui - vum->vhost_user_interfaces) % vum->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);
diff --git a/vnet/vnet/devices/virtio/vhost-user.h b/vnet/vnet/devices/virtio/vhost-user.h
index 0108ffa9ba3..91369c33e65 100644
--- a/vnet/vnet/devices/virtio/vhost-user.h
+++ b/vnet/vnet/devices/virtio/vhost-user.h
@@ -255,6 +255,12 @@ typedef struct
u32 coalesce_frames;
f64 coalesce_time;
int dont_dump_vhost_user_memory;
+
+ /* first cpu index */
+ u32 input_cpu_first_index;
+
+ /* total cpu count */
+ u32 input_cpu_count;
} vhost_user_main_t;
typedef struct