[dpdk-dev,v2,2/3] virtio: allow nb_desc < vq_size
Commit Message
When running on GCE vq_size is 16K but number of Rx descriptors
desired maybe less than that. Handle the situtaiton by initializing
full ring but only filling the smaller number.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/virtio/virtio_ethdev.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
@@ -286,10 +286,6 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,
return -EINVAL;
}
- if (nb_desc != vq_size)
- PMD_INIT_LOG(ERR, "Warning: nb_desc(%d) is not equal to vq size (%d), fall to vq size",
- nb_desc, vq_size);
-
if (queue_type == VTNET_RQ) {
snprintf(vq_name, sizeof(vq_name), "port%d_rvq%d",
dev->data->port_id, queue_idx);
@@ -317,7 +313,10 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,
vq->queue_id = queue_idx;
vq->vq_queue_index = vtpci_queue_idx;
vq->vq_nentries = vq_size;
- vq->vq_free_cnt = vq_size;
+
+ if (nb_desc == 0 || nb_desc > vq_size)
+ nb_desc = vq_size;
+ vq->vq_free_cnt = nb_desc;
/*
* Reserve a memzone for vring elements