[PATCH 6/7] net/bnxt: update consumer index of NQ regularly

Ajit Khaparde ajit.khaparde at broadcom.com
Thu Feb 8 18:13:29 CET 2024


Update the consumer index of the default CQ/NQ at regular intervals.
Since the size of the queue can vary, ring the queue at 1/8th the queue
depth.

Also skip NQ doorbell update if done already.

If the NQ is rearmed already or if there was no valid entry,
which is indicated by cnt being 0, skip ringing the doorbell for the NQ.

Signed-off-by: Ajit Khaparde <ajit.khaparde at broadcom.com>
Reviewed-by: Damodharam Ammepalli <damodharam.ammepalli at broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur at broadcom.com>
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil at broadcom.com>
---
 drivers/net/bnxt/bnxt_irq.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_irq.c b/drivers/net/bnxt/bnxt_irq.c
index 71d1565e08..edf16bd33e 100644
--- a/drivers/net/bnxt/bnxt_irq.c
+++ b/drivers/net/bnxt/bnxt_irq.c
@@ -17,6 +17,19 @@
  * Interrupts
  */
 
+static inline void bnxt_int_handler_rearm(struct bnxt *bp,
+					  struct bnxt_cp_ring_info *cpr,
+					  uint32_t raw_cons)
+{
+	cpr->cp_raw_cons = raw_cons;
+	if (BNXT_HAS_NQ(bp))
+		bnxt_db_nq_arm(cpr);
+	else
+		B_CP_DB_REARM(cpr, cpr->cp_raw_cons);
+}
+
+/* ARM the default CQ/NQ at intervals of 1/8th of ring size */
+#define BNXT_DB_REARM_FACTOR		8
 void bnxt_int_handler(void *param)
 {
 	struct rte_eth_dev *eth_dev = (struct rte_eth_dev *)param;
@@ -24,6 +37,7 @@ void bnxt_int_handler(void *param)
 	uint32_t cons, raw_cons, cp_ring_size;
 	struct bnxt_cp_ring_info *cpr;
 	struct cmpl_base *cmp;
+	uint16_t cnt = 0;
 
 
 	if (bp == NULL)
@@ -54,13 +68,15 @@ void bnxt_int_handler(void *param)
 
 		bnxt_event_hwrm_resp_handler(bp, cmp);
 		raw_cons = NEXT_RAW_CMP(raw_cons);
+		if (++cnt >= cp_ring_size / BNXT_DB_REARM_FACTOR) {
+			bnxt_int_handler_rearm(bp, cpr, raw_cons);
+			cnt = 0;
+		}
 	}
 
-	cpr->cp_raw_cons = raw_cons;
-	if (BNXT_HAS_NQ(bp))
-		bnxt_db_nq_arm(cpr);
-	else
-		B_CP_DB_REARM(cpr, cpr->cp_raw_cons);
+	/* cnt = 0 means no work or we rearmed already */
+	if (cnt > 0)
+		bnxt_int_handler_rearm(bp, cpr, raw_cons);
 
 	pthread_mutex_unlock(&bp->def_cp_lock);
 }
-- 
2.39.2 (Apple Git-143)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4218 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mails.dpdk.org/archives/dev/attachments/20240208/1a488004/attachment.bin>


More information about the dev mailing list