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.khapa...@broadcom.com>
Reviewed-by: Damodharam Ammepalli <damodharam.ammepa...@broadcom.com>
---
 drivers/net/bnxt/bnxt_cpr.h  | 5 ++---
 drivers/net/bnxt/bnxt_ring.c | 9 ++-------
 2 files changed, 4 insertions(+), 10 deletions(-)

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,
-- 
2.39.2 (Apple Git-143)

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to