MCPcopy Create free account
hub / github.com/F-Stack/f-stack / alloc_lfsr

Function alloc_lfsr

dpdk/lib/hash/rte_thash.c:187–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187static struct thash_lfsr *
188alloc_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
219static void
220attach_lfsr(struct rte_thash_subtuple_helper *h, struct thash_lfsr *lfsr)

Callers 2

insert_beforeFunction · 0.85
rte_thash_add_helperFunction · 0.85

Calls 5

rte_zmallocFunction · 0.85
thash_get_rand_polyFunction · 0.85
rte_randFunction · 0.85
get_rev_polyFunction · 0.85
get_rev_bit_lfsrFunction · 0.85

Tested by

no test coverage detected