]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
IB/mlx5: Set uid as part of MCG commands
authorYishai Hadas <yishaih@mellanox.com>
Thu, 20 Sep 2018 18:39:25 +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 MCG commands so that the firmware can manage the
MCG object in a secured way.

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/main.c

index 67f16e900445d505bcd5aa09fac43b94f9add938..91cfc2856bc49c7102cb2c5f6b3e57e3591dc8ec 100644 (file)
@@ -208,3 +208,33 @@ void mlx5_cmd_dealloc_pd(struct mlx5_core_dev *dev, u32 pdn, u16 uid)
        MLX5_SET(dealloc_pd_in, in, uid, uid);
        mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
 }
+
+int mlx5_cmd_attach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid,
+                       u32 qpn, u16 uid)
+{
+       u32 out[MLX5_ST_SZ_DW(attach_to_mcg_out)] = {};
+       u32 in[MLX5_ST_SZ_DW(attach_to_mcg_in)]   = {};
+       void *gid;
+
+       MLX5_SET(attach_to_mcg_in, in, opcode, MLX5_CMD_OP_ATTACH_TO_MCG);
+       MLX5_SET(attach_to_mcg_in, in, qpn, qpn);
+       MLX5_SET(attach_to_mcg_in, in, uid, uid);
+       gid = MLX5_ADDR_OF(attach_to_mcg_in, in, multicast_gid);
+       memcpy(gid, mgid, sizeof(*mgid));
+       return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
+}
+
+int mlx5_cmd_detach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid,
+                       u32 qpn, u16 uid)
+{
+       u32 out[MLX5_ST_SZ_DW(detach_from_mcg_out)] = {};
+       u32 in[MLX5_ST_SZ_DW(detach_from_mcg_in)]   = {};
+       void *gid;
+
+       MLX5_SET(detach_from_mcg_in, in, opcode, MLX5_CMD_OP_DETACH_FROM_MCG);
+       MLX5_SET(detach_from_mcg_in, in, qpn, qpn);
+       MLX5_SET(detach_from_mcg_in, in, uid, uid);
+       gid = MLX5_ADDR_OF(detach_from_mcg_in, in, multicast_gid);
+       memcpy(gid, mgid, sizeof(*mgid));
+       return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
+}
index 6df031d41a8fa5260f91b7f5c31c7064f80d5982..24175b3d5965decc2b7db52210d5fb9c767e43bc 100644 (file)
@@ -48,4 +48,8 @@ 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);
+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,
+                       u32 qpn, u16 uid);
 #endif /* MLX5_IB_CMD_H */
index 821dceb614a1223320b0f04419a2c2a319649c1f..2ed30e181a8b2caad766845bb3fa6800e2914c76 100644 (file)
@@ -4033,13 +4033,17 @@ static int mlx5_ib_mcg_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
        struct mlx5_ib_dev *dev = to_mdev(ibqp->device);
        struct mlx5_ib_qp *mqp = to_mqp(ibqp);
        int err;
+       u16 uid;
+
+       uid = ibqp->pd ?
+               to_mpd(ibqp->pd)->uid : 0;
 
        if (mqp->flags & MLX5_IB_QP_UNDERLAY) {
                mlx5_ib_dbg(dev, "Attaching a multi cast group to underlay QP is not supported\n");
                return -EOPNOTSUPP;
        }
 
-       err = mlx5_core_attach_mcg(dev->mdev, gid, ibqp->qp_num);
+       err = mlx5_cmd_attach_mcg(dev->mdev, gid, ibqp->qp_num, uid);
        if (err)
                mlx5_ib_warn(dev, "failed attaching QPN 0x%x, MGID %pI6\n",
                             ibqp->qp_num, gid->raw);
@@ -4051,8 +4055,11 @@ static int mlx5_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
 {
        struct mlx5_ib_dev *dev = to_mdev(ibqp->device);
        int err;
+       u16 uid;
 
-       err = mlx5_core_detach_mcg(dev->mdev, gid, ibqp->qp_num);
+       uid = ibqp->pd ?
+               to_mpd(ibqp->pd)->uid : 0;
+       err = mlx5_cmd_detach_mcg(dev->mdev, gid, ibqp->qp_num, uid);
        if (err)
                mlx5_ib_warn(dev, "failed detaching QPN 0x%x, MGID %pI6\n",
                             ibqp->qp_num, gid->raw);