- i = 0;
- FSLMC_VFIO_LOG(DEBUG, "DPAA2 - Parsing devices:");
- /* Parsing each object and initiating them*/
- while ((dir = readdir(d)) != NULL) {
- if (dir->d_type != DT_LNK)
- continue;
- if (!strncmp("dprc", dir->d_name, 4) ||
- !strncmp("dpmcp", dir->d_name, 5))
- continue;
- dev_name = malloc(sizeof(dir->d_name));
- if (!dev_name) {
- FSLMC_VFIO_LOG(ERR, "name: Unable to allocate memory");
- goto FAILURE;
- }
- strcpy(dev_name, dir->d_name);
- object_type = strtok(dir->d_name, ".");
- temp_obj = strtok(NULL, ".");
- sscanf(temp_obj, "%d", &object_id);
- FSLMC_VFIO_LOG(DEBUG, " - %s ", dev_name);
-
- /* getting the device fd*/
- dev_fd = ioctl(group->fd, VFIO_GROUP_GET_DEVICE_FD, dev_name);
- if (dev_fd < 0) {
- FSLMC_VFIO_LOG(ERR, "VFIO_GROUP_GET_DEVICE_FD error"
- " Device fd: %s, Group: %d",
- dev_name, group->fd);
- free(dev_name);
- goto FAILURE;
+int
+fslmc_vfio_process_group(void)
+{
+ int ret;
+ int found_mportal = 0;
+ struct rte_dpaa2_device *dev, *dev_temp;
+
+ /* Search the MCP as that should be initialized first. */
+ TAILQ_FOREACH_SAFE(dev, &rte_fslmc_bus.device_list, next, dev_temp) {
+ if (dev->dev_type == DPAA2_MPORTAL) {
+ ret = fslmc_process_mcp(dev);
+ if (ret) {
+ FSLMC_VFIO_LOG(DEBUG, "Unable to map Portal.");
+ return -1;
+ }
+ if (!found_mportal)
+ found_mportal = 1;
+
+ TAILQ_REMOVE(&rte_fslmc_bus.device_list, dev, next);
+ free(dev);
+ dev = NULL;
+ /* Ideally there is only a single dpmcp, but in case
+ * multiple exists, looping on remaining devices.
+ */