Skip to content

Commit

Permalink
net/af_xdp: count mbuf allocation failures
Browse files Browse the repository at this point in the history
[ upstream commit f294405ab98594aa41269507dde95cc89bb20a61 ]

Failures to allocate mbufs in the receive path were not being
accounted for in the ethdev statistics. Fix this.

Bugzilla ID: 1429
Fixes: f1debd7 ("net/af_xdp: introduce AF_XDP PMD")

Reported-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
  • Loading branch information
cloftus authored and bluca committed Jun 24, 2024
1 parent 20c39f6 commit 13ac242
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/net/af_xdp/rte_eth_af_xdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ af_xdp_rx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
unsigned long rx_bytes = 0;
int i;
struct rte_mbuf *fq_bufs[ETH_AF_XDP_RX_BATCH_SIZE];
struct rte_eth_dev *dev = &rte_eth_devices[rxq->port];

nb_pkts = xsk_ring_cons__peek(rx, nb_pkts, &idx_rx);

Expand Down Expand Up @@ -317,6 +318,8 @@ af_xdp_rx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
* xsk_ring_cons__peek
*/
rx->cached_cons -= nb_pkts;
dev->data->rx_mbuf_alloc_failed += nb_pkts;

return 0;
}

Expand Down Expand Up @@ -368,6 +371,7 @@ af_xdp_rx_cp(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
int i;
uint32_t free_thresh = fq->size >> 1;
struct rte_mbuf *mbufs[ETH_AF_XDP_RX_BATCH_SIZE];
struct rte_eth_dev *dev = &rte_eth_devices[rxq->port];

if (xsk_prod_nb_free(fq, free_thresh) >= free_thresh)
(void)reserve_fill_queue(umem, nb_pkts, NULL, fq);
Expand All @@ -386,6 +390,7 @@ af_xdp_rx_cp(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
* xsk_ring_cons__peek
*/
rx->cached_cons -= nb_pkts;
dev->data->rx_mbuf_alloc_failed += nb_pkts;
return 0;
}

Expand Down

0 comments on commit 13ac242

Please sign in to comment.