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

Function rte_distributor_create

dpdk/lib/distributor/rte_distributor.c:710–788  ·  view source on GitHub ↗

creates a distributor instance */

Source from the content-addressed store, hash-verified

708
709/* creates a distributor instance */
710struct rte_distributor *
711rte_distributor_create(const char *name,
712 unsigned int socket_id,
713 unsigned int num_workers,
714 unsigned int alg_type)
715{
716 struct rte_distributor *d;
717 struct rte_dist_burst_list *dist_burst_list;
718 char mz_name[RTE_MEMZONE_NAMESIZE];
719 const struct rte_memzone *mz;
720 unsigned int i;
721
722 /* TODO Reorganise function properly around RTE_DIST_ALG_SINGLE/BURST */
723
724 /* compilation-time checks */
725 RTE_BUILD_BUG_ON((sizeof(*d) & RTE_CACHE_LINE_MASK) != 0);
726 RTE_BUILD_BUG_ON((RTE_DISTRIB_MAX_WORKERS & 7) != 0);
727
728 if (name == NULL || num_workers >=
729 (unsigned int)RTE_MIN(RTE_DISTRIB_MAX_WORKERS, RTE_MAX_LCORE)) {
730 rte_errno = EINVAL;
731 return NULL;
732 }
733
734 if (alg_type == RTE_DIST_ALG_SINGLE) {
735 d = malloc(sizeof(struct rte_distributor));
736 if (d == NULL) {
737 rte_errno = ENOMEM;
738 return NULL;
739 }
740 d->d_single = rte_distributor_create_single(name,
741 socket_id, num_workers);
742 if (d->d_single == NULL) {
743 free(d);
744 /* rte_errno will have been set */
745 return NULL;
746 }
747 d->alg_type = alg_type;
748 return d;
749 }
750
751 snprintf(mz_name, sizeof(mz_name), RTE_DISTRIB_PREFIX"%s", name);
752 mz = rte_memzone_reserve(mz_name, sizeof(*d), socket_id, NO_FLAGS);
753 if (mz == NULL) {
754 rte_errno = ENOMEM;
755 return NULL;
756 }
757
758 d = mz->addr;
759 strlcpy(d->name, name, sizeof(d->name));
760 d->num_workers = num_workers;
761 d->alg_type = alg_type;
762
763 d->dist_match_fn = RTE_DIST_MATCH_SCALAR;
764#if defined(RTE_ARCH_X86)
765 if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128)
766 d->dist_match_fn = RTE_DIST_MATCH_VECTOR;
767#endif

Callers 5

test_distributorFunction · 0.85
test_distributor_perfFunction · 0.85
mainFunction · 0.85

Calls 10

mallocFunction · 0.85
snprintfFunction · 0.85
rte_memzone_reserveFunction · 0.85
memsetFunction · 0.85
freeFunction · 0.50
strlcpyFunction · 0.50

Tested by 4

test_distributorFunction · 0.68
test_distributor_perfFunction · 0.68