All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] virtio-net: fix max vring buf size when set ring num
@ 2022-09-19  9:39 liuhaiwei
  2022-09-19  9:39 ` [PATCH 2/3] virtio-net: update the default and max of rx/tx_queue_size liuhaiwei
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: liuhaiwei @ 2022-09-19  9:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, jasowang, liuhaiwei

Signed-off-by: liuhaiwei <liuhaiwei9699@126.com>
---
 hw/virtio/virtio.c         | 10 +++++++---
 include/hw/virtio/virtio.h |  1 +
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 5d607aeaa0..d93c20d747 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -2286,13 +2286,17 @@ void virtio_queue_set_rings(VirtIODevice *vdev, int n, hwaddr desc,
 
 void virtio_queue_set_num(VirtIODevice *vdev, int n, int num)
 {
+    int vq_max_size = VIRTQUEUE_MAX_SIZE;
+    if (!strcmp(vdev->name, "virtio-net")) {
+        vq_max_size = VIRTIO_NET_VQ_MAX_SIZE;
+    }
+
     /* Don't allow guest to flip queue between existent and
      * nonexistent states, or to set it to an invalid size.
      */
     if (!!num != !!vdev->vq[n].vring.num ||
-        num > VIRTQUEUE_MAX_SIZE ||
-        num < 0) {
-        return;
+        num > vq_max_size || num < 0) {
+	    return;
     }
     vdev->vq[n].vring.num = num;
 }
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index db1c0ddf6b..1f4d2eb5d7 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -50,6 +50,7 @@ size_t virtio_feature_get_config_size(const VirtIOFeature *features,
 typedef struct VirtQueue VirtQueue;
 
 #define VIRTQUEUE_MAX_SIZE 1024
+#define VIRTIO_NET_VQ_MAX_SIZE (4096)
 
 typedef struct VirtQueueElement
 {
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-09-19 10:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-19  9:39 [PATCH 1/3] virtio-net: fix max vring buf size when set ring num liuhaiwei
2022-09-19  9:39 ` [PATCH 2/3] virtio-net: update the default and max of rx/tx_queue_size liuhaiwei
2022-09-19 10:22   ` Michael S. Tsirkin
2022-09-19  9:39 ` [PATCH 3/3] virtio-net: set the max of queue size to 4096 liuhaiwei
2022-09-19 10:23   ` Michael S. Tsirkin
2022-09-19 10:21 ` [PATCH 1/3] virtio-net: fix max vring buf size when set ring num Michael S. Tsirkin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.