From e3a395c8406a292becb719495052374449fcd152 Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 9 May 2017 16:19:50 -0700 Subject: 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 --- src/vnet/interface_cli.c | 72 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 18 deletions(-) (limited to 'src/vnet/interface_cli.c') diff --git a/src/vnet/interface_cli.c b/src/vnet/interface_cli.c index bfce03e1..e18a80fc 100644 --- a/src/vnet/interface_cli.c +++ b/src/vnet/interface_cli.c @@ -1175,6 +1175,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); } /*? -- cgit 1.2.3-korg