Lines Matching +full:poll +full:- +full:retry +full:- +full:count
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright 2008-2013 Solarflare Communications Inc.
17 * Management-Controller-to-Driver Interface
57 "Enable MCDI logging on newly-probed functions");
64 int rc = -ENOMEM; in efx_mcdi_init()
66 efx->mcdi = kzalloc(sizeof(*efx->mcdi), GFP_KERNEL); in efx_mcdi_init()
67 if (!efx->mcdi) in efx_mcdi_init()
71 mcdi->efx = efx; in efx_mcdi_init()
73 /* consuming code assumes buffer is page-sized */ in efx_mcdi_init()
74 mcdi->logging_buffer = (char *)__get_free_page(GFP_KERNEL); in efx_mcdi_init()
75 if (!mcdi->logging_buffer) in efx_mcdi_init()
77 mcdi->logging_enabled = mcdi_logging_default; in efx_mcdi_init()
79 init_waitqueue_head(&mcdi->wq); in efx_mcdi_init()
80 init_waitqueue_head(&mcdi->proxy_rx_wq); in efx_mcdi_init()
81 spin_lock_init(&mcdi->iface_lock); in efx_mcdi_init()
82 mcdi->state = MCDI_STATE_QUIESCENT; in efx_mcdi_init()
83 mcdi->mode = MCDI_MODE_POLL; in efx_mcdi_init()
84 spin_lock_init(&mcdi->async_lock); in efx_mcdi_init()
85 INIT_LIST_HEAD(&mcdi->async_list); in efx_mcdi_init()
86 timer_setup(&mcdi->async_timer, efx_mcdi_timeout_async, 0); in efx_mcdi_init()
89 mcdi->new_epoch = true; in efx_mcdi_init()
101 pci_err(efx->pci_dev, "Unable to register driver with MCPU\n"); in efx_mcdi_init()
106 pci_err(efx->pci_dev, "Host already registered with MCPU\n"); in efx_mcdi_init()
108 if (efx->mcdi->fn_flags & in efx_mcdi_init()
110 efx->primary = efx; in efx_mcdi_init()
115 free_page((unsigned long)mcdi->logging_buffer); in efx_mcdi_init()
118 kfree(efx->mcdi); in efx_mcdi_init()
119 efx->mcdi = NULL; in efx_mcdi_init()
126 if (!efx->mcdi) in efx_mcdi_detach()
129 BUG_ON(efx->mcdi->iface.state != MCDI_STATE_QUIESCENT); in efx_mcdi_detach()
137 if (!efx->mcdi) in efx_mcdi_fini()
141 free_page((unsigned long)efx->mcdi->iface.logging_buffer); in efx_mcdi_fini()
144 kfree(efx->mcdi); in efx_mcdi_fini()
152 char *buf = mcdi->logging_buffer; /* page-sized */ in efx_mcdi_send_request()
158 BUG_ON(mcdi->state == MCDI_STATE_QUIESCENT); in efx_mcdi_send_request()
161 spin_lock_bh(&mcdi->iface_lock); in efx_mcdi_send_request()
162 ++mcdi->seqno; in efx_mcdi_send_request()
163 seqno = mcdi->seqno & SEQ_MASK; in efx_mcdi_send_request()
164 spin_unlock_bh(&mcdi->iface_lock); in efx_mcdi_send_request()
167 if (mcdi->mode == MCDI_MODE_EVENTS) in efx_mcdi_send_request()
170 if (efx->type->mcdi_max_ver == 1) { in efx_mcdi_send_request()
179 MCDI_HEADER_NOT_EPOCH, !mcdi->new_epoch); in efx_mcdi_send_request()
191 MCDI_HEADER_NOT_EPOCH, !mcdi->new_epoch); in efx_mcdi_send_request()
199 if (mcdi->logging_enabled && !WARN_ON_ONCE(!buf)) { in efx_mcdi_send_request()
212 bytes += scnprintf(buf + bytes, PAGE_SIZE - bytes, in efx_mcdi_send_request()
217 bytes += scnprintf(buf + bytes, PAGE_SIZE - bytes, in efx_mcdi_send_request()
221 netif_info(efx, hw, efx->net_dev, "MCDI RPC REQ:%s\n", buf); in efx_mcdi_send_request()
225 efx->type->mcdi_request(efx, hdr, hdr_len, inbuf, inlen); in efx_mcdi_send_request()
227 mcdi->new_epoch = false; in efx_mcdi_send_request()
237 return -name; in efx_mcdi_errno()
252 return -EOPNOTSUPP; in efx_mcdi_errno()
254 return -ENOBUFS; in efx_mcdi_errno()
256 return -EADDRINUSE; in efx_mcdi_errno()
258 return -EPROTO; in efx_mcdi_errno()
267 char *buf = mcdi->logging_buffer; /* page-sized */ in efx_mcdi_read_response_header()
271 efx->type->mcdi_read_response(efx, &hdr, 0, 4); in efx_mcdi_read_response_header()
277 mcdi->resp_hdr_len = 4; in efx_mcdi_read_response_header()
278 mcdi->resp_data_len = EFX_DWORD_FIELD(hdr, MCDI_HEADER_DATALEN); in efx_mcdi_read_response_header()
280 efx->type->mcdi_read_response(efx, &hdr, 4, 4); in efx_mcdi_read_response_header()
281 mcdi->resp_hdr_len = 8; in efx_mcdi_read_response_header()
282 mcdi->resp_data_len = in efx_mcdi_read_response_header()
287 if (mcdi->logging_enabled && !WARN_ON_ONCE(!buf)) { in efx_mcdi_read_response_header()
292 WARN_ON_ONCE(mcdi->resp_hdr_len % 4); in efx_mcdi_read_response_header()
293 hdr_len = mcdi->resp_hdr_len / 4; in efx_mcdi_read_response_header()
297 data_len = DIV_ROUND_UP(mcdi->resp_data_len, 4); in efx_mcdi_read_response_header()
303 efx->type->mcdi_read_response(efx, &hdr, (i * 4), 4); in efx_mcdi_read_response_header()
304 bytes += scnprintf(buf + bytes, PAGE_SIZE - bytes, in efx_mcdi_read_response_header()
309 efx->type->mcdi_read_response(efx, &hdr, in efx_mcdi_read_response_header()
310 mcdi->resp_hdr_len + (i * 4), 4); in efx_mcdi_read_response_header()
311 bytes += scnprintf(buf + bytes, PAGE_SIZE - bytes, in efx_mcdi_read_response_header()
315 netif_info(efx, hw, efx->net_dev, "MCDI RPC RESP:%s\n", buf); in efx_mcdi_read_response_header()
319 mcdi->resprc_raw = 0; in efx_mcdi_read_response_header()
320 if (error && mcdi->resp_data_len == 0) { in efx_mcdi_read_response_header()
321 netif_err(efx, hw, efx->net_dev, "MC rebooted\n"); in efx_mcdi_read_response_header()
322 mcdi->resprc = -EIO; in efx_mcdi_read_response_header()
323 } else if ((respseq ^ mcdi->seqno) & SEQ_MASK) { in efx_mcdi_read_response_header()
324 netif_err(efx, hw, efx->net_dev, in efx_mcdi_read_response_header()
326 respseq, mcdi->seqno); in efx_mcdi_read_response_header()
327 mcdi->resprc = -EIO; in efx_mcdi_read_response_header()
329 efx->type->mcdi_read_response(efx, &hdr, mcdi->resp_hdr_len, 4); in efx_mcdi_read_response_header()
330 mcdi->resprc_raw = EFX_DWORD_FIELD(hdr, EFX_DWORD_0); in efx_mcdi_read_response_header()
331 mcdi->resprc = efx_mcdi_errno(mcdi->resprc_raw); in efx_mcdi_read_response_header()
333 mcdi->resprc = 0; in efx_mcdi_read_response_header()
342 if (!efx->type->mcdi_poll_response(efx)) in efx_mcdi_poll_once()
345 spin_lock_bh(&mcdi->iface_lock); in efx_mcdi_poll_once()
347 spin_unlock_bh(&mcdi->iface_lock); in efx_mcdi_poll_once()
362 spin_lock_bh(&mcdi->iface_lock); in efx_mcdi_poll()
363 mcdi->resprc = rc; in efx_mcdi_poll()
364 mcdi->resp_hdr_len = 0; in efx_mcdi_poll()
365 mcdi->resp_data_len = 0; in efx_mcdi_poll()
366 spin_unlock_bh(&mcdi->iface_lock); in efx_mcdi_poll()
370 /* Poll for completion. Poll quickly (once a us) for the 1st jiffy, in efx_mcdi_poll()
372 * and poll once a jiffy (approximately) in efx_mcdi_poll()
379 --spins; in efx_mcdi_poll()
391 return -ETIMEDOUT; in efx_mcdi_poll()
398 /* Test and clear MC-rebooted flag for this port/function; reset
403 if (!efx->mcdi) in efx_mcdi_poll_reboot()
406 return efx->type->mcdi_poll_reboot(efx); in efx_mcdi_poll_reboot()
411 return cmpxchg(&mcdi->state, in efx_mcdi_acquire_async()
421 wait_event(mcdi->wq, in efx_mcdi_acquire_sync()
422 cmpxchg(&mcdi->state, in efx_mcdi_acquire_sync()
431 if (wait_event_timeout(mcdi->wq, mcdi->state == MCDI_STATE_COMPLETED, in efx_mcdi_await_completion()
433 return -ETIMEDOUT; in efx_mcdi_await_completion()
436 * In which case, poll for completions directly. If efx_mcdi_ev_cpl() in efx_mcdi_await_completion()
443 if (mcdi->mode == MCDI_MODE_POLL) in efx_mcdi_await_completion()
454 if (cmpxchg(&mcdi->state, in efx_mcdi_complete_sync()
457 wake_up(&mcdi->wq); in efx_mcdi_complete_sync()
466 if (mcdi->mode == MCDI_MODE_EVENTS) { in efx_mcdi_release()
468 struct efx_nic *efx = mcdi->efx; in efx_mcdi_release()
471 spin_lock_bh(&mcdi->async_lock); in efx_mcdi_release()
473 &mcdi->async_list, struct efx_mcdi_async_param, list); in efx_mcdi_release()
475 mcdi->state = MCDI_STATE_RUNNING_ASYNC; in efx_mcdi_release()
476 efx_mcdi_send_request(efx, async->cmd, in efx_mcdi_release()
478 async->inlen); in efx_mcdi_release()
479 mod_timer(&mcdi->async_timer, in efx_mcdi_release()
482 spin_unlock_bh(&mcdi->async_lock); in efx_mcdi_release()
488 mcdi->state = MCDI_STATE_QUIESCENT; in efx_mcdi_release()
489 wake_up(&mcdi->wq); in efx_mcdi_release()
494 * Return whether this was done. Must be called in bh-disabled
499 struct efx_nic *efx = mcdi->efx; in efx_mcdi_complete_async()
506 if (cmpxchg(&mcdi->state, in efx_mcdi_complete_async()
511 spin_lock(&mcdi->iface_lock); in efx_mcdi_complete_async()
516 ++mcdi->seqno; in efx_mcdi_complete_async()
517 ++mcdi->credits; in efx_mcdi_complete_async()
518 rc = -ETIMEDOUT; in efx_mcdi_complete_async()
522 rc = mcdi->resprc; in efx_mcdi_complete_async()
523 hdr_len = mcdi->resp_hdr_len; in efx_mcdi_complete_async()
524 data_len = mcdi->resp_data_len; in efx_mcdi_complete_async()
526 spin_unlock(&mcdi->iface_lock); in efx_mcdi_complete_async()
533 del_timer_sync(&mcdi->async_timer); in efx_mcdi_complete_async()
535 spin_lock(&mcdi->async_lock); in efx_mcdi_complete_async()
536 async = list_first_entry(&mcdi->async_list, in efx_mcdi_complete_async()
538 list_del(&async->list); in efx_mcdi_complete_async()
539 spin_unlock(&mcdi->async_lock); in efx_mcdi_complete_async()
542 efx->type->mcdi_read_response(efx, outbuf, hdr_len, in efx_mcdi_complete_async()
543 min(async->outlen, data_len)); in efx_mcdi_complete_async()
544 if (!timeout && rc && !async->quiet) { in efx_mcdi_complete_async()
546 efx->type->mcdi_read_response(efx, errbuf, hdr_len, in efx_mcdi_complete_async()
548 efx_mcdi_display_error(efx, async->cmd, async->inlen, errbuf, in efx_mcdi_complete_async()
552 if (async->complete) in efx_mcdi_complete_async()
553 async->complete(efx, async->cookie, rc, outbuf, in efx_mcdi_complete_async()
554 min(async->outlen, data_len)); in efx_mcdi_complete_async()
568 spin_lock(&mcdi->iface_lock); in efx_mcdi_ev_cpl()
570 if ((seqno ^ mcdi->seqno) & SEQ_MASK) { in efx_mcdi_ev_cpl()
571 if (mcdi->credits) in efx_mcdi_ev_cpl()
573 --mcdi->credits; in efx_mcdi_ev_cpl()
575 netif_err(efx, hw, efx->net_dev, in efx_mcdi_ev_cpl()
577 "seq 0x%x\n", seqno, mcdi->seqno); in efx_mcdi_ev_cpl()
579 if (efx->type->mcdi_max_ver >= 2) { in efx_mcdi_ev_cpl()
583 mcdi->resprc = efx_mcdi_errno(mcdi_err); in efx_mcdi_ev_cpl()
584 mcdi->resp_hdr_len = 4; in efx_mcdi_ev_cpl()
585 mcdi->resp_data_len = datalen; in efx_mcdi_ev_cpl()
591 spin_unlock(&mcdi->iface_lock); in efx_mcdi_ev_cpl()
616 if (efx->type->mcdi_max_ver < 0 || in efx_mcdi_check_supported()
617 (efx->type->mcdi_max_ver < 2 && in efx_mcdi_check_supported()
619 return -EINVAL; in efx_mcdi_check_supported()
622 (efx->type->mcdi_max_ver < 2 && in efx_mcdi_check_supported()
624 return -EMSGSIZE; in efx_mcdi_check_supported()
639 efx->type->mcdi_read_response(efx, testbuf, hdr_len, buflen); in efx_mcdi_get_proxy_handle()
658 if (mcdi->mode == MCDI_MODE_POLL) in _efx_mcdi_rpc_finish()
664 netif_err(efx, hw, efx->net_dev, in _efx_mcdi_rpc_finish()
666 cmd, (int)inlen, mcdi->mode); in _efx_mcdi_rpc_finish()
668 if (mcdi->mode == MCDI_MODE_EVENTS && efx_mcdi_poll_once(efx)) { in _efx_mcdi_rpc_finish()
669 netif_err(efx, hw, efx->net_dev, in _efx_mcdi_rpc_finish()
680 spin_lock_bh(&mcdi->iface_lock); in _efx_mcdi_rpc_finish()
681 ++mcdi->seqno; in _efx_mcdi_rpc_finish()
682 ++mcdi->credits; in _efx_mcdi_rpc_finish()
683 spin_unlock_bh(&mcdi->iface_lock); in _efx_mcdi_rpc_finish()
699 spin_lock_bh(&mcdi->iface_lock); in _efx_mcdi_rpc_finish()
700 rc = mcdi->resprc; in _efx_mcdi_rpc_finish()
702 *raw_rc = mcdi->resprc_raw; in _efx_mcdi_rpc_finish()
703 hdr_len = mcdi->resp_hdr_len; in _efx_mcdi_rpc_finish()
704 data_len = mcdi->resp_data_len; in _efx_mcdi_rpc_finish()
706 spin_unlock_bh(&mcdi->iface_lock); in _efx_mcdi_rpc_finish()
710 efx->type->mcdi_read_response(efx, outbuf, hdr_len, in _efx_mcdi_rpc_finish()
715 efx->type->mcdi_read_response(efx, errbuf, hdr_len, err_len); in _efx_mcdi_rpc_finish()
717 if (cmd == MC_CMD_REBOOT && rc == -EIO) { in _efx_mcdi_rpc_finish()
719 } else if (rc == -EIO || rc == -EINTR) { in _efx_mcdi_rpc_finish()
720 netif_err(efx, hw, efx->net_dev, "MC reboot detected\n"); in _efx_mcdi_rpc_finish()
721 netif_dbg(efx, hw, efx->net_dev, "MC rebooted during command %d rc %d\n", in _efx_mcdi_rpc_finish()
722 cmd, -rc); in _efx_mcdi_rpc_finish()
723 if (efx->type->mcdi_reboot_detected) in _efx_mcdi_rpc_finish()
724 efx->type->mcdi_reboot_detected(efx); in _efx_mcdi_rpc_finish()
726 } else if (proxy_handle && (rc == -EPROTO) && in _efx_mcdi_rpc_finish()
729 mcdi->proxy_rx_status = 0; in _efx_mcdi_rpc_finish()
730 mcdi->proxy_rx_handle = 0; in _efx_mcdi_rpc_finish()
731 mcdi->state = MCDI_STATE_PROXY_WAIT; in _efx_mcdi_rpc_finish()
737 if (rc == -EIO || rc == -EINTR) { in _efx_mcdi_rpc_finish()
740 mcdi->new_epoch = true; in _efx_mcdi_rpc_finish()
751 if (mcdi->state == MCDI_STATE_PROXY_WAIT) { in efx_mcdi_proxy_abort()
753 mcdi->proxy_rx_status = -EINTR; in efx_mcdi_proxy_abort()
754 wake_up(&mcdi->proxy_rx_wq); in efx_mcdi_proxy_abort()
763 WARN_ON(mcdi->state != MCDI_STATE_PROXY_WAIT); in efx_mcdi_ev_proxy_response()
765 mcdi->proxy_rx_status = efx_mcdi_errno(status); in efx_mcdi_ev_proxy_response()
770 mcdi->proxy_rx_handle = handle; in efx_mcdi_ev_proxy_response()
771 wake_up(&mcdi->proxy_rx_wq); in efx_mcdi_ev_proxy_response()
780 rc = wait_event_timeout(mcdi->proxy_rx_wq, in efx_mcdi_proxy_wait()
781 mcdi->proxy_rx_handle != 0 || in efx_mcdi_proxy_wait()
782 mcdi->proxy_rx_status == -EINTR, in efx_mcdi_proxy_wait()
786 netif_dbg(efx, hw, efx->net_dev, in efx_mcdi_proxy_wait()
788 return -ETIMEDOUT; in efx_mcdi_proxy_wait()
789 } else if (mcdi->proxy_rx_handle != handle) { in efx_mcdi_proxy_wait()
790 netif_warn(efx, hw, efx->net_dev, in efx_mcdi_proxy_wait()
792 mcdi->proxy_rx_handle, handle); in efx_mcdi_proxy_wait()
793 return -EINVAL; in efx_mcdi_proxy_wait()
796 return mcdi->proxy_rx_status; in efx_mcdi_proxy_wait()
810 return -EINVAL; in _efx_mcdi_rpc()
827 netif_dbg(efx, hw, efx->net_dev, in _efx_mcdi_rpc()
833 netif_dbg(efx, hw, efx->net_dev, in _efx_mcdi_rpc()
834 "MCDI proxy retry %d\n", proxy_handle); in _efx_mcdi_rpc()
836 /* We now retry the original request. */ in _efx_mcdi_rpc()
837 mcdi->state = MCDI_STATE_RUNNING_SYNC; in _efx_mcdi_rpc()
844 netif_cond_dbg(efx, hw, efx->net_dev, rc == -EPERM, err, in _efx_mcdi_rpc()
848 if (rc == -EINTR || rc == -EIO) in _efx_mcdi_rpc()
868 if ((rc == -EPROTO) && (raw_rc == MC_CMD_ERR_NO_EVB_PORT) && in _efx_mcdi_rpc_evb_retry()
869 efx->type->is_vf) { in _efx_mcdi_rpc_evb_retry()
872 * retry our request shortly. in _efx_mcdi_rpc_evb_retry()
877 netif_dbg(efx, hw, efx->net_dev, in _efx_mcdi_rpc_evb_retry()
878 "%s: NO_EVB_PORT; will retry request\n", in _efx_mcdi_rpc_evb_retry()
888 } while ((rc == -EPROTO) && in _efx_mcdi_rpc_evb_retry()
893 if (rc && !quiet && !(cmd == MC_CMD_REBOOT && rc == -EIO)) in _efx_mcdi_rpc_evb_retry()
901 * efx_mcdi_rpc - Issue an MCDI command and wait for completion
960 if (efx->mc_bist_for_other_fn) in efx_mcdi_rpc_start()
961 return -ENETDOWN; in efx_mcdi_rpc_start()
963 if (mcdi->mode == MCDI_MODE_FAIL) in efx_mcdi_rpc_start()
964 return -ENETDOWN; in efx_mcdi_rpc_start()
985 if (efx->mc_bist_for_other_fn) in _efx_mcdi_rpc_async()
986 return -ENETDOWN; in _efx_mcdi_rpc_async()
991 return -ENOMEM; in _efx_mcdi_rpc_async()
993 async->cmd = cmd; in _efx_mcdi_rpc_async()
994 async->inlen = inlen; in _efx_mcdi_rpc_async()
995 async->outlen = outlen; in _efx_mcdi_rpc_async()
996 async->quiet = quiet; in _efx_mcdi_rpc_async()
997 async->complete = complete; in _efx_mcdi_rpc_async()
998 async->cookie = cookie; in _efx_mcdi_rpc_async()
1001 spin_lock_bh(&mcdi->async_lock); in _efx_mcdi_rpc_async()
1003 if (mcdi->mode == MCDI_MODE_EVENTS) { in _efx_mcdi_rpc_async()
1004 list_add_tail(&async->list, &mcdi->async_list); in _efx_mcdi_rpc_async()
1009 if (mcdi->async_list.next == &async->list && in _efx_mcdi_rpc_async()
1012 mod_timer(&mcdi->async_timer, in _efx_mcdi_rpc_async()
1017 rc = -ENETDOWN; in _efx_mcdi_rpc_async()
1020 spin_unlock_bh(&mcdi->async_lock); in _efx_mcdi_rpc_async()
1026 * efx_mcdi_rpc_async - Schedule an MCDI command to run asynchronously
1043 * (c) the request times-out (in timer context)
1089 netif_cond_dbg(efx, hw, efx->net_dev, rc == -EPERM, err, in efx_mcdi_display_error()
1102 if (!efx->mcdi) in efx_mcdi_mode_poll()
1107 * If in fail-fast state, don't switch to polled completion. in efx_mcdi_mode_poll()
1110 if (mcdi->mode == MCDI_MODE_POLL || mcdi->mode == MCDI_MODE_FAIL) in efx_mcdi_mode_poll()
1115 * switching the mode to POLL'd then completing the request. in efx_mcdi_mode_poll()
1121 mcdi->mode = MCDI_MODE_POLL; in efx_mcdi_mode_poll()
1134 if (!efx->mcdi) in efx_mcdi_flush_async()
1139 /* We must be in poll or fail mode so no more requests can be queued */ in efx_mcdi_flush_async()
1140 BUG_ON(mcdi->mode == MCDI_MODE_EVENTS); in efx_mcdi_flush_async()
1142 del_timer_sync(&mcdi->async_timer); in efx_mcdi_flush_async()
1148 if (mcdi->state == MCDI_STATE_RUNNING_ASYNC) { in efx_mcdi_flush_async()
1150 mcdi->state = MCDI_STATE_QUIESCENT; in efx_mcdi_flush_async()
1158 list_for_each_entry_safe(async, next, &mcdi->async_list, list) { in efx_mcdi_flush_async()
1159 if (async->complete) in efx_mcdi_flush_async()
1160 async->complete(efx, async->cookie, -ENETDOWN, NULL, 0); in efx_mcdi_flush_async()
1161 list_del(&async->list); in efx_mcdi_flush_async()
1170 if (!efx->mcdi) in efx_mcdi_mode_event()
1175 * If in fail-fast state, don't switch to event completion. FLR in efx_mcdi_mode_event()
1178 if (mcdi->mode == MCDI_MODE_EVENTS || mcdi->mode == MCDI_MODE_FAIL) in efx_mcdi_mode_event()
1189 mcdi->mode = MCDI_MODE_EVENTS; in efx_mcdi_mode_event()
1213 * event mode, this condition is just an edge-case of in efx_mcdi_ev_death()
1221 spin_lock(&mcdi->iface_lock); in efx_mcdi_ev_death()
1225 if (mcdi->mode == MCDI_MODE_EVENTS) { in efx_mcdi_ev_death()
1226 mcdi->resprc = rc; in efx_mcdi_ev_death()
1227 mcdi->resp_hdr_len = 0; in efx_mcdi_ev_death()
1228 mcdi->resp_data_len = 0; in efx_mcdi_ev_death()
1229 ++mcdi->credits; in efx_mcdi_ev_death()
1232 int count; in efx_mcdi_ev_death() local
1235 for (count = 0; count < MCDI_STATUS_DELAY_COUNT; ++count) { in efx_mcdi_ev_death()
1248 if (!rc && efx->type->mcdi_reboot_detected) in efx_mcdi_ev_death()
1249 efx->type->mcdi_reboot_detected(efx); in efx_mcdi_ev_death()
1251 mcdi->new_epoch = true; in efx_mcdi_ev_death()
1257 spin_unlock(&mcdi->iface_lock); in efx_mcdi_ev_death()
1261 * new MCDI, cancel any outstanding MCDI and schedule a BIST-type reset
1269 spin_lock(&mcdi->iface_lock); in efx_mcdi_ev_bist()
1270 efx->mc_bist_for_other_fn = true; in efx_mcdi_ev_bist()
1274 if (mcdi->mode == MCDI_MODE_EVENTS) { in efx_mcdi_ev_bist()
1275 mcdi->resprc = -EIO; in efx_mcdi_ev_bist()
1276 mcdi->resp_hdr_len = 0; in efx_mcdi_ev_bist()
1277 mcdi->resp_data_len = 0; in efx_mcdi_ev_bist()
1278 ++mcdi->credits; in efx_mcdi_ev_bist()
1281 mcdi->new_epoch = true; in efx_mcdi_ev_bist()
1283 spin_unlock(&mcdi->iface_lock); in efx_mcdi_ev_bist()
1286 /* MCDI timeouts seen, so make all MCDI calls fail-fast and issue an FLR to try
1293 if (xchg(&mcdi->mode, MCDI_MODE_FAIL) == MCDI_MODE_FAIL) in efx_mcdi_abandon()
1295 netif_dbg(efx, hw, efx->net_dev, "MCDI is timing out; trying to recover\n"); in efx_mcdi_abandon()
1301 if (atomic_dec_and_test(&efx->active_queues)) in efx_handle_drain_event()
1302 wake_up(&efx->flush_wq); in efx_handle_drain_event()
1304 WARN_ON(atomic_read(&efx->active_queues) < 0); in efx_handle_drain_event()
1311 struct efx_nic *efx = channel->efx; in efx_mcdi_process_event()
1317 netif_err(efx, hw, efx->net_dev, in efx_mcdi_process_event()
1319 efx_mcdi_ev_death(efx, -EINTR); in efx_mcdi_process_event()
1323 netif_info(efx, wol, efx->net_dev, "MCDI PM event.\n"); in efx_mcdi_process_event()
1340 netif_dbg(efx, hw, efx->net_dev, in efx_mcdi_process_event()
1345 netif_info(efx, hw, efx->net_dev, "MC Reboot\n"); in efx_mcdi_process_event()
1346 efx_mcdi_ev_death(efx, -EIO); in efx_mcdi_process_event()
1349 netif_info(efx, hw, efx->net_dev, "MC entered BIST mode\n"); in efx_mcdi_process_event()
1377 netif_err(efx, hw, efx->net_dev, in efx_mcdi_process_event()
1389 netif_err(efx, hw, efx->net_dev, in efx_mcdi_process_event()
1416 rc = -EIO; in efx_mcdi_print_fwver()
1427 if (efx->type->print_additional_fwver) in efx_mcdi_print_fwver()
1428 offset += efx->type->print_additional_fwver(efx, buf + offset, in efx_mcdi_print_fwver()
1429 len - offset); in efx_mcdi_print_fwver()
1441 pci_err(efx->pci_dev, "%s: failed rc=%d\n", __func__, rc); in efx_mcdi_print_fwver()
1464 if (rc == -EPERM) { in efx_mcdi_drv_attach()
1465 pci_dbg(efx->pci_dev, in efx_mcdi_drv_attach()
1466 "%s with fw-variant setting failed EPERM, trying without it\n", in efx_mcdi_drv_attach()
1480 rc = -EIO; in efx_mcdi_drv_attach()
1486 efx->mcdi->fn_flags = in efx_mcdi_drv_attach()
1491 efx->mcdi->fn_flags = in efx_mcdi_drv_attach()
1509 pci_err(efx->pci_dev, "%s: failed rc=%d\n", __func__, rc); in efx_mcdi_drv_attach()
1532 rc = -EIO; in efx_mcdi_get_board_cfg()
1563 netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d len=%d\n", in efx_mcdi_get_board_cfg()
1603 rc = -EIO; in efx_mcdi_nvram_types()
1611 netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", in efx_mcdi_nvram_types()
1626 return -ENOMEM; in efx_new_mcdi_nvram_types()
1661 rc = -EIO; in efx_mcdi_nvram_info()
1672 netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc); in efx_mcdi_nvram_info()
1694 return -EIO; in efx_mcdi_nvram_test()
1707 return -ENOMEM; in efx_new_mcdi_nvram_test_all()
1714 rc = -EAGAIN; in efx_new_mcdi_nvram_test_all()
1755 netif_err(efx, hw, efx->net_dev, "%s: failed type=%u\n", in efx_mcdi_nvram_test_all()
1758 netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc); in efx_mcdi_nvram_test_all()
1772 int retry; in efx_mcdi_read_assertion() local
1776 * the mcfw out of the assertion handler. Retry twice, once in efx_mcdi_read_assertion()
1777 * because a boot-time assertion might cause this command to fail in efx_mcdi_read_assertion()
1780 retry = 2; in efx_mcdi_read_assertion()
1786 if (rc == -EPERM) in efx_mcdi_read_assertion()
1788 } while ((rc == -EINTR || rc == -EIO) && retry-- > 0); in efx_mcdi_read_assertion()
1797 return -EIO; in efx_mcdi_read_assertion()
1805 ? "system-level assertion" in efx_mcdi_read_assertion()
1807 ? "thread-level assertion" in efx_mcdi_read_assertion()
1811 netif_err(efx, hw, efx->net_dev, in efx_mcdi_read_assertion()
1820 netif_err(efx, hw, efx->net_dev, "R%.2d (?): 0x%.8x\n", in efx_mcdi_read_assertion()
1835 * reboot. We set a flag that makes the command a no-op if it in efx_mcdi_exit_assertion()
1837 * The MCDI will thus return either 0 or -EIO. in efx_mcdi_exit_assertion()
1844 if (rc == -EIO) in efx_mcdi_exit_assertion()
1901 if (rc == -EIO) in efx_mcdi_reset_mc()
1904 rc = -EIO; in efx_mcdi_reset_mc()
1919 rc = pci_reset_function(efx->pci_dev); in efx_mcdi_reset()
1922 /* Re-enable polled MCDI completion */ in efx_mcdi_reset()
1923 if (efx->mcdi) { in efx_mcdi_reset()
1925 mcdi->mode = MCDI_MODE_POLL; in efx_mcdi_reset()
1930 /* Recover from a failed assertion pre-reset */ in efx_mcdi_reset()
1962 rc = -EIO; in efx_mcdi_wol_filter_set()
1971 *id_out = -1; in efx_mcdi_wol_filter_set()
1972 netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc); in efx_mcdi_wol_filter_set()
1997 rc = -EIO; in efx_mcdi_wol_filter_get_magic()
2006 *id_out = -1; in efx_mcdi_wol_filter_get_magic()
2007 netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc); in efx_mcdi_wol_filter_get_magic()
2030 int rc, count; in efx_mcdi_flush_rxqs() local
2035 count = 0; in efx_mcdi_flush_rxqs()
2038 if (rx_queue->flush_pending) { in efx_mcdi_flush_rxqs()
2039 rx_queue->flush_pending = false; in efx_mcdi_flush_rxqs()
2040 atomic_dec(&efx->rxq_flush_pending); in efx_mcdi_flush_rxqs()
2043 count, efx_rx_queue_index(rx_queue)); in efx_mcdi_flush_rxqs()
2044 count++; in efx_mcdi_flush_rxqs()
2050 MC_CMD_FLUSH_RX_QUEUES_IN_LEN(count), NULL, 0, NULL); in efx_mcdi_flush_rxqs()
2104 rc = -EIO; in efx_mcdi_get_workarounds()
2120 netif_cond_dbg(efx, hw, efx->net_dev, rc == -ENOSYS, err, in efx_mcdi_get_workarounds()
2139 return -EINVAL; in efx_mcdi_get_privilege_mask()
2148 return -EIO; in efx_mcdi_get_privilege_mask()
2164 return -EIO; in efx_mcdi_get_privilege_mask()
2183 return -ENOMEM; in efx_mcdi_nvram_metadata()
2194 rc = -EIO; in efx_mcdi_nvram_metadata()
2204 rc = -E2BIG; in efx_mcdi_nvram_metadata()
2343 netif_err(efx, drv, efx->net_dev, in efx_mcdi_nvram_update_finish()
2354 rc = -EIO; in efx_mcdi_nvram_update_finish()
2358 rc = -EINVAL; in efx_mcdi_nvram_update_finish()
2363 rc = -EPERM; in efx_mcdi_nvram_update_finish()
2366 netif_err(efx, drv, efx->net_dev, in efx_mcdi_nvram_update_finish()
2368 rc = -EIO; in efx_mcdi_nvram_update_finish()
2379 struct efx_nic *efx = mtd->priv; in efx_mcdi_mtd_read()
2381 loff_t end = min_t(loff_t, start + len, mtd->size); in efx_mcdi_mtd_read()
2386 chunk = min_t(size_t, end - offset, EFX_MCDI_NVRAM_LEN_MAX); in efx_mcdi_mtd_read()
2387 rc = efx_mcdi_nvram_read(efx, part->nvram_type, offset, in efx_mcdi_mtd_read()
2395 *retlen = offset - start; in efx_mcdi_mtd_read()
2402 struct efx_nic *efx = mtd->priv; in efx_mcdi_mtd_erase()
2403 loff_t offset = start & ~((loff_t)(mtd->erasesize - 1)); in efx_mcdi_mtd_erase()
2404 loff_t end = min_t(loff_t, start + len, mtd->size); in efx_mcdi_mtd_erase()
2405 size_t chunk = part->common.mtd.erasesize; in efx_mcdi_mtd_erase()
2408 if (!part->updating) { in efx_mcdi_mtd_erase()
2409 rc = efx_mcdi_nvram_update_start(efx, part->nvram_type); in efx_mcdi_mtd_erase()
2412 part->updating = true; in efx_mcdi_mtd_erase()
2419 rc = efx_mcdi_nvram_erase(efx, part->nvram_type, offset, in efx_mcdi_mtd_erase()
2433 struct efx_nic *efx = mtd->priv; in efx_mcdi_mtd_write()
2435 loff_t end = min_t(loff_t, start + len, mtd->size); in efx_mcdi_mtd_write()
2439 if (!part->updating) { in efx_mcdi_mtd_write()
2440 rc = efx_mcdi_nvram_update_start(efx, part->nvram_type); in efx_mcdi_mtd_write()
2443 part->updating = true; in efx_mcdi_mtd_write()
2447 chunk = min_t(size_t, end - offset, EFX_MCDI_NVRAM_LEN_MAX); in efx_mcdi_mtd_write()
2448 rc = efx_mcdi_nvram_write(efx, part->nvram_type, offset, in efx_mcdi_mtd_write()
2456 *retlen = offset - start; in efx_mcdi_mtd_write()
2463 struct efx_nic *efx = mtd->priv; in efx_mcdi_mtd_sync()
2466 if (part->updating) { in efx_mcdi_mtd_sync()
2467 part->updating = false; in efx_mcdi_mtd_sync()
2468 rc = efx_mcdi_nvram_update_finish(efx, part->nvram_type); in efx_mcdi_mtd_sync()
2478 struct efx_nic *efx = part->mtd.priv; in efx_mcdi_mtd_rename()
2480 snprintf(part->name, sizeof(part->name), "%s %s:%02x", in efx_mcdi_mtd_rename()
2481 efx->name, part->type_name, mcdi_part->fw_subtype); in efx_mcdi_mtd_rename()