Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/sfxge/common/efx_port.c
Property | Old Value | New Value |
---|---|---|
svn:eol-style | null | native \ No newline at end of property |
svn:mime-type | null | text/plain \ No newline at end of property |
/*- | /*- | ||||
* Copyright 2009 Solarflare Communications Inc. All rights reserved. | * Copyright (c) 2009-2015 Solarflare Communications Inc. | ||||
* All rights reserved. | |||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
* modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions are met: | ||||
* are met: | |||||
* 1. Redistributions of source code must retain the above copyright | |||||
* notice, this list of conditions and the following disclaimer. | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in the | |||||
* documentation and/or other materials provided with the distribution. | |||||
* | * | ||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS AND | * 1. Redistributions of source code must retain the above copyright notice, | ||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | * this list of conditions and the following disclaimer. | ||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | * 2. Redistributions in binary form must reproduce the above copyright notice, | ||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | * this list of conditions and the following disclaimer in the documentation | ||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | * and/or other materials provided with the distribution. | ||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | * | ||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||||
* SUCH DAMAGE. | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | |||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | |||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | |||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||
* | |||||
* The views and conclusions contained in the software and documentation are | |||||
* those of the authors and should not be interpreted as representing official | |||||
* policies, either expressed or implied, of the FreeBSD Project. | |||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include "efsys.h" | #include "efsys.h" | ||||
#include "efx.h" | #include "efx.h" | ||||
#include "efx_types.h" | #include "efx_types.h" | ||||
Show All 24 Lines | efx_port_init( | ||||
epp->ep_mac_drain = B_TRUE; | epp->ep_mac_drain = B_TRUE; | ||||
/* Configure the MAC */ | /* Configure the MAC */ | ||||
if ((rc = efx_mac_select(enp)) != 0) | if ((rc = efx_mac_select(enp)) != 0) | ||||
goto fail1; | goto fail1; | ||||
epp->ep_emop->emo_reconfigure(enp); | epp->ep_emop->emo_reconfigure(enp); | ||||
/* Pick up current phy capababilities */ | |||||
efx_port_poll(enp, NULL); | |||||
/* | /* | ||||
* Turn on the PHY if available, otherwise reset it, and | * Turn on the PHY if available, otherwise reset it, and | ||||
* reconfigure it with the current configuration. | * reconfigure it with the current configuration. | ||||
*/ | */ | ||||
if (epop->epo_power != NULL) { | if (epop->epo_power != NULL) { | ||||
if ((rc = epop->epo_power(enp, B_TRUE)) != 0) | if ((rc = epop->epo_power(enp, B_TRUE)) != 0) | ||||
goto fail2; | goto fail2; | ||||
} else { | } else { | ||||
Show All 19 Lines | fail1: | ||||
enp->en_mod_flags &= ~EFX_MOD_PORT; | enp->en_mod_flags &= ~EFX_MOD_PORT; | ||||
return (rc); | return (rc); | ||||
} | } | ||||
__checkReturn int | __checkReturn int | ||||
efx_port_poll( | efx_port_poll( | ||||
__in efx_nic_t *enp, | __in efx_nic_t *enp, | ||||
__out efx_link_mode_t *link_modep) | __out_opt efx_link_mode_t *link_modep) | ||||
{ | { | ||||
efx_port_t *epp = &(enp->en_port); | efx_port_t *epp = &(enp->en_port); | ||||
efx_mac_ops_t *emop = epp->ep_emop; | efx_mac_ops_t *emop = epp->ep_emop; | ||||
efx_link_mode_t ignore_link_mode; | efx_link_mode_t ignore_link_mode; | ||||
int rc; | int rc; | ||||
EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); | EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); | ||||
EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT); | EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT); | ||||
Show All 28 Lines | efx_port_loopback_set( | ||||
efx_mac_ops_t *emop = epp->ep_emop; | efx_mac_ops_t *emop = epp->ep_emop; | ||||
int rc; | int rc; | ||||
EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); | EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); | ||||
EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT); | EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PORT); | ||||
EFSYS_ASSERT(emop != NULL); | EFSYS_ASSERT(emop != NULL); | ||||
EFSYS_ASSERT(link_mode < EFX_LINK_NMODES); | EFSYS_ASSERT(link_mode < EFX_LINK_NMODES); | ||||
if ((1 << loopback_type) & ~encp->enc_loopback_types[link_mode]) { | |||||
if (EFX_TEST_QWORD_BIT(encp->enc_loopback_types[link_mode], | |||||
loopback_type) == 0) { | |||||
rc = ENOTSUP; | rc = ENOTSUP; | ||||
goto fail1; | goto fail1; | ||||
} | } | ||||
if (epp->ep_loopback_type == loopback_type && | if (epp->ep_loopback_type == loopback_type && | ||||
epp->ep_loopback_link_mode == link_mode) | epp->ep_loopback_link_mode == link_mode) | ||||
return (0); | return (0); | ||||
if ((rc = emop->emo_loopback_set(enp, link_mode, loopback_type)) != 0) | if ((rc = emop->emo_loopback_set(enp, link_mode, loopback_type)) != 0) | ||||
goto fail2; | goto fail2; | ||||
return (0); | return (0); | ||||
fail2: | fail2: | ||||
EFSYS_PROBE(fail2); | EFSYS_PROBE(fail2); | ||||
fail1: | fail1: | ||||
EFSYS_PROBE1(fail1, int, rc); | EFSYS_PROBE1(fail1, int, rc); | ||||
return (rc); | return (rc); | ||||
} | } | ||||
#if EFSYS_OPT_NAMES | #if EFSYS_OPT_NAMES | ||||
static const char __cs * __cs __efx_loopback_type_name[] = { | static const char *__efx_loopback_type_name[] = { | ||||
"OFF", | "OFF", | ||||
"DATA", | "DATA", | ||||
"GMAC", | "GMAC", | ||||
"XGMII", | "XGMII", | ||||
"XGXS", | "XGXS", | ||||
"XAUI", | "XAUI", | ||||
"GMII", | "GMII", | ||||
"SGMII", | "SGMII", | ||||
"XGBR", | "XGBR", | ||||
"XFI", | "XFI", | ||||
"XAUI_FAR", | "XAUI_FAR", | ||||
"GMII_FAR", | "GMII_FAR", | ||||
"SGMII_FAR", | "SGMII_FAR", | ||||
"XFI_FAR", | "XFI_FAR", | ||||
"GPHY", | "GPHY", | ||||
"PHY_XS", | "PHY_XS", | ||||
"PCS", | "PCS", | ||||
"PMA_PMD", | "PMA_PMD", | ||||
"XPORT", | |||||
"XGMII_WS", | |||||
"XAUI_WS", | |||||
"XAUI_WS_FAR", | |||||
"XAUI_WS_NEAR", | |||||
"GMII_WS", | |||||
"XFI_WS", | |||||
"XFI_WS_FAR", | |||||
"PHYXS_WS", | |||||
"PMA_INT", | |||||
"SD_NEAR", | |||||
"SD_FAR", | |||||
"PMA_INT_WS", | |||||
"SD_FEP2_WS", | |||||
"SD_FEP1_5_WS", | |||||
"SD_FEP_WS", | |||||
"SD_FES_WS", | |||||
}; | }; | ||||
__checkReturn const char __cs * | __checkReturn const char * | ||||
efx_loopback_type_name( | efx_loopback_type_name( | ||||
__in efx_nic_t *enp, | __in efx_nic_t *enp, | ||||
__in efx_loopback_type_t type) | __in efx_loopback_type_t type) | ||||
{ | { | ||||
EFX_STATIC_ASSERT(EFX_ARRAY_SIZE(__efx_loopback_type_name) == | |||||
EFX_LOOPBACK_NTYPES); | |||||
_NOTE(ARGUNUSED(enp)) | _NOTE(ARGUNUSED(enp)) | ||||
EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); | EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); | ||||
EFSYS_ASSERT3U(type, <, EFX_LOOPBACK_NTYPES); | EFSYS_ASSERT3U(type, <, EFX_LOOPBACK_NTYPES); | ||||
return (__efx_loopback_type_name[type]); | return (__efx_loopback_type_name[type]); | ||||
} | } | ||||
#endif /* EFSYS_OPT_NAMES */ | #endif /* EFSYS_OPT_NAMES */ | ||||
Show All 28 Lines |