Author: arybchik Date: Fri May 13 07:03:04 2016 New Revision: 299601 URL: https://svnweb.freebsd.org/changeset/base/299601
Log: sfxge(4): move ef10_nic_* to ef10_nic.c Submitted by: Andy Moreton <amoreton at solarflare.com> Sponsored by: Solarflare Communications, Inc. MFC after: 1 week Added: head/sys/dev/sfxge/common/ef10_nic.c - copied, changed from r299592, head/sys/dev/sfxge/common/hunt_nic.c Modified: head/sys/dev/sfxge/common/hunt_nic.c head/sys/modules/sfxge/Makefile Copied and modified: head/sys/dev/sfxge/common/ef10_nic.c (from r299592, head/sys/dev/sfxge/common/hunt_nic.c) ============================================================================== --- head/sys/dev/sfxge/common/hunt_nic.c Fri May 13 06:26:42 2016 (r299592, copy source) +++ head/sys/dev/sfxge/common/ef10_nic.c Fri May 13 07:03:04 2016 (r299601) @@ -37,7 +37,7 @@ __FBSDID("$FreeBSD$"); #include "mcdi_mon.h" #endif -#if EFSYS_OPT_HUNTINGTON +#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD #include "ef10_tlv_layout.h" @@ -1115,286 +1115,6 @@ fail1: return (rc); } - __checkReturn efx_rc_t -hunt_board_cfg( - __in efx_nic_t *enp) -{ - efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); - efx_nic_cfg_t *encp = &(enp->en_nic_cfg); - uint8_t mac_addr[6]; - uint32_t board_type = 0; - ef10_link_state_t els; - efx_port_t *epp = &(enp->en_port); - uint32_t port; - uint32_t pf; - uint32_t vf; - uint32_t mask; - uint32_t flags; - uint32_t sysclk; - uint32_t base, nvec; - efx_rc_t rc; - - if ((rc = efx_mcdi_get_port_assignment(enp, &port)) != 0) - goto fail1; - - /* - * NOTE: The MCDI protocol numbers ports from zero. - * The common code MCDI interface numbers ports from one. - */ - emip->emi_port = port + 1; - - if ((rc = ef10_external_port_mapping(enp, port, - &encp->enc_external_port)) != 0) - goto fail2; - - /* - * Get PCIe function number from firmware (used for - * per-function privilege and dynamic config info). - * - PCIe PF: pf = PF number, vf = 0xffff. - * - PCIe VF: pf = parent PF, vf = VF number. - */ - if ((rc = efx_mcdi_get_function_info(enp, &pf, &vf)) != 0) - goto fail3; - - encp->enc_pf = pf; - encp->enc_vf = vf; - - /* MAC address for this function */ - if (EFX_PCI_FUNCTION_IS_PF(encp)) { - rc = efx_mcdi_get_mac_address_pf(enp, mac_addr); - if ((rc == 0) && (mac_addr[0] & 0x02)) { - /* - * If the static config does not include a global MAC - * address pool then the board may return a locally - * administered MAC address (this should only happen on - * incorrectly programmed boards). - */ - rc = EINVAL; - } - } else { - rc = efx_mcdi_get_mac_address_vf(enp, mac_addr); - } - if (rc != 0) - goto fail4; - - EFX_MAC_ADDR_COPY(encp->enc_mac_addr, mac_addr); - - /* Board configuration */ - rc = efx_mcdi_get_board_cfg(enp, &board_type, NULL, NULL); - if (rc != 0) { - /* Unprivileged functions may not be able to read board cfg */ - if (rc == EACCES) - board_type = 0; - else - goto fail5; - } - - encp->enc_board_type = board_type; - encp->enc_clk_mult = 1; /* not used for Huntington */ - - /* Fill out fields in enp->en_port and enp->en_nic_cfg from MCDI */ - if ((rc = efx_mcdi_get_phy_cfg(enp)) != 0) - goto fail6; - - /* Obtain the default PHY advertised capabilities */ - if ((rc = ef10_phy_get_link(enp, &els)) != 0) - goto fail7; - epp->ep_default_adv_cap_mask = els.els_adv_cap_mask; - epp->ep_adv_cap_mask = els.els_adv_cap_mask; - - /* - * Enable firmware workarounds for hardware errata. - * Expected responses are: - * - 0 (zero): - * Success: workaround enabled or disabled as requested. - * - MC_CMD_ERR_ENOSYS (reported as ENOTSUP): - * Firmware does not support the MC_CMD_WORKAROUND request. - * (assume that the workaround is not supported). - * - MC_CMD_ERR_ENOENT (reported as ENOENT): - * Firmware does not support the requested workaround. - * - MC_CMD_ERR_EPERM (reported as EACCES): - * Unprivileged function cannot enable/disable workarounds. - * - * See efx_mcdi_request_errcode() for MCDI error translations. - */ - - /* - * If the bug35388 workaround is enabled, then use an indirect access - * method to avoid unsafe EVQ writes. - */ - rc = efx_mcdi_set_workaround(enp, MC_CMD_WORKAROUND_BUG35388, B_TRUE, - NULL); - if ((rc == 0) || (rc == EACCES)) - encp->enc_bug35388_workaround = B_TRUE; - else if ((rc == ENOTSUP) || (rc == ENOENT)) - encp->enc_bug35388_workaround = B_FALSE; - else - goto fail8; - - /* - * If the bug41750 workaround is enabled, then do not test interrupts, - * as the test will fail (seen with Greenport controllers). - */ - rc = efx_mcdi_set_workaround(enp, MC_CMD_WORKAROUND_BUG41750, B_TRUE, - NULL); - if (rc == 0) { - encp->enc_bug41750_workaround = B_TRUE; - } else if (rc == EACCES) { - /* Assume a controller with 40G ports needs the workaround. */ - if (epp->ep_default_adv_cap_mask & EFX_PHY_CAP_40000FDX) - encp->enc_bug41750_workaround = B_TRUE; - else - encp->enc_bug41750_workaround = B_FALSE; - } else if ((rc == ENOTSUP) || (rc == ENOENT)) { - encp->enc_bug41750_workaround = B_FALSE; - } else { - goto fail9; - } - if (EFX_PCI_FUNCTION_IS_VF(encp)) { - /* Interrupt testing does not work for VFs. See bug50084. */ - encp->enc_bug41750_workaround = B_TRUE; - } - - /* - * If the bug26807 workaround is enabled, then firmware has enabled - * support for chained multicast filters. Firmware will reset (FLR) - * functions which have filters in the hardware filter table when the - * workaround is enabled/disabled. - * - * We must recheck if the workaround is enabled after inserting the - * first hardware filter, in case it has been changed since this check. - */ - rc = efx_mcdi_set_workaround(enp, MC_CMD_WORKAROUND_BUG26807, - B_TRUE, &flags); - if (rc == 0) { - encp->enc_bug26807_workaround = B_TRUE; - if (flags & (1 << MC_CMD_WORKAROUND_EXT_OUT_FLR_DONE_LBN)) { - /* - * Other functions had installed filters before the - * workaround was enabled, and they have been reset - * by firmware. - */ - EFSYS_PROBE(bug26807_workaround_flr_done); - /* FIXME: bump MC warm boot count ? */ - } - } else if (rc == EACCES) { - /* - * Unprivileged functions cannot enable the workaround in older - * firmware. - */ - encp->enc_bug26807_workaround = B_FALSE; - } else if ((rc == ENOTSUP) || (rc == ENOENT)) { - encp->enc_bug26807_workaround = B_FALSE; - } else { - goto fail10; - } - - /* Get sysclk frequency (in MHz). */ - if ((rc = efx_mcdi_get_clock(enp, &sysclk)) != 0) - goto fail11; - - /* - * The timer quantum is 1536 sysclk cycles, documented for the - * EV_TMR_VAL field of EV_TIMER_TBL. Scale for MHz and ns units. - */ - encp->enc_evq_timer_quantum_ns = 1536000UL / sysclk; /* 1536 cycles */ - if (encp->enc_bug35388_workaround) { - encp->enc_evq_timer_max_us = (encp->enc_evq_timer_quantum_ns << - ERF_DD_EVQ_IND_TIMER_VAL_WIDTH) / 1000; - } else { - encp->enc_evq_timer_max_us = (encp->enc_evq_timer_quantum_ns << - FRF_CZ_TC_TIMER_VAL_WIDTH) / 1000; - } - - /* Check capabilities of running datapath firmware */ - if ((rc = ef10_get_datapath_caps(enp)) != 0) - goto fail12; - - /* Alignment for receive packet DMA buffers */ - encp->enc_rx_buf_align_start = 1; - encp->enc_rx_buf_align_end = 64; /* RX DMA end padding */ - - /* Alignment for WPTR updates */ - encp->enc_rx_push_align = EF10_RX_WPTR_ALIGN; - - /* - * Set resource limits for MC_CMD_ALLOC_VIS. Note that we cannot use - * MC_CMD_GET_RESOURCE_LIMITS here as that reports the available - * resources (allocated to this PCIe function), which is zero until - * after we have allocated VIs. - */ - encp->enc_evq_limit = 1024; - encp->enc_rxq_limit = EFX_RXQ_LIMIT_TARGET; - encp->enc_txq_limit = EFX_TXQ_LIMIT_TARGET; - - encp->enc_buftbl_limit = 0xFFFFFFFF; - - encp->enc_piobuf_limit = HUNT_PIOBUF_NBUFS; - encp->enc_piobuf_size = HUNT_PIOBUF_SIZE; - encp->enc_piobuf_min_alloc_size = HUNT_MIN_PIO_ALLOC_SIZE; - - /* - * Get the current privilege mask. Note that this may be modified - * dynamically, so this value is informational only. DO NOT use - * the privilege mask to check for sufficient privileges, as that - * can result in time-of-check/time-of-use bugs. - */ - if ((rc = ef10_get_privilege_mask(enp, &mask)) != 0) - goto fail13; - encp->enc_privilege_mask = mask; - - /* Get interrupt vector limits */ - if ((rc = efx_mcdi_get_vector_cfg(enp, &base, &nvec, NULL)) != 0) { - if (EFX_PCI_FUNCTION_IS_PF(encp)) - goto fail14; - - /* Ignore error (cannot query vector limits from a VF). */ - base = 0; - nvec = 1024; - } - encp->enc_intr_vec_base = base; - encp->enc_intr_limit = nvec; - - /* - * Maximum number of bytes into the frame the TCP header can start for - * firmware assisted TSO to work. - */ - encp->enc_tx_tso_tcp_header_offset_limit = EF10_TCP_HEADER_OFFSET_LIMIT; - - return (0); - -fail14: - EFSYS_PROBE(fail14); -fail13: - EFSYS_PROBE(fail13); -fail12: - EFSYS_PROBE(fail12); -fail11: - EFSYS_PROBE(fail11); -fail10: - EFSYS_PROBE(fail10); -fail9: - EFSYS_PROBE(fail9); -fail8: - EFSYS_PROBE(fail8); -fail7: - EFSYS_PROBE(fail7); -fail6: - EFSYS_PROBE(fail6); -fail5: - EFSYS_PROBE(fail5); -fail4: - EFSYS_PROBE(fail4); -fail3: - EFSYS_PROBE(fail3); -fail2: - EFSYS_PROBE(fail2); -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - - return (rc); -} - __checkReturn efx_rc_t ef10_nic_probe( @@ -1893,5 +1613,4 @@ fail1: #endif /* EFSYS_OPT_DIAG */ - -#endif /* EFSYS_OPT_HUNTINGTON */ +#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */ Modified: head/sys/dev/sfxge/common/hunt_nic.c ============================================================================== --- head/sys/dev/sfxge/common/hunt_nic.c Fri May 13 07:00:46 2016 (r299600) +++ head/sys/dev/sfxge/common/hunt_nic.c Fri May 13 07:03:04 2016 (r299601) @@ -39,1081 +39,6 @@ __FBSDID("$FreeBSD$"); #if EFSYS_OPT_HUNTINGTON -#include "ef10_tlv_layout.h" - - __checkReturn efx_rc_t -efx_mcdi_get_port_assignment( - __in efx_nic_t *enp, - __out uint32_t *portp) -{ - efx_mcdi_req_t req; - uint8_t payload[MAX(MC_CMD_GET_PORT_ASSIGNMENT_IN_LEN, - MC_CMD_GET_PORT_ASSIGNMENT_OUT_LEN)]; - efx_rc_t rc; - - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || - enp->en_family == EFX_FAMILY_MEDFORD); - - (void) memset(payload, 0, sizeof (payload)); - req.emr_cmd = MC_CMD_GET_PORT_ASSIGNMENT; - req.emr_in_buf = payload; - req.emr_in_length = MC_CMD_GET_PORT_ASSIGNMENT_IN_LEN; - req.emr_out_buf = payload; - req.emr_out_length = MC_CMD_GET_PORT_ASSIGNMENT_OUT_LEN; - - efx_mcdi_execute(enp, &req); - - if (req.emr_rc != 0) { - rc = req.emr_rc; - goto fail1; - } - - if (req.emr_out_length_used < MC_CMD_GET_PORT_ASSIGNMENT_OUT_LEN) { - rc = EMSGSIZE; - goto fail2; - } - - *portp = MCDI_OUT_DWORD(req, GET_PORT_ASSIGNMENT_OUT_PORT); - - return (0); - -fail2: - EFSYS_PROBE(fail2); -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - - return (rc); -} - - __checkReturn efx_rc_t -efx_mcdi_get_port_modes( - __in efx_nic_t *enp, - __out uint32_t *modesp) -{ - efx_mcdi_req_t req; - uint8_t payload[MAX(MC_CMD_GET_PORT_MODES_IN_LEN, - MC_CMD_GET_PORT_MODES_OUT_LEN)]; - efx_rc_t rc; - - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || - enp->en_family == EFX_FAMILY_MEDFORD); - - (void) memset(payload, 0, sizeof (payload)); - req.emr_cmd = MC_CMD_GET_PORT_MODES; - req.emr_in_buf = payload; - req.emr_in_length = MC_CMD_GET_PORT_MODES_IN_LEN; - req.emr_out_buf = payload; - req.emr_out_length = MC_CMD_GET_PORT_MODES_OUT_LEN; - - efx_mcdi_execute(enp, &req); - - if (req.emr_rc != 0) { - rc = req.emr_rc; - goto fail1; - } - - /* - * Require only Modes and DefaultMode fields. - * (CurrentMode field was added for Medford) - */ - if (req.emr_out_length_used < - MC_CMD_GET_PORT_MODES_OUT_CURRENT_MODE_OFST) { - rc = EMSGSIZE; - goto fail2; - } - - *modesp = MCDI_OUT_DWORD(req, GET_PORT_MODES_OUT_MODES); - - return (0); - -fail2: - EFSYS_PROBE(fail2); -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - - return (rc); -} - - -static __checkReturn efx_rc_t -efx_mcdi_vadaptor_alloc( - __in efx_nic_t *enp, - __in uint32_t port_id) -{ - efx_mcdi_req_t req; - uint8_t payload[MAX(MC_CMD_VADAPTOR_ALLOC_IN_LEN, - MC_CMD_VADAPTOR_ALLOC_OUT_LEN)]; - efx_rc_t rc; - - EFSYS_ASSERT3U(enp->en_vport_id, ==, EVB_PORT_ID_NULL); - - (void) memset(payload, 0, sizeof (payload)); - req.emr_cmd = MC_CMD_VADAPTOR_ALLOC; - req.emr_in_buf = payload; - req.emr_in_length = MC_CMD_VADAPTOR_ALLOC_IN_LEN; - req.emr_out_buf = payload; - req.emr_out_length = MC_CMD_VADAPTOR_ALLOC_OUT_LEN; - - MCDI_IN_SET_DWORD(req, VADAPTOR_ALLOC_IN_UPSTREAM_PORT_ID, port_id); - MCDI_IN_POPULATE_DWORD_1(req, VADAPTOR_ALLOC_IN_FLAGS, - VADAPTOR_ALLOC_IN_FLAG_PERMIT_SET_MAC_WHEN_FILTERS_INSTALLED, - enp->en_nic_cfg.enc_allow_set_mac_with_installed_filters ? 1 : 0); - - efx_mcdi_execute(enp, &req); - - if (req.emr_rc != 0) { - rc = req.emr_rc; - goto fail1; - } - - return (0); - -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - - return (rc); -} - -static __checkReturn efx_rc_t -efx_mcdi_vadaptor_free( - __in efx_nic_t *enp, - __in uint32_t port_id) -{ - efx_mcdi_req_t req; - uint8_t payload[MAX(MC_CMD_VADAPTOR_FREE_IN_LEN, - MC_CMD_VADAPTOR_FREE_OUT_LEN)]; - efx_rc_t rc; - - (void) memset(payload, 0, sizeof (payload)); - req.emr_cmd = MC_CMD_VADAPTOR_FREE; - req.emr_in_buf = payload; - req.emr_in_length = MC_CMD_VADAPTOR_FREE_IN_LEN; - req.emr_out_buf = payload; - req.emr_out_length = MC_CMD_VADAPTOR_FREE_OUT_LEN; - - MCDI_IN_SET_DWORD(req, VADAPTOR_FREE_IN_UPSTREAM_PORT_ID, port_id); - - efx_mcdi_execute(enp, &req); - - if (req.emr_rc != 0) { - rc = req.emr_rc; - goto fail1; - } - - return (0); - -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - - return (rc); -} - - __checkReturn efx_rc_t -efx_mcdi_get_mac_address_pf( - __in efx_nic_t *enp, - __out_ecount_opt(6) uint8_t mac_addrp[6]) -{ - efx_mcdi_req_t req; - uint8_t payload[MAX(MC_CMD_GET_MAC_ADDRESSES_IN_LEN, - MC_CMD_GET_MAC_ADDRESSES_OUT_LEN)]; - efx_rc_t rc; - - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || - enp->en_family == EFX_FAMILY_MEDFORD); - - (void) memset(payload, 0, sizeof (payload)); - req.emr_cmd = MC_CMD_GET_MAC_ADDRESSES; - req.emr_in_buf = payload; - req.emr_in_length = MC_CMD_GET_MAC_ADDRESSES_IN_LEN; - req.emr_out_buf = payload; - req.emr_out_length = MC_CMD_GET_MAC_ADDRESSES_OUT_LEN; - - efx_mcdi_execute(enp, &req); - - if (req.emr_rc != 0) { - rc = req.emr_rc; - goto fail1; - } - - if (req.emr_out_length_used < MC_CMD_GET_MAC_ADDRESSES_OUT_LEN) { - rc = EMSGSIZE; - goto fail2; - } - - if (MCDI_OUT_DWORD(req, GET_MAC_ADDRESSES_OUT_MAC_COUNT) < 1) { - rc = ENOENT; - goto fail3; - } - - if (mac_addrp != NULL) { - uint8_t *addrp; - - addrp = MCDI_OUT2(req, uint8_t, - GET_MAC_ADDRESSES_OUT_MAC_ADDR_BASE); - - EFX_MAC_ADDR_COPY(mac_addrp, addrp); - } - - return (0); - -fail3: - EFSYS_PROBE(fail3); -fail2: - EFSYS_PROBE(fail2); -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - - return (rc); -} - - __checkReturn efx_rc_t -efx_mcdi_get_mac_address_vf( - __in efx_nic_t *enp, - __out_ecount_opt(6) uint8_t mac_addrp[6]) -{ - efx_mcdi_req_t req; - uint8_t payload[MAX(MC_CMD_VPORT_GET_MAC_ADDRESSES_IN_LEN, - MC_CMD_VPORT_GET_MAC_ADDRESSES_OUT_LENMAX)]; - efx_rc_t rc; - - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || - enp->en_family == EFX_FAMILY_MEDFORD); - - (void) memset(payload, 0, sizeof (payload)); - req.emr_cmd = MC_CMD_VPORT_GET_MAC_ADDRESSES; - req.emr_in_buf = payload; - req.emr_in_length = MC_CMD_VPORT_GET_MAC_ADDRESSES_IN_LEN; - req.emr_out_buf = payload; - req.emr_out_length = MC_CMD_VPORT_GET_MAC_ADDRESSES_OUT_LENMAX; - - MCDI_IN_SET_DWORD(req, VPORT_GET_MAC_ADDRESSES_IN_VPORT_ID, - EVB_PORT_ID_ASSIGNED); - - efx_mcdi_execute(enp, &req); - - if (req.emr_rc != 0) { - rc = req.emr_rc; - goto fail1; - } - - if (req.emr_out_length_used < - MC_CMD_VPORT_GET_MAC_ADDRESSES_OUT_LENMIN) { - rc = EMSGSIZE; - goto fail2; - } - - if (MCDI_OUT_DWORD(req, - VPORT_GET_MAC_ADDRESSES_OUT_MACADDR_COUNT) < 1) { - rc = ENOENT; - goto fail3; - } - - if (mac_addrp != NULL) { - uint8_t *addrp; - - addrp = MCDI_OUT2(req, uint8_t, - VPORT_GET_MAC_ADDRESSES_OUT_MACADDR); - - EFX_MAC_ADDR_COPY(mac_addrp, addrp); - } - - return (0); - -fail3: - EFSYS_PROBE(fail3); -fail2: - EFSYS_PROBE(fail2); -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - - return (rc); -} - - __checkReturn efx_rc_t -efx_mcdi_get_clock( - __in efx_nic_t *enp, - __out uint32_t *sys_freqp) -{ - efx_mcdi_req_t req; - uint8_t payload[MAX(MC_CMD_GET_CLOCK_IN_LEN, - MC_CMD_GET_CLOCK_OUT_LEN)]; - efx_rc_t rc; - - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || - enp->en_family == EFX_FAMILY_MEDFORD); - - (void) memset(payload, 0, sizeof (payload)); - req.emr_cmd = MC_CMD_GET_CLOCK; - req.emr_in_buf = payload; - req.emr_in_length = MC_CMD_GET_CLOCK_IN_LEN; - req.emr_out_buf = payload; - req.emr_out_length = MC_CMD_GET_CLOCK_OUT_LEN; - - efx_mcdi_execute(enp, &req); - - if (req.emr_rc != 0) { - rc = req.emr_rc; - goto fail1; - } - - if (req.emr_out_length_used < MC_CMD_GET_CLOCK_OUT_LEN) { - rc = EMSGSIZE; - goto fail2; - } - - *sys_freqp = MCDI_OUT_DWORD(req, GET_CLOCK_OUT_SYS_FREQ); - if (*sys_freqp == 0) { - rc = EINVAL; - goto fail3; - } - - return (0); - -fail3: - EFSYS_PROBE(fail3); -fail2: - EFSYS_PROBE(fail2); -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - - return (rc); -} - - __checkReturn efx_rc_t -efx_mcdi_get_vector_cfg( - __in efx_nic_t *enp, - __out_opt uint32_t *vec_basep, - __out_opt uint32_t *pf_nvecp, - __out_opt uint32_t *vf_nvecp) -{ - efx_mcdi_req_t req; - uint8_t payload[MAX(MC_CMD_GET_VECTOR_CFG_IN_LEN, - MC_CMD_GET_VECTOR_CFG_OUT_LEN)]; - efx_rc_t rc; - - (void) memset(payload, 0, sizeof (payload)); - req.emr_cmd = MC_CMD_GET_VECTOR_CFG; - req.emr_in_buf = payload; - req.emr_in_length = MC_CMD_GET_VECTOR_CFG_IN_LEN; - req.emr_out_buf = payload; - req.emr_out_length = MC_CMD_GET_VECTOR_CFG_OUT_LEN; - - efx_mcdi_execute(enp, &req); - - if (req.emr_rc != 0) { - rc = req.emr_rc; - goto fail1; - } - - if (req.emr_out_length_used < MC_CMD_GET_VECTOR_CFG_OUT_LEN) { - rc = EMSGSIZE; - goto fail2; - } - - if (vec_basep != NULL) - *vec_basep = MCDI_OUT_DWORD(req, GET_VECTOR_CFG_OUT_VEC_BASE); - if (pf_nvecp != NULL) - *pf_nvecp = MCDI_OUT_DWORD(req, GET_VECTOR_CFG_OUT_VECS_PER_PF); - if (vf_nvecp != NULL) - *vf_nvecp = MCDI_OUT_DWORD(req, GET_VECTOR_CFG_OUT_VECS_PER_VF); - - return (0); - -fail2: - EFSYS_PROBE(fail2); -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - - return (rc); -} - -static __checkReturn efx_rc_t -efx_mcdi_get_capabilities( - __in efx_nic_t *enp, - __out uint32_t *flagsp, - __out uint32_t *flags2p) -{ - efx_mcdi_req_t req; - uint8_t payload[MAX(MC_CMD_GET_CAPABILITIES_IN_LEN, - MC_CMD_GET_CAPABILITIES_V2_OUT_LEN)]; - efx_rc_t rc; - - (void) memset(payload, 0, sizeof (payload)); - req.emr_cmd = MC_CMD_GET_CAPABILITIES; - req.emr_in_buf = payload; - req.emr_in_length = MC_CMD_GET_CAPABILITIES_IN_LEN; - req.emr_out_buf = payload; - req.emr_out_length = MC_CMD_GET_CAPABILITIES_V2_OUT_LEN; - - efx_mcdi_execute(enp, &req); - - if (req.emr_rc != 0) { - rc = req.emr_rc; - goto fail1; - } - - if (req.emr_out_length_used < MC_CMD_GET_CAPABILITIES_OUT_LEN) { - rc = EMSGSIZE; - goto fail2; - } - - *flagsp = MCDI_OUT_DWORD(req, GET_CAPABILITIES_OUT_FLAGS1); - - if (req.emr_out_length_used < MC_CMD_GET_CAPABILITIES_V2_OUT_LEN) - *flags2p = 0; - else - *flags2p = MCDI_OUT_DWORD(req, GET_CAPABILITIES_V2_OUT_FLAGS2); - - return (0); - -fail2: - EFSYS_PROBE(fail2); -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - - return (rc); -} - - -static __checkReturn efx_rc_t -efx_mcdi_alloc_vis( - __in efx_nic_t *enp, - __in uint32_t min_vi_count, - __in uint32_t max_vi_count, - __out uint32_t *vi_basep, - __out uint32_t *vi_countp, - __out uint32_t *vi_shiftp) -{ - efx_mcdi_req_t req; - uint8_t payload[MAX(MC_CMD_ALLOC_VIS_IN_LEN, - MC_CMD_ALLOC_VIS_OUT_LEN)]; - efx_rc_t rc; - - if (vi_countp == NULL) { - rc = EINVAL; - goto fail1; - } - - (void) memset(payload, 0, sizeof (payload)); - req.emr_cmd = MC_CMD_ALLOC_VIS; - req.emr_in_buf = payload; - req.emr_in_length = MC_CMD_ALLOC_VIS_IN_LEN; - req.emr_out_buf = payload; - req.emr_out_length = MC_CMD_ALLOC_VIS_OUT_LEN; - - MCDI_IN_SET_DWORD(req, ALLOC_VIS_IN_MIN_VI_COUNT, min_vi_count); - MCDI_IN_SET_DWORD(req, ALLOC_VIS_IN_MAX_VI_COUNT, max_vi_count); - - efx_mcdi_execute(enp, &req); - - if (req.emr_rc != 0) { - rc = req.emr_rc; - goto fail2; - } - - if (req.emr_out_length_used < MC_CMD_ALLOC_VIS_OUT_LEN) { - rc = EMSGSIZE; - goto fail3; - } - - *vi_basep = MCDI_OUT_DWORD(req, ALLOC_VIS_OUT_VI_BASE); - *vi_countp = MCDI_OUT_DWORD(req, ALLOC_VIS_OUT_VI_COUNT); - - /* Report VI_SHIFT if available (always zero for Huntington) */ - if (req.emr_out_length_used < MC_CMD_ALLOC_VIS_EXT_OUT_LEN) - *vi_shiftp = 0; - else - *vi_shiftp = MCDI_OUT_DWORD(req, ALLOC_VIS_EXT_OUT_VI_SHIFT); - - return (0); - -fail3: - EFSYS_PROBE(fail3); -fail2: - EFSYS_PROBE(fail2); -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - - return (rc); -} - - -static __checkReturn efx_rc_t -efx_mcdi_free_vis( - __in efx_nic_t *enp) -{ - efx_mcdi_req_t req; - efx_rc_t rc; - - EFX_STATIC_ASSERT(MC_CMD_FREE_VIS_IN_LEN == 0); - EFX_STATIC_ASSERT(MC_CMD_FREE_VIS_OUT_LEN == 0); - - req.emr_cmd = MC_CMD_FREE_VIS; - req.emr_in_buf = NULL; - req.emr_in_length = 0; - req.emr_out_buf = NULL; - req.emr_out_length = 0; - - efx_mcdi_execute_quiet(enp, &req); - - /* Ignore ELREADY (no allocated VIs, so nothing to free) */ - if ((req.emr_rc != 0) && (req.emr_rc != EALREADY)) { - rc = req.emr_rc; - goto fail1; - } - - return (0); - -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - - return (rc); -} - - -static __checkReturn efx_rc_t -efx_mcdi_alloc_piobuf( - __in efx_nic_t *enp, - __out efx_piobuf_handle_t *handlep) -{ - efx_mcdi_req_t req; - uint8_t payload[MAX(MC_CMD_ALLOC_PIOBUF_IN_LEN, - MC_CMD_ALLOC_PIOBUF_OUT_LEN)]; - efx_rc_t rc; - - if (handlep == NULL) { - rc = EINVAL; - goto fail1; - } - - (void) memset(payload, 0, sizeof (payload)); - req.emr_cmd = MC_CMD_ALLOC_PIOBUF; - req.emr_in_buf = payload; - req.emr_in_length = MC_CMD_ALLOC_PIOBUF_IN_LEN; - req.emr_out_buf = payload; - req.emr_out_length = MC_CMD_ALLOC_PIOBUF_OUT_LEN; - - efx_mcdi_execute_quiet(enp, &req); - - if (req.emr_rc != 0) { - rc = req.emr_rc; - goto fail2; - } - - if (req.emr_out_length_used < MC_CMD_ALLOC_PIOBUF_OUT_LEN) { - rc = EMSGSIZE; - goto fail3; - } - - *handlep = MCDI_OUT_DWORD(req, ALLOC_PIOBUF_OUT_PIOBUF_HANDLE); - - return (0); - -fail3: - EFSYS_PROBE(fail3); -fail2: - EFSYS_PROBE(fail2); -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - - return (rc); -} - -static __checkReturn efx_rc_t -efx_mcdi_free_piobuf( - __in efx_nic_t *enp, - __in efx_piobuf_handle_t handle) -{ - efx_mcdi_req_t req; - uint8_t payload[MAX(MC_CMD_FREE_PIOBUF_IN_LEN, - MC_CMD_FREE_PIOBUF_OUT_LEN)]; - efx_rc_t rc; - - (void) memset(payload, 0, sizeof (payload)); - req.emr_cmd = MC_CMD_FREE_PIOBUF; - req.emr_in_buf = payload; - req.emr_in_length = MC_CMD_FREE_PIOBUF_IN_LEN; - req.emr_out_buf = payload; - req.emr_out_length = MC_CMD_FREE_PIOBUF_OUT_LEN; - - MCDI_IN_SET_DWORD(req, FREE_PIOBUF_IN_PIOBUF_HANDLE, handle); - - efx_mcdi_execute_quiet(enp, &req); - - if (req.emr_rc != 0) { - rc = req.emr_rc; - goto fail1; - } - - return (0); - -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - - return (rc); -} - -static __checkReturn efx_rc_t -efx_mcdi_link_piobuf( - __in efx_nic_t *enp, - __in uint32_t vi_index, - __in efx_piobuf_handle_t handle) -{ - efx_mcdi_req_t req; - uint8_t payload[MAX(MC_CMD_LINK_PIOBUF_IN_LEN, - MC_CMD_LINK_PIOBUF_OUT_LEN)]; - efx_rc_t rc; - - (void) memset(payload, 0, sizeof (payload)); - req.emr_cmd = MC_CMD_LINK_PIOBUF; - req.emr_in_buf = payload; - req.emr_in_length = MC_CMD_LINK_PIOBUF_IN_LEN; - req.emr_out_buf = payload; - req.emr_out_length = MC_CMD_LINK_PIOBUF_OUT_LEN; - - MCDI_IN_SET_DWORD(req, LINK_PIOBUF_IN_PIOBUF_HANDLE, handle); - MCDI_IN_SET_DWORD(req, LINK_PIOBUF_IN_TXQ_INSTANCE, vi_index); - - efx_mcdi_execute(enp, &req); - - if (req.emr_rc != 0) { - rc = req.emr_rc; - goto fail1; - } - - return (0); - -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - - return (rc); -} - -static __checkReturn efx_rc_t -efx_mcdi_unlink_piobuf( - __in efx_nic_t *enp, - __in uint32_t vi_index) -{ - efx_mcdi_req_t req; - uint8_t payload[MAX(MC_CMD_UNLINK_PIOBUF_IN_LEN, - MC_CMD_UNLINK_PIOBUF_OUT_LEN)]; - efx_rc_t rc; - - (void) memset(payload, 0, sizeof (payload)); - req.emr_cmd = MC_CMD_UNLINK_PIOBUF; - req.emr_in_buf = payload; - req.emr_in_length = MC_CMD_UNLINK_PIOBUF_IN_LEN; - req.emr_out_buf = payload; - req.emr_out_length = MC_CMD_UNLINK_PIOBUF_OUT_LEN; - - MCDI_IN_SET_DWORD(req, UNLINK_PIOBUF_IN_TXQ_INSTANCE, vi_index); - - efx_mcdi_execute(enp, &req); - - if (req.emr_rc != 0) { - rc = req.emr_rc; - goto fail1; - } - - return (0); - -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - - return (rc); -} - -static void -ef10_nic_alloc_piobufs( - __in efx_nic_t *enp, - __in uint32_t max_piobuf_count) -{ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"