141eda65cSLeon Romanovsky /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ 241eda65cSLeon Romanovsky /* 341eda65cSLeon Romanovsky * Copyright (c) 2017-2019 Mellanox Technologies. All rights reserved. 441eda65cSLeon Romanovsky */ 541eda65cSLeon Romanovsky 641eda65cSLeon Romanovsky #ifndef _RDMA_CORE_RESTRACK_H_ 741eda65cSLeon Romanovsky #define _RDMA_CORE_RESTRACK_H_ 841eda65cSLeon Romanovsky 941eda65cSLeon Romanovsky #include <linux/mutex.h> 1041eda65cSLeon Romanovsky 1141eda65cSLeon Romanovsky /** 1241eda65cSLeon Romanovsky * struct rdma_restrack_root - main resource tracking management 1341eda65cSLeon Romanovsky * entity, per-device 1441eda65cSLeon Romanovsky */ 1541eda65cSLeon Romanovsky struct rdma_restrack_root { 1641eda65cSLeon Romanovsky /** 177c77c6a9SLeon Romanovsky * @xa: Array of XArray structure to hold restrack entries. 1841eda65cSLeon Romanovsky */ 197c77c6a9SLeon Romanovsky struct xarray xa; 2041eda65cSLeon Romanovsky /** 2141eda65cSLeon Romanovsky * @next_id: Next ID to support cyclic allocation 2241eda65cSLeon Romanovsky */ 237c77c6a9SLeon Romanovsky u32 next_id; 2441eda65cSLeon Romanovsky }; 2541eda65cSLeon Romanovsky 2641eda65cSLeon Romanovsky int rdma_restrack_init(struct ib_device *dev); 2741eda65cSLeon Romanovsky void rdma_restrack_clean(struct ib_device *dev); 28c34a23c2SLeon Romanovsky void rdma_restrack_add(struct rdma_restrack_entry *res); 2913ef5539SLeon Romanovsky void rdma_restrack_del(struct rdma_restrack_entry *res); 3013ef5539SLeon Romanovsky void rdma_restrack_new(struct rdma_restrack_entry *res, 3113ef5539SLeon Romanovsky enum rdma_restrack_type type); 32*b09c4d70SLeon Romanovsky void rdma_restrack_set_name(struct rdma_restrack_entry *res, 33*b09c4d70SLeon Romanovsky const char *caller); 34*b09c4d70SLeon Romanovsky void rdma_restrack_parent_name(struct rdma_restrack_entry *dst, 35*b09c4d70SLeon Romanovsky const struct rdma_restrack_entry *parent); 3641eda65cSLeon Romanovsky #endif /* _RDMA_CORE_RESTRACK_H_ */ 37