* For TBL8 extension exhaustion. Add 512 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. * */
| 998 | * a tbl8 extension and get fail. |
| 999 | * */ |
| 1000 | int32_t |
| 1001 | test14(void) |
| 1002 | { |
| 1003 | |
| 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*/ |
| 1006 | |
| 1007 | struct rte_lpm *lpm = NULL; |
| 1008 | struct rte_lpm_config config; |
| 1009 | |
| 1010 | config.max_rules = 256 * 32; |
| 1011 | config.number_tbl8s = 512; |
| 1012 | config.flags = 0; |
| 1013 | uint32_t ip, next_hop_base, next_hop_return; |
| 1014 | uint8_t depth; |
| 1015 | int32_t status = 0; |
| 1016 | xmm_t ipx4; |
| 1017 | uint32_t hop[4]; |
| 1018 | |
| 1019 | /* Add enough space for 256 rules for every depth */ |
| 1020 | lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, &config); |
| 1021 | TEST_LPM_ASSERT(lpm != NULL); |
| 1022 | |
| 1023 | depth = 32; |
| 1024 | next_hop_base = 100; |
| 1025 | ip = RTE_IPV4(0, 0, 0, 0); |
| 1026 | |
| 1027 | /* Add 256 rules that require a tbl8 extension */ |
| 1028 | for (; ip <= RTE_IPV4(0, 1, 255, 0); ip += 256) { |
| 1029 | status = rte_lpm_add(lpm, ip, depth, next_hop_base + ip); |
| 1030 | TEST_LPM_ASSERT(status == 0); |
| 1031 | |
| 1032 | status = rte_lpm_lookup(lpm, ip, &next_hop_return); |
| 1033 | TEST_LPM_ASSERT((status == 0) && |
| 1034 | (next_hop_return == next_hop_base + ip)); |
| 1035 | |
| 1036 | ipx4 = vect_set_epi32(ip + 3, ip + 2, ip + 1, ip); |
| 1037 | rte_lpm_lookupx4(lpm, ipx4, hop, UINT32_MAX); |
| 1038 | TEST_LPM_ASSERT(hop[0] == next_hop_base + ip); |
| 1039 | TEST_LPM_ASSERT(hop[1] == UINT32_MAX); |
| 1040 | TEST_LPM_ASSERT(hop[2] == UINT32_MAX); |
| 1041 | TEST_LPM_ASSERT(hop[3] == UINT32_MAX); |
| 1042 | } |
| 1043 | |
| 1044 | /* All tbl8 extensions have been used above. Try to add one more and |
| 1045 | * we get a fail */ |
| 1046 | ip = RTE_IPV4(1, 0, 0, 0); |
| 1047 | depth = 32; |
| 1048 | |
| 1049 | status = rte_lpm_add(lpm, ip, depth, next_hop_base + ip); |
| 1050 | TEST_LPM_ASSERT(status < 0); |
| 1051 | |
| 1052 | rte_lpm_free(lpm); |
| 1053 | |
| 1054 | return PASS; |
| 1055 | } |
| 1056 | |
| 1057 | /* |
nothing calls this directly
no test coverage detected