Test that the flush function is able to move packets between workers when * one worker shuts down.. */
| 523 | * one worker shuts down.. |
| 524 | */ |
| 525 | static int |
| 526 | test_flush_with_worker_shutdown(struct worker_params *wp, |
| 527 | struct rte_mempool *p) |
| 528 | { |
| 529 | struct rte_distributor *d = wp->dist; |
| 530 | struct rte_mbuf *bufs[BURST]; |
| 531 | unsigned int i; |
| 532 | unsigned int failed = 0; |
| 533 | unsigned int processed; |
| 534 | |
| 535 | printf("=== Test flush fn with worker shutdown (%s) ===\n", wp->name); |
| 536 | |
| 537 | clear_packet_count(); |
| 538 | if (rte_mempool_get_bulk(p, (void *)bufs, BURST) != 0) { |
| 539 | printf("line %d: Error getting mbufs from pool\n", __LINE__); |
| 540 | return -1; |
| 541 | } |
| 542 | |
| 543 | /* now set all hash values in all buffers to zero, so all pkts go to the |
| 544 | * one worker thread */ |
| 545 | for (i = 0; i < BURST; i++) |
| 546 | bufs[i]->hash.usr = 0; |
| 547 | |
| 548 | processed = 0; |
| 549 | while (processed < BURST) |
| 550 | processed += rte_distributor_process(d, &bufs[processed], |
| 551 | BURST - processed); |
| 552 | /* at this point, we will have processed some packets and have a full |
| 553 | * backlog for the other ones at worker 0. |
| 554 | */ |
| 555 | |
| 556 | /* get worker zero to quit */ |
| 557 | zero_quit = 1; |
| 558 | |
| 559 | /* flush the distributor */ |
| 560 | rte_distributor_flush(d); |
| 561 | |
| 562 | while (!__atomic_load_n(&zero_sleep, __ATOMIC_ACQUIRE)) |
| 563 | rte_distributor_flush(d); |
| 564 | |
| 565 | zero_quit = 0; |
| 566 | |
| 567 | while (__atomic_load_n(&zero_sleep, __ATOMIC_ACQUIRE)) |
| 568 | rte_delay_us(100); |
| 569 | |
| 570 | for (i = 0; i < rte_lcore_count() - 1; i++) |
| 571 | printf("Worker %u handled %u packets\n", i, |
| 572 | __atomic_load_n(&worker_stats[i].handled_packets, |
| 573 | __ATOMIC_RELAXED)); |
| 574 | |
| 575 | if (total_packet_count() != BURST) { |
| 576 | printf("Line %d: Error, not all packets flushed. " |
| 577 | "Expected %u, got %u\n", |
| 578 | __LINE__, BURST, total_packet_count()); |
| 579 | failed = 1; |
| 580 | } |
| 581 | |
| 582 | rte_mempool_put_bulk(p, (void *)bufs, BURST); |
no test coverage detected