From 25b2999485f6cf8938f5e1baeb88b302cd420bf3 Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Mon, 1 Apr 2024 23:04:45 +0200 Subject: [PATCH] Backport https://gerrit.fd.io/r/c/vpp/+/40441 --- lcpng.c | 22 ++++++++++++++++++++++ lcpng.h | 10 +++++++++- lcpng_interface.c | 11 +++++++++-- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/lcpng.c b/lcpng.c index 7e8d617..d3422f6 100644 --- a/lcpng.c +++ b/lcpng.c @@ -131,6 +131,28 @@ lcp_auto_subint (void) return lcpm->lcp_auto_subint; } +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/lcpng.h b/lcpng.h index 2447433..2fd8e91 100644 --- a/lcpng.h +++ b/lcpng.h @@ -27,6 +27,8 @@ typedef struct lcp_main_s u8 lcp_auto_subint; /* Automatically create/delete LCP sub-interfaces */ u8 lcp_sync; /* Automatically sync VPP changes to LCP */ u8 lcp_sync_unnumbered; /* Automatically sync unnumbered interfaces to LCP */ + u16 num_rx_queues; + u16 num_tx_queues; /* Set when Unit testing */ u8 test_mode; } lcp_main_t; @@ -40,11 +42,17 @@ int lcp_set_default_ns (u8 *ns); u8 *lcp_get_default_ns (void); /* Returns NULL or shared string */ int lcp_get_default_ns_fd (void); -/* +/** * Sync state from VPP into all LCP devices */ void lcp_itf_pair_sync_state_all (); +/** + * 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/lcpng_interface.c b/lcpng_interface.c index ac6f6d7..c1edb65 100644 --- a/lcpng_interface.c +++ b/lcpng_interface.c @@ -552,6 +552,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; @@ -571,6 +572,10 @@ lcp_itf_pair_config (vlib_main_t *vm, unformat_input_t *input) lcp_set_auto_subint (1 /* is_auto */); else if (unformat (input, "lcp-sync")) lcp_set_sync (1 /* is_auto */); + 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, "unknown input `%U'", format_unformat_error, input); @@ -993,8 +998,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 = ~0, .sw_if_index = ~0, .rx_ring_sz = 256,