| 407 | |
| 408 | |
| 409 | static int |
| 410 | lcore_distributor(struct lcore_params *p) |
| 411 | { |
| 412 | struct rte_ring *in_r = p->rx_dist_ring; |
| 413 | struct rte_ring *out_r = p->dist_tx_ring; |
| 414 | struct rte_mbuf *bufs[BURST_SIZE * 4]; |
| 415 | struct rte_distributor *d = p->d; |
| 416 | |
| 417 | printf("\nCore %u acting as distributor core.\n", rte_lcore_id()); |
| 418 | while (!quit_signal_dist) { |
| 419 | const uint16_t nb_rx = rte_ring_dequeue_burst(in_r, |
| 420 | (void *)bufs, BURST_SIZE*1, NULL); |
| 421 | if (nb_rx) { |
| 422 | app_stats.dist.in_pkts += nb_rx; |
| 423 | |
| 424 | /* Distribute the packets */ |
| 425 | rte_distributor_process(d, bufs, nb_rx); |
| 426 | /* Handle Returns */ |
| 427 | const uint16_t nb_ret = |
| 428 | rte_distributor_returned_pkts(d, |
| 429 | bufs, BURST_SIZE*2); |
| 430 | |
| 431 | if (unlikely(nb_ret == 0)) |
| 432 | continue; |
| 433 | app_stats.dist.ret_pkts += nb_ret; |
| 434 | |
| 435 | uint16_t sent = rte_ring_enqueue_burst(out_r, |
| 436 | (void *)bufs, nb_ret, NULL); |
| 437 | app_stats.dist.sent_pkts += sent; |
| 438 | if (unlikely(sent < nb_ret)) { |
| 439 | app_stats.dist.enqdrop_pkts += nb_ret - sent; |
| 440 | RTE_LOG(DEBUG, DISTRAPP, |
| 441 | "%s:Packet loss due to full out ring\n", |
| 442 | __func__); |
| 443 | while (sent < nb_ret) |
| 444 | rte_pktmbuf_free(bufs[sent++]); |
| 445 | } |
| 446 | } |
| 447 | } |
| 448 | if (power_lib_initialised) |
| 449 | rte_power_exit(rte_lcore_id()); |
| 450 | printf("\nCore %u exiting distributor task.\n", rte_lcore_id()); |
| 451 | /* set tx threads quit flag */ |
| 452 | quit_signal = 1; |
| 453 | /* set worker threads quit flag */ |
| 454 | quit_signal_work = 1; |
| 455 | rte_distributor_flush(d); |
| 456 | /* Unblock any returns so workers can exit */ |
| 457 | rte_distributor_clear_returns(d); |
| 458 | return 0; |
| 459 | } |
| 460 | |
| 461 | |
| 462 | static int |
nothing calls this directly
no test coverage detected