1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright (c) 2012-2018 Solarflare Communications Inc.
13 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
15 #include "ef10_tlv_layout.h"
17 __checkReturn efx_rc_t
18 efx_mcdi_get_port_assignment(
20 __out uint32_t *portp)
23 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_GET_PORT_ASSIGNMENT_IN_LEN,
24 MC_CMD_GET_PORT_ASSIGNMENT_OUT_LEN);
27 EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
28 enp->en_family == EFX_FAMILY_MEDFORD ||
29 enp->en_family == EFX_FAMILY_MEDFORD2);
31 req.emr_cmd = MC_CMD_GET_PORT_ASSIGNMENT;
32 req.emr_in_buf = payload;
33 req.emr_in_length = MC_CMD_GET_PORT_ASSIGNMENT_IN_LEN;
34 req.emr_out_buf = payload;
35 req.emr_out_length = MC_CMD_GET_PORT_ASSIGNMENT_OUT_LEN;
37 efx_mcdi_execute(enp, &req);
39 if (req.emr_rc != 0) {
44 if (req.emr_out_length_used < MC_CMD_GET_PORT_ASSIGNMENT_OUT_LEN) {
49 *portp = MCDI_OUT_DWORD(req, GET_PORT_ASSIGNMENT_OUT_PORT);
56 EFSYS_PROBE1(fail1, efx_rc_t, rc);
61 __checkReturn efx_rc_t
62 efx_mcdi_get_port_modes(
64 __out uint32_t *modesp,
65 __out_opt uint32_t *current_modep,
66 __out_opt uint32_t *default_modep)
69 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_GET_PORT_MODES_IN_LEN,
70 MC_CMD_GET_PORT_MODES_OUT_LEN);
73 EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
74 enp->en_family == EFX_FAMILY_MEDFORD ||
75 enp->en_family == EFX_FAMILY_MEDFORD2);
77 req.emr_cmd = MC_CMD_GET_PORT_MODES;
78 req.emr_in_buf = payload;
79 req.emr_in_length = MC_CMD_GET_PORT_MODES_IN_LEN;
80 req.emr_out_buf = payload;
81 req.emr_out_length = MC_CMD_GET_PORT_MODES_OUT_LEN;
83 efx_mcdi_execute(enp, &req);
85 if (req.emr_rc != 0) {
91 * Require only Modes and DefaultMode fields, unless the current mode
92 * was requested (CurrentMode field was added for Medford).
94 if (req.emr_out_length_used <
95 MC_CMD_GET_PORT_MODES_OUT_CURRENT_MODE_OFST) {
99 if ((current_modep != NULL) && (req.emr_out_length_used <
100 MC_CMD_GET_PORT_MODES_OUT_CURRENT_MODE_OFST + 4)) {
105 *modesp = MCDI_OUT_DWORD(req, GET_PORT_MODES_OUT_MODES);
107 if (current_modep != NULL) {
108 *current_modep = MCDI_OUT_DWORD(req,
109 GET_PORT_MODES_OUT_CURRENT_MODE);
112 if (default_modep != NULL) {
113 *default_modep = MCDI_OUT_DWORD(req,
114 GET_PORT_MODES_OUT_DEFAULT_MODE);
124 EFSYS_PROBE1(fail1, efx_rc_t, rc);
129 __checkReturn efx_rc_t
130 ef10_nic_get_port_mode_bandwidth(
132 __out uint32_t *bandwidth_mbpsp)
135 uint32_t current_mode;
136 efx_port_t *epp = &(enp->en_port);
138 uint32_t single_lane;
144 if ((rc = efx_mcdi_get_port_modes(enp, &port_modes,
145 ¤t_mode, NULL)) != 0) {
146 /* No port mode info available. */
150 if (epp->ep_phy_cap_mask & (1 << EFX_PHY_CAP_25000FDX))
155 if (epp->ep_phy_cap_mask & (1 << EFX_PHY_CAP_50000FDX))
160 if (epp->ep_phy_cap_mask & (1 << EFX_PHY_CAP_100000FDX))
165 switch (current_mode) {
166 case TLV_PORT_MODE_1x1_NA: /* mode 0 */
167 bandwidth = single_lane;
169 case TLV_PORT_MODE_1x2_NA: /* mode 10 */
170 case TLV_PORT_MODE_NA_1x2: /* mode 11 */
171 bandwidth = dual_lane;
173 case TLV_PORT_MODE_1x1_1x1: /* mode 2 */
174 bandwidth = single_lane + single_lane;
176 case TLV_PORT_MODE_4x1_NA: /* mode 4 */
177 case TLV_PORT_MODE_NA_4x1: /* mode 8 */
178 bandwidth = 4 * single_lane;
180 case TLV_PORT_MODE_2x1_2x1: /* mode 5 */
181 bandwidth = (2 * single_lane) + (2 * single_lane);
183 case TLV_PORT_MODE_1x2_1x2: /* mode 12 */
184 bandwidth = dual_lane + dual_lane;
186 case TLV_PORT_MODE_1x2_2x1: /* mode 17 */
187 case TLV_PORT_MODE_2x1_1x2: /* mode 18 */
188 bandwidth = dual_lane + (2 * single_lane);
190 /* Legacy Medford-only mode. Do not use (see bug63270) */
191 case TLV_PORT_MODE_10G_10G_10G_10G_Q1_Q2: /* mode 9 */
192 bandwidth = 4 * single_lane;
194 case TLV_PORT_MODE_1x4_NA: /* mode 1 */
195 case TLV_PORT_MODE_NA_1x4: /* mode 22 */
196 bandwidth = quad_lane;
198 case TLV_PORT_MODE_2x2_NA: /* mode 13 */
199 case TLV_PORT_MODE_NA_2x2: /* mode 14 */
200 bandwidth = 2 * dual_lane;
202 case TLV_PORT_MODE_1x4_2x1: /* mode 6 */
203 case TLV_PORT_MODE_2x1_1x4: /* mode 7 */
204 bandwidth = quad_lane + (2 * single_lane);
206 case TLV_PORT_MODE_1x4_1x2: /* mode 15 */
207 case TLV_PORT_MODE_1x2_1x4: /* mode 16 */
208 bandwidth = quad_lane + dual_lane;
210 case TLV_PORT_MODE_1x4_1x4: /* mode 3 */
211 bandwidth = quad_lane + quad_lane;
218 *bandwidth_mbpsp = bandwidth;
225 EFSYS_PROBE1(fail1, efx_rc_t, rc);
230 static __checkReturn efx_rc_t
231 efx_mcdi_vadaptor_alloc(
233 __in uint32_t port_id)
236 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_VADAPTOR_ALLOC_IN_LEN,
237 MC_CMD_VADAPTOR_ALLOC_OUT_LEN);
240 EFSYS_ASSERT3U(enp->en_vport_id, ==, EVB_PORT_ID_NULL);
242 req.emr_cmd = MC_CMD_VADAPTOR_ALLOC;
243 req.emr_in_buf = payload;
244 req.emr_in_length = MC_CMD_VADAPTOR_ALLOC_IN_LEN;
245 req.emr_out_buf = payload;
246 req.emr_out_length = MC_CMD_VADAPTOR_ALLOC_OUT_LEN;
248 MCDI_IN_SET_DWORD(req, VADAPTOR_ALLOC_IN_UPSTREAM_PORT_ID, port_id);
249 MCDI_IN_POPULATE_DWORD_1(req, VADAPTOR_ALLOC_IN_FLAGS,
250 VADAPTOR_ALLOC_IN_FLAG_PERMIT_SET_MAC_WHEN_FILTERS_INSTALLED,
251 enp->en_nic_cfg.enc_allow_set_mac_with_installed_filters ? 1 : 0);
253 efx_mcdi_execute(enp, &req);
255 if (req.emr_rc != 0) {
263 EFSYS_PROBE1(fail1, efx_rc_t, rc);
268 static __checkReturn efx_rc_t
269 efx_mcdi_vadaptor_free(
271 __in uint32_t port_id)
274 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_VADAPTOR_FREE_IN_LEN,
275 MC_CMD_VADAPTOR_FREE_OUT_LEN);
278 req.emr_cmd = MC_CMD_VADAPTOR_FREE;
279 req.emr_in_buf = payload;
280 req.emr_in_length = MC_CMD_VADAPTOR_FREE_IN_LEN;
281 req.emr_out_buf = payload;
282 req.emr_out_length = MC_CMD_VADAPTOR_FREE_OUT_LEN;
284 MCDI_IN_SET_DWORD(req, VADAPTOR_FREE_IN_UPSTREAM_PORT_ID, port_id);
286 efx_mcdi_execute(enp, &req);
288 if (req.emr_rc != 0) {
296 EFSYS_PROBE1(fail1, efx_rc_t, rc);
301 __checkReturn efx_rc_t
302 efx_mcdi_get_mac_address_pf(
304 __out_ecount_opt(6) uint8_t mac_addrp[6])
307 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_GET_MAC_ADDRESSES_IN_LEN,
308 MC_CMD_GET_MAC_ADDRESSES_OUT_LEN);
311 EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
312 enp->en_family == EFX_FAMILY_MEDFORD ||
313 enp->en_family == EFX_FAMILY_MEDFORD2);
315 req.emr_cmd = MC_CMD_GET_MAC_ADDRESSES;
316 req.emr_in_buf = payload;
317 req.emr_in_length = MC_CMD_GET_MAC_ADDRESSES_IN_LEN;
318 req.emr_out_buf = payload;
319 req.emr_out_length = MC_CMD_GET_MAC_ADDRESSES_OUT_LEN;
321 efx_mcdi_execute(enp, &req);
323 if (req.emr_rc != 0) {
328 if (req.emr_out_length_used < MC_CMD_GET_MAC_ADDRESSES_OUT_LEN) {
333 if (MCDI_OUT_DWORD(req, GET_MAC_ADDRESSES_OUT_MAC_COUNT) < 1) {
338 if (mac_addrp != NULL) {
341 addrp = MCDI_OUT2(req, uint8_t,
342 GET_MAC_ADDRESSES_OUT_MAC_ADDR_BASE);
344 EFX_MAC_ADDR_COPY(mac_addrp, addrp);
354 EFSYS_PROBE1(fail1, efx_rc_t, rc);
359 __checkReturn efx_rc_t
360 efx_mcdi_get_mac_address_vf(
362 __out_ecount_opt(6) uint8_t mac_addrp[6])
365 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_VPORT_GET_MAC_ADDRESSES_IN_LEN,
366 MC_CMD_VPORT_GET_MAC_ADDRESSES_OUT_LENMAX);
369 EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
370 enp->en_family == EFX_FAMILY_MEDFORD ||
371 enp->en_family == EFX_FAMILY_MEDFORD2);
373 req.emr_cmd = MC_CMD_VPORT_GET_MAC_ADDRESSES;
374 req.emr_in_buf = payload;
375 req.emr_in_length = MC_CMD_VPORT_GET_MAC_ADDRESSES_IN_LEN;
376 req.emr_out_buf = payload;
377 req.emr_out_length = MC_CMD_VPORT_GET_MAC_ADDRESSES_OUT_LENMAX;
379 MCDI_IN_SET_DWORD(req, VPORT_GET_MAC_ADDRESSES_IN_VPORT_ID,
380 EVB_PORT_ID_ASSIGNED);
382 efx_mcdi_execute(enp, &req);
384 if (req.emr_rc != 0) {
389 if (req.emr_out_length_used <
390 MC_CMD_VPORT_GET_MAC_ADDRESSES_OUT_LENMIN) {
395 if (MCDI_OUT_DWORD(req,
396 VPORT_GET_MAC_ADDRESSES_OUT_MACADDR_COUNT) < 1) {
401 if (mac_addrp != NULL) {
404 addrp = MCDI_OUT2(req, uint8_t,
405 VPORT_GET_MAC_ADDRESSES_OUT_MACADDR);
407 EFX_MAC_ADDR_COPY(mac_addrp, addrp);
417 EFSYS_PROBE1(fail1, efx_rc_t, rc);
422 __checkReturn efx_rc_t
425 __out uint32_t *sys_freqp,
426 __out uint32_t *dpcpu_freqp)
429 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_GET_CLOCK_IN_LEN,
430 MC_CMD_GET_CLOCK_OUT_LEN);
433 EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
434 enp->en_family == EFX_FAMILY_MEDFORD ||
435 enp->en_family == EFX_FAMILY_MEDFORD2);
437 req.emr_cmd = MC_CMD_GET_CLOCK;
438 req.emr_in_buf = payload;
439 req.emr_in_length = MC_CMD_GET_CLOCK_IN_LEN;
440 req.emr_out_buf = payload;
441 req.emr_out_length = MC_CMD_GET_CLOCK_OUT_LEN;
443 efx_mcdi_execute(enp, &req);
445 if (req.emr_rc != 0) {
450 if (req.emr_out_length_used < MC_CMD_GET_CLOCK_OUT_LEN) {
455 *sys_freqp = MCDI_OUT_DWORD(req, GET_CLOCK_OUT_SYS_FREQ);
456 if (*sys_freqp == 0) {
460 *dpcpu_freqp = MCDI_OUT_DWORD(req, GET_CLOCK_OUT_DPCPU_FREQ);
461 if (*dpcpu_freqp == 0) {
475 EFSYS_PROBE1(fail1, efx_rc_t, rc);
480 __checkReturn efx_rc_t
481 efx_mcdi_get_rxdp_config(
483 __out uint32_t *end_paddingp)
486 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_GET_RXDP_CONFIG_IN_LEN,
487 MC_CMD_GET_RXDP_CONFIG_OUT_LEN);
488 uint32_t end_padding;
491 req.emr_cmd = MC_CMD_GET_RXDP_CONFIG;
492 req.emr_in_buf = payload;
493 req.emr_in_length = MC_CMD_GET_RXDP_CONFIG_IN_LEN;
494 req.emr_out_buf = payload;
495 req.emr_out_length = MC_CMD_GET_RXDP_CONFIG_OUT_LEN;
497 efx_mcdi_execute(enp, &req);
498 if (req.emr_rc != 0) {
503 if (MCDI_OUT_DWORD_FIELD(req, GET_RXDP_CONFIG_OUT_DATA,
504 GET_RXDP_CONFIG_OUT_PAD_HOST_DMA) == 0) {
505 /* RX DMA end padding is disabled */
508 switch (MCDI_OUT_DWORD_FIELD(req, GET_RXDP_CONFIG_OUT_DATA,
509 GET_RXDP_CONFIG_OUT_PAD_HOST_LEN)) {
510 case MC_CMD_SET_RXDP_CONFIG_IN_PAD_HOST_64:
513 case MC_CMD_SET_RXDP_CONFIG_IN_PAD_HOST_128:
516 case MC_CMD_SET_RXDP_CONFIG_IN_PAD_HOST_256:
525 *end_paddingp = end_padding;
532 EFSYS_PROBE1(fail1, efx_rc_t, rc);
537 __checkReturn efx_rc_t
538 efx_mcdi_get_vector_cfg(
540 __out_opt uint32_t *vec_basep,
541 __out_opt uint32_t *pf_nvecp,
542 __out_opt uint32_t *vf_nvecp)
545 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_GET_VECTOR_CFG_IN_LEN,
546 MC_CMD_GET_VECTOR_CFG_OUT_LEN);
549 req.emr_cmd = MC_CMD_GET_VECTOR_CFG;
550 req.emr_in_buf = payload;
551 req.emr_in_length = MC_CMD_GET_VECTOR_CFG_IN_LEN;
552 req.emr_out_buf = payload;
553 req.emr_out_length = MC_CMD_GET_VECTOR_CFG_OUT_LEN;
555 efx_mcdi_execute(enp, &req);
557 if (req.emr_rc != 0) {
562 if (req.emr_out_length_used < MC_CMD_GET_VECTOR_CFG_OUT_LEN) {
567 if (vec_basep != NULL)
568 *vec_basep = MCDI_OUT_DWORD(req, GET_VECTOR_CFG_OUT_VEC_BASE);
569 if (pf_nvecp != NULL)
570 *pf_nvecp = MCDI_OUT_DWORD(req, GET_VECTOR_CFG_OUT_VECS_PER_PF);
571 if (vf_nvecp != NULL)
572 *vf_nvecp = MCDI_OUT_DWORD(req, GET_VECTOR_CFG_OUT_VECS_PER_VF);
579 EFSYS_PROBE1(fail1, efx_rc_t, rc);
584 static __checkReturn efx_rc_t
587 __in uint32_t min_vi_count,
588 __in uint32_t max_vi_count,
589 __out uint32_t *vi_basep,
590 __out uint32_t *vi_countp,
591 __out uint32_t *vi_shiftp)
594 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_ALLOC_VIS_IN_LEN,
595 MC_CMD_ALLOC_VIS_EXT_OUT_LEN);
598 if (vi_countp == NULL) {
603 req.emr_cmd = MC_CMD_ALLOC_VIS;
604 req.emr_in_buf = payload;
605 req.emr_in_length = MC_CMD_ALLOC_VIS_IN_LEN;
606 req.emr_out_buf = payload;
607 req.emr_out_length = MC_CMD_ALLOC_VIS_EXT_OUT_LEN;
609 MCDI_IN_SET_DWORD(req, ALLOC_VIS_IN_MIN_VI_COUNT, min_vi_count);
610 MCDI_IN_SET_DWORD(req, ALLOC_VIS_IN_MAX_VI_COUNT, max_vi_count);
612 efx_mcdi_execute(enp, &req);
614 if (req.emr_rc != 0) {
619 if (req.emr_out_length_used < MC_CMD_ALLOC_VIS_OUT_LEN) {
624 *vi_basep = MCDI_OUT_DWORD(req, ALLOC_VIS_OUT_VI_BASE);
625 *vi_countp = MCDI_OUT_DWORD(req, ALLOC_VIS_OUT_VI_COUNT);
627 /* Report VI_SHIFT if available (always zero for Huntington) */
628 if (req.emr_out_length_used < MC_CMD_ALLOC_VIS_EXT_OUT_LEN)
631 *vi_shiftp = MCDI_OUT_DWORD(req, ALLOC_VIS_EXT_OUT_VI_SHIFT);
640 EFSYS_PROBE1(fail1, efx_rc_t, rc);
646 static __checkReturn efx_rc_t
653 EFX_STATIC_ASSERT(MC_CMD_FREE_VIS_IN_LEN == 0);
654 EFX_STATIC_ASSERT(MC_CMD_FREE_VIS_OUT_LEN == 0);
656 req.emr_cmd = MC_CMD_FREE_VIS;
657 req.emr_in_buf = NULL;
658 req.emr_in_length = 0;
659 req.emr_out_buf = NULL;
660 req.emr_out_length = 0;
662 efx_mcdi_execute_quiet(enp, &req);
664 /* Ignore ELREADY (no allocated VIs, so nothing to free) */
665 if ((req.emr_rc != 0) && (req.emr_rc != EALREADY)) {
673 EFSYS_PROBE1(fail1, efx_rc_t, rc);
679 static __checkReturn efx_rc_t
680 efx_mcdi_alloc_piobuf(
682 __out efx_piobuf_handle_t *handlep)
685 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_ALLOC_PIOBUF_IN_LEN,
686 MC_CMD_ALLOC_PIOBUF_OUT_LEN);
689 if (handlep == NULL) {
694 req.emr_cmd = MC_CMD_ALLOC_PIOBUF;
695 req.emr_in_buf = payload;
696 req.emr_in_length = MC_CMD_ALLOC_PIOBUF_IN_LEN;
697 req.emr_out_buf = payload;
698 req.emr_out_length = MC_CMD_ALLOC_PIOBUF_OUT_LEN;
700 efx_mcdi_execute_quiet(enp, &req);
702 if (req.emr_rc != 0) {
707 if (req.emr_out_length_used < MC_CMD_ALLOC_PIOBUF_OUT_LEN) {
712 *handlep = MCDI_OUT_DWORD(req, ALLOC_PIOBUF_OUT_PIOBUF_HANDLE);
721 EFSYS_PROBE1(fail1, efx_rc_t, rc);
726 static __checkReturn efx_rc_t
727 efx_mcdi_free_piobuf(
729 __in efx_piobuf_handle_t handle)
732 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_FREE_PIOBUF_IN_LEN,
733 MC_CMD_FREE_PIOBUF_OUT_LEN);
736 req.emr_cmd = MC_CMD_FREE_PIOBUF;
737 req.emr_in_buf = payload;
738 req.emr_in_length = MC_CMD_FREE_PIOBUF_IN_LEN;
739 req.emr_out_buf = payload;
740 req.emr_out_length = MC_CMD_FREE_PIOBUF_OUT_LEN;
742 MCDI_IN_SET_DWORD(req, FREE_PIOBUF_IN_PIOBUF_HANDLE, handle);
744 efx_mcdi_execute_quiet(enp, &req);
746 if (req.emr_rc != 0) {
754 EFSYS_PROBE1(fail1, efx_rc_t, rc);
759 static __checkReturn efx_rc_t
760 efx_mcdi_link_piobuf(
762 __in uint32_t vi_index,
763 __in efx_piobuf_handle_t handle)
766 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_LINK_PIOBUF_IN_LEN,
767 MC_CMD_LINK_PIOBUF_OUT_LEN);
770 req.emr_cmd = MC_CMD_LINK_PIOBUF;
771 req.emr_in_buf = payload;
772 req.emr_in_length = MC_CMD_LINK_PIOBUF_IN_LEN;
773 req.emr_out_buf = payload;
774 req.emr_out_length = MC_CMD_LINK_PIOBUF_OUT_LEN;
776 MCDI_IN_SET_DWORD(req, LINK_PIOBUF_IN_PIOBUF_HANDLE, handle);
777 MCDI_IN_SET_DWORD(req, LINK_PIOBUF_IN_TXQ_INSTANCE, vi_index);
779 efx_mcdi_execute(enp, &req);
781 if (req.emr_rc != 0) {
789 EFSYS_PROBE1(fail1, efx_rc_t, rc);
794 static __checkReturn efx_rc_t
795 efx_mcdi_unlink_piobuf(
797 __in uint32_t vi_index)
800 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_UNLINK_PIOBUF_IN_LEN,
801 MC_CMD_UNLINK_PIOBUF_OUT_LEN);
804 req.emr_cmd = MC_CMD_UNLINK_PIOBUF;
805 req.emr_in_buf = payload;
806 req.emr_in_length = MC_CMD_UNLINK_PIOBUF_IN_LEN;
807 req.emr_out_buf = payload;
808 req.emr_out_length = MC_CMD_UNLINK_PIOBUF_OUT_LEN;
810 MCDI_IN_SET_DWORD(req, UNLINK_PIOBUF_IN_TXQ_INSTANCE, vi_index);
812 efx_mcdi_execute_quiet(enp, &req);
814 if (req.emr_rc != 0) {
822 EFSYS_PROBE1(fail1, efx_rc_t, rc);
828 ef10_nic_alloc_piobufs(
830 __in uint32_t max_piobuf_count)
832 efx_piobuf_handle_t *handlep;
835 EFSYS_ASSERT3U(max_piobuf_count, <=,
836 EFX_ARRAY_SIZE(enp->en_arch.ef10.ena_piobuf_handle));
838 enp->en_arch.ef10.ena_piobuf_count = 0;
840 for (i = 0; i < max_piobuf_count; i++) {
841 handlep = &enp->en_arch.ef10.ena_piobuf_handle[i];
843 if (efx_mcdi_alloc_piobuf(enp, handlep) != 0)
846 enp->en_arch.ef10.ena_pio_alloc_map[i] = 0;
847 enp->en_arch.ef10.ena_piobuf_count++;
853 for (i = 0; i < enp->en_arch.ef10.ena_piobuf_count; i++) {
854 handlep = &enp->en_arch.ef10.ena_piobuf_handle[i];
856 (void) efx_mcdi_free_piobuf(enp, *handlep);
857 *handlep = EFX_PIOBUF_HANDLE_INVALID;
859 enp->en_arch.ef10.ena_piobuf_count = 0;
864 ef10_nic_free_piobufs(
867 efx_piobuf_handle_t *handlep;
870 for (i = 0; i < enp->en_arch.ef10.ena_piobuf_count; i++) {
871 handlep = &enp->en_arch.ef10.ena_piobuf_handle[i];
873 (void) efx_mcdi_free_piobuf(enp, *handlep);
874 *handlep = EFX_PIOBUF_HANDLE_INVALID;
876 enp->en_arch.ef10.ena_piobuf_count = 0;
879 /* Sub-allocate a block from a piobuf */
880 __checkReturn efx_rc_t
882 __inout efx_nic_t *enp,
883 __out uint32_t *bufnump,
884 __out efx_piobuf_handle_t *handlep,
885 __out uint32_t *blknump,
886 __out uint32_t *offsetp,
889 efx_nic_cfg_t *encp = &enp->en_nic_cfg;
890 efx_drv_cfg_t *edcp = &enp->en_drv_cfg;
891 uint32_t blk_per_buf;
895 EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
896 enp->en_family == EFX_FAMILY_MEDFORD ||
897 enp->en_family == EFX_FAMILY_MEDFORD2);
898 EFSYS_ASSERT(bufnump);
899 EFSYS_ASSERT(handlep);
900 EFSYS_ASSERT(blknump);
901 EFSYS_ASSERT(offsetp);
904 if ((edcp->edc_pio_alloc_size == 0) ||
905 (enp->en_arch.ef10.ena_piobuf_count == 0)) {
909 blk_per_buf = encp->enc_piobuf_size / edcp->edc_pio_alloc_size;
911 for (buf = 0; buf < enp->en_arch.ef10.ena_piobuf_count; buf++) {
912 uint32_t *map = &enp->en_arch.ef10.ena_pio_alloc_map[buf];
917 EFSYS_ASSERT3U(blk_per_buf, <=, (8 * sizeof (*map)));
918 for (blk = 0; blk < blk_per_buf; blk++) {
919 if ((*map & (1u << blk)) == 0) {
929 *handlep = enp->en_arch.ef10.ena_piobuf_handle[buf];
932 *sizep = edcp->edc_pio_alloc_size;
933 *offsetp = blk * (*sizep);
940 EFSYS_PROBE1(fail1, efx_rc_t, rc);
945 /* Free a piobuf sub-allocated block */
946 __checkReturn efx_rc_t
948 __inout efx_nic_t *enp,
949 __in uint32_t bufnum,
950 __in uint32_t blknum)
955 if ((bufnum >= enp->en_arch.ef10.ena_piobuf_count) ||
956 (blknum >= (8 * sizeof (*map)))) {
961 map = &enp->en_arch.ef10.ena_pio_alloc_map[bufnum];
962 if ((*map & (1u << blknum)) == 0) {
966 *map &= ~(1u << blknum);
973 EFSYS_PROBE1(fail1, efx_rc_t, rc);
978 __checkReturn efx_rc_t
980 __inout efx_nic_t *enp,
981 __in uint32_t vi_index,
982 __in efx_piobuf_handle_t handle)
984 return (efx_mcdi_link_piobuf(enp, vi_index, handle));
987 __checkReturn efx_rc_t
989 __inout efx_nic_t *enp,
990 __in uint32_t vi_index)
992 return (efx_mcdi_unlink_piobuf(enp, vi_index));
995 static __checkReturn efx_rc_t
996 ef10_mcdi_get_pf_count(
998 __out uint32_t *pf_countp)
1001 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_GET_PF_COUNT_IN_LEN,
1002 MC_CMD_GET_PF_COUNT_OUT_LEN);
1005 req.emr_cmd = MC_CMD_GET_PF_COUNT;
1006 req.emr_in_buf = payload;
1007 req.emr_in_length = MC_CMD_GET_PF_COUNT_IN_LEN;
1008 req.emr_out_buf = payload;
1009 req.emr_out_length = MC_CMD_GET_PF_COUNT_OUT_LEN;
1011 efx_mcdi_execute(enp, &req);
1013 if (req.emr_rc != 0) {
1018 if (req.emr_out_length_used < MC_CMD_GET_PF_COUNT_OUT_LEN) {
1023 *pf_countp = *MCDI_OUT(req, uint8_t,
1024 MC_CMD_GET_PF_COUNT_OUT_PF_COUNT_OFST);
1026 EFSYS_ASSERT(*pf_countp != 0);
1033 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1038 static __checkReturn efx_rc_t
1039 ef10_get_datapath_caps(
1040 __in efx_nic_t *enp)
1042 efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
1044 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_GET_CAPABILITIES_IN_LEN,
1045 MC_CMD_GET_CAPABILITIES_V5_OUT_LEN);
1048 if ((rc = ef10_mcdi_get_pf_count(enp, &encp->enc_hw_pf_count)) != 0)
1052 req.emr_cmd = MC_CMD_GET_CAPABILITIES;
1053 req.emr_in_buf = payload;
1054 req.emr_in_length = MC_CMD_GET_CAPABILITIES_IN_LEN;
1055 req.emr_out_buf = payload;
1056 req.emr_out_length = MC_CMD_GET_CAPABILITIES_V5_OUT_LEN;
1058 efx_mcdi_execute_quiet(enp, &req);
1060 if (req.emr_rc != 0) {
1065 if (req.emr_out_length_used < MC_CMD_GET_CAPABILITIES_OUT_LEN) {
1070 #define CAP_FLAGS1(_req, _flag) \
1071 (MCDI_OUT_DWORD((_req), GET_CAPABILITIES_OUT_FLAGS1) & \
1072 (1u << (MC_CMD_GET_CAPABILITIES_V2_OUT_ ## _flag ## _LBN)))
1074 #define CAP_FLAGS2(_req, _flag) \
1075 (((_req).emr_out_length_used >= MC_CMD_GET_CAPABILITIES_V2_OUT_LEN) && \
1076 (MCDI_OUT_DWORD((_req), GET_CAPABILITIES_V2_OUT_FLAGS2) & \
1077 (1u << (MC_CMD_GET_CAPABILITIES_V2_OUT_ ## _flag ## _LBN))))
1080 * Huntington RXDP firmware inserts a 0 or 14 byte prefix.
1081 * We only support the 14 byte prefix here.
1083 if (CAP_FLAGS1(req, RX_PREFIX_LEN_14) == 0) {
1087 encp->enc_rx_prefix_size = 14;
1089 #if EFSYS_OPT_RX_SCALE
1090 /* Check if the firmware supports additional RSS modes */
1091 if (CAP_FLAGS1(req, ADDITIONAL_RSS_MODES))
1092 encp->enc_rx_scale_additional_modes_supported = B_TRUE;
1094 encp->enc_rx_scale_additional_modes_supported = B_FALSE;
1095 #endif /* EFSYS_OPT_RX_SCALE */
1097 /* Check if the firmware supports TSO */
1098 if (CAP_FLAGS1(req, TX_TSO))
1099 encp->enc_fw_assisted_tso_enabled = B_TRUE;
1101 encp->enc_fw_assisted_tso_enabled = B_FALSE;
1103 /* Check if the firmware supports FATSOv2 */
1104 if (CAP_FLAGS2(req, TX_TSO_V2)) {
1105 encp->enc_fw_assisted_tso_v2_enabled = B_TRUE;
1106 encp->enc_fw_assisted_tso_v2_n_contexts = MCDI_OUT_WORD(req,
1107 GET_CAPABILITIES_V2_OUT_TX_TSO_V2_N_CONTEXTS);
1109 encp->enc_fw_assisted_tso_v2_enabled = B_FALSE;
1110 encp->enc_fw_assisted_tso_v2_n_contexts = 0;
1113 /* Check if the firmware supports FATSOv2 encap */
1114 if (CAP_FLAGS2(req, TX_TSO_V2_ENCAP))
1115 encp->enc_fw_assisted_tso_v2_encap_enabled = B_TRUE;
1117 encp->enc_fw_assisted_tso_v2_encap_enabled = B_FALSE;
1119 /* Check if the firmware has vadapter/vport/vswitch support */
1120 if (CAP_FLAGS1(req, EVB))
1121 encp->enc_datapath_cap_evb = B_TRUE;
1123 encp->enc_datapath_cap_evb = B_FALSE;
1125 /* Check if the firmware supports VLAN insertion */
1126 if (CAP_FLAGS1(req, TX_VLAN_INSERTION))
1127 encp->enc_hw_tx_insert_vlan_enabled = B_TRUE;
1129 encp->enc_hw_tx_insert_vlan_enabled = B_FALSE;
1131 /* Check if the firmware supports RX event batching */
1132 if (CAP_FLAGS1(req, RX_BATCHING))
1133 encp->enc_rx_batching_enabled = B_TRUE;
1135 encp->enc_rx_batching_enabled = B_FALSE;
1138 * Even if batching isn't reported as supported, we may still get
1139 * batched events (see bug61153).
1141 encp->enc_rx_batch_max = 16;
1143 /* Check if the firmware supports disabling scatter on RXQs */
1144 if (CAP_FLAGS1(req, RX_DISABLE_SCATTER))
1145 encp->enc_rx_disable_scatter_supported = B_TRUE;
1147 encp->enc_rx_disable_scatter_supported = B_FALSE;
1149 /* Check if the firmware supports packed stream mode */
1150 if (CAP_FLAGS1(req, RX_PACKED_STREAM))
1151 encp->enc_rx_packed_stream_supported = B_TRUE;
1153 encp->enc_rx_packed_stream_supported = B_FALSE;
1156 * Check if the firmware supports configurable buffer sizes
1157 * for packed stream mode (otherwise buffer size is 1Mbyte)
1159 if (CAP_FLAGS1(req, RX_PACKED_STREAM_VAR_BUFFERS))
1160 encp->enc_rx_var_packed_stream_supported = B_TRUE;
1162 encp->enc_rx_var_packed_stream_supported = B_FALSE;
1164 /* Check if the firmware supports equal stride super-buffer mode */
1165 if (CAP_FLAGS2(req, EQUAL_STRIDE_SUPER_BUFFER))
1166 encp->enc_rx_es_super_buffer_supported = B_TRUE;
1168 encp->enc_rx_es_super_buffer_supported = B_FALSE;
1170 /* Check if the firmware supports FW subvariant w/o Tx checksumming */
1171 if (CAP_FLAGS2(req, FW_SUBVARIANT_NO_TX_CSUM))
1172 encp->enc_fw_subvariant_no_tx_csum_supported = B_TRUE;
1174 encp->enc_fw_subvariant_no_tx_csum_supported = B_FALSE;
1176 /* Check if the firmware supports set mac with running filters */
1177 if (CAP_FLAGS1(req, VADAPTOR_PERMIT_SET_MAC_WHEN_FILTERS_INSTALLED))
1178 encp->enc_allow_set_mac_with_installed_filters = B_TRUE;
1180 encp->enc_allow_set_mac_with_installed_filters = B_FALSE;
1183 * Check if firmware supports the extended MC_CMD_SET_MAC, which allows
1184 * specifying which parameters to configure.
1186 if (CAP_FLAGS1(req, SET_MAC_ENHANCED))
1187 encp->enc_enhanced_set_mac_supported = B_TRUE;
1189 encp->enc_enhanced_set_mac_supported = B_FALSE;
1192 * Check if firmware supports version 2 of MC_CMD_INIT_EVQ, which allows
1193 * us to let the firmware choose the settings to use on an EVQ.
1195 if (CAP_FLAGS2(req, INIT_EVQ_V2))
1196 encp->enc_init_evq_v2_supported = B_TRUE;
1198 encp->enc_init_evq_v2_supported = B_FALSE;
1201 * Check if the NO_CONT_EV mode for RX events is supported.
1203 if (CAP_FLAGS2(req, INIT_RXQ_NO_CONT_EV))
1204 encp->enc_no_cont_ev_mode_supported = B_TRUE;
1206 encp->enc_no_cont_ev_mode_supported = B_FALSE;
1209 * Check if firmware-verified NVRAM updates must be used.
1211 * The firmware trusted installer requires all NVRAM updates to use
1212 * version 2 of MC_CMD_NVRAM_UPDATE_START (to enable verified update)
1213 * and version 2 of MC_CMD_NVRAM_UPDATE_FINISH (to verify the updated
1214 * partition and report the result).
1216 if (CAP_FLAGS2(req, NVRAM_UPDATE_REPORT_VERIFY_RESULT))
1217 encp->enc_nvram_update_verify_result_supported = B_TRUE;
1219 encp->enc_nvram_update_verify_result_supported = B_FALSE;
1222 * Check if firmware provides packet memory and Rx datapath
1225 if (CAP_FLAGS1(req, PM_AND_RXDP_COUNTERS))
1226 encp->enc_pm_and_rxdp_counters = B_TRUE;
1228 encp->enc_pm_and_rxdp_counters = B_FALSE;
1231 * Check if the 40G MAC hardware is capable of reporting
1232 * statistics for Tx size bins.
1234 if (CAP_FLAGS2(req, MAC_STATS_40G_TX_SIZE_BINS))
1235 encp->enc_mac_stats_40g_tx_size_bins = B_TRUE;
1237 encp->enc_mac_stats_40g_tx_size_bins = B_FALSE;
1240 * Check if firmware supports VXLAN and NVGRE tunnels.
1241 * The capability indicates Geneve protocol support as well.
1243 if (CAP_FLAGS1(req, VXLAN_NVGRE)) {
1244 encp->enc_tunnel_encapsulations_supported =
1245 (1u << EFX_TUNNEL_PROTOCOL_VXLAN) |
1246 (1u << EFX_TUNNEL_PROTOCOL_GENEVE) |
1247 (1u << EFX_TUNNEL_PROTOCOL_NVGRE);
1249 EFX_STATIC_ASSERT(EFX_TUNNEL_MAXNENTRIES ==
1250 MC_CMD_SET_TUNNEL_ENCAP_UDP_PORTS_IN_ENTRIES_MAXNUM);
1251 encp->enc_tunnel_config_udp_entries_max =
1252 EFX_TUNNEL_MAXNENTRIES;
1254 encp->enc_tunnel_config_udp_entries_max = 0;
1258 * Check if firmware reports the VI window mode.
1259 * Medford2 has a variable VI window size (8K, 16K or 64K).
1260 * Medford and Huntington have a fixed 8K VI window size.
1262 if (req.emr_out_length_used >= MC_CMD_GET_CAPABILITIES_V3_OUT_LEN) {
1264 MCDI_OUT_BYTE(req, GET_CAPABILITIES_V3_OUT_VI_WINDOW_MODE);
1267 case MC_CMD_GET_CAPABILITIES_V3_OUT_VI_WINDOW_MODE_8K:
1268 encp->enc_vi_window_shift = EFX_VI_WINDOW_SHIFT_8K;
1270 case MC_CMD_GET_CAPABILITIES_V3_OUT_VI_WINDOW_MODE_16K:
1271 encp->enc_vi_window_shift = EFX_VI_WINDOW_SHIFT_16K;
1273 case MC_CMD_GET_CAPABILITIES_V3_OUT_VI_WINDOW_MODE_64K:
1274 encp->enc_vi_window_shift = EFX_VI_WINDOW_SHIFT_64K;
1277 encp->enc_vi_window_shift = EFX_VI_WINDOW_SHIFT_INVALID;
1280 } else if ((enp->en_family == EFX_FAMILY_HUNTINGTON) ||
1281 (enp->en_family == EFX_FAMILY_MEDFORD)) {
1282 /* Huntington and Medford have fixed 8K window size */
1283 encp->enc_vi_window_shift = EFX_VI_WINDOW_SHIFT_8K;
1285 encp->enc_vi_window_shift = EFX_VI_WINDOW_SHIFT_INVALID;
1288 /* Check if firmware supports extended MAC stats. */
1289 if (req.emr_out_length_used >= MC_CMD_GET_CAPABILITIES_V4_OUT_LEN) {
1290 /* Extended stats buffer supported */
1291 encp->enc_mac_stats_nstats = MCDI_OUT_WORD(req,
1292 GET_CAPABILITIES_V4_OUT_MAC_STATS_NUM_STATS);
1294 /* Use Siena-compatible legacy MAC stats */
1295 encp->enc_mac_stats_nstats = MC_CMD_MAC_NSTATS;
1298 if (encp->enc_mac_stats_nstats >= MC_CMD_MAC_NSTATS_V2)
1299 encp->enc_fec_counters = B_TRUE;
1301 encp->enc_fec_counters = B_FALSE;
1303 /* Check if the firmware provides head-of-line blocking counters */
1304 if (CAP_FLAGS2(req, RXDP_HLB_IDLE))
1305 encp->enc_hlb_counters = B_TRUE;
1307 encp->enc_hlb_counters = B_FALSE;
1309 #if EFSYS_OPT_RX_SCALE
1310 if (CAP_FLAGS1(req, RX_RSS_LIMITED)) {
1311 /* Only one exclusive RSS context is available per port. */
1312 encp->enc_rx_scale_max_exclusive_contexts = 1;
1314 switch (enp->en_family) {
1315 case EFX_FAMILY_MEDFORD2:
1316 encp->enc_rx_scale_hash_alg_mask =
1317 (1U << EFX_RX_HASHALG_TOEPLITZ);
1320 case EFX_FAMILY_MEDFORD:
1321 case EFX_FAMILY_HUNTINGTON:
1323 * Packed stream firmware variant maintains a
1324 * non-standard algorithm for hash computation.
1325 * It implies explicit XORing together
1326 * source + destination IP addresses (or last
1327 * four bytes in the case of IPv6) and using the
1328 * resulting value as the input to a Toeplitz hash.
1330 encp->enc_rx_scale_hash_alg_mask =
1331 (1U << EFX_RX_HASHALG_PACKED_STREAM);
1339 /* Port numbers cannot contribute to the hash value */
1340 encp->enc_rx_scale_l4_hash_supported = B_FALSE;
1343 * Maximum number of exclusive RSS contexts.
1344 * EF10 hardware supports 64 in total, but 6 are reserved
1345 * for shared contexts. They are a global resource so
1346 * not all may be available.
1348 encp->enc_rx_scale_max_exclusive_contexts = 64 - 6;
1350 encp->enc_rx_scale_hash_alg_mask =
1351 (1U << EFX_RX_HASHALG_TOEPLITZ);
1354 * It is possible to use port numbers as
1355 * the input data for hash computation.
1357 encp->enc_rx_scale_l4_hash_supported = B_TRUE;
1359 #endif /* EFSYS_OPT_RX_SCALE */
1361 /* Check if the firmware supports "FLAG" and "MARK" filter actions */
1362 if (CAP_FLAGS2(req, FILTER_ACTION_FLAG))
1363 encp->enc_filter_action_flag_supported = B_TRUE;
1365 encp->enc_filter_action_flag_supported = B_FALSE;
1367 if (CAP_FLAGS2(req, FILTER_ACTION_MARK))
1368 encp->enc_filter_action_mark_supported = B_TRUE;
1370 encp->enc_filter_action_mark_supported = B_FALSE;
1372 /* Get maximum supported value for "MARK" filter action */
1373 if (req.emr_out_length_used >= MC_CMD_GET_CAPABILITIES_V5_OUT_LEN)
1374 encp->enc_filter_action_mark_max = MCDI_OUT_DWORD(req,
1375 GET_CAPABILITIES_V5_OUT_FILTER_ACTION_MARK_MAX);
1377 encp->enc_filter_action_mark_max = 0;
1384 #if EFSYS_OPT_RX_SCALE
1387 #endif /* EFSYS_OPT_RX_SCALE */
1395 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1401 #define EF10_LEGACY_PF_PRIVILEGE_MASK \
1402 (MC_CMD_PRIVILEGE_MASK_IN_GRP_ADMIN | \
1403 MC_CMD_PRIVILEGE_MASK_IN_GRP_LINK | \
1404 MC_CMD_PRIVILEGE_MASK_IN_GRP_ONLOAD | \
1405 MC_CMD_PRIVILEGE_MASK_IN_GRP_PTP | \
1406 MC_CMD_PRIVILEGE_MASK_IN_GRP_INSECURE_FILTERS | \
1407 MC_CMD_PRIVILEGE_MASK_IN_GRP_MAC_SPOOFING | \
1408 MC_CMD_PRIVILEGE_MASK_IN_GRP_UNICAST | \
1409 MC_CMD_PRIVILEGE_MASK_IN_GRP_MULTICAST | \
1410 MC_CMD_PRIVILEGE_MASK_IN_GRP_BROADCAST | \
1411 MC_CMD_PRIVILEGE_MASK_IN_GRP_ALL_MULTICAST | \
1412 MC_CMD_PRIVILEGE_MASK_IN_GRP_PROMISCUOUS)
1414 #define EF10_LEGACY_VF_PRIVILEGE_MASK 0
1417 __checkReturn efx_rc_t
1418 ef10_get_privilege_mask(
1419 __in efx_nic_t *enp,
1420 __out uint32_t *maskp)
1422 efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
1426 if ((rc = efx_mcdi_privilege_mask(enp, encp->enc_pf, encp->enc_vf,
1431 /* Fallback for old firmware without privilege mask support */
1432 if (EFX_PCI_FUNCTION_IS_PF(encp)) {
1433 /* Assume PF has admin privilege */
1434 mask = EF10_LEGACY_PF_PRIVILEGE_MASK;
1436 /* VF is always unprivileged by default */
1437 mask = EF10_LEGACY_VF_PRIVILEGE_MASK;
1446 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1452 #define EFX_EXT_PORT_MAX 4
1453 #define EFX_EXT_PORT_NA 0xFF
1456 * Table of mapping schemes from port number to external number.
1458 * Each port number ultimately corresponds to a connector: either as part of
1459 * a cable assembly attached to a module inserted in an SFP+/QSFP+ cage on
1460 * the board, or fixed to the board (e.g. 10GBASE-T magjack on SFN5121T
1461 * "Salina"). In general:
1463 * Port number (0-based)
1465 * port mapping (n:1)
1468 * External port number (1-based)
1470 * fixed (1:1) or cable assembly (1:m)
1475 * The external numbering refers to the cages or magjacks on the board,
1476 * as visibly annotated on the board or back panel. This table describes
1477 * how to determine which external cage/magjack corresponds to the port
1478 * numbers used by the driver.
1480 * The count of consecutive port numbers that map to each external number,
1481 * is determined by the chip family and the current port mode.
1483 * For the Huntington family, the current port mode cannot be discovered,
1484 * but a single mapping is used by all modes for a given chip variant,
1485 * so the mapping used is instead the last match in the table to the full
1486 * set of port modes to which the NIC can be configured. Therefore the
1487 * ordering of entries in the mapping table is significant.
1489 static struct ef10_external_port_map_s {
1490 efx_family_t family;
1491 uint32_t modes_mask;
1492 uint8_t base_port[EFX_EXT_PORT_MAX];
1493 } __ef10_external_port_mappings[] = {
1495 * Modes used by Huntington family controllers where each port
1496 * number maps to a separate cage.
1497 * SFN7x22F (Torino):
1507 EFX_FAMILY_HUNTINGTON,
1508 (1U << TLV_PORT_MODE_10G) | /* mode 0 */
1509 (1U << TLV_PORT_MODE_10G_10G) | /* mode 2 */
1510 (1U << TLV_PORT_MODE_10G_10G_10G_10G), /* mode 4 */
1514 * Modes which for Huntington identify a chip variant where 2
1515 * adjacent port numbers map to each cage.
1523 EFX_FAMILY_HUNTINGTON,
1524 (1U << TLV_PORT_MODE_40G) | /* mode 1 */
1525 (1U << TLV_PORT_MODE_40G_40G) | /* mode 3 */
1526 (1U << TLV_PORT_MODE_40G_10G_10G) | /* mode 6 */
1527 (1U << TLV_PORT_MODE_10G_10G_40G), /* mode 7 */
1528 { 0, 2, EFX_EXT_PORT_NA, EFX_EXT_PORT_NA }
1531 * Modes that on Medford allocate each port number to a separate
1540 (1U << TLV_PORT_MODE_1x1_NA) | /* mode 0 */
1541 (1U << TLV_PORT_MODE_1x4_NA) | /* mode 1 */
1542 (1U << TLV_PORT_MODE_1x1_1x1), /* mode 2 */
1546 * Modes that on Medford allocate 2 adjacent port numbers to each
1555 (1U << TLV_PORT_MODE_1x4_1x4) | /* mode 3 */
1556 (1U << TLV_PORT_MODE_2x1_2x1) | /* mode 5 */
1557 (1U << TLV_PORT_MODE_1x4_2x1) | /* mode 6 */
1558 (1U << TLV_PORT_MODE_2x1_1x4) | /* mode 7 */
1559 /* Do not use 10G_10G_10G_10G_Q1_Q2 (see bug63270) */
1560 (1U << TLV_PORT_MODE_10G_10G_10G_10G_Q1_Q2), /* mode 9 */
1561 { 0, 2, EFX_EXT_PORT_NA, EFX_EXT_PORT_NA }
1564 * Modes that on Medford allocate 4 adjacent port numbers to
1573 /* Do not use 10G_10G_10G_10G_Q1 (see bug63270) */
1574 (1U << TLV_PORT_MODE_4x1_NA), /* mode 4 */
1575 { 0, EFX_EXT_PORT_NA, EFX_EXT_PORT_NA, EFX_EXT_PORT_NA }
1578 * Modes that on Medford allocate 4 adjacent port numbers to
1587 (1U << TLV_PORT_MODE_NA_4x1), /* mode 8 */
1588 { EFX_EXT_PORT_NA, 0, EFX_EXT_PORT_NA, EFX_EXT_PORT_NA }
1591 * Modes that on Medford2 allocate each port number to a separate
1599 EFX_FAMILY_MEDFORD2,
1600 (1U << TLV_PORT_MODE_1x1_NA) | /* mode 0 */
1601 (1U << TLV_PORT_MODE_1x4_NA) | /* mode 1 */
1602 (1U << TLV_PORT_MODE_1x1_1x1) | /* mode 2 */
1603 (1U << TLV_PORT_MODE_1x4_1x4) | /* mode 3 */
1604 (1U << TLV_PORT_MODE_1x2_NA) | /* mode 10 */
1605 (1U << TLV_PORT_MODE_1x2_1x2) | /* mode 12 */
1606 (1U << TLV_PORT_MODE_1x4_1x2) | /* mode 15 */
1607 (1U << TLV_PORT_MODE_1x2_1x4), /* mode 16 */
1611 * Modes that on Medford2 allocate 1 port to cage 1 and the rest
1618 EFX_FAMILY_MEDFORD2,
1619 (1U << TLV_PORT_MODE_1x2_2x1) | /* mode 17 */
1620 (1U << TLV_PORT_MODE_1x4_2x1), /* mode 6 */
1621 { 0, 1, EFX_EXT_PORT_NA, EFX_EXT_PORT_NA }
1624 * Modes that on Medford2 allocate 2 adjacent port numbers to cage 1
1625 * and the rest to cage 2.
1632 EFX_FAMILY_MEDFORD2,
1633 (1U << TLV_PORT_MODE_2x1_2x1) | /* mode 4 */
1634 (1U << TLV_PORT_MODE_2x1_1x4) | /* mode 7 */
1635 (1U << TLV_PORT_MODE_2x2_NA) | /* mode 13 */
1636 (1U << TLV_PORT_MODE_2x1_1x2), /* mode 18 */
1637 { 0, 2, EFX_EXT_PORT_NA, EFX_EXT_PORT_NA }
1640 * Modes that on Medford2 allocate up to 4 adjacent port numbers
1648 EFX_FAMILY_MEDFORD2,
1649 (1U << TLV_PORT_MODE_4x1_NA), /* mode 5 */
1650 { 0, EFX_EXT_PORT_NA, EFX_EXT_PORT_NA, EFX_EXT_PORT_NA }
1653 * Modes that on Medford2 allocate up to 4 adjacent port numbers
1661 EFX_FAMILY_MEDFORD2,
1662 (1U << TLV_PORT_MODE_NA_4x1) | /* mode 8 */
1663 (1U << TLV_PORT_MODE_NA_1x2) | /* mode 11 */
1664 (1U << TLV_PORT_MODE_NA_2x2), /* mode 14 */
1665 { EFX_EXT_PORT_NA, 0, EFX_EXT_PORT_NA, EFX_EXT_PORT_NA }
1669 static __checkReturn efx_rc_t
1670 ef10_external_port_mapping(
1671 __in efx_nic_t *enp,
1673 __out uint8_t *external_portp)
1677 uint32_t port_modes;
1680 struct ef10_external_port_map_s *mapp = NULL;
1681 int ext_index = port; /* Default 1-1 mapping */
1683 if ((rc = efx_mcdi_get_port_modes(enp, &port_modes, ¤t,
1686 * No current port mode information (i.e. Huntington)
1687 * - infer mapping from available modes
1689 if ((rc = efx_mcdi_get_port_modes(enp,
1690 &port_modes, NULL, NULL)) != 0) {
1692 * No port mode information available
1693 * - use default mapping
1698 /* Only need to scan the current mode */
1699 port_modes = 1 << current;
1703 * Infer the internal port -> external number mapping from
1704 * the possible port modes for this NIC.
1706 for (i = 0; i < EFX_ARRAY_SIZE(__ef10_external_port_mappings); ++i) {
1707 struct ef10_external_port_map_s *eepmp =
1708 &__ef10_external_port_mappings[i];
1709 if (eepmp->family != enp->en_family)
1711 matches = (eepmp->modes_mask & port_modes);
1714 * Some modes match. For some Huntington boards
1715 * there will be multiple matches. The mapping on the
1716 * last match is used.
1719 port_modes &= ~matches;
1723 if (port_modes != 0) {
1724 /* Some advertised modes are not supported */
1732 * External ports are assigned a sequence of consecutive
1733 * port numbers, so find the one with the closest base_port.
1735 uint32_t delta = EFX_EXT_PORT_NA;
1737 for (i = 0; i < EFX_EXT_PORT_MAX; i++) {
1738 uint32_t base = mapp->base_port[i];
1739 if ((base != EFX_EXT_PORT_NA) && (base <= port)) {
1740 if ((port - base) < delta) {
1741 delta = (port - base);
1747 *external_portp = (uint8_t)(ext_index + 1);
1752 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1757 static __checkReturn efx_rc_t
1759 __in efx_nic_t *enp)
1761 const efx_nic_ops_t *enop = enp->en_enop;
1762 efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
1763 efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
1764 ef10_link_state_t els;
1765 efx_port_t *epp = &(enp->en_port);
1766 uint32_t board_type = 0;
1767 uint32_t base, nvec;
1772 uint8_t mac_addr[6] = { 0 };
1775 /* Get the (zero-based) MCDI port number */
1776 if ((rc = efx_mcdi_get_port_assignment(enp, &port)) != 0)
1779 /* EFX MCDI interface uses one-based port numbers */
1780 emip->emi_port = port + 1;
1782 if ((rc = ef10_external_port_mapping(enp, port,
1783 &encp->enc_external_port)) != 0)
1787 * Get PCIe function number from firmware (used for
1788 * per-function privilege and dynamic config info).
1789 * - PCIe PF: pf = PF number, vf = 0xffff.
1790 * - PCIe VF: pf = parent PF, vf = VF number.
1792 if ((rc = efx_mcdi_get_function_info(enp, &pf, &vf)) != 0)
1798 /* MAC address for this function */
1799 if (EFX_PCI_FUNCTION_IS_PF(encp)) {
1800 rc = efx_mcdi_get_mac_address_pf(enp, mac_addr);
1801 #if EFSYS_OPT_ALLOW_UNCONFIGURED_NIC
1803 * Disable static config checking, ONLY for manufacturing test
1804 * and setup at the factory, to allow the static config to be
1807 #else /* EFSYS_OPT_ALLOW_UNCONFIGURED_NIC */
1808 if ((rc == 0) && (mac_addr[0] & 0x02)) {
1810 * If the static config does not include a global MAC
1811 * address pool then the board may return a locally
1812 * administered MAC address (this should only happen on
1813 * incorrectly programmed boards).
1817 #endif /* EFSYS_OPT_ALLOW_UNCONFIGURED_NIC */
1819 rc = efx_mcdi_get_mac_address_vf(enp, mac_addr);
1824 EFX_MAC_ADDR_COPY(encp->enc_mac_addr, mac_addr);
1826 /* Board configuration (legacy) */
1827 rc = efx_mcdi_get_board_cfg(enp, &board_type, NULL, NULL);
1829 /* Unprivileged functions may not be able to read board cfg */
1836 encp->enc_board_type = board_type;
1837 encp->enc_clk_mult = 1; /* not used for EF10 */
1839 /* Fill out fields in enp->en_port and enp->en_nic_cfg from MCDI */
1840 if ((rc = efx_mcdi_get_phy_cfg(enp)) != 0)
1844 * Firmware with support for *_FEC capability bits does not
1845 * report that the corresponding *_FEC_REQUESTED bits are supported.
1846 * Add them here so that drivers understand that they are supported.
1848 if (epp->ep_phy_cap_mask & (1u << EFX_PHY_CAP_BASER_FEC))
1849 epp->ep_phy_cap_mask |=
1850 (1u << EFX_PHY_CAP_BASER_FEC_REQUESTED);
1851 if (epp->ep_phy_cap_mask & (1u << EFX_PHY_CAP_RS_FEC))
1852 epp->ep_phy_cap_mask |=
1853 (1u << EFX_PHY_CAP_RS_FEC_REQUESTED);
1854 if (epp->ep_phy_cap_mask & (1u << EFX_PHY_CAP_25G_BASER_FEC))
1855 epp->ep_phy_cap_mask |=
1856 (1u << EFX_PHY_CAP_25G_BASER_FEC_REQUESTED);
1858 /* Obtain the default PHY advertised capabilities */
1859 if ((rc = ef10_phy_get_link(enp, &els)) != 0)
1861 epp->ep_default_adv_cap_mask = els.epls.epls_adv_cap_mask;
1862 epp->ep_adv_cap_mask = els.epls.epls_adv_cap_mask;
1864 /* Check capabilities of running datapath firmware */
1865 if ((rc = ef10_get_datapath_caps(enp)) != 0)
1868 /* Alignment for WPTR updates */
1869 encp->enc_rx_push_align = EF10_RX_WPTR_ALIGN;
1871 encp->enc_tx_dma_desc_size_max = EFX_MASK32(ESF_DZ_RX_KER_BYTE_CNT);
1872 /* No boundary crossing limits */
1873 encp->enc_tx_dma_desc_boundary = 0;
1876 * Maximum number of bytes into the frame the TCP header can start for
1877 * firmware assisted TSO to work.
1879 encp->enc_tx_tso_tcp_header_offset_limit = EF10_TCP_HEADER_OFFSET_LIMIT;
1882 * Set resource limits for MC_CMD_ALLOC_VIS. Note that we cannot use
1883 * MC_CMD_GET_RESOURCE_LIMITS here as that reports the available
1884 * resources (allocated to this PCIe function), which is zero until
1885 * after we have allocated VIs.
1887 encp->enc_evq_limit = 1024;
1888 encp->enc_rxq_limit = EFX_RXQ_LIMIT_TARGET;
1889 encp->enc_txq_limit = EFX_TXQ_LIMIT_TARGET;
1891 encp->enc_buftbl_limit = 0xFFFFFFFF;
1893 /* Get interrupt vector limits */
1894 if ((rc = efx_mcdi_get_vector_cfg(enp, &base, &nvec, NULL)) != 0) {
1895 if (EFX_PCI_FUNCTION_IS_PF(encp))
1898 /* Ignore error (cannot query vector limits from a VF). */
1902 encp->enc_intr_vec_base = base;
1903 encp->enc_intr_limit = nvec;
1906 * Get the current privilege mask. Note that this may be modified
1907 * dynamically, so this value is informational only. DO NOT use
1908 * the privilege mask to check for sufficient privileges, as that
1909 * can result in time-of-check/time-of-use bugs.
1911 if ((rc = ef10_get_privilege_mask(enp, &mask)) != 0)
1913 encp->enc_privilege_mask = mask;
1915 /* Get remaining controller-specific board config */
1916 if ((rc = enop->eno_board_cfg(enp)) != 0)
1923 EFSYS_PROBE(fail11);
1925 EFSYS_PROBE(fail10);
1943 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1948 __checkReturn efx_rc_t
1950 __in efx_nic_t *enp)
1952 efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
1953 efx_drv_cfg_t *edcp = &(enp->en_drv_cfg);
1956 EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
1957 enp->en_family == EFX_FAMILY_MEDFORD ||
1958 enp->en_family == EFX_FAMILY_MEDFORD2);
1960 /* Read and clear any assertion state */
1961 if ((rc = efx_mcdi_read_assertion(enp)) != 0)
1964 /* Exit the assertion handler */
1965 if ((rc = efx_mcdi_exit_assertion_handler(enp)) != 0)
1969 if ((rc = efx_mcdi_drv_attach(enp, B_TRUE)) != 0)
1972 if ((rc = ef10_nic_board_cfg(enp)) != 0)
1976 * Set default driver config limits (based on board config).
1978 * FIXME: For now allocate a fixed number of VIs which is likely to be
1979 * sufficient and small enough to allow multiple functions on the same
1982 edcp->edc_min_vi_count = edcp->edc_max_vi_count =
1983 MIN(128, MAX(encp->enc_rxq_limit, encp->enc_txq_limit));
1985 /* The client driver must configure and enable PIO buffer support */
1986 edcp->edc_max_piobuf_count = 0;
1987 edcp->edc_pio_alloc_size = 0;
1989 #if EFSYS_OPT_MAC_STATS
1990 /* Wipe the MAC statistics */
1991 if ((rc = efx_mcdi_mac_stats_clear(enp)) != 0)
1995 #if EFSYS_OPT_LOOPBACK
1996 if ((rc = efx_mcdi_get_loopback_modes(enp)) != 0)
2000 #if EFSYS_OPT_MON_STATS
2001 if ((rc = mcdi_mon_cfg_build(enp)) != 0) {
2002 /* Unprivileged functions do not have access to sensors */
2008 encp->enc_features = enp->en_features;
2012 #if EFSYS_OPT_MON_STATS
2016 #if EFSYS_OPT_LOOPBACK
2020 #if EFSYS_OPT_MAC_STATS
2031 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2036 __checkReturn efx_rc_t
2037 ef10_nic_set_drv_limits(
2038 __inout efx_nic_t *enp,
2039 __in efx_drv_limits_t *edlp)
2041 efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
2042 efx_drv_cfg_t *edcp = &(enp->en_drv_cfg);
2043 uint32_t min_evq_count, max_evq_count;
2044 uint32_t min_rxq_count, max_rxq_count;
2045 uint32_t min_txq_count, max_txq_count;
2053 /* Get minimum required and maximum usable VI limits */
2054 min_evq_count = MIN(edlp->edl_min_evq_count, encp->enc_evq_limit);
2055 min_rxq_count = MIN(edlp->edl_min_rxq_count, encp->enc_rxq_limit);
2056 min_txq_count = MIN(edlp->edl_min_txq_count, encp->enc_txq_limit);
2058 edcp->edc_min_vi_count =
2059 MAX(min_evq_count, MAX(min_rxq_count, min_txq_count));
2061 max_evq_count = MIN(edlp->edl_max_evq_count, encp->enc_evq_limit);
2062 max_rxq_count = MIN(edlp->edl_max_rxq_count, encp->enc_rxq_limit);
2063 max_txq_count = MIN(edlp->edl_max_txq_count, encp->enc_txq_limit);
2065 edcp->edc_max_vi_count =
2066 MAX(max_evq_count, MAX(max_rxq_count, max_txq_count));
2069 * Check limits for sub-allocated piobuf blocks.
2070 * PIO is optional, so don't fail if the limits are incorrect.
2072 if ((encp->enc_piobuf_size == 0) ||
2073 (encp->enc_piobuf_limit == 0) ||
2074 (edlp->edl_min_pio_alloc_size == 0) ||
2075 (edlp->edl_min_pio_alloc_size > encp->enc_piobuf_size)) {
2077 edcp->edc_max_piobuf_count = 0;
2078 edcp->edc_pio_alloc_size = 0;
2080 uint32_t blk_size, blk_count, blks_per_piobuf;
2083 MAX(edlp->edl_min_pio_alloc_size,
2084 encp->enc_piobuf_min_alloc_size);
2086 blks_per_piobuf = encp->enc_piobuf_size / blk_size;
2087 EFSYS_ASSERT3U(blks_per_piobuf, <=, 32);
2089 blk_count = (encp->enc_piobuf_limit * blks_per_piobuf);
2091 /* A zero max pio alloc count means unlimited */
2092 if ((edlp->edl_max_pio_alloc_count > 0) &&
2093 (edlp->edl_max_pio_alloc_count < blk_count)) {
2094 blk_count = edlp->edl_max_pio_alloc_count;
2097 edcp->edc_pio_alloc_size = blk_size;
2098 edcp->edc_max_piobuf_count =
2099 (blk_count + (blks_per_piobuf - 1)) / blks_per_piobuf;
2105 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2111 __checkReturn efx_rc_t
2113 __in efx_nic_t *enp)
2116 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_ENTITY_RESET_IN_LEN,
2117 MC_CMD_ENTITY_RESET_OUT_LEN);
2120 /* ef10_nic_reset() is called to recover from BADASSERT failures. */
2121 if ((rc = efx_mcdi_read_assertion(enp)) != 0)
2123 if ((rc = efx_mcdi_exit_assertion_handler(enp)) != 0)
2126 req.emr_cmd = MC_CMD_ENTITY_RESET;
2127 req.emr_in_buf = payload;
2128 req.emr_in_length = MC_CMD_ENTITY_RESET_IN_LEN;
2129 req.emr_out_buf = payload;
2130 req.emr_out_length = MC_CMD_ENTITY_RESET_OUT_LEN;
2132 MCDI_IN_POPULATE_DWORD_1(req, ENTITY_RESET_IN_FLAG,
2133 ENTITY_RESET_IN_FUNCTION_RESOURCE_RESET, 1);
2135 efx_mcdi_execute(enp, &req);
2137 if (req.emr_rc != 0) {
2142 /* Clear RX/TX DMA queue errors */
2143 enp->en_reset_flags &= ~(EFX_RESET_RXQ_ERR | EFX_RESET_TXQ_ERR);
2152 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2157 __checkReturn efx_rc_t
2159 __in efx_nic_t *enp)
2161 efx_drv_cfg_t *edcp = &(enp->en_drv_cfg);
2162 uint32_t min_vi_count, max_vi_count;
2163 uint32_t vi_count, vi_base, vi_shift;
2167 uint32_t vi_window_size;
2170 EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
2171 enp->en_family == EFX_FAMILY_MEDFORD ||
2172 enp->en_family == EFX_FAMILY_MEDFORD2);
2174 /* Enable reporting of some events (e.g. link change) */
2175 if ((rc = efx_mcdi_log_ctrl(enp)) != 0)
2178 /* Allocate (optional) on-chip PIO buffers */
2179 ef10_nic_alloc_piobufs(enp, edcp->edc_max_piobuf_count);
2182 * For best performance, PIO writes should use a write-combined
2183 * (WC) memory mapping. Using a separate WC mapping for the PIO
2184 * aperture of each VI would be a burden to drivers (and not
2185 * possible if the host page size is >4Kbyte).
2187 * To avoid this we use a single uncached (UC) mapping for VI
2188 * register access, and a single WC mapping for extra VIs used
2191 * Each piobuf must be linked to a VI in the WC mapping, and to
2192 * each VI that is using a sub-allocated block from the piobuf.
2194 min_vi_count = edcp->edc_min_vi_count;
2196 edcp->edc_max_vi_count + enp->en_arch.ef10.ena_piobuf_count;
2198 /* Ensure that the previously attached driver's VIs are freed */
2199 if ((rc = efx_mcdi_free_vis(enp)) != 0)
2203 * Reserve VI resources (EVQ+RXQ+TXQ) for this PCIe function. If this
2204 * fails then retrying the request for fewer VI resources may succeed.
2207 if ((rc = efx_mcdi_alloc_vis(enp, min_vi_count, max_vi_count,
2208 &vi_base, &vi_count, &vi_shift)) != 0)
2211 EFSYS_PROBE2(vi_alloc, uint32_t, vi_base, uint32_t, vi_count);
2213 if (vi_count < min_vi_count) {
2218 enp->en_arch.ef10.ena_vi_base = vi_base;
2219 enp->en_arch.ef10.ena_vi_count = vi_count;
2220 enp->en_arch.ef10.ena_vi_shift = vi_shift;
2222 if (vi_count < min_vi_count + enp->en_arch.ef10.ena_piobuf_count) {
2223 /* Not enough extra VIs to map piobufs */
2224 ef10_nic_free_piobufs(enp);
2227 enp->en_arch.ef10.ena_pio_write_vi_base =
2228 vi_count - enp->en_arch.ef10.ena_piobuf_count;
2230 EFSYS_ASSERT3U(enp->en_nic_cfg.enc_vi_window_shift, !=,
2231 EFX_VI_WINDOW_SHIFT_INVALID);
2232 EFSYS_ASSERT3U(enp->en_nic_cfg.enc_vi_window_shift, <=,
2233 EFX_VI_WINDOW_SHIFT_64K);
2234 vi_window_size = 1U << enp->en_nic_cfg.enc_vi_window_shift;
2236 /* Save UC memory mapping details */
2237 enp->en_arch.ef10.ena_uc_mem_map_offset = 0;
2238 if (enp->en_arch.ef10.ena_piobuf_count > 0) {
2239 enp->en_arch.ef10.ena_uc_mem_map_size =
2241 enp->en_arch.ef10.ena_pio_write_vi_base);
2243 enp->en_arch.ef10.ena_uc_mem_map_size =
2245 enp->en_arch.ef10.ena_vi_count);
2248 /* Save WC memory mapping details */
2249 enp->en_arch.ef10.ena_wc_mem_map_offset =
2250 enp->en_arch.ef10.ena_uc_mem_map_offset +
2251 enp->en_arch.ef10.ena_uc_mem_map_size;
2253 enp->en_arch.ef10.ena_wc_mem_map_size =
2255 enp->en_arch.ef10.ena_piobuf_count);
2257 /* Link piobufs to extra VIs in WC mapping */
2258 if (enp->en_arch.ef10.ena_piobuf_count > 0) {
2259 for (i = 0; i < enp->en_arch.ef10.ena_piobuf_count; i++) {
2260 rc = efx_mcdi_link_piobuf(enp,
2261 enp->en_arch.ef10.ena_pio_write_vi_base + i,
2262 enp->en_arch.ef10.ena_piobuf_handle[i]);
2269 * Allocate a vAdaptor attached to our upstream vPort/pPort.
2271 * On a VF, this may fail with MC_CMD_ERR_NO_EVB_PORT (ENOENT) if the PF
2272 * driver has yet to bring up the EVB port. See bug 56147. In this case,
2273 * retry the request several times after waiting a while. The wait time
2274 * between retries starts small (10ms) and exponentially increases.
2275 * Total wait time is a little over two seconds. Retry logic in the
2276 * client driver may mean this whole loop is repeated if it continues to
2281 while ((rc = efx_mcdi_vadaptor_alloc(enp, EVB_PORT_ID_ASSIGNED)) != 0) {
2282 if (EFX_PCI_FUNCTION_IS_PF(&enp->en_nic_cfg) ||
2285 * Do not retry alloc for PF, or for other errors on
2291 /* VF startup before PF is ready. Retry allocation. */
2293 /* Too many attempts */
2297 EFSYS_PROBE1(mcdi_no_evb_port_retry, int, retry);
2298 EFSYS_SLEEP(delay_us);
2300 if (delay_us < 500000)
2304 enp->en_vport_id = EVB_PORT_ID_ASSIGNED;
2305 enp->en_nic_cfg.enc_mcdi_max_payload_length = MCDI_CTL_SDU_LEN_MAX_V2;
2320 ef10_nic_free_piobufs(enp);
2323 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2328 __checkReturn efx_rc_t
2329 ef10_nic_get_vi_pool(
2330 __in efx_nic_t *enp,
2331 __out uint32_t *vi_countp)
2333 EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
2334 enp->en_family == EFX_FAMILY_MEDFORD ||
2335 enp->en_family == EFX_FAMILY_MEDFORD2);
2338 * Report VIs that the client driver can use.
2339 * Do not include VIs used for PIO buffer writes.
2341 *vi_countp = enp->en_arch.ef10.ena_pio_write_vi_base;
2346 __checkReturn efx_rc_t
2347 ef10_nic_get_bar_region(
2348 __in efx_nic_t *enp,
2349 __in efx_nic_region_t region,
2350 __out uint32_t *offsetp,
2351 __out size_t *sizep)
2355 EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
2356 enp->en_family == EFX_FAMILY_MEDFORD ||
2357 enp->en_family == EFX_FAMILY_MEDFORD2);
2360 * TODO: Specify host memory mapping alignment and granularity
2361 * in efx_drv_limits_t so that they can be taken into account
2362 * when allocating extra VIs for PIO writes.
2366 /* UC mapped memory BAR region for VI registers */
2367 *offsetp = enp->en_arch.ef10.ena_uc_mem_map_offset;
2368 *sizep = enp->en_arch.ef10.ena_uc_mem_map_size;
2371 case EFX_REGION_PIO_WRITE_VI:
2372 /* WC mapped memory BAR region for piobuf writes */
2373 *offsetp = enp->en_arch.ef10.ena_wc_mem_map_offset;
2374 *sizep = enp->en_arch.ef10.ena_wc_mem_map_size;
2385 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2390 __checkReturn boolean_t
2391 ef10_nic_hw_unavailable(
2392 __in efx_nic_t *enp)
2396 if (enp->en_reset_flags & EFX_RESET_HW_UNAVAIL)
2399 EFX_BAR_READD(enp, ER_DZ_BIU_MC_SFT_STATUS_REG, &dword, B_FALSE);
2400 if (EFX_DWORD_FIELD(dword, EFX_DWORD_0) == 0xffffffff)
2406 ef10_nic_set_hw_unavailable(enp);
2412 ef10_nic_set_hw_unavailable(
2413 __in efx_nic_t *enp)
2415 EFSYS_PROBE(hw_unavail);
2416 enp->en_reset_flags |= EFX_RESET_HW_UNAVAIL;
2422 __in efx_nic_t *enp)
2427 (void) efx_mcdi_vadaptor_free(enp, enp->en_vport_id);
2428 enp->en_vport_id = 0;
2430 /* Unlink piobufs from extra VIs in WC mapping */
2431 if (enp->en_arch.ef10.ena_piobuf_count > 0) {
2432 for (i = 0; i < enp->en_arch.ef10.ena_piobuf_count; i++) {
2433 rc = efx_mcdi_unlink_piobuf(enp,
2434 enp->en_arch.ef10.ena_pio_write_vi_base + i);
2440 ef10_nic_free_piobufs(enp);
2442 (void) efx_mcdi_free_vis(enp);
2443 enp->en_arch.ef10.ena_vi_count = 0;
2448 __in efx_nic_t *enp)
2450 #if EFSYS_OPT_MON_STATS
2451 mcdi_mon_cfg_free(enp);
2452 #endif /* EFSYS_OPT_MON_STATS */
2453 (void) efx_mcdi_drv_attach(enp, B_FALSE);
2458 __checkReturn efx_rc_t
2459 ef10_nic_register_test(
2460 __in efx_nic_t *enp)
2465 _NOTE(ARGUNUSED(enp))
2466 _NOTE(CONSTANTCONDITION)
2476 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2481 #endif /* EFSYS_OPT_DIAG */
2483 #if EFSYS_OPT_FW_SUBVARIANT_AWARE
2485 __checkReturn efx_rc_t
2486 efx_mcdi_get_nic_global(
2487 __in efx_nic_t *enp,
2489 __out uint32_t *valuep)
2492 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_GET_NIC_GLOBAL_IN_LEN,
2493 MC_CMD_GET_NIC_GLOBAL_OUT_LEN);
2496 req.emr_cmd = MC_CMD_GET_NIC_GLOBAL;
2497 req.emr_in_buf = payload;
2498 req.emr_in_length = MC_CMD_GET_NIC_GLOBAL_IN_LEN;
2499 req.emr_out_buf = payload;
2500 req.emr_out_length = MC_CMD_GET_NIC_GLOBAL_OUT_LEN;
2502 MCDI_IN_SET_DWORD(req, GET_NIC_GLOBAL_IN_KEY, key);
2504 efx_mcdi_execute(enp, &req);
2506 if (req.emr_rc != 0) {
2511 if (req.emr_out_length_used != MC_CMD_GET_NIC_GLOBAL_OUT_LEN) {
2516 *valuep = MCDI_OUT_DWORD(req, GET_NIC_GLOBAL_OUT_VALUE);
2523 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2528 __checkReturn efx_rc_t
2529 efx_mcdi_set_nic_global(
2530 __in efx_nic_t *enp,
2532 __in uint32_t value)
2535 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_SET_NIC_GLOBAL_IN_LEN, 0);
2538 req.emr_cmd = MC_CMD_SET_NIC_GLOBAL;
2539 req.emr_in_buf = payload;
2540 req.emr_in_length = MC_CMD_SET_NIC_GLOBAL_IN_LEN;
2541 req.emr_out_buf = NULL;
2542 req.emr_out_length = 0;
2544 MCDI_IN_SET_DWORD(req, SET_NIC_GLOBAL_IN_KEY, key);
2545 MCDI_IN_SET_DWORD(req, SET_NIC_GLOBAL_IN_VALUE, value);
2547 efx_mcdi_execute(enp, &req);
2549 if (req.emr_rc != 0) {
2557 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2562 #endif /* EFSYS_OPT_FW_SUBVARIANT_AWARE */
2564 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */