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

Function async_dma_map

dpdk/lib/vhost/vhost_user.c:116–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114}
115
116static void
117async_dma_map(struct virtio_net *dev, bool do_map)
118{
119 int ret = 0;
120 uint32_t i;
121 struct guest_page *page;
122
123 if (do_map) {
124 for (i = 0; i < dev->nr_guest_pages; i++) {
125 page = &dev->guest_pages[i];
126 ret = rte_vfio_container_dma_map(RTE_VFIO_DEFAULT_CONTAINER_FD,
127 page->host_user_addr,
128 page->host_iova,
129 page->size);
130 if (ret) {
131 /*
132 * DMA device may bind with kernel driver, in this case,
133 * we don't need to program IOMMU manually. However, if no
134 * device is bound with vfio/uio in DPDK, and vfio kernel
135 * module is loaded, the API will still be called and return
136 * with ENODEV.
137 *
138 * DPDK vfio only returns ENODEV in very similar situations
139 * (vfio either unsupported, or supported but no devices found).
140 * Either way, no mappings could be performed. We treat it as
141 * normal case in async path. This is a workaround.
142 */
143 if (rte_errno == ENODEV)
144 return;
145
146 /* DMA mapping errors won't stop VHOST_USER_SET_MEM_TABLE. */
147 VHOST_LOG_CONFIG(dev->ifname, ERR, "DMA engine map failed\n");
148 }
149 }
150
151 } else {
152 for (i = 0; i < dev->nr_guest_pages; i++) {
153 page = &dev->guest_pages[i];
154 ret = rte_vfio_container_dma_unmap(RTE_VFIO_DEFAULT_CONTAINER_FD,
155 page->host_user_addr,
156 page->host_iova,
157 page->size);
158 if (ret) {
159 /* like DMA map, ignore the kernel driver case when unmap. */
160 if (rte_errno == EINVAL)
161 return;
162
163 VHOST_LOG_CONFIG(dev->ifname, ERR, "DMA engine unmap failed\n");
164 }
165 }
166 }
167}
168
169static void
170free_mem_region(struct virtio_net *dev)

Callers 2

free_mem_regionFunction · 0.85
vhost_user_set_mem_tableFunction · 0.85

Calls 2

Tested by

no test coverage detected