2 * Copyright (c) 2009-2016 Solarflare Communications Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * The views and conclusions contained in the software and documentation are
27 * those of the authors and should not be interpreted as representing official
28 * policies, either expressed or implied, of the FreeBSD Project.
34 __checkReturn efx_rc_t
38 efx_port_t *epp = &(enp->en_port);
39 const efx_phy_ops_t *epop = epp->ep_epop;
42 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
43 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
44 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NIC);
46 if (enp->en_mod_flags & EFX_MOD_PORT) {
51 enp->en_mod_flags |= EFX_MOD_PORT;
53 epp->ep_mac_type = EFX_MAC_INVALID;
54 epp->ep_link_mode = EFX_LINK_UNKNOWN;
55 epp->ep_mac_drain = B_TRUE;
57 /* Configure the MAC */
58 if ((rc = efx_mac_select(enp)) != 0)
61 epp->ep_emop->emo_reconfigure(enp);
63 /* Pick up current phy capababilities */
64 efx_port_poll(enp, NULL);
67 * Turn on the PHY if available, otherwise reset it, and
68 * reconfigure it with the current configuration.
70 if (epop->epo_power != NULL) {
71 if ((rc = epop->epo_power(enp, B_TRUE)) != 0)
74 if ((rc = epop->epo_reset(enp)) != 0)
78 EFSYS_ASSERT(enp->en_reset_flags & EFX_RESET_PHY);
79 enp->en_reset_flags &= ~EFX_RESET_PHY;
81 if ((rc = epop->epo_reconfigure(enp)) != 0)
91 EFSYS_PROBE1(fail1, efx_rc_t, rc);
93 enp->en_mod_flags &= ~EFX_MOD_PORT;
98 __checkReturn efx_rc_t
101 __out_opt efx_link_mode_t *link_modep)
103 efx_port_t *epp = &(enp->en_port);
104 const efx_mac_ops_t *emop = epp->ep_emop;
105 efx_link_mode_t ignore_link_mode;
108 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
109 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
111 EFSYS_ASSERT(emop != NULL);
112 EFSYS_ASSERT(!epp->ep_mac_stats_pending);
114 if (link_modep == NULL)
115 link_modep = &ignore_link_mode;
117 if ((rc = emop->emo_poll(enp, link_modep)) != 0)
123 EFSYS_PROBE1(fail1, efx_rc_t, rc);
132 efx_port_t *epp = &(enp->en_port);
133 const efx_phy_ops_t *epop = epp->ep_epop;
135 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
136 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
137 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NIC);
138 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT);
140 EFSYS_ASSERT(epp->ep_mac_drain);
143 epp->ep_mac_type = EFX_MAC_INVALID;
144 epp->ep_mac_drain = B_FALSE;
146 /* Turn off the PHY */
147 if (epop->epo_power != NULL)
148 (void) epop->epo_power(enp, B_FALSE);
150 enp->en_mod_flags &= ~EFX_MOD_PORT;