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 AB522A0542; Mon, 6 Jun 2022 11:39:21 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5E81740A7F; Mon, 6 Jun 2022 11:39:21 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id AF8CF40150 for ; Mon, 6 Jun 2022 11:39:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654508359; x=1686044359; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LoHt8kVAaV7OzY3Jiiet5hSDLu+0fsJya+IqWBrKhao=; b=IWGiWVskU5WBM2khkfa1g2pT66aDHKOI6SqSSBP5dXUrQETYFNCYdDuG RKkXvWOWubVZ0sMcEuiCxCv4LrlhNk5u+WBpbIvTMoUNDjvV6xABoSeI5 ArvVACemHspDy/8dNuytSDAmKCVehD+HMRLi9Hs4uHOuow8A8h87gimzv xzyiCaIuKoGt4p8NuQqBVZXmcZr/SK0CimG7m4rHV/24EBBEJpR69wPo6 ZPC0k2iXrSY35rVV/paZC5bQB4bwzvmx2BZG8GIJLKAsFzjdaDWFDS+53 LIahJCG66sqzHOEqs2SF0qdzqaGgeFzFmAtgkIgM3tXEf83DorH+4iRvy w==; X-IronPort-AV: E=McAfee;i="6400,9594,10369"; a="274178623" X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="274178623" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2022 02:39:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,280,1647327600"; d="scan'208";a="669403851" Received: from dpdk-jf-ntb-v2.sh.intel.com ([10.67.119.111]) by FMSMGA003.fm.intel.com with ESMTP; 06 Jun 2022 02:39:16 -0700 From: Junfeng Guo To: qi.z.zhang@intel.com, jingjing.wu@intel.com, beilei.xing@intel.com Cc: dev@dpdk.org, junfeng.guo@intel.com, Xiao Wang Subject: [PATCH v2] app/testpmd: add throughput stats for forward streams Date: Mon, 6 Jun 2022 17:39:45 +0800 Message-Id: <20220606093945.2978915-1-junfeng.guo@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220524082745.4072844-1-junfeng.guo@intel.com> References: <20220524082745.4072844-1-junfeng.guo@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 1. add throughput statistics (in pps) for forward streams. 2. display the forward statistics for every forward stream. v2: add parameter descriptions and fix commit title. Signed-off-by: Xiao Wang Signed-off-by: Junfeng Guo --- app/test-pmd/testpmd.c | 41 ++++++++++++++++++++++++++++++++++++++--- app/test-pmd/testpmd.h | 6 ++++++ 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index fe2ce19f99..076a042e77 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -1926,6 +1926,8 @@ fwd_stream_stats_display(streamid_t stream_id) { struct fwd_stream *fs; static const char *fwd_top_stats_border = "-------"; + uint64_t diff_pkts_rx, diff_pkts_tx, diff_cycles; + uint64_t pps_rx, pps_tx; fs = fwd_streams[stream_id]; if ((fs->rx_packets == 0) && (fs->tx_packets == 0) && @@ -1939,6 +1941,21 @@ fwd_stream_stats_display(streamid_t stream_id) " TX-dropped: %-14"PRIu64, fs->rx_packets, fs->tx_packets, fs->fwd_dropped); + diff_pkts_rx = fs->rx_packets - fs->pre_rx; + diff_pkts_tx = fs->tx_packets - fs->pre_tx; + diff_cycles = fs->pre_cycles; + + fs->pre_rx = fs->rx_packets; + fs->pre_tx = fs->tx_packets; + fs->pre_cycles = rte_rdtsc(); + if (diff_cycles > 0) + diff_cycles = fs->pre_cycles - diff_cycles; + + pps_rx = diff_cycles > 0 ? + (double)diff_pkts_rx * rte_get_tsc_hz() / diff_cycles : 0; + pps_tx = diff_cycles > 0 ? + (double)diff_pkts_tx * rte_get_tsc_hz() / diff_cycles : 0; + /* if checksum mode */ if (cur_fwd_eng == &csum_fwd_engine) { printf(" RX- bad IP checksum: %-14"PRIu64 @@ -1952,6 +1969,11 @@ fwd_stream_stats_display(streamid_t stream_id) printf("\n"); } + printf("\n Throughput (since last show)\n"); + printf(" Rx-pps: %12"PRIu64"\n Tx-pps: %12"PRIu64"\n", pps_rx, pps_tx); + fs->rx_pps = pps_rx; + fs->tx_pps = pps_tx; + if (record_burst_stats) { pkt_burst_stats_display("RX", &fs->rx_burst_stats); pkt_burst_stats_display("TX", &fs->tx_burst_stats); @@ -1979,6 +2001,8 @@ fwd_stats_display(void) uint64_t fwd_cycles = 0; uint64_t total_recv = 0; uint64_t total_xmit = 0; + uint64_t total_rx_pps = 0; + uint64_t total_tx_pps = 0; struct rte_port *port; streamid_t sm_id; portid_t pt_id; @@ -1989,10 +2013,9 @@ fwd_stats_display(void) for (sm_id = 0; sm_id < cur_fwd_config.nb_fwd_streams; sm_id++) { struct fwd_stream *fs = fwd_streams[sm_id]; - if (cur_fwd_config.nb_fwd_streams > + fwd_stream_stats_display(sm_id); + if (cur_fwd_config.nb_fwd_streams == cur_fwd_config.nb_fwd_ports) { - fwd_stream_stats_display(sm_id); - } else { ports_stats[fs->tx_port].tx_stream = fs; ports_stats[fs->rx_port].rx_stream = fs; } @@ -2008,7 +2031,14 @@ fwd_stats_display(void) if (record_core_cycles) fwd_cycles += fs->core_cycles; + + total_rx_pps += fs->rx_pps; + total_tx_pps += fs->tx_pps; } + + printf("\n Total Rx-pps: %12"PRIu64" Tx-pps: %12"PRIu64"\n", + total_rx_pps, total_tx_pps); + for (i = 0; i < cur_fwd_config.nb_fwd_ports; i++) { pt_id = fwd_ports_ids[i]; port = &ports[pt_id]; @@ -2124,6 +2154,11 @@ fwd_stats_reset(void) fs->rx_bad_l4_csum = 0; fs->rx_bad_outer_l4_csum = 0; fs->rx_bad_outer_ip_csum = 0; + fs->pre_rx = 0; + fs->pre_tx = 0; + fs->pre_cycles = 0; + fs->rx_pps = 0; + fs->tx_pps = 0; memset(&fs->rx_burst_stats, 0, sizeof(fs->rx_burst_stats)); memset(&fs->tx_burst_stats, 0, sizeof(fs->tx_burst_stats)); diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 31f766c965..dc1bba5637 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -155,6 +155,12 @@ struct fwd_stream { struct pkt_burst_stats rx_burst_stats; struct pkt_burst_stats tx_burst_stats; struct fwd_lcore *lcore; /**< Lcore being scheduled. */ + + uint64_t pre_rx; /**< previously recorded received packets */ + uint64_t pre_tx; /**< previously recorded transmitted packets */ + uint64_t pre_cycles; /**< previously recorded processor's time-stamp counter cycles */ + uint64_t rx_pps; /**< throughput of received packets in pps */ + uint64_t tx_pps; /**< throughput of transmitted packets in pps */ }; /** -- 2.25.1