X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_hash%2Frte_hash.c;h=924571614ef96e5160fee295a440479af4c2cf7c;hb=66e1591687ac;hp=d02b6b4faf32b48b1fdada46b674cafbd360f761;hpb=4542f8939779d7acbbdebbf45e32e5df291eec6d;p=dpdk.git diff --git a/lib/librte_hash/rte_hash.c b/lib/librte_hash/rte_hash.c index d02b6b4faf..924571614e 100644 --- a/lib/librte_hash/rte_hash.c +++ b/lib/librte_hash/rte_hash.c @@ -39,14 +39,13 @@ #include #include -#include /* for definition of CACHE_LINE_SIZE */ +#include /* for definition of RTE_CACHE_LINE_SIZE */ #include #include #include #include #include #include -#include #include #include #include @@ -59,9 +58,13 @@ #include "rte_hash.h" - TAILQ_HEAD(rte_hash_list, rte_tailq_entry); +static struct rte_tailq_elem rte_hash_tailq = { + .name = "RTE_HASH", +}; +EAL_REGISTER_TAILQ(rte_hash_tailq) + /* Macro to enable/disable run-time checking of function parameters */ #if defined(RTE_LIBRTE_HASH_DEBUG) #define RETURN_IF_TRUE(cond, retval) do { \ @@ -145,12 +148,7 @@ rte_hash_find_existing(const char *name) struct rte_tailq_entry *te; struct rte_hash_list *hash_list; - /* check that we have an initialised tail queue */ - if ((hash_list = - RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_HASH, rte_hash_list)) == NULL) { - rte_errno = E_RTE_NO_TAILQ; - return NULL; - } + hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list); rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK); TAILQ_FOREACH(te, hash_list, next) { @@ -177,12 +175,7 @@ rte_hash_create(const struct rte_hash_parameters *params) char hash_name[RTE_HASH_NAMESIZE]; struct rte_hash_list *hash_list; - /* check that we have an initialised tail queue */ - if ((hash_list = - RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_HASH, rte_hash_list)) == NULL) { - rte_errno = E_RTE_NO_TAILQ; - return NULL; - } + hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list); /* Check for valid parameters */ if ((params == NULL) || @@ -206,11 +199,11 @@ rte_hash_create(const struct rte_hash_parameters *params) sizeof(hash_sig_t), SIG_BUCKET_ALIGNMENT); key_size = align_size(params->key_len, KEY_ALIGNMENT); - hash_tbl_size = align_size(sizeof(struct rte_hash), CACHE_LINE_SIZE); + hash_tbl_size = align_size(sizeof(struct rte_hash), RTE_CACHE_LINE_SIZE); sig_tbl_size = align_size(num_buckets * sig_bucket_size, - CACHE_LINE_SIZE); + RTE_CACHE_LINE_SIZE); key_tbl_size = align_size(num_buckets * key_size * - params->bucket_entries, CACHE_LINE_SIZE); + params->bucket_entries, RTE_CACHE_LINE_SIZE); /* Total memory required for hash context */ mem_size = hash_tbl_size + sig_tbl_size + key_tbl_size; @@ -233,7 +226,7 @@ rte_hash_create(const struct rte_hash_parameters *params) } h = (struct rte_hash *)rte_zmalloc_socket(hash_name, mem_size, - CACHE_LINE_SIZE, params->socket_id); + RTE_CACHE_LINE_SIZE, params->socket_id); if (h == NULL) { RTE_LOG(ERR, HASH, "memory allocation failed\n"); rte_free(te); @@ -275,12 +268,7 @@ rte_hash_free(struct rte_hash *h) if (h == NULL) return; - /* check that we have an initialised tail queue */ - if ((hash_list = - RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_HASH, rte_hash_list)) == NULL) { - rte_errno = E_RTE_NO_TAILQ; - return; - } + hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list); rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);