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

Function new_device

dpdk/examples/vhost_blk/vhost_blk.c:592–690  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

590}
591
592static int
593new_device(int vid)
594{
595 struct vhost_blk_ctrlr *ctrlr;
596 struct vhost_blk_queue *vq;
597 char path[PATH_MAX];
598 uint64_t features, protocol_features;
599 rte_thread_t tid;
600 int i, ret;
601 bool packed_ring, inflight_shmfd;
602
603 ret = rte_vhost_get_ifname(vid, path, PATH_MAX);
604 if (ret) {
605 fprintf(stderr, "Failed to get the socket path\n");
606 return -1;
607 }
608
609 ctrlr = vhost_blk_ctrlr_find(path);
610 if (!ctrlr) {
611 fprintf(stderr, "Failed to find controller\n");
612 return -1;
613 }
614
615 if (ctrlr->started)
616 return 0;
617
618 ctrlr->vid = vid;
619 ret = rte_vhost_get_negotiated_features(vid, &features);
620 if (ret) {
621 fprintf(stderr, "Failed to get the negotiated features\n");
622 return -1;
623 }
624 packed_ring = !!(features & (1ULL << VIRTIO_F_RING_PACKED));
625
626 ret = rte_vhost_get_negotiated_protocol_features(
627 vid, &protocol_features);
628 if (ret) {
629 fprintf(stderr,
630 "Failed to get the negotiated protocol features\n");
631 return -1;
632 }
633 inflight_shmfd = !!(features &
634 (1ULL << VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD));
635
636 /* Disable Notifications and init last idx */
637 for (i = 0; i < NUM_OF_BLK_QUEUES; i++) {
638 vq = &ctrlr->queues[i];
639 vq->id = i;
640
641 assert(rte_vhost_get_vhost_vring(ctrlr->vid, i,
642 &vq->vring) == 0);
643 assert(rte_vhost_get_vring_base(ctrlr->vid, i,
644 &vq->last_avail_idx,
645 &vq->last_used_idx) == 0);
646
647 if (inflight_shmfd)
648 assert(rte_vhost_get_vhost_ring_inflight(
649 ctrlr->vid, i,

Callers

nothing calls this directly

Tested by

no test coverage detected