diff mbox series

[v3,29/60] common/sfc_efx/base: maintain RxQ counter in generic code

Message ID 1600949555-28043-30-git-send-email-arybchenko@solarflare.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers show
Series common/sfc_efx: support Riverhead NIC family | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Andrew Rybchenko Sept. 24, 2020, 12:12 p.m. UTC
The counter is incremented in generic efx_rx_qcreate(), but was
asserted and decremented in NIC family specific queue create and
destroy callbacks.  Move assert and decrement to generic functions
as well to make NIC family specific callbacks shorter.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/common/sfc_efx/base/ef10_rx.c | 4 ----
 drivers/common/sfc_efx/base/efx_rx.c  | 9 +++++----
 2 files changed, 5 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/drivers/common/sfc_efx/base/ef10_rx.c b/drivers/common/sfc_efx/base/ef10_rx.c
index f27058963f..7004ab2aca 100644
--- a/drivers/common/sfc_efx/base/ef10_rx.c
+++ b/drivers/common/sfc_efx/base/ef10_rx.c
@@ -844,7 +844,6 @@  ef10_rx_qcreate(
 
 	EFX_STATIC_ASSERT(EFX_EV_RX_NLABELS == (1 << ESF_DZ_RX_QLABEL_WIDTH));
 	EFSYS_ASSERT3U(label, <, EFX_EV_RX_NLABELS);
-	EFSYS_ASSERT3U(enp->en_rx_qcount + 1, <, encp->enc_rxq_limit);
 
 	if (index >= encp->enc_rxq_limit) {
 		rc = EINVAL;
@@ -1022,9 +1021,6 @@  ef10_rx_qdestroy(
 
 	ef10_ev_rxlabel_fini(eep, label);
 
-	EFSYS_ASSERT(enp->en_rx_qcount != 0);
-	--enp->en_rx_qcount;
-
 	EFSYS_KMEM_FREE(enp->en_esip, sizeof (efx_rxq_t), erp);
 }
 
diff --git a/drivers/common/sfc_efx/base/efx_rx.c b/drivers/common/sfc_efx/base/efx_rx.c
index cce34cfce9..a361112849 100644
--- a/drivers/common/sfc_efx/base/efx_rx.c
+++ b/drivers/common/sfc_efx/base/efx_rx.c
@@ -819,6 +819,8 @@  efx_rx_qcreate_internal(
 	EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
 	EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_RX);
 
+	EFSYS_ASSERT3U(enp->en_rx_qcount + 1, <, encp->enc_rxq_limit);
+
 	EFSYS_ASSERT(ISP2(encp->enc_rxq_max_ndescs));
 	EFSYS_ASSERT(ISP2(encp->enc_rxq_min_ndescs));
 
@@ -975,6 +977,9 @@  efx_rx_qdestroy(
 
 	EFSYS_ASSERT3U(erp->er_magic, ==, EFX_RXQ_MAGIC);
 
+	EFSYS_ASSERT(enp->en_rx_qcount != 0);
+	--enp->en_rx_qcount;
+
 	erxop->erxo_qdestroy(erp);
 }
 
@@ -1626,7 +1631,6 @@  siena_rx_qcreate(
 	EFX_STATIC_ASSERT(EFX_EV_RX_NLABELS ==
 	    (1 << FRF_AZ_RX_DESCQ_LABEL_WIDTH));
 	EFSYS_ASSERT3U(label, <, EFX_EV_RX_NLABELS);
-	EFSYS_ASSERT3U(enp->en_rx_qcount + 1, <, encp->enc_rxq_limit);
 
 	if (index >= encp->enc_rxq_limit) {
 		rc = EINVAL;
@@ -1697,9 +1701,6 @@  siena_rx_qdestroy(
 	efx_nic_t *enp = erp->er_enp;
 	efx_oword_t oword;
 
-	EFSYS_ASSERT(enp->en_rx_qcount != 0);
-	--enp->en_rx_qcount;
-
 	/* Purge descriptor queue */
 	EFX_ZERO_OWORD(oword);