Skip to content

Commit 798653a

Browse files
Saravanan Vajravelrleon
authored andcommitted
RDMA/bnxt_re: Add check for path mtu in modify_qp
When RDMA app configures path MTU, add a check in modify_qp verb to make sure that it doesn't go beyond interface MTU. If this check fails, driver will fail the modify_qp verb. Fixes: 1ac5a40 ("RDMA/bnxt_re: Add bnxt_re RoCE driver") Reviewed-by: Kalesh AP <[email protected]> Signed-off-by: Saravanan Vajravel <[email protected]> Signed-off-by: Selvin Xavier <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Leon Romanovsky <[email protected]>
1 parent 3865147 commit 798653a

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

drivers/infiniband/hw/bnxt_re/ib_verbs.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2162,18 +2162,20 @@ int bnxt_re_modify_qp(struct ib_qp *ib_qp, struct ib_qp_attr *qp_attr,
21622162
}
21632163
}
21642164

2165-
if (qp_attr_mask & IB_QP_PATH_MTU) {
2166-
qp->qplib_qp.modify_flags |=
2167-
CMDQ_MODIFY_QP_MODIFY_MASK_PATH_MTU;
2168-
qp->qplib_qp.path_mtu = __from_ib_mtu(qp_attr->path_mtu);
2169-
qp->qplib_qp.mtu = ib_mtu_enum_to_int(qp_attr->path_mtu);
2170-
} else if (qp_attr->qp_state == IB_QPS_RTR) {
2171-
qp->qplib_qp.modify_flags |=
2172-
CMDQ_MODIFY_QP_MODIFY_MASK_PATH_MTU;
2173-
qp->qplib_qp.path_mtu =
2174-
__from_ib_mtu(iboe_get_mtu(rdev->netdev->mtu));
2175-
qp->qplib_qp.mtu =
2176-
ib_mtu_enum_to_int(iboe_get_mtu(rdev->netdev->mtu));
2165+
if (qp_attr->qp_state == IB_QPS_RTR) {
2166+
enum ib_mtu qpmtu;
2167+
2168+
qpmtu = iboe_get_mtu(rdev->netdev->mtu);
2169+
if (qp_attr_mask & IB_QP_PATH_MTU) {
2170+
if (ib_mtu_enum_to_int(qp_attr->path_mtu) >
2171+
ib_mtu_enum_to_int(qpmtu))
2172+
return -EINVAL;
2173+
qpmtu = qp_attr->path_mtu;
2174+
}
2175+
2176+
qp->qplib_qp.modify_flags |= CMDQ_MODIFY_QP_MODIFY_MASK_PATH_MTU;
2177+
qp->qplib_qp.path_mtu = __from_ib_mtu(qpmtu);
2178+
qp->qplib_qp.mtu = ib_mtu_enum_to_int(qpmtu);
21772179
}
21782180

21792181
if (qp_attr_mask & IB_QP_TIMEOUT) {

0 commit comments

Comments
 (0)