net/octeontx: support fast mbuf free
[dpdk.git] / lib / librte_hash / rte_cuckoo_hash.c
index 6c292b6..6af8ca4 100644 (file)
@@ -506,6 +506,21 @@ rte_hash_hash(const struct rte_hash *h, const void *key)
        return h->hash_func(key, h->key_len, h->hash_func_init_val);
 }
 
+int32_t
+rte_hash_max_key_id(const struct rte_hash *h)
+{
+       RETURN_IF_TRUE((h == NULL), -EINVAL);
+       if (h->use_local_cache)
+               /*
+                * Increase number of slots by total number of indices
+                * that can be stored in the lcore caches
+                */
+               return (h->entries + ((RTE_MAX_LCORE - 1) *
+                                       (LCORE_CACHE_SIZE - 1)));
+       else
+               return h->entries;
+}
+
 int32_t
 rte_hash_count(const struct rte_hash *h)
 {
@@ -1286,10 +1301,8 @@ __rte_hash_lookup_with_hash_lf(const struct rte_hash *h, const void *key,
                /* Check if key is in primary location */
                bkt = &h->buckets[prim_bucket_idx];
                ret = search_one_bucket_lf(h, key, short_sig, data, bkt);
-               if (ret != -1) {
-                       __hash_rw_reader_unlock(h);
+               if (ret != -1)
                        return ret;
-               }
                /* Calculate secondary hash */
                bkt = &h->buckets[sec_bucket_idx];
 
@@ -1297,10 +1310,8 @@ __rte_hash_lookup_with_hash_lf(const struct rte_hash *h, const void *key,
                FOR_EACH_BUCKET(cur_bkt, bkt) {
                        ret = search_one_bucket_lf(h, key, short_sig,
                                                data, cur_bkt);
-                       if (ret != -1) {
-                               __hash_rw_reader_unlock(h);
+                       if (ret != -1)
                                return ret;
-                       }
                }
 
                /* The loads of sig_current in search_one_bucket