Perform a sanity test of the distributor with a large number of packets, * where we allocate a new set of mbufs for each burst. The workers then * free the mbufs. This ensures that we don't have any packet leaks in the * library. */
| 439 | * library. |
| 440 | */ |
| 441 | static int |
| 442 | sanity_test_with_worker_shutdown(struct worker_params *wp, |
| 443 | struct rte_mempool *p) |
| 444 | { |
| 445 | struct rte_distributor *d = wp->dist; |
| 446 | struct rte_mbuf *bufs[BURST]; |
| 447 | struct rte_mbuf *bufs2[BURST]; |
| 448 | unsigned int i; |
| 449 | unsigned int failed = 0; |
| 450 | unsigned int processed = 0; |
| 451 | |
| 452 | printf("=== Sanity test of worker shutdown ===\n"); |
| 453 | |
| 454 | clear_packet_count(); |
| 455 | |
| 456 | if (rte_mempool_get_bulk(p, (void *)bufs, BURST) != 0) { |
| 457 | printf("line %d: Error getting mbufs from pool\n", __LINE__); |
| 458 | return -1; |
| 459 | } |
| 460 | |
| 461 | /* |
| 462 | * Now set all hash values in all buffers to same value so all |
| 463 | * pkts go to the one worker thread |
| 464 | */ |
| 465 | for (i = 0; i < BURST; i++) |
| 466 | bufs[i]->hash.usr = 1; |
| 467 | |
| 468 | processed = 0; |
| 469 | while (processed < BURST) |
| 470 | processed += rte_distributor_process(d, &bufs[processed], |
| 471 | BURST - processed); |
| 472 | rte_distributor_flush(d); |
| 473 | |
| 474 | /* at this point, we will have processed some packets and have a full |
| 475 | * backlog for the other ones at worker 0. |
| 476 | */ |
| 477 | |
| 478 | /* get more buffers to queue up, again setting them to the same flow */ |
| 479 | if (rte_mempool_get_bulk(p, (void *)bufs2, BURST) != 0) { |
| 480 | printf("line %d: Error getting mbufs from pool\n", __LINE__); |
| 481 | rte_mempool_put_bulk(p, (void *)bufs, BURST); |
| 482 | return -1; |
| 483 | } |
| 484 | for (i = 0; i < BURST; i++) |
| 485 | bufs2[i]->hash.usr = 1; |
| 486 | |
| 487 | /* get worker zero to quit */ |
| 488 | zero_quit = 1; |
| 489 | rte_distributor_process(d, bufs2, BURST); |
| 490 | |
| 491 | /* flush the distributor */ |
| 492 | rte_distributor_flush(d); |
| 493 | while (!__atomic_load_n(&zero_sleep, __ATOMIC_ACQUIRE)) |
| 494 | rte_distributor_flush(d); |
| 495 | |
| 496 | zero_quit = 0; |
| 497 | while (__atomic_load_n(&zero_sleep, __ATOMIC_ACQUIRE)) |
| 498 | rte_delay_us(100); |
no test coverage detected