f0d69a9dc84a5df8d14b3bd5758f44f8a868f6a4
[dpdk.git] / drivers / bus / fslmc / fslmc_vfio.c
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright (c) 2015-2016 Freescale Semiconductor, Inc. All rights reserved.
5  *   Copyright 2016 NXP.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *     * Neither the name of Freescale Semiconductor, Inc nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #include <unistd.h>
35 #include <stdio.h>
36 #include <sys/types.h>
37 #include <string.h>
38 #include <stdlib.h>
39 #include <fcntl.h>
40 #include <errno.h>
41 #include <sys/ioctl.h>
42 #include <sys/stat.h>
43 #include <sys/mman.h>
44 #include <sys/vfs.h>
45 #include <libgen.h>
46 #include <dirent.h>
47 #include <sys/eventfd.h>
48
49 #include <rte_mbuf.h>
50 #include <rte_ethdev.h>
51 #include <rte_malloc.h>
52 #include <rte_memcpy.h>
53 #include <rte_string_fns.h>
54 #include <rte_cycles.h>
55 #include <rte_kvargs.h>
56 #include <rte_dev.h>
57 #include <rte_bus.h>
58
59 #include "rte_fslmc.h"
60 #include "fslmc_vfio.h"
61
62 #include "portal/dpaa2_hw_pvt.h"
63 #include "portal/dpaa2_hw_dpio.h"
64
65 #define FSLMC_VFIO_LOG(level, fmt, args...) \
66         RTE_LOG(level, EAL, "%s(): " fmt "\n", __func__, ##args)
67
68 /** Pathname of FSL-MC devices directory. */
69 #define SYSFS_FSL_MC_DEVICES "/sys/bus/fsl-mc/devices"
70
71 /* Number of VFIO containers & groups with in */
72 static struct fslmc_vfio_group vfio_group;
73 static struct fslmc_vfio_container vfio_container;
74 static int container_device_fd;
75 static uint32_t *msi_intr_vaddr;
76 void *(*rte_mcp_ptr_list);
77 static uint32_t mcp_id;
78 static int is_dma_done;
79
80 static struct rte_dpaa2_object_list dpaa2_obj_list =
81         TAILQ_HEAD_INITIALIZER(dpaa2_obj_list);
82
83 /*register a fslmc bus based dpaa2 driver */
84 void
85 rte_fslmc_object_register(struct rte_dpaa2_object *object)
86 {
87         RTE_VERIFY(object);
88
89         TAILQ_INSERT_TAIL(&dpaa2_obj_list, object, next);
90 }
91
92 static int vfio_connect_container(void)
93 {
94         int fd, ret;
95
96         /* Try connecting to vfio container if already created */
97         if (!ioctl(vfio_group.fd, VFIO_GROUP_SET_CONTAINER,
98                 &vfio_container.fd)) {
99                 FSLMC_VFIO_LOG(INFO,
100                     "Container pre-exists with FD[0x%x] for this group",
101                     vfio_container.fd);
102                 vfio_group.container = &vfio_container;
103                 return 0;
104         }
105
106         /* Opens main vfio file descriptor which represents the "container" */
107         fd = vfio_get_container_fd();
108         if (fd < 0) {
109                 FSLMC_VFIO_LOG(ERR, "Failed to open VFIO container");
110                 return -errno;
111         }
112
113         /* Check whether support for SMMU type IOMMU present or not */
114         if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU)) {
115                 /* Connect group to container */
116                 ret = ioctl(vfio_group.fd, VFIO_GROUP_SET_CONTAINER, &fd);
117                 if (ret) {
118                         FSLMC_VFIO_LOG(ERR, "Failed to setup group container");
119                         close(fd);
120                         return -errno;
121                 }
122
123                 ret = ioctl(fd, VFIO_SET_IOMMU, VFIO_TYPE1_IOMMU);
124                 if (ret) {
125                         FSLMC_VFIO_LOG(ERR, "Failed to setup VFIO iommu");
126                         close(fd);
127                         return -errno;
128                 }
129         } else {
130                 FSLMC_VFIO_LOG(ERR, "No supported IOMMU available");
131                 close(fd);
132                 return -EINVAL;
133         }
134
135         vfio_container.used = 1;
136         vfio_container.fd = fd;
137         vfio_container.group = &vfio_group;
138         vfio_group.container = &vfio_container;
139
140         return 0;
141 }
142
143 static int vfio_map_irq_region(struct fslmc_vfio_group *group)
144 {
145         int ret;
146         unsigned long *vaddr = NULL;
147         struct vfio_iommu_type1_dma_map map = {
148                 .argsz = sizeof(map),
149                 .flags = VFIO_DMA_MAP_FLAG_READ | VFIO_DMA_MAP_FLAG_WRITE,
150                 .vaddr = 0x6030000,
151                 .iova = 0x6030000,
152                 .size = 0x1000,
153         };
154
155         vaddr = (unsigned long *)mmap(NULL, 0x1000, PROT_WRITE |
156                 PROT_READ, MAP_SHARED, container_device_fd, 0x6030000);
157         if (vaddr == MAP_FAILED) {
158                 FSLMC_VFIO_LOG(ERR, "Unable to map region (errno = %d)", errno);
159                 return -errno;
160         }
161
162         msi_intr_vaddr = (uint32_t *)((char *)(vaddr) + 64);
163         map.vaddr = (unsigned long)vaddr;
164         ret = ioctl(group->container->fd, VFIO_IOMMU_MAP_DMA, &map);
165         if (ret == 0)
166                 return 0;
167
168         FSLMC_VFIO_LOG(ERR, "VFIO_IOMMU_MAP_DMA fails (errno = %d)", errno);
169         return -errno;
170 }
171
172 int rte_fslmc_vfio_dmamap(void)
173 {
174         int ret;
175         struct fslmc_vfio_group *group;
176         struct vfio_iommu_type1_dma_map dma_map = {
177                 .argsz = sizeof(struct vfio_iommu_type1_dma_map),
178                 .flags = VFIO_DMA_MAP_FLAG_READ | VFIO_DMA_MAP_FLAG_WRITE,
179         };
180
181         int i;
182         const struct rte_memseg *memseg;
183
184         if (is_dma_done)
185                 return 0;
186
187         memseg = rte_eal_get_physmem_layout();
188         if (memseg == NULL) {
189                 FSLMC_VFIO_LOG(ERR, "Cannot get physical layout.");
190                 return -ENODEV;
191         }
192
193         for (i = 0; i < RTE_MAX_MEMSEG; i++) {
194                 if (memseg[i].addr == NULL && memseg[i].len == 0) {
195                         FSLMC_VFIO_LOG(DEBUG, "Total %d segments found.", i);
196                         break;
197                 }
198
199                 dma_map.size = memseg[i].len;
200                 dma_map.vaddr = memseg[i].addr_64;
201 #ifdef RTE_LIBRTE_DPAA2_USE_PHYS_IOVA
202                 dma_map.iova = memseg[i].phys_addr;
203 #else
204                 dma_map.iova = dma_map.vaddr;
205 #endif
206
207                 /* SET DMA MAP for IOMMU */
208                 group = &vfio_group;
209
210                 if (!group->container) {
211                         FSLMC_VFIO_LOG(ERR, "Container is not connected ");
212                         return -1;
213                 }
214
215                 FSLMC_VFIO_LOG(DEBUG, "-->Initial SHM Virtual ADDR %llX",
216                              dma_map.vaddr);
217                 FSLMC_VFIO_LOG(DEBUG, "-----> DMA size 0x%llX", dma_map.size);
218                 ret = ioctl(group->container->fd, VFIO_IOMMU_MAP_DMA,
219                             &dma_map);
220                 if (ret) {
221                         FSLMC_VFIO_LOG(ERR, "VFIO_IOMMU_MAP_DMA API(errno = %d)",
222                                        errno);
223                         return ret;
224                 }
225         }
226
227         /* Verifying that at least single segment is available */
228         if (i <= 0) {
229                 FSLMC_VFIO_LOG(ERR, "No Segments found for VFIO Mapping");
230                 return -1;
231         }
232
233         /* TODO - This is a W.A. as VFIO currently does not add the mapping of
234          * the interrupt region to SMMU. This should be removed once the
235          * support is added in the Kernel.
236          */
237         vfio_map_irq_region(group);
238
239         is_dma_done = 1;
240
241         return 0;
242 }
243
244 static int64_t vfio_map_mcp_obj(struct fslmc_vfio_group *group, char *mcp_obj)
245 {
246         int64_t v_addr = (int64_t)MAP_FAILED;
247         int32_t ret, mc_fd;
248
249         struct vfio_device_info d_info = { .argsz = sizeof(d_info) };
250         struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) };
251
252         /* getting the mcp object's fd*/
253         mc_fd = ioctl(group->fd, VFIO_GROUP_GET_DEVICE_FD, mcp_obj);
254         if (mc_fd < 0) {
255                 FSLMC_VFIO_LOG(ERR, "error in VFIO get dev %s fd from group %d",
256                                mcp_obj, group->fd);
257                 return v_addr;
258         }
259
260         /* getting device info*/
261         ret = ioctl(mc_fd, VFIO_DEVICE_GET_INFO, &d_info);
262         if (ret < 0) {
263                 FSLMC_VFIO_LOG(ERR, "error in VFIO getting DEVICE_INFO");
264                 goto MC_FAILURE;
265         }
266
267         /* getting device region info*/
268         ret = ioctl(mc_fd, VFIO_DEVICE_GET_REGION_INFO, &reg_info);
269         if (ret < 0) {
270                 FSLMC_VFIO_LOG(ERR, "error in VFIO getting REGION_INFO");
271                 goto MC_FAILURE;
272         }
273
274         FSLMC_VFIO_LOG(DEBUG, "region offset = %llx  , region size = %llx",
275                        reg_info.offset, reg_info.size);
276
277         v_addr = (uint64_t)mmap(NULL, reg_info.size,
278                 PROT_WRITE | PROT_READ, MAP_SHARED,
279                 mc_fd, reg_info.offset);
280
281 MC_FAILURE:
282         close(mc_fd);
283
284         return v_addr;
285 }
286
287 static inline int
288 dpaa2_compare_dpaa2_dev(const struct rte_dpaa2_device *dev,
289                          const struct rte_dpaa2_device *dev2)
290 {
291         /*not the same family device */
292         if (dev->dev_type != DPAA2_ETH ||
293                         dev->dev_type != DPAA2_CRYPTO)
294                 return -1;
295
296         if (dev->object_id == dev2->object_id)
297                 return 0;
298         else
299                 return 1;
300 }
301
302 static void
303 fslmc_bus_add_device(struct rte_dpaa2_device *dev)
304 {
305         struct rte_fslmc_device_list *dev_l;
306
307         dev_l = &rte_fslmc_bus.device_list;
308
309         /* device is valid, add in list (sorted) */
310         if (TAILQ_EMPTY(dev_l)) {
311                 TAILQ_INSERT_TAIL(dev_l, dev, next);
312         } else {
313                 struct rte_dpaa2_device *dev2;
314                 int ret;
315
316                 TAILQ_FOREACH(dev2, dev_l, next) {
317                         ret = dpaa2_compare_dpaa2_dev(dev, dev2);
318                         if (ret <= 0)
319                                 continue;
320
321                         TAILQ_INSERT_BEFORE(dev2, dev, next);
322                         return;
323                 }
324
325                 TAILQ_INSERT_TAIL(dev_l, dev, next);
326         }
327 }
328
329 #define IRQ_SET_BUF_LEN  (sizeof(struct vfio_irq_set) + sizeof(int))
330
331 int rte_dpaa2_intr_enable(struct rte_intr_handle *intr_handle,
332                           uint32_t index)
333 {
334         struct vfio_irq_set *irq_set;
335         char irq_set_buf[IRQ_SET_BUF_LEN];
336         int *fd_ptr, fd, ret;
337
338         /* Prepare vfio_irq_set structure and SET the IRQ in VFIO */
339         /* Give the eventfd to VFIO */
340         fd = eventfd(0, 0);
341         irq_set = (struct vfio_irq_set *)irq_set_buf;
342         irq_set->argsz = sizeof(irq_set_buf);
343         irq_set->count = 1;
344         irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD |
345                          VFIO_IRQ_SET_ACTION_TRIGGER;
346         irq_set->index = index;
347         irq_set->start = 0;
348         fd_ptr = (int *)&irq_set->data;
349         *fd_ptr = fd;
350
351         ret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);
352         if (ret < 0) {
353                 FSLMC_VFIO_LOG(ERR, "Unable to set IRQ in VFIO, ret: %d\n",
354                                ret);
355                 return -1;
356         }
357
358         /* Set the FD and update the flags */
359         intr_handle->fd = fd;
360         return 0;
361 }
362
363 /* Following function shall fetch total available list of MC devices
364  * from VFIO container & populate private list of devices and other
365  * data structures
366  */
367 int fslmc_vfio_process_group(void)
368 {
369         struct fslmc_vfio_device *vdev;
370         struct vfio_device_info device_info = { .argsz = sizeof(device_info) };
371         char *temp_obj, *object_type, *mcp_obj, *dev_name;
372         int32_t object_id, i, dev_fd, ret;
373         DIR *d;
374         struct dirent *dir;
375         char path[PATH_MAX];
376         int64_t v_addr;
377         int ndev_count;
378         struct fslmc_vfio_group *group = &vfio_group;
379         static int process_once;
380
381         /* if already done once */
382         if (process_once) {
383                 FSLMC_VFIO_LOG(DEBUG,
384                                "Already scanned once - re-scan not supported");
385                 return 0;
386         }
387         process_once = 0;
388
389         sprintf(path, "/sys/kernel/iommu_groups/%d/devices", group->groupid);
390
391         d = opendir(path);
392         if (!d) {
393                 FSLMC_VFIO_LOG(ERR, "Unable to open directory %s", path);
394                 return -1;
395         }
396
397         /*Counting the number of devices in a group and getting the mcp ID*/
398         ndev_count = 0;
399         mcp_obj = NULL;
400         while ((dir = readdir(d)) != NULL) {
401                 if (dir->d_type == DT_LNK) {
402                         ndev_count++;
403                         if (!strncmp("dpmcp", dir->d_name, 5)) {
404                                 if (mcp_obj)
405                                         free(mcp_obj);
406                                 mcp_obj = malloc(sizeof(dir->d_name));
407                                 if (!mcp_obj) {
408                                         FSLMC_VFIO_LOG(ERR,
409                                                        "mcp obj:alloc failed");
410                                         closedir(d);
411                                         return -ENOMEM;
412                                 }
413                                 strcpy(mcp_obj, dir->d_name);
414                                 temp_obj = strtok(dir->d_name, ".");
415                                 temp_obj = strtok(NULL, ".");
416                                 sscanf(temp_obj, "%d", &mcp_id);
417                         }
418                 }
419         }
420         closedir(d);
421         d = NULL;
422         if (!mcp_obj) {
423                 FSLMC_VFIO_LOG(ERR, "DPAA2 MCP Object not Found");
424                 return -ENODEV;
425         }
426         RTE_LOG(INFO, EAL, "fslmc: DPRC contains = %d devices\n", ndev_count);
427
428         /* Allocate the memory depends upon number of objects in a group*/
429         group->vfio_device = (struct fslmc_vfio_device *)malloc(ndev_count *
430                              sizeof(struct fslmc_vfio_device));
431         if (!(group->vfio_device)) {
432                 FSLMC_VFIO_LOG(ERR, "vfio device: Unable to allocate memory\n");
433                 free(mcp_obj);
434                 return -ENOMEM;
435         }
436
437         /* Allocate memory for MC Portal list */
438         rte_mcp_ptr_list = malloc(sizeof(void *) * 1);
439         if (!rte_mcp_ptr_list) {
440                 FSLMC_VFIO_LOG(ERR, "portal list: Unable to allocate memory!");
441                 free(mcp_obj);
442                 goto FAILURE;
443         }
444
445         v_addr = vfio_map_mcp_obj(group, mcp_obj);
446         free(mcp_obj);
447         if (v_addr == (int64_t)MAP_FAILED) {
448                 FSLMC_VFIO_LOG(ERR, "Error mapping region (errno = %d)", errno);
449                 goto FAILURE;
450         }
451
452         rte_mcp_ptr_list[0] = (void *)v_addr;
453
454         d = opendir(path);
455         if (!d) {
456                 FSLMC_VFIO_LOG(ERR, "Unable to open %s Directory", path);
457                 goto FAILURE;
458         }
459
460         i = 0;
461         /* Parsing each object and initiating them*/
462         while ((dir = readdir(d)) != NULL) {
463                 if (dir->d_type != DT_LNK)
464                         continue;
465                 if (!strncmp("dprc", dir->d_name, 4) ||
466                     !strncmp("dpmcp", dir->d_name, 5))
467                         continue;
468                 dev_name = malloc(sizeof(dir->d_name));
469                 if (!dev_name) {
470                         FSLMC_VFIO_LOG(ERR, "name: Unable to allocate memory");
471                         goto FAILURE;
472                 }
473                 strcpy(dev_name, dir->d_name);
474                 object_type = strtok(dir->d_name, ".");
475                 temp_obj = strtok(NULL, ".");
476                 sscanf(temp_obj, "%d", &object_id);
477
478                 /* getting the device fd*/
479                 dev_fd = ioctl(group->fd, VFIO_GROUP_GET_DEVICE_FD, dev_name);
480                 if (dev_fd < 0) {
481                         FSLMC_VFIO_LOG(ERR,
482                                        "GET_DEVICE_FD error fd: %s, Group: %d",
483                                        dev_name, group->fd);
484                         free(dev_name);
485                         goto FAILURE;
486                 }
487
488                 free(dev_name);
489                 vdev = &group->vfio_device[group->object_index++];
490                 vdev->fd = dev_fd;
491                 vdev->index = i;
492                 i++;
493                 /* Get Device inofrmation */
494                 if (ioctl(vdev->fd, VFIO_DEVICE_GET_INFO, &device_info)) {
495                         FSLMC_VFIO_LOG(ERR, "DPAA2 VFIO_DEVICE_GET_INFO fail");
496                         goto FAILURE;
497                 }
498                 if (!strcmp(object_type, "dpni") ||
499                     !strcmp(object_type, "dpseci")) {
500                         struct rte_dpaa2_device *dev;
501
502                         dev = malloc(sizeof(struct rte_dpaa2_device));
503                         if (dev == NULL)
504                                 return -1;
505
506                         memset(dev, 0, sizeof(*dev));
507                         /* store hw_id of dpni/dpseci device */
508                         dev->object_id = object_id;
509                         dev->dev_type = (strcmp(object_type, "dpseci")) ?
510                                 DPAA2_ETH : DPAA2_CRYPTO;
511
512                         sprintf(dev->name, "%s.%d", object_type, object_id);
513                         dev->device.name = dev->name;
514
515                         fslmc_bus_add_device(dev);
516                         FSLMC_VFIO_LOG(DEBUG, "DPAA2: Added %s", dev->name);
517                 } else {
518                         /* Parse all other objects */
519                         struct rte_dpaa2_object *object;
520
521                         TAILQ_FOREACH(object, &dpaa2_obj_list, next) {
522                                 if (!strcmp(object_type, object->name))
523                                         object->create(dev_fd, &device_info,
524                                                        object_id);
525                                 else
526                                         continue;
527                         }
528                 }
529         }
530         closedir(d);
531
532         ret = dpaa2_affine_qbman_swp();
533         if (ret)
534                 FSLMC_VFIO_LOG(DEBUG, "Error in affining qbman swp %d", ret);
535
536         return 0;
537
538 FAILURE:
539         if (d)
540                 closedir(d);
541         if (rte_mcp_ptr_list) {
542                 free(rte_mcp_ptr_list);
543                 rte_mcp_ptr_list = NULL;
544         }
545
546         free(group->vfio_device);
547         group->vfio_device = NULL;
548         return -1;
549 }
550
551 int fslmc_vfio_setup_group(void)
552 {
553         struct fslmc_vfio_group *group = NULL;
554         int groupid;
555         int ret;
556         char *container;
557         struct vfio_group_status status = { .argsz = sizeof(status) };
558
559         /* if already done once */
560         if (container_device_fd)
561                 return 0;
562
563         container = getenv("DPRC");
564
565         if (container == NULL) {
566                 FSLMC_VFIO_LOG(ERR, "VFIO container not set in env DPRC");
567                 return -EOPNOTSUPP;
568         }
569
570         /* get group number */
571         ret = vfio_get_group_no(SYSFS_FSL_MC_DEVICES, container, &groupid);
572         if (ret == 0) {
573                 RTE_LOG(WARNING, EAL, "%s not managed by VFIO, skipping\n",
574                         container);
575                 return -EOPNOTSUPP;
576         }
577
578         /* if negative, something failed */
579         if (ret < 0)
580                 return ret;
581
582         FSLMC_VFIO_LOG(DEBUG, "VFIO iommu group id = %d", groupid);
583
584         /* Check if group already exists */
585         group = &vfio_group;
586         if (group->groupid == groupid) {
587                 FSLMC_VFIO_LOG(ERR, "groupid already exists %d",
588                                groupid);
589                 return 0;
590         }
591
592         /* get the actual group fd */
593         ret = vfio_get_group_fd(groupid);
594         if (ret < 0)
595                 return ret;
596         group->fd = ret;
597
598         /*
599          * at this point, we know that this group is viable (meaning,
600          * all devices are either bound to VFIO or not bound to anything)
601          */
602
603         ret = ioctl(group->fd, VFIO_GROUP_GET_STATUS, &status);
604         if (ret) {
605                 FSLMC_VFIO_LOG(ERR, " VFIO error getting group status");
606                 close(group->fd);
607                 return ret;
608         }
609
610         if (!(status.flags & VFIO_GROUP_FLAGS_VIABLE)) {
611                 FSLMC_VFIO_LOG(ERR, "VFIO group not viable");
612                 close(group->fd);
613                 return -EPERM;
614         }
615         /* Since Group is VIABLE, Store the groupid */
616         group->groupid = groupid;
617
618         /* check if group does not have a container yet */
619         if (!(status.flags & VFIO_GROUP_FLAGS_CONTAINER_SET)) {
620                 /* Now connect this IOMMU group to given container */
621                 ret = vfio_connect_container();
622                 if (ret) {
623                         FSLMC_VFIO_LOG(ERR, "VFIO error connecting container"
624                                        " with groupid %d", groupid);
625                         close(group->fd);
626                         return ret;
627                 }
628         }
629
630         /* Get Device information */
631         ret = ioctl(group->fd, VFIO_GROUP_GET_DEVICE_FD, container);
632         if (ret < 0) {
633                 FSLMC_VFIO_LOG(ERR, "VFIO error getting device %s fd from"
634                                " group  %d", container, group->groupid);
635                 return ret;
636         }
637         container_device_fd = ret;
638         FSLMC_VFIO_LOG(DEBUG, "VFIO Container FD is [0x%X]",
639                      container_device_fd);
640
641         return 0;
642 }