aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/interface.api20
-rw-r--r--src/vnet/interface_api.c29
-rw-r--r--src/vnet/interface_cli.c49
-rw-r--r--src/vnet/interface_funcs.h8
4 files changed, 88 insertions, 18 deletions
diff --git a/src/vnet/interface.api b/src/vnet/interface.api
index 2f2e8373357..a6fd5ad60d4 100644
--- a/src/vnet/interface.api
+++ b/src/vnet/interface.api
@@ -391,6 +391,26 @@ autoreply define sw_interface_set_mac_address
u8 mac_address[6];
};
+/** \brief Set an interface's rx-mode
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param sw_if_index - the interface whose rx-mode will be set
+ @param queue_id_valid - 1 = the queue_id field is valid. 0 means all
+ queue_id's
+ @param queue_id - the queue number whose rx-mode will be set. Only valid
+ if queue_id_valid is 1
+ @param mode - polling=1, interrupt=2, adaptive=3
+*/
+autoreply define sw_interface_set_rx_mode
+{
+ u32 client_index;
+ u32 context;
+ u32 sw_if_index;
+ u8 queue_id_valid;
+ u32 queue_id;
+ u8 mode;
+};
+
/*
* Local Variables:
* eval: (c-set-style "gnu")
diff --git a/src/vnet/interface_api.c b/src/vnet/interface_api.c
index c19f0a84297..a6414bc9ac6 100644
--- a/src/vnet/interface_api.c
+++ b/src/vnet/interface_api.c
@@ -54,6 +54,7 @@ _(SW_INTERFACE_SET_MTU, sw_interface_set_mtu) \
_(WANT_INTERFACE_EVENTS, want_interface_events) \
_(SW_INTERFACE_DUMP, sw_interface_dump) \
_(SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address) \
+_(SW_INTERFACE_SET_RX_MODE, sw_interface_set_rx_mode) \
_(SW_INTERFACE_SET_TABLE, sw_interface_set_table) \
_(SW_INTERFACE_GET_TABLE, sw_interface_get_table) \
_(SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered) \
@@ -907,6 +908,34 @@ out:
REPLY_MACRO (VL_API_SW_INTERFACE_SET_MAC_ADDRESS_REPLY);
}
+static void vl_api_sw_interface_set_rx_mode_t_handler
+ (vl_api_sw_interface_set_rx_mode_t * mp)
+{
+ vl_api_sw_interface_set_rx_mode_reply_t *rmp;
+ vnet_main_t *vnm = vnet_get_main ();
+ u32 sw_if_index = ntohl (mp->sw_if_index);
+ vnet_sw_interface_t *si;
+ clib_error_t *error;
+ int rv = 0;
+
+ VALIDATE_SW_IF_INDEX (mp);
+
+ si = vnet_get_sw_interface (vnm, sw_if_index);
+ error = set_hw_interface_change_rx_mode (vnm, si->hw_if_index,
+ mp->queue_id_valid,
+ ntohl (mp->queue_id), mp->mode);
+ if (error)
+ {
+ rv = VNET_API_ERROR_UNIMPLEMENTED;
+ clib_error_report (error);
+ goto out;
+ }
+
+ BAD_SW_IF_INDEX_LABEL;
+out:
+ REPLY_MACRO (VL_API_SW_INTERFACE_SET_RX_MODE_REPLY);
+}
+
/*
* vpe_api_hookup
* Add vpe's API message handlers to the table.
diff --git a/src/vnet/interface_cli.c b/src/vnet/interface_cli.c
index 15dc7f8d504..e5efb1faef7 100644
--- a/src/vnet/interface_cli.c
+++ b/src/vnet/interface_cli.c
@@ -1347,6 +1347,33 @@ set_hw_interface_rx_mode (vnet_main_t * vnm, u32 hw_if_index,
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,
+ vnet_hw_interface_rx_mode mode)
+{
+ clib_error_t *error = 0;
+ vnet_hw_interface_t *hw;
+ int i;
+
+ hw = vnet_get_hw_interface (vnm, hw_if_index);
+
+ 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);
+}
+
static clib_error_t *
set_interface_rx_mode (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_command_t * cmd)
@@ -1354,12 +1381,10 @@ set_interface_rx_mode (vlib_main_t * vm, unformat_input_t * input,
clib_error_t *error = 0;
unformat_input_t _line_input, *line_input = &_line_input;
vnet_main_t *vnm = vnet_get_main ();
- vnet_hw_interface_t *hw;
u32 hw_if_index = (u32) ~ 0;
u32 queue_id = (u32) ~ 0;
vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
- int i;
- u8 input_queue_id = 0;
+ u8 queue_id_valid = 0;
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
@@ -1370,7 +1395,7 @@ set_interface_rx_mode (vlib_main_t * vm, unformat_input_t * input,
(line_input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
;
else if (unformat (line_input, "queue %d", &queue_id))
- input_queue_id = 1;
+ queue_id_valid = 1;
else if (unformat (line_input, "polling"))
mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
else if (unformat (line_input, "interrupt"))
@@ -1394,20 +1419,8 @@ set_interface_rx_mode (vlib_main_t * vm, unformat_input_t * input,
if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
return clib_error_return (0, "please specify valid rx-mode");
- hw = vnet_get_hw_interface (vnm, hw_if_index);
-
- if (input_queue_id == 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);
+ error = set_hw_interface_change_rx_mode (vnm, hw_if_index, queue_id_valid,
+ queue_id, mode);
return (error);
}
diff --git a/src/vnet/interface_funcs.h b/src/vnet/interface_funcs.h
index 142bef57465..6f7ed111e46 100644
--- a/src/vnet/interface_funcs.h
+++ b/src/vnet/interface_funcs.h
@@ -276,6 +276,14 @@ clib_error_t *vnet_hw_interface_change_mac_address (vnet_main_t * vnm,
u32 hw_if_index,
u64 mac_address);
+/* Change rx-mode */
+clib_error_t *set_hw_interface_change_rx_mode (vnet_main_t * vnm,
+ u32 hw_if_index,
+ u8 queue_id_valid,
+ u32 queue_id,
+ vnet_hw_interface_rx_mode
+ mode);
+
/* Formats sw/hw interface. */
format_function_t format_vnet_hw_interface;
format_function_t format_vnet_hw_interface_rx_mode;