Commit 968f0b6f authored by Leon Romanovsky's avatar Leon Romanovsky Committed by Jason Gunthorpe

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.orgReviewed-by: default avatarMaor Gottlieb <maorg@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 6367da46
...@@ -1953,6 +1953,7 @@ static int create_xrc_tgt_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp, ...@@ -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); list_add_tail(&qp->qps_list, &dev->qp_list);
spin_unlock_irqrestore(&dev->reset_flow_resource_lock, flags); spin_unlock_irqrestore(&dev->reset_flow_resource_lock, flags);
qp->trans_qp.xrcdn = to_mxrcd(attr->xrcd)->xrcdn;
return 0; return 0;
} }
...@@ -2785,14 +2786,54 @@ static int process_udata_size(struct mlx5_ib_dev *dev, ...@@ -2785,14 +2786,54 @@ static int process_udata_size(struct mlx5_ib_dev *dev,
return (params->inlen) ? 0 : -EINVAL; return (params->inlen) ? 0 : -EINVAL;
} }
static int create_raw_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd, static int create_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd,
struct mlx5_ib_qp *qp, struct mlx5_ib_qp *qp,
struct mlx5_create_qp_params *params) struct mlx5_create_qp_params *params)
{ {
if (params->is_rss_raw) int err;
return create_rss_raw_qp_tir(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 create_user_qp(dev, pd, qp, params); return 0;
} }
static int check_qp_attr(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp, 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, ...@@ -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_dev *dev;
struct mlx5_ib_qp *qp; struct mlx5_ib_qp *qp;
enum ib_qp_type type; enum ib_qp_type type;
u16 xrcdn = 0;
int err; int err;
dev = pd ? to_mdev(pd->device) : 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, ...@@ -2922,40 +2962,13 @@ struct ib_qp *mlx5_ib_create_qp(struct ib_pd *pd, struct ib_qp_init_attr *attr,
if (err) if (err)
goto free_qp; goto free_qp;
switch (qp->type) { err = create_qp(dev, pd, qp, &params);
case IB_QPT_RAW_PACKET: if (err)
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);
goto free_qp; goto free_qp;
}
kfree(params.ucmd); kfree(params.ucmd);
params.ucmd = NULL; 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) if (udata)
/* /*
* It is safe to copy response for all user create QP flows, * It is safe to copy response for all user create QP flows,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment