[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 38/57] tests/libqos: support multiqueue for virtio-ne
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 38/57] tests/libqos: support multiqueue for virtio-net |
Date: |
Thu, 7 Mar 2019 18:29:45 +0100 |
Initialize the additional virtqueues if they are supported.
This is needed to switch vhost-user-test's multiqueue test
to the virtio-net qgraph.
Signed-off-by: Paolo Bonzini <address@hidden>
---
tests/libqos/virtio-net.c | 21 +++++++++++++++++----
tests/libqos/virtio-net.h | 4 ++--
tests/virtio-net-test.c | 6 +++---
3 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/tests/libqos/virtio-net.c b/tests/libqos/virtio-net.c
index 3ddfbdc..61c5617 100644
--- a/tests/libqos/virtio-net.c
+++ b/tests/libqos/virtio-net.c
@@ -27,14 +27,19 @@ static QGuestAllocator *alloc;
static void virtio_net_cleanup(QVirtioNet *interface)
{
- qvirtqueue_cleanup(interface->vdev->bus, interface->rx, alloc);
- qvirtqueue_cleanup(interface->vdev->bus, interface->tx, alloc);
+ int i;
+
+ for (i = 0; i < interface->n_queues; i++) {
+ qvirtqueue_cleanup(interface->vdev->bus, interface->queues[i], alloc);
+ }
+ g_free(interface->queues);
}
static void virtio_net_setup(QVirtioNet *interface)
{
QVirtioDevice *vdev = interface->vdev;
uint64_t features;
+ int i;
features = qvirtio_get_features(vdev);
features &= ~(QVIRTIO_F_BAD_FEATURE |
@@ -42,8 +47,16 @@ static void virtio_net_setup(QVirtioNet *interface)
(1u << VIRTIO_RING_F_EVENT_IDX));
qvirtio_set_features(vdev, features);
- interface->rx = qvirtqueue_setup(vdev, alloc, 0);
- interface->tx = qvirtqueue_setup(vdev, alloc, 1);
+ if (features & (1u << VIRTIO_NET_F_MQ)) {
+ interface->n_queues = qvirtio_config_readw(vdev, 8) * 2;
+ } else {
+ interface->n_queues = 2;
+ }
+
+ interface->queues = g_new(QVirtQueue *, interface->n_queues);
+ for (i = 0; i < interface->n_queues; i++) {
+ interface->queues[i] = qvirtqueue_setup(vdev, alloc, i);
+ }
qvirtio_set_driver_ok(vdev);
}
diff --git a/tests/libqos/virtio-net.h b/tests/libqos/virtio-net.h
index e6905cd..28238a1 100644
--- a/tests/libqos/virtio-net.h
+++ b/tests/libqos/virtio-net.h
@@ -26,8 +26,8 @@ typedef struct QVirtioNetDevice QVirtioNetDevice;
struct QVirtioNet {
QVirtioDevice *vdev;
- QVirtQueue *rx;
- QVirtQueue *tx;
+ int n_queues;
+ QVirtQueue **queues;
};
struct QVirtioNetPCI {
diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c
index 2d3630c..c58e670 100644
--- a/tests/virtio-net-test.c
+++ b/tests/virtio-net-test.c
@@ -136,8 +136,8 @@ static void send_recv_test(void *obj, void *data,
QGuestAllocator *t_alloc)
{
QVirtioNet *net_if = obj;
QVirtioDevice *dev = net_if->vdev;
- QVirtQueue *rx = net_if->rx;
- QVirtQueue *tx = net_if->tx;
+ QVirtQueue *rx = net_if->queues[0];
+ QVirtQueue *tx = net_if->queues[1];
int *sv = data;
rx_test(dev, t_alloc, rx, sv[0]);
@@ -148,7 +148,7 @@ static void stop_cont_test(void *obj, void *data,
QGuestAllocator *t_alloc)
{
QVirtioNet *net_if = obj;
QVirtioDevice *dev = net_if->vdev;
- QVirtQueue *rx = net_if->rx;
+ QVirtQueue *rx = net_if->queues[0];
int *sv = data;
rx_stop_cont_test(dev, t_alloc, rx, sv[0]);
--
1.8.3.1
- [Qemu-devel] [PULL 32/57] tests/libqos: virtio-rng driver and interface nodes, (continued)
- [Qemu-devel] [PULL 32/57] tests/libqos: virtio-rng driver and interface nodes, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 33/57] qos-test: virtio-rng test node, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 34/57] tests/libqos: virtio-blk driver and interface nodes, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 36/57] tests/libqos: virtio-net driver and interface nodes, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 37/57] qos-test: virtio-net test node, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 31/57] tests/qgraph: remove virtio-balloon-test, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 29/57] qos-test: virtio-9p test node, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 39/57] vhost-user-test: always use 256 MiB of guest memory, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 35/57] qos-test: virtio-blk test node, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 41/57] tests/libqos: virtio-scsi driver and interface nodes, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 38/57] tests/libqos: support multiqueue for virtio-net,
Paolo Bonzini <=
- [Qemu-devel] [PULL 42/57] qos-test: virtio-scsi test node, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 40/57] qos-test: vhost-user test node, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 45/57] qos-test: ac97 test node, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 43/57] tests/libqos: remove pre-qgraph QVirtioPCIDevice API, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 44/57] tests: move virtio entirely to qos-test, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 47/57] qos-test: ipoctal232 test node, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 48/57] qos-test: ne2k_pci test node, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 46/57] qos-test: tpci200 test node, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 49/57] qos-test: nvme test node, Paolo Bonzini, 2019/03/07
- [Qemu-devel] [PULL 50/57] qos-test: pcnet test node, Paolo Bonzini, 2019/03/07