From patchwork Wed Oct 9 15:29:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Flavia Musatescu X-Patchwork-Id: 60824 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 385EC1E8FA; Wed, 9 Oct 2019 17:29:23 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id E42931C236; Wed, 9 Oct 2019 17:29:21 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Oct 2019 08:29:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,276,1566889200"; d="scan'208";a="205779191" Received: from silpixa00389033.ir.intel.com ([10.237.222.118]) by orsmga002.jf.intel.com with ESMTP; 09 Oct 2019 08:29:16 -0700 From: Flavia Musatescu To: dev@dpdk.org, "John W. Linville" Cc: stable@dpdk.org, Flavia Musatescu , ciwillia@brocade.com Date: Wed, 9 Oct 2019 16:29:09 +0100 Message-Id: <1570634949-26819-1-git-send-email-flavia.musatescu@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH] net/af_packet: improve Tx statistics accuracy X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" When sendto call fails and ENOBUFS error is being set some of the packets are actually successfully transmitted. There is no available count of those packets, so in order to make the statistics more accurate, all the previously enqueued packets will be considered successful, even though this is not entirely correct. Before: testpmd Tx statistics: TX-packets: 7529062 TX-errors: 3702150 TX-bytes: 451743720 pktgen Rx statistics: Total Rx Pkts: 10700700 After: testpmd TX statistics: TX-packets: 11510625 TX-errors: 0 TX-bytes: 690637500 pktgen Rx statistics: Total Rx Pkts: 10974307 Fixes: 74b7fc0a0ff1 ("net/af_packet: fix packet bytes counting") Cc: ciwillia@brocade.com Cc: stable@dpdk.org Signed-off-by: Flavia Musatescu --- drivers/net/af_packet/rte_eth_af_packet.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index 6df09f2..330fa75 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -244,8 +244,16 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) } /* kick-off transmits */ - if (sendto(pkt_q->sockfd, NULL, 0, MSG_DONTWAIT, NULL, 0) == -1) { - /* error sending -- no packets transmitted */ + if (sendto(pkt_q->sockfd, NULL, 0, MSG_DONTWAIT, NULL, 0) == -1 && + errno != ENOBUFS) { + /* Error sending. + * When sendto call fails and ENOBUFS error is being set + * some of the packets are actually successfully transmitted. + * There is no available count of those packets, so in order + * to make the statistics more accurate, all of the previously + * enqueued packets will be considered successful, even though + * this is not entirely correct. + */ num_tx = 0; num_tx_bytes = 0; }