ethernet: put vlib_get_buffers together
The patch brings 0.8 clocks saved per pkt in IPv4 l3fwd case on Skylake.
Type: improvement
@@ -842,18 +842,15 @@ eth_input_process_frame (vlib_main_t * vm, vlib_node_runtime_t * node,
u16 et_vlan = clib_host_to_net_u16 (ETHERNET_TYPE_VLAN);
u16 et_dot1ad = clib_host_to_net_u16 (ETHERNET_TYPE_DOT1AD);
i32 n_left = n_packets;
- vlib_buffer_t *b[20];
- u32 *from;
+ vlib_buffer_t *bufs[VLIB_FRAME_SIZE];
+ vlib_buffer_t **b = bufs;
ethernet_interface_t *ei = ethernet_get_interface (em, hi->hw_if_index);
- from = buffer_indices;
+ vlib_get_buffers (vm, buffer_indices, b, n_left);
while (n_left >= 20)
{
vlib_buffer_t **ph = b + 16, **pd = b + 8;
- vlib_get_buffers (vm, from, b, 4);
- vlib_get_buffers (vm, from + 8, pd, 4);
- vlib_get_buffers (vm, from + 16, ph, 4);
vlib_prefetch_buffer_header (ph[0], LOAD);
vlib_prefetch_buffer_data (pd[0], LOAD);
@@ -874,15 +871,14 @@ eth_input_process_frame (vlib_main_t * vm, vlib_node_runtime_t * node,
eth_input_adv_and_flags_x4 (b, main_is_l3);
/* next */
+ b += 4;
n_left -= 4;
etype += 4;
tag += 4;
dmac += 4;
- from += 4;
}
while (n_left >= 4)
{
- vlib_get_buffers (vm, from, b, 4);
eth_input_get_etype_and_tags (b, etype, tag, dmac, 0, dmac_check);
eth_input_get_etype_and_tags (b, etype, tag, dmac, 1, dmac_check);
eth_input_get_etype_and_tags (b, etype, tag, dmac, 2, dmac_check);
@@ -890,24 +886,23 @@ eth_input_process_frame (vlib_main_t * vm, vlib_node_runtime_t * node,
eth_input_adv_and_flags_x4 (b, main_is_l3);
/* next */
+ b += 4;
n_left -= 4;
etype += 4;
tag += 4;
dmac += 4;
- from += 4;
}
while (n_left)
{
- vlib_get_buffers (vm, from, b, 1);
eth_input_get_etype_and_tags (b, etype, tag, dmac, 0, dmac_check);
eth_input_adv_and_flags_x1 (b, main_is_l3);
/* next */
+ b += 1;
n_left -= 1;
etype += 1;
tag += 1;
dmac += 4;
- from += 1;
}
if (dmac_check)
