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

Function vhost_user_set_mem_table

dpdk/lib/vhost/vhost_user.c:1315–1471  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1313}
1314
1315static int
1316vhost_user_set_mem_table(struct virtio_net **pdev,
1317 struct vhu_msg_context *ctx,
1318 int main_fd)
1319{
1320 struct virtio_net *dev = *pdev;
1321 struct VhostUserMemory *memory = &ctx->msg.payload.memory;
1322 struct rte_vhost_mem_region *reg;
1323 int numa_node = SOCKET_ID_ANY;
1324 uint64_t mmap_offset;
1325 uint32_t i;
1326 bool async_notify = false;
1327
1328 if (validate_msg_fds(dev, ctx, memory->nregions) != 0)
1329 return RTE_VHOST_MSG_RESULT_ERR;
1330
1331 if (memory->nregions > VHOST_MEMORY_MAX_NREGIONS) {
1332 VHOST_LOG_CONFIG(dev->ifname, ERR,
1333 "too many memory regions (%u)\n",
1334 memory->nregions);
1335 goto close_msg_fds;
1336 }
1337
1338 if (dev->mem && !vhost_memory_changed(memory, dev->mem)) {
1339 VHOST_LOG_CONFIG(dev->ifname, INFO, "memory regions not changed\n");
1340
1341 close_msg_fds(ctx);
1342
1343 return RTE_VHOST_MSG_RESULT_OK;
1344 }
1345
1346 if (dev->mem) {
1347 if (dev->flags & VIRTIO_DEV_VDPA_CONFIGURED) {
1348 struct rte_vdpa_device *vdpa_dev = dev->vdpa_dev;
1349
1350 if (vdpa_dev && vdpa_dev->ops->dev_close)
1351 vdpa_dev->ops->dev_close(dev->vid);
1352 dev->flags &= ~VIRTIO_DEV_VDPA_CONFIGURED;
1353 }
1354
1355 /* notify the vhost application to stop DMA transfers */
1356 if (dev->async_copy && dev->notify_ops->vring_state_changed) {
1357 for (i = 0; i < dev->nr_vring; i++) {
1358 dev->notify_ops->vring_state_changed(dev->vid,
1359 i, 0);
1360 }
1361 async_notify = true;
1362 }
1363
1364 /* Flush IOTLB cache as previous HVAs are now invalid */
1365 if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM))
1366 vhost_user_iotlb_flush_all(dev);
1367
1368 free_mem_region(dev);
1369 rte_free(dev->mem);
1370 dev->mem = NULL;
1371 }
1372

Callers

nothing calls this directly

Calls 14

validate_msg_fdsFunction · 0.85
vhost_memory_changedFunction · 0.85
close_msg_fdsFunction · 0.85
free_mem_regionFunction · 0.85
rte_freeFunction · 0.85
rte_zmalloc_socketFunction · 0.85
vhost_user_mmap_regionFunction · 0.85
async_dma_mapFunction · 0.85
vring_invalidateFunction · 0.85
translate_ring_addressesFunction · 0.85

Tested by

no test coverage detected