git.droids-corp.org
/
dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
mempool: add structure for object trailers
[dpdk.git]
/
lib
/
librte_lpm
/
rte_lpm.c
diff --git
a/lib/librte_lpm/rte_lpm.c
b/lib/librte_lpm/rte_lpm.c
index
983e04b
..
0c87a29
100644
(file)
--- a/
lib/librte_lpm/rte_lpm.c
+++ b/
lib/librte_lpm/rte_lpm.c
@@
-45,7
+45,6
@@
#include <rte_memory.h> /* for definition of RTE_CACHE_LINE_SIZE */
#include <rte_malloc.h>
#include <rte_memzone.h>
#include <rte_memory.h> /* for definition of RTE_CACHE_LINE_SIZE */
#include <rte_malloc.h>
#include <rte_memzone.h>
-#include <rte_tailq.h>
#include <rte_eal.h>
#include <rte_eal_memconfig.h>
#include <rte_per_lcore.h>
#include <rte_eal.h>
#include <rte_eal_memconfig.h>
#include <rte_per_lcore.h>
@@
-58,6
+57,11
@@
TAILQ_HEAD(rte_lpm_list, rte_tailq_entry);
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 {
#define MAX_DEPTH_TBL24 24
enum valid_flag {
@@
-122,12
+126,7
@@
rte_lpm_find_existing(const char *name)
struct rte_tailq_entry *te;
struct rte_lpm_list *lpm_list;
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) {
rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
TAILQ_FOREACH(te, lpm_list, next) {
@@
-158,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;
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);
RTE_BUILD_BUG_ON(sizeof(struct rte_lpm_tbl24_entry) != 2);
RTE_BUILD_BUG_ON(sizeof(struct rte_lpm_tbl8_entry) != 2);
@@
-233,12
+227,7
@@
rte_lpm_free(struct rte_lpm *lpm)
if (lpm == NULL)
return;
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);
rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
@@
-298,6
+287,9
@@
rule_add(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth,
return rule_index;
}
}
return rule_index;
}
}
+
+ if (rule_index == lpm->max_rules)
+ return -ENOSPC;
} else {
/* Calculate the position in which the rule will be stored. */
rule_index = 0;
} else {
/* Calculate the position in which the rule will be stored. */
rule_index = 0;
@@
-382,8
+374,8
@@
rule_find(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth)
return (rule_index);
}
return (rule_index);
}
- /* If rule is not found return -E
_RTE_NO_TAILQ
. */
- return -E
_RTE_NO_TAILQ
;
+ /* If rule is not found return -E
INVAL
. */
+ return -E
INVAL
;
}
/*
}
/*
@@
-967,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
/*
* 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 -E
INVAL
.
*/
if (rule_to_delete_index < 0)
*/
if (rule_to_delete_index < 0)
- return -E
_RTE_NO_TAILQ
;
+ return -E
INVAL
;
/* Delete the rule from the rule table. */
rule_delete(lpm, rule_to_delete_index, depth);
/* Delete the rule from the rule table. */
rule_delete(lpm, rule_to_delete_index, depth);
@@
-1014,4
+1006,3
@@
rte_lpm_delete_all(struct rte_lpm *lpm)
/* Delete all rules form the rules table. */
memset(lpm->rules_tbl, 0, sizeof(lpm->rules_tbl[0]) * lpm->max_rules);
}
/* Delete all rules form the rules table. */
memset(lpm->rules_tbl, 0, sizeof(lpm->rules_tbl[0]) * lpm->max_rules);
}
-