i_qdf_hashtable.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #ifndef __I_QDF_HASHTABLE_H
  19. #define __I_QDF_HASHTABLE_H
  20. #include "linux/hashtable.h"
  21. #define __qdf_ht hlist_head
  22. #define __qdf_ht_entry hlist_node
  23. #define __qdf_ht_declare(name, bits) DECLARE_HASHTABLE(name, bits)
  24. #define __qdf_ht_init(table) hash_init(table)
  25. #define __qdf_ht_deinit(table) do { } while (false)
  26. #define __qdf_ht_empty(table) hash_empty(table)
  27. #define __qdf_ht_add(table, entry, key) hash_add(table, entry, key)
  28. #define __qdf_ht_remove(entry) hash_del(entry)
  29. #define __qdf_ht_for_each(table, i, cursor, entry_field) \
  30. hash_for_each(table, i, cursor, entry_field)
  31. #define __qdf_ht_for_each_in_bucket(table, cursor, entry_field, key) \
  32. hash_for_each_possible(table, cursor, entry_field, key)
  33. #define __qdf_ht_for_each_match(table, cursor, entry_field, key, key_field) \
  34. hash_for_each_possible(table, (cursor), entry_field, (key)) \
  35. if ((cursor)->key_field == (key))
  36. #define __qdf_ht_get(table, cursor, entry_field, key, key_field) \
  37. do { \
  38. cursor = NULL; \
  39. __qdf_ht_for_each_match(table, cursor, entry_field, key, key_field) \
  40. break; \
  41. } while (false)
  42. #define __qdf_ht_for_each_safe(table, i, tmp, cursor, entry_field) \
  43. hash_for_each_safe(table, i, tmp, cursor, entry_field)
  44. #endif /* __I_QDF_HASHTABLE_H */