mirror of https://gitee.com/openkylin/qemu.git
tests/libqos: support multiqueue for virtio-net
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 <pbonzini@redhat.com>
This commit is contained in:
parent
6ae333f91b
commit
6bd4a6d4b8
|
@ -27,14 +27,19 @@ static QGuestAllocator *alloc;
|
||||||
|
|
||||||
static void virtio_net_cleanup(QVirtioNet *interface)
|
static void virtio_net_cleanup(QVirtioNet *interface)
|
||||||
{
|
{
|
||||||
qvirtqueue_cleanup(interface->vdev->bus, interface->rx, alloc);
|
int i;
|
||||||
qvirtqueue_cleanup(interface->vdev->bus, interface->tx, alloc);
|
|
||||||
|
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)
|
static void virtio_net_setup(QVirtioNet *interface)
|
||||||
{
|
{
|
||||||
QVirtioDevice *vdev = interface->vdev;
|
QVirtioDevice *vdev = interface->vdev;
|
||||||
uint64_t features;
|
uint64_t features;
|
||||||
|
int i;
|
||||||
|
|
||||||
features = qvirtio_get_features(vdev);
|
features = qvirtio_get_features(vdev);
|
||||||
features &= ~(QVIRTIO_F_BAD_FEATURE |
|
features &= ~(QVIRTIO_F_BAD_FEATURE |
|
||||||
|
@ -42,8 +47,16 @@ static void virtio_net_setup(QVirtioNet *interface)
|
||||||
(1u << VIRTIO_RING_F_EVENT_IDX));
|
(1u << VIRTIO_RING_F_EVENT_IDX));
|
||||||
qvirtio_set_features(vdev, features);
|
qvirtio_set_features(vdev, features);
|
||||||
|
|
||||||
interface->rx = qvirtqueue_setup(vdev, alloc, 0);
|
if (features & (1u << VIRTIO_NET_F_MQ)) {
|
||||||
interface->tx = qvirtqueue_setup(vdev, alloc, 1);
|
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);
|
qvirtio_set_driver_ok(vdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,8 @@ typedef struct QVirtioNetDevice QVirtioNetDevice;
|
||||||
|
|
||||||
struct QVirtioNet {
|
struct QVirtioNet {
|
||||||
QVirtioDevice *vdev;
|
QVirtioDevice *vdev;
|
||||||
QVirtQueue *rx;
|
int n_queues;
|
||||||
QVirtQueue *tx;
|
QVirtQueue **queues;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct QVirtioNetPCI {
|
struct QVirtioNetPCI {
|
||||||
|
|
|
@ -136,8 +136,8 @@ static void send_recv_test(void *obj, void *data, QGuestAllocator *t_alloc)
|
||||||
{
|
{
|
||||||
QVirtioNet *net_if = obj;
|
QVirtioNet *net_if = obj;
|
||||||
QVirtioDevice *dev = net_if->vdev;
|
QVirtioDevice *dev = net_if->vdev;
|
||||||
QVirtQueue *rx = net_if->rx;
|
QVirtQueue *rx = net_if->queues[0];
|
||||||
QVirtQueue *tx = net_if->tx;
|
QVirtQueue *tx = net_if->queues[1];
|
||||||
int *sv = data;
|
int *sv = data;
|
||||||
|
|
||||||
rx_test(dev, t_alloc, rx, sv[0]);
|
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;
|
QVirtioNet *net_if = obj;
|
||||||
QVirtioDevice *dev = net_if->vdev;
|
QVirtioDevice *dev = net_if->vdev;
|
||||||
QVirtQueue *rx = net_if->rx;
|
QVirtQueue *rx = net_if->queues[0];
|
||||||
int *sv = data;
|
int *sv = data;
|
||||||
|
|
||||||
rx_stop_cont_test(dev, t_alloc, rx, sv[0]);
|
rx_stop_cont_test(dev, t_alloc, rx, sv[0]);
|
||||||
|
|
Loading…
Reference in New Issue