Lines Matching defs:lfsr

37 	/**< polynomial associated with the lfsr */
41 /**< current state of the lfsr */
43 /**< current state of the lfsr for reverse direction */
45 uint32_t bits_cnt; /**< number of bits generated by lfsr*/
51 struct thash_lfsr *lfsr;
104 get_bit_lfsr(struct thash_lfsr *lfsr)
112 bit = rte_popcount32(lfsr->state & lfsr->poly) & 0x1;
113 ret = lfsr->state & 0x1;
114 lfsr->state = ((lfsr->state >> 1) | (bit << (lfsr->deg - 1))) &
115 ((1 << lfsr->deg) - 1);
117 lfsr->bits_cnt++;
122 get_rev_bit_lfsr(struct thash_lfsr *lfsr)
126 bit = rte_popcount32(lfsr->rev_state & lfsr->rev_poly) & 0x1;
127 ret = lfsr->rev_state & (1 << (lfsr->deg - 1));
128 lfsr->rev_state = ((lfsr->rev_state << 1) | bit) &
129 ((1 << lfsr->deg) - 1);
131 lfsr->bits_cnt++;
162 struct thash_lfsr *lfsr;
168 lfsr = rte_zmalloc(NULL, sizeof(struct thash_lfsr), 0);
169 if (lfsr == NULL)
172 lfsr->deg = poly_degree;
173 lfsr->poly = thash_get_rand_poly(lfsr->deg);
175 lfsr->state = rte_rand() & ((1 << lfsr->deg) - 1);
176 } while (lfsr->state == 0);
178 lfsr->rev_poly = get_rev_poly(lfsr->poly, lfsr->deg);
180 lfsr->rev_state = lfsr->state;
181 for (i = 0; i <= lfsr->deg; i++)
182 get_rev_bit_lfsr(lfsr);
185 lfsr->bits_cnt = 0;
186 lfsr->ref_cnt = 1;
188 return lfsr;
192 attach_lfsr(struct rte_thash_subtuple_helper *h, struct thash_lfsr *lfsr)
194 lfsr->ref_cnt++;
195 h->lfsr = lfsr;
199 free_lfsr(struct thash_lfsr *lfsr)
201 lfsr->ref_cnt--;
202 if (lfsr->ref_cnt == 0)
203 rte_free(lfsr);
345 free_lfsr(ent->lfsr);
375 generate_subkey(struct rte_thash_ctx *ctx, struct thash_lfsr *lfsr,
382 /* check if lfsr overflow period of the m-sequence */
383 if (((lfsr->bits_cnt + req_bits) > (1ULL << lfsr->deg) - 1) &&
394 set_bit(ctx->hash_key, get_bit_lfsr(lfsr), i);
399 set_bit(ctx->hash_key, get_rev_bit_lfsr(lfsr), i);
453 ent->lfsr = alloc_lfsr(ctx->reta_sz_log);
454 if (ent->lfsr == NULL) {
459 ret = generate_subkey(ctx, ent->lfsr, start, end - 1);
461 free_lfsr(ent->lfsr);
472 attach_lfsr(ent, cur_ent->lfsr);
478 ret = generate_subkey(ctx, ent->lfsr, cur_ent->offset - 1, start);
480 free_lfsr(ent->lfsr);
490 ret = generate_subkey(ctx, ent->lfsr, range_end, end - 1);
492 free_lfsr(ent->lfsr);
522 attach_lfsr(ent, cur_ent->lfsr);
528 ret = generate_subkey(ctx, ent->lfsr, range_end, end - 1);
530 free_lfsr(ent->lfsr);
606 ent->lfsr = alloc_lfsr(ctx->reta_sz_log);
607 if (ent->lfsr == NULL) {
613 ret = generate_subkey(ctx, ent->lfsr, start, end - 1);
615 free_lfsr(ent->lfsr);
832 /* define lfsr sequence range*/
840 struct thash_lfsr *lfsr = alloc_lfsr(reta_sz_log);
841 if (lfsr == NULL)
845 set_bit(key, get_bit_lfsr(lfsr), i);
847 free_lfsr(lfsr);