Commit 1f11a761 authored by Jason Gunthorpe's avatar Jason Gunthorpe
Browse files

RDMA: Check create_flags during create_qp

Each driver should check that the QP attrs create_flags is supported.
Unfortuantely when create_flags was added to the QP attrs the drivers were
not updated. uverbs_ex_cmd_mask was used to block it - even though kernel
drivers use these flags too.

Check that flags is zero in all drivers that don't use it, remove
IB_USER_VERBS_EX_CMD_CREATE_QP from uverbs_ex_cmd_mask. Fix the error code
to be EOPNOTSUPP.

Link: https://lore.kernel.org/r/8-v1-caa70ba3d1ab+1436e-ucmd_mask_jgg@nvidia.com


Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent 1c407cb5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -634,6 +634,7 @@ struct ib_device *_ib_alloc_device(size_t size)
	device->uverbs_ex_cmd_mask =
		BIT_ULL(IB_USER_VERBS_EX_CMD_CREATE_CQ) |
		BIT_ULL(IB_USER_VERBS_EX_CMD_CREATE_FLOW) |
		BIT_ULL(IB_USER_VERBS_EX_CMD_CREATE_QP) |
		BIT_ULL(IB_USER_VERBS_EX_CMD_CREATE_RWQ_IND_TBL) |
		BIT_ULL(IB_USER_VERBS_EX_CMD_CREATE_WQ) |
		BIT_ULL(IB_USER_VERBS_EX_CMD_DESTROY_FLOW) |
+3 −1
Original line number Diff line number Diff line
@@ -1271,10 +1271,12 @@ static int bnxt_re_init_qp_attr(struct bnxt_re_qp *qp, struct bnxt_re_pd *pd,
	}
	qplqp->mtu = ib_mtu_enum_to_int(iboe_get_mtu(rdev->netdev->mtu));
	qplqp->dpi = &rdev->dpi_privileged; /* Doorbell page */
	if (init_attr->create_flags)
	if (init_attr->create_flags) {
		ibdev_dbg(&rdev->ibdev,
			  "QP create flags 0x%x not supported",
			  init_attr->create_flags);
		return -EOPNOTSUPP;
	}

	/* Setup CQs */
	if (init_attr->send_cq) {
+1 −1
Original line number Diff line number Diff line
@@ -2126,7 +2126,7 @@ struct ib_qp *c4iw_create_qp(struct ib_pd *pd, struct ib_qp_init_attr *attrs,

	pr_debug("ib_pd %p\n", pd);

	if (attrs->qp_type != IB_QPT_RC)
	if (attrs->qp_type != IB_QPT_RC || attrs->create_flags)
		return ERR_PTR(-EOPNOTSUPP);

	php = to_c4iw_pd(pd);
+3 −11
Original line number Diff line number Diff line
@@ -869,17 +869,6 @@ static int set_qp_param(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
		if (ret)
			ibdev_err(ibdev, "Failed to set user SQ size\n");
	} else {
		if (init_attr->create_flags &
		    IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK) {
			ibdev_err(ibdev, "Failed to check multicast loopback\n");
			return -EINVAL;
		}

		if (init_attr->create_flags & IB_QP_CREATE_IPOIB_UD_LSO) {
			ibdev_err(ibdev, "Failed to check ipoib ud lso\n");
			return -EINVAL;
		}

		ret = set_kernel_sq_size(hr_dev, &init_attr->cap, hr_qp);
		if (ret)
			ibdev_err(ibdev, "Failed to set kernel SQ size\n");
@@ -906,6 +895,9 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev,
	hr_qp->state = IB_QPS_RESET;
	hr_qp->flush_flag = 0;

	if (init_attr->create_flags)
		return -EOPNOTSUPP;

	ret = set_qp_param(hr_dev, hr_qp, init_attr, udata, &ucmd);
	if (ret) {
		ibdev_err(ibdev, "Failed to set QP param\n");
+1 −1
Original line number Diff line number Diff line
@@ -556,7 +556,7 @@ static struct ib_qp *i40iw_create_qp(struct ib_pd *ibpd,
		return ERR_PTR(-ENODEV);

	if (init_attr->create_flags)
		return ERR_PTR(-EINVAL);
		return ERR_PTR(-EOPNOTSUPP);
	if (init_attr->cap.max_inline_data > I40IW_MAX_INLINE_DATA_SIZE)
		init_attr->cap.max_inline_data = I40IW_MAX_INLINE_DATA_SIZE;

Loading