mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
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>
This commit is contained in:
parent
7dc5a0eeea
commit
0a020d416d
8 changed files with 1633 additions and 0 deletions
46
include/linux/objagg.h
Normal file
46
include/linux/objagg.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
|
||||
/* Copyright (c) 2018 Mellanox Technologies. All rights reserved */
|
||||
|
||||
#ifndef _OBJAGG_H
|
||||
#define _OBJAGG_H
|
||||
|
||||
struct objagg_ops {
|
||||
size_t obj_size;
|
||||
void * (*delta_create)(void *priv, void *parent_obj, void *obj);
|
||||
void (*delta_destroy)(void *priv, void *delta_priv);
|
||||
void * (*root_create)(void *priv, void *obj);
|
||||
void (*root_destroy)(void *priv, void *root_priv);
|
||||
};
|
||||
|
||||
struct objagg;
|
||||
struct objagg_obj;
|
||||
|
||||
const void *objagg_obj_root_priv(const struct objagg_obj *objagg_obj);
|
||||
const void *objagg_obj_delta_priv(const struct objagg_obj *objagg_obj);
|
||||
const void *objagg_obj_raw(const struct objagg_obj *objagg_obj);
|
||||
|
||||
struct objagg_obj *objagg_obj_get(struct objagg *objagg, void *obj);
|
||||
void objagg_obj_put(struct objagg *objagg, struct objagg_obj *objagg_obj);
|
||||
struct objagg *objagg_create(const struct objagg_ops *ops, void *priv);
|
||||
void objagg_destroy(struct objagg *objagg);
|
||||
|
||||
struct objagg_obj_stats {
|
||||
unsigned int user_count;
|
||||
unsigned int delta_user_count; /* includes delta object users */
|
||||
};
|
||||
|
||||
struct objagg_obj_stats_info {
|
||||
struct objagg_obj_stats stats;
|
||||
struct objagg_obj *objagg_obj; /* associated object */
|
||||
bool is_root;
|
||||
};
|
||||
|
||||
struct objagg_stats {
|
||||
unsigned int stats_info_count;
|
||||
struct objagg_obj_stats_info stats_info[];
|
||||
};
|
||||
|
||||
const struct objagg_stats *objagg_stats_get(struct objagg *objagg);
|
||||
void objagg_stats_put(const struct objagg_stats *objagg_stats);
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue