[v2,2/4] net/af_xdp: fix mbuf alloc failed statistic
Checks
Commit Message
Failures to allocate mbufs in the receive path were not being
accounted for in the ethdev statistics. Fix this.
Bugzilla ID: 1429
Fixes: f1debd77efaf ("net/af_xdp: introduce AF_XDP PMD")
cc: stable@dpdk.org
Reported-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
---
v2:
* Fixed typo in commit message
* Remove unnecessary local stat for alloc_failed
drivers/net/af_xdp/rte_eth_af_xdp.c | 5 +++++
1 file changed, 5 insertions(+)
@@ -312,6 +312,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);
@@ -339,6 +340,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;
}
@@ -390,6 +393,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);
@@ -408,6 +412,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;
}