* Verify that rte_jhash and rte_jhash_32b return the same */
| 183 | * Verify that rte_jhash and rte_jhash_32b return the same |
| 184 | */ |
| 185 | static int |
| 186 | verify_jhash_32bits(void) |
| 187 | { |
| 188 | unsigned i, j; |
| 189 | uint8_t key[64]; |
| 190 | uint32_t hash, hash32; |
| 191 | |
| 192 | for (i = 0; i < 64; i++) |
| 193 | key[i] = rand() & 0xff; |
| 194 | |
| 195 | for (i = 0; i < RTE_DIM(hashtest_key_lens); i++) { |
| 196 | for (j = 0; j < RTE_DIM(hashtest_initvals); j++) { |
| 197 | /* Key size must be multiple of 4 (32 bits) */ |
| 198 | if ((hashtest_key_lens[i] & 0x3) == 0) { |
| 199 | hash = rte_jhash(key, hashtest_key_lens[i], |
| 200 | hashtest_initvals[j]); |
| 201 | /* Divide key length by 4 in rte_jhash for 32 bits */ |
| 202 | hash32 = rte_jhash_32b((const unaligned_uint32_t *)key, |
| 203 | hashtest_key_lens[i] >> 2, |
| 204 | hashtest_initvals[j]); |
| 205 | if (hash != hash32) { |
| 206 | printf("rte_jhash returns different value (0x%x)" |
| 207 | "than rte_jhash_32b (0x%x)\n", |
| 208 | hash, hash32); |
| 209 | return -1; |
| 210 | } |
| 211 | } |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | return 0; |
| 216 | } |
| 217 | |
| 218 | /* |
| 219 | * Verify that rte_jhash and rte_jhash_1word, rte_jhash_2words |
no test coverage detected