* Scan the content of the PCI bus, and the devices in the devices * list */
| 441 | * list |
| 442 | */ |
| 443 | int |
| 444 | rte_pci_scan(void) |
| 445 | { |
| 446 | struct dirent *e; |
| 447 | DIR *dir; |
| 448 | char dirname[PATH_MAX]; |
| 449 | struct rte_pci_addr addr; |
| 450 | |
| 451 | /* for debug purposes, PCI can be disabled */ |
| 452 | if (!rte_eal_has_pci()) |
| 453 | return 0; |
| 454 | |
| 455 | dir = opendir(rte_pci_get_sysfs_path()); |
| 456 | if (dir == NULL) { |
| 457 | RTE_LOG(ERR, EAL, "%s(): opendir failed: %s\n", |
| 458 | __func__, strerror(errno)); |
| 459 | return -1; |
| 460 | } |
| 461 | |
| 462 | while ((e = readdir(dir)) != NULL) { |
| 463 | if (e->d_name[0] == '.') |
| 464 | continue; |
| 465 | |
| 466 | if (parse_pci_addr_format(e->d_name, sizeof(e->d_name), &addr) != 0) |
| 467 | continue; |
| 468 | |
| 469 | if (rte_pci_ignore_device(&addr)) |
| 470 | continue; |
| 471 | |
| 472 | snprintf(dirname, sizeof(dirname), "%s/%s", |
| 473 | rte_pci_get_sysfs_path(), e->d_name); |
| 474 | |
| 475 | if (pci_scan_one(dirname, &addr) < 0) |
| 476 | goto error; |
| 477 | } |
| 478 | closedir(dir); |
| 479 | return 0; |
| 480 | |
| 481 | error: |
| 482 | closedir(dir); |
| 483 | return -1; |
| 484 | } |
| 485 | |
| 486 | #if defined(RTE_ARCH_X86) |
| 487 | bool |
nothing calls this directly
no test coverage detected