dm.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
  2. /*
  3. * Copyright (c) 2021, Mellanox Technologies inc. All rights reserved.
  4. */
  5. #ifndef _MLX5_IB_DM_H
  6. #define _MLX5_IB_DM_H
  7. #include "mlx5_ib.h"
  8. extern const struct ib_device_ops mlx5_ib_dev_dm_ops;
  9. extern const struct uapi_definition mlx5_ib_dm_defs[];
  10. struct mlx5_ib_dm {
  11. struct ib_dm ibdm;
  12. u32 type;
  13. phys_addr_t dev_addr;
  14. size_t size;
  15. };
  16. struct mlx5_ib_dm_op_entry {
  17. struct mlx5_user_mmap_entry mentry;
  18. phys_addr_t op_addr;
  19. struct mlx5_ib_dm_memic *dm;
  20. u8 op;
  21. };
  22. struct mlx5_ib_dm_memic {
  23. struct mlx5_ib_dm base;
  24. struct mlx5_user_mmap_entry mentry;
  25. struct xarray ops;
  26. struct mutex ops_xa_lock;
  27. struct kref ref;
  28. size_t req_length;
  29. };
  30. struct mlx5_ib_dm_icm {
  31. struct mlx5_ib_dm base;
  32. u32 obj_id;
  33. };
  34. static inline struct mlx5_ib_dm *to_mdm(struct ib_dm *ibdm)
  35. {
  36. return container_of(ibdm, struct mlx5_ib_dm, ibdm);
  37. }
  38. static inline struct mlx5_ib_dm_memic *to_memic(struct ib_dm *ibdm)
  39. {
  40. return container_of(ibdm, struct mlx5_ib_dm_memic, base.ibdm);
  41. }
  42. static inline struct mlx5_ib_dm_icm *to_icm(struct ib_dm *ibdm)
  43. {
  44. return container_of(ibdm, struct mlx5_ib_dm_icm, base.ibdm);
  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_ib_dm_mmap_free(struct mlx5_ib_dev *dev,
  51. struct mlx5_user_mmap_entry *mentry);
  52. void mlx5_cmd_dealloc_memic(struct mlx5_dm *dm, phys_addr_t addr,
  53. u64 length);
  54. void mlx5_cmd_dealloc_memic_op(struct mlx5_dm *dm, phys_addr_t addr,
  55. u8 operation);
  56. #endif /* _MLX5_IB_DM_H */