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

Function dma_rx_port

dpdk/examples/dma/dmafwd.c:399–474  ·  view source on GitHub ↗

Receive packets on one port and enqueue to dmadev or rte_ring. 8< */

Source from the content-addressed store, hash-verified

397
398/* Receive packets on one port and enqueue to dmadev or rte_ring. 8< */
399static void
400dma_rx_port(struct rxtx_port_config *rx_config)
401{
402 int32_t ret;
403 uint32_t nb_rx, nb_enq, i, j;
404 struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
405 struct rte_mbuf *pkts_burst_copy[MAX_PKT_BURST];
406
407 for (i = 0; i < rx_config->nb_queues; i++) {
408
409 nb_rx = rte_eth_rx_burst(rx_config->rxtx_port, i,
410 pkts_burst, MAX_PKT_BURST);
411
412 if (nb_rx == 0) {
413 if (copy_mode == COPY_MODE_DMA_NUM &&
414 (nb_rx = dma_dequeue(pkts_burst, pkts_burst_copy,
415 MAX_PKT_BURST, rx_config->dmadev_ids[i])) > 0)
416 goto handle_tx;
417 continue;
418 }
419
420 port_statistics.rx[rx_config->rxtx_port] += nb_rx;
421
422 ret = rte_mempool_get_bulk(dma_pktmbuf_pool,
423 (void *)pkts_burst_copy, nb_rx);
424
425 if (unlikely(ret < 0))
426 rte_exit(EXIT_FAILURE,
427 "Unable to allocate memory.\n");
428
429 for (j = 0; j < nb_rx; j++)
430 pktmbuf_metadata_copy(pkts_burst[j],
431 pkts_burst_copy[j]);
432
433 if (copy_mode == COPY_MODE_DMA_NUM) {
434 /* enqueue packets for hardware copy */
435 nb_enq = dma_enqueue(pkts_burst, pkts_burst_copy,
436 nb_rx, dma_batch_sz, rx_config->dmadev_ids[i]);
437
438 /* free any not enqueued packets. */
439 rte_mempool_put_bulk(dma_pktmbuf_pool,
440 (void *)&pkts_burst[nb_enq],
441 nb_rx - nb_enq);
442 rte_mempool_put_bulk(dma_pktmbuf_pool,
443 (void *)&pkts_burst_copy[nb_enq],
444 nb_rx - nb_enq);
445
446 port_statistics.copy_dropped[rx_config->rxtx_port] +=
447 (nb_rx - nb_enq);
448
449 /* get completed copies */
450 nb_rx = dma_dequeue(pkts_burst, pkts_burst_copy,
451 MAX_PKT_BURST, rx_config->dmadev_ids[i]);
452 } else {
453 /* Perform packet software copy, free source packets */
454 for (j = 0; j < nb_rx; j++)
455 pktmbuf_sw_copy(pkts_burst[j],
456 pkts_burst_copy[j]);

Callers 2

rx_main_loopFunction · 0.85
rxtx_main_loopFunction · 0.85

Calls 9

rte_eth_rx_burstFunction · 0.85
dma_dequeueFunction · 0.85
rte_mempool_get_bulkFunction · 0.85
rte_exitFunction · 0.85
pktmbuf_metadata_copyFunction · 0.85
dma_enqueueFunction · 0.85
rte_mempool_put_bulkFunction · 0.85
pktmbuf_sw_copyFunction · 0.85
rte_ring_enqueue_burstFunction · 0.85

Tested by

no test coverage detected