| 73 | } |
| 74 | |
| 75 | int |
| 76 | rte_member_create_ht(struct rte_member_setsum *ss, |
| 77 | const struct rte_member_parameters *params) |
| 78 | { |
| 79 | uint32_t i, j; |
| 80 | uint32_t size_bucket_t; |
| 81 | uint32_t num_entries = rte_align32pow2(params->num_keys); |
| 82 | |
| 83 | if ((num_entries > RTE_MEMBER_ENTRIES_MAX) || |
| 84 | !rte_is_power_of_2(RTE_MEMBER_BUCKET_ENTRIES) || |
| 85 | num_entries < RTE_MEMBER_BUCKET_ENTRIES) { |
| 86 | rte_errno = EINVAL; |
| 87 | RTE_MEMBER_LOG(ERR, |
| 88 | "Membership HT create with invalid parameters\n"); |
| 89 | return -EINVAL; |
| 90 | } |
| 91 | |
| 92 | uint32_t num_buckets = num_entries / RTE_MEMBER_BUCKET_ENTRIES; |
| 93 | |
| 94 | size_bucket_t = sizeof(struct member_ht_bucket); |
| 95 | |
| 96 | struct member_ht_bucket *buckets = rte_zmalloc_socket(NULL, |
| 97 | num_buckets * size_bucket_t, |
| 98 | RTE_CACHE_LINE_SIZE, ss->socket_id); |
| 99 | |
| 100 | if (buckets == NULL) { |
| 101 | RTE_MEMBER_LOG(ERR, "memory allocation failed for HT " |
| 102 | "setsummary\n"); |
| 103 | return -ENOMEM; |
| 104 | } |
| 105 | |
| 106 | ss->table = buckets; |
| 107 | ss->bucket_cnt = num_buckets; |
| 108 | ss->bucket_mask = num_buckets - 1; |
| 109 | ss->cache = params->is_cache; |
| 110 | |
| 111 | for (i = 0; i < num_buckets; i++) { |
| 112 | for (j = 0; j < RTE_MEMBER_BUCKET_ENTRIES; j++) |
| 113 | buckets[i].sets[j] = RTE_MEMBER_NO_MATCH; |
| 114 | } |
| 115 | #if defined(RTE_ARCH_X86) |
| 116 | if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2) && |
| 117 | RTE_MEMBER_BUCKET_ENTRIES == 16 && |
| 118 | rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_256) |
| 119 | ss->sig_cmp_fn = RTE_MEMBER_COMPARE_AVX2; |
| 120 | else |
| 121 | #endif |
| 122 | ss->sig_cmp_fn = RTE_MEMBER_COMPARE_SCALAR; |
| 123 | |
| 124 | RTE_MEMBER_LOG(DEBUG, "Hash table based filter created, " |
| 125 | "the table has %u entries, %u buckets\n", |
| 126 | num_entries, num_buckets); |
| 127 | return 0; |
| 128 | } |
| 129 | |
| 130 | static inline void |
| 131 | get_buckets_index(const struct rte_member_setsum *ss, const void *key, |
no test coverage detected