Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
0002 /* Copyright (c) 2018 Mellanox Technologies. All rights reserved */
0003 
0004 #ifndef _OBJAGG_H
0005 #define _OBJAGG_H
0006 
0007 struct objagg_ops {
0008     size_t obj_size;
0009     bool (*delta_check)(void *priv, const void *parent_obj,
0010                 const void *obj);
0011     int (*hints_obj_cmp)(const void *obj1, const void *obj2);
0012     void * (*delta_create)(void *priv, void *parent_obj, void *obj);
0013     void (*delta_destroy)(void *priv, void *delta_priv);
0014     void * (*root_create)(void *priv, void *obj, unsigned int root_id);
0015 #define OBJAGG_OBJ_ROOT_ID_INVALID UINT_MAX
0016     void (*root_destroy)(void *priv, void *root_priv);
0017 };
0018 
0019 struct objagg;
0020 struct objagg_obj;
0021 struct objagg_hints;
0022 
0023 const void *objagg_obj_root_priv(const struct objagg_obj *objagg_obj);
0024 const void *objagg_obj_delta_priv(const struct objagg_obj *objagg_obj);
0025 const void *objagg_obj_raw(const struct objagg_obj *objagg_obj);
0026 
0027 struct objagg_obj *objagg_obj_get(struct objagg *objagg, void *obj);
0028 void objagg_obj_put(struct objagg *objagg, struct objagg_obj *objagg_obj);
0029 struct objagg *objagg_create(const struct objagg_ops *ops,
0030                  struct objagg_hints *hints, void *priv);
0031 void objagg_destroy(struct objagg *objagg);
0032 
0033 struct objagg_obj_stats {
0034     unsigned int user_count;
0035     unsigned int delta_user_count; /* includes delta object users */
0036 };
0037 
0038 struct objagg_obj_stats_info {
0039     struct objagg_obj_stats stats;
0040     struct objagg_obj *objagg_obj; /* associated object */
0041     bool is_root;
0042 };
0043 
0044 struct objagg_stats {
0045     unsigned int root_count;
0046     unsigned int stats_info_count;
0047     struct objagg_obj_stats_info stats_info[];
0048 };
0049 
0050 const struct objagg_stats *objagg_stats_get(struct objagg *objagg);
0051 void objagg_stats_put(const struct objagg_stats *objagg_stats);
0052 
0053 enum objagg_opt_algo_type {
0054     OBJAGG_OPT_ALGO_SIMPLE_GREEDY,
0055 };
0056 
0057 struct objagg_hints *objagg_hints_get(struct objagg *objagg,
0058                       enum objagg_opt_algo_type opt_algo_type);
0059 void objagg_hints_put(struct objagg_hints *objagg_hints);
0060 const struct objagg_stats *
0061 objagg_hints_stats_get(struct objagg_hints *objagg_hints);
0062 
0063 #endif