Skip to content

Commit 0062818

Browse files
chuckleverJ. Bruce Fields
authored andcommitted
rdma core: Add rdma_rw_mr_payload()
The amount of payload per MR depends on device capabilities and the memory registration mode in use. The new rdma_rw API hides both, making it difficult for ULPs to determine how large their transport send queues need to be. Expose the MR payload information via a new API. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Acked-by: Doug Ledford <dledford@redhat.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent 5a25bfd commit 0062818

File tree

2 files changed

+26
-0
lines changed
  • drivers/infiniband/core
  • include/rdma

2 files changed

+26
-0
lines changed

drivers/infiniband/core/rw.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,30 @@ void rdma_rw_ctx_destroy_signature(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
643643
}
644644
EXPORT_SYMBOL(rdma_rw_ctx_destroy_signature);
645645

646+
/**
647+
* rdma_rw_mr_factor - return number of MRs required for a payload
648+
* @device: device handling the connection
649+
* @port_num: port num to which the connection is bound
650+
* @maxpages: maximum payload pages per rdma_rw_ctx
651+
*
652+
* Returns the number of MRs the device requires to move @maxpayload
653+
* bytes. The returned value is used during transport creation to
654+
* compute max_rdma_ctxts and the size of the transport's Send and
655+
* Send Completion Queues.
656+
*/
657+
unsigned int rdma_rw_mr_factor(struct ib_device *device, u8 port_num,
658+
unsigned int maxpages)
659+
{
660+
unsigned int mr_pages;
661+
662+
if (rdma_rw_can_use_mr(device, port_num))
663+
mr_pages = rdma_rw_fr_page_list_len(device);
664+
else
665+
mr_pages = device->attrs.max_sge_rd;
666+
return DIV_ROUND_UP(maxpages, mr_pages);
667+
}
668+
EXPORT_SYMBOL(rdma_rw_mr_factor);
669+
646670
void rdma_rw_init_qp(struct ib_device *dev, struct ib_qp_init_attr *attr)
647671
{
648672
u32 factor;

include/rdma/rw.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ struct ib_send_wr *rdma_rw_ctx_wrs(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
8181
int rdma_rw_ctx_post(struct rdma_rw_ctx *ctx, struct ib_qp *qp, u8 port_num,
8282
struct ib_cqe *cqe, struct ib_send_wr *chain_wr);
8383

84+
unsigned int rdma_rw_mr_factor(struct ib_device *device, u8 port_num,
85+
unsigned int maxpages);
8486
void rdma_rw_init_qp(struct ib_device *dev, struct ib_qp_init_attr *attr);
8587
int rdma_rw_init_mrs(struct ib_qp *qp, struct ib_qp_init_attr *attr);
8688
void rdma_rw_cleanup_mrs(struct ib_qp *qp);

0 commit comments

Comments
 (0)