| 463 | } |
| 464 | |
| 465 | static int |
| 466 | vdev_scan(void) |
| 467 | { |
| 468 | struct rte_vdev_device *dev; |
| 469 | struct rte_devargs *devargs; |
| 470 | struct vdev_custom_scan *custom_scan; |
| 471 | |
| 472 | if (rte_mp_action_register(VDEV_MP_KEY, vdev_action) < 0 && |
| 473 | rte_errno != EEXIST) { |
| 474 | /* for primary, unsupported IPC is not an error */ |
| 475 | if (rte_eal_process_type() == RTE_PROC_PRIMARY && |
| 476 | rte_errno == ENOTSUP) |
| 477 | goto scan; |
| 478 | VDEV_LOG(ERR, "Failed to add vdev mp action"); |
| 479 | return -1; |
| 480 | } |
| 481 | |
| 482 | if (rte_eal_process_type() == RTE_PROC_SECONDARY) { |
| 483 | struct rte_mp_msg mp_req, *mp_rep; |
| 484 | struct rte_mp_reply mp_reply; |
| 485 | struct timespec ts = {.tv_sec = 5, .tv_nsec = 0}; |
| 486 | struct vdev_param *req = (struct vdev_param *)mp_req.param; |
| 487 | struct vdev_param *resp; |
| 488 | |
| 489 | strlcpy(mp_req.name, VDEV_MP_KEY, sizeof(mp_req.name)); |
| 490 | mp_req.len_param = sizeof(*req); |
| 491 | mp_req.num_fds = 0; |
| 492 | req->type = VDEV_SCAN_REQ; |
| 493 | if (rte_mp_request_sync(&mp_req, &mp_reply, &ts) == 0 && |
| 494 | mp_reply.nb_received == 1) { |
| 495 | mp_rep = &mp_reply.msgs[0]; |
| 496 | resp = (struct vdev_param *)mp_rep->param; |
| 497 | VDEV_LOG(INFO, "Received %d vdevs", resp->num); |
| 498 | free(mp_reply.msgs); |
| 499 | } else |
| 500 | VDEV_LOG(ERR, "Failed to request vdev from primary"); |
| 501 | |
| 502 | /* Fall through to allow private vdevs in secondary process */ |
| 503 | } |
| 504 | |
| 505 | scan: |
| 506 | /* call custom scan callbacks if any */ |
| 507 | rte_spinlock_lock(&vdev_custom_scan_lock); |
| 508 | TAILQ_FOREACH(custom_scan, &vdev_custom_scans, next) { |
| 509 | if (custom_scan->callback != NULL) |
| 510 | /* |
| 511 | * the callback should update devargs list |
| 512 | * by calling rte_devargs_insert() with |
| 513 | * devargs.bus = rte_bus_find_by_name("vdev"); |
| 514 | * devargs.type = RTE_DEVTYPE_VIRTUAL; |
| 515 | * devargs.policy = RTE_DEV_ALLOWED; |
| 516 | */ |
| 517 | custom_scan->callback(custom_scan->user_arg); |
| 518 | } |
| 519 | rte_spinlock_unlock(&vdev_custom_scan_lock); |
| 520 | |
| 521 | /* for virtual devices we scan the devargs_list populated via cmdline */ |
| 522 | RTE_EAL_DEVARGS_FOREACH("vdev", devargs) { |
nothing calls this directly
no test coverage detected