restrack.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
  2. /*
  3. * Copyright (c) 2017-2019 Mellanox Technologies. All rights reserved.
  4. */
  5. #ifndef _RDMA_CORE_RESTRACK_H_
  6. #define _RDMA_CORE_RESTRACK_H_
  7. #include <linux/mutex.h>
  8. /**
  9. * struct rdma_restrack_root - main resource tracking management
  10. * entity, per-device
  11. */
  12. struct rdma_restrack_root {
  13. /**
  14. * @xa: Array of XArray structure to hold restrack entries.
  15. */
  16. struct xarray xa;
  17. /**
  18. * @next_id: Next ID to support cyclic allocation
  19. */
  20. u32 next_id;
  21. };
  22. int rdma_restrack_init(struct ib_device *dev);
  23. void rdma_restrack_clean(struct ib_device *dev);
  24. void rdma_restrack_add(struct rdma_restrack_entry *res);
  25. void rdma_restrack_del(struct rdma_restrack_entry *res);
  26. void rdma_restrack_new(struct rdma_restrack_entry *res,
  27. enum rdma_restrack_type type);
  28. void rdma_restrack_set_name(struct rdma_restrack_entry *res,
  29. const char *caller);
  30. void rdma_restrack_parent_name(struct rdma_restrack_entry *dst,
  31. const struct rdma_restrack_entry *parent);
  32. #endif /* _RDMA_CORE_RESTRACK_H_ */