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

Function insert_before

dpdk/lib/hash/rte_thash.c:471–530  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

469}
470
471static inline int
472insert_before(struct rte_thash_ctx *ctx,
473 struct rte_thash_subtuple_helper *ent,
474 struct rte_thash_subtuple_helper *cur_ent,
475 struct rte_thash_subtuple_helper *next_ent,
476 uint32_t start, uint32_t end, uint32_t range_end)
477{
478 int ret;
479
480 if (end < cur_ent->offset) {
481 ent->lfsr = alloc_lfsr(ctx);
482 if (ent->lfsr == NULL) {
483 rte_free(ent);
484 return -ENOMEM;
485 }
486 /* generate nonoverlapping range [start, end) */
487 ret = generate_subkey(ctx, ent->lfsr, start, end - 1);
488 if (ret != 0) {
489 free_lfsr(ent->lfsr);
490 rte_free(ent);
491 return ret;
492 }
493 } else if ((next_ent != NULL) && (end > next_ent->offset)) {
494 RTE_LOG(ERR, HASH,
495 "Can't add helper %s due to conflict with existing"
496 " helper %s\n", ent->name, next_ent->name);
497 rte_free(ent);
498 return -ENOSPC;
499 }
500 attach_lfsr(ent, cur_ent->lfsr);
501
502 /**
503 * generate partially overlapping range
504 * [start, cur_ent->start) in reverse order
505 */
506 ret = generate_subkey(ctx, ent->lfsr, cur_ent->offset - 1, start);
507 if (ret != 0) {
508 free_lfsr(ent->lfsr);
509 rte_free(ent);
510 return ret;
511 }
512
513 if (end > range_end) {
514 /**
515 * generate partially overlapping range
516 * (range_end, end)
517 */
518 ret = generate_subkey(ctx, ent->lfsr, range_end, end - 1);
519 if (ret != 0) {
520 free_lfsr(ent->lfsr);
521 rte_free(ent);
522 return ret;
523 }
524 }
525
526 LIST_INSERT_BEFORE(cur_ent, ent, next);
527 generate_complement_table(ctx, ent);
528 ctx->subtuples_nb++;

Callers 1

rte_thash_add_helperFunction · 0.85

Calls 6

alloc_lfsrFunction · 0.85
rte_freeFunction · 0.85
generate_subkeyFunction · 0.85
free_lfsrFunction · 0.85
attach_lfsrFunction · 0.85

Tested by

no test coverage detected