1
2
3
4
5
6
7
8
9 #ifndef _LINUX_RHASHTABLE_TYPES_H
10 #define _LINUX_RHASHTABLE_TYPES_H
11
12 #include <linux/atomic.h>
13 #include <linux/compiler.h>
14 #include <linux/mutex.h>
15 #include <linux/workqueue.h>
16
17 struct rhash_head {
18 struct rhash_head __rcu *next;
19 };
20
21 struct rhlist_head {
22 struct rhash_head rhead;
23 struct rhlist_head __rcu *next;
24 };
25
26 struct bucket_table;
27
28
29
30
31
32
33 struct rhashtable_compare_arg {
34 struct rhashtable *ht;
35 const void *key;
36 };
37
38 typedef u32 (*rht_hashfn_t)(const void *data, u32 len, u32 seed);
39 typedef u32 (*rht_obj_hashfn_t)(const void *data, u32 len, u32 seed);
40 typedef int (*rht_obj_cmpfn_t)(struct rhashtable_compare_arg *arg,
41 const void *obj);
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 struct rhashtable_params {
57 u16 nelem_hint;
58 u16 key_len;
59 u16 key_offset;
60 u16 head_offset;
61 unsigned int max_size;
62 u16 min_size;
63 bool automatic_shrinking;
64 rht_hashfn_t hashfn;
65 rht_obj_hashfn_t obj_hashfn;
66 rht_obj_cmpfn_t obj_cmpfn;
67 };
68
69
70
71
72
73
74
75
76
77
78
79
80
81 struct rhashtable {
82 struct bucket_table __rcu *tbl;
83 unsigned int key_len;
84 unsigned int max_elems;
85 struct rhashtable_params p;
86 bool rhlist;
87 struct work_struct run_work;
88 struct mutex mutex;
89 spinlock_t lock;
90 atomic_t nelems;
91 };
92
93
94
95
96
97 struct rhltable {
98 struct rhashtable ht;
99 };
100
101
102
103
104
105
106 struct rhashtable_walker {
107 struct list_head list;
108 struct bucket_table *tbl;
109 };
110
111
112
113
114
115
116
117
118
119
120 struct rhashtable_iter {
121 struct rhashtable *ht;
122 struct rhash_head *p;
123 struct rhlist_head *list;
124 struct rhashtable_walker walker;
125 unsigned int slot;
126 unsigned int skip;
127 bool end_of_table;
128 };
129
130 int rhashtable_init(struct rhashtable *ht,
131 const struct rhashtable_params *params);
132 int rhltable_init(struct rhltable *hlt,
133 const struct rhashtable_params *params);
134
135 #endif