[dpdk-dev] [RFC] rte_hash: introduce hash list into hash lib
Stephen Hemminger
stephen at networkplumber.org
Wed Aug 28 13:53:47 CEST 2019
On Wed, 28 Aug 2019 14:51:49 +0800
Bing Zhao <bingz at mellanox.com> wrote:
> +
> +/** Node element structure on the LIST of the link */
> +struct rte_hlist_node_entry {
> + LIST_ENTRY(rte_hlist_node_entry) next; /**< Next element pointer. */
> + /**< Data element inside this noed. */
> + struct rte_hlist_data_element d;
> + char key[]; /**< Copied and stored key. */
> +};
> +
> +/** Head of all the nodes with the same hash value */
> +struct rte_hlist_head_entry {
> + LIST_HEAD(, rte_hlist_node_entry) head; /**< Head for each hash list. */
> + /**< Current items in the list. */
> + uint16_t entries_in_bucket;
> + /**< Shift number for extension */
> + uint16_t bucket_shift;
> +};
> +
> +/** The hlist table structure. */
> +struct rte_hlist_table {
> + char name[RTE_HLIST_NAMESIZE]; /**< Name of the hash. */
> + uint32_t entries; /**< Total number of entries. */
> + uint32_t entries_per_bucket; /**< Number of entries in a list. */
> + /**< Number of entries with data from customer. */
> + uint32_t custom_entries;
> + uint16_t key_len; /**< Length of the key. */
> + /**< Shift number of the whole table. */
> + uint16_t bucket_shift;
> + /**< To find which list the key is in. */
> + uint32_t bucket_mask;
> + rte_hlist_calc_fn hash_func; /**< The hash function to calcuate. */
> + /**< The function to free the custom data. */
> + rte_hlist_free_fn free_func;
> + uint32_t init_val; /**< For initializing hash function. */
> + /**< Reserved for fast shrinking of the table. */
> + char *map;
You probably should use void * for that.
> + /**< A flat and extendible table of all lists. */
> + struct rte_hlist_head_entry *t;
> +};
> +
Since API/ABI considerations are important.
You will save yourself a lot of pain if these structures can be made
private and only part of rte_hlist.c.
More information about the dev
mailing list