summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorChenmin Sun <chenmin.sun@intel.com>2020-07-06 08:20:39 +0800
committerDamjan Marion <dmarion@me.com>2020-09-09 10:12:06 +0000
commitc4665093cdb0a8122d9640b6f5b3acd627918f32 (patch)
tree08a3babefc4f126dec07740628d094fd24413e36 /src/vnet
parent765008670bec75cab679c4f549c5dac744842887 (diff)
interface: support configuring RSS steering queues
This patch adds the RSS steering queues set interface, and it's implementation in DPDK device: /* Interface to set rss queues of the interface */ typedef clib_error_t *(vnet_interface_rss_queues_set_t) (struct vnet_main_t * vnm, struct vnet_hw_interface_t * hi, clib_bitmap_t *bitmap); This patch also introduces a command line to set the RSS queues: set interface rss queues <interface> <list <queue-list>> To display the rss queues, use "show hardware-interfaces" Below is the example to configure rss queues for interface Gig0: vpp# set interface rss queues Gig0 list 0,2,4-7 vpp# show hardware-interfaces brief Name Idx Link Hardware VirtualFunctionEthernet18/1/0 1 down VirtualFunctionEthernet18/1/0 Link speed: unknown RSS queues: 0 2 4 5 6 7 local0 0 down local0 Link speed: unknown vpp# Users can also configure the rss queues on a dpdk interface in startup.conf: dpdk { dev 0000:18:01.0 { rss-queues 0,2,5-7 } } Type: feature Signed-off-by: Chenmin Sun <chenmin.sun@intel.com> Change-Id: I1835595a1c54016a84eabee9fd62ce137935385d
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/devices/devices.c2
-rw-r--r--src/vnet/interface.c36
-rw-r--r--src/vnet/interface.h12
-rw-r--r--src/vnet/interface_cli.c83
-rw-r--r--src/vnet/interface_format.c26
-rw-r--r--src/vnet/interface_funcs.h5
6 files changed, 162 insertions, 2 deletions
diff --git a/src/vnet/devices/devices.c b/src/vnet/devices/devices.c
index e78c5cbe45b..cfce2ac2856 100644
--- a/src/vnet/devices/devices.c
+++ b/src/vnet/devices/devices.c
@@ -341,8 +341,6 @@ vnet_hw_interface_get_rx_mode (vnet_main_t * vnm, u32 hw_if_index,
return VNET_API_ERROR_INVALID_INTERFACE;
}
-
-
static clib_error_t *
vnet_device_init (vlib_main_t * vm)
{
diff --git a/src/vnet/interface.c b/src/vnet/interface.c
index 6d5b3561f19..18c7696e9a4 100644
--- a/src/vnet/interface.c
+++ b/src/vnet/interface.c
@@ -1692,6 +1692,42 @@ default_update_adjacency (vnet_main_t * vnm, u32 sw_if_index, u32 ai)
}
}
+clib_error_t *
+vnet_hw_interface_set_rss_queues (vnet_main_t * vnm,
+ vnet_hw_interface_t * hi,
+ clib_bitmap_t * bitmap)
+{
+ clib_error_t *error = 0;
+ vnet_device_class_t *dev_class =
+ vnet_get_device_class (vnm, hi->dev_class_index);
+
+ if (dev_class->set_rss_queues_function)
+ {
+ if (clib_bitmap_count_set_bits (bitmap) == 0)
+ {
+ error = clib_error_return (0,
+ "must assign at least one valid rss queue");
+ goto done;
+ }
+
+ error = dev_class->set_rss_queues_function (vnm, hi, bitmap);
+ }
+ else
+ {
+ error = clib_error_return (0,
+ "setting rss queues is not supported on this interface");
+ }
+
+ if (!error)
+ {
+ clib_bitmap_free (hi->rss_queues);
+ hi->rss_queues = clib_bitmap_dup (bitmap);
+ }
+
+done:
+ return error;
+}
+
int collect_detailed_interface_stats_flag = 0;
void
diff --git a/src/vnet/interface.h b/src/vnet/interface.h
index 07da2617d71..895ce2e9279 100644
--- a/src/vnet/interface.h
+++ b/src/vnet/interface.h
@@ -88,6 +88,11 @@ typedef clib_error_t *(vnet_interface_set_l2_mode_function_t)
(struct vnet_main_t * vnm, struct vnet_hw_interface_t * hi,
i32 l2_if_adjust);
+/* Interface to set rss queues of the interface */
+typedef clib_error_t *(vnet_interface_rss_queues_set_t)
+ (struct vnet_main_t * vnm, struct vnet_hw_interface_t * hi,
+ clib_bitmap_t * bitmap);
+
typedef enum
{
VNET_FLOW_DEV_OP_ADD_FLOW,
@@ -273,6 +278,10 @@ typedef struct _vnet_device_class
/* Function to add/delete additional MAC addresses */
vnet_interface_add_del_mac_address_function_t *mac_addr_add_del_function;
+
+ /* Interface to set rss queues of the interface */
+ vnet_interface_rss_queues_set_t *set_rss_queues_function;
+
} vnet_device_class_t;
#ifndef CLIB_MARCH_VARIANT
@@ -601,6 +610,9 @@ typedef struct vnet_hw_interface_t
/* numa node that hardware device connects to */
u8 numa_node;
+ /* rss queues bitmap */
+ clib_bitmap_t *rss_queues;
+
/* trace */
i32 n_trace;
diff --git a/src/vnet/interface_cli.c b/src/vnet/interface_cli.c
index bee813f5874..28f24ae3977 100644
--- a/src/vnet/interface_cli.c
+++ b/src/vnet/interface_cli.c
@@ -1886,6 +1886,89 @@ VLIB_CLI_COMMAND (cmd_set_if_rx_placement,static) = {
};
/* *INDENT-ON* */
+clib_error_t *
+set_interface_rss_queues (vlib_main_t * vm, u32 hw_if_index,
+ clib_bitmap_t * bitmap)
+{
+ vnet_main_t *vnm = vnet_get_main ();
+ vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
+
+ return vnet_hw_interface_set_rss_queues (vnm, hi, bitmap);
+}
+
+static clib_error_t *
+set_interface_rss_queues_fn (vlib_main_t * vm,
+ unformat_input_t * input,
+ vlib_cli_command_t * cmd)
+{
+ clib_error_t *error = 0;
+ unformat_input_t _line_input, *line_input = &_line_input;
+ vnet_main_t *vnm = vnet_get_main ();
+ u32 hw_if_index = (u32) ~ 0;
+ clib_bitmap_t *bitmap = NULL;
+
+ if (!unformat_user (input, unformat_line_input, line_input))
+ return 0;
+
+ while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat
+ (line_input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
+ ;
+ else
+ if (unformat (line_input, "list %U", unformat_bitmap_list, &bitmap))
+ ;
+ else
+ {
+ error = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ unformat_free (line_input);
+ goto done;
+ }
+ }
+
+ unformat_free (line_input);
+
+ if (hw_if_index == (u32) ~ 0)
+ {
+ error = clib_error_return (0, "please specify valid interface name");
+ goto done;
+ }
+
+ if (bitmap == NULL)
+ {
+ error = clib_error_return (0, "please specify the valid rss queues");
+ goto done;
+ }
+
+ error = set_interface_rss_queues (vm, hw_if_index, bitmap);
+
+done:
+ if (bitmap)
+ clib_bitmap_free (bitmap);
+
+ return (error);
+}
+
+/*?
+ * This command is used to set the rss queues of a given interface
+ * Not all the interfaces support this operation.
+ * To display the current rss queues, use the command
+ * '<em>show hardware-interfaces</em>'.
+ *
+ * @cliexpar
+ * Example of how to set the rss queues to 0,2-5,7 of an interface:
+ * @cliexstart{set interface rss queues VirtualFunctionEthernet18/1/0 list 0,2-5,7}
+ * @cliexend
+?*/
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (cmd_set_interface_rss_queues,static) = {
+ .path = "set interface rss queues",
+ .short_help = "set interface rss queues <interface> <list <queue-list>>",
+ .function = set_interface_rss_queues_fn,
+};
+/* *INDENT-ON* */
+
static u8 *
format_vnet_pcap (u8 * s, va_list * args)
{
diff --git a/src/vnet/interface_format.c b/src/vnet/interface_format.c
index 8278102c644..2b691a66071 100644
--- a/src/vnet/interface_format.c
+++ b/src/vnet/interface_format.c
@@ -130,6 +130,26 @@ format_vnet_hw_interface_link_speed (u8 * s, va_list * args)
return format (s, "%u Kbps", link_speed);
}
+u8 *
+format_vnet_hw_interface_rss_queues (u8 * s, va_list * args)
+{
+ clib_bitmap_t *bitmap = va_arg (*args, clib_bitmap_t *);
+ int i;
+
+ if (bitmap == NULL)
+ return s;
+
+ if (bitmap)
+ {
+ /* *INDENT-OFF* */
+ clib_bitmap_foreach (i, bitmap, ({
+ s = format (s, "%u ", i);
+ }));
+ /* *INDENT-ON* */
+ }
+
+ return s;
+}
u8 *
format_vnet_hw_interface (u8 * s, va_list * args)
@@ -172,6 +192,12 @@ format_vnet_hw_interface (u8 * s, va_list * args)
s = format (s, "\n%ULink speed: %U", format_white_space, indent + 2,
format_vnet_hw_interface_link_speed, hi->link_speed);
+ if (hi->rss_queues)
+ {
+ s = format (s, "\n%URSS queues: %U", format_white_space, indent + 2,
+ format_vnet_hw_interface_rss_queues, hi->rss_queues);
+ }
+
if (verbose)
{
if (hw_class->format_device)
diff --git a/src/vnet/interface_funcs.h b/src/vnet/interface_funcs.h
index 7d9c098b118..8f589d1d6dd 100644
--- a/src/vnet/interface_funcs.h
+++ b/src/vnet/interface_funcs.h
@@ -431,6 +431,11 @@ int vnet_sw_interface_stats_collect_enable_disable (u32 sw_if_index,
void vnet_sw_interface_ip_directed_broadcast (vnet_main_t * vnm,
u32 sw_if_index, u8 enable);
+/* set interface rss queues */
+clib_error_t *vnet_hw_interface_set_rss_queues (vnet_main_t * vnm,
+ vnet_hw_interface_t * hi,
+ clib_bitmap_t * bitmap);
+
/* Formats sw/hw interface. */
format_function_t format_vnet_hw_interface;
format_function_t format_vnet_hw_interface_rx_mode;