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

Function sanity_mark_test

dpdk/app/test/test_distributor.c:619–729  ·  view source on GitHub ↗

sanity_mark_test sends packets to workers which mark them. * Every packet has also encoded sequence number. * The returned packets are sorted and verified if they were handled * by proper workers. */

Source from the content-addressed store, hash-verified

617 * by proper workers.
618 */
619static int
620sanity_mark_test(struct worker_params *wp, struct rte_mempool *p)
621{
622 const unsigned int buf_count = 24;
623 const unsigned int burst = 8;
624 const unsigned int shift = 12;
625 const unsigned int seq_shift = 10;
626
627 struct rte_distributor *db = wp->dist;
628 struct rte_mbuf *bufs[buf_count];
629 struct rte_mbuf *returns[buf_count];
630 unsigned int i, count, id;
631 unsigned int sorted[buf_count], seq;
632 unsigned int failed = 0;
633 unsigned int processed;
634
635 printf("=== Marked packets test ===\n");
636 clear_packet_count();
637 if (rte_mempool_get_bulk(p, (void *)bufs, buf_count) != 0) {
638 printf("line %d: Error getting mbufs from pool\n", __LINE__);
639 return -1;
640 }
641
642 /* bufs' hashes will be like these below, but shifted left.
643 * The shifting is for avoiding collisions with backlogs
644 * and in-flight tags left by previous tests.
645 * [1, 1, 1, 1, 1, 1, 1, 1
646 * 1, 1, 1, 1, 2, 2, 2, 2
647 * 2, 2, 2, 2, 1, 1, 1, 1]
648 */
649 for (i = 0; i < burst; i++) {
650 bufs[0 * burst + i]->hash.usr = 1 << shift;
651 bufs[1 * burst + i]->hash.usr = ((i < burst / 2) ? 1 : 2)
652 << shift;
653 bufs[2 * burst + i]->hash.usr = ((i < burst / 2) ? 2 : 1)
654 << shift;
655 }
656 /* Assign a sequence number to each packet. The sequence is shifted,
657 * so that lower bits will hold mark from worker.
658 */
659 for (i = 0; i < buf_count; i++)
660 *seq_field(bufs[i]) = i << seq_shift;
661
662 count = 0;
663 for (i = 0; i < buf_count/burst; i++) {
664 processed = 0;
665 while (processed < burst)
666 processed += rte_distributor_process(db,
667 &bufs[i * burst + processed],
668 burst - processed);
669 count += rte_distributor_returned_pkts(db, &returns[count],
670 buf_count - count);
671 }
672
673 do {
674 rte_distributor_flush(db);
675 count += rte_distributor_returned_pkts(db, &returns[count],
676 buf_count - count);

Callers 1

test_distributorFunction · 0.85

Calls 9

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

Tested by

no test coverage detected