xref: /dpdk/lib/hash/rte_hash.h (revision 567bb951716f1ae9e418eacda3dd9dac5edf6fde)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2015 Intel Corporation
3  */
4 
5 #ifndef _RTE_HASH_H_
6 #define _RTE_HASH_H_
7 
8 /**
9  * @file
10  *
11  * RTE Hash Table
12  */
13 
14 #include <stdint.h>
15 #include <stddef.h>
16 
17 #include <rte_rcu_qsbr.h>
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 /** Maximum size of hash table that can be created. */
24 #define RTE_HASH_ENTRIES_MAX			(1 << 30)
25 
26 /** Maximum number of characters in hash name.*/
27 #define RTE_HASH_NAMESIZE			32
28 
29 /** Maximum number of keys that can be searched for using rte_hash_lookup_bulk. */
30 #define RTE_HASH_LOOKUP_BULK_MAX		64
31 #define RTE_HASH_LOOKUP_MULTI_MAX		RTE_HASH_LOOKUP_BULK_MAX
32 
33 /** Enable Hardware transactional memory support. */
34 #define RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT	0x01
35 
36 /** Default behavior of insertion, single writer/multi writer */
37 #define RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD 0x02
38 
39 /** Flag to support reader writer concurrency */
40 #define RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY 0x04
41 
42 /** Flag to indicate the extendable bucket table feature should be used */
43 #define RTE_HASH_EXTRA_FLAGS_EXT_TABLE 0x08
44 
45 /** Flag to disable freeing of key index on hash delete.
46  * Refer to rte_hash_del_xxx APIs for more details.
47  * This is enabled by default when RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF
48  * is enabled. However, if internal RCU is enabled, freeing of internal
49  * memory/index is done on delete
50  */
51 #define RTE_HASH_EXTRA_FLAGS_NO_FREE_ON_DEL 0x10
52 
53 /** Flag to support lock free reader writer concurrency. Both single writer
54  * and multi writer use cases are supported.
55  */
56 #define RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF 0x20
57 
58 /**
59  * The type of hash value of a key.
60  * It should be a value of at least 32bit with fully random pattern.
61  */
62 typedef uint32_t hash_sig_t;
63 
64 /** Type of function that can be used for calculating the hash value. */
65 typedef uint32_t (*rte_hash_function)(const void *key, uint32_t key_len,
66 				      uint32_t init_val);
67 
68 /** Type of function used to compare the hash key. */
69 typedef int (*rte_hash_cmp_eq_t)(const void *key1, const void *key2, size_t key_len);
70 
71 /**
72  * Type of function used to free data stored in the key.
73  * Required when using internal RCU to allow application to free key-data once
74  * the key is returned to the ring of free key-slots.
75  */
76 typedef void (*rte_hash_free_key_data)(void *p, void *key_data);
77 
78 /**
79  * Parameters used when creating the hash table.
80  */
81 struct rte_hash_parameters {
82 	const char *name;		/**< Name of the hash. */
83 	uint32_t entries;		/**< Total hash table entries. */
84 	uint32_t reserved;		/**< Unused field. Should be set to 0 */
85 	uint32_t key_len;		/**< Length of hash key. */
86 	rte_hash_function hash_func;	/**< Primary Hash function used to calculate hash. */
87 	uint32_t hash_func_init_val;	/**< Init value used by hash_func. */
88 	int socket_id;			/**< NUMA Socket ID for memory. */
89 	uint8_t extra_flag;		/**< Indicate if additional parameters are present. */
90 };
91 
92 /** RCU reclamation modes */
93 enum rte_hash_qsbr_mode {
94 	/** Create defer queue for reclaim. */
95 	RTE_HASH_QSBR_MODE_DQ = 0,
96 	/** Use blocking mode reclaim. No defer queue created. */
97 	RTE_HASH_QSBR_MODE_SYNC
98 };
99 
100 /** HASH RCU QSBR configuration structure. */
101 struct rte_hash_rcu_config {
102 	struct rte_rcu_qsbr *v;		/**< RCU QSBR variable. */
103 	enum rte_hash_qsbr_mode mode;
104 	/**< Mode of RCU QSBR. RTE_HASH_QSBR_MODE_xxx
105 	 * '0' for default: create defer queue for reclaim.
106 	 */
107 	uint32_t dq_size;
108 	/**< RCU defer queue size.
109 	 * default: total hash table entries.
110 	 */
111 	uint32_t trigger_reclaim_limit;	/**< Threshold to trigger auto reclaim. */
112 	uint32_t max_reclaim_size;
113 	/**< Max entries to reclaim in one go.
114 	 * default: RTE_HASH_RCU_DQ_RECLAIM_MAX.
115 	 */
116 	void *key_data_ptr;
117 	/**< Pointer passed to the free function. Typically, this is the
118 	 * pointer to the data structure to which the resource to free
119 	 * (key-data) belongs. This can be NULL.
120 	 */
121 	rte_hash_free_key_data free_key_data_func;
122 	/**< Function to call to free the resource (key-data). */
123 };
124 
125 /** @internal A hash table structure. */
126 struct rte_hash;
127 
128 /**
129  * Create a new hash table.
130  *
131  * @param params
132  *   Parameters used to create and initialise the hash table.
133  * @return
134  *   Pointer to hash table structure that is used in future hash table
135  *   operations, or NULL on error, with error code set in rte_errno.
136  *   Possible rte_errno errors include:
137  *    - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
138  *    - E_RTE_SECONDARY - function was called from a secondary process instance
139  *    - ENOENT - missing entry
140  *    - EINVAL - invalid parameter passed to function
141  *    - ENOSPC - the maximum number of memzones has already been allocated
142  *    - EEXIST - a memzone with the same name already exists
143  *    - ENOMEM - no appropriate memory area found in which to create memzone
144  */
145 struct rte_hash *
146 rte_hash_create(const struct rte_hash_parameters *params);
147 
148 /**
149  * Set a new hash compare function other than the default one.
150  *
151  * @note Function pointer does not work with multi-process, so do not use it
152  * in multi-process mode.
153  *
154  * @param h
155  *   Hash table for which the function is to be changed
156  * @param func
157  *   New compare function
158  */
159 void rte_hash_set_cmp_func(struct rte_hash *h, rte_hash_cmp_eq_t func);
160 
161 /**
162  * Find an existing hash table object and return a pointer to it.
163  *
164  * @param name
165  *   Name of the hash table as passed to rte_hash_create()
166  * @return
167  *   Pointer to hash table or NULL if object not found
168  *   with rte_errno set appropriately. Possible rte_errno values include:
169  *    - ENOENT - value not available for return
170  */
171 struct rte_hash *
172 rte_hash_find_existing(const char *name);
173 
174 /**
175  * De-allocate all memory used by hash table.
176  *
177  * @param h
178  *   Hash table to free, if NULL, the function does nothing.
179  */
180 void
181 rte_hash_free(struct rte_hash *h);
182 
183 /**
184  * Reset all hash structure, by zeroing all entries.
185  * When RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF is enabled,
186  * it is application's responsibility to make sure that
187  * none of the readers are referencing the hash table
188  * while calling this API.
189  *
190  * @param h
191  *   Hash table to reset
192  */
193 void
194 rte_hash_reset(struct rte_hash *h);
195 
196 /**
197  * Return the number of keys in the hash table
198  * @param h
199  *  Hash table to query from
200  * @return
201  *   - -EINVAL if parameters are invalid
202  *   - A value indicating how many keys were inserted in the table.
203  */
204 int32_t
205 rte_hash_count(const struct rte_hash *h);
206 
207 /**
208  * Return the maximum key value ID that could possibly be returned by
209  * rte_hash_add_key function.
210  *
211  * @param h
212  *  Hash table to query from
213  * @return
214  *   - -EINVAL if parameters are invalid
215  *   - A value indicating the max key ID of key slots present in the table.
216  */
217 int32_t
218 rte_hash_max_key_id(const struct rte_hash *h);
219 
220 /**
221  * Add a key-value pair to an existing hash table.
222  * This operation is not multi-thread safe
223  * and should only be called from one thread by default.
224  * Thread safety can be enabled by setting flag during
225  * table creation.
226  * If the key exists already in the table, this API updates its value
227  * with 'data' passed in this API. It is the responsibility of
228  * the application to manage any memory associated with the old value.
229  * The readers might still be using the old value even after this API
230  * has returned.
231  *
232  * @param h
233  *   Hash table to add the key to.
234  * @param key
235  *   Key to add to the hash table.
236  * @param data
237  *   Data to add to the hash table.
238  * @return
239  *   - 0 if added successfully
240  *   - -EINVAL if the parameters are invalid.
241  *   - -ENOSPC if there is no space in the hash for this key.
242  */
243 int
244 rte_hash_add_key_data(const struct rte_hash *h, const void *key, void *data);
245 
246 /**
247  * Add a key-value pair with a pre-computed hash value
248  * to an existing hash table.
249  * This operation is not multi-thread safe
250  * and should only be called from one thread by default.
251  * Thread safety can be enabled by setting flag during
252  * table creation.
253  * If the key exists already in the table, this API updates its value
254  * with 'data' passed in this API. It is the responsibility of
255  * the application to manage any memory associated with the old value.
256  * The readers might still be using the old value even after this API
257  * has returned.
258  *
259  * @param h
260  *   Hash table to add the key to.
261  * @param key
262  *   Key to add to the hash table.
263  * @param sig
264  *   Precomputed hash value for 'key'
265  * @param data
266  *   Data to add to the hash table.
267  * @return
268  *   - 0 if added successfully
269  *   - -EINVAL if the parameters are invalid.
270  *   - -ENOSPC if there is no space in the hash for this key.
271  */
272 int32_t
273 rte_hash_add_key_with_hash_data(const struct rte_hash *h, const void *key,
274 						hash_sig_t sig, void *data);
275 
276 /**
277  * Add a key to an existing hash table. This operation is not multi-thread safe
278  * and should only be called from one thread by default.
279  * Thread safety can be enabled by setting flag during
280  * table creation.
281  *
282  * @param h
283  *   Hash table to add the key to.
284  * @param key
285  *   Key to add to the hash table.
286  * @return
287  *   - -EINVAL if the parameters are invalid.
288  *   - -ENOSPC if there is no space in the hash for this key.
289  *   - A non-negative value that can be used by the caller as an offset into an
290  *     array of user data. This value is unique for this key. This
291  *     unique key id may be larger than the user specified entry count
292  *     when RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD flag is set.
293  */
294 int32_t
295 rte_hash_add_key(const struct rte_hash *h, const void *key);
296 
297 /**
298  * Add a key to an existing hash table.
299  * This operation is not multi-thread safe
300  * and should only be called from one thread by default.
301  * Thread safety can be enabled by setting flag during
302  * table creation.
303  *
304  * @param h
305  *   Hash table to add the key to.
306  * @param key
307  *   Key to add to the hash table.
308  * @param sig
309  *   Precomputed hash value for 'key'.
310  * @return
311  *   - -EINVAL if the parameters are invalid.
312  *   - -ENOSPC if there is no space in the hash for this key.
313  *   - A non-negative value that can be used by the caller as an offset into an
314  *     array of user data. This value is unique for this key. This
315  *     unique key ID may be larger than the user specified entry count
316  *     when RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD flag is set.
317  */
318 int32_t
319 rte_hash_add_key_with_hash(const struct rte_hash *h, const void *key, hash_sig_t sig);
320 
321 /**
322  * Remove a key from an existing hash table.
323  * This operation is not multi-thread safe
324  * and should only be called from one thread by default.
325  * Thread safety can be enabled by setting flag during
326  * table creation.
327  * If RTE_HASH_EXTRA_FLAGS_NO_FREE_ON_DEL or
328  * RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF is enabled and
329  * internal RCU is NOT enabled,
330  * the key index returned by rte_hash_add_key_xxx APIs will not be
331  * freed by this API. rte_hash_free_key_with_position API must be called
332  * additionally to free the index associated with the key.
333  * rte_hash_free_key_with_position API should be called after all
334  * the readers have stopped referencing the entry corresponding to
335  * this key. RCU mechanisms could be used to determine such a state.
336  *
337  * @param h
338  *   Hash table to remove the key from.
339  * @param key
340  *   Key to remove from the hash table.
341  * @return
342  *   - -EINVAL if the parameters are invalid.
343  *   - -ENOENT if the key is not found.
344  *   - A non-negative value that can be used by the caller as an offset into an
345  *     array of user data. This value is unique for this key, and is the same
346  *     value that was returned when the key was added.
347  */
348 int32_t
349 rte_hash_del_key(const struct rte_hash *h, const void *key);
350 
351 /**
352  * Remove a key from an existing hash table.
353  * This operation is not multi-thread safe
354  * and should only be called from one thread by default.
355  * Thread safety can be enabled by setting flag during
356  * table creation.
357  * If RTE_HASH_EXTRA_FLAGS_NO_FREE_ON_DEL or
358  * RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF is enabled and
359  * internal RCU is NOT enabled,
360  * the key index returned by rte_hash_add_key_xxx APIs will not be
361  * freed by this API. rte_hash_free_key_with_position API must be called
362  * additionally to free the index associated with the key.
363  * rte_hash_free_key_with_position API should be called after all
364  * the readers have stopped referencing the entry corresponding to
365  * this key. RCU mechanisms could be used to determine such a state.
366  *
367  * @param h
368  *   Hash table to remove the key from.
369  * @param key
370  *   Key to remove from the hash table.
371  * @param sig
372  *   Precomputed hash value for 'key'.
373  * @return
374  *   - -EINVAL if the parameters are invalid.
375  *   - -ENOENT if the key is not found.
376  *   - A non-negative value that can be used by the caller as an offset into an
377  *     array of user data. This value is unique for this key, and is the same
378  *     value that was returned when the key was added.
379  */
380 int32_t
381 rte_hash_del_key_with_hash(const struct rte_hash *h, const void *key, hash_sig_t sig);
382 
383 /**
384  * Find a key in the hash table given the position.
385  * This operation is multi-thread safe with regarding to other lookup threads.
386  * Read-write concurrency can be enabled by setting flag during
387  * table creation.
388  *
389  * @param h
390  *   Hash table to get the key from.
391  * @param position
392  *   Position returned when the key was inserted.
393  * @param key
394  *   Output containing a pointer to the key
395  * @return
396  *   - 0 if retrieved successfully
397  *   - -EINVAL if the parameters are invalid.
398  *   - -ENOENT if no valid key is found in the given position.
399  */
400 int
401 rte_hash_get_key_with_position(const struct rte_hash *h, const int32_t position,
402 			       void **key);
403 
404 /**
405  * Free a hash key in the hash table given the position
406  * of the key. This operation is not multi-thread safe and should
407  * only be called from one thread by default. Thread safety
408  * can be enabled by setting flag during table creation.
409  * If RTE_HASH_EXTRA_FLAGS_NO_FREE_ON_DEL or
410  * RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF is enabled and
411  * internal RCU is NOT enabled,
412  * the key index returned by rte_hash_del_key_xxx APIs must be freed
413  * using this API. This API should be called after all the readers
414  * have stopped referencing the entry corresponding to this key.
415  * RCU mechanisms could be used to determine such a state.
416  * This API does not validate if the key is already freed.
417  *
418  * @param h
419  *   Hash table to free the key from.
420  * @param position
421  *   Position returned when the key was deleted.
422  * @return
423  *   - 0 if freed successfully
424  *   - -EINVAL if the parameters are invalid.
425  */
426 int
427 rte_hash_free_key_with_position(const struct rte_hash *h,
428 				const int32_t position);
429 
430 /**
431  * Find a key-value pair in the hash table.
432  * This operation is multi-thread safe with regarding to other lookup threads.
433  * Read-write concurrency can be enabled by setting flag during
434  * table creation.
435  *
436  * @param h
437  *   Hash table to look in.
438  * @param key
439  *   Key to find.
440  * @param data
441  *   Output with pointer to data returned from the hash table.
442  * @return
443  *   - A non-negative value that can be used by the caller as an offset into an
444  *     array of user data. This value is unique for this key, and is the same
445  *     value that was returned when the key was added.
446  *   - -EINVAL if the parameters are invalid.
447  *   - -ENOENT if the key is not found.
448  */
449 int
450 rte_hash_lookup_data(const struct rte_hash *h, const void *key, void **data);
451 
452 /**
453  * Find a key-value pair with a pre-computed hash value
454  * to an existing hash table.
455  * This operation is multi-thread safe with regarding to other lookup threads.
456  * Read-write concurrency can be enabled by setting flag during
457  * table creation.
458  *
459  * @param h
460  *   Hash table to look in.
461  * @param key
462  *   Key to find.
463  * @param sig
464  *   Precomputed hash value for 'key'
465  * @param data
466  *   Output with pointer to data returned from the hash table.
467  * @return
468  *   - A non-negative value that can be used by the caller as an offset into an
469  *     array of user data. This value is unique for this key, and is the same
470  *     value that was returned when the key was added.
471  *   - -EINVAL if the parameters are invalid.
472  *   - -ENOENT if the key is not found.
473  */
474 int
475 rte_hash_lookup_with_hash_data(const struct rte_hash *h, const void *key,
476 					hash_sig_t sig, void **data);
477 
478 /**
479  * Find a key in the hash table.
480  * This operation is multi-thread safe with regarding to other lookup threads.
481  * Read-write concurrency can be enabled by setting flag during
482  * table creation.
483  *
484  * @param h
485  *   Hash table to look in.
486  * @param key
487  *   Key to find.
488  * @return
489  *   - -EINVAL if the parameters are invalid.
490  *   - -ENOENT if the key is not found.
491  *   - A non-negative value that can be used by the caller as an offset into an
492  *     array of user data. This value is unique for this key, and is the same
493  *     value that was returned when the key was added.
494  */
495 int32_t
496 rte_hash_lookup(const struct rte_hash *h, const void *key);
497 
498 /**
499  * Find a key in the hash table.
500  * This operation is multi-thread safe with regarding to other lookup threads.
501  * Read-write concurrency can be enabled by setting flag during
502  * table creation.
503  *
504  * @param h
505  *   Hash table to look in.
506  * @param key
507  *   Key to find.
508  * @param sig
509  *   Precomputed hash value for 'key'.
510  * @return
511  *   - -EINVAL if the parameters are invalid.
512  *   - -ENOENT if the key is not found.
513  *   - A non-negative value that can be used by the caller as an offset into an
514  *     array of user data. This value is unique for this key, and is the same
515  *     value that was returned when the key was added.
516  */
517 int32_t
518 rte_hash_lookup_with_hash(const struct rte_hash *h,
519 				const void *key, hash_sig_t sig);
520 
521 /**
522  * Calc a hash value by key.
523  * This operation is not multi-process safe.
524  *
525  * @param h
526  *   Hash table to look in.
527  * @param key
528  *   Key to find.
529  * @return
530  *   - hash value
531  */
532 hash_sig_t
533 rte_hash_hash(const struct rte_hash *h, const void *key);
534 
535 /**
536  * Find multiple keys in the hash table.
537  * This operation is multi-thread safe with regarding to other lookup threads.
538  * Read-write concurrency can be enabled by setting flag during
539  * table creation.
540  *
541  * @param h
542  *   Hash table to look in.
543  * @param keys
544  *   A pointer to a list of keys to look for.
545  * @param num_keys
546  *   How many keys are in the keys list (less than RTE_HASH_LOOKUP_BULK_MAX).
547  * @param hit_mask
548  *   Output containing a bitmask with all successful lookups.
549  * @param data
550  *   Output containing array of data returned from all the successful lookups.
551  * @return
552  *   -EINVAL if there's an error, otherwise number of successful lookups.
553  */
554 int
555 rte_hash_lookup_bulk_data(const struct rte_hash *h, const void **keys,
556 		      uint32_t num_keys, uint64_t *hit_mask, void *data[]);
557 
558 /**
559  * Find multiple keys in the hash table with precomputed hash value array.
560  * This operation is multi-thread safe with regarding to other lookup threads.
561  * Read-write concurrency can be enabled by setting flag during
562  * table creation.
563  *
564  * @param h
565  *   Hash table to look in.
566  * @param keys
567  *   A pointer to a list of keys to look for.
568  * @param sig
569  *   A pointer to a list of precomputed hash values for keys.
570  * @param num_keys
571  *   How many keys are in the keys list (less than RTE_HASH_LOOKUP_BULK_MAX).
572  * @param positions
573  *   Output containing a list of values, corresponding to the list of keys that
574  *   can be used by the caller as an offset into an array of user data. These
575  *   values are unique for each key, and are the same values that were returned
576  *   when each key was added. If a key in the list was not found, then -ENOENT
577  *   will be the value.
578  * @return
579  *   -EINVAL if there's an error, otherwise 0.
580  */
581 int
582 rte_hash_lookup_with_hash_bulk(const struct rte_hash *h, const void **keys,
583 		hash_sig_t *sig, uint32_t num_keys, int32_t *positions);
584 
585 /**
586  * Find multiple keys in the hash table with precomputed hash value array.
587  * This operation is multi-thread safe with regarding to other lookup threads.
588  * Read-write concurrency can be enabled by setting flag during
589  * table creation.
590  *
591  * @param h
592  *   Hash table to look in.
593  * @param keys
594  *   A pointer to a list of keys to look for.
595  * @param sig
596  *   A pointer to a list of precomputed hash values for keys.
597  * @param num_keys
598  *   How many keys are in the keys list (less than RTE_HASH_LOOKUP_BULK_MAX).
599  * @param hit_mask
600  *   Output containing a bitmask with all successful lookups.
601  * @param data
602  *   Output containing array of data returned from all the successful lookups.
603  * @return
604  *   -EINVAL if there's an error, otherwise number of successful lookups.
605  */
606 int
607 rte_hash_lookup_with_hash_bulk_data(const struct rte_hash *h,
608 		const void **keys, hash_sig_t *sig,
609 		uint32_t num_keys, uint64_t *hit_mask, void *data[]);
610 
611 /**
612  * Find multiple keys in the hash table.
613  * This operation is multi-thread safe with regarding to other lookup threads.
614  * Read-write concurrency can be enabled by setting flag during
615  * table creation.
616  *
617  * @param h
618  *   Hash table to look in.
619  * @param keys
620  *   A pointer to a list of keys to look for.
621  * @param num_keys
622  *   How many keys are in the keys list (less than RTE_HASH_LOOKUP_BULK_MAX).
623  * @param positions
624  *   Output containing a list of values, corresponding to the list of keys that
625  *   can be used by the caller as an offset into an array of user data. These
626  *   values are unique for each key, and are the same values that were returned
627  *   when each key was added. If a key in the list was not found, then -ENOENT
628  *   will be the value.
629  * @return
630  *   -EINVAL if there's an error, otherwise 0.
631  */
632 int
633 rte_hash_lookup_bulk(const struct rte_hash *h, const void **keys,
634 		      uint32_t num_keys, int32_t *positions);
635 
636 /**
637  * Iterate through the hash table, returning key-value pairs.
638  *
639  * @param h
640  *   Hash table to iterate
641  * @param key
642  *   Output containing the key where current iterator
643  *   was pointing at
644  * @param data
645  *   Output containing the data associated with key.
646  *   Returns NULL if data was not stored.
647  * @param next
648  *   Pointer to iterator. Should be 0 to start iterating the hash table.
649  *   Iterator is incremented after each call of this function.
650  * @return
651  *   Position where key was stored, if successful.
652  *   - -EINVAL if the parameters are invalid.
653  *   - -ENOENT if end of the hash table.
654  */
655 int32_t
656 rte_hash_iterate(const struct rte_hash *h, const void **key, void **data, uint32_t *next);
657 
658 /**
659  * Associate RCU QSBR variable with a Hash object.
660  * This API should be called to enable the integrated RCU QSBR support and
661  * should be called immediately after creating the Hash object.
662  *
663  * @param h
664  *   the hash object to add RCU QSBR
665  * @param cfg
666  *   RCU QSBR configuration
667  * @return
668  *   On success - 0
669  *   On error - 1 with error code set in rte_errno.
670  *   Possible rte_errno codes are:
671  *   - EINVAL - invalid pointer
672  *   - EEXIST - already added QSBR
673  *   - ENOMEM - memory allocation failure
674  */
675 int rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg);
676 
677 /**
678  * Reclaim resources from the defer queue.
679  * This API reclaim the resources from the defer queue if rcu is enabled.
680  *
681  * @param h
682  *   The hash object to reclaim resources.
683  * @param freed
684  *   Number of resources that were freed.
685  * @param pending
686  *   Number of resources pending on the defer queue.
687  *   This number might not be accurate if multi-thread safety is configured.
688  * @param available
689  *   Number of resources that can be added to the defer queue.
690  *   This number might not be accurate if multi-thread safety is configured.
691  * @return
692  *   On success - 0
693  *   On error - 1 with error code set in rte_errno.
694  *   Possible rte_errno codes are:
695  *   - EINVAL - invalid pointer
696  */
697 __rte_experimental
698 int rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h, unsigned int *freed,
699 		unsigned int *pending, unsigned int *available);
700 
701 #ifdef __cplusplus
702 }
703 #endif
704 
705 #endif /* _RTE_HASH_H_ */
706