Commit 48fd0d1f authored by Michael S. Tsirkin's avatar Michael S. Tsirkin Committed by Roland Dreier

IB/mthca: Safer max_send_sge/max_recv_sge calculation

Calculation of QP capabilities still isn't exactly right in mthca:
max_send_sge/max_recv_sge fields returned in create_qp can exceed the
handware supported limits.
Signed-off-by: default avatarMichael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent cbc5b2bb
...@@ -918,10 +918,12 @@ static void mthca_adjust_qp_caps(struct mthca_dev *dev, ...@@ -918,10 +918,12 @@ static void mthca_adjust_qp_caps(struct mthca_dev *dev,
else else
qp->max_inline_data = max_data_size - MTHCA_INLINE_HEADER_SIZE; qp->max_inline_data = max_data_size - MTHCA_INLINE_HEADER_SIZE;
qp->sq.max_gs = max_data_size / sizeof (struct mthca_data_seg); qp->sq.max_gs = min_t(int, dev->limits.max_sg,
qp->rq.max_gs = (min(dev->limits.max_desc_sz, 1 << qp->rq.wqe_shift) - max_data_size / sizeof (struct mthca_data_seg));
qp->rq.max_gs = min_t(int, dev->limits.max_sg,
(min(dev->limits.max_desc_sz, 1 << qp->rq.wqe_shift) -
sizeof (struct mthca_next_seg)) / sizeof (struct mthca_next_seg)) /
sizeof (struct mthca_data_seg); sizeof (struct mthca_data_seg));
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment