aboutsummaryrefslogtreecommitdiff
path: root/hw/virtio-net.h
diff options
context:
space:
mode:
authorAlex Williamson <alex.williamson@redhat.com>2010-09-02 09:00:57 -0600
committerMichael S. Tsirkin <mst@redhat.com>2010-09-07 20:29:26 +0300
commite3f30488e5f802547b3a60e40cebaef3b4ec16a3 (patch)
treedaaf476a94f131569113cf3bd7f2204c1d62e33e /hw/virtio-net.h
parentf0c07c7c7b4fe4f9b63c88341fd32707def5a058 (diff)
virtio-net: Limit number of packets sent per TX flush
If virtio_net_flush_tx() is called with notification disabled, we can race with the guest, processing packets at the same rate as they get produced. The trouble is that this means we have no guaranteed exit condition from the function and can spend minutes in there. Currently flush_tx is only called with notification on, which seems to limit us to one pass through the queue per call. An upcoming patch changes this. Also add an option to set this value on the command line as different workloads may wish to use different values. We can't necessarily support any random value, so this is a developer option: x-txburst= Usage: -device virtio-net-pci,x-txburst=64 # 64 packets per tx flush One pass through the queue (256) seems to be a good default value for this, balancing latency with throughput. We use a signed int for x-txburst because 2^31 packets in a burst would take many, many minutes to process and it allows us to easily return a negative value value from virtio_net_flush_tx() to indicate a back-off or error condition. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/virtio-net.h')
-rw-r--r--hw/virtio-net.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/hw/virtio-net.h b/hw/virtio-net.h
index 46a2e1c57d..a2d1545e4c 100644
--- a/hw/virtio-net.h
+++ b/hw/virtio-net.h
@@ -49,9 +49,17 @@
#define TX_TIMER_INTERVAL 150000 /* 150 us */
+/* Limit the number of packets that can be sent via a single flush
+ * of the TX queue. This gives us a guaranteed exit condition and
+ * ensures fairness in the io path. 256 conveniently matches the
+ * length of the TX queue and shows a good balance of performance
+ * and latency. */
+#define TX_BURST 256
+
typedef struct virtio_net_conf
{
uint32_t txtimer;
+ int32_t txburst;
} virtio_net_conf;
/* Maximum packet size we can receive from tap device: header + 64k */