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

Function device_map_resources

dpdk/drivers/bus/platform/platform.c:266–312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

264}
265
266static int
267device_map_resources(struct rte_platform_device *pdev, unsigned int num)
268{
269 struct rte_platform_resource *res;
270 unsigned int i;
271 int ret;
272
273 if (num == 0) {
274 PLATFORM_LOG(WARNING, "device %s has no resources\n", pdev->name);
275 return 0;
276 }
277
278 pdev->resource = calloc(num, sizeof(*pdev->resource));
279 if (pdev->resource == NULL)
280 return -ENOMEM;
281
282 for (i = 0; i < num; i++) {
283 struct vfio_region_info reg_info = {
284 .argsz = sizeof(reg_info),
285 .index = i,
286 };
287
288 ret = ioctl(pdev->dev_fd, VFIO_DEVICE_GET_REGION_INFO, &reg_info);
289 if (ret) {
290 PLATFORM_LOG(ERR, "failed to get region info at %d\n", i);
291 ret = -errno;
292 goto out;
293 }
294
295 res = &pdev->resource[i];
296 res->name = of_resource_name(pdev->name, reg_info.index);
297 res->mem.len = reg_info.size;
298 ret = device_map_resource_offset(pdev, res, reg_info.offset);
299 if (ret) {
300 PLATFORM_LOG(ERR, "failed to ioremap resource at %d\n", i);
301 goto out;
302 }
303
304 pdev->num_resource++;
305 }
306
307 return 0;
308out:
309 device_unmap_resources(pdev);
310
311 return ret;
312}
313
314static void
315device_cleanup(struct rte_platform_device *pdev)

Callers 1

device_setupFunction · 0.85

Calls 5

callocFunction · 0.85
of_resource_nameFunction · 0.85
device_unmap_resourcesFunction · 0.85
ioctlFunction · 0.50

Tested by

no test coverage detected