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