Further improvements to bnxt_re driver
Subsystems (2)
cover Further improvements to bnxt_re driver
This short patch series is an extension to the previous refactor series. The main pourpose of these patches is to streamline the queue management code in slightly better way.
Devesh Sharma (4):
RDMA/bnxt_re: reduce device page size detection code RDMA/bnxt_re: Update missing hsi data structures RDMA/bnxt_re: simplify obtaining queue entry from hw ring RDMA/bnxt_re: Remove dead code from rcfw
drivers/infiniband/hw/bnxt_re/ib_verbs.c | 65 +++--- drivers/infiniband/hw/bnxt_re/ib_verbs.h | 10 + drivers/infiniband/hw/bnxt_re/qplib_fp.c | 354 ++++++++++++----------------- drivers/infiniband/hw/bnxt_re/qplib_fp.h | 42 +--- drivers/infiniband/hw/bnxt_re/qplib_rcfw.c | 88 +++---- drivers/infiniband/hw/bnxt_re/qplib_rcfw.h | 91 -------- drivers/infiniband/hw/bnxt_re/qplib_res.c | 1 + drivers/infiniband/hw/bnxt_re/qplib_res.h | 53 +++++ drivers/infiniband/hw/bnxt_re/roce_hsi.h | 106 +++++++++ 9 files changed, 385 insertions(+), 425 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/4 RDMA/bnxt_re: reduce device page size detection code
Getting rid of the repeated code in the driver when deciding on the page size of the hardware ring memory. A new common function would translate the ring page size into device specific page size.
--- drivers/infiniband/hw/bnxt_re/qplib_fp.c | 138 ++++++++--------------------- drivers/infiniband/hw/bnxt_re/qplib_rcfw.c | 72 ++++++--------- drivers/infiniband/hw/bnxt_re/qplib_res.h | 40 +++++++++ 3 files changed, 103 insertions(+), 147 deletions(-)
drivers/infiniband/hw/bnxt_re/qplib_fp.c +36 -102
@@ -612,6 +612,7 @@ int bnxt_qplib_create_srq(struct bnxt_qplib_res *res,struct cmdq_create_srq req;struct bnxt_qplib_pbl *pbl;u16 cmd_flags =0 ; +u16 pg_sz_lvl;int rc, idx; hwq_attr.res = res;
@@ -638,22 +639,11 @@ int bnxt_qplib_create_srq(struct bnxt_qplib_res *res, req.srq_size =cpu_to_le16 ((u16 )srq->hwq.max_elements); pbl = &srq->hwq.pbl[PBL_LVL_0 ]; - req.pg_size_lvl =cpu_to_le16 ((((u16 )srq->hwq.level & -CMDQ_CREATE_SRQ_LVL_MASK ) << -CMDQ_CREATE_SRQ_LVL_SFT ) | - (pbl->pg_size ==ROCE_PG_SIZE_4K ? -CMDQ_CREATE_SRQ_PG_SIZE_PG_4K : - pbl->pg_size ==ROCE_PG_SIZE_8K ? -CMDQ_CREATE_SRQ_PG_SIZE_PG_8K : - pbl->pg_size ==ROCE_PG_SIZE_64K ? -CMDQ_CREATE_SRQ_PG_SIZE_PG_64K : - pbl->pg_size ==ROCE_PG_SIZE_2M ? -CMDQ_CREATE_SRQ_PG_SIZE_PG_2M : - pbl->pg_size ==ROCE_PG_SIZE_8M ? -CMDQ_CREATE_SRQ_PG_SIZE_PG_8M : - pbl->pg_size ==ROCE_PG_SIZE_1G ? -CMDQ_CREATE_SRQ_PG_SIZE_PG_1G : -CMDQ_CREATE_SRQ_PG_SIZE_PG_4K )); + pg_sz_lvl = ((u16 )bnxt_qplib_base_pg_size (&srq->hwq) << +CMDQ_CREATE_SRQ_PG_SIZE_SFT ); + pg_sz_lvl |= (srq->hwq.level &CMDQ_CREATE_SRQ_LVL_MASK ) << +CMDQ_CREATE_SRQ_LVL_SFT ; + req.pg_size_lvl =cpu_to_le16 (pg_sz_lvl); req.pbl =cpu_to_le64 (pbl->pg_map_arr[0 ]); req.pd_id =cpu_to_le32 (srq->pd->id); req.eventq_id =cpu_to_le16 (srq->eventq_hw_ring_id);
@@ -809,6 +799,7 @@ int bnxt_qplib_create_qp1(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)struct bnxt_qplib_pbl *pbl;u16 cmd_flags =0 ;u32 qp_flags =0 ; +u8 pg_sz_lvl;int rc;RCFW_CMD_PREP (req,CREATE_QP1 , cmd_flags);
@@ -835,28 +826,13 @@ int bnxt_qplib_create_qp1(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp) } pbl = &sq->hwq.pbl[PBL_LVL_0 ]; req.sq_pbl =cpu_to_le64 (pbl->pg_map_arr[0 ]); - req.sq_pg_size_sq_lvl = - ((sq->hwq.level &CMDQ_CREATE_QP1_SQ_LVL_MASK ) - <<CMDQ_CREATE_QP1_SQ_LVL_SFT ) | - (pbl->pg_size ==ROCE_PG_SIZE_4K ? -CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_4K : - pbl->pg_size ==ROCE_PG_SIZE_8K ? -CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_8K : - pbl->pg_size ==ROCE_PG_SIZE_64K ? -CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_64K : - pbl->pg_size ==ROCE_PG_SIZE_2M ? -CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_2M : - pbl->pg_size ==ROCE_PG_SIZE_8M ? -CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_8M : - pbl->pg_size ==ROCE_PG_SIZE_1G ? -CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_1G : -CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_4K ); + pg_sz_lvl = (bnxt_qplib_base_pg_size (&sq->hwq) << +CMDQ_CREATE_QP1_SQ_PG_SIZE_SFT ); + pg_sz_lvl |= (sq->hwq.level &CMDQ_CREATE_QP1_SQ_LVL_MASK ); + req.sq_pg_size_sq_lvl = pg_sz_lvl;if (qp->scq) req.scq_cid =cpu_to_le32 (qp->scq->id); - - qp_flags |=CMDQ_CREATE_QP1_QP_FLAGS_RESERVED_LKEY_ENABLE ; -/* RQ */ if (rq->max_wqe) { hwq_attr.res = res;
@@ -876,32 +852,20 @@ int bnxt_qplib_create_qp1(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp) } pbl = &rq->hwq.pbl[PBL_LVL_0 ]; req.rq_pbl =cpu_to_le64 (pbl->pg_map_arr[0 ]); - req.rq_pg_size_rq_lvl = - ((rq->hwq.level &CMDQ_CREATE_QP1_RQ_LVL_MASK ) << -CMDQ_CREATE_QP1_RQ_LVL_SFT ) | - (pbl->pg_size ==ROCE_PG_SIZE_4K ? -CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_4K : - pbl->pg_size ==ROCE_PG_SIZE_8K ? -CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_8K : - pbl->pg_size ==ROCE_PG_SIZE_64K ? -CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_64K : - pbl->pg_size ==ROCE_PG_SIZE_2M ? -CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_2M : - pbl->pg_size ==ROCE_PG_SIZE_8M ? -CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_8M : - pbl->pg_size ==ROCE_PG_SIZE_1G ? -CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_1G : -CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_4K ); + pg_sz_lvl = (bnxt_qplib_base_pg_size (&rq->hwq) << +CMDQ_CREATE_QP1_RQ_PG_SIZE_SFT ); + pg_sz_lvl |= (rq->hwq.level &CMDQ_CREATE_QP1_RQ_LVL_MASK ); + req.rq_pg_size_rq_lvl = pg_sz_lvl;if (qp->rcq) req.rcq_cid =cpu_to_le32 (qp->rcq->id); } -/* Header buffer - allow hdr_buf pass in */ rc =bnxt_qplib_alloc_qp_hdr_buf (res, qp);if (rc) { rc = -ENOMEM ; goto fail; } + qp_flags |=CMDQ_CREATE_QP1_QP_FLAGS_RESERVED_LKEY_ENABLE ; req.qp_flags =cpu_to_le32 (qp_flags); req.sq_size =cpu_to_le32 (sq->hwq.max_elements); req.rq_size =cpu_to_le32 (rq->hwq.max_elements);
@@ -965,6 +929,7 @@ int bnxt_qplib_create_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)struct cmdq_create_qp req;struct bnxt_qplib_pbl *pbl;u32 qp_flags =0 ; +u8 pg_sz_lvl;u16 max_rsge;RCFW_CMD_PREP (req,CREATE_QP , cmd_flags);
@@ -1025,31 +990,14 @@ int bnxt_qplib_create_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp) } pbl = &sq->hwq.pbl[PBL_LVL_0 ]; req.sq_pbl =cpu_to_le64 (pbl->pg_map_arr[0 ]); - req.sq_pg_size_sq_lvl = - ((sq->hwq.level &CMDQ_CREATE_QP_SQ_LVL_MASK ) - <<CMDQ_CREATE_QP_SQ_LVL_SFT ) | - (pbl->pg_size ==ROCE_PG_SIZE_4K ? -CMDQ_CREATE_QP_SQ_PG_SIZE_PG_4K : - pbl->pg_size ==ROCE_PG_SIZE_8K ? -CMDQ_CREATE_QP_SQ_PG_SIZE_PG_8K : - pbl->pg_size ==ROCE_PG_SIZE_64K ? -CMDQ_CREATE_QP_SQ_PG_SIZE_PG_64K : - pbl->pg_size ==ROCE_PG_SIZE_2M ? -CMDQ_CREATE_QP_SQ_PG_SIZE_PG_2M : - pbl->pg_size ==ROCE_PG_SIZE_8M ? -CMDQ_CREATE_QP_SQ_PG_SIZE_PG_8M : - pbl->pg_size ==ROCE_PG_SIZE_1G ? -CMDQ_CREATE_QP_SQ_PG_SIZE_PG_1G : -CMDQ_CREATE_QP_SQ_PG_SIZE_PG_4K ); + pg_sz_lvl = (bnxt_qplib_base_pg_size (&sq->hwq) << +CMDQ_CREATE_QP_SQ_PG_SIZE_SFT ); + pg_sz_lvl |= (sq->hwq.level &CMDQ_CREATE_QP_SQ_LVL_MASK ); + req.sq_pg_size_sq_lvl = pg_sz_lvl;if (qp->scq) req.scq_cid =cpu_to_le32 (qp->scq->id); - qp_flags |=CMDQ_CREATE_QP_QP_FLAGS_RESERVED_LKEY_ENABLE ; - qp_flags |=CMDQ_CREATE_QP_QP_FLAGS_FR_PMR_ENABLED ; -if (qp->sig_type) - qp_flags |=CMDQ_CREATE_QP_QP_FLAGS_FORCE_COMPLETION ; -/* RQ */ if (rq->max_wqe) { hwq_attr.res = res;
@@ -1071,22 +1019,10 @@ int bnxt_qplib_create_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp) } pbl = &rq->hwq.pbl[PBL_LVL_0 ]; req.rq_pbl =cpu_to_le64 (pbl->pg_map_arr[0 ]); - req.rq_pg_size_rq_lvl = - ((rq->hwq.level &CMDQ_CREATE_QP_RQ_LVL_MASK ) << -CMDQ_CREATE_QP_RQ_LVL_SFT ) | - (pbl->pg_size ==ROCE_PG_SIZE_4K ? -CMDQ_CREATE_QP_RQ_PG_SIZE_PG_4K : - pbl->pg_size ==ROCE_PG_SIZE_8K ? -CMDQ_CREATE_QP_RQ_PG_SIZE_PG_8K : - pbl->pg_size ==ROCE_PG_SIZE_64K ? -CMDQ_CREATE_QP_RQ_PG_SIZE_PG_64K : - pbl->pg_size ==ROCE_PG_SIZE_2M ? -CMDQ_CREATE_QP_RQ_PG_SIZE_PG_2M : - pbl->pg_size ==ROCE_PG_SIZE_8M ? -CMDQ_CREATE_QP_RQ_PG_SIZE_PG_8M : - pbl->pg_size ==ROCE_PG_SIZE_1G ? -CMDQ_CREATE_QP_RQ_PG_SIZE_PG_1G : -CMDQ_CREATE_QP_RQ_PG_SIZE_PG_4K ); + pg_sz_lvl = (bnxt_qplib_base_pg_size (&rq->hwq) << +CMDQ_CREATE_QP_RQ_PG_SIZE_SFT ); + pg_sz_lvl |= (rq->hwq.level &CMDQ_CREATE_QP_RQ_LVL_MASK ); + req.rq_pg_size_rq_lvl = pg_sz_lvl; }else {/* SRQ */ if (qp->srq) {
@@ -1097,7 +1033,13 @@ int bnxt_qplib_create_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)if (qp->rcq) req.rcq_cid =cpu_to_le32 (qp->rcq->id); + + qp_flags |=CMDQ_CREATE_QP_QP_FLAGS_RESERVED_LKEY_ENABLE ; + qp_flags |=CMDQ_CREATE_QP_QP_FLAGS_FR_PMR_ENABLED ; +if (qp->sig_type) + qp_flags |=CMDQ_CREATE_QP_QP_FLAGS_FORCE_COMPLETION ; req.qp_flags =cpu_to_le32 (qp_flags); + req.sq_size =cpu_to_le32 (sq->hwq.max_elements); req.rq_size =cpu_to_le32 (rq->hwq.max_elements); qp->sq_hdr_buf =NULL ;
@@ -2000,6 +1942,7 @@ int bnxt_qplib_create_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq)struct cmdq_create_cq req;struct bnxt_qplib_pbl *pbl;u16 cmd_flags =0 ; +u32 pg_sz_lvl;int rc; hwq_attr.res = res;
@@ -2020,22 +1963,13 @@ int bnxt_qplib_create_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq) } req.dpi =cpu_to_le32 (cq->dpi->dpi); req.cq_handle =cpu_to_le64 (cq->cq_handle); - req.cq_size =cpu_to_le32 (cq->hwq.max_elements); pbl = &cq->hwq.pbl[PBL_LVL_0 ]; - req.pg_size_lvl =cpu_to_le32 ( - ((cq->hwq.level &CMDQ_CREATE_CQ_LVL_MASK ) << -CMDQ_CREATE_CQ_LVL_SFT ) | - (pbl->pg_size ==ROCE_PG_SIZE_4K ?CMDQ_CREATE_CQ_PG_SIZE_PG_4K : - pbl->pg_size ==ROCE_PG_SIZE_8K ?CMDQ_CREATE_CQ_PG_SIZE_PG_8K : - pbl->pg_size ==ROCE_PG_SIZE_64K ?CMDQ_CREATE_CQ_PG_SIZE_PG_64K : - pbl->pg_size ==ROCE_PG_SIZE_2M ?CMDQ_CREATE_CQ_PG_SIZE_PG_2M : - pbl->pg_size ==ROCE_PG_SIZE_8M ?CMDQ_CREATE_CQ_PG_SIZE_PG_8M : - pbl->pg_size ==ROCE_PG_SIZE_1G ?CMDQ_CREATE_CQ_PG_SIZE_PG_1G : -CMDQ_CREATE_CQ_PG_SIZE_PG_4K )); - + pg_sz_lvl = (bnxt_qplib_base_pg_size (&cq->hwq) << +CMDQ_CREATE_CQ_PG_SIZE_SFT ); + pg_sz_lvl |= (cq->hwq.level &CMDQ_CREATE_CQ_LVL_MASK ); + req.pg_size_lvl =cpu_to_le32 (pg_sz_lvl); req.pbl =cpu_to_le64 (pbl->pg_map_arr[0 ]); - req.cq_fco_cnq_id =cpu_to_le32 ( (cq->cnq_hw_ring_id &CMDQ_CREATE_CQ_CNQ_ID_MASK ) <<CMDQ_CREATE_CQ_CNQ_ID_SFT );
drivers/infiniband/hw/bnxt_re/qplib_rcfw.c +27 -45
88 lines not on this page · raw message
drivers/infiniband/hw/bnxt_re/qplib_res.h +40 -0
@@ -80,6 +80,15 @@ enum bnxt_qplib_pbl_lvl {#define ROCE_PG_SIZE_8M (8 * 1024 * 1024)#define ROCE_PG_SIZE_1G (1024 * 1024 * 1024) +enum bnxt_qplib_hwrm_pg_size { +BNXT_QPLIB_HWRM_PG_SIZE_4K =0 , +BNXT_QPLIB_HWRM_PG_SIZE_8K =1 , +BNXT_QPLIB_HWRM_PG_SIZE_64K =2 , +BNXT_QPLIB_HWRM_PG_SIZE_2M =3 , +BNXT_QPLIB_HWRM_PG_SIZE_8M =4 , +BNXT_QPLIB_HWRM_PG_SIZE_1G =5 , +}; +struct bnxt_qplib_reg_desc {u8 bar_id;resource_size_t bar_base;
@@ -263,6 +272,37 @@ static inline u8 bnxt_qplib_get_ring_type(struct bnxt_qplib_chip_ctx *cctx)RING_ALLOC_REQ_RING_TYPE_ROCE_CMPL ; } +static inline u8 bnxt_qplib_base_pg_size (struct bnxt_qplib_hwq *hwq) +{ +u8 pg_size =BNXT_QPLIB_HWRM_PG_SIZE_4K ; +struct bnxt_qplib_pbl *pbl; + + pbl = &hwq->pbl[PBL_LVL_0 ]; +switch (pbl->pg_size) { +case ROCE_PG_SIZE_4K : + pg_size =BNXT_QPLIB_HWRM_PG_SIZE_4K ; +break ; +case ROCE_PG_SIZE_8K : + pg_size =BNXT_QPLIB_HWRM_PG_SIZE_8K ; +break ; +case ROCE_PG_SIZE_64K : + pg_size =BNXT_QPLIB_HWRM_PG_SIZE_64K ; +break ; +case ROCE_PG_SIZE_2M : + pg_size =BNXT_QPLIB_HWRM_PG_SIZE_2M ; +break ; +case ROCE_PG_SIZE_8M : + pg_size =BNXT_QPLIB_HWRM_PG_SIZE_8M ; +break ; +case ROCE_PG_SIZE_1G : + pg_size =BNXT_QPLIB_HWRM_PG_SIZE_1G ; +break ; +default : +break ; + } + +return pg_size; +}#define to_bnxt_qplib (ptr, type, member) \ container_of(ptr, type, member)
Signature · 1 line
1.8.3.1
PATCH 2/4 RDMA/bnxt_re: Update missing hsi data structures
In reply to Devesh SharmaAdding fast path support data structure into hardware HSI. These structures are header only definition of RQE/SRQE/SQE. This is to help calculating the size of hardware wqe size.
--- drivers/infiniband/hw/bnxt_re/roce_hsi.h | 106 +++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+)
drivers/infiniband/hw/bnxt_re/roce_hsi.h +106 -0
@@ -210,6 +210,20 @@ struct sq_send {__le32 data[24 ]; }; +/* sq_send_hdr (size:256b/32B) */ +struct sq_send_hdr { +u8 wqe_type; +u8 flags; +u8 wqe_size; +u8 reserved8_1; +__le32 inv_key_or_imm_data; +__le32 length; +__le32 q_key; +__le32 dst_qp; +__le32 avid; +__le64 reserved64; +}; +/* Send Raw Ethernet and QP1 SQ WQE (40 bytes) */ struct sq_send_raweth_qp1 {u8 wqe_type;
@@ -265,6 +279,21 @@ struct sq_send_raweth_qp1 {__le32 data[24 ]; }; +/* sq_send_raweth_qp1_hdr (size:256b/32B) */ +struct sq_send_raweth_qp1_hdr { +u8 wqe_type; +u8 flags; +u8 wqe_size; +u8 reserved8; +__le16 lflags; +__le16 cfa_action; +__le32 length; +__le32 reserved32_1; +__le32 cfa_meta; +__le32 reserved32_2; +__le64 reserved64; +}; +/* RDMA SQ WQE (40 bytes) */ struct sq_rdma {u8 wqe_type;
@@ -288,6 +317,20 @@ struct sq_rdma {__le32 data[24 ]; }; +/* sq_rdma_hdr (size:256b/32B) */ +struct sq_rdma_hdr { +u8 wqe_type; +u8 flags; +u8 wqe_size; +u8 reserved8; +__le32 imm_data; +__le32 length; +__le32 reserved32_1; +__le64 remote_va; +__le32 remote_key; +__le32 reserved32_2; +}; +/* Atomic SQ WQE (40 bytes) */ struct sq_atomic {u8 wqe_type;
@@ -307,6 +350,17 @@ struct sq_atomic {__le32 data[24 ]; }; +/* sq_atomic_hdr (size:256b/32B) */ +struct sq_atomic_hdr { +u8 wqe_type; +u8 flags; +__le16 reserved16; +__le32 remote_key; +__le64 remote_va; +__le64 swap_data; +__le64 cmp_data; +}; +/* Local Invalidate SQ WQE (40 bytes) */ struct sq_localinvalidate {u8 wqe_type;
@@ -324,6 +378,16 @@ struct sq_localinvalidate {__le32 data[24 ]; }; +/* sq_localinvalidate_hdr (size:256b/32B) */ +struct sq_localinvalidate_hdr { +u8 wqe_type; +u8 flags; +__le16 reserved16; +__le32 inv_l_key; +__le64 reserved64; +u8 reserved128[16 ]; +}; +/* FR-PMR SQ WQE (40 bytes) */ struct sq_fr_pmr {u8 wqe_type;
@@ -380,6 +444,21 @@ struct sq_fr_pmr {__le32 data[24 ]; }; +/* sq_fr_pmr_hdr (size:256b/32B) */ +struct sq_fr_pmr_hdr { +u8 wqe_type; +u8 flags; +u8 access_cntl; +u8 zero_based_page_size_log; +__le32 l_key; +u8 length[5 ]; +u8 reserved8_1; +u8 reserved8_2; +u8 numlevels_pbl_page_size_log; +__le64 pblptr; +__le64 va; +}; +/* Bind SQ WQE (40 bytes) */ struct sq_bind {u8 wqe_type;
@@ -417,6 +496,22 @@ struct sq_bind {#define SQ_BIND_DATA_SFT 0 }; +/* sq_bind_hdr (size:256b/32B) */ +struct sq_bind_hdr { +u8 wqe_type; +u8 flags; +u8 access_cntl; +u8 reserved8_1; +u8 mw_type_zero_based; +u8 reserved8_2; +__le16 reserved16; +__le32 parent_l_key; +__le32 l_key; +__le64 va; +u8 length[5 ]; +u8 reserved24[3 ]; +}; +/* RQ/SRQ WQE Structures */ /* RQ/SRQ WQE (40 bytes) */ struct rq_wqe {
@@ -435,6 +530,17 @@ struct rq_wqe {__le32 data[24 ]; }; +/* rq_wqe_hdr (size:256b/32B) */ +struct rq_wqe_hdr { +u8 wqe_type; +u8 flags; +u8 wqe_size; +u8 reserved8; +__le32 reserved32; +__le32 wr_id[2 ]; +u8 reserved128[16 ]; +}; +/* CQ CQE Structures */ /* Base CQE (32 bytes) */ struct cq_base {
Signature · 1 line
1.8.3.1
PATCH 3/4 RDMA/bnxt_re: simplify obtaining queue entry from hw ring
In reply to Devesh SharmaRestructring the data path and control path queue management code to simplify the way a queue element is extracted from the hardware ring.
Introduced a new function which will give a pointer to the next ring item depending upon the current cons/prod index in the hardware queue.
further, there are hardcoding when size of queue entry is calculated, replacing it with an inline function. This function would be easier to expand if need going forward.
The code section to initialize the PSN search areas has also been restructured and couple of functions has been added there.
--- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 65 +++++---- drivers/infiniband/hw/bnxt_re/ib_verbs.h | 10 ++ drivers/infiniband/hw/bnxt_re/qplib_fp.c | 216 ++++++++++++++--------------- drivers/infiniband/hw/bnxt_re/qplib_fp.h | 42 +----- drivers/infiniband/hw/bnxt_re/qplib_rcfw.c | 16 +-- drivers/infiniband/hw/bnxt_re/qplib_rcfw.h | 41 ------ drivers/infiniband/hw/bnxt_re/qplib_res.c | 1 + drivers/infiniband/hw/bnxt_re/qplib_res.h | 13 ++ 8 files changed, 176 insertions(+), 228 deletions(-)
drivers/infiniband/hw/bnxt_re/ib_verbs.c +38 -27
@@ -856,7 +856,7 @@ static int bnxt_re_init_user_qp(struct bnxt_re_dev *rdev, struct bnxt_re_pd *pd,if (ib_copy_from_udata (&ureq, udata,sizeof (ureq)))return -EFAULT ; - bytes = (qplib_qp->sq.max_wqe *BNXT_QPLIB_MAX_SQE_ENTRY_SIZE ); + bytes = (qplib_qp->sq.max_wqe * qplib_qp->sq.wqe_size);/* Consider mapping PSN search memory only for RC QPs. */ if (qplib_qp->type ==CMDQ_CREATE_QP_TYPE_RC ) { psn_sz = bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx) ?
@@ -879,7 +879,7 @@ static int bnxt_re_init_user_qp(struct bnxt_re_dev *rdev, struct bnxt_re_pd *pd, qplib_qp->qp_handle = ureq.qp_handle;if (!qp->qplib_qp.srq) { - bytes = (qplib_qp->rq.max_wqe *BNXT_QPLIB_MAX_RQE_ENTRY_SIZE ); + bytes = (qplib_qp->rq.max_wqe * qplib_qp->rq.wqe_size); bytes =PAGE_ALIGN (bytes); umem =ib_umem_get (&rdev->ibdev, ureq.qprva, bytes,IB_ACCESS_LOCAL_WRITE );
@@ -976,6 +976,7 @@ static int bnxt_re_init_user_qp(struct bnxt_re_dev *rdev, struct bnxt_re_pd *pd, qp->qplib_qp.sig_type = true;/* Shadow QP SQ depth should be same as QP1 RQ depth */ + qp->qplib_qp.sq.wqe_size =bnxt_re_get_swqe_size (); qp->qplib_qp.sq.max_wqe = qp1_qp->rq.max_wqe; qp->qplib_qp.sq.max_sge =2 ;/* Q full delta can be 1 since it is internal QP */
@@ -986,6 +987,7 @@ static int bnxt_re_init_user_qp(struct bnxt_re_dev *rdev, struct bnxt_re_pd *pd, qp->qplib_qp.scq = qp1_qp->scq; qp->qplib_qp.rcq = qp1_qp->rcq; + qp->qplib_qp.rq.wqe_size =bnxt_re_get_rwqe_size (); qp->qplib_qp.rq.max_wqe = qp1_qp->rq.max_wqe; qp->qplib_qp.rq.max_sge = qp1_qp->rq.max_sge;/* Q full delta can be 1 since it is internal QP */
@@ -1021,10 +1023,12 @@ static int bnxt_re_init_rq_attr(struct bnxt_re_qp *qp,struct bnxt_qplib_dev_attr *dev_attr;struct bnxt_qplib_qp *qplqp;struct bnxt_re_dev *rdev; +struct bnxt_qplib_q *rq;int entries; rdev = qp->rdev; qplqp = &qp->qplib_qp; + rq = &qplqp->rq; dev_attr = &rdev->dev_attr;if (init_attr->srq) {
@@ -1036,23 +1040,21 @@ static int bnxt_re_init_rq_attr(struct bnxt_re_qp *qp,return -EINVAL ; } qplqp->srq = &srq->qplib_srq; - qplqp->rq.max_wqe =0 ; + rq->max_wqe =0 ; }else { + rq->wqe_size =bnxt_re_get_rwqe_size ();/* Allocate 1 more than what's provided so posting max doesn't * mean empty. */ entries =roundup_pow_of_two (init_attr->cap.max_recv_wr +1 ); - qplqp->rq.max_wqe =min_t (u32, entries, - dev_attr->max_qp_wqes +1 ); - - qplqp->rq.q_full_delta = qplqp->rq.max_wqe - - init_attr->cap.max_recv_wr; - qplqp->rq.max_sge = init_attr->cap.max_recv_sge; -if (qplqp->rq.max_sge > dev_attr->max_qp_sges) - qplqp->rq.max_sge = dev_attr->max_qp_sges; + rq->max_wqe =min_t (u32, entries, dev_attr->max_qp_wqes +1 ); + rq->q_full_delta = rq->max_wqe - init_attr->cap.max_recv_wr; + rq->max_sge = init_attr->cap.max_recv_sge; +if (rq->max_sge > dev_attr->max_qp_sges) + rq->max_sge = dev_attr->max_qp_sges; } - qplqp->rq.sg_info.pgsize =PAGE_SIZE ; - qplqp->rq.sg_info.pgshft =PAGE_SHIFT ; + rq->sg_info.pgsize =PAGE_SIZE ; + rq->sg_info.pgshft =PAGE_SHIFT ;return 0 ; }
@@ -1080,15 +1082,18 @@ static void bnxt_re_init_sq_attr(struct bnxt_re_qp *qp,struct bnxt_qplib_dev_attr *dev_attr;struct bnxt_qplib_qp *qplqp;struct bnxt_re_dev *rdev; +struct bnxt_qplib_q *sq;int entries; rdev = qp->rdev; qplqp = &qp->qplib_qp; + sq = &qplqp->sq; dev_attr = &rdev->dev_attr; - qplqp->sq.max_sge = init_attr->cap.max_send_sge; -if (qplqp->sq.max_sge > dev_attr->max_qp_sges) - qplqp->sq.max_sge = dev_attr->max_qp_sges; + sq->wqe_size =bnxt_re_get_swqe_size (); + sq->max_sge = init_attr->cap.max_send_sge; +if (sq->max_sge > dev_attr->max_qp_sges) + sq->max_sge = dev_attr->max_qp_sges;/* * Change the SQ depth if user has requested minimum using * configfs. Only supported for kernel consumers
@@ -1096,9 +1101,9 @@ static void bnxt_re_init_sq_attr(struct bnxt_re_qp *qp, entries = init_attr->cap.max_send_wr;/* Allocate 128 + 1 more than what's provided */ entries =roundup_pow_of_two (entries +BNXT_QPLIB_RESERVED_QP_WRS +1 ); - qplqp->sq.max_wqe =min_t (u32, entries, dev_attr->max_qp_wqes + -BNXT_QPLIB_RESERVED_QP_WRS +1 ); - qplqp->sq.q_full_delta =BNXT_QPLIB_RESERVED_QP_WRS +1 ; + sq->max_wqe =min_t (u32, entries, dev_attr->max_qp_wqes + +BNXT_QPLIB_RESERVED_QP_WRS +1 ); + sq->q_full_delta =BNXT_QPLIB_RESERVED_QP_WRS +1 ;/* * Reserving one slot for Phantom WQE. Application can * post one extra entry in this case. But allowing this to avoid
@@ -1511,7 +1516,7 @@ static int bnxt_re_init_user_srq(struct bnxt_re_dev *rdev,if (ib_copy_from_udata (&ureq, udata,sizeof (ureq)))return -EFAULT ; - bytes = (qplib_srq->max_wqe *BNXT_QPLIB_MAX_RQE_ENTRY_SIZE ); + bytes = (qplib_srq->max_wqe * qplib_srq->wqe_size); bytes =PAGE_ALIGN (bytes); umem =ib_umem_get (&rdev->ibdev, ureq.srqva, bytes,IB_ACCESS_LOCAL_WRITE );
@@ -1534,15 +1539,20 @@ int bnxt_re_create_srq(struct ib_srq *ib_srq,struct ib_srq_init_attr *srq_init_attr, struct ib_udata *udata) { - struct ib_pd *ib_pd = ib_srq->pd; - struct bnxt_re_pd *pd = container_of(ib_pd, struct bnxt_re_pd, ib_pd); -struct bnxt_re_dev *rdev = pd->rdev; -struct bnxt_qplib_dev_attr *dev_attr = &rdev->dev_attr; -struct bnxt_re_srq *srq = - container_of(ib_srq, struct bnxt_re_srq, ib_srq); + struct bnxt_qplib_dev_attr *dev_attr;struct bnxt_qplib_nq *nq =NULL ; +struct bnxt_re_dev *rdev; +struct bnxt_re_srq *srq; +struct bnxt_re_pd *pd; +struct ib_pd *ib_pd;int rc, entries; + ib_pd = ib_srq->pd; + pd = container_of(ib_pd, struct bnxt_re_pd, ib_pd); + rdev = pd->rdev; + dev_attr = &rdev->dev_attr; + srq = container_of(ib_srq, struct bnxt_re_srq, ib_srq); +if (srq_init_attr->attr.max_wr >= dev_attr->max_srq_wqes) {ibdev_err (&rdev->ibdev,"Create CQ failed - max exceeded" ); rc = -EINVAL ;
@@ -1563,8 +1573,9 @@ int bnxt_re_create_srq(struct ib_srq *ib_srq, entries =roundup_pow_of_two (srq_init_attr->attr.max_wr +1 );if (entries > dev_attr->max_srq_wqes +1 ) entries = dev_attr->max_srq_wqes +1 ; - srq->qplib_srq.max_wqe = entries; + + srq->qplib_srq.wqe_size =bnxt_re_get_rwqe_size (); srq->qplib_srq.max_sge = srq_init_attr->attr.max_sge; srq->qplib_srq.threshold = srq_init_attr->attr.srq_limit; srq->srq_limit = srq_init_attr->attr.srq_limit;
drivers/infiniband/hw/bnxt_re/ib_verbs.h +10 -0
@@ -142,6 +142,16 @@ struct bnxt_re_ucontext {spinlock_t sh_lock;/* protect shpg */ }; +static inline u16 bnxt_re_get_swqe_size (void ) +{ +return sizeof (struct sq_send ); +} + +static inline u16 bnxt_re_get_rwqe_size (void ) +{ +return sizeof (struct rq_wqe ); +} +int bnxt_re_query_device (struct ib_device *ibdev,struct ib_device_attr *ib_attr,struct ib_udata *udata);
drivers/infiniband/hw/bnxt_re/qplib_fp.c +106 -110
427 lines not on this page · raw message
drivers/infiniband/hw/bnxt_re/qplib_fp.h +3 -39
73 lines not on this page · raw message
drivers/infiniband/hw/bnxt_re/qplib_rcfw.c +5 -11
@@ -89,10 +89,9 @@ static int __send_message(struct bnxt_qplib_rcfw *rcfw, struct cmdq_base *req, struct creq_base *resp, void *sb, u8 is_block) { struct bnxt_qplib_cmdq_ctx *cmdq = &rcfw->cmdq; -struct bnxt_qplib_cmdqe *cmdqe, **hwq_ptr;struct bnxt_qplib_hwq *hwq = &cmdq->hwq;struct bnxt_qplib_crsqe *crsqe; -u32 cmdq_depth = rcfw->cmdq_depth; +struct bnxt_qplib_cmdqe *cmdqe;u32 sw_prod, cmdq_prod;struct pci_dev *pdev;unsigned long flags;
@@ -163,13 +162,11 @@ static int __send_message(struct bnxt_qplib_rcfw *rcfw, struct cmdq_base *req,BNXT_QPLIB_CMDQE_UNITS ; } - hwq_ptr = (struct bnxt_qplib_cmdqe **)hwq->pbl_ptr; preq = (u8 *)req; do { /* Locate the next cmdq slot */ sw_prod = HWQ_CMP(hwq->prod, hwq); - cmdqe = &hwq_ptr[get_cmdq_pg(sw_prod, cmdq_depth)] - [get_cmdq_idx(sw_prod, cmdq_depth)]; + cmdqe = bnxt_qplib_get_qe(hwq, sw_prod, NULL); if (!cmdqe) { dev_err(&pdev->dev, "RCFW request failed with no cmdqe!\n");
@@ -378,7 +375,7 @@ static void bnxt_qplib_service_creq(unsigned long data)struct bnxt_qplib_creq_ctx *creq = &rcfw->creq;u32 type, budget =CREQ_ENTRY_POLL_BUDGET ;struct bnxt_qplib_hwq *hwq = &creq->hwq; -struct creq_base *creqe, **hwq_ptr; +struct creq_base *creqe;u32 sw_cons, raw_cons;unsigned long flags;
@@ -387,8 +384,7 @@ static void bnxt_qplib_service_creq(unsigned long data) raw_cons = hwq->cons;while (budget >0 ) { sw_cons =HWQ_CMP (raw_cons, hwq); - hwq_ptr = (struct creq_base **)hwq->pbl_ptr; - creqe = &hwq_ptr[get_creq_pg (sw_cons)][get_creq_idx (sw_cons)]; + creqe =bnxt_qplib_get_qe (hwq, sw_cons,NULL );if (!CREQ_CMP_VALID (creqe, raw_cons, hwq->max_elements))break ;/* The valid test of the entry must be done first before
@@ -434,7 +430,6 @@ static irqreturn_t bnxt_qplib_creq_irq(int irq, void *dev_instance) {struct bnxt_qplib_rcfw *rcfw = dev_instance;struct bnxt_qplib_creq_ctx *creq; -struct creq_base **creq_ptr;struct bnxt_qplib_hwq *hwq;u32 sw_cons;
@@ -442,8 +437,7 @@ static irqreturn_t bnxt_qplib_creq_irq(int irq, void *dev_instance) hwq = &creq->hwq;/* Prefetch the CREQ element */ sw_cons =HWQ_CMP (hwq->cons, hwq); - creq_ptr = (struct creq_base **)creq->hwq.pbl_ptr; -prefetch (&creq_ptr[get_creq_pg (sw_cons)][get_creq_idx (sw_cons)]); +prefetch (bnxt_qplib_get_qe (hwq, sw_cons,NULL ));tasklet_schedule (&creq->creq_tasklet);
drivers/infiniband/hw/bnxt_re/qplib_rcfw.h +0 -41
65 lines not on this page · raw message
drivers/infiniband/hw/bnxt_re/qplib_res.c +1 -0
@@ -347,6 +347,7 @@ int bnxt_qplib_alloc_init_hwq(struct bnxt_qplib_hwq *hwq, hwq->depth = hwq_attr->depth; hwq->max_elements = depth; hwq->element_size = stride; + hwq->qe_ppg = pg_size / stride;/* For direct access to the elements */ lvl = hwq->level;if (hwq_attr->sginfo->nopte && hwq->level)
drivers/infiniband/hw/bnxt_re/qplib_res.h +13 -0
@@ -135,6 +135,7 @@ struct bnxt_qplib_hwq {u32 max_elements;u32 depth;u16 element_size;/* Size of each entry */ +u16 qe_ppg;/* queue entry per page */ u32 prod;/* raw */ u32 cons;/* raw */
@@ -304,6 +305,18 @@ static inline u8 bnxt_qplib_base_pg_size(struct bnxt_qplib_hwq *hwq)return pg_size; } +static inline void *bnxt_qplib_get_qe (struct bnxt_qplib_hwq *hwq, +u32 indx,u64 *pg) +{ +u32 pg_num, pg_idx; + + pg_num = (indx / hwq->qe_ppg); + pg_idx = (indx % hwq->qe_ppg); +if (pg) + *pg = (u64)&hwq->pbl_ptr[pg_num]; +return (void *)(hwq->pbl_ptr[pg_num] + hwq->element_size * pg_idx); +} +#define to_bnxt_qplib (ptr, type, member) \ container_of(ptr, type, member)
Signature · 1 line
1.8.3.1
PATCH 4/4 RDMA/bnxt_re: Remove dead code from rcfw
In reply to Devesh SharmaIn the previous refactoring serise there were few
leftover functions which are not is use anymore.
Removed them as it is a dead code.
--- drivers/infiniband/hw/bnxt_re/qplib_rcfw.h | 50 ------------------------------ 1 file changed, 50 deletions(-)
drivers/infiniband/hw/bnxt_re/qplib_rcfw.h +0 -50
@@ -112,56 +112,6 @@ struct bnxt_qplib_crsbe {#define CREQ_CMP_VALID (hdr, raw_cons, cp_bit) \ (!!((hdr)->v & CREQ_BASE_V) == \ !((raw_cons) & (cp_bit))) - -#define CREQ_DB_KEY_CP (0x2 << CMPL_DOORBELL_KEY_SFT) -#define CREQ_DB_IDX_VALID CMPL_DOORBELL_IDX_VALID -#define CREQ_DB_IRQ_DIS CMPL_DOORBELL_MASK -#define CREQ_DB_CP_FLAGS_REARM (CREQ_DB_KEY_CP | \ - CREQ_DB_IDX_VALID) -#define CREQ_DB_CP_FLAGS (CREQ_DB_KEY_CP | \ - CREQ_DB_IDX_VALID | \ - CREQ_DB_IRQ_DIS) - -static inline void bnxt_qplib_ring_creq_db64 (void __iomem *db,u32 index, -u32 xid,bool arm) -{ -u64 val =0 ; - - val = xid &DBC_DBC_XID_MASK ; - val |=DBC_DBC_PATH_ROCE ; - val |= arm ?DBC_DBC_TYPE_NQ_ARM :DBC_DBC_TYPE_NQ ; - val <<=32 ; - val |= index &DBC_DBC_INDEX_MASK ; - -writeq (val, db); -} - -static inline void bnxt_qplib_ring_creq_db_rearm (void __iomem *db,u32 raw_cons, -u32 max_elements,u32 xid, -bool gen_p5) -{ -u32 index = raw_cons & (max_elements -1 ); - -if (gen_p5) -bnxt_qplib_ring_creq_db64 (db, index, xid, true); -else -writel (CREQ_DB_CP_FLAGS_REARM | (index &DBC_DBC32_XID_MASK ), - db); -} - -static inline void bnxt_qplib_ring_creq_db (void __iomem *db,u32 raw_cons, -u32 max_elements,u32 xid, -bool gen_p5) -{ -u32 index = raw_cons & (max_elements -1 ); - -if (gen_p5) -bnxt_qplib_ring_creq_db64 (db, index, xid, true); -else -writel (CREQ_DB_CP_FLAGS | (index &DBC_DBC32_XID_MASK ), - db); -} -#define CREQ_ENTRY_POLL_BUDGET 0x100/* HWQ */
Signature · 1 line
1.8.3.1
cover further improvements to bnxt_re driver
In reply to Devesh SharmaThis short patch series is an extension to the previous refactor series. The main pourpose of these patches is to streamline the queue management code in slightly better way.
Devesh Sharma (4):
RDMA/bnxt_re: reduce device page size detection code RDMA/bnxt_re: Update missing hsi data structures RDMA/bnxt_re: simplify obtaining queue entry from hw ring RDMA/bnxt_re: Remove dead code from rcfw
drivers/infiniband/hw/bnxt_re/ib_verbs.c | 65 +++--- drivers/infiniband/hw/bnxt_re/ib_verbs.h | 10 + drivers/infiniband/hw/bnxt_re/qplib_fp.c | 354 ++++++++++++----------------- drivers/infiniband/hw/bnxt_re/qplib_fp.h | 42 +--- drivers/infiniband/hw/bnxt_re/qplib_rcfw.c | 88 +++---- drivers/infiniband/hw/bnxt_re/qplib_rcfw.h | 91 -------- drivers/infiniband/hw/bnxt_re/qplib_res.c | 1 + drivers/infiniband/hw/bnxt_re/qplib_res.h | 47 ++++ drivers/infiniband/hw/bnxt_re/roce_hsi.h | 106 +++++++++ 9 files changed, 379 insertions(+), 425 deletions(-)
Signature · 1 line
1.8.3.1
Re: [internal PATCH for-next 0/4] further improvements to bnxt_re driver
Quoted 23 lines · Devesh Sharma
This short patch series is an extension to the previous refactor series. The main pourpose of these patches is to streamline the queue management code in slightly better way.
Devesh Sharma (4):
RDMA/bnxt_re: reduce device page size detection code RDMA/bnxt_re: Update missing hsi data structures RDMA/bnxt_re: simplify obtaining queue entry from hw ring RDMA/bnxt_re: Remove dead code from rcfwdrivers/infiniband/hw/bnxt_re/ib_verbs.c | 65 +++--- drivers/infiniband/hw/bnxt_re/ib_verbs.h | 10 + drivers/infiniband/hw/bnxt_re/qplib_fp.c | 354 ++++++++++++----------------- drivers/infiniband/hw/bnxt_re/qplib_fp.h | 42 +--- drivers/infiniband/hw/bnxt_re/qplib_rcfw.c | 88 +++---- drivers/infiniband/hw/bnxt_re/qplib_rcfw.h | 91 -------- drivers/infiniband/hw/bnxt_re/qplib_res.c | 1 + drivers/infiniband/hw/bnxt_re/qplib_res.h | 47 ++++ drivers/infiniband/hw/bnxt_re/roce_hsi.h | 106 +++++++++ 9 files changed, 379 insertions(+), 425 deletions(-)
Quoted 3 lines
--
1.8.3.1
Please ignore this cover letter, it was not intended for an internal audience, sent out unintentionally.
Jason Gunthorpe
AppliedQuoted 10 lines · Devesh Sharma
This short patch series is an extension to the previous refactor series. The main pourpose of these patches is to streamline the queue management code in slightly better way.
Devesh Sharma (4):
RDMA/bnxt_re: reduce device page size detection code RDMA/bnxt_re: Update missing hsi data structures RDMA/bnxt_re: simplify obtaining queue entry from hw ring RDMA/bnxt_re: Remove dead code from rcfw
Applied to for-next, thanks
Jason