| 3734 | } |
| 3735 | |
| 3736 | void |
| 3737 | detach_devargs(char *identifier) |
| 3738 | { |
| 3739 | struct rte_dev_iterator iterator; |
| 3740 | struct rte_devargs da; |
| 3741 | portid_t port_id; |
| 3742 | |
| 3743 | printf("Removing a device...\n"); |
| 3744 | |
| 3745 | memset(&da, 0, sizeof(da)); |
| 3746 | if (rte_devargs_parsef(&da, "%s", identifier)) { |
| 3747 | fprintf(stderr, "cannot parse identifier\n"); |
| 3748 | return; |
| 3749 | } |
| 3750 | |
| 3751 | RTE_ETH_FOREACH_MATCHING_DEV(port_id, identifier, &iterator) { |
| 3752 | if (ports[port_id].port_status != RTE_PORT_CLOSED) { |
| 3753 | if (ports[port_id].port_status != RTE_PORT_STOPPED) { |
| 3754 | fprintf(stderr, "Port %u not stopped\n", |
| 3755 | port_id); |
| 3756 | rte_eth_iterator_cleanup(&iterator); |
| 3757 | rte_devargs_reset(&da); |
| 3758 | return; |
| 3759 | } |
| 3760 | flush_port_owned_resources(port_id); |
| 3761 | } |
| 3762 | } |
| 3763 | |
| 3764 | if (rte_eal_hotplug_remove(rte_bus_name(da.bus), da.name) != 0) { |
| 3765 | TESTPMD_LOG(ERR, "Failed to detach device %s(%s)\n", |
| 3766 | da.name, rte_bus_name(da.bus)); |
| 3767 | rte_devargs_reset(&da); |
| 3768 | return; |
| 3769 | } |
| 3770 | |
| 3771 | remove_invalid_ports(); |
| 3772 | |
| 3773 | printf("Device %s is detached\n", identifier); |
| 3774 | printf("Now total ports is %d\n", nb_ports); |
| 3775 | printf("Done\n"); |
| 3776 | rte_devargs_reset(&da); |
| 3777 | } |
| 3778 | |
| 3779 | void |
| 3780 | pmd_test_exit(void) |
no test coverage detected