RDMA/ionic: size the MR PTE reservation to max_sg
Subsystems (2)
Abhijit Gangurde
maintainerPATCH 1/3 RDMA/ionic: size the MR PTE reservation to max_sg
From: Amit Kumar <[email protected]>
CREATE_MR with map_count zero makes firmware reserve its default number of PTEs. A fast-registration memory region (MR) whose max_sg is larger than that default fails at REG_MR.
Pass max_sg as map_count. The virtual address (VA) and length stay zero because no buffer is mapped yet.
--- .../infiniband/hw/ionic/ionic_controlpath.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/infiniband/hw/ionic/ionic_controlpath.c +11 -7
@@ -1121,21 +1121,25 @@ struct ib_mr *ionic_alloc_mr(struct ib_pd *ibpd, enum ib_mr_type type, mr->flags =IONIC_MRF_PHYS_MR ; - rc =ionic_pgtbl_init (dev, &mr->buf, mr->umem,0 , max_sg,PAGE_SIZE ); + mr->buf.tbl_pages = max_sg; + rc =ionic_create_mr_cmd (dev, pd, mr,0 ,0 ); +if (rc) + goto err_cmd; + + rc =ionic_pgtbl_init (dev, &mr->buf,NULL ,0 , max_sg,0 );if (rc) goto err_pgtbl; +/* NIC reservation was already posted. tbl_pages means "mapped". */ mr->buf.tbl_pages =0 ; - rc =ionic_create_mr_cmd (dev, pd, mr,0 ,0 ); -if (rc) - goto err_cmd; -return &mr->ibmr; -err_cmd: -ionic_pgtbl_unbuf (dev, &mr->buf); err_pgtbl: +/* Keep the id if the NIC still holds the MR. */ +if (ionic_destroy_mr_cmd (dev, mr->mrid)) + goto err_mrid; +err_cmd:ionic_put_mrid (dev, mr->mrid); err_mrid:kfree (mr);
Signature · 1 line
2.43.0
Abhijit Gangurde
maintainerPATCH 2/3 RDMA/ionic: set the SQ WQE color bit
From: Amit Kumar <[email protected]>
The NIC uses the WQE color bit to tell one pass of the send queue from the next. Userspace sets IONIC_V1_FLAG_COLOR and toggles it when prod wraps. Do the same for kernel send queues, and start again at the initial color when a QP reset returns prod to zero.
--- drivers/infiniband/hw/ionic/ionic_controlpath.c | 3 +++ drivers/infiniband/hw/ionic/ionic_datapath.c | 4 ++++ drivers/infiniband/hw/ionic/ionic_fw.h | 1 + drivers/infiniband/hw/ionic/ionic_ibdev.h | 1 + 4 files changed, 9 insertions(+)
drivers/infiniband/hw/ionic/ionic_controlpath.c +3 -0
@@ -1949,6 +1949,8 @@ static int ionic_qp_sq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx,return rc; } + qp->sq_color = true; + rc = -EINVAL ;if (max_wr <0 || max_wr >0xffff )
@@ -2662,6 +2664,7 @@ static void ionic_reset_qp(struct ionic_ibdev *dev, struct ionic_qp *qp) qp->sq_msn_cons =0 ; qp->sq.prod =0 ; qp->sq.cons =0 ; + qp->sq_color = true;spin_unlock (&qp->sq_lock); }
drivers/infiniband/hw/ionic/ionic_datapath.c +4 -0
@@ -820,6 +820,9 @@ static void ionic_prep_base(struct ionic_qp *qp, wqe->base.wqe_idx =cpu_to_le64 (qp->sq.prod); +if (qp->sq_color) + wqe->base.flags |=cpu_to_be16 (IONIC_V1_FLAG_COLOR ); +if (wr->send_flags &IB_SEND_FENCE ) wqe->base.flags |=cpu_to_be16 (IONIC_V1_FLAG_FENCE );
@@ -843,6 +846,7 @@ static void ionic_prep_base(struct ionic_qp *qp, }ionic_queue_produce (&qp->sq); + qp->sq_color =ionic_color_wrap (qp->sq.prod, qp->sq_color); } static int ionic_prep_common(struct ionic_qp *qp,
drivers/infiniband/hw/ionic/ionic_fw.h +1 -0
@@ -532,6 +532,7 @@ enum ionic_v1_op {IONIC_V1_FLAG_SOL =BIT (1 ),IONIC_V1_FLAG_INL =BIT (2 ),IONIC_V1_FLAG_SIG =BIT (3 ), +IONIC_V1_FLAG_COLOR =BIT (4 ),/* flags last four bits for sgl spec format */ IONIC_V1_FLAG_SPEC32 = (1u << 12),
drivers/infiniband/hw/ionic/ionic_ibdev.h +1 -0
@@ -306,6 +306,7 @@ struct ionic_qp {u8 sq_cmb;bool sq_flush;bool sq_flush_rcvd; +bool sq_color;struct ionic_rq rq;
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [for-next 2/3] RDMA/ionic: set the SQ WQE color bit
Sashiko has reviewed this patch and found no issues.
Quoted 9 lines
From: Amit Kumar <[email protected]>
The NIC uses the WQE color bit to tell one pass of the send queue from the next. Userspace sets
IONIC_V1_FLAG_COLORand toggles it when prod wraps. Do the same for kernel send queues, and start again at the initial color when a QP reset returns prod to zero.Signed-off-by Amit Kumar <[email protected]>Signed-off-by Abhijit Gangurde <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Abhijit Gangurde
maintainerPATCH 3/3 RDMA/ionic: key recv completions by producer index
In reply to Abhijit GangurdeThe recv completion's wqe_idx is the RQ producer index. Store the wr_id at that slot and write the same index into the posted WQE. A posted flag on the slot rejects a completion for a recv that is not outstanding.
--- .../infiniband/hw/ionic/ionic_controlpath.c | 19 ++++----------- drivers/infiniband/hw/ionic/ionic_datapath.c | 24 +++++++++---------- drivers/infiniband/hw/ionic/ionic_ibdev.h | 6 +---- 3 files changed, 18 insertions(+), 31 deletions(-)
drivers/infiniband/hw/ionic/ionic_controlpath.c +5 -14
@@ -2195,8 +2195,8 @@ static int ionic_rq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx, struct ionic_tbl_buf *buf, int max_wr, int max_sge, int rq_spec, struct ib_udata *udata) { - int rc = 0, i; u32 wqe_size; +int rc =0 ; rc = -EINVAL ;
@@ -2258,16 +2258,11 @@ static int ionic_rq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx,ionic_queue_dbell_init (&rq->q, rq->qid); - rq->meta =kmalloc_objs (*rq->meta, (u32 )rq->q.mask +1 ); + rq->meta =kzalloc_objs (*rq->meta, (u32 )rq->q.mask +1 );if (!rq->meta) { rc = -ENOMEM ; goto err_rq_meta; } - -for (i =0 ; i < rq->q.mask; ++i) - rq->meta[i].next = &rq->meta[i +1 ]; - rq->meta[i].next =IONIC_META_LAST ; - rq->meta_head = &rq->meta[0 ]; }ionic_rq_init_cmb (dev, rq, udata);
@@ -2638,7 +2633,6 @@ static void ionic_reset_qp(struct ionic_ibdev *dev, struct ionic_qp *qp) {unsigned long irqflags;struct ionic_cq *cq; -int i;local_irq_save (irqflags);
@@ -2673,12 +2667,9 @@ static void ionic_reset_qp(struct ionic_ibdev *dev, struct ionic_qp *qp) qp->rq.flush = false; qp->rq.q.prod =0 ; qp->rq.q.cons =0 ; -if (qp->rq.meta) { -for (i =0 ; i < qp->rq.q.mask; ++i) - qp->rq.meta[i].next = &qp->rq.meta[i +1 ]; - qp->rq.meta[i].next =IONIC_META_LAST ; - } - qp->rq.meta_head = &qp->rq.meta[0 ]; +if (qp->rq.meta) +memset (qp->rq.meta,0 , + (qp->rq.q.mask +1 ) *sizeof (*qp->rq.meta));spin_unlock (&qp->rq.lock); }
drivers/infiniband/hw/ionic/ionic_datapath.c +12 -12
@@ -53,7 +53,7 @@ static int ionic_flush_recv(struct ionic_qp *qp, struct ib_wc *wc)/* wqe_idx must indicate a request that is outstanding */ meta = &qp->rq.meta[wqe_idx]; -if (unlikely (meta->next !=IONIC_META_POSTED )) { +if (unlikely (!meta->posted)) {ibdev_warn (qp->ibqp.device,"flush qp %u recv index %llu not posted\n" , qp->qpid, (unsigned long long )wqe_idx);
@@ -68,8 +68,7 @@ static int ionic_flush_recv(struct ionic_qp *qp, struct ib_wc *wc) wc->wr_id = meta->wrid; wc->qp = &qp->ibqp; - meta->next = qp->rq.meta_head; - qp->rq.meta_head = meta; + meta->posted = false;return 1 ; }
@@ -172,14 +171,13 @@ static int ionic_poll_recv(struct ionic_ibdev *dev, struct ionic_cq *cq,/* wqe_idx must indicate a request that is outstanding */ meta = &qp->rq.meta[wqe_idx]; -if (unlikely (meta->next !=IONIC_META_POSTED )) { +if (unlikely (!meta->posted)) {ibdev_warn (&dev->ibdev,"qp %u recv index %u not posted\n" , qp->qpid, wqe_idx);return -EIO ; } - meta->next = qp->rq.meta_head; - qp->rq.meta_head = meta; + meta->posted = false;memset (wc,0 ,sizeof (*wc));
@@ -1199,9 +1197,12 @@ static int ionic_prep_recv(struct ionic_qp *qp,if (wqe->base.flags &cpu_to_be16 (IONIC_V1_FLAG_FENCE ))return -EAGAIN ; - meta = qp->rq.meta_head; -if (unlikely (meta ==IONIC_META_LAST ) || -unlikely (meta ==IONIC_META_POSTED )) +/* +* The completion carries this producer index, so the wr_id +* lives in the meta slot at the same index. +*/ + meta = &qp->rq.meta[qp->rq.q.prod]; +if (unlikely (meta->posted))return -EIO ;ionic_prep_rq_wqe (qp, wqe);
@@ -1216,7 +1217,7 @@ static int ionic_prep_recv(struct ionic_qp *qp, meta->wrid = wr->wr_id; - wqe->base.wqe_idx =cpu_to_le64 (meta - qp->rq.meta); + wqe->base.wqe_idx =cpu_to_le64 (qp->rq.q.prod); wqe->base.num_sge_key = wr->num_sge;/* total length for recv goes in base imm_data_key */
@@ -1224,8 +1225,7 @@ static int ionic_prep_recv(struct ionic_qp *qp,ionic_queue_produce (&qp->rq.q); - qp->rq.meta_head = meta->next; - meta->next =IONIC_META_POSTED ; + meta->posted = true;return 0 ; }
drivers/infiniband/hw/ionic/ionic_ibdev.h +1 -5
@@ -40,9 +40,6 @@#define IONIC_MAX_SRQ_LIMIT 0xffff#define IONIC_MAX_SRQ_DEPTH 0xffff -#define IONIC_META_LAST ((void *)1ul) -#define IONIC_META_POSTED ((void *)2ul) -#define IONIC_CQ_GRACE 100#define IONIC_ROCE_UDP_SPORT 28272
@@ -242,8 +239,8 @@ struct ionic_sq_meta { };struct ionic_rq_meta { -struct ionic_rq_meta *next;u64 wrid; +bool posted; };struct ionic_rq {
@@ -257,7 +254,6 @@ struct ionic_rq {struct rdma_user_mmap_entry *mmap_cmb;struct ionic_rq_meta *meta; -struct ionic_rq_meta *meta_head;struct ib_umem *umem;int spec;
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [for-next 3/3] RDMA/ionic: key recv completions by producer index
Sashiko has reviewed this patch and found no issues.
Quoted 6 lines
The recv completion's
wqe_idxis the RQ producer index. Store thewr_idat that slot and write the same index into the posted WQE. A posted flag on the slot rejects a completion for a recv that is not outstanding.Signed-off-by Abhijit Gangurde <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 6 lines
From: Amit Kumar <[email protected]>
CREATE_MRwithmap_countzero makes firmware reserve its default number of PTEs. A fast-registration memory region (MR) whosemax_sgis larger than that default fails atREG_MR.
Quoted 6 lines
Pass
max_sgasmap_count. The virtual address (VA) and length stay zero because no buffer is mapped yet.Fixes e8521822c733 ("RDMA/ionic: Register device ops for control path")Signed-off-by Amit Kumar <[email protected]>Signed-off-by Abhijit Gangurde <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Leon Romanovsky
AppliedQuoted 8 lines · Abhijit Gangurde
CREATE_MRwithmap_countzero makes firmware reserve its default number of PTEs. A fast-registration memory region (MR) whosemax_sgis larger than that default fails atREG_MR.Pass
max_sgasmap_count. The virtual address (VA) and length stay zero because no buffer is mapped yet.[...]
Applied, thanks!
[1/3] RDMA/ionic: size the MR PTE reservation to max_sg
https://git.kernel.org/rdma/rdma/c/bfef8b13241cdb [2/3] RDMA/ionic: set the SQ WQE color bit https://git.kernel.org/rdma/rdma/c/d1b8977f3a009e [3/3] RDMA/ionic: key recv completions by producer index https://git.kernel.org/rdma/rdma/c/9ca2239d2fd274
Best regards,
Signature · 1 line
Leon Romanovsky <[email protected]>