From 47a3d9975fa3af7a7537b565d6511dadc0df61fb Mon Sep 17 00:00:00 2001 From: Neale Ranns Date: Tue, 29 Sep 2020 15:38:51 +0000 Subject: l2: input performance Type: improvement - cache the values form the BD on the input config to avoid loading - avoid the short write long read on the sequence number - use vlib_buffer_enqueue_to_next Signed-off-by: Neale Ranns Change-Id: I33442b9104b457e4c638d26e9ad3bc965687a0bc --- src/vnet/ethernet/interface.c | 48 +++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'src/vnet/ethernet/interface.c') diff --git a/src/vnet/ethernet/interface.c b/src/vnet/ethernet/interface.c index 7b11fdad8b1..b09e2b02256 100644 --- a/src/vnet/ethernet/interface.c +++ b/src/vnet/ethernet/interface.c @@ -496,10 +496,10 @@ simulated_ethernet_interface_tx (vlib_main_t * vm, /* Ordinarily, this is the only config lookup. */ config = l2input_intf_config (vnet_buffer (b[0])->sw_if_index[VLIB_TX]); - next_index = - config->bridge ? VNET_SIMULATED_ETHERNET_TX_NEXT_L2_INPUT : - VNET_SIMULATED_ETHERNET_TX_NEXT_ETHERNET_INPUT; - new_tx_sw_if_index = config->bvi ? L2INPUT_BVI : ~0; + next_index = (l2_input_is_bridge (config) ? + VNET_SIMULATED_ETHERNET_TX_NEXT_L2_INPUT : + VNET_SIMULATED_ETHERNET_TX_NEXT_ETHERNET_INPUT); + new_tx_sw_if_index = l2_input_is_bvi (config) ? L2INPUT_BVI : ~0; new_rx_sw_if_index = vnet_buffer (b[0])->sw_if_index[VLIB_TX]; while (n_left_from >= 4) @@ -579,10 +579,10 @@ simulated_ethernet_interface_tx (vlib_main_t * vm, { config = l2input_intf_config (vnet_buffer (b[0])->sw_if_index[VLIB_TX]); - next_index = - config->bridge ? VNET_SIMULATED_ETHERNET_TX_NEXT_L2_INPUT : - VNET_SIMULATED_ETHERNET_TX_NEXT_ETHERNET_INPUT; - new_tx_sw_if_index = config->bvi ? L2INPUT_BVI : ~0; + next_index = (l2_input_is_bridge (config) ? + VNET_SIMULATED_ETHERNET_TX_NEXT_L2_INPUT : + VNET_SIMULATED_ETHERNET_TX_NEXT_ETHERNET_INPUT); + new_tx_sw_if_index = l2_input_is_bvi (config) ? L2INPUT_BVI : ~0; new_rx_sw_if_index = vnet_buffer (b[0])->sw_if_index[VLIB_TX]; } next[0] = next_index; @@ -602,11 +602,11 @@ simulated_ethernet_interface_tx (vlib_main_t * vm, { config = l2input_intf_config (vnet_buffer (b[1])->sw_if_index[VLIB_TX]); - next_index = - config->bridge ? VNET_SIMULATED_ETHERNET_TX_NEXT_L2_INPUT : - VNET_SIMULATED_ETHERNET_TX_NEXT_ETHERNET_INPUT; + next_index = (l2_input_is_bridge (config) ? + VNET_SIMULATED_ETHERNET_TX_NEXT_L2_INPUT : + VNET_SIMULATED_ETHERNET_TX_NEXT_ETHERNET_INPUT); new_rx_sw_if_index = vnet_buffer (b[1])->sw_if_index[VLIB_TX]; - new_tx_sw_if_index = config->bvi ? L2INPUT_BVI : ~0; + new_tx_sw_if_index = l2_input_is_bvi (config) ? L2INPUT_BVI : ~0; } next[1] = next_index; vnet_buffer (b[1])->sw_if_index[VLIB_RX] = new_rx_sw_if_index; @@ -625,11 +625,11 @@ simulated_ethernet_interface_tx (vlib_main_t * vm, { config = l2input_intf_config (vnet_buffer (b[2])->sw_if_index[VLIB_TX]); - next_index = - config->bridge ? VNET_SIMULATED_ETHERNET_TX_NEXT_L2_INPUT : - VNET_SIMULATED_ETHERNET_TX_NEXT_ETHERNET_INPUT; + next_index = (l2_input_is_bridge (config) ? + VNET_SIMULATED_ETHERNET_TX_NEXT_L2_INPUT : + VNET_SIMULATED_ETHERNET_TX_NEXT_ETHERNET_INPUT); new_rx_sw_if_index = vnet_buffer (b[2])->sw_if_index[VLIB_TX]; - new_tx_sw_if_index = config->bvi ? L2INPUT_BVI : ~0; + new_tx_sw_if_index = l2_input_is_bvi (config) ? L2INPUT_BVI : ~0; } next[2] = next_index; vnet_buffer (b[2])->sw_if_index[VLIB_RX] = new_rx_sw_if_index; @@ -648,11 +648,11 @@ simulated_ethernet_interface_tx (vlib_main_t * vm, { config = l2input_intf_config (vnet_buffer (b[3])->sw_if_index[VLIB_TX]); - next_index = - config->bridge ? VNET_SIMULATED_ETHERNET_TX_NEXT_L2_INPUT : - VNET_SIMULATED_ETHERNET_TX_NEXT_ETHERNET_INPUT; + next_index = (l2_input_is_bridge (config) ? + VNET_SIMULATED_ETHERNET_TX_NEXT_L2_INPUT : + VNET_SIMULATED_ETHERNET_TX_NEXT_ETHERNET_INPUT); new_rx_sw_if_index = vnet_buffer (b[3])->sw_if_index[VLIB_TX]; - new_tx_sw_if_index = config->bvi ? L2INPUT_BVI : ~0; + new_tx_sw_if_index = l2_input_is_bvi (config) ? L2INPUT_BVI : ~0; } next[3] = next_index; vnet_buffer (b[3])->sw_if_index[VLIB_RX] = new_rx_sw_if_index; @@ -676,10 +676,10 @@ simulated_ethernet_interface_tx (vlib_main_t * vm, { config = l2input_intf_config (vnet_buffer (b[0])->sw_if_index[VLIB_TX]); - next_index = - config->bridge ? VNET_SIMULATED_ETHERNET_TX_NEXT_L2_INPUT : - VNET_SIMULATED_ETHERNET_TX_NEXT_ETHERNET_INPUT; - new_tx_sw_if_index = config->bvi ? L2INPUT_BVI : ~0; + next_index = (l2_input_is_bridge (config) ? + VNET_SIMULATED_ETHERNET_TX_NEXT_L2_INPUT : + VNET_SIMULATED_ETHERNET_TX_NEXT_ETHERNET_INPUT); + new_tx_sw_if_index = l2_input_is_bvi (config) ? L2INPUT_BVI : ~0; new_rx_sw_if_index = vnet_buffer (b[0])->sw_if_index[VLIB_TX]; } next[0] = next_index; -- cgit 1.2.3-korg