* Search for a hash function for a group that satisfies all group results */
| 366 | * Search for a hash function for a group that satisfies all group results |
| 367 | */ |
| 368 | static inline int |
| 369 | efd_search_hash(struct rte_efd_table * const table, |
| 370 | const struct efd_offline_group_rules * const off_group, |
| 371 | struct efd_online_group_entry * const on_group) |
| 372 | { |
| 373 | efd_hashfunc_t hash_idx; |
| 374 | efd_hashfunc_t start_hash_idx[RTE_EFD_VALUE_NUM_BITS]; |
| 375 | efd_lookuptbl_t start_lookup_table[RTE_EFD_VALUE_NUM_BITS]; |
| 376 | |
| 377 | uint32_t i, j, rule_id; |
| 378 | uint32_t hash_val_a[EFD_MAX_GROUP_NUM_RULES]; |
| 379 | uint32_t hash_val_b[EFD_MAX_GROUP_NUM_RULES]; |
| 380 | uint32_t hash_val[EFD_MAX_GROUP_NUM_RULES]; |
| 381 | |
| 382 | |
| 383 | rte_prefetch0(off_group->value); |
| 384 | |
| 385 | /* |
| 386 | * Prepopulate the hash_val tables by running the two hash functions |
| 387 | * for each provided rule |
| 388 | */ |
| 389 | for (i = 0; i < off_group->num_rules; i++) { |
| 390 | void *key_stored = EFD_KEY(off_group->key_idx[i], table); |
| 391 | hash_val_b[i] = EFD_HASHFUNCB(key_stored, table); |
| 392 | hash_val_a[i] = EFD_HASHFUNCA(key_stored, table); |
| 393 | } |
| 394 | |
| 395 | for (i = 0; i < RTE_EFD_VALUE_NUM_BITS; i++) { |
| 396 | hash_idx = on_group->hash_idx[i]; |
| 397 | start_hash_idx[i] = hash_idx; |
| 398 | start_lookup_table[i] = on_group->lookup_table[i]; |
| 399 | |
| 400 | do { |
| 401 | efd_lookuptbl_t lookup_table = 0; |
| 402 | efd_lookuptbl_t lookup_table_complement = 0; |
| 403 | |
| 404 | for (rule_id = 0; rule_id < off_group->num_rules; rule_id++) |
| 405 | hash_val[rule_id] = hash_val_a[rule_id] + (hash_idx * |
| 406 | hash_val_b[rule_id]); |
| 407 | |
| 408 | /* |
| 409 | * The goal here is to find a hash function for this |
| 410 | * particular bit entry that meets the following criteria: |
| 411 | * The most significant bits of the hash result define a |
| 412 | * shift into the lookup table where the bit will be stored |
| 413 | */ |
| 414 | |
| 415 | /* Iterate over each provided rule */ |
| 416 | for (rule_id = 0; rule_id < off_group->num_rules; |
| 417 | rule_id++) { |
| 418 | /* |
| 419 | * Use the few most significant bits (number based on |
| 420 | * EFD_LOOKUPTBL_SIZE) to see what position the |
| 421 | * expected bit should be set in the lookup_table |
| 422 | */ |
| 423 | uint32_t bucket_idx = hash_val[rule_id] >> |
| 424 | EFD_LOOKUPTBL_SHIFT; |
| 425 |
no test coverage detected