sfxge(4): support non-interrupting event queues creation

Poll-mode driver does not use interrupts and number of used event queues
should not be limitted by the number of interrupts allocated for the
NIC.

Reviewed by:    gnn
Sponsored by:   Solarflare Communications, Inc.
MFC after:      2 days
Differential Revision:  https://reviews.freebsd.org/D8967
This commit is contained in:
Andrew Rybchenko 2016-12-30 11:54:27 +00:00
parent e390161841
commit 82d2a1482e
4 changed files with 72 additions and 9 deletions

View File

@ -49,6 +49,12 @@ __FBSDID("$FreeBSD$");
#define EFX_EV_QSTAT_INCR(_eep, _stat)
#endif
/*
* Non-interrupting event queue requires interrrupting event queue to
* refer to for wake-up events even if wake ups are never used.
* It could be even non-allocated event queue.
*/
#define EFX_EF10_ALWAYS_INTERRUPTING_EVQ_INDEX (0)
static __checkReturn boolean_t
ef10_ev_rx(
@ -151,6 +157,7 @@ efx_mcdi_init_evq(
uint64_t addr;
int npages;
int i;
boolean_t interrupting;
int ev_cut_through;
efx_rc_t rc;
@ -171,6 +178,9 @@ efx_mcdi_init_evq(
MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_INSTANCE, instance);
MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_IRQ_NUM, irq);
interrupting = ((flags & EFX_EVQ_FLAGS_NOTIFY_MASK) ==
EFX_EVQ_FLAGS_NOTIFY_INTERRUPT);
/*
* On Huntington RX and TX event batching can only be requested together
* (even if the datapath firmware doesn't actually support RX
@ -194,7 +204,7 @@ efx_mcdi_init_evq(
goto fail2;
}
MCDI_IN_POPULATE_DWORD_6(req, INIT_EVQ_IN_FLAGS,
INIT_EVQ_IN_FLAG_INTERRUPTING, 1,
INIT_EVQ_IN_FLAG_INTERRUPTING, interrupting,
INIT_EVQ_IN_FLAG_RPTR_DOS, 0,
INIT_EVQ_IN_FLAG_INT_ARMD, 0,
INIT_EVQ_IN_FLAG_CUT_THRU, ev_cut_through,
@ -280,6 +290,7 @@ efx_mcdi_init_evq_v2(
uint8_t payload[
MAX(MC_CMD_INIT_EVQ_V2_IN_LEN(EFX_EVQ_NBUFS(EFX_EVQ_MAXNEVS)),
MC_CMD_INIT_EVQ_V2_OUT_LEN)];
boolean_t interrupting;
unsigned int evq_type;
efx_qword_t *dma_addr;
uint64_t addr;
@ -304,6 +315,9 @@ efx_mcdi_init_evq_v2(
MCDI_IN_SET_DWORD(req, INIT_EVQ_V2_IN_INSTANCE, instance);
MCDI_IN_SET_DWORD(req, INIT_EVQ_V2_IN_IRQ_NUM, irq);
interrupting = ((flags & EFX_EVQ_FLAGS_NOTIFY_MASK) ==
EFX_EVQ_FLAGS_NOTIFY_INTERRUPT);
switch (flags & EFX_EVQ_FLAGS_TYPE_MASK) {
case EFX_EVQ_FLAGS_TYPE_AUTO:
evq_type = MC_CMD_INIT_EVQ_V2_IN_FLAG_TYPE_AUTO;
@ -319,7 +333,7 @@ efx_mcdi_init_evq_v2(
goto fail2;
}
MCDI_IN_POPULATE_DWORD_4(req, INIT_EVQ_V2_IN_FLAGS,
INIT_EVQ_V2_IN_FLAG_INTERRUPTING, 1,
INIT_EVQ_V2_IN_FLAG_INTERRUPTING, interrupting,
INIT_EVQ_V2_IN_FLAG_RPTR_DOS, 0,
INIT_EVQ_V2_IN_FLAG_INT_ARMD, 0,
INIT_EVQ_V2_IN_FLAG_TYPE, evq_type);
@ -484,7 +498,17 @@ ef10_ev_qcreate(
eep->ee_mcdi = ef10_ev_mcdi;
/* Set up the event queue */
irq = index; /* INIT_EVQ expects function-relative vector number */
/* INIT_EVQ expects function-relative vector number */
if ((flags & EFX_EVQ_FLAGS_NOTIFY_MASK) ==
EFX_EVQ_FLAGS_NOTIFY_INTERRUPT) {
irq = index;
} else if (index == EFX_EF10_ALWAYS_INTERRUPTING_EVQ_INDEX) {
irq = index;
flags = (flags & ~EFX_EVQ_FLAGS_NOTIFY_MASK) |
EFX_EVQ_FLAGS_NOTIFY_INTERRUPT;
} else {
irq = EFX_EF10_ALWAYS_INTERRUPTING_EVQ_INDEX;
}
/*
* Interrupts may be raised for events immediately after the queue is

View File

@ -1624,6 +1624,10 @@ efx_ev_fini(
#define EFX_EVQ_FLAGS_TYPE_THROUGHPUT (0x1)
#define EFX_EVQ_FLAGS_TYPE_LOW_LATENCY (0x2)
#define EFX_EVQ_FLAGS_NOTIFY_MASK (0xC)
#define EFX_EVQ_FLAGS_NOTIFY_INTERRUPT (0x0) /* Interrupting (default) */
#define EFX_EVQ_FLAGS_NOTIFY_DISABLED (0x4) /* Non-interrupting */
extern __checkReturn efx_rc_t
efx_ev_qcreate(
__in efx_nic_t *enp,

View File

@ -235,17 +235,32 @@ efx_ev_qcreate(
EFSYS_ASSERT3U(enp->en_ev_qcount + 1, <, encp->enc_evq_limit);
switch (flags & EFX_EVQ_FLAGS_NOTIFY_MASK) {
case EFX_EVQ_FLAGS_NOTIFY_INTERRUPT:
break;
case EFX_EVQ_FLAGS_NOTIFY_DISABLED:
if (us != 0) {
rc = EINVAL;
goto fail1;
}
break;
default:
rc = EINVAL;
goto fail2;
}
/* Allocate an EVQ object */
EFSYS_KMEM_ALLOC(enp->en_esip, sizeof (efx_evq_t), eep);
if (eep == NULL) {
rc = ENOMEM;
goto fail1;
goto fail3;
}
eep->ee_magic = EFX_EVQ_MAGIC;
eep->ee_enp = enp;
eep->ee_index = index;
eep->ee_mask = n - 1;
eep->ee_flags = flags;
eep->ee_esmp = esmp;
/*
@ -261,16 +276,20 @@ efx_ev_qcreate(
if ((rc = eevop->eevo_qcreate(enp, index, esmp, n, id, us, flags,
eep)) != 0)
goto fail2;
goto fail4;
return (0);
fail2:
EFSYS_PROBE(fail2);
fail4:
EFSYS_PROBE(fail4);
*eepp = NULL;
enp->en_ev_qcount--;
EFSYS_KMEM_FREE(enp->en_esip, sizeof (efx_evq_t), eep);
fail3:
EFSYS_PROBE(fail3);
fail2:
EFSYS_PROBE(fail2);
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
@ -553,11 +572,19 @@ efx_ev_qmoderate(
EFSYS_ASSERT3U(eep->ee_magic, ==, EFX_EVQ_MAGIC);
if ((rc = eevop->eevo_qmoderate(eep, us)) != 0)
if ((eep->ee_flags & EFX_EVQ_FLAGS_NOTIFY_MASK) ==
EFX_EVQ_FLAGS_NOTIFY_DISABLED) {
rc = EINVAL;
goto fail1;
}
if ((rc = eevop->eevo_qmoderate(eep, us)) != 0)
goto fail2;
return (0);
fail2:
EFSYS_PROBE(fail2);
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
@ -1267,6 +1294,7 @@ siena_ev_qcreate(
uint32_t size;
efx_oword_t oword;
efx_rc_t rc;
boolean_t notify_mode;
_NOTE(ARGUNUSED(esmp))
@ -1307,8 +1335,13 @@ siena_ev_qcreate(
eep->ee_mcdi = siena_ev_mcdi;
#endif /* EFSYS_OPT_MCDI */
notify_mode = ((flags & EFX_EVQ_FLAGS_NOTIFY_MASK) !=
EFX_EVQ_FLAGS_NOTIFY_INTERRUPT);
/* Set up the new event queue */
EFX_POPULATE_OWORD_1(oword, FRF_CZ_TIMER_Q_EN, 1);
EFX_POPULATE_OWORD_3(oword, FRF_CZ_TIMER_Q_EN, 1,
FRF_CZ_HOST_NOTIFY_MODE, notify_mode,
FRF_CZ_TIMER_MODE, FFE_CZ_TIMER_MODE_DIS);
EFX_BAR_TBL_WRITEO(enp, FR_AZ_TIMER_TBL, index, &oword, B_TRUE);
EFX_POPULATE_OWORD_3(oword, FRF_AZ_EVQ_EN, 1, FRF_AZ_EVQ_SIZE, size,

View File

@ -711,6 +711,8 @@ struct efx_evq_s {
#endif /* EFSYS_OPT_MCDI */
efx_evq_rxq_state_t ee_rxq_state[EFX_EV_RX_NLABELS];
uint32_t ee_flags;
};
#define EFX_EVQ_MAGIC 0x08081997