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

Function ena_populate_rx_queue

dpdk/drivers/net/ena/ena_ethdev.c:1692–1757  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1690}
1691
1692static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count)
1693{
1694 unsigned int i;
1695 int rc;
1696 uint16_t next_to_use = rxq->next_to_use;
1697 uint16_t req_id;
1698#ifdef RTE_ETHDEV_DEBUG_RX
1699 uint16_t in_use;
1700#endif
1701 struct rte_mbuf **mbufs = rxq->rx_refill_buffer;
1702
1703 if (unlikely(!count))
1704 return 0;
1705
1706#ifdef RTE_ETHDEV_DEBUG_RX
1707 in_use = rxq->ring_size - 1 -
1708 ena_com_free_q_entries(rxq->ena_com_io_sq);
1709 if (unlikely((in_use + count) >= rxq->ring_size))
1710 PMD_RX_LOG(ERR, "Bad Rx ring state\n");
1711#endif
1712
1713 /* get resources for incoming packets */
1714 rc = rte_pktmbuf_alloc_bulk(rxq->mb_pool, mbufs, count);
1715 if (unlikely(rc < 0)) {
1716 rte_atomic64_inc(&rxq->adapter->drv_stats->rx_nombuf);
1717 ++rxq->rx_stats.mbuf_alloc_fail;
1718 PMD_RX_LOG(DEBUG, "There are not enough free buffers\n");
1719 return 0;
1720 }
1721
1722 for (i = 0; i < count; i++) {
1723 struct rte_mbuf *mbuf = mbufs[i];
1724 struct ena_rx_buffer *rx_info;
1725
1726 if (likely((i + 4) < count))
1727 rte_prefetch0(mbufs[i + 4]);
1728
1729 req_id = rxq->empty_rx_reqs[next_to_use];
1730 rx_info = &rxq->rx_buffer_info[req_id];
1731
1732 rc = ena_add_single_rx_desc(rxq->ena_com_io_sq, mbuf, req_id);
1733 if (unlikely(rc != 0))
1734 break;
1735
1736 rx_info->mbuf = mbuf;
1737 next_to_use = ENA_IDX_NEXT_MASKED(next_to_use, rxq->size_mask);
1738 }
1739
1740 if (unlikely(i < count)) {
1741 PMD_RX_LOG(WARNING,
1742 "Refilled Rx queue[%d] with only %d/%d buffers\n",
1743 rxq->id, i, count);
1744 rte_pktmbuf_free_bulk(&mbufs[i], count - i);
1745 ++rxq->rx_stats.refill_partial;
1746 }
1747
1748 /* When we submitted free resources to device... */
1749 if (likely(i > 0)) {

Callers 2

ena_queue_startFunction · 0.85
eth_ena_recv_pktsFunction · 0.85

Calls 7

rte_pktmbuf_alloc_bulkFunction · 0.85
ena_add_single_rx_descFunction · 0.85
rte_pktmbuf_free_bulkFunction · 0.85
ena_com_free_q_entriesFunction · 0.50
rte_atomic64_incFunction · 0.50
rte_prefetch0Function · 0.50

Tested by

no test coverage detected