@@ -367,4 +367,6 @@ int mlx4_alloc_av(struct mlx4_pd *pd, struct ibv_ah_attr *attr,
struct mlx4_ah *ah);
void mlx4_free_av(struct mlx4_ah *ah);
+#define min(a, b) (a < b ? a : b)
+
#endif /* MLX4_H */
@@ -622,7 +622,8 @@ void mlx4_set_sq_sizes(struct mlx4_qp *qp, struct ibv_qp_cap *cap,
{
int wqe_size;
- wqe_size = (1 << qp->sq.wqe_shift) - sizeof (struct mlx4_wqe_ctrl_seg);
+ wqe_size = min((1 << qp->sq.wqe_shift), MLX4_MAX_WQE_SIZE) -
+ sizeof (struct mlx4_wqe_ctrl_seg);
switch (type) {
case IBV_QPT_UD:
wqe_size -= sizeof (struct mlx4_wqe_datagram_seg);