xref: /freebsd/sys/dev/sfxge/common/medford_nic.c (revision 929c7feb83b66d65bde31f02eca36b9bdd65eb9c)
15f5c71ccSAndrew Rybchenko /*-
2*929c7febSAndrew 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 				    &current_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 
230cfa023ebSAndrew Rybchenko 	if (EFX_PCI_FUNCTION_IS_VF(encp)) {
231cfa023ebSAndrew Rybchenko 		/*
232cfa023ebSAndrew Rybchenko 		 * Interrupt testing does not work for VFs. See bug50084.
233cfa023ebSAndrew Rybchenko 		 * FIXME: Does this still  apply to Medford?
234cfa023ebSAndrew Rybchenko 		 */
235cfa023ebSAndrew Rybchenko 		encp->enc_bug41750_workaround = B_TRUE;
236cfa023ebSAndrew Rybchenko 	}
237cfa023ebSAndrew Rybchenko 
238cfa023ebSAndrew Rybchenko 	/* Chained multicast is always enabled on Medford */
239cfa023ebSAndrew Rybchenko 	encp->enc_bug26807_workaround = B_TRUE;
240cfa023ebSAndrew Rybchenko 
24178e5c87cSAndrew Rybchenko 	/* Get clock frequencies (in MHz). */
24278e5c87cSAndrew Rybchenko 	if ((rc = efx_mcdi_get_clock(enp, &sysclk, &dpcpu_clk)) != 0)
243cfa023ebSAndrew Rybchenko 		goto fail8;
244cfa023ebSAndrew Rybchenko 
245cfa023ebSAndrew Rybchenko 	/*
24678e5c87cSAndrew Rybchenko 	 * The Medford timer quantum is 1536 dpcpu_clk cycles, documented for
24778e5c87cSAndrew Rybchenko 	 * the EV_TMR_VAL field of EV_TIMER_TBL. Scale for MHz and ns units.
248cfa023ebSAndrew Rybchenko 	 */
24978e5c87cSAndrew Rybchenko 	encp->enc_evq_timer_quantum_ns = 1536000UL / dpcpu_clk; /* 1536 cycles */
250cfa023ebSAndrew Rybchenko 	encp->enc_evq_timer_max_us = (encp->enc_evq_timer_quantum_ns <<
251cfa023ebSAndrew Rybchenko 		    FRF_CZ_TC_TIMER_VAL_WIDTH) / 1000;
252cfa023ebSAndrew Rybchenko 
253cfa023ebSAndrew Rybchenko 	/* Check capabilities of running datapath firmware */
254cfa023ebSAndrew Rybchenko 	if ((rc = ef10_get_datapath_caps(enp)) != 0)
255cfa023ebSAndrew Rybchenko 	    goto fail9;
256cfa023ebSAndrew Rybchenko 
257cfa023ebSAndrew Rybchenko 	/* Alignment for receive packet DMA buffers */
258cfa023ebSAndrew Rybchenko 	encp->enc_rx_buf_align_start = 1;
259cfa023ebSAndrew Rybchenko 
2606de7c598SAndrew Rybchenko 	/* Get the RX DMA end padding alignment configuration */
2616de7c598SAndrew Rybchenko 	if ((rc = efx_mcdi_get_rxdp_config(enp, &end_padding)) != 0)
2626de7c598SAndrew Rybchenko 		goto fail10;
2636de7c598SAndrew Rybchenko 	encp->enc_rx_buf_align_end = end_padding;
264cfa023ebSAndrew Rybchenko 
265cfa023ebSAndrew Rybchenko 	/* Alignment for WPTR updates */
266cfa023ebSAndrew Rybchenko 	encp->enc_rx_push_align = EF10_RX_WPTR_ALIGN;
267cfa023ebSAndrew Rybchenko 
268cfa023ebSAndrew Rybchenko 	/*
269cfa023ebSAndrew Rybchenko 	 * Set resource limits for MC_CMD_ALLOC_VIS. Note that we cannot use
270cfa023ebSAndrew Rybchenko 	 * MC_CMD_GET_RESOURCE_LIMITS here as that reports the available
271cfa023ebSAndrew Rybchenko 	 * resources (allocated to this PCIe function), which is zero until
272cfa023ebSAndrew Rybchenko 	 * after we have allocated VIs.
273cfa023ebSAndrew Rybchenko 	 */
274cfa023ebSAndrew Rybchenko 	encp->enc_evq_limit = 1024;
275cfa023ebSAndrew Rybchenko 	encp->enc_rxq_limit = EFX_RXQ_LIMIT_TARGET;
276cfa023ebSAndrew Rybchenko 	encp->enc_txq_limit = EFX_TXQ_LIMIT_TARGET;
277cfa023ebSAndrew Rybchenko 
278cfa023ebSAndrew Rybchenko 	encp->enc_buftbl_limit = 0xFFFFFFFF;
279cfa023ebSAndrew Rybchenko 
280cfa023ebSAndrew Rybchenko 	encp->enc_piobuf_limit = MEDFORD_PIOBUF_NBUFS;
281cfa023ebSAndrew Rybchenko 	encp->enc_piobuf_size = MEDFORD_PIOBUF_SIZE;
282cfa023ebSAndrew Rybchenko 	encp->enc_piobuf_min_alloc_size = MEDFORD_MIN_PIO_ALLOC_SIZE;
283cfa023ebSAndrew Rybchenko 
284cfa023ebSAndrew Rybchenko 	/*
285cfa023ebSAndrew Rybchenko 	 * Get the current privilege mask. Note that this may be modified
286cfa023ebSAndrew Rybchenko 	 * dynamically, so this value is informational only. DO NOT use
287cfa023ebSAndrew Rybchenko 	 * the privilege mask to check for sufficient privileges, as that
288cfa023ebSAndrew Rybchenko 	 * can result in time-of-check/time-of-use bugs.
289cfa023ebSAndrew Rybchenko 	 */
29080af6f26SAndrew Rybchenko 	if ((rc = ef10_get_privilege_mask(enp, &mask)) != 0)
2916de7c598SAndrew Rybchenko 		goto fail11;
292cfa023ebSAndrew Rybchenko 	encp->enc_privilege_mask = mask;
293cfa023ebSAndrew Rybchenko 
294cfa023ebSAndrew Rybchenko 	/* Get interrupt vector limits */
295cfa023ebSAndrew Rybchenko 	if ((rc = efx_mcdi_get_vector_cfg(enp, &base, &nvec, NULL)) != 0) {
296cfa023ebSAndrew Rybchenko 		if (EFX_PCI_FUNCTION_IS_PF(encp))
2976de7c598SAndrew Rybchenko 			goto fail12;
298cfa023ebSAndrew Rybchenko 
299cfa023ebSAndrew Rybchenko 		/* Ignore error (cannot query vector limits from a VF). */
300cfa023ebSAndrew Rybchenko 		base = 0;
301cfa023ebSAndrew Rybchenko 		nvec = 1024;
302cfa023ebSAndrew Rybchenko 	}
303cfa023ebSAndrew Rybchenko 	encp->enc_intr_vec_base = base;
304cfa023ebSAndrew Rybchenko 	encp->enc_intr_limit = nvec;
305cfa023ebSAndrew Rybchenko 
306cfa023ebSAndrew Rybchenko 	/*
307cfa023ebSAndrew Rybchenko 	 * Maximum number of bytes into the frame the TCP header can start for
308cfa023ebSAndrew Rybchenko 	 * firmware assisted TSO to work.
309cfa023ebSAndrew Rybchenko 	 */
310cfa023ebSAndrew Rybchenko 	encp->enc_tx_tso_tcp_header_offset_limit = EF10_TCP_HEADER_OFFSET_LIMIT;
311cfa023ebSAndrew Rybchenko 
312739ebba6SAndrew Rybchenko 	/*
313739ebba6SAndrew Rybchenko 	 * Medford stores a single global copy of VPD, not per-PF as on
314739ebba6SAndrew Rybchenko 	 * Huntington.
315739ebba6SAndrew Rybchenko 	 */
316739ebba6SAndrew Rybchenko 	encp->enc_vpd_is_global = B_TRUE;
317739ebba6SAndrew Rybchenko 
318f6d61784SAndrew Rybchenko 	rc = medford_nic_get_required_pcie_bandwidth(enp, &bandwidth);
319f6d61784SAndrew Rybchenko 	if (rc != 0)
320f6d61784SAndrew Rybchenko 		goto fail13;
321f6d61784SAndrew Rybchenko 	encp->enc_required_pcie_bandwidth_mbps = bandwidth;
322f6d61784SAndrew Rybchenko 	encp->enc_max_pcie_link_gen = EFX_PCIE_LINK_SPEED_GEN3;
323f6d61784SAndrew Rybchenko 
324cfa023ebSAndrew Rybchenko 	return (0);
325cfa023ebSAndrew Rybchenko 
326f6d61784SAndrew Rybchenko fail13:
327f6d61784SAndrew Rybchenko 	EFSYS_PROBE(fail13);
3286de7c598SAndrew Rybchenko fail12:
3296de7c598SAndrew Rybchenko 	EFSYS_PROBE(fail12);
330cfa023ebSAndrew Rybchenko fail11:
331cfa023ebSAndrew Rybchenko 	EFSYS_PROBE(fail11);
332cfa023ebSAndrew Rybchenko fail10:
333cfa023ebSAndrew Rybchenko 	EFSYS_PROBE(fail10);
334cfa023ebSAndrew Rybchenko fail9:
335cfa023ebSAndrew Rybchenko 	EFSYS_PROBE(fail9);
336cfa023ebSAndrew Rybchenko fail8:
337cfa023ebSAndrew Rybchenko 	EFSYS_PROBE(fail8);
338cfa023ebSAndrew Rybchenko fail7:
339cfa023ebSAndrew Rybchenko 	EFSYS_PROBE(fail7);
340cfa023ebSAndrew Rybchenko fail6:
341cfa023ebSAndrew Rybchenko 	EFSYS_PROBE(fail6);
342cfa023ebSAndrew Rybchenko fail5:
343cfa023ebSAndrew Rybchenko 	EFSYS_PROBE(fail5);
344cfa023ebSAndrew Rybchenko fail4:
345cfa023ebSAndrew Rybchenko 	EFSYS_PROBE(fail4);
346cfa023ebSAndrew Rybchenko fail3:
347cfa023ebSAndrew Rybchenko 	EFSYS_PROBE(fail3);
348cfa023ebSAndrew Rybchenko fail2:
349cfa023ebSAndrew Rybchenko 	EFSYS_PROBE(fail2);
350cfa023ebSAndrew Rybchenko fail1:
351cfa023ebSAndrew Rybchenko 	EFSYS_PROBE1(fail1, efx_rc_t, rc);
352cfa023ebSAndrew Rybchenko 
353cfa023ebSAndrew Rybchenko 	return (rc);
354cfa023ebSAndrew Rybchenko }
3555f5c71ccSAndrew Rybchenko 
3565f5c71ccSAndrew Rybchenko #endif	/* EFSYS_OPT_MEDFORD */
357