[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 17/18] virtio-net: vhost control virtqueue support
From: |
Jason Wang |
Subject: |
[PATCH 17/18] virtio-net: vhost control virtqueue support |
Date: |
Mon, 21 Jun 2021 12:16:49 +0800 |
This patch implements the control virtqueue support for vhost. This
requires virtio-net to figure out the datapath queue pairs and control
virtqueue via is_datapath and pass the number of those two types
of virtqueues to vhost_net_start()/vhost_net_stop().
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
hw/net/virtio-net.c | 20 +++++++++++++++++---
include/hw/virtio/virtio-net.h | 1 +
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 36bd197087..5074b521cf 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -244,6 +244,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t
status)
VirtIODevice *vdev = VIRTIO_DEVICE(n);
NetClientState *nc = qemu_get_queue(n->nic);
int qps = n->multiqueue ? n->max_qps : 1;
+ int cvq = n->max_ncs - n->max_qps;
if (!get_vhost_net(nc->peer)) {
return;
@@ -285,14 +286,14 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t
status)
}
n->vhost_started = 1;
- r = vhost_net_start(vdev, n->nic->ncs, qps, 0);
+ r = vhost_net_start(vdev, n->nic->ncs, qps, cvq);
if (r < 0) {
error_report("unable to start vhost net: %d: "
"falling back on userspace virtio", -r);
n->vhost_started = 0;
}
} else {
- vhost_net_stop(vdev, n->nic->ncs, qps, 0);
+ vhost_net_stop(vdev, n->nic->ncs, qps, cvq);
n->vhost_started = 0;
}
}
@@ -3367,7 +3368,20 @@ static void virtio_net_device_realize(DeviceState *dev,
Error **errp)
return;
}
- n->max_qps = MAX(n->nic_conf.peers.queues, 1);
+ n->max_ncs = MAX(n->nic_conf.peers.queues, 1);
+
+ /* Figure out the datapath queue pairs since the bakcend could
+ * provide control queue via peers as well.
+ */
+ if (n->nic_conf.peers.queues) {
+ for (i = 0; i < n->max_ncs; i++) {
+ if (n->nic_conf.peers.ncs[i]->is_datapath) {
+ ++n->max_qps;
+ }
+ }
+ }
+ n->max_qps = MAX(n->max_qps, 1);
+
if (n->max_qps * 2 + 1 > VIRTIO_QUEUE_MAX) {
error_setg(errp, "Invalid number of qps (= %" PRIu32 "), "
"must be a positive integer less than %d.",
diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
index a9b6dc252e..ed4659c189 100644
--- a/include/hw/virtio/virtio-net.h
+++ b/include/hw/virtio/virtio-net.h
@@ -194,6 +194,7 @@ struct VirtIONet {
NICConf nic_conf;
DeviceState *qdev;
int multiqueue;
+ uint16_t max_ncs;
uint16_t max_qps;
uint16_t curr_qps;
size_t config_size;
--
2.25.1
- [PATCH 07/18] vhost-vdpa: tweak the error label in vhost_vdpa_add(), (continued)
- [PATCH 07/18] vhost-vdpa: tweak the error label in vhost_vdpa_add(), Jason Wang, 2021/06/21
- [PATCH 08/18] vhost-vdpa: fix the wrong assertion in vhost_vdpa_init(), Jason Wang, 2021/06/21
- [PATCH 09/18] vhost-vdpa: remove the unncessary queue_index assignment, Jason Wang, 2021/06/21
- [PATCH 10/18] vhost-vdpa: open device fd in net_init_vhost_vdpa(), Jason Wang, 2021/06/21
- [PATCH 11/18] vhost-vdpa: classify one time request, Jason Wang, 2021/06/21
- [PATCH 12/18] vhost-vdpa: prepare for the multiqueue support, Jason Wang, 2021/06/21
- [PATCH 13/18] vhost-vdpa: let net_vhost_vdpa_init() returns NetClientState *, Jason Wang, 2021/06/21
- [PATCH 14/18] net: introduce control client, Jason Wang, 2021/06/21
- [PATCH 15/18] vhost-net: control virtqueue support, Jason Wang, 2021/06/21
- [PATCH 16/18] virito-net: use "qps" instead of "queues" when possible, Jason Wang, 2021/06/21
- [PATCH 17/18] virtio-net: vhost control virtqueue support,
Jason Wang <=
- [PATCH 18/18] vhost-vdpa: multiqueue support, Jason Wang, 2021/06/21
- Re: [PATCH 00/18] vhost-vDPA multiqueue, no-reply, 2021/06/21