2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2008-2016 Solarflare Communications Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
10 * 1. Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * The views and conclusions contained in the software and documentation are
29 * those of the authors and should not be interpreted as representing official
30 * policies, either expressed or implied, of the FreeBSD Project.
33 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
42 * There are three versions of the MCDI interface:
43 * - MCDIv0: Siena BootROM. Transport uses MCDIv1 headers.
44 * - MCDIv1: Siena firmware and Huntington BootROM.
45 * - MCDIv2: EF10 firmware (Huntington/Medford) and Medford BootROM.
46 * Transport uses MCDIv2 headers.
48 * MCDIv2 Header NOT_EPOCH flag
49 * ----------------------------
50 * A new epoch begins at initial startup or after an MC reboot, and defines when
51 * the MC should reject stale MCDI requests.
53 * The first MCDI request sent by the host should contain NOT_EPOCH=0, and all
54 * subsequent requests (until the next MC reboot) should contain NOT_EPOCH=1.
56 * After rebooting the MC will fail all requests with NOT_EPOCH=1 by writing a
57 * response with ERROR=1 and DATALEN=0 until a request is seen with NOT_EPOCH=0.
64 static const efx_mcdi_ops_t __efx_mcdi_siena_ops = {
65 siena_mcdi_init, /* emco_init */
66 siena_mcdi_send_request, /* emco_send_request */
67 siena_mcdi_poll_reboot, /* emco_poll_reboot */
68 siena_mcdi_poll_response, /* emco_poll_response */
69 siena_mcdi_read_response, /* emco_read_response */
70 siena_mcdi_fini, /* emco_fini */
71 siena_mcdi_feature_supported, /* emco_feature_supported */
72 siena_mcdi_get_timeout, /* emco_get_timeout */
75 #endif /* EFSYS_OPT_SIENA */
77 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
79 static const efx_mcdi_ops_t __efx_mcdi_ef10_ops = {
80 ef10_mcdi_init, /* emco_init */
81 ef10_mcdi_send_request, /* emco_send_request */
82 ef10_mcdi_poll_reboot, /* emco_poll_reboot */
83 ef10_mcdi_poll_response, /* emco_poll_response */
84 ef10_mcdi_read_response, /* emco_read_response */
85 ef10_mcdi_fini, /* emco_fini */
86 ef10_mcdi_feature_supported, /* emco_feature_supported */
87 ef10_mcdi_get_timeout, /* emco_get_timeout */
90 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
94 __checkReturn efx_rc_t
97 __in const efx_mcdi_transport_t *emtp)
99 const efx_mcdi_ops_t *emcop;
102 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
103 EFSYS_ASSERT3U(enp->en_mod_flags, ==, 0);
105 switch (enp->en_family) {
107 case EFX_FAMILY_SIENA:
108 emcop = &__efx_mcdi_siena_ops;
110 #endif /* EFSYS_OPT_SIENA */
112 #if EFSYS_OPT_HUNTINGTON
113 case EFX_FAMILY_HUNTINGTON:
114 emcop = &__efx_mcdi_ef10_ops;
116 #endif /* EFSYS_OPT_HUNTINGTON */
118 #if EFSYS_OPT_MEDFORD
119 case EFX_FAMILY_MEDFORD:
120 emcop = &__efx_mcdi_ef10_ops;
122 #endif /* EFSYS_OPT_MEDFORD */
130 if (enp->en_features & EFX_FEATURE_MCDI_DMA) {
131 /* MCDI requires a DMA buffer in host memory */
132 if ((emtp == NULL) || (emtp->emt_dma_mem) == NULL) {
137 enp->en_mcdi.em_emtp = emtp;
139 if (emcop != NULL && emcop->emco_init != NULL) {
140 if ((rc = emcop->emco_init(enp, emtp)) != 0)
144 enp->en_mcdi.em_emcop = emcop;
145 enp->en_mod_flags |= EFX_MOD_MCDI;
154 EFSYS_PROBE1(fail1, efx_rc_t, rc);
156 enp->en_mcdi.em_emcop = NULL;
157 enp->en_mcdi.em_emtp = NULL;
158 enp->en_mod_flags &= ~EFX_MOD_MCDI;
167 efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
168 const efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop;
170 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
171 EFSYS_ASSERT3U(enp->en_mod_flags, ==, EFX_MOD_MCDI);
173 if (emcop != NULL && emcop->emco_fini != NULL)
174 emcop->emco_fini(enp);
177 emip->emi_aborted = 0;
179 enp->en_mcdi.em_emcop = NULL;
180 enp->en_mod_flags &= ~EFX_MOD_MCDI;
187 efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
188 efsys_lock_state_t state;
190 /* Start a new epoch (allow fresh MCDI requests to succeed) */
191 EFSYS_LOCK(enp->en_eslp, state);
192 emip->emi_new_epoch = B_TRUE;
193 EFSYS_UNLOCK(enp->en_eslp, state);
197 efx_mcdi_send_request(
204 const efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop;
206 emcop->emco_send_request(enp, hdrp, hdr_len, sdup, sdu_len);
210 efx_mcdi_poll_reboot(
213 const efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop;
216 rc = emcop->emco_poll_reboot(enp);
221 efx_mcdi_poll_response(
224 const efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop;
227 available = emcop->emco_poll_response(enp);
232 efx_mcdi_read_response(
238 const efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop;
240 emcop->emco_read_response(enp, bufferp, offset, length);
244 efx_mcdi_request_start(
246 __in efx_mcdi_req_t *emrp,
247 __in boolean_t ev_cpl)
249 #if EFSYS_OPT_MCDI_LOGGING
250 const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
252 efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
255 unsigned int max_version;
259 efsys_lock_state_t state;
261 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
262 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MCDI);
263 EFSYS_ASSERT3U(enp->en_features, &, EFX_FEATURE_MCDI);
266 * efx_mcdi_request_start() is naturally serialised against both
267 * efx_mcdi_request_poll() and efx_mcdi_ev_cpl()/efx_mcdi_ev_death(),
268 * by virtue of there only being one outstanding MCDI request.
269 * Unfortunately, upper layers may also call efx_mcdi_request_abort()
270 * at any time, to timeout a pending mcdi request, That request may
271 * then subsequently complete, meaning efx_mcdi_ev_cpl() or
272 * efx_mcdi_ev_death() may end up running in parallel with
273 * efx_mcdi_request_start(). This race is handled by ensuring that
274 * %emi_pending_req, %emi_ev_cpl and %emi_seq are protected by the
277 EFSYS_LOCK(enp->en_eslp, state);
278 EFSYS_ASSERT(emip->emi_pending_req == NULL);
279 emip->emi_pending_req = emrp;
280 emip->emi_ev_cpl = ev_cpl;
281 emip->emi_poll_cnt = 0;
282 seq = emip->emi_seq++ & EFX_MASK32(MCDI_HEADER_SEQ);
283 new_epoch = emip->emi_new_epoch;
284 max_version = emip->emi_max_version;
285 EFSYS_UNLOCK(enp->en_eslp, state);
289 xflags |= MCDI_HEADER_XFLAGS_EVREQ;
292 * Huntington firmware supports MCDIv2, but the Huntington BootROM only
293 * supports MCDIv1. Use MCDIv1 headers for MCDIv1 commands where
294 * possible to support this.
296 if ((max_version >= 2) &&
297 ((emrp->emr_cmd > MC_CMD_CMD_SPACE_ESCAPE_7) ||
298 (emrp->emr_in_length > MCDI_CTL_SDU_LEN_MAX_V1))) {
299 /* Construct MCDI v2 header */
300 hdr_len = sizeof (hdr);
301 EFX_POPULATE_DWORD_8(hdr[0],
302 MCDI_HEADER_CODE, MC_CMD_V2_EXTN,
303 MCDI_HEADER_RESYNC, 1,
304 MCDI_HEADER_DATALEN, 0,
305 MCDI_HEADER_SEQ, seq,
306 MCDI_HEADER_NOT_EPOCH, new_epoch ? 0 : 1,
307 MCDI_HEADER_ERROR, 0,
308 MCDI_HEADER_RESPONSE, 0,
309 MCDI_HEADER_XFLAGS, xflags);
311 EFX_POPULATE_DWORD_2(hdr[1],
312 MC_CMD_V2_EXTN_IN_EXTENDED_CMD, emrp->emr_cmd,
313 MC_CMD_V2_EXTN_IN_ACTUAL_LEN, emrp->emr_in_length);
315 /* Construct MCDI v1 header */
316 hdr_len = sizeof (hdr[0]);
317 EFX_POPULATE_DWORD_8(hdr[0],
318 MCDI_HEADER_CODE, emrp->emr_cmd,
319 MCDI_HEADER_RESYNC, 1,
320 MCDI_HEADER_DATALEN, emrp->emr_in_length,
321 MCDI_HEADER_SEQ, seq,
322 MCDI_HEADER_NOT_EPOCH, new_epoch ? 0 : 1,
323 MCDI_HEADER_ERROR, 0,
324 MCDI_HEADER_RESPONSE, 0,
325 MCDI_HEADER_XFLAGS, xflags);
328 #if EFSYS_OPT_MCDI_LOGGING
329 if (emtp->emt_logger != NULL) {
330 emtp->emt_logger(emtp->emt_context, EFX_LOG_MCDI_REQUEST,
332 emrp->emr_in_buf, emrp->emr_in_length);
334 #endif /* EFSYS_OPT_MCDI_LOGGING */
336 efx_mcdi_send_request(enp, &hdr[0], hdr_len,
337 emrp->emr_in_buf, emrp->emr_in_length);
342 efx_mcdi_read_response_header(
344 __inout efx_mcdi_req_t *emrp)
346 #if EFSYS_OPT_MCDI_LOGGING
347 const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
348 #endif /* EFSYS_OPT_MCDI_LOGGING */
349 efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
351 unsigned int hdr_len;
352 unsigned int data_len;
358 EFSYS_ASSERT(emrp != NULL);
360 efx_mcdi_read_response(enp, &hdr[0], 0, sizeof (hdr[0]));
361 hdr_len = sizeof (hdr[0]);
363 cmd = EFX_DWORD_FIELD(hdr[0], MCDI_HEADER_CODE);
364 seq = EFX_DWORD_FIELD(hdr[0], MCDI_HEADER_SEQ);
365 error = EFX_DWORD_FIELD(hdr[0], MCDI_HEADER_ERROR);
367 if (cmd != MC_CMD_V2_EXTN) {
368 data_len = EFX_DWORD_FIELD(hdr[0], MCDI_HEADER_DATALEN);
370 efx_mcdi_read_response(enp, &hdr[1], hdr_len, sizeof (hdr[1]));
371 hdr_len += sizeof (hdr[1]);
373 cmd = EFX_DWORD_FIELD(hdr[1], MC_CMD_V2_EXTN_IN_EXTENDED_CMD);
375 EFX_DWORD_FIELD(hdr[1], MC_CMD_V2_EXTN_IN_ACTUAL_LEN);
378 if (error && (data_len == 0)) {
379 /* The MC has rebooted since the request was sent. */
380 EFSYS_SPIN(EFX_MCDI_STATUS_SLEEP_US);
381 efx_mcdi_poll_reboot(enp);
385 if ((cmd != emrp->emr_cmd) ||
386 (seq != ((emip->emi_seq - 1) & EFX_MASK32(MCDI_HEADER_SEQ)))) {
387 /* Response is for a different request */
393 unsigned int err_len = MIN(data_len, sizeof (err));
394 int err_code = MC_CMD_ERR_EPROTO;
397 /* Read error code (and arg num for MCDI v2 commands) */
398 efx_mcdi_read_response(enp, &err, hdr_len, err_len);
400 if (err_len >= (MC_CMD_ERR_CODE_OFST + sizeof (efx_dword_t)))
401 err_code = EFX_DWORD_FIELD(err[0], EFX_DWORD_0);
403 if (err_len >= (MC_CMD_ERR_ARG_OFST + sizeof (efx_dword_t)))
404 err_arg = EFX_DWORD_FIELD(err[1], EFX_DWORD_0);
406 emrp->emr_err_code = err_code;
407 emrp->emr_err_arg = err_arg;
409 #if EFSYS_OPT_MCDI_PROXY_AUTH
410 if ((err_code == MC_CMD_ERR_PROXY_PENDING) &&
411 (err_len == sizeof (err))) {
413 * The MCDI request would normally fail with EPERM, but
414 * firmware has forwarded it to an authorization agent
415 * attached to a privileged PF.
417 * Save the authorization request handle. The client
418 * must wait for a PROXY_RESPONSE event, or timeout.
420 emrp->emr_proxy_handle = err_arg;
422 #endif /* EFSYS_OPT_MCDI_PROXY_AUTH */
424 #if EFSYS_OPT_MCDI_LOGGING
425 if (emtp->emt_logger != NULL) {
426 emtp->emt_logger(emtp->emt_context,
427 EFX_LOG_MCDI_RESPONSE,
431 #endif /* EFSYS_OPT_MCDI_LOGGING */
433 if (!emrp->emr_quiet) {
434 EFSYS_PROBE3(mcdi_err_arg, int, emrp->emr_cmd,
435 int, err_code, int, err_arg);
438 rc = efx_mcdi_request_errcode(err_code);
443 emrp->emr_out_length_used = data_len;
444 #if EFSYS_OPT_MCDI_PROXY_AUTH
445 emrp->emr_proxy_handle = 0;
446 #endif /* EFSYS_OPT_MCDI_PROXY_AUTH */
453 emrp->emr_out_length_used = 0;
457 efx_mcdi_finish_response(
459 __in efx_mcdi_req_t *emrp)
461 #if EFSYS_OPT_MCDI_LOGGING
462 const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
463 #endif /* EFSYS_OPT_MCDI_LOGGING */
465 unsigned int hdr_len;
468 if (emrp->emr_out_buf == NULL)
471 /* Read the command header to detect MCDI response format */
472 hdr_len = sizeof (hdr[0]);
473 efx_mcdi_read_response(enp, &hdr[0], 0, hdr_len);
474 if (EFX_DWORD_FIELD(hdr[0], MCDI_HEADER_CODE) == MC_CMD_V2_EXTN) {
476 * Read the actual payload length. The length given in the event
477 * is only correct for responses with the V1 format.
479 efx_mcdi_read_response(enp, &hdr[1], hdr_len, sizeof (hdr[1]));
480 hdr_len += sizeof (hdr[1]);
482 emrp->emr_out_length_used = EFX_DWORD_FIELD(hdr[1],
483 MC_CMD_V2_EXTN_IN_ACTUAL_LEN);
486 /* Copy payload out into caller supplied buffer */
487 bytes = MIN(emrp->emr_out_length_used, emrp->emr_out_length);
488 efx_mcdi_read_response(enp, emrp->emr_out_buf, hdr_len, bytes);
490 #if EFSYS_OPT_MCDI_LOGGING
491 if (emtp->emt_logger != NULL) {
492 emtp->emt_logger(emtp->emt_context,
493 EFX_LOG_MCDI_RESPONSE,
495 emrp->emr_out_buf, bytes);
497 #endif /* EFSYS_OPT_MCDI_LOGGING */
501 __checkReturn boolean_t
502 efx_mcdi_request_poll(
505 efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
506 efx_mcdi_req_t *emrp;
507 efsys_lock_state_t state;
510 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
511 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MCDI);
512 EFSYS_ASSERT3U(enp->en_features, &, EFX_FEATURE_MCDI);
514 /* Serialise against post-watchdog efx_mcdi_ev* */
515 EFSYS_LOCK(enp->en_eslp, state);
517 EFSYS_ASSERT(emip->emi_pending_req != NULL);
518 EFSYS_ASSERT(!emip->emi_ev_cpl);
519 emrp = emip->emi_pending_req;
521 /* Check for reboot atomically w.r.t efx_mcdi_request_start */
522 if (emip->emi_poll_cnt++ == 0) {
523 if ((rc = efx_mcdi_poll_reboot(enp)) != 0) {
524 emip->emi_pending_req = NULL;
525 EFSYS_UNLOCK(enp->en_eslp, state);
527 /* Reboot/Assertion */
528 if (rc == EIO || rc == EINTR)
529 efx_mcdi_raise_exception(enp, emrp, rc);
535 /* Check if a response is available */
536 if (efx_mcdi_poll_response(enp) == B_FALSE) {
537 EFSYS_UNLOCK(enp->en_eslp, state);
541 /* Read the response header */
542 efx_mcdi_read_response_header(enp, emrp);
544 /* Request complete */
545 emip->emi_pending_req = NULL;
547 /* Ensure stale MCDI requests fail after an MC reboot. */
548 emip->emi_new_epoch = B_FALSE;
550 EFSYS_UNLOCK(enp->en_eslp, state);
552 if ((rc = emrp->emr_rc) != 0)
555 efx_mcdi_finish_response(enp, emrp);
559 if (!emrp->emr_quiet)
562 if (!emrp->emr_quiet)
563 EFSYS_PROBE1(fail1, efx_rc_t, rc);
568 __checkReturn boolean_t
569 efx_mcdi_request_abort(
572 efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
573 efx_mcdi_req_t *emrp;
575 efsys_lock_state_t state;
577 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
578 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MCDI);
579 EFSYS_ASSERT3U(enp->en_features, &, EFX_FEATURE_MCDI);
582 * efx_mcdi_ev_* may have already completed this event, and be
583 * spinning/blocked on the upper layer lock. So it *is* legitimate
584 * to for emi_pending_req to be NULL. If there is a pending event
585 * completed request, then provide a "credit" to allow
586 * efx_mcdi_ev_cpl() to accept a single spurious completion.
588 EFSYS_LOCK(enp->en_eslp, state);
589 emrp = emip->emi_pending_req;
590 aborted = (emrp != NULL);
592 emip->emi_pending_req = NULL;
594 /* Error the request */
595 emrp->emr_out_length_used = 0;
596 emrp->emr_rc = ETIMEDOUT;
598 /* Provide a credit for seqno/emr_pending_req mismatches */
599 if (emip->emi_ev_cpl)
603 * The upper layer has called us, so we don't
604 * need to complete the request.
607 EFSYS_UNLOCK(enp->en_eslp, state);
613 efx_mcdi_get_timeout(
615 __in efx_mcdi_req_t *emrp,
616 __out uint32_t *timeoutp)
618 const efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop;
620 emcop->emco_get_timeout(enp, emrp, timeoutp);
623 __checkReturn efx_rc_t
624 efx_mcdi_request_errcode(
625 __in unsigned int err)
630 case MC_CMD_ERR_EPERM:
632 case MC_CMD_ERR_ENOENT:
634 case MC_CMD_ERR_EINTR:
636 case MC_CMD_ERR_EACCES:
638 case MC_CMD_ERR_EBUSY:
640 case MC_CMD_ERR_EINVAL:
642 case MC_CMD_ERR_EDEADLK:
644 case MC_CMD_ERR_ENOSYS:
646 case MC_CMD_ERR_ETIME:
648 case MC_CMD_ERR_ENOTSUP:
650 case MC_CMD_ERR_EALREADY:
654 case MC_CMD_ERR_EEXIST:
656 #ifdef MC_CMD_ERR_EAGAIN
657 case MC_CMD_ERR_EAGAIN:
660 #ifdef MC_CMD_ERR_ENOSPC
661 case MC_CMD_ERR_ENOSPC:
664 case MC_CMD_ERR_ERANGE:
667 case MC_CMD_ERR_ALLOC_FAIL:
669 case MC_CMD_ERR_NO_VADAPTOR:
671 case MC_CMD_ERR_NO_EVB_PORT:
673 case MC_CMD_ERR_NO_VSWITCH:
675 case MC_CMD_ERR_VLAN_LIMIT:
677 case MC_CMD_ERR_BAD_PCI_FUNC:
679 case MC_CMD_ERR_BAD_VLAN_MODE:
681 case MC_CMD_ERR_BAD_VSWITCH_TYPE:
683 case MC_CMD_ERR_BAD_VPORT_TYPE:
685 case MC_CMD_ERR_MAC_EXIST:
688 case MC_CMD_ERR_PROXY_PENDING:
692 EFSYS_PROBE1(mc_pcol_error, int, err);
698 efx_mcdi_raise_exception(
700 __in_opt efx_mcdi_req_t *emrp,
703 const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
704 efx_mcdi_exception_t exception;
706 /* Reboot or Assertion failure only */
707 EFSYS_ASSERT(rc == EIO || rc == EINTR);
710 * If MC_CMD_REBOOT causes a reboot (dependent on parameters),
711 * then the EIO is not worthy of an exception.
713 if (emrp != NULL && emrp->emr_cmd == MC_CMD_REBOOT && rc == EIO)
716 exception = (rc == EIO)
717 ? EFX_MCDI_EXCEPTION_MC_REBOOT
718 : EFX_MCDI_EXCEPTION_MC_BADASSERT;
720 emtp->emt_exception(emtp->emt_context, exception);
726 __inout efx_mcdi_req_t *emrp)
728 const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
730 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MCDI);
731 EFSYS_ASSERT3U(enp->en_features, &, EFX_FEATURE_MCDI);
733 emrp->emr_quiet = B_FALSE;
734 emtp->emt_execute(emtp->emt_context, emrp);
738 efx_mcdi_execute_quiet(
740 __inout efx_mcdi_req_t *emrp)
742 const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
744 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MCDI);
745 EFSYS_ASSERT3U(enp->en_features, &, EFX_FEATURE_MCDI);
747 emrp->emr_quiet = B_TRUE;
748 emtp->emt_execute(emtp->emt_context, emrp);
754 __in unsigned int seq,
755 __in unsigned int outlen,
758 efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
759 const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
760 efx_mcdi_req_t *emrp;
761 efsys_lock_state_t state;
763 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MCDI);
764 EFSYS_ASSERT3U(enp->en_features, &, EFX_FEATURE_MCDI);
767 * Serialise against efx_mcdi_request_poll()/efx_mcdi_request_start()
768 * when we're completing an aborted request.
770 EFSYS_LOCK(enp->en_eslp, state);
771 if (emip->emi_pending_req == NULL || !emip->emi_ev_cpl ||
772 (seq != ((emip->emi_seq - 1) & EFX_MASK32(MCDI_HEADER_SEQ)))) {
773 EFSYS_ASSERT(emip->emi_aborted > 0);
774 if (emip->emi_aborted > 0)
776 EFSYS_UNLOCK(enp->en_eslp, state);
780 emrp = emip->emi_pending_req;
781 emip->emi_pending_req = NULL;
782 EFSYS_UNLOCK(enp->en_eslp, state);
784 if (emip->emi_max_version >= 2) {
785 /* MCDIv2 response details do not fit into an event. */
786 efx_mcdi_read_response_header(enp, emrp);
789 if (!emrp->emr_quiet) {
790 EFSYS_PROBE2(mcdi_err, int, emrp->emr_cmd,
793 emrp->emr_out_length_used = 0;
794 emrp->emr_rc = efx_mcdi_request_errcode(errcode);
796 emrp->emr_out_length_used = outlen;
801 efx_mcdi_finish_response(enp, emrp);
804 emtp->emt_ev_cpl(emtp->emt_context);
807 #if EFSYS_OPT_MCDI_PROXY_AUTH
809 __checkReturn efx_rc_t
810 efx_mcdi_get_proxy_handle(
812 __in efx_mcdi_req_t *emrp,
813 __out uint32_t *handlep)
818 * Return proxy handle from MCDI request that returned with error
819 * MC_MCD_ERR_PROXY_PENDING. This handle is used to wait for a matching
820 * PROXY_RESPONSE event.
822 if ((emrp == NULL) || (handlep == NULL)) {
826 if ((emrp->emr_rc != 0) &&
827 (emrp->emr_err_code == MC_CMD_ERR_PROXY_PENDING)) {
828 *handlep = emrp->emr_proxy_handle;
837 EFSYS_PROBE1(fail1, efx_rc_t, rc);
842 efx_mcdi_ev_proxy_response(
844 __in unsigned int handle,
845 __in unsigned int status)
847 const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
851 * Handle results of an authorization request for a privileged MCDI
852 * command. If authorization was granted then we must re-issue the
853 * original MCDI request. If authorization failed or timed out,
854 * then the original MCDI request should be completed with the
855 * result code from this event.
857 rc = (status == 0) ? 0 : efx_mcdi_request_errcode(status);
859 emtp->emt_ev_proxy_response(emtp->emt_context, handle, rc);
861 #endif /* EFSYS_OPT_MCDI_PROXY_AUTH */
868 efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
869 const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
870 efx_mcdi_req_t *emrp = NULL;
872 efsys_lock_state_t state;
875 * The MCDI request (if there is one) has been terminated, either
876 * by a BADASSERT or REBOOT event.
878 * If there is an outstanding event-completed MCDI operation, then we
879 * will never receive the completion event (because both MCDI
880 * completions and BADASSERT events are sent to the same evq). So
881 * complete this MCDI op.
883 * This function might run in parallel with efx_mcdi_request_poll()
884 * for poll completed mcdi requests, and also with
885 * efx_mcdi_request_start() for post-watchdog completions.
887 EFSYS_LOCK(enp->en_eslp, state);
888 emrp = emip->emi_pending_req;
889 ev_cpl = emip->emi_ev_cpl;
890 if (emrp != NULL && emip->emi_ev_cpl) {
891 emip->emi_pending_req = NULL;
893 emrp->emr_out_length_used = 0;
899 * Since we're running in parallel with a request, consume the
900 * status word before dropping the lock.
902 if (rc == EIO || rc == EINTR) {
903 EFSYS_SPIN(EFX_MCDI_STATUS_SLEEP_US);
904 (void) efx_mcdi_poll_reboot(enp);
905 emip->emi_new_epoch = B_TRUE;
908 EFSYS_UNLOCK(enp->en_eslp, state);
910 efx_mcdi_raise_exception(enp, emrp, rc);
912 if (emrp != NULL && ev_cpl)
913 emtp->emt_ev_cpl(emtp->emt_context);
916 __checkReturn efx_rc_t
919 __out_ecount_opt(4) uint16_t versionp[4],
920 __out_opt uint32_t *buildp,
921 __out_opt efx_mcdi_boot_t *statusp)
924 uint8_t payload[MAX(MAX(MC_CMD_GET_VERSION_IN_LEN,
925 MC_CMD_GET_VERSION_OUT_LEN),
926 MAX(MC_CMD_GET_BOOT_STATUS_IN_LEN,
927 MC_CMD_GET_BOOT_STATUS_OUT_LEN))];
928 efx_word_t *ver_words;
931 efx_mcdi_boot_t status;
934 EFSYS_ASSERT3U(enp->en_features, &, EFX_FEATURE_MCDI);
936 (void) memset(payload, 0, sizeof (payload));
937 req.emr_cmd = MC_CMD_GET_VERSION;
938 req.emr_in_buf = payload;
939 req.emr_in_length = MC_CMD_GET_VERSION_IN_LEN;
940 req.emr_out_buf = payload;
941 req.emr_out_length = MC_CMD_GET_VERSION_OUT_LEN;
943 efx_mcdi_execute(enp, &req);
945 if (req.emr_rc != 0) {
950 /* bootrom support */
951 if (req.emr_out_length_used == MC_CMD_GET_VERSION_V0_OUT_LEN) {
952 version[0] = version[1] = version[2] = version[3] = 0;
953 build = MCDI_OUT_DWORD(req, GET_VERSION_OUT_FIRMWARE);
958 if (req.emr_out_length_used < MC_CMD_GET_VERSION_OUT_LEN) {
963 ver_words = MCDI_OUT2(req, efx_word_t, GET_VERSION_OUT_VERSION);
964 version[0] = EFX_WORD_FIELD(ver_words[0], EFX_WORD_0);
965 version[1] = EFX_WORD_FIELD(ver_words[1], EFX_WORD_0);
966 version[2] = EFX_WORD_FIELD(ver_words[2], EFX_WORD_0);
967 version[3] = EFX_WORD_FIELD(ver_words[3], EFX_WORD_0);
968 build = MCDI_OUT_DWORD(req, GET_VERSION_OUT_FIRMWARE);
971 /* The bootrom doesn't understand BOOT_STATUS */
972 if (MC_FW_VERSION_IS_BOOTLOADER(build)) {
973 status = EFX_MCDI_BOOT_ROM;
977 (void) memset(payload, 0, sizeof (payload));
978 req.emr_cmd = MC_CMD_GET_BOOT_STATUS;
979 req.emr_in_buf = payload;
980 req.emr_in_length = MC_CMD_GET_BOOT_STATUS_IN_LEN;
981 req.emr_out_buf = payload;
982 req.emr_out_length = MC_CMD_GET_BOOT_STATUS_OUT_LEN;
984 efx_mcdi_execute_quiet(enp, &req);
986 if (req.emr_rc == EACCES) {
987 /* Unprivileged functions cannot access BOOT_STATUS */
988 status = EFX_MCDI_BOOT_PRIMARY;
989 version[0] = version[1] = version[2] = version[3] = 0;
994 if (req.emr_rc != 0) {
999 if (req.emr_out_length_used < MC_CMD_GET_BOOT_STATUS_OUT_LEN) {
1004 if (MCDI_OUT_DWORD_FIELD(req, GET_BOOT_STATUS_OUT_FLAGS,
1005 GET_BOOT_STATUS_OUT_FLAGS_PRIMARY))
1006 status = EFX_MCDI_BOOT_PRIMARY;
1008 status = EFX_MCDI_BOOT_SECONDARY;
1011 if (versionp != NULL)
1012 memcpy(versionp, version, sizeof (version));
1015 if (statusp != NULL)
1027 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1032 static __checkReturn efx_rc_t
1034 __in efx_nic_t *enp,
1035 __in boolean_t after_assertion)
1037 uint8_t payload[MAX(MC_CMD_REBOOT_IN_LEN, MC_CMD_REBOOT_OUT_LEN)];
1042 * We could require the caller to have caused en_mod_flags=0 to
1043 * call this function. This doesn't help the other port though,
1044 * who's about to get the MC ripped out from underneath them.
1045 * Since they have to cope with the subsequent fallout of MCDI
1046 * failures, we should as well.
1048 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
1050 (void) memset(payload, 0, sizeof (payload));
1051 req.emr_cmd = MC_CMD_REBOOT;
1052 req.emr_in_buf = payload;
1053 req.emr_in_length = MC_CMD_REBOOT_IN_LEN;
1054 req.emr_out_buf = payload;
1055 req.emr_out_length = MC_CMD_REBOOT_OUT_LEN;
1057 MCDI_IN_SET_DWORD(req, REBOOT_IN_FLAGS,
1058 (after_assertion ? MC_CMD_REBOOT_FLAGS_AFTER_ASSERTION : 0));
1060 efx_mcdi_execute_quiet(enp, &req);
1062 if (req.emr_rc == EACCES) {
1063 /* Unprivileged functions cannot reboot the MC. */
1067 /* A successful reboot request returns EIO. */
1068 if (req.emr_rc != 0 && req.emr_rc != EIO) {
1077 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1082 __checkReturn efx_rc_t
1084 __in efx_nic_t *enp)
1086 return (efx_mcdi_do_reboot(enp, B_FALSE));
1089 __checkReturn efx_rc_t
1090 efx_mcdi_exit_assertion_handler(
1091 __in efx_nic_t *enp)
1093 return (efx_mcdi_do_reboot(enp, B_TRUE));
1096 __checkReturn efx_rc_t
1097 efx_mcdi_read_assertion(
1098 __in efx_nic_t *enp)
1101 uint8_t payload[MAX(MC_CMD_GET_ASSERTS_IN_LEN,
1102 MC_CMD_GET_ASSERTS_OUT_LEN)];
1111 * Before we attempt to chat to the MC, we should verify that the MC
1112 * isn't in its assertion handler, either due to a previous reboot,
1113 * or because we're reinitializing due to an eec_exception().
1115 * Use GET_ASSERTS to read any assertion state that may be present.
1116 * Retry this command twice. Once because a boot-time assertion failure
1117 * might cause the 1st MCDI request to fail. And once again because
1118 * we might race with efx_mcdi_exit_assertion_handler() running on
1119 * partner port(s) on the same NIC.
1123 (void) memset(payload, 0, sizeof (payload));
1124 req.emr_cmd = MC_CMD_GET_ASSERTS;
1125 req.emr_in_buf = payload;
1126 req.emr_in_length = MC_CMD_GET_ASSERTS_IN_LEN;
1127 req.emr_out_buf = payload;
1128 req.emr_out_length = MC_CMD_GET_ASSERTS_OUT_LEN;
1130 MCDI_IN_SET_DWORD(req, GET_ASSERTS_IN_CLEAR, 1);
1131 efx_mcdi_execute_quiet(enp, &req);
1133 } while ((req.emr_rc == EINTR || req.emr_rc == EIO) && retry-- > 0);
1135 if (req.emr_rc != 0) {
1136 if (req.emr_rc == EACCES) {
1137 /* Unprivileged functions cannot clear assertions. */
1144 if (req.emr_out_length_used < MC_CMD_GET_ASSERTS_OUT_LEN) {
1149 /* Print out any assertion state recorded */
1150 flags = MCDI_OUT_DWORD(req, GET_ASSERTS_OUT_GLOBAL_FLAGS);
1151 if (flags == MC_CMD_GET_ASSERTS_FLAGS_NO_FAILS)
1154 reason = (flags == MC_CMD_GET_ASSERTS_FLAGS_SYS_FAIL)
1155 ? "system-level assertion"
1156 : (flags == MC_CMD_GET_ASSERTS_FLAGS_THR_FAIL)
1157 ? "thread-level assertion"
1158 : (flags == MC_CMD_GET_ASSERTS_FLAGS_WDOG_FIRED)
1160 : (flags == MC_CMD_GET_ASSERTS_FLAGS_ADDR_TRAP)
1161 ? "illegal address trap"
1162 : "unknown assertion";
1163 EFSYS_PROBE3(mcpu_assertion,
1164 const char *, reason, unsigned int,
1165 MCDI_OUT_DWORD(req, GET_ASSERTS_OUT_SAVED_PC_OFFS),
1167 MCDI_OUT_DWORD(req, GET_ASSERTS_OUT_THREAD_OFFS));
1169 /* Print out the registers (r1 ... r31) */
1170 ofst = MC_CMD_GET_ASSERTS_OUT_GP_REGS_OFFS_OFST;
1172 index < 1 + MC_CMD_GET_ASSERTS_OUT_GP_REGS_OFFS_NUM;
1174 EFSYS_PROBE2(mcpu_register, unsigned int, index, unsigned int,
1175 EFX_DWORD_FIELD(*MCDI_OUT(req, efx_dword_t, ofst),
1177 ofst += sizeof (efx_dword_t);
1179 EFSYS_ASSERT(ofst <= MC_CMD_GET_ASSERTS_OUT_LEN);
1187 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1194 * Internal routines for for specific MCDI requests.
1197 __checkReturn efx_rc_t
1198 efx_mcdi_drv_attach(
1199 __in efx_nic_t *enp,
1200 __in boolean_t attach)
1203 uint8_t payload[MAX(MC_CMD_DRV_ATTACH_IN_LEN,
1204 MC_CMD_DRV_ATTACH_EXT_OUT_LEN)];
1207 (void) memset(payload, 0, sizeof (payload));
1208 req.emr_cmd = MC_CMD_DRV_ATTACH;
1209 req.emr_in_buf = payload;
1210 req.emr_in_length = MC_CMD_DRV_ATTACH_IN_LEN;
1211 req.emr_out_buf = payload;
1212 req.emr_out_length = MC_CMD_DRV_ATTACH_EXT_OUT_LEN;
1215 * Use DONT_CARE for the datapath firmware type to ensure that the
1216 * driver can attach to an unprivileged function. The datapath firmware
1217 * type to use is controlled by the 'sfboot' utility.
1219 MCDI_IN_SET_DWORD(req, DRV_ATTACH_IN_NEW_STATE, attach ? 1 : 0);
1220 MCDI_IN_SET_DWORD(req, DRV_ATTACH_IN_UPDATE, 1);
1221 MCDI_IN_SET_DWORD(req, DRV_ATTACH_IN_FIRMWARE_ID, MC_CMD_FW_DONT_CARE);
1223 efx_mcdi_execute(enp, &req);
1225 if (req.emr_rc != 0) {
1230 if (req.emr_out_length_used < MC_CMD_DRV_ATTACH_OUT_LEN) {
1240 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1245 __checkReturn efx_rc_t
1246 efx_mcdi_get_board_cfg(
1247 __in efx_nic_t *enp,
1248 __out_opt uint32_t *board_typep,
1249 __out_opt efx_dword_t *capabilitiesp,
1250 __out_ecount_opt(6) uint8_t mac_addrp[6])
1252 efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
1254 uint8_t payload[MAX(MC_CMD_GET_BOARD_CFG_IN_LEN,
1255 MC_CMD_GET_BOARD_CFG_OUT_LENMIN)];
1258 (void) memset(payload, 0, sizeof (payload));
1259 req.emr_cmd = MC_CMD_GET_BOARD_CFG;
1260 req.emr_in_buf = payload;
1261 req.emr_in_length = MC_CMD_GET_BOARD_CFG_IN_LEN;
1262 req.emr_out_buf = payload;
1263 req.emr_out_length = MC_CMD_GET_BOARD_CFG_OUT_LENMIN;
1265 efx_mcdi_execute(enp, &req);
1267 if (req.emr_rc != 0) {
1272 if (req.emr_out_length_used < MC_CMD_GET_BOARD_CFG_OUT_LENMIN) {
1277 if (mac_addrp != NULL) {
1280 if (emip->emi_port == 1) {
1281 addrp = MCDI_OUT2(req, uint8_t,
1282 GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT0);
1283 } else if (emip->emi_port == 2) {
1284 addrp = MCDI_OUT2(req, uint8_t,
1285 GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT1);
1291 EFX_MAC_ADDR_COPY(mac_addrp, addrp);
1294 if (capabilitiesp != NULL) {
1295 if (emip->emi_port == 1) {
1296 *capabilitiesp = *MCDI_OUT2(req, efx_dword_t,
1297 GET_BOARD_CFG_OUT_CAPABILITIES_PORT0);
1298 } else if (emip->emi_port == 2) {
1299 *capabilitiesp = *MCDI_OUT2(req, efx_dword_t,
1300 GET_BOARD_CFG_OUT_CAPABILITIES_PORT1);
1307 if (board_typep != NULL) {
1308 *board_typep = MCDI_OUT_DWORD(req,
1309 GET_BOARD_CFG_OUT_BOARD_TYPE);
1321 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1326 __checkReturn efx_rc_t
1327 efx_mcdi_get_resource_limits(
1328 __in efx_nic_t *enp,
1329 __out_opt uint32_t *nevqp,
1330 __out_opt uint32_t *nrxqp,
1331 __out_opt uint32_t *ntxqp)
1334 uint8_t payload[MAX(MC_CMD_GET_RESOURCE_LIMITS_IN_LEN,
1335 MC_CMD_GET_RESOURCE_LIMITS_OUT_LEN)];
1338 (void) memset(payload, 0, sizeof (payload));
1339 req.emr_cmd = MC_CMD_GET_RESOURCE_LIMITS;
1340 req.emr_in_buf = payload;
1341 req.emr_in_length = MC_CMD_GET_RESOURCE_LIMITS_IN_LEN;
1342 req.emr_out_buf = payload;
1343 req.emr_out_length = MC_CMD_GET_RESOURCE_LIMITS_OUT_LEN;
1345 efx_mcdi_execute(enp, &req);
1347 if (req.emr_rc != 0) {
1352 if (req.emr_out_length_used < MC_CMD_GET_RESOURCE_LIMITS_OUT_LEN) {
1358 *nevqp = MCDI_OUT_DWORD(req, GET_RESOURCE_LIMITS_OUT_EVQ);
1360 *nrxqp = MCDI_OUT_DWORD(req, GET_RESOURCE_LIMITS_OUT_RXQ);
1362 *ntxqp = MCDI_OUT_DWORD(req, GET_RESOURCE_LIMITS_OUT_TXQ);
1369 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1374 __checkReturn efx_rc_t
1375 efx_mcdi_get_phy_cfg(
1376 __in efx_nic_t *enp)
1378 efx_port_t *epp = &(enp->en_port);
1379 efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
1381 uint8_t payload[MAX(MC_CMD_GET_PHY_CFG_IN_LEN,
1382 MC_CMD_GET_PHY_CFG_OUT_LEN)];
1385 (void) memset(payload, 0, sizeof (payload));
1386 req.emr_cmd = MC_CMD_GET_PHY_CFG;
1387 req.emr_in_buf = payload;
1388 req.emr_in_length = MC_CMD_GET_PHY_CFG_IN_LEN;
1389 req.emr_out_buf = payload;
1390 req.emr_out_length = MC_CMD_GET_PHY_CFG_OUT_LEN;
1392 efx_mcdi_execute(enp, &req);
1394 if (req.emr_rc != 0) {
1399 if (req.emr_out_length_used < MC_CMD_GET_PHY_CFG_OUT_LEN) {
1404 encp->enc_phy_type = MCDI_OUT_DWORD(req, GET_PHY_CFG_OUT_TYPE);
1406 (void) strncpy(encp->enc_phy_name,
1407 MCDI_OUT2(req, char, GET_PHY_CFG_OUT_NAME),
1408 MIN(sizeof (encp->enc_phy_name) - 1,
1409 MC_CMD_GET_PHY_CFG_OUT_NAME_LEN));
1410 #endif /* EFSYS_OPT_NAMES */
1411 (void) memset(encp->enc_phy_revision, 0,
1412 sizeof (encp->enc_phy_revision));
1413 memcpy(encp->enc_phy_revision,
1414 MCDI_OUT2(req, char, GET_PHY_CFG_OUT_REVISION),
1415 MIN(sizeof (encp->enc_phy_revision) - 1,
1416 MC_CMD_GET_PHY_CFG_OUT_REVISION_LEN));
1417 #if EFSYS_OPT_PHY_LED_CONTROL
1418 encp->enc_led_mask = ((1 << EFX_PHY_LED_DEFAULT) |
1419 (1 << EFX_PHY_LED_OFF) |
1420 (1 << EFX_PHY_LED_ON));
1421 #endif /* EFSYS_OPT_PHY_LED_CONTROL */
1423 /* Get the media type of the fixed port, if recognised. */
1424 EFX_STATIC_ASSERT(MC_CMD_MEDIA_XAUI == EFX_PHY_MEDIA_XAUI);
1425 EFX_STATIC_ASSERT(MC_CMD_MEDIA_CX4 == EFX_PHY_MEDIA_CX4);
1426 EFX_STATIC_ASSERT(MC_CMD_MEDIA_KX4 == EFX_PHY_MEDIA_KX4);
1427 EFX_STATIC_ASSERT(MC_CMD_MEDIA_XFP == EFX_PHY_MEDIA_XFP);
1428 EFX_STATIC_ASSERT(MC_CMD_MEDIA_SFP_PLUS == EFX_PHY_MEDIA_SFP_PLUS);
1429 EFX_STATIC_ASSERT(MC_CMD_MEDIA_BASE_T == EFX_PHY_MEDIA_BASE_T);
1430 EFX_STATIC_ASSERT(MC_CMD_MEDIA_QSFP_PLUS == EFX_PHY_MEDIA_QSFP_PLUS);
1431 epp->ep_fixed_port_type =
1432 MCDI_OUT_DWORD(req, GET_PHY_CFG_OUT_MEDIA_TYPE);
1433 if (epp->ep_fixed_port_type >= EFX_PHY_MEDIA_NTYPES)
1434 epp->ep_fixed_port_type = EFX_PHY_MEDIA_INVALID;
1436 epp->ep_phy_cap_mask =
1437 MCDI_OUT_DWORD(req, GET_PHY_CFG_OUT_SUPPORTED_CAP);
1438 #if EFSYS_OPT_PHY_FLAGS
1439 encp->enc_phy_flags_mask = MCDI_OUT_DWORD(req, GET_PHY_CFG_OUT_FLAGS);
1440 #endif /* EFSYS_OPT_PHY_FLAGS */
1442 encp->enc_port = (uint8_t)MCDI_OUT_DWORD(req, GET_PHY_CFG_OUT_PRT);
1444 /* Populate internal state */
1445 encp->enc_mcdi_mdio_channel =
1446 (uint8_t)MCDI_OUT_DWORD(req, GET_PHY_CFG_OUT_CHANNEL);
1448 #if EFSYS_OPT_PHY_STATS
1449 encp->enc_mcdi_phy_stat_mask =
1450 MCDI_OUT_DWORD(req, GET_PHY_CFG_OUT_STATS_MASK);
1451 #endif /* EFSYS_OPT_PHY_STATS */
1454 encp->enc_bist_mask = 0;
1455 if (MCDI_OUT_DWORD_FIELD(req, GET_PHY_CFG_OUT_FLAGS,
1456 GET_PHY_CFG_OUT_BIST_CABLE_SHORT))
1457 encp->enc_bist_mask |= (1 << EFX_BIST_TYPE_PHY_CABLE_SHORT);
1458 if (MCDI_OUT_DWORD_FIELD(req, GET_PHY_CFG_OUT_FLAGS,
1459 GET_PHY_CFG_OUT_BIST_CABLE_LONG))
1460 encp->enc_bist_mask |= (1 << EFX_BIST_TYPE_PHY_CABLE_LONG);
1461 if (MCDI_OUT_DWORD_FIELD(req, GET_PHY_CFG_OUT_FLAGS,
1462 GET_PHY_CFG_OUT_BIST))
1463 encp->enc_bist_mask |= (1 << EFX_BIST_TYPE_PHY_NORMAL);
1464 #endif /* EFSYS_OPT_BIST */
1471 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1476 __checkReturn efx_rc_t
1477 efx_mcdi_firmware_update_supported(
1478 __in efx_nic_t *enp,
1479 __out boolean_t *supportedp)
1481 const efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop;
1484 if (emcop != NULL) {
1485 if ((rc = emcop->emco_feature_supported(enp,
1486 EFX_MCDI_FEATURE_FW_UPDATE, supportedp)) != 0)
1489 /* Earlier devices always supported updates */
1490 *supportedp = B_TRUE;
1496 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1501 __checkReturn efx_rc_t
1502 efx_mcdi_macaddr_change_supported(
1503 __in efx_nic_t *enp,
1504 __out boolean_t *supportedp)
1506 const efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop;
1509 if (emcop != NULL) {
1510 if ((rc = emcop->emco_feature_supported(enp,
1511 EFX_MCDI_FEATURE_MACADDR_CHANGE, supportedp)) != 0)
1514 /* Earlier devices always supported MAC changes */
1515 *supportedp = B_TRUE;
1521 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1526 __checkReturn efx_rc_t
1527 efx_mcdi_link_control_supported(
1528 __in efx_nic_t *enp,
1529 __out boolean_t *supportedp)
1531 const efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop;
1534 if (emcop != NULL) {
1535 if ((rc = emcop->emco_feature_supported(enp,
1536 EFX_MCDI_FEATURE_LINK_CONTROL, supportedp)) != 0)
1539 /* Earlier devices always supported link control */
1540 *supportedp = B_TRUE;
1546 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1551 __checkReturn efx_rc_t
1552 efx_mcdi_mac_spoofing_supported(
1553 __in efx_nic_t *enp,
1554 __out boolean_t *supportedp)
1556 const efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop;
1559 if (emcop != NULL) {
1560 if ((rc = emcop->emco_feature_supported(enp,
1561 EFX_MCDI_FEATURE_MAC_SPOOFING, supportedp)) != 0)
1564 /* Earlier devices always supported MAC spoofing */
1565 *supportedp = B_TRUE;
1571 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1578 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
1580 * Enter bist offline mode. This is a fw mode which puts the NIC into a state
1581 * where memory BIST tests can be run and not much else can interfere or happen.
1582 * A reboot is required to exit this mode.
1584 __checkReturn efx_rc_t
1585 efx_mcdi_bist_enable_offline(
1586 __in efx_nic_t *enp)
1591 EFX_STATIC_ASSERT(MC_CMD_ENABLE_OFFLINE_BIST_IN_LEN == 0);
1592 EFX_STATIC_ASSERT(MC_CMD_ENABLE_OFFLINE_BIST_OUT_LEN == 0);
1594 req.emr_cmd = MC_CMD_ENABLE_OFFLINE_BIST;
1595 req.emr_in_buf = NULL;
1596 req.emr_in_length = 0;
1597 req.emr_out_buf = NULL;
1598 req.emr_out_length = 0;
1600 efx_mcdi_execute(enp, &req);
1602 if (req.emr_rc != 0) {
1610 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1614 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
1616 __checkReturn efx_rc_t
1617 efx_mcdi_bist_start(
1618 __in efx_nic_t *enp,
1619 __in efx_bist_type_t type)
1622 uint8_t payload[MAX(MC_CMD_START_BIST_IN_LEN,
1623 MC_CMD_START_BIST_OUT_LEN)];
1626 (void) memset(payload, 0, sizeof (payload));
1627 req.emr_cmd = MC_CMD_START_BIST;
1628 req.emr_in_buf = payload;
1629 req.emr_in_length = MC_CMD_START_BIST_IN_LEN;
1630 req.emr_out_buf = payload;
1631 req.emr_out_length = MC_CMD_START_BIST_OUT_LEN;
1634 case EFX_BIST_TYPE_PHY_NORMAL:
1635 MCDI_IN_SET_DWORD(req, START_BIST_IN_TYPE, MC_CMD_PHY_BIST);
1637 case EFX_BIST_TYPE_PHY_CABLE_SHORT:
1638 MCDI_IN_SET_DWORD(req, START_BIST_IN_TYPE,
1639 MC_CMD_PHY_BIST_CABLE_SHORT);
1641 case EFX_BIST_TYPE_PHY_CABLE_LONG:
1642 MCDI_IN_SET_DWORD(req, START_BIST_IN_TYPE,
1643 MC_CMD_PHY_BIST_CABLE_LONG);
1645 case EFX_BIST_TYPE_MC_MEM:
1646 MCDI_IN_SET_DWORD(req, START_BIST_IN_TYPE,
1647 MC_CMD_MC_MEM_BIST);
1649 case EFX_BIST_TYPE_SAT_MEM:
1650 MCDI_IN_SET_DWORD(req, START_BIST_IN_TYPE,
1651 MC_CMD_PORT_MEM_BIST);
1653 case EFX_BIST_TYPE_REG:
1654 MCDI_IN_SET_DWORD(req, START_BIST_IN_TYPE,
1661 efx_mcdi_execute(enp, &req);
1663 if (req.emr_rc != 0) {
1671 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1676 #endif /* EFSYS_OPT_BIST */
1679 /* Enable logging of some events (e.g. link state changes) */
1680 __checkReturn efx_rc_t
1682 __in efx_nic_t *enp)
1685 uint8_t payload[MAX(MC_CMD_LOG_CTRL_IN_LEN,
1686 MC_CMD_LOG_CTRL_OUT_LEN)];
1689 (void) memset(payload, 0, sizeof (payload));
1690 req.emr_cmd = MC_CMD_LOG_CTRL;
1691 req.emr_in_buf = payload;
1692 req.emr_in_length = MC_CMD_LOG_CTRL_IN_LEN;
1693 req.emr_out_buf = payload;
1694 req.emr_out_length = MC_CMD_LOG_CTRL_OUT_LEN;
1696 MCDI_IN_SET_DWORD(req, LOG_CTRL_IN_LOG_DEST,
1697 MC_CMD_LOG_CTRL_IN_LOG_DEST_EVQ);
1698 MCDI_IN_SET_DWORD(req, LOG_CTRL_IN_LOG_DEST_EVQ, 0);
1700 efx_mcdi_execute(enp, &req);
1702 if (req.emr_rc != 0) {
1710 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1716 #if EFSYS_OPT_MAC_STATS
1718 typedef enum efx_stats_action_e {
1721 EFX_STATS_ENABLE_NOEVENTS,
1722 EFX_STATS_ENABLE_EVENTS,
1724 } efx_stats_action_t;
1726 static __checkReturn efx_rc_t
1728 __in efx_nic_t *enp,
1729 __in_opt efsys_mem_t *esmp,
1730 __in efx_stats_action_t action,
1731 __in uint16_t period_ms)
1734 uint8_t payload[MAX(MC_CMD_MAC_STATS_IN_LEN,
1735 MC_CMD_MAC_STATS_OUT_DMA_LEN)];
1736 int clear = (action == EFX_STATS_CLEAR);
1737 int upload = (action == EFX_STATS_UPLOAD);
1738 int enable = (action == EFX_STATS_ENABLE_NOEVENTS);
1739 int events = (action == EFX_STATS_ENABLE_EVENTS);
1740 int disable = (action == EFX_STATS_DISABLE);
1743 (void) memset(payload, 0, sizeof (payload));
1744 req.emr_cmd = MC_CMD_MAC_STATS;
1745 req.emr_in_buf = payload;
1746 req.emr_in_length = MC_CMD_MAC_STATS_IN_LEN;
1747 req.emr_out_buf = payload;
1748 req.emr_out_length = MC_CMD_MAC_STATS_OUT_DMA_LEN;
1750 MCDI_IN_POPULATE_DWORD_6(req, MAC_STATS_IN_CMD,
1751 MAC_STATS_IN_DMA, upload,
1752 MAC_STATS_IN_CLEAR, clear,
1753 MAC_STATS_IN_PERIODIC_CHANGE, enable | events | disable,
1754 MAC_STATS_IN_PERIODIC_ENABLE, enable | events,
1755 MAC_STATS_IN_PERIODIC_NOEVENT, !events,
1756 MAC_STATS_IN_PERIOD_MS, (enable | events) ? period_ms : 0);
1759 int bytes = MC_CMD_MAC_NSTATS * sizeof (uint64_t);
1761 EFX_STATIC_ASSERT(MC_CMD_MAC_NSTATS * sizeof (uint64_t) <=
1762 EFX_MAC_STATS_SIZE);
1764 MCDI_IN_SET_DWORD(req, MAC_STATS_IN_DMA_ADDR_LO,
1765 EFSYS_MEM_ADDR(esmp) & 0xffffffff);
1766 MCDI_IN_SET_DWORD(req, MAC_STATS_IN_DMA_ADDR_HI,
1767 EFSYS_MEM_ADDR(esmp) >> 32);
1768 MCDI_IN_SET_DWORD(req, MAC_STATS_IN_DMA_LEN, bytes);
1770 EFSYS_ASSERT(!upload && !enable && !events);
1774 * NOTE: Do not use EVB_PORT_ID_ASSIGNED when disabling periodic stats,
1775 * as this may fail (and leave periodic DMA enabled) if the
1776 * vadapter has already been deleted.
1778 MCDI_IN_SET_DWORD(req, MAC_STATS_IN_PORT_ID,
1779 (disable ? EVB_PORT_ID_NULL : enp->en_vport_id));
1781 efx_mcdi_execute(enp, &req);
1783 if (req.emr_rc != 0) {
1784 /* EF10: Expect ENOENT if no DMA queues are initialised */
1785 if ((req.emr_rc != ENOENT) ||
1786 (enp->en_rx_qcount + enp->en_tx_qcount != 0)) {
1795 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1800 __checkReturn efx_rc_t
1801 efx_mcdi_mac_stats_clear(
1802 __in efx_nic_t *enp)
1806 if ((rc = efx_mcdi_mac_stats(enp, NULL, EFX_STATS_CLEAR, 0)) != 0)
1812 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1817 __checkReturn efx_rc_t
1818 efx_mcdi_mac_stats_upload(
1819 __in efx_nic_t *enp,
1820 __in efsys_mem_t *esmp)
1825 * The MC DMAs aggregate statistics for our convenience, so we can
1826 * avoid having to pull the statistics buffer into the cache to
1827 * maintain cumulative statistics.
1829 if ((rc = efx_mcdi_mac_stats(enp, esmp, EFX_STATS_UPLOAD, 0)) != 0)
1835 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1840 __checkReturn efx_rc_t
1841 efx_mcdi_mac_stats_periodic(
1842 __in efx_nic_t *enp,
1843 __in efsys_mem_t *esmp,
1844 __in uint16_t period_ms,
1845 __in boolean_t events)
1850 * The MC DMAs aggregate statistics for our convenience, so we can
1851 * avoid having to pull the statistics buffer into the cache to
1852 * maintain cumulative statistics.
1853 * Huntington uses a fixed 1sec period.
1854 * Medford uses a fixed 1sec period before v6.2.1.1033 firmware.
1857 rc = efx_mcdi_mac_stats(enp, NULL, EFX_STATS_DISABLE, 0);
1859 rc = efx_mcdi_mac_stats(enp, esmp, EFX_STATS_ENABLE_EVENTS,
1862 rc = efx_mcdi_mac_stats(enp, esmp, EFX_STATS_ENABLE_NOEVENTS,
1871 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1876 #endif /* EFSYS_OPT_MAC_STATS */
1878 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
1881 * This function returns the pf and vf number of a function. If it is a pf the
1882 * vf number is 0xffff. The vf number is the index of the vf on that
1883 * function. So if you have 3 vfs on pf 0 the 3 vfs will return (pf=0,vf=0),
1884 * (pf=0,vf=1), (pf=0,vf=2) aand the pf will return (pf=0, vf=0xffff).
1886 __checkReturn efx_rc_t
1887 efx_mcdi_get_function_info(
1888 __in efx_nic_t *enp,
1889 __out uint32_t *pfp,
1890 __out_opt uint32_t *vfp)
1893 uint8_t payload[MAX(MC_CMD_GET_FUNCTION_INFO_IN_LEN,
1894 MC_CMD_GET_FUNCTION_INFO_OUT_LEN)];
1897 (void) memset(payload, 0, sizeof (payload));
1898 req.emr_cmd = MC_CMD_GET_FUNCTION_INFO;
1899 req.emr_in_buf = payload;
1900 req.emr_in_length = MC_CMD_GET_FUNCTION_INFO_IN_LEN;
1901 req.emr_out_buf = payload;
1902 req.emr_out_length = MC_CMD_GET_FUNCTION_INFO_OUT_LEN;
1904 efx_mcdi_execute(enp, &req);
1906 if (req.emr_rc != 0) {
1911 if (req.emr_out_length_used < MC_CMD_GET_FUNCTION_INFO_OUT_LEN) {
1916 *pfp = MCDI_OUT_DWORD(req, GET_FUNCTION_INFO_OUT_PF);
1918 *vfp = MCDI_OUT_DWORD(req, GET_FUNCTION_INFO_OUT_VF);
1925 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1930 __checkReturn efx_rc_t
1931 efx_mcdi_privilege_mask(
1932 __in efx_nic_t *enp,
1935 __out uint32_t *maskp)
1938 uint8_t payload[MAX(MC_CMD_PRIVILEGE_MASK_IN_LEN,
1939 MC_CMD_PRIVILEGE_MASK_OUT_LEN)];
1942 (void) memset(payload, 0, sizeof (payload));
1943 req.emr_cmd = MC_CMD_PRIVILEGE_MASK;
1944 req.emr_in_buf = payload;
1945 req.emr_in_length = MC_CMD_PRIVILEGE_MASK_IN_LEN;
1946 req.emr_out_buf = payload;
1947 req.emr_out_length = MC_CMD_PRIVILEGE_MASK_OUT_LEN;
1949 MCDI_IN_POPULATE_DWORD_2(req, PRIVILEGE_MASK_IN_FUNCTION,
1950 PRIVILEGE_MASK_IN_FUNCTION_PF, pf,
1951 PRIVILEGE_MASK_IN_FUNCTION_VF, vf);
1953 efx_mcdi_execute(enp, &req);
1955 if (req.emr_rc != 0) {
1960 if (req.emr_out_length_used < MC_CMD_PRIVILEGE_MASK_OUT_LEN) {
1965 *maskp = MCDI_OUT_DWORD(req, PRIVILEGE_MASK_OUT_OLD_MASK);
1972 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1977 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
1979 __checkReturn efx_rc_t
1980 efx_mcdi_set_workaround(
1981 __in efx_nic_t *enp,
1983 __in boolean_t enabled,
1984 __out_opt uint32_t *flagsp)
1987 uint8_t payload[MAX(MC_CMD_WORKAROUND_IN_LEN,
1988 MC_CMD_WORKAROUND_EXT_OUT_LEN)];
1991 (void) memset(payload, 0, sizeof (payload));
1992 req.emr_cmd = MC_CMD_WORKAROUND;
1993 req.emr_in_buf = payload;
1994 req.emr_in_length = MC_CMD_WORKAROUND_IN_LEN;
1995 req.emr_out_buf = payload;
1996 req.emr_out_length = MC_CMD_WORKAROUND_OUT_LEN;
1998 MCDI_IN_SET_DWORD(req, WORKAROUND_IN_TYPE, type);
1999 MCDI_IN_SET_DWORD(req, WORKAROUND_IN_ENABLED, enabled ? 1 : 0);
2001 efx_mcdi_execute_quiet(enp, &req);
2003 if (req.emr_rc != 0) {
2008 if (flagsp != NULL) {
2009 if (req.emr_out_length_used >= MC_CMD_WORKAROUND_EXT_OUT_LEN)
2010 *flagsp = MCDI_OUT_DWORD(req, WORKAROUND_EXT_OUT_FLAGS);
2018 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2024 __checkReturn efx_rc_t
2025 efx_mcdi_get_workarounds(
2026 __in efx_nic_t *enp,
2027 __out_opt uint32_t *implementedp,
2028 __out_opt uint32_t *enabledp)
2031 uint8_t payload[MC_CMD_GET_WORKAROUNDS_OUT_LEN];
2034 (void) memset(payload, 0, sizeof (payload));
2035 req.emr_cmd = MC_CMD_GET_WORKAROUNDS;
2036 req.emr_in_buf = NULL;
2037 req.emr_in_length = 0;
2038 req.emr_out_buf = payload;
2039 req.emr_out_length = MC_CMD_GET_WORKAROUNDS_OUT_LEN;
2041 efx_mcdi_execute(enp, &req);
2043 if (req.emr_rc != 0) {
2048 if (implementedp != NULL) {
2050 MCDI_OUT_DWORD(req, GET_WORKAROUNDS_OUT_IMPLEMENTED);
2053 if (enabledp != NULL) {
2054 *enabledp = MCDI_OUT_DWORD(req, GET_WORKAROUNDS_OUT_ENABLED);
2060 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2066 * Size of media information page in accordance with SFF-8472 and SFF-8436.
2067 * It is used in MCDI interface as well.
2069 #define EFX_PHY_MEDIA_INFO_PAGE_SIZE 0x80
2071 static __checkReturn efx_rc_t
2072 efx_mcdi_get_phy_media_info(
2073 __in efx_nic_t *enp,
2074 __in uint32_t mcdi_page,
2075 __in uint8_t offset,
2077 __out_bcount(len) uint8_t *data)
2080 uint8_t payload[MAX(MC_CMD_GET_PHY_MEDIA_INFO_IN_LEN,
2081 MC_CMD_GET_PHY_MEDIA_INFO_OUT_LEN(
2082 EFX_PHY_MEDIA_INFO_PAGE_SIZE))];
2085 EFSYS_ASSERT((uint32_t)offset + len <= EFX_PHY_MEDIA_INFO_PAGE_SIZE);
2087 (void) memset(payload, 0, sizeof (payload));
2088 req.emr_cmd = MC_CMD_GET_PHY_MEDIA_INFO;
2089 req.emr_in_buf = payload;
2090 req.emr_in_length = MC_CMD_GET_PHY_MEDIA_INFO_IN_LEN;
2091 req.emr_out_buf = payload;
2092 req.emr_out_length =
2093 MC_CMD_GET_PHY_MEDIA_INFO_OUT_LEN(EFX_PHY_MEDIA_INFO_PAGE_SIZE);
2095 MCDI_IN_SET_DWORD(req, GET_PHY_MEDIA_INFO_IN_PAGE, mcdi_page);
2097 efx_mcdi_execute(enp, &req);
2099 if (req.emr_rc != 0) {
2104 if (req.emr_out_length_used !=
2105 MC_CMD_GET_PHY_MEDIA_INFO_OUT_LEN(EFX_PHY_MEDIA_INFO_PAGE_SIZE)) {
2110 if (MCDI_OUT_DWORD(req, GET_PHY_MEDIA_INFO_OUT_DATALEN) !=
2111 EFX_PHY_MEDIA_INFO_PAGE_SIZE) {
2117 MCDI_OUT2(req, uint8_t, GET_PHY_MEDIA_INFO_OUT_DATA) + offset,
2127 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2133 * 2-wire device address of the base information in accordance with SFF-8472
2134 * Diagnostic Monitoring Interface for Optical Transceivers section
2135 * 4 Memory Organization.
2137 #define EFX_PHY_MEDIA_INFO_DEV_ADDR_SFP_BASE 0xA0
2140 * 2-wire device address of the digital diagnostics monitoring interface
2141 * in accordance with SFF-8472 Diagnostic Monitoring Interface for Optical
2142 * Transceivers section 4 Memory Organization.
2144 #define EFX_PHY_MEDIA_INFO_DEV_ADDR_SFP_DDM 0xA2
2147 * Hard wired 2-wire device address for QSFP+ in accordance with SFF-8436
2148 * QSFP+ 10 Gbs 4X PLUGGABLE TRANSCEIVER section 7.4 Device Addressing and
2151 #define EFX_PHY_MEDIA_INFO_DEV_ADDR_QSFP 0xA0
2153 __checkReturn efx_rc_t
2154 efx_mcdi_phy_module_get_info(
2155 __in efx_nic_t *enp,
2156 __in uint8_t dev_addr,
2157 __in uint8_t offset,
2159 __out_bcount(len) uint8_t *data)
2161 efx_port_t *epp = &(enp->en_port);
2163 uint32_t mcdi_lower_page;
2164 uint32_t mcdi_upper_page;
2166 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
2169 * Map device address to MC_CMD_GET_PHY_MEDIA_INFO pages.
2170 * Offset plus length interface allows to access page 0 only.
2171 * I.e. non-zero upper pages are not accessible.
2172 * See SFF-8472 section 4 Memory Organization and SFF-8436 section 7.6
2173 * QSFP+ Memory Map for details on how information is structured
2176 switch (epp->ep_fixed_port_type) {
2177 case EFX_PHY_MEDIA_SFP_PLUS:
2179 * In accordance with SFF-8472 Diagnostic Monitoring
2180 * Interface for Optical Transceivers section 4 Memory
2181 * Organization two 2-wire addresses are defined.
2184 /* Base information */
2185 case EFX_PHY_MEDIA_INFO_DEV_ADDR_SFP_BASE:
2187 * MCDI page 0 should be used to access lower
2188 * page 0 (0x00 - 0x7f) at the device address 0xA0.
2190 mcdi_lower_page = 0;
2192 * MCDI page 1 should be used to access upper
2193 * page 0 (0x80 - 0xff) at the device address 0xA0.
2195 mcdi_upper_page = 1;
2198 case EFX_PHY_MEDIA_INFO_DEV_ADDR_SFP_DDM:
2200 * MCDI page 2 should be used to access lower
2201 * page 0 (0x00 - 0x7f) at the device address 0xA2.
2203 mcdi_lower_page = 2;
2205 * MCDI page 3 should be used to access upper
2206 * page 0 (0x80 - 0xff) at the device address 0xA2.
2208 mcdi_upper_page = 3;
2215 case EFX_PHY_MEDIA_QSFP_PLUS:
2217 case EFX_PHY_MEDIA_INFO_DEV_ADDR_QSFP:
2219 * MCDI page -1 should be used to access lower page 0
2222 mcdi_lower_page = (uint32_t)-1;
2224 * MCDI page 0 should be used to access upper page 0
2227 mcdi_upper_page = 0;
2239 if (offset < EFX_PHY_MEDIA_INFO_PAGE_SIZE) {
2241 MIN(len, EFX_PHY_MEDIA_INFO_PAGE_SIZE - offset);
2243 rc = efx_mcdi_get_phy_media_info(enp,
2244 mcdi_lower_page, offset, read_len, data);
2253 offset -= EFX_PHY_MEDIA_INFO_PAGE_SIZE;
2257 EFSYS_ASSERT3U(len, <=, EFX_PHY_MEDIA_INFO_PAGE_SIZE);
2258 EFSYS_ASSERT3U(offset, <, EFX_PHY_MEDIA_INFO_PAGE_SIZE);
2260 rc = efx_mcdi_get_phy_media_info(enp,
2261 mcdi_upper_page, offset, len, data);
2273 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2278 #endif /* EFSYS_OPT_MCDI */