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

Function lcore_rx_and_distributor

dpdk/examples/distributor/main.c:291–372  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

289}
290
291static int
292lcore_rx_and_distributor(struct lcore_params *p)
293{
294 struct rte_distributor *d = p->d;
295 const uint16_t nb_ports = rte_eth_dev_count_avail();
296 const int socket_id = rte_socket_id();
297 uint16_t port;
298 struct rte_mbuf *bufs[BURST_SIZE*2];
299
300 RTE_ETH_FOREACH_DEV(port) {
301 /* skip ports that are not enabled */
302 if ((enabled_port_mask & (1 << port)) == 0)
303 continue;
304
305 if (rte_eth_dev_socket_id(port) > 0 &&
306 rte_eth_dev_socket_id(port) != socket_id)
307 printf("WARNING, port %u is on remote NUMA node to "
308 "RX thread.\n\tPerformance will not "
309 "be optimal.\n", port);
310 }
311
312 printf("\nCore %u doing packet RX and Distributor.\n", rte_lcore_id());
313 port = 0;
314 while (!quit_signal_rx) {
315
316 /* skip ports that are not enabled */
317 if ((enabled_port_mask & (1 << port)) == 0) {
318 if (++port == nb_ports)
319 port = 0;
320 continue;
321 }
322 const uint16_t nb_rx = rte_eth_rx_burst(port, 0, bufs,
323 BURST_SIZE);
324 if (unlikely(nb_rx == 0)) {
325 if (++port == nb_ports)
326 port = 0;
327 continue;
328 }
329 app_stats.rx.rx_pkts += nb_rx;
330
331 /*
332 * Run the distributor on the rx core. Returned
333 * packets are then send straight to the tx core.
334 */
335 rte_distributor_process(d, bufs, nb_rx);
336 const uint16_t nb_ret = rte_distributor_returned_pkts(d,
337 bufs, BURST_SIZE*2);
338
339 app_stats.rx.returned_pkts += nb_ret;
340 if (unlikely(nb_ret == 0)) {
341 if (++port == nb_ports)
342 port = 0;
343 continue;
344 }
345
346 struct rte_ring *tx_ring = p->dist_tx_ring;
347 uint16_t sent = rte_ring_enqueue_burst(tx_ring,
348 (void *)bufs, nb_ret, NULL);

Callers

nothing calls this directly

Calls 13

rte_eth_dev_count_availFunction · 0.85
rte_socket_idFunction · 0.85
rte_eth_dev_socket_idFunction · 0.85
rte_lcore_idFunction · 0.85
rte_eth_rx_burstFunction · 0.85
rte_distributor_processFunction · 0.85
rte_ring_enqueue_burstFunction · 0.85
rte_pktmbuf_freeFunction · 0.85
rte_power_exitFunction · 0.85
rte_distributor_flushFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected