Skip to content

Commit 9c0b06d

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Remove BNXT_RX_HDL and BNXT_TX_HDL
These 2 constants were used for the one RX and one TX completion ring pointer in the cpr->cp_ring_arr fixed array. Now that we've changed to allocating the array for the exact number of entries to support more TX rings, we no longer use these constants. The array index as well as the type of completion ring (RX/TX) are now encoded in the handle for the completion ring. This will allow us to locate the completion ring during NAPI for any number of completion rings sharing the same MSIX. In the following patches, we'll be adding support for more TX rings associated with the same MSIX vector. Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com> Signed-off-by: Michael Chan <michael.chan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7845b8d commit 9c0b06d

File tree

2 files changed

+44
-24
lines changed

2 files changed

+44
-24
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2906,12 +2906,15 @@ static int bnxt_poll_p5(struct napi_struct *napi, int budget)
29062906

29072907
if (nqcmp->type == cpu_to_le16(NQ_CN_TYPE_CQ_NOTIFICATION)) {
29082908
u32 idx = le32_to_cpu(nqcmp->cq_handle_low);
2909+
u32 cq_type = BNXT_NQ_HDL_TYPE(idx);
29092910
struct bnxt_cp_ring_info *cpr2;
29102911

29112912
/* No more budget for RX work */
2912-
if (budget && work_done >= budget && idx == BNXT_RX_HDL)
2913+
if (budget && work_done >= budget &&
2914+
cq_type == BNXT_NQ_HDL_TYPE_RX)
29132915
break;
29142916

2917+
idx = BNXT_NQ_HDL_IDX(idx);
29152918
cpr2 = &cpr->cp_ring_arr[idx];
29162919
work_done += __bnxt_poll_work(bp, cpr2,
29172920
budget - work_done);
@@ -2927,8 +2930,9 @@ static int bnxt_poll_p5(struct napi_struct *napi, int budget)
29272930
BNXT_DB_NQ_P5(&cpr->cp_db, raw_cons);
29282931
}
29292932
poll_done:
2930-
cpr_rx = &cpr->cp_ring_arr[BNXT_RX_HDL];
2931-
if (cpr_rx->bnapi && (bp->flags & BNXT_FLAG_DIM)) {
2933+
cpr_rx = &cpr->cp_ring_arr[0];
2934+
if (cpr_rx->cp_ring_type == BNXT_NQ_HDL_TYPE_RX &&
2935+
(bp->flags & BNXT_FLAG_DIM)) {
29322936
struct dim_sample dim_sample = {};
29332937

29342938
dim_update_sample(cpr->event_ctr,
@@ -3592,6 +3596,7 @@ static int bnxt_alloc_cp_rings(struct bnxt *bp)
35923596
struct bnxt_napi *bnapi = bp->bnapi[i];
35933597
struct bnxt_cp_ring_info *cpr, *cpr2;
35943598
struct bnxt_ring_struct *ring;
3599+
int cp_count = 0, k;
35953600

35963601
if (!bnapi)
35973602
continue;
@@ -3612,30 +3617,32 @@ static int bnxt_alloc_cp_rings(struct bnxt *bp)
36123617
if (!(bp->flags & BNXT_FLAG_CHIP_P5))
36133618
continue;
36143619

3615-
cpr->cp_ring_count = 2;
3616-
cpr->cp_ring_arr = kcalloc(cpr->cp_ring_count, sizeof(*cpr),
3620+
if (i < bp->rx_nr_rings)
3621+
cp_count++;
3622+
if ((sh && i < bp->tx_nr_rings) ||
3623+
(!sh && i >= bp->rx_nr_rings))
3624+
cp_count++;
3625+
3626+
cpr->cp_ring_arr = kcalloc(cp_count, sizeof(*cpr),
36173627
GFP_KERNEL);
3618-
if (!cpr->cp_ring_arr) {
3619-
cpr->cp_ring_count = 0;
3628+
if (!cpr->cp_ring_arr)
36203629
return -ENOMEM;
3621-
}
3630+
cpr->cp_ring_count = cp_count;
36223631

3623-
if (i < bp->rx_nr_rings) {
3624-
cpr2 = &cpr->cp_ring_arr[BNXT_RX_HDL];
3625-
rc = bnxt_alloc_cp_sub_ring(bp, cpr2);
3626-
if (rc)
3627-
return rc;
3628-
cpr2->bnapi = bnapi;
3629-
bp->rx_ring[i].rx_cpr = cpr2;
3630-
}
3631-
if ((sh && i < bp->tx_nr_rings) ||
3632-
(!sh && i >= bp->rx_nr_rings)) {
3633-
cpr2 = &cpr->cp_ring_arr[BNXT_TX_HDL];
3632+
for (k = 0; k < cp_count; k++) {
3633+
cpr2 = &cpr->cp_ring_arr[k];
36343634
rc = bnxt_alloc_cp_sub_ring(bp, cpr2);
36353635
if (rc)
36363636
return rc;
36373637
cpr2->bnapi = bnapi;
3638-
bp->tx_ring[j++].tx_cpr = cpr2;
3638+
cpr2->cp_idx = k;
3639+
if (!k && i < bp->rx_nr_rings) {
3640+
bp->rx_ring[i].rx_cpr = cpr2;
3641+
cpr2->cp_ring_type = BNXT_NQ_HDL_TYPE_RX;
3642+
} else {
3643+
bp->tx_ring[j++].tx_cpr = cpr2;
3644+
cpr2->cp_ring_type = BNXT_NQ_HDL_TYPE_TX;
3645+
}
36393646
}
36403647
}
36413648
return 0;
@@ -6023,7 +6030,7 @@ static int bnxt_hwrm_ring_alloc(struct bnxt *bp)
60236030
u32 type2 = HWRM_RING_ALLOC_CMPL;
60246031

60256032
ring = &cpr2->cp_ring_struct;
6026-
ring->handle = BNXT_TX_HDL;
6033+
ring->handle = BNXT_SET_NQ_HDL(cpr2);
60276034
map_idx = bnapi->index;
60286035
rc = hwrm_ring_alloc_send_msg(bp, ring, type2, map_idx);
60296036
if (rc)
@@ -6060,7 +6067,7 @@ static int bnxt_hwrm_ring_alloc(struct bnxt *bp)
60606067
u32 type2 = HWRM_RING_ALLOC_CMPL;
60616068

60626069
ring = &cpr2->cp_ring_struct;
6063-
ring->handle = BNXT_RX_HDL;
6070+
ring->handle = BNXT_SET_NQ_HDL(cpr2);
60646071
rc = hwrm_ring_alloc_send_msg(bp, ring, type2, map_idx);
60656072
if (rc)
60666073
goto err_out;

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,19 @@ struct nqe_cn {
543543
__le32 cq_handle_high;
544544
};
545545

546+
#define BNXT_NQ_HDL_IDX_MASK 0x00ffffff
547+
#define BNXT_NQ_HDL_TYPE_MASK 0xff000000
548+
#define BNXT_NQ_HDL_TYPE_SHIFT 24
549+
#define BNXT_NQ_HDL_TYPE_RX 0x00
550+
#define BNXT_NQ_HDL_TYPE_TX 0x01
551+
552+
#define BNXT_NQ_HDL_IDX(hdl) ((hdl) & BNXT_NQ_HDL_IDX_MASK)
553+
#define BNXT_NQ_HDL_TYPE(hdl) (((hdl) & BNXT_NQ_HDL_TYPE_MASK) >> \
554+
BNXT_NQ_HDL_TYPE_SHIFT)
555+
556+
#define BNXT_SET_NQ_HDL(cpr) \
557+
(((cpr)->cp_ring_type << BNXT_NQ_HDL_TYPE_SHIFT) | (cpr)->cp_idx)
558+
546559
#define DB_IDX_MASK 0xffffff
547560
#define DB_IDX_VALID (0x1 << 26)
548561
#define DB_IRQ_DIS (0x1 << 27)
@@ -997,6 +1010,8 @@ struct bnxt_cp_ring_info {
9971010

9981011
u8 had_work_done:1;
9991012
u8 has_more_work:1;
1013+
u8 cp_ring_type;
1014+
u8 cp_idx;
10001015

10011016
u32 last_cp_raw_cons;
10021017

@@ -1023,8 +1038,6 @@ struct bnxt_cp_ring_info {
10231038

10241039
int cp_ring_count;
10251040
struct bnxt_cp_ring_info *cp_ring_arr;
1026-
#define BNXT_RX_HDL 0
1027-
#define BNXT_TX_HDL 1
10281041
};
10291042

10301043
struct bnxt_napi {

0 commit comments

Comments
 (0)