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 9AF16A0C43; Thu, 26 Aug 2021 05:16:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1F23040140; Thu, 26 Aug 2021 05:16:56 +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 E9E874013F for ; Thu, 26 Aug 2021 05:16:53 +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=8YkbY 5K3uMFerP5irX4MC98F4kO0saOlCx07S3CoFZ8=; b=f6+WlI3qpZE4Dy/AArdgJ wCJwiy4wb2VBiCwL1PHZi7sGdTN72Gw8wmN9Fzn1/kYVqJJb5yDz7mWvk827EZvH LS7Dil2UKf1zPuN8P0mtpDj1lFhw1uWc239f1BCaghSNqnadlw2dBLHCOa8VEp+2 rd07NI15EKfn80kKqvBvKk= Received: from localhost.localdomain (unknown [124.160.213.207]) by smtp2 (Coremail) with SMTP id GtxpCgAHU_+gBydhukbUPw--.232S2; Thu, 26 Aug 2021 11:16:50 +0800 (CST) From: Qiming Chen To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Qiming Chen Date: Thu, 26 Aug 2021 11:16:04 +0800 Message-Id: <20210826031604.1089-1-chenqiming_huawei@163.com> X-Mailer: git-send-email 2.30.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: GtxpCgAHU_+gBydhukbUPw--.232S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Zr15JFWxKw1xXw45ArWrKrg_yoW8ZFykpF W3KFyqkw48Jr4xJwn7uF1rJr1DW3yxt3y7WrZ7G34Y93sxKryfK348KFyFvFykKrs5Cr1S yr4DJFWDWa4DAF7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jwJ5rUUUUU= X-Originating-IP: [124.160.213.207] X-CM-SenderInfo: xfkh01xlpl0w5bkxt4lhl6il2tof0z/1tbiNgn5oFWBn7lwygACss Subject: [dpdk-dev] [PATCH] 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 --- drivers/net/pcap/pcap_ethdev.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c index a8774b7a43..5b39dbfeb0 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,13 @@ 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 +792,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