All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Chan <michael.chan@broadcom.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org
Subject: [PATCH net-next 2/8] bnxt_en: Simplify __bnxt_poll_cqs_done().
Date: Sun,  8 Mar 2020 18:45:48 -0400	[thread overview]
Message-ID: <1583707554-1163-3-git-send-email-michael.chan@broadcom.com> (raw)
In-Reply-To: <1583707554-1163-1-git-send-email-michael.chan@broadcom.com>

Simplify the function by removing tha 'all' parameter.  In the current
code, the caller has to specify whether to update/arm both completion
rings with the 'all' parameter.

Instead of this, we can just update/arm all the completion rings
that have been polled.  By setting cpr->had_work_done earlier in
__bnxt_poll_work(), we know which completion ring has been polled
and can just update/arm all the completion rings with
cpr->had_work_done set.

This simplifies the function with one less parameter and works just
as well.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 0b1af02..6b4f8d8 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -2162,6 +2162,7 @@ static int __bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
 	struct tx_cmp *txcmp;
 
 	cpr->has_more_work = 0;
+	cpr->had_work_done = 1;
 	while (1) {
 		int rc;
 
@@ -2175,7 +2176,6 @@ static int __bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
 		 * reading any further.
 		 */
 		dma_rmb();
-		cpr->had_work_done = 1;
 		if (TX_CMP_TYPE(txcmp) == CMP_TYPE_TX_L2_CMP) {
 			tx_pkts++;
 			/* return full budget so NAPI will complete. */
@@ -2392,7 +2392,7 @@ static int __bnxt_poll_cqs(struct bnxt *bp, struct bnxt_napi *bnapi, int budget)
 }
 
 static void __bnxt_poll_cqs_done(struct bnxt *bp, struct bnxt_napi *bnapi,
-				 u64 dbr_type, bool all)
+				 u64 dbr_type)
 {
 	struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring;
 	int i;
@@ -2401,7 +2401,7 @@ static void __bnxt_poll_cqs_done(struct bnxt *bp, struct bnxt_napi *bnapi,
 		struct bnxt_cp_ring_info *cpr2 = cpr->cp_ring_arr[i];
 		struct bnxt_db_info *db;
 
-		if (cpr2 && (all || cpr2->had_work_done)) {
+		if (cpr2 && cpr2->had_work_done) {
 			db = &cpr2->cp_db;
 			writeq(db->db_key64 | dbr_type |
 			       RING_CMP(cpr2->cp_raw_cons), db->doorbell);
@@ -2425,10 +2425,10 @@ static int bnxt_poll_p5(struct napi_struct *napi, int budget)
 		cpr->has_more_work = 0;
 		work_done = __bnxt_poll_cqs(bp, bnapi, budget);
 		if (cpr->has_more_work) {
-			__bnxt_poll_cqs_done(bp, bnapi, DBR_TYPE_CQ, false);
+			__bnxt_poll_cqs_done(bp, bnapi, DBR_TYPE_CQ);
 			return work_done;
 		}
-		__bnxt_poll_cqs_done(bp, bnapi, DBR_TYPE_CQ_ARMALL, true);
+		__bnxt_poll_cqs_done(bp, bnapi, DBR_TYPE_CQ_ARMALL);
 		if (napi_complete_done(napi, work_done))
 			BNXT_DB_NQ_ARM_P5(&cpr->cp_db, cpr->cp_raw_cons);
 		return work_done;
@@ -2441,8 +2441,7 @@ static int bnxt_poll_p5(struct napi_struct *napi, int budget)
 			if (cpr->has_more_work)
 				break;
 
-			__bnxt_poll_cqs_done(bp, bnapi, DBR_TYPE_CQ_ARMALL,
-					     false);
+			__bnxt_poll_cqs_done(bp, bnapi, DBR_TYPE_CQ_ARMALL);
 			cpr->cp_raw_cons = raw_cons;
 			if (napi_complete_done(napi, work_done))
 				BNXT_DB_NQ_ARM_P5(&cpr->cp_db,
@@ -2468,7 +2467,7 @@ static int bnxt_poll_p5(struct napi_struct *napi, int budget)
 		}
 		raw_cons = NEXT_RAW_CMP(raw_cons);
 	}
-	__bnxt_poll_cqs_done(bp, bnapi, DBR_TYPE_CQ, true);
+	__bnxt_poll_cqs_done(bp, bnapi, DBR_TYPE_CQ);
 	cpr->cp_raw_cons = raw_cons;
 	return work_done;
 }
-- 
2.5.1


  parent reply	other threads:[~2020-03-08 22:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-08 22:45 [PATCH net-next 0/8] bnxt_en: Updates Michael Chan
2020-03-08 22:45 ` [PATCH net-next 1/8] bnxt_en: Handle all NQ notifications in bnxt_poll_p5() Michael Chan
2020-03-08 22:45 ` Michael Chan [this message]
2020-03-08 22:45 ` [PATCH net-next 3/8] bnxt_en: Process the NQ under NAPI continuous polling Michael Chan
2020-03-08 22:45 ` [PATCH net-next 4/8] bnxt_en: Clear DCB settings after firmware reset Michael Chan
2020-03-08 22:45 ` [PATCH net-next 5/8] bnxt_en: Remove unnecessary assignment of return code Michael Chan
2020-03-08 22:45 ` [PATCH net-next 6/8] bnxt_en: Modify some bnxt_hwrm_*_free() functions to void Michael Chan
2020-03-08 22:45 ` [PATCH net-next 7/8] bnxt_en: Return -EAGAIN if fw command returns BUSY Michael Chan
2020-03-08 22:45 ` [PATCH net-next 8/8] bnxt_en: Call devlink_port_type_clear() in remove() Michael Chan
2020-03-09  4:55 ` [PATCH net-next 0/8] bnxt_en: Updates David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1583707554-1163-3-git-send-email-michael.chan@broadcom.com \
    --to=michael.chan@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.