average_keys_added += added_keys;
/* Reset the table */
- rte_hash_free(handle);
- handle = rte_hash_create(&ut_params);
- RETURN_IF_ERROR(handle == NULL, "hash creation failed");
+ rte_hash_reset(handle);
/* Print a dot to show progress on operations */
printf(".");
rte_hash_free(h[table_index]);
}
-static int
+static void
reset_table(unsigned table_index)
{
- free_table(table_index);
- if (create_table(table_index) != 0)
- return -1;
-
- return 0;
+ rte_hash_reset(h[table_index]);
}
static int
if (timed_deletes(with_hash, i) < 0)
return -1;
- if (reset_table(i) < 0)
- return -1;
+ reset_table(i);
/* Print a dot to show progress on operations */
printf(".");
fflush(stdout);
-
}
free_table(i);
return (primary_hash ^ ((tag + 1) * alt_bits_xor));
}
+void
+rte_hash_reset(struct rte_hash *h)
+{
+ void *ptr;
+ unsigned i;
+
+ if (h == NULL)
+ return;
+
+ memset(h->buckets, 0, h->num_buckets * sizeof(struct rte_hash_bucket));
+ memset(h->key_store, 0, h->key_entry_size * (h->entries + 1));
+
+ /* clear the free ring */
+ while (rte_ring_dequeue(h->free_slots, &ptr) == 0)
+ rte_pause();
+
+ /* Repopulate the free slots ring. Entry zero is reserved for key misses */
+ for (i = 1; i < h->entries + 1; i++)
+ rte_ring_sp_enqueue(h->free_slots, (void *)((uintptr_t) i));
+}
+
/* Search for an entry that can be pushed to its alternative location */
static inline int
make_space_bucket(const struct rte_hash *h, struct rte_hash_bucket *bkt)
rte_hash_free(struct rte_hash *h);
/**
- * Add a key to an existing hash table.
- * This operation is not multi-thread safe
+ * Reset all hash structure, by zeroing all entries
+ * @param h
+ * Hash table to reset
+ */
+void
+rte_hash_reset(struct rte_hash *h);
+
+/**
+ * Add a key to an existing hash table. This operation is not multi-thread safe
* and should only be called from one thread.
*
* @param h
local: *;
};
+
+DPDK_2.1 {
+ global:
+
+ rte_hash_reset;
+
+} DPDK_2.0;