From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 10BFF43FEF;
	Fri, 10 May 2024 12:04:27 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id F32DC402EF;
	Fri, 10 May 2024 12:04:26 +0200 (CEST)
Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13])
 by mails.dpdk.org (Postfix) with ESMTP id C9FEF402BB
 for <dev@dpdk.org>; Fri, 10 May 2024 12:04:24 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
 d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
 t=1715335465; x=1746871465;
 h=from:to:cc:subject:date:message-id:in-reply-to:
 references:mime-version:content-transfer-encoding;
 bh=eIPM6CTtZnF+YyTVkTD5j+kd0Le1RPg+Et+ENbtc+jI=;
 b=RK3c/6NChVnDXaoqoqpe7zXtvcAGhr19hJR6LOkgsxnmNPijFEeiZN+g
 GdfePd1p/RTdpbBblE4Xgh1PAZxcv+FtPURD+7DAdS9ocHlQm/IbmsaNp
 VxAkg7OD9KnkHo55PfsG1GjcN0/yuhH20HujKxPv61+Ng/VN6PZold92k
 /HQNfb4IWsbAX1ZtG8SIA7ATSKKV2oOelMW1aLj+POQi82inqSNn3TCxX
 sImAB4j3Z49NBTLA/0+VZX1IWNLldcZHTu94ynseSnndFjPchz6H6u+pi
 /rPuRDmfiU1hUuJKav1CzlXyV7omsIq6/73aedVsTwOwn4lPQFlYYPIUM A==;
X-CSE-ConnectionGUID: pb8TK21yQCeA+uQaoXhXig==
X-CSE-MsgGUID: gWHGDCLpT8q1jAHyV8hb3g==
X-IronPort-AV: E=McAfee;i="6600,9927,11068"; a="22460633"
X-IronPort-AV: E=Sophos;i="6.08,150,1712646000"; d="scan'208";a="22460633"
Received: from orviesa009.jf.intel.com ([10.64.159.149])
 by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 10 May 2024 03:04:24 -0700
X-CSE-ConnectionGUID: 1JfqTSTBQbqd5yIT8dDGsg==
X-CSE-MsgGUID: OysLYIRnTW+CCa23Nf01kw==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="6.08,150,1712646000"; d="scan'208";a="29672606"
Received: from silpixa00401177.ir.intel.com (HELO vm177..) ([10.55.128.139])
 by orviesa009.jf.intel.com with ESMTP; 10 May 2024 03:04:23 -0700
From: Ciara Loftus <ciara.loftus@intel.com>
To: dev@dpdk.org
Cc: stephen@networkplumber.org, Ciara Loftus <ciara.loftus@intel.com>,
 stable@dpdk.og
Subject: [PATCH 2/3] net/af_xdp: Fix mbuf alloc failed statistic
Date: Fri, 10 May 2024 10:03:57 +0000
Message-Id: <20240510100358.18815-2-ciara.loftus@intel.com>
X-Mailer: git-send-email 2.34.1
In-Reply-To: <20240510100358.18815-1-ciara.loftus@intel.com>
References: <20240510100358.18815-1-ciara.loftus@intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

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.og

Reported-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index fee0d5d5f3..968bbf6d45 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -124,6 +124,7 @@ struct rx_stats {
 	uint64_t rx_pkts;
 	uint64_t rx_bytes;
 	uint64_t rx_dropped;
+	uint64_t alloc_failed;
 };
 
 struct pkt_rx_queue {
@@ -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;
+		rxq->stats.alloc_failed += nb_pkts;
+
 		return 0;
 	}
 
@@ -408,6 +411,7 @@ af_xdp_rx_cp(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 		 * xsk_ring_cons__peek
 		 */
 		rx->cached_cons -= nb_pkts;
+		rxq->stats.alloc_failed += nb_pkts;
 		return 0;
 	}
 
@@ -872,6 +876,7 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 		stats->ibytes += stats->q_ibytes[i];
 		stats->imissed += rxq->stats.rx_dropped;
 		stats->oerrors += txq->stats.tx_dropped;
+		dev->data->rx_mbuf_alloc_failed += rxq->stats.alloc_failed;
 		fd = process_private->rxq_xsk_fds[i];
 		ret = fd >= 0 ? getsockopt(fd, SOL_XDP, XDP_STATISTICS,
 					   &xdp_stats, &optlen) : -1;
-- 
2.34.1