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

Function vfio_map_dev_obj

dpdk/drivers/crypto/bcmfs/bcmfs_vfio.c:17–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15
16#ifdef VFIO_PRESENT
17static int
18vfio_map_dev_obj(const char *path, const char *dev_obj,
19 uint32_t *size, void **addr, int *dev_fd)
20{
21 int32_t ret;
22 struct vfio_group_status status = { .argsz = sizeof(status) };
23
24 struct vfio_device_info d_info = { .argsz = sizeof(d_info) };
25 struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) };
26
27 ret = rte_vfio_setup_device(path, dev_obj, dev_fd, &d_info);
28 if (ret) {
29 BCMFS_LOG(ERR, "VFIO Setting for device failed");
30 return ret;
31 }
32
33 /* getting device region info*/
34 ret = ioctl(*dev_fd, VFIO_DEVICE_GET_REGION_INFO, &reg_info);
35 if (ret < 0) {
36 BCMFS_LOG(ERR, "Error in VFIO getting REGION_INFO");
37 goto map_failed;
38 }
39
40 *addr = mmap(NULL, reg_info.size,
41 PROT_WRITE | PROT_READ, MAP_SHARED,
42 *dev_fd, reg_info.offset);
43 if (*addr == MAP_FAILED) {
44 BCMFS_LOG(ERR, "Error mapping region (errno = %d)", errno);
45 ret = errno;
46 goto map_failed;
47 }
48 *size = reg_info.size;
49
50 return 0;
51
52map_failed:
53 rte_vfio_release_device(path, dev_obj, *dev_fd);
54
55 return ret;
56}
57
58int
59bcmfs_attach_vfio(struct bcmfs_device *dev)

Callers 1

bcmfs_attach_vfioFunction · 0.85

Calls 3

rte_vfio_setup_deviceFunction · 0.50
ioctlFunction · 0.50
rte_vfio_release_deviceFunction · 0.50

Tested by

no test coverage detected