From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 156C3A0547; Thu, 9 Sep 2021 10:24:13 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 903F640041; Thu, 9 Sep 2021 10:24:12 +0200 (CEST) Received: from mail-m971.mail.163.com (mail-m971.mail.163.com [123.126.97.1]) by mails.dpdk.org (Postfix) with ESMTP id 6E8114003E for ; Thu, 9 Sep 2021 10:24:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=/2B54 A9VQHm8K5xPf4S3a+TvPy+v4Xn5flaURcEW9QY=; b=Cuq/rAb0e2JU9cjYvpCgX j9tMZiTF+u9u4i7GRLN+2J7XN8xOygsBhsNDL3se3CoQ9BFNkMVS2lBkaAbh/rmY GjNpShA61u7hzowuC8tgSMGZ1sGM2Pa3QI7fz6JhB2hCgdC70J3dJsFnRMZMCALG jv20n464wPlUKOJP6pX2Lg= Received: from localhost.localdomain (unknown [124.160.214.74]) by smtp1 (Coremail) with SMTP id GdxpCgAHhGOlxDlhsXxFAw--.65S2; Thu, 09 Sep 2021 16:24:08 +0800 (CST) From: Qiming Chen To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Qiming Chen Date: Thu, 9 Sep 2021 16:23:23 +0800 Message-Id: <20210909082323.10658-1-chenqiming_huawei@163.com> X-Mailer: git-send-email 2.30.1.windows.1 In-Reply-To: <20210909041658.10123-1-chenqiming_huawei@163.com> References: <20210909041658.10123-1-chenqiming_huawei@163.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: GdxpCgAHhGOlxDlhsXxFAw--.65S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxGw1rWF1kJFWrtw45Cw15Arb_yoW5CFy7pa 98Ka47t347XFZrG3srGFWrZr1DG3y2gr4xWFZ7W34Yk3Z8K34Y9ryUKFWjyF92kayDC3Wf Aw4DGFWDJFWUJFUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j5l1kUUUUU= X-Originating-IP: [124.160.214.74] X-CM-SenderInfo: xfkh01xlpl0w5bkxt4lhl6il2tof0z/1tbiDhoJoFXl1QvQUQABsT Subject: [dpdk-dev] [PATCH v5] net/pcap: improve rx statistics X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" In the receiving direction, if alloc mbuf or jumbo process failed, there is no err_pkts count, which makes it difficult to locate the problem. Because alloc mbuf failed, the rx_nombuf field is counted. Signed-off-by: Qiming Chen --- drivers/net/pcap/pcap_ethdev.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c index a8774b7a43..766e239f02 100644 --- a/drivers/net/pcap/pcap_ethdev.c +++ b/drivers/net/pcap/pcap_ethdev.c @@ -51,6 +51,7 @@ struct queue_stat { volatile unsigned long pkts; volatile unsigned long bytes; volatile unsigned long err_pkts; + volatile unsigned long rx_nombuf; }; struct queue_missed_stat { @@ -297,8 +298,10 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) break; mbuf = rte_pktmbuf_alloc(pcap_q->mb_pool); - if (unlikely(mbuf == NULL)) + if (unlikely(mbuf == NULL)) { + pcap_q->rx_stat.rx_nombuf++; break; + } if (header.caplen <= rte_pktmbuf_tailroom(mbuf)) { /* pcap packet will fit in the mbuf, can copy it */ @@ -311,6 +314,7 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) mbuf, packet, header.caplen) == -1)) { + pcap_q->rx_stat.err_pkts++; rte_pktmbuf_free(mbuf); break; } @@ -742,7 +746,7 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { unsigned int i; unsigned long rx_packets_total = 0, rx_bytes_total = 0; - unsigned long rx_missed_total = 0; + unsigned long rx_missed_total = 0, rx_nombuf = 0, rx_err_total = 0; unsigned long tx_packets_total = 0, tx_bytes_total = 0; unsigned long tx_packets_err_total = 0; const struct pmd_internals *internal = dev->data->dev_private; @@ -751,6 +755,8 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) i < dev->data->nb_rx_queues; i++) { stats->q_ipackets[i] = internal->rx_queue[i].rx_stat.pkts; stats->q_ibytes[i] = internal->rx_queue[i].rx_stat.bytes; + rx_nombuf += internal->rx_queue[i].rx_stat.rx_nombuf; + rx_err_total += internal->rx_queue[i].rx_stat.err_pkts; rx_packets_total += stats->q_ipackets[i]; rx_bytes_total += stats->q_ibytes[i]; rx_missed_total += queue_missed_stat_get(dev, i); @@ -768,6 +774,8 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) stats->ipackets = rx_packets_total; stats->ibytes = rx_bytes_total; stats->imissed = rx_missed_total; + stats->ierrors = rx_err_total; + stats->rx_nombuf = rx_nombuf; stats->opackets = tx_packets_total; stats->obytes = tx_bytes_total; stats->oerrors = tx_packets_err_total; @@ -784,6 +792,8 @@ eth_stats_reset(struct rte_eth_dev *dev) for (i = 0; i < dev->data->nb_rx_queues; i++) { internal->rx_queue[i].rx_stat.pkts = 0; internal->rx_queue[i].rx_stat.bytes = 0; + internal->rx_queue[i].rx_stat.err_pkts = 0; + internal->rx_queue[i].rx_stat.rx_nombuf = 0; queue_missed_stat_reset(dev, i); } -- 2.30.1.windows.1