IB/mlx5: Set uid as part of TIR commands
authorYishai Hadas <yishaih@mellanox.com>
Thu, 20 Sep 2018 18:39:26 +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 TIR commands so that the firmware can manage the
TIR object in a secured way.

That will enable using a TIR 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/qp.c

index 91cfc2856bc49c7102cb2c5f6b3e57e3591dc8ec..9834cd4d1e457855e18cd0d864d9fd4db9fe85ca 100644 (file)
@@ -198,6 +198,17 @@ int mlx5_cmd_query_ext_ppcnt_counters(struct mlx5_core_dev *dev, void *out)
                                     0, 0);
 }
 
+void mlx5_cmd_destroy_tir(struct mlx5_core_dev *dev, u32 tirn, u16 uid)
+{
+       u32 in[MLX5_ST_SZ_DW(destroy_tir_in)]   = {};
+       u32 out[MLX5_ST_SZ_DW(destroy_tir_out)] = {};
+
+       MLX5_SET(destroy_tir_in, in, opcode, MLX5_CMD_OP_DESTROY_TIR);
+       MLX5_SET(destroy_tir_in, in, tirn, tirn);
+       MLX5_SET(destroy_tir_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 24175b3d5965decc2b7db52210d5fb9c767e43bc..feab7682bfbdc44559b4bcb13e9f0313fbf60e91 100644 (file)
@@ -48,6 +48,7 @@ int mlx5_cmd_alloc_memic(struct mlx5_memic *memic, phys_addr_t *addr,
                         u64 length, u32 alignment);
 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);
 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 13495816a10fa86ccd10568a70c9c6036331dfb2..2b2d26fa071d358ffc0f9c09de4cc8fdd74e2b50 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/mlx5/fs.h>
 #include "mlx5_ib.h"
 #include "ib_rep.h"
+#include "cmd.h"
 
 /* not supported currently */
 static int wq_signature;
@@ -1261,17 +1262,19 @@ static bool tunnel_offload_supported(struct mlx5_core_dev *dev)
 
 static void destroy_raw_packet_qp_tir(struct mlx5_ib_dev *dev,
                                      struct mlx5_ib_rq *rq,
-                                     u32 qp_flags_en)
+                                     u32 qp_flags_en,
+                                     struct ib_pd *pd)
 {
        if (qp_flags_en & (MLX5_QP_FLAG_TIR_ALLOW_SELF_LB_UC |
                           MLX5_QP_FLAG_TIR_ALLOW_SELF_LB_MC))
                mlx5_ib_disable_lb(dev, false, true);
-       mlx5_core_destroy_tir(dev->mdev, rq->tirn);
+       mlx5_cmd_destroy_tir(dev->mdev, rq->tirn, to_mpd(pd)->uid);
 }
 
 static int create_raw_packet_qp_tir(struct mlx5_ib_dev *dev,
                                    struct mlx5_ib_rq *rq, u32 tdn,
-                                   u32 *qp_flags_en)
+                                   u32 *qp_flags_en,
+                                   struct ib_pd *pd)
 {
        u8 lb_flag = 0;
        u32 *in;
@@ -1284,6 +1287,7 @@ static int create_raw_packet_qp_tir(struct mlx5_ib_dev *dev,
        if (!in)
                return -ENOMEM;
 
+       MLX5_SET(create_tir_in, in, uid, to_mpd(pd)->uid);
        tirc = MLX5_ADDR_OF(create_tir_in, in, ctx);
        MLX5_SET(tirc, tirc, disp_type, MLX5_TIRC_DISP_TYPE_DIRECT);
        MLX5_SET(tirc, tirc, inline_rqn, rq->base.mqp.qpn);
@@ -1310,7 +1314,7 @@ static int create_raw_packet_qp_tir(struct mlx5_ib_dev *dev,
                err = mlx5_ib_enable_lb(dev, false, true);
 
                if (err)
-                       destroy_raw_packet_qp_tir(dev, rq, 0);
+                       destroy_raw_packet_qp_tir(dev, rq, 0, pd);
        }
        kvfree(in);
 
@@ -1354,8 +1358,7 @@ static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
                if (err)
                        goto err_destroy_sq;
 
-
-               err = create_raw_packet_qp_tir(dev, rq, tdn, &qp->flags_en);
+               err = create_raw_packet_qp_tir(dev, rq, tdn, &qp->flags_en, pd);
                if (err)
                        goto err_destroy_rq;
        }
@@ -1385,7 +1388,7 @@ static void destroy_raw_packet_qp(struct mlx5_ib_dev *dev,
        struct mlx5_ib_rq *rq = &raw_packet_qp->rq;
 
        if (qp->rq.wqe_cnt) {
-               destroy_raw_packet_qp_tir(dev, rq, qp->flags_en);
+               destroy_raw_packet_qp_tir(dev, rq, qp->flags_en, qp->ibqp.pd);
                destroy_raw_packet_qp_rq(dev, rq);
        }
 
@@ -1412,7 +1415,8 @@ static void destroy_rss_raw_qp_tir(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *q
        if (qp->flags_en & (MLX5_QP_FLAG_TIR_ALLOW_SELF_LB_UC |
                            MLX5_QP_FLAG_TIR_ALLOW_SELF_LB_MC))
                mlx5_ib_disable_lb(dev, false, true);
-       mlx5_core_destroy_tir(dev->mdev, qp->rss_qp.tirn);
+       mlx5_cmd_destroy_tir(dev->mdev, qp->rss_qp.tirn,
+                            to_mpd(qp->ibqp.pd)->uid);
 }
 
 static int create_rss_raw_qp_tir(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
@@ -1510,6 +1514,7 @@ static int create_rss_raw_qp_tir(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
        if (!in)
                return -ENOMEM;
 
+       MLX5_SET(create_tir_in, in, uid, to_mpd(pd)->uid);
        tirc = MLX5_ADDR_OF(create_tir_in, in, ctx);
        MLX5_SET(tirc, tirc, disp_type,
                 MLX5_TIRC_DISP_TYPE_INDIRECT);
@@ -1626,7 +1631,8 @@ create_tir:
                err = mlx5_ib_enable_lb(dev, false, true);
 
                if (err)
-                       mlx5_core_destroy_tir(dev->mdev, qp->rss_qp.tirn);
+                       mlx5_cmd_destroy_tir(dev->mdev, qp->rss_qp.tirn,
+                                            to_mpd(pd)->uid);
        }
 
        if (err)