| 3555 | } |
| 3556 | |
| 3557 | void |
| 3558 | reset_port(portid_t pid) |
| 3559 | { |
| 3560 | int diag; |
| 3561 | portid_t pi; |
| 3562 | struct rte_port *port; |
| 3563 | |
| 3564 | if (port_id_is_invalid(pid, ENABLED_WARN)) |
| 3565 | return; |
| 3566 | |
| 3567 | if ((pid == (portid_t)RTE_PORT_ALL && !all_ports_stopped()) || |
| 3568 | (pid != (portid_t)RTE_PORT_ALL && !port_is_stopped(pid))) { |
| 3569 | fprintf(stderr, |
| 3570 | "Can not reset port(s), please stop port(s) first.\n"); |
| 3571 | return; |
| 3572 | } |
| 3573 | |
| 3574 | printf("Resetting ports...\n"); |
| 3575 | |
| 3576 | RTE_ETH_FOREACH_DEV(pi) { |
| 3577 | if (pid != pi && pid != (portid_t)RTE_PORT_ALL) |
| 3578 | continue; |
| 3579 | |
| 3580 | if (port_is_forwarding(pi) != 0 && test_done == 0) { |
| 3581 | fprintf(stderr, |
| 3582 | "Please remove port %d from forwarding configuration.\n", |
| 3583 | pi); |
| 3584 | continue; |
| 3585 | } |
| 3586 | |
| 3587 | if (port_is_bonding_member(pi)) { |
| 3588 | fprintf(stderr, |
| 3589 | "Please remove port %d from bonding device.\n", |
| 3590 | pi); |
| 3591 | continue; |
| 3592 | } |
| 3593 | |
| 3594 | if (is_proc_primary()) { |
| 3595 | diag = rte_eth_dev_reset(pi); |
| 3596 | if (diag == 0) { |
| 3597 | port = &ports[pi]; |
| 3598 | port->need_reconfig = 1; |
| 3599 | port->need_reconfig_queues = 1; |
| 3600 | } else { |
| 3601 | fprintf(stderr, "Failed to reset port %d. diag=%d\n", |
| 3602 | pi, diag); |
| 3603 | } |
| 3604 | } |
| 3605 | } |
| 3606 | |
| 3607 | printf("Done\n"); |
| 3608 | } |
| 3609 | |
| 3610 | void |
| 3611 | attach_port(char *identifier) |
no test coverage detected