From patchwork Thu Mar 19 13:50:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 66934 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id BB888A0583; Thu, 19 Mar 2020 14:51:15 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AAC4F29C6; Thu, 19 Mar 2020 14:51:08 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id CA47F29C6 for ; Thu, 19 Mar 2020 14:51:07 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Mar 2020 15:51:03 +0200 Received: from pegasus12.mtr.labs.mlnx (pegasus12.mtr.labs.mlnx [10.210.17.40]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 02JDp3rR009967; Thu, 19 Mar 2020 15:51:03 +0200 Received: from pegasus12.mtr.labs.mlnx (localhost [127.0.0.1]) by pegasus12.mtr.labs.mlnx (8.14.7/8.14.7) with ESMTP id 02JDp3ab010408; Thu, 19 Mar 2020 13:51:03 GMT Received: (from viacheslavo@localhost) by pegasus12.mtr.labs.mlnx (8.14.7/8.14.7/Submit) id 02JDp3ms010407; Thu, 19 Mar 2020 13:51:03 GMT X-Authentication-Warning: pegasus12.mtr.labs.mlnx: viacheslavo set sender to viacheslavo@mellanox.com using -f From: Viacheslav Ovsiienko To: dev@dpdk.org Cc: ferruh.yigit@intel.com, thomas@monjalon.net, bernard.iremonger@intel.com Date: Thu, 19 Mar 2020 13:50:49 +0000 Message-Id: <1584625851-10291-2-git-send-email-viacheslavo@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1584625851-10291-1-git-send-email-viacheslavo@mellanox.com> References: <1561553317-16777-1-git-send-email-viacheslavo@mellanox.com> <1584625851-10291-1-git-send-email-viacheslavo@mellanox.com> Subject: [dpdk-dev] [PATCH v2 1/3] app/testpmd: add profiling flags set command 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" This commit is preparation step before adding the separated profiling of Rx and Tx burst routines. The new testpmd command is introduced: set fwdprof (flags) This command controls which profiling statistics is being gathered in runtime: - bit 0 - enables profiling the entire forward routine, counts the ticks spent in the forwarding routine, is set by default. Provides the same data as previous implementation. - bit 1 - enables gathering the profiling data for the transmit datapath, counts the ticks spent within rte_eth_tx_burst() routine, is cleared by default, extends the existing statistics. - bit 2 - enables gathering the profiling data for the receive datapath, counts the ticks spent within rte_eth_rx_burst() routine, is cleared by default, extends the existing statistics. The new counters for the cycles spent into rx/tx burst routines are introduced. The feature is engaged only if CONFIG_RTE_TEST_PMD_RECORD_CORE_CYCLES configured to 'Y'. Signed-off-by: Viacheslav Ovsiienko --- app/test-pmd/cmdline.c | 15 +++++++++++++++ app/test-pmd/config.c | 10 ++++++++++ app/test-pmd/testpmd.c | 3 +++ app/test-pmd/testpmd.h | 8 ++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 22 ++++++++++++++++++++++ 5 files changed, 58 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index a037a55..74dbb29 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -263,6 +263,9 @@ static void cmd_help_long_parsed(void *parsed_result, "set verbose (level)\n" " Set the debug verbosity level X.\n\n" + "set fwdprof (flags)\n" + " Set the flags to profile the forwarding.\n\n" + "set log global|(type) (level)\n" " Set the log level.\n\n" @@ -3743,20 +3746,32 @@ static void cmd_set_parsed(void *parsed_result, set_nb_pkt_per_burst(res->value); else if (!strcmp(res->what, "verbose")) set_verbose_level(res->value); +#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES + else if (!strcmp(res->what, "fwdprof")) + set_fwdprof_flags(res->value); +#endif } cmdline_parse_token_string_t cmd_set_set = TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set"); cmdline_parse_token_string_t cmd_set_what = TOKEN_STRING_INITIALIZER(struct cmd_set_result, what, +#ifndef RTE_TEST_PMD_RECORD_CORE_CYCLES "nbport#nbcore#burst#verbose"); +#else + "nbport#nbcore#burst#verbose#fwdprof"); +#endif cmdline_parse_token_num_t cmd_set_value = TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16); cmdline_parse_inst_t cmd_set_numbers = { .f = cmd_set_parsed, .data = NULL, +#ifndef RTE_TEST_PMD_RECORD_CORE_CYCLES .help_str = "set nbport|nbcore|burst|verbose ", +#else + .help_str = "set nbport|nbcore|burst|verbose|fwdprof ", +#endif .tokens = { (void *)&cmd_set_set, (void *)&cmd_set_what, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 8cf84cc..1d86250 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -3151,6 +3151,16 @@ struct igb_ring_desc_16_bytes { configure_rxtx_dump_callbacks(verbose_level); } +#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES +void +set_fwdprof_flags(uint16_t pf_flags) +{ + printf("Change forward profiling flags from %u to %u\n", + (unsigned int) fwdprof_flags, (unsigned int) pf_flags); + fwdprof_flags = pf_flags; +} +#endif + void vlan_extend_set(portid_t port_id, int on) { diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 035836a..c93fa35 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -81,6 +81,9 @@ #define EXTBUF_ZONE_SIZE RTE_PGSIZE_2M uint16_t verbose_level = 0; /**< Silent by default. */ +#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES +uint16_t fwdprof_flags = RECORD_CORE_CYCLES_FWD; /**< Fwd only by default. */ +#endif int testpmd_logtype; /**< Log type for testpmd logs */ /* use master core for command line ? */ diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 7a7c73f..466e611 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -321,8 +321,15 @@ struct queue_stats_mappings { extern uint8_t xstats_hide_zero; /**< Hide zero values for xstats display */ +#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES +#define RECORD_CORE_CYCLES_FWD (1<<0) +#define RECORD_CORE_CYCLES_RX (1<<1) +#define RECORD_CORE_CYCLES_TX (1<<2) +#endif + /* globals used for configuration */ extern uint16_t verbose_level; /**< Drives messages being displayed, if any. */ +extern uint16_t fwdprof_flags; /**< Controls the profiling statistics. */ extern int testpmd_logtype; /**< Log type for testpmd logs */ extern uint8_t interactive; extern uint8_t auto_start; @@ -787,6 +794,7 @@ void vlan_tpid_set(portid_t port_id, enum rte_vlan_type vlan_type, void set_xstats_hide_zero(uint8_t on_off); void set_verbose_level(uint16_t vb_level); +void set_fwdprof_flags(uint16_t pf_flags); void set_tx_pkt_segments(unsigned *seg_lengths, unsigned nb_segs); void show_tx_pkt_segments(void); void set_tx_pkt_split(const char *name); diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 5bb12a5..b6ec783 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -647,6 +647,28 @@ Regexes can also be used for type. To change log level of user1, user2 and user3 testpmd> set log user[1-3] (level) +set fwdprof +~~~~~~~~~~~ + +Set the flags controlling the datapath profiling statistics:: + + testpmd> set fwdprof (flags) + +This command is available only if ``CONFIG_RTE_TEST_PMD_RECORD_CORE_CYCLES`` is +configured to Y, enabling the profiling code generation. + +The bitmask flag controls the gathering profiling statistics for datapath: + +* ``bit 0`` enables gathering the profiling data for the entire + forwarding routine, counts the ticks spent in the forwarding routine, + is set by default. +* ``bit 1`` enables gathering the profiling data for the transmit datapath, + counts the ticks spent within rte_eth_tx_burst() routine, is cleared by + default. +* ``bit 2`` enables gathering the profiling data for the receive datapath, + counts the ticks spent within rte_eth_rx_burst() routine, is cleared by + default. + set nbport ~~~~~~~~~~ From patchwork Thu Mar 19 13:50:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 66936 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3E514A0583; Thu, 19 Mar 2020 14:51:34 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 886E81C030; Thu, 19 Mar 2020 14:51:14 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id A99FEF90 for ; Thu, 19 Mar 2020 14:51:12 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Mar 2020 15:51:08 +0200 Received: from pegasus12.mtr.labs.mlnx (pegasus12.mtr.labs.mlnx [10.210.17.40]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 02JDp80V010117; Thu, 19 Mar 2020 15:51:08 +0200 Received: from pegasus12.mtr.labs.mlnx (localhost [127.0.0.1]) by pegasus12.mtr.labs.mlnx (8.14.7/8.14.7) with ESMTP id 02JDp835010413; Thu, 19 Mar 2020 13:51:08 GMT Received: (from viacheslavo@localhost) by pegasus12.mtr.labs.mlnx (8.14.7/8.14.7/Submit) id 02JDp865010412; Thu, 19 Mar 2020 13:51:08 GMT X-Authentication-Warning: pegasus12.mtr.labs.mlnx: viacheslavo set sender to viacheslavo@mellanox.com using -f From: Viacheslav Ovsiienko To: dev@dpdk.org Cc: ferruh.yigit@intel.com, thomas@monjalon.net, bernard.iremonger@intel.com Date: Thu, 19 Mar 2020 13:50:50 +0000 Message-Id: <1584625851-10291-3-git-send-email-viacheslavo@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1584625851-10291-1-git-send-email-viacheslavo@mellanox.com> References: <1561553317-16777-1-git-send-email-viacheslavo@mellanox.com> <1584625851-10291-1-git-send-email-viacheslavo@mellanox.com> Subject: [dpdk-dev] [PATCH v2 2/3] app/testpmd: gather Rx and Tx routines profiling 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" This patch counts the tick spent in rx-tx_burst routines in dedicated counters and displays the gathered profiling statistics. The feature is engaged only if CONFIG_RTE_TEST_PMD_RECORD_CORE_CYCLES configured as 'Y'. The "set fwdprof (flags)" command can be used to select what counters should be involved. Signed-off-by: Viacheslav Ovsiienko --- app/test-pmd/csumonly.c | 21 +++++++++------------ app/test-pmd/flowgen.c | 21 +++++++++------------ app/test-pmd/icmpecho.c | 21 +++++++++------------ app/test-pmd/iofwd.c | 21 +++++++++------------ app/test-pmd/macfwd.c | 21 +++++++++------------ app/test-pmd/macswap.c | 21 +++++++++------------ app/test-pmd/rxonly.c | 14 ++++---------- app/test-pmd/softnicfwd.c | 21 +++++++++------------ app/test-pmd/testpmd.c | 18 +++++++++++++++++- app/test-pmd/testpmd.h | 34 ++++++++++++++++++++++++++++++++-- app/test-pmd/txonly.c | 20 ++++++++------------ 11 files changed, 124 insertions(+), 109 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 25091de..4104737 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -789,18 +789,15 @@ struct simple_gre_hdr { int ret; #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - uint64_t start_tsc; - uint64_t end_tsc; - uint64_t core_cycles; -#endif - -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - start_tsc = rte_rdtsc(); + uint64_t start_rx_tsc = 0; + uint64_t start_tx_tsc = 0; #endif /* receive a burst of packet */ + TEST_PMD_CORE_CYC_RX_START(start_rx_tsc); nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); + TEST_PMD_CORE_CYC_RX_ADD(fs, start_rx_tsc); if (unlikely(nb_rx == 0)) return; #ifdef RTE_TEST_PMD_RECORD_BURST_STATS @@ -1067,8 +1064,10 @@ struct simple_gre_hdr { printf("Preparing packet burst to transmit failed: %s\n", rte_strerror(rte_errno)); + TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, tx_pkts_burst, nb_prep); + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); /* * Retry if necessary @@ -1077,8 +1076,10 @@ struct simple_gre_hdr { retry = 0; while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { rte_delay_us(burst_tx_delay_time); + TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, &tx_pkts_burst[nb_tx], nb_rx - nb_tx); + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); } } fs->tx_packets += nb_tx; @@ -1096,11 +1097,7 @@ struct simple_gre_hdr { } while (++nb_tx < nb_rx); } -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - end_tsc = rte_rdtsc(); - core_cycles = (end_tsc - start_tsc); - fs->core_cycles = (uint64_t) (fs->core_cycles + core_cycles); -#endif + TEST_PMD_CORE_CYC_FWD_ADD(fs, start_rx_tsc); } struct fwd_engine csum_fwd_engine = { diff --git a/app/test-pmd/flowgen.c b/app/test-pmd/flowgen.c index 4bd351e..51e87b0 100644 --- a/app/test-pmd/flowgen.c +++ b/app/test-pmd/flowgen.c @@ -98,19 +98,16 @@ uint32_t retry; uint64_t tx_offloads; #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - uint64_t start_tsc; - uint64_t end_tsc; - uint64_t core_cycles; + uint64_t start_rx_tsc = 0; + uint64_t start_tx_tsc = 0; #endif static int next_flow = 0; -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - start_tsc = rte_rdtsc(); -#endif - /* Receive a burst of packets and discard them. */ + TEST_PMD_CORE_CYC_RX_START(start_rx_tsc); nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); + TEST_PMD_CORE_CYC_RX_ADD(fs, start_rx_tsc); fs->rx_packets += nb_rx; for (i = 0; i < nb_rx; i++) @@ -180,7 +177,9 @@ next_flow = (next_flow + 1) % cfg_n_flows; } + TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_pkt); + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); /* * Retry if necessary */ @@ -188,8 +187,10 @@ retry = 0; while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { rte_delay_us(burst_tx_delay_time); + TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, &pkts_burst[nb_tx], nb_rx - nb_tx); + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); } } fs->tx_packets += nb_tx; @@ -207,11 +208,7 @@ rte_pktmbuf_free(pkts_burst[nb_tx]); } while (++nb_tx < nb_pkt); } -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - end_tsc = rte_rdtsc(); - core_cycles = (end_tsc - start_tsc); - fs->core_cycles = (uint64_t) (fs->core_cycles + core_cycles); -#endif + TEST_PMD_CORE_CYC_FWD_ADD(fs, start_rx_tsc); } struct fwd_engine flow_gen_engine = { diff --git a/app/test-pmd/icmpecho.c b/app/test-pmd/icmpecho.c index 65aece16..8843183 100644 --- a/app/test-pmd/icmpecho.c +++ b/app/test-pmd/icmpecho.c @@ -294,20 +294,17 @@ uint8_t i; int l2_len; #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - uint64_t start_tsc; - uint64_t end_tsc; - uint64_t core_cycles; -#endif - -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - start_tsc = rte_rdtsc(); + uint64_t start_rx_tsc = 0; + uint64_t start_tx_tsc = 0; #endif /* * First, receive a burst of packets. */ + TEST_PMD_CORE_CYC_RX_START(start_rx_tsc); nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); + TEST_PMD_CORE_CYC_RX_ADD(fs, start_rx_tsc); if (unlikely(nb_rx == 0)) return; @@ -492,8 +489,10 @@ /* Send back ICMP echo replies, if any. */ if (nb_replies > 0) { + TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_replies); + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); /* * Retry if necessary */ @@ -502,10 +501,12 @@ while (nb_tx < nb_replies && retry++ < burst_tx_retry_num) { rte_delay_us(burst_tx_delay_time); + TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, &pkts_burst[nb_tx], nb_replies - nb_tx); + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); } } fs->tx_packets += nb_tx; @@ -520,11 +521,7 @@ } } -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - end_tsc = rte_rdtsc(); - core_cycles = (end_tsc - start_tsc); - fs->core_cycles = (uint64_t) (fs->core_cycles + core_cycles); -#endif + TEST_PMD_CORE_CYC_FWD_ADD(fs, start_rx_tsc); } struct fwd_engine icmp_echo_engine = { diff --git a/app/test-pmd/iofwd.c b/app/test-pmd/iofwd.c index 9dce76e..9ff6531 100644 --- a/app/test-pmd/iofwd.c +++ b/app/test-pmd/iofwd.c @@ -52,20 +52,17 @@ uint32_t retry; #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - uint64_t start_tsc; - uint64_t end_tsc; - uint64_t core_cycles; -#endif - -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - start_tsc = rte_rdtsc(); + uint64_t start_rx_tsc = 0; + uint64_t start_tx_tsc = 0; #endif /* * Receive a burst of packets and forward them. */ + TEST_PMD_CORE_CYC_RX_START(start_rx_tsc); nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); + TEST_PMD_CORE_CYC_RX_ADD(fs, start_rx_tsc); if (unlikely(nb_rx == 0)) return; fs->rx_packets += nb_rx; @@ -73,8 +70,10 @@ #ifdef RTE_TEST_PMD_RECORD_BURST_STATS fs->rx_burst_stats.pkt_burst_spread[nb_rx]++; #endif + TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_rx); + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); /* * Retry if necessary */ @@ -82,8 +81,10 @@ retry = 0; while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { rte_delay_us(burst_tx_delay_time); + TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, &pkts_burst[nb_tx], nb_rx - nb_tx); + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); } } fs->tx_packets += nb_tx; @@ -96,11 +97,7 @@ rte_pktmbuf_free(pkts_burst[nb_tx]); } while (++nb_tx < nb_rx); } -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - end_tsc = rte_rdtsc(); - core_cycles = (end_tsc - start_tsc); - fs->core_cycles = (uint64_t) (fs->core_cycles + core_cycles); -#endif + TEST_PMD_CORE_CYC_FWD_ADD(fs, start_rx_tsc); } struct fwd_engine io_fwd_engine = { diff --git a/app/test-pmd/macfwd.c b/app/test-pmd/macfwd.c index d2ebb11..f4a213e 100644 --- a/app/test-pmd/macfwd.c +++ b/app/test-pmd/macfwd.c @@ -57,20 +57,17 @@ uint64_t ol_flags = 0; uint64_t tx_offloads; #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - uint64_t start_tsc; - uint64_t end_tsc; - uint64_t core_cycles; -#endif - -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - start_tsc = rte_rdtsc(); + uint64_t start_rx_tsc = 0; + uint64_t start_tx_tsc = 0; #endif /* * Receive a burst of packets and forward them. */ + TEST_PMD_CORE_CYC_RX_START(start_rx_tsc); nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); + TEST_PMD_CORE_CYC_RX_ADD(fs, start_tx_tsc); if (unlikely(nb_rx == 0)) return; @@ -103,7 +100,9 @@ mb->vlan_tci = txp->tx_vlan_id; mb->vlan_tci_outer = txp->tx_vlan_id_outer; } + TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_rx); + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); /* * Retry if necessary */ @@ -111,8 +110,10 @@ retry = 0; while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { rte_delay_us(burst_tx_delay_time); + TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, &pkts_burst[nb_tx], nb_rx - nb_tx); + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); } } @@ -126,11 +127,7 @@ rte_pktmbuf_free(pkts_burst[nb_tx]); } while (++nb_tx < nb_rx); } -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - end_tsc = rte_rdtsc(); - core_cycles = (end_tsc - start_tsc); - fs->core_cycles = (uint64_t) (fs->core_cycles + core_cycles); -#endif + TEST_PMD_CORE_CYC_FWD_ADD(fs, start_rx_tsc); } struct fwd_engine mac_fwd_engine = { diff --git a/app/test-pmd/macswap.c b/app/test-pmd/macswap.c index 8428c26..5cb3133 100644 --- a/app/test-pmd/macswap.c +++ b/app/test-pmd/macswap.c @@ -58,20 +58,17 @@ uint16_t nb_tx; uint32_t retry; #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - uint64_t start_tsc; - uint64_t end_tsc; - uint64_t core_cycles; -#endif - -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - start_tsc = rte_rdtsc(); + uint64_t start_rx_tsc = 0; + uint64_t start_tx_tsc = 0; #endif /* * Receive a burst of packets and forward them. */ + TEST_PMD_CORE_CYC_RX_START(start_rx_tsc); nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); + TEST_PMD_CORE_CYC_RX_ADD(fs, start_rx_tsc); if (unlikely(nb_rx == 0)) return; @@ -83,7 +80,9 @@ do_macswap(pkts_burst, nb_rx, txp); + TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_rx); + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); /* * Retry if necessary */ @@ -91,8 +90,10 @@ retry = 0; while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { rte_delay_us(burst_tx_delay_time); + TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, &pkts_burst[nb_tx], nb_rx - nb_tx); + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); } } fs->tx_packets += nb_tx; @@ -105,11 +106,7 @@ rte_pktmbuf_free(pkts_burst[nb_tx]); } while (++nb_tx < nb_rx); } -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - end_tsc = rte_rdtsc(); - core_cycles = (end_tsc - start_tsc); - fs->core_cycles = (uint64_t) (fs->core_cycles + core_cycles); -#endif + TEST_PMD_CORE_CYC_FWD_ADD(fs, start_rx_tsc); } struct fwd_engine mac_swap_engine = { diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c index 5c65fc4..2820d7f 100644 --- a/app/test-pmd/rxonly.c +++ b/app/test-pmd/rxonly.c @@ -51,18 +51,16 @@ uint16_t i; #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - uint64_t start_tsc; - uint64_t end_tsc; - uint64_t core_cycles; - - start_tsc = rte_rdtsc(); + uint64_t start_rx_tsc = 0; #endif /* * Receive a burst of packets. */ + TEST_PMD_CORE_CYC_RX_START(start_rx_tsc); nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); + TEST_PMD_CORE_CYC_RX_ADD(fs, start_rx_tsc); if (unlikely(nb_rx == 0)) return; @@ -73,11 +71,7 @@ for (i = 0; i < nb_rx; i++) rte_pktmbuf_free(pkts_burst[i]); -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - end_tsc = rte_rdtsc(); - core_cycles = (end_tsc - start_tsc); - fs->core_cycles = (uint64_t) (fs->core_cycles + core_cycles); -#endif + TEST_PMD_CORE_CYC_FWD_ADD(fs, start_rx_tsc); } struct fwd_engine rx_only_engine = { diff --git a/app/test-pmd/softnicfwd.c b/app/test-pmd/softnicfwd.c index e9d4373..b78f2ce 100644 --- a/app/test-pmd/softnicfwd.c +++ b/app/test-pmd/softnicfwd.c @@ -88,34 +88,35 @@ struct tm_hierarchy { uint32_t retry; #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - uint64_t start_tsc; - uint64_t end_tsc; - uint64_t core_cycles; -#endif - -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - start_tsc = rte_rdtsc(); + uint64_t start_rx_tsc = 0; + uint64_t start_tx_tsc = 0; #endif /* Packets Receive */ + TEST_PMD_CORE_CYC_RX_START(start_rx_tsc); nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); + TEST_PMD_CORE_CYC_RX_ADD(fs, start_rx_tsc); fs->rx_packets += nb_rx; #ifdef RTE_TEST_PMD_RECORD_BURST_STATS fs->rx_burst_stats.pkt_burst_spread[nb_rx]++; #endif + TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_rx); + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); /* Retry if necessary */ if (unlikely(nb_tx < nb_rx) && fs->retry_enabled) { retry = 0; while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { rte_delay_us(burst_tx_delay_time); + TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, &pkts_burst[nb_tx], nb_rx - nb_tx); + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); } } fs->tx_packets += nb_tx; @@ -130,11 +131,7 @@ struct tm_hierarchy { rte_pktmbuf_free(pkts_burst[nb_tx]); } while (++nb_tx < nb_rx); } -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - end_tsc = rte_rdtsc(); - core_cycles = (end_tsc - start_tsc); - fs->core_cycles = (uint64_t) (fs->core_cycles + core_cycles); -#endif + TEST_PMD_CORE_CYC_FWD_ADD(fs, start_rx_tsc); } static void diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index c93fa35..b195880 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -1625,6 +1625,8 @@ struct extmem_param { struct rte_eth_stats stats; #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES uint64_t fwd_cycles = 0; + uint64_t rx_cycles = 0; + uint64_t tx_cycles = 0; #endif uint64_t total_recv = 0; uint64_t total_xmit = 0; @@ -1655,6 +1657,8 @@ struct extmem_param { #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES fwd_cycles += fs->core_cycles; + rx_cycles += fs->core_rx_cycles; + tx_cycles += fs->core_tx_cycles; #endif } for (i = 0; i < cur_fwd_config.nb_fwd_ports; i++) { @@ -1785,11 +1789,21 @@ struct extmem_param { "%s\n", acc_stats_border, acc_stats_border); #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - if (total_recv > 0) + if (fwdprof_flags & RECORD_CORE_CYCLES_FWD && total_recv > 0) printf("\n CPU cycles/packet=%u (total cycles=" "%"PRIu64" / total RX packets=%"PRIu64")\n", (unsigned int)(fwd_cycles / total_recv), fwd_cycles, total_recv); + if (fwdprof_flags & RECORD_CORE_CYCLES_RX && total_recv > 0) + printf("\n rx CPU cycles/packet=%u (total cycles=" + "%"PRIu64" / total RX packets=%"PRIu64")\n", + (unsigned int)(rx_cycles / total_recv), + rx_cycles, total_recv); + if (fwdprof_flags & RECORD_CORE_CYCLES_TX && total_xmit > 0) + printf("\n tx CPU cycles/packet=%u (total cycles=" + "%"PRIu64" / total TX packets=%"PRIu64")\n", + (unsigned int)(tx_cycles / total_xmit), + tx_cycles, total_xmit); #endif } @@ -1820,6 +1834,8 @@ struct extmem_param { #endif #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES fs->core_cycles = 0; + fs->core_rx_cycles = 0; + fs->core_tx_cycles = 0; #endif } } diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 466e611..6177a50 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -136,7 +136,9 @@ struct fwd_stream { /**< received packets has bad outer l4 checksum */ unsigned int gro_times; /**< GRO operation times */ #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - uint64_t core_cycles; /**< used for RX and TX processing */ + uint64_t core_cycles; /**< used for RX and TX processing */ + uint64_t core_tx_cycles; /**< used for tx_burst processing */ + uint64_t core_rx_cycles; /**< used for rx_burst processing */ #endif #ifdef RTE_TEST_PMD_RECORD_BURST_STATS struct pkt_burst_stats rx_burst_stats; @@ -325,7 +327,35 @@ struct queue_stats_mappings { #define RECORD_CORE_CYCLES_FWD (1<<0) #define RECORD_CORE_CYCLES_RX (1<<1) #define RECORD_CORE_CYCLES_TX (1<<2) -#endif + +/* Macros to gather profiling statistics. */ +#define TEST_PMD_CORE_CYC_TX_START(a) \ +{if (fwdprof_flags & RECORD_CORE_CYCLES_TX) a = rte_rdtsc(); } + +#define TEST_PMD_CORE_CYC_RX_START(a) \ +{if (fwdprof_flags & (RECORD_CORE_CYCLES_FWD | \ + RECORD_CORE_CYCLES_RX)) a = rte_rdtsc(); } + +#define TEST_PMD_CORE_CYC_FWD_ADD(fs, s) \ +{if (fwdprof_flags & RECORD_CORE_CYCLES_FWD) \ +{uint64_t tsc = rte_rdtsc(); tsc -= (s); fs->core_cycles += tsc; } } + +#define TEST_PMD_CORE_CYC_TX_ADD(fs, s) \ +{if (fwdprof_flags & RECORD_CORE_CYCLES_TX) \ +{uint64_t tsc = rte_rdtsc(); tsc -= (s); fs->core_tx_cycles += tsc; } } + +#define TEST_PMD_CORE_CYC_RX_ADD(fs, s) \ +{if (fwdprof_flags & RECORD_CORE_CYCLES_RX) \ +{uint64_t tsc = rte_rdtsc(); tsc -= (s); fs->core_rx_cycles += tsc; } } + +#else +/* No profiling statistics is configured. */ +#define TEST_PMD_CORE_CYC_TX_START(a) +#define TEST_PMD_CORE_CYC_RX_START(a) +#define TEST_PMD_CORE_CYC_FWD_ADD(fs, s) +#define TEST_PMD_CORE_CYC_TX_ADD(fs, s) +#define TEST_PMD_CORE_CYC_RX_ADD(fs, s) +#endif /* RTE_TEST_PMD_RECORD_CORE_CYCLES */ /* globals used for configuration */ extern uint16_t verbose_level; /**< Drives messages being displayed, if any. */ diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c index 8a1989f..8ff7410 100644 --- a/app/test-pmd/txonly.c +++ b/app/test-pmd/txonly.c @@ -241,15 +241,11 @@ uint64_t ol_flags = 0; uint64_t tx_offloads; #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - uint64_t start_tsc; - uint64_t end_tsc; - uint64_t core_cycles; -#endif - -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - start_tsc = rte_rdtsc(); + uint64_t start_rx_tsc = 0; + uint64_t start_tx_tsc = 0; #endif + TEST_PMD_CORE_CYC_RX_START(start_rx_tsc); mbp = current_fwd_lcore()->mbp; txp = &ports[fs->tx_port]; tx_offloads = txp->dev_conf.txmode.offloads; @@ -301,7 +297,9 @@ if (nb_pkt == 0) return; + TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_pkt); + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); /* * Retry if necessary */ @@ -309,8 +307,10 @@ retry = 0; while (nb_tx < nb_pkt && retry++ < burst_tx_retry_num) { rte_delay_us(burst_tx_delay_time); + TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, &pkts_burst[nb_tx], nb_pkt - nb_tx); + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); } } fs->tx_packets += nb_tx; @@ -334,11 +334,7 @@ } while (++nb_tx < nb_pkt); } -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - end_tsc = rte_rdtsc(); - core_cycles = (end_tsc - start_tsc); - fs->core_cycles = (uint64_t) (fs->core_cycles + core_cycles); -#endif + TEST_PMD_CORE_CYC_FWD_ADD(fs, start_rx_tsc); } static void From patchwork Thu Mar 19 13:50:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 66935 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1022EA0583; Thu, 19 Mar 2020 14:51:24 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 038B01C02A; Thu, 19 Mar 2020 14:51:13 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id F31BF1C029 for ; Thu, 19 Mar 2020 14:51:11 +0100 (CET) Received: from Internal Mail-Server by MTLPINE2 (envelope-from viacheslavo@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Mar 2020 15:51:11 +0200 Received: from pegasus12.mtr.labs.mlnx (pegasus12.mtr.labs.mlnx [10.210.17.40]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 02JDpBjH010190; Thu, 19 Mar 2020 15:51:11 +0200 Received: from pegasus12.mtr.labs.mlnx (localhost [127.0.0.1]) by pegasus12.mtr.labs.mlnx (8.14.7/8.14.7) with ESMTP id 02JDpBLa010416; Thu, 19 Mar 2020 13:51:11 GMT Received: (from viacheslavo@localhost) by pegasus12.mtr.labs.mlnx (8.14.7/8.14.7/Submit) id 02JDpA78010415; Thu, 19 Mar 2020 13:51:10 GMT X-Authentication-Warning: pegasus12.mtr.labs.mlnx: viacheslavo set sender to viacheslavo@mellanox.com using -f From: Viacheslav Ovsiienko To: dev@dpdk.org Cc: ferruh.yigit@intel.com, thomas@monjalon.net, bernard.iremonger@intel.com Date: Thu, 19 Mar 2020 13:50:51 +0000 Message-Id: <1584625851-10291-4-git-send-email-viacheslavo@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1584625851-10291-1-git-send-email-viacheslavo@mellanox.com> References: <1561553317-16777-1-git-send-email-viacheslavo@mellanox.com> <1584625851-10291-1-git-send-email-viacheslavo@mellanox.com> Subject: [dpdk-dev] [PATCH v2 3/3] app/testpmd: qualify profiling statistics on burst size 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" The execution time of rx/tx burst routine depends on the burst size. It would be meaningful to research this dependency, the patch provides an extra profiling data per rx/tx burst size. Signed-off-by: Viacheslav Ovsiienko Reviewed-by: Andrzej Ostruszka --- app/test-pmd/csumonly.c | 11 +++++++---- app/test-pmd/flowgen.c | 11 +++++++---- app/test-pmd/icmpecho.c | 12 ++++++++---- app/test-pmd/iofwd.c | 11 +++++++---- app/test-pmd/macfwd.c | 11 +++++++---- app/test-pmd/macswap.c | 11 +++++++---- app/test-pmd/rxonly.c | 2 +- app/test-pmd/softnicfwd.c | 11 +++++++---- app/test-pmd/testpmd.c | 31 ++++++++++++++++++++++++------- app/test-pmd/testpmd.h | 26 ++++++++++++++++++++++---- app/test-pmd/txonly.c | 9 ++++++--- 11 files changed, 103 insertions(+), 43 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 4104737..c966892 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -797,7 +797,7 @@ struct simple_gre_hdr { TEST_PMD_CORE_CYC_RX_START(start_rx_tsc); nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); - TEST_PMD_CORE_CYC_RX_ADD(fs, start_rx_tsc); + TEST_PMD_CORE_CYC_RX_ADD(fs, start_rx_tsc, nb_rx); if (unlikely(nb_rx == 0)) return; #ifdef RTE_TEST_PMD_RECORD_BURST_STATS @@ -1067,7 +1067,7 @@ struct simple_gre_hdr { TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, tx_pkts_burst, nb_prep); - TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc, nb_tx); /* * Retry if necessary @@ -1075,11 +1075,14 @@ struct simple_gre_hdr { if (unlikely(nb_tx < nb_rx) && fs->retry_enabled) { retry = 0; while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { + uint16_t nb_rt; + rte_delay_us(burst_tx_delay_time); TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); - nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, + nb_rt = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, &tx_pkts_burst[nb_tx], nb_rx - nb_tx); - TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); + nb_tx += nb_rt; + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc, nb_rt); } } fs->tx_packets += nb_tx; diff --git a/app/test-pmd/flowgen.c b/app/test-pmd/flowgen.c index 51e87b0..9189e7b 100644 --- a/app/test-pmd/flowgen.c +++ b/app/test-pmd/flowgen.c @@ -107,7 +107,7 @@ TEST_PMD_CORE_CYC_RX_START(start_rx_tsc); nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); - TEST_PMD_CORE_CYC_RX_ADD(fs, start_rx_tsc); + TEST_PMD_CORE_CYC_RX_ADD(fs, start_rx_tsc, nb_rx); fs->rx_packets += nb_rx; for (i = 0; i < nb_rx; i++) @@ -179,18 +179,21 @@ TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_pkt); - TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc, nb_tx); /* * Retry if necessary */ if (unlikely(nb_tx < nb_rx) && fs->retry_enabled) { retry = 0; while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { + uint16_t nb_rt; + rte_delay_us(burst_tx_delay_time); TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); - nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, + nb_rt = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, &pkts_burst[nb_tx], nb_rx - nb_tx); - TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); + nb_tx += nb_rt; + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc, nb_rt); } } fs->tx_packets += nb_tx; diff --git a/app/test-pmd/icmpecho.c b/app/test-pmd/icmpecho.c index 8843183..0c8a8af 100644 --- a/app/test-pmd/icmpecho.c +++ b/app/test-pmd/icmpecho.c @@ -304,7 +304,7 @@ TEST_PMD_CORE_CYC_RX_START(start_rx_tsc); nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); - TEST_PMD_CORE_CYC_RX_ADD(fs, start_rx_tsc); + TEST_PMD_CORE_CYC_RX_ADD(fs, start_rx_tsc, nb_rx); if (unlikely(nb_rx == 0)) return; @@ -492,7 +492,7 @@ TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_replies); - TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc, nb_tx); /* * Retry if necessary */ @@ -500,13 +500,17 @@ retry = 0; while (nb_tx < nb_replies && retry++ < burst_tx_retry_num) { + uint16_t nb_rt; + rte_delay_us(burst_tx_delay_time); TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); - nb_tx += rte_eth_tx_burst(fs->tx_port, + nb_rt = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, &pkts_burst[nb_tx], nb_replies - nb_tx); - TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); + nb_tx += nb_rt; + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc, + nb_rt); } } fs->tx_packets += nb_tx; diff --git a/app/test-pmd/iofwd.c b/app/test-pmd/iofwd.c index 9ff6531..b05ed02 100644 --- a/app/test-pmd/iofwd.c +++ b/app/test-pmd/iofwd.c @@ -62,7 +62,7 @@ TEST_PMD_CORE_CYC_RX_START(start_rx_tsc); nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); - TEST_PMD_CORE_CYC_RX_ADD(fs, start_rx_tsc); + TEST_PMD_CORE_CYC_RX_ADD(fs, start_rx_tsc, nb_rx); if (unlikely(nb_rx == 0)) return; fs->rx_packets += nb_rx; @@ -73,18 +73,21 @@ TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_rx); - TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc, nb_tx); /* * Retry if necessary */ if (unlikely(nb_tx < nb_rx) && fs->retry_enabled) { retry = 0; while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { + uint16_t nb_rt; + rte_delay_us(burst_tx_delay_time); TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); - nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, + nb_rt = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, &pkts_burst[nb_tx], nb_rx - nb_tx); - TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); + nb_tx += nb_rt; + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc, nb_rt); } } fs->tx_packets += nb_tx; diff --git a/app/test-pmd/macfwd.c b/app/test-pmd/macfwd.c index f4a213e..a4aae0c 100644 --- a/app/test-pmd/macfwd.c +++ b/app/test-pmd/macfwd.c @@ -67,7 +67,7 @@ TEST_PMD_CORE_CYC_RX_START(start_rx_tsc); nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); - TEST_PMD_CORE_CYC_RX_ADD(fs, start_tx_tsc); + TEST_PMD_CORE_CYC_RX_ADD(fs, start_tx_tsc, nb_rx); if (unlikely(nb_rx == 0)) return; @@ -102,18 +102,21 @@ } TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_rx); - TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc, nb_tx); /* * Retry if necessary */ if (unlikely(nb_tx < nb_rx) && fs->retry_enabled) { retry = 0; while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { + uint16_t nb_rt; + rte_delay_us(burst_tx_delay_time); TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); - nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, + nb_rt = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, &pkts_burst[nb_tx], nb_rx - nb_tx); - TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); + nb_tx += nb_rt; + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc, nb_rt); } } diff --git a/app/test-pmd/macswap.c b/app/test-pmd/macswap.c index 5cb3133..57628ba 100644 --- a/app/test-pmd/macswap.c +++ b/app/test-pmd/macswap.c @@ -68,7 +68,7 @@ TEST_PMD_CORE_CYC_RX_START(start_rx_tsc); nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); - TEST_PMD_CORE_CYC_RX_ADD(fs, start_rx_tsc); + TEST_PMD_CORE_CYC_RX_ADD(fs, start_rx_tsc, nb_rx); if (unlikely(nb_rx == 0)) return; @@ -82,18 +82,21 @@ TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_rx); - TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc, nb_tx); /* * Retry if necessary */ if (unlikely(nb_tx < nb_rx) && fs->retry_enabled) { retry = 0; while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { + uint16_t nb_rt; + rte_delay_us(burst_tx_delay_time); TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); - nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, + nb_rt = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, &pkts_burst[nb_tx], nb_rx - nb_tx); - TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); + nb_tx += nb_rt; + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc, nb_rt); } } fs->tx_packets += nb_tx; diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c index 2820d7f..ee79e7b 100644 --- a/app/test-pmd/rxonly.c +++ b/app/test-pmd/rxonly.c @@ -60,7 +60,7 @@ TEST_PMD_CORE_CYC_RX_START(start_rx_tsc); nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); - TEST_PMD_CORE_CYC_RX_ADD(fs, start_rx_tsc); + TEST_PMD_CORE_CYC_RX_ADD(fs, start_rx_tsc, nb_rx); if (unlikely(nb_rx == 0)) return; diff --git a/app/test-pmd/softnicfwd.c b/app/test-pmd/softnicfwd.c index b78f2ce..793677d 100644 --- a/app/test-pmd/softnicfwd.c +++ b/app/test-pmd/softnicfwd.c @@ -96,7 +96,7 @@ struct tm_hierarchy { TEST_PMD_CORE_CYC_RX_START(start_rx_tsc); nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); - TEST_PMD_CORE_CYC_RX_ADD(fs, start_rx_tsc); + TEST_PMD_CORE_CYC_RX_ADD(fs, start_rx_tsc, nb_rx); fs->rx_packets += nb_rx; #ifdef RTE_TEST_PMD_RECORD_BURST_STATS @@ -106,17 +106,20 @@ struct tm_hierarchy { TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_rx); - TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc, nb_tx); /* Retry if necessary */ if (unlikely(nb_tx < nb_rx) && fs->retry_enabled) { retry = 0; while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { + uint16_t nb_rt; + rte_delay_us(burst_tx_delay_time); TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); - nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, + nb_rt = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, &pkts_burst[nb_tx], nb_rx - nb_tx); - TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); + nb_tx += nb_rt; + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc, nb_rt); } } fs->tx_packets += nb_tx; diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index b195880..1d4b55b 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -1515,7 +1515,7 @@ struct extmem_param { #ifdef RTE_TEST_PMD_RECORD_BURST_STATS static void -pkt_burst_stats_display(const char *rx_tx, struct pkt_burst_stats *pbs) +pkt_burst_stats_display(int nrx_tx, struct pkt_burst_stats *pbs) { unsigned int total_burst; unsigned int nb_burst; @@ -1549,8 +1549,8 @@ struct extmem_param { if (total_burst == 0) return; burst_percent[0] = (burst_stats[0] * 100) / total_burst; - printf(" %s-bursts : %u [%d%% of %d pkts", rx_tx, total_burst, - burst_percent[0], (int) pktnb_stats[0]); + printf(" %s-bursts : %u [%d%% of %d pkts", nrx_tx ? "TX" : "RX", + total_burst, burst_percent[0], (int) pktnb_stats[0]); if (burst_stats[0] == total_burst) { printf("]\n"); return; @@ -1568,6 +1568,23 @@ struct extmem_param { } printf(" + %d%% of %d pkts + %d%% of others]\n", burst_percent[1], (int) pktnb_stats[1], burst_percent[2]); +#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES + if (!(fwdprof_flags & (nrx_tx ? RECORD_CORE_CYCLES_TX + : RECORD_CORE_CYCLES_RX))) + return; + for (nb_pkt = 0; nb_pkt < MAX_PKT_BURST; nb_pkt++) { + nb_burst = nrx_tx ? pbs->pkt_retry_spread[nb_pkt] + : pbs->pkt_burst_spread[nb_pkt]; + if (nb_burst == 0) + continue; + printf(" CPU cycles/%u packet burst=%u (total cycles=" + "%"PRIu64" / total %s bursts=%u)\n", + (unsigned int)nb_pkt, + (unsigned int)(pbs->pkt_ticks_spread[nb_pkt] / nb_burst), + pbs->pkt_ticks_spread[nb_pkt], + nrx_tx ? "TX" : "RX", nb_burst); + } +#endif } #endif /* RTE_TEST_PMD_RECORD_BURST_STATS */ @@ -1601,8 +1618,8 @@ struct extmem_param { } #ifdef RTE_TEST_PMD_RECORD_BURST_STATS - pkt_burst_stats_display("RX", &fs->rx_burst_stats); - pkt_burst_stats_display("TX", &fs->tx_burst_stats); + pkt_burst_stats_display(false, &fs->rx_burst_stats); + pkt_burst_stats_display(true, &fs->tx_burst_stats); #endif } @@ -1742,10 +1759,10 @@ struct extmem_param { #ifdef RTE_TEST_PMD_RECORD_BURST_STATS if (ports_stats[pt_id].rx_stream) - pkt_burst_stats_display("RX", + pkt_burst_stats_display(false, &ports_stats[pt_id].rx_stream->rx_burst_stats); if (ports_stats[pt_id].tx_stream) - pkt_burst_stats_display("TX", + pkt_burst_stats_display(true, &ports_stats[pt_id].tx_stream->tx_burst_stats); #endif diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 6177a50..90eb0ef 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -89,6 +89,10 @@ enum { */ struct pkt_burst_stats { unsigned int pkt_burst_spread[MAX_PKT_BURST]; +#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES + unsigned int pkt_retry_spread[MAX_PKT_BURST]; + uint64_t pkt_ticks_spread[MAX_PKT_BURST]; +#endif }; #endif @@ -340,21 +344,35 @@ struct queue_stats_mappings { {if (fwdprof_flags & RECORD_CORE_CYCLES_FWD) \ {uint64_t tsc = rte_rdtsc(); tsc -= (s); fs->core_cycles += tsc; } } -#define TEST_PMD_CORE_CYC_TX_ADD(fs, s) \ +#ifdef RTE_TEST_PMD_RECORD_BURST_STATS +#define TEST_PMD_CORE_CYC_TX_ADD(fs, s, np) \ +{if (fwdprof_flags & RECORD_CORE_CYCLES_TX) \ +{uint64_t tsc = rte_rdtsc(); tsc -= (s); fs->core_tx_cycles += tsc; \ +fs->tx_burst_stats.pkt_ticks_spread[np] += tsc; \ +fs->tx_burst_stats.pkt_retry_spread[np]++; } } + +#define TEST_PMD_CORE_CYC_RX_ADD(fs, s, np) \ +{if (fwdprof_flags & RECORD_CORE_CYCLES_RX) \ +{uint64_t tsc = rte_rdtsc(); tsc -= (s); fs->core_rx_cycles += tsc; \ +fs->rx_burst_stats.pkt_ticks_spread[np] += tsc; } } + +#else /* RTE_TEST_PMD_RECORD_BURST_STATS */ +#define TEST_PMD_CORE_CYC_TX_ADD(fs, s, np) \ {if (fwdprof_flags & RECORD_CORE_CYCLES_TX) \ {uint64_t tsc = rte_rdtsc(); tsc -= (s); fs->core_tx_cycles += tsc; } } -#define TEST_PMD_CORE_CYC_RX_ADD(fs, s) \ +#define TEST_PMD_CORE_CYC_RX_ADD(fs, s, np) \ {if (fwdprof_flags & RECORD_CORE_CYCLES_RX) \ {uint64_t tsc = rte_rdtsc(); tsc -= (s); fs->core_rx_cycles += tsc; } } +#endif /* RTE_TEST_PMD_RECORD_BURST_STATS */ #else /* No profiling statistics is configured. */ #define TEST_PMD_CORE_CYC_TX_START(a) #define TEST_PMD_CORE_CYC_RX_START(a) #define TEST_PMD_CORE_CYC_FWD_ADD(fs, s) -#define TEST_PMD_CORE_CYC_TX_ADD(fs, s) -#define TEST_PMD_CORE_CYC_RX_ADD(fs, s) +#define TEST_PMD_CORE_CYC_TX_ADD(fs, s, np) +#define TEST_PMD_CORE_CYC_RX_ADD(fs, s, np) #endif /* RTE_TEST_PMD_RECORD_CORE_CYCLES */ /* globals used for configuration */ diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c index 8ff7410..593044e 100644 --- a/app/test-pmd/txonly.c +++ b/app/test-pmd/txonly.c @@ -299,18 +299,21 @@ TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_pkt); - TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc, nb_tx); /* * Retry if necessary */ if (unlikely(nb_tx < nb_pkt) && fs->retry_enabled) { retry = 0; while (nb_tx < nb_pkt && retry++ < burst_tx_retry_num) { + uint16_t nb_rt; + rte_delay_us(burst_tx_delay_time); TEST_PMD_CORE_CYC_TX_START(start_tx_tsc); - nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue, + nb_rt = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, &pkts_burst[nb_tx], nb_pkt - nb_tx); - TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc); + nb_tx += nb_rt; + TEST_PMD_CORE_CYC_TX_ADD(fs, start_tx_tsc, nb_rt); } } fs->tx_packets += nb_tx;