vdpa/mlx5: default polling mode delay time to zero
[dpdk.git] / lib / librte_hash / rte_cuckoo_hash.h
index ff95181..85be49d 100644 (file)
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2016 Intel Corporation
+ * Copyright(c) 2018 Arm Limited
  */
 
 /* rte_cuckoo_hash.h
 #define RETURN_IF_TRUE(cond, retval)
 #endif
 
+#if defined(RTE_LIBRTE_HASH_DEBUG)
+#define ERR_IF_TRUE(cond, fmt, args...) do { \
+       if (cond) { \
+               RTE_LOG(ERR, HASH, fmt, ##args); \
+               return; \
+       } \
+} while (0)
+#else
+#define ERR_IF_TRUE(cond, fmt, args...)
+#endif
+
 #include <rte_hash_crc.h>
 #include <rte_jhash.h>
 
@@ -112,7 +124,7 @@ const rte_hash_cmp_eq_t cmp_jump_table[NUM_KEY_CMP_CASES] = {
 
 struct lcore_cache {
        unsigned len; /**< Cache len */
-       void *objs[LCORE_CACHE_SIZE]; /**< Cache objects */
+       uint32_t objs[LCORE_CACHE_SIZE]; /**< Cache objects */
 } __rte_cache_aligned;
 
 /* Structure that stores key-value pair */
@@ -123,12 +135,13 @@ struct rte_hash_key {
        };
        /* Variable key size */
        char key[0];
-} __attribute__((aligned(KEY_ALIGNMENT)));
+};
 
 /* All different signature compare functions */
 enum rte_hash_sig_compare_function {
        RTE_HASH_COMPARE_SCALAR = 0,
        RTE_HASH_COMPARE_SSE,
+       RTE_HASH_COMPARE_NEON,
        RTE_HASH_COMPARE_NUM
 };
 
@@ -155,6 +168,11 @@ struct rte_hash {
        struct lcore_cache *local_free_slots;
        /**< Local cache per lcore, storing some indexes of the free slots */
 
+       /* RCU config */
+       struct rte_hash_rcu_config *hash_rcu_cfg;
+       /**< HASH RCU QSBR configuration structure */
+       struct rte_rcu_qsbr_dq *dq;     /**< RCU QSBR defer queue. */
+
        /* Fields used in lookup */
 
        uint32_t key_len __rte_cache_aligned;
@@ -174,6 +192,8 @@ struct rte_hash {
         * free the key index associated with the deleted entry.
         * This flag is enabled by default.
         */
+       uint8_t readwrite_concur_lf_support;
+       /**< If read-write concurrency lock free support is enabled */
        uint8_t writer_takes_lock;
        /**< Indicates if the writer threads need to take lock */
        rte_hash_function hash_func;    /**< Function used to calculate hash. */
@@ -196,6 +216,15 @@ struct rte_hash {
        rte_rwlock_t *readwrite_lock; /**< Read-write lock thread-safety. */
        struct rte_hash_bucket *buckets_ext; /**< Extra buckets array */
        struct rte_ring *free_ext_bkts; /**< Ring of indexes of free buckets */
+       /* Stores index of an empty ext bkt to be recycled on calling
+        * rte_hash_del_xxx APIs. When lock free read-write concurrency is
+        * enabled, an empty ext bkt cannot be put into free list immediately
+        * (as readers might be using it still). Hence freeing of the ext bkt
+        * is piggy-backed to freeing of the key index.
+        */
+       uint32_t *ext_bkt_to_free;
+       uint32_t *tbl_chng_cnt;
+       /**< Indicates if the hash table changed from last read. */
 } __rte_cache_aligned;
 
 struct queue_node {
@@ -206,4 +235,7 @@ struct queue_node {
        int prev_slot;               /* Parent(slot) in search path */
 };
 
+/** @internal Default RCU defer queue entries to reclaim in one go. */
+#define RTE_HASH_RCU_DQ_RECLAIM_MAX    16
+
 #endif