0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _LINUX_RHASHTABLE_TYPES_H
0010 #define _LINUX_RHASHTABLE_TYPES_H
0011
0012 #include <linux/atomic.h>
0013 #include <linux/compiler.h>
0014 #include <linux/mutex.h>
0015 #include <linux/workqueue.h>
0016
0017 struct rhash_head {
0018 struct rhash_head __rcu *next;
0019 };
0020
0021 struct rhlist_head {
0022 struct rhash_head rhead;
0023 struct rhlist_head __rcu *next;
0024 };
0025
0026 struct bucket_table;
0027
0028
0029
0030
0031
0032
0033 struct rhashtable_compare_arg {
0034 struct rhashtable *ht;
0035 const void *key;
0036 };
0037
0038 typedef u32 (*rht_hashfn_t)(const void *data, u32 len, u32 seed);
0039 typedef u32 (*rht_obj_hashfn_t)(const void *data, u32 len, u32 seed);
0040 typedef int (*rht_obj_cmpfn_t)(struct rhashtable_compare_arg *arg,
0041 const void *obj);
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056 struct rhashtable_params {
0057 u16 nelem_hint;
0058 u16 key_len;
0059 u16 key_offset;
0060 u16 head_offset;
0061 unsigned int max_size;
0062 u16 min_size;
0063 bool automatic_shrinking;
0064 rht_hashfn_t hashfn;
0065 rht_obj_hashfn_t obj_hashfn;
0066 rht_obj_cmpfn_t obj_cmpfn;
0067 };
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081 struct rhashtable {
0082 struct bucket_table __rcu *tbl;
0083 unsigned int key_len;
0084 unsigned int max_elems;
0085 struct rhashtable_params p;
0086 bool rhlist;
0087 struct work_struct run_work;
0088 struct mutex mutex;
0089 spinlock_t lock;
0090 atomic_t nelems;
0091 };
0092
0093
0094
0095
0096
0097 struct rhltable {
0098 struct rhashtable ht;
0099 };
0100
0101
0102
0103
0104
0105
0106 struct rhashtable_walker {
0107 struct list_head list;
0108 struct bucket_table *tbl;
0109 };
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120 struct rhashtable_iter {
0121 struct rhashtable *ht;
0122 struct rhash_head *p;
0123 struct rhlist_head *list;
0124 struct rhashtable_walker walker;
0125 unsigned int slot;
0126 unsigned int skip;
0127 bool end_of_table;
0128 };
0129
0130 int rhashtable_init(struct rhashtable *ht,
0131 const struct rhashtable_params *params);
0132 int rhltable_init(struct rhltable *hlt,
0133 const struct rhashtable_params *params);
0134
0135 #endif