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

Function generate_subkey

dpdk/lib/hash/rte_thash.c:402–435  ·  view source on GitHub ↗

* writes m-sequence to the hash_key for range [start, end] * (i.e. including start and end positions) */

Source from the content-addressed store, hash-verified

400 * (i.e. including start and end positions)
401 */
402static int
403generate_subkey(struct rte_thash_ctx *ctx, struct thash_lfsr *lfsr,
404 uint32_t start, uint32_t end)
405{
406 uint32_t i;
407 uint32_t req_bits = (start < end) ? (end - start) : (start - end);
408 req_bits++; /* due to including end */
409
410 /* check if lfsr overflow period of the m-sequence */
411 if (((lfsr->bits_cnt + req_bits) > (1ULL << lfsr->deg) - 1) &&
412 ((ctx->flags & RTE_THASH_IGNORE_PERIOD_OVERFLOW) !=
413 RTE_THASH_IGNORE_PERIOD_OVERFLOW)) {
414 RTE_LOG(ERR, HASH,
415 "Can't generate m-sequence due to period overflow\n");
416 return -ENOSPC;
417 }
418
419 if (start < end) {
420 /* original direction (from left to right)*/
421 for (i = start; i <= end; i++)
422 set_bit(ctx->hash_key, get_bit_lfsr(lfsr), i);
423
424 } else {
425 /* reverse direction (from right to left) */
426 for (i = end; i >= start; i--)
427 set_bit(ctx->hash_key, get_rev_bit_lfsr(lfsr), i);
428 }
429
430 if (ctx->matrices != NULL)
431 rte_thash_complete_matrix(ctx->matrices, ctx->hash_key,
432 ctx->key_len);
433
434 return 0;
435}
436
437static inline uint32_t
438get_subvalue(struct rte_thash_ctx *ctx, uint32_t offset)

Callers 3

insert_beforeFunction · 0.85
insert_afterFunction · 0.85
rte_thash_add_helperFunction · 0.85

Calls 4

get_bit_lfsrFunction · 0.85
get_rev_bit_lfsrFunction · 0.85
set_bitFunction · 0.70

Tested by

no test coverage detected