net->dev.nvqs = options->nvqs;
net->feature_bits = options->feature_bits;
net->save_acked_features = options->save_acked_features;
+ net->max_tx_queue_size = options->max_tx_queue_size;
net->dev.max_queues = 1;
net->dev.vqs = net->vqs;
static int virtio_net_max_tx_queue_size(VirtIONet *n)
{
NetClientState *peer = n->nic_conf.peers.ncs[0];
+ struct vhost_net *net;
- /*
- * Backends other than vhost-user or vhost-vdpa don't support max queue
- * size.
- */
if (!peer) {
- return VIRTIO_NET_TX_QUEUE_DEFAULT_SIZE;
+ goto default_value;
}
- switch(peer->info->type) {
- case NET_CLIENT_DRIVER_VHOST_USER:
- case NET_CLIENT_DRIVER_VHOST_VDPA:
- return VIRTQUEUE_MAX_SIZE;
- default:
- return VIRTIO_NET_TX_QUEUE_DEFAULT_SIZE;
- };
+ net = get_vhost_net(peer);
+
+ if (!net || !net->max_tx_queue_size) {
+ goto default_value;
+ }
+
+ return net->max_tx_queue_size;
+
+default_value:
+ return VIRTIO_NET_TX_QUEUE_DEFAULT_SIZE;
}
static int peer_attach(VirtIONet *n, int index)
struct vhost_virtqueue vqs[2];
int backend;
const int *feature_bits;
+ int max_tx_queue_size;
SaveAcketFeatures *save_acked_features;
NetClientState *nc;
};
uint32_t busyloop_timeout;
unsigned int nvqs;
const int *feature_bits;
+ int max_tx_queue_size;
GetAckedFeatures *get_acked_features;
SaveAcketFeatures *save_acked_features;
void *opaque;
options.feature_bits = kernel_feature_bits;
options.get_acked_features = NULL;
options.save_acked_features = NULL;
+ options.max_tx_queue_size = 0;
s->vhost_net = vhost_net_init(&options);
if (!s->vhost_net) {
options.busyloop_timeout = 0;
options.nvqs = 2;
options.feature_bits = user_feature_bits;
+ options.max_tx_queue_size = VIRTQUEUE_MAX_SIZE;
options.get_acked_features = vhost_user_get_acked_features;
options.save_acked_features = vhost_user_save_acked_features;
options.feature_bits = vdpa_feature_bits;
options.get_acked_features = NULL;
options.save_acked_features = NULL;
+ options.max_tx_queue_size = VIRTQUEUE_MAX_SIZE;
net = vhost_net_init(&options);
if (!net) {