X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=sidebyside;f=lib%2Flibrte_lpm%2Frte_lpm.c;h=0945b8103c262f73983d13f7cc030bd8e8761273;hb=a2348166ea186506d45b61d5073d16ad974e79bb;hp=264cde8f2593e99d7d34ddeeab67263a89cd8113;hpb=873a61c7526be06f45d8d709a7c56d10cc06ab34;p=dpdk.git diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c index 264cde8f25..0945b8103c 100644 --- a/lib/librte_lpm/rte_lpm.c +++ b/lib/librte_lpm/rte_lpm.c @@ -57,6 +57,11 @@ TAILQ_HEAD(rte_lpm_list, rte_tailq_entry); +static struct rte_tailq_elem rte_lpm_tailq = { + .name = "RTE_LPM", +}; +EAL_REGISTER_TAILQ(rte_lpm_tailq) + #define MAX_DEPTH_TBL24 24 enum valid_flag { @@ -121,12 +126,7 @@ rte_lpm_find_existing(const char *name) struct rte_tailq_entry *te; struct rte_lpm_list *lpm_list; - /* check that we have an initialised tail queue */ - if ((lpm_list = RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_LPM, - rte_lpm_list)) == NULL) { - rte_errno = E_RTE_NO_TAILQ; - return NULL; - } + lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list); rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK); TAILQ_FOREACH(te, lpm_list, next) { @@ -157,12 +157,7 @@ rte_lpm_create(const char *name, int socket_id, int max_rules, uint32_t mem_size; struct rte_lpm_list *lpm_list; - /* check that we have an initialised tail queue */ - if ((lpm_list = RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_LPM, - rte_lpm_list)) == NULL) { - rte_errno = E_RTE_NO_TAILQ; - return NULL; - } + lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list); RTE_BUILD_BUG_ON(sizeof(struct rte_lpm_tbl24_entry) != 2); RTE_BUILD_BUG_ON(sizeof(struct rte_lpm_tbl8_entry) != 2); @@ -232,12 +227,7 @@ rte_lpm_free(struct rte_lpm *lpm) if (lpm == NULL) return; - /* check that we have an initialised tail queue */ - if ((lpm_list = - RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_LPM, rte_lpm_list)) == NULL) { - rte_errno = E_RTE_NO_TAILQ; - return; - } + lpm_list = RTE_TAILQ_CAST(rte_lpm_tailq.head, rte_lpm_list); rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK); @@ -384,8 +374,8 @@ rule_find(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth) return (rule_index); } - /* If rule is not found return -E_RTE_NO_TAILQ. */ - return -E_RTE_NO_TAILQ; + /* If rule is not found return -EINVAL. */ + return -EINVAL; } /* @@ -969,10 +959,10 @@ rte_lpm_delete(struct rte_lpm *lpm, uint32_t ip, uint8_t depth) /* * Check if rule_to_delete_index was found. If no rule was found the - * function rule_find returns -E_RTE_NO_TAILQ. + * function rule_find returns -EINVAL. */ if (rule_to_delete_index < 0) - return -E_RTE_NO_TAILQ; + return -EINVAL; /* Delete the rule from the rule table. */ rule_delete(lpm, rule_to_delete_index, depth);