| 96 | |
| 97 | |
| 98 | static int |
| 99 | test_hash_multiwriter(void) |
| 100 | { |
| 101 | unsigned int i, rounded_nb_total_tsx_insertion; |
| 102 | static unsigned calledCount = 1; |
| 103 | uint16_t enabled_core_ids[RTE_MAX_LCORE]; |
| 104 | uint16_t core_id; |
| 105 | |
| 106 | uint32_t *keys; |
| 107 | uint32_t *found; |
| 108 | |
| 109 | struct rte_hash_parameters hash_params = { |
| 110 | .entries = nb_entries, |
| 111 | .key_len = sizeof(uint32_t), |
| 112 | .hash_func = rte_jhash, |
| 113 | .hash_func_init_val = 0, |
| 114 | .socket_id = rte_socket_id(), |
| 115 | }; |
| 116 | if (use_htm) |
| 117 | hash_params.extra_flag = |
| 118 | RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT |
| 119 | | RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD; |
| 120 | else |
| 121 | hash_params.extra_flag = |
| 122 | RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD; |
| 123 | |
| 124 | struct rte_hash *handle; |
| 125 | char name[RTE_HASH_NAMESIZE]; |
| 126 | |
| 127 | const void *next_key; |
| 128 | void *next_data; |
| 129 | uint32_t iter = 0; |
| 130 | |
| 131 | uint32_t duplicated_keys = 0; |
| 132 | uint32_t lost_keys = 0; |
| 133 | uint32_t count; |
| 134 | |
| 135 | snprintf(name, 32, "test%u", calledCount++); |
| 136 | hash_params.name = name; |
| 137 | |
| 138 | handle = rte_hash_create(&hash_params); |
| 139 | RETURN_IF_ERROR(handle == NULL, "hash creation failed"); |
| 140 | |
| 141 | tbl_multiwriter_test_params.h = handle; |
| 142 | tbl_multiwriter_test_params.nb_tsx_insertion = |
| 143 | nb_total_tsx_insertion / rte_lcore_count(); |
| 144 | |
| 145 | rounded_nb_total_tsx_insertion = (nb_total_tsx_insertion / |
| 146 | tbl_multiwriter_test_params.nb_tsx_insertion) |
| 147 | * tbl_multiwriter_test_params.nb_tsx_insertion; |
| 148 | |
| 149 | rte_srand(rte_rdtsc()); |
| 150 | |
| 151 | keys = rte_malloc(NULL, sizeof(uint32_t) * nb_entries, 0); |
| 152 | |
| 153 | if (keys == NULL) { |
| 154 | printf("RTE_MALLOC failed\n"); |
| 155 | goto err1; |
no test coverage detected