net/ionic: cut down queue structure
[dpdk.git] / drivers / net / bnxt / bnxt_ring.c
index adddf9b..ba23c1f 100644 (file)
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2014-2018 Broadcom
+ * Copyright(c) 2014-2021 Broadcom
  * All rights reserved.
  */
 
@@ -346,10 +346,7 @@ static void bnxt_set_db(struct bnxt *bp,
                        uint32_t ring_mask)
 {
        if (BNXT_CHIP_P5(bp)) {
-               if (BNXT_PF(bp))
-                       db->doorbell = (char *)bp->doorbell_base + 0x10000;
-               else
-                       db->doorbell = (char *)bp->doorbell_base + 0x4000;
+               int db_offset = DB_PF_OFFSET;
                switch (ring_type) {
                case HWRM_RING_ALLOC_INPUT_RING_TYPE_TX:
                        db->db_key64 = DBR_PATH_L2 | DBR_TYPE_SQ;
@@ -365,6 +362,14 @@ static void bnxt_set_db(struct bnxt *bp,
                        db->db_key64 = DBR_PATH_L2;
                        break;
                }
+               if (BNXT_CHIP_SR2(bp)) {
+                       db->db_key64 |= DBR_VALID;
+                       db_offset = bp->legacy_db_size;
+               } else if (BNXT_VF(bp)) {
+                       db_offset = DB_VF_OFFSET;
+               }
+
+               db->doorbell = (char *)bp->doorbell_base + db_offset;
                db->db_key64 |= (uint64_t)fid << DBR_XID_SFT;
                db->db_64 = true;
        } else {
@@ -383,6 +388,12 @@ 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,
@@ -572,6 +583,17 @@ int bnxt_alloc_hwrm_rx_ring(struct bnxt *bp, int queue_index)
        struct bnxt_rx_ring_info *rxr = rxq->rx_ring;
        int rc;
 
+       /*
+        * Storage for the cp ring is allocated based on worst-case
+        * usage, the actual size to be used by hw is computed here.
+        */
+       cp_ring->ring_size = rxr->rx_ring_struct->ring_size * 2;
+
+       if (bp->eth_dev->data->scattered_rx)
+               cp_ring->ring_size *= AGG_RING_SIZE_FACTOR;
+
+       cp_ring->ring_mask = cp_ring->ring_size - 1;
+
        rc = bnxt_alloc_cmpl_ring(bp, queue_index, cpr);
        if (rc)
                goto err_out;
@@ -682,6 +704,17 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
                struct bnxt_ring *cp_ring = cpr->cp_ring_struct;
                struct bnxt_rx_ring_info *rxr = rxq->rx_ring;
 
+               /*
+                * Storage for the cp ring is allocated based on worst-case
+                * usage, the actual size to be used by hw is computed here.
+                */
+               cp_ring->ring_size = rxr->rx_ring_struct->ring_size * 2;
+
+               if (bp->eth_dev->data->scattered_rx)
+                       cp_ring->ring_size *= AGG_RING_SIZE_FACTOR;
+
+               cp_ring->ring_mask = cp_ring->ring_size - 1;
+
                if (bnxt_alloc_cmpl_ring(bp, i, cpr))
                        goto err_out;