Lines Matching defs:ctx

210 	struct rte_thash_ctx *ctx;
226 ctx = (struct rte_thash_ctx *)te->data;
227 if (strncmp(name, ctx->name, sizeof(ctx->name)) == 0)
230 ctx = NULL;
246 ctx = rte_zmalloc(NULL, sizeof(struct rte_thash_ctx) + key_len, 0);
247 if (ctx == NULL) {
248 HASH_LOG(ERR, "thash ctx %s memory allocation failed",
254 rte_strlcpy(ctx->name, name, sizeof(ctx->name));
255 ctx->key_len = key_len;
256 ctx->reta_sz_log = reta_sz;
257 LIST_INIT(&ctx->head);
258 ctx->flags = flags;
261 rte_memcpy(ctx->hash_key, key, key_len);
264 ctx->hash_key[i] = rte_rand();
268 ctx->matrices = rte_zmalloc(NULL, key_len * sizeof(uint64_t),
270 if (ctx->matrices == NULL) {
276 rte_thash_complete_matrix(ctx->matrices, ctx->hash_key,
280 te->data = (void *)ctx;
285 return ctx;
288 rte_free(ctx);
299 struct rte_thash_ctx *ctx;
307 ctx = (struct rte_thash_ctx *)te->data;
308 if (strncmp(name, ctx->name, sizeof(ctx->name)) == 0)
319 return ctx;
323 rte_thash_free_ctx(struct rte_thash_ctx *ctx)
329 if (ctx == NULL)
335 if (te->data == (void *)ctx)
343 ent = LIST_FIRST(&(ctx->head));
352 rte_free(ctx);
375 generate_subkey(struct rte_thash_ctx *ctx, struct thash_lfsr *lfsr,
384 ((ctx->flags & RTE_THASH_IGNORE_PERIOD_OVERFLOW) !=
394 set_bit(ctx->hash_key, get_bit_lfsr(lfsr), i);
399 set_bit(ctx->hash_key, get_rev_bit_lfsr(lfsr), i);
402 if (ctx->matrices != NULL)
403 rte_thash_complete_matrix(ctx->matrices, ctx->hash_key,
404 ctx->key_len);
410 get_subvalue(struct rte_thash_ctx *ctx, uint32_t offset)
414 tmp = (uint32_t *)(&ctx->hash_key[offset >> 3]);
417 ctx->reta_sz_log));
419 return val & ((1 << ctx->reta_sz_log) - 1);
423 generate_complement_table(struct rte_thash_ctx *ctx,
430 start = h->offset + h->len - (2 * ctx->reta_sz_log - 1);
432 for (i = 1; i < (1 << ctx->reta_sz_log); i++) {
436 val ^= get_subvalue(ctx, start - k +
437 ctx->reta_sz_log - 1);
444 insert_before(struct rte_thash_ctx *ctx,
453 ent->lfsr = alloc_lfsr(ctx->reta_sz_log);
459 ret = generate_subkey(ctx, ent->lfsr, start, end - 1);
478 ret = generate_subkey(ctx, ent->lfsr, cur_ent->offset - 1, start);
490 ret = generate_subkey(ctx, ent->lfsr, range_end, end - 1);
499 generate_complement_table(ctx, ent);
500 ctx->subtuples_nb++;
505 insert_after(struct rte_thash_ctx *ctx,
528 ret = generate_subkey(ctx, ent->lfsr, range_end, end - 1);
537 generate_complement_table(ctx, ent);
538 ctx->subtuples_nb++;
544 rte_thash_add_helper(struct rte_thash_ctx *ctx, const char *name, uint32_t len,
551 if ((ctx == NULL) || (name == NULL) || (len < ctx->reta_sz_log) ||
553 ctx->key_len * CHAR_BIT))
557 LIST_FOREACH(cur_ent, &ctx->head, next) {
563 start = ((ctx->flags & RTE_THASH_MINIMAL_SEQ) ==
564 RTE_THASH_MINIMAL_SEQ) ? (end - (2 * ctx->reta_sz_log - 1)) :
568 sizeof(uint32_t) * (1 << ctx->reta_sz_log),
578 ent->lsb_msk = (1 << ctx->reta_sz_log) - 1;
580 cur_ent = LIST_FIRST(&ctx->head);
596 return insert_before(ctx, ent, cur_ent, next_ent,
599 return insert_after(ctx, ent, cur_ent, next_ent,
606 ent->lfsr = alloc_lfsr(ctx->reta_sz_log);
613 ret = generate_subkey(ctx, ent->lfsr, start, end - 1);
619 if (LIST_EMPTY(&ctx->head)) {
620 LIST_INSERT_HEAD(&ctx->head, ent, next);
622 LIST_FOREACH(next_ent, &ctx->head, next)
627 generate_complement_table(ctx, ent);
628 ctx->subtuples_nb++;
634 rte_thash_get_helper(struct rte_thash_ctx *ctx, const char *name)
638 if ((ctx == NULL) || (name == NULL))
641 LIST_FOREACH(ent, &ctx->head, next) {
657 rte_thash_get_key(struct rte_thash_ctx *ctx)
659 return ctx->hash_key;
663 rte_thash_get_gfni_matrices(struct rte_thash_ctx *ctx)
665 return ctx->matrices;
758 rte_thash_adjust_tuple(struct rte_thash_ctx *ctx,
772 if ((ctx == NULL) || (h == NULL) || (tuple == NULL) ||
776 hash_key = rte_thash_get_key(ctx);
778 attempts = RTE_MIN(attempts, 1U << (h->tuple_len - ctx->reta_sz_log));
781 if (ctx->matrices != NULL)
782 hash = rte_thash_gfni(ctx->matrices, tuple, tuple_len);
798 offset = h->tuple_offset + h->tuple_len - ctx->reta_sz_log;
799 tmp = read_unaligned_bits(tuple, ctx->reta_sz_log, offset);
801 write_unaligned_bits(tuple, ctx->reta_sz_log, offset, tmp);
810 h->tuple_len - ctx->reta_sz_log);