Lines Matching +full:reboot +full:- +full:offset
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright 2008-2013 Solarflare Communications Inc.
18 * Management-Controller-to-Driver Interface
25 /* A reboot/assertion causes the MCDI status word to be set after the
26 * command word is set or a REBOOT event is sent. If we notice a reboot
59 "Enable MCDI logging on newly-probed functions");
66 int rc = -ENOMEM; in efx_siena_mcdi_init()
68 efx->mcdi = kzalloc(sizeof(*efx->mcdi), GFP_KERNEL); in efx_siena_mcdi_init()
69 if (!efx->mcdi) in efx_siena_mcdi_init()
73 mcdi->efx = efx; in efx_siena_mcdi_init()
75 /* consuming code assumes buffer is page-sized */ in efx_siena_mcdi_init()
76 mcdi->logging_buffer = (char *)__get_free_page(GFP_KERNEL); in efx_siena_mcdi_init()
77 if (!mcdi->logging_buffer) in efx_siena_mcdi_init()
79 mcdi->logging_enabled = efx_siena_mcdi_logging_default; in efx_siena_mcdi_init()
81 init_waitqueue_head(&mcdi->wq); in efx_siena_mcdi_init()
82 init_waitqueue_head(&mcdi->proxy_rx_wq); in efx_siena_mcdi_init()
83 spin_lock_init(&mcdi->iface_lock); in efx_siena_mcdi_init()
84 mcdi->state = MCDI_STATE_QUIESCENT; in efx_siena_mcdi_init()
85 mcdi->mode = MCDI_MODE_POLL; in efx_siena_mcdi_init()
86 spin_lock_init(&mcdi->async_lock); in efx_siena_mcdi_init()
87 INIT_LIST_HEAD(&mcdi->async_list); in efx_siena_mcdi_init()
88 timer_setup(&mcdi->async_timer, efx_mcdi_timeout_async, 0); in efx_siena_mcdi_init()
91 mcdi->new_epoch = true; in efx_siena_mcdi_init()
103 netif_err(efx, probe, efx->net_dev, in efx_siena_mcdi_init()
109 netif_err(efx, probe, efx->net_dev, in efx_siena_mcdi_init()
112 if (efx->mcdi->fn_flags & in efx_siena_mcdi_init()
114 efx->primary = efx; in efx_siena_mcdi_init()
119 free_page((unsigned long)mcdi->logging_buffer); in efx_siena_mcdi_init()
122 kfree(efx->mcdi); in efx_siena_mcdi_init()
123 efx->mcdi = NULL; in efx_siena_mcdi_init()
130 if (!efx->mcdi) in efx_siena_mcdi_detach()
133 BUG_ON(efx->mcdi->iface.state != MCDI_STATE_QUIESCENT); in efx_siena_mcdi_detach()
141 if (!efx->mcdi) in efx_siena_mcdi_fini()
145 free_page((unsigned long)efx->mcdi->iface.logging_buffer); in efx_siena_mcdi_fini()
148 kfree(efx->mcdi); in efx_siena_mcdi_fini()
156 char *buf = mcdi->logging_buffer; /* page-sized */ in efx_mcdi_send_request()
162 BUG_ON(mcdi->state == MCDI_STATE_QUIESCENT); in efx_mcdi_send_request()
165 spin_lock_bh(&mcdi->iface_lock); in efx_mcdi_send_request()
166 ++mcdi->seqno; in efx_mcdi_send_request()
167 seqno = mcdi->seqno & SEQ_MASK; in efx_mcdi_send_request()
168 spin_unlock_bh(&mcdi->iface_lock); in efx_mcdi_send_request()
171 if (mcdi->mode == MCDI_MODE_EVENTS) in efx_mcdi_send_request()
174 if (efx->type->mcdi_max_ver == 1) { in efx_mcdi_send_request()
183 MCDI_HEADER_NOT_EPOCH, !mcdi->new_epoch); in efx_mcdi_send_request()
195 MCDI_HEADER_NOT_EPOCH, !mcdi->new_epoch); in efx_mcdi_send_request()
203 if (mcdi->logging_enabled && !WARN_ON_ONCE(!buf)) { in efx_mcdi_send_request()
216 bytes += scnprintf(buf + bytes, PAGE_SIZE - bytes, in efx_mcdi_send_request()
221 bytes += scnprintf(buf + bytes, PAGE_SIZE - bytes, in efx_mcdi_send_request()
225 netif_info(efx, hw, efx->net_dev, "MCDI RPC REQ:%s\n", buf); in efx_mcdi_send_request()
229 efx->type->mcdi_request(efx, hdr, hdr_len, inbuf, inlen); in efx_mcdi_send_request()
231 mcdi->new_epoch = false; in efx_mcdi_send_request()
241 return -name; in efx_mcdi_errno()
256 return -EOPNOTSUPP; in efx_mcdi_errno()
258 return -ENOBUFS; in efx_mcdi_errno()
260 return -EADDRINUSE; in efx_mcdi_errno()
262 return -EPROTO; in efx_mcdi_errno()
271 char *buf = mcdi->logging_buffer; /* page-sized */ in efx_mcdi_read_response_header()
275 efx->type->mcdi_read_response(efx, &hdr, 0, 4); in efx_mcdi_read_response_header()
281 mcdi->resp_hdr_len = 4; in efx_mcdi_read_response_header()
282 mcdi->resp_data_len = EFX_DWORD_FIELD(hdr, MCDI_HEADER_DATALEN); in efx_mcdi_read_response_header()
284 efx->type->mcdi_read_response(efx, &hdr, 4, 4); in efx_mcdi_read_response_header()
285 mcdi->resp_hdr_len = 8; in efx_mcdi_read_response_header()
286 mcdi->resp_data_len = in efx_mcdi_read_response_header()
291 if (mcdi->logging_enabled && !WARN_ON_ONCE(!buf)) { in efx_mcdi_read_response_header()
296 WARN_ON_ONCE(mcdi->resp_hdr_len % 4); in efx_mcdi_read_response_header()
297 hdr_len = mcdi->resp_hdr_len / 4; in efx_mcdi_read_response_header()
301 data_len = DIV_ROUND_UP(mcdi->resp_data_len, 4); in efx_mcdi_read_response_header()
307 efx->type->mcdi_read_response(efx, &hdr, (i * 4), 4); in efx_mcdi_read_response_header()
308 bytes += scnprintf(buf + bytes, PAGE_SIZE - bytes, in efx_mcdi_read_response_header()
313 efx->type->mcdi_read_response(efx, &hdr, in efx_mcdi_read_response_header()
314 mcdi->resp_hdr_len + (i * 4), 4); in efx_mcdi_read_response_header()
315 bytes += scnprintf(buf + bytes, PAGE_SIZE - bytes, in efx_mcdi_read_response_header()
319 netif_info(efx, hw, efx->net_dev, "MCDI RPC RESP:%s\n", buf); in efx_mcdi_read_response_header()
323 mcdi->resprc_raw = 0; in efx_mcdi_read_response_header()
324 if (error && mcdi->resp_data_len == 0) { in efx_mcdi_read_response_header()
325 netif_err(efx, hw, efx->net_dev, "MC rebooted\n"); in efx_mcdi_read_response_header()
326 mcdi->resprc = -EIO; in efx_mcdi_read_response_header()
327 } else if ((respseq ^ mcdi->seqno) & SEQ_MASK) { in efx_mcdi_read_response_header()
328 netif_err(efx, hw, efx->net_dev, in efx_mcdi_read_response_header()
330 respseq, mcdi->seqno); in efx_mcdi_read_response_header()
331 mcdi->resprc = -EIO; in efx_mcdi_read_response_header()
333 efx->type->mcdi_read_response(efx, &hdr, mcdi->resp_hdr_len, 4); in efx_mcdi_read_response_header()
334 mcdi->resprc_raw = EFX_DWORD_FIELD(hdr, EFX_DWORD_0); in efx_mcdi_read_response_header()
335 mcdi->resprc = efx_mcdi_errno(mcdi->resprc_raw); in efx_mcdi_read_response_header()
337 mcdi->resprc = 0; in efx_mcdi_read_response_header()
346 if (!efx->type->mcdi_poll_response(efx)) in efx_mcdi_poll_once()
349 spin_lock_bh(&mcdi->iface_lock); in efx_mcdi_poll_once()
351 spin_unlock_bh(&mcdi->iface_lock); in efx_mcdi_poll_once()
363 /* Check for a reboot atomically with respect to efx_mcdi_copyout() */ in efx_mcdi_poll()
366 spin_lock_bh(&mcdi->iface_lock); in efx_mcdi_poll()
367 mcdi->resprc = rc; in efx_mcdi_poll()
368 mcdi->resp_hdr_len = 0; in efx_mcdi_poll()
369 mcdi->resp_data_len = 0; in efx_mcdi_poll()
370 spin_unlock_bh(&mcdi->iface_lock); in efx_mcdi_poll()
383 --spins; in efx_mcdi_poll()
395 return -ETIMEDOUT; in efx_mcdi_poll()
402 /* Test and clear MC-rebooted flag for this port/function; reset
407 if (!efx->mcdi) in efx_siena_mcdi_poll_reboot()
410 return efx->type->mcdi_poll_reboot(efx); in efx_siena_mcdi_poll_reboot()
415 return cmpxchg(&mcdi->state, in efx_mcdi_acquire_async()
425 wait_event(mcdi->wq, in efx_mcdi_acquire_sync()
426 cmpxchg(&mcdi->state, in efx_mcdi_acquire_sync()
435 if (wait_event_timeout(mcdi->wq, mcdi->state == MCDI_STATE_COMPLETED, in efx_mcdi_await_completion()
437 return -ETIMEDOUT; in efx_mcdi_await_completion()
447 if (mcdi->mode == MCDI_MODE_POLL) in efx_mcdi_await_completion()
458 if (cmpxchg(&mcdi->state, in efx_mcdi_complete_sync()
461 wake_up(&mcdi->wq); in efx_mcdi_complete_sync()
470 if (mcdi->mode == MCDI_MODE_EVENTS) { in efx_mcdi_release()
472 struct efx_nic *efx = mcdi->efx; in efx_mcdi_release()
475 spin_lock_bh(&mcdi->async_lock); in efx_mcdi_release()
477 &mcdi->async_list, struct efx_mcdi_async_param, list); in efx_mcdi_release()
479 mcdi->state = MCDI_STATE_RUNNING_ASYNC; in efx_mcdi_release()
480 efx_mcdi_send_request(efx, async->cmd, in efx_mcdi_release()
482 async->inlen); in efx_mcdi_release()
483 mod_timer(&mcdi->async_timer, in efx_mcdi_release()
486 spin_unlock_bh(&mcdi->async_lock); in efx_mcdi_release()
492 mcdi->state = MCDI_STATE_QUIESCENT; in efx_mcdi_release()
493 wake_up(&mcdi->wq); in efx_mcdi_release()
498 * Return whether this was done. Must be called in bh-disabled
503 struct efx_nic *efx = mcdi->efx; in efx_mcdi_complete_async()
510 if (cmpxchg(&mcdi->state, in efx_mcdi_complete_async()
515 spin_lock(&mcdi->iface_lock); in efx_mcdi_complete_async()
520 ++mcdi->seqno; in efx_mcdi_complete_async()
521 ++mcdi->credits; in efx_mcdi_complete_async()
522 rc = -ETIMEDOUT; in efx_mcdi_complete_async()
526 rc = mcdi->resprc; in efx_mcdi_complete_async()
527 hdr_len = mcdi->resp_hdr_len; in efx_mcdi_complete_async()
528 data_len = mcdi->resp_data_len; in efx_mcdi_complete_async()
530 spin_unlock(&mcdi->iface_lock); in efx_mcdi_complete_async()
537 del_timer_sync(&mcdi->async_timer); in efx_mcdi_complete_async()
539 spin_lock(&mcdi->async_lock); in efx_mcdi_complete_async()
540 async = list_first_entry(&mcdi->async_list, in efx_mcdi_complete_async()
542 list_del(&async->list); in efx_mcdi_complete_async()
543 spin_unlock(&mcdi->async_lock); in efx_mcdi_complete_async()
546 efx->type->mcdi_read_response(efx, outbuf, hdr_len, in efx_mcdi_complete_async()
547 min(async->outlen, data_len)); in efx_mcdi_complete_async()
548 if (!timeout && rc && !async->quiet) { in efx_mcdi_complete_async()
550 efx->type->mcdi_read_response(efx, errbuf, hdr_len, in efx_mcdi_complete_async()
552 efx_siena_mcdi_display_error(efx, async->cmd, async->inlen, in efx_mcdi_complete_async()
556 if (async->complete) in efx_mcdi_complete_async()
557 async->complete(efx, async->cookie, rc, outbuf, in efx_mcdi_complete_async()
558 min(async->outlen, data_len)); in efx_mcdi_complete_async()
572 spin_lock(&mcdi->iface_lock); in efx_mcdi_ev_cpl()
574 if ((seqno ^ mcdi->seqno) & SEQ_MASK) { in efx_mcdi_ev_cpl()
575 if (mcdi->credits) in efx_mcdi_ev_cpl()
577 --mcdi->credits; in efx_mcdi_ev_cpl()
579 netif_err(efx, hw, efx->net_dev, in efx_mcdi_ev_cpl()
581 "seq 0x%x\n", seqno, mcdi->seqno); in efx_mcdi_ev_cpl()
583 if (efx->type->mcdi_max_ver >= 2) { in efx_mcdi_ev_cpl()
587 mcdi->resprc = efx_mcdi_errno(mcdi_err); in efx_mcdi_ev_cpl()
588 mcdi->resp_hdr_len = 4; in efx_mcdi_ev_cpl()
589 mcdi->resp_data_len = datalen; in efx_mcdi_ev_cpl()
595 spin_unlock(&mcdi->iface_lock); in efx_mcdi_ev_cpl()
620 if (efx->type->mcdi_max_ver < 0 || in efx_mcdi_check_supported()
621 (efx->type->mcdi_max_ver < 2 && in efx_mcdi_check_supported()
623 return -EINVAL; in efx_mcdi_check_supported()
626 (efx->type->mcdi_max_ver < 2 && in efx_mcdi_check_supported()
628 return -EMSGSIZE; in efx_mcdi_check_supported()
643 efx->type->mcdi_read_response(efx, testbuf, hdr_len, buflen); in efx_mcdi_get_proxy_handle()
662 if (mcdi->mode == MCDI_MODE_POLL) in _efx_mcdi_rpc_finish()
668 netif_err(efx, hw, efx->net_dev, in _efx_mcdi_rpc_finish()
670 cmd, (int)inlen, mcdi->mode); in _efx_mcdi_rpc_finish()
672 if (mcdi->mode == MCDI_MODE_EVENTS && efx_mcdi_poll_once(efx)) { in _efx_mcdi_rpc_finish()
673 netif_err(efx, hw, efx->net_dev, in _efx_mcdi_rpc_finish()
684 spin_lock_bh(&mcdi->iface_lock); in _efx_mcdi_rpc_finish()
685 ++mcdi->seqno; in _efx_mcdi_rpc_finish()
686 ++mcdi->credits; in _efx_mcdi_rpc_finish()
687 spin_unlock_bh(&mcdi->iface_lock); in _efx_mcdi_rpc_finish()
703 spin_lock_bh(&mcdi->iface_lock); in _efx_mcdi_rpc_finish()
704 rc = mcdi->resprc; in _efx_mcdi_rpc_finish()
706 *raw_rc = mcdi->resprc_raw; in _efx_mcdi_rpc_finish()
707 hdr_len = mcdi->resp_hdr_len; in _efx_mcdi_rpc_finish()
708 data_len = mcdi->resp_data_len; in _efx_mcdi_rpc_finish()
710 spin_unlock_bh(&mcdi->iface_lock); in _efx_mcdi_rpc_finish()
714 efx->type->mcdi_read_response(efx, outbuf, hdr_len, in _efx_mcdi_rpc_finish()
719 efx->type->mcdi_read_response(efx, errbuf, hdr_len, err_len); in _efx_mcdi_rpc_finish()
721 if (cmd == MC_CMD_REBOOT && rc == -EIO) { in _efx_mcdi_rpc_finish()
723 } else if (rc == -EIO || rc == -EINTR) { in _efx_mcdi_rpc_finish()
724 netif_err(efx, hw, efx->net_dev, "MC reboot detected\n"); in _efx_mcdi_rpc_finish()
725 netif_dbg(efx, hw, efx->net_dev, "MC rebooted during command %d rc %d\n", in _efx_mcdi_rpc_finish()
726 cmd, -rc); in _efx_mcdi_rpc_finish()
727 if (efx->type->mcdi_reboot_detected) in _efx_mcdi_rpc_finish()
728 efx->type->mcdi_reboot_detected(efx); in _efx_mcdi_rpc_finish()
730 } else if (proxy_handle && (rc == -EPROTO) && in _efx_mcdi_rpc_finish()
733 mcdi->proxy_rx_status = 0; in _efx_mcdi_rpc_finish()
734 mcdi->proxy_rx_handle = 0; in _efx_mcdi_rpc_finish()
735 mcdi->state = MCDI_STATE_PROXY_WAIT; in _efx_mcdi_rpc_finish()
741 if (rc == -EIO || rc == -EINTR) { in _efx_mcdi_rpc_finish()
744 mcdi->new_epoch = true; in _efx_mcdi_rpc_finish()
755 if (mcdi->state == MCDI_STATE_PROXY_WAIT) { in efx_mcdi_proxy_abort()
757 mcdi->proxy_rx_status = -EINTR; in efx_mcdi_proxy_abort()
758 wake_up(&mcdi->proxy_rx_wq); in efx_mcdi_proxy_abort()
767 WARN_ON(mcdi->state != MCDI_STATE_PROXY_WAIT); in efx_mcdi_ev_proxy_response()
769 mcdi->proxy_rx_status = efx_mcdi_errno(status); in efx_mcdi_ev_proxy_response()
774 mcdi->proxy_rx_handle = handle; in efx_mcdi_ev_proxy_response()
775 wake_up(&mcdi->proxy_rx_wq); in efx_mcdi_ev_proxy_response()
784 rc = wait_event_timeout(mcdi->proxy_rx_wq, in efx_mcdi_proxy_wait()
785 mcdi->proxy_rx_handle != 0 || in efx_mcdi_proxy_wait()
786 mcdi->proxy_rx_status == -EINTR, in efx_mcdi_proxy_wait()
790 netif_dbg(efx, hw, efx->net_dev, in efx_mcdi_proxy_wait()
792 return -ETIMEDOUT; in efx_mcdi_proxy_wait()
793 } else if (mcdi->proxy_rx_handle != handle) { in efx_mcdi_proxy_wait()
794 netif_warn(efx, hw, efx->net_dev, in efx_mcdi_proxy_wait()
796 mcdi->proxy_rx_handle, handle); in efx_mcdi_proxy_wait()
797 return -EINVAL; in efx_mcdi_proxy_wait()
800 return mcdi->proxy_rx_status; in efx_mcdi_proxy_wait()
814 return -EINVAL; in _efx_mcdi_rpc()
831 netif_dbg(efx, hw, efx->net_dev, in _efx_mcdi_rpc()
837 netif_dbg(efx, hw, efx->net_dev, in _efx_mcdi_rpc()
841 mcdi->state = MCDI_STATE_RUNNING_SYNC; in _efx_mcdi_rpc()
848 netif_cond_dbg(efx, hw, efx->net_dev, rc == -EPERM, err, in _efx_mcdi_rpc()
852 if (rc == -EINTR || rc == -EIO) in _efx_mcdi_rpc()
872 if ((rc == -EPROTO) && (raw_rc == MC_CMD_ERR_NO_EVB_PORT) && in _efx_mcdi_rpc_evb_retry()
873 efx->type->is_vf) { in _efx_mcdi_rpc_evb_retry()
881 netif_dbg(efx, hw, efx->net_dev, in _efx_mcdi_rpc_evb_retry()
892 } while ((rc == -EPROTO) && in _efx_mcdi_rpc_evb_retry()
897 if (rc && !quiet && !(cmd == MC_CMD_REBOOT && rc == -EIO)) in _efx_mcdi_rpc_evb_retry()
905 * efx_siena_mcdi_rpc - Issue an MCDI command and wait for completion
964 if (efx->mc_bist_for_other_fn) in efx_siena_mcdi_rpc_start()
965 return -ENETDOWN; in efx_siena_mcdi_rpc_start()
967 if (mcdi->mode == MCDI_MODE_FAIL) in efx_siena_mcdi_rpc_start()
968 return -ENETDOWN; in efx_siena_mcdi_rpc_start()
989 if (efx->mc_bist_for_other_fn) in _efx_mcdi_rpc_async()
990 return -ENETDOWN; in _efx_mcdi_rpc_async()
995 return -ENOMEM; in _efx_mcdi_rpc_async()
997 async->cmd = cmd; in _efx_mcdi_rpc_async()
998 async->inlen = inlen; in _efx_mcdi_rpc_async()
999 async->outlen = outlen; in _efx_mcdi_rpc_async()
1000 async->quiet = quiet; in _efx_mcdi_rpc_async()
1001 async->complete = complete; in _efx_mcdi_rpc_async()
1002 async->cookie = cookie; in _efx_mcdi_rpc_async()
1005 spin_lock_bh(&mcdi->async_lock); in _efx_mcdi_rpc_async()
1007 if (mcdi->mode == MCDI_MODE_EVENTS) { in _efx_mcdi_rpc_async()
1008 list_add_tail(&async->list, &mcdi->async_list); in _efx_mcdi_rpc_async()
1013 if (mcdi->async_list.next == &async->list && in _efx_mcdi_rpc_async()
1016 mod_timer(&mcdi->async_timer, in _efx_mcdi_rpc_async()
1021 rc = -ENETDOWN; in _efx_mcdi_rpc_async()
1024 spin_unlock_bh(&mcdi->async_lock); in _efx_mcdi_rpc_async()
1030 * efx_siena_mcdi_rpc_async - Schedule an MCDI command to run asynchronously
1047 * (c) the request times-out (in timer context)
1095 netif_cond_dbg(efx, hw, efx->net_dev, rc == -EPERM, err, in efx_siena_mcdi_display_error()
1108 if (!efx->mcdi) in efx_siena_mcdi_mode_poll()
1113 * If in fail-fast state, don't switch to polled completion. in efx_siena_mcdi_mode_poll()
1116 if (mcdi->mode == MCDI_MODE_POLL || mcdi->mode == MCDI_MODE_FAIL) in efx_siena_mcdi_mode_poll()
1127 mcdi->mode = MCDI_MODE_POLL; in efx_siena_mcdi_mode_poll()
1140 if (!efx->mcdi) in efx_siena_mcdi_flush_async()
1146 BUG_ON(mcdi->mode == MCDI_MODE_EVENTS); in efx_siena_mcdi_flush_async()
1148 del_timer_sync(&mcdi->async_timer); in efx_siena_mcdi_flush_async()
1154 if (mcdi->state == MCDI_STATE_RUNNING_ASYNC) { in efx_siena_mcdi_flush_async()
1156 mcdi->state = MCDI_STATE_QUIESCENT; in efx_siena_mcdi_flush_async()
1164 list_for_each_entry_safe(async, next, &mcdi->async_list, list) { in efx_siena_mcdi_flush_async()
1165 if (async->complete) in efx_siena_mcdi_flush_async()
1166 async->complete(efx, async->cookie, -ENETDOWN, NULL, 0); in efx_siena_mcdi_flush_async()
1167 list_del(&async->list); in efx_siena_mcdi_flush_async()
1176 if (!efx->mcdi) in efx_siena_mcdi_mode_event()
1181 * If in fail-fast state, don't switch to event completion. FLR in efx_siena_mcdi_mode_event()
1184 if (mcdi->mode == MCDI_MODE_EVENTS || mcdi->mode == MCDI_MODE_FAIL) in efx_siena_mcdi_mode_event()
1195 mcdi->mode = MCDI_MODE_EVENTS; in efx_siena_mcdi_mode_event()
1204 * either by a BADASSERT or REBOOT event. If the mcdi interface is in efx_mcdi_ev_death()
1205 * in polled mode, then do nothing because the MC reboot handler will in efx_mcdi_ev_death()
1216 * we might receive a REBOOT event *before* the request has in efx_mcdi_ev_death()
1219 * event mode, this condition is just an edge-case of in efx_mcdi_ev_death()
1220 * receiving a REBOOT event after posting the MCDI in efx_mcdi_ev_death()
1221 * request. Did the mc reboot before or after the copyout? The in efx_mcdi_ev_death()
1227 spin_lock(&mcdi->iface_lock); in efx_mcdi_ev_death()
1231 if (mcdi->mode == MCDI_MODE_EVENTS) { in efx_mcdi_ev_death()
1232 mcdi->resprc = rc; in efx_mcdi_ev_death()
1233 mcdi->resp_hdr_len = 0; in efx_mcdi_ev_death()
1234 mcdi->resp_data_len = 0; in efx_mcdi_ev_death()
1235 ++mcdi->credits; in efx_mcdi_ev_death()
1249 * reboot detection in efx_siena_mcdi_poll_reboot() being triggered. in efx_mcdi_ev_death()
1251 * efx_siena_mcdi_poll_reboot(), the MC reboot wasn't noticed but the in efx_mcdi_ev_death()
1254 if (!rc && efx->type->mcdi_reboot_detected) in efx_mcdi_ev_death()
1255 efx->type->mcdi_reboot_detected(efx); in efx_mcdi_ev_death()
1257 mcdi->new_epoch = true; in efx_mcdi_ev_death()
1263 spin_unlock(&mcdi->iface_lock); in efx_mcdi_ev_death()
1267 * new MCDI, cancel any outstanding MCDI and schedule a BIST-type reset
1275 spin_lock(&mcdi->iface_lock); in efx_mcdi_ev_bist()
1276 efx->mc_bist_for_other_fn = true; in efx_mcdi_ev_bist()
1280 if (mcdi->mode == MCDI_MODE_EVENTS) { in efx_mcdi_ev_bist()
1281 mcdi->resprc = -EIO; in efx_mcdi_ev_bist()
1282 mcdi->resp_hdr_len = 0; in efx_mcdi_ev_bist()
1283 mcdi->resp_data_len = 0; in efx_mcdi_ev_bist()
1284 ++mcdi->credits; in efx_mcdi_ev_bist()
1287 mcdi->new_epoch = true; in efx_mcdi_ev_bist()
1289 spin_unlock(&mcdi->iface_lock); in efx_mcdi_ev_bist()
1292 /* MCDI timeouts seen, so make all MCDI calls fail-fast and issue an FLR to try
1299 if (xchg(&mcdi->mode, MCDI_MODE_FAIL) == MCDI_MODE_FAIL) in efx_mcdi_abandon()
1301 netif_dbg(efx, hw, efx->net_dev, "MCDI is timing out; trying to recover\n"); in efx_mcdi_abandon()
1307 if (atomic_dec_and_test(&efx->active_queues)) in efx_handle_drain_event()
1308 wake_up(&efx->flush_wq); in efx_handle_drain_event()
1310 WARN_ON(atomic_read(&efx->active_queues) < 0); in efx_handle_drain_event()
1317 struct efx_nic *efx = channel->efx; in efx_siena_mcdi_process_event()
1323 netif_err(efx, hw, efx->net_dev, in efx_siena_mcdi_process_event()
1325 efx_mcdi_ev_death(efx, -EINTR); in efx_siena_mcdi_process_event()
1329 netif_info(efx, wol, efx->net_dev, "MCDI PM event.\n"); in efx_siena_mcdi_process_event()
1346 netif_dbg(efx, hw, efx->net_dev, in efx_siena_mcdi_process_event()
1351 netif_info(efx, hw, efx->net_dev, "MC Reboot\n"); in efx_siena_mcdi_process_event()
1352 efx_mcdi_ev_death(efx, -EIO); in efx_siena_mcdi_process_event()
1355 netif_info(efx, hw, efx->net_dev, "MC entered BIST mode\n"); in efx_siena_mcdi_process_event()
1362 if (efx->type->sriov_flr) in efx_siena_mcdi_process_event()
1363 efx->type->sriov_flr(efx, in efx_siena_mcdi_process_event()
1389 netif_err(efx, hw, efx->net_dev, in efx_siena_mcdi_process_event()
1401 netif_err(efx, hw, efx->net_dev, in efx_siena_mcdi_process_event()
1419 size_t offset; in efx_siena_mcdi_print_fwver() local
1428 rc = -EIO; in efx_siena_mcdi_print_fwver()
1433 offset = scnprintf(buf, len, "%u.%u.%u.%u", in efx_siena_mcdi_print_fwver()
1439 if (efx->type->print_additional_fwver) in efx_siena_mcdi_print_fwver()
1440 offset += efx->type->print_additional_fwver(efx, buf + offset, in efx_siena_mcdi_print_fwver()
1441 len - offset); in efx_siena_mcdi_print_fwver()
1447 if (WARN_ON(offset >= len)) in efx_siena_mcdi_print_fwver()
1453 netif_err(efx, probe, efx->net_dev, "%s: failed rc=%d\n", __func__, rc); in efx_siena_mcdi_print_fwver()
1477 if (rc == -EPERM) { in efx_mcdi_drv_attach()
1478 netif_dbg(efx, probe, efx->net_dev, in efx_mcdi_drv_attach()
1479 "efx_mcdi_drv_attach with fw-variant setting failed EPERM, trying without it\n"); in efx_mcdi_drv_attach()
1492 rc = -EIO; in efx_mcdi_drv_attach()
1498 efx->mcdi->fn_flags = in efx_mcdi_drv_attach()
1503 efx->mcdi->fn_flags = in efx_mcdi_drv_attach()
1521 netif_err(efx, probe, efx->net_dev, "%s: failed rc=%d\n", __func__, rc); in efx_mcdi_drv_attach()
1544 rc = -EIO; in efx_siena_mcdi_get_board_cfg()
1575 netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d len=%d\n", in efx_siena_mcdi_get_board_cfg()
1616 rc = -EIO; in efx_siena_mcdi_nvram_types()
1624 netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", in efx_siena_mcdi_nvram_types()
1645 rc = -EIO; in efx_siena_mcdi_nvram_info()
1656 netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc); in efx_siena_mcdi_nvram_info()
1678 return -EIO; in efx_mcdi_nvram_test()
1706 netif_err(efx, hw, efx->net_dev, "%s: failed type=%u\n", in efx_siena_mcdi_nvram_test_all()
1709 netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc); in efx_siena_mcdi_nvram_test_all()
1726 /* Attempt to read any stored assertion state before we reboot in efx_mcdi_read_assertion()
1728 * because a boot-time assertion might cause this command to fail in efx_mcdi_read_assertion()
1737 if (rc == -EPERM) in efx_mcdi_read_assertion()
1739 } while ((rc == -EINTR || rc == -EIO) && retry-- > 0); in efx_mcdi_read_assertion()
1748 return -EIO; in efx_mcdi_read_assertion()
1756 ? "system-level assertion" in efx_mcdi_read_assertion()
1758 ? "thread-level assertion" in efx_mcdi_read_assertion()
1762 netif_err(efx, hw, efx->net_dev, in efx_mcdi_read_assertion()
1771 netif_err(efx, hw, efx->net_dev, "R%.2d (?): 0x%.8x\n", in efx_mcdi_read_assertion()
1786 * reboot. We set a flag that makes the command a no-op if it in efx_mcdi_exit_assertion()
1788 * The MCDI will thus return either 0 or -EIO. in efx_mcdi_exit_assertion()
1795 if (rc == -EIO) in efx_mcdi_exit_assertion()
1853 if (rc == -EIO) in efx_mcdi_reset_mc()
1856 rc = -EIO; in efx_mcdi_reset_mc()
1871 rc = pci_reset_function(efx->pci_dev); in efx_siena_mcdi_reset()
1874 /* Re-enable polled MCDI completion */ in efx_siena_mcdi_reset()
1875 if (efx->mcdi) { in efx_siena_mcdi_reset()
1877 mcdi->mode = MCDI_MODE_POLL; in efx_siena_mcdi_reset()
1882 /* Recover from a failed assertion pre-reset */ in efx_siena_mcdi_reset()
1914 rc = -EIO; in efx_mcdi_wol_filter_set()
1923 *id_out = -1; in efx_mcdi_wol_filter_set()
1924 netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc); in efx_mcdi_wol_filter_set()
1949 rc = -EIO; in efx_siena_mcdi_wol_filter_get_magic()
1958 *id_out = -1; in efx_siena_mcdi_wol_filter_get_magic()
1959 netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc); in efx_siena_mcdi_wol_filter_get_magic()
1990 if (rx_queue->flush_pending) { in efx_siena_mcdi_flush_rxqs()
1991 rx_queue->flush_pending = false; in efx_siena_mcdi_flush_rxqs()
1992 atomic_dec(&efx->rxq_flush_pending); in efx_siena_mcdi_flush_rxqs()
2041 loff_t offset, u8 *buffer, size_t length) in efx_mcdi_nvram_read() argument
2050 MCDI_SET_DWORD(inbuf, NVRAM_READ_IN_OFFSET, offset); in efx_mcdi_nvram_read()
2065 loff_t offset, const u8 *buffer, size_t length) in efx_mcdi_nvram_write() argument
2072 MCDI_SET_DWORD(inbuf, NVRAM_WRITE_IN_OFFSET, offset); in efx_mcdi_nvram_write()
2085 loff_t offset, size_t length) in efx_mcdi_nvram_erase() argument
2091 MCDI_SET_DWORD(inbuf, NVRAM_ERASE_IN_OFFSET, offset); in efx_mcdi_nvram_erase()
2119 netif_err(efx, drv, efx->net_dev, in efx_mcdi_nvram_update_finish()
2130 rc = -EIO; in efx_mcdi_nvram_update_finish()
2134 rc = -EINVAL; in efx_mcdi_nvram_update_finish()
2139 rc = -EPERM; in efx_mcdi_nvram_update_finish()
2142 netif_err(efx, drv, efx->net_dev, in efx_mcdi_nvram_update_finish()
2144 rc = -EIO; in efx_mcdi_nvram_update_finish()
2155 struct efx_nic *efx = mtd->priv; in efx_siena_mcdi_mtd_read()
2156 loff_t offset = start; in efx_siena_mcdi_mtd_read() local
2157 loff_t end = min_t(loff_t, start + len, mtd->size); in efx_siena_mcdi_mtd_read()
2161 while (offset < end) { in efx_siena_mcdi_mtd_read()
2162 chunk = min_t(size_t, end - offset, EFX_MCDI_NVRAM_LEN_MAX); in efx_siena_mcdi_mtd_read()
2163 rc = efx_mcdi_nvram_read(efx, part->nvram_type, offset, in efx_siena_mcdi_mtd_read()
2167 offset += chunk; in efx_siena_mcdi_mtd_read()
2171 *retlen = offset - start; in efx_siena_mcdi_mtd_read()
2178 struct efx_nic *efx = mtd->priv; in efx_siena_mcdi_mtd_erase()
2179 loff_t offset = start & ~((loff_t)(mtd->erasesize - 1)); in efx_siena_mcdi_mtd_erase() local
2180 loff_t end = min_t(loff_t, start + len, mtd->size); in efx_siena_mcdi_mtd_erase()
2181 size_t chunk = part->common.mtd.erasesize; in efx_siena_mcdi_mtd_erase()
2184 if (!part->updating) { in efx_siena_mcdi_mtd_erase()
2185 rc = efx_mcdi_nvram_update_start(efx, part->nvram_type); in efx_siena_mcdi_mtd_erase()
2188 part->updating = true; in efx_siena_mcdi_mtd_erase()
2194 while (offset < end) { in efx_siena_mcdi_mtd_erase()
2195 rc = efx_mcdi_nvram_erase(efx, part->nvram_type, offset, in efx_siena_mcdi_mtd_erase()
2199 offset += chunk; in efx_siena_mcdi_mtd_erase()
2209 struct efx_nic *efx = mtd->priv; in efx_siena_mcdi_mtd_write()
2210 loff_t offset = start; in efx_siena_mcdi_mtd_write() local
2211 loff_t end = min_t(loff_t, start + len, mtd->size); in efx_siena_mcdi_mtd_write()
2215 if (!part->updating) { in efx_siena_mcdi_mtd_write()
2216 rc = efx_mcdi_nvram_update_start(efx, part->nvram_type); in efx_siena_mcdi_mtd_write()
2219 part->updating = true; in efx_siena_mcdi_mtd_write()
2222 while (offset < end) { in efx_siena_mcdi_mtd_write()
2223 chunk = min_t(size_t, end - offset, EFX_MCDI_NVRAM_LEN_MAX); in efx_siena_mcdi_mtd_write()
2224 rc = efx_mcdi_nvram_write(efx, part->nvram_type, offset, in efx_siena_mcdi_mtd_write()
2228 offset += chunk; in efx_siena_mcdi_mtd_write()
2232 *retlen = offset - start; in efx_siena_mcdi_mtd_write()
2239 struct efx_nic *efx = mtd->priv; in efx_siena_mcdi_mtd_sync()
2242 if (part->updating) { in efx_siena_mcdi_mtd_sync()
2243 part->updating = false; in efx_siena_mcdi_mtd_sync()
2244 rc = efx_mcdi_nvram_update_finish(efx, part->nvram_type); in efx_siena_mcdi_mtd_sync()
2254 struct efx_nic *efx = part->mtd.priv; in efx_siena_mcdi_mtd_rename()
2256 snprintf(part->name, sizeof(part->name), "%s %s:%02x", in efx_siena_mcdi_mtd_rename()
2257 efx->name, part->type_name, mcdi_part->fw_subtype); in efx_siena_mcdi_mtd_rename()