[v2,01/14] net/bnxt: refactor epoch setting

Message ID 20231210012455.20229-2-ajit.khaparde@broadcom.com (mailing list archive)
State Changes Requested
Delegated to: Ajit Khaparde
Headers
Series support new 5760X P7 devices |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ajit Khaparde Dec. 10, 2023, 1:24 a.m. UTC
  Fix epoch bit setting when we ring the doorbell.
Epoch bit needs to toggle alternatively from 0 to 1 every time the
ring indices wrap.
Currently its value is everything but an alternating 0 and 1.

Remove unnecessary field db_epoch_shift from
bnxt_db_info structure.

Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Damodharam Ammepalli <damodharam.ammepalli@broadcom.com>
---
 drivers/net/bnxt/bnxt_cpr.h  | 5 ++---
 drivers/net/bnxt/bnxt_ring.c | 9 ++-------
 2 files changed, 4 insertions(+), 10 deletions(-)
  

Patch

diff --git a/drivers/net/bnxt/bnxt_cpr.h b/drivers/net/bnxt/bnxt_cpr.h
index 2de154322d..26e81a6a7e 100644
--- a/drivers/net/bnxt/bnxt_cpr.h
+++ b/drivers/net/bnxt/bnxt_cpr.h
@@ -53,11 +53,10 @@  struct bnxt_db_info {
 	bool                    db_64;
 	uint32_t		db_ring_mask;
 	uint32_t		db_epoch_mask;
-	uint32_t		db_epoch_shift;
 };
 
-#define DB_EPOCH(db, idx)	(((idx) & (db)->db_epoch_mask) <<	\
-				 ((db)->db_epoch_shift))
+#define DB_EPOCH(db, idx)	(!!((idx) & (db)->db_epoch_mask) <<	\
+				 DBR_EPOCH_SFT)
 #define DB_RING_IDX(db, idx)	(((idx) & (db)->db_ring_mask) |		\
 				 DB_EPOCH(db, idx))
 
diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c
index 34b2510d54..6dacb1b37f 100644
--- a/drivers/net/bnxt/bnxt_ring.c
+++ b/drivers/net/bnxt/bnxt_ring.c
@@ -371,9 +371,10 @@  static void bnxt_set_db(struct bnxt *bp,
 			db->db_key64 = DBR_PATH_L2;
 			break;
 		}
-		if (BNXT_CHIP_SR2(bp)) {
+		if (BNXT_CHIP_P7(bp)) {
 			db->db_key64 |= DBR_VALID;
 			db_offset = bp->legacy_db_size;
+			db->db_epoch_mask = ring_mask + 1;
 		} else if (BNXT_VF(bp)) {
 			db_offset = DB_VF_OFFSET;
 		}
@@ -397,12 +398,6 @@  static void bnxt_set_db(struct bnxt *bp,
 		db->db_64 = false;
 	}
 	db->db_ring_mask = ring_mask;
-
-	if (BNXT_CHIP_SR2(bp)) {
-		db->db_epoch_mask = db->db_ring_mask + 1;
-		db->db_epoch_shift = DBR_EPOCH_SFT -
-					rte_log2_u32(db->db_epoch_mask);
-	}
 }
 
 static int bnxt_alloc_cmpl_ring(struct bnxt *bp, int queue_index,