Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/sfxge/common/efx_phy.c
Show All 30 Lines | |||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include "efx.h" | #include "efx.h" | ||||
#include "efx_impl.h" | #include "efx_impl.h" | ||||
#if EFSYS_OPT_SIENA | #if EFSYS_OPT_SIENA | ||||
static efx_phy_ops_t __efx_phy_siena_ops = { | static const efx_phy_ops_t __efx_phy_siena_ops = { | ||||
siena_phy_power, /* epo_power */ | siena_phy_power, /* epo_power */ | ||||
NULL, /* epo_reset */ | NULL, /* epo_reset */ | ||||
siena_phy_reconfigure, /* epo_reconfigure */ | siena_phy_reconfigure, /* epo_reconfigure */ | ||||
siena_phy_verify, /* epo_verify */ | siena_phy_verify, /* epo_verify */ | ||||
NULL, /* epo_uplink_check */ | NULL, /* epo_uplink_check */ | ||||
NULL, /* epo_downlink_check */ | NULL, /* epo_downlink_check */ | ||||
siena_phy_oui_get, /* epo_oui_get */ | siena_phy_oui_get, /* epo_oui_get */ | ||||
#if EFSYS_OPT_PHY_STATS | #if EFSYS_OPT_PHY_STATS | ||||
Show All 11 Lines | #if EFSYS_OPT_BIST | ||||
siena_phy_bist_start, /* epo_bist_start */ | siena_phy_bist_start, /* epo_bist_start */ | ||||
siena_phy_bist_poll, /* epo_bist_poll */ | siena_phy_bist_poll, /* epo_bist_poll */ | ||||
siena_phy_bist_stop, /* epo_bist_stop */ | siena_phy_bist_stop, /* epo_bist_stop */ | ||||
#endif /* EFSYS_OPT_BIST */ | #endif /* EFSYS_OPT_BIST */ | ||||
}; | }; | ||||
#endif /* EFSYS_OPT_SIENA */ | #endif /* EFSYS_OPT_SIENA */ | ||||
#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD | #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD | ||||
static efx_phy_ops_t __efx_phy_ef10_ops = { | static const efx_phy_ops_t __efx_phy_ef10_ops = { | ||||
ef10_phy_power, /* epo_power */ | ef10_phy_power, /* epo_power */ | ||||
NULL, /* epo_reset */ | NULL, /* epo_reset */ | ||||
ef10_phy_reconfigure, /* epo_reconfigure */ | ef10_phy_reconfigure, /* epo_reconfigure */ | ||||
ef10_phy_verify, /* epo_verify */ | ef10_phy_verify, /* epo_verify */ | ||||
NULL, /* epo_uplink_check */ | NULL, /* epo_uplink_check */ | ||||
NULL, /* epo_downlink_check */ | NULL, /* epo_downlink_check */ | ||||
ef10_phy_oui_get, /* epo_oui_get */ | ef10_phy_oui_get, /* epo_oui_get */ | ||||
#if EFSYS_OPT_PHY_STATS | #if EFSYS_OPT_PHY_STATS | ||||
Show All 17 Lines | |||||
#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */ | #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */ | ||||
__checkReturn efx_rc_t | __checkReturn efx_rc_t | ||||
efx_phy_probe( | efx_phy_probe( | ||||
__in efx_nic_t *enp) | __in efx_nic_t *enp) | ||||
{ | { | ||||
efx_port_t *epp = &(enp->en_port); | efx_port_t *epp = &(enp->en_port); | ||||
efx_nic_cfg_t *encp = &(enp->en_nic_cfg); | efx_nic_cfg_t *encp = &(enp->en_nic_cfg); | ||||
efx_phy_ops_t *epop; | const efx_phy_ops_t *epop; | ||||
efx_rc_t rc; | efx_rc_t rc; | ||||
EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); | EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); | ||||
epp->ep_port = encp->enc_port; | epp->ep_port = encp->enc_port; | ||||
epp->ep_phy_type = encp->enc_phy_type; | epp->ep_phy_type = encp->enc_phy_type; | ||||
/* Hook in operations structure */ | /* Hook in operations structure */ | ||||
switch (enp->en_family) { | switch (enp->en_family) { | ||||
#if EFSYS_OPT_SIENA | #if EFSYS_OPT_SIENA | ||||
case EFX_FAMILY_SIENA: | case EFX_FAMILY_SIENA: | ||||
epop = (efx_phy_ops_t *)&__efx_phy_siena_ops; | epop = &__efx_phy_siena_ops; | ||||
break; | break; | ||||
#endif /* EFSYS_OPT_SIENA */ | #endif /* EFSYS_OPT_SIENA */ | ||||
#if EFSYS_OPT_HUNTINGTON | #if EFSYS_OPT_HUNTINGTON | ||||
case EFX_FAMILY_HUNTINGTON: | case EFX_FAMILY_HUNTINGTON: | ||||
epop = (efx_phy_ops_t *)&__efx_phy_ef10_ops; | epop = &__efx_phy_ef10_ops; | ||||
break; | break; | ||||
#endif /* EFSYS_OPT_HUNTINGTON */ | #endif /* EFSYS_OPT_HUNTINGTON */ | ||||
#if EFSYS_OPT_MEDFORD | #if EFSYS_OPT_MEDFORD | ||||
case EFX_FAMILY_MEDFORD: | case EFX_FAMILY_MEDFORD: | ||||
epop = (efx_phy_ops_t *)&__efx_phy_ef10_ops; | epop = &__efx_phy_ef10_ops; | ||||
break; | break; | ||||
#endif /* EFSYS_OPT_MEDFORD */ | #endif /* EFSYS_OPT_MEDFORD */ | ||||
default: | default: | ||||
rc = ENOTSUP; | rc = ENOTSUP; | ||||
goto fail1; | goto fail1; | ||||
} | } | ||||
epp->ep_epop = epop; | epp->ep_epop = epop; | ||||
Show All 9 Lines | fail1: | ||||
return (rc); | return (rc); | ||||
} | } | ||||
__checkReturn efx_rc_t | __checkReturn efx_rc_t | ||||
efx_phy_verify( | efx_phy_verify( | ||||
__in efx_nic_t *enp) | __in efx_nic_t *enp) | ||||
{ | { | ||||
efx_port_t *epp = &(enp->en_port); | efx_port_t *epp = &(enp->en_port); | ||||
efx_phy_ops_t *epop = epp->ep_epop; | const efx_phy_ops_t *epop = epp->ep_epop; | ||||
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); | ||||
return (epop->epo_verify(enp)); | return (epop->epo_verify(enp)); | ||||
} | } | ||||
#if EFSYS_OPT_PHY_LED_CONTROL | #if EFSYS_OPT_PHY_LED_CONTROL | ||||
__checkReturn efx_rc_t | __checkReturn efx_rc_t | ||||
efx_phy_led_set( | efx_phy_led_set( | ||||
__in efx_nic_t *enp, | __in efx_nic_t *enp, | ||||
__in efx_phy_led_mode_t mode) | __in efx_phy_led_mode_t mode) | ||||
{ | { | ||||
efx_nic_cfg_t *encp = (&enp->en_nic_cfg); | efx_nic_cfg_t *encp = (&enp->en_nic_cfg); | ||||
efx_port_t *epp = &(enp->en_port); | efx_port_t *epp = &(enp->en_port); | ||||
efx_phy_ops_t *epop = epp->ep_epop; | const efx_phy_ops_t *epop = epp->ep_epop; | ||||
uint32_t mask; | uint32_t mask; | ||||
efx_rc_t rc; | efx_rc_t 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); | ||||
if (epp->ep_phy_led_mode == mode) | if (epp->ep_phy_led_mode == mode) | ||||
goto done; | goto done; | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
__checkReturn efx_rc_t | __checkReturn efx_rc_t | ||||
efx_phy_adv_cap_set( | efx_phy_adv_cap_set( | ||||
__in efx_nic_t *enp, | __in efx_nic_t *enp, | ||||
__in uint32_t mask) | __in uint32_t mask) | ||||
{ | { | ||||
efx_port_t *epp = &(enp->en_port); | efx_port_t *epp = &(enp->en_port); | ||||
efx_phy_ops_t *epop = epp->ep_epop; | const efx_phy_ops_t *epop = epp->ep_epop; | ||||
uint32_t old_mask; | uint32_t old_mask; | ||||
efx_rc_t rc; | efx_rc_t 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); | ||||
if ((mask & ~epp->ep_phy_cap_mask) != 0) { | if ((mask & ~epp->ep_phy_cap_mask) != 0) { | ||||
rc = ENOTSUP; | rc = ENOTSUP; | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
__checkReturn efx_rc_t | __checkReturn efx_rc_t | ||||
efx_phy_oui_get( | efx_phy_oui_get( | ||||
__in efx_nic_t *enp, | __in efx_nic_t *enp, | ||||
__out uint32_t *ouip) | __out uint32_t *ouip) | ||||
{ | { | ||||
efx_port_t *epp = &(enp->en_port); | efx_port_t *epp = &(enp->en_port); | ||||
efx_phy_ops_t *epop = epp->ep_epop; | const efx_phy_ops_t *epop = epp->ep_epop; | ||||
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); | ||||
return (epop->epo_oui_get(enp, ouip)); | return (epop->epo_oui_get(enp, ouip)); | ||||
} | } | ||||
void | void | ||||
▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | #endif /* EFSYS_OPT_NAMES */ | ||||
__checkReturn efx_rc_t | __checkReturn efx_rc_t | ||||
efx_phy_stats_update( | efx_phy_stats_update( | ||||
__in efx_nic_t *enp, | __in efx_nic_t *enp, | ||||
__in efsys_mem_t *esmp, | __in efsys_mem_t *esmp, | ||||
__inout_ecount(EFX_PHY_NSTATS) uint32_t *stat) | __inout_ecount(EFX_PHY_NSTATS) uint32_t *stat) | ||||
{ | { | ||||
efx_port_t *epp = &(enp->en_port); | efx_port_t *epp = &(enp->en_port); | ||||
efx_phy_ops_t *epop = epp->ep_epop; | const efx_phy_ops_t *epop = epp->ep_epop; | ||||
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); | ||||
return (epop->epo_stats_update(enp, esmp, stat)); | return (epop->epo_stats_update(enp, esmp, stat)); | ||||
} | } | ||||
#endif /* EFSYS_OPT_PHY_STATS */ | #endif /* EFSYS_OPT_PHY_STATS */ | ||||
#if EFSYS_OPT_PHY_PROPS | #if EFSYS_OPT_PHY_PROPS | ||||
#if EFSYS_OPT_NAMES | #if EFSYS_OPT_NAMES | ||||
const char * | const char * | ||||
efx_phy_prop_name( | efx_phy_prop_name( | ||||
__in efx_nic_t *enp, | __in efx_nic_t *enp, | ||||
__in unsigned int id) | __in unsigned int id) | ||||
{ | { | ||||
efx_port_t *epp = &(enp->en_port); | efx_port_t *epp = &(enp->en_port); | ||||
efx_phy_ops_t *epop = epp->ep_epop; | const efx_phy_ops_t *epop = epp->ep_epop; | ||||
EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); | EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); | ||||
EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE); | EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE); | ||||
return (epop->epo_prop_name(enp, id)); | return (epop->epo_prop_name(enp, id)); | ||||
} | } | ||||
#endif /* EFSYS_OPT_NAMES */ | #endif /* EFSYS_OPT_NAMES */ | ||||
__checkReturn efx_rc_t | __checkReturn efx_rc_t | ||||
efx_phy_prop_get( | efx_phy_prop_get( | ||||
__in efx_nic_t *enp, | __in efx_nic_t *enp, | ||||
__in unsigned int id, | __in unsigned int id, | ||||
__in uint32_t flags, | __in uint32_t flags, | ||||
__out uint32_t *valp) | __out uint32_t *valp) | ||||
{ | { | ||||
efx_port_t *epp = &(enp->en_port); | efx_port_t *epp = &(enp->en_port); | ||||
efx_phy_ops_t *epop = epp->ep_epop; | const efx_phy_ops_t *epop = epp->ep_epop; | ||||
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); | ||||
return (epop->epo_prop_get(enp, id, flags, valp)); | return (epop->epo_prop_get(enp, id, flags, valp)); | ||||
} | } | ||||
__checkReturn efx_rc_t | __checkReturn efx_rc_t | ||||
efx_phy_prop_set( | efx_phy_prop_set( | ||||
__in efx_nic_t *enp, | __in efx_nic_t *enp, | ||||
__in unsigned int id, | __in unsigned int id, | ||||
__in uint32_t val) | __in uint32_t val) | ||||
{ | { | ||||
efx_port_t *epp = &(enp->en_port); | efx_port_t *epp = &(enp->en_port); | ||||
efx_phy_ops_t *epop = epp->ep_epop; | const efx_phy_ops_t *epop = epp->ep_epop; | ||||
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); | ||||
return (epop->epo_prop_set(enp, id, val)); | return (epop->epo_prop_set(enp, id, val)); | ||||
} | } | ||||
#endif /* EFSYS_OPT_PHY_STATS */ | #endif /* EFSYS_OPT_PHY_STATS */ | ||||
#if EFSYS_OPT_BIST | #if EFSYS_OPT_BIST | ||||
__checkReturn efx_rc_t | __checkReturn efx_rc_t | ||||
efx_bist_enable_offline( | efx_bist_enable_offline( | ||||
__in efx_nic_t *enp) | __in efx_nic_t *enp) | ||||
{ | { | ||||
efx_port_t *epp = &(enp->en_port); | efx_port_t *epp = &(enp->en_port); | ||||
efx_phy_ops_t *epop = epp->ep_epop; | const efx_phy_ops_t *epop = epp->ep_epop; | ||||
efx_rc_t rc; | efx_rc_t rc; | ||||
EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); | EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); | ||||
if (epop->epo_bist_enable_offline == NULL) { | if (epop->epo_bist_enable_offline == NULL) { | ||||
rc = ENOTSUP; | rc = ENOTSUP; | ||||
goto fail1; | goto fail1; | ||||
} | } | ||||
Show All 13 Lines | |||||
} | } | ||||
__checkReturn efx_rc_t | __checkReturn efx_rc_t | ||||
efx_bist_start( | efx_bist_start( | ||||
__in efx_nic_t *enp, | __in efx_nic_t *enp, | ||||
__in efx_bist_type_t type) | __in efx_bist_type_t type) | ||||
{ | { | ||||
efx_port_t *epp = &(enp->en_port); | efx_port_t *epp = &(enp->en_port); | ||||
efx_phy_ops_t *epop = epp->ep_epop; | const efx_phy_ops_t *epop = epp->ep_epop; | ||||
efx_rc_t rc; | efx_rc_t rc; | ||||
EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); | EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); | ||||
EFSYS_ASSERT3U(type, !=, EFX_BIST_TYPE_UNKNOWN); | EFSYS_ASSERT3U(type, !=, EFX_BIST_TYPE_UNKNOWN); | ||||
EFSYS_ASSERT3U(type, <, EFX_BIST_TYPE_NTYPES); | EFSYS_ASSERT3U(type, <, EFX_BIST_TYPE_NTYPES); | ||||
EFSYS_ASSERT3U(epp->ep_current_bist, ==, EFX_BIST_TYPE_UNKNOWN); | EFSYS_ASSERT3U(epp->ep_current_bist, ==, EFX_BIST_TYPE_UNKNOWN); | ||||
Show All 22 Lines | efx_bist_poll( | ||||
__in efx_nic_t *enp, | __in efx_nic_t *enp, | ||||
__in efx_bist_type_t type, | __in efx_bist_type_t type, | ||||
__out efx_bist_result_t *resultp, | __out efx_bist_result_t *resultp, | ||||
__out_opt uint32_t *value_maskp, | __out_opt uint32_t *value_maskp, | ||||
__out_ecount_opt(count) unsigned long *valuesp, | __out_ecount_opt(count) unsigned long *valuesp, | ||||
__in size_t count) | __in size_t count) | ||||
{ | { | ||||
efx_port_t *epp = &(enp->en_port); | efx_port_t *epp = &(enp->en_port); | ||||
efx_phy_ops_t *epop = epp->ep_epop; | const efx_phy_ops_t *epop = epp->ep_epop; | ||||
efx_rc_t rc; | efx_rc_t rc; | ||||
EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); | EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); | ||||
EFSYS_ASSERT3U(type, !=, EFX_BIST_TYPE_UNKNOWN); | EFSYS_ASSERT3U(type, !=, EFX_BIST_TYPE_UNKNOWN); | ||||
EFSYS_ASSERT3U(type, <, EFX_BIST_TYPE_NTYPES); | EFSYS_ASSERT3U(type, <, EFX_BIST_TYPE_NTYPES); | ||||
EFSYS_ASSERT3U(epp->ep_current_bist, ==, type); | EFSYS_ASSERT3U(epp->ep_current_bist, ==, type); | ||||
Show All 18 Lines | |||||
} | } | ||||
void | void | ||||
efx_bist_stop( | efx_bist_stop( | ||||
__in efx_nic_t *enp, | __in efx_nic_t *enp, | ||||
__in efx_bist_type_t type) | __in efx_bist_type_t type) | ||||
{ | { | ||||
efx_port_t *epp = &(enp->en_port); | efx_port_t *epp = &(enp->en_port); | ||||
efx_phy_ops_t *epop = epp->ep_epop; | const efx_phy_ops_t *epop = epp->ep_epop; | ||||
EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); | EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); | ||||
EFSYS_ASSERT3U(type, !=, EFX_BIST_TYPE_UNKNOWN); | EFSYS_ASSERT3U(type, !=, EFX_BIST_TYPE_UNKNOWN); | ||||
EFSYS_ASSERT3U(type, <, EFX_BIST_TYPE_NTYPES); | EFSYS_ASSERT3U(type, <, EFX_BIST_TYPE_NTYPES); | ||||
EFSYS_ASSERT3U(epp->ep_current_bist, ==, type); | EFSYS_ASSERT3U(epp->ep_current_bist, ==, type); | ||||
EFSYS_ASSERT(epop->epo_bist_stop != NULL); | EFSYS_ASSERT(epop->epo_bist_stop != NULL); | ||||
Show All 23 Lines |