summaryrefslogtreecommitdiffstats
path: root/src/vnet/devices/virtio/virtio.c
diff options
context:
space:
mode:
authorMohsin Kazmi <sykazmi@cisco.com>2020-09-28 10:26:33 +0000
committerBeno�t Ganne <bganne@cisco.com>2020-09-28 16:47:30 +0000
commite347acbc31111504c015531e8ad764a86d489309 (patch)
tree3a72d961fd97b9ce7985865d89b0c45d27cab2fc /src/vnet/devices/virtio/virtio.c
parent7741afaf5c66a5d7ed1d2d76ae36a81ec24fdaaa (diff)
virtio: add packet buffering on tx
Type: feature This patch adds packet buffering on tx for slow backend which have some jitter/delays in freeing the vrings. There are some limitations to the current design: 1) It only works in poll mode. 2) Atleast 1 rx queue of an interface (with buffering enabled) should be placed on each worker and main thread. Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com> Change-Id: Ib93c350298b228e80426e58ac77f3bbc93b8be27
Diffstat (limited to 'src/vnet/devices/virtio/virtio.c')
-rw-r--r--src/vnet/devices/virtio/virtio.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/vnet/devices/virtio/virtio.c b/src/vnet/devices/virtio/virtio.c
index e74f3783756..8209a46b52f 100644
--- a/src/vnet/devices/virtio/virtio.c
+++ b/src/vnet/devices/virtio/virtio.c
@@ -216,6 +216,7 @@ virtio_vring_free_tx (vlib_main_t * vm, virtio_if_t * vif, u32 idx)
clib_mem_free (vring->avail);
vec_free (vring->buffers);
gro_flow_table_free (vring->flow_table);
+ virtio_vring_buffering_free (vm, vring->buffering);
clib_spinlock_free (&vring->lockp);
return 0;
}
@@ -235,6 +236,28 @@ virtio_set_packet_coalesce (virtio_if_t * vif)
}
}
+clib_error_t *
+virtio_set_packet_buffering (virtio_if_t * vif, u16 buffering_size)
+{
+ vnet_main_t *vnm = vnet_get_main ();
+ vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, vif->hw_if_index);
+ virtio_vring_t *vring;
+ clib_error_t *error = 0;
+ vif->packet_buffering = 1;
+
+ vec_foreach (vring, vif->txq_vrings)
+ {
+ if ((error =
+ virtio_vring_buffering_init (&vring->buffering, hw->tx_node_index,
+ buffering_size)))
+ {
+ break;
+ }
+ }
+
+ return error;
+}
+
void
virtio_vring_set_numa_node (vlib_main_t * vm, virtio_if_t * vif, u32 idx)
{
@@ -335,6 +358,7 @@ virtio_show (vlib_main_t * vm, u32 * hw_if_indices, u8 show_descr, u32 type)
vlib_cli_output (vm, " gso-enabled %d", vif->gso_enabled);
vlib_cli_output (vm, " csum-enabled %d", vif->csum_offload_enabled);
vlib_cli_output (vm, " packet-coalesce %d", vif->packet_coalesce);
+ vlib_cli_output (vm, " packet-buffering %d", vif->packet_buffering);
if (type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_PCI))
vlib_cli_output (vm, " Mac Address: %U", format_ethernet_address,
vif->mac_addr);
@@ -432,6 +456,11 @@ virtio_show (vlib_main_t * vm, u32 * hw_if_indices, u8 show_descr, u32 type)
vlib_cli_output (vm, " %U", gro_flow_table_format,
vring->flow_table);
}
+ if (vif->packet_buffering)
+ {
+ vlib_cli_output (vm, " %U", virtio_vring_buffering_format,
+ vring->buffering);
+ }
if (show_descr)
{
vlib_cli_output (vm, "\n descriptor table:\n");