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

Function sanity_test

dpdk/app/test/test_distributor.c:119–297  ·  view source on GitHub ↗

do basic sanity testing of the distributor. This test tests the following: * - send 32 packets through distributor with the same tag and ensure they * all go to the one worker * - send 32 packets through the distributor with two different tags and * verify that they go equally to two different workers. * - send 32 packets with different tags through the distributors and * just verify w

Source from the content-addressed store, hash-verified

117 * not necessarily in the same order (as different flows).
118 */
119static int
120sanity_test(struct worker_params *wp, struct rte_mempool *p)
121{
122 struct rte_distributor *db = wp->dist;
123 struct rte_mbuf *bufs[BURST];
124 struct rte_mbuf *returns[BURST*2];
125 unsigned int i, count;
126 unsigned int retries;
127 unsigned int processed;
128
129 printf("=== Basic distributor sanity tests ===\n");
130 clear_packet_count();
131 if (rte_mempool_get_bulk(p, (void *)bufs, BURST) != 0) {
132 printf("line %d: Error getting mbufs from pool\n", __LINE__);
133 return -1;
134 }
135
136 /* now set all hash values in all buffers to zero, so all pkts go to the
137 * one worker thread */
138 for (i = 0; i < BURST; i++)
139 bufs[i]->hash.usr = 0;
140
141 processed = 0;
142 while (processed < BURST)
143 processed += rte_distributor_process(db, &bufs[processed],
144 BURST - processed);
145
146 count = 0;
147 do {
148
149 rte_distributor_flush(db);
150 count += rte_distributor_returned_pkts(db,
151 returns, BURST*2);
152 } while (count < BURST);
153
154 if (total_packet_count() != BURST) {
155 printf("Line %d: Error, not all packets flushed. "
156 "Expected %u, got %u\n",
157 __LINE__, BURST, total_packet_count());
158 rte_mempool_put_bulk(p, (void *)bufs, BURST);
159 return -1;
160 }
161
162 for (i = 0; i < rte_lcore_count() - 1; i++)
163 printf("Worker %u handled %u packets\n", i,
164 __atomic_load_n(&worker_stats[i].handled_packets,
165 __ATOMIC_RELAXED));
166 printf("Sanity test with all zero hashes done.\n");
167
168 /* pick two flows and check they go correctly */
169 if (rte_lcore_count() >= 3) {
170 clear_packet_count();
171 for (i = 0; i < BURST; i++)
172 bufs[i]->hash.usr = (i & 1) << 8;
173
174 rte_distributor_process(db, bufs, BURST);
175 count = 0;
176 do {

Callers 1

test_distributorFunction · 0.85

Calls 10

rte_mempool_get_bulkFunction · 0.85
rte_distributor_processFunction · 0.85
rte_distributor_flushFunction · 0.85
rte_mempool_put_bulkFunction · 0.85
rte_lcore_countFunction · 0.85
clear_packet_countFunction · 0.70
total_packet_countFunction · 0.70
printfFunction · 0.50

Tested by

no test coverage detected