MCPcopy Create free account
hub / github.com/F-Stack/f-stack / alloc_vring_queue

Function alloc_vring_queue

dpdk/lib/vhost/vhost.c:630–661  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

628}
629
630int
631alloc_vring_queue(struct virtio_net *dev, uint32_t vring_idx)
632{
633 struct vhost_virtqueue *vq;
634 uint32_t i;
635
636 /* Also allocate holes, if any, up to requested vring index. */
637 for (i = 0; i <= vring_idx; i++) {
638 if (dev->virtqueue[i])
639 continue;
640
641 vq = rte_zmalloc(NULL, sizeof(struct vhost_virtqueue), 0);
642 if (vq == NULL) {
643 VHOST_LOG_CONFIG(dev->ifname, ERR,
644 "failed to allocate memory for vring %u.\n",
645 i);
646 return -1;
647 }
648
649 dev->virtqueue[i] = vq;
650 init_vring_queue(dev, vq, i);
651 rte_rwlock_init(&vq->access_lock);
652 rte_rwlock_init(&vq->iotlb_lock);
653 vq->avail_wrap_counter = 1;
654 vq->used_wrap_counter = 1;
655 vq->signalled_used_valid = false;
656 }
657
658 dev->nr_vring = RTE_MAX(dev->nr_vring, vring_idx + 1);
659
660 return 0;
661}
662
663/*
664 * Reset some variables in device structure, while keeping few

Callers 2

vduse_device_createFunction · 0.85

Calls 3

rte_zmallocFunction · 0.85
init_vring_queueFunction · 0.85
rte_rwlock_initFunction · 0.85

Tested by

no test coverage detected