aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/memif
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/memif')
-rw-r--r--src/plugins/memif/memif.c22
-rw-r--r--src/plugins/memif/node.c40
2 files changed, 40 insertions, 22 deletions
diff --git a/src/plugins/memif/memif.c b/src/plugins/memif/memif.c
index 98d31eb0453..41c882fd04b 100644
--- a/src/plugins/memif/memif.c
+++ b/src/plugins/memif/memif.c
@@ -406,7 +406,7 @@ static clib_error_t *
memif_int_fd_read_ready (unix_file_t * uf)
{
memif_main_t *mm = &memif_main;
- vlib_main_t *vm = vlib_get_main ();
+ vnet_main_t *vnm = vnet_get_main ();
memif_if_t *mif = vec_elt_at_index (mm->interfaces, uf->private_data);
u8 b;
ssize_t size;
@@ -420,7 +420,7 @@ memif_int_fd_read_ready (unix_file_t * uf)
mif->interrupt_line.index = ~0;
mif->interrupt_line.fd = -1;
}
- vlib_node_set_interrupt_pending (vm, memif_input_node.index);
+ vnet_device_input_set_interrupt_pending (vnm, mif->hw_if_index, 0);
return 0;
}
@@ -789,6 +789,7 @@ memif_create_if (vlib_main_t * vm, memif_create_if_args_t * args)
clib_error_t *error = 0;
int ret = 0;
uword *p;
+ vnet_hw_interface_t *hw;
p = mhash_get (&mm->if_index_by_key, &args->key);
if (p)
@@ -937,6 +938,17 @@ memif_create_if (vlib_main_t * vm, memif_create_if_args_t * args)
mif->flags |= MEMIF_IF_FLAG_IS_SLAVE;
}
+ hw = vnet_get_hw_interface (vnm, mif->hw_if_index);
+ hw->flags |= VNET_HW_INTERFACE_FLAG_SUPPORTS_INT_MODE;
+ vnet_hw_interface_set_input_node (vnm, mif->hw_if_index,
+ memif_input_node.index);
+ vnet_hw_interface_assign_rx_thread (vnm, mif->hw_if_index, 0, ~0);
+ ret = vnet_hw_interface_set_rx_mode (vnm, mif->hw_if_index, 0,
+ VNET_HW_INTERFACE_RX_MODE_INTERRUPT);
+ if (ret)
+ clib_warning ("Warning: unable to set rx mode for interface %d: "
+ "rc=%d", mif->hw_if_index, ret);
+
#if 0
/* use configured or generate random MAC address */
if (!args->hw_addr_set &&
@@ -969,6 +981,7 @@ memif_delete_if (vlib_main_t * vm, u64 key)
memif_main_t *mm = &memif_main;
memif_if_t *mif;
uword *p;
+ int ret;
p = mhash_get (&mm->if_index_by_key, &key);
if (p == NULL)
@@ -980,6 +993,11 @@ memif_delete_if (vlib_main_t * vm, u64 key)
mif = pool_elt_at_index (mm->interfaces, p[0]);
mif->flags |= MEMIF_IF_FLAG_DELETING;
+ ret = vnet_hw_interface_unassign_rx_thread (vnm, mif->hw_if_index, 0);
+ if (ret)
+ clib_warning ("Warning: unable to unassign interface %d: rc=%d",
+ mif->hw_if_index, ret);
+
/* bring down the interface */
vnet_hw_interface_set_flags (vnm, mif->hw_if_index, 0);
vnet_sw_interface_set_flags (vnm, mif->sw_if_index, 0);
diff --git a/src/plugins/memif/node.c b/src/plugins/memif/node.c
index cee1f3d1b7b..2690dc4e0ec 100644
--- a/src/plugins/memif/node.c
+++ b/src/plugins/memif/node.c
@@ -331,26 +331,26 @@ memif_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
u32 thread_index = vlib_get_thread_index ();
memif_main_t *nm = &memif_main;
memif_if_t *mif;
-
- /* *INDENT-OFF* */
- pool_foreach (mif, nm->interfaces,
- ({
- if (mif->flags & MEMIF_IF_FLAG_ADMIN_UP &&
- mif->flags & MEMIF_IF_FLAG_CONNECTED &&
- (mif->if_index % nm->input_cpu_count) ==
- (thread_index - nm->input_cpu_first_index))
- {
- if (mif->flags & MEMIF_IF_FLAG_IS_SLAVE)
- n_rx_packets +=
- memif_device_input_inline (vm, node, frame, mif,
- MEMIF_RING_M2S);
- else
- n_rx_packets +=
- memif_device_input_inline (vm, node, frame, mif,
- MEMIF_RING_S2M);
- }
- }));
- /* *INDENT-ON* */
+ vnet_device_input_runtime_t *rt = (void *) node->runtime_data;
+ vnet_device_and_queue_t *dq;
+ memif_ring_type_t type;
+
+ foreach_device_and_queue (dq, rt->devices_and_queues)
+ {
+ mif = vec_elt_at_index (nm->interfaces, dq->dev_instance);
+ if (mif->flags & MEMIF_IF_FLAG_ADMIN_UP &&
+ mif->flags & MEMIF_IF_FLAG_CONNECTED &&
+ (mif->if_index % nm->input_cpu_count) ==
+ (thread_index - nm->input_cpu_first_index))
+ {
+ if (mif->flags & MEMIF_IF_FLAG_IS_SLAVE)
+ type = MEMIF_RING_M2S;
+ else
+ type = MEMIF_RING_S2M;
+ n_rx_packets +=
+ memif_device_input_inline (vm, node, frame, mif, type);
+ }
+ }
return n_rx_packets;
}