RDMA/mlx5: Consolidate into special function all create QP calls

Finish separation to blocks of mlx5_ib_create_qp() functions,
so all internal create QP implementation are located in one place.

Link: https://lore.kernel.org/r/20200427154636.381474-36-leon@kernel.org
Reviewed-by: Maor Gottlieb <maorg@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:
Leon Romanovsky 2020-04-27 18:46:35 +03:00 committed by Jason Gunthorpe
parent 6367da46d3
commit 968f0b6f9c

View File

@ -1953,6 +1953,7 @@ static int create_xrc_tgt_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
list_add_tail(&qp->qps_list, &dev->qp_list);
spin_unlock_irqrestore(&dev->reset_flow_resource_lock, flags);
qp->trans_qp.xrcdn = to_mxrcd(attr->xrcd)->xrcdn;
return 0;
}
@ -2785,14 +2786,54 @@ out:
return (params->inlen) ? 0 : -EINVAL;
}
static int create_raw_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd,
struct mlx5_ib_qp *qp,
struct mlx5_create_qp_params *params)
static int create_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd,
struct mlx5_ib_qp *qp,
struct mlx5_create_qp_params *params)
{
if (params->is_rss_raw)
return create_rss_raw_qp_tir(dev, pd, qp, params);
int err;
return create_user_qp(dev, pd, qp, params);
if (params->is_rss_raw) {
err = create_rss_raw_qp_tir(dev, pd, qp, params);
goto out;
}
if (qp->type == MLX5_IB_QPT_DCT) {
err = create_dct(pd, qp, params);
goto out;
}
if (qp->type == IB_QPT_XRC_TGT) {
err = create_xrc_tgt_qp(dev, qp, params);
goto out;
}
if (params->udata)
err = create_user_qp(dev, pd, qp, params);
else
err = create_kernel_qp(dev, pd, qp, params);
out:
if (err) {
mlx5_ib_err(dev, "Create QP type %d failed\n", qp->type);
return err;
}
if (is_qp0(qp->type))
qp->ibqp.qp_num = 0;
else if (is_qp1(qp->type))
qp->ibqp.qp_num = 1;
else
qp->ibqp.qp_num = qp->trans_qp.base.mqp.qpn;
mlx5_ib_dbg(dev,
"QP type %d, ib qpn 0x%X, mlx qpn 0x%x, rcqn 0x%x, scqn 0x%x\n",
qp->type, qp->ibqp.qp_num, qp->trans_qp.base.mqp.qpn,
params->attr->recv_cq ? to_mcq(params->attr->recv_cq)->mcq.cqn :
-1,
params->attr->send_cq ? to_mcq(params->attr->send_cq)->mcq.cqn :
-1);
return 0;
}
static int check_qp_attr(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
@ -2862,7 +2903,6 @@ struct ib_qp *mlx5_ib_create_qp(struct ib_pd *pd, struct ib_qp_init_attr *attr,
struct mlx5_ib_dev *dev;
struct mlx5_ib_qp *qp;
enum ib_qp_type type;
u16 xrcdn = 0;
int err;
dev = pd ? to_mdev(pd->device) :
@ -2922,40 +2962,13 @@ struct ib_qp *mlx5_ib_create_qp(struct ib_pd *pd, struct ib_qp_init_attr *attr,
if (err)
goto free_qp;
switch (qp->type) {
case IB_QPT_RAW_PACKET:
err = create_raw_qp(dev, pd, qp, &params);
break;
case MLX5_IB_QPT_DCT:
err = create_dct(pd, qp, &params);
break;
case IB_QPT_XRC_TGT:
xrcdn = to_mxrcd(attr->xrcd)->xrcdn;
err = create_xrc_tgt_qp(dev, qp, &params);
break;
default:
if (udata)
err = create_user_qp(dev, pd, qp, &params);
else
err = create_kernel_qp(dev, pd, qp, &params);
}
if (err) {
mlx5_ib_err(dev, "create_qp failed %d\n", err);
err = create_qp(dev, pd, qp, &params);
if (err)
goto free_qp;
}
kfree(params.ucmd);
params.ucmd = NULL;
if (is_qp0(attr->qp_type))
qp->ibqp.qp_num = 0;
else if (is_qp1(attr->qp_type))
qp->ibqp.qp_num = 1;
else
qp->ibqp.qp_num = qp->trans_qp.base.mqp.qpn;
qp->trans_qp.xrcdn = xrcdn;
if (udata)
/*
* It is safe to copy response for all user create QP flows,