Skip to content

Commit 204cbe4

Browse files
Wenpeng Liangjgunthorpe
Wenpeng Liang
authored andcommitted
RDMA/hns: Add verification of QP type when post_recv
The post_recv only supports QP types of RC, GSI and UD. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Wenpeng Liang <[email protected]> Signed-off-by: Weihang Li <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 2e07a3d commit 204cbe4

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

drivers/infiniband/hw/hns/hns_roce_hw_v2.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,9 +721,21 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp,
721721
static int check_recv_valid(struct hns_roce_dev *hr_dev,
722722
struct hns_roce_qp *hr_qp)
723723
{
724+
struct ib_device *ibdev = &hr_dev->ib_dev;
725+
struct ib_qp *ibqp = &hr_qp->ibqp;
726+
727+
if (unlikely(ibqp->qp_type != IB_QPT_RC &&
728+
ibqp->qp_type != IB_QPT_GSI &&
729+
ibqp->qp_type != IB_QPT_UD)) {
730+
ibdev_err(ibdev, "unsupported qp type, qp_type = %d.\n",
731+
ibqp->qp_type);
732+
return -EOPNOTSUPP;
733+
}
734+
724735
if (unlikely(hr_dev->state >= HNS_ROCE_DEVICE_STATE_RST_DOWN))
725736
return -EIO;
726-
else if (hr_qp->state == IB_QPS_RESET)
737+
738+
if (hr_qp->state == IB_QPS_RESET)
727739
return -EINVAL;
728740

729741
return 0;

0 commit comments

Comments
 (0)