Skip to content

Commit

Permalink
IB/core, RDMA RW API: Do not exceed QP SGE send limit
Browse files Browse the repository at this point in the history
Compute the SGE limit for RDMA READ and WRITE requests in
ib_create_qp(). Use that limit in the RDMA RW API implementation.

Signed-off-by: Bart Van Assche <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Sagi Grimberg <[email protected]>
Cc: Steve Wise <[email protected]>
Cc: Parav Pandit <[email protected]>
Cc: Nicholas Bellinger <[email protected]>
Cc: Laurence Oberman <[email protected]>
Cc: <[email protected]> #v4.7+
Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: Doug Ledford <[email protected]>
  • Loading branch information
Bart Van Assche authored and dledford committed Aug 2, 2016
1 parent eaa74ec commit 632bc3f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
10 changes: 2 additions & 8 deletions drivers/infiniband/core/rw.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ static inline bool rdma_rw_io_needs_mr(struct ib_device *dev, u8 port_num,
return false;
}

static inline u32 rdma_rw_max_sge(struct ib_device *dev,
enum dma_data_direction dir)
{
return dir == DMA_TO_DEVICE ?
dev->attrs.max_sge : dev->attrs.max_sge_rd;
}

static inline u32 rdma_rw_fr_page_list_len(struct ib_device *dev)
{
/* arbitrary limit to avoid allocating gigantic resources */
Expand Down Expand Up @@ -186,7 +179,8 @@ static int rdma_rw_init_map_wrs(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
u64 remote_addr, u32 rkey, enum dma_data_direction dir)
{
struct ib_device *dev = qp->pd->device;
u32 max_sge = rdma_rw_max_sge(dev, dir);
u32 max_sge = dir == DMA_TO_DEVICE ? qp->max_write_sge :
qp->max_read_sge;
struct ib_sge *sge;
u32 total_len = 0, i, j;

Expand Down
9 changes: 9 additions & 0 deletions drivers/infiniband/core/verbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,15 @@ struct ib_qp *ib_create_qp(struct ib_pd *pd,
}
}

/*
* Note: all hw drivers guarantee that max_send_sge is lower than
* the device RDMA WRITE SGE limit but not all hw drivers ensure that
* max_send_sge <= max_sge_rd.
*/
qp->max_write_sge = qp_init_attr->cap.max_send_sge;
qp->max_read_sge = min_t(u32, qp_init_attr->cap.max_send_sge,
device->attrs.max_sge_rd);

return qp;
}
EXPORT_SYMBOL(ib_create_qp);
Expand Down
6 changes: 6 additions & 0 deletions include/rdma/ib_verbs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,10 @@ struct ib_srq {
} ext;
};

/*
* @max_write_sge: Maximum SGE elements per RDMA WRITE request.
* @max_read_sge: Maximum SGE elements per RDMA READ request.
*/
struct ib_qp {
struct ib_device *device;
struct ib_pd *pd;
Expand All @@ -1449,6 +1453,8 @@ struct ib_qp {
void (*event_handler)(struct ib_event *, void *);
void *qp_context;
u32 qp_num;
u32 max_write_sge;
u32 max_read_sge;
enum ib_qp_type qp_type;
};

Expand Down

0 comments on commit 632bc3f

Please sign in to comment.