src/dpdk/drivers/net/sfc/sfc_ev.c
int
sfc_ev_qstart(struct sfc_evq *evq, unsigned int hw_index)
{
	struct sfc_adapter *sa = evq->sa;
	efsys_mem_t *esmp;
	uint32_t evq_flags = sa->evq_flags;
	unsigned int total_delay_us;
	unsigned int delay_us;
	int rc;

	sfc_log_init(sa, "hw_index=%u", hw_index);

	esmp = &evq->mem;

	evq->evq_index = hw_index;

	/* Clear all events */
	(void)memset((void *)esmp->esm_base, 0xff,
		     efx_evq_size(sa->nic, evq->entries, evq_flags));

	if ((sa->intr.lsc_intr && hw_index == sa->mgmt_evq_index) ||
	    (sa->intr.rxq_intr && evq->dp_rxq != NULL))
		evq_flags |= EFX_EVQ_FLAGS_NOTIFY_INTERRUPT;
	else
		evq_flags |= EFX_EVQ_FLAGS_NOTIFY_DISABLED;

	evq->init_state = SFC_EVQ_STARTING;

	/* Create the common code event queue */
	rc = efx_ev_qcreate(sa->nic, hw_index, esmp, evq->entries,
			    0 /* unused on EF10 */, 0, evq_flags,
			    &evq->common);
	if (rc != 0)
		goto fail_ev_qcreate;

	SFC_ASSERT(evq->dp_rxq == NULL || evq->dp_txq == NULL);
	if (evq->dp_rxq != 0) {
		if (strcmp(sa->priv.dp_rx->dp.name,
			   SFC_KVARG_DATAPATH_EFX) == 0)
			evq->callbacks = &sfc_ev_callbacks_efx_rx;
		else
			evq->callbacks = &sfc_ev_callbacks_dp_rx;
	} else if (evq->dp_txq != 0) {
		if (strcmp(sa->priv.dp_tx->dp.name,
			   SFC_KVARG_DATAPATH_EFX) == 0)
			evq->callbacks = &sfc_ev_callbacks_efx_tx;
		else
			evq->callbacks = &sfc_ev_callbacks_dp_tx;
	} else {
		evq->callbacks = &sfc_ev_callbacks;
	}

	/*
	 * Poll once to ensure that eec_initialized callback is invoked in
	 * case if the hardware does not support INIT_DONE events. If the
	 * hardware supports INIT_DONE events, this will do nothing, and the
	 * corresponding event will be processed by sfc_ev_qpoll() below.
	 */
	efx_ev_qcreate_check_init_done(evq->common, evq->callbacks, evq);

	/* Wait for the initialization event */
	total_delay_us = 0;
	delay_us = SFC_EVQ_INIT_BACKOFF_START_US;
	do {
		(void)sfc_ev_qpoll(evq);

		/* Check to see if the initialization complete indication
		 * posted by the hardware.
		 */
		if (evq->init_state == SFC_EVQ_STARTED)
			goto done;

		/* Give event queue some time to init */
		rte_delay_us(delay_us);

		total_delay_us += delay_us;

		/* Exponential backoff */
		delay_us *= 2;
		if (delay_us > SFC_EVQ_INIT_BACKOFF_MAX_US)
			delay_us = SFC_EVQ_INIT_BACKOFF_MAX_US;

	} while (total_delay_us < SFC_EVQ_INIT_TIMEOUT_US);

	rc = ETIMEDOUT;
	goto fail_timedout;

done:
	return 0;

fail_timedout:
	efx_ev_qdestroy(evq->common);

fail_ev_qcreate:
	evq->init_state = SFC_EVQ_INITIALIZED;
	sfc_log_init(sa, "failed %d", rc);
	return rc;
}
/* Event queue HW index allocation scheme is described in sfc_ev.h. */
Event queue HW index allocation scheme is described in sfc_ev.h.
Event queue HW index allocation scheme is described in sfc_ev . h .
int
sfc_ev_qstart(struct sfc_evq *evq, unsigned int hw_index)
{
	struct sfc_adapter *sa = evq->sa;
	efsys_mem_t *esmp;
	uint32_t evq_flags = sa->evq_flags;
	unsigned int total_delay_us;
	unsigned int delay_us;
	int rc;
	sfc_log_init(sa, "hw_index=%u", hw_index);
	esmp = &evq->mem;
	evq->evq_index = hw_index;
	(void)memset((void *)esmp->esm_base, 0xff,
		     efx_evq_size(sa->nic, evq->entries, evq_flags));
	if ((sa->intr.lsc_intr && hw_index == sa->mgmt_evq_index) ||
	    (sa->intr.rxq_intr && evq->dp_rxq != NULL))
		evq_flags |= EFX_EVQ_FLAGS_NOTIFY_INTERRUPT;
	else
		evq_flags |= EFX_EVQ_FLAGS_NOTIFY_DISABLED;
	evq->init_state = SFC_EVQ_STARTING;
	rc = efx_ev_qcreate(sa->nic, hw_index, esmp, evq->entries,
			    0 , 0, evq_flags,
			    &evq->common);
	if (rc != 0)
		goto fail_ev_qcreate;
	SFC_ASSERT(evq->dp_rxq == NULL || evq->dp_txq == NULL);
	if (evq->dp_rxq != 0) {
		if (strcmp(sa->priv.dp_rx->dp.name,
			   SFC_KVARG_DATAPATH_EFX) == 0)
			evq->callbacks = &sfc_ev_callbacks_efx_rx;
		else
			evq->callbacks = &sfc_ev_callbacks_dp_rx;
	} else if (evq->dp_txq != 0) {
		if (strcmp(sa->priv.dp_tx->dp.name,
			   SFC_KVARG_DATAPATH_EFX) == 0)
			evq->callbacks = &sfc_ev_callbacks_efx_tx;
		else
			evq->callbacks = &sfc_ev_callbacks_dp_tx;
	} else {
		evq->callbacks = &sfc_ev_callbacks;
	}
	efx_ev_qcreate_check_init_done(evq->common, evq->callbacks, evq);
	total_delay_us = 0;
	delay_us = SFC_EVQ_INIT_BACKOFF_START_US;
	do {
		(void)sfc_ev_qpoll(evq);
		if (evq->init_state == SFC_EVQ_STARTED)
			goto done;
		rte_delay_us(delay_us);
		total_delay_us += delay_us;
		delay_us *= 2;
		if (delay_us > SFC_EVQ_INIT_BACKOFF_MAX_US)
			delay_us = SFC_EVQ_INIT_BACKOFF_MAX_US;
	} while (total_delay_us < SFC_EVQ_INIT_TIMEOUT_US);
	rc = ETIMEDOUT;
	goto fail_timedout;
done:
	return 0;
fail_timedout:
	efx_ev_qdestroy(evq->common);
fail_ev_qcreate:
	evq->init_state = SFC_EVQ_INITIALIZED;
	sfc_log_init(sa, "failed %d", rc);
	return rc;
}
int sfc_ev_qstart ( struct sfc_evq * evq , unsigned int hw_index ) { struct sfc_adapter * sa = evq -> sa ; efsys_mem_t * esmp ; uint32_t evq_flags = sa -> evq_flags ; unsigned int total_delay_us ; unsigned int delay_us ; int rc ; sfc_log_init ( sa , " " , hw_index ) ; esmp = & evq -> mem ; evq -> evq_index = hw_index ; ( void ) memset ( ( void * ) esmp -> esm_base , 0xff , efx_evq_size ( sa -> nic , evq -> entries , evq_flags ) ) ; if ( ( sa -> intr . lsc_intr && hw_index == sa -> mgmt_evq_index ) || ( sa -> intr . rxq_intr && evq -> dp_rxq != NULL ) ) evq_flags |= EFX_EVQ_FLAGS_NOTIFY_INTERRUPT ; else evq_flags |= EFX_EVQ_FLAGS_NOTIFY_DISABLED ; evq -> init_state = SFC_EVQ_STARTING ; rc = efx_ev_qcreate ( sa -> nic , hw_index , esmp , evq -> entries , 0 , 0 , evq_flags , & evq -> common ) ; if ( rc != 0 ) goto fail_ev_qcreate ; SFC_ASSERT ( evq -> dp_rxq == NULL || evq -> dp_txq == NULL ) ; if ( evq -> dp_rxq != 0 ) { if ( strcmp ( sa -> priv . dp_rx -> dp . name , SFC_KVARG_DATAPATH_EFX ) == 0 ) evq -> callbacks = & sfc_ev_callbacks_efx_rx ; else evq -> callbacks = & sfc_ev_callbacks_dp_rx ; } else if ( evq -> dp_txq != 0 ) { if ( strcmp ( sa -> priv . dp_tx -> dp . name , SFC_KVARG_DATAPATH_EFX ) == 0 ) evq -> callbacks = & sfc_ev_callbacks_efx_tx ; else evq -> callbacks = & sfc_ev_callbacks_dp_tx ; } else { evq -> callbacks = & sfc_ev_callbacks ; } efx_ev_qcreate_check_init_done ( evq -> common , evq -> callbacks , evq ) ; total_delay_us = 0 ; delay_us = SFC_EVQ_INIT_BACKOFF_START_US ; do { ( void ) sfc_ev_qpoll ( evq ) ; if ( evq -> init_state == SFC_EVQ_STARTED ) goto done ; rte_delay_us ( delay_us ) ; total_delay_us += delay_us ; delay_us *= 2 ; if ( delay_us > SFC_EVQ_INIT_BACKOFF_MAX_US ) delay_us = SFC_EVQ_INIT_BACKOFF_MAX_US ; } while ( total_delay_us < SFC_EVQ_INIT_TIMEOUT_US ) ; rc = ETIMEDOUT ; goto fail_timedout ; done : return 0 ; fail_timedout : efx_ev_qdestroy ( evq -> common ) ; fail_ev_qcreate : evq -> init_state = SFC_EVQ_INITIALIZED ; sfc_log_init ( sa , " " , rc ) ; return rc ; }
Event queue HW index allocation scheme is described in sfc_ev.h.
Event queue HW index allocation scheme is described in sfc_ev . h .
/* Clear all events */ /* Create the common code event queue */ /* unused on EF10 */ /*
	 * Poll once to ensure that eec_initialized callback is invoked in
	 * case if the hardware does not support INIT_DONE events. If the
	 * hardware supports INIT_DONE events, this will do nothing, and the
	 * corresponding event will be processed by sfc_ev_qpoll() below.
	 */ /* Wait for the initialization event */ /* Check to see if the initialization complete indication
		 * posted by the hardware.
		 */ /* Give event queue some time to init */ /* Exponential backoff */