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

Function main_loop

dpdk/app/test/test_pmd_perf.c:452–538  ·  view source on GitHub ↗

main processing loop */

Source from the content-addressed store, hash-verified

450
451/* main processing loop */
452static int
453main_loop(__rte_unused void *args)
454{
455#define PACKET_SIZE 64
456#define FRAME_GAP 12
457#define MAC_PREAMBLE 8
458#define MAX_RETRY_COUNT 5
459 struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
460 unsigned lcore_id;
461 unsigned i, portid, nb_rx = 0, nb_tx = 0;
462 struct lcore_conf *conf;
463 int pkt_per_port;
464 uint64_t diff_tsc;
465 uint64_t packets_per_second, total_packets;
466 int retry_cnt = 0;
467 int free_pkt = 0;
468
469 lcore_id = rte_lcore_id();
470 conf = &lcore_conf[lcore_id];
471 if (conf->status != LCORE_USED)
472 return 0;
473
474 pkt_per_port = MAX_TRAFFIC_BURST;
475
476 int idx = 0;
477 for (i = 0; i < conf->nb_ports; i++) {
478 int num = pkt_per_port;
479 portid = conf->portlist[i];
480 printf("inject %d packet to port %d\n", num, portid);
481 while (num) {
482 nb_tx = RTE_MIN(MAX_PKT_BURST, num);
483 nb_tx = rte_eth_tx_burst(portid, 0,
484 &tx_burst[idx], nb_tx);
485 if (nb_tx == 0)
486 retry_cnt++;
487 num -= nb_tx;
488 idx += nb_tx;
489 if (retry_cnt == MAX_RETRY_COUNT) {
490 retry_cnt = 0;
491 break;
492 }
493 }
494 }
495 for (free_pkt = idx; free_pkt < (MAX_TRAFFIC_BURST * conf->nb_ports);
496 free_pkt++)
497 rte_pktmbuf_free(tx_burst[free_pkt]);
498 printf("Total packets inject to prime ports = %u\n", idx);
499
500 packets_per_second = (link_mbps * 1000 * 1000) /
501 ((PACKET_SIZE + FRAME_GAP + MAC_PREAMBLE) * CHAR_BIT);
502 printf("Each port will do %"PRIu64" packets per second\n",
503 packets_per_second);
504
505 total_packets = RTE_TEST_DURATION * conf->nb_ports * packets_per_second;
506 printf("Test will stop after at least %"PRIu64" packets received\n",
507 + total_packets);
508
509 diff_tsc = do_measure(conf, pkts_burst, total_packets);

Callers

nothing calls this directly

Calls 5

rte_lcore_idFunction · 0.85
rte_eth_tx_burstFunction · 0.85
rte_pktmbuf_freeFunction · 0.85
rte_eth_rx_burstFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected