From: Alex Williamson <alex.williamson@redhat.com>
To: qemu-devel@nongnu.org
Cc: jes.sorensen@redhat.com, alex.williamson@redhat.com, kvm@vger.kernel.org
Subject: [Qemu-devel] [PATCH 1/5] virtio-net: Make tx_timer timeout configurable
Date: Fri, 27 Aug 2010 16:37:08 -0600 [thread overview]
Message-ID: <20100827223708.2696.47389.stgit@s20.home> (raw)
In-Reply-To: <20100827223659.2696.3589.stgit@s20.home>
The tx_timer used for TX mitigation in virtio-net has a hard coded
timeout. Make an option for this to be configurable using a
txtimer=<ns> device config option. Note that we reserve a value of
"1" to simply mean use the default, we'll later use the value "0"
to disable the timer. Everything else is the timeout in ns. We
limit the timeout to a uint32_t, because anything over a 4s timeout
probably doens't make any kind of practical sense.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
hw/s390-virtio-bus.c | 3 ++-
hw/s390-virtio-bus.h | 2 ++
hw/syborg_virtio.c | 5 ++++-
hw/virtio-net.c | 17 ++++++++++++++---
hw/virtio-net.h | 2 --
hw/virtio-pci.c | 5 ++++-
hw/virtio.h | 3 ++-
7 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index fe6884d..4da0b40 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -110,7 +110,7 @@ static int s390_virtio_net_init(VirtIOS390Device *dev)
{
VirtIODevice *vdev;
- vdev = virtio_net_init((DeviceState *)dev, &dev->nic);
+ vdev = virtio_net_init((DeviceState *)dev, &dev->nic, dev->txtimer);
if (!vdev) {
return -1;
}
@@ -327,6 +327,7 @@ static VirtIOS390DeviceInfo s390_virtio_net = {
.qdev.size = sizeof(VirtIOS390Device),
.qdev.props = (Property[]) {
DEFINE_NIC_PROPERTIES(VirtIOS390Device, nic),
+ DEFINE_PROP_UINT32("txtimer", VirtIOS390Device, txtimer, 1),
DEFINE_PROP_END_OF_LIST(),
},
};
diff --git a/hw/s390-virtio-bus.h b/hw/s390-virtio-bus.h
index 333fea8..922daf2 100644
--- a/hw/s390-virtio-bus.h
+++ b/hw/s390-virtio-bus.h
@@ -43,6 +43,8 @@ typedef struct VirtIOS390Device {
uint32_t host_features;
/* Max. number of ports we can have for a the virtio-serial device */
uint32_t max_virtserial_ports;
+ /* Timeout value for virtio-net txtimer, 1 = default, >1 = ns timeout */
+ uint32_t txtimer;
} VirtIOS390Device;
typedef struct VirtIOS390Bus {
diff --git a/hw/syborg_virtio.c b/hw/syborg_virtio.c
index abf0370..c8d731a 100644
--- a/hw/syborg_virtio.c
+++ b/hw/syborg_virtio.c
@@ -68,6 +68,8 @@ typedef struct {
uint32_t id;
NICConf nic;
uint32_t host_features;
+ /* Timeout value for virtio-net txtimer, 1 = default, >1 = ns timeout */
+ uint32_t txtimer;
} SyborgVirtIOProxy;
static uint32_t syborg_virtio_readl(void *opaque, target_phys_addr_t offset)
@@ -284,7 +286,7 @@ static int syborg_virtio_net_init(SysBusDevice *dev)
VirtIODevice *vdev;
SyborgVirtIOProxy *proxy = FROM_SYSBUS(SyborgVirtIOProxy, dev);
- vdev = virtio_net_init(&dev->qdev, &proxy->nic);
+ vdev = virtio_net_init(&dev->qdev, &proxy->nic, proxy->txtimer);
return syborg_virtio_init(proxy, vdev);
}
@@ -295,6 +297,7 @@ static SysBusDeviceInfo syborg_virtio_net_info = {
.qdev.props = (Property[]) {
DEFINE_NIC_PROPERTIES(SyborgVirtIOProxy, nic),
DEFINE_VIRTIO_NET_FEATURES(SyborgVirtIOProxy, host_features),
+ DEFINE_PROP_UINT32("txtimer", SyborgVirtIOProxy, txtimer, 1),
DEFINE_PROP_END_OF_LIST(),
}
};
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 075f72d..9ef29f0 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -36,6 +36,7 @@ typedef struct VirtIONet
VirtQueue *ctrl_vq;
NICState *nic;
QEMUTimer *tx_timer;
+ uint32_t tx_timeout;
int tx_timer_active;
uint32_t has_vnet_hdr;
uint8_t has_ufo;
@@ -702,7 +703,7 @@ static void virtio_net_handle_tx(VirtIODevice *vdev, VirtQueue *vq)
virtio_net_flush_tx(n, vq);
} else {
qemu_mod_timer(n->tx_timer,
- qemu_get_clock(vm_clock) + TX_TIMER_INTERVAL);
+ qemu_get_clock(vm_clock) + n->tx_timeout);
n->tx_timer_active = 1;
virtio_queue_set_notification(vq, 0);
}
@@ -842,7 +843,7 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
if (n->tx_timer_active) {
qemu_mod_timer(n->tx_timer,
- qemu_get_clock(vm_clock) + TX_TIMER_INTERVAL);
+ qemu_get_clock(vm_clock) + n->tx_timeout);
}
return 0;
}
@@ -903,7 +904,8 @@ static void virtio_net_vmstate_change(void *opaque, int running, int reason)
virtio_net_set_status(&n->vdev, n->vdev.status & status);
}
-VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf)
+VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf,
+ uint32_t txtimer)
{
VirtIONet *n;
@@ -931,6 +933,15 @@ VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf)
n->tx_timer = qemu_new_timer(vm_clock, virtio_net_tx_timer, n);
n->tx_timer_active = 0;
+ if (txtimer) {
+ if (txtimer == 1) {
+ /* For convenience, 1 = "on" = predefined default, anything else
+ * specifies and actual timeout value */
+ n->tx_timeout = 150000; /* 150 us */
+ } else {
+ n->tx_timeout = txtimer;
+ }
+ }
n->mergeable_rx_bufs = 0;
n->promisc = 1; /* for compatibility */
diff --git a/hw/virtio-net.h b/hw/virtio-net.h
index 235f1a9..ae21c35 100644
--- a/hw/virtio-net.h
+++ b/hw/virtio-net.h
@@ -47,8 +47,6 @@
#define VIRTIO_NET_S_LINK_UP 1 /* Link is up */
-#define TX_TIMER_INTERVAL 150000 /* 150 us */
-
/* Maximum packet size we can receive from tap device: header + 64k */
#define VIRTIO_NET_MAX_BUFSIZE (sizeof(struct virtio_net_hdr) + (64 << 10))
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 6e8f88a..e3b9897 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -107,6 +107,8 @@ typedef struct {
#endif
/* Max. number of ports we can have for a the virtio-serial device */
uint32_t max_virtserial_ports;
+ /* Timeout value for virtio-net txtimer, 1 = default, >1 = ns timeout */
+ uint32_t txtimer;
} VirtIOPCIProxy;
/* virtio device */
@@ -613,7 +615,7 @@ static int virtio_net_init_pci(PCIDevice *pci_dev)
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
VirtIODevice *vdev;
- vdev = virtio_net_init(&pci_dev->qdev, &proxy->nic);
+ vdev = virtio_net_init(&pci_dev->qdev, &proxy->nic, proxy->txtimer);
vdev->nvectors = proxy->nvectors;
virtio_init_pci(proxy, vdev,
@@ -690,6 +692,7 @@ static PCIDeviceInfo virtio_info[] = {
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 3),
DEFINE_VIRTIO_NET_FEATURES(VirtIOPCIProxy, host_features),
DEFINE_NIC_PROPERTIES(VirtIOPCIProxy, nic),
+ DEFINE_PROP_UINT32("txtimer", VirtIOPCIProxy, txtimer, 1),
DEFINE_PROP_END_OF_LIST(),
},
.qdev.reset = virtio_pci_reset,
diff --git a/hw/virtio.h b/hw/virtio.h
index 5836ab6..77d05e0 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -185,7 +185,8 @@ void virtio_bind_device(VirtIODevice *vdev, const VirtIOBindings *binding,
/* Base devices. */
VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf);
-VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf);
+VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf,
+ uint32_t txtimer);
VirtIODevice *virtio_serial_init(DeviceState *dev, uint32_t max_nr_ports);
VirtIODevice *virtio_balloon_init(DeviceState *dev);
#ifdef CONFIG_LINUX
next prev parent reply other threads:[~2010-08-27 22:37 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-27 22:36 [Qemu-devel] [PATCH 0/5] virtio-net: More configurability and bh handling for tx Alex Williamson
2010-08-27 22:37 ` Alex Williamson [this message]
2010-08-31 18:00 ` [Qemu-devel] [PATCH 1/5] virtio-net: Make tx_timer timeout configurable Chris Wright
2010-08-31 18:07 ` Alex Williamson
2010-08-31 19:29 ` Chris Wright
2010-08-27 22:37 ` [Qemu-devel] [PATCH 2/5] virtio-net: Limit number of packets sent per TX flush Alex Williamson
2010-08-31 20:23 ` [Qemu-devel] " Michael S. Tsirkin
2010-08-27 22:37 ` [Qemu-devel] [PATCH 3/5] virtio-net: Rename tx_timer_active to tx_waiting Alex Williamson
2010-08-27 22:37 ` [Qemu-devel] [PATCH 4/5] virtio-net: Introduce a new bottom half packet TX Alex Williamson
2010-08-31 20:14 ` [Qemu-devel] " Michael S. Tsirkin
2010-08-31 20:33 ` Alex Williamson
2010-09-01 9:47 ` Michael S. Tsirkin
2010-08-27 22:37 ` [Qemu-devel] [PATCH 5/5] virtio-net: Switch default to new bottom half TX handler for iothread Alex Williamson
2010-08-31 20:25 ` [Qemu-devel] " Michael S. Tsirkin
2010-08-31 22:32 ` Alex Williamson
2010-08-31 22:46 ` Anthony Liguori
2010-09-01 6:21 ` Stefan Hajnoczi
2010-09-01 8:47 ` Michael S. Tsirkin
2010-08-31 20:20 ` [Qemu-devel] Re: [PATCH 0/5] virtio-net: More configurability and bh handling for tx Michael S. Tsirkin
2010-08-31 20:27 ` Michael S. Tsirkin
2010-08-31 21:33 ` Anthony Liguori
2010-08-31 22:26 ` Alex Williamson
2010-09-01 10:40 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100827223708.2696.47389.stgit@s20.home \
--to=alex.williamson@redhat.com \
--cc=jes.sorensen@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).