| 8 | #include "efx_impl.h" |
| 9 | |
| 10 | __checkReturn efx_rc_t |
| 11 | efx_port_init( |
| 12 | __in efx_nic_t *enp) |
| 13 | { |
| 14 | efx_port_t *epp = &(enp->en_port); |
| 15 | const efx_phy_ops_t *epop = epp->ep_epop; |
| 16 | efx_rc_t rc; |
| 17 | |
| 18 | EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); |
| 19 | EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE); |
| 20 | EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NIC); |
| 21 | |
| 22 | if (enp->en_mod_flags & EFX_MOD_PORT) { |
| 23 | rc = EINVAL; |
| 24 | goto fail1; |
| 25 | } |
| 26 | |
| 27 | enp->en_mod_flags |= EFX_MOD_PORT; |
| 28 | |
| 29 | epp->ep_mac_type = EFX_MAC_INVALID; |
| 30 | epp->ep_link_mode = EFX_LINK_UNKNOWN; |
| 31 | epp->ep_mac_drain = B_TRUE; |
| 32 | |
| 33 | /* Configure the MAC */ |
| 34 | if ((rc = efx_mac_select(enp)) != 0) |
| 35 | goto fail1; |
| 36 | |
| 37 | epp->ep_emop->emo_reconfigure(enp); |
| 38 | |
| 39 | /* Pick up current phy capababilities */ |
| 40 | (void) efx_port_poll(enp, NULL); |
| 41 | |
| 42 | /* |
| 43 | * Turn on the PHY if available, otherwise reset it, and |
| 44 | * reconfigure it with the current configuration. |
| 45 | */ |
| 46 | if (epop->epo_power != NULL) { |
| 47 | if ((rc = epop->epo_power(enp, B_TRUE)) != 0) |
| 48 | goto fail2; |
| 49 | } else { |
| 50 | if ((rc = epop->epo_reset(enp)) != 0) |
| 51 | goto fail2; |
| 52 | } |
| 53 | |
| 54 | EFSYS_ASSERT(enp->en_reset_flags & EFX_RESET_PHY); |
| 55 | enp->en_reset_flags &= ~EFX_RESET_PHY; |
| 56 | |
| 57 | if ((rc = epop->epo_reconfigure(enp)) != 0) |
| 58 | goto fail3; |
| 59 | |
| 60 | return (0); |
| 61 | |
| 62 | fail3: |
| 63 | EFSYS_PROBE(fail3); |
| 64 | fail2: |
| 65 | EFSYS_PROBE(fail2); |
| 66 | fail1: |
| 67 | EFSYS_PROBE1(fail1, efx_rc_t, rc); |
no test coverage detected