Commit 50e3ab78 authored by Michael Chan's avatar Michael Chan Committed by David S. Miller

bnxt_en: Allocate completion ring structures for 57500 series chips.

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: default avatarMichael Chan <michael.chan@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 41e8d798
...@@ -2482,6 +2482,7 @@ static void bnxt_free_cp_rings(struct bnxt *bp) ...@@ -2482,6 +2482,7 @@ static void bnxt_free_cp_rings(struct bnxt *bp)
struct bnxt_napi *bnapi = bp->bnapi[i]; struct bnxt_napi *bnapi = bp->bnapi[i];
struct bnxt_cp_ring_info *cpr; struct bnxt_cp_ring_info *cpr;
struct bnxt_ring_struct *ring; struct bnxt_ring_struct *ring;
int j;
if (!bnapi) if (!bnapi)
continue; continue;
...@@ -2490,11 +2491,50 @@ static void bnxt_free_cp_rings(struct bnxt *bp) ...@@ -2490,11 +2491,50 @@ static void bnxt_free_cp_rings(struct bnxt *bp)
ring = &cpr->cp_ring_struct; ring = &cpr->cp_ring_struct;
bnxt_free_ring(bp, &ring->ring_mem); 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) 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; int i, rc, ulp_base_vec, ulp_msix;
ulp_msix = bnxt_get_ulp_msix_num(bp); ulp_msix = bnxt_get_ulp_msix_num(bp);
...@@ -2508,6 +2548,7 @@ static int bnxt_alloc_cp_rings(struct bnxt *bp) ...@@ -2508,6 +2548,7 @@ static int bnxt_alloc_cp_rings(struct bnxt *bp)
continue; continue;
cpr = &bnapi->cp_ring; cpr = &bnapi->cp_ring;
cpr->bnapi = bnapi;
ring = &cpr->cp_ring_struct; ring = &cpr->cp_ring_struct;
rc = bnxt_alloc_ring(bp, &ring->ring_mem); rc = bnxt_alloc_ring(bp, &ring->ring_mem);
...@@ -2518,6 +2559,29 @@ static int bnxt_alloc_cp_rings(struct bnxt *bp) ...@@ -2518,6 +2559,29 @@ static int bnxt_alloc_cp_rings(struct bnxt *bp)
ring->map_idx = i + ulp_msix; ring->map_idx = i + ulp_msix;
else else
ring->map_idx = i; 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; return 0;
} }
......
...@@ -787,6 +787,7 @@ struct bnxt_rx_ring_info { ...@@ -787,6 +787,7 @@ struct bnxt_rx_ring_info {
}; };
struct bnxt_cp_ring_info { struct bnxt_cp_ring_info {
struct bnxt_napi *bnapi;
u32 cp_raw_cons; u32 cp_raw_cons;
struct bnxt_db_info cp_db; struct bnxt_db_info cp_db;
...@@ -812,6 +813,8 @@ struct bnxt_cp_ring_info { ...@@ -812,6 +813,8 @@ struct bnxt_cp_ring_info {
struct bnxt_ring_struct cp_ring_struct; struct bnxt_ring_struct cp_ring_struct;
struct bnxt_cp_ring_info *cp_ring_arr[2]; struct bnxt_cp_ring_info *cp_ring_arr[2];
#define BNXT_RX_HDL 0
#define BNXT_TX_HDL 1
}; };
struct bnxt_napi { struct bnxt_napi {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment