| 628 | } |
| 629 | |
| 630 | int |
| 631 | alloc_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 |
no test coverage detected