* Similar to the test above (full bucket test), but for extendable buckets. */
| 895 | * Similar to the test above (full bucket test), but for extendable buckets. |
| 896 | */ |
| 897 | static int test_extendable_bucket(void) |
| 898 | { |
| 899 | struct rte_hash_parameters params_pseudo_hash = { |
| 900 | .name = "test5", |
| 901 | .entries = 64, |
| 902 | .key_len = sizeof(struct flow_key), |
| 903 | .hash_func = pseudo_hash, |
| 904 | .hash_func_init_val = 0, |
| 905 | .socket_id = 0, |
| 906 | .extra_flag = RTE_HASH_EXTRA_FLAGS_EXT_TABLE |
| 907 | }; |
| 908 | struct rte_hash *handle; |
| 909 | int pos[64]; |
| 910 | int expected_pos[64]; |
| 911 | unsigned int i; |
| 912 | struct flow_key rand_keys[64]; |
| 913 | |
| 914 | for (i = 0; i < 64; i++) { |
| 915 | rand_keys[i].port_dst = i; |
| 916 | rand_keys[i].port_src = i+1; |
| 917 | } |
| 918 | |
| 919 | handle = rte_hash_create(¶ms_pseudo_hash); |
| 920 | RETURN_IF_ERROR(handle == NULL, "hash creation failed"); |
| 921 | |
| 922 | /* Fill bucket */ |
| 923 | for (i = 0; i < 64; i++) { |
| 924 | pos[i] = rte_hash_add_key(handle, &rand_keys[i]); |
| 925 | print_key_info("Add", &rand_keys[i], pos[i]); |
| 926 | RETURN_IF_ERROR(pos[i] < 0, |
| 927 | "failed to add key (pos[%u]=%d)", i, pos[i]); |
| 928 | expected_pos[i] = pos[i]; |
| 929 | } |
| 930 | |
| 931 | /* Lookup */ |
| 932 | for (i = 0; i < 64; i++) { |
| 933 | pos[i] = rte_hash_lookup(handle, &rand_keys[i]); |
| 934 | print_key_info("Lkp", &rand_keys[i], pos[i]); |
| 935 | RETURN_IF_ERROR(pos[i] != expected_pos[i], |
| 936 | "failed to find key (pos[%u]=%d)", i, pos[i]); |
| 937 | } |
| 938 | |
| 939 | /* Add - update */ |
| 940 | for (i = 0; i < 64; i++) { |
| 941 | pos[i] = rte_hash_add_key(handle, &rand_keys[i]); |
| 942 | print_key_info("Add", &rand_keys[i], pos[i]); |
| 943 | RETURN_IF_ERROR(pos[i] != expected_pos[i], |
| 944 | "failed to add key (pos[%u]=%d)", i, pos[i]); |
| 945 | } |
| 946 | |
| 947 | /* Lookup */ |
| 948 | for (i = 0; i < 64; i++) { |
| 949 | pos[i] = rte_hash_lookup(handle, &rand_keys[i]); |
| 950 | print_key_info("Lkp", &rand_keys[i], pos[i]); |
| 951 | RETURN_IF_ERROR(pos[i] != expected_pos[i], |
| 952 | "failed to find key (pos[%u]=%d)", i, pos[i]); |
| 953 | } |
| 954 |
no test coverage detected