X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_efd%2Frte_efd.c;h=4deeb17924f102318e477b0a7e553817ba130588;hb=6c45dff00aa65080bcfb161fc0f58e44f211cd11;hp=e6e5cfda22ed6e700a53219e1525adb69a481a8f;hpb=f493119397d0f5dbe33f67697ff09aa646e5f17c;p=dpdk.git diff --git a/lib/librte_efd/rte_efd.c b/lib/librte_efd/rte_efd.c index e6e5cfda22..4deeb17924 100644 --- a/lib/librte_efd/rte_efd.c +++ b/lib/librte_efd/rte_efd.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -19,6 +20,7 @@ #include #include #include +#include #include "rte_efd.h" #if defined(RTE_ARCH_X86) @@ -179,7 +181,7 @@ struct efd_offline_group_rules { /**< Array with all values of the keys of the group. */ uint8_t bin_id[EFD_MAX_GROUP_NUM_RULES]; - /**< Stores the bin for each correspending key to + /**< Stores the bin for each corresponding key to * avoid having to recompute it */ }; @@ -531,7 +533,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, num_chunks_shift = rte_bsf32(num_chunks); - rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK); + rte_mcfg_tailq_write_lock(); /* * Guarantee there's no existing: this is normally already checked @@ -591,7 +593,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, goto error_unlock_exit; } table->keys = key_array; - snprintf(table->name, sizeof(table->name), "%s", name); + strlcpy(table->name, name, sizeof(table->name)); RTE_LOG(DEBUG, EFD, "Creating an EFD table with %u chunks," " which potentially supports %u entries\n", @@ -684,7 +686,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, te->data = (void *) table; TAILQ_INSERT_TAIL(efd_list, te, next); - rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK); + rte_mcfg_tailq_write_unlock(); snprintf(ring_name, sizeof(ring_name), "HT_%s", table->name); /* Create ring (Dummy slot index is not enqueued) */ @@ -704,7 +706,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, return table; error_unlock_exit: - rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK); + rte_mcfg_tailq_write_unlock(); rte_efd_free(table); return NULL; @@ -719,7 +721,7 @@ rte_efd_find_existing(const char *name) efd_list = RTE_TAILQ_CAST(rte_efd_tailq.head, rte_efd_list); - rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK); + rte_mcfg_tailq_read_lock(); TAILQ_FOREACH(te, efd_list, next) { @@ -727,7 +729,7 @@ rte_efd_find_existing(const char *name) if (strncmp(name, table->name, RTE_EFD_NAMESIZE) == 0) break; } - rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK); + rte_mcfg_tailq_read_unlock(); if (te == NULL) { rte_errno = ENOENT; @@ -740,6 +742,8 @@ void rte_efd_free(struct rte_efd_table *table) { uint8_t socket_id; + struct rte_efd_list *efd_list; + struct rte_tailq_entry *te, *temp; if (table == NULL) return; @@ -747,6 +751,18 @@ rte_efd_free(struct rte_efd_table *table) for (socket_id = 0; socket_id < RTE_MAX_NUMA_NODES; socket_id++) rte_free(table->chunks[socket_id]); + efd_list = RTE_TAILQ_CAST(rte_efd_tailq.head, rte_efd_list); + rte_mcfg_tailq_write_lock(); + + TAILQ_FOREACH_SAFE(te, efd_list, next, temp) { + if (te->data == (void *) table) { + TAILQ_REMOVE(efd_list, te, next); + rte_free(te); + break; + } + } + + rte_mcfg_tailq_write_unlock(); rte_ring_free(table->free_slots); rte_free(table->offline_chunks); rte_free(table->keys);