| 309 | } |
| 310 | |
| 311 | static int |
| 312 | rte_fslmc_scan(void) |
| 313 | { |
| 314 | int ret; |
| 315 | char fslmc_dirpath[PATH_MAX]; |
| 316 | DIR *dir; |
| 317 | struct dirent *entry; |
| 318 | static int process_once; |
| 319 | int groupid; |
| 320 | |
| 321 | if (process_once) { |
| 322 | DPAA2_BUS_DEBUG("Fslmc bus already scanned. Not rescanning"); |
| 323 | return 0; |
| 324 | } |
| 325 | process_once = 1; |
| 326 | |
| 327 | ret = fslmc_get_container_group(&groupid); |
| 328 | if (ret != 0) |
| 329 | goto scan_fail; |
| 330 | |
| 331 | /* Scan devices on the group */ |
| 332 | sprintf(fslmc_dirpath, "%s/%s", SYSFS_FSL_MC_DEVICES, fslmc_container); |
| 333 | dir = opendir(fslmc_dirpath); |
| 334 | if (!dir) { |
| 335 | DPAA2_BUS_ERR("Unable to open VFIO group directory"); |
| 336 | goto scan_fail; |
| 337 | } |
| 338 | |
| 339 | /* Scan the DPRC container object */ |
| 340 | ret = scan_one_fslmc_device(fslmc_container); |
| 341 | if (ret != 0) { |
| 342 | /* Error in parsing directory - exit gracefully */ |
| 343 | goto scan_fail_cleanup; |
| 344 | } |
| 345 | |
| 346 | while ((entry = readdir(dir)) != NULL) { |
| 347 | if (entry->d_name[0] == '.' || entry->d_type != DT_DIR) |
| 348 | continue; |
| 349 | |
| 350 | ret = scan_one_fslmc_device(entry->d_name); |
| 351 | if (ret != 0) { |
| 352 | /* Error in parsing directory - exit gracefully */ |
| 353 | goto scan_fail_cleanup; |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | closedir(dir); |
| 358 | |
| 359 | DPAA2_BUS_INFO("FSLMC Bus scan completed"); |
| 360 | /* If debugging is enabled, device list is dumped to log output */ |
| 361 | dump_device_list(); |
| 362 | |
| 363 | return 0; |
| 364 | |
| 365 | scan_fail_cleanup: |
| 366 | closedir(dir); |
| 367 | |
| 368 | /* Remove all devices in the list */ |
nothing calls this directly
no test coverage detected