890a8526b46a0d68852fc2f2e3b989660482984f
[deb_dpdk.git] / test / test / test_distributor.c
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2010-2017 Intel Corporation. All rights reserved.
5  *   All rights reserved.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *     * Neither the name of Intel Corporation nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #include "test.h"
35
36 #include <unistd.h>
37 #include <string.h>
38 #include <rte_cycles.h>
39 #include <rte_errno.h>
40 #include <rte_mempool.h>
41 #include <rte_mbuf.h>
42 #include <rte_distributor.h>
43
44 #define ITER_POWER 20 /* log 2 of how many iterations we do when timing. */
45 #define BURST 32
46 #define BIG_BATCH 1024
47
48 struct worker_params {
49         char name[64];
50         struct rte_distributor *dist;
51 };
52
53 struct worker_params worker_params;
54
55 /* statics - all zero-initialized by default */
56 static volatile int quit;      /**< general quit variable for all threads */
57 static volatile int zero_quit; /**< var for when we just want thr0 to quit*/
58 static volatile unsigned worker_idx;
59
60 struct worker_stats {
61         volatile unsigned handled_packets;
62 } __rte_cache_aligned;
63 struct worker_stats worker_stats[RTE_MAX_LCORE];
64
65 /* returns the total count of the number of packets handled by the worker
66  * functions given below.
67  */
68 static inline unsigned
69 total_packet_count(void)
70 {
71         unsigned i, count = 0;
72         for (i = 0; i < worker_idx; i++)
73                 count += worker_stats[i].handled_packets;
74         return count;
75 }
76
77 /* resets the packet counts for a new test */
78 static inline void
79 clear_packet_count(void)
80 {
81         memset(&worker_stats, 0, sizeof(worker_stats));
82 }
83
84 /* this is the basic worker function for sanity test
85  * it does nothing but return packets and count them.
86  */
87 static int
88 handle_work(void *arg)
89 {
90         struct rte_mbuf *buf[8] __rte_cache_aligned;
91         struct worker_params *wp = arg;
92         struct rte_distributor *db = wp->dist;
93         unsigned int count = 0, num = 0;
94         unsigned int id = __sync_fetch_and_add(&worker_idx, 1);
95         int i;
96
97         for (i = 0; i < 8; i++)
98                 buf[i] = NULL;
99         num = rte_distributor_get_pkt(db, id, buf, buf, num);
100         while (!quit) {
101                 worker_stats[id].handled_packets += num;
102                 count += num;
103                 num = rte_distributor_get_pkt(db, id,
104                                 buf, buf, num);
105         }
106         worker_stats[id].handled_packets += num;
107         count += num;
108         rte_distributor_return_pkt(db, id, buf, num);
109         return 0;
110 }
111
112 /* do basic sanity testing of the distributor. This test tests the following:
113  * - send 32 packets through distributor with the same tag and ensure they
114  *   all go to the one worker
115  * - send 32 packets throught the distributor with two different tags and
116  *   verify that they go equally to two different workers.
117  * - send 32 packets with different tags through the distributors and
118  *   just verify we get all packets back.
119  * - send 1024 packets through the distributor, gathering the returned packets
120  *   as we go. Then verify that we correctly got all 1024 pointers back again,
121  *   not necessarily in the same order (as different flows).
122  */
123 static int
124 sanity_test(struct worker_params *wp, struct rte_mempool *p)
125 {
126         struct rte_distributor *db = wp->dist;
127         struct rte_mbuf *bufs[BURST];
128         struct rte_mbuf *returns[BURST*2];
129         unsigned int i, count;
130         unsigned int retries;
131
132         printf("=== Basic distributor sanity tests ===\n");
133         clear_packet_count();
134         if (rte_mempool_get_bulk(p, (void *)bufs, BURST) != 0) {
135                 printf("line %d: Error getting mbufs from pool\n", __LINE__);
136                 return -1;
137         }
138
139         /* now set all hash values in all buffers to zero, so all pkts go to the
140          * one worker thread */
141         for (i = 0; i < BURST; i++)
142                 bufs[i]->hash.usr = 0;
143
144         rte_distributor_process(db, bufs, BURST);
145         count = 0;
146         do {
147
148                 rte_distributor_flush(db);
149                 count += rte_distributor_returned_pkts(db,
150                                 returns, BURST*2);
151         } while (count < BURST);
152
153         if (total_packet_count() != BURST) {
154                 printf("Line %d: Error, not all packets flushed. "
155                                 "Expected %u, got %u\n",
156                                 __LINE__, BURST, total_packet_count());
157                 return -1;
158         }
159
160         for (i = 0; i < rte_lcore_count() - 1; i++)
161                 printf("Worker %u handled %u packets\n", i,
162                                 worker_stats[i].handled_packets);
163         printf("Sanity test with all zero hashes done.\n");
164
165         /* pick two flows and check they go correctly */
166         if (rte_lcore_count() >= 3) {
167                 clear_packet_count();
168                 for (i = 0; i < BURST; i++)
169                         bufs[i]->hash.usr = (i & 1) << 8;
170
171                 rte_distributor_process(db, bufs, BURST);
172                 count = 0;
173                 do {
174                         rte_distributor_flush(db);
175                         count += rte_distributor_returned_pkts(db,
176                                         returns, BURST*2);
177                 } while (count < BURST);
178                 if (total_packet_count() != BURST) {
179                         printf("Line %d: Error, not all packets flushed. "
180                                         "Expected %u, got %u\n",
181                                         __LINE__, BURST, total_packet_count());
182                         return -1;
183                 }
184
185                 for (i = 0; i < rte_lcore_count() - 1; i++)
186                         printf("Worker %u handled %u packets\n", i,
187                                         worker_stats[i].handled_packets);
188                 printf("Sanity test with two hash values done\n");
189         }
190
191         /* give a different hash value to each packet,
192          * so load gets distributed */
193         clear_packet_count();
194         for (i = 0; i < BURST; i++)
195                 bufs[i]->hash.usr = i+1;
196
197         rte_distributor_process(db, bufs, BURST);
198         count = 0;
199         do {
200                 rte_distributor_flush(db);
201                 count += rte_distributor_returned_pkts(db,
202                                 returns, BURST*2);
203         } while (count < BURST);
204         if (total_packet_count() != BURST) {
205                 printf("Line %d: Error, not all packets flushed. "
206                                 "Expected %u, got %u\n",
207                                 __LINE__, BURST, total_packet_count());
208                 return -1;
209         }
210
211         for (i = 0; i < rte_lcore_count() - 1; i++)
212                 printf("Worker %u handled %u packets\n", i,
213                                 worker_stats[i].handled_packets);
214         printf("Sanity test with non-zero hashes done\n");
215
216         rte_mempool_put_bulk(p, (void *)bufs, BURST);
217
218         /* sanity test with BIG_BATCH packets to ensure they all arrived back
219          * from the returned packets function */
220         clear_packet_count();
221         struct rte_mbuf *many_bufs[BIG_BATCH], *return_bufs[BIG_BATCH];
222         unsigned num_returned = 0;
223
224         /* flush out any remaining packets */
225         rte_distributor_flush(db);
226         rte_distributor_clear_returns(db);
227
228         if (rte_mempool_get_bulk(p, (void *)many_bufs, BIG_BATCH) != 0) {
229                 printf("line %d: Error getting mbufs from pool\n", __LINE__);
230                 return -1;
231         }
232         for (i = 0; i < BIG_BATCH; i++)
233                 many_bufs[i]->hash.usr = i << 2;
234
235         printf("=== testing big burst (%s) ===\n", wp->name);
236         for (i = 0; i < BIG_BATCH/BURST; i++) {
237                 rte_distributor_process(db,
238                                 &many_bufs[i*BURST], BURST);
239                 count = rte_distributor_returned_pkts(db,
240                                 &return_bufs[num_returned],
241                                 BIG_BATCH - num_returned);
242                 num_returned += count;
243         }
244         rte_distributor_flush(db);
245         count = rte_distributor_returned_pkts(db,
246                 &return_bufs[num_returned],
247                         BIG_BATCH - num_returned);
248         num_returned += count;
249         retries = 0;
250         do {
251                 rte_distributor_flush(db);
252                 count = rte_distributor_returned_pkts(db,
253                                 &return_bufs[num_returned],
254                                 BIG_BATCH - num_returned);
255                 num_returned += count;
256                 retries++;
257         } while ((num_returned < BIG_BATCH) && (retries < 100));
258
259         if (num_returned != BIG_BATCH) {
260                 printf("line %d: Missing packets, expected %d\n",
261                                 __LINE__, num_returned);
262                 return -1;
263         }
264
265         /* big check -  make sure all packets made it back!! */
266         for (i = 0; i < BIG_BATCH; i++) {
267                 unsigned j;
268                 struct rte_mbuf *src = many_bufs[i];
269                 for (j = 0; j < BIG_BATCH; j++) {
270                         if (return_bufs[j] == src)
271                                 break;
272                 }
273
274                 if (j == BIG_BATCH) {
275                         printf("Error: could not find source packet #%u\n", i);
276                         return -1;
277                 }
278         }
279         printf("Sanity test of returned packets done\n");
280
281         rte_mempool_put_bulk(p, (void *)many_bufs, BIG_BATCH);
282
283         printf("\n");
284         return 0;
285 }
286
287
288 /* to test that the distributor does not lose packets, we use this worker
289  * function which frees mbufs when it gets them. The distributor thread does
290  * the mbuf allocation. If distributor drops packets we'll eventually run out
291  * of mbufs.
292  */
293 static int
294 handle_work_with_free_mbufs(void *arg)
295 {
296         struct rte_mbuf *buf[8] __rte_cache_aligned;
297         struct worker_params *wp = arg;
298         struct rte_distributor *d = wp->dist;
299         unsigned int count = 0;
300         unsigned int i;
301         unsigned int num = 0;
302         unsigned int id = __sync_fetch_and_add(&worker_idx, 1);
303
304         for (i = 0; i < 8; i++)
305                 buf[i] = NULL;
306         num = rte_distributor_get_pkt(d, id, buf, buf, num);
307         while (!quit) {
308                 worker_stats[id].handled_packets += num;
309                 count += num;
310                 for (i = 0; i < num; i++)
311                         rte_pktmbuf_free(buf[i]);
312                 num = rte_distributor_get_pkt(d,
313                                 id, buf, buf, num);
314         }
315         worker_stats[id].handled_packets += num;
316         count += num;
317         rte_distributor_return_pkt(d, id, buf, num);
318         return 0;
319 }
320
321 /* Perform a sanity test of the distributor with a large number of packets,
322  * where we allocate a new set of mbufs for each burst. The workers then
323  * free the mbufs. This ensures that we don't have any packet leaks in the
324  * library.
325  */
326 static int
327 sanity_test_with_mbuf_alloc(struct worker_params *wp, struct rte_mempool *p)
328 {
329         struct rte_distributor *d = wp->dist;
330         unsigned i;
331         struct rte_mbuf *bufs[BURST];
332
333         printf("=== Sanity test with mbuf alloc/free (%s) ===\n", wp->name);
334
335         clear_packet_count();
336         for (i = 0; i < ((1<<ITER_POWER)); i += BURST) {
337                 unsigned j;
338                 while (rte_mempool_get_bulk(p, (void *)bufs, BURST) < 0)
339                         rte_distributor_process(d, NULL, 0);
340                 for (j = 0; j < BURST; j++) {
341                         bufs[j]->hash.usr = (i+j) << 1;
342                         rte_mbuf_refcnt_set(bufs[j], 1);
343                 }
344
345                 rte_distributor_process(d, bufs, BURST);
346         }
347
348         rte_distributor_flush(d);
349
350         rte_delay_us(10000);
351
352         if (total_packet_count() < (1<<ITER_POWER)) {
353                 printf("Line %u: Packet count is incorrect, %u, expected %u\n",
354                                 __LINE__, total_packet_count(),
355                                 (1<<ITER_POWER));
356                 return -1;
357         }
358
359         printf("Sanity test with mbuf alloc/free passed\n\n");
360         return 0;
361 }
362
363 static int
364 handle_work_for_shutdown_test(void *arg)
365 {
366         struct rte_mbuf *pkt = NULL;
367         struct rte_mbuf *buf[8] __rte_cache_aligned;
368         struct worker_params *wp = arg;
369         struct rte_distributor *d = wp->dist;
370         unsigned int count = 0;
371         unsigned int num = 0;
372         unsigned int total = 0;
373         unsigned int i;
374         unsigned int returned = 0;
375         const unsigned int id = __sync_fetch_and_add(&worker_idx, 1);
376
377         num = rte_distributor_get_pkt(d, id, buf, buf, num);
378
379         /* wait for quit single globally, or for worker zero, wait
380          * for zero_quit */
381         while (!quit && !(id == 0 && zero_quit)) {
382                 worker_stats[id].handled_packets += num;
383                 count += num;
384                 for (i = 0; i < num; i++)
385                         rte_pktmbuf_free(buf[i]);
386                 num = rte_distributor_get_pkt(d,
387                                 id, buf, buf, num);
388                 total += num;
389         }
390         worker_stats[id].handled_packets += num;
391         count += num;
392         returned = rte_distributor_return_pkt(d, id, buf, num);
393
394         if (id == 0) {
395                 /* for worker zero, allow it to restart to pick up last packet
396                  * when all workers are shutting down.
397                  */
398                 while (zero_quit)
399                         usleep(100);
400
401                 num = rte_distributor_get_pkt(d,
402                                 id, buf, buf, num);
403
404                 while (!quit) {
405                         worker_stats[id].handled_packets++, count++;
406                         rte_pktmbuf_free(pkt);
407                         num = rte_distributor_get_pkt(d, id, buf, buf, num);
408                 }
409                 returned = rte_distributor_return_pkt(d,
410                                 id, buf, num);
411                 printf("Num returned = %d\n", returned);
412         }
413         return 0;
414 }
415
416
417 /* Perform a sanity test of the distributor with a large number of packets,
418  * where we allocate a new set of mbufs for each burst. The workers then
419  * free the mbufs. This ensures that we don't have any packet leaks in the
420  * library.
421  */
422 static int
423 sanity_test_with_worker_shutdown(struct worker_params *wp,
424                 struct rte_mempool *p)
425 {
426         struct rte_distributor *d = wp->dist;
427         struct rte_mbuf *bufs[BURST];
428         unsigned i;
429
430         printf("=== Sanity test of worker shutdown ===\n");
431
432         clear_packet_count();
433
434         if (rte_mempool_get_bulk(p, (void *)bufs, BURST) != 0) {
435                 printf("line %d: Error getting mbufs from pool\n", __LINE__);
436                 return -1;
437         }
438
439         /*
440          * Now set all hash values in all buffers to same value so all
441          * pkts go to the one worker thread
442          */
443         for (i = 0; i < BURST; i++)
444                 bufs[i]->hash.usr = 1;
445
446         rte_distributor_process(d, bufs, BURST);
447         rte_distributor_flush(d);
448
449         /* at this point, we will have processed some packets and have a full
450          * backlog for the other ones at worker 0.
451          */
452
453         /* get more buffers to queue up, again setting them to the same flow */
454         if (rte_mempool_get_bulk(p, (void *)bufs, BURST) != 0) {
455                 printf("line %d: Error getting mbufs from pool\n", __LINE__);
456                 return -1;
457         }
458         for (i = 0; i < BURST; i++)
459                 bufs[i]->hash.usr = 1;
460
461         /* get worker zero to quit */
462         zero_quit = 1;
463         rte_distributor_process(d, bufs, BURST);
464
465         /* flush the distributor */
466         rte_distributor_flush(d);
467         rte_delay_us(10000);
468
469         for (i = 0; i < rte_lcore_count() - 1; i++)
470                 printf("Worker %u handled %u packets\n", i,
471                                 worker_stats[i].handled_packets);
472
473         if (total_packet_count() != BURST * 2) {
474                 printf("Line %d: Error, not all packets flushed. "
475                                 "Expected %u, got %u\n",
476                                 __LINE__, BURST * 2, total_packet_count());
477                 return -1;
478         }
479
480         printf("Sanity test with worker shutdown passed\n\n");
481         return 0;
482 }
483
484 /* Test that the flush function is able to move packets between workers when
485  * one worker shuts down..
486  */
487 static int
488 test_flush_with_worker_shutdown(struct worker_params *wp,
489                 struct rte_mempool *p)
490 {
491         struct rte_distributor *d = wp->dist;
492         struct rte_mbuf *bufs[BURST];
493         unsigned i;
494
495         printf("=== Test flush fn with worker shutdown (%s) ===\n", wp->name);
496
497         clear_packet_count();
498         if (rte_mempool_get_bulk(p, (void *)bufs, BURST) != 0) {
499                 printf("line %d: Error getting mbufs from pool\n", __LINE__);
500                 return -1;
501         }
502
503         /* now set all hash values in all buffers to zero, so all pkts go to the
504          * one worker thread */
505         for (i = 0; i < BURST; i++)
506                 bufs[i]->hash.usr = 0;
507
508         rte_distributor_process(d, bufs, BURST);
509         /* at this point, we will have processed some packets and have a full
510          * backlog for the other ones at worker 0.
511          */
512
513         /* get worker zero to quit */
514         zero_quit = 1;
515
516         /* flush the distributor */
517         rte_distributor_flush(d);
518
519         rte_delay_us(10000);
520
521         zero_quit = 0;
522         for (i = 0; i < rte_lcore_count() - 1; i++)
523                 printf("Worker %u handled %u packets\n", i,
524                                 worker_stats[i].handled_packets);
525
526         if (total_packet_count() != BURST) {
527                 printf("Line %d: Error, not all packets flushed. "
528                                 "Expected %u, got %u\n",
529                                 __LINE__, BURST, total_packet_count());
530                 return -1;
531         }
532
533         printf("Flush test with worker shutdown passed\n\n");
534         return 0;
535 }
536
537 static
538 int test_error_distributor_create_name(void)
539 {
540         struct rte_distributor *d = NULL;
541         struct rte_distributor *db = NULL;
542         char *name = NULL;
543
544         d = rte_distributor_create(name, rte_socket_id(),
545                         rte_lcore_count() - 1,
546                         RTE_DIST_ALG_SINGLE);
547         if (d != NULL || rte_errno != EINVAL) {
548                 printf("ERROR: No error on create() with NULL name param\n");
549                 return -1;
550         }
551
552         db = rte_distributor_create(name, rte_socket_id(),
553                         rte_lcore_count() - 1,
554                         RTE_DIST_ALG_BURST);
555         if (db != NULL || rte_errno != EINVAL) {
556                 printf("ERROR: No error on create() with NULL param\n");
557                 return -1;
558         }
559
560         return 0;
561 }
562
563
564 static
565 int test_error_distributor_create_numworkers(void)
566 {
567         struct rte_distributor *ds = NULL;
568         struct rte_distributor *db = NULL;
569
570         ds = rte_distributor_create("test_numworkers", rte_socket_id(),
571                         RTE_MAX_LCORE + 10,
572                         RTE_DIST_ALG_SINGLE);
573         if (ds != NULL || rte_errno != EINVAL) {
574                 printf("ERROR: No error on create() with num_workers > MAX\n");
575                 return -1;
576         }
577
578         db = rte_distributor_create("test_numworkers", rte_socket_id(),
579                         RTE_MAX_LCORE + 10,
580                         RTE_DIST_ALG_BURST);
581         if (db != NULL || rte_errno != EINVAL) {
582                 printf("ERROR: No error on create() num_workers > MAX\n");
583                 return -1;
584         }
585
586         return 0;
587 }
588
589
590 /* Useful function which ensures that all worker functions terminate */
591 static void
592 quit_workers(struct worker_params *wp, struct rte_mempool *p)
593 {
594         struct rte_distributor *d = wp->dist;
595         const unsigned num_workers = rte_lcore_count() - 1;
596         unsigned i;
597         struct rte_mbuf *bufs[RTE_MAX_LCORE];
598         rte_mempool_get_bulk(p, (void *)bufs, num_workers);
599
600         zero_quit = 0;
601         quit = 1;
602         for (i = 0; i < num_workers; i++)
603                 bufs[i]->hash.usr = i << 1;
604         rte_distributor_process(d, bufs, num_workers);
605
606         rte_mempool_put_bulk(p, (void *)bufs, num_workers);
607
608         rte_distributor_process(d, NULL, 0);
609         rte_distributor_flush(d);
610         rte_eal_mp_wait_lcore();
611         quit = 0;
612         worker_idx = 0;
613 }
614
615 static int
616 test_distributor(void)
617 {
618         static struct rte_distributor *ds;
619         static struct rte_distributor *db;
620         static struct rte_distributor *dist[2];
621         static struct rte_mempool *p;
622         int i;
623
624         if (rte_lcore_count() < 2) {
625                 printf("ERROR: not enough cores to test distributor\n");
626                 return -1;
627         }
628
629         if (db == NULL) {
630                 db = rte_distributor_create("Test_dist_burst", rte_socket_id(),
631                                 rte_lcore_count() - 1,
632                                 RTE_DIST_ALG_BURST);
633                 if (db == NULL) {
634                         printf("Error creating burst distributor\n");
635                         return -1;
636                 }
637         } else {
638                 rte_distributor_flush(db);
639                 rte_distributor_clear_returns(db);
640         }
641
642         if (ds == NULL) {
643                 ds = rte_distributor_create("Test_dist_single",
644                                 rte_socket_id(),
645                                 rte_lcore_count() - 1,
646                         RTE_DIST_ALG_SINGLE);
647                 if (ds == NULL) {
648                         printf("Error creating single distributor\n");
649                         return -1;
650                 }
651         } else {
652                 rte_distributor_flush(ds);
653                 rte_distributor_clear_returns(ds);
654         }
655
656         const unsigned nb_bufs = (511 * rte_lcore_count()) < BIG_BATCH ?
657                         (BIG_BATCH * 2) - 1 : (511 * rte_lcore_count());
658         if (p == NULL) {
659                 p = rte_pktmbuf_pool_create("DT_MBUF_POOL", nb_bufs, BURST,
660                         0, RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id());
661                 if (p == NULL) {
662                         printf("Error creating mempool\n");
663                         return -1;
664                 }
665         }
666
667         dist[0] = ds;
668         dist[1] = db;
669
670         for (i = 0; i < 2; i++) {
671
672                 worker_params.dist = dist[i];
673                 if (i)
674                         sprintf(worker_params.name, "burst");
675                 else
676                         sprintf(worker_params.name, "single");
677
678                 rte_eal_mp_remote_launch(handle_work,
679                                 &worker_params, SKIP_MASTER);
680                 if (sanity_test(&worker_params, p) < 0)
681                         goto err;
682                 quit_workers(&worker_params, p);
683
684                 rte_eal_mp_remote_launch(handle_work_with_free_mbufs,
685                                 &worker_params, SKIP_MASTER);
686                 if (sanity_test_with_mbuf_alloc(&worker_params, p) < 0)
687                         goto err;
688                 quit_workers(&worker_params, p);
689
690                 if (rte_lcore_count() > 2) {
691                         rte_eal_mp_remote_launch(handle_work_for_shutdown_test,
692                                         &worker_params,
693                                         SKIP_MASTER);
694                         if (sanity_test_with_worker_shutdown(&worker_params,
695                                         p) < 0)
696                                 goto err;
697                         quit_workers(&worker_params, p);
698
699                         rte_eal_mp_remote_launch(handle_work_for_shutdown_test,
700                                         &worker_params,
701                                         SKIP_MASTER);
702                         if (test_flush_with_worker_shutdown(&worker_params,
703                                         p) < 0)
704                                 goto err;
705                         quit_workers(&worker_params, p);
706
707                 } else {
708                         printf("Too few cores to run worker shutdown test\n");
709                 }
710
711         }
712
713         if (test_error_distributor_create_numworkers() == -1 ||
714                         test_error_distributor_create_name() == -1) {
715                 printf("rte_distributor_create parameter check tests failed");
716                 return -1;
717         }
718
719         return 0;
720
721 err:
722         quit_workers(&worker_params, p);
723         return -1;
724 }
725
726 REGISTER_TEST_COMMAND(distributor_autotest, test_distributor);