bnge/bng_re: fix ring ID widths
Subsystems (5)
Vikas Gupta
maintainerPATCH v2 1/1 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.
RX, completion, and NQ ring IDs are unaffected and remain 16-bit.
---
V2:
Sashiko review:
- Updated commit message only, no code change.
- Sashiko's concern about XID overflow is valid in theory but is handled by firmware, which guarantees TX ring IDs stay within the 24-bit hardware doorbell XID field.
- Backward compatibility with older firmware is not a concern.
drivers/infiniband/hw/bng_re/bng_dev.c | 6 +-- drivers/net/ethernet/broadcom/bnge/bnge.h | 1 + .../ethernet/broadcom/bnge/bnge_hwrm_lib.c | 8 +-- .../ethernet/broadcom/bnge/bnge_hwrm_lib.h | 2 +- .../net/ethernet/broadcom/bnge/bnge_netdev.c | 50 +++++++++---------- .../net/ethernet/broadcom/bnge/bnge_netdev.h | 4 +- .../net/ethernet/broadcom/bnge/bnge_rmem.h | 2 +- include/linux/bnge/hsi.h | 7 ++- 8 files changed, 39 insertions(+), 41 deletions(-)
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, }static int bng_re_net_ring_free (struct bng_re_dev *rdev, -u16 fw_ring_id,int type) +u32 fw_ring_id,int type) {struct bnge_auxr_dev *aux_dev = rdev->aux_dev;struct hwrm_ring_free_input req = {};
@@ -123,7 +123,7 @@ static int bng_re_net_ring_free(struct bng_re_dev *rdev,bng_re_init_hwrm_hdr ((void *)&req,HWRM_RING_FREE ); req.ring_type = type; - req.ring_id =cpu_to_le16 (fw_ring_id); + req.ring_id =cpu_to_le32 (fw_ring_id);bng_re_fill_fw_msg (&fw_msg, (void *)&req,sizeof (req), (void *)&resp,sizeof (resp),BNGE_DFLT_HWRM_CMD_TIMEOUT ); rc =bnge_send_msg (aux_dev, &fw_msg);
@@ -161,7 +161,7 @@ static int bng_re_net_ring_alloc(struct bng_re_dev *rdev, sizeof(resp), BNGE_DFLT_HWRM_CMD_TIMEOUT); rc =bnge_send_msg (aux_dev, &fw_msg);if (!rc) - *fw_ring_id =le16_to_cpu (resp.ring_id); + *fw_ring_id = (u16 )le32_to_cpu (resp.ring_id);return rc; }
drivers/net/ethernet/broadcom/bnge/bnge.h +1 -0
@@ -36,6 +36,7 @@ struct bnge_pf_info { };#define INVALID_HW_RING_ID ((u16)-1) +#define INVALID_HW_RING_ID_32BIT (U32_MAX)enum {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)int hwrm_ring_free_send_msg (struct bnge_net *bn,struct bnge_ring_struct *ring, -u32 ring_type,int cmpl_ring_id) +u32 ring_type,u32 cmpl_ring_id) {struct hwrm_ring_free_input *req;struct bnge_dev *bd = bn->bd;
@@ -1295,7 +1295,7 @@ int hwrm_ring_free_send_msg(struct bnge_net *bn, req->cmpl_ring =cpu_to_le16 (cmpl_ring_id); req->ring_type = ring_type; - req->ring_id =cpu_to_le16 (ring->fw_ring_id); + req->ring_id =cpu_to_le32 (ring->fw_ring_id);bnge_hwrm_req_hold (bd, req); rc =bnge_hwrm_req_send (bd, req);
@@ -1317,7 +1317,7 @@ int hwrm_ring_alloc_send_msg(struct bnge_net *bn,struct hwrm_ring_alloc_output *resp;struct hwrm_ring_alloc_input *req;struct bnge_dev *bd = bn->bd; -u16 ring_id, flags =0 ; +u32 ring_id, flags =0 ;int rc; rc =bnge_hwrm_req_init (bd, req,HWRM_RING_ALLOC );
@@ -1401,7 +1401,7 @@ int hwrm_ring_alloc_send_msg(struct bnge_net *bn, resp =bnge_hwrm_req_hold (bd, req); rc =bnge_hwrm_req_send (bd, req); - ring_id =le16_to_cpu (resp->ring_id); + ring_id =le32_to_cpu (resp->ring_id);bnge_hwrm_req_drop (bd, req); 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,void bnge_hwrm_stat_ctx_free (struct bnge_net *bn);int bnge_hwrm_stat_ctx_alloc (struct bnge_net *bn);int hwrm_ring_free_send_msg (struct bnge_net *bn,struct bnge_ring_struct *ring, -u32 ring_type,int cmpl_ring_id); +u32 ring_type,u32 cmpl_ring_id);int hwrm_ring_alloc_send_msg (struct bnge_net *bn,struct bnge_ring_struct *ring,u32 ring_type,u32 map_index);
drivers/net/ethernet/broadcom/bnge/bnge_netdev.c +24 -26
177 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnge/bnge_netdev.h +2 -2
@@ -630,8 +630,8 @@ struct bnge_l2_filter {refcount_t refcnt; }; -u16 bnge_cp_ring_for_rx (struct bnge_rx_ring_info *rxr); -u16 bnge_cp_ring_for_tx (struct bnge_tx_ring_info *txr); +u32 bnge_cp_ring_for_rx (struct bnge_rx_ring_info *rxr); +u32 bnge_cp_ring_for_tx (struct bnge_tx_ring_info *txr);void bnge_fill_hw_rss_tbl (struct bnge_net *bn,struct bnge_vnic_info *vnic);int bnge_alloc_rx_data (struct bnge_net *bn,struct bnge_rx_ring_info *rxr,u16 prod,gfp_t gfp);
drivers/net/ethernet/broadcom/bnge/bnge_rmem.h +1 -1
@@ -184,7 +184,7 @@ struct bnge_ctx_mem_info {struct bnge_ring_struct {struct bnge_ring_mem_info ring_mem; -u16 fw_ring_id; +u32 fw_ring_id;union {u16 grp_idx;u16 map_idx;/* Used by NQs */
include/linux/bnge/hsi.h +3 -4
@@ -8317,8 +8317,7 @@ struct hwrm_ring_alloc_output {__le16 req_type;__le16 seq_id;__le16 resp_len; -__le16 ring_id; -__le16 logical_ring_id; +__le32 ring_id;u8 push_buffer_index;#define RING_ALLOC_RESP_PUSH_BUFFER_INDEX_PING_BUFFER 0x0UL#define RING_ALLOC_RESP_PUSH_BUFFER_INDEX_PONG_BUFFER 0x1UL
@@ -8345,10 +8344,10 @@ struct hwrm_ring_free_input {u8 flags;#define RING_FREE_REQ_FLAGS_VIRTIO_RING_VALID 0x1UL#define RING_FREE_REQ_FLAGS_LAST RING_FREE_REQ_FLAGS_VIRTIO_RING_VALID -__le16 ring_id; +__le16 unused_1;__le32 prod_idx;__le32 opaque; -__le32 unused_1; +__le32 ring_id; };/* hwrm_ring_free_output (size:128b/16B) */
Signature · 1 line
2.47.1
Quoted 1 line
- Backward compatibility with older firmware is not a concern.
Could you expand on that please.
Andrew
Vikas Gupta
maintainerHi Andrew,
Quoted 4 lines · Andrew Lunn
Quoted 2 lines
- Backward compatibility with older firmware is not a concern.
Could you expand on that please.
The backward compatibility concern raised in v1 does not apply. Thor Ultra hardware has not yet been deployed and no firmware has been released to the field. However, future revisions of HSI must maintain backward compatibility.
Thanks,
Vikas
Quoted 2 lines
Andrew
Quoted 4 lines · Vikas Gupta
Hi Andrew,
Quoted 1 line · Andrew Lunn
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
- Backward compatibility with older firmware is not a concern.
Could you expand on that please.
The backward compatibility concern raised in v1 does not apply. Thor Ultra hardware has not yet been deployed and no firmware has been released to the field. However, future revisions of HSI must maintain backward compatibility.
O.K, thanks.
We take backwards compatibility seriously. The fact this hardware has not yet escaped the laboratory, is one of the few reasons acceptable for breaking backwards compatibility, so should be stated in the commit message. That also avoids having to answer the question again and again.
Andrew
Quoted 6 lines · Vikas Gupta
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.
RX, completion, and NQ ring IDs are unaffected and remain 16-bit.
Here you mention Rx is unaffected. But you touch multiple places that are Rx specific (some comments below).
[..]
drivers/net/ethernet/broadcom/bnge/bnge.h struct bnge_pf_info { · line 39
Quoted 7 lines
drivers/net/ethernet/broadcom/bnge/bnge.h +1
-0@@ -36,6 +36,7 @@ struct bnge_pf_info { };#define INVALID_HW_RING_ID ((u16)-1) +#define INVALID_HW_RING_ID_32BIT (U32_MAX)
OK, there is much more usage of INVALID_HW_RING_ID than places touched by this patch.
[...]
drivers/net/ethernet/broadcom/bnge/bnge.h static int bnge_alloc_core(struct bnge_net *bn) · line 1330
Quoted 7 lines
drivers/net/ethernet/broadcom/bnge/bnge.h +2
-1+++ b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c@@ -1327,12 +1327,12 @@ static int bnge_alloc_core(struct bnge_net *bn)return rc; } -u16 bnge_cp_ring_for_rx (struct bnge_rx_ring_info *rxr) +u32 bnge_cp_ring_for_rx (struct bnge_rx_ring_info *rxr)
and here you change Rx ring ID width.
drivers/net/ethernet/broadcom/bnge/bnge.h static void bnge_init_one_rx_ring_rxbd(struct bnge_net *bn,
Quoted 25 lines
drivers/net/ethernet/broadcom/bnge/bnge.h +3
-3{return rxr->rx_cpr->ring_struct.fw_ring_id; } -u16 bnge_cp_ring_for_tx (struct bnge_tx_ring_info *txr) +u32 bnge_cp_ring_for_tx (struct bnge_tx_ring_info *txr) {return txr->tx_cpr->ring_struct.fw_ring_id; }@@ -1375,12 +1375,12 @@ static void bnge_init_nq_tree(struct bnge_net *bn)struct bnge_nq_ring_info *nqr = &bn->bnapi[i]->nq_ring;struct bnge_ring_struct *ring = &nqr->ring_struct; - ring->fw_ring_id =INVALID_HW_RING_ID ; + ring->fw_ring_id =INVALID_HW_RING_ID_32BIT ;for (j =0 ; j < nqr->cp_ring_count; j++) {struct bnge_cp_ring_info *cpr = &nqr->cp_ring_arr[j]; ring = &cpr->ring_struct; - ring->fw_ring_id =INVALID_HW_RING_ID ; + ring->fw_ring_id =INVALID_HW_RING_ID_32BIT ; } } }@@ -1637,7 +1637,7 @@ static void bnge_init_one_rx_ring_rxbd(struct bnge_net *bn,
ditto Rx
drivers/net/ethernet/broadcom/bnge/bnge.h static void bnge_init_one_agg_ring_rxbd(struct bnge_net *bn,
Quoted 9 lines
drivers/net/ethernet/broadcom/bnge/bnge.h +1
-1ring = &rxr->rx_ring_struct;bnge_init_rxbd_pages (ring, type); - ring->fw_ring_id =INVALID_HW_RING_ID ; + ring->fw_ring_id =INVALID_HW_RING_ID_32BIT ; } 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,
ditto Rx, and in some other places too
Vikas Gupta
maintainerQuoted 11 lines · Przemek Kitszel
Quoted 6 lines · Vikas Gupta
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.
RX, completion, and NQ ring IDs are unaffected and remain 16-bit.
Here you mention Rx is unaffected. But you touch multiple places that are Rx specific (some comments below).
The fw_ring_id field belongs to bnge_ring_struct, a common struct shared by all ring types. Widening it to u32 applies uniformly across TX, RX, CP, and NQ rings at the struct level.
I believe the commit message is incomplete but the intent was that firmware assigns values within 16-bit range for all ring types except TX, which requires the wider field.
Please let me know if this clarifies.
Quoted 8 lines
[..]
Quoted 5 lines
drivers/net/ethernet/broadcom/bnge/bnge.h +0
-0@@ -36,6 +36,7 @@ struct bnge_pf_info { };
Quoted 5 lines
drivers/net/ethernet/broadcom/bnge/bnge.h struct bnge_pf_info { · line 39
Quoted 2 lines
drivers/net/ethernet/broadcom/bnge/bnge.h +1
-0#define INVALID_HW_RING_ID ((u16)-1) +#define INVALID_HW_RING_ID_32BIT (U32_MAX)OK, there is much more usage of
INVALID_HW_RING_IDthan places touched by this patch.
INVALID_HW_RING_ID applies to 16-bit fields such as those in bnge_ring_grp_info (rx_fw_ring_id, agg_fw_ring_id, nq_fw_ring_id) and vnic fields.INVALID_HW_RING_ID_32BIT applies to ring_struct.fw_ring_id (u32), all instances of which are updated in this patch.
Thanks,
Vikas
Quoted 52 lines
[...]
drivers/net/ethernet/broadcom/bnge/bnge.h static int bnge_alloc_core(struct bnge_net *bn) · line 1330
Quoted 7 lines
+++
b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.cdrivers/net/ethernet/broadcom/bnge/bnge.h +1
-1@@ -1327,12 +1327,12 @@ static int bnge_alloc_core(struct bnge_net *bn)return rc; } -u16 bnge_cp_ring_for_rx (struct bnge_rx_ring_info *rxr) +u32 bnge_cp_ring_for_rx (struct bnge_rx_ring_info *rxr)and here you change Rx ring ID width.
drivers/net/ethernet/broadcom/bnge/bnge.h static void bnge_init_one_rx_ring_rxbd(struct bnge_net *bn,
Quoted 25 lines
drivers/net/ethernet/broadcom/bnge/bnge.h +3
-3{return rxr->rx_cpr->ring_struct.fw_ring_id; } -u16 bnge_cp_ring_for_tx (struct bnge_tx_ring_info *txr) +u32 bnge_cp_ring_for_tx (struct bnge_tx_ring_info *txr) {return txr->tx_cpr->ring_struct.fw_ring_id; }@@ -1375,12 +1375,12 @@ static void bnge_init_nq_tree(struct bnge_net *bn)struct bnge_nq_ring_info *nqr = &bn->bnapi[i]->nq_ring;struct bnge_ring_struct *ring = &nqr->ring_struct; - ring->fw_ring_id =INVALID_HW_RING_ID ; + ring->fw_ring_id =INVALID_HW_RING_ID_32BIT ;for (j =0 ; j < nqr->cp_ring_count; j++) {struct bnge_cp_ring_info *cpr = &nqr->cp_ring_arr[j]; ring = &cpr->ring_struct; - ring->fw_ring_id =INVALID_HW_RING_ID ; + ring->fw_ring_id =INVALID_HW_RING_ID_32BIT ; } } }@@ -1637,7 +1637,7 @@ static void bnge_init_one_rx_ring_rxbd(struct bnge_net *bn,ditto Rx
drivers/net/ethernet/broadcom/bnge/bnge.h static void bnge_init_one_agg_ring_rxbd(struct bnge_net *bn,
Quoted 9 lines
drivers/net/ethernet/broadcom/bnge/bnge.h +1
-1ring = &rxr->rx_ring_struct;bnge_init_rxbd_pages (ring, type); - ring->fw_ring_id =INVALID_HW_RING_ID ; + ring->fw_ring_id =INVALID_HW_RING_ID_32BIT ; } 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,ditto Rx, and in some other places too
Przemek Kitszel
Reviewed-byQuoted 14 lines · Vikas Gupta
Quoted 11 lines · Przemek Kitszel
Quoted 6 lines · Vikas Gupta
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.
RX, completion, and NQ ring IDs are unaffected and remain 16-bit.
Here you mention Rx is unaffected. But you touch multiple places that are Rx specific (some comments below).
Quoted 7 lines
The
fw_ring_idfield belongs tobnge_ring_struct, a common struct shared by all ring types. Widening it to u32 applies uniformly across TX, RX, CP, and NQ rings at the struct level.
I believe the commit message is incomplete but the intent was that firmware assigns values within 16-bit range for all ring types except TX, which requires the wider field.
Please let me know if this clarifies.
Thank you, it does clarify.
Would be nice to extend commit message to include that and also the info about HW not yet being released. Not sure if it is worth v2 though.
Jakub Kicinski
maintainerQuoted 6 lines · On Sat, 4 Jul 2026 22:17:47 +0530 Vikas Gupta wrote:
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.
RX, completion, and NQ ring IDs are unaffected and remain 16-bit.
The netdev patch queue has overflown. Please repost.