qdf_hashtable.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. * DOC: qdf_hashtable.h - Public APIs for a hashtable data structure
  20. */
  21. #ifndef __QDF_HASHTABLE_H
  22. #define __QDF_HASHTABLE_H
  23. #include "i_qdf_hashtable.h"
  24. /**
  25. * struct qdf_ht - opaque hashtable data type
  26. */
  27. #define qdf_ht __qdf_ht
  28. /**
  29. * struct qdf_ht_entry - opaque hashtable entry for membership in a qdf_ht
  30. */
  31. #define qdf_ht_entry __qdf_ht_entry
  32. /**
  33. * qdf_ht_declare() - declare a new qdf_ht
  34. * @name: variable name of the hashtable to declare
  35. * @bits: number of hash bits to use; buckets=2^bits; Needs to be a compile
  36. * time constant
  37. *
  38. */
  39. #define qdf_ht_declare(name, bits) __qdf_ht_declare(name, bits)
  40. /**
  41. * qdf_ht_init() - initialize a qdf_ht instance
  42. * @table: a non-pointer qdf_ht instance to initialize
  43. *
  44. * Return: none
  45. */
  46. #define qdf_ht_init(table) __qdf_ht_init(table)
  47. /**
  48. * qdf_ht_deinit() - de-initialize a qdf_ht instance
  49. * @table: a non-pointer qdf_ht instance to de-initialize
  50. *
  51. * Return: none
  52. */
  53. #define qdf_ht_deinit(table) __qdf_ht_deinit(table)
  54. /**
  55. * qdf_ht_empty() - check if a qdf_ht has any entries
  56. * @table: a non-pointer qdf_ht instance to check
  57. *
  58. * Return: true if the hashtable is empty
  59. */
  60. #define qdf_ht_empty(table) __qdf_ht_empty(table)
  61. /**
  62. * qdf_ht_add() - add an entry to a qdf_ht instance
  63. * @table: a non-pointer qdf_ht instance to add an entry to
  64. * @entry: pinter to a qdf_ht_entry instance to add to @table
  65. * @key: the key to use for entry insertion and lookup
  66. *
  67. * Return: none
  68. */
  69. #define qdf_ht_add(table, entry, key) __qdf_ht_add(table, entry, key)
  70. /**
  71. * qdf_ht_remove() - remove and entry from a qdf_ht instance
  72. * @entry: pointer to a qdf_ht_entry instance to remove
  73. *
  74. * Return: none
  75. */
  76. #define qdf_ht_remove(entry) __qdf_ht_remove(entry)
  77. /**
  78. * qdf_ht_for_each() - iterate all entries in @table
  79. * @table: a non-pointer qdf_ht instance to iterate
  80. * @i: int type cursor populated with the bucket index
  81. * @cursor: container struct pointer populated with each iteration
  82. * @entry_field: name of the entry field in the entry container struct
  83. */
  84. #define qdf_ht_for_each(table, i, cursor, entry_field) \
  85. __qdf_ht_for_each(table, i, cursor, entry_field)
  86. /**
  87. * qdf_ht_for_each_in_bucket() - iterate entries in the bucket for @key
  88. * @table: a non-pointer qdf_ht instance to iterate
  89. * @cursor: container struct pointer populated with each iteration
  90. * @entry_field: name of the entry field in the entry container struct
  91. * @key: key used to lookup the hashtable bucket
  92. */
  93. #define qdf_ht_for_each_in_bucket(table, cursor, entry_field, key) \
  94. __qdf_ht_for_each_in_bucket(table, cursor, entry_field, key)
  95. /**
  96. * qdf_ht_for_each_match() - iterates through each entry matching @key
  97. * @table: a non-pointer qdf_ht instance to iterate
  98. * @cursor: container struct pointer populated with each iteration
  99. * @entry_field: name of the entry field in the entry container struct
  100. * @key: key used to lookup the entries
  101. * @key_field: name of the key field in the entry container struct
  102. */
  103. #define qdf_ht_for_each_match(table, cursor, entry_field, key, key_field) \
  104. __qdf_ht_for_each_match(table, cursor, entry_field, key, key_field)
  105. /**
  106. * qdf_ht_get() - get the first entry with a key matching @key
  107. * @table: a non-pointer qdf_ht instance to look in
  108. * @cursor: container struct pointer populated with each iteration
  109. * @entry_field: name of the entry field in the entry container struct
  110. * @key: key used to lookup the entry
  111. * @key_field: name of the key field in the entry container struct
  112. */
  113. #define qdf_ht_get(table, cursor, entry_field, key, key_field) \
  114. __qdf_ht_get(table, cursor, entry_field, key, key_field)
  115. #endif /* __QDF_HASHTABLE_H */