diff options
author | Eli Cohen <eli@mellanox.com> | 2013-09-11 09:35:22 -0400 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2013-10-10 12:23:55 -0400 |
commit | b125a54bfd7734a44253d2f2909a3c609768c1ec (patch) | |
tree | a0a209f7901341d75d16ed5ea5d0afca0ef8395f | |
parent | 4a10c2ac2f368583138b774ca41fac4207911983 (diff) |
IB/mlx5: Fix send work queue size calculation
1. Make sure wqe_cnt does not exceed the limit published by firmware.
2. There is no requirement that the number of outstanding work
requests will be a power of two. Remove the ilog2 in the
calculation of sq.max_post to fix that.
3. Add case for IB_QPT_XRC_TGT in sq_overhead and return 0 as XRC
target QPs do not have a send queue.
Signed-off-by: Eli Cohen <eli@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
-rw-r--r-- | drivers/infiniband/hw/mlx5/qp.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c index 045f8cdbd303..05d53f184744 100644 --- a/drivers/infiniband/hw/mlx5/qp.c +++ b/drivers/infiniband/hw/mlx5/qp.c | |||
@@ -203,7 +203,7 @@ static int sq_overhead(enum ib_qp_type qp_type) | |||
203 | 203 | ||
204 | switch (qp_type) { | 204 | switch (qp_type) { |
205 | case IB_QPT_XRC_INI: | 205 | case IB_QPT_XRC_INI: |
206 | size = sizeof(struct mlx5_wqe_xrc_seg); | 206 | size += sizeof(struct mlx5_wqe_xrc_seg); |
207 | /* fall through */ | 207 | /* fall through */ |
208 | case IB_QPT_RC: | 208 | case IB_QPT_RC: |
209 | size += sizeof(struct mlx5_wqe_ctrl_seg) + | 209 | size += sizeof(struct mlx5_wqe_ctrl_seg) + |
@@ -211,20 +211,23 @@ static int sq_overhead(enum ib_qp_type qp_type) | |||
211 | sizeof(struct mlx5_wqe_raddr_seg); | 211 | sizeof(struct mlx5_wqe_raddr_seg); |
212 | break; | 212 | break; |
213 | 213 | ||
214 | case IB_QPT_XRC_TGT: | ||
215 | return 0; | ||
216 | |||
214 | case IB_QPT_UC: | 217 | case IB_QPT_UC: |
215 | size = sizeof(struct mlx5_wqe_ctrl_seg) + | 218 | size += sizeof(struct mlx5_wqe_ctrl_seg) + |
216 | sizeof(struct mlx5_wqe_raddr_seg); | 219 | sizeof(struct mlx5_wqe_raddr_seg); |
217 | break; | 220 | break; |
218 | 221 | ||
219 | case IB_QPT_UD: | 222 | case IB_QPT_UD: |
220 | case IB_QPT_SMI: | 223 | case IB_QPT_SMI: |
221 | case IB_QPT_GSI: | 224 | case IB_QPT_GSI: |
222 | size = sizeof(struct mlx5_wqe_ctrl_seg) + | 225 | size += sizeof(struct mlx5_wqe_ctrl_seg) + |
223 | sizeof(struct mlx5_wqe_datagram_seg); | 226 | sizeof(struct mlx5_wqe_datagram_seg); |
224 | break; | 227 | break; |
225 | 228 | ||
226 | case MLX5_IB_QPT_REG_UMR: | 229 | case MLX5_IB_QPT_REG_UMR: |
227 | size = sizeof(struct mlx5_wqe_ctrl_seg) + | 230 | size += sizeof(struct mlx5_wqe_ctrl_seg) + |
228 | sizeof(struct mlx5_wqe_umr_ctrl_seg) + | 231 | sizeof(struct mlx5_wqe_umr_ctrl_seg) + |
229 | sizeof(struct mlx5_mkey_seg); | 232 | sizeof(struct mlx5_mkey_seg); |
230 | break; | 233 | break; |
@@ -270,7 +273,8 @@ static int calc_sq_size(struct mlx5_ib_dev *dev, struct ib_qp_init_attr *attr, | |||
270 | return wqe_size; | 273 | return wqe_size; |
271 | 274 | ||
272 | if (wqe_size > dev->mdev.caps.max_sq_desc_sz) { | 275 | if (wqe_size > dev->mdev.caps.max_sq_desc_sz) { |
273 | mlx5_ib_dbg(dev, "\n"); | 276 | mlx5_ib_dbg(dev, "wqe_size(%d) > max_sq_desc_sz(%d)\n", |
277 | wqe_size, dev->mdev.caps.max_sq_desc_sz); | ||
274 | return -EINVAL; | 278 | return -EINVAL; |
275 | } | 279 | } |
276 | 280 | ||
@@ -280,9 +284,15 @@ static int calc_sq_size(struct mlx5_ib_dev *dev, struct ib_qp_init_attr *attr, | |||
280 | 284 | ||
281 | wq_size = roundup_pow_of_two(attr->cap.max_send_wr * wqe_size); | 285 | wq_size = roundup_pow_of_two(attr->cap.max_send_wr * wqe_size); |
282 | qp->sq.wqe_cnt = wq_size / MLX5_SEND_WQE_BB; | 286 | qp->sq.wqe_cnt = wq_size / MLX5_SEND_WQE_BB; |
287 | if (qp->sq.wqe_cnt > dev->mdev.caps.max_wqes) { | ||
288 | mlx5_ib_dbg(dev, "wqe count(%d) exceeds limits(%d)\n", | ||
289 | qp->sq.wqe_cnt, dev->mdev.caps.max_wqes); | ||
290 | return -ENOMEM; | ||
291 | } | ||
283 | qp->sq.wqe_shift = ilog2(MLX5_SEND_WQE_BB); | 292 | qp->sq.wqe_shift = ilog2(MLX5_SEND_WQE_BB); |
284 | qp->sq.max_gs = attr->cap.max_send_sge; | 293 | qp->sq.max_gs = attr->cap.max_send_sge; |
285 | qp->sq.max_post = 1 << ilog2(wq_size / wqe_size); | 294 | qp->sq.max_post = wq_size / wqe_size; |
295 | attr->cap.max_send_wr = qp->sq.max_post; | ||
286 | 296 | ||
287 | return wq_size; | 297 | return wq_size; |
288 | } | 298 | } |