aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/devices/af_packet/af_packet.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2017-03-20 16:34:15 +0100
committerDamjan Marion <damarion@cisco.com>2017-03-20 16:34:15 +0100
commiteb743fad56b32cb20ad2d2cadc4760f9c25be5e1 (patch)
tree4e5b6cd7b7635ee7269ab33300188de7fd42595d /src/vnet/devices/af_packet/af_packet.c
parent95475a3661b95150c8d1e60a3942b91c2b5d06bc (diff)
vnet: add device-input threadplacement infra
This change adds two new debug CLI command: - "show interface placmenet" to display which thread (main or worker) is responsible for processing interface rx queue vpp# show interface placement Thread 0 (vpp_main): node af-packet-input: host-vpp1 queue 0 Thread 1 (vpp_wk_0): node af-packet-input: host-virbr0 queue 0 Thread 2 (vpp_wk_1): node af-packet-input: host-vpp2 queue 0 host-lxcbr0 queue 0 - "set interface placmenet" to assign thread (main or worker) which process specific interface rx queue vpp# set interface placement host-vpp1 queue 0 main Change-Id: Id4dd00cf2b05e10fae2125ac7cb4411b446c5e9c Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet/devices/af_packet/af_packet.c')
-rw-r--r--src/vnet/devices/af_packet/af_packet.c54
1 files changed, 6 insertions, 48 deletions
diff --git a/src/vnet/devices/af_packet/af_packet.c b/src/vnet/devices/af_packet/af_packet.c
index e491ba473d5..5fdc59f2a20 100644
--- a/src/vnet/devices/af_packet/af_packet.c
+++ b/src/vnet/devices/af_packet/af_packet.c
@@ -67,15 +67,16 @@ af_packet_eth_flag_change (vnet_main_t * vnm, vnet_hw_interface_t * hi,
static clib_error_t *
af_packet_fd_read_ready (unix_file_t * uf)
{
- vlib_main_t *vm = vlib_get_main ();
af_packet_main_t *apm = &af_packet_main;
+ vnet_main_t *vnm = vnet_get_main ();
u32 idx = uf->private_data;
+ af_packet_if_t *apif = pool_elt_at_index (apm->interfaces, idx);
apm->pending_input_bitmap =
clib_bitmap_set (apm->pending_input_bitmap, idx, 1);
/* Schedule the rx node */
- vlib_node_set_interrupt_pending (vm, af_packet_input_node.index);
+ vnet_device_input_set_interrupt_pending (vnm, apif->hw_if_index, 0);
return 0;
}
@@ -171,31 +172,6 @@ error:
return ret;
}
-static void
-af_packet_worker_thread_enable ()
-{
- /* If worker threads are enabled, switch to polling mode */
- foreach_vlib_main ((
- {
- vlib_node_set_state (this_vlib_main,
- af_packet_input_node.index,
- VLIB_NODE_STATE_POLLING);
- }));
-
-}
-
-static void
-af_packet_worker_thread_disable ()
-{
- foreach_vlib_main ((
- {
- vlib_node_set_state (this_vlib_main,
- af_packet_input_node.index,
- VLIB_NODE_STATE_INTERRUPT);
- }));
-
-}
-
int
af_packet_create_if (vlib_main_t * vm, u8 * host_if_name, u8 * hw_addr_set,
u32 * sw_if_index)
@@ -298,6 +274,9 @@ af_packet_create_if (vlib_main_t * vm, u8 * host_if_name, u8 * hw_addr_set,
sw = vnet_get_hw_sw_interface (vnm, apif->hw_if_index);
apif->sw_if_index = sw->sw_if_index;
+ vnet_set_device_input_node (apif->hw_if_index, af_packet_input_node.index);
+ vnet_device_input_assign_thread (apif->hw_if_index, 0, /* queue */
+ ~0 /* any cpu */ );
vnet_hw_interface_set_flags (vnm, apif->hw_if_index,
VNET_HW_INTERFACE_FLAG_LINK_UP);
@@ -307,9 +286,6 @@ af_packet_create_if (vlib_main_t * vm, u8 * host_if_name, u8 * hw_addr_set,
if (sw_if_index)
*sw_if_index = apif->sw_if_index;
- if (tm->n_vlib_mains > 1 && pool_elts (apm->interfaces) == 1)
- af_packet_worker_thread_enable ();
-
return 0;
error:
@@ -323,7 +299,6 @@ int
af_packet_delete_if (vlib_main_t * vm, u8 * host_if_name)
{
vnet_main_t *vnm = vnet_get_main ();
- vlib_thread_main_t *tm = vlib_get_thread_main ();
af_packet_main_t *apm = &af_packet_main;
af_packet_if_t *apif;
uword *p;
@@ -373,8 +348,6 @@ af_packet_delete_if (vlib_main_t * vm, u8 * host_if_name)
ethernet_delete_interface (vnm, apif->hw_if_index);
pool_put (apm->interfaces, apif);
- if (tm->n_vlib_mains > 1 && pool_elts (apm->interfaces) == 0)
- af_packet_worker_thread_disable ();
return 0;
}
@@ -384,24 +357,9 @@ af_packet_init (vlib_main_t * vm)
{
af_packet_main_t *apm = &af_packet_main;
vlib_thread_main_t *tm = vlib_get_thread_main ();
- vlib_thread_registration_t *tr;
- uword *p;
memset (apm, 0, sizeof (af_packet_main_t));
- apm->input_cpu_first_index = 0;
- apm->input_cpu_count = 1;
-
- /* find out which cpus will be used for input */
- p = hash_get_mem (tm->thread_registrations_by_name, "workers");
- tr = p ? (vlib_thread_registration_t *) p[0] : 0;
-
- if (tr && tr->count > 0)
- {
- apm->input_cpu_first_index = tr->first_index;
- apm->input_cpu_count = tr->count;
- }
-
mhash_init_vec_string (&apm->if_index_by_host_if_name, sizeof (uword));
vec_validate_aligned (apm->rx_buffers, tm->n_vlib_mains - 1,