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

Function test_refcnt_mbuf

dpdk/app/test/test_mbuf.c:1092–1160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1090#endif
1091
1092static int
1093test_refcnt_mbuf(void)
1094{
1095#ifdef RTE_MBUF_REFCNT_ATOMIC
1096 unsigned int main_lcore, worker, tref;
1097 int ret = -1;
1098 struct rte_mempool *refcnt_pool = NULL;
1099 struct rte_ring *refcnt_mbuf_ring = NULL;
1100
1101 if (rte_lcore_count() < 2) {
1102 printf("Not enough cores for test_refcnt_mbuf, expecting at least 2\n");
1103 return TEST_SKIPPED;
1104 }
1105
1106 printf("starting %s, at %u lcores\n", __func__, rte_lcore_count());
1107
1108 /* create refcnt pool & ring if they don't exist */
1109
1110 refcnt_pool = rte_pktmbuf_pool_create(MAKE_STRING(refcnt_pool),
1111 REFCNT_MBUF_NUM, 0, 0, 0,
1112 SOCKET_ID_ANY);
1113 if (refcnt_pool == NULL) {
1114 printf("%s: cannot allocate " MAKE_STRING(refcnt_pool) "\n",
1115 __func__);
1116 return -1;
1117 }
1118
1119 refcnt_mbuf_ring = rte_ring_create("refcnt_mbuf_ring",
1120 rte_align32pow2(REFCNT_RING_SIZE), SOCKET_ID_ANY,
1121 RING_F_SP_ENQ);
1122 if (refcnt_mbuf_ring == NULL) {
1123 printf("%s: cannot allocate " MAKE_STRING(refcnt_mbuf_ring)
1124 "\n", __func__);
1125 goto err;
1126 }
1127
1128 refcnt_stop_workers = 0;
1129 memset(refcnt_lcore, 0, sizeof (refcnt_lcore));
1130
1131 rte_eal_mp_remote_launch(test_refcnt_worker, refcnt_mbuf_ring, SKIP_MAIN);
1132
1133 test_refcnt_main(refcnt_pool, refcnt_mbuf_ring);
1134
1135 rte_eal_mp_wait_lcore();
1136
1137 /* check that we processed all references */
1138 tref = 0;
1139 main_lcore = rte_get_main_lcore();
1140
1141 RTE_LCORE_FOREACH_WORKER(worker)
1142 tref += refcnt_lcore[worker];
1143
1144 if (tref != refcnt_lcore[main_lcore])
1145 rte_panic("referenced mbufs: %u, freed mbufs: %u\n",
1146 tref, refcnt_lcore[main_lcore]);
1147
1148 rte_mempool_dump(stdout, refcnt_pool);
1149 rte_ring_dump(stdout, refcnt_mbuf_ring);

Callers 1

test_mbufFunction · 0.85

Calls 14

rte_lcore_countFunction · 0.85
rte_pktmbuf_pool_createFunction · 0.85
rte_ring_createFunction · 0.85
memsetFunction · 0.85
rte_eal_mp_remote_launchFunction · 0.85
test_refcnt_mainFunction · 0.85
rte_eal_mp_wait_lcoreFunction · 0.85
rte_get_main_lcoreFunction · 0.85
rte_mempool_dumpFunction · 0.85
rte_ring_dumpFunction · 0.85
rte_mempool_freeFunction · 0.85
rte_ring_freeFunction · 0.85

Tested by

no test coverage detected