Skip to content

Commit e1714de

Browse files
Michael Chankuba-moo
authored andcommitted
bnxt_en: Refactor RX/RX AGG ring parameters setup for P5_PLUS
There is some common code for setting up RX and RX AGG ring allocation parameters for P5_PLUS chips. Refactor the logic into a new function. Reviewed-by: Hongguang Gao <[email protected]> Reviewed-by: Ajit Khaparde <[email protected]> Reviewed-by: Michal Swiatkowski <[email protected]> Signed-off-by: Michael Chan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 09cc58d commit e1714de

File tree

1 file changed

+28
-30
lines changed
  • drivers/net/ethernet/broadcom/bnxt

1 file changed

+28
-30
lines changed

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

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6944,6 +6944,28 @@ static void bnxt_hwrm_ring_grp_free(struct bnxt *bp)
69446944
hwrm_req_drop(bp, req);
69456945
}
69466946

6947+
static void bnxt_set_rx_ring_params_p5(struct bnxt *bp, u32 ring_type,
6948+
struct hwrm_ring_alloc_input *req,
6949+
struct bnxt_ring_struct *ring)
6950+
{
6951+
struct bnxt_ring_grp_info *grp_info = &bp->grp_info[ring->grp_idx];
6952+
u32 enables = RING_ALLOC_REQ_ENABLES_RX_BUF_SIZE_VALID;
6953+
6954+
if (ring_type == HWRM_RING_ALLOC_AGG) {
6955+
req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX_AGG;
6956+
req->rx_ring_id = cpu_to_le16(grp_info->rx_fw_ring_id);
6957+
req->rx_buf_size = cpu_to_le16(BNXT_RX_PAGE_SIZE);
6958+
enables |= RING_ALLOC_REQ_ENABLES_RX_RING_ID_VALID;
6959+
} else {
6960+
req->rx_buf_size = cpu_to_le16(bp->rx_buf_use_size);
6961+
if (NET_IP_ALIGN == 2)
6962+
req->flags =
6963+
cpu_to_le16(RING_ALLOC_REQ_FLAGS_RX_SOP_PAD);
6964+
}
6965+
req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx);
6966+
req->enables |= cpu_to_le32(enables);
6967+
}
6968+
69476969
static int hwrm_ring_alloc_send_msg(struct bnxt *bp,
69486970
struct bnxt_ring_struct *ring,
69496971
u32 ring_type, u32 map_index)
@@ -6995,37 +7017,13 @@ static int hwrm_ring_alloc_send_msg(struct bnxt *bp,
69957017
break;
69967018
}
69977019
case HWRM_RING_ALLOC_RX:
6998-
req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX;
6999-
req->length = cpu_to_le32(bp->rx_ring_mask + 1);
7000-
if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) {
7001-
u16 flags = 0;
7002-
7003-
/* Association of rx ring with stats context */
7004-
grp_info = &bp->grp_info[ring->grp_idx];
7005-
req->rx_buf_size = cpu_to_le16(bp->rx_buf_use_size);
7006-
req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx);
7007-
req->enables |= cpu_to_le32(
7008-
RING_ALLOC_REQ_ENABLES_RX_BUF_SIZE_VALID);
7009-
if (NET_IP_ALIGN == 2)
7010-
flags = RING_ALLOC_REQ_FLAGS_RX_SOP_PAD;
7011-
req->flags = cpu_to_le16(flags);
7012-
}
7013-
break;
70147020
case HWRM_RING_ALLOC_AGG:
7015-
if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) {
7016-
req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX_AGG;
7017-
/* Association of agg ring with rx ring */
7018-
grp_info = &bp->grp_info[ring->grp_idx];
7019-
req->rx_ring_id = cpu_to_le16(grp_info->rx_fw_ring_id);
7020-
req->rx_buf_size = cpu_to_le16(BNXT_RX_PAGE_SIZE);
7021-
req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx);
7022-
req->enables |= cpu_to_le32(
7023-
RING_ALLOC_REQ_ENABLES_RX_RING_ID_VALID |
7024-
RING_ALLOC_REQ_ENABLES_RX_BUF_SIZE_VALID);
7025-
} else {
7026-
req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX;
7027-
}
7028-
req->length = cpu_to_le32(bp->rx_agg_ring_mask + 1);
7021+
req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX;
7022+
req->length = (ring_type == HWRM_RING_ALLOC_RX) ?
7023+
cpu_to_le32(bp->rx_ring_mask + 1) :
7024+
cpu_to_le32(bp->rx_agg_ring_mask + 1);
7025+
if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS)
7026+
bnxt_set_rx_ring_params_p5(bp, ring_type, req, ring);
70297027
break;
70307028
case HWRM_RING_ALLOC_CMPL:
70317029
req->ring_type = RING_ALLOC_REQ_RING_TYPE_L2_CMPL;

0 commit comments

Comments
 (0)