diff options
author | Steven <sluong@cisco.com> | 2017-05-09 16:19:50 -0700 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2017-05-10 15:49:27 +0000 |
commit | e3a395c8406a292becb719495052374449fcd152 (patch) | |
tree | 5ac8bc25792ffb9b2db7433f33f4a5751d4edd1e /src/vnet/interface_cli.c | |
parent | cfe0fc95f2df763b97b278735153c85455655f67 (diff) |
device: Add callback for set interface rx-mode
- When the interface rx-mode is changed via CLI, the corresponding device
may want to know about it and to reset the driver. This patch is to add
the callback.
- In the function vnet_hw_interface_set_rx_mode, it appears it is missing
a line
hw->rx_mode_by_queue[queue_id] = mode
because the function is checking if the new mode is the same as
hw->rx_mode_by_queue which is initialized to POLLING. So if the function is
called to change the mode to interrupt, it just returns without doing
anything. This is the check that I am talking about in the same function.
if (hw->rx_mode_by_queue[queue_id] == mode)
return 0;
Change-Id: Iaca2651c43e0ae3fda6fd8dc128e247b0851cc65
Signed-off-by: Steven <sluong@cisco.com>
Diffstat (limited to 'src/vnet/interface_cli.c')
-rw-r--r-- | src/vnet/interface_cli.c | 72 |
1 files changed, 54 insertions, 18 deletions
diff --git a/src/vnet/interface_cli.c b/src/vnet/interface_cli.c index bfce03e155d..e18a80fc744 100644 --- a/src/vnet/interface_cli.c +++ b/src/vnet/interface_cli.c @@ -1176,6 +1176,54 @@ VLIB_CLI_COMMAND (clear_tag_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_interface_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_interface_rx_mode old_mode; + int rv; + + 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"); + 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"); + default: + return clib_error_return (0, "unknown error"); + } + + return 0; +} + +static clib_error_t * set_interface_rx_mode (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { @@ -1186,7 +1234,7 @@ set_interface_rx_mode (vlib_main_t * vm, unformat_input_t * input, 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, rv = 0; + int i; if (!unformat_user (input, unformat_line_input, line_input)) return 0; @@ -1226,26 +1274,14 @@ set_interface_rx_mode (vlib_main_t * vm, unformat_input_t * input, if (queue_id == ~0) for (i = 0; i < vec_len (hw->dq_runtime_index_by_queue); i++) { - rv = vnet_hw_interface_set_rx_mode (vnm, hw_if_index, i, mode); - if (rv) - goto error; + error = set_hw_interface_rx_mode (vnm, hw_if_index, i, mode); + if (error) + break; } else - rv = vnet_hw_interface_set_rx_mode (vnm, hw_if_index, queue_id, mode); - - if (rv) - goto error; - - return 0; - -error: - if (rv == VNET_API_ERROR_UNSUPPORTED) - return clib_error_return (0, "unsupported"); - - if (rv == VNET_API_ERROR_INVALID_INTERFACE) - return clib_error_return (0, "invalid interfaace"); + error = set_hw_interface_rx_mode (vnm, hw_if_index, queue_id, mode); - return clib_error_return (0, "unknown error"); + return (error); } /*? |