rtw_rhashtable.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #ifdef CONFIG_RTW_MESH /* for now, only promised for kernel versions we support mesh */
  18. /* directly reference rhashtable in kernel */
  19. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
  20. #include <linux/rhashtable.h>
  21. #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) */
  22. /* Use rhashtable from kernel 4.4 */
  23. #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0))
  24. #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0))
  25. #define NULLS_MARKER(value) (1UL | (((long)value) << 1))
  26. #endif
  27. #include "rhashtable.h"
  28. #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)) */
  29. typedef struct rhashtable rtw_rhashtable;
  30. typedef struct rhash_head rtw_rhash_head;
  31. typedef struct rhashtable_params rtw_rhashtable_params;
  32. #define rtw_rhashtable_init(ht, params) rhashtable_init(ht, params)
  33. typedef struct rhashtable_iter rtw_rhashtable_iter;
  34. int rtw_rhashtable_walk_enter(rtw_rhashtable *ht, rtw_rhashtable_iter *iter);
  35. #define rtw_rhashtable_walk_exit(iter) rhashtable_walk_exit(iter)
  36. #define rtw_rhashtable_walk_start(iter) rhashtable_walk_start(iter)
  37. #define rtw_rhashtable_walk_next(iter) rhashtable_walk_next(iter)
  38. #define rtw_rhashtable_walk_stop(iter) rhashtable_walk_stop(iter)
  39. #define rtw_rhashtable_free_and_destroy(ht, free_fn, arg) rhashtable_free_and_destroy((ht), (free_fn), (arg))
  40. #define rtw_rhashtable_lookup_fast(ht, key, params) rhashtable_lookup_fast((ht), (key), (params))
  41. #define rtw_rhashtable_lookup_insert_fast(ht, obj, params) rhashtable_lookup_insert_fast((ht), (obj), (params))
  42. #define rtw_rhashtable_remove_fast(ht, obj, params) rhashtable_remove_fast((ht), (obj), (params))
  43. #endif /* CONFIG_RTW_MESH */
  44. #endif /* __RTW_RHASHTABLE_H__ */