summaryrefslogtreecommitdiffstats
path: root/include/linux/objagg.h
diff options
context:
space:
mode:
authorJiri Pirko <jiri@mellanox.com>2018-11-14 03:22:28 -0500
committerDavid S. Miller <davem@davemloft.net>2018-11-15 17:43:43 -0500
commit0a020d416d0af0b0c782e2a8363896e756e9121e (patch)
tree2bd2d93bf7fdddceb76f0450c1063db9ea3776a3 /include/linux/objagg.h
parent7dc5a0eeea185e5f3af3f97a86e76419791cdd60 (diff)
lib: introduce initial implementation of object aggregation manager
This lib tracks objects which could be of two types: 1) root object 2) nested object - with a "delta" which differentiates it from the associated root object The objects are tracked by a hashtable and reference-counted. User is responsible of implementing callbacks to create/destroy root entity related to each root object and callback to create/destroy nested object delta. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/objagg.h')
-rw-r--r--include/linux/objagg.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/include/linux/objagg.h b/include/linux/objagg.h
new file mode 100644
index 000000000000..34f38c186ea0
--- /dev/null
+++ b/include/linux/objagg.h
@@ -0,0 +1,46 @@
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
7struct 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
15struct objagg;
16struct objagg_obj;
17
18const void *objagg_obj_root_priv(const struct objagg_obj *objagg_obj);
19const void *objagg_obj_delta_priv(const struct objagg_obj *objagg_obj);
20const void *objagg_obj_raw(const struct objagg_obj *objagg_obj);
21
22struct objagg_obj *objagg_obj_get(struct objagg *objagg, void *obj);
23void objagg_obj_put(struct objagg *objagg, struct objagg_obj *objagg_obj);
24struct objagg *objagg_create(const struct objagg_ops *ops, void *priv);
25void objagg_destroy(struct objagg *objagg);
26
27struct objagg_obj_stats {
28 unsigned int user_count;
29 unsigned int delta_user_count; /* includes delta object users */
30};
31
32struct objagg_obj_stats_info {
33 struct objagg_obj_stats stats;
34 struct objagg_obj *objagg_obj; /* associated object */
35 bool is_root;
36};
37
38struct objagg_stats {
39 unsigned int stats_info_count;
40 struct objagg_obj_stats_info stats_info[];
41};
42
43const struct objagg_stats *objagg_stats_get(struct objagg *objagg);
44void objagg_stats_put(const struct objagg_stats *objagg_stats);
45
46#endif