RDMA/drivers: Remove udata check from special QP
GSI QP can't be created from the user space, hence the udata check is always false (udata == NULL). Remove that check and simplify the flow. Link: https://lore.kernel.org/r/20200926102450.2966017-9-leon@kernel.org Reviewed-by: Maor Gottlieb <maorg@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
This commit is contained in:
parent
5807bb3205
commit
b925c555a1
@ -1015,53 +1015,32 @@ struct ib_qp *hns_roce_create_qp(struct ib_pd *pd,
|
||||
int ret;
|
||||
|
||||
switch (init_attr->qp_type) {
|
||||
case IB_QPT_RC: {
|
||||
hr_qp = kzalloc(sizeof(*hr_qp), GFP_KERNEL);
|
||||
if (!hr_qp)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
ret = hns_roce_create_qp_common(hr_dev, pd, init_attr, udata,
|
||||
hr_qp);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Create QP 0x%06lx failed(%d)\n",
|
||||
hr_qp->qpn, ret);
|
||||
kfree(hr_qp);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
case IB_QPT_RC:
|
||||
case IB_QPT_GSI:
|
||||
break;
|
||||
}
|
||||
case IB_QPT_GSI: {
|
||||
/* Userspace is not allowed to create special QPs: */
|
||||
if (udata) {
|
||||
ibdev_err(ibdev, "not support usr space GSI\n");
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
hr_qp = kzalloc(sizeof(*hr_qp), GFP_KERNEL);
|
||||
if (!hr_qp)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
hr_qp->port = init_attr->port_num - 1;
|
||||
hr_qp->phy_port = hr_dev->iboe.phy_port[hr_qp->port];
|
||||
|
||||
ret = hns_roce_create_qp_common(hr_dev, pd, init_attr, udata,
|
||||
hr_qp);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Create GSI QP failed!\n");
|
||||
kfree(hr_qp);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:{
|
||||
default:
|
||||
ibdev_err(ibdev, "not support QP type %d\n",
|
||||
init_attr->qp_type);
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
}
|
||||
|
||||
hr_qp = kzalloc(sizeof(*hr_qp), GFP_KERNEL);
|
||||
if (!hr_qp)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
if (init_attr->qp_type == IB_QPT_GSI) {
|
||||
hr_qp->port = init_attr->port_num - 1;
|
||||
hr_qp->phy_port = hr_dev->iboe.phy_port[hr_qp->port];
|
||||
}
|
||||
|
||||
ret = hns_roce_create_qp_common(hr_dev, pd, init_attr, udata, hr_qp);
|
||||
if (ret) {
|
||||
ibdev_err(ibdev, "Create QP type 0x%x failed(%d)\n",
|
||||
init_attr->qp_type, ret);
|
||||
ibdev_err(ibdev, "Create GSI QP failed!\n");
|
||||
kfree(hr_qp);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
return &hr_qp->ibqp;
|
||||
}
|
||||
|
||||
|
@ -1544,9 +1544,6 @@ static int _mlx4_ib_create_qp(struct ib_pd *pd, struct mlx4_ib_qp *qp,
|
||||
{
|
||||
int sqpn;
|
||||
|
||||
/* Userspace is not allowed to create special QPs: */
|
||||
if (udata)
|
||||
return -EINVAL;
|
||||
if (init_attr->create_flags & MLX4_IB_QP_CREATE_ROCE_V2_GSI) {
|
||||
int res = mlx4_qp_reserve_range(to_mdev(pd->device)->dev,
|
||||
1, 1, &sqpn, 0,
|
||||
|
@ -2511,18 +2511,6 @@ static int check_valid_flow(struct mlx5_ib_dev *dev, struct ib_pd *pd,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
switch (attr->qp_type) {
|
||||
case IB_QPT_SMI:
|
||||
case MLX5_IB_QPT_HW_GSI:
|
||||
case MLX5_IB_QPT_REG_UMR:
|
||||
case IB_QPT_GSI:
|
||||
mlx5_ib_dbg(dev, "Kernel doesn't support QP type %d\n",
|
||||
attr->qp_type);
|
||||
return -EINVAL;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* We don't need to see this warning, it means that kernel code
|
||||
* missing ib_pd. Placed here to catch developer's mistakes.
|
||||
|
@ -535,10 +535,6 @@ static struct ib_qp *mthca_create_qp(struct ib_pd *pd,
|
||||
case IB_QPT_SMI:
|
||||
case IB_QPT_GSI:
|
||||
{
|
||||
/* Don't allow userspace to create special QPs */
|
||||
if (udata)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
qp = kzalloc(sizeof(struct mthca_sqp), GFP_KERNEL);
|
||||
if (!qp)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
@ -1235,14 +1235,6 @@ static int qedr_check_qp_attrs(struct ib_pd *ibpd, struct qedr_dev *dev,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Unprivileged user space cannot create special QP */
|
||||
if (udata && attrs->qp_type == IB_QPT_GSI) {
|
||||
DP_ERR(dev,
|
||||
"create qp: userspace can't create special QPs of type=0x%x\n",
|
||||
attrs->qp_type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* verify consumer QPs are not trying to use GSI QP's CQ.
|
||||
* TGT QP isn't associated with RQ/SQ
|
||||
*/
|
||||
|
@ -232,8 +232,7 @@ struct ib_qp *pvrdma_create_qp(struct ib_pd *pd,
|
||||
switch (init_attr->qp_type) {
|
||||
case IB_QPT_GSI:
|
||||
if (init_attr->port_num == 0 ||
|
||||
init_attr->port_num > pd->device->phys_port_cnt ||
|
||||
udata) {
|
||||
init_attr->port_num > pd->device->phys_port_cnt) {
|
||||
dev_warn(&dev->pdev->dev, "invalid queuepair attrs\n");
|
||||
ret = -EINVAL;
|
||||
goto err_qp;
|
||||
|
Loading…
Reference in New Issue
Block a user