#define PASS 0
/*
- * TEST 0
- *
* Check that rte_lpm_create fails gracefully for incorrect user input
* arguments
*/
struct rte_lpm *lpm = NULL;
/* rte_lpm_create: lpm name == NULL */
- lpm = rte_lpm_create(NULL, SOCKET_ID_ANY, MAX_RULES, RTE_LPM_HEAP);
+ lpm = rte_lpm_create(NULL, SOCKET_ID_ANY, MAX_RULES, 0);
TEST_LPM_ASSERT(lpm == NULL);
/* rte_lpm_create: max_rules = 0 */
/* Note: __func__ inserts the function name, in this case "test0". */
- lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, 0, RTE_LPM_HEAP);
- TEST_LPM_ASSERT(lpm == NULL);
-
- /* rte_lpm_create: mem_location is not RTE_LPM_HEAP or not MEMZONE */
- /* Note: __func__ inserts the function name, in this case "test0". */
- lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, MAX_RULES, 2);
- TEST_LPM_ASSERT(lpm == NULL);
-
- lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, MAX_RULES, -1);
+ lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, 0, 0);
TEST_LPM_ASSERT(lpm == NULL);
/* socket_id < -1 is invalid */
- lpm = rte_lpm_create(__func__, -2, MAX_RULES, RTE_LPM_HEAP);
+ lpm = rte_lpm_create(__func__, -2, MAX_RULES, 0);
TEST_LPM_ASSERT(lpm == NULL);
return PASS;
}
-/* TEST 1
- *
+/*
* Create lpm table then delete lpm table 100 times
* Use a slightly different rules size each time
* */
/* rte_lpm_free: Free NULL */
for (i = 0; i < 100; i++) {
- lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, MAX_RULES - i,
- RTE_LPM_HEAP);
+ lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, MAX_RULES - i, 0);
TEST_LPM_ASSERT(lpm != NULL);
rte_lpm_free(lpm);
return PASS;
}
-/* TEST 2
- *
+/*
* Call rte_lpm_free for NULL pointer user input. Note: free has no return and
* therefore it is impossible to check for failure but this test is added to
* increase function coverage metrics and to validate that freeing null does
return PASS;
}
-/* TEST 3
- *
+/*
* Check that rte_lpm_add fails gracefully for incorrect user input arguments
*/
int32_t
TEST_LPM_ASSERT(status < 0);
/*Create vaild lpm to use in rest of test. */
- lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, MAX_RULES, RTE_LPM_HEAP);
+ lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, MAX_RULES, 0);
TEST_LPM_ASSERT(lpm != NULL);
/* rte_lpm_add: depth < 1 */
return PASS;
}
-/* TEST 4
- *
+/*
* Check that rte_lpm_delete fails gracefully for incorrect user input
* arguments
*/
TEST_LPM_ASSERT(status < 0);
/*Create vaild lpm to use in rest of test. */
- lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, MAX_RULES, RTE_LPM_HEAP);
+ lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, MAX_RULES, 0);
TEST_LPM_ASSERT(lpm != NULL);
/* rte_lpm_delete: depth < 1 */
return PASS;
}
-/* TEST 5
- *
+/*
* Check that rte_lpm_lookup fails gracefully for incorrect user input
* arguments
*/
TEST_LPM_ASSERT(status < 0);
/*Create vaild lpm to use in rest of test. */
- lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, MAX_RULES, RTE_LPM_HEAP);
+ lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, MAX_RULES, 0);
TEST_LPM_ASSERT(lpm != NULL);
/* rte_lpm_lookup: depth < 1 */
-/* TEST 6
- *
+/*
* Call add, lookup and delete for a single rule with depth <= 24
*/
int32_t
uint8_t depth = 24, next_hop_add = 100, next_hop_return = 0;
int32_t status = 0;
- lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, MAX_RULES, RTE_LPM_HEAP);
+ lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, MAX_RULES, 0);
TEST_LPM_ASSERT(lpm != NULL);
status = rte_lpm_add(lpm, ip, depth, next_hop_add);
return PASS;
}
-/* TEST 7
- *
+/*
* Call add, lookup and delete for a single rule with depth > 24
*/
uint8_t depth = 32, next_hop_add = 100, next_hop_return = 0;
int32_t status = 0;
- lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, MAX_RULES, RTE_LPM_HEAP);
+ lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, MAX_RULES, 0);
TEST_LPM_ASSERT(lpm != NULL);
status = rte_lpm_add(lpm, ip, depth, next_hop_add);
return PASS;
}
-/* TEST 8
- *
+/*
* Use rte_lpm_add to add rules which effect only the second half of the lpm
* table. Use all possible depths ranging from 1..32. Set the next hop = to the
* depth. Check lookup hit for on every add and check for lookup miss on the
uint8_t depth, next_hop_add, next_hop_return;
int32_t status = 0;
- lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, MAX_RULES, RTE_LPM_HEAP);
+ lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, MAX_RULES, 0);
TEST_LPM_ASSERT(lpm != NULL);
/* Loop with rte_lpm_add. */
return PASS;
}
-/* TEST 9
- *
+/*
* - Add & lookup to hit invalid TBL24 entry
* - Add & lookup to hit valid TBL24 entry not extended
* - Add & lookup to hit valid extended TBL24 entry with invalid TBL8 entry
depth = 24;
next_hop_add = 100;
- lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, MAX_RULES, RTE_LPM_HEAP);
+ lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, MAX_RULES, 0);
TEST_LPM_ASSERT(lpm != NULL);
status = rte_lpm_add(lpm, ip, depth, next_hop_add);
}
-/* TEST 10
- *
+/*
* - Add rule that covers a TBL24 range previously invalid & lookup (& delete &
* lookup)
* - Add rule that extends a TBL24 invalid entry & lookup (& delete & lookup)
return PASS;
}
-/* TEST 11
- *
+/*
* Add two rules, lookup to hit the more specific one, lookup to hit the less
* specific one delete the less specific rule and lookup previous values again;
* add a more specific rule than the existing rule, lookup again
uint8_t depth, next_hop_add, next_hop_return;
int32_t status = 0;
- lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, MAX_RULES, RTE_LPM_HEAP);
+ lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, MAX_RULES, 0);
TEST_LPM_ASSERT(lpm != NULL);
ip = IPv4(128, 0, 0, 0);
return PASS;
}
-/* TEST 12
- *
+/*
* Add an extended rule (i.e. depth greater than 24, lookup (hit), delete,
* lookup (miss) in a for loop of 1000 times. This will check tbl8 extension
* and contraction.
uint8_t depth, next_hop_add, next_hop_return;
int32_t status = 0;
- lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, MAX_RULES, RTE_LPM_HEAP);
+ lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, MAX_RULES, 0);
TEST_LPM_ASSERT(lpm != NULL);
ip = IPv4(128, 0, 0, 0);
return PASS;
}
-/* TEST 13
- *
+/*
* Add a rule to tbl24, lookup (hit), then add a rule that will extend this
* tbl24 entry, lookup (hit). delete the rule that caused the tbl24 extension,
* lookup (miss) and repeat for loop of 1000 times. This will check tbl8
uint8_t depth, next_hop_add_1, next_hop_add_2, next_hop_return;
int32_t status = 0;
- lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, MAX_RULES, RTE_LPM_HEAP);
+ lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, MAX_RULES, 0);
TEST_LPM_ASSERT(lpm != NULL);
ip = IPv4(128, 0, 0, 0);
return PASS;
}
-/* TEST 14
- *
+/*
* Fore TBL8 extension exhaustion. Add 256 rules that require a tbl8 extension.
* No more tbl8 extensions will be allowed. Now add one more rule that required
* a tbl8 extension and get fail.
int32_t status = 0;
/* Add enough space for 256 rules for every depth */
- lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, 256 * 32, RTE_LPM_HEAP);
+ lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, 256 * 32, 0);
TEST_LPM_ASSERT(lpm != NULL);
ip = IPv4(0, 0, 0, 0);
struct rte_lpm *lpm = NULL, *result = NULL;
/* Create lpm */
- lpm = rte_lpm_create("lpm_find_existing", SOCKET_ID_ANY, 256 * 32, RTE_LPM_HEAP);
+ lpm = rte_lpm_create("lpm_find_existing", SOCKET_ID_ANY, 256 * 32, 0);
TEST_LPM_ASSERT(lpm != NULL);
/* Try to find existing lpm */
*/
struct rte_lpm *
rte_lpm_create(const char *name, int socket_id, int max_rules,
- int mem_location)
+ __rte_unused int flags)
{
char mem_name[RTE_LPM_NAMESIZE];
struct rte_lpm *lpm = NULL;
RTE_BUILD_BUG_ON(sizeof(struct rte_lpm_tbl8_entry) != 2);
/* Check user arguments. */
- if ((name == NULL) || (socket_id < -1) || (max_rules == 0) ||
- (mem_location != RTE_LPM_HEAP &&
- mem_location != RTE_LPM_MEMZONE)){
+ if ((name == NULL) || (socket_id < -1) || (max_rules == 0)){
rte_errno = EINVAL;
return NULL;
}
return NULL;
/* Allocate memory to store the LPM data structures. */
- if (mem_location == RTE_LPM_MEMZONE) {
- const struct rte_memzone *mz;
- uint32_t mz_flags = 0;
-
- mz = rte_memzone_reserve(mem_name, mem_size, socket_id,
- mz_flags);
- if (mz == NULL) {
- RTE_LOG(ERR, LPM, "LPM memzone creation failed\n");
- return NULL;
- }
-
- memset(mz->addr, 0, mem_size);
- lpm = (struct rte_lpm *) mz->addr;
-
- }
- else {
- lpm = (struct rte_lpm *)rte_zmalloc(mem_name, mem_size,
+ lpm = (struct rte_lpm *)rte_zmalloc(mem_name, mem_size,
CACHE_LINE_SIZE);
- if (lpm == NULL) {
- RTE_LOG(ERR, LPM, "LPM memory allocation failed\n");
- return NULL;
- }
+ if (lpm == NULL) {
+ RTE_LOG(ERR, LPM, "LPM memory allocation failed\n");
+ return NULL;
}
/* Save user arguments. */
lpm->max_rules_per_depth = max_rules / RTE_LPM_MAX_DEPTH;
rte_snprintf(lpm->name, sizeof(lpm->name), "%s", name);
- lpm->mem_location = mem_location;
TAILQ_INSERT_TAIL(lpm_list, lpm, next);
if (lpm == NULL)
return;
- /* Note: Its is currently not possible to free a memzone. */
- if (lpm->mem_location == RTE_LPM_HEAP){
- RTE_EAL_TAILQ_REMOVE(RTE_TAILQ_LPM, rte_lpm_list, lpm);
- rte_free(lpm);
- }
+ RTE_EAL_TAILQ_REMOVE(RTE_TAILQ_LPM, rte_lpm_list, lpm);
+ rte_free(lpm);
}
/*