1 /*
2  * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #ifndef __I_QDF_HASHTABLE_H
20 #define __I_QDF_HASHTABLE_H
21 
22 #include "linux/hashtable.h"
23 
24 #define __qdf_ht hlist_head
25 #define __qdf_ht_entry hlist_node
26 #define __qdf_ht_declare(name, bits) DECLARE_HASHTABLE(name, bits)
27 #define __qdf_ht_init(table) hash_init(table)
28 #define __qdf_ht_deinit(table) do { } while (false)
29 #define __qdf_ht_empty(table) hash_empty(table)
30 #define __qdf_ht_add(table, entry, key) hash_add(table, entry, key)
31 #define __qdf_ht_remove(entry) hash_del(entry)
32 
33 #define __qdf_ht_for_each(table, i, cursor, entry_field) \
34 	hash_for_each(table, i, cursor, entry_field)
35 
36 #define __qdf_ht_for_each_in_bucket(table, cursor, entry_field, key) \
37 	hash_for_each_possible(table, cursor, entry_field, key)
38 
39 #define __qdf_ht_for_each_match(table, cursor, entry_field, key, key_field) \
40 	hash_for_each_possible(table, (cursor), entry_field, (key)) \
41 		if ((cursor)->key_field == (key))
42 
43 #define __qdf_ht_get(table, cursor, entry_field, key, key_field) \
44 do { \
45 	cursor = NULL; \
46 	__qdf_ht_for_each_match(table, cursor, entry_field, key, key_field) \
47 		break; \
48 } while (false)
49 
50 #define __qdf_ht_for_each_safe(table, i, tmp, cursor, entry_field) \
51 	hash_for_each_safe(table, i, tmp, cursor, entry_field)
52 
53 #endif /* __I_QDF_HASHTABLE_H */
54