[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 29/35] vhost_net: do not assume nvqs is always 2
From: |
Michael S. Tsirkin |
Subject: |
[PULL 29/35] vhost_net: do not assume nvqs is always 2 |
Date: |
Sat, 4 Sep 2021 17:37:22 -0400 |
From: Jason Wang <jasowang@redhat.com>
This patch switches to initialize dev.nvqs from the VhostNetOptions
instead of assuming it was 2. This is useful for implementing control
virtqueue support which will be a single vhost_net structure with a
single cvq.
Note that nvqs is still set to 2 for all users and this patch does not
change functionality.
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Eli Cohen <elic@nvidia.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Message-Id: <20210903091031.47303-6-jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/net/vhost_net.h | 1 +
hw/net/vhost_net.c | 2 +-
net/tap.c | 1 +
net/vhost-user.c | 1 +
net/vhost-vdpa.c | 1 +
5 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h
index 172b0051d8..fba40cf695 100644
--- a/include/net/vhost_net.h
+++ b/include/net/vhost_net.h
@@ -14,6 +14,7 @@ typedef struct VhostNetOptions {
VhostBackendType backend_type;
NetClientState *net_backend;
uint32_t busyloop_timeout;
+ unsigned int nvqs;
void *opaque;
} VhostNetOptions;
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 6ed0c39836..386ec2eaa2 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -165,9 +165,9 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
goto fail;
}
net->nc = options->net_backend;
+ net->dev.nvqs = options->nvqs;
net->dev.max_queues = 1;
- net->dev.nvqs = 2;
net->dev.vqs = net->vqs;
if (backend_kernel) {
diff --git a/net/tap.c b/net/tap.c
index f5686bbf77..f716be3e3f 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -749,6 +749,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap,
NetClientState *peer,
qemu_set_nonblock(vhostfd);
}
options.opaque = (void *)(uintptr_t)vhostfd;
+ options.nvqs = 2;
s->vhost_net = vhost_net_init(&options);
if (!s->vhost_net) {
diff --git a/net/vhost-user.c b/net/vhost-user.c
index 6adfcd623a..4a939124d2 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -85,6 +85,7 @@ static int vhost_user_start(int queues, NetClientState *ncs[],
options.net_backend = ncs[i];
options.opaque = be;
options.busyloop_timeout = 0;
+ options.nvqs = 2;
net = vhost_net_init(&options);
if (!net) {
error_report("failed to init vhost_net for queue %d", i);
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index 72829884d7..395117debd 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -104,6 +104,7 @@ static int vhost_vdpa_add(NetClientState *ncs, void *be)
options.net_backend = ncs;
options.opaque = be;
options.busyloop_timeout = 0;
+ options.nvqs = 2;
net = vhost_net_init(&options);
if (!net) {
--
MST
- [PULL 21/35] hw/virtio: Remove NULL check in virtio_free_region_cache(), (continued)
- [PULL 21/35] hw/virtio: Remove NULL check in virtio_free_region_cache(), Michael S. Tsirkin, 2021/09/04
- [PULL 19/35] MAINTAINERS: Added myself as a reviewer for acpi/smbios subsystem, Michael S. Tsirkin, 2021/09/04
- [PULL 18/35] hw/acpi: use existing references to pci device struct within functions, Michael S. Tsirkin, 2021/09/04
- [PULL 22/35] hw/virtio: Add flatview update in vhost_user_cleanup(), Michael S. Tsirkin, 2021/09/04
- [PULL 23/35] tests/vhost-user-bridge.c: Sanity check socket path length, Michael S. Tsirkin, 2021/09/04
- [PULL 24/35] tests/vhost-user-bridge.c: Fix typo in help message, Michael S. Tsirkin, 2021/09/04
- [PULL 25/35] vhost-vdpa: remove unused variable "acked_features", Michael S. Tsirkin, 2021/09/04
- [PULL 26/35] vhost-vdpa: correctly return err in vhost_vdpa_set_backend_cap(), Michael S. Tsirkin, 2021/09/04
- [PULL 27/35] vhost_net: remove the meaningless assignment in vhost_net_start_one(), Michael S. Tsirkin, 2021/09/04
- [PULL 28/35] vhost: use unsigned int for nvqs, Michael S. Tsirkin, 2021/09/04
- [PULL 29/35] vhost_net: do not assume nvqs is always 2,
Michael S. Tsirkin <=
- [PULL 30/35] vhost-vdpa: remove the unnecessary check in vhost_vdpa_add(), Michael S. Tsirkin, 2021/09/04
- [PULL 31/35] vhost-vdpa: don't cleanup twice in vhost_vdpa_add(), Michael S. Tsirkin, 2021/09/04
- [PULL 33/35] vhost-vdpa: tweak the error label in vhost_vdpa_add(), Michael S. Tsirkin, 2021/09/04
- [PULL 34/35] vhost-vdpa: fix the wrong assertion in vhost_vdpa_init(), Michael S. Tsirkin, 2021/09/04
- [PULL 35/35] vhost-vdpa: remove the unncessary queue_index assignment, Michael S. Tsirkin, 2021/09/04
- [PULL 08/35] vhost-user: add missing space in error message, Michael S. Tsirkin, 2021/09/04
- [PULL 15/35] vhost: correctly detect the enabling IOMMU, Michael S. Tsirkin, 2021/09/04
- [PULL 32/35] vhost-vdpa: fix leaking of vhost_net in vhost_vdpa_add(), Michael S. Tsirkin, 2021/09/04
- Re: [PULL 00/35] pc,pci,virtio: fixes, cleanups, Peter Maydell, 2021/09/06