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

Function trie_create

dpdk/lib/fib/trie.c:621–686  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

619}
620
621void *
622trie_create(const char *name, int socket_id,
623 struct rte_fib6_conf *conf)
624{
625 char mem_name[TRIE_NAMESIZE];
626 struct rte_trie_tbl *dp = NULL;
627 uint64_t def_nh;
628 uint32_t num_tbl8;
629 enum rte_fib_trie_nh_sz nh_sz;
630
631 if ((name == NULL) || (conf == NULL) ||
632 (conf->trie.nh_sz < RTE_FIB6_TRIE_2B) ||
633 (conf->trie.nh_sz > RTE_FIB6_TRIE_8B) ||
634 (conf->trie.num_tbl8 >
635 get_max_nh(conf->trie.nh_sz)) ||
636 (conf->trie.num_tbl8 == 0) ||
637 (conf->default_nh >
638 get_max_nh(conf->trie.nh_sz))) {
639
640 rte_errno = EINVAL;
641 return NULL;
642 }
643
644 def_nh = conf->default_nh;
645 nh_sz = conf->trie.nh_sz;
646 num_tbl8 = conf->trie.num_tbl8;
647
648 snprintf(mem_name, sizeof(mem_name), "DP_%s", name);
649 dp = rte_zmalloc_socket(name, sizeof(struct rte_trie_tbl) +
650 TRIE_TBL24_NUM_ENT * (1 << nh_sz) + sizeof(uint32_t),
651 RTE_CACHE_LINE_SIZE, socket_id);
652 if (dp == NULL) {
653 rte_errno = ENOMEM;
654 return dp;
655 }
656
657 write_to_dp(&dp->tbl24, (def_nh << 1), nh_sz, 1 << 24);
658
659 snprintf(mem_name, sizeof(mem_name), "TBL8_%p", dp);
660 dp->tbl8 = rte_zmalloc_socket(mem_name, TRIE_TBL8_GRP_NUM_ENT *
661 (1ll << nh_sz) * (num_tbl8 + 1),
662 RTE_CACHE_LINE_SIZE, socket_id);
663 if (dp->tbl8 == NULL) {
664 rte_errno = ENOMEM;
665 rte_free(dp);
666 return NULL;
667 }
668 dp->def_nh = def_nh;
669 dp->nh_sz = nh_sz;
670 dp->number_tbl8s = num_tbl8;
671
672 snprintf(mem_name, sizeof(mem_name), "TBL8_idxes_%p", dp);
673 dp->tbl8_pool = rte_zmalloc_socket(mem_name,
674 sizeof(uint32_t) * dp->number_tbl8s,
675 RTE_CACHE_LINE_SIZE, socket_id);
676 if (dp->tbl8_pool == NULL) {
677 rte_errno = ENOMEM;
678 rte_free(dp->tbl8);

Callers 1

init_dataplaneFunction · 0.85

Calls 6

snprintfFunction · 0.85
rte_zmalloc_socketFunction · 0.85
write_to_dpFunction · 0.85
rte_freeFunction · 0.85
get_max_nhFunction · 0.70
tbl8_pool_initFunction · 0.70

Tested by

no test coverage detected