| 552 | } |
| 553 | |
| 554 | int |
| 555 | sfc_start(struct sfc_adapter *sa) |
| 556 | { |
| 557 | unsigned int start_tries = 3; |
| 558 | int rc; |
| 559 | |
| 560 | sfc_log_init(sa, "entry"); |
| 561 | |
| 562 | SFC_ASSERT(sfc_adapter_is_locked(sa)); |
| 563 | |
| 564 | switch (sa->state) { |
| 565 | case SFC_ETHDEV_CONFIGURED: |
| 566 | break; |
| 567 | case SFC_ETHDEV_STARTED: |
| 568 | sfc_notice(sa, "already started"); |
| 569 | return 0; |
| 570 | default: |
| 571 | rc = EINVAL; |
| 572 | goto fail_bad_state; |
| 573 | } |
| 574 | |
| 575 | sa->state = SFC_ETHDEV_STARTING; |
| 576 | |
| 577 | rc = 0; |
| 578 | do { |
| 579 | /* |
| 580 | * FIXME Try to recreate vSwitch on start retry. |
| 581 | * vSwitch is absent after MC reboot like events and |
| 582 | * we should recreate it. May be we need proper |
| 583 | * indication instead of guessing. |
| 584 | */ |
| 585 | if (rc != 0) { |
| 586 | sfc_sriov_vswitch_destroy(sa); |
| 587 | rc = sfc_sriov_vswitch_create(sa); |
| 588 | if (rc != 0) |
| 589 | goto fail_sriov_vswitch_create; |
| 590 | } |
| 591 | rc = sfc_try_start(sa); |
| 592 | } while ((--start_tries > 0) && |
| 593 | (rc == EIO || rc == EAGAIN || rc == ENOENT || rc == EINVAL)); |
| 594 | |
| 595 | if (rc != 0) |
| 596 | goto fail_try_start; |
| 597 | |
| 598 | sa->state = SFC_ETHDEV_STARTED; |
| 599 | sfc_log_init(sa, "done"); |
| 600 | return 0; |
| 601 | |
| 602 | fail_try_start: |
| 603 | fail_sriov_vswitch_create: |
| 604 | sa->state = SFC_ETHDEV_CONFIGURED; |
| 605 | fail_bad_state: |
| 606 | sfc_log_init(sa, "failed %d", rc); |
| 607 | return rc; |
| 608 | } |
| 609 | |
| 610 | void |
| 611 | sfc_stop(struct sfc_adapter *sa) |
no test coverage detected