[v3,20/60] common/sfc_efx/base: move EvQ create generic checks
diff mbox series

Message ID 1600949555-28043-21-git-send-email-arybchenko@solarflare.com
State Accepted
Delegated to: Ferruh Yigit
Headers show
Series
  • common/sfc_efx: support Riverhead NIC family
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Andrew Rybchenko Sept. 24, 2020, 12:11 p.m. UTC
There is no point to duplicate these generic checks in NIC family
specific handlers.

As the side effect it fixes bug with incorrect interrupt moderation
settings silently ignored on event queue create on Siena.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
Reviewed-by: Vijay Kumar Srivastava <vsrivast@xilinx.com>
---
 drivers/common/sfc_efx/base/ef10_ev.c | 20 ++-----------
 drivers/common/sfc_efx/base/efx_ev.c  | 42 ++++++++++++++++-----------
 2 files changed, 28 insertions(+), 34 deletions(-)

Patch
diff mbox series

diff --git a/drivers/common/sfc_efx/base/ef10_ev.c b/drivers/common/sfc_efx/base/ef10_ev.c
index 08729cf71e..18f19e816d 100644
--- a/drivers/common/sfc_efx/base/ef10_ev.c
+++ b/drivers/common/sfc_efx/base/ef10_ev.c
@@ -133,16 +133,6 @@  ef10_ev_qcreate(
 
 	_NOTE(ARGUNUSED(id))	/* buftbl id managed by MC */
 
-	if (index >= encp->enc_evq_limit) {
-		rc = EINVAL;
-		goto fail1;
-	}
-
-	if (us > encp->enc_evq_timer_max_us) {
-		rc = EINVAL;
-		goto fail2;
-	}
-
 	/*
 	 * NO_CONT_EV mode is only requested from the firmware when creating
 	 * receive queues, but here it needs to be specified at event queue
@@ -156,7 +146,7 @@  ef10_ev_qcreate(
 	if (flags & EFX_EVQ_FLAGS_NO_CONT_EV) {
 		if (enp->en_nic_cfg.enc_no_cont_ev_mode_supported == B_FALSE) {
 			rc = EINVAL;
-			goto fail3;
+			goto fail1;
 		}
 	}
 
@@ -197,7 +187,7 @@  ef10_ev_qcreate(
 		rc = efx_mcdi_init_evq_v2(enp, index, esmp, ndescs, irq, us,
 		    flags);
 		if (rc != 0)
-			goto fail4;
+			goto fail2;
 	} else {
 		/*
 		 * On Huntington we need to specify the settings to use.
@@ -214,15 +204,11 @@  ef10_ev_qcreate(
 		rc = efx_mcdi_init_evq(enp, index, esmp, ndescs, irq, us, flags,
 		    low_latency);
 		if (rc != 0)
-			goto fail5;
+			goto fail3;
 	}
 
 	return (0);
 
-fail5:
-	EFSYS_PROBE(fail5);
-fail4:
-	EFSYS_PROBE(fail4);
 fail3:
 	EFSYS_PROBE(fail3);
 fail2:
diff --git a/drivers/common/sfc_efx/base/efx_ev.c b/drivers/common/sfc_efx/base/efx_ev.c
index 21fddfb64d..4d11c531ce 100644
--- a/drivers/common/sfc_efx/base/efx_ev.c
+++ b/drivers/common/sfc_efx/base/efx_ev.c
@@ -236,18 +236,28 @@  efx_ev_qcreate(
 	EFSYS_ASSERT3U(enp->en_ev_qcount + 1, <,
 	    enp->en_nic_cfg.enc_evq_limit);
 
+	if (index >= encp->enc_evq_limit) {
+		rc = EINVAL;
+		goto fail1;
+	}
+
+	if (us > encp->enc_evq_timer_max_us) {
+		rc = EINVAL;
+		goto fail2;
+	}
+
 	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;
+			goto fail3;
 		}
 		break;
 	default:
 		rc = EINVAL;
-		goto fail2;
+		goto fail4;
 	}
 
 	EFSYS_ASSERT(ISP2(encp->enc_evq_max_nevs));
@@ -257,14 +267,14 @@  efx_ev_qcreate(
 	    ndescs < encp->enc_evq_min_nevs ||
 	    ndescs > encp->enc_evq_max_nevs) {
 		rc = EINVAL;
-		goto fail3;
+		goto fail5;
 	}
 
 	/* Allocate an EVQ object */
 	EFSYS_KMEM_ALLOC(enp->en_esip, sizeof (efx_evq_t), eep);
 	if (eep == NULL) {
 		rc = ENOMEM;
-		goto fail4;
+		goto fail6;
 	}
 
 	eep->ee_magic = EFX_EVQ_MAGIC;
@@ -287,16 +297,20 @@  efx_ev_qcreate(
 
 	if ((rc = eevop->eevo_qcreate(enp, index, esmp, ndescs, id, us, flags,
 	    eep)) != 0)
-		goto fail5;
+		goto fail7;
 
 	return (0);
 
-fail5:
-	EFSYS_PROBE(fail5);
+fail7:
+	EFSYS_PROBE(fail7);
 
 	*eepp = NULL;
 	enp->en_ev_qcount--;
 	EFSYS_KMEM_FREE(enp->en_esip, sizeof (efx_evq_t), eep);
+fail6:
+	EFSYS_PROBE(fail6);
+fail5:
+	EFSYS_PROBE(fail5);
 fail4:
 	EFSYS_PROBE(fail4);
 fail3:
@@ -1189,15 +1203,11 @@  siena_ev_qcreate(
 
 	_NOTE(ARGUNUSED(esmp))
 
-	if (index >= encp->enc_evq_limit) {
-		rc = EINVAL;
-		goto fail1;
-	}
 #if EFSYS_OPT_RX_SCALE
 	if (enp->en_intr.ei_type == EFX_INTR_LINE &&
 	    index >= EFX_MAXRSS_LEGACY) {
 		rc = EINVAL;
-		goto fail2;
+		goto fail1;
 	}
 #endif
 	for (size = 0;
@@ -1207,7 +1217,7 @@  siena_ev_qcreate(
 			break;
 	if (id + (1 << size) >= encp->enc_buftbl_limit) {
 		rc = EINVAL;
-		goto fail3;
+		goto fail2;
 	}
 
 	/* Set up the handler table */
@@ -1239,13 +1249,11 @@  siena_ev_qcreate(
 
 	return (0);
 
-fail3:
-	EFSYS_PROBE(fail3);
-#if EFSYS_OPT_RX_SCALE
 fail2:
 	EFSYS_PROBE(fail2);
-#endif
+#if EFSYS_OPT_RX_SCALE
 fail1:
+#endif
 	EFSYS_PROBE1(fail1, efx_rc_t, rc);
 
 	return (rc);