bnxt_en: Allocate completion ring structures for 57500 series chips.
authorMichael Chan <michael.chan@broadcom.com>
Sun, 14 Oct 2018 11:02:49 +0000 (07:02 -0400)
committerDavid S. Miller <davem@davemloft.net>
Tue, 16 Oct 2018 05:44:32 +0000 (22:44 -0700)
On 57500 chips, the original bnxt_cp_ring_info struct now refers to the
NQ.  bp->cp_nr_rings refer to the number of NQs on 57500 chips.  There
are now 2 pointers for the CP rings associated with RX and TX rings.
Modify bnxt_alloc_cp_rings() and bnxt_free_cp_rings() accordingly.

With multiple CP rings per NAPI, we need to add a pointer in
bnxt_cp_ring_info struct to point back to the bnxt_napi struct.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt.h

index a0d72370293c3ab280d90733b4d430f6de949813..9af99dd379cb9e9435bedd5e4514376c6345485f 100644 (file)
@@ -2482,6 +2482,7 @@ static void bnxt_free_cp_rings(struct bnxt *bp)
                struct bnxt_napi *bnapi = bp->bnapi[i];
                struct bnxt_cp_ring_info *cpr;
                struct bnxt_ring_struct *ring;
+               int j;
 
                if (!bnapi)
                        continue;
@@ -2490,11 +2491,50 @@ static void bnxt_free_cp_rings(struct bnxt *bp)
                ring = &cpr->cp_ring_struct;
 
                bnxt_free_ring(bp, &ring->ring_mem);
+
+               for (j = 0; j < 2; j++) {
+                       struct bnxt_cp_ring_info *cpr2 = cpr->cp_ring_arr[j];
+
+                       if (cpr2) {
+                               ring = &cpr2->cp_ring_struct;
+                               bnxt_free_ring(bp, &ring->ring_mem);
+                               kfree(cpr2);
+                               cpr->cp_ring_arr[j] = NULL;
+                       }
+               }
        }
 }
 
+static struct bnxt_cp_ring_info *bnxt_alloc_cp_sub_ring(struct bnxt *bp)
+{
+       struct bnxt_ring_mem_info *rmem;
+       struct bnxt_ring_struct *ring;
+       struct bnxt_cp_ring_info *cpr;
+       int rc;
+
+       cpr = kzalloc(sizeof(*cpr), GFP_KERNEL);
+       if (!cpr)
+               return NULL;
+
+       ring = &cpr->cp_ring_struct;
+       rmem = &ring->ring_mem;
+       rmem->nr_pages = bp->cp_nr_pages;
+       rmem->page_size = HW_CMPD_RING_SIZE;
+       rmem->pg_arr = (void **)cpr->cp_desc_ring;
+       rmem->dma_arr = cpr->cp_desc_mapping;
+       rmem->flags = BNXT_RMEM_RING_PTE_FLAG;
+       rc = bnxt_alloc_ring(bp, rmem);
+       if (rc) {
+               bnxt_free_ring(bp, rmem);
+               kfree(cpr);
+               cpr = NULL;
+       }
+       return cpr;
+}
+
 static int bnxt_alloc_cp_rings(struct bnxt *bp)
 {
+       bool sh = !!(bp->flags & BNXT_FLAG_SHARED_RINGS);
        int i, rc, ulp_base_vec, ulp_msix;
 
        ulp_msix = bnxt_get_ulp_msix_num(bp);
@@ -2508,6 +2548,7 @@ static int bnxt_alloc_cp_rings(struct bnxt *bp)
                        continue;
 
                cpr = &bnapi->cp_ring;
+               cpr->bnapi = bnapi;
                ring = &cpr->cp_ring_struct;
 
                rc = bnxt_alloc_ring(bp, &ring->ring_mem);
@@ -2518,6 +2559,29 @@ static int bnxt_alloc_cp_rings(struct bnxt *bp)
                        ring->map_idx = i + ulp_msix;
                else
                        ring->map_idx = i;
+
+               if (!(bp->flags & BNXT_FLAG_CHIP_P5))
+                       continue;
+
+               if (i < bp->rx_nr_rings) {
+                       struct bnxt_cp_ring_info *cpr2 =
+                               bnxt_alloc_cp_sub_ring(bp);
+
+                       cpr->cp_ring_arr[BNXT_RX_HDL] = cpr2;
+                       if (!cpr2)
+                               return -ENOMEM;
+                       cpr2->bnapi = bnapi;
+               }
+               if ((sh && i < bp->tx_nr_rings) ||
+                   (!sh && i >= bp->rx_nr_rings)) {
+                       struct bnxt_cp_ring_info *cpr2 =
+                               bnxt_alloc_cp_sub_ring(bp);
+
+                       cpr->cp_ring_arr[BNXT_TX_HDL] = cpr2;
+                       if (!cpr2)
+                               return -ENOMEM;
+                       cpr2->bnapi = bnapi;
+               }
        }
        return 0;
 }
index 25d592d0f304ae38578de64ac26da5b8d00d0cff..589b0be80f4ca00932db870cbe3a3de004ddce9c 100644 (file)
@@ -787,6 +787,7 @@ struct bnxt_rx_ring_info {
 };
 
 struct bnxt_cp_ring_info {
+       struct bnxt_napi        *bnapi;
        u32                     cp_raw_cons;
        struct bnxt_db_info     cp_db;
 
@@ -812,6 +813,8 @@ struct bnxt_cp_ring_info {
        struct bnxt_ring_struct cp_ring_struct;
 
        struct bnxt_cp_ring_info *cp_ring_arr[2];
+#define BNXT_RX_HDL    0
+#define BNXT_TX_HDL    1
 };
 
 struct bnxt_napi {