Lines Matching refs:dev
32 __vhost_iova_to_vva(struct virtio_net *dev, struct vhost_virtqueue *vq, in __vhost_iova_to_vva() argument
59 if (vhost_user_iotlb_miss(dev, iova, perm)) { in __vhost_iova_to_vva()
98 __vhost_log_write(struct virtio_net *dev, uint64_t addr, uint64_t len) in __vhost_log_write() argument
102 if (unlikely(!dev->log_base || !len)) in __vhost_log_write()
105 if (unlikely(dev->log_size <= ((addr + len - 1) / VHOST_LOG_PAGE / 8))) in __vhost_log_write()
113 vhost_log_page((uint8_t *)(uintptr_t)dev->log_base, page); in __vhost_log_write()
119 __vhost_log_write_iova(struct virtio_net *dev, struct vhost_virtqueue *vq, in __vhost_log_write_iova() argument
125 hva = __vhost_iova_to_vva(dev, vq, iova, &map_len, VHOST_ACCESS_RW); in __vhost_log_write_iova()
133 gpa = hva_to_gpa(dev, hva, len); in __vhost_log_write_iova()
135 __vhost_log_write(dev, gpa, len); in __vhost_log_write_iova()
139 __vhost_log_cache_sync(struct virtio_net *dev, struct vhost_virtqueue *vq) in __vhost_log_cache_sync() argument
144 if (unlikely(!dev->log_base)) in __vhost_log_cache_sync()
149 log_base = (unsigned long *)(uintptr_t)dev->log_base; in __vhost_log_cache_sync()
172 vhost_log_cache_page(struct virtio_net *dev, struct vhost_virtqueue *vq, in vhost_log_cache_page() argument
194 vhost_log_page((uint8_t *)(uintptr_t)dev->log_base, page); in vhost_log_cache_page()
205 __vhost_log_cache_write(struct virtio_net *dev, struct vhost_virtqueue *vq, in __vhost_log_cache_write() argument
210 if (unlikely(!dev->log_base || !len)) in __vhost_log_cache_write()
213 if (unlikely(dev->log_size <= ((addr + len - 1) / VHOST_LOG_PAGE / 8))) in __vhost_log_cache_write()
218 vhost_log_cache_page(dev, vq, page); in __vhost_log_cache_write()
224 __vhost_log_cache_write_iova(struct virtio_net *dev, struct vhost_virtqueue *vq, in __vhost_log_cache_write_iova() argument
230 hva = __vhost_iova_to_vva(dev, vq, iova, &map_len, VHOST_ACCESS_RW); in __vhost_log_cache_write_iova()
238 gpa = hva_to_gpa(dev, hva, len); in __vhost_log_cache_write_iova()
240 __vhost_log_cache_write(dev, vq, gpa, len); in __vhost_log_cache_write_iova()
244 vhost_alloc_copy_ind_table(struct virtio_net *dev, struct vhost_virtqueue *vq, in vhost_alloc_copy_ind_table() argument
259 src = vhost_iova_to_vva(dev, vq, desc_addr, &len, in vhost_alloc_copy_ind_table()
286 cleanup_vq_inflight(struct virtio_net *dev, struct vhost_virtqueue *vq) in cleanup_vq_inflight() argument
288 if (!(dev->protocol_features & in cleanup_vq_inflight()
292 if (vq_is_packed(dev)) { in cleanup_vq_inflight()
315 cleanup_device(struct virtio_net *dev, int destroy) in cleanup_device() argument
319 vhost_backend_cleanup(dev); in cleanup_device()
321 for (i = 0; i < dev->nr_vring; i++) { in cleanup_device()
322 cleanup_vq(dev->virtqueue[i], destroy); in cleanup_device()
323 cleanup_vq_inflight(dev, dev->virtqueue[i]); in cleanup_device()
346 free_vq(struct virtio_net *dev, struct vhost_virtqueue *vq) in free_vq() argument
348 if (vq_is_packed(dev)) in free_vq()
363 free_device(struct virtio_net *dev) in free_device() argument
367 for (i = 0; i < dev->nr_vring; i++) in free_device()
368 free_vq(dev, dev->virtqueue[i]); in free_device()
370 rte_free(dev); in free_device()
374 log_translate(struct virtio_net *dev, struct vhost_virtqueue *vq) in log_translate() argument
379 vq->log_guest_addr = translate_log_addr(dev, vq, in log_translate()
395 translate_log_addr(struct virtio_net *dev, struct vhost_virtqueue *vq, in translate_log_addr() argument
398 if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)) { in translate_log_addr()
403 hva = vhost_iova_to_vva(dev, vq, log_addr, in translate_log_addr()
409 gpa = hva_to_gpa(dev, hva, exp_size); in translate_log_addr()
425 vring_translate_split(struct virtio_net *dev, struct vhost_virtqueue *vq) in vring_translate_split() argument
431 vq->desc = (struct vring_desc *)(uintptr_t)vhost_iova_to_vva(dev, vq, in vring_translate_split()
439 if (dev->features & (1ULL << VIRTIO_RING_F_EVENT_IDX)) in vring_translate_split()
442 vq->avail = (struct vring_avail *)(uintptr_t)vhost_iova_to_vva(dev, vq, in vring_translate_split()
450 if (dev->features & (1ULL << VIRTIO_RING_F_EVENT_IDX)) in vring_translate_split()
453 vq->used = (struct vring_used *)(uintptr_t)vhost_iova_to_vva(dev, vq, in vring_translate_split()
464 vring_translate_packed(struct virtio_net *dev, struct vhost_virtqueue *vq) in vring_translate_packed() argument
471 vhost_iova_to_vva(dev, vq, vq->ring_addrs.desc_user_addr, in vring_translate_packed()
479 vhost_iova_to_vva(dev, vq, vq->ring_addrs.avail_user_addr, in vring_translate_packed()
487 vhost_iova_to_vva(dev, vq, vq->ring_addrs.used_user_addr, in vring_translate_packed()
496 vring_translate(struct virtio_net *dev, struct vhost_virtqueue *vq) in vring_translate() argument
499 if (!(dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM))) in vring_translate()
502 if (vq_is_packed(dev)) { in vring_translate()
503 if (vring_translate_packed(dev, vq) < 0) in vring_translate()
506 if (vring_translate_split(dev, vq) < 0) in vring_translate()
510 if (log_translate(dev, vq) < 0) in vring_translate()
519 vring_invalidate(struct virtio_net *dev, struct vhost_virtqueue *vq) in vring_invalidate() argument
521 if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)) in vring_invalidate()
530 if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)) in vring_invalidate()
535 init_vring_queue(struct virtio_net *dev, uint32_t vring_idx) in init_vring_queue() argument
546 vq = dev->virtqueue[vring_idx]; in init_vring_queue()
559 vhost_user_iotlb_init(dev, vring_idx); in init_vring_queue()
565 reset_vring_queue(struct virtio_net *dev, uint32_t vring_idx) in reset_vring_queue() argument
577 vq = dev->virtqueue[vring_idx]; in reset_vring_queue()
585 init_vring_queue(dev, vring_idx); in reset_vring_queue()
590 alloc_vring_queue(struct virtio_net *dev, uint32_t vring_idx) in alloc_vring_queue() argument
597 if (dev->virtqueue[i]) in alloc_vring_queue()
607 dev->virtqueue[i] = vq; in alloc_vring_queue()
608 init_vring_queue(dev, i); in alloc_vring_queue()
615 dev->nr_vring = RTE_MAX(dev->nr_vring, vring_idx + 1); in alloc_vring_queue()
626 reset_device(struct virtio_net *dev) in reset_device() argument
630 dev->features = 0; in reset_device()
631 dev->protocol_features = 0; in reset_device()
632 dev->flags &= VIRTIO_DEV_BUILTIN_VIRTIO_NET; in reset_device()
634 for (i = 0; i < dev->nr_vring; i++) in reset_device()
635 reset_vring_queue(dev, i); in reset_device()
645 struct virtio_net *dev; in vhost_new_device() local
659 dev = rte_zmalloc(NULL, sizeof(struct virtio_net), 0); in vhost_new_device()
660 if (dev == NULL) { in vhost_new_device()
666 vhost_devices[i] = dev; in vhost_new_device()
667 dev->vid = i; in vhost_new_device()
668 dev->flags = VIRTIO_DEV_BUILTIN_VIRTIO_NET; in vhost_new_device()
669 dev->slave_req_fd = -1; in vhost_new_device()
670 dev->postcopy_ufd = -1; in vhost_new_device()
671 rte_spinlock_init(&dev->slave_req_lock); in vhost_new_device()
677 vhost_destroy_device_notify(struct virtio_net *dev) in vhost_destroy_device_notify() argument
681 if (dev->flags & VIRTIO_DEV_RUNNING) { in vhost_destroy_device_notify()
682 vdpa_dev = dev->vdpa_dev; in vhost_destroy_device_notify()
684 vdpa_dev->ops->dev_close(dev->vid); in vhost_destroy_device_notify()
685 dev->flags &= ~VIRTIO_DEV_RUNNING; in vhost_destroy_device_notify()
686 dev->notify_ops->destroy_device(dev->vid); in vhost_destroy_device_notify()
697 struct virtio_net *dev = get_device(vid); in vhost_destroy_device() local
699 if (dev == NULL) in vhost_destroy_device()
702 vhost_destroy_device_notify(dev); in vhost_destroy_device()
704 cleanup_device(dev, 1); in vhost_destroy_device()
705 free_device(dev); in vhost_destroy_device()
713 struct virtio_net *dev = get_device(vid); in vhost_attach_vdpa_device() local
715 if (dev == NULL) in vhost_attach_vdpa_device()
718 dev->vdpa_dev = vdpa_dev; in vhost_attach_vdpa_device()
724 struct virtio_net *dev; in vhost_set_ifname() local
727 dev = get_device(vid); in vhost_set_ifname()
728 if (dev == NULL) in vhost_set_ifname()
731 len = if_len > sizeof(dev->ifname) ? in vhost_set_ifname()
732 sizeof(dev->ifname) : if_len; in vhost_set_ifname()
734 strncpy(dev->ifname, if_name, len); in vhost_set_ifname()
735 dev->ifname[sizeof(dev->ifname) - 1] = '\0'; in vhost_set_ifname()
741 struct virtio_net *dev = get_device(vid); in vhost_set_builtin_virtio_net() local
743 if (dev == NULL) in vhost_set_builtin_virtio_net()
747 dev->flags |= VIRTIO_DEV_BUILTIN_VIRTIO_NET; in vhost_set_builtin_virtio_net()
749 dev->flags &= ~VIRTIO_DEV_BUILTIN_VIRTIO_NET; in vhost_set_builtin_virtio_net()
755 struct virtio_net *dev = get_device(vid); in vhost_enable_extbuf() local
757 if (dev == NULL) in vhost_enable_extbuf()
760 dev->extbuf = 1; in vhost_enable_extbuf()
766 struct virtio_net *dev = get_device(vid); in vhost_enable_linearbuf() local
768 if (dev == NULL) in vhost_enable_linearbuf()
771 dev->linearbuf = 1; in vhost_enable_linearbuf()
777 struct virtio_net *dev = get_device(vid); in rte_vhost_get_mtu() local
779 if (dev == NULL || mtu == NULL) in rte_vhost_get_mtu()
782 if (!(dev->flags & VIRTIO_DEV_READY)) in rte_vhost_get_mtu()
785 if (!(dev->features & (1ULL << VIRTIO_NET_F_MTU))) in rte_vhost_get_mtu()
788 *mtu = dev->mtu; in rte_vhost_get_mtu()
797 struct virtio_net *dev = get_device(vid); in rte_vhost_get_numa_node() local
801 if (dev == NULL || numa_available() != 0) in rte_vhost_get_numa_node()
804 ret = get_mempolicy(&numa_node, NULL, 0, dev, in rte_vhost_get_numa_node()
823 struct virtio_net *dev = get_device(vid); in rte_vhost_get_queue_num() local
825 if (dev == NULL) in rte_vhost_get_queue_num()
828 return dev->nr_vring / 2; in rte_vhost_get_queue_num()
834 struct virtio_net *dev = get_device(vid); in rte_vhost_get_vring_num() local
836 if (dev == NULL) in rte_vhost_get_vring_num()
839 return dev->nr_vring; in rte_vhost_get_vring_num()
845 struct virtio_net *dev = get_device(vid); in rte_vhost_get_ifname() local
847 if (dev == NULL || buf == NULL) in rte_vhost_get_ifname()
850 len = RTE_MIN(len, sizeof(dev->ifname)); in rte_vhost_get_ifname()
852 strncpy(buf, dev->ifname, len); in rte_vhost_get_ifname()
861 struct virtio_net *dev; in rte_vhost_get_negotiated_features() local
863 dev = get_device(vid); in rte_vhost_get_negotiated_features()
864 if (dev == NULL || features == NULL) in rte_vhost_get_negotiated_features()
867 *features = dev->features; in rte_vhost_get_negotiated_features()
874 struct virtio_net *dev; in rte_vhost_get_mem_table() local
878 dev = get_device(vid); in rte_vhost_get_mem_table()
879 if (dev == NULL || mem == NULL) in rte_vhost_get_mem_table()
882 size = dev->mem->nregions * sizeof(struct rte_vhost_mem_region); in rte_vhost_get_mem_table()
887 m->nregions = dev->mem->nregions; in rte_vhost_get_mem_table()
888 memcpy(m->regions, dev->mem->regions, size); in rte_vhost_get_mem_table()
898 struct virtio_net *dev; in rte_vhost_get_vhost_vring() local
901 dev = get_device(vid); in rte_vhost_get_vhost_vring()
902 if (dev == NULL || vring == NULL) in rte_vhost_get_vhost_vring()
908 vq = dev->virtqueue[vring_idx]; in rte_vhost_get_vhost_vring()
912 if (vq_is_packed(dev)) { in rte_vhost_get_vhost_vring()
934 struct virtio_net *dev; in rte_vhost_get_vhost_ring_inflight() local
937 dev = get_device(vid); in rte_vhost_get_vhost_ring_inflight()
938 if (unlikely(!dev)) in rte_vhost_get_vhost_ring_inflight()
944 vq = dev->virtqueue[vring_idx]; in rte_vhost_get_vhost_ring_inflight()
948 if (vq_is_packed(dev)) { in rte_vhost_get_vhost_ring_inflight()
970 struct virtio_net *dev; in rte_vhost_set_inflight_desc_split() local
972 dev = get_device(vid); in rte_vhost_set_inflight_desc_split()
973 if (unlikely(!dev)) in rte_vhost_set_inflight_desc_split()
976 if (unlikely(!(dev->protocol_features & in rte_vhost_set_inflight_desc_split()
980 if (unlikely(vq_is_packed(dev))) in rte_vhost_set_inflight_desc_split()
986 vq = dev->virtqueue[vring_idx]; in rte_vhost_set_inflight_desc_split()
1007 struct virtio_net *dev; in rte_vhost_set_inflight_desc_packed() local
1012 dev = get_device(vid); in rte_vhost_set_inflight_desc_packed()
1013 if (unlikely(!dev)) in rte_vhost_set_inflight_desc_packed()
1016 if (unlikely(!(dev->protocol_features & in rte_vhost_set_inflight_desc_packed()
1020 if (unlikely(!vq_is_packed(dev))) in rte_vhost_set_inflight_desc_packed()
1026 vq = dev->virtqueue[vring_idx]; in rte_vhost_set_inflight_desc_packed()
1073 struct virtio_net *dev; in rte_vhost_clr_inflight_desc_split() local
1076 dev = get_device(vid); in rte_vhost_clr_inflight_desc_split()
1077 if (unlikely(!dev)) in rte_vhost_clr_inflight_desc_split()
1080 if (unlikely(!(dev->protocol_features & in rte_vhost_clr_inflight_desc_split()
1084 if (unlikely(vq_is_packed(dev))) in rte_vhost_clr_inflight_desc_split()
1090 vq = dev->virtqueue[vring_idx]; in rte_vhost_clr_inflight_desc_split()
1115 struct virtio_net *dev; in rte_vhost_clr_inflight_desc_packed() local
1118 dev = get_device(vid); in rte_vhost_clr_inflight_desc_packed()
1119 if (unlikely(!dev)) in rte_vhost_clr_inflight_desc_packed()
1122 if (unlikely(!(dev->protocol_features & in rte_vhost_clr_inflight_desc_packed()
1126 if (unlikely(!vq_is_packed(dev))) in rte_vhost_clr_inflight_desc_packed()
1132 vq = dev->virtqueue[vring_idx]; in rte_vhost_clr_inflight_desc_packed()
1160 struct virtio_net *dev; in rte_vhost_set_last_inflight_io_split() local
1163 dev = get_device(vid); in rte_vhost_set_last_inflight_io_split()
1164 if (unlikely(!dev)) in rte_vhost_set_last_inflight_io_split()
1167 if (unlikely(!(dev->protocol_features & in rte_vhost_set_last_inflight_io_split()
1171 if (unlikely(vq_is_packed(dev))) in rte_vhost_set_last_inflight_io_split()
1177 vq = dev->virtqueue[vring_idx]; in rte_vhost_set_last_inflight_io_split()
1193 struct virtio_net *dev; in rte_vhost_set_last_inflight_io_packed() local
1197 dev = get_device(vid); in rte_vhost_set_last_inflight_io_packed()
1198 if (unlikely(!dev)) in rte_vhost_set_last_inflight_io_packed()
1201 if (unlikely(!(dev->protocol_features & in rte_vhost_set_last_inflight_io_packed()
1205 if (unlikely(!vq_is_packed(dev))) in rte_vhost_set_last_inflight_io_packed()
1211 vq = dev->virtqueue[vring_idx]; in rte_vhost_set_last_inflight_io_packed()
1241 struct virtio_net *dev; in rte_vhost_vring_call() local
1244 dev = get_device(vid); in rte_vhost_vring_call()
1245 if (!dev) in rte_vhost_vring_call()
1251 vq = dev->virtqueue[vring_idx]; in rte_vhost_vring_call()
1255 if (vq_is_packed(dev)) in rte_vhost_vring_call()
1256 vhost_vring_call_packed(dev, vq); in rte_vhost_vring_call()
1258 vhost_vring_call_split(dev, vq); in rte_vhost_vring_call()
1266 struct virtio_net *dev; in rte_vhost_avail_entries() local
1270 dev = get_device(vid); in rte_vhost_avail_entries()
1271 if (!dev) in rte_vhost_avail_entries()
1277 vq = dev->virtqueue[queue_id]; in rte_vhost_avail_entries()
1294 vhost_enable_notify_split(struct virtio_net *dev, in vhost_enable_notify_split() argument
1300 if (!(dev->features & (1ULL << VIRTIO_RING_F_EVENT_IDX))) { in vhost_enable_notify_split()
1313 vhost_enable_notify_packed(struct virtio_net *dev, in vhost_enable_notify_packed() argument
1327 if (dev->features & (1ULL << VIRTIO_RING_F_EVENT_IDX)) { in vhost_enable_notify_packed()
1340 vhost_enable_guest_notification(struct virtio_net *dev, in vhost_enable_guest_notification() argument
1350 if (vq_is_packed(dev)) in vhost_enable_guest_notification()
1351 return vhost_enable_notify_packed(dev, vq, enable); in vhost_enable_guest_notification()
1353 return vhost_enable_notify_split(dev, vq, enable); in vhost_enable_guest_notification()
1359 struct virtio_net *dev = get_device(vid); in rte_vhost_enable_guest_notification() local
1363 if (!dev) in rte_vhost_enable_guest_notification()
1369 vq = dev->virtqueue[queue_id]; in rte_vhost_enable_guest_notification()
1376 ret = vhost_enable_guest_notification(dev, vq, enable); in rte_vhost_enable_guest_notification()
1386 struct virtio_net *dev = get_device(vid); in rte_vhost_log_write() local
1388 if (dev == NULL) in rte_vhost_log_write()
1391 vhost_log_write(dev, addr, len); in rte_vhost_log_write()
1398 struct virtio_net *dev; in rte_vhost_log_used_vring() local
1401 dev = get_device(vid); in rte_vhost_log_used_vring()
1402 if (dev == NULL) in rte_vhost_log_used_vring()
1407 vq = dev->virtqueue[vring_idx]; in rte_vhost_log_used_vring()
1411 vhost_log_used_vring(dev, vq, offset, len); in rte_vhost_log_used_vring()
1417 struct virtio_net *dev; in rte_vhost_rx_queue_count() local
1421 dev = get_device(vid); in rte_vhost_rx_queue_count()
1422 if (dev == NULL) in rte_vhost_rx_queue_count()
1425 if (unlikely(qid >= dev->nr_vring || (qid & 1) == 0)) { in rte_vhost_rx_queue_count()
1427 dev->vid, __func__, qid); in rte_vhost_rx_queue_count()
1431 vq = dev->virtqueue[qid]; in rte_vhost_rx_queue_count()
1450 struct virtio_net *dev = get_device(vid); in rte_vhost_get_vdpa_device() local
1452 if (dev == NULL) in rte_vhost_get_vdpa_device()
1455 return dev->vdpa_dev; in rte_vhost_get_vdpa_device()
1461 struct virtio_net *dev = get_device(vid); in rte_vhost_get_log_base() local
1463 if (dev == NULL || log_base == NULL || log_size == NULL) in rte_vhost_get_log_base()
1466 *log_base = dev->log_base; in rte_vhost_get_log_base()
1467 *log_size = dev->log_size; in rte_vhost_get_log_base()
1476 struct virtio_net *dev = get_device(vid); in rte_vhost_get_vring_base() local
1478 if (dev == NULL || last_avail_idx == NULL || last_used_idx == NULL) in rte_vhost_get_vring_base()
1484 vq = dev->virtqueue[queue_id]; in rte_vhost_get_vring_base()
1488 if (vq_is_packed(dev)) { in rte_vhost_get_vring_base()
1505 struct virtio_net *dev = get_device(vid); in rte_vhost_set_vring_base() local
1507 if (!dev) in rte_vhost_set_vring_base()
1513 vq = dev->virtqueue[queue_id]; in rte_vhost_set_vring_base()
1517 if (vq_is_packed(dev)) { in rte_vhost_set_vring_base()
1538 struct virtio_net *dev = get_device(vid); in rte_vhost_get_vring_base_from_inflight() local
1540 if (dev == NULL || last_avail_idx == NULL || last_used_idx == NULL) in rte_vhost_get_vring_base_from_inflight()
1546 vq = dev->virtqueue[queue_id]; in rte_vhost_get_vring_base_from_inflight()
1550 if (!vq_is_packed(dev)) in rte_vhost_get_vring_base_from_inflight()
1567 struct virtio_net *dev = get_device(vid); in rte_vhost_extern_callback_register() local
1569 if (dev == NULL || ops == NULL) in rte_vhost_extern_callback_register()
1572 dev->extern_ops = *ops; in rte_vhost_extern_callback_register()
1573 dev->extern_data = ctx; in rte_vhost_extern_callback_register()
1582 struct virtio_net *dev = get_device(vid); in rte_vhost_async_channel_register() local
1586 if (dev == NULL || ops == NULL) in rte_vhost_async_channel_register()
1594 vq = dev->virtqueue[queue_id]; in rte_vhost_async_channel_register()
1596 if (unlikely(vq == NULL || !dev->async_copy)) in rte_vhost_async_channel_register()
1600 if (unlikely(vq_is_packed(dev) || !f.async_inorder)) { in rte_vhost_async_channel_register()
1669 struct virtio_net *dev = get_device(vid); in rte_vhost_async_channel_unregister() local
1672 if (dev == NULL) in rte_vhost_async_channel_unregister()
1678 vq = dev->virtqueue[queue_id]; in rte_vhost_async_channel_unregister()