aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorVladislav Grishenko <themiron@yandex-team.ru>2023-10-07 23:04:03 +0500
committerMatthew Smith <mgsmith@netgate.com>2024-04-01 20:20:08 +0000
commit704d5a53e06d105c86822ea0cc20bb9c19f5b8d3 (patch)
tree0c81ea44788511e6a670bb5fd3dacff8a76865a7 /src/plugins
parentd465fd0819853079c78ad3b6b1a86e2e05c3c142 (diff)
linux-cp: add support for tap num queues config
This change allows to limit lcp interface queues to be used by explicit host interface workers. Type: improvement Signed-off-by: Vladislav Grishenko <themiron@yandex-team.ru> Change-Id: I0626f66021e5a5f251470156231dc44ddaea5ee6
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/linux-cp/lcp.c22
-rw-r--r--src/plugins/linux-cp/lcp.h8
-rw-r--r--src/plugins/linux-cp/lcp_interface.c11
3 files changed, 39 insertions, 2 deletions
diff --git a/src/plugins/linux-cp/lcp.c b/src/plugins/linux-cp/lcp.c
index 561ebb152ae..34e8550a13f 100644
--- a/src/plugins/linux-cp/lcp.c
+++ b/src/plugins/linux-cp/lcp.c
@@ -161,6 +161,28 @@ lcp_get_netlink_processing_active (void)
return lcpm->netlink_processing_active;
}
+void
+lcp_set_default_num_queues (u16 num_queues, u8 is_tx)
+{
+ lcp_main_t *lcpm = &lcp_main;
+
+ if (is_tx)
+ lcpm->num_tx_queues = num_queues;
+ else
+ lcpm->num_rx_queues = num_queues;
+}
+
+u16
+lcp_get_default_num_queues (u8 is_tx)
+{
+ lcp_main_t *lcpm = &lcp_main;
+
+ if (is_tx)
+ return lcpm->num_tx_queues;
+
+ return lcpm->num_rx_queues ?: vlib_num_workers ();
+}
+
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/plugins/linux-cp/lcp.h b/src/plugins/linux-cp/lcp.h
index 3b6b4ec00d4..e89b149f67d 100644
--- a/src/plugins/linux-cp/lcp.h
+++ b/src/plugins/linux-cp/lcp.h
@@ -28,6 +28,8 @@ typedef struct lcp_main_s
u8 lcp_sync; /* Automatically sync VPP changes to LCP */
u8 del_static_on_link_down; /* Delete static routes when link goes down */
u8 del_dynamic_on_link_down; /* Delete dynamic routes when link goes down */
+ u16 num_rx_queues;
+ u16 num_tx_queues;
u8 test_mode; /* Set when Unit testing */
u8 netlink_processing_active; /* Set while a batch of Netlink messages are
being processed */
@@ -61,6 +63,12 @@ u8 lcp_get_del_dynamic_on_link_down (void);
void lcp_set_netlink_processing_active (u8 is_processing);
u8 lcp_get_netlink_processing_active (void);
+/**
+ * Get/Set the default queue number for LCP host taps.
+ */
+void lcp_set_default_num_queues (u16 num_queues, u8 is_tx);
+u16 lcp_get_default_num_queues (u8 is_tx);
+
#endif
/*
diff --git a/src/plugins/linux-cp/lcp_interface.c b/src/plugins/linux-cp/lcp_interface.c
index 921dccf5519..e1f4a6a1d69 100644
--- a/src/plugins/linux-cp/lcp_interface.c
+++ b/src/plugins/linux-cp/lcp_interface.c
@@ -555,6 +555,7 @@ static clib_error_t *
lcp_itf_pair_config (vlib_main_t *vm, unformat_input_t *input)
{
u8 *default_ns;
+ u32 tmp;
default_ns = NULL;
@@ -579,6 +580,10 @@ lcp_itf_pair_config (vlib_main_t *vm, unformat_input_t *input)
lcp_set_del_static_on_link_down (1 /* is_del */);
else if (unformat (input, "del-dynamic-on-link-down"))
lcp_set_del_dynamic_on_link_down (1 /* is_del */);
+ else if (unformat (input, "num-rx-queues %d", &tmp))
+ lcp_set_default_num_queues (tmp, 0 /* is_tx */);
+ else if (unformat (input, "num-tx-queues %d", &tmp))
+ lcp_set_default_num_queues (tmp, 1 /* is_tx */);
else
return clib_error_return (0, "interfaces not found");
}
@@ -988,8 +993,10 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name,
else
{
tap_create_if_args_t args = {
- .num_rx_queues = clib_max (1, vlib_num_workers ()),
- .num_tx_queues = 1,
+ .num_rx_queues =
+ clib_max (1, lcp_get_default_num_queues (0 /* is_tx */)),
+ .num_tx_queues =
+ clib_max (1, lcp_get_default_num_queues (1 /* is_tx */)),
.id = hw->hw_if_index,
.sw_if_index = ~0,
.rx_ring_sz = 256,