• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2017 Realtek Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  *****************************************************************************/
15 #ifndef __RTW_RHASHTABLE_H__
16 #define __RTW_RHASHTABLE_H__
17 
18 #if defined(CONFIG_RTW_WDS) || defined(CONFIG_RTW_MESH) /* for now, only promised for kernel versions we support mesh */
19 
20 /* directly reference rhashtable in kernel */
21 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
22 #include <linux/rhashtable.h>
23 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) */
24 
25 /* Use rhashtable from kernel 4.4 */
26 #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0))
27 #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0))
28 #define NULLS_MARKER(value) (1UL | (((long)value) << 1))
29 #endif
30 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0))
kmalloc_array(size_t n,size_t size,gfp_t flags)31 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
32 {
33 	if (size != 0 && n > ULONG_MAX / size)
34 		return NULL;
35 	return __kmalloc(n * size, flags);
36 }
37 #endif
38 #include "rhashtable.h"
39 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)) */
40 
41 typedef struct rhashtable rtw_rhashtable;
42 typedef struct rhash_head rtw_rhash_head;
43 typedef struct rhashtable_params rtw_rhashtable_params;
44 
45 #define rtw_rhashtable_init(ht, params) rhashtable_init(ht, params)
46 
47 typedef struct rhashtable_iter rtw_rhashtable_iter;
48 
49 int rtw_rhashtable_walk_enter(rtw_rhashtable *ht, rtw_rhashtable_iter *iter);
50 #define rtw_rhashtable_walk_exit(iter) rhashtable_walk_exit(iter)
51 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0))
52 #define rtw_rhashtable_walk_start(iter) rhashtable_walk_start_check(iter)
53 #else
54 #define rtw_rhashtable_walk_start(iter) rhashtable_walk_start(iter)
55 #endif
56 #define rtw_rhashtable_walk_next(iter) rhashtable_walk_next(iter)
57 #define rtw_rhashtable_walk_stop(iter) rhashtable_walk_stop(iter)
58 
59 #define rtw_rhashtable_free_and_destroy(ht, free_fn, arg) rhashtable_free_and_destroy((ht), (free_fn), (arg))
60 #define rtw_rhashtable_lookup_fast(ht, key, params) rhashtable_lookup_fast((ht), (key), (params))
61 #define rtw_rhashtable_lookup_insert_fast(ht, obj, params) rhashtable_lookup_insert_fast((ht), (obj), (params))
62 #define rtw_rhashtable_remove_fast(ht, obj, params) rhashtable_remove_fast((ht), (obj), (params))
63 
64 #endif /* defined(CONFIG_RTW_WDS) || defined(CONFIG_RTW_MESH) */
65 
66 #endif /* __RTW_RHASHTABLE_H__ */
67 
68