IB/mlx5: Set uid as part of RQT commands
authorYishai Hadas <yishaih@mellanox.com>
Thu, 20 Sep 2018 18:39:28 +0000 (21:39 +0300)
committerJason Gunthorpe <jgg@mellanox.com>
Tue, 25 Sep 2018 20:06:04 +0000 (14:06 -0600)
Set uid as part of RQT commands so that the firmware can manage the
RQT object in a secured way.

That will enable using an RQT that was created by verbs application
to be used by the DEVX flow in case the uid is equal.

Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/hw/mlx5/cmd.c
drivers/infiniband/hw/mlx5/cmd.h
drivers/infiniband/hw/mlx5/mlx5_ib.h
drivers/infiniband/hw/mlx5/qp.c

index 40f7299dbb1d95c639c5c2dc6339382f9f6cf547..6862b03dbdec1b90c004275c7821329f76ce598a 100644 (file)
@@ -220,6 +220,17 @@ void mlx5_cmd_destroy_tis(struct mlx5_core_dev *dev, u32 tisn, u16 uid)
        mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
 }
 
+void mlx5_cmd_destroy_rqt(struct mlx5_core_dev *dev, u32 rqtn, u16 uid)
+{
+       u32 in[MLX5_ST_SZ_DW(destroy_rqt_in)]   = {};
+       u32 out[MLX5_ST_SZ_DW(destroy_rqt_out)] = {};
+
+       MLX5_SET(destroy_rqt_in, in, opcode, MLX5_CMD_OP_DESTROY_RQT);
+       MLX5_SET(destroy_rqt_in, in, rqtn, rqtn);
+       MLX5_SET(destroy_rqt_in, in, uid, uid);
+       mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
+}
+
 void mlx5_cmd_dealloc_pd(struct mlx5_core_dev *dev, u32 pdn, u16 uid)
 {
        u32 out[MLX5_ST_SZ_DW(dealloc_pd_out)] = {};
index f7722d7b92a39d7eff3ad44c5daca9cb51713e4c..742452e4be7eab8023a0dee5f40d7f3ca16f0ca4 100644 (file)
@@ -50,6 +50,7 @@ int mlx5_cmd_dealloc_memic(struct mlx5_memic *memic, u64 addr, u64 length);
 void mlx5_cmd_dealloc_pd(struct mlx5_core_dev *dev, u32 pdn, u16 uid);
 void mlx5_cmd_destroy_tir(struct mlx5_core_dev *dev, u32 tirn, u16 uid);
 void mlx5_cmd_destroy_tis(struct mlx5_core_dev *dev, u32 tisn, u16 uid);
+void mlx5_cmd_destroy_rqt(struct mlx5_core_dev *dev, u32 rqtn, u16 uid);
 int mlx5_cmd_attach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid,
                        u32 qpn, u16 uid);
 int mlx5_cmd_detach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid,
index 6b0f27b05c67366d34e09b7917ee457c7baa7a19..43eddd452a6825fb8a47d757df309954bb1e60e8 100644 (file)
@@ -325,6 +325,7 @@ enum {
 struct mlx5_ib_rwq_ind_table {
        struct ib_rwq_ind_table ib_rwq_ind_tbl;
        u32                     rqtn;
+       u16                     uid;
 };
 
 struct mlx5_ib_ubuffer {
index 027e81abd50c15d6391be18173746da7c2b6d747..5dc5869692eba141238e316e0aaa6a7d9f3db1b4 100644 (file)
@@ -5679,6 +5679,9 @@ struct ib_rwq_ind_table *mlx5_ib_create_rwq_ind_table(struct ib_device *device,
        for (i = 0; i < sz; i++)
                MLX5_SET(rqtc, rqtc, rq_num[i], init_attr->ind_tbl[i]->wq_num);
 
+       rwq_ind_tbl->uid = to_mpd(init_attr->ind_tbl[0]->pd)->uid;
+       MLX5_SET(create_rqt_in, in, uid, rwq_ind_tbl->uid);
+
        err = mlx5_core_create_rqt(dev->mdev, in, inlen, &rwq_ind_tbl->rqtn);
        kvfree(in);
 
@@ -5697,7 +5700,7 @@ struct ib_rwq_ind_table *mlx5_ib_create_rwq_ind_table(struct ib_device *device,
        return &rwq_ind_tbl->ib_rwq_ind_tbl;
 
 err_copy:
-       mlx5_core_destroy_rqt(dev->mdev, rwq_ind_tbl->rqtn);
+       mlx5_cmd_destroy_rqt(dev->mdev, rwq_ind_tbl->rqtn, rwq_ind_tbl->uid);
 err:
        kfree(rwq_ind_tbl);
        return ERR_PTR(err);
@@ -5708,7 +5711,7 @@ int mlx5_ib_destroy_rwq_ind_table(struct ib_rwq_ind_table *ib_rwq_ind_tbl)
        struct mlx5_ib_rwq_ind_table *rwq_ind_tbl = to_mrwq_ind_table(ib_rwq_ind_tbl);
        struct mlx5_ib_dev *dev = to_mdev(ib_rwq_ind_tbl->device);
 
-       mlx5_core_destroy_rqt(dev->mdev, rwq_ind_tbl->rqtn);
+       mlx5_cmd_destroy_rqt(dev->mdev, rwq_ind_tbl->rqtn, rwq_ind_tbl->uid);
 
        kfree(rwq_ind_tbl);
        return 0;