From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 84E08A04DB; Fri, 16 Oct 2020 15:48:01 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D93851EE5D; Fri, 16 Oct 2020 15:46:45 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 581821EE50 for ; Fri, 16 Oct 2020 15:46:40 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@nvidia.com) with SMTP; 16 Oct 2020 16:39:55 +0300 Received: from nvidia.com (pegasus12.mtr.labs.mlnx [10.210.17.40]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 09GDdjaU006420; Fri, 16 Oct 2020 16:39:55 +0300 From: Viacheslav Ovsiienko To: dev@dpdk.org Cc: thomas@monjalon.net, stephen@networkplumber.org, ferruh.yigit@intel.com, olivier.matz@6wind.com, jerinjacobk@gmail.com, maxime.coquelin@redhat.com, david.marchand@redhat.com, arybchenko@solarflare.com Date: Fri, 16 Oct 2020 13:39:40 +0000 Message-Id: <1602855582-15847-5-git-send-email-viacheslavo@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1602855582-15847-1-git-send-email-viacheslavo@nvidia.com> References: <1602855582-15847-1-git-send-email-viacheslavo@nvidia.com> Subject: [dpdk-dev] [PATCH v11 4/6] app/testpmd: add rxpkts commands and parameters 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" Add command line parameter: --rxpkts=X[,Y] Sets the length of segments to scatter packets on receiving if split feature is engaged. Affects only the queues configured with split offloads (currently BUFFER_SPLIT is supported only). Add interactive mode command: testpmd> set rxpkts (x[,y]*) Where x[,y]* represents a CSV list of values, without white space. Sets the length of segments to scatter packets on receiving if split feature is engaged. Affects only the queues configured with split offloads (currently BUFFER_SPLIT is supported only). Optionally the multiple memory pools can be specified with --mbuf-size command line parameter and the mbufs to receive will be allocated sequentially from these extra memory pools. Signed-off-by: Viacheslav Ovsiienko --- app/test-pmd/cmdline.c | 61 +++++++++++++++++++++++++++-- app/test-pmd/config.c | 48 ++++++++++++++++++++++- app/test-pmd/parameters.c | 15 +++++++ app/test-pmd/testpmd.c | 7 ++++ app/test-pmd/testpmd.h | 11 +++++- doc/guides/testpmd_app_ug/run_app.rst | 9 +++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 21 +++++++++- 7 files changed, 165 insertions(+), 7 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 0ef87c9..a195e37 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -183,7 +183,7 @@ static void cmd_help_long_parsed(void *parsed_result, "show (rxq|txq) info (port_id) (queue_id)\n" " Display information for configured RX/TX queue.\n\n" - "show config (rxtx|cores|fwd|txpkts)\n" + "show config (rxtx|cores|fwd|rxpkts|txpkts)\n" " Display the given configuration.\n\n" "read rxd (port_id) (queue_id) (rxd_id)\n" @@ -294,6 +294,12 @@ static void cmd_help_long_parsed(void *parsed_result, " Set the transmit delay time and number of retries," " effective when retry is enabled.\n\n" + "set rxpkts (x[,y]*)\n" + " Set the length of each segment to scatter" + " packets on receiving if split feature is engaged." + " Affects only the queues configured with split" + " offloads.\n\n" + "set txpkts (x[,y]*)\n" " Set the length of each segment of TXONLY" " and optionally CSUM packets.\n\n" @@ -3907,6 +3913,52 @@ struct cmd_set_log_result { }, }; +/* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */ + +struct cmd_set_rxpkts_result { + cmdline_fixed_string_t cmd_keyword; + cmdline_fixed_string_t rxpkts; + cmdline_fixed_string_t seg_lengths; +}; + +static void +cmd_set_rxpkts_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_set_rxpkts_result *res; + unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT]; + unsigned int nb_segs; + + res = parsed_result; + nb_segs = parse_item_list(res->seg_lengths, "segment lengths", + MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0); + if (nb_segs > 0) + set_rx_pkt_segments(seg_lengths, nb_segs); +} + +cmdline_parse_token_string_t cmd_set_rxpkts_keyword = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, + cmd_keyword, "set"); +cmdline_parse_token_string_t cmd_set_rxpkts_name = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, + rxpkts, "rxpkts"); +cmdline_parse_token_string_t cmd_set_rxpkts_lengths = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result, + seg_lengths, NULL); + +cmdline_parse_inst_t cmd_set_rxpkts = { + .f = cmd_set_rxpkts_parsed, + .data = NULL, + .help_str = "set rxpkts ", + .tokens = { + (void *)&cmd_set_rxpkts_keyword, + (void *)&cmd_set_rxpkts_name, + (void *)&cmd_set_rxpkts_lengths, + NULL, + }, +}; + /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ struct cmd_set_txpkts_result { @@ -7535,6 +7587,8 @@ static void cmd_showcfg_parsed(void *parsed_result, fwd_lcores_config_display(); else if (!strcmp(res->what, "fwd")) pkt_fwd_config_display(&cur_fwd_config); + else if (!strcmp(res->what, "rxpkts")) + show_rx_pkt_segments(); else if (!strcmp(res->what, "txpkts")) show_tx_pkt_segments(); else if (!strcmp(res->what, "txtimes")) @@ -7547,12 +7601,12 @@ static void cmd_showcfg_parsed(void *parsed_result, TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config"); cmdline_parse_token_string_t cmd_showcfg_what = TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, - "rxtx#cores#fwd#txpkts#txtimes"); + "rxtx#cores#fwd#rxpkts#txpkts#txtimes"); cmdline_parse_inst_t cmd_showcfg = { .f = cmd_showcfg_parsed, .data = NULL, - .help_str = "show config rxtx|cores|fwd|txpkts|txtimes", + .help_str = "show config rxtx|cores|fwd|rxpkts|txpkts|txtimes", .tokens = { (void *)&cmd_showcfg_show, (void *)&cmd_showcfg_port, @@ -19825,6 +19879,7 @@ struct cmd_showport_macs_result { (cmdline_parse_inst_t *)&cmd_reset, (cmdline_parse_inst_t *)&cmd_set_numbers, (cmdline_parse_inst_t *)&cmd_set_log, + (cmdline_parse_inst_t *)&cmd_set_rxpkts, (cmdline_parse_inst_t *)&cmd_set_txpkts, (cmdline_parse_inst_t *)&cmd_set_txsplit, (cmdline_parse_inst_t *)&cmd_set_txtimes, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 0f041e1..4ac2052 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -3528,6 +3528,50 @@ struct igb_ring_desc_16_bytes { } void +show_rx_pkt_segments(void) +{ + uint32_t i, n; + + n = rx_pkt_nb_segs; + printf("Number of segments: %u\n", n); + if (n) { + printf("Segment sizes: "); + for (i = 0; i != n - 1; i++) + printf("%hu,", rx_pkt_seg_lengths[i]); + printf("%hu\n", rx_pkt_seg_lengths[i]); + } +} + +void +set_rx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs) +{ + unsigned int i; + + if (nb_segs >= MAX_SEGS_BUFFER_SPLIT) { + printf("nb segments per RX packets=%u >= " + "MAX_SEGS_BUFFER_SPLIT - ignored\n", nb_segs); + return; + } + + /* + * No extra check here, the segment length will be checked by PMD + * in the extended queue setup. + */ + for (i = 0; i < nb_segs; i++) { + if (seg_lengths[i] >= UINT16_MAX) { + printf("length[%u]=%u > UINT16_MAX - give up\n", + i, seg_lengths[i]); + return; + } + } + + for (i = 0; i < nb_segs; i++) + rx_pkt_seg_lengths[i] = (uint16_t) seg_lengths[i]; + + rx_pkt_nb_segs = (uint8_t) nb_segs; +} + +void show_tx_pkt_segments(void) { uint32_t i, n; @@ -3572,10 +3616,10 @@ struct igb_ring_desc_16_bytes { } void -set_tx_pkt_segments(unsigned *seg_lengths, unsigned nb_segs) +set_tx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs) { uint16_t tx_pkt_len; - unsigned i; + unsigned int i; if (nb_segs_is_invalid(nb_segs)) return; diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 4db4987..e4e3635 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -184,6 +184,7 @@ "(0 <= mapping <= %d).\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1); printf(" --no-flush-rx: Don't flush RX streams before forwarding." " Used mainly with PCAP drivers.\n"); + printf(" --rxpkts=X[,Y]*: set RX segment sizes to split.\n"); printf(" --txpkts=X[,Y]*: set TX segment sizes" " or total packet length.\n"); printf(" --txonly-multi-flow: generate multiple flows in txonly mode\n"); @@ -662,6 +663,7 @@ { "rx-queue-stats-mapping", 1, 0, 0 }, { "no-flush-rx", 0, 0, 0 }, { "flow-isolate-all", 0, 0, 0 }, + { "rxpkts", 1, 0, 0 }, { "txpkts", 1, 0, 0 }, { "txonly-multi-flow", 0, 0, 0 }, { "disable-link-check", 0, 0, 0 }, @@ -1272,6 +1274,19 @@ "invalid RX queue statistics mapping config entered\n"); } } + if (!strcmp(lgopts[opt_idx].name, "rxpkts")) { + unsigned int seg_len[MAX_SEGS_BUFFER_SPLIT]; + unsigned int nb_segs; + + nb_segs = parse_item_list + (optarg, "rxpkt segments", + MAX_SEGS_BUFFER_SPLIT, + seg_len, 0); + if (nb_segs > 0) + set_rx_pkt_segments(seg_len, nb_segs); + else + rte_exit(EXIT_FAILURE, "bad rxpkts\n"); + } if (!strcmp(lgopts[opt_idx].name, "txpkts")) { unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT]; unsigned int nb_segs; diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 7e6ef80..f88c1e2 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -210,6 +210,13 @@ struct fwd_engine * fwd_engines[] = { uint8_t f_quit; /* + * Configuration of packet segments used to scatter received packets + * if some of split features is configured. + */ +uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT]; +uint8_t rx_pkt_nb_segs; /**< Number of segments to split */ + +/* * Configuration of packet segments used by the "txonly" processing engine. */ uint16_t tx_pkt_length = TXONLY_DEF_PACKET_LEN; /**< TXONLY packet length. */ diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 0975305..c5c942a 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -430,6 +430,13 @@ struct queue_stats_mappings { extern struct rte_fdir_conf fdir_conf; /* + * Configuration of packet segments used to scatter received packets + * if some of split features is configured. + */ +extern uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT]; +extern uint8_t rx_pkt_nb_segs; /**< Number of segments to split */ + +/* * Configuration of packet segments used by the "txonly" processing engine. */ #define TXONLY_DEF_PACKET_LEN 64 @@ -836,7 +843,9 @@ void vlan_tpid_set(portid_t port_id, enum rte_vlan_type vlan_type, 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 set_rx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs); +void show_rx_pkt_segments(void); +void set_tx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs); void show_tx_pkt_segments(void); void set_tx_pkt_times(unsigned int *tx_times); void show_tx_pkt_times(void); diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst index 1eb0a10..463b76c 100644 --- a/doc/guides/testpmd_app_ug/run_app.rst +++ b/doc/guides/testpmd_app_ug/run_app.rst @@ -361,6 +361,15 @@ The command line options are: Don't flush the RX streams before starting forwarding. Used mainly with the PCAP PMD. +* ``--rxpkts=X[,Y]`` + + Set the length of segments to scatter packets on receiving if split + feature is engaged. Affects only the queues configured + with split offloads (currently BUFFER_SPLIT is supported only). + Optionally the multiple memory pools can be specified with --mbuf-size + command line parameter and the mbufs to receive will be allocated + sequentially from these extra memory pools. + * ``--txpkts=X[,Y]`` Set TX segment sizes or total packet length. Valid for ``tx-only`` diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 43c0ea0..b9fad3a 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -273,7 +273,7 @@ show config Displays the configuration of the application. The configuration comes from the command-line, the runtime or the application defaults:: - testpmd> show config (rxtx|cores|fwd|txpkts|txtimes) + testpmd> show config (rxtx|cores|fwd|rxpkts|txpkts|txtimes) The available information categories are: @@ -283,6 +283,8 @@ The available information categories are: * ``fwd``: Packet forwarding configuration. +* ``rxpkts``: Packets to RX split configuration. + * ``txpkts``: Packets to TX configuration. * ``txtimes``: Burst time pattern for Tx only mode. @@ -774,6 +776,23 @@ When retry is enabled, the transmit delay time and number of retries can also be testpmd> set burst tx delay (microseconds) retry (num) +set rxpkts +~~~~~~~~~~ + +Set the length of segments to scatter packets on receiving if split +feature is engaged. Affects only the queues configured with split offloads +(currently BUFFER_SPLIT is supported only). Optionally the multiple memory +pools can be specified with --mbuf-size command line parameter and the mbufs +to receive will be allocated sequentially from these extra memory pools (the +mbuf for the first segment is allocated from the first pool, the second one +from the second pool, and so on, if segment number is greater then pool's the +mbuf for remaining segments will be allocated from the last valid pool). + + testpmd> set rxpkts (x[,y]*) + +Where x[,y]* represents a CSV list of values, without white space. Zero value +means to use the corresponding memory pool data buffer size. + set txpkts ~~~~~~~~~~ -- 1.8.3.1