From: Laurent Vivier <lvivier@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Stefan Weil" <sw@weilnetz.de>,
"Stefano Garzarella" <sgarzare@redhat.com>,
"Jason Wang" <jasowang@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Dr. David Alan Gilbert" <dave@treblig.org>,
"Eric Blake" <eblake@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Laurent Vivier" <lvivier@redhat.com>
Subject: [PATCH v2 08/10] net: Allow network backends to advertise max TX queue size
Date: Wed, 18 Jun 2025 17:57:16 +0200 [thread overview]
Message-ID: <20250618155718.550968-9-lvivier@redhat.com> (raw)
In-Reply-To: <20250618155718.550968-1-lvivier@redhat.com>
This commit refactors how the maximum transmit queue size for
virtio-net devices is determined, making the mechanism more generic
and extensible.
Previously, virtio_net_max_tx_queue_size() contained hardcoded
checks for specific network backend types (vhost-user and
vhost-vdpa) to determine their supported maximum queue size. This
created direct dependencies and would require modifications for
every new backend that supports variable queue sizes.
To improve flexibility, a new max_tx_queue_size field is added
to the NetClientInfo structure. This allows each network backend
to advertise its supported maximum transmit queue size directly.
This change centralizes the configuration of transmit queue sizes,
simplifying the virtio-net driver and making it easier to integrate
new network backends with diverse queue size capabilities.
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
hw/net/virtio-net.c | 16 ++--------------
include/net/net.h | 1 +
net/vhost-user.c | 1 +
net/vhost-vdpa.c | 2 ++
4 files changed, 6 insertions(+), 14 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 1367d2b581b1..2468621375e9 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -671,23 +671,11 @@ static int virtio_net_max_tx_queue_size(VirtIONet *n)
{
NetClientState *peer = n->nic_conf.peers.ncs[0];
- /*
- * Backends other than vhost-user or vhost-vdpa don't support max queue
- * size.
- */
- if (!peer) {
+ if (!peer || !peer->info->max_tx_queue_size) {
return VIRTIO_NET_TX_QUEUE_DEFAULT_SIZE;
}
- if (qemu_is_vhost_user(peer)) {
- return VIRTQUEUE_MAX_SIZE;
- }
-
- if (peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) {
- return VIRTQUEUE_MAX_SIZE;
- }
-
- return VIRTIO_NET_TX_QUEUE_DEFAULT_SIZE;
+ return peer->info->max_tx_queue_size;
}
static int peer_attach(VirtIONet *n, int index)
diff --git a/include/net/net.h b/include/net/net.h
index 179ffee5bd11..25dd29e07d7f 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -101,6 +101,7 @@ typedef struct NetClientInfo {
GetVHostNet *get_vhost_net;
GetAckedFeatures *get_acked_features;
SaveAcketFeatures *save_acked_features;
+ int max_tx_queue_size;
} NetClientInfo;
struct NetClientState {
diff --git a/net/vhost-user.c b/net/vhost-user.c
index 15609faedb88..89d216714c13 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -284,6 +284,7 @@ static NetClientInfo net_vhost_user_info = {
.vhost_feature_bits = user_feature_bits,
.get_acked_features = vhost_user_get_acked_features,
.save_acked_features = vhost_user_save_acked_features,
+ .max_tx_queue_size = VIRTQUEUE_MAX_SIZE,
};
static gboolean net_vhost_user_watch(void *do_not_use, GIOCondition cond,
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index bd699066a3ab..4fc5d381ceef 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -434,6 +434,7 @@ static NetClientInfo net_vhost_vdpa_info = {
.set_steering_ebpf = vhost_vdpa_set_steering_ebpf,
.get_vhost_net = vhost_vdpa_get_vhost_net,
.vhost_feature_bits = vdpa_feature_bits,
+ .max_tx_queue_size = VIRTQUEUE_MAX_SIZE,
};
static int64_t vhost_vdpa_get_vring_group(int device_fd, unsigned vq_index,
@@ -1291,6 +1292,7 @@ static NetClientInfo net_vhost_vdpa_cvq_info = {
.set_steering_ebpf = vhost_vdpa_set_steering_ebpf,
.get_vhost_net = vhost_vdpa_get_vhost_net,
.vhost_feature_bits = vdpa_feature_bits,
+ .max_tx_queue_size = VIRTQUEUE_MAX_SIZE,
};
/*
--
2.49.0
next prev parent reply other threads:[~2025-06-18 16:00 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-18 15:57 [PATCH v2 00/10] net: Add passt netdev backend Laurent Vivier
2025-06-18 15:57 ` [PATCH v2 01/10] net: Refactor stream logic for reuse in '-net passt' Laurent Vivier
2025-06-18 15:57 ` [PATCH v2 02/10] net: Define net_client_set_link() Laurent Vivier
2025-06-18 15:57 ` [PATCH v2 03/10] net: Introduce helper to identify vhost-user clients Laurent Vivier
2025-07-01 1:36 ` Jason Wang
2025-06-18 15:57 ` [PATCH v2 04/10] net: Add get_vhost_net callback to NetClientInfo Laurent Vivier
2025-06-18 15:57 ` [PATCH v2 05/10] net: Consolidate vhost feature bits into NetClientInfo Laurent Vivier
2025-07-01 1:39 ` Jason Wang
2025-06-18 15:57 ` [PATCH v2 06/10] net: Add get_acked_features callback to NetClientInfo Laurent Vivier
2025-06-18 15:57 ` [PATCH v2 07/10] net: Add save_acked_features " Laurent Vivier
2025-06-18 15:57 ` Laurent Vivier [this message]
2025-06-18 15:57 ` [PATCH v2 09/10] net: Add passt network backend Laurent Vivier
2025-06-24 8:16 ` Markus Armbruster
2025-06-24 8:37 ` Laurent Vivier
2025-06-24 11:55 ` Markus Armbruster
2025-06-24 12:03 ` Daniel P. Berrangé
2025-06-24 12:47 ` Laurent Vivier
2025-06-25 6:57 ` Markus Armbruster
2025-06-30 14:22 ` Stefano Brivio
2025-07-01 1:46 ` Jason Wang
2025-07-01 13:00 ` Laurent Vivier
2025-07-03 10:27 ` Stefano Brivio
2025-06-18 15:57 ` [PATCH v2 10/10] net/passt: Implement vhost-user backend support Laurent Vivier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250618155718.550968-9-lvivier@redhat.com \
--to=lvivier@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=dave@treblig.org \
--cc=eblake@redhat.com \
--cc=jasowang@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=sgarzare@redhat.com \
--cc=sw@weilnetz.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).