* writes m-sequence to the hash_key for range [start, end] * (i.e. including start and end positions) */
| 400 | * (i.e. including start and end positions) |
| 401 | */ |
| 402 | static int |
| 403 | generate_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 | |
| 437 | static inline uint32_t |
| 438 | get_subvalue(struct rte_thash_ctx *ctx, uint32_t offset) |
no test coverage detected