1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
11 #include <rte_malloc.h>
14 #include "test_xmmt_ops.h"
16 #define TEST_LPM_ASSERT(cond) do { \
18 printf("Error at line %d: \n", __LINE__); \
23 typedef int32_t (*rte_lpm_test)(void);
25 static int32_t test0(void);
26 static int32_t test1(void);
27 static int32_t test2(void);
28 static int32_t test3(void);
29 static int32_t test4(void);
30 static int32_t test5(void);
31 static int32_t test6(void);
32 static int32_t test7(void);
33 static int32_t test8(void);
34 static int32_t test9(void);
35 static int32_t test10(void);
36 static int32_t test11(void);
37 static int32_t test12(void);
38 static int32_t test13(void);
39 static int32_t test14(void);
40 static int32_t test15(void);
41 static int32_t test16(void);
42 static int32_t test17(void);
43 static int32_t test18(void);
44 static int32_t test19(void);
45 static int32_t test20(void);
46 static int32_t test21(void);
48 rte_lpm_test tests[] = {
76 #define NUMBER_TBL8S 256
80 * Check that rte_lpm_create fails gracefully for incorrect user input
86 struct rte_lpm *lpm = NULL;
87 struct rte_lpm_config config;
89 config.max_rules = MAX_RULES;
90 config.number_tbl8s = NUMBER_TBL8S;
93 /* rte_lpm_create: lpm name == NULL */
94 lpm = rte_lpm_create(NULL, SOCKET_ID_ANY, &config);
95 TEST_LPM_ASSERT(lpm == NULL);
97 /* rte_lpm_create: max_rules = 0 */
98 /* Note: __func__ inserts the function name, in this case "test0". */
100 lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
101 TEST_LPM_ASSERT(lpm == NULL);
103 /* socket_id < -1 is invalid */
104 config.max_rules = MAX_RULES;
105 lpm = rte_lpm_create(__func__, -2, &config);
106 TEST_LPM_ASSERT(lpm == NULL);
112 * Create lpm table then delete lpm table 100 times
113 * Use a slightly different rules size each time
118 struct rte_lpm *lpm = NULL;
119 struct rte_lpm_config config;
121 config.number_tbl8s = NUMBER_TBL8S;
125 /* rte_lpm_free: Free NULL */
126 for (i = 0; i < 100; i++) {
127 config.max_rules = MAX_RULES - i;
128 lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
129 TEST_LPM_ASSERT(lpm != NULL);
134 /* Can not test free so return success */
139 * Call rte_lpm_free for NULL pointer user input. Note: free has no return and
140 * therefore it is impossible to check for failure but this test is added to
141 * increase function coverage metrics and to validate that freeing null does
147 struct rte_lpm *lpm = NULL;
148 struct rte_lpm_config config;
150 config.max_rules = MAX_RULES;
151 config.number_tbl8s = NUMBER_TBL8S;
154 lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
155 TEST_LPM_ASSERT(lpm != NULL);
163 * Check that rte_lpm_add fails gracefully for incorrect user input arguments
168 struct rte_lpm *lpm = NULL;
169 struct rte_lpm_config config;
171 config.max_rules = MAX_RULES;
172 config.number_tbl8s = NUMBER_TBL8S;
174 uint32_t ip = RTE_IPV4(0, 0, 0, 0), next_hop = 100;
178 /* rte_lpm_add: lpm == NULL */
179 status = rte_lpm_add(NULL, ip, depth, next_hop);
180 TEST_LPM_ASSERT(status < 0);
182 /*Create vaild lpm to use in rest of test. */
183 lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
184 TEST_LPM_ASSERT(lpm != NULL);
186 /* rte_lpm_add: depth < 1 */
187 status = rte_lpm_add(lpm, ip, 0, next_hop);
188 TEST_LPM_ASSERT(status < 0);
190 /* rte_lpm_add: depth > MAX_DEPTH */
191 status = rte_lpm_add(lpm, ip, (MAX_DEPTH + 1), next_hop);
192 TEST_LPM_ASSERT(status < 0);
200 * Check that rte_lpm_delete fails gracefully for incorrect user input
206 struct rte_lpm *lpm = NULL;
207 struct rte_lpm_config config;
209 config.max_rules = MAX_RULES;
210 config.number_tbl8s = NUMBER_TBL8S;
212 uint32_t ip = RTE_IPV4(0, 0, 0, 0);
216 /* rte_lpm_delete: lpm == NULL */
217 status = rte_lpm_delete(NULL, ip, depth);
218 TEST_LPM_ASSERT(status < 0);
220 /*Create vaild lpm to use in rest of test. */
221 lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
222 TEST_LPM_ASSERT(lpm != NULL);
224 /* rte_lpm_delete: depth < 1 */
225 status = rte_lpm_delete(lpm, ip, 0);
226 TEST_LPM_ASSERT(status < 0);
228 /* rte_lpm_delete: depth > MAX_DEPTH */
229 status = rte_lpm_delete(lpm, ip, (MAX_DEPTH + 1));
230 TEST_LPM_ASSERT(status < 0);
238 * Check that rte_lpm_lookup fails gracefully for incorrect user input
244 #if defined(RTE_LIBRTE_LPM_DEBUG)
245 struct rte_lpm *lpm = NULL;
246 struct rte_lpm_config config;
248 config.max_rules = MAX_RULES;
249 config.number_tbl8s = NUMBER_TBL8S;
251 uint32_t ip = RTE_IPV4(0, 0, 0, 0), next_hop_return = 0;
254 /* rte_lpm_lookup: lpm == NULL */
255 status = rte_lpm_lookup(NULL, ip, &next_hop_return);
256 TEST_LPM_ASSERT(status < 0);
258 /*Create vaild lpm to use in rest of test. */
259 lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
260 TEST_LPM_ASSERT(lpm != NULL);
262 /* rte_lpm_lookup: depth < 1 */
263 status = rte_lpm_lookup(lpm, ip, NULL);
264 TEST_LPM_ASSERT(status < 0);
274 * Call add, lookup and delete for a single rule with depth <= 24
279 struct rte_lpm *lpm = NULL;
280 struct rte_lpm_config config;
282 config.max_rules = MAX_RULES;
283 config.number_tbl8s = NUMBER_TBL8S;
285 uint32_t ip = RTE_IPV4(0, 0, 0, 0), next_hop_add = 100, next_hop_return = 0;
289 lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
290 TEST_LPM_ASSERT(lpm != NULL);
292 status = rte_lpm_add(lpm, ip, depth, next_hop_add);
293 TEST_LPM_ASSERT(status == 0);
295 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
296 TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add));
298 status = rte_lpm_delete(lpm, ip, depth);
299 TEST_LPM_ASSERT(status == 0);
301 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
302 TEST_LPM_ASSERT(status == -ENOENT);
310 * Call add, lookup and delete for a single rule with depth > 24
318 struct rte_lpm *lpm = NULL;
319 struct rte_lpm_config config;
321 config.max_rules = MAX_RULES;
322 config.number_tbl8s = NUMBER_TBL8S;
324 uint32_t ip = RTE_IPV4(0, 0, 0, 0), next_hop_add = 100, next_hop_return = 0;
328 lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
329 TEST_LPM_ASSERT(lpm != NULL);
331 status = rte_lpm_add(lpm, ip, depth, next_hop_add);
332 TEST_LPM_ASSERT(status == 0);
334 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
335 TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add));
337 ipx4 = vect_set_epi32(ip, ip + 0x100, ip - 0x100, ip);
338 rte_lpm_lookupx4(lpm, ipx4, hop, UINT32_MAX);
339 TEST_LPM_ASSERT(hop[0] == next_hop_add);
340 TEST_LPM_ASSERT(hop[1] == UINT32_MAX);
341 TEST_LPM_ASSERT(hop[2] == UINT32_MAX);
342 TEST_LPM_ASSERT(hop[3] == next_hop_add);
344 status = rte_lpm_delete(lpm, ip, depth);
345 TEST_LPM_ASSERT(status == 0);
347 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
348 TEST_LPM_ASSERT(status == -ENOENT);
356 * Use rte_lpm_add to add rules which effect only the second half of the lpm
357 * table. Use all possible depths ranging from 1..32. Set the next hop = to the
358 * depth. Check lookup hit for on every add and check for lookup miss on the
359 * first half of the lpm table after each add. Finally delete all rules going
360 * backwards (i.e. from depth = 32 ..1) and carry out a lookup after each
361 * delete. The lookup should return the next_hop_add value related to the
362 * previous depth value (i.e. depth -1).
369 struct rte_lpm *lpm = NULL;
370 struct rte_lpm_config config;
372 config.max_rules = MAX_RULES;
373 config.number_tbl8s = NUMBER_TBL8S;
375 uint32_t ip1 = RTE_IPV4(127, 255, 255, 255), ip2 = RTE_IPV4(128, 0, 0, 0);
376 uint32_t next_hop_add, next_hop_return;
380 lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
381 TEST_LPM_ASSERT(lpm != NULL);
383 /* Loop with rte_lpm_add. */
384 for (depth = 1; depth <= 32; depth++) {
385 /* Let the next_hop_add value = depth. Just for change. */
386 next_hop_add = depth;
388 status = rte_lpm_add(lpm, ip2, depth, next_hop_add);
389 TEST_LPM_ASSERT(status == 0);
391 /* Check IP in first half of tbl24 which should be empty. */
392 status = rte_lpm_lookup(lpm, ip1, &next_hop_return);
393 TEST_LPM_ASSERT(status == -ENOENT);
395 status = rte_lpm_lookup(lpm, ip2, &next_hop_return);
396 TEST_LPM_ASSERT((status == 0) &&
397 (next_hop_return == next_hop_add));
399 ipx4 = vect_set_epi32(ip2, ip1, ip2, ip1);
400 rte_lpm_lookupx4(lpm, ipx4, hop, UINT32_MAX);
401 TEST_LPM_ASSERT(hop[0] == UINT32_MAX);
402 TEST_LPM_ASSERT(hop[1] == next_hop_add);
403 TEST_LPM_ASSERT(hop[2] == UINT32_MAX);
404 TEST_LPM_ASSERT(hop[3] == next_hop_add);
407 /* Loop with rte_lpm_delete. */
408 for (depth = 32; depth >= 1; depth--) {
409 next_hop_add = (uint8_t) (depth - 1);
411 status = rte_lpm_delete(lpm, ip2, depth);
412 TEST_LPM_ASSERT(status == 0);
414 status = rte_lpm_lookup(lpm, ip2, &next_hop_return);
417 TEST_LPM_ASSERT((status == 0) &&
418 (next_hop_return == next_hop_add));
420 TEST_LPM_ASSERT(status == -ENOENT);
423 status = rte_lpm_lookup(lpm, ip1, &next_hop_return);
424 TEST_LPM_ASSERT(status == -ENOENT);
426 ipx4 = vect_set_epi32(ip1, ip1, ip2, ip2);
427 rte_lpm_lookupx4(lpm, ipx4, hop, UINT32_MAX);
429 TEST_LPM_ASSERT(hop[0] == next_hop_add);
430 TEST_LPM_ASSERT(hop[1] == next_hop_add);
432 TEST_LPM_ASSERT(hop[0] == UINT32_MAX);
433 TEST_LPM_ASSERT(hop[1] == UINT32_MAX);
435 TEST_LPM_ASSERT(hop[2] == UINT32_MAX);
436 TEST_LPM_ASSERT(hop[3] == UINT32_MAX);
445 * - Add & lookup to hit invalid TBL24 entry
446 * - Add & lookup to hit valid TBL24 entry not extended
447 * - Add & lookup to hit valid extended TBL24 entry with invalid TBL8 entry
448 * - Add & lookup to hit valid extended TBL24 entry with valid TBL8 entry
454 struct rte_lpm *lpm = NULL;
455 struct rte_lpm_config config;
457 config.max_rules = MAX_RULES;
458 config.number_tbl8s = NUMBER_TBL8S;
460 uint32_t ip, ip_1, ip_2;
461 uint8_t depth, depth_1, depth_2;
462 uint32_t next_hop_add, next_hop_add_1, next_hop_add_2, next_hop_return;
465 /* Add & lookup to hit invalid TBL24 entry */
466 ip = RTE_IPV4(128, 0, 0, 0);
470 lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
471 TEST_LPM_ASSERT(lpm != NULL);
473 status = rte_lpm_add(lpm, ip, depth, next_hop_add);
474 TEST_LPM_ASSERT(status == 0);
476 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
477 TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add));
479 status = rte_lpm_delete(lpm, ip, depth);
480 TEST_LPM_ASSERT(status == 0);
482 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
483 TEST_LPM_ASSERT(status == -ENOENT);
485 rte_lpm_delete_all(lpm);
487 /* Add & lookup to hit valid TBL24 entry not extended */
488 ip = RTE_IPV4(128, 0, 0, 0);
492 status = rte_lpm_add(lpm, ip, depth, next_hop_add);
493 TEST_LPM_ASSERT(status == 0);
495 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
496 TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add));
501 status = rte_lpm_add(lpm, ip, depth, next_hop_add);
502 TEST_LPM_ASSERT(status == 0);
504 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
505 TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add));
509 status = rte_lpm_delete(lpm, ip, depth);
510 TEST_LPM_ASSERT(status == 0);
514 status = rte_lpm_delete(lpm, ip, depth);
515 TEST_LPM_ASSERT(status == 0);
517 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
518 TEST_LPM_ASSERT(status == -ENOENT);
520 rte_lpm_delete_all(lpm);
522 /* Add & lookup to hit valid extended TBL24 entry with invalid TBL8
524 ip = RTE_IPV4(128, 0, 0, 0);
528 status = rte_lpm_add(lpm, ip, depth, next_hop_add);
529 TEST_LPM_ASSERT(status == 0);
531 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
532 TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add));
534 ip = RTE_IPV4(128, 0, 0, 5);
538 status = rte_lpm_add(lpm, ip, depth, next_hop_add);
539 TEST_LPM_ASSERT(status == 0);
541 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
542 TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add));
544 status = rte_lpm_delete(lpm, ip, depth);
545 TEST_LPM_ASSERT(status == 0);
547 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
548 TEST_LPM_ASSERT(status == -ENOENT);
550 ip = RTE_IPV4(128, 0, 0, 0);
554 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
555 TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add));
557 status = rte_lpm_delete(lpm, ip, depth);
558 TEST_LPM_ASSERT(status == 0);
560 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
561 TEST_LPM_ASSERT(status == -ENOENT);
563 rte_lpm_delete_all(lpm);
565 /* Add & lookup to hit valid extended TBL24 entry with valid TBL8
567 ip_1 = RTE_IPV4(128, 0, 0, 0);
569 next_hop_add_1 = 101;
571 ip_2 = RTE_IPV4(128, 0, 0, 5);
573 next_hop_add_2 = 102;
577 status = rte_lpm_add(lpm, ip_1, depth_1, next_hop_add_1);
578 TEST_LPM_ASSERT(status == 0);
580 status = rte_lpm_lookup(lpm, ip_1, &next_hop_return);
581 TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add_1));
583 status = rte_lpm_add(lpm, ip_2, depth_2, next_hop_add_2);
584 TEST_LPM_ASSERT(status == 0);
586 status = rte_lpm_lookup(lpm, ip_2, &next_hop_return);
587 TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add_2));
589 status = rte_lpm_delete(lpm, ip_2, depth_2);
590 TEST_LPM_ASSERT(status == 0);
592 status = rte_lpm_lookup(lpm, ip_2, &next_hop_return);
593 TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add_1));
595 status = rte_lpm_delete(lpm, ip_1, depth_1);
596 TEST_LPM_ASSERT(status == 0);
598 status = rte_lpm_lookup(lpm, ip_1, &next_hop_return);
599 TEST_LPM_ASSERT(status == -ENOENT);
608 * - Add rule that covers a TBL24 range previously invalid & lookup (& delete &
610 * - Add rule that extends a TBL24 invalid entry & lookup (& delete & lookup)
611 * - Add rule that extends a TBL24 valid entry & lookup for both rules (&
613 * - Add rule that updates the next hop in TBL24 & lookup (& delete & lookup)
614 * - Add rule that updates the next hop in TBL8 & lookup (& delete & lookup)
615 * - Delete a rule that is not present in the TBL24 & lookup
616 * - Delete a rule that is not present in the TBL8 & lookup
623 struct rte_lpm *lpm = NULL;
624 struct rte_lpm_config config;
626 config.max_rules = MAX_RULES;
627 config.number_tbl8s = NUMBER_TBL8S;
629 uint32_t ip, next_hop_add, next_hop_return;
633 /* Add rule that covers a TBL24 range previously invalid & lookup
634 * (& delete & lookup) */
635 lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
636 TEST_LPM_ASSERT(lpm != NULL);
638 ip = RTE_IPV4(128, 0, 0, 0);
642 status = rte_lpm_add(lpm, ip, depth, next_hop_add);
643 TEST_LPM_ASSERT(status == 0);
645 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
646 TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add));
648 status = rte_lpm_delete(lpm, ip, depth);
649 TEST_LPM_ASSERT(status == 0);
651 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
652 TEST_LPM_ASSERT(status == -ENOENT);
654 rte_lpm_delete_all(lpm);
656 ip = RTE_IPV4(128, 0, 0, 0);
660 status = rte_lpm_add(lpm, ip, depth, next_hop_add);
661 TEST_LPM_ASSERT(status == 0);
663 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
664 TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add));
666 status = rte_lpm_delete(lpm, ip, depth);
667 TEST_LPM_ASSERT(status == 0);
669 rte_lpm_delete_all(lpm);
671 /* Add rule that extends a TBL24 valid entry & lookup for both rules
672 * (& delete & lookup) */
674 ip = RTE_IPV4(128, 0, 0, 0);
678 status = rte_lpm_add(lpm, ip, depth, next_hop_add);
679 TEST_LPM_ASSERT(status == 0);
681 ip = RTE_IPV4(128, 0, 0, 10);
685 status = rte_lpm_add(lpm, ip, depth, next_hop_add);
686 TEST_LPM_ASSERT(status == 0);
688 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
689 TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add));
691 ip = RTE_IPV4(128, 0, 0, 0);
694 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
695 TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add));
697 ip = RTE_IPV4(128, 0, 0, 0);
700 status = rte_lpm_delete(lpm, ip, depth);
701 TEST_LPM_ASSERT(status == 0);
703 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
704 TEST_LPM_ASSERT(status == -ENOENT);
706 ip = RTE_IPV4(128, 0, 0, 10);
709 status = rte_lpm_delete(lpm, ip, depth);
710 TEST_LPM_ASSERT(status == 0);
712 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
713 TEST_LPM_ASSERT(status == -ENOENT);
715 rte_lpm_delete_all(lpm);
717 /* Add rule that updates the next hop in TBL24 & lookup
718 * (& delete & lookup) */
720 ip = RTE_IPV4(128, 0, 0, 0);
724 status = rte_lpm_add(lpm, ip, depth, next_hop_add);
725 TEST_LPM_ASSERT(status == 0);
727 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
728 TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add));
732 status = rte_lpm_add(lpm, ip, depth, next_hop_add);
733 TEST_LPM_ASSERT(status == 0);
735 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
736 TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add));
738 status = rte_lpm_delete(lpm, ip, depth);
739 TEST_LPM_ASSERT(status == 0);
741 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
742 TEST_LPM_ASSERT(status == -ENOENT);
744 rte_lpm_delete_all(lpm);
746 /* Add rule that updates the next hop in TBL8 & lookup
747 * (& delete & lookup) */
749 ip = RTE_IPV4(128, 0, 0, 0);
753 status = rte_lpm_add(lpm, ip, depth, next_hop_add);
754 TEST_LPM_ASSERT(status == 0);
756 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
757 TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add));
761 status = rte_lpm_add(lpm, ip, depth, next_hop_add);
762 TEST_LPM_ASSERT(status == 0);
764 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
765 TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add));
767 status = rte_lpm_delete(lpm, ip, depth);
768 TEST_LPM_ASSERT(status == 0);
770 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
771 TEST_LPM_ASSERT(status == -ENOENT);
773 rte_lpm_delete_all(lpm);
775 /* Delete a rule that is not present in the TBL24 & lookup */
777 ip = RTE_IPV4(128, 0, 0, 0);
780 status = rte_lpm_delete(lpm, ip, depth);
781 TEST_LPM_ASSERT(status < 0);
783 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
784 TEST_LPM_ASSERT(status == -ENOENT);
786 rte_lpm_delete_all(lpm);
788 /* Delete a rule that is not present in the TBL8 & lookup */
790 ip = RTE_IPV4(128, 0, 0, 0);
793 status = rte_lpm_delete(lpm, ip, depth);
794 TEST_LPM_ASSERT(status < 0);
796 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
797 TEST_LPM_ASSERT(status == -ENOENT);
805 * Add two rules, lookup to hit the more specific one, lookup to hit the less
806 * specific one delete the less specific rule and lookup previous values again;
807 * add a more specific rule than the existing rule, lookup again
814 struct rte_lpm *lpm = NULL;
815 struct rte_lpm_config config;
817 config.max_rules = MAX_RULES;
818 config.number_tbl8s = NUMBER_TBL8S;
820 uint32_t ip, next_hop_add, next_hop_return;
824 lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
825 TEST_LPM_ASSERT(lpm != NULL);
827 ip = RTE_IPV4(128, 0, 0, 0);
831 status = rte_lpm_add(lpm, ip, depth, next_hop_add);
832 TEST_LPM_ASSERT(status == 0);
834 ip = RTE_IPV4(128, 0, 0, 10);
838 status = rte_lpm_add(lpm, ip, depth, next_hop_add);
839 TEST_LPM_ASSERT(status == 0);
841 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
842 TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add));
844 ip = RTE_IPV4(128, 0, 0, 0);
847 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
848 TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add));
850 ip = RTE_IPV4(128, 0, 0, 0);
853 status = rte_lpm_delete(lpm, ip, depth);
854 TEST_LPM_ASSERT(status == 0);
856 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
857 TEST_LPM_ASSERT(status == -ENOENT);
859 ip = RTE_IPV4(128, 0, 0, 10);
862 status = rte_lpm_delete(lpm, ip, depth);
863 TEST_LPM_ASSERT(status == 0);
865 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
866 TEST_LPM_ASSERT(status == -ENOENT);
874 * Add an extended rule (i.e. depth greater than 24, lookup (hit), delete,
875 * lookup (miss) in a for loop of 1000 times. This will check tbl8 extension
885 struct rte_lpm *lpm = NULL;
886 struct rte_lpm_config config;
888 config.max_rules = MAX_RULES;
889 config.number_tbl8s = NUMBER_TBL8S;
891 uint32_t ip, i, next_hop_add, next_hop_return;
895 lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
896 TEST_LPM_ASSERT(lpm != NULL);
898 ip = RTE_IPV4(128, 0, 0, 0);
902 for (i = 0; i < 1000; i++) {
903 status = rte_lpm_add(lpm, ip, depth, next_hop_add);
904 TEST_LPM_ASSERT(status == 0);
906 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
907 TEST_LPM_ASSERT((status == 0) &&
908 (next_hop_return == next_hop_add));
910 ipx4 = vect_set_epi32(ip, ip + 1, ip, ip - 1);
911 rte_lpm_lookupx4(lpm, ipx4, hop, UINT32_MAX);
912 TEST_LPM_ASSERT(hop[0] == UINT32_MAX);
913 TEST_LPM_ASSERT(hop[1] == next_hop_add);
914 TEST_LPM_ASSERT(hop[2] == UINT32_MAX);
915 TEST_LPM_ASSERT(hop[3] == next_hop_add);
917 status = rte_lpm_delete(lpm, ip, depth);
918 TEST_LPM_ASSERT(status == 0);
920 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
921 TEST_LPM_ASSERT(status == -ENOENT);
930 * Add a rule to tbl24, lookup (hit), then add a rule that will extend this
931 * tbl24 entry, lookup (hit). delete the rule that caused the tbl24 extension,
932 * lookup (miss) and repeat for loop of 1000 times. This will check tbl8
933 * extension and contraction.
940 struct rte_lpm *lpm = NULL;
941 struct rte_lpm_config config;
943 config.max_rules = MAX_RULES;
944 config.number_tbl8s = NUMBER_TBL8S;
946 uint32_t ip, i, next_hop_add_1, next_hop_add_2, next_hop_return;
950 lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
951 TEST_LPM_ASSERT(lpm != NULL);
953 ip = RTE_IPV4(128, 0, 0, 0);
955 next_hop_add_1 = 100;
957 status = rte_lpm_add(lpm, ip, depth, next_hop_add_1);
958 TEST_LPM_ASSERT(status == 0);
960 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
961 TEST_LPM_ASSERT((status == 0) && (next_hop_return == next_hop_add_1));
964 next_hop_add_2 = 101;
966 for (i = 0; i < 1000; i++) {
967 status = rte_lpm_add(lpm, ip, depth, next_hop_add_2);
968 TEST_LPM_ASSERT(status == 0);
970 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
971 TEST_LPM_ASSERT((status == 0) &&
972 (next_hop_return == next_hop_add_2));
974 status = rte_lpm_delete(lpm, ip, depth);
975 TEST_LPM_ASSERT(status == 0);
977 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
978 TEST_LPM_ASSERT((status == 0) &&
979 (next_hop_return == next_hop_add_1));
984 status = rte_lpm_delete(lpm, ip, depth);
985 TEST_LPM_ASSERT(status == 0);
987 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
988 TEST_LPM_ASSERT(status == -ENOENT);
996 * Fore TBL8 extension exhaustion. Add 256 rules that require a tbl8 extension.
997 * No more tbl8 extensions will be allowed. Now add one more rule that required
998 * a tbl8 extension and get fail.
1004 /* We only use depth = 32 in the loop below so we must make sure
1005 * that we have enough storage for all rules at that depth*/
1007 struct rte_lpm *lpm = NULL;
1008 struct rte_lpm_config config;
1010 config.max_rules = 256 * 32;
1011 config.number_tbl8s = NUMBER_TBL8S;
1013 uint32_t ip, next_hop_add, next_hop_return;
1017 /* Add enough space for 256 rules for every depth */
1018 lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
1019 TEST_LPM_ASSERT(lpm != NULL);
1023 ip = RTE_IPV4(0, 0, 0, 0);
1025 /* Add 256 rules that require a tbl8 extension */
1026 for (; ip <= RTE_IPV4(0, 0, 255, 0); ip += 256) {
1027 status = rte_lpm_add(lpm, ip, depth, next_hop_add);
1028 TEST_LPM_ASSERT(status == 0);
1030 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
1031 TEST_LPM_ASSERT((status == 0) &&
1032 (next_hop_return == next_hop_add));
1035 /* All tbl8 extensions have been used above. Try to add one more and
1037 ip = RTE_IPV4(1, 0, 0, 0);
1040 status = rte_lpm_add(lpm, ip, depth, next_hop_add);
1041 TEST_LPM_ASSERT(status < 0);
1049 * Sequence of operations for find existing lpm table
1052 * - find existing table: hit
1053 * - find non-existing table: miss
1059 struct rte_lpm *lpm = NULL, *result = NULL;
1060 struct rte_lpm_config config;
1062 config.max_rules = 256 * 32;
1063 config.number_tbl8s = NUMBER_TBL8S;
1067 lpm = rte_lpm_create("lpm_find_existing", SOCKET_ID_ANY, &config);
1068 TEST_LPM_ASSERT(lpm != NULL);
1070 /* Try to find existing lpm */
1071 result = rte_lpm_find_existing("lpm_find_existing");
1072 TEST_LPM_ASSERT(result == lpm);
1074 /* Try to find non-existing lpm */
1075 result = rte_lpm_find_existing("lpm_find_non_existing");
1076 TEST_LPM_ASSERT(result == NULL);
1079 rte_lpm_delete_all(lpm);
1086 * test failure condition of overloading the tbl8 so no more will fit
1087 * Check we get an error return value in that case
1093 struct rte_lpm_config config;
1095 config.max_rules = 256 * 32;
1096 config.number_tbl8s = NUMBER_TBL8S;
1098 struct rte_lpm *lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
1100 /* ip loops through all possibilities for top 24 bits of address */
1101 for (ip = 0; ip < 0xFFFFFF; ip++) {
1102 /* add an entry within a different tbl8 each time, since
1103 * depth >24 and the top 24 bits are different */
1104 if (rte_lpm_add(lpm, (ip << 8) + 0xF0, 30, 0) < 0)
1108 if (ip != NUMBER_TBL8S) {
1109 printf("Error, unexpected failure with filling tbl8 groups\n");
1110 printf("Failed after %u additions, expected after %u\n",
1111 (unsigned)ip, (unsigned)NUMBER_TBL8S);
1119 * Test for overwriting of tbl8:
1120 * - add rule /32 and lookup
1121 * - add new rule /24 and lookup
1122 * - add third rule /25 and lookup
1123 * - lookup /32 and /24 rule to ensure the table has not been overwritten.
1128 struct rte_lpm *lpm = NULL;
1129 struct rte_lpm_config config;
1131 config.max_rules = MAX_RULES;
1132 config.number_tbl8s = NUMBER_TBL8S;
1134 const uint32_t ip_10_32 = RTE_IPV4(10, 10, 10, 2);
1135 const uint32_t ip_10_24 = RTE_IPV4(10, 10, 10, 0);
1136 const uint32_t ip_20_25 = RTE_IPV4(10, 10, 20, 2);
1137 const uint8_t d_ip_10_32 = 32,
1140 const uint32_t next_hop_ip_10_32 = 100,
1141 next_hop_ip_10_24 = 105,
1142 next_hop_ip_20_25 = 111;
1143 uint32_t next_hop_return = 0;
1146 lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
1147 TEST_LPM_ASSERT(lpm != NULL);
1149 if ((status = rte_lpm_add(lpm, ip_10_32, d_ip_10_32,
1150 next_hop_ip_10_32)) < 0)
1153 status = rte_lpm_lookup(lpm, ip_10_32, &next_hop_return);
1154 uint32_t test_hop_10_32 = next_hop_return;
1155 TEST_LPM_ASSERT(status == 0);
1156 TEST_LPM_ASSERT(next_hop_return == next_hop_ip_10_32);
1158 if ((status = rte_lpm_add(lpm, ip_10_24, d_ip_10_24,
1159 next_hop_ip_10_24)) < 0)
1162 status = rte_lpm_lookup(lpm, ip_10_24, &next_hop_return);
1163 uint32_t test_hop_10_24 = next_hop_return;
1164 TEST_LPM_ASSERT(status == 0);
1165 TEST_LPM_ASSERT(next_hop_return == next_hop_ip_10_24);
1167 if ((status = rte_lpm_add(lpm, ip_20_25, d_ip_20_25,
1168 next_hop_ip_20_25)) < 0)
1171 status = rte_lpm_lookup(lpm, ip_20_25, &next_hop_return);
1172 uint32_t test_hop_20_25 = next_hop_return;
1173 TEST_LPM_ASSERT(status == 0);
1174 TEST_LPM_ASSERT(next_hop_return == next_hop_ip_20_25);
1176 if (test_hop_10_32 == test_hop_10_24) {
1177 printf("Next hop return equal\n");
1181 if (test_hop_10_24 == test_hop_20_25) {
1182 printf("Next hop return equal\n");
1186 status = rte_lpm_lookup(lpm, ip_10_32, &next_hop_return);
1187 TEST_LPM_ASSERT(status == 0);
1188 TEST_LPM_ASSERT(next_hop_return == next_hop_ip_10_32);
1190 status = rte_lpm_lookup(lpm, ip_10_24, &next_hop_return);
1191 TEST_LPM_ASSERT(status == 0);
1192 TEST_LPM_ASSERT(next_hop_return == next_hop_ip_10_24);
1200 * Test for recycle of tbl8
1201 * - step 1: add a rule with depth=28 (> 24)
1202 * - step 2: add a rule with same 24-bit prefix and depth=23 (< 24)
1203 * - step 3: delete the first rule
1204 * - step 4: check tbl8 is freed
1205 * - step 5: add a rule same as the first one (depth=28)
1206 * - step 6: check same tbl8 is allocated
1207 * - step 7: add a rule with same 24-bit prefix and depth=24
1208 * - step 8: delete the rule (depth=28) added in step 5
1209 * - step 9: check tbl8 is freed
1210 * - step 10: add a rule with same 24-bit prefix and depth = 28
1211 * - setp 11: check same tbl8 is allocated again
1216 #define group_idx next_hop
1217 struct rte_lpm *lpm = NULL;
1218 struct rte_lpm_config config;
1219 uint32_t ip, next_hop;
1221 uint32_t tbl8_group_index;
1223 config.max_rules = MAX_RULES;
1224 config.number_tbl8s = NUMBER_TBL8S;
1227 lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
1228 TEST_LPM_ASSERT(lpm != NULL);
1230 ip = RTE_IPV4(192, 168, 100, 100);
1233 rte_lpm_add(lpm, ip, depth, next_hop);
1235 TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group);
1236 tbl8_group_index = lpm->tbl24[ip>>8].group_idx;
1240 rte_lpm_add(lpm, ip, depth, next_hop);
1241 TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group);
1244 rte_lpm_delete(lpm, ip, depth);
1246 TEST_LPM_ASSERT(!lpm->tbl24[ip>>8].valid_group);
1249 rte_lpm_add(lpm, ip, depth, next_hop);
1251 TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group);
1252 TEST_LPM_ASSERT(tbl8_group_index == lpm->tbl24[ip>>8].group_idx);
1256 rte_lpm_add(lpm, ip, depth, next_hop);
1257 TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group);
1260 rte_lpm_delete(lpm, ip, depth);
1262 TEST_LPM_ASSERT(!lpm->tbl24[ip>>8].valid_group);
1265 rte_lpm_add(lpm, ip, depth, next_hop);
1267 TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group);
1268 TEST_LPM_ASSERT(tbl8_group_index == lpm->tbl24[ip>>8].group_idx);
1276 * rte_lpm_rcu_qsbr_add positive and negative tests.
1277 * - Add RCU QSBR variable to LPM
1278 * - Add another RCU QSBR variable to LPM
1284 struct rte_lpm *lpm = NULL;
1285 struct rte_lpm_config config;
1287 struct rte_rcu_qsbr *qsv;
1288 struct rte_rcu_qsbr *qsv2;
1290 struct rte_lpm_rcu_config rcu_cfg = {0};
1292 config.max_rules = MAX_RULES;
1293 config.number_tbl8s = NUMBER_TBL8S;
1296 lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
1297 TEST_LPM_ASSERT(lpm != NULL);
1299 /* Create RCU QSBR variable */
1300 sz = rte_rcu_qsbr_get_memsize(RTE_MAX_LCORE);
1301 qsv = (struct rte_rcu_qsbr *)rte_zmalloc_socket(NULL, sz,
1302 RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY);
1303 TEST_LPM_ASSERT(qsv != NULL);
1305 status = rte_rcu_qsbr_init(qsv, RTE_MAX_LCORE);
1306 TEST_LPM_ASSERT(status == 0);
1309 /* Invalid QSBR mode */
1311 status = rte_lpm_rcu_qsbr_add(lpm, &rcu_cfg);
1312 TEST_LPM_ASSERT(status != 0);
1314 rcu_cfg.mode = RTE_LPM_QSBR_MODE_DQ;
1315 /* Attach RCU QSBR to LPM table */
1316 status = rte_lpm_rcu_qsbr_add(lpm, &rcu_cfg);
1317 TEST_LPM_ASSERT(status == 0);
1319 /* Create and attach another RCU QSBR to LPM table */
1320 qsv2 = (struct rte_rcu_qsbr *)rte_zmalloc_socket(NULL, sz,
1321 RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY);
1322 TEST_LPM_ASSERT(qsv2 != NULL);
1325 rcu_cfg.mode = RTE_LPM_QSBR_MODE_SYNC;
1326 status = rte_lpm_rcu_qsbr_add(lpm, &rcu_cfg);
1327 TEST_LPM_ASSERT(status != 0);
1337 * rte_lpm_rcu_qsbr_add DQ mode functional test.
1338 * Reader and writer are in the same thread in this test.
1339 * - Create LPM which supports 1 tbl8 group at max
1340 * - Add RCU QSBR variable to LPM
1341 * - Add a rule with depth=28 (> 24)
1342 * - Register a reader thread (not a real thread)
1343 * - Reader lookup existing rule
1344 * - Writer delete the rule
1345 * - Reader lookup the rule
1346 * - Writer re-add the rule (no available tbl8 group)
1347 * - Reader report quiescent state and unregister
1348 * - Writer re-add the rule
1349 * - Reader lookup the rule
1354 struct rte_lpm *lpm = NULL;
1355 struct rte_lpm_config config;
1357 struct rte_rcu_qsbr *qsv;
1359 uint32_t ip, next_hop, next_hop_return;
1361 struct rte_lpm_rcu_config rcu_cfg = {0};
1363 config.max_rules = MAX_RULES;
1364 config.number_tbl8s = 1;
1367 lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
1368 TEST_LPM_ASSERT(lpm != NULL);
1370 /* Create RCU QSBR variable */
1371 sz = rte_rcu_qsbr_get_memsize(1);
1372 qsv = (struct rte_rcu_qsbr *)rte_zmalloc_socket(NULL, sz,
1373 RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY);
1374 TEST_LPM_ASSERT(qsv != NULL);
1376 status = rte_rcu_qsbr_init(qsv, 1);
1377 TEST_LPM_ASSERT(status == 0);
1380 rcu_cfg.mode = RTE_LPM_QSBR_MODE_DQ;
1381 /* Attach RCU QSBR to LPM table */
1382 status = rte_lpm_rcu_qsbr_add(lpm, &rcu_cfg);
1383 TEST_LPM_ASSERT(status == 0);
1385 ip = RTE_IPV4(192, 0, 2, 100);
1388 status = rte_lpm_add(lpm, ip, depth, next_hop);
1389 TEST_LPM_ASSERT(status == 0);
1390 TEST_LPM_ASSERT(lpm->tbl24[ip>>8].valid_group);
1392 /* Register pseudo reader */
1393 status = rte_rcu_qsbr_thread_register(qsv, 0);
1394 TEST_LPM_ASSERT(status == 0);
1395 rte_rcu_qsbr_thread_online(qsv, 0);
1397 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
1398 TEST_LPM_ASSERT(status == 0);
1399 TEST_LPM_ASSERT(next_hop_return == next_hop);
1402 status = rte_lpm_delete(lpm, ip, depth);
1403 TEST_LPM_ASSERT(status == 0);
1404 TEST_LPM_ASSERT(!lpm->tbl24[ip>>8].valid);
1406 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
1407 TEST_LPM_ASSERT(status != 0);
1409 status = rte_lpm_add(lpm, ip, depth, next_hop);
1410 TEST_LPM_ASSERT(status != 0);
1412 /* Reader quiescent */
1413 rte_rcu_qsbr_quiescent(qsv, 0);
1415 status = rte_lpm_add(lpm, ip, depth, next_hop);
1416 TEST_LPM_ASSERT(status == 0);
1418 rte_rcu_qsbr_thread_offline(qsv, 0);
1419 status = rte_rcu_qsbr_thread_unregister(qsv, 0);
1420 TEST_LPM_ASSERT(status == 0);
1422 status = rte_lpm_lookup(lpm, ip, &next_hop_return);
1423 TEST_LPM_ASSERT(status == 0);
1424 TEST_LPM_ASSERT(next_hop_return == next_hop);
1432 static struct rte_lpm *g_lpm;
1433 static struct rte_rcu_qsbr *g_v;
1434 static uint32_t g_ip = RTE_IPV4(192, 0, 2, 100);
1435 static volatile uint8_t writer_done;
1436 /* Report quiescent state interval every 1024 lookups. Larger critical
1437 * sections in reader will result in writer polling multiple times.
1439 #define QSBR_REPORTING_INTERVAL 1024
1440 #define WRITER_ITERATIONS 512
1443 * Reader thread using rte_lpm data structure with RCU.
1446 test_lpm_rcu_qsbr_reader(void *arg)
1449 uint32_t next_hop_return = 0;
1452 /* Register this thread to report quiescent state */
1453 rte_rcu_qsbr_thread_register(g_v, 0);
1454 rte_rcu_qsbr_thread_online(g_v, 0);
1457 for (i = 0; i < QSBR_REPORTING_INTERVAL; i++)
1458 rte_lpm_lookup(g_lpm, g_ip, &next_hop_return);
1460 /* Update quiescent state */
1461 rte_rcu_qsbr_quiescent(g_v, 0);
1462 } while (!writer_done);
1464 rte_rcu_qsbr_thread_offline(g_v, 0);
1465 rte_rcu_qsbr_thread_unregister(g_v, 0);
1471 * rte_lpm_rcu_qsbr_add sync mode functional test.
1472 * 1 Reader and 1 writer. They cannot be in the same thread in this test.
1473 * - Create LPM which supports 1 tbl8 group at max
1474 * - Add RCU QSBR variable with sync mode to LPM
1475 * - Register a reader thread. Reader keeps looking up a specific rule.
1476 * - Writer keeps adding and deleting a specific rule with depth=28 (> 24)
1481 struct rte_lpm_config config;
1484 uint32_t i, next_hop;
1486 struct rte_lpm_rcu_config rcu_cfg = {0};
1488 if (rte_lcore_count() < 2) {
1489 printf("Not enough cores for %s, expecting at least 2\n",
1491 return TEST_SKIPPED;
1494 config.max_rules = MAX_RULES;
1495 config.number_tbl8s = 1;
1498 g_lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config);
1499 TEST_LPM_ASSERT(g_lpm != NULL);
1501 /* Create RCU QSBR variable */
1502 sz = rte_rcu_qsbr_get_memsize(1);
1503 g_v = (struct rte_rcu_qsbr *)rte_zmalloc_socket(NULL, sz,
1504 RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY);
1505 TEST_LPM_ASSERT(g_v != NULL);
1507 status = rte_rcu_qsbr_init(g_v, 1);
1508 TEST_LPM_ASSERT(status == 0);
1511 rcu_cfg.mode = RTE_LPM_QSBR_MODE_SYNC;
1512 /* Attach RCU QSBR to LPM table */
1513 status = rte_lpm_rcu_qsbr_add(g_lpm, &rcu_cfg);
1514 TEST_LPM_ASSERT(status == 0);
1517 /* Launch reader thread */
1518 rte_eal_remote_launch(test_lpm_rcu_qsbr_reader, NULL,
1519 rte_get_next_lcore(-1, 1, 0));
1523 status = rte_lpm_add(g_lpm, g_ip, depth, next_hop);
1525 printf("%s: Failed to add rule\n", __func__);
1530 for (i = 0; i < WRITER_ITERATIONS; i++) {
1531 status = rte_lpm_delete(g_lpm, g_ip, depth);
1533 printf("%s: Failed to delete rule at iteration %d\n",
1538 status = rte_lpm_add(g_lpm, g_ip, depth, next_hop);
1540 printf("%s: Failed to add rule at iteration %d\n",
1548 /* Wait until reader exited. */
1549 rte_eal_mp_wait_lcore();
1551 rte_lpm_free(g_lpm);
1554 return (status == 0) ? PASS : -1;
1558 * Do all unit tests.
1565 int status, global_status = 0;
1567 for (i = 0; i < RTE_DIM(tests); i++) {
1568 status = tests[i]();
1570 printf("ERROR: LPM Test %u: FAIL\n", i);
1571 global_status = status;
1575 return global_status;
1578 REGISTER_TEST_COMMAND(lpm_autotest, test_lpm);