bnge/bng_re: fix ring ID widths
Subsystems (5)
Vikas Gupta
maintainerPATCH 1/1 bnge/bng_re: fix ring ID widths
Firmware extended the TX ring ID from 16 to 32 bits to accommodate its internal QP management. Update the HSI and the ring ID fields in the ring alloc/free calls accordingly.
Only the TX ring ID managed by firmware is widened but RX, completion and NQ ring IDs remain within the 16-bit range.
--- 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
Paolo Abeni
maintainerdrivers/net/ethernet/broadcom/bnge/bnge_rmem.h struct bnge_ctx_mem_info { · line 187
Quoted 10 lines · Vikas Gupta
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;
Sashiko gemini has a few concerns about the id size increases:
https://sashiko.dev/#/patchset/20260630101554.1221733-1-vikas.gupta%40broadcom.com
please have a look.
/P
Vikas Gupta
maintainerQuoted 10 lines · Paolo Abeni
Quoted 8 lines · Vikas Gupta
drivers/net/ethernet/broadcom/bnge/bnge_rmem.h +0
-0@@ -184,7 +184,7 @@ struct bnge_ctx_mem_info {struct bnge_ring_struct {struct bnge_ring_mem_info ring_mem;
Quoted 8 lines
drivers/net/ethernet/broadcom/bnge/bnge_rmem.h struct bnge_ctx_mem_info { · line 187
Quoted 2 lines
drivers/net/ethernet/broadcom/bnge/bnge_rmem.h +1
-1-u16 fw_ring_id; +u32 fw_ring_id;Sashiko gemini has a few concerns about the id size increases:
https://sashiko.dev/#/patchset/20260630101554.1221733-1-vikas.gupta%40broadcom.com
please have a look.
Sashiko's concern about backward compatibility is valid, however, the driver is not expected to work with older firmware because the Thor Ultra device has not been deployed yet.
The concern about overlapping bits is also valid, but the firmware uses a ring ID with a maximum width of 18 bits, so no overlap occurs. Nevertheless, I will add a mask for xid to improve code clarity and readability.
Thanks,
Vikas
Quoted 4 lines
/P