Commit 7f72052c authored by Yishai Hadas's avatar Yishai Hadas Committed by Jason Gunthorpe

IB/mlx5: Expose RAW QP device handles to user space

Expose RAW QP device handles to user space by extending the UHW part of
mlx5_ib_create_qp_resp.

This data is returned only when DEVX context is used where it may be
applicable.
Signed-off-by: default avatarYishai Hadas <yishaih@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 3994586f
...@@ -1325,7 +1325,9 @@ static int create_raw_packet_qp_tir(struct mlx5_ib_dev *dev, ...@@ -1325,7 +1325,9 @@ static int create_raw_packet_qp_tir(struct mlx5_ib_dev *dev,
static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp, static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
u32 *in, size_t inlen, u32 *in, size_t inlen,
struct ib_pd *pd) struct ib_pd *pd,
struct ib_udata *udata,
struct mlx5_ib_create_qp_resp *resp)
{ {
struct mlx5_ib_raw_packet_qp *raw_packet_qp = &qp->raw_packet_qp; struct mlx5_ib_raw_packet_qp *raw_packet_qp = &qp->raw_packet_qp;
struct mlx5_ib_sq *sq = &raw_packet_qp->sq; struct mlx5_ib_sq *sq = &raw_packet_qp->sq;
...@@ -1335,6 +1337,7 @@ static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp, ...@@ -1335,6 +1337,7 @@ static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
struct mlx5_ib_ucontext *mucontext = to_mucontext(ucontext); struct mlx5_ib_ucontext *mucontext = to_mucontext(ucontext);
int err; int err;
u32 tdn = mucontext->tdn; u32 tdn = mucontext->tdn;
u16 uid = to_mpd(pd)->uid;
if (qp->sq.wqe_cnt) { if (qp->sq.wqe_cnt) {
err = create_raw_packet_qp_tis(dev, qp, sq, tdn, pd); err = create_raw_packet_qp_tis(dev, qp, sq, tdn, pd);
...@@ -1345,6 +1348,13 @@ static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp, ...@@ -1345,6 +1348,13 @@ static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
if (err) if (err)
goto err_destroy_tis; goto err_destroy_tis;
if (uid) {
resp->tisn = sq->tisn;
resp->comp_mask |= MLX5_IB_CREATE_QP_RESP_MASK_TISN;
resp->sqn = sq->base.mqp.qpn;
resp->comp_mask |= MLX5_IB_CREATE_QP_RESP_MASK_SQN;
}
sq->base.container_mibqp = qp; sq->base.container_mibqp = qp;
sq->base.mqp.event = mlx5_ib_qp_event; sq->base.mqp.event = mlx5_ib_qp_event;
} }
...@@ -1363,13 +1373,25 @@ static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp, ...@@ -1363,13 +1373,25 @@ static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
err = create_raw_packet_qp_tir(dev, rq, tdn, &qp->flags_en, pd); err = create_raw_packet_qp_tir(dev, rq, tdn, &qp->flags_en, pd);
if (err) if (err)
goto err_destroy_rq; goto err_destroy_rq;
if (uid) {
resp->rqn = rq->base.mqp.qpn;
resp->comp_mask |= MLX5_IB_CREATE_QP_RESP_MASK_RQN;
resp->tirn = rq->tirn;
resp->comp_mask |= MLX5_IB_CREATE_QP_RESP_MASK_TIRN;
}
} }
qp->trans_qp.base.mqp.qpn = qp->sq.wqe_cnt ? sq->base.mqp.qpn : qp->trans_qp.base.mqp.qpn = qp->sq.wqe_cnt ? sq->base.mqp.qpn :
rq->base.mqp.qpn; rq->base.mqp.qpn;
err = ib_copy_to_udata(udata, resp, min(udata->outlen, sizeof(*resp)));
if (err)
goto err_destroy_tir;
return 0; return 0;
err_destroy_tir:
destroy_raw_packet_qp_tir(dev, rq, qp->flags_en, pd);
err_destroy_rq: err_destroy_rq:
destroy_raw_packet_qp_rq(dev, rq); destroy_raw_packet_qp_rq(dev, rq);
err_destroy_sq: err_destroy_sq:
...@@ -1640,12 +1662,23 @@ static int create_rss_raw_qp_tir(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp, ...@@ -1640,12 +1662,23 @@ static int create_rss_raw_qp_tir(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
if (err) if (err)
goto err; goto err;
if (mucontext->devx_uid) {
resp.comp_mask |= MLX5_IB_CREATE_QP_RESP_MASK_TIRN;
resp.tirn = qp->rss_qp.tirn;
}
err = ib_copy_to_udata(udata, &resp, min(udata->outlen, sizeof(resp)));
if (err)
goto err_copy;
kvfree(in); kvfree(in);
/* qpn is reserved for that QP */ /* qpn is reserved for that QP */
qp->trans_qp.base.mqp.qpn = 0; qp->trans_qp.base.mqp.qpn = 0;
qp->flags |= MLX5_IB_QP_RSS; qp->flags |= MLX5_IB_QP_RSS;
return 0; return 0;
err_copy:
mlx5_cmd_destroy_tir(dev->mdev, qp->rss_qp.tirn, mucontext->devx_uid);
err: err:
kvfree(in); kvfree(in);
return err; return err;
...@@ -1978,7 +2011,8 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd, ...@@ -1978,7 +2011,8 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
qp->flags & MLX5_IB_QP_UNDERLAY) { qp->flags & MLX5_IB_QP_UNDERLAY) {
qp->raw_packet_qp.sq.ubuffer.buf_addr = ucmd.sq_buf_addr; qp->raw_packet_qp.sq.ubuffer.buf_addr = ucmd.sq_buf_addr;
raw_packet_qp_copy_info(qp, &qp->raw_packet_qp); raw_packet_qp_copy_info(qp, &qp->raw_packet_qp);
err = create_raw_packet_qp(dev, qp, in, inlen, pd); err = create_raw_packet_qp(dev, qp, in, inlen, pd, udata,
&resp);
} else { } else {
err = mlx5_core_create_qp(dev->mdev, &base->mqp, in, inlen); err = mlx5_core_create_qp(dev->mdev, &base->mqp, in, inlen);
} }
......
...@@ -351,9 +351,22 @@ struct mlx5_ib_create_qp_rss { ...@@ -351,9 +351,22 @@ struct mlx5_ib_create_qp_rss {
__u32 flags; __u32 flags;
}; };
enum mlx5_ib_create_qp_resp_mask {
MLX5_IB_CREATE_QP_RESP_MASK_TIRN = 1UL << 0,
MLX5_IB_CREATE_QP_RESP_MASK_TISN = 1UL << 1,
MLX5_IB_CREATE_QP_RESP_MASK_RQN = 1UL << 2,
MLX5_IB_CREATE_QP_RESP_MASK_SQN = 1UL << 3,
};
struct mlx5_ib_create_qp_resp { struct mlx5_ib_create_qp_resp {
__u32 bfreg_index; __u32 bfreg_index;
__u32 reserved; __u32 reserved;
__u32 comp_mask;
__u32 tirn;
__u32 tisn;
__u32 rqn;
__u32 sqn;
__u32 reserved1;
}; };
struct mlx5_ib_alloc_mw { struct mlx5_ib_alloc_mw {
......
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