From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8D392A31F3 for ; Fri, 18 Oct 2019 16:25:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B0BFF1C0AC; Fri, 18 Oct 2019 16:25:00 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 6A23E1C07E; Fri, 18 Oct 2019 16:24:58 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Oct 2019 07:24:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,312,1566889200"; d="scan'208";a="396639768" Received: from silpixa00389033.ir.intel.com ([10.237.222.179]) by fmsmga005.fm.intel.com with ESMTP; 18 Oct 2019 07:24:55 -0700 From: Flavia Musatescu To: dev@dpdk.org, "John W. Linville" Cc: stable@dpdk.org, Flavia Musatescu , ciwillia@brocade.com Date: Fri, 18 Oct 2019 15:24:31 +0100 Message-Id: <1571408671-29209-1-git-send-email-flavia.musatescu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1571313107-31794-1-git-send-email-flavia.musatescu@intel.com> References: <1571313107-31794-1-git-send-email-flavia.musatescu@intel.com> Subject: [dpdk-dev] [PATCH v4] 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/EAGAIN 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. Statistics numbers before this update: Pktgen: Total Rx Pkts: 1360084 Tx Pkts: 2000000 testpmd: RX-packets: 1408346 RX-missed: 0 RX-bytes: 84503418 TX-packets: 526486 TX-errors: 881851 TX-bytes: 31589724 Statistics numbers after this update: Pktgen: Total Rx Pkts: 1329872 Tx Pkts: 2000000 testpmd: RX-packets: 1389156 RX-missed: 0 RX-bytes: 83349360 TX-packets: 1389156 TX-errors: 0 TX-bytes: 83349360 Fixes: 74b7fc0a0ff1 ("net/af_packet: fix packet bytes counting") Cc: ciwillia@brocade.com Cc: stable@dpdk.org Signed-off-by: Flavia Musatescu --- v2: * Changed the comment. v3: * Same applied for EAGAIN error. v4: * Updated the statistics in the commit message --- drivers/net/af_packet/rte_eth_af_packet.c | 10 ++++++++-- 1 file changed, 8 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..5592626 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -244,8 +244,14 @@ 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 && errno != EAGAIN) { + /* + * In case of a ENOBUFS/EAGAIN error all of the enqueued + * packets will be considered successful even though only some + * are sent. + */ + num_tx = 0; num_tx_bytes = 0; } -- 2.7.4