From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 7243D6CC9 for ; Thu, 13 Oct 2016 16:35:15 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from olegk@mellanox.com) with ESMTPS (AES256-SHA encrypted); 13 Oct 2016 16:35:12 +0200 Received: from r-aa-zorro016.mtr.labs.mlnx (r-aa-zorro016.mtr.labs.mlnx [10.209.68.122]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id u9DEZCgp029473 for ; Thu, 13 Oct 2016 17:35:12 +0300 Received: from r-aa-zorro016.mtr.labs.mlnx (localhost [127.0.0.1]) by r-aa-zorro016.mtr.labs.mlnx (8.14.7/8.14.7) with ESMTP id u9DEZBYQ017264 for ; Thu, 13 Oct 2016 14:35:12 GMT From: Oleg Kuporosov To: dev@dpdk.org Date: Thu, 13 Oct 2016 14:35:07 +0000 Message-Id: <1476369308-17021-3-git-send-email-olegk@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1476369308-17021-1-git-send-email-olegk@mellanox.com> References: <1476369308-17021-1-git-send-email-olegk@mellanox.com> Subject: [dpdk-dev] [PATCH 2/3] app/testpmd: enabled control for packet timestamps X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 14:35:16 -0000 Implemented two methods of control - by --enable-timestamps CL testpmd application we can enable timestamping for all ports; - in interactive mode port config timestamps on|off is able to configure timestamping per specific port. The control doesn't interact with IEEE1588 PTP implementation there as it is under macro compilation but can be extended in the future. This feature is required for debugging/testing purposes for real time HW packet timestamping. Signed-off-by: Oleg Kuporosov --- app/test-pmd/cmdline.c | 122 ++++++++++++++++++++++++++++ app/test-pmd/parameters.c | 4 + app/test-pmd/testpmd.c | 5 ++ app/test-pmd/testpmd.h | 1 + doc/guides/testpmd_app_ug/run_app.rst | 4 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 ++ 6 files changed, 143 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 17d238f..9b202ce 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -561,6 +561,9 @@ static void cmd_help_long_parsed(void *parsed_result, " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en" " for ports.\n\n" + "port config (port_id|all) timestamps (on|off)\n" + " Enable/disable packet timestamps.\n\n" + "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none)\n" " Set the RSS mode.\n\n" @@ -10188,6 +10191,123 @@ cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = { }, }; +/* Configure port timestamping */ +struct cmd_config_timestamps_result { + cmdline_fixed_string_t port; + cmdline_fixed_string_t config; + cmdline_fixed_string_t all; + uint8_t id; + cmdline_fixed_string_t timestamps; + cmdline_fixed_string_t mode; +}; + +cmdline_parse_token_string_t cmd_config_timestamps_port = + TOKEN_STRING_INITIALIZER + (struct cmd_config_timestamps_result, + port, "port"); +cmdline_parse_token_string_t cmd_config_timestamps_config = + TOKEN_STRING_INITIALIZER + (struct cmd_config_timestamps_result, + config, "config"); +cmdline_parse_token_string_t cmd_config_timestamps_all_str = + TOKEN_STRING_INITIALIZER + (struct cmd_config_timestamps_result, + all, "all"); +cmdline_parse_token_num_t cmd_config_timestamps_id = + TOKEN_NUM_INITIALIZER + (struct cmd_config_timestamps_result, + id, UINT8); +cmdline_parse_token_string_t cmd_config_timestamps_ts_str = + TOKEN_STRING_INITIALIZER + (struct cmd_config_timestamps_result, + timestamps, "timestamps"); +cmdline_parse_token_string_t cmd_config_timestamps_path = + TOKEN_STRING_INITIALIZER + (struct cmd_config_timestamps_result, + mode, "on#off"); + +/* enable/disable timestamps (on/off) for a port */ +static void +cmd_config_timestamps_all_parsed( + void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_config_timestamps_result *res = parsed_result; + portid_t pid; + uint8_t mode = 0; + + if (!strcmp("on", res->mode)) + mode = 1; + else if (!strcmp("off", res->mode)) + mode = 0; + else { + printf("Unknown timestamps mode parameter\n"); + return; + } + FOREACH_PORT(pid, ports) { + if (mode) + rte_eth_timesync_enable(pid); + else + rte_eth_timesync_disable(pid); + } +} + +cmdline_parse_inst_t cmd_config_timestamps_all = { + .f = cmd_config_timestamps_all_parsed, + .data = NULL, + .help_str = "port config all timestamps on|off", + .tokens = { + (void *)&cmd_config_timestamps_port, + (void *)&cmd_config_timestamps_config, + (void *)&cmd_config_timestamps_all_str, + (void *)&cmd_config_timestamps_ts_str, + (void *)&cmd_config_timestamps_path, + NULL, + }, +}; + +/* enable/disable timestamps (rx/tx/both) for a port */ +static void +cmd_config_timestamps_specific_parsed( + void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_config_timestamps_result *res = + parsed_result; + uint8_t mode = 0; + + if (port_id_is_invalid(res->id, ENABLED_WARN)) + return; + if (!strcmp("on", res->mode)) + mode = 1; + else if (!strcmp("off", res->mode)) + mode = 0; + else { + printf("Unknown timestamps mode parameter\n"); + return; + } + if (mode) + rte_eth_timesync_enable(res->id); + else + rte_eth_timesync_disable(res->id); +} + +cmdline_parse_inst_t cmd_config_timestamps_specific = { + .f = cmd_config_timestamps_specific_parsed, + .data = NULL, + .help_str = "port config timestamps on|off", + .tokens = { + (void *)&cmd_config_timestamps_port, + (void *)&cmd_config_timestamps_config, + (void *)&cmd_config_timestamps_id, + (void *)&cmd_config_timestamps_ts_str, + (void *)&cmd_config_timestamps_path, + NULL, + }, +}; + /* E-tag configuration */ /* Common result structure for all E-tag configuration */ @@ -10739,6 +10859,8 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis, (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add, (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del, + (cmdline_parse_inst_t *)&cmd_config_timestamps_all, + (cmdline_parse_inst_t *)&cmd_config_timestamps_specific, NULL, }; diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 6a6a07e..f15cd5a 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -150,6 +150,7 @@ usage(char* progname) "By default drop-queue=127.\n"); printf(" --crc-strip: enable CRC stripping by hardware.\n"); printf(" --enable-rx-cksum: enable rx hardware checksum offload.\n"); + printf(" --enable-timestamps: enable rx hardware timestamp.\n"); printf(" --disable-hw-vlan: disable hardware vlan.\n"); printf(" --disable-hw-vlan-filter: disable hardware vlan filter.\n"); printf(" --disable-hw-vlan-strip: disable hardware vlan strip.\n"); @@ -525,6 +526,7 @@ launch_args_parse(int argc, char** argv) { "pkt-filter-drop-queue", 1, 0, 0 }, { "crc-strip", 0, 0, 0 }, { "enable-rx-cksum", 0, 0, 0 }, + { "enable-timestamps", 0, 0, 0 }, { "enable-scatter", 0, 0, 0 }, { "disable-hw-vlan", 0, 0, 0 }, { "disable-hw-vlan-filter", 0, 0, 0 }, @@ -768,6 +770,8 @@ launch_args_parse(int argc, char** argv) rx_mode.enable_scatter = 1; if (!strcmp(lgopts[opt_idx].name, "enable-rx-cksum")) rx_mode.hw_ip_checksum = 1; + if (!strcmp(lgopts[opt_idx].name, "enable-timestamps")) + timestamps_enabled = 1; if (!strcmp(lgopts[opt_idx].name, "disable-hw-vlan")) { rx_mode.hw_vlan_filter = 0; diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index e2403c3..ee76282 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -189,6 +189,8 @@ uint8_t dcb_config = 0; /* Whether the dcb is in testing status */ uint8_t dcb_test = 0; +/**< Enabling runtime packet timestamps by CL: --enable-timestamps */ +uint8_t timestamps_enabled = 0; /* * Configurable number of RX/TX queues. */ @@ -1851,6 +1853,9 @@ init_port_config(void) rte_eth_macaddr_get(pid, &port->eth_addr); + if (timestamps_enabled) + rte_eth_timesync_enable(pid); + map_port_queue_stats_mapping_registers(pid, port); #ifdef RTE_NIC_BYPASS rte_eth_dev_bypass_init(pid); diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 2b281cc..489661e 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -353,6 +353,7 @@ extern int32_t txq_flags; extern uint8_t dcb_config; extern uint8_t dcb_test; +extern uint8_t timestamps_enabled; /**< Timestamps by --enable-timestamps */ extern enum dcb_queue_mapping_mode dcb_q_mapping; extern uint16_t mbuf_data_size; /**< Mbuf data space size. */ diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst index 7712bd2..fb56846 100644 --- a/doc/guides/testpmd_app_ug/run_app.rst +++ b/doc/guides/testpmd_app_ug/run_app.rst @@ -313,6 +313,10 @@ The commandline options are: Enable per-queue packet drop for packets with no descriptors. +* ``--enable-timestamps`` + + Enable timesync and per packet timestamping for all ports. + * ``--disable-rss`` Disable RSS (Receive Side Scaling). diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index f87e0c2..ed84c6d 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -1312,6 +1312,13 @@ Set the DCB mode for an individual port:: The traffic class should be 4 or 8. +port config - Timesync/timestamping +~~~~~~~~~~~~~~~~~~~ + +Enable/disable time synhronzation/packet timestamping for specific port or all ports:: + + testpmd> port config (port_id|all) timestamps (on|off) + port config - Burst ~~~~~~~~~~~~~~~~~~~ -- 1.8.3.1