1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright (c) 2008-2018 Solarflare Communications Inc.
13 * There are three versions of the MCDI interface:
14 * - MCDIv0: Siena BootROM. Transport uses MCDIv1 headers.
15 * - MCDIv1: Siena firmware and Huntington BootROM.
16 * - MCDIv2: EF10 firmware (Huntington/Medford) and Medford BootROM.
17 * Transport uses MCDIv2 headers.
19 * MCDIv2 Header NOT_EPOCH flag
20 * ----------------------------
21 * A new epoch begins at initial startup or after an MC reboot, and defines when
22 * the MC should reject stale MCDI requests.
24 * The first MCDI request sent by the host should contain NOT_EPOCH=0, and all
25 * subsequent requests (until the next MC reboot) should contain NOT_EPOCH=1.
27 * After rebooting the MC will fail all requests with NOT_EPOCH=1 by writing a
28 * response with ERROR=1 and DATALEN=0 until a request is seen with NOT_EPOCH=0.
35 static const efx_mcdi_ops_t __efx_mcdi_siena_ops = {
36 siena_mcdi_init, /* emco_init */
37 siena_mcdi_send_request, /* emco_send_request */
38 siena_mcdi_poll_reboot, /* emco_poll_reboot */
39 siena_mcdi_poll_response, /* emco_poll_response */
40 siena_mcdi_read_response, /* emco_read_response */
41 siena_mcdi_fini, /* emco_fini */
42 siena_mcdi_feature_supported, /* emco_feature_supported */
43 siena_mcdi_get_timeout, /* emco_get_timeout */
46 #endif /* EFSYS_OPT_SIENA */
48 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
50 static const efx_mcdi_ops_t __efx_mcdi_ef10_ops = {
51 ef10_mcdi_init, /* emco_init */
52 ef10_mcdi_send_request, /* emco_send_request */
53 ef10_mcdi_poll_reboot, /* emco_poll_reboot */
54 ef10_mcdi_poll_response, /* emco_poll_response */
55 ef10_mcdi_read_response, /* emco_read_response */
56 ef10_mcdi_fini, /* emco_fini */
57 ef10_mcdi_feature_supported, /* emco_feature_supported */
58 ef10_mcdi_get_timeout, /* emco_get_timeout */
61 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
65 __checkReturn efx_rc_t
68 __in const efx_mcdi_transport_t *emtp)
70 const efx_mcdi_ops_t *emcop;
73 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
74 EFSYS_ASSERT3U(enp->en_mod_flags, ==, 0);
76 switch (enp->en_family) {
78 case EFX_FAMILY_SIENA:
79 emcop = &__efx_mcdi_siena_ops;
81 #endif /* EFSYS_OPT_SIENA */
83 #if EFSYS_OPT_HUNTINGTON
84 case EFX_FAMILY_HUNTINGTON:
85 emcop = &__efx_mcdi_ef10_ops;
87 #endif /* EFSYS_OPT_HUNTINGTON */
90 case EFX_FAMILY_MEDFORD:
91 emcop = &__efx_mcdi_ef10_ops;
93 #endif /* EFSYS_OPT_MEDFORD */
95 #if EFSYS_OPT_MEDFORD2
96 case EFX_FAMILY_MEDFORD2:
97 emcop = &__efx_mcdi_ef10_ops;
99 #endif /* EFSYS_OPT_MEDFORD2 */
107 if (enp->en_features & EFX_FEATURE_MCDI_DMA) {
108 /* MCDI requires a DMA buffer in host memory */
109 if ((emtp == NULL) || (emtp->emt_dma_mem) == NULL) {
114 enp->en_mcdi.em_emtp = emtp;
116 if (emcop != NULL && emcop->emco_init != NULL) {
117 if ((rc = emcop->emco_init(enp, emtp)) != 0)
121 enp->en_mcdi.em_emcop = emcop;
122 enp->en_mod_flags |= EFX_MOD_MCDI;
131 EFSYS_PROBE1(fail1, efx_rc_t, rc);
133 enp->en_mcdi.em_emcop = NULL;
134 enp->en_mcdi.em_emtp = NULL;
135 enp->en_mod_flags &= ~EFX_MOD_MCDI;
144 efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
145 const efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop;
147 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
148 EFSYS_ASSERT3U(enp->en_mod_flags, ==, EFX_MOD_MCDI);
150 if (emcop != NULL && emcop->emco_fini != NULL)
151 emcop->emco_fini(enp);
154 emip->emi_aborted = 0;
156 enp->en_mcdi.em_emcop = NULL;
157 enp->en_mod_flags &= ~EFX_MOD_MCDI;
164 efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
165 efsys_lock_state_t state;
167 /* Start a new epoch (allow fresh MCDI requests to succeed) */
168 EFSYS_LOCK(enp->en_eslp, state);
169 emip->emi_new_epoch = B_TRUE;
170 EFSYS_UNLOCK(enp->en_eslp, state);
174 efx_mcdi_send_request(
181 const efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop;
183 emcop->emco_send_request(enp, hdrp, hdr_len, sdup, sdu_len);
187 efx_mcdi_poll_reboot(
190 const efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop;
193 rc = emcop->emco_poll_reboot(enp);
198 efx_mcdi_poll_response(
201 const efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop;
204 available = emcop->emco_poll_response(enp);
209 efx_mcdi_read_response(
215 const efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop;
217 emcop->emco_read_response(enp, bufferp, offset, length);
221 efx_mcdi_request_start(
223 __in efx_mcdi_req_t *emrp,
224 __in boolean_t ev_cpl)
226 #if EFSYS_OPT_MCDI_LOGGING
227 const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
229 efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
232 unsigned int max_version;
236 efsys_lock_state_t state;
238 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
239 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MCDI);
240 EFSYS_ASSERT3U(enp->en_features, &, EFX_FEATURE_MCDI);
243 * efx_mcdi_request_start() is naturally serialised against both
244 * efx_mcdi_request_poll() and efx_mcdi_ev_cpl()/efx_mcdi_ev_death(),
245 * by virtue of there only being one outstanding MCDI request.
246 * Unfortunately, upper layers may also call efx_mcdi_request_abort()
247 * at any time, to timeout a pending mcdi request, That request may
248 * then subsequently complete, meaning efx_mcdi_ev_cpl() or
249 * efx_mcdi_ev_death() may end up running in parallel with
250 * efx_mcdi_request_start(). This race is handled by ensuring that
251 * %emi_pending_req, %emi_ev_cpl and %emi_seq are protected by the
254 EFSYS_LOCK(enp->en_eslp, state);
255 EFSYS_ASSERT(emip->emi_pending_req == NULL);
256 emip->emi_pending_req = emrp;
257 emip->emi_ev_cpl = ev_cpl;
258 emip->emi_poll_cnt = 0;
259 seq = emip->emi_seq++ & EFX_MASK32(MCDI_HEADER_SEQ);
260 new_epoch = emip->emi_new_epoch;
261 max_version = emip->emi_max_version;
262 EFSYS_UNLOCK(enp->en_eslp, state);
266 xflags |= MCDI_HEADER_XFLAGS_EVREQ;
269 * Huntington firmware supports MCDIv2, but the Huntington BootROM only
270 * supports MCDIv1. Use MCDIv1 headers for MCDIv1 commands where
271 * possible to support this.
273 if ((max_version >= 2) &&
274 ((emrp->emr_cmd > MC_CMD_CMD_SPACE_ESCAPE_7) ||
275 (emrp->emr_in_length > MCDI_CTL_SDU_LEN_MAX_V1) ||
276 (emrp->emr_out_length > MCDI_CTL_SDU_LEN_MAX_V1))) {
277 /* Construct MCDI v2 header */
278 hdr_len = sizeof (hdr);
279 EFX_POPULATE_DWORD_8(hdr[0],
280 MCDI_HEADER_CODE, MC_CMD_V2_EXTN,
281 MCDI_HEADER_RESYNC, 1,
282 MCDI_HEADER_DATALEN, 0,
283 MCDI_HEADER_SEQ, seq,
284 MCDI_HEADER_NOT_EPOCH, new_epoch ? 0 : 1,
285 MCDI_HEADER_ERROR, 0,
286 MCDI_HEADER_RESPONSE, 0,
287 MCDI_HEADER_XFLAGS, xflags);
289 EFX_POPULATE_DWORD_2(hdr[1],
290 MC_CMD_V2_EXTN_IN_EXTENDED_CMD, emrp->emr_cmd,
291 MC_CMD_V2_EXTN_IN_ACTUAL_LEN, emrp->emr_in_length);
293 /* Construct MCDI v1 header */
294 hdr_len = sizeof (hdr[0]);
295 EFX_POPULATE_DWORD_8(hdr[0],
296 MCDI_HEADER_CODE, emrp->emr_cmd,
297 MCDI_HEADER_RESYNC, 1,
298 MCDI_HEADER_DATALEN, emrp->emr_in_length,
299 MCDI_HEADER_SEQ, seq,
300 MCDI_HEADER_NOT_EPOCH, new_epoch ? 0 : 1,
301 MCDI_HEADER_ERROR, 0,
302 MCDI_HEADER_RESPONSE, 0,
303 MCDI_HEADER_XFLAGS, xflags);
306 #if EFSYS_OPT_MCDI_LOGGING
307 if (emtp->emt_logger != NULL) {
308 emtp->emt_logger(emtp->emt_context, EFX_LOG_MCDI_REQUEST,
310 emrp->emr_in_buf, emrp->emr_in_length);
312 #endif /* EFSYS_OPT_MCDI_LOGGING */
314 efx_mcdi_send_request(enp, &hdr[0], hdr_len,
315 emrp->emr_in_buf, emrp->emr_in_length);
320 efx_mcdi_read_response_header(
322 __inout efx_mcdi_req_t *emrp)
324 #if EFSYS_OPT_MCDI_LOGGING
325 const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
326 #endif /* EFSYS_OPT_MCDI_LOGGING */
327 efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
329 unsigned int hdr_len;
330 unsigned int data_len;
336 EFSYS_ASSERT(emrp != NULL);
338 efx_mcdi_read_response(enp, &hdr[0], 0, sizeof (hdr[0]));
339 hdr_len = sizeof (hdr[0]);
341 cmd = EFX_DWORD_FIELD(hdr[0], MCDI_HEADER_CODE);
342 seq = EFX_DWORD_FIELD(hdr[0], MCDI_HEADER_SEQ);
343 error = EFX_DWORD_FIELD(hdr[0], MCDI_HEADER_ERROR);
345 if (cmd != MC_CMD_V2_EXTN) {
346 data_len = EFX_DWORD_FIELD(hdr[0], MCDI_HEADER_DATALEN);
348 efx_mcdi_read_response(enp, &hdr[1], hdr_len, sizeof (hdr[1]));
349 hdr_len += sizeof (hdr[1]);
351 cmd = EFX_DWORD_FIELD(hdr[1], MC_CMD_V2_EXTN_IN_EXTENDED_CMD);
353 EFX_DWORD_FIELD(hdr[1], MC_CMD_V2_EXTN_IN_ACTUAL_LEN);
356 if (error && (data_len == 0)) {
357 /* The MC has rebooted since the request was sent. */
358 EFSYS_SPIN(EFX_MCDI_STATUS_SLEEP_US);
359 efx_mcdi_poll_reboot(enp);
363 if ((cmd != emrp->emr_cmd) ||
364 (seq != ((emip->emi_seq - 1) & EFX_MASK32(MCDI_HEADER_SEQ)))) {
365 /* Response is for a different request */
371 unsigned int err_len = MIN(data_len, sizeof (err));
372 int err_code = MC_CMD_ERR_EPROTO;
375 /* Read error code (and arg num for MCDI v2 commands) */
376 efx_mcdi_read_response(enp, &err, hdr_len, err_len);
378 if (err_len >= (MC_CMD_ERR_CODE_OFST + sizeof (efx_dword_t)))
379 err_code = EFX_DWORD_FIELD(err[0], EFX_DWORD_0);
381 if (err_len >= (MC_CMD_ERR_ARG_OFST + sizeof (efx_dword_t)))
382 err_arg = EFX_DWORD_FIELD(err[1], EFX_DWORD_0);
384 emrp->emr_err_code = err_code;
385 emrp->emr_err_arg = err_arg;
387 #if EFSYS_OPT_MCDI_PROXY_AUTH
388 if ((err_code == MC_CMD_ERR_PROXY_PENDING) &&
389 (err_len == sizeof (err))) {
391 * The MCDI request would normally fail with EPERM, but
392 * firmware has forwarded it to an authorization agent
393 * attached to a privileged PF.
395 * Save the authorization request handle. The client
396 * must wait for a PROXY_RESPONSE event, or timeout.
398 emrp->emr_proxy_handle = err_arg;
400 #endif /* EFSYS_OPT_MCDI_PROXY_AUTH */
402 #if EFSYS_OPT_MCDI_LOGGING
403 if (emtp->emt_logger != NULL) {
404 emtp->emt_logger(emtp->emt_context,
405 EFX_LOG_MCDI_RESPONSE,
409 #endif /* EFSYS_OPT_MCDI_LOGGING */
411 if (!emrp->emr_quiet) {
412 EFSYS_PROBE3(mcdi_err_arg, int, emrp->emr_cmd,
413 int, err_code, int, err_arg);
416 rc = efx_mcdi_request_errcode(err_code);
421 emrp->emr_out_length_used = data_len;
422 #if EFSYS_OPT_MCDI_PROXY_AUTH
423 emrp->emr_proxy_handle = 0;
424 #endif /* EFSYS_OPT_MCDI_PROXY_AUTH */
431 emrp->emr_out_length_used = 0;
435 efx_mcdi_finish_response(
437 __in efx_mcdi_req_t *emrp)
439 #if EFSYS_OPT_MCDI_LOGGING
440 const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
441 #endif /* EFSYS_OPT_MCDI_LOGGING */
443 unsigned int hdr_len;
446 if (emrp->emr_out_buf == NULL)
449 /* Read the command header to detect MCDI response format */
450 hdr_len = sizeof (hdr[0]);
451 efx_mcdi_read_response(enp, &hdr[0], 0, hdr_len);
452 if (EFX_DWORD_FIELD(hdr[0], MCDI_HEADER_CODE) == MC_CMD_V2_EXTN) {
454 * Read the actual payload length. The length given in the event
455 * is only correct for responses with the V1 format.
457 efx_mcdi_read_response(enp, &hdr[1], hdr_len, sizeof (hdr[1]));
458 hdr_len += sizeof (hdr[1]);
460 emrp->emr_out_length_used = EFX_DWORD_FIELD(hdr[1],
461 MC_CMD_V2_EXTN_IN_ACTUAL_LEN);
464 /* Copy payload out into caller supplied buffer */
465 bytes = MIN(emrp->emr_out_length_used, emrp->emr_out_length);
466 efx_mcdi_read_response(enp, emrp->emr_out_buf, hdr_len, bytes);
468 #if EFSYS_OPT_MCDI_LOGGING
469 if (emtp->emt_logger != NULL) {
470 emtp->emt_logger(emtp->emt_context,
471 EFX_LOG_MCDI_RESPONSE,
473 emrp->emr_out_buf, bytes);
475 #endif /* EFSYS_OPT_MCDI_LOGGING */
479 __checkReturn boolean_t
480 efx_mcdi_request_poll(
483 efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
484 efx_mcdi_req_t *emrp;
485 efsys_lock_state_t state;
488 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
489 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MCDI);
490 EFSYS_ASSERT3U(enp->en_features, &, EFX_FEATURE_MCDI);
492 /* Serialise against post-watchdog efx_mcdi_ev* */
493 EFSYS_LOCK(enp->en_eslp, state);
495 EFSYS_ASSERT(emip->emi_pending_req != NULL);
496 EFSYS_ASSERT(!emip->emi_ev_cpl);
497 emrp = emip->emi_pending_req;
499 /* Check if hardware is unavailable */
500 if (efx_nic_hw_unavailable(enp)) {
501 EFSYS_UNLOCK(enp->en_eslp, state);
505 /* Check for reboot atomically w.r.t efx_mcdi_request_start */
506 if (emip->emi_poll_cnt++ == 0) {
507 if ((rc = efx_mcdi_poll_reboot(enp)) != 0) {
508 emip->emi_pending_req = NULL;
509 EFSYS_UNLOCK(enp->en_eslp, state);
511 /* Reboot/Assertion */
512 if (rc == EIO || rc == EINTR)
513 efx_mcdi_raise_exception(enp, emrp, rc);
519 /* Check if a response is available */
520 if (efx_mcdi_poll_response(enp) == B_FALSE) {
521 EFSYS_UNLOCK(enp->en_eslp, state);
525 /* Read the response header */
526 efx_mcdi_read_response_header(enp, emrp);
528 /* Request complete */
529 emip->emi_pending_req = NULL;
531 /* Ensure stale MCDI requests fail after an MC reboot. */
532 emip->emi_new_epoch = B_FALSE;
534 EFSYS_UNLOCK(enp->en_eslp, state);
536 if ((rc = emrp->emr_rc) != 0)
539 efx_mcdi_finish_response(enp, emrp);
543 if (!emrp->emr_quiet)
546 if (!emrp->emr_quiet)
547 EFSYS_PROBE1(fail1, efx_rc_t, rc);
552 __checkReturn boolean_t
553 efx_mcdi_request_abort(
556 efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
557 efx_mcdi_req_t *emrp;
559 efsys_lock_state_t state;
561 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
562 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MCDI);
563 EFSYS_ASSERT3U(enp->en_features, &, EFX_FEATURE_MCDI);
566 * efx_mcdi_ev_* may have already completed this event, and be
567 * spinning/blocked on the upper layer lock. So it *is* legitimate
568 * to for emi_pending_req to be NULL. If there is a pending event
569 * completed request, then provide a "credit" to allow
570 * efx_mcdi_ev_cpl() to accept a single spurious completion.
572 EFSYS_LOCK(enp->en_eslp, state);
573 emrp = emip->emi_pending_req;
574 aborted = (emrp != NULL);
576 emip->emi_pending_req = NULL;
578 /* Error the request */
579 emrp->emr_out_length_used = 0;
580 emrp->emr_rc = ETIMEDOUT;
582 /* Provide a credit for seqno/emr_pending_req mismatches */
583 if (emip->emi_ev_cpl)
587 * The upper layer has called us, so we don't
588 * need to complete the request.
591 EFSYS_UNLOCK(enp->en_eslp, state);
597 efx_mcdi_get_timeout(
599 __in efx_mcdi_req_t *emrp,
600 __out uint32_t *timeoutp)
602 const efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop;
604 emcop->emco_get_timeout(enp, emrp, timeoutp);
607 __checkReturn efx_rc_t
608 efx_mcdi_request_errcode(
609 __in unsigned int err)
614 case MC_CMD_ERR_EPERM:
616 case MC_CMD_ERR_ENOENT:
618 case MC_CMD_ERR_EINTR:
620 case MC_CMD_ERR_EACCES:
622 case MC_CMD_ERR_EBUSY:
624 case MC_CMD_ERR_EINVAL:
626 case MC_CMD_ERR_EDEADLK:
628 case MC_CMD_ERR_ENOSYS:
630 case MC_CMD_ERR_ETIME:
632 case MC_CMD_ERR_ENOTSUP:
634 case MC_CMD_ERR_EALREADY:
638 case MC_CMD_ERR_EEXIST:
640 #ifdef MC_CMD_ERR_EAGAIN
641 case MC_CMD_ERR_EAGAIN:
644 #ifdef MC_CMD_ERR_ENOSPC
645 case MC_CMD_ERR_ENOSPC:
648 case MC_CMD_ERR_ERANGE:
651 case MC_CMD_ERR_ALLOC_FAIL:
653 case MC_CMD_ERR_NO_VADAPTOR:
655 case MC_CMD_ERR_NO_EVB_PORT:
657 case MC_CMD_ERR_NO_VSWITCH:
659 case MC_CMD_ERR_VLAN_LIMIT:
661 case MC_CMD_ERR_BAD_PCI_FUNC:
663 case MC_CMD_ERR_BAD_VLAN_MODE:
665 case MC_CMD_ERR_BAD_VSWITCH_TYPE:
667 case MC_CMD_ERR_BAD_VPORT_TYPE:
669 case MC_CMD_ERR_MAC_EXIST:
672 case MC_CMD_ERR_PROXY_PENDING:
676 EFSYS_PROBE1(mc_pcol_error, int, err);
682 efx_mcdi_raise_exception(
684 __in_opt efx_mcdi_req_t *emrp,
687 const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
688 efx_mcdi_exception_t exception;
690 /* Reboot or Assertion failure only */
691 EFSYS_ASSERT(rc == EIO || rc == EINTR);
694 * If MC_CMD_REBOOT causes a reboot (dependent on parameters),
695 * then the EIO is not worthy of an exception.
697 if (emrp != NULL && emrp->emr_cmd == MC_CMD_REBOOT && rc == EIO)
700 exception = (rc == EIO)
701 ? EFX_MCDI_EXCEPTION_MC_REBOOT
702 : EFX_MCDI_EXCEPTION_MC_BADASSERT;
704 emtp->emt_exception(emtp->emt_context, exception);
710 __inout efx_mcdi_req_t *emrp)
712 const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
714 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MCDI);
715 EFSYS_ASSERT3U(enp->en_features, &, EFX_FEATURE_MCDI);
717 emrp->emr_quiet = B_FALSE;
718 emtp->emt_execute(emtp->emt_context, emrp);
722 efx_mcdi_execute_quiet(
724 __inout efx_mcdi_req_t *emrp)
726 const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
728 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MCDI);
729 EFSYS_ASSERT3U(enp->en_features, &, EFX_FEATURE_MCDI);
731 emrp->emr_quiet = B_TRUE;
732 emtp->emt_execute(emtp->emt_context, emrp);
738 __in unsigned int seq,
739 __in unsigned int outlen,
742 efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
743 const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
744 efx_mcdi_req_t *emrp;
745 efsys_lock_state_t state;
747 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MCDI);
748 EFSYS_ASSERT3U(enp->en_features, &, EFX_FEATURE_MCDI);
751 * Serialise against efx_mcdi_request_poll()/efx_mcdi_request_start()
752 * when we're completing an aborted request.
754 EFSYS_LOCK(enp->en_eslp, state);
755 if (emip->emi_pending_req == NULL || !emip->emi_ev_cpl ||
756 (seq != ((emip->emi_seq - 1) & EFX_MASK32(MCDI_HEADER_SEQ)))) {
757 EFSYS_ASSERT(emip->emi_aborted > 0);
758 if (emip->emi_aborted > 0)
760 EFSYS_UNLOCK(enp->en_eslp, state);
764 emrp = emip->emi_pending_req;
765 emip->emi_pending_req = NULL;
766 EFSYS_UNLOCK(enp->en_eslp, state);
768 if (emip->emi_max_version >= 2) {
769 /* MCDIv2 response details do not fit into an event. */
770 efx_mcdi_read_response_header(enp, emrp);
773 if (!emrp->emr_quiet) {
774 EFSYS_PROBE2(mcdi_err, int, emrp->emr_cmd,
777 emrp->emr_out_length_used = 0;
778 emrp->emr_rc = efx_mcdi_request_errcode(errcode);
780 emrp->emr_out_length_used = outlen;
784 if (emrp->emr_rc == 0)
785 efx_mcdi_finish_response(enp, emrp);
787 emtp->emt_ev_cpl(emtp->emt_context);
790 #if EFSYS_OPT_MCDI_PROXY_AUTH
792 __checkReturn efx_rc_t
793 efx_mcdi_get_proxy_handle(
795 __in efx_mcdi_req_t *emrp,
796 __out uint32_t *handlep)
800 _NOTE(ARGUNUSED(enp))
803 * Return proxy handle from MCDI request that returned with error
804 * MC_MCD_ERR_PROXY_PENDING. This handle is used to wait for a matching
805 * PROXY_RESPONSE event.
807 if ((emrp == NULL) || (handlep == NULL)) {
811 if ((emrp->emr_rc != 0) &&
812 (emrp->emr_err_code == MC_CMD_ERR_PROXY_PENDING)) {
813 *handlep = emrp->emr_proxy_handle;
822 EFSYS_PROBE1(fail1, efx_rc_t, rc);
827 efx_mcdi_ev_proxy_response(
829 __in unsigned int handle,
830 __in unsigned int status)
832 const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
836 * Handle results of an authorization request for a privileged MCDI
837 * command. If authorization was granted then we must re-issue the
838 * original MCDI request. If authorization failed or timed out,
839 * then the original MCDI request should be completed with the
840 * result code from this event.
842 rc = (status == 0) ? 0 : efx_mcdi_request_errcode(status);
844 emtp->emt_ev_proxy_response(emtp->emt_context, handle, rc);
846 #endif /* EFSYS_OPT_MCDI_PROXY_AUTH */
853 efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
854 const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp;
855 efx_mcdi_req_t *emrp = NULL;
857 efsys_lock_state_t state;
860 * The MCDI request (if there is one) has been terminated, either
861 * by a BADASSERT or REBOOT event.
863 * If there is an outstanding event-completed MCDI operation, then we
864 * will never receive the completion event (because both MCDI
865 * completions and BADASSERT events are sent to the same evq). So
866 * complete this MCDI op.
868 * This function might run in parallel with efx_mcdi_request_poll()
869 * for poll completed mcdi requests, and also with
870 * efx_mcdi_request_start() for post-watchdog completions.
872 EFSYS_LOCK(enp->en_eslp, state);
873 emrp = emip->emi_pending_req;
874 ev_cpl = emip->emi_ev_cpl;
875 if (emrp != NULL && emip->emi_ev_cpl) {
876 emip->emi_pending_req = NULL;
878 emrp->emr_out_length_used = 0;
884 * Since we're running in parallel with a request, consume the
885 * status word before dropping the lock.
887 if (rc == EIO || rc == EINTR) {
888 EFSYS_SPIN(EFX_MCDI_STATUS_SLEEP_US);
889 (void) efx_mcdi_poll_reboot(enp);
890 emip->emi_new_epoch = B_TRUE;
893 EFSYS_UNLOCK(enp->en_eslp, state);
895 efx_mcdi_raise_exception(enp, emrp, rc);
897 if (emrp != NULL && ev_cpl)
898 emtp->emt_ev_cpl(emtp->emt_context);
901 __checkReturn efx_rc_t
904 __out_ecount_opt(4) uint16_t versionp[4],
905 __out_opt uint32_t *buildp,
906 __out_opt efx_mcdi_boot_t *statusp)
909 EFX_MCDI_DECLARE_BUF(payload,
910 MAX(MC_CMD_GET_VERSION_IN_LEN, MC_CMD_GET_BOOT_STATUS_IN_LEN),
911 MAX(MC_CMD_GET_VERSION_OUT_LEN,
912 MC_CMD_GET_BOOT_STATUS_OUT_LEN));
913 efx_word_t *ver_words;
916 efx_mcdi_boot_t status;
919 EFSYS_ASSERT3U(enp->en_features, &, EFX_FEATURE_MCDI);
921 req.emr_cmd = MC_CMD_GET_VERSION;
922 req.emr_in_buf = payload;
923 req.emr_in_length = MC_CMD_GET_VERSION_IN_LEN;
924 req.emr_out_buf = payload;
925 req.emr_out_length = MC_CMD_GET_VERSION_OUT_LEN;
927 efx_mcdi_execute(enp, &req);
929 if (req.emr_rc != 0) {
934 /* bootrom support */
935 if (req.emr_out_length_used == MC_CMD_GET_VERSION_V0_OUT_LEN) {
936 version[0] = version[1] = version[2] = version[3] = 0;
937 build = MCDI_OUT_DWORD(req, GET_VERSION_OUT_FIRMWARE);
942 if (req.emr_out_length_used < MC_CMD_GET_VERSION_OUT_LEN) {
947 ver_words = MCDI_OUT2(req, efx_word_t, GET_VERSION_OUT_VERSION);
948 version[0] = EFX_WORD_FIELD(ver_words[0], EFX_WORD_0);
949 version[1] = EFX_WORD_FIELD(ver_words[1], EFX_WORD_0);
950 version[2] = EFX_WORD_FIELD(ver_words[2], EFX_WORD_0);
951 version[3] = EFX_WORD_FIELD(ver_words[3], EFX_WORD_0);
952 build = MCDI_OUT_DWORD(req, GET_VERSION_OUT_FIRMWARE);
955 /* The bootrom doesn't understand BOOT_STATUS */
956 if (MC_FW_VERSION_IS_BOOTLOADER(build)) {
957 status = EFX_MCDI_BOOT_ROM;
961 (void) memset(payload, 0, sizeof (payload));
962 req.emr_cmd = MC_CMD_GET_BOOT_STATUS;
963 req.emr_in_buf = payload;
964 req.emr_in_length = MC_CMD_GET_BOOT_STATUS_IN_LEN;
965 req.emr_out_buf = payload;
966 req.emr_out_length = MC_CMD_GET_BOOT_STATUS_OUT_LEN;
968 efx_mcdi_execute_quiet(enp, &req);
970 if (req.emr_rc == EACCES) {
971 /* Unprivileged functions cannot access BOOT_STATUS */
972 status = EFX_MCDI_BOOT_PRIMARY;
973 version[0] = version[1] = version[2] = version[3] = 0;
978 if (req.emr_rc != 0) {
983 if (req.emr_out_length_used < MC_CMD_GET_BOOT_STATUS_OUT_LEN) {
988 if (MCDI_OUT_DWORD_FIELD(req, GET_BOOT_STATUS_OUT_FLAGS,
989 GET_BOOT_STATUS_OUT_FLAGS_PRIMARY))
990 status = EFX_MCDI_BOOT_PRIMARY;
992 status = EFX_MCDI_BOOT_SECONDARY;
995 if (versionp != NULL)
996 memcpy(versionp, version, sizeof (version));
1011 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1016 __checkReturn efx_rc_t
1017 efx_mcdi_get_capabilities(
1018 __in efx_nic_t *enp,
1019 __out_opt uint32_t *flagsp,
1020 __out_opt uint16_t *rx_dpcpu_fw_idp,
1021 __out_opt uint16_t *tx_dpcpu_fw_idp,
1022 __out_opt uint32_t *flags2p,
1023 __out_opt uint32_t *tso2ncp)
1026 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_GET_CAPABILITIES_IN_LEN,
1027 MC_CMD_GET_CAPABILITIES_V2_OUT_LEN);
1028 boolean_t v2_capable;
1031 req.emr_cmd = MC_CMD_GET_CAPABILITIES;
1032 req.emr_in_buf = payload;
1033 req.emr_in_length = MC_CMD_GET_CAPABILITIES_IN_LEN;
1034 req.emr_out_buf = payload;
1035 req.emr_out_length = MC_CMD_GET_CAPABILITIES_V2_OUT_LEN;
1037 efx_mcdi_execute_quiet(enp, &req);
1039 if (req.emr_rc != 0) {
1044 if (req.emr_out_length_used < MC_CMD_GET_CAPABILITIES_OUT_LEN) {
1050 *flagsp = MCDI_OUT_DWORD(req, GET_CAPABILITIES_OUT_FLAGS1);
1052 if (rx_dpcpu_fw_idp != NULL)
1053 *rx_dpcpu_fw_idp = MCDI_OUT_WORD(req,
1054 GET_CAPABILITIES_OUT_RX_DPCPU_FW_ID);
1056 if (tx_dpcpu_fw_idp != NULL)
1057 *tx_dpcpu_fw_idp = MCDI_OUT_WORD(req,
1058 GET_CAPABILITIES_OUT_TX_DPCPU_FW_ID);
1060 if (req.emr_out_length_used < MC_CMD_GET_CAPABILITIES_V2_OUT_LEN)
1061 v2_capable = B_FALSE;
1063 v2_capable = B_TRUE;
1065 if (flags2p != NULL) {
1066 *flags2p = (v2_capable) ?
1067 MCDI_OUT_DWORD(req, GET_CAPABILITIES_V2_OUT_FLAGS2) :
1071 if (tso2ncp != NULL) {
1072 *tso2ncp = (v2_capable) ?
1074 GET_CAPABILITIES_V2_OUT_TX_TSO_V2_N_CONTEXTS) :
1083 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1088 static __checkReturn efx_rc_t
1090 __in efx_nic_t *enp,
1091 __in boolean_t after_assertion)
1093 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_REBOOT_IN_LEN,
1094 MC_CMD_REBOOT_OUT_LEN);
1099 * We could require the caller to have caused en_mod_flags=0 to
1100 * call this function. This doesn't help the other port though,
1101 * who's about to get the MC ripped out from underneath them.
1102 * Since they have to cope with the subsequent fallout of MCDI
1103 * failures, we should as well.
1105 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
1107 req.emr_cmd = MC_CMD_REBOOT;
1108 req.emr_in_buf = payload;
1109 req.emr_in_length = MC_CMD_REBOOT_IN_LEN;
1110 req.emr_out_buf = payload;
1111 req.emr_out_length = MC_CMD_REBOOT_OUT_LEN;
1113 MCDI_IN_SET_DWORD(req, REBOOT_IN_FLAGS,
1114 (after_assertion ? MC_CMD_REBOOT_FLAGS_AFTER_ASSERTION : 0));
1116 efx_mcdi_execute_quiet(enp, &req);
1118 if (req.emr_rc == EACCES) {
1119 /* Unprivileged functions cannot reboot the MC. */
1123 /* A successful reboot request returns EIO. */
1124 if (req.emr_rc != 0 && req.emr_rc != EIO) {
1133 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1138 __checkReturn efx_rc_t
1140 __in efx_nic_t *enp)
1142 return (efx_mcdi_do_reboot(enp, B_FALSE));
1145 __checkReturn efx_rc_t
1146 efx_mcdi_exit_assertion_handler(
1147 __in efx_nic_t *enp)
1149 return (efx_mcdi_do_reboot(enp, B_TRUE));
1152 __checkReturn efx_rc_t
1153 efx_mcdi_read_assertion(
1154 __in efx_nic_t *enp)
1157 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_GET_ASSERTS_IN_LEN,
1158 MC_CMD_GET_ASSERTS_OUT_LEN);
1167 * Before we attempt to chat to the MC, we should verify that the MC
1168 * isn't in it's assertion handler, either due to a previous reboot,
1169 * or because we're reinitializing due to an eec_exception().
1171 * Use GET_ASSERTS to read any assertion state that may be present.
1172 * Retry this command twice. Once because a boot-time assertion failure
1173 * might cause the 1st MCDI request to fail. And once again because
1174 * we might race with efx_mcdi_exit_assertion_handler() running on
1175 * partner port(s) on the same NIC.
1179 (void) memset(payload, 0, sizeof (payload));
1180 req.emr_cmd = MC_CMD_GET_ASSERTS;
1181 req.emr_in_buf = payload;
1182 req.emr_in_length = MC_CMD_GET_ASSERTS_IN_LEN;
1183 req.emr_out_buf = payload;
1184 req.emr_out_length = MC_CMD_GET_ASSERTS_OUT_LEN;
1186 MCDI_IN_SET_DWORD(req, GET_ASSERTS_IN_CLEAR, 1);
1187 efx_mcdi_execute_quiet(enp, &req);
1189 } while ((req.emr_rc == EINTR || req.emr_rc == EIO) && retry-- > 0);
1191 if (req.emr_rc != 0) {
1192 if (req.emr_rc == EACCES) {
1193 /* Unprivileged functions cannot clear assertions. */
1200 if (req.emr_out_length_used < MC_CMD_GET_ASSERTS_OUT_LEN) {
1205 /* Print out any assertion state recorded */
1206 flags = MCDI_OUT_DWORD(req, GET_ASSERTS_OUT_GLOBAL_FLAGS);
1207 if (flags == MC_CMD_GET_ASSERTS_FLAGS_NO_FAILS)
1210 reason = (flags == MC_CMD_GET_ASSERTS_FLAGS_SYS_FAIL)
1211 ? "system-level assertion"
1212 : (flags == MC_CMD_GET_ASSERTS_FLAGS_THR_FAIL)
1213 ? "thread-level assertion"
1214 : (flags == MC_CMD_GET_ASSERTS_FLAGS_WDOG_FIRED)
1216 : (flags == MC_CMD_GET_ASSERTS_FLAGS_ADDR_TRAP)
1217 ? "illegal address trap"
1218 : "unknown assertion";
1219 EFSYS_PROBE3(mcpu_assertion,
1220 const char *, reason, unsigned int,
1221 MCDI_OUT_DWORD(req, GET_ASSERTS_OUT_SAVED_PC_OFFS),
1223 MCDI_OUT_DWORD(req, GET_ASSERTS_OUT_THREAD_OFFS));
1225 /* Print out the registers (r1 ... r31) */
1226 ofst = MC_CMD_GET_ASSERTS_OUT_GP_REGS_OFFS_OFST;
1228 index < 1 + MC_CMD_GET_ASSERTS_OUT_GP_REGS_OFFS_NUM;
1230 EFSYS_PROBE2(mcpu_register, unsigned int, index, unsigned int,
1231 EFX_DWORD_FIELD(*MCDI_OUT(req, efx_dword_t, ofst),
1233 ofst += sizeof (efx_dword_t);
1235 EFSYS_ASSERT(ofst <= MC_CMD_GET_ASSERTS_OUT_LEN);
1243 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1250 * Internal routines for for specific MCDI requests.
1253 __checkReturn efx_rc_t
1254 efx_mcdi_drv_attach(
1255 __in efx_nic_t *enp,
1256 __in boolean_t attach)
1259 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_DRV_ATTACH_IN_LEN,
1260 MC_CMD_DRV_ATTACH_EXT_OUT_LEN);
1263 req.emr_cmd = MC_CMD_DRV_ATTACH;
1264 req.emr_in_buf = payload;
1265 req.emr_in_length = MC_CMD_DRV_ATTACH_IN_LEN;
1266 req.emr_out_buf = payload;
1267 req.emr_out_length = MC_CMD_DRV_ATTACH_EXT_OUT_LEN;
1270 * Typically, client drivers use DONT_CARE for the datapath firmware
1271 * type to ensure that the driver can attach to an unprivileged
1272 * function. The datapath firmware type to use is controlled by the
1274 * If a client driver wishes to attach with a specific datapath firmware
1275 * type, that can be passed in second argument of efx_nic_probe API. One
1276 * such example is the ESXi native driver that attempts attaching with
1277 * FULL_FEATURED datapath firmware type first and fall backs to
1278 * DONT_CARE datapath firmware type if MC_CMD_DRV_ATTACH fails.
1280 MCDI_IN_POPULATE_DWORD_2(req, DRV_ATTACH_IN_NEW_STATE,
1281 DRV_ATTACH_IN_ATTACH, attach ? 1 : 0,
1282 DRV_ATTACH_IN_SUBVARIANT_AWARE, EFSYS_OPT_FW_SUBVARIANT_AWARE);
1283 MCDI_IN_SET_DWORD(req, DRV_ATTACH_IN_UPDATE, 1);
1284 MCDI_IN_SET_DWORD(req, DRV_ATTACH_IN_FIRMWARE_ID, enp->efv);
1286 efx_mcdi_execute(enp, &req);
1288 if (req.emr_rc != 0) {
1293 if (req.emr_out_length_used < MC_CMD_DRV_ATTACH_OUT_LEN) {
1303 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1308 __checkReturn efx_rc_t
1309 efx_mcdi_get_board_cfg(
1310 __in efx_nic_t *enp,
1311 __out_opt uint32_t *board_typep,
1312 __out_opt efx_dword_t *capabilitiesp,
1313 __out_ecount_opt(6) uint8_t mac_addrp[6])
1315 efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip);
1317 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_GET_BOARD_CFG_IN_LEN,
1318 MC_CMD_GET_BOARD_CFG_OUT_LENMIN);
1321 req.emr_cmd = MC_CMD_GET_BOARD_CFG;
1322 req.emr_in_buf = payload;
1323 req.emr_in_length = MC_CMD_GET_BOARD_CFG_IN_LEN;
1324 req.emr_out_buf = payload;
1325 req.emr_out_length = MC_CMD_GET_BOARD_CFG_OUT_LENMIN;
1327 efx_mcdi_execute(enp, &req);
1329 if (req.emr_rc != 0) {
1334 if (req.emr_out_length_used < MC_CMD_GET_BOARD_CFG_OUT_LENMIN) {
1339 if (mac_addrp != NULL) {
1342 if (emip->emi_port == 1) {
1343 addrp = MCDI_OUT2(req, uint8_t,
1344 GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT0);
1345 } else if (emip->emi_port == 2) {
1346 addrp = MCDI_OUT2(req, uint8_t,
1347 GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT1);
1353 EFX_MAC_ADDR_COPY(mac_addrp, addrp);
1356 if (capabilitiesp != NULL) {
1357 if (emip->emi_port == 1) {
1358 *capabilitiesp = *MCDI_OUT2(req, efx_dword_t,
1359 GET_BOARD_CFG_OUT_CAPABILITIES_PORT0);
1360 } else if (emip->emi_port == 2) {
1361 *capabilitiesp = *MCDI_OUT2(req, efx_dword_t,
1362 GET_BOARD_CFG_OUT_CAPABILITIES_PORT1);
1369 if (board_typep != NULL) {
1370 *board_typep = MCDI_OUT_DWORD(req,
1371 GET_BOARD_CFG_OUT_BOARD_TYPE);
1383 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1388 __checkReturn efx_rc_t
1389 efx_mcdi_get_resource_limits(
1390 __in efx_nic_t *enp,
1391 __out_opt uint32_t *nevqp,
1392 __out_opt uint32_t *nrxqp,
1393 __out_opt uint32_t *ntxqp)
1396 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_GET_RESOURCE_LIMITS_IN_LEN,
1397 MC_CMD_GET_RESOURCE_LIMITS_OUT_LEN);
1400 req.emr_cmd = MC_CMD_GET_RESOURCE_LIMITS;
1401 req.emr_in_buf = payload;
1402 req.emr_in_length = MC_CMD_GET_RESOURCE_LIMITS_IN_LEN;
1403 req.emr_out_buf = payload;
1404 req.emr_out_length = MC_CMD_GET_RESOURCE_LIMITS_OUT_LEN;
1406 efx_mcdi_execute(enp, &req);
1408 if (req.emr_rc != 0) {
1413 if (req.emr_out_length_used < MC_CMD_GET_RESOURCE_LIMITS_OUT_LEN) {
1419 *nevqp = MCDI_OUT_DWORD(req, GET_RESOURCE_LIMITS_OUT_EVQ);
1421 *nrxqp = MCDI_OUT_DWORD(req, GET_RESOURCE_LIMITS_OUT_RXQ);
1423 *ntxqp = MCDI_OUT_DWORD(req, GET_RESOURCE_LIMITS_OUT_TXQ);
1430 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1435 __checkReturn efx_rc_t
1436 efx_mcdi_get_phy_cfg(
1437 __in efx_nic_t *enp)
1439 efx_port_t *epp = &(enp->en_port);
1440 efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
1442 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_GET_PHY_CFG_IN_LEN,
1443 MC_CMD_GET_PHY_CFG_OUT_LEN);
1448 uint32_t phy_media_type;
1451 req.emr_cmd = MC_CMD_GET_PHY_CFG;
1452 req.emr_in_buf = payload;
1453 req.emr_in_length = MC_CMD_GET_PHY_CFG_IN_LEN;
1454 req.emr_out_buf = payload;
1455 req.emr_out_length = MC_CMD_GET_PHY_CFG_OUT_LEN;
1457 efx_mcdi_execute(enp, &req);
1459 if (req.emr_rc != 0) {
1464 if (req.emr_out_length_used < MC_CMD_GET_PHY_CFG_OUT_LEN) {
1469 encp->enc_phy_type = MCDI_OUT_DWORD(req, GET_PHY_CFG_OUT_TYPE);
1471 namep = MCDI_OUT2(req, char, GET_PHY_CFG_OUT_NAME);
1472 namelen = MIN(sizeof (encp->enc_phy_name) - 1,
1473 strnlen(namep, MC_CMD_GET_PHY_CFG_OUT_NAME_LEN));
1474 (void) memset(encp->enc_phy_name, 0,
1475 sizeof (encp->enc_phy_name));
1476 memcpy(encp->enc_phy_name, namep, namelen);
1477 #endif /* EFSYS_OPT_NAMES */
1478 (void) memset(encp->enc_phy_revision, 0,
1479 sizeof (encp->enc_phy_revision));
1480 memcpy(encp->enc_phy_revision,
1481 MCDI_OUT2(req, char, GET_PHY_CFG_OUT_REVISION),
1482 MIN(sizeof (encp->enc_phy_revision) - 1,
1483 MC_CMD_GET_PHY_CFG_OUT_REVISION_LEN));
1484 #if EFSYS_OPT_PHY_LED_CONTROL
1485 encp->enc_led_mask = ((1 << EFX_PHY_LED_DEFAULT) |
1486 (1 << EFX_PHY_LED_OFF) |
1487 (1 << EFX_PHY_LED_ON));
1488 #endif /* EFSYS_OPT_PHY_LED_CONTROL */
1490 /* Get the media type of the fixed port, if recognised. */
1491 EFX_STATIC_ASSERT(MC_CMD_MEDIA_XAUI == EFX_PHY_MEDIA_XAUI);
1492 EFX_STATIC_ASSERT(MC_CMD_MEDIA_CX4 == EFX_PHY_MEDIA_CX4);
1493 EFX_STATIC_ASSERT(MC_CMD_MEDIA_KX4 == EFX_PHY_MEDIA_KX4);
1494 EFX_STATIC_ASSERT(MC_CMD_MEDIA_XFP == EFX_PHY_MEDIA_XFP);
1495 EFX_STATIC_ASSERT(MC_CMD_MEDIA_SFP_PLUS == EFX_PHY_MEDIA_SFP_PLUS);
1496 EFX_STATIC_ASSERT(MC_CMD_MEDIA_BASE_T == EFX_PHY_MEDIA_BASE_T);
1497 EFX_STATIC_ASSERT(MC_CMD_MEDIA_QSFP_PLUS == EFX_PHY_MEDIA_QSFP_PLUS);
1498 phy_media_type = MCDI_OUT_DWORD(req, GET_PHY_CFG_OUT_MEDIA_TYPE);
1499 epp->ep_fixed_port_type = (efx_phy_media_type_t)phy_media_type;
1500 if (epp->ep_fixed_port_type >= EFX_PHY_MEDIA_NTYPES)
1501 epp->ep_fixed_port_type = EFX_PHY_MEDIA_INVALID;
1503 epp->ep_phy_cap_mask =
1504 MCDI_OUT_DWORD(req, GET_PHY_CFG_OUT_SUPPORTED_CAP);
1505 #if EFSYS_OPT_PHY_FLAGS
1506 encp->enc_phy_flags_mask = MCDI_OUT_DWORD(req, GET_PHY_CFG_OUT_FLAGS);
1507 #endif /* EFSYS_OPT_PHY_FLAGS */
1509 encp->enc_port = (uint8_t)MCDI_OUT_DWORD(req, GET_PHY_CFG_OUT_PRT);
1511 /* Populate internal state */
1512 encp->enc_mcdi_mdio_channel =
1513 (uint8_t)MCDI_OUT_DWORD(req, GET_PHY_CFG_OUT_CHANNEL);
1515 #if EFSYS_OPT_PHY_STATS
1516 encp->enc_mcdi_phy_stat_mask =
1517 MCDI_OUT_DWORD(req, GET_PHY_CFG_OUT_STATS_MASK);
1518 #endif /* EFSYS_OPT_PHY_STATS */
1521 encp->enc_bist_mask = 0;
1522 if (MCDI_OUT_DWORD_FIELD(req, GET_PHY_CFG_OUT_FLAGS,
1523 GET_PHY_CFG_OUT_BIST_CABLE_SHORT))
1524 encp->enc_bist_mask |= (1 << EFX_BIST_TYPE_PHY_CABLE_SHORT);
1525 if (MCDI_OUT_DWORD_FIELD(req, GET_PHY_CFG_OUT_FLAGS,
1526 GET_PHY_CFG_OUT_BIST_CABLE_LONG))
1527 encp->enc_bist_mask |= (1 << EFX_BIST_TYPE_PHY_CABLE_LONG);
1528 if (MCDI_OUT_DWORD_FIELD(req, GET_PHY_CFG_OUT_FLAGS,
1529 GET_PHY_CFG_OUT_BIST))
1530 encp->enc_bist_mask |= (1 << EFX_BIST_TYPE_PHY_NORMAL);
1531 #endif /* EFSYS_OPT_BIST */
1538 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1543 __checkReturn efx_rc_t
1544 efx_mcdi_firmware_update_supported(
1545 __in efx_nic_t *enp,
1546 __out boolean_t *supportedp)
1548 const efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop;
1551 if (emcop != NULL) {
1552 if ((rc = emcop->emco_feature_supported(enp,
1553 EFX_MCDI_FEATURE_FW_UPDATE, supportedp)) != 0)
1556 /* Earlier devices always supported updates */
1557 *supportedp = B_TRUE;
1563 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1568 __checkReturn efx_rc_t
1569 efx_mcdi_macaddr_change_supported(
1570 __in efx_nic_t *enp,
1571 __out boolean_t *supportedp)
1573 const efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop;
1576 if (emcop != NULL) {
1577 if ((rc = emcop->emco_feature_supported(enp,
1578 EFX_MCDI_FEATURE_MACADDR_CHANGE, supportedp)) != 0)
1581 /* Earlier devices always supported MAC changes */
1582 *supportedp = B_TRUE;
1588 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1593 __checkReturn efx_rc_t
1594 efx_mcdi_link_control_supported(
1595 __in efx_nic_t *enp,
1596 __out boolean_t *supportedp)
1598 const efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop;
1601 if (emcop != NULL) {
1602 if ((rc = emcop->emco_feature_supported(enp,
1603 EFX_MCDI_FEATURE_LINK_CONTROL, supportedp)) != 0)
1606 /* Earlier devices always supported link control */
1607 *supportedp = B_TRUE;
1613 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1618 __checkReturn efx_rc_t
1619 efx_mcdi_mac_spoofing_supported(
1620 __in efx_nic_t *enp,
1621 __out boolean_t *supportedp)
1623 const efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop;
1626 if (emcop != NULL) {
1627 if ((rc = emcop->emco_feature_supported(enp,
1628 EFX_MCDI_FEATURE_MAC_SPOOFING, supportedp)) != 0)
1631 /* Earlier devices always supported MAC spoofing */
1632 *supportedp = B_TRUE;
1638 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1645 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
1647 * Enter bist offline mode. This is a fw mode which puts the NIC into a state
1648 * where memory BIST tests can be run and not much else can interfere or happen.
1649 * A reboot is required to exit this mode.
1651 __checkReturn efx_rc_t
1652 efx_mcdi_bist_enable_offline(
1653 __in efx_nic_t *enp)
1658 EFX_STATIC_ASSERT(MC_CMD_ENABLE_OFFLINE_BIST_IN_LEN == 0);
1659 EFX_STATIC_ASSERT(MC_CMD_ENABLE_OFFLINE_BIST_OUT_LEN == 0);
1661 req.emr_cmd = MC_CMD_ENABLE_OFFLINE_BIST;
1662 req.emr_in_buf = NULL;
1663 req.emr_in_length = 0;
1664 req.emr_out_buf = NULL;
1665 req.emr_out_length = 0;
1667 efx_mcdi_execute(enp, &req);
1669 if (req.emr_rc != 0) {
1677 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1681 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
1683 __checkReturn efx_rc_t
1684 efx_mcdi_bist_start(
1685 __in efx_nic_t *enp,
1686 __in efx_bist_type_t type)
1689 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_START_BIST_IN_LEN,
1690 MC_CMD_START_BIST_OUT_LEN);
1693 req.emr_cmd = MC_CMD_START_BIST;
1694 req.emr_in_buf = payload;
1695 req.emr_in_length = MC_CMD_START_BIST_IN_LEN;
1696 req.emr_out_buf = payload;
1697 req.emr_out_length = MC_CMD_START_BIST_OUT_LEN;
1700 case EFX_BIST_TYPE_PHY_NORMAL:
1701 MCDI_IN_SET_DWORD(req, START_BIST_IN_TYPE, MC_CMD_PHY_BIST);
1703 case EFX_BIST_TYPE_PHY_CABLE_SHORT:
1704 MCDI_IN_SET_DWORD(req, START_BIST_IN_TYPE,
1705 MC_CMD_PHY_BIST_CABLE_SHORT);
1707 case EFX_BIST_TYPE_PHY_CABLE_LONG:
1708 MCDI_IN_SET_DWORD(req, START_BIST_IN_TYPE,
1709 MC_CMD_PHY_BIST_CABLE_LONG);
1711 case EFX_BIST_TYPE_MC_MEM:
1712 MCDI_IN_SET_DWORD(req, START_BIST_IN_TYPE,
1713 MC_CMD_MC_MEM_BIST);
1715 case EFX_BIST_TYPE_SAT_MEM:
1716 MCDI_IN_SET_DWORD(req, START_BIST_IN_TYPE,
1717 MC_CMD_PORT_MEM_BIST);
1719 case EFX_BIST_TYPE_REG:
1720 MCDI_IN_SET_DWORD(req, START_BIST_IN_TYPE,
1727 efx_mcdi_execute(enp, &req);
1729 if (req.emr_rc != 0) {
1737 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1742 #endif /* EFSYS_OPT_BIST */
1745 /* Enable logging of some events (e.g. link state changes) */
1746 __checkReturn efx_rc_t
1748 __in efx_nic_t *enp)
1751 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_LOG_CTRL_IN_LEN,
1752 MC_CMD_LOG_CTRL_OUT_LEN);
1755 req.emr_cmd = MC_CMD_LOG_CTRL;
1756 req.emr_in_buf = payload;
1757 req.emr_in_length = MC_CMD_LOG_CTRL_IN_LEN;
1758 req.emr_out_buf = payload;
1759 req.emr_out_length = MC_CMD_LOG_CTRL_OUT_LEN;
1761 MCDI_IN_SET_DWORD(req, LOG_CTRL_IN_LOG_DEST,
1762 MC_CMD_LOG_CTRL_IN_LOG_DEST_EVQ);
1763 MCDI_IN_SET_DWORD(req, LOG_CTRL_IN_LOG_DEST_EVQ, 0);
1765 efx_mcdi_execute(enp, &req);
1767 if (req.emr_rc != 0) {
1775 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1781 #if EFSYS_OPT_MAC_STATS
1783 typedef enum efx_stats_action_e {
1786 EFX_STATS_ENABLE_NOEVENTS,
1787 EFX_STATS_ENABLE_EVENTS,
1789 } efx_stats_action_t;
1791 static __checkReturn efx_rc_t
1793 __in efx_nic_t *enp,
1794 __in_opt efsys_mem_t *esmp,
1795 __in efx_stats_action_t action,
1796 __in uint16_t period_ms)
1799 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_MAC_STATS_IN_LEN,
1800 MC_CMD_MAC_STATS_V2_OUT_DMA_LEN);
1801 int clear = (action == EFX_STATS_CLEAR);
1802 int upload = (action == EFX_STATS_UPLOAD);
1803 int enable = (action == EFX_STATS_ENABLE_NOEVENTS);
1804 int events = (action == EFX_STATS_ENABLE_EVENTS);
1805 int disable = (action == EFX_STATS_DISABLE);
1808 req.emr_cmd = MC_CMD_MAC_STATS;
1809 req.emr_in_buf = payload;
1810 req.emr_in_length = MC_CMD_MAC_STATS_IN_LEN;
1811 req.emr_out_buf = payload;
1812 req.emr_out_length = MC_CMD_MAC_STATS_V2_OUT_DMA_LEN;
1814 MCDI_IN_POPULATE_DWORD_6(req, MAC_STATS_IN_CMD,
1815 MAC_STATS_IN_DMA, upload,
1816 MAC_STATS_IN_CLEAR, clear,
1817 MAC_STATS_IN_PERIODIC_CHANGE, enable | events | disable,
1818 MAC_STATS_IN_PERIODIC_ENABLE, enable | events,
1819 MAC_STATS_IN_PERIODIC_NOEVENT, !events,
1820 MAC_STATS_IN_PERIOD_MS, (enable | events) ? period_ms : 0);
1822 if (enable || events || upload) {
1823 const efx_nic_cfg_t *encp = &enp->en_nic_cfg;
1826 /* Periodic stats or stats upload require a DMA buffer */
1832 if (encp->enc_mac_stats_nstats < MC_CMD_MAC_NSTATS) {
1833 /* MAC stats count too small for legacy MAC stats */
1838 bytes = encp->enc_mac_stats_nstats * sizeof (efx_qword_t);
1840 if (EFSYS_MEM_SIZE(esmp) < bytes) {
1841 /* DMA buffer too small */
1846 MCDI_IN_SET_DWORD(req, MAC_STATS_IN_DMA_ADDR_LO,
1847 EFSYS_MEM_ADDR(esmp) & 0xffffffff);
1848 MCDI_IN_SET_DWORD(req, MAC_STATS_IN_DMA_ADDR_HI,
1849 EFSYS_MEM_ADDR(esmp) >> 32);
1850 MCDI_IN_SET_DWORD(req, MAC_STATS_IN_DMA_LEN, bytes);
1854 * NOTE: Do not use EVB_PORT_ID_ASSIGNED when disabling periodic stats,
1855 * as this may fail (and leave periodic DMA enabled) if the
1856 * vadapter has already been deleted.
1858 MCDI_IN_SET_DWORD(req, MAC_STATS_IN_PORT_ID,
1859 (disable ? EVB_PORT_ID_NULL : enp->en_vport_id));
1861 efx_mcdi_execute(enp, &req);
1863 if (req.emr_rc != 0) {
1864 /* EF10: Expect ENOENT if no DMA queues are initialised */
1865 if ((req.emr_rc != ENOENT) ||
1866 (enp->en_rx_qcount + enp->en_tx_qcount != 0)) {
1881 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1886 __checkReturn efx_rc_t
1887 efx_mcdi_mac_stats_clear(
1888 __in efx_nic_t *enp)
1892 if ((rc = efx_mcdi_mac_stats(enp, NULL, EFX_STATS_CLEAR, 0)) != 0)
1898 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1903 __checkReturn efx_rc_t
1904 efx_mcdi_mac_stats_upload(
1905 __in efx_nic_t *enp,
1906 __in efsys_mem_t *esmp)
1911 * The MC DMAs aggregate statistics for our convenience, so we can
1912 * avoid having to pull the statistics buffer into the cache to
1913 * maintain cumulative statistics.
1915 if ((rc = efx_mcdi_mac_stats(enp, esmp, EFX_STATS_UPLOAD, 0)) != 0)
1921 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1926 __checkReturn efx_rc_t
1927 efx_mcdi_mac_stats_periodic(
1928 __in efx_nic_t *enp,
1929 __in efsys_mem_t *esmp,
1930 __in uint16_t period_ms,
1931 __in boolean_t events)
1936 * The MC DMAs aggregate statistics for our convenience, so we can
1937 * avoid having to pull the statistics buffer into the cache to
1938 * maintain cumulative statistics.
1939 * Huntington uses a fixed 1sec period.
1940 * Medford uses a fixed 1sec period before v6.2.1.1033 firmware.
1943 rc = efx_mcdi_mac_stats(enp, NULL, EFX_STATS_DISABLE, 0);
1945 rc = efx_mcdi_mac_stats(enp, esmp, EFX_STATS_ENABLE_EVENTS,
1948 rc = efx_mcdi_mac_stats(enp, esmp, EFX_STATS_ENABLE_NOEVENTS,
1957 EFSYS_PROBE1(fail1, efx_rc_t, rc);
1962 #endif /* EFSYS_OPT_MAC_STATS */
1964 #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
1967 * This function returns the pf and vf number of a function. If it is a pf the
1968 * vf number is 0xffff. The vf number is the index of the vf on that
1969 * function. So if you have 3 vfs on pf 0 the 3 vfs will return (pf=0,vf=0),
1970 * (pf=0,vf=1), (pf=0,vf=2) aand the pf will return (pf=0, vf=0xffff).
1972 __checkReturn efx_rc_t
1973 efx_mcdi_get_function_info(
1974 __in efx_nic_t *enp,
1975 __out uint32_t *pfp,
1976 __out_opt uint32_t *vfp)
1979 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_GET_FUNCTION_INFO_IN_LEN,
1980 MC_CMD_GET_FUNCTION_INFO_OUT_LEN);
1983 req.emr_cmd = MC_CMD_GET_FUNCTION_INFO;
1984 req.emr_in_buf = payload;
1985 req.emr_in_length = MC_CMD_GET_FUNCTION_INFO_IN_LEN;
1986 req.emr_out_buf = payload;
1987 req.emr_out_length = MC_CMD_GET_FUNCTION_INFO_OUT_LEN;
1989 efx_mcdi_execute(enp, &req);
1991 if (req.emr_rc != 0) {
1996 if (req.emr_out_length_used < MC_CMD_GET_FUNCTION_INFO_OUT_LEN) {
2001 *pfp = MCDI_OUT_DWORD(req, GET_FUNCTION_INFO_OUT_PF);
2003 *vfp = MCDI_OUT_DWORD(req, GET_FUNCTION_INFO_OUT_VF);
2010 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2015 __checkReturn efx_rc_t
2016 efx_mcdi_privilege_mask(
2017 __in efx_nic_t *enp,
2020 __out uint32_t *maskp)
2023 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_PRIVILEGE_MASK_IN_LEN,
2024 MC_CMD_PRIVILEGE_MASK_OUT_LEN);
2027 req.emr_cmd = MC_CMD_PRIVILEGE_MASK;
2028 req.emr_in_buf = payload;
2029 req.emr_in_length = MC_CMD_PRIVILEGE_MASK_IN_LEN;
2030 req.emr_out_buf = payload;
2031 req.emr_out_length = MC_CMD_PRIVILEGE_MASK_OUT_LEN;
2033 MCDI_IN_POPULATE_DWORD_2(req, PRIVILEGE_MASK_IN_FUNCTION,
2034 PRIVILEGE_MASK_IN_FUNCTION_PF, pf,
2035 PRIVILEGE_MASK_IN_FUNCTION_VF, vf);
2037 efx_mcdi_execute(enp, &req);
2039 if (req.emr_rc != 0) {
2044 if (req.emr_out_length_used < MC_CMD_PRIVILEGE_MASK_OUT_LEN) {
2049 *maskp = MCDI_OUT_DWORD(req, PRIVILEGE_MASK_OUT_OLD_MASK);
2056 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2061 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
2063 __checkReturn efx_rc_t
2064 efx_mcdi_set_workaround(
2065 __in efx_nic_t *enp,
2067 __in boolean_t enabled,
2068 __out_opt uint32_t *flagsp)
2071 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_WORKAROUND_IN_LEN,
2072 MC_CMD_WORKAROUND_EXT_OUT_LEN);
2075 req.emr_cmd = MC_CMD_WORKAROUND;
2076 req.emr_in_buf = payload;
2077 req.emr_in_length = MC_CMD_WORKAROUND_IN_LEN;
2078 req.emr_out_buf = payload;
2079 req.emr_out_length = MC_CMD_WORKAROUND_OUT_LEN;
2081 MCDI_IN_SET_DWORD(req, WORKAROUND_IN_TYPE, type);
2082 MCDI_IN_SET_DWORD(req, WORKAROUND_IN_ENABLED, enabled ? 1 : 0);
2084 efx_mcdi_execute_quiet(enp, &req);
2086 if (req.emr_rc != 0) {
2091 if (flagsp != NULL) {
2092 if (req.emr_out_length_used >= MC_CMD_WORKAROUND_EXT_OUT_LEN)
2093 *flagsp = MCDI_OUT_DWORD(req, WORKAROUND_EXT_OUT_FLAGS);
2101 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2107 __checkReturn efx_rc_t
2108 efx_mcdi_get_workarounds(
2109 __in efx_nic_t *enp,
2110 __out_opt uint32_t *implementedp,
2111 __out_opt uint32_t *enabledp)
2114 EFX_MCDI_DECLARE_BUF(payload, 0, MC_CMD_GET_WORKAROUNDS_OUT_LEN);
2117 req.emr_cmd = MC_CMD_GET_WORKAROUNDS;
2118 req.emr_in_buf = NULL;
2119 req.emr_in_length = 0;
2120 req.emr_out_buf = payload;
2121 req.emr_out_length = MC_CMD_GET_WORKAROUNDS_OUT_LEN;
2123 efx_mcdi_execute(enp, &req);
2125 if (req.emr_rc != 0) {
2130 if (implementedp != NULL) {
2132 MCDI_OUT_DWORD(req, GET_WORKAROUNDS_OUT_IMPLEMENTED);
2135 if (enabledp != NULL) {
2136 *enabledp = MCDI_OUT_DWORD(req, GET_WORKAROUNDS_OUT_ENABLED);
2142 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2148 * Size of media information page in accordance with SFF-8472 and SFF-8436.
2149 * It is used in MCDI interface as well.
2151 #define EFX_PHY_MEDIA_INFO_PAGE_SIZE 0x80
2153 static __checkReturn efx_rc_t
2154 efx_mcdi_get_phy_media_info(
2155 __in efx_nic_t *enp,
2156 __in uint32_t mcdi_page,
2157 __in uint8_t offset,
2159 __out_bcount(len) uint8_t *data)
2162 EFX_MCDI_DECLARE_BUF(payload, MC_CMD_GET_PHY_MEDIA_INFO_IN_LEN,
2163 MC_CMD_GET_PHY_MEDIA_INFO_OUT_LEN(
2164 EFX_PHY_MEDIA_INFO_PAGE_SIZE));
2167 EFSYS_ASSERT((uint32_t)offset + len <= EFX_PHY_MEDIA_INFO_PAGE_SIZE);
2169 req.emr_cmd = MC_CMD_GET_PHY_MEDIA_INFO;
2170 req.emr_in_buf = payload;
2171 req.emr_in_length = MC_CMD_GET_PHY_MEDIA_INFO_IN_LEN;
2172 req.emr_out_buf = payload;
2173 req.emr_out_length =
2174 MC_CMD_GET_PHY_MEDIA_INFO_OUT_LEN(EFX_PHY_MEDIA_INFO_PAGE_SIZE);
2176 MCDI_IN_SET_DWORD(req, GET_PHY_MEDIA_INFO_IN_PAGE, mcdi_page);
2178 efx_mcdi_execute(enp, &req);
2180 if (req.emr_rc != 0) {
2185 if (req.emr_out_length_used !=
2186 MC_CMD_GET_PHY_MEDIA_INFO_OUT_LEN(EFX_PHY_MEDIA_INFO_PAGE_SIZE)) {
2191 if (MCDI_OUT_DWORD(req, GET_PHY_MEDIA_INFO_OUT_DATALEN) !=
2192 EFX_PHY_MEDIA_INFO_PAGE_SIZE) {
2198 MCDI_OUT2(req, uint8_t, GET_PHY_MEDIA_INFO_OUT_DATA) + offset,
2208 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2213 __checkReturn efx_rc_t
2214 efx_mcdi_phy_module_get_info(
2215 __in efx_nic_t *enp,
2216 __in uint8_t dev_addr,
2219 __out_bcount(len) uint8_t *data)
2221 efx_port_t *epp = &(enp->en_port);
2223 uint32_t mcdi_lower_page;
2224 uint32_t mcdi_upper_page;
2226 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
2229 * Map device address to MC_CMD_GET_PHY_MEDIA_INFO pages.
2230 * Offset plus length interface allows to access page 0 only.
2231 * I.e. non-zero upper pages are not accessible.
2232 * See SFF-8472 section 4 Memory Organization and SFF-8436 section 7.6
2233 * QSFP+ Memory Map for details on how information is structured
2236 switch (epp->ep_fixed_port_type) {
2237 case EFX_PHY_MEDIA_SFP_PLUS:
2239 * In accordance with SFF-8472 Diagnostic Monitoring
2240 * Interface for Optical Transceivers section 4 Memory
2241 * Organization two 2-wire addresses are defined.
2244 /* Base information */
2245 case EFX_PHY_MEDIA_INFO_DEV_ADDR_SFP_BASE:
2247 * MCDI page 0 should be used to access lower
2248 * page 0 (0x00 - 0x7f) at the device address 0xA0.
2250 mcdi_lower_page = 0;
2252 * MCDI page 1 should be used to access upper
2253 * page 0 (0x80 - 0xff) at the device address 0xA0.
2255 mcdi_upper_page = 1;
2258 case EFX_PHY_MEDIA_INFO_DEV_ADDR_SFP_DDM:
2260 * MCDI page 2 should be used to access lower
2261 * page 0 (0x00 - 0x7f) at the device address 0xA2.
2263 mcdi_lower_page = 2;
2265 * MCDI page 3 should be used to access upper
2266 * page 0 (0x80 - 0xff) at the device address 0xA2.
2268 mcdi_upper_page = 3;
2275 case EFX_PHY_MEDIA_QSFP_PLUS:
2277 case EFX_PHY_MEDIA_INFO_DEV_ADDR_QSFP:
2279 * MCDI page -1 should be used to access lower page 0
2282 mcdi_lower_page = (uint32_t)-1;
2284 * MCDI page 0 should be used to access upper page 0
2287 mcdi_upper_page = 0;
2299 EFX_STATIC_ASSERT(EFX_PHY_MEDIA_INFO_PAGE_SIZE <= 0xFF);
2301 if (offset < EFX_PHY_MEDIA_INFO_PAGE_SIZE) {
2303 MIN(len, EFX_PHY_MEDIA_INFO_PAGE_SIZE - offset);
2305 rc = efx_mcdi_get_phy_media_info(enp,
2306 mcdi_lower_page, (uint8_t)offset, (uint8_t)read_len, data);
2315 offset -= EFX_PHY_MEDIA_INFO_PAGE_SIZE;
2319 EFSYS_ASSERT3U(len, <=, EFX_PHY_MEDIA_INFO_PAGE_SIZE);
2320 EFSYS_ASSERT3U(offset, <, EFX_PHY_MEDIA_INFO_PAGE_SIZE);
2322 rc = efx_mcdi_get_phy_media_info(enp,
2323 mcdi_upper_page, (uint8_t)offset, (uint8_t)len, data);
2335 EFSYS_PROBE1(fail1, efx_rc_t, rc);
2340 #endif /* EFSYS_OPT_MCDI */