diff options
Diffstat (limited to 'sys/dev/sfxge/common/efx_nic.c')
-rw-r--r-- | sys/dev/sfxge/common/efx_nic.c | 169 |
1 files changed, 91 insertions, 78 deletions
diff --git a/sys/dev/sfxge/common/efx_nic.c b/sys/dev/sfxge/common/efx_nic.c index b5ad65e..07acc56 100644 --- a/sys/dev/sfxge/common/efx_nic.c +++ b/sys/dev/sfxge/common/efx_nic.c @@ -31,13 +31,10 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "efsys.h" #include "efx.h" -#include "efx_types.h" -#include "efx_regs.h" #include "efx_impl.h" - __checkReturn int + __checkReturn efx_rc_t efx_family( __in uint16_t venid, __in uint16_t devid, @@ -49,7 +46,8 @@ efx_family( case EFX_PCI_DEVID_FALCON: *efp = EFX_FAMILY_FALCON; return (0); -#endif +#endif /* EFSYS_OPT_FALCON */ + #if EFSYS_OPT_SIENA case EFX_PCI_DEVID_SIENA_F1_UNINIT: /* @@ -63,7 +61,7 @@ efx_family( case EFX_PCI_DEVID_SIENA: *efp = EFX_FAMILY_SIENA; return (0); -#endif +#endif /* EFSYS_OPT_SIENA */ #if EFSYS_OPT_HUNTINGTON case EFX_PCI_DEVID_HUNTINGTON_PF_UNINIT: @@ -76,16 +74,33 @@ efx_family( case EFX_PCI_DEVID_FARMINGDALE: case EFX_PCI_DEVID_GREENPORT: - case EFX_PCI_DEVID_HUNTINGTON: *efp = EFX_FAMILY_HUNTINGTON; return (0); case EFX_PCI_DEVID_FARMINGDALE_VF: case EFX_PCI_DEVID_GREENPORT_VF: - case EFX_PCI_DEVID_HUNTINGTON_VF: *efp = EFX_FAMILY_HUNTINGTON; return (0); -#endif +#endif /* EFSYS_OPT_HUNTINGTON */ + +#if EFSYS_OPT_MEDFORD + case EFX_PCI_DEVID_MEDFORD_PF_UNINIT: + /* + * Hardware default for PF0 of uninitialised Medford. + * manftest must be able to cope with this device id. + */ + *efp = EFX_FAMILY_MEDFORD; + return (0); + + case EFX_PCI_DEVID_MEDFORD: + *efp = EFX_FAMILY_MEDFORD; + return (0); + + case EFX_PCI_DEVID_MEDFORD_VF: + *efp = EFX_FAMILY_MEDFORD; + return (0); +#endif /* EFSYS_OPT_MEDFORD */ + default: break; } @@ -100,7 +115,7 @@ efx_family( * the hardware family by inspecting the hardware. Obviously the caller * must be damn sure they're really talking to a supported device. */ - __checkReturn int + __checkReturn efx_rc_t efx_infer_family( __in efsys_bar_t *esbp, __out efx_family_t *efp) @@ -108,12 +123,16 @@ efx_infer_family( efx_family_t family; efx_oword_t oword; unsigned int portnum; - int rc; + efx_rc_t rc; EFSYS_BAR_READO(esbp, FR_AZ_CS_DEBUG_REG_OFST, &oword, B_TRUE); portnum = EFX_OWORD_FIELD(oword, FRF_CZ_CS_PORT_NUM); - switch (portnum) { - case 0: { + if ((portnum == 1) || (portnum == 2)) { +#if EFSYS_OPT_SIENA + family = EFX_FAMILY_SIENA; + goto out; +#endif + } else if (portnum == 0) { efx_dword_t dword; uint32_t hw_rev; @@ -121,37 +140,31 @@ efx_infer_family( B_TRUE); hw_rev = EFX_DWORD_FIELD(dword, ERF_DZ_HW_REV_ID); if (hw_rev == ER_DZ_BIU_HW_REV_ID_REG_RESET) { -#if EFSYS_OPT_HUNTINGTON +#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD + /* + * BIU_HW_REV_ID is the same for Huntington and Medford. + * Assume Huntington, as Medford is very similar. + */ family = EFX_FAMILY_HUNTINGTON; - break; + goto out; #endif } else { #if EFSYS_OPT_FALCON family = EFX_FAMILY_FALCON; - break; + goto out; #endif } - rc = ENOTSUP; - goto fail1; - } - -#if EFSYS_OPT_SIENA - case 1: - case 2: - family = EFX_FAMILY_SIENA; - break; -#endif - default: - rc = ENOTSUP; - goto fail1; } + rc = ENOTSUP; + goto fail1; +out: if (efp != NULL) *efp = family; return (0); fail1: - EFSYS_PROBE1(fail1, int, rc); + EFSYS_PROBE1(fail1, efx_rc_t, rc); return (rc); } @@ -159,12 +172,12 @@ fail1: #define EFX_BIU_MAGIC0 0x01234567 #define EFX_BIU_MAGIC1 0xfedcba98 - __checkReturn int + __checkReturn efx_rc_t efx_nic_biu_test( __in efx_nic_t *enp) { efx_oword_t oword; - int rc; + efx_rc_t rc; /* * Write magic values to scratch registers 0 and 1, then @@ -222,7 +235,7 @@ fail3: fail2: EFSYS_PROBE(fail2); fail1: - EFSYS_PROBE1(fail1, int, rc); + EFSYS_PROBE1(fail1, efx_rc_t, rc); return (rc); } @@ -268,23 +281,23 @@ static efx_nic_ops_t __efx_nic_siena_ops = { #if EFSYS_OPT_HUNTINGTON static efx_nic_ops_t __efx_nic_hunt_ops = { - hunt_nic_probe, /* eno_probe */ - hunt_nic_set_drv_limits, /* eno_set_drv_limits */ - hunt_nic_reset, /* eno_reset */ - hunt_nic_init, /* eno_init */ - hunt_nic_get_vi_pool, /* eno_get_vi_pool */ - hunt_nic_get_bar_region, /* eno_get_bar_region */ + ef10_nic_probe, /* eno_probe */ + ef10_nic_set_drv_limits, /* eno_set_drv_limits */ + ef10_nic_reset, /* eno_reset */ + ef10_nic_init, /* eno_init */ + ef10_nic_get_vi_pool, /* eno_get_vi_pool */ + ef10_nic_get_bar_region, /* eno_get_bar_region */ #if EFSYS_OPT_DIAG - hunt_sram_test, /* eno_sram_test */ - hunt_nic_register_test, /* eno_register_test */ + ef10_sram_test, /* eno_sram_test */ + ef10_nic_register_test, /* eno_register_test */ #endif /* EFSYS_OPT_DIAG */ - hunt_nic_fini, /* eno_fini */ - hunt_nic_unprobe, /* eno_unprobe */ + ef10_nic_fini, /* eno_fini */ + ef10_nic_unprobe, /* eno_unprobe */ }; #endif /* EFSYS_OPT_HUNTINGTON */ - __checkReturn int + __checkReturn efx_rc_t efx_nic_create( __in efx_family_t family, __in efsys_identifier_t *esip, @@ -293,7 +306,7 @@ efx_nic_create( __deref_out efx_nic_t **enpp) { efx_nic_t *enp; - int rc; + efx_rc_t rc; EFSYS_ASSERT3U(family, >, EFX_FAMILY_INVALID); EFSYS_ASSERT3U(family, <, EFX_FAMILY_NTYPES); @@ -371,17 +384,17 @@ fail2: EFSYS_KMEM_FREE(esip, sizeof (efx_nic_t), enp); fail1: - EFSYS_PROBE1(fail1, int, rc); + EFSYS_PROBE1(fail1, efx_rc_t, rc); return (rc); } - __checkReturn int + __checkReturn efx_rc_t efx_nic_probe( __in efx_nic_t *enp) { efx_nic_ops_t *enop; - int rc; + efx_rc_t rc; EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); #if EFSYS_OPT_MCDI @@ -406,14 +419,14 @@ fail2: enop->eno_unprobe(enp); fail1: - EFSYS_PROBE1(fail1, int, rc); + EFSYS_PROBE1(fail1, efx_rc_t, rc); return (rc); } #if EFSYS_OPT_PCIE_TUNE - __checkReturn int + __checkReturn efx_rc_t efx_nic_pcie_tune( __in efx_nic_t *enp, unsigned int nlanes) @@ -429,7 +442,7 @@ efx_nic_pcie_tune( return (ENOTSUP); } - __checkReturn int + __checkReturn efx_rc_t efx_nic_pcie_extended_sync( __in efx_nic_t *enp) { @@ -447,13 +460,13 @@ efx_nic_pcie_extended_sync( #endif /* EFSYS_OPT_PCIE_TUNE */ - __checkReturn int + __checkReturn efx_rc_t efx_nic_set_drv_limits( __inout efx_nic_t *enp, __in efx_drv_limits_t *edlp) { efx_nic_ops_t *enop = enp->en_enop; - int rc; + efx_rc_t rc; EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE); @@ -466,12 +479,12 @@ efx_nic_set_drv_limits( return (0); fail1: - EFSYS_PROBE1(fail1, int, rc); + EFSYS_PROBE1(fail1, efx_rc_t, rc); return (rc); } - __checkReturn int + __checkReturn efx_rc_t efx_nic_get_bar_region( __in efx_nic_t *enp, __in efx_nic_region_t region, @@ -479,7 +492,7 @@ efx_nic_get_bar_region( __out size_t *sizep) { efx_nic_ops_t *enop = enp->en_enop; - int rc; + efx_rc_t rc; EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE); @@ -500,13 +513,13 @@ fail2: EFSYS_PROBE(fail2); fail1: - EFSYS_PROBE1(fail1, int, rc); + EFSYS_PROBE1(fail1, efx_rc_t, rc); return (rc); } - __checkReturn int + __checkReturn efx_rc_t efx_nic_get_vi_pool( __in efx_nic_t *enp, __out uint32_t *evq_countp, @@ -515,7 +528,7 @@ efx_nic_get_vi_pool( { efx_nic_ops_t *enop = enp->en_enop; efx_nic_cfg_t *encp = &enp->en_nic_cfg; - int rc; + efx_rc_t rc; EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE); @@ -540,18 +553,18 @@ efx_nic_get_vi_pool( return (0); fail1: - EFSYS_PROBE1(fail1, int, rc); + EFSYS_PROBE1(fail1, efx_rc_t, rc); return (rc); } - __checkReturn int + __checkReturn efx_rc_t efx_nic_init( __in efx_nic_t *enp) { efx_nic_ops_t *enop = enp->en_enop; - int rc; + efx_rc_t rc; EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE); @@ -571,7 +584,7 @@ efx_nic_init( fail2: EFSYS_PROBE(fail2); fail1: - EFSYS_PROBE1(fail1, int, rc); + EFSYS_PROBE1(fail1, efx_rc_t, rc); return (rc); } @@ -641,13 +654,13 @@ efx_nic_destroy( EFSYS_KMEM_FREE(esip, sizeof (efx_nic_t), enp); } - __checkReturn int + __checkReturn efx_rc_t efx_nic_reset( __in efx_nic_t *enp) { efx_nic_ops_t *enop = enp->en_enop; unsigned int mod_flags; - int rc; + efx_rc_t rc; EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); EFSYS_ASSERT(enp->en_mod_flags & EFX_MOD_PROBE); @@ -678,7 +691,7 @@ efx_nic_reset( fail2: EFSYS_PROBE(fail2); fail1: - EFSYS_PROBE1(fail1, int, rc); + EFSYS_PROBE1(fail1, efx_rc_t, rc); return (rc); } @@ -694,12 +707,12 @@ efx_nic_cfg_get( #if EFSYS_OPT_DIAG - __checkReturn int + __checkReturn efx_rc_t efx_nic_register_test( __in efx_nic_t *enp) { efx_nic_ops_t *enop = enp->en_enop; - int rc; + efx_rc_t rc; EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE); @@ -711,12 +724,12 @@ efx_nic_register_test( return (0); fail1: - EFSYS_PROBE1(fail1, int, rc); + EFSYS_PROBE1(fail1, efx_rc_t, rc); return (rc); } - __checkReturn int + __checkReturn efx_rc_t efx_nic_test_registers( __in efx_nic_t *enp, __in efx_register_set_t *rsp, @@ -726,7 +739,7 @@ efx_nic_test_registers( efx_oword_t original; efx_oword_t reg; efx_oword_t buf; - int rc; + efx_rc_t rc; while (count > 0) { /* This function is only suitable for registers */ @@ -785,7 +798,7 @@ efx_nic_test_registers( fail2: EFSYS_PROBE(fail2); fail1: - EFSYS_PROBE1(fail1, int, rc); + EFSYS_PROBE1(fail1, efx_rc_t, rc); /* Restore the old value */ EFSYS_BAR_WRITEO(enp->en_esbp, rsp->address, &original, B_TRUE); @@ -793,7 +806,7 @@ fail1: return (rc); } - __checkReturn int + __checkReturn efx_rc_t efx_nic_test_tables( __in efx_nic_t *enp, __in efx_register_set_t *rsp, @@ -805,7 +818,7 @@ efx_nic_test_tables( unsigned int address; efx_oword_t reg; efx_oword_t buf; - int rc; + efx_rc_t rc; EFSYS_ASSERT(pattern < EFX_PATTERN_NTYPES); func = __efx_sram_pattern_fns[pattern]; @@ -844,7 +857,7 @@ efx_nic_test_tables( return (0); fail1: - EFSYS_PROBE1(fail1, int, rc); + EFSYS_PROBE1(fail1, efx_rc_t, rc); return (rc); } @@ -955,7 +968,7 @@ efx_loopback_mask( *maskp = mask; } -__checkReturn int + __checkReturn efx_rc_t efx_mcdi_get_loopback_modes( __in efx_nic_t *enp) { @@ -965,7 +978,7 @@ efx_mcdi_get_loopback_modes( MC_CMD_GET_LOOPBACK_MODES_OUT_LEN)]; efx_qword_t mask; efx_qword_t modes; - int rc; + efx_rc_t rc; (void) memset(payload, 0, sizeof (payload)); req.emr_cmd = MC_CMD_GET_LOOPBACK_MODES; @@ -1032,7 +1045,7 @@ efx_mcdi_get_loopback_modes( fail2: EFSYS_PROBE(fail2); fail1: - EFSYS_PROBE1(fail1, int, rc); + EFSYS_PROBE1(fail1, efx_rc_t, rc); return (rc); } |