- efx_nic_t *enp;
- unsigned int delay_total;
- unsigned int delay_us;
- boolean_t aborted __rte_unused;
-
- delay_total = 0;
- delay_us = SFC_MCDI_POLL_INTERVAL_MIN_US;
- enp = sa->nic;
-
- do {
- boolean_t poll_completed;
-
- poll_completed = (proxy) ? sfc_mcdi_proxy_event_available(sa) :
- efx_mcdi_request_poll(enp);
- if (poll_completed)
- return;
-
- if (delay_total > SFC_MCDI_WATCHDOG_INTERVAL_US) {
- if (!proxy) {
- aborted = efx_mcdi_request_abort(enp);
- SFC_ASSERT(aborted);
- sfc_mcdi_timeout(sa);
- }
-
- return;
- }
-
- rte_delay_us(delay_us);
-
- delay_total += delay_us;
-
- /* Exponentially back off the poll frequency */
- RTE_BUILD_BUG_ON(SFC_MCDI_POLL_INTERVAL_MAX_US > UINT_MAX / 2);
- delay_us *= 2;
- if (delay_us > SFC_MCDI_POLL_INTERVAL_MAX_US)
- delay_us = SFC_MCDI_POLL_INTERVAL_MAX_US;
-
- } while (1);
-}
-
-static void
-sfc_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
-{
- struct sfc_adapter *sa = (struct sfc_adapter *)arg;
- struct sfc_mcdi *mcdi = &sa->mcdi;
- uint32_t proxy_handle;
-
- rte_spinlock_lock(&mcdi->lock);
-
- SFC_ASSERT(mcdi->state == SFC_MCDI_INITIALIZED);
-
- efx_mcdi_request_start(sa->nic, emrp, B_FALSE);
- sfc_mcdi_poll(sa, B_FALSE);
-
- if (efx_mcdi_get_proxy_handle(sa->nic, emrp, &proxy_handle) == 0) {
- /*
- * Authorization is required for the MCDI request;
- * wait for an MCDI proxy response event to bring
- * a non-zero proxy handle (should be the same as
- * the value obtained above) and operation status
- */
- sfc_mcdi_poll(sa, B_TRUE);