| 185 | } |
| 186 | |
| 187 | static struct thash_lfsr * |
| 188 | alloc_lfsr(struct rte_thash_ctx *ctx) |
| 189 | { |
| 190 | struct thash_lfsr *lfsr; |
| 191 | uint32_t i; |
| 192 | |
| 193 | if (ctx == NULL) |
| 194 | return NULL; |
| 195 | |
| 196 | lfsr = rte_zmalloc(NULL, sizeof(struct thash_lfsr), 0); |
| 197 | if (lfsr == NULL) |
| 198 | return NULL; |
| 199 | |
| 200 | lfsr->deg = ctx->reta_sz_log; |
| 201 | lfsr->poly = thash_get_rand_poly(lfsr->deg); |
| 202 | do { |
| 203 | lfsr->state = rte_rand() & ((1 << lfsr->deg) - 1); |
| 204 | } while (lfsr->state == 0); |
| 205 | /* init reverse order polynomial */ |
| 206 | lfsr->rev_poly = get_rev_poly(lfsr->poly, lfsr->deg); |
| 207 | /* init proper rev_state*/ |
| 208 | lfsr->rev_state = lfsr->state; |
| 209 | for (i = 0; i <= lfsr->deg; i++) |
| 210 | get_rev_bit_lfsr(lfsr); |
| 211 | |
| 212 | /* clear bits_cnt after rev_state was inited */ |
| 213 | lfsr->bits_cnt = 0; |
| 214 | lfsr->ref_cnt = 1; |
| 215 | |
| 216 | return lfsr; |
| 217 | } |
| 218 | |
| 219 | static void |
| 220 | attach_lfsr(struct rte_thash_subtuple_helper *h, struct thash_lfsr *lfsr) |
no test coverage detected