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 4DE23A0C43; Thu, 26 Aug 2021 05:24:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DDF0C40140; Thu, 26 Aug 2021 05:24:41 +0200 (CEST) Received: from mail-m972.mail.163.com (mail-m972.mail.163.com [123.126.97.2]) by mails.dpdk.org (Postfix) with ESMTP id C7AB24013F for ; Thu, 26 Aug 2021 05:24:39 +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=e+ePc rFgXdOILox9mVorHz043/22HzWq6qtk2zXKb+g=; b=JjUdYvuZjRYNL8QN+xDJD 5rc2gi/Gt7AWHBGhndbiGuaBsKjCW3+Ebsbh5Qa4nHMmxK0xLcgVHeTKAA+WlHA4 4sDnBsutHUQyrkL4ccKEVw2Cfrz5kS6dMw70E80jY81tzSLuLwjJ/02qu69a2wFd DiQo2RjkV79W+A21UwzTcY= Received: from localhost.localdomain (unknown [124.160.213.207]) by smtp2 (Coremail) with SMTP id GtxpCgAH_fxzCSdhFRDVPw--.259S2; Thu, 26 Aug 2021 11:24:38 +0800 (CST) From: Qiming Chen To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Qiming Chen Date: Thu, 26 Aug 2021 11:23:54 +0800 Message-Id: <20210826032354.1146-1-chenqiming_huawei@163.com> X-Mailer: git-send-email 2.30.1.windows.1 In-Reply-To: <20210826031604.1089-1-chenqiming_huawei@163.com> References: <20210826031604.1089-1-chenqiming_huawei@163.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: GtxpCgAH_fxzCSdhFRDVPw--.259S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Zr15JFWxKw1xXw45ArWrKrg_yoW8Zw47pF W3KFyqkw4rJr1xGwn7uF1rJr1DG3yft3y7uFZ7G34Y9r9xKr9ak348KFyFvFyktws5Cr1S yr4DJFWDWa4DAF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jwF4_UUUUU= X-Originating-IP: [124.160.213.207] X-CM-SenderInfo: xfkh01xlpl0w5bkxt4lhl6il2tof0z/1tbiQAj6oFSIj5YAzgAAsZ Subject: [dpdk-dev] [PATCH v2] net/pcap: improve rxtx 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. In the sending direction, if the pcap_sendpacket function returns EMSGSIZE, it means that the size of the sent packet exceeds the buffer size provided, and the corresponding mbuf needs to be released, otherwise it will cause the mbuf to leak. Signed-off-by: Qiming Chen --- v2: Clear coding style issues. --- drivers/net/pcap/pcap_ethdev.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c index a8774b7a43..4606f8ff60 100644 --- a/drivers/net/pcap/pcap_ethdev.c +++ b/drivers/net/pcap/pcap_ethdev.c @@ -297,8 +297,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)) - break; + if (unlikely(mbuf == NULL)) { + pcap_q->rx_stat.err_pkts++; + continue; + } if (header.caplen <= rte_pktmbuf_tailroom(mbuf)) { /* pcap packet will fit in the mbuf, can copy it */ @@ -311,6 +313,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; } @@ -490,8 +493,12 @@ eth_pcap_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) */ ret = pcap_sendpacket(pcap, rte_pktmbuf_read(mbuf, 0, len, temp_data), len); - if (unlikely(ret != 0)) + if (unlikely(ret != 0)) { + if (errno == EMSGSIZE) + rte_pktmbuf_free(mbuf); break; + } + num_tx++; tx_bytes += len; rte_pktmbuf_free(mbuf); @@ -784,6 +791,7 @@ 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; queue_missed_stat_reset(dev, i); } -- 2.30.1.windows.1