aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/devices/devices.c242
-rw-r--r--src/vnet/devices/devices.h73
-rw-r--r--src/vnet/interface.c2
-rw-r--r--src/vnet/interface.h5
-rw-r--r--src/vnet/interface_cli.c98
5 files changed, 1 insertions, 419 deletions
diff --git a/src/vnet/devices/devices.c b/src/vnet/devices/devices.c
index 82b46f7244a..5c28cadc03c 100644
--- a/src/vnet/devices/devices.c
+++ b/src/vnet/devices/devices.c
@@ -32,7 +32,7 @@ device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
VLIB_REGISTER_NODE (device_input_node) = {
.function = device_input_fn,
.name = "device-input",
- .runtime_data_bytes = sizeof (vnet_device_input_runtime_t),
+ .runtime_data_bytes = sizeof (vnet_hw_if_rx_node_runtime_t),
.type = VLIB_NODE_TYPE_INPUT,
.state = VLIB_NODE_STATE_DISABLED,
.n_next_nodes = VNET_DEVICE_INPUT_N_NEXT_NODES,
@@ -101,246 +101,6 @@ VNET_FEATURE_INIT (ethernet_input, static) = {
};
/* *INDENT-ON* */
-static int
-vnet_device_queue_sort (void *a1, void *a2)
-{
- vnet_device_and_queue_t *dq1 = a1;
- vnet_device_and_queue_t *dq2 = a2;
-
- if (dq1->dev_instance > dq2->dev_instance)
- return 1;
- else if (dq1->dev_instance < dq2->dev_instance)
- return -1;
- else if (dq1->queue_id > dq2->queue_id)
- return 1;
- else if (dq1->queue_id < dq2->queue_id)
- return -1;
- else
- return 0;
-}
-
-static void
-vnet_device_queue_update (vnet_main_t * vnm, vnet_device_input_runtime_t * rt)
-{
- vnet_device_and_queue_t *dq;
- vnet_hw_interface_t *hw;
-
- vec_sort_with_function (rt->devices_and_queues, vnet_device_queue_sort);
-
- vec_foreach (dq, rt->devices_and_queues)
- {
- hw = vnet_get_hw_interface (vnm, dq->hw_if_index);
- vec_validate (hw->dq_runtime_index_by_queue, dq->queue_id);
- hw->dq_runtime_index_by_queue[dq->queue_id] = dq - rt->devices_and_queues;
- }
-}
-
-void
-vnet_hw_interface_assign_rx_thread (vnet_main_t * vnm, u32 hw_if_index,
- u16 queue_id, uword thread_index)
-{
- vnet_device_main_t *vdm = &vnet_device_main;
- vlib_main_t *vm, *vm0;
- vnet_device_input_runtime_t *rt;
- vnet_device_and_queue_t *dq;
- vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
-
- ASSERT (hw->input_node_index > 0);
-
- if (vdm->first_worker_thread_index == 0)
- thread_index = 0;
-
- if (thread_index != 0 &&
- (thread_index < vdm->first_worker_thread_index ||
- thread_index > vdm->last_worker_thread_index))
- {
- thread_index = vdm->next_worker_thread_index++;
- if (vdm->next_worker_thread_index > vdm->last_worker_thread_index)
- vdm->next_worker_thread_index = vdm->first_worker_thread_index;
- }
-
- vm = vlib_mains[thread_index];
- vm0 = vlib_get_main ();
-
- vlib_worker_thread_barrier_sync (vm0);
-
- rt = vlib_node_get_runtime_data (vm, hw->input_node_index);
-
- vec_add2 (rt->devices_and_queues, dq, 1);
- dq->hw_if_index = hw_if_index;
- dq->dev_instance = hw->dev_instance;
- dq->queue_id = queue_id;
- dq->mode = VNET_HW_IF_RX_MODE_POLLING;
- rt->enabled_node_state = VLIB_NODE_STATE_POLLING;
-
- vnet_device_queue_update (vnm, rt);
- vec_validate (hw->input_node_thread_index_by_queue, queue_id);
- vec_validate (hw->rx_mode_by_queue, queue_id);
- hw->input_node_thread_index_by_queue[queue_id] = thread_index;
- hw->rx_mode_by_queue[queue_id] = VNET_HW_IF_RX_MODE_POLLING;
-
- vlib_worker_thread_barrier_release (vm0);
-
- vlib_node_set_state (vm, hw->input_node_index, rt->enabled_node_state);
-}
-
-int
-vnet_hw_interface_unassign_rx_thread (vnet_main_t * vnm, u32 hw_if_index,
- u16 queue_id)
-{
- vlib_main_t *vm, *vm0;
- vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
- vnet_device_input_runtime_t *rt;
- vnet_device_and_queue_t *dq;
- uword old_thread_index;
- vnet_hw_if_rx_mode mode;
-
- if (hw->input_node_thread_index_by_queue == 0)
- return VNET_API_ERROR_INVALID_INTERFACE;
-
- if (vec_len (hw->input_node_thread_index_by_queue) < queue_id + 1)
- return VNET_API_ERROR_INVALID_INTERFACE;
-
- old_thread_index = hw->input_node_thread_index_by_queue[queue_id];
-
- vm = vlib_mains[old_thread_index];
-
- rt = vlib_node_get_runtime_data (vm, hw->input_node_index);
-
- vec_foreach (dq, rt->devices_and_queues)
- if (dq->hw_if_index == hw_if_index && dq->queue_id == queue_id)
- {
- mode = dq->mode;
- goto delete;
- }
-
- return VNET_API_ERROR_INVALID_INTERFACE;
-
-delete:
-
- vm0 = vlib_get_main ();
- vlib_worker_thread_barrier_sync (vm0);
- vec_del1 (rt->devices_and_queues, dq - rt->devices_and_queues);
- vnet_device_queue_update (vnm, rt);
- hw->rx_mode_by_queue[queue_id] = VNET_HW_IF_RX_MODE_UNKNOWN;
- vlib_worker_thread_barrier_release (vm0);
-
- if (vec_len (rt->devices_and_queues) == 0)
- vlib_node_set_state (vm, hw->input_node_index, VLIB_NODE_STATE_DISABLED);
- else if (mode == VNET_HW_IF_RX_MODE_POLLING)
- {
- /*
- * if the deleted interface is polling, we may need to set the node state
- * to interrupt if there is no more polling interface for this device's
- * corresponding thread. This is because mixed interfaces
- * (polling and interrupt), assigned to the same thread, set the
- * thread to polling prior to the deletion.
- */
- vec_foreach (dq, rt->devices_and_queues)
- {
- if (dq->mode == VNET_HW_IF_RX_MODE_POLLING)
- return 0;
- }
- rt->enabled_node_state = VLIB_NODE_STATE_INTERRUPT;
- vlib_node_set_state (vm, hw->input_node_index, rt->enabled_node_state);
- }
-
- return 0;
-}
-
-
-int
-vnet_hw_interface_set_rx_mode (vnet_main_t * vnm, u32 hw_if_index,
- u16 queue_id, vnet_hw_if_rx_mode mode)
-{
- vlib_main_t *vm;
- uword thread_index;
- vnet_device_and_queue_t *dq;
- vlib_node_state_t enabled_node_state;
- ASSERT (mode < VNET_HW_IF_NUM_RX_MODES);
- vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
- vnet_device_input_runtime_t *rt;
- int is_polling = 0;
-
- if (mode == VNET_HW_IF_RX_MODE_DEFAULT)
- mode = hw->default_rx_mode;
-
- if (hw->input_node_thread_index_by_queue == 0 || hw->rx_mode_by_queue == 0)
- return VNET_API_ERROR_INVALID_INTERFACE;
-
- if (hw->rx_mode_by_queue[queue_id] == mode)
- return 0;
-
- if (mode != VNET_HW_IF_RX_MODE_POLLING &&
- (hw->flags & VNET_HW_INTERFACE_FLAG_SUPPORTS_INT_MODE) == 0)
- return VNET_API_ERROR_UNSUPPORTED;
-
- if ((vec_len (hw->input_node_thread_index_by_queue) < queue_id + 1) ||
- (vec_len (hw->rx_mode_by_queue) < queue_id + 1))
- return VNET_API_ERROR_INVALID_QUEUE;
-
- hw->rx_mode_by_queue[queue_id] = mode;
- thread_index = hw->input_node_thread_index_by_queue[queue_id];
- vm = vlib_mains[thread_index];
-
- rt = vlib_node_get_runtime_data (vm, hw->input_node_index);
-
- vec_foreach (dq, rt->devices_and_queues)
- {
- if (dq->hw_if_index == hw_if_index && dq->queue_id == queue_id)
- dq->mode = mode;
- if (dq->mode == VNET_HW_IF_RX_MODE_POLLING)
- is_polling = 1;
- }
-
- if (is_polling)
- enabled_node_state = VLIB_NODE_STATE_POLLING;
- else
- enabled_node_state = VLIB_NODE_STATE_INTERRUPT;
-
- if (rt->enabled_node_state != enabled_node_state)
- {
- rt->enabled_node_state = enabled_node_state;
- if (vlib_node_get_state (vm, hw->input_node_index) !=
- VLIB_NODE_STATE_DISABLED)
- vlib_node_set_state (vm, hw->input_node_index, enabled_node_state);
- }
-
- return 0;
-}
-
-int
-vnet_hw_interface_get_rx_mode (vnet_main_t * vnm, u32 hw_if_index,
- u16 queue_id, vnet_hw_if_rx_mode * mode)
-{
- vlib_main_t *vm;
- uword thread_index;
- vnet_device_and_queue_t *dq;
- vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
- vnet_device_input_runtime_t *rt;
-
- if (hw->input_node_thread_index_by_queue == 0)
- return VNET_API_ERROR_INVALID_INTERFACE;
-
- if ((vec_len (hw->input_node_thread_index_by_queue) < queue_id + 1) ||
- (vec_len (hw->rx_mode_by_queue) < queue_id + 1))
- return VNET_API_ERROR_INVALID_QUEUE;
-
- thread_index = hw->input_node_thread_index_by_queue[queue_id];
- vm = vlib_mains[thread_index];
-
- rt = vlib_node_get_runtime_data (vm, hw->input_node_index);
-
- vec_foreach (dq, rt->devices_and_queues)
- if (dq->hw_if_index == hw_if_index && dq->queue_id == queue_id)
- {
- *mode = dq->mode;
- return 0;
- }
-
- return VNET_API_ERROR_INVALID_INTERFACE;
-}
-
static clib_error_t *
vnet_device_init (vlib_main_t * vm)
{
diff --git a/src/vnet/devices/devices.h b/src/vnet/devices/devices.h
index 02eb5cf050d..a14c1966e44 100644
--- a/src/vnet/devices/devices.h
+++ b/src/vnet/devices/devices.h
@@ -55,44 +55,11 @@ typedef struct
uword next_worker_thread_index;
} vnet_device_main_t;
-typedef struct
-{
- u32 hw_if_index;
- u32 dev_instance;
- u16 queue_id;
- vnet_hw_if_rx_mode mode;
- u32 interrupt_pending;
-} vnet_device_and_queue_t;
-
-typedef struct
-{
- vnet_device_and_queue_t *devices_and_queues;
- vlib_node_state_t enabled_node_state;
- u32 pad;
-} vnet_device_input_runtime_t;
-
extern vnet_device_main_t vnet_device_main;
extern vlib_node_registration_t device_input_node;
extern const u32 device_input_next_node_advance[];
extern const u32 device_input_next_node_flags[];
-static inline void
-vnet_hw_interface_set_input_node (vnet_main_t * vnm, u32 hw_if_index,
- u32 node_index)
-{
- vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
- hw->input_node_index = node_index;
-}
-
-void vnet_hw_interface_assign_rx_thread (vnet_main_t * vnm, u32 hw_if_index,
- u16 queue_id, uword thread_index);
-int vnet_hw_interface_unassign_rx_thread (vnet_main_t * vnm, u32 hw_if_index,
- u16 queue_id);
-int vnet_hw_interface_set_rx_mode (vnet_main_t * vnm, u32 hw_if_index,
- u16 queue_id, vnet_hw_if_rx_mode mode);
-int vnet_hw_interface_get_rx_mode (vnet_main_t * vnm, u32 hw_if_index,
- u16 queue_id, vnet_hw_if_rx_mode * mode);
-
static inline u64
vnet_get_aggregate_rx_packets (void)
{
@@ -115,46 +82,6 @@ vnet_device_increment_rx_packets (u32 thread_index, u64 count)
pwd->aggregate_rx_packets += count;
}
-static_always_inline uword
-vnet_get_device_input_thread_index (vnet_main_t * vnm, u32 hw_if_index,
- u16 queue_id)
-{
- vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
- ASSERT (queue_id < vec_len (hw->input_node_thread_index_by_queue));
- return hw->input_node_thread_index_by_queue[queue_id];
-}
-
-static_always_inline void
-vnet_device_input_set_interrupt_pending (vnet_main_t * vnm, u32 hw_if_index,
- u16 queue_id)
-{
- vlib_main_t *vm;
- vnet_hw_interface_t *hw;
- vnet_device_input_runtime_t *rt;
- vnet_device_and_queue_t *dq;
- uword idx;
-
- hw = vnet_get_hw_interface (vnm, hw_if_index);
- idx = vnet_get_device_input_thread_index (vnm, hw_if_index, queue_id);
- vm = vlib_mains[idx];
- rt = vlib_node_get_runtime_data (vm, hw->input_node_index);
- idx = hw->dq_runtime_index_by_queue[queue_id];
- dq = vec_elt_at_index (rt->devices_and_queues, idx);
-
- clib_atomic_store_rel_n (&(dq->interrupt_pending), 1);
-
- vlib_node_set_interrupt_pending (vm, hw->input_node_index);
-}
-
-/*
- * Acquire RMW Access
- * Paired with Release Store in vnet_device_input_set_interrupt_pending
- */
-#define foreach_device_and_queue(var,vec) \
- for (var = (vec); var < vec_end (vec); var++) \
- if ((var->mode == VNET_HW_IF_RX_MODE_POLLING) \
- || clib_atomic_swap_acq_n (&((var)->interrupt_pending), 0))
-
#endif /* included_vnet_vnet_device_h */
/*
diff --git a/src/vnet/interface.c b/src/vnet/interface.c
index 5823cc4140e..e2e4e9166bf 100644
--- a/src/vnet/interface.c
+++ b/src/vnet/interface.c
@@ -47,7 +47,6 @@
/* *INDENT-OFF* */
VLIB_REGISTER_LOG_CLASS (if_default_log, static) = {
.class_name = "interface",
- .default_syslog_level = VLIB_LOG_LEVEL_DEBUG,
};
/* *INDENT-ON* */
@@ -1079,7 +1078,6 @@ vnet_delete_hw_interface (vnet_main_t * vnm, u32 hw_if_index)
vec_free (hw->name);
vec_free (hw->hw_address);
vec_free (hw->input_node_thread_index_by_queue);
- vec_free (hw->dq_runtime_index_by_queue);
vec_free (hw->rx_queue_indices);
pool_put (im->hw_interfaces, hw);
}
diff --git a/src/vnet/interface.h b/src/vnet/interface.h
index 1d97fd022c2..e9e7462efd7 100644
--- a/src/vnet/interface.h
+++ b/src/vnet/interface.h
@@ -626,13 +626,8 @@ typedef struct vnet_hw_interface_t
/* input node cpu index by queue */
u32 *input_node_thread_index_by_queue;
- /* vnet_hw_if_rx_mode by queue */
- u8 *rx_mode_by_queue;
vnet_hw_if_rx_mode default_rx_mode;
- /* device input device_and_queue runtime index */
- uword *dq_runtime_index_by_queue;
-
/* rx queues */
u32 *rx_queue_indices;
diff --git a/src/vnet/interface_cli.c b/src/vnet/interface_cli.c
index c79fddbc0b4..3cb32a225ab 100644
--- a/src/vnet/interface_cli.c
+++ b/src/vnet/interface_cli.c
@@ -1473,61 +1473,6 @@ VLIB_CLI_COMMAND (set_ip_directed_broadcast_command, static) = {
};
/* *INDENT-ON* */
-static clib_error_t *
-set_hw_interface_rx_mode (vnet_main_t * vnm, u32 hw_if_index,
- u32 queue_id, vnet_hw_if_rx_mode mode)
-{
- vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
- vnet_device_class_t *dev_class =
- vnet_get_device_class (vnm, hw->dev_class_index);
- clib_error_t *error;
- vnet_hw_if_rx_mode old_mode;
- int rv;
-
- if (mode == VNET_HW_IF_RX_MODE_DEFAULT)
- mode = hw->default_rx_mode;
-
- rv = vnet_hw_interface_get_rx_mode (vnm, hw_if_index, queue_id, &old_mode);
- switch (rv)
- {
- case 0:
- if (old_mode == mode)
- return 0; /* same rx-mode, no change */
- break;
- case VNET_API_ERROR_INVALID_INTERFACE:
- return clib_error_return (0, "invalid interface");
- case VNET_API_ERROR_INVALID_QUEUE:
- return clib_error_return (0, "invalid queue");
- default:
- return clib_error_return (0, "unknown error");
- }
-
- if (dev_class->rx_mode_change_function)
- {
- error = dev_class->rx_mode_change_function (vnm, hw_if_index, queue_id,
- mode);
- if (error)
- return (error);
- }
-
- rv = vnet_hw_interface_set_rx_mode (vnm, hw_if_index, queue_id, mode);
- switch (rv)
- {
- case 0:
- break;
- case VNET_API_ERROR_UNSUPPORTED:
- return clib_error_return (0, "unsupported");
- case VNET_API_ERROR_INVALID_INTERFACE:
- return clib_error_return (0, "invalid interface");
- case VNET_API_ERROR_INVALID_QUEUE:
- return clib_error_return (0, "invalid queue");
- default:
- return clib_error_return (0, "unknown error");
- }
-
- return 0;
-}
-
clib_error_t *
set_hw_interface_change_rx_mode (vnet_main_t * vnm, u32 hw_if_index,
u8 queue_id_valid, u32 queue_id,
@@ -1536,29 +1481,9 @@ set_hw_interface_change_rx_mode (vnet_main_t * vnm, u32 hw_if_index,
clib_error_t *error = 0;
vnet_hw_interface_t *hw;
u32 *queue_indices = 0;
- int i;
hw = vnet_get_hw_interface (vnm, hw_if_index);
- /* to be deprecated */
- if (vec_len (hw->rx_queue_indices) == 0)
- {
- if (queue_id_valid == 0)
- {
- for (i = 0; i < vec_len (hw->dq_runtime_index_by_queue); i++)
- {
- error = set_hw_interface_rx_mode (vnm, hw_if_index, i, mode);
- if (error)
- break;
- }
- hw->default_rx_mode = mode;
- }
- else
- error = set_hw_interface_rx_mode (vnm, hw_if_index, queue_id, mode);
-
- return (error);
- }
-
if (queue_id_valid)
{
u32 queue_index;
@@ -1757,7 +1682,6 @@ set_hw_interface_rx_placement (u32 hw_if_index, u32 queue_id,
vnet_device_main_t *vdm = &vnet_device_main;
vnet_hw_interface_t *hw;
u32 queue_index;
- int rv;
if (is_main)
thread_index = 0;
@@ -1770,28 +1694,6 @@ set_hw_interface_rx_placement (u32 hw_if_index, u32 queue_id,
hw = vnet_get_hw_interface (vnm, hw_if_index);
- /* to be deprecated */
- if (vec_len (hw->rx_queue_indices) == 0)
- {
- clib_error_t *error = 0;
- vnet_hw_if_rx_mode mode = VNET_HW_IF_RX_MODE_UNKNOWN;
- rv = vnet_hw_interface_get_rx_mode (vnm, hw_if_index, queue_id, &mode);
-
- if (rv)
- return clib_error_return (0, "not found");
-
- rv = vnet_hw_interface_unassign_rx_thread (vnm, hw_if_index, queue_id);
-
- if (rv)
- return clib_error_return (0, "not found");
-
- vnet_hw_interface_assign_rx_thread (vnm, hw_if_index, queue_id,
- thread_index);
- vnet_hw_interface_set_rx_mode (vnm, hw_if_index, queue_id, mode);
-
- return (error);
- }
-
queue_index =
vnet_hw_if_get_rx_queue_index_by_id (vnm, hw_if_index, queue_id);
if (queue_index == ~0)