15f5c71ccSAndrew Rybchenko /*- 2929c7febSAndrew Rybchenko * Copyright (c) 2015-2016 Solarflare Communications Inc. 35f5c71ccSAndrew Rybchenko * All rights reserved. 45f5c71ccSAndrew Rybchenko * 55f5c71ccSAndrew Rybchenko * Redistribution and use in source and binary forms, with or without 65f5c71ccSAndrew Rybchenko * modification, are permitted provided that the following conditions are met: 75f5c71ccSAndrew Rybchenko * 85f5c71ccSAndrew Rybchenko * 1. Redistributions of source code must retain the above copyright notice, 95f5c71ccSAndrew Rybchenko * this list of conditions and the following disclaimer. 105f5c71ccSAndrew Rybchenko * 2. Redistributions in binary form must reproduce the above copyright notice, 115f5c71ccSAndrew Rybchenko * this list of conditions and the following disclaimer in the documentation 125f5c71ccSAndrew Rybchenko * and/or other materials provided with the distribution. 135f5c71ccSAndrew Rybchenko * 145f5c71ccSAndrew Rybchenko * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 155f5c71ccSAndrew Rybchenko * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 165f5c71ccSAndrew Rybchenko * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 175f5c71ccSAndrew Rybchenko * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 185f5c71ccSAndrew Rybchenko * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 195f5c71ccSAndrew Rybchenko * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 205f5c71ccSAndrew Rybchenko * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 215f5c71ccSAndrew Rybchenko * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 225f5c71ccSAndrew Rybchenko * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 235f5c71ccSAndrew Rybchenko * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 245f5c71ccSAndrew Rybchenko * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 255f5c71ccSAndrew Rybchenko * 265f5c71ccSAndrew Rybchenko * The views and conclusions contained in the software and documentation are 275f5c71ccSAndrew Rybchenko * those of the authors and should not be interpreted as representing official 285f5c71ccSAndrew Rybchenko * policies, either expressed or implied, of the FreeBSD Project. 295f5c71ccSAndrew Rybchenko */ 305f5c71ccSAndrew Rybchenko 315f5c71ccSAndrew Rybchenko #include <sys/cdefs.h> 325f5c71ccSAndrew Rybchenko __FBSDID("$FreeBSD$"); 335f5c71ccSAndrew Rybchenko 345f5c71ccSAndrew Rybchenko #include "efx.h" 355f5c71ccSAndrew Rybchenko #include "efx_impl.h" 36dcb49ebaSAndrew Rybchenko 375f5c71ccSAndrew Rybchenko 385f5c71ccSAndrew Rybchenko #if EFSYS_OPT_MEDFORD 395f5c71ccSAndrew Rybchenko 406de7c598SAndrew Rybchenko static __checkReturn efx_rc_t 416de7c598SAndrew Rybchenko efx_mcdi_get_rxdp_config( 426de7c598SAndrew Rybchenko __in efx_nic_t *enp, 436de7c598SAndrew Rybchenko __out uint32_t *end_paddingp) 446de7c598SAndrew Rybchenko { 456de7c598SAndrew Rybchenko efx_mcdi_req_t req; 466de7c598SAndrew Rybchenko uint8_t payload[MAX(MC_CMD_GET_RXDP_CONFIG_IN_LEN, 476de7c598SAndrew Rybchenko MC_CMD_GET_RXDP_CONFIG_OUT_LEN)]; 486de7c598SAndrew Rybchenko uint32_t end_padding; 496de7c598SAndrew Rybchenko efx_rc_t rc; 506de7c598SAndrew Rybchenko 516de7c598SAndrew Rybchenko memset(payload, 0, sizeof (payload)); 526de7c598SAndrew Rybchenko req.emr_cmd = MC_CMD_GET_RXDP_CONFIG; 536de7c598SAndrew Rybchenko req.emr_in_buf = payload; 546de7c598SAndrew Rybchenko req.emr_in_length = MC_CMD_GET_RXDP_CONFIG_IN_LEN; 556de7c598SAndrew Rybchenko req.emr_out_buf = payload; 566de7c598SAndrew Rybchenko req.emr_out_length = MC_CMD_GET_RXDP_CONFIG_OUT_LEN; 576de7c598SAndrew Rybchenko 586de7c598SAndrew Rybchenko efx_mcdi_execute(enp, &req); 596de7c598SAndrew Rybchenko if (req.emr_rc != 0) { 606de7c598SAndrew Rybchenko rc = req.emr_rc; 616de7c598SAndrew Rybchenko goto fail1; 626de7c598SAndrew Rybchenko } 636de7c598SAndrew Rybchenko 646de7c598SAndrew Rybchenko if (MCDI_OUT_DWORD_FIELD(req, GET_RXDP_CONFIG_OUT_DATA, 656de7c598SAndrew Rybchenko GET_RXDP_CONFIG_OUT_PAD_HOST_DMA) == 0) { 666de7c598SAndrew Rybchenko /* RX DMA end padding is disabled */ 676de7c598SAndrew Rybchenko end_padding = 0; 686de7c598SAndrew Rybchenko } else { 696de7c598SAndrew Rybchenko switch (MCDI_OUT_DWORD_FIELD(req, GET_RXDP_CONFIG_OUT_DATA, 706de7c598SAndrew Rybchenko GET_RXDP_CONFIG_OUT_PAD_HOST_LEN)) { 716de7c598SAndrew Rybchenko case MC_CMD_SET_RXDP_CONFIG_IN_PAD_HOST_64: 726de7c598SAndrew Rybchenko end_padding = 64; 736de7c598SAndrew Rybchenko break; 746de7c598SAndrew Rybchenko case MC_CMD_SET_RXDP_CONFIG_IN_PAD_HOST_128: 756de7c598SAndrew Rybchenko end_padding = 128; 766de7c598SAndrew Rybchenko break; 776de7c598SAndrew Rybchenko case MC_CMD_SET_RXDP_CONFIG_IN_PAD_HOST_256: 786de7c598SAndrew Rybchenko end_padding = 256; 796de7c598SAndrew Rybchenko break; 806de7c598SAndrew Rybchenko default: 816de7c598SAndrew Rybchenko rc = ENOTSUP; 826de7c598SAndrew Rybchenko goto fail2; 836de7c598SAndrew Rybchenko } 846de7c598SAndrew Rybchenko } 856de7c598SAndrew Rybchenko 866de7c598SAndrew Rybchenko *end_paddingp = end_padding; 876de7c598SAndrew Rybchenko 886de7c598SAndrew Rybchenko return (0); 896de7c598SAndrew Rybchenko 906de7c598SAndrew Rybchenko fail2: 916de7c598SAndrew Rybchenko EFSYS_PROBE(fail2); 926de7c598SAndrew Rybchenko fail1: 936de7c598SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 946de7c598SAndrew Rybchenko 956de7c598SAndrew Rybchenko return (rc); 966de7c598SAndrew Rybchenko } 976de7c598SAndrew Rybchenko 98f6d61784SAndrew Rybchenko static __checkReturn efx_rc_t 99f6d61784SAndrew Rybchenko medford_nic_get_required_pcie_bandwidth( 100f6d61784SAndrew Rybchenko __in efx_nic_t *enp, 101f6d61784SAndrew Rybchenko __out uint32_t *bandwidth_mbpsp) 102f6d61784SAndrew Rybchenko { 103f6d61784SAndrew Rybchenko uint32_t port_modes; 104f6d61784SAndrew Rybchenko uint32_t current_mode; 105f6d61784SAndrew Rybchenko uint32_t bandwidth; 106f6d61784SAndrew Rybchenko efx_rc_t rc; 107f6d61784SAndrew Rybchenko 108f6d61784SAndrew Rybchenko if ((rc = efx_mcdi_get_port_modes(enp, &port_modes, 109f6d61784SAndrew Rybchenko ¤t_mode)) != 0) { 110f6d61784SAndrew Rybchenko /* No port mode info available. */ 111f6d61784SAndrew Rybchenko bandwidth = 0; 112f6d61784SAndrew Rybchenko goto out; 113f6d61784SAndrew Rybchenko } 114f6d61784SAndrew Rybchenko 115f6d61784SAndrew Rybchenko if ((rc = ef10_nic_get_port_mode_bandwidth(current_mode, 116f6d61784SAndrew Rybchenko &bandwidth)) != 0) 117f6d61784SAndrew Rybchenko goto fail1; 118f6d61784SAndrew Rybchenko 119f6d61784SAndrew Rybchenko out: 120f6d61784SAndrew Rybchenko *bandwidth_mbpsp = bandwidth; 121f6d61784SAndrew Rybchenko 122f6d61784SAndrew Rybchenko return (0); 123f6d61784SAndrew Rybchenko 124f6d61784SAndrew Rybchenko fail1: 125f6d61784SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 126f6d61784SAndrew Rybchenko 127f6d61784SAndrew Rybchenko return (rc); 128f6d61784SAndrew Rybchenko } 129f6d61784SAndrew Rybchenko 130cfa023ebSAndrew Rybchenko __checkReturn efx_rc_t 131cfa023ebSAndrew Rybchenko medford_board_cfg( 132cfa023ebSAndrew Rybchenko __in efx_nic_t *enp) 133cfa023ebSAndrew Rybchenko { 134cfa023ebSAndrew Rybchenko efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); 135cfa023ebSAndrew Rybchenko efx_nic_cfg_t *encp = &(enp->en_nic_cfg); 136cfa023ebSAndrew Rybchenko uint8_t mac_addr[6] = { 0 }; 137cfa023ebSAndrew Rybchenko uint32_t board_type = 0; 138177347ddSAndrew Rybchenko ef10_link_state_t els; 139cfa023ebSAndrew Rybchenko efx_port_t *epp = &(enp->en_port); 140cfa023ebSAndrew Rybchenko uint32_t port; 141cfa023ebSAndrew Rybchenko uint32_t pf; 142cfa023ebSAndrew Rybchenko uint32_t vf; 143cfa023ebSAndrew Rybchenko uint32_t mask; 14478e5c87cSAndrew Rybchenko uint32_t sysclk, dpcpu_clk; 145cfa023ebSAndrew Rybchenko uint32_t base, nvec; 1466de7c598SAndrew Rybchenko uint32_t end_padding; 147f6d61784SAndrew Rybchenko uint32_t bandwidth; 148cfa023ebSAndrew Rybchenko efx_rc_t rc; 1495f5c71ccSAndrew Rybchenko 150cfa023ebSAndrew Rybchenko /* 151cfa023ebSAndrew Rybchenko * FIXME: Likely to be incomplete and incorrect. 152cfa023ebSAndrew Rybchenko * Parts of this should be shared with Huntington. 153cfa023ebSAndrew Rybchenko */ 1545f5c71ccSAndrew Rybchenko 155cfa023ebSAndrew Rybchenko if ((rc = efx_mcdi_get_port_assignment(enp, &port)) != 0) 156cfa023ebSAndrew Rybchenko goto fail1; 157cfa023ebSAndrew Rybchenko 158cfa023ebSAndrew Rybchenko /* 159cfa023ebSAndrew Rybchenko * NOTE: The MCDI protocol numbers ports from zero. 160cfa023ebSAndrew Rybchenko * The common code MCDI interface numbers ports from one. 161cfa023ebSAndrew Rybchenko */ 162cfa023ebSAndrew Rybchenko emip->emi_port = port + 1; 163cfa023ebSAndrew Rybchenko 164cfa023ebSAndrew Rybchenko if ((rc = ef10_external_port_mapping(enp, port, 165cfa023ebSAndrew Rybchenko &encp->enc_external_port)) != 0) 166cfa023ebSAndrew Rybchenko goto fail2; 167cfa023ebSAndrew Rybchenko 168cfa023ebSAndrew Rybchenko /* 169cfa023ebSAndrew Rybchenko * Get PCIe function number from firmware (used for 170cfa023ebSAndrew Rybchenko * per-function privilege and dynamic config info). 171cfa023ebSAndrew Rybchenko * - PCIe PF: pf = PF number, vf = 0xffff. 172cfa023ebSAndrew Rybchenko * - PCIe VF: pf = parent PF, vf = VF number. 173cfa023ebSAndrew Rybchenko */ 174cfa023ebSAndrew Rybchenko if ((rc = efx_mcdi_get_function_info(enp, &pf, &vf)) != 0) 175cfa023ebSAndrew Rybchenko goto fail3; 176cfa023ebSAndrew Rybchenko 177cfa023ebSAndrew Rybchenko encp->enc_pf = pf; 178cfa023ebSAndrew Rybchenko encp->enc_vf = vf; 179cfa023ebSAndrew Rybchenko 180cfa023ebSAndrew Rybchenko /* MAC address for this function */ 181cfa023ebSAndrew Rybchenko if (EFX_PCI_FUNCTION_IS_PF(encp)) { 182cfa023ebSAndrew Rybchenko rc = efx_mcdi_get_mac_address_pf(enp, mac_addr); 183ecaa500cSAndrew Rybchenko #if EFSYS_OPT_ALLOW_UNCONFIGURED_NIC 184ecaa500cSAndrew Rybchenko /* Disable static config checking for Medford NICs, ONLY 185ecaa500cSAndrew Rybchenko * for manufacturing test and setup at the factory, to 186ecaa500cSAndrew Rybchenko * allow the static config to be installed. 187ecaa500cSAndrew Rybchenko */ 188ecaa500cSAndrew Rybchenko #else /* EFSYS_OPT_ALLOW_UNCONFIGURED_NIC */ 189cfa023ebSAndrew Rybchenko if ((rc == 0) && (mac_addr[0] & 0x02)) { 190cfa023ebSAndrew Rybchenko /* 191cfa023ebSAndrew Rybchenko * If the static config does not include a global MAC 192cfa023ebSAndrew Rybchenko * address pool then the board may return a locally 193cfa023ebSAndrew Rybchenko * administered MAC address (this should only happen on 194cfa023ebSAndrew Rybchenko * incorrectly programmed boards). 195cfa023ebSAndrew Rybchenko */ 196cfa023ebSAndrew Rybchenko rc = EINVAL; 197cfa023ebSAndrew Rybchenko } 198ecaa500cSAndrew Rybchenko #endif /* EFSYS_OPT_ALLOW_UNCONFIGURED_NIC */ 199cfa023ebSAndrew Rybchenko } else { 200cfa023ebSAndrew Rybchenko rc = efx_mcdi_get_mac_address_vf(enp, mac_addr); 201cfa023ebSAndrew Rybchenko } 202cfa023ebSAndrew Rybchenko if (rc != 0) 203cfa023ebSAndrew Rybchenko goto fail4; 204cfa023ebSAndrew Rybchenko 205cfa023ebSAndrew Rybchenko EFX_MAC_ADDR_COPY(encp->enc_mac_addr, mac_addr); 206cfa023ebSAndrew Rybchenko 207cfa023ebSAndrew Rybchenko /* Board configuration */ 208cfa023ebSAndrew Rybchenko rc = efx_mcdi_get_board_cfg(enp, &board_type, NULL, NULL); 209cfa023ebSAndrew Rybchenko if (rc != 0) { 210cfa023ebSAndrew Rybchenko /* Unprivileged functions may not be able to read board cfg */ 211cfa023ebSAndrew Rybchenko if (rc == EACCES) 212cfa023ebSAndrew Rybchenko board_type = 0; 213cfa023ebSAndrew Rybchenko else 214cfa023ebSAndrew Rybchenko goto fail5; 215cfa023ebSAndrew Rybchenko } 216cfa023ebSAndrew Rybchenko 217cfa023ebSAndrew Rybchenko encp->enc_board_type = board_type; 218cfa023ebSAndrew Rybchenko encp->enc_clk_mult = 1; /* not used for Medford */ 219cfa023ebSAndrew Rybchenko 220cfa023ebSAndrew Rybchenko /* Fill out fields in enp->en_port and enp->en_nic_cfg from MCDI */ 221cfa023ebSAndrew Rybchenko if ((rc = efx_mcdi_get_phy_cfg(enp)) != 0) 222cfa023ebSAndrew Rybchenko goto fail6; 223cfa023ebSAndrew Rybchenko 224cfa023ebSAndrew Rybchenko /* Obtain the default PHY advertised capabilities */ 225ee2812adSAndrew Rybchenko if ((rc = ef10_phy_get_link(enp, &els)) != 0) 226cfa023ebSAndrew Rybchenko goto fail7; 227177347ddSAndrew Rybchenko epp->ep_default_adv_cap_mask = els.els_adv_cap_mask; 228177347ddSAndrew Rybchenko epp->ep_adv_cap_mask = els.els_adv_cap_mask; 229cfa023ebSAndrew Rybchenko 230e26f5dacSAndrew Rybchenko /* 231e26f5dacSAndrew Rybchenko * Enable firmware workarounds for hardware errata. 232e26f5dacSAndrew Rybchenko * Expected responses are: 233e26f5dacSAndrew Rybchenko * - 0 (zero): 234e26f5dacSAndrew Rybchenko * Success: workaround enabled or disabled as requested. 235e26f5dacSAndrew Rybchenko * - MC_CMD_ERR_ENOSYS (reported as ENOTSUP): 236e26f5dacSAndrew Rybchenko * Firmware does not support the MC_CMD_WORKAROUND request. 237e26f5dacSAndrew Rybchenko * (assume that the workaround is not supported). 238e26f5dacSAndrew Rybchenko * - MC_CMD_ERR_ENOENT (reported as ENOENT): 239e26f5dacSAndrew Rybchenko * Firmware does not support the requested workaround. 240e26f5dacSAndrew Rybchenko * - MC_CMD_ERR_EPERM (reported as EACCES): 241e26f5dacSAndrew Rybchenko * Unprivileged function cannot enable/disable workarounds. 242e26f5dacSAndrew Rybchenko * 243e26f5dacSAndrew Rybchenko * See efx_mcdi_request_errcode() for MCDI error translations. 244e26f5dacSAndrew Rybchenko */ 245e26f5dacSAndrew Rybchenko 246e26f5dacSAndrew Rybchenko 247cfa023ebSAndrew Rybchenko if (EFX_PCI_FUNCTION_IS_VF(encp)) { 248cfa023ebSAndrew Rybchenko /* 249cfa023ebSAndrew Rybchenko * Interrupt testing does not work for VFs. See bug50084. 250cfa023ebSAndrew Rybchenko * FIXME: Does this still apply to Medford? 251cfa023ebSAndrew Rybchenko */ 252cfa023ebSAndrew Rybchenko encp->enc_bug41750_workaround = B_TRUE; 253cfa023ebSAndrew Rybchenko } 254cfa023ebSAndrew Rybchenko 255cfa023ebSAndrew Rybchenko /* Chained multicast is always enabled on Medford */ 256cfa023ebSAndrew Rybchenko encp->enc_bug26807_workaround = B_TRUE; 257cfa023ebSAndrew Rybchenko 258e26f5dacSAndrew Rybchenko /* 259e26f5dacSAndrew Rybchenko * If the bug61265 workaround is enabled, then interrupt holdoff timers 260e26f5dacSAndrew Rybchenko * cannot be controlled by timer table writes, so MCDI must be used 261e26f5dacSAndrew Rybchenko * (timer table writes can still be used for wakeup timers). 262e26f5dacSAndrew Rybchenko */ 263e26f5dacSAndrew Rybchenko rc = efx_mcdi_set_workaround(enp, MC_CMD_WORKAROUND_BUG61265, B_TRUE, 264e26f5dacSAndrew Rybchenko NULL); 265e26f5dacSAndrew Rybchenko if ((rc == 0) || (rc == EACCES)) 266e26f5dacSAndrew Rybchenko encp->enc_bug61265_workaround = B_TRUE; 267e26f5dacSAndrew Rybchenko else if ((rc == ENOTSUP) || (rc == ENOENT)) 268e26f5dacSAndrew Rybchenko encp->enc_bug61265_workaround = B_FALSE; 269e26f5dacSAndrew Rybchenko else 270e26f5dacSAndrew Rybchenko goto fail8; 271e26f5dacSAndrew Rybchenko 27278e5c87cSAndrew Rybchenko /* Get clock frequencies (in MHz). */ 27378e5c87cSAndrew Rybchenko if ((rc = efx_mcdi_get_clock(enp, &sysclk, &dpcpu_clk)) != 0) 274e26f5dacSAndrew Rybchenko goto fail9; 275cfa023ebSAndrew Rybchenko 276cfa023ebSAndrew Rybchenko /* 27778e5c87cSAndrew Rybchenko * The Medford timer quantum is 1536 dpcpu_clk cycles, documented for 27878e5c87cSAndrew Rybchenko * the EV_TMR_VAL field of EV_TIMER_TBL. Scale for MHz and ns units. 279cfa023ebSAndrew Rybchenko */ 28078e5c87cSAndrew Rybchenko encp->enc_evq_timer_quantum_ns = 1536000UL / dpcpu_clk; /* 1536 cycles */ 281cfa023ebSAndrew Rybchenko encp->enc_evq_timer_max_us = (encp->enc_evq_timer_quantum_ns << 282cfa023ebSAndrew Rybchenko FRF_CZ_TC_TIMER_VAL_WIDTH) / 1000; 283cfa023ebSAndrew Rybchenko 284cfa023ebSAndrew Rybchenko /* Check capabilities of running datapath firmware */ 285cfa023ebSAndrew Rybchenko if ((rc = ef10_get_datapath_caps(enp)) != 0) 286e26f5dacSAndrew Rybchenko goto fail10; 287cfa023ebSAndrew Rybchenko 288cfa023ebSAndrew Rybchenko /* Alignment for receive packet DMA buffers */ 289cfa023ebSAndrew Rybchenko encp->enc_rx_buf_align_start = 1; 290cfa023ebSAndrew Rybchenko 2916de7c598SAndrew Rybchenko /* Get the RX DMA end padding alignment configuration */ 292ab72be51SAndrew Rybchenko if ((rc = efx_mcdi_get_rxdp_config(enp, &end_padding)) != 0) { 293ab72be51SAndrew Rybchenko if (rc != EACCES) 294e26f5dacSAndrew Rybchenko goto fail11; 295ab72be51SAndrew Rybchenko 296ab72be51SAndrew Rybchenko /* Assume largest tail padding size supported by hardware */ 297ab72be51SAndrew Rybchenko end_padding = 256; 298ab72be51SAndrew Rybchenko } 2996de7c598SAndrew Rybchenko encp->enc_rx_buf_align_end = end_padding; 300cfa023ebSAndrew Rybchenko 301cfa023ebSAndrew Rybchenko /* Alignment for WPTR updates */ 302cfa023ebSAndrew Rybchenko encp->enc_rx_push_align = EF10_RX_WPTR_ALIGN; 303cfa023ebSAndrew Rybchenko 3046a09b206SAndrew Rybchenko encp->enc_tx_dma_desc_size_max = EFX_MASK32(ESF_DZ_RX_KER_BYTE_CNT); 3056a09b206SAndrew Rybchenko /* No boundary crossing limits */ 3066a09b206SAndrew Rybchenko encp->enc_tx_dma_desc_boundary = 0; 3076a09b206SAndrew Rybchenko 308cfa023ebSAndrew Rybchenko /* 309cfa023ebSAndrew Rybchenko * Set resource limits for MC_CMD_ALLOC_VIS. Note that we cannot use 310cfa023ebSAndrew Rybchenko * MC_CMD_GET_RESOURCE_LIMITS here as that reports the available 311cfa023ebSAndrew Rybchenko * resources (allocated to this PCIe function), which is zero until 312cfa023ebSAndrew Rybchenko * after we have allocated VIs. 313cfa023ebSAndrew Rybchenko */ 314cfa023ebSAndrew Rybchenko encp->enc_evq_limit = 1024; 315cfa023ebSAndrew Rybchenko encp->enc_rxq_limit = EFX_RXQ_LIMIT_TARGET; 316cfa023ebSAndrew Rybchenko encp->enc_txq_limit = EFX_TXQ_LIMIT_TARGET; 317cfa023ebSAndrew Rybchenko 318*d343a7f4SAndrew Rybchenko /* 319*d343a7f4SAndrew Rybchenko * The maximum supported transmit queue size is 2048. TXQs with 4096 320*d343a7f4SAndrew Rybchenko * descriptors are not supported as the top bit is used for vfifo 321*d343a7f4SAndrew Rybchenko * stuffing. 322*d343a7f4SAndrew Rybchenko */ 323*d343a7f4SAndrew Rybchenko encp->enc_txq_max_ndescs = 2048; 324*d343a7f4SAndrew Rybchenko 325cfa023ebSAndrew Rybchenko encp->enc_buftbl_limit = 0xFFFFFFFF; 326cfa023ebSAndrew Rybchenko 327cfa023ebSAndrew Rybchenko encp->enc_piobuf_limit = MEDFORD_PIOBUF_NBUFS; 328cfa023ebSAndrew Rybchenko encp->enc_piobuf_size = MEDFORD_PIOBUF_SIZE; 329cfa023ebSAndrew Rybchenko encp->enc_piobuf_min_alloc_size = MEDFORD_MIN_PIO_ALLOC_SIZE; 330cfa023ebSAndrew Rybchenko 331cfa023ebSAndrew Rybchenko /* 332cfa023ebSAndrew Rybchenko * Get the current privilege mask. Note that this may be modified 333cfa023ebSAndrew Rybchenko * dynamically, so this value is informational only. DO NOT use 334cfa023ebSAndrew Rybchenko * the privilege mask to check for sufficient privileges, as that 335cfa023ebSAndrew Rybchenko * can result in time-of-check/time-of-use bugs. 336cfa023ebSAndrew Rybchenko */ 33780af6f26SAndrew Rybchenko if ((rc = ef10_get_privilege_mask(enp, &mask)) != 0) 338e26f5dacSAndrew Rybchenko goto fail12; 339cfa023ebSAndrew Rybchenko encp->enc_privilege_mask = mask; 340cfa023ebSAndrew Rybchenko 341cfa023ebSAndrew Rybchenko /* Get interrupt vector limits */ 342cfa023ebSAndrew Rybchenko if ((rc = efx_mcdi_get_vector_cfg(enp, &base, &nvec, NULL)) != 0) { 343cfa023ebSAndrew Rybchenko if (EFX_PCI_FUNCTION_IS_PF(encp)) 344e26f5dacSAndrew Rybchenko goto fail13; 345cfa023ebSAndrew Rybchenko 346cfa023ebSAndrew Rybchenko /* Ignore error (cannot query vector limits from a VF). */ 347cfa023ebSAndrew Rybchenko base = 0; 348cfa023ebSAndrew Rybchenko nvec = 1024; 349cfa023ebSAndrew Rybchenko } 350cfa023ebSAndrew Rybchenko encp->enc_intr_vec_base = base; 351cfa023ebSAndrew Rybchenko encp->enc_intr_limit = nvec; 352cfa023ebSAndrew Rybchenko 353cfa023ebSAndrew Rybchenko /* 354cfa023ebSAndrew Rybchenko * Maximum number of bytes into the frame the TCP header can start for 355cfa023ebSAndrew Rybchenko * firmware assisted TSO to work. 356cfa023ebSAndrew Rybchenko */ 357cfa023ebSAndrew Rybchenko encp->enc_tx_tso_tcp_header_offset_limit = EF10_TCP_HEADER_OFFSET_LIMIT; 358cfa023ebSAndrew Rybchenko 359739ebba6SAndrew Rybchenko /* 360739ebba6SAndrew Rybchenko * Medford stores a single global copy of VPD, not per-PF as on 361739ebba6SAndrew Rybchenko * Huntington. 362739ebba6SAndrew Rybchenko */ 363739ebba6SAndrew Rybchenko encp->enc_vpd_is_global = B_TRUE; 364739ebba6SAndrew Rybchenko 365f6d61784SAndrew Rybchenko rc = medford_nic_get_required_pcie_bandwidth(enp, &bandwidth); 366f6d61784SAndrew Rybchenko if (rc != 0) 367e26f5dacSAndrew Rybchenko goto fail14; 368f6d61784SAndrew Rybchenko encp->enc_required_pcie_bandwidth_mbps = bandwidth; 369f6d61784SAndrew Rybchenko encp->enc_max_pcie_link_gen = EFX_PCIE_LINK_SPEED_GEN3; 370f6d61784SAndrew Rybchenko 371cfa023ebSAndrew Rybchenko return (0); 372cfa023ebSAndrew Rybchenko 373e26f5dacSAndrew Rybchenko fail14: 374e26f5dacSAndrew Rybchenko EFSYS_PROBE(fail14); 375f6d61784SAndrew Rybchenko fail13: 376f6d61784SAndrew Rybchenko EFSYS_PROBE(fail13); 3776de7c598SAndrew Rybchenko fail12: 3786de7c598SAndrew Rybchenko EFSYS_PROBE(fail12); 379cfa023ebSAndrew Rybchenko fail11: 380cfa023ebSAndrew Rybchenko EFSYS_PROBE(fail11); 381cfa023ebSAndrew Rybchenko fail10: 382cfa023ebSAndrew Rybchenko EFSYS_PROBE(fail10); 383cfa023ebSAndrew Rybchenko fail9: 384cfa023ebSAndrew Rybchenko EFSYS_PROBE(fail9); 385cfa023ebSAndrew Rybchenko fail8: 386cfa023ebSAndrew Rybchenko EFSYS_PROBE(fail8); 387cfa023ebSAndrew Rybchenko fail7: 388cfa023ebSAndrew Rybchenko EFSYS_PROBE(fail7); 389cfa023ebSAndrew Rybchenko fail6: 390cfa023ebSAndrew Rybchenko EFSYS_PROBE(fail6); 391cfa023ebSAndrew Rybchenko fail5: 392cfa023ebSAndrew Rybchenko EFSYS_PROBE(fail5); 393cfa023ebSAndrew Rybchenko fail4: 394cfa023ebSAndrew Rybchenko EFSYS_PROBE(fail4); 395cfa023ebSAndrew Rybchenko fail3: 396cfa023ebSAndrew Rybchenko EFSYS_PROBE(fail3); 397cfa023ebSAndrew Rybchenko fail2: 398cfa023ebSAndrew Rybchenko EFSYS_PROBE(fail2); 399cfa023ebSAndrew Rybchenko fail1: 400cfa023ebSAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 401cfa023ebSAndrew Rybchenko 402cfa023ebSAndrew Rybchenko return (rc); 403cfa023ebSAndrew Rybchenko } 4045f5c71ccSAndrew Rybchenko 4055f5c71ccSAndrew Rybchenko #endif /* EFSYS_OPT_MEDFORD */ 406