1 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */ 2 /* Copyright (c) 2018 Mellanox Technologies. All rights reserved */ 3 4 #ifndef _OBJAGG_H 5 #define _OBJAGG_H 6 7 struct objagg_ops { 8 size_t obj_size; 9 void * (*delta_create)(void *priv, void *parent_obj, void *obj); 10 void (*delta_destroy)(void *priv, void *delta_priv); 11 void * (*root_create)(void *priv, void *obj); 12 void (*root_destroy)(void *priv, void *root_priv); 13 }; 14 15 struct objagg; 16 struct objagg_obj; 17 18 const void *objagg_obj_root_priv(const struct objagg_obj *objagg_obj); 19 const void *objagg_obj_delta_priv(const struct objagg_obj *objagg_obj); 20 const void *objagg_obj_raw(const struct objagg_obj *objagg_obj); 21 22 struct objagg_obj *objagg_obj_get(struct objagg *objagg, void *obj); 23 void objagg_obj_put(struct objagg *objagg, struct objagg_obj *objagg_obj); 24 struct objagg *objagg_create(const struct objagg_ops *ops, void *priv); 25 void objagg_destroy(struct objagg *objagg); 26 27 struct objagg_obj_stats { 28 unsigned int user_count; 29 unsigned int delta_user_count; /* includes delta object users */ 30 }; 31 32 struct objagg_obj_stats_info { 33 struct objagg_obj_stats stats; 34 struct objagg_obj *objagg_obj; /* associated object */ 35 bool is_root; 36 }; 37 38 struct objagg_stats { 39 unsigned int stats_info_count; 40 struct objagg_obj_stats_info stats_info[]; 41 }; 42 43 const struct objagg_stats *objagg_stats_get(struct objagg *objagg); 44 void objagg_stats_put(const struct objagg_stats *objagg_stats); 45 46 #endif 47