aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStanislav Zaikin <zstaseg@gmail.com>2022-05-05 12:04:39 +0200
committerBeno�t Ganne <bganne@cisco.com>2023-06-27 08:18:10 +0000
commit5fe1cf80cad75a2e08450303410fb484cdc708ad (patch)
tree1c742252b4185f32f03959831c78731b7994ffa0 /src
parentd96859f09b8fa9bb458d62e43b962f240744b5c3 (diff)
virtio: use fast-path for ethernet-input if possible
If a frame should be sent to 'ethernet-input' set the ETH_INPUT_FRAME_F_SINGLE_SW_IF_IDX flag. It will force 'ethernet-input' to use a fast-path for such frames. This patch also aligns the behaviour with other input nodes. Type: improvement Change-Id: Icff0fa31204d5304a2ea0a4f4e7bc418dedbfe32 Signed-off-by: Stanislav Zaikin <zstaseg@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/vnet/devices/virtio/node.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/vnet/devices/virtio/node.c b/src/vnet/devices/virtio/node.c
index a022ee5eacc..ec8b31038e5 100644
--- a/src/vnet/devices/virtio/node.c
+++ b/src/vnet/devices/virtio/node.c
@@ -214,6 +214,29 @@ virtio_get_len (vnet_virtio_vring_t *vring, const int packed, const int hdr_sz,
} \
while (0)
+static_always_inline void
+virtio_device_input_ethernet (vlib_main_t *vm, vlib_node_runtime_t *node,
+ const u32 next_index, const u32 sw_if_index,
+ const u32 hw_if_index)
+{
+ vlib_next_frame_t *nf;
+ vlib_frame_t *f;
+ ethernet_input_frame_t *ef;
+
+ if (PREDICT_FALSE (VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT != next_index))
+ return;
+
+ nf = vlib_node_runtime_get_next_frame (
+ vm, node, VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT);
+ f = vlib_get_frame (vm, nf->frame);
+ f->flags = ETH_INPUT_FRAME_F_SINGLE_SW_IF_IDX;
+
+ ef = vlib_frame_scalar_args (f);
+ ef->sw_if_index = sw_if_index;
+ ef->hw_if_index = hw_if_index;
+ vlib_frame_no_append (f);
+}
+
static_always_inline uword
virtio_device_input_gso_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
vlib_frame_t *frame, virtio_if_t *vif,
@@ -256,7 +279,7 @@ virtio_device_input_gso_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
u32 n_left_to_next;
u32 next0 = next_index;
- vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+ vlib_get_new_next_frame (vm, node, next_index, to_next, n_left_to_next);
while (n_left && n_left_to_next)
{
@@ -386,6 +409,8 @@ virtio_device_input_gso_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
n_rx_packets++;
n_rx_bytes += len;
}
+ virtio_device_input_ethernet (vm, node, next_index, vif->sw_if_index,
+ vif->hw_if_index);
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
vring->last_used_idx = last;