1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ 2 /* 3 * Copyright (c) 2021, Mellanox Technologies inc. All rights reserved. 4 */ 5 6 #ifndef _MLX5_IB_DM_H 7 #define _MLX5_IB_DM_H 8 9 #include "mlx5_ib.h" 10 11 extern const struct ib_device_ops mlx5_ib_dev_dm_ops; 12 extern const struct uapi_definition mlx5_ib_dm_defs[]; 13 14 struct mlx5_ib_dm { 15 struct ib_dm ibdm; 16 u32 type; 17 phys_addr_t dev_addr; 18 size_t size; 19 }; 20 21 struct mlx5_ib_dm_memic { 22 struct mlx5_ib_dm base; 23 struct mlx5_user_mmap_entry mentry; 24 }; 25 26 struct mlx5_ib_dm_icm { 27 struct mlx5_ib_dm base; 28 u32 obj_id; 29 }; 30 31 static inline struct mlx5_ib_dm *to_mdm(struct ib_dm *ibdm) 32 { 33 return container_of(ibdm, struct mlx5_ib_dm, ibdm); 34 } 35 36 static inline struct mlx5_ib_dm_memic *to_memic(struct ib_dm *ibdm) 37 { 38 return container_of(ibdm, struct mlx5_ib_dm_memic, base.ibdm); 39 } 40 41 static inline struct mlx5_ib_dm_icm *to_icm(struct ib_dm *ibdm) 42 { 43 return container_of(ibdm, struct mlx5_ib_dm_icm, base.ibdm); 44 } 45 46 struct ib_dm *mlx5_ib_alloc_dm(struct ib_device *ibdev, 47 struct ib_ucontext *context, 48 struct ib_dm_alloc_attr *attr, 49 struct uverbs_attr_bundle *attrs); 50 void mlx5_cmd_dealloc_memic(struct mlx5_dm *dm, phys_addr_t addr, 51 u64 length); 52 53 #endif /* _MLX5_IB_DM_H */ 54