Skip to content

Commit 39cc792

Browse files
maorgottliebjgunthorpe
authored andcommitted
RDMA/mlx5: Add support to MODIFY_MEMIC command
Add two functions to allocate and deallocate MEMIC operations by using the MODIFY_MEMIC command. Link: https://lore.kernel.org/r/20210411122924.60230-6-leon@kernel.org Signed-off-by: Maor Gottlieb <maorg@nvidia.com> Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 251b9d7 commit 39cc792

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

‎drivers/infiniband/hw/mlx5/dm.c‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,42 @@ void mlx5_cmd_dealloc_memic(struct mlx5_dm *dm, phys_addr_t addr,
111111
spin_unlock(&dm->lock);
112112
}
113113

114+
void mlx5_cmd_dealloc_memic_op(struct mlx5_dm *dm, phys_addr_t addr,
115+
u8 operation)
116+
{
117+
u32 in[MLX5_ST_SZ_DW(modify_memic_in)] = {};
118+
struct mlx5_core_dev *dev = dm->dev;
119+
120+
MLX5_SET(modify_memic_in, in, opcode, MLX5_CMD_OP_MODIFY_MEMIC);
121+
MLX5_SET(modify_memic_in, in, op_mod, MLX5_MODIFY_MEMIC_OP_MOD_DEALLOC);
122+
MLX5_SET(modify_memic_in, in, memic_operation_type, operation);
123+
MLX5_SET64(modify_memic_in, in, memic_start_addr, addr - dev->bar_addr);
124+
125+
mlx5_cmd_exec_in(dev, modify_memic, in);
126+
}
127+
128+
static int mlx5_cmd_alloc_memic_op(struct mlx5_dm *dm, phys_addr_t addr,
129+
u8 operation, phys_addr_t *op_addr)
130+
{
131+
u32 out[MLX5_ST_SZ_DW(modify_memic_out)] = {};
132+
u32 in[MLX5_ST_SZ_DW(modify_memic_in)] = {};
133+
struct mlx5_core_dev *dev = dm->dev;
134+
int err;
135+
136+
MLX5_SET(modify_memic_in, in, opcode, MLX5_CMD_OP_MODIFY_MEMIC);
137+
MLX5_SET(modify_memic_in, in, op_mod, MLX5_MODIFY_MEMIC_OP_MOD_ALLOC);
138+
MLX5_SET(modify_memic_in, in, memic_operation_type, operation);
139+
MLX5_SET64(modify_memic_in, in, memic_start_addr, addr - dev->bar_addr);
140+
141+
err = mlx5_cmd_exec_inout(dev, modify_memic, in, out);
142+
if (err)
143+
return err;
144+
145+
*op_addr = dev->bar_addr +
146+
MLX5_GET64(modify_memic_out, out, memic_operation_addr);
147+
return 0;
148+
}
149+
114150
static int add_dm_mmap_entry(struct ib_ucontext *context,
115151
struct mlx5_ib_dm_memic *mdm, u64 address)
116152
{

‎drivers/infiniband/hw/mlx5/dm.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,7 @@ struct ib_dm *mlx5_ib_alloc_dm(struct ib_device *ibdev,
4949
struct uverbs_attr_bundle *attrs);
5050
void mlx5_cmd_dealloc_memic(struct mlx5_dm *dm, phys_addr_t addr,
5151
u64 length);
52+
void mlx5_cmd_dealloc_memic_op(struct mlx5_dm *dm, phys_addr_t addr,
53+
u8 operation);
5254

5355
#endif /* _MLX5_IB_DM_H */

0 commit comments

Comments
 (0)