1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright (c) 2009-2018 Solarflare Communications Inc.
10 __checkReturn efx_rc_t
14 efx_port_t *epp = &(enp->en_port);
15 const efx_phy_ops_t *epop = epp->ep_epop;
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);
22 if (enp->en_mod_flags & EFX_MOD_PORT) {
27 enp->en_mod_flags |= EFX_MOD_PORT;
29 epp->ep_mac_type = EFX_MAC_INVALID;
30 epp->ep_link_mode = EFX_LINK_UNKNOWN;
31 epp->ep_mac_drain = B_TRUE;
33 /* Configure the MAC */
34 if ((rc = efx_mac_select(enp)) != 0)
37 epp->ep_emop->emo_reconfigure(enp);
39 /* Pick up current phy capababilities */
40 efx_port_poll(enp, NULL);
43 * Turn on the PHY if available, otherwise reset it, and
44 * reconfigure it with the current configuration.
46 if (epop->epo_power != NULL) {
47 if ((rc = epop->epo_power(enp, B_TRUE)) != 0)
50 if ((rc = epop->epo_reset(enp)) != 0)
54 EFSYS_ASSERT(enp->en_reset_flags & EFX_RESET_PHY);
55 enp->en_reset_flags &= ~EFX_RESET_PHY;
57 if ((rc = epop->epo_reconfigure(enp)) != 0)
67 EFSYS_PROBE1(fail1, efx_rc_t, rc);
69 enp->en_mod_flags &= ~EFX_MOD_PORT;
74 __checkReturn efx_rc_t
77 __out_opt efx_link_mode_t *link_modep)
79 efx_port_t *epp = &(enp->en_port);
80 const efx_mac_ops_t *emop = epp->ep_emop;
81 efx_link_mode_t ignore_link_mode;
84 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
85 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
87 EFSYS_ASSERT(emop != NULL);
89 if (link_modep == NULL)
90 link_modep = &ignore_link_mode;
92 if ((rc = emop->emo_poll(enp, link_modep)) != 0)
98 EFSYS_PROBE1(fail1, efx_rc_t, rc);
103 #if EFSYS_OPT_LOOPBACK
105 __checkReturn efx_rc_t
106 efx_port_loopback_set(
108 __in efx_link_mode_t link_mode,
109 __in efx_loopback_type_t loopback_type)
111 efx_port_t *epp = &(enp->en_port);
112 efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
113 const efx_mac_ops_t *emop = epp->ep_emop;
116 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
117 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
118 EFSYS_ASSERT(emop != NULL);
120 EFSYS_ASSERT(link_mode < EFX_LINK_NMODES);
122 if (EFX_TEST_QWORD_BIT(encp->enc_loopback_types[link_mode],
123 (int)loopback_type) == 0) {
128 if (epp->ep_loopback_type == loopback_type &&
129 epp->ep_loopback_link_mode == link_mode)
132 if ((rc = emop->emo_loopback_set(enp, link_mode, loopback_type)) != 0)
140 EFSYS_PROBE1(fail1, efx_rc_t, rc);
147 static const char * const __efx_loopback_type_name[] = {
188 __checkReturn const char *
189 efx_loopback_type_name(
191 __in efx_loopback_type_t type)
193 EFX_STATIC_ASSERT(EFX_ARRAY_SIZE(__efx_loopback_type_name) ==
194 EFX_LOOPBACK_NTYPES);
196 _NOTE(ARGUNUSED(enp))
197 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
198 EFSYS_ASSERT3U(type, <, EFX_LOOPBACK_NTYPES);
200 return (__efx_loopback_type_name[type]);
203 #endif /* EFSYS_OPT_NAMES */
205 #endif /* EFSYS_OPT_LOOPBACK */
211 efx_port_t *epp = &(enp->en_port);
212 const efx_phy_ops_t *epop = epp->ep_epop;
214 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
215 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
216 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NIC);
217 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
219 EFSYS_ASSERT(epp->ep_mac_drain);
222 epp->ep_mac_type = EFX_MAC_INVALID;
223 epp->ep_mac_drain = B_FALSE;
225 /* Turn off the PHY */
226 if (epop->epo_power != NULL)
227 (void) epop->epo_power(enp, B_FALSE);
229 enp->en_mod_flags &= ~EFX_MOD_PORT;