History

bnge/bng_re: fix ring ID widths

Firmware requires more than 16 bits to address TX ring IDs for its internal QP management. Widen the associated HSI ring ID fields to 32 bits. The values firmware assigns remain within 24 bits, bounded by the hardware doorbell XID field. The fw_ring_id field belongs to bnge_ring_struct, a common struct shared by all ring types, so widening it to u32 applies uniformly across TX, RX, CP, and NQ rings but firmware assigns values within 16-bit range for all ring types except TX, which requires the wider field. Note that, Thor Ultra hardware has not yet been deployed and no firmware has been released to field, so backward compatibility is not a concern.

Vikas Gupta committed 3 months ago

Commit b9e55891 parent 47f42ff8 files · +39 −41Browse files

Unified · Split

8 files
  1. drivers/infiniband/hw/bng_re/bng_dev.c +3 −3
  2. drivers/net/ethernet/broadcom/bnge/bnge.h +1 −0
  3. drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.c +4 −4
  4. drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.h +1 −1
  5. drivers/net/ethernet/broadcom/bnge/bnge_netdev.c +24 −26
  6. drivers/net/ethernet/broadcom/bnge/bnge_netdev.h +2 −2
  7. drivers/net/ethernet/broadcom/bnge/bnge_rmem.h +1 −1
  8. include/linux/bnge/hsi.h +3 −4
drivers/infiniband/hw/bng_re/bng_dev.c+3−3
@@ -113,7 +113,7 @@ static void bng_re_fill_fw_msg(struct bnge_fw_msg *fw_msg, void *msg, · 112 unmodified lines
113113 }
114114
115115 static int bng_re_net_ring_free(struct bng_re_dev *rdev,
116− u16 fw_ring_id, int type)
116+ u32 fw_ring_id, int type)
117117 {
118118 struct bnge_auxr_dev *aux_dev = rdev->aux_dev;
119119 struct hwrm_ring_free_input req = {};
@@ -123,7 +123,7 @@ static int bng_re_net_ring_free(struct bng_re_dev *rdev, · 3 unmodified lines
123123
124124 bng_re_init_hwrm_hdr((void *)&req, HWRM_RING_FREE);
125125 req.ring_type = type;
126− req.ring_id = cpu_to_le16(fw_ring_id);
126+ req.ring_id = cpu_to_le32(fw_ring_id);
127127 bng_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
128128 sizeof(resp), BNGE_DFLT_HWRM_CMD_TIMEOUT);
129129 rc = bnge_send_msg(aux_dev, &fw_msg);
@@ -161,7 +161,7 @@ static int bng_re_net_ring_alloc(struct bng_re_dev *rdev, · 31 unmodified lines
161161 sizeof(resp), BNGE_DFLT_HWRM_CMD_TIMEOUT);
162162 rc = bnge_send_msg(aux_dev, &fw_msg);
163163 if (!rc)
164− *fw_ring_id = le16_to_cpu(resp.ring_id);
164+ *fw_ring_id = (u16)le32_to_cpu(resp.ring_id);
165165
166166 return rc;
167167 }
drivers/net/ethernet/broadcom/bnge/bnge.h+1−0
@@ -36,6 +36,7 @@ struct bnge_pf_info { · 35 unmodified lines
3636 };
3737
3838 #define INVALID_HW_RING_ID ((u16)-1)
39+#define INVALID_HW_RING_ID_32BIT (U32_MAX)
3940
4041 enum {
4142 BNGE_FW_CAP_SHORT_CMD = BIT_ULL(0),
drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.c+4−4
@@ -1283,7 +1283,7 @@ int bnge_hwrm_stat_ctx_alloc(struct bnge_net *bn) · 1282 unmodified lines
12831283
12841284 int hwrm_ring_free_send_msg(struct bnge_net *bn,
12851285 struct bnge_ring_struct *ring,
1286− u32 ring_type, int cmpl_ring_id)
1286+ u32 ring_type, u32 cmpl_ring_id)
12871287 {
12881288 struct hwrm_ring_free_input *req;
12891289 struct bnge_dev *bd = bn->bd;
@@ -1295,7 +1295,7 @@ int hwrm_ring_free_send_msg(struct bnge_net *bn, · 5 unmodified lines
12951295
12961296 req->cmpl_ring = cpu_to_le16(cmpl_ring_id);
12971297 req->ring_type = ring_type;
1298− req->ring_id = cpu_to_le16(ring->fw_ring_id);
1298+ req->ring_id = cpu_to_le32(ring->fw_ring_id);
12991299
13001300 bnge_hwrm_req_hold(bd, req);
13011301 rc = bnge_hwrm_req_send(bd, req);
@@ -1317,7 +1317,7 @@ int hwrm_ring_alloc_send_msg(struct bnge_net *bn, · 15 unmodified lines
13171317 struct hwrm_ring_alloc_output *resp;
13181318 struct hwrm_ring_alloc_input *req;
13191319 struct bnge_dev *bd = bn->bd;
1320− u16 ring_id, flags = 0;
1320+ u32 ring_id, flags = 0;
13211321 int rc;
13221322
13231323 rc = bnge_hwrm_req_init(bd, req, HWRM_RING_ALLOC);
@@ -1401,7 +1401,7 @@ int hwrm_ring_alloc_send_msg(struct bnge_net *bn, · 77 unmodified lines
14011401
14021402 resp = bnge_hwrm_req_hold(bd, req);
14031403 rc = bnge_hwrm_req_send(bd, req);
1404− ring_id = le16_to_cpu(resp->ring_id);
1404+ ring_id = le32_to_cpu(resp->ring_id);
14051405 bnge_hwrm_req_drop(bd, req);
14061406
14071407 exit:
drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.h+1−1
@@ -50,7 +50,7 @@ int bnge_hwrm_cfa_l2_set_rx_mask(struct bnge_dev *bd, · 49 unmodified lines
5050 void bnge_hwrm_stat_ctx_free(struct bnge_net *bn);
5151 int bnge_hwrm_stat_ctx_alloc(struct bnge_net *bn);
5252 int hwrm_ring_free_send_msg(struct bnge_net *bn, struct bnge_ring_struct *ring,
53− u32 ring_type, int cmpl_ring_id);
53+ u32 ring_type, u32 cmpl_ring_id);
5454 int hwrm_ring_alloc_send_msg(struct bnge_net *bn,
5555 struct bnge_ring_struct *ring,
5656 u32 ring_type, u32 map_index);
drivers/net/ethernet/broadcom/bnge/bnge_netdev.c+24−26
@@ -1327,12 +1327,12 @@ err_free_core: · 1326 unmodified lines
13271327 return rc;
13281328 }
13291329
1330−u16 bnge_cp_ring_for_rx(struct bnge_rx_ring_info *rxr)
1330+u32 bnge_cp_ring_for_rx(struct bnge_rx_ring_info *rxr)
13311331 {
13321332 return rxr->rx_cpr->ring_struct.fw_ring_id;
13331333 }
13341334
1335−u16 bnge_cp_ring_for_tx(struct bnge_tx_ring_info *txr)
1335+u32 bnge_cp_ring_for_tx(struct bnge_tx_ring_info *txr)
13361336 {
13371337 return txr->tx_cpr->ring_struct.fw_ring_id;
13381338 }
@@ -1375,12 +1375,12 @@ static void bnge_init_nq_tree(struct bnge_net *bn) · 36 unmodified lines
13751375 struct bnge_nq_ring_info *nqr = &bn->bnapi[i]->nq_ring;
13761376 struct bnge_ring_struct *ring = &nqr->ring_struct;
13771377
1378− ring->fw_ring_id = INVALID_HW_RING_ID;
1378+ ring->fw_ring_id = INVALID_HW_RING_ID_32BIT;
13791379 for (j = 0; j < nqr->cp_ring_count; j++) {
13801380 struct bnge_cp_ring_info *cpr = &nqr->cp_ring_arr[j];
13811381
13821382 ring = &cpr->ring_struct;
1383− ring->fw_ring_id = INVALID_HW_RING_ID;
1383+ ring->fw_ring_id = INVALID_HW_RING_ID_32BIT;
13841384 }
13851385 }
13861386 }
@@ -1637,7 +1637,7 @@ static void bnge_init_one_rx_ring_rxbd(struct bnge_net *bn, · 250 unmodified lines
16371637
16381638 ring = &rxr->rx_ring_struct;
16391639 bnge_init_rxbd_pages(ring, type);
1640− ring->fw_ring_id = INVALID_HW_RING_ID;
1640+ ring->fw_ring_id = INVALID_HW_RING_ID_32BIT;
16411641 }
16421642
16431643 static void bnge_init_one_agg_ring_rxbd(struct bnge_net *bn,
@@ -1647,7 +1647,7 @@ static void bnge_init_one_agg_ring_rxbd(struct bnge_net *bn, · 3 unmodified lines
16471647 u32 type;
16481648
16491649 ring = &rxr->rx_agg_ring_struct;
1650− ring->fw_ring_id = INVALID_HW_RING_ID;
1650+ ring->fw_ring_id = INVALID_HW_RING_ID_32BIT;
16511651 if (bnge_is_agg_reqd(bn->bd)) {
16521652 type = ((u32)BNGE_RX_PAGE_SIZE << RX_BD_LEN_SHIFT) |
16531653 RX_BD_TYPE_RX_AGG_BD | RX_BD_FLAGS_SOP;
@@ -1708,7 +1708,7 @@ static void bnge_init_tx_rings(struct bnge_net *bn) · 54 unmodified lines
17081708 struct bnge_tx_ring_info *txr = &bn->tx_ring[i];
17091709 struct bnge_ring_struct *ring = &txr->tx_ring_struct;
17101710
1711− ring->fw_ring_id = INVALID_HW_RING_ID;
1711+ ring->fw_ring_id = INVALID_HW_RING_ID_32BIT;
17121712
17131713 netif_queue_set_napi(bn->netdev, i, NETDEV_QUEUE_TYPE_TX,
17141714 &txr->bnapi->napi);
@@ -1867,7 +1867,7 @@ static int bnge_hwrm_rx_agg_ring_alloc(struct bnge_net *bn, · 152 unmodified lines
18671867 ring->fw_ring_id);
18681868 bnge_db_write(bn->bd, &rxr->rx_agg_db, rxr->rx_agg_prod);
18691869 bnge_db_write(bn->bd, &rxr->rx_db, rxr->rx_prod);
1870− bn->grp_info[grp_idx].agg_fw_ring_id = ring->fw_ring_id;
1870+ bn->grp_info[grp_idx].agg_fw_ring_id = (u16)ring->fw_ring_id;
18711871
18721872 return 0;
18731873 }
@@ -1886,7 +1886,7 @@ static int bnge_hwrm_rx_ring_alloc(struct bnge_net *bn, · 12 unmodified lines
18861886 return rc;
18871887
18881888 bnge_set_db(bn, &rxr->rx_db, type, map_idx, ring->fw_ring_id);
1889− bn->grp_info[map_idx].rx_fw_ring_id = ring->fw_ring_id;
1889+ bn->grp_info[map_idx].rx_fw_ring_id = (u16)ring->fw_ring_id;
18901890
18911891 return 0;
18921892 }
@@ -1916,7 +1916,7 @@ static int bnge_hwrm_ring_alloc(struct bnge_net *bn) · 23 unmodified lines
19161916 bnge_set_db(bn, &nqr->nq_db, type, map_idx, ring->fw_ring_id);
19171917 bnge_db_nq(bn, &nqr->nq_db, nqr->nq_raw_cons);
19181918 enable_irq(vector);
1919− bn->grp_info[i].nq_fw_ring_id = ring->fw_ring_id;
1919+ bn->grp_info[i].nq_fw_ring_id = (u16)ring->fw_ring_id;
19201920
19211921 if (!i) {
19221922 rc = bnge_hwrm_set_async_event_cr(bd, ring->fw_ring_id);
@@ -1986,15 +1986,13 @@ void bnge_fill_hw_rss_tbl(struct bnge_net *bn, struct bnge_vnic_info *vnic) · 63 unmodified lines
19861986 tbl_size = bnge_get_rxfh_indir_size(bd);
19871987
19881988 for (i = 0; i < tbl_size; i++) {
1989− u16 ring_id, j;
1989+ u32 j;
19901990
19911991 j = bd->rss_indir_tbl[i];
19921992 rxr = &bn->rx_ring[j];
19931993
1994− ring_id = rxr->rx_ring_struct.fw_ring_id;
1995− *ring_tbl++ = cpu_to_le16(ring_id);
1996− ring_id = bnge_cp_ring_for_rx(rxr);
1997− *ring_tbl++ = cpu_to_le16(ring_id);
1994+ *ring_tbl++ = cpu_to_le16(rxr->rx_ring_struct.fw_ring_id);
1995+ *ring_tbl++ = cpu_to_le16(bnge_cp_ring_for_rx(rxr));
19981996 }
19991997 }
20001998
@@ -2285,7 +2283,7 @@ static void bnge_disable_int(struct bnge_net *bn) · 284 unmodified lines
22852283 nqr = &bnapi->nq_ring;
22862284 ring = &nqr->ring_struct;
22872285
2288− if (ring->fw_ring_id != INVALID_HW_RING_ID)
2286+ if (ring->fw_ring_id != INVALID_HW_RING_ID_32BIT)
22892287 bnge_db_nq(bn, &nqr->nq_db, nqr->nq_raw_cons);
22902288 }
22912289 }
@@ -2401,7 +2399,7 @@ static void bnge_hwrm_rx_ring_free(struct bnge_net *bn, · 109 unmodified lines
24012399 u32 grp_idx = rxr->bnapi->index;
24022400 u32 cmpl_ring_id;
24032401
2404− if (ring->fw_ring_id == INVALID_HW_RING_ID)
2402+ if (ring->fw_ring_id == INVALID_HW_RING_ID_32BIT)
24052403 return;
24062404
24072405 cmpl_ring_id = bnge_cp_ring_for_rx(rxr);
@@ -2409,7 +2407,7 @@ static void bnge_hwrm_rx_ring_free(struct bnge_net *bn, · 1 unmodified line
24092407 RING_FREE_REQ_RING_TYPE_RX,
24102408 close_path ? cmpl_ring_id :
24112409 INVALID_HW_RING_ID);
2412− ring->fw_ring_id = INVALID_HW_RING_ID;
2410+ ring->fw_ring_id = INVALID_HW_RING_ID_32BIT;
24132411 bn->grp_info[grp_idx].rx_fw_ring_id = INVALID_HW_RING_ID;
24142412 }
24152413
@@ -2421,14 +2419,14 @@ static void bnge_hwrm_rx_agg_ring_free(struct bnge_net *bn, · 5 unmodified lines
24212419 u32 grp_idx = rxr->bnapi->index;
24222420 u32 cmpl_ring_id;
24232421
2424− if (ring->fw_ring_id == INVALID_HW_RING_ID)
2422+ if (ring->fw_ring_id == INVALID_HW_RING_ID_32BIT)
24252423 return;
24262424
24272425 cmpl_ring_id = bnge_cp_ring_for_rx(rxr);
24282426 hwrm_ring_free_send_msg(bn, ring, RING_FREE_REQ_RING_TYPE_RX_AGG,
24292427 close_path ? cmpl_ring_id :
24302428 INVALID_HW_RING_ID);
2431− ring->fw_ring_id = INVALID_HW_RING_ID;
2429+ ring->fw_ring_id = INVALID_HW_RING_ID_32BIT;
24322430 bn->grp_info[grp_idx].agg_fw_ring_id = INVALID_HW_RING_ID;
24332431 }
24342432
@@ -2439,14 +2437,14 @@ static void bnge_hwrm_tx_ring_free(struct bnge_net *bn, · 4 unmodified lines
24392437 struct bnge_ring_struct *ring = &txr->tx_ring_struct;
24402438 u32 cmpl_ring_id;
24412439
2442− if (ring->fw_ring_id == INVALID_HW_RING_ID)
2440+ if (ring->fw_ring_id == INVALID_HW_RING_ID_32BIT)
24432441 return;
24442442
24452443 cmpl_ring_id = close_path ? bnge_cp_ring_for_tx(txr) :
24462444 INVALID_HW_RING_ID;
24472445 hwrm_ring_free_send_msg(bn, ring, RING_FREE_REQ_RING_TYPE_TX,
24482446 cmpl_ring_id);
2449− ring->fw_ring_id = INVALID_HW_RING_ID;
2447+ ring->fw_ring_id = INVALID_HW_RING_ID_32BIT;
24502448 }
24512449
24522450 static void bnge_hwrm_cp_ring_free(struct bnge_net *bn,
@@ -2455,12 +2453,12 @@ static void bnge_hwrm_cp_ring_free(struct bnge_net *bn, · 2 unmodified lines
24552453 struct bnge_ring_struct *ring;
24562454
24572455 ring = &cpr->ring_struct;
2458− if (ring->fw_ring_id == INVALID_HW_RING_ID)
2456+ if (ring->fw_ring_id == INVALID_HW_RING_ID_32BIT)
24592457 return;
24602458
24612459 hwrm_ring_free_send_msg(bn, ring, RING_FREE_REQ_RING_TYPE_L2_CMPL,
24622460 INVALID_HW_RING_ID);
2463− ring->fw_ring_id = INVALID_HW_RING_ID;
2461+ ring->fw_ring_id = INVALID_HW_RING_ID_32BIT;
24642462 }
24652463
24662464 static void bnge_hwrm_ring_free(struct bnge_net *bn, bool close_path)
@@ -2496,11 +2494,11 @@ static void bnge_hwrm_ring_free(struct bnge_net *bn, bool close_path) · 29 unmodified lines
24962494 bnge_hwrm_cp_ring_free(bn, &nqr->cp_ring_arr[j]);
24972495
24982496 ring = &nqr->ring_struct;
2499− if (ring->fw_ring_id != INVALID_HW_RING_ID) {
2497+ if (ring->fw_ring_id != INVALID_HW_RING_ID_32BIT) {
25002498 hwrm_ring_free_send_msg(bn, ring,
25012499 RING_FREE_REQ_RING_TYPE_NQ,
25022500 INVALID_HW_RING_ID);
2503− ring->fw_ring_id = INVALID_HW_RING_ID;
2501+ ring->fw_ring_id = INVALID_HW_RING_ID_32BIT;
25042502 bn->grp_info[i].nq_fw_ring_id = INVALID_HW_RING_ID;
25052503 }
25062504 }
drivers/net/ethernet/broadcom/bnge/bnge_netdev.h+2−2
@@ -630,8 +630,8 @@ struct bnge_l2_filter { · 629 unmodified lines
630630 refcount_t refcnt;
631631 };
632632
633−u16 bnge_cp_ring_for_rx(struct bnge_rx_ring_info *rxr);
634−u16 bnge_cp_ring_for_tx(struct bnge_tx_ring_info *txr);
633+u32 bnge_cp_ring_for_rx(struct bnge_rx_ring_info *rxr);
634+u32 bnge_cp_ring_for_tx(struct bnge_tx_ring_info *txr);
635635 void bnge_fill_hw_rss_tbl(struct bnge_net *bn, struct bnge_vnic_info *vnic);
636636 int bnge_alloc_rx_data(struct bnge_net *bn, struct bnge_rx_ring_info *rxr,
637637 u16 prod, gfp_t gfp);
drivers/net/ethernet/broadcom/bnge/bnge_rmem.h+1−1
@@ -184,7 +184,7 @@ struct bnge_ctx_mem_info { · 183 unmodified lines
184184 struct bnge_ring_struct {
185185 struct bnge_ring_mem_info ring_mem;
186186
187− u16 fw_ring_id;
187+ u32 fw_ring_id;
188188 union {
189189 u16 grp_idx;
190190 u16 map_idx; /* Used by NQs */
include/linux/bnge/hsi.h+3−4
@@ -8317,8 +8317,7 @@ struct hwrm_ring_alloc_output { · 8316 unmodified lines
83178317 __le16 req_type;
83188318 __le16 seq_id;
83198319 __le16 resp_len;
8320− __le16 ring_id;
8321− __le16 logical_ring_id;
8320+ __le32 ring_id;
83228321 u8 push_buffer_index;
83238322 #define RING_ALLOC_RESP_PUSH_BUFFER_INDEX_PING_BUFFER 0x0UL
83248323 #define RING_ALLOC_RESP_PUSH_BUFFER_INDEX_PONG_BUFFER 0x1UL
@@ -8345,10 +8344,10 @@ struct hwrm_ring_free_input { · 20 unmodified lines
83458344 u8 flags;
83468345 #define RING_FREE_REQ_FLAGS_VIRTIO_RING_VALID 0x1UL
83478346 #define RING_FREE_REQ_FLAGS_LAST RING_FREE_REQ_FLAGS_VIRTIO_RING_VALID
8348− __le16 ring_id;
8347+ __le16 unused_1;
83498348 __le32 prod_idx;
83508349 __le32 opaque;
8351− __le32 unused_1;
8350+ __le32 ring_id;
83528351 };
83538352
83548353 /* hwrm_ring_free_output (size:128b/16B) */