From patchwork Tue Jul 14 21:51:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dharmik Thakkar X-Patchwork-Id: 74020 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 09B15A0540; Tue, 14 Jul 2020 23:52:10 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 367E81C21F; Tue, 14 Jul 2020 23:51:48 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id 89E211C1F2 for ; Tue, 14 Jul 2020 23:51:41 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C91DDFC2; Tue, 14 Jul 2020 14:51:40 -0700 (PDT) Received: from localhost.localdomain (2p2660v4-1.austin.arm.com [10.118.12.95]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BFB413F66E; Tue, 14 Jul 2020 14:51:40 -0700 (PDT) From: Dharmik Thakkar To: Wenzhuo Lu , Beilei Xing , Bernard Iremonger Cc: dev@dpdk.org, nd@arm.com, Dharmik Thakkar Date: Tue, 14 Jul 2020 16:51:03 -0500 Message-Id: <20200714215108.22437-2-dharmik.thakkar@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200714215108.22437-1-dharmik.thakkar@arm.com> References: <20200520032023.2649-2-dharmik.thakkar@arm.com> <20200714215108.22437-1-dharmik.thakkar@arm.com> Subject: [dpdk-dev] [PATCH 1/6] app/testpmd: add record-core-cycles runtime config 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" Convert CONFIG_RTE_TEST_PMD_RECORD_CORE_CYCLES to a runtime configuration. Signed-off-by: Dharmik Thakkar Tested-by: Phil Yang Reviewed-by: Ruifeng Wang Reviewed-by: Honnappa Nagarahalli --- app/test-pmd/5tswap.c | 16 +++----------- app/test-pmd/cmdline.c | 46 +++++++++++++++++++++++++++++++++++++++ app/test-pmd/config.c | 6 +++++ app/test-pmd/csumonly.c | 16 +++----------- app/test-pmd/flowgen.c | 17 ++++----------- app/test-pmd/icmpecho.c | 16 +++----------- app/test-pmd/iofwd.c | 18 ++++----------- app/test-pmd/macfwd.c | 17 ++++----------- app/test-pmd/macswap.c | 16 +++----------- app/test-pmd/parameters.c | 6 ++++- app/test-pmd/rxonly.c | 15 +++---------- app/test-pmd/testpmd.c | 44 ++++++++++++++++++------------------- app/test-pmd/testpmd.h | 18 +++++++++++++-- app/test-pmd/txonly.c | 16 +++----------- 14 files changed, 125 insertions(+), 142 deletions(-) diff --git a/app/test-pmd/5tswap.c b/app/test-pmd/5tswap.c index 972f6b93b31d..04f035bb450f 100644 --- a/app/test-pmd/5tswap.c +++ b/app/test-pmd/5tswap.c @@ -105,15 +105,9 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs) uint8_t *byte; } h; -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - uint64_t start_tsc; - uint64_t end_tsc; - uint64_t core_cycles; -#endif + uint64_t start_tsc = 0; -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - start_tsc = rte_rdtsc(); -#endif + get_start_cycles(&start_tsc); /* * Receive a burst of packets and forward them. @@ -193,11 +187,7 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs) 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 + get_end_cycles(fs, start_tsc); } struct fwd_engine five_tuple_swap_fwd_engine = { diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 39a1e772ed7c..1f30a9021500 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -529,6 +529,9 @@ static void cmd_help_long_parsed(void *parsed_result, " Set the option to hide the zero values" " for xstats display.\n" + "set record-core-cycles on|off\n" + " Set the option to enable measurement of CPU cycles.\n" + "set port (port_id) vf (vf_id) rx|tx on|off\n" " Enable/Disable a VF receive/tranmit from a port\n\n" @@ -8335,6 +8338,48 @@ cmdline_parse_inst_t cmd_set_xstats_hide_zero = { }, }; +/* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */ +struct cmd_set_record_core_cycles_result { + cmdline_fixed_string_t keyword; + cmdline_fixed_string_t name; + cmdline_fixed_string_t on_off; +}; + +static void +cmd_set_record_core_cycles_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_set_record_core_cycles_result *res; + uint16_t on_off = 0; + + res = parsed_result; + on_off = !strcmp(res->on_off, "on") ? 1 : 0; + set_record_core_cycles(on_off); +} + +cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword = + TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, + keyword, "set"); +cmdline_parse_token_string_t cmd_set_record_core_cycles_name = + TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, + name, "record-core-cycles"); +cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off = + TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result, + on_off, "on#off"); + +cmdline_parse_inst_t cmd_set_record_core_cycles = { + .f = cmd_set_record_core_cycles_parsed, + .data = NULL, + .help_str = "set record-core-cycles on|off", + .tokens = { + (void *)&cmd_set_record_core_cycles_keyword, + (void *)&cmd_set_record_core_cycles_name, + (void *)&cmd_set_record_core_cycles_on_off, + NULL, + }, +}; + /* *** CONFIGURE UNICAST HASH TABLE *** */ struct cmd_set_uc_hash_table { cmdline_fixed_string_t set; @@ -19487,6 +19532,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer, (cmdline_parse_inst_t *)&cmd_set_qmap, (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero, + (cmdline_parse_inst_t *)&cmd_set_record_core_cycles, (cmdline_parse_inst_t *)&cmd_operate_port, (cmdline_parse_inst_t *)&cmd_operate_specific_port, (cmdline_parse_inst_t *)&cmd_operate_attach_port, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index fcbe6b6f7440..d93699b34e3a 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -3679,6 +3679,12 @@ set_xstats_hide_zero(uint8_t on_off) xstats_hide_zero = on_off; } +void +set_record_core_cycles(uint8_t on_off) +{ + record_core_cycles = on_off; +} + static inline void print_fdir_mask(struct rte_eth_fdir_masks *mask) { diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 0a96b24eb27b..836bafa0f6df 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -789,15 +789,9 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) uint16_t nb_segments = 0; int ret; -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - uint64_t start_tsc; - uint64_t end_tsc; - uint64_t core_cycles; -#endif + uint64_t start_tsc = 0; -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - start_tsc = rte_rdtsc(); -#endif + get_start_cycles(&start_tsc); /* receive a burst of packet */ nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, @@ -1098,11 +1092,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) } 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 + get_end_cycles(fs, start_tsc); } struct fwd_engine csum_fwd_engine = { diff --git a/app/test-pmd/flowgen.c b/app/test-pmd/flowgen.c index 4bd351e6754a..e92a0eeca254 100644 --- a/app/test-pmd/flowgen.c +++ b/app/test-pmd/flowgen.c @@ -97,16 +97,10 @@ pkt_burst_flow_gen(struct fwd_stream *fs) uint16_t i; 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; -#endif + uint64_t start_tsc = 0; static int next_flow = 0; -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - start_tsc = rte_rdtsc(); -#endif + get_start_cycles(&start_tsc); /* Receive a burst of packets and discard them. */ nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, @@ -207,11 +201,8 @@ pkt_burst_flow_gen(struct fwd_stream *fs) 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 + + get_end_cycles(fs, start_tsc); } struct fwd_engine flow_gen_engine = { diff --git a/app/test-pmd/icmpecho.c b/app/test-pmd/icmpecho.c index 78e3adf2c106..3f27e8c29d33 100644 --- a/app/test-pmd/icmpecho.c +++ b/app/test-pmd/icmpecho.c @@ -293,15 +293,9 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs) uint32_t cksum; 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 + uint64_t start_tsc = 0; -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - start_tsc = rte_rdtsc(); -#endif + get_start_cycles(&start_tsc); /* * First, receive a burst of packets. @@ -520,11 +514,7 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs) } } -#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 + get_end_cycles(fs, start_tsc); } struct fwd_engine icmp_echo_engine = { diff --git a/app/test-pmd/iofwd.c b/app/test-pmd/iofwd.c index 22b59bbdaf5a..456f7b5925ed 100644 --- a/app/test-pmd/iofwd.c +++ b/app/test-pmd/iofwd.c @@ -50,16 +50,9 @@ pkt_burst_io_forward(struct fwd_stream *fs) uint16_t nb_rx; uint16_t nb_tx; uint32_t retry; + uint64_t start_tsc = 0; -#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(); -#endif + get_start_cycles(&start_tsc); /* * Receive a burst of packets and forward them. @@ -96,11 +89,8 @@ pkt_burst_io_forward(struct fwd_stream *fs) 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 + + get_end_cycles(fs, start_tsc); } struct fwd_engine io_fwd_engine = { diff --git a/app/test-pmd/macfwd.c b/app/test-pmd/macfwd.c index 0a89d94befe5..6a77568c7e60 100644 --- a/app/test-pmd/macfwd.c +++ b/app/test-pmd/macfwd.c @@ -56,15 +56,9 @@ pkt_burst_mac_forward(struct fwd_stream *fs) uint16_t i; 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 + uint64_t start_tsc = 0; -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - start_tsc = rte_rdtsc(); -#endif + get_start_cycles(&start_tsc); /* * Receive a burst of packets and forward them. @@ -126,11 +120,8 @@ pkt_burst_mac_forward(struct fwd_stream *fs) 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 + + get_end_cycles(fs, start_tsc); } struct fwd_engine mac_fwd_engine = { diff --git a/app/test-pmd/macswap.c b/app/test-pmd/macswap.c index fbe8cb39e5d2..aaef5b0047b1 100644 --- a/app/test-pmd/macswap.c +++ b/app/test-pmd/macswap.c @@ -57,15 +57,9 @@ pkt_burst_mac_swap(struct fwd_stream *fs) uint16_t nb_rx; 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 + uint64_t start_tsc = 0; -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - start_tsc = rte_rdtsc(); -#endif + get_start_cycles(&start_tsc); /* * Receive a burst of packets and forward them. @@ -105,11 +99,7 @@ pkt_burst_mac_swap(struct fwd_stream *fs) 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 + get_end_cycles(fs, start_tsc); } struct fwd_engine mac_swap_engine = { diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 7cb0e3d6ec0a..76072ae81b93 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -70,7 +70,7 @@ usage(char* progname) "--rxpt= | --rxht= | --rxwt= | --rxfreet= | " "--txpt= | --txht= | --txwt= | --txfreet= | " "--txrst= | --tx-offloads= | | --rx-offloads= | " - "--vxlan-gpe-port= ]\n", + "--vxlan-gpe-port= | --record-core-cycles]\n", progname); #ifdef RTE_LIBRTE_CMDLINE printf(" --interactive: run in interactive mode.\n"); @@ -216,6 +216,7 @@ usage(char* progname) "valid only with --mp-alloc=anon\n"); printf(" --rx-mq-mode=0xX: hexadecimal bitmask of RX mq mode can be " "enabled\n"); + printf(" --record-core-cycles: enable measurement of CPU cycles.\n"); } #ifdef RTE_LIBRTE_CMDLINE @@ -677,6 +678,7 @@ launch_args_parse(int argc, char** argv) { "noisy-lkup-num-reads-writes", 1, 0, 0 }, { "no-iova-contig", 0, 0, 0 }, { "rx-mq-mode", 1, 0, 0 }, + { "record-core-cycles", 0, 0, 0 }, { 0, 0, 0, 0 }, }; @@ -1381,6 +1383,8 @@ launch_args_parse(int argc, char** argv) "rx-mq-mode must be >= 0 and <= %d\n", ETH_MQ_RX_VMDQ_DCB_RSS); } + if (!strcmp(lgopts[opt_idx].name, "record-core-cycles")) + record_core_cycles = 1; break; case 'h': usage(argv[0]); diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c index 18d59a68d652..b6c8b8c7d5db 100644 --- a/app/test-pmd/rxonly.c +++ b/app/test-pmd/rxonly.c @@ -49,14 +49,9 @@ pkt_burst_receive(struct fwd_stream *fs) struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; uint16_t nb_rx; uint16_t i; + uint64_t start_tsc = 0; -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - uint64_t start_tsc; - uint64_t end_tsc; - uint64_t core_cycles; - - start_tsc = rte_rdtsc(); -#endif + get_start_cycles(&start_tsc); /* * Receive a burst of packets. @@ -73,11 +68,7 @@ pkt_burst_receive(struct fwd_stream *fs) 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 + get_end_cycles(fs, start_tsc); } struct fwd_engine rx_only_engine = { diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 7842c3b78120..f327b16604d2 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -475,6 +475,11 @@ uint16_t nb_rx_queue_stats_mappings = 0; */ uint8_t xstats_hide_zero; +/* + * Measure of CPU cycles disabled by default + */ +uint8_t record_core_cycles; + unsigned int num_sockets = 0; unsigned int socket_ids[RTE_MAX_NUMA_NODES]; @@ -1800,9 +1805,7 @@ fwd_stats_display(void) uint64_t total_tx_dropped = 0; uint64_t total_rx_nombuf = 0; struct rte_eth_stats stats; -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES uint64_t fwd_cycles = 0; -#endif uint64_t total_recv = 0; uint64_t total_xmit = 0; struct rte_port *port; @@ -1830,9 +1833,8 @@ fwd_stats_display(void) ports_stats[fs->rx_port].rx_bad_outer_l4_csum += fs->rx_bad_outer_l4_csum; -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - fwd_cycles += fs->core_cycles; -#endif + if (record_core_cycles) + fwd_cycles += fs->core_cycles; } for (i = 0; i < cur_fwd_config.nb_fwd_ports; i++) { uint8_t j; @@ -1961,24 +1963,24 @@ fwd_stats_display(void) printf(" %s++++++++++++++++++++++++++++++++++++++++++++++" "%s\n", acc_stats_border, acc_stats_border); -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES + if (record_core_cycles) { #define CYC_PER_MHZ 1E6 - if (total_recv > 0 || total_xmit > 0) { - uint64_t total_pkts = 0; - if (strcmp(cur_fwd_eng->fwd_mode_name, "txonly") == 0 || - strcmp(cur_fwd_eng->fwd_mode_name, "flowgen") == 0) - total_pkts = total_xmit; - else - total_pkts = total_recv; + if (total_recv > 0 || total_xmit > 0) { + uint64_t total_pkts = 0; + if (strcmp(cur_fwd_eng->fwd_mode_name, "txonly") == 0 || + strcmp(cur_fwd_eng->fwd_mode_name, "flowgen") == 0) + total_pkts = total_xmit; + else + total_pkts = total_recv; - printf("\n CPU cycles/packet=%.2F (total cycles=" - "%"PRIu64" / total %s packets=%"PRIu64") at %"PRIu64 - " MHz Clock\n", - (double) fwd_cycles / total_pkts, - fwd_cycles, cur_fwd_eng->fwd_mode_name, total_pkts, - (uint64_t)(rte_get_tsc_hz() / CYC_PER_MHZ)); + printf("\n CPU cycles/packet=%.2F (total cycles=" + "%"PRIu64" / total %s packets=%"PRIu64") at %"PRIu64 + " MHz Clock\n", + (double) fwd_cycles / total_pkts, + fwd_cycles, cur_fwd_eng->fwd_mode_name, total_pkts, + (uint64_t)(rte_get_tsc_hz() / CYC_PER_MHZ)); + } } -#endif } void @@ -2006,9 +2008,7 @@ fwd_stats_reset(void) memset(&fs->rx_burst_stats, 0, sizeof(fs->rx_burst_stats)); memset(&fs->tx_burst_stats, 0, sizeof(fs->tx_burst_stats)); #endif -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES fs->core_cycles = 0; -#endif } } diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 25a12b14f29d..dcc37be02d59 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -129,9 +129,7 @@ struct fwd_stream { uint64_t rx_bad_outer_l4_csum; /**< 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 */ -#endif #ifdef RTE_TEST_PMD_RECORD_BURST_STATS struct pkt_burst_stats rx_burst_stats; struct pkt_burst_stats tx_burst_stats; @@ -301,6 +299,7 @@ extern uint16_t nb_rx_queue_stats_mappings; extern uint8_t xstats_hide_zero; /**< Hide zero values for xstats display */ /* globals used for configuration */ +extern uint8_t record_core_cycles; /**< Enables measurement of CPU cycles */ extern uint16_t verbose_level; /**< Drives messages being displayed, if any. */ extern int testpmd_logtype; /**< Log type for testpmd logs */ extern uint8_t interactive; @@ -681,6 +680,20 @@ port_pci_reg_write(struct rte_port *port, uint32_t reg_off, uint32_t reg_v) #define port_id_pci_reg_write(pt_id, reg_off, reg_value) \ port_pci_reg_write(&ports[(pt_id)], (reg_off), (reg_value)) +static inline void +get_start_cycles(uint64_t *start_tsc) +{ + if (record_core_cycles) + *start_tsc = rte_rdtsc(); +} + +static inline void +get_end_cycles(struct fwd_stream *fs, uint64_t start_tsc) +{ + if (record_core_cycles) + fs->core_cycles += rte_rdtsc() - start_tsc; +} + /* Prototypes */ unsigned int parse_item_list(char* str, const char* item_name, unsigned int max_items, @@ -772,6 +785,7 @@ void set_qmap(portid_t port_id, uint8_t is_rx, uint16_t queue_id, uint8_t map_va void set_xstats_hide_zero(uint8_t on_off); +void set_record_core_cycles(uint8_t on_off); void set_verbose_level(uint16_t vb_level); void set_tx_pkt_segments(unsigned *seg_lengths, unsigned nb_segs); void show_tx_pkt_segments(void); diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c index 97f4a452da12..00a3a6f90c7a 100644 --- a/app/test-pmd/txonly.c +++ b/app/test-pmd/txonly.c @@ -294,15 +294,9 @@ pkt_burst_transmit(struct fwd_stream *fs) uint32_t retry; 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 + uint64_t start_tsc = 0; -#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES - start_tsc = rte_rdtsc(); -#endif + get_start_cycles(&start_tsc); mbp = current_fwd_lcore()->mbp; txp = &ports[fs->tx_port]; @@ -391,11 +385,7 @@ pkt_burst_transmit(struct fwd_stream *fs) } 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 + get_end_cycles(fs, start_tsc); } static void From patchwork Tue Jul 14 21:51:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dharmik Thakkar X-Patchwork-Id: 74017 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 298D2A0540; Tue, 14 Jul 2020 23:51:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 50F8F1C1F2; Tue, 14 Jul 2020 23:51:43 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id 86C191C18E for ; Tue, 14 Jul 2020 23:51:41 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E157B101E; Tue, 14 Jul 2020 14:51:40 -0700 (PDT) Received: from localhost.localdomain (2p2660v4-1.austin.arm.com [10.118.12.95]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DB3153F66E; Tue, 14 Jul 2020 14:51:40 -0700 (PDT) From: Dharmik Thakkar To: Wenzhuo Lu , Beilei Xing , Bernard Iremonger , John McNamara , Marko Kovacevic Cc: dev@dpdk.org, nd@arm.com, Dharmik Thakkar Date: Tue, 14 Jul 2020 16:51:04 -0500 Message-Id: <20200714215108.22437-3-dharmik.thakkar@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200714215108.22437-1-dharmik.thakkar@arm.com> References: <20200520032023.2649-2-dharmik.thakkar@arm.com> <20200714215108.22437-1-dharmik.thakkar@arm.com> Subject: [dpdk-dev] [PATCH 2/6] doc: add record-core-cycles to testpmd funcs doc 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" Update documentation to include description of 'record-core-cycles' runtime configuration. Signed-off-by: Dharmik Thakkar Reviewed-by: Phil Yang Reviewed-by: Ruifeng Wang Reviewed-by: Honnappa Nagarahalli --- doc/guides/testpmd_app_ug/run_app.rst | 6 ++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst index d1e4ee3e7a46..2b8e0ad69157 100644 --- a/doc/guides/testpmd_app_ug/run_app.rst +++ b/doc/guides/testpmd_app_ug/run_app.rst @@ -489,3 +489,9 @@ The command line options are: The default value is 0x7:: ETH_MQ_RX_RSS_FLAG | ETH_MQ_RX_DCB_FLAG | ETH_MQ_RX_VMDQ_FLAG + +* ``--record-core-cycles`` + + Enable measurement of CPU cycles per packet. + + diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index f8cfb02e38ab..980bf3340763 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -710,6 +710,21 @@ Set the forwarding ports hexadecimal mask:: This is equivalent to the ``--portmask`` command-line option. +set record-core-cycles +~~~~~~~~~~~~~~~~~~~~~~ + +Set the recording of CPU cycles:: + + testpmd> set record-core-cycles (on|off) + +Where: + +* ``on`` enables measurement of CPU cycles per packet. + +* ``off`` disables measurement of CPU cycles per packet. + +This is equivalent to the ``--record-core-cycles command-line`` option. + set burst ~~~~~~~~~ From patchwork Tue Jul 14 21:51:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dharmik Thakkar X-Patchwork-Id: 74021 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 E868FA0540; Tue, 14 Jul 2020 23:52:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DA1E71C229; Tue, 14 Jul 2020 23:51:49 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id A37ED1C1F4 for ; Tue, 14 Jul 2020 23:51:41 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1851E11B3; Tue, 14 Jul 2020 14:51:41 -0700 (PDT) Received: from localhost.localdomain (2p2660v4-1.austin.arm.com [10.118.12.95]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0FC383F66E; Tue, 14 Jul 2020 14:51:41 -0700 (PDT) From: Dharmik Thakkar To: Wenzhuo Lu , Beilei Xing , Bernard Iremonger Cc: dev@dpdk.org, nd@arm.com, Dharmik Thakkar Date: Tue, 14 Jul 2020 16:51:05 -0500 Message-Id: <20200714215108.22437-4-dharmik.thakkar@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200714215108.22437-1-dharmik.thakkar@arm.com> References: <20200520032023.2649-2-dharmik.thakkar@arm.com> <20200714215108.22437-1-dharmik.thakkar@arm.com> Subject: [dpdk-dev] [PATCH 3/6] app/testpmd: add record-burst-stats runtime config 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" Convert CONFIG_RTE_TEST_PMD_RECORD_BURST_STATS to a runtime configuration. Signed-off-by: Dharmik Thakkar Tested-by: Phil Yang Reviewed-by: Ruifeng Wang Reviewed-by: Honnappa Nagarahalli --- app/test-pmd/5tswap.c | 8 ++----- app/test-pmd/cmdline.c | 46 +++++++++++++++++++++++++++++++++++++++ app/test-pmd/config.c | 6 +++++ app/test-pmd/csumonly.c | 8 ++----- app/test-pmd/flowgen.c | 4 +--- app/test-pmd/icmpecho.c | 8 ++----- app/test-pmd/iofwd.c | 8 ++----- app/test-pmd/macfwd.c | 8 ++----- app/test-pmd/macswap.c | 8 ++----- app/test-pmd/parameters.c | 7 +++++- app/test-pmd/rxonly.c | 4 +--- app/test-pmd/testpmd.c | 33 ++++++++++++++-------------- app/test-pmd/testpmd.h | 20 +++++++++++++---- app/test-pmd/txonly.c | 4 +--- 14 files changed, 106 insertions(+), 66 deletions(-) diff --git a/app/test-pmd/5tswap.c b/app/test-pmd/5tswap.c index 04f035bb450f..d9026ce86556 100644 --- a/app/test-pmd/5tswap.c +++ b/app/test-pmd/5tswap.c @@ -117,9 +117,7 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs) if (unlikely(nb_rx == 0)) return; -#ifdef RTE_TEST_PMD_RECORD_BURST_STATS - fs->rx_burst_stats.pkt_burst_spread[nb_rx]++; -#endif + inc_rx_burst_stats(fs, nb_rx); fs->rx_packets += nb_rx; txp = &ports[fs->tx_port]; @@ -178,9 +176,7 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs) } } fs->tx_packets += nb_tx; -#ifdef RTE_TEST_PMD_RECORD_BURST_STATS - fs->tx_burst_stats.pkt_burst_spread[nb_tx]++; -#endif + inc_tx_burst_stats(fs, nb_tx); if (unlikely(nb_tx < nb_rx)) { fs->fwd_dropped += (nb_rx - nb_tx); do { diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 1f30a9021500..6235fa0074d4 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -532,6 +532,9 @@ static void cmd_help_long_parsed(void *parsed_result, "set record-core-cycles on|off\n" " Set the option to enable measurement of CPU cycles.\n" + "set record-burst-stats on|off\n" + " Set the option to enable display of RX and TX bursts.\n" + "set port (port_id) vf (vf_id) rx|tx on|off\n" " Enable/Disable a VF receive/tranmit from a port\n\n" @@ -8380,6 +8383,48 @@ cmdline_parse_inst_t cmd_set_record_core_cycles = { }, }; +/* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */ +struct cmd_set_record_burst_stats_result { + cmdline_fixed_string_t keyword; + cmdline_fixed_string_t name; + cmdline_fixed_string_t on_off; +}; + +static void +cmd_set_record_burst_stats_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_set_record_burst_stats_result *res; + uint16_t on_off = 0; + + res = parsed_result; + on_off = !strcmp(res->on_off, "on") ? 1 : 0; + set_record_burst_stats(on_off); +} + +cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword = + TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, + keyword, "set"); +cmdline_parse_token_string_t cmd_set_record_burst_stats_name = + TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, + name, "record-burst-stats"); +cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off = + TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result, + on_off, "on#off"); + +cmdline_parse_inst_t cmd_set_record_burst_stats = { + .f = cmd_set_record_burst_stats_parsed, + .data = NULL, + .help_str = "set record-burst-stats on|off", + .tokens = { + (void *)&cmd_set_record_burst_stats_keyword, + (void *)&cmd_set_record_burst_stats_name, + (void *)&cmd_set_record_burst_stats_on_off, + NULL, + }, +}; + /* *** CONFIGURE UNICAST HASH TABLE *** */ struct cmd_set_uc_hash_table { cmdline_fixed_string_t set; @@ -19533,6 +19578,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_qmap, (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero, (cmdline_parse_inst_t *)&cmd_set_record_core_cycles, + (cmdline_parse_inst_t *)&cmd_set_record_burst_stats, (cmdline_parse_inst_t *)&cmd_operate_port, (cmdline_parse_inst_t *)&cmd_operate_specific_port, (cmdline_parse_inst_t *)&cmd_operate_attach_port, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index d93699b34e3a..873a29a123a5 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -3685,6 +3685,12 @@ set_record_core_cycles(uint8_t on_off) record_core_cycles = on_off; } +void +set_record_burst_stats(uint8_t on_off) +{ + record_burst_stats = on_off; +} + static inline void print_fdir_mask(struct rte_eth_fdir_masks *mask) { diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 836bafa0f6df..7ece398bd462 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -796,9 +796,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) /* receive a burst of packet */ nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); -#ifdef RTE_TEST_PMD_RECORD_BURST_STATS - fs->rx_burst_stats.pkt_burst_spread[nb_rx]++; -#endif + inc_rx_burst_stats(fs, nb_rx); if (unlikely(nb_rx == 0)) return; @@ -1082,9 +1080,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) fs->rx_bad_l4_csum += rx_bad_l4_csum; fs->rx_bad_outer_l4_csum += rx_bad_outer_l4_csum; -#ifdef RTE_TEST_PMD_RECORD_BURST_STATS - fs->tx_burst_stats.pkt_burst_spread[nb_tx]++; -#endif + inc_tx_burst_stats(fs, nb_tx); if (unlikely(nb_tx < nb_rx)) { fs->fwd_dropped += (nb_rx - nb_tx); do { diff --git a/app/test-pmd/flowgen.c b/app/test-pmd/flowgen.c index e92a0eeca254..acf3e24605eb 100644 --- a/app/test-pmd/flowgen.c +++ b/app/test-pmd/flowgen.c @@ -188,9 +188,7 @@ pkt_burst_flow_gen(struct fwd_stream *fs) } fs->tx_packets += nb_tx; -#ifdef RTE_TEST_PMD_RECORD_BURST_STATS - fs->tx_burst_stats.pkt_burst_spread[nb_tx]++; -#endif + inc_tx_burst_stats(fs, nb_tx); if (unlikely(nb_tx < nb_pkt)) { /* Back out the flow counter. */ next_flow -= (nb_pkt - nb_tx); diff --git a/app/test-pmd/icmpecho.c b/app/test-pmd/icmpecho.c index 3f27e8c29d33..af6f7e7902e4 100644 --- a/app/test-pmd/icmpecho.c +++ b/app/test-pmd/icmpecho.c @@ -302,9 +302,7 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs) */ nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); -#ifdef RTE_TEST_PMD_RECORD_BURST_STATS - fs->rx_burst_stats.pkt_burst_spread[nb_rx]++; -#endif + inc_rx_burst_stats(fs, nb_rx); if (unlikely(nb_rx == 0)) return; @@ -503,9 +501,7 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs) } } fs->tx_packets += nb_tx; -#ifdef RTE_TEST_PMD_RECORD_BURST_STATS - fs->tx_burst_stats.pkt_burst_spread[nb_tx]++; -#endif + inc_tx_burst_stats(fs, nb_tx); if (unlikely(nb_tx < nb_replies)) { fs->fwd_dropped += (nb_replies - nb_tx); do { diff --git a/app/test-pmd/iofwd.c b/app/test-pmd/iofwd.c index 456f7b5925ed..83d098adcbf5 100644 --- a/app/test-pmd/iofwd.c +++ b/app/test-pmd/iofwd.c @@ -59,9 +59,7 @@ pkt_burst_io_forward(struct fwd_stream *fs) */ nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); -#ifdef RTE_TEST_PMD_RECORD_BURST_STATS - fs->rx_burst_stats.pkt_burst_spread[nb_rx]++; -#endif + inc_rx_burst_stats(fs, nb_rx); if (unlikely(nb_rx == 0)) return; fs->rx_packets += nb_rx; @@ -80,9 +78,7 @@ pkt_burst_io_forward(struct fwd_stream *fs) } } fs->tx_packets += nb_tx; -#ifdef RTE_TEST_PMD_RECORD_BURST_STATS - fs->tx_burst_stats.pkt_burst_spread[nb_tx]++; -#endif + inc_tx_burst_stats(fs, nb_tx); if (unlikely(nb_tx < nb_rx)) { fs->fwd_dropped += (nb_rx - nb_tx); do { diff --git a/app/test-pmd/macfwd.c b/app/test-pmd/macfwd.c index 6a77568c7e60..0568ea794d48 100644 --- a/app/test-pmd/macfwd.c +++ b/app/test-pmd/macfwd.c @@ -65,9 +65,7 @@ pkt_burst_mac_forward(struct fwd_stream *fs) */ nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); -#ifdef RTE_TEST_PMD_RECORD_BURST_STATS - fs->rx_burst_stats.pkt_burst_spread[nb_rx]++; -#endif + inc_rx_burst_stats(fs, nb_rx); if (unlikely(nb_rx == 0)) return; @@ -111,9 +109,7 @@ pkt_burst_mac_forward(struct fwd_stream *fs) } fs->tx_packets += nb_tx; -#ifdef RTE_TEST_PMD_RECORD_BURST_STATS - fs->tx_burst_stats.pkt_burst_spread[nb_tx]++; -#endif + inc_tx_burst_stats(fs, nb_tx); if (unlikely(nb_tx < nb_rx)) { fs->fwd_dropped += (nb_rx - nb_tx); do { diff --git a/app/test-pmd/macswap.c b/app/test-pmd/macswap.c index aaef5b0047b1..74e2dd838dd5 100644 --- a/app/test-pmd/macswap.c +++ b/app/test-pmd/macswap.c @@ -66,9 +66,7 @@ pkt_burst_mac_swap(struct fwd_stream *fs) */ nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); -#ifdef RTE_TEST_PMD_RECORD_BURST_STATS - fs->rx_burst_stats.pkt_burst_spread[nb_rx]++; -#endif + inc_rx_burst_stats(fs, nb_rx); if (unlikely(nb_rx == 0)) return; @@ -90,9 +88,7 @@ pkt_burst_mac_swap(struct fwd_stream *fs) } } fs->tx_packets += nb_tx; -#ifdef RTE_TEST_PMD_RECORD_BURST_STATS - fs->tx_burst_stats.pkt_burst_spread[nb_tx]++; -#endif + inc_tx_burst_stats(fs, nb_tx); if (unlikely(nb_tx < nb_rx)) { fs->fwd_dropped += (nb_rx - nb_tx); do { diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 76072ae81b93..784515314ebd 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -70,7 +70,8 @@ usage(char* progname) "--rxpt= | --rxht= | --rxwt= | --rxfreet= | " "--txpt= | --txht= | --txwt= | --txfreet= | " "--txrst= | --tx-offloads= | | --rx-offloads= | " - "--vxlan-gpe-port= | --record-core-cycles]\n", + "--vxlan-gpe-port= | --record-core-cycles | " + "--record-burst-stats]\n", progname); #ifdef RTE_LIBRTE_CMDLINE printf(" --interactive: run in interactive mode.\n"); @@ -217,6 +218,7 @@ usage(char* progname) printf(" --rx-mq-mode=0xX: hexadecimal bitmask of RX mq mode can be " "enabled\n"); printf(" --record-core-cycles: enable measurement of CPU cycles.\n"); + printf(" --record-burst-stats: enable display of RX and TX bursts.\n"); } #ifdef RTE_LIBRTE_CMDLINE @@ -679,6 +681,7 @@ launch_args_parse(int argc, char** argv) { "no-iova-contig", 0, 0, 0 }, { "rx-mq-mode", 1, 0, 0 }, { "record-core-cycles", 0, 0, 0 }, + { "record-burst-stats", 0, 0, 0 }, { 0, 0, 0, 0 }, }; @@ -1385,6 +1388,8 @@ launch_args_parse(int argc, char** argv) } if (!strcmp(lgopts[opt_idx].name, "record-core-cycles")) record_core_cycles = 1; + if (!strcmp(lgopts[opt_idx].name, "record-burst-stats")) + record_burst_stats = 1; break; case 'h': usage(argv[0]); diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c index b6c8b8c7d5db..c78fc4609ae5 100644 --- a/app/test-pmd/rxonly.c +++ b/app/test-pmd/rxonly.c @@ -58,9 +58,7 @@ pkt_burst_receive(struct fwd_stream *fs) */ nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); -#ifdef RTE_TEST_PMD_RECORD_BURST_STATS - fs->rx_burst_stats.pkt_burst_spread[nb_rx]++; -#endif + inc_rx_burst_stats(fs, nb_rx); if (unlikely(nb_rx == 0)) return; diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index f327b16604d2..fb286b86e51b 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -480,6 +480,11 @@ uint8_t xstats_hide_zero; */ uint8_t record_core_cycles; +/* + * Display of RX and TX bursts disabled by default + */ +uint8_t record_burst_stats; + unsigned int num_sockets = 0; unsigned int socket_ids[RTE_MAX_NUMA_NODES]; @@ -1684,7 +1689,6 @@ init_fwd_streams(void) return 0; } -#ifdef RTE_TEST_PMD_RECORD_BURST_STATS static void pkt_burst_stats_display(const char *rx_tx, struct pkt_burst_stats *pbs) { @@ -1751,7 +1755,6 @@ pkt_burst_stats_display(const char *rx_tx, struct pkt_burst_stats *pbs) sburstp += burst_percent[i]; } } -#endif /* RTE_TEST_PMD_RECORD_BURST_STATS */ static void fwd_stream_stats_display(streamid_t stream_id) @@ -1782,10 +1785,10 @@ fwd_stream_stats_display(streamid_t stream_id) printf("\n"); } -#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); -#endif + if (record_burst_stats) { + pkt_burst_stats_display("RX", &fs->rx_burst_stats); + pkt_burst_stats_display("TX", &fs->tx_burst_stats); + } } void @@ -1915,14 +1918,14 @@ fwd_stats_display(void) stats.opackets + ports_stats[pt_id].tx_dropped); } -#ifdef RTE_TEST_PMD_RECORD_BURST_STATS - if (ports_stats[pt_id].rx_stream) - pkt_burst_stats_display("RX", - &ports_stats[pt_id].rx_stream->rx_burst_stats); - if (ports_stats[pt_id].tx_stream) - pkt_burst_stats_display("TX", - &ports_stats[pt_id].tx_stream->tx_burst_stats); -#endif + if (record_burst_stats) { + if (ports_stats[pt_id].rx_stream) + pkt_burst_stats_display("RX", + &ports_stats[pt_id].rx_stream->rx_burst_stats); + if (ports_stats[pt_id].tx_stream) + pkt_burst_stats_display("TX", + &ports_stats[pt_id].tx_stream->tx_burst_stats); + } if (port->rx_queue_stats_mapping_enabled) { printf("\n"); @@ -2004,10 +2007,8 @@ fwd_stats_reset(void) fs->rx_bad_l4_csum = 0; fs->rx_bad_outer_l4_csum = 0; -#ifdef RTE_TEST_PMD_RECORD_BURST_STATS memset(&fs->rx_burst_stats, 0, sizeof(fs->rx_burst_stats)); memset(&fs->tx_burst_stats, 0, sizeof(fs->tx_burst_stats)); -#endif fs->core_cycles = 0; } } diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index dcc37be02d59..a8ae5cceb198 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -76,7 +76,6 @@ enum { /**< allocate mempool natively, use rte_pktmbuf_pool_create_extbuf */ }; -#ifdef RTE_TEST_PMD_RECORD_BURST_STATS /** * The data structure associated with RX and TX packet burst statistics * that are recorded for each forwarding stream. @@ -84,7 +83,6 @@ enum { struct pkt_burst_stats { unsigned int pkt_burst_spread[MAX_PKT_BURST]; }; -#endif /** Information for a given RSS type. */ struct rss_type_info { @@ -130,10 +128,8 @@ struct fwd_stream { /**< received packets has bad outer l4 checksum */ unsigned int gro_times; /**< GRO operation times */ uint64_t core_cycles; /**< used for RX and TX processing */ -#ifdef RTE_TEST_PMD_RECORD_BURST_STATS struct pkt_burst_stats rx_burst_stats; struct pkt_burst_stats tx_burst_stats; -#endif }; /** Descriptor for a single flow. */ @@ -300,6 +296,7 @@ extern uint8_t xstats_hide_zero; /**< Hide zero values for xstats display */ /* globals used for configuration */ extern uint8_t record_core_cycles; /**< Enables measurement of CPU cycles */ +extern uint8_t record_burst_stats; /**< Enables display of RX and TX bursts */ extern uint16_t verbose_level; /**< Drives messages being displayed, if any. */ extern int testpmd_logtype; /**< Log type for testpmd logs */ extern uint8_t interactive; @@ -694,6 +691,20 @@ get_end_cycles(struct fwd_stream *fs, uint64_t start_tsc) fs->core_cycles += rte_rdtsc() - start_tsc; } +static inline void +inc_rx_burst_stats(struct fwd_stream *fs, uint16_t nb_rx) +{ + if (record_burst_stats) + fs->rx_burst_stats.pkt_burst_spread[nb_rx]++; +} + +static inline void +inc_tx_burst_stats(struct fwd_stream *fs, uint16_t nb_tx) +{ + if (record_burst_stats) + fs->tx_burst_stats.pkt_burst_spread[nb_tx]++; +} + /* Prototypes */ unsigned int parse_item_list(char* str, const char* item_name, unsigned int max_items, @@ -786,6 +797,7 @@ void set_qmap(portid_t port_id, uint8_t is_rx, uint16_t queue_id, uint8_t map_va void set_xstats_hide_zero(uint8_t on_off); void set_record_core_cycles(uint8_t on_off); +void set_record_burst_stats(uint8_t on_off); void set_verbose_level(uint16_t vb_level); void set_tx_pkt_segments(unsigned *seg_lengths, unsigned nb_segs); void show_tx_pkt_segments(void); diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c index 00a3a6f90c7a..7d4f105ccd68 100644 --- a/app/test-pmd/txonly.c +++ b/app/test-pmd/txonly.c @@ -369,9 +369,7 @@ pkt_burst_transmit(struct fwd_stream *fs) if (txonly_multi_flow) RTE_PER_LCORE(_ip_var) -= nb_pkt - nb_tx; -#ifdef RTE_TEST_PMD_RECORD_BURST_STATS - fs->tx_burst_stats.pkt_burst_spread[nb_tx]++; -#endif + inc_tx_burst_stats(fs, nb_tx); if (unlikely(nb_tx < nb_pkt)) { if (verbose_level > 0 && fs->fwd_dropped == 0) printf("port %d tx_queue %d - drop " From patchwork Tue Jul 14 21:51:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dharmik Thakkar X-Patchwork-Id: 74019 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 75E05A0540; Tue, 14 Jul 2020 23:52:01 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7BAF11C20D; Tue, 14 Jul 2020 23:51:46 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id B26551C1F5 for ; Tue, 14 Jul 2020 23:51:41 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3401612FC; Tue, 14 Jul 2020 14:51:41 -0700 (PDT) Received: from localhost.localdomain (2p2660v4-1.austin.arm.com [10.118.12.95]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2A2993F66E; Tue, 14 Jul 2020 14:51:41 -0700 (PDT) From: Dharmik Thakkar To: Wenzhuo Lu , Beilei Xing , Bernard Iremonger , John McNamara , Marko Kovacevic Cc: dev@dpdk.org, nd@arm.com, Dharmik Thakkar Date: Tue, 14 Jul 2020 16:51:06 -0500 Message-Id: <20200714215108.22437-5-dharmik.thakkar@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200714215108.22437-1-dharmik.thakkar@arm.com> References: <20200520032023.2649-2-dharmik.thakkar@arm.com> <20200714215108.22437-1-dharmik.thakkar@arm.com> Subject: [dpdk-dev] [PATCH 4/6] doc: add record-burst-stats to testpmd funcs doc 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" Update documentation to include description of 'record-burst-stats' runtime configuration. Signed-off-by: Dharmik Thakkar Reviewed-by: Phil Yang Reviewed-by: Ruifeng Wang Reviewed-by: Honnappa Nagarahalli --- doc/guides/testpmd_app_ug/run_app.rst | 2 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst index 2b8e0ad69157..e2539f693f66 100644 --- a/doc/guides/testpmd_app_ug/run_app.rst +++ b/doc/guides/testpmd_app_ug/run_app.rst @@ -494,4 +494,6 @@ The command line options are: Enable measurement of CPU cycles per packet. +* ``--record-burst-stats`` + Enable display of RX and TX burst stats. diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 980bf3340763..2192a7e4720d 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -725,6 +725,21 @@ Where: This is equivalent to the ``--record-core-cycles command-line`` option. +set record-burst-stats +~~~~~~~~~~~~~~~~~~~~~~ + +Set the displaying of RX and TX bursts:: + + testpmd> set record-burst-stats (on|off) + +Where: + +* ``on`` enables display of RX and TX bursts. + +* ``off`` disables display of RX and TX bursts. + +This is equivalent to the ``--record-burst-stats command-line`` option. + set burst ~~~~~~~~~ From patchwork Tue Jul 14 21:51:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dharmik Thakkar X-Patchwork-Id: 74023 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 A28C0A0540; Tue, 14 Jul 2020 23:52:37 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2C35C1C2A0; Tue, 14 Jul 2020 23:51:52 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id 40D301C1F2; Tue, 14 Jul 2020 23:51:42 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4ACD0143B; Tue, 14 Jul 2020 14:51:41 -0700 (PDT) Received: from localhost.localdomain (2p2660v4-1.austin.arm.com [10.118.12.95]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4403E3F66E; Tue, 14 Jul 2020 14:51:41 -0700 (PDT) From: Dharmik Thakkar To: Wenzhuo Lu , Beilei Xing , Bernard Iremonger , Kevin Traynor , Jens Freimann Cc: dev@dpdk.org, nd@arm.com, Phil Yang , stable@dpdk.org, Dharmik Thakkar Date: Tue, 14 Jul 2020 16:51:07 -0500 Message-Id: <20200714215108.22437-6-dharmik.thakkar@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200714215108.22437-1-dharmik.thakkar@arm.com> References: <20200520032023.2649-2-dharmik.thakkar@arm.com> <20200714215108.22437-1-dharmik.thakkar@arm.com> Subject: [dpdk-dev] [PATCH 5/6] app/testpmd: enable burst stats for noisy vnf mode 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" From: Phil Yang Add burst stats for noisy vnf mode. Fixes: 3c156061b938 ("app/testpmd: add noisy neighbour forwarding mode") Cc: stable@dpdk.org Cc: jfreimann@redhat.com Signed-off-by: Dharmik Thakkar Signed-off-by: Phil Yang Reviewed-by: Honnappa Nagarahalli Reviewed-by: Ruifeng Wang --- app/test-pmd/noisy_vnf.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/test-pmd/noisy_vnf.c b/app/test-pmd/noisy_vnf.c index 58c4ee925566..382a4c2aaef1 100644 --- a/app/test-pmd/noisy_vnf.c +++ b/app/test-pmd/noisy_vnf.c @@ -154,6 +154,7 @@ pkt_burst_noisy_vnf(struct fwd_stream *fs) nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); + inc_rx_burst_stats(fs, nb_rx); if (unlikely(nb_rx == 0)) goto flush; fs->rx_packets += nb_rx; @@ -164,6 +165,7 @@ pkt_burst_noisy_vnf(struct fwd_stream *fs) pkts_burst, nb_rx); if (unlikely(nb_tx < nb_rx) && fs->retry_enabled) nb_tx += do_retry(nb_rx, nb_tx, pkts_burst, fs); + inc_tx_burst_stats(fs, nb_tx); fs->tx_packets += nb_tx; fs->fwd_dropped += drop_pkts(pkts_burst, nb_rx, nb_tx); return; @@ -187,6 +189,7 @@ pkt_burst_noisy_vnf(struct fwd_stream *fs) nb_deqd); if (unlikely(nb_tx < nb_rx) && fs->retry_enabled) nb_tx += do_retry(nb_rx, nb_tx, tmp_pkts, fs); + inc_tx_burst_stats(fs, nb_tx); fs->fwd_dropped += drop_pkts(tmp_pkts, nb_deqd, nb_tx); } } @@ -211,6 +214,7 @@ pkt_burst_noisy_vnf(struct fwd_stream *fs) tmp_pkts, nb_deqd); if (unlikely(sent < nb_deqd) && fs->retry_enabled) nb_tx += do_retry(nb_rx, nb_tx, tmp_pkts, fs); + inc_tx_burst_stats(fs, nb_tx); fs->fwd_dropped += drop_pkts(tmp_pkts, nb_deqd, sent); ncf->prev_time = rte_get_timer_cycles(); } From patchwork Tue Jul 14 21:51:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dharmik Thakkar X-Patchwork-Id: 74022 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 4B9D3A0540; Tue, 14 Jul 2020 23:52:27 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 374711C23C; Tue, 14 Jul 2020 23:51:51 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id 2CB891C18E for ; Tue, 14 Jul 2020 23:51:42 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 609C31477; Tue, 14 Jul 2020 14:51:41 -0700 (PDT) Received: from localhost.localdomain (2p2660v4-1.austin.arm.com [10.118.12.95]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5B02C3F66E; Tue, 14 Jul 2020 14:51:41 -0700 (PDT) From: Dharmik Thakkar To: Wenzhuo Lu , Beilei Xing , Bernard Iremonger Cc: dev@dpdk.org, nd@arm.com, Dharmik Thakkar Date: Tue, 14 Jul 2020 16:51:08 -0500 Message-Id: <20200714215108.22437-7-dharmik.thakkar@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200714215108.22437-1-dharmik.thakkar@arm.com> References: <20200520032023.2649-2-dharmik.thakkar@arm.com> <20200714215108.22437-1-dharmik.thakkar@arm.com> Subject: [dpdk-dev] [PATCH 6/6] app/testpmd: enable empty polls in 5tswap 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" Enable empty polls in burst stats within 5tswap.c Signed-off-by: Dharmik Thakkar Reviewed-by: Honnappa Nagarahalli Reviewed-by: Phil Yang --- app/test-pmd/5tswap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/test-pmd/5tswap.c b/app/test-pmd/5tswap.c index d9026ce86556..3cf1692eaba8 100644 --- a/app/test-pmd/5tswap.c +++ b/app/test-pmd/5tswap.c @@ -114,11 +114,10 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs) */ nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); + inc_rx_burst_stats(fs, nb_rx); if (unlikely(nb_rx == 0)) return; - inc_rx_burst_stats(fs, nb_rx); - fs->rx_packets += nb_rx; txp = &ports[fs->tx_port]; ol_flags = ol_flags_init(txp->dev_conf.txmode.offloads);