Commit 5aa3771d authored by Yishai Hadas's avatar Yishai Hadas Committed by Doug Ledford

IB/mlx5: Allow XRC usage via verbs in DEVX context

Allows XRC usage from the verbs flow in a DEVX context.
As XRCD is some shared kernel resource between processes it should be
created with UID=0 to point on that.

As a result once XRC QP/SRQ are created they must be used as well with
UID=0 so that firmware will allow the XRCD usage.
Signed-off-by: default avatarYishai Hadas <yishaih@mellanox.com>
Reviewed-by: default avatarArtemy Kovalyov <artemyko@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 719598c9
...@@ -543,7 +543,6 @@ struct mlx5_ib_srq { ...@@ -543,7 +543,6 @@ struct mlx5_ib_srq {
struct mlx5_ib_xrcd { struct mlx5_ib_xrcd {
struct ib_xrcd ibxrcd; struct ib_xrcd ibxrcd;
u32 xrcdn; u32 xrcdn;
u16 uid;
}; };
enum mlx5_ib_mtt_access_flags { enum mlx5_ib_mtt_access_flags {
......
...@@ -775,6 +775,7 @@ static int create_user_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd, ...@@ -775,6 +775,7 @@ static int create_user_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd,
__be64 *pas; __be64 *pas;
void *qpc; void *qpc;
int err; int err;
u16 uid;
err = ib_copy_from_udata(&ucmd, udata, sizeof(ucmd)); err = ib_copy_from_udata(&ucmd, udata, sizeof(ucmd));
if (err) { if (err) {
...@@ -836,7 +837,8 @@ static int create_user_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd, ...@@ -836,7 +837,8 @@ static int create_user_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd,
goto err_umem; goto err_umem;
} }
MLX5_SET(create_qp_in, *in, uid, to_mpd(pd)->uid); uid = (attr->qp_type != IB_QPT_XRC_TGT) ? to_mpd(pd)->uid : 0;
MLX5_SET(create_qp_in, *in, uid, uid);
pas = (__be64 *)MLX5_ADDR_OF(create_qp_in, *in, pas); pas = (__be64 *)MLX5_ADDR_OF(create_qp_in, *in, pas);
if (ubuffer->umem) if (ubuffer->umem)
mlx5_ib_populate_pas(dev, ubuffer->umem, page_shift, pas, 0); mlx5_ib_populate_pas(dev, ubuffer->umem, page_shift, pas, 0);
...@@ -5514,7 +5516,6 @@ struct ib_xrcd *mlx5_ib_alloc_xrcd(struct ib_device *ibdev, ...@@ -5514,7 +5516,6 @@ struct ib_xrcd *mlx5_ib_alloc_xrcd(struct ib_device *ibdev,
struct mlx5_ib_dev *dev = to_mdev(ibdev); struct mlx5_ib_dev *dev = to_mdev(ibdev);
struct mlx5_ib_xrcd *xrcd; struct mlx5_ib_xrcd *xrcd;
int err; int err;
u16 uid;
if (!MLX5_CAP_GEN(dev->mdev, xrc)) if (!MLX5_CAP_GEN(dev->mdev, xrc))
return ERR_PTR(-ENOSYS); return ERR_PTR(-ENOSYS);
...@@ -5523,14 +5524,12 @@ struct ib_xrcd *mlx5_ib_alloc_xrcd(struct ib_device *ibdev, ...@@ -5523,14 +5524,12 @@ struct ib_xrcd *mlx5_ib_alloc_xrcd(struct ib_device *ibdev,
if (!xrcd) if (!xrcd)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
uid = context ? to_mucontext(context)->devx_uid : 0; err = mlx5_cmd_xrcd_alloc(dev->mdev, &xrcd->xrcdn, 0);
err = mlx5_cmd_xrcd_alloc(dev->mdev, &xrcd->xrcdn, uid);
if (err) { if (err) {
kfree(xrcd); kfree(xrcd);
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
xrcd->uid = uid;
return &xrcd->ibxrcd; return &xrcd->ibxrcd;
} }
...@@ -5538,10 +5537,9 @@ int mlx5_ib_dealloc_xrcd(struct ib_xrcd *xrcd) ...@@ -5538,10 +5537,9 @@ int mlx5_ib_dealloc_xrcd(struct ib_xrcd *xrcd)
{ {
struct mlx5_ib_dev *dev = to_mdev(xrcd->device); struct mlx5_ib_dev *dev = to_mdev(xrcd->device);
u32 xrcdn = to_mxrcd(xrcd)->xrcdn; u32 xrcdn = to_mxrcd(xrcd)->xrcdn;
u16 uid = to_mxrcd(xrcd)->uid;
int err; int err;
err = mlx5_cmd_xrcd_dealloc(dev->mdev, xrcdn, uid); err = mlx5_cmd_xrcd_dealloc(dev->mdev, xrcdn, 0);
if (err) if (err)
mlx5_ib_warn(dev, "failed to dealloc xrcdn 0x%x\n", xrcdn); mlx5_ib_warn(dev, "failed to dealloc xrcdn 0x%x\n", xrcdn);
......
...@@ -113,7 +113,7 @@ static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq, ...@@ -113,7 +113,7 @@ static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq,
in->log_page_size = page_shift - MLX5_ADAPTER_PAGE_SHIFT; in->log_page_size = page_shift - MLX5_ADAPTER_PAGE_SHIFT;
in->page_offset = offset; in->page_offset = offset;
in->uid = to_mpd(pd)->uid; in->uid = (in->type != IB_SRQT_XRC) ? to_mpd(pd)->uid : 0;
if (MLX5_CAP_GEN(dev->mdev, cqe_version) == MLX5_CQE_VERSION_V1 && if (MLX5_CAP_GEN(dev->mdev, cqe_version) == MLX5_CQE_VERSION_V1 &&
in->type != IB_SRQT_BASIC) in->type != IB_SRQT_BASIC)
in->user_index = uidx; in->user_index = uidx;
......
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