hash: fix scaling by reducing contention
[dpdk.git] / lib / librte_hash / rte_hash.h
index ff75445..b678766 100644 (file)
@@ -49,12 +49,6 @@ extern "C" {
 /** Maximum size of hash table that can be created. */
 #define RTE_HASH_ENTRIES_MAX                   (1 << 30)
 
-/** @deprecated Maximum bucket size that can be created. */
-#define RTE_HASH_BUCKET_ENTRIES_MAX            4
-
-/** @deprecated Maximum length of key that can be used. */
-#define RTE_HASH_KEY_LENGTH_MAX                        64
-
 /** Maximum number of characters in hash name.*/
 #define RTE_HASH_NAMESIZE                      32
 
@@ -62,6 +56,9 @@ extern "C" {
 #define RTE_HASH_LOOKUP_BULK_MAX               64
 #define RTE_HASH_LOOKUP_MULTI_MAX              RTE_HASH_LOOKUP_BULK_MAX
 
+/** Enable Hardware transactional memory support. */
+#define RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT 0x01
+
 /** Signature of key that is stored internally. */
 typedef uint32_t hash_sig_t;
 
@@ -75,7 +72,7 @@ typedef uint32_t (*rte_hash_function)(const void *key, uint32_t key_len,
 struct rte_hash_parameters {
        const char *name;               /**< Name of the hash. */
        uint32_t entries;               /**< Total hash table entries. */
-       uint32_t bucket_entries;        /**< Bucket entries. */
+       uint32_t reserved;              /**< Unused field. Should be set to 0 */
        uint32_t key_len;               /**< Length of hash key. */
        rte_hash_function hash_func;    /**< Primary Hash function used to calculate hash. */
        uint32_t hash_func_init_val;    /**< Init value used by hash_func. */
@@ -393,6 +390,28 @@ rte_hash_lookup_bulk_data(const struct rte_hash *h, const void **keys,
 int
 rte_hash_lookup_bulk(const struct rte_hash *h, const void **keys,
                      uint32_t num_keys, int32_t *positions);
+
+/**
+ * Iterate through the hash table, returning key-value pairs.
+ *
+ * @param h
+ *   Hash table to iterate
+ * @param key
+ *   Output containing the key where current iterator
+ *   was pointing at
+ * @param data
+ *   Output containing the data associated with key.
+ *   Returns NULL if data was not stored.
+ * @param next
+ *   Pointer to iterator. Should be 0 to start iterating the hash table.
+ *   Iterator is incremented after each call of this function.
+ * @return
+ *   Position where key was stored, if successful.
+ *   - -EINVAL if the parameters are invalid.
+ *   - -ENOENT if end of the hash table.
+ */
+int32_t
+rte_hash_iterate(const struct rte_hash *h, const void **key, void **data, uint32_t *next);
 #ifdef __cplusplus
 }
 #endif