This commit is contained in:
Pim van Pelt
2024-04-01 23:04:45 +02:00
parent cb78074e46
commit 25b2999485
3 changed files with 40 additions and 3 deletions

22
lcpng.c
View File

@ -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
*

10
lcpng.h
View File

@ -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
/*

View File

@ -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,