From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A1ED4A0093; Fri, 17 Jun 2022 07:08:13 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 113F3410D2; Fri, 17 Jun 2022 07:08:13 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 1139C410D2 for ; Fri, 17 Jun 2022 07:08:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655442489; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BSsIkKoE5//vmznZ51D2KWnbkQukL7remyTdQO4Ocr8=; b=OgBnwsqz/QK6UH50P96Fkmagd9W2F8RydruQTMRM3ZSEcNKnDvM987/dtndFg4iRygfTNn 4jaRkTiA+mDFLDXOslXCmqoxHeqBzZWpVUfieE1/CBJcCIT2SLZUebPiAdP98tFNWq6x4M eZK0IKU8Iu4TmVeuVEe+bLlSpLUIPug= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-591-5N1Rrq4COE2IGXZt8Hk0LQ-1; Fri, 17 Jun 2022 01:08:06 -0400 X-MC-Unique: 5N1Rrq4COE2IGXZt8Hk0LQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DB92985A583; Fri, 17 Jun 2022 05:08:05 +0000 (UTC) Received: from fchome.redhat.com (unknown [10.40.193.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id 15F272026985; Fri, 17 Jun 2022 05:08:03 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Xiaoyun Li , Aman Singh , Yuying Zhang , Qiming Yang , Wenjun Wu Subject: [PATCH v2 2/3] net/ixgbe: move testpmd commands Date: Fri, 17 Jun 2022 07:07:52 +0200 Message-Id: <20220617050753.1273320-2-david.marchand@redhat.com> In-Reply-To: <20220617050753.1273320-1-david.marchand@redhat.com> References: <20220523071031.1868862-6-david.marchand@redhat.com> <20220617050753.1273320-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Move related specific testpmd commands into this driver directory. The bypass init is left in testpmd at this point and can be moved later. While at it, fix checkpatch warnings. Signed-off-by: David Marchand --- Changes since v1: - rebased on next-net, - updated link in documentation to directly point at commands, - moved bypass code but separated bypass init change in the next patch, Changes since RFC v2: - dropped bypass commands, - updated documentation, - fixed some indent, --- app/test-pmd/cmdline.c | 977 +----------------- app/test-pmd/testpmd.c | 10 - app/test-pmd/testpmd.h | 5 +- doc/guides/nics/ixgbe.rst | 95 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 90 +- drivers/net/ixgbe/ixgbe_testpmd.c | 1008 +++++++++++++++++++ drivers/net/ixgbe/meson.build | 2 + 7 files changed, 1109 insertions(+), 1078 deletions(-) create mode 100644 drivers/net/ixgbe/ixgbe_testpmd.c diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index a59e6166d5..73a9e5ac4c 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -73,8 +73,6 @@ static cmdline_parse_ctx_t *main_ctx; static TAILQ_HEAD(, testpmd_driver_commands) driver_commands_head = TAILQ_HEAD_INITIALIZER(driver_commands_head); -static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue); - /* *** Help command with introduction. *** */ struct cmd_help_brief_result { cmdline_fixed_string_t help; @@ -348,24 +346,9 @@ static void cmd_help_long_parsed(void *parsed_result, "set all queues drop (port_id) (on|off)\n" " Set drop enable bit for all queues.\n\n" - "set vf split drop (port_id) (vf_id) (on|off)\n" - " Set split drop enable bit for a VF from the PF.\n\n" - "set vf mac antispoof (port_id) (vf_id) (on|off).\n" " Set MAC antispoof for a VF from the PF.\n\n" - "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n" - " Enable MACsec offload.\n\n" - - "set macsec offload (port_id) off\n" - " Disable MACsec offload.\n\n" - - "set macsec sc (tx|rx) (port_id) (mac) (pi)\n" - " Configure MACsec secure connection (SC).\n\n" - - "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n" - " Configure MACsec secure association (SA).\n\n" - "set vf broadcast (port_id) (vf_id) (on|off)\n" " Set VF broadcast for a VF from the PF.\n\n" @@ -396,9 +379,6 @@ static void cmd_help_long_parsed(void *parsed_result, "set tx strict-link-priority (port_id) (tc_bitmap)\n" " Set some TCs' strict link priority mode on a physical port.\n\n" - "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n" - " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n" - "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n" " Set the VLAN strip or filter or qinq strip or extend\n\n" @@ -594,29 +574,6 @@ static void cmd_help_long_parsed(void *parsed_result, " Flush (default) or don't flush RX streams before" " forwarding. Mainly used with PCAP drivers.\n\n" - "set bypass mode (normal|bypass|isolate) (port_id)\n" - " Set the bypass mode for the lowest port on bypass enabled" - " NIC.\n\n" - - "set bypass event (timeout|os_on|os_off|power_on|power_off) " - "mode (normal|bypass|isolate) (port_id)\n" - " Set the event required to initiate specified bypass mode for" - " the lowest port on a bypass enabled NIC where:\n" - " timeout = enable bypass after watchdog timeout.\n" - " os_on = enable bypass when OS/board is powered on.\n" - " os_off = enable bypass when OS/board is powered off.\n" - " power_on = enable bypass when power supply is turned on.\n" - " power_off = enable bypass when power supply is turned off." - "\n\n" - - "set bypass timeout (0|1.5|2|3|4|8|16|32)\n" - " Set the bypass watchdog timeout to 'n' seconds" - " where 0 = instant.\n\n" - - "show bypass config (port_id)\n" - " Show the bypass configuration for a bypass enabled NIC" - " using the lowest port on the NIC.\n\n" - #ifdef RTE_NET_BOND "create bonded device (mode) (socket)\n" " Create a new bonded device with specific bonding mode and socket.\n\n" @@ -5592,347 +5549,6 @@ static cmdline_parse_inst_t cmd_set_link_check = { }, }; -/* *** SET NIC BYPASS MODE *** */ -struct cmd_set_bypass_mode_result { - cmdline_fixed_string_t set; - cmdline_fixed_string_t bypass; - cmdline_fixed_string_t mode; - cmdline_fixed_string_t value; - portid_t port_id; -}; - -static void -cmd_set_bypass_mode_parsed(void *parsed_result, - __rte_unused struct cmdline *cl, - __rte_unused void *data) -{ - struct cmd_set_bypass_mode_result *res = parsed_result; - portid_t port_id = res->port_id; - int32_t rc = -EINVAL; - -#if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS - uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; - - if (!strcmp(res->value, "bypass")) - bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; - else if (!strcmp(res->value, "isolate")) - bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; - else - bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; - - /* Set the bypass mode for the relevant port. */ - rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode); -#endif - if (rc != 0) - fprintf(stderr, "\t Failed to set bypass mode for port = %d.\n", - port_id); -} - -static cmdline_parse_token_string_t cmd_setbypass_mode_set = - TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, - set, "set"); -static cmdline_parse_token_string_t cmd_setbypass_mode_bypass = - TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, - bypass, "bypass"); -static cmdline_parse_token_string_t cmd_setbypass_mode_mode = - TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, - mode, "mode"); -static cmdline_parse_token_string_t cmd_setbypass_mode_value = - TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, - value, "normal#bypass#isolate"); -static cmdline_parse_token_num_t cmd_setbypass_mode_port = - TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result, - port_id, RTE_UINT16); - -static cmdline_parse_inst_t cmd_set_bypass_mode = { - .f = cmd_set_bypass_mode_parsed, - .help_str = "set bypass mode normal|bypass|isolate : " - "Set the NIC bypass mode for port_id", - .data = NULL, - .tokens = { - (void *)&cmd_setbypass_mode_set, - (void *)&cmd_setbypass_mode_bypass, - (void *)&cmd_setbypass_mode_mode, - (void *)&cmd_setbypass_mode_value, - (void *)&cmd_setbypass_mode_port, - NULL, - }, -}; - -/* *** SET NIC BYPASS EVENT *** */ -struct cmd_set_bypass_event_result { - cmdline_fixed_string_t set; - cmdline_fixed_string_t bypass; - cmdline_fixed_string_t event; - cmdline_fixed_string_t event_value; - cmdline_fixed_string_t mode; - cmdline_fixed_string_t mode_value; - portid_t port_id; -}; - -static void -cmd_set_bypass_event_parsed(void *parsed_result, - __rte_unused struct cmdline *cl, - __rte_unused void *data) -{ - int32_t rc = -EINVAL; - struct cmd_set_bypass_event_result *res = parsed_result; - portid_t port_id = res->port_id; - -#if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS - uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; - uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; - - if (!strcmp(res->event_value, "timeout")) - bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT; - else if (!strcmp(res->event_value, "os_on")) - bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON; - else if (!strcmp(res->event_value, "os_off")) - bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF; - else if (!strcmp(res->event_value, "power_on")) - bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON; - else if (!strcmp(res->event_value, "power_off")) - bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF; - else - bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; - - if (!strcmp(res->mode_value, "bypass")) - bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; - else if (!strcmp(res->mode_value, "isolate")) - bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; - else - bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; - - /* Set the watchdog timeout. */ - if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) { - - rc = -EINVAL; - if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) { - rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id, - bypass_timeout); - } - if (rc != 0) { - fprintf(stderr, - "Failed to set timeout value %u for port %d, errto code: %d.\n", - bypass_timeout, port_id, rc); - } - } - - /* Set the bypass event to transition to bypass mode. */ - rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event, - bypass_mode); -#endif - - if (rc != 0) - fprintf(stderr, "\t Failed to set bypass event for port = %d.\n", - port_id); -} - -static cmdline_parse_token_string_t cmd_setbypass_event_set = - TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, - set, "set"); -static cmdline_parse_token_string_t cmd_setbypass_event_bypass = - TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, - bypass, "bypass"); -static cmdline_parse_token_string_t cmd_setbypass_event_event = - TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, - event, "event"); -static cmdline_parse_token_string_t cmd_setbypass_event_event_value = - TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, - event_value, "none#timeout#os_off#os_on#power_on#power_off"); -static cmdline_parse_token_string_t cmd_setbypass_event_mode = - TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, - mode, "mode"); -static cmdline_parse_token_string_t cmd_setbypass_event_mode_value = - TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, - mode_value, "normal#bypass#isolate"); -static cmdline_parse_token_num_t cmd_setbypass_event_port = - TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result, - port_id, RTE_UINT16); - -static cmdline_parse_inst_t cmd_set_bypass_event = { - .f = cmd_set_bypass_event_parsed, - .help_str = "set bypass event none|timeout|os_on|os_off|power_on|" - "power_off mode normal|bypass|isolate : " - "Set the NIC bypass event mode for port_id", - .data = NULL, - .tokens = { - (void *)&cmd_setbypass_event_set, - (void *)&cmd_setbypass_event_bypass, - (void *)&cmd_setbypass_event_event, - (void *)&cmd_setbypass_event_event_value, - (void *)&cmd_setbypass_event_mode, - (void *)&cmd_setbypass_event_mode_value, - (void *)&cmd_setbypass_event_port, - NULL, - }, -}; - - -/* *** SET NIC BYPASS TIMEOUT *** */ -struct cmd_set_bypass_timeout_result { - cmdline_fixed_string_t set; - cmdline_fixed_string_t bypass; - cmdline_fixed_string_t timeout; - cmdline_fixed_string_t value; -}; - -static void -cmd_set_bypass_timeout_parsed(void *parsed_result, - __rte_unused struct cmdline *cl, - __rte_unused void *data) -{ - __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result; - -#if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS - if (!strcmp(res->value, "1.5")) - bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC; - else if (!strcmp(res->value, "2")) - bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC; - else if (!strcmp(res->value, "3")) - bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC; - else if (!strcmp(res->value, "4")) - bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC; - else if (!strcmp(res->value, "8")) - bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC; - else if (!strcmp(res->value, "16")) - bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC; - else if (!strcmp(res->value, "32")) - bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC; - else - bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; -#endif -} - -static cmdline_parse_token_string_t cmd_setbypass_timeout_set = - TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, - set, "set"); -static cmdline_parse_token_string_t cmd_setbypass_timeout_bypass = - TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, - bypass, "bypass"); -static cmdline_parse_token_string_t cmd_setbypass_timeout_timeout = - TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, - timeout, "timeout"); -static cmdline_parse_token_string_t cmd_setbypass_timeout_value = - TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, - value, "0#1.5#2#3#4#8#16#32"); - -static cmdline_parse_inst_t cmd_set_bypass_timeout = { - .f = cmd_set_bypass_timeout_parsed, - .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: " - "Set the NIC bypass watchdog timeout in seconds", - .data = NULL, - .tokens = { - (void *)&cmd_setbypass_timeout_set, - (void *)&cmd_setbypass_timeout_bypass, - (void *)&cmd_setbypass_timeout_timeout, - (void *)&cmd_setbypass_timeout_value, - NULL, - }, -}; - -/* *** SHOW NIC BYPASS MODE *** */ -struct cmd_show_bypass_config_result { - cmdline_fixed_string_t show; - cmdline_fixed_string_t bypass; - cmdline_fixed_string_t config; - portid_t port_id; -}; - -static void -cmd_show_bypass_config_parsed(void *parsed_result, - __rte_unused struct cmdline *cl, - __rte_unused void *data) -{ - struct cmd_show_bypass_config_result *res = parsed_result; - portid_t port_id = res->port_id; - int rc = -EINVAL; -#if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS - uint32_t event_mode; - uint32_t bypass_mode; - uint32_t timeout = bypass_timeout; - unsigned int i; - - static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] = - {"off", "1.5", "2", "3", "4", "8", "16", "32"}; - static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] = - {"UNKNOWN", "normal", "bypass", "isolate"}; - static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = { - "NONE", - "OS/board on", - "power supply on", - "OS/board off", - "power supply off", - "timeout"}; - - /* Display the bypass mode.*/ - if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) { - fprintf(stderr, "\tFailed to get bypass mode for port = %d\n", - port_id); - return; - } - else { - if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode)) - bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; - - printf("\tbypass mode = %s\n", modes[bypass_mode]); - } - - /* Display the bypass timeout.*/ - if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout)) - timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; - - printf("\tbypass timeout = %s\n", timeouts[timeout]); - - /* Display the bypass events and associated modes. */ - for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) { - - if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) { - fprintf(stderr, - "\tFailed to get bypass mode for event = %s\n", - events[i]); - } else { - if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode)) - event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; - - printf("\tbypass event: %-16s = %s\n", events[i], - modes[event_mode]); - } - } -#endif - if (rc != 0) - fprintf(stderr, - "\tFailed to get bypass configuration for port = %d\n", - port_id); -} - -static cmdline_parse_token_string_t cmd_showbypass_config_show = - TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, - show, "show"); -static cmdline_parse_token_string_t cmd_showbypass_config_bypass = - TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, - bypass, "bypass"); -static cmdline_parse_token_string_t cmd_showbypass_config_config = - TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, - config, "config"); -static cmdline_parse_token_num_t cmd_showbypass_config_port = - TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result, - port_id, RTE_UINT16); - -static cmdline_parse_inst_t cmd_show_bypass_config = { - .f = cmd_show_bypass_config_parsed, - .help_str = "show bypass config : " - "Show the NIC bypass config for port_id", - .data = NULL, - .tokens = { - (void *)&cmd_showbypass_config_show, - (void *)&cmd_showbypass_config_bypass, - (void *)&cmd_showbypass_config_config, - (void *)&cmd_showbypass_config_port, - NULL, - }, -}; - #ifdef RTE_NET_BOND /* *** SET BONDING MODE *** */ struct cmd_set_bonding_mode_result { @@ -11767,100 +11383,6 @@ static cmdline_parse_inst_t cmd_set_all_queues_drop_en = { }, }; -/* vf split drop enable configuration */ - -/* Common result structure for vf split drop enable */ -struct cmd_vf_split_drop_en_result { - cmdline_fixed_string_t set; - cmdline_fixed_string_t vf; - cmdline_fixed_string_t split; - cmdline_fixed_string_t drop; - portid_t port_id; - uint16_t vf_id; - cmdline_fixed_string_t on_off; -}; - -/* Common CLI fields for vf split drop enable disable */ -static cmdline_parse_token_string_t cmd_vf_split_drop_en_set = - TOKEN_STRING_INITIALIZER - (struct cmd_vf_split_drop_en_result, - set, "set"); -static cmdline_parse_token_string_t cmd_vf_split_drop_en_vf = - TOKEN_STRING_INITIALIZER - (struct cmd_vf_split_drop_en_result, - vf, "vf"); -static cmdline_parse_token_string_t cmd_vf_split_drop_en_split = - TOKEN_STRING_INITIALIZER - (struct cmd_vf_split_drop_en_result, - split, "split"); -static cmdline_parse_token_string_t cmd_vf_split_drop_en_drop = - TOKEN_STRING_INITIALIZER - (struct cmd_vf_split_drop_en_result, - drop, "drop"); -static cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id = - TOKEN_NUM_INITIALIZER - (struct cmd_vf_split_drop_en_result, - port_id, RTE_UINT16); -static cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id = - TOKEN_NUM_INITIALIZER - (struct cmd_vf_split_drop_en_result, - vf_id, RTE_UINT16); -static cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off = - TOKEN_STRING_INITIALIZER - (struct cmd_vf_split_drop_en_result, - on_off, "on#off"); - -static void -cmd_set_vf_split_drop_en_parsed( - void *parsed_result, - __rte_unused struct cmdline *cl, - __rte_unused void *data) -{ - struct cmd_vf_split_drop_en_result *res = parsed_result; - int ret = -ENOTSUP; - int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; - - if (port_id_is_invalid(res->port_id, ENABLED_WARN)) - return; - -#ifdef RTE_NET_IXGBE - ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id, - is_on); -#endif - switch (ret) { - case 0: - break; - case -EINVAL: - fprintf(stderr, "invalid vf_id %d or is_on %d\n", - res->vf_id, is_on); - break; - case -ENODEV: - fprintf(stderr, "invalid port_id %d\n", res->port_id); - break; - case -ENOTSUP: - fprintf(stderr, "not supported on port %d\n", res->port_id); - break; - default: - fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); - } -} - -static cmdline_parse_inst_t cmd_set_vf_split_drop_en = { - .f = cmd_set_vf_split_drop_en_parsed, - .data = NULL, - .help_str = "set vf split drop on|off", - .tokens = { - (void *)&cmd_vf_split_drop_en_set, - (void *)&cmd_vf_split_drop_en_vf, - (void *)&cmd_vf_split_drop_en_split, - (void *)&cmd_vf_split_drop_en_drop, - (void *)&cmd_vf_split_drop_en_port_id, - (void *)&cmd_vf_split_drop_en_vf_id, - (void *)&cmd_vf_split_drop_en_on_off, - NULL, - }, -}; - /* vf mac address configuration */ /* Common result structure for vf mac address */ @@ -11965,431 +11487,6 @@ static cmdline_parse_inst_t cmd_set_vf_mac_addr = { }, }; -/* MACsec configuration */ - -/* Common result structure for MACsec offload enable */ -struct cmd_macsec_offload_on_result { - cmdline_fixed_string_t set; - cmdline_fixed_string_t macsec; - cmdline_fixed_string_t offload; - portid_t port_id; - cmdline_fixed_string_t on; - cmdline_fixed_string_t encrypt; - cmdline_fixed_string_t en_on_off; - cmdline_fixed_string_t replay_protect; - cmdline_fixed_string_t rp_on_off; -}; - -/* Common CLI fields for MACsec offload disable */ -static cmdline_parse_token_string_t cmd_macsec_offload_on_set = - TOKEN_STRING_INITIALIZER - (struct cmd_macsec_offload_on_result, - set, "set"); -static cmdline_parse_token_string_t cmd_macsec_offload_on_macsec = - TOKEN_STRING_INITIALIZER - (struct cmd_macsec_offload_on_result, - macsec, "macsec"); -static cmdline_parse_token_string_t cmd_macsec_offload_on_offload = - TOKEN_STRING_INITIALIZER - (struct cmd_macsec_offload_on_result, - offload, "offload"); -static cmdline_parse_token_num_t cmd_macsec_offload_on_port_id = - TOKEN_NUM_INITIALIZER - (struct cmd_macsec_offload_on_result, - port_id, RTE_UINT16); -static cmdline_parse_token_string_t cmd_macsec_offload_on_on = - TOKEN_STRING_INITIALIZER - (struct cmd_macsec_offload_on_result, - on, "on"); -static cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt = - TOKEN_STRING_INITIALIZER - (struct cmd_macsec_offload_on_result, - encrypt, "encrypt"); -static cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off = - TOKEN_STRING_INITIALIZER - (struct cmd_macsec_offload_on_result, - en_on_off, "on#off"); -static cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect = - TOKEN_STRING_INITIALIZER - (struct cmd_macsec_offload_on_result, - replay_protect, "replay-protect"); -static cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off = - TOKEN_STRING_INITIALIZER - (struct cmd_macsec_offload_on_result, - rp_on_off, "on#off"); - -static void -cmd_set_macsec_offload_on_parsed( - void *parsed_result, - __rte_unused struct cmdline *cl, - __rte_unused void *data) -{ - struct cmd_macsec_offload_on_result *res = parsed_result; - int ret = -ENOTSUP; - portid_t port_id = res->port_id; - int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0; - int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0; - struct rte_eth_dev_info dev_info; - - if (port_id_is_invalid(port_id, ENABLED_WARN)) - return; - if (!port_is_stopped(port_id)) { - fprintf(stderr, "Please stop port %d first\n", port_id); - return; - } - - ret = eth_dev_info_get_print_err(port_id, &dev_info); - if (ret != 0) - return; - - if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) { -#ifdef RTE_NET_IXGBE - ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp); -#endif - } - RTE_SET_USED(en); - RTE_SET_USED(rp); - - switch (ret) { - case 0: - ports[port_id].dev_conf.txmode.offloads |= - RTE_ETH_TX_OFFLOAD_MACSEC_INSERT; - cmd_reconfig_device_queue(port_id, 1, 1); - break; - case -ENODEV: - fprintf(stderr, "invalid port_id %d\n", port_id); - break; - case -ENOTSUP: - fprintf(stderr, "not supported on port %d\n", port_id); - break; - default: - fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); - } -} - -static cmdline_parse_inst_t cmd_set_macsec_offload_on = { - .f = cmd_set_macsec_offload_on_parsed, - .data = NULL, - .help_str = "set macsec offload on " - "encrypt on|off replay-protect on|off", - .tokens = { - (void *)&cmd_macsec_offload_on_set, - (void *)&cmd_macsec_offload_on_macsec, - (void *)&cmd_macsec_offload_on_offload, - (void *)&cmd_macsec_offload_on_port_id, - (void *)&cmd_macsec_offload_on_on, - (void *)&cmd_macsec_offload_on_encrypt, - (void *)&cmd_macsec_offload_on_en_on_off, - (void *)&cmd_macsec_offload_on_replay_protect, - (void *)&cmd_macsec_offload_on_rp_on_off, - NULL, - }, -}; - -/* Common result structure for MACsec offload disable */ -struct cmd_macsec_offload_off_result { - cmdline_fixed_string_t set; - cmdline_fixed_string_t macsec; - cmdline_fixed_string_t offload; - portid_t port_id; - cmdline_fixed_string_t off; -}; - -/* Common CLI fields for MACsec offload disable */ -static cmdline_parse_token_string_t cmd_macsec_offload_off_set = - TOKEN_STRING_INITIALIZER - (struct cmd_macsec_offload_off_result, - set, "set"); -static cmdline_parse_token_string_t cmd_macsec_offload_off_macsec = - TOKEN_STRING_INITIALIZER - (struct cmd_macsec_offload_off_result, - macsec, "macsec"); -static cmdline_parse_token_string_t cmd_macsec_offload_off_offload = - TOKEN_STRING_INITIALIZER - (struct cmd_macsec_offload_off_result, - offload, "offload"); -static cmdline_parse_token_num_t cmd_macsec_offload_off_port_id = - TOKEN_NUM_INITIALIZER - (struct cmd_macsec_offload_off_result, - port_id, RTE_UINT16); -static cmdline_parse_token_string_t cmd_macsec_offload_off_off = - TOKEN_STRING_INITIALIZER - (struct cmd_macsec_offload_off_result, - off, "off"); - -static void -cmd_set_macsec_offload_off_parsed( - void *parsed_result, - __rte_unused struct cmdline *cl, - __rte_unused void *data) -{ - struct cmd_macsec_offload_off_result *res = parsed_result; - int ret = -ENOTSUP; - struct rte_eth_dev_info dev_info; - portid_t port_id = res->port_id; - - if (port_id_is_invalid(port_id, ENABLED_WARN)) - return; - if (!port_is_stopped(port_id)) { - fprintf(stderr, "Please stop port %d first\n", port_id); - return; - } - - ret = eth_dev_info_get_print_err(port_id, &dev_info); - if (ret != 0) - return; - - if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) { -#ifdef RTE_NET_IXGBE - ret = rte_pmd_ixgbe_macsec_disable(port_id); -#endif - } - switch (ret) { - case 0: - ports[port_id].dev_conf.txmode.offloads &= - ~RTE_ETH_TX_OFFLOAD_MACSEC_INSERT; - cmd_reconfig_device_queue(port_id, 1, 1); - break; - case -ENODEV: - fprintf(stderr, "invalid port_id %d\n", port_id); - break; - case -ENOTSUP: - fprintf(stderr, "not supported on port %d\n", port_id); - break; - default: - fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); - } -} - -static cmdline_parse_inst_t cmd_set_macsec_offload_off = { - .f = cmd_set_macsec_offload_off_parsed, - .data = NULL, - .help_str = "set macsec offload off", - .tokens = { - (void *)&cmd_macsec_offload_off_set, - (void *)&cmd_macsec_offload_off_macsec, - (void *)&cmd_macsec_offload_off_offload, - (void *)&cmd_macsec_offload_off_port_id, - (void *)&cmd_macsec_offload_off_off, - NULL, - }, -}; - -/* Common result structure for MACsec secure connection configure */ -struct cmd_macsec_sc_result { - cmdline_fixed_string_t set; - cmdline_fixed_string_t macsec; - cmdline_fixed_string_t sc; - cmdline_fixed_string_t tx_rx; - portid_t port_id; - struct rte_ether_addr mac; - uint16_t pi; -}; - -/* Common CLI fields for MACsec secure connection configure */ -static cmdline_parse_token_string_t cmd_macsec_sc_set = - TOKEN_STRING_INITIALIZER - (struct cmd_macsec_sc_result, - set, "set"); -static cmdline_parse_token_string_t cmd_macsec_sc_macsec = - TOKEN_STRING_INITIALIZER - (struct cmd_macsec_sc_result, - macsec, "macsec"); -static cmdline_parse_token_string_t cmd_macsec_sc_sc = - TOKEN_STRING_INITIALIZER - (struct cmd_macsec_sc_result, - sc, "sc"); -static cmdline_parse_token_string_t cmd_macsec_sc_tx_rx = - TOKEN_STRING_INITIALIZER - (struct cmd_macsec_sc_result, - tx_rx, "tx#rx"); -static cmdline_parse_token_num_t cmd_macsec_sc_port_id = - TOKEN_NUM_INITIALIZER - (struct cmd_macsec_sc_result, - port_id, RTE_UINT16); -static cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac = - TOKEN_ETHERADDR_INITIALIZER - (struct cmd_macsec_sc_result, - mac); -static cmdline_parse_token_num_t cmd_macsec_sc_pi = - TOKEN_NUM_INITIALIZER - (struct cmd_macsec_sc_result, - pi, RTE_UINT16); - -static void -cmd_set_macsec_sc_parsed( - void *parsed_result, - __rte_unused struct cmdline *cl, - __rte_unused void *data) -{ - struct cmd_macsec_sc_result *res = parsed_result; - int ret = -ENOTSUP; - int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; - -#ifdef RTE_NET_IXGBE - ret = is_tx ? - rte_pmd_ixgbe_macsec_config_txsc(res->port_id, - res->mac.addr_bytes) : - rte_pmd_ixgbe_macsec_config_rxsc(res->port_id, - res->mac.addr_bytes, res->pi); -#endif - RTE_SET_USED(is_tx); - - switch (ret) { - case 0: - break; - case -ENODEV: - fprintf(stderr, "invalid port_id %d\n", res->port_id); - break; - case -ENOTSUP: - fprintf(stderr, "not supported on port %d\n", res->port_id); - break; - default: - fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); - } -} - -static cmdline_parse_inst_t cmd_set_macsec_sc = { - .f = cmd_set_macsec_sc_parsed, - .data = NULL, - .help_str = "set macsec sc tx|rx ", - .tokens = { - (void *)&cmd_macsec_sc_set, - (void *)&cmd_macsec_sc_macsec, - (void *)&cmd_macsec_sc_sc, - (void *)&cmd_macsec_sc_tx_rx, - (void *)&cmd_macsec_sc_port_id, - (void *)&cmd_macsec_sc_mac, - (void *)&cmd_macsec_sc_pi, - NULL, - }, -}; - -/* Common result structure for MACsec secure connection configure */ -struct cmd_macsec_sa_result { - cmdline_fixed_string_t set; - cmdline_fixed_string_t macsec; - cmdline_fixed_string_t sa; - cmdline_fixed_string_t tx_rx; - portid_t port_id; - uint8_t idx; - uint8_t an; - uint32_t pn; - cmdline_fixed_string_t key; -}; - -/* Common CLI fields for MACsec secure connection configure */ -static cmdline_parse_token_string_t cmd_macsec_sa_set = - TOKEN_STRING_INITIALIZER - (struct cmd_macsec_sa_result, - set, "set"); -static cmdline_parse_token_string_t cmd_macsec_sa_macsec = - TOKEN_STRING_INITIALIZER - (struct cmd_macsec_sa_result, - macsec, "macsec"); -static cmdline_parse_token_string_t cmd_macsec_sa_sa = - TOKEN_STRING_INITIALIZER - (struct cmd_macsec_sa_result, - sa, "sa"); -static cmdline_parse_token_string_t cmd_macsec_sa_tx_rx = - TOKEN_STRING_INITIALIZER - (struct cmd_macsec_sa_result, - tx_rx, "tx#rx"); -static cmdline_parse_token_num_t cmd_macsec_sa_port_id = - TOKEN_NUM_INITIALIZER - (struct cmd_macsec_sa_result, - port_id, RTE_UINT16); -static cmdline_parse_token_num_t cmd_macsec_sa_idx = - TOKEN_NUM_INITIALIZER - (struct cmd_macsec_sa_result, - idx, RTE_UINT8); -static cmdline_parse_token_num_t cmd_macsec_sa_an = - TOKEN_NUM_INITIALIZER - (struct cmd_macsec_sa_result, - an, RTE_UINT8); -static cmdline_parse_token_num_t cmd_macsec_sa_pn = - TOKEN_NUM_INITIALIZER - (struct cmd_macsec_sa_result, - pn, RTE_UINT32); -static cmdline_parse_token_string_t cmd_macsec_sa_key = - TOKEN_STRING_INITIALIZER - (struct cmd_macsec_sa_result, - key, NULL); - -static void -cmd_set_macsec_sa_parsed( - void *parsed_result, - __rte_unused struct cmdline *cl, - __rte_unused void *data) -{ - struct cmd_macsec_sa_result *res = parsed_result; - int ret = -ENOTSUP; - int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; - uint8_t key[16] = { 0 }; - uint8_t xdgt0; - uint8_t xdgt1; - int key_len; - int i; - - key_len = strlen(res->key) / 2; - if (key_len > 16) - key_len = 16; - - for (i = 0; i < key_len; i++) { - xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); - if (xdgt0 == 0xFF) - return; - xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); - if (xdgt1 == 0xFF) - return; - key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); - } - -#ifdef RTE_NET_IXGBE - ret = is_tx ? - rte_pmd_ixgbe_macsec_select_txsa(res->port_id, - res->idx, res->an, res->pn, key) : - rte_pmd_ixgbe_macsec_select_rxsa(res->port_id, - res->idx, res->an, res->pn, key); -#endif - RTE_SET_USED(is_tx); - RTE_SET_USED(key); - - switch (ret) { - case 0: - break; - case -EINVAL: - fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an); - break; - case -ENODEV: - fprintf(stderr, "invalid port_id %d\n", res->port_id); - break; - case -ENOTSUP: - fprintf(stderr, "not supported on port %d\n", res->port_id); - break; - default: - fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); - } -} - -static cmdline_parse_inst_t cmd_set_macsec_sa = { - .f = cmd_set_macsec_sa_parsed, - .data = NULL, - .help_str = "set macsec sa tx|rx ", - .tokens = { - (void *)&cmd_macsec_sa_set, - (void *)&cmd_macsec_sa_macsec, - (void *)&cmd_macsec_sa_sa, - (void *)&cmd_macsec_sa_tx_rx, - (void *)&cmd_macsec_sa_port_id, - (void *)&cmd_macsec_sa_idx, - (void *)&cmd_macsec_sa_an, - (void *)&cmd_macsec_sa_pn, - (void *)&cmd_macsec_sa_key, - NULL, - }, -}; - /* VF unicast promiscuous mode configuration */ /* Common result structure for VF unicast promiscuous mode */ @@ -12982,68 +12079,6 @@ static cmdline_parse_inst_t cmd_vf_tc_min_bw = { }, }; -static void -cmd_tc_min_bw_parsed( - void *parsed_result, - __rte_unused struct cmdline *cl, - __rte_unused void *data) -{ - struct cmd_vf_tc_bw_result *res = parsed_result; - struct rte_port *port; - uint8_t tc_num; - uint8_t bw[16]; - int ret = -ENOTSUP; - - if (port_id_is_invalid(res->port_id, ENABLED_WARN)) - return; - - port = &ports[res->port_id]; - /** Check if the port is not started **/ - if (port->port_status != RTE_PORT_STOPPED) { - fprintf(stderr, "Please stop port %d first\n", res->port_id); - return; - } - - ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); - if (ret) - return; - -#ifdef RTE_NET_IXGBE - ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw); -#endif - - switch (ret) { - case 0: - break; - case -EINVAL: - fprintf(stderr, "invalid bandwidth\n"); - break; - case -ENODEV: - fprintf(stderr, "invalid port_id %d\n", res->port_id); - break; - case -ENOTSUP: - fprintf(stderr, "function not implemented\n"); - break; - default: - fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); - } -} - -static cmdline_parse_inst_t cmd_tc_min_bw = { - .f = cmd_tc_min_bw_parsed, - .data = NULL, - .help_str = "set tc tx min-bandwidth ", - .tokens = { - (void *)&cmd_vf_tc_bw_set, - (void *)&cmd_vf_tc_bw_tc, - (void *)&cmd_vf_tc_bw_tx, - (void *)&cmd_vf_tc_bw_min_bw, - (void *)&cmd_vf_tc_bw_port_id, - (void *)&cmd_vf_tc_bw_bw_list, - NULL, - }, -}; - /* TC max bandwidth setting */ static void cmd_vf_tc_max_bw_parsed( @@ -17938,10 +16973,6 @@ static cmdline_parse_ctx_t builtin_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all, (cmdline_parse_inst_t *)&cmd_set_flush_rx, (cmdline_parse_inst_t *)&cmd_set_link_check, - (cmdline_parse_inst_t *)&cmd_set_bypass_mode, - (cmdline_parse_inst_t *)&cmd_set_bypass_event, - (cmdline_parse_inst_t *)&cmd_set_bypass_timeout, - (cmdline_parse_inst_t *)&cmd_show_bypass_config, #ifdef RTE_NET_BOND (cmdline_parse_inst_t *) &cmd_set_bonding_mode, (cmdline_parse_inst_t *) &cmd_show_bonding_config, @@ -18075,11 +17106,6 @@ static cmdline_parse_ctx_t builtin_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert, (cmdline_parse_inst_t *)&cmd_set_tx_loopback, (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en, - (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en, - (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on, - (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off, - (cmdline_parse_inst_t *)&cmd_set_macsec_sc, - (cmdline_parse_inst_t *)&cmd_set_macsec_sa, (cmdline_parse_inst_t *)&cmd_set_vf_traffic, (cmdline_parse_inst_t *)&cmd_set_vf_rxmode, (cmdline_parse_inst_t *)&cmd_vf_rate_limit, @@ -18093,7 +17119,6 @@ static cmdline_parse_ctx_t builtin_ctx[] = { (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw, (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw, (cmdline_parse_inst_t *)&cmd_strict_link_prio, - (cmdline_parse_inst_t *)&cmd_tc_min_bw, (cmdline_parse_inst_t *)&cmd_set_vxlan, (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl, (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan, @@ -18280,7 +17305,7 @@ prompt_exit(void) } } -static void +void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue) { if (id == (portid_t)RTE_PORT_ALL) { diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 205d98ee3d..4e8523f961 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -442,16 +442,6 @@ uint32_t event_print_mask = (UINT32_C(1) << RTE_ETH_EVENT_UNKNOWN) | */ int do_mlockall = 0; -/* - * NIC bypass mode configuration options. - */ - -#if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS -/* The NIC bypass watchdog timeout. */ -uint32_t bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; -#endif - - #ifdef RTE_LIB_LATENCYSTATS /* diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index ab333c7324..00b9c4d9ca 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -459,10 +459,6 @@ extern uint8_t hot_plug; /**< enable by "--hot-plug" parameter */ extern int do_mlockall; /**< set by "--mlockall" or "--no-mlockall" parameter */ extern uint8_t clear_ptypes; /**< disabled by set ptype cmd */ -#ifdef RTE_LIBRTE_IXGBE_BYPASS -extern uint32_t bypass_timeout; /**< Store the NIC bypass watchdog timeout */ -#endif - /* * Store specified sockets on which memory pool to be used by ports * is allocated. @@ -891,6 +887,7 @@ unsigned int parse_item_list(const char *str, const char *item_name, unsigned int max_items, unsigned int *parsed_items, int check_unique_values); void launch_args_parse(int argc, char** argv); +void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue); void cmdline_read_from_file(const char *filename); int init_cmdline(void); void prompt(void); diff --git a/doc/guides/nics/ixgbe.rst b/doc/guides/nics/ixgbe.rst index ad1a3da610..ea4684c2dc 100644 --- a/doc/guides/nics/ixgbe.rst +++ b/doc/guides/nics/ixgbe.rst @@ -364,3 +364,98 @@ Supported Chipsets and NICs - Intel Ethernet Converged Network Adapter X540-T2 - Intel Ethernet Converged Network Adapter X550-T1 - Intel Ethernet Converged Network Adapter X550-T2 + +.. _net_ixgbe_testpmd_commands: + +Testpmd driver specific commands +-------------------------------- + +Some ixgbe driver specific features are integrated in testpmd. + +set split drop enable (for VF) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Set split drop enable bit for VF from PF:: + + testpmd> set vf split drop (port_id) (vf_id) (on|off) + +set macsec offload +~~~~~~~~~~~~~~~~~~ + +Enable/disable MACsec offload:: + + testpmd> set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off) + testpmd> set macsec offload (port_id) off + +set macsec sc +~~~~~~~~~~~~~ + +Configure MACsec secure connection (SC):: + + testpmd> set macsec sc (tx|rx) (port_id) (mac) (pi) + +.. note:: + + The pi argument is ignored for tx. + Check the NIC Datasheet for hardware limitations. + +set macsec sa +~~~~~~~~~~~~~ + +Configure MACsec secure association (SA):: + + testpmd> set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key) + +.. note:: + + The IDX value must be 0 or 1. + Check the NIC Datasheet for hardware limitations. + +set tc tx min bandwidth +~~~~~~~~~~~~~~~~~~~~~~~ + +Set all TCs' TX min relative bandwidth (%) globally for all PF and VFs:: + + testpmd> set tc tx min-bandwidth (port_id) (bw1, bw2, ...) + +set bypass mode +~~~~~~~~~~~~~~~ + +Set the bypass mode for the lowest port on bypass enabled NIC:: + + testpmd> set bypass mode (normal|bypass|isolate) (port_id) + +set bypass event +~~~~~~~~~~~~~~~~ + +Set the event required to initiate specified bypass mode for the lowest port on a bypass enabled:: + + testpmd> set bypass event (timeout|os_on|os_off|power_on|power_off) \ + mode (normal|bypass|isolate) (port_id) + +Where: + +* ``timeout``: Enable bypass after watchdog timeout. + +* ``os_on``: Enable bypass when OS/board is powered on. + +* ``os_off``: Enable bypass when OS/board is powered off. + +* ``power_on``: Enable bypass when power supply is turned on. + +* ``power_off``: Enable bypass when power supply is turned off. + + +set bypass timeout +~~~~~~~~~~~~~~~~~~ + +Set the bypass watchdog timeout to ``n`` seconds where 0 = instant:: + + testpmd> set bypass timeout (0|1.5|2|3|4|8|16|32) + +show bypass config +~~~~~~~~~~~~~~~~~~ + +Show the bypass configuration for a bypass enabled NIC using the lowest port on the NIC:: + + testpmd> show bypass config (port_id) diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index f311b7d27b..bd9bbfa26e 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -951,13 +951,6 @@ set drop enable bit for all queues:: testpmd> set all queues drop (port_id) (on|off) -set split drop enable (for VF) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -set split drop enable bit for VF from PF:: - - testpmd> set vf split drop (port_id) (vf_id) (on|off) - set mac antispoof (for VF) ~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -965,38 +958,6 @@ Set mac antispoof for a VF from the PF:: testpmd> set vf mac antispoof (port_id) (vf_id) (on|off) -set macsec offload -~~~~~~~~~~~~~~~~~~ - -Enable/disable MACsec offload:: - - testpmd> set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off) - testpmd> set macsec offload (port_id) off - -set macsec sc -~~~~~~~~~~~~~ - -Configure MACsec secure connection (SC):: - - testpmd> set macsec sc (tx|rx) (port_id) (mac) (pi) - -.. note:: - - The pi argument is ignored for tx. - Check the NIC Datasheet for hardware limits. - -set macsec sa -~~~~~~~~~~~~~ - -Configure MACsec secure association (SA):: - - testpmd> set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key) - -.. note:: - - The IDX value must be 0 or 1. - Check the NIC Datasheet for hardware limits. - set broadcast mode (for VF) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1509,13 +1470,6 @@ Set some TCs' strict link priority mode on a physical port:: testpmd> set tx strict-link-priority (port_id) (tc_bitmap) -set tc tx min bandwidth -~~~~~~~~~~~~~~~~~~~~~~~ - -Set all TCs' TX min relative bandwidth (%) globally for all PF and VFs:: - - testpmd> set tc tx min-bandwidth (port_id) (bw1, bw2, ...) - set flow_ctrl rx ~~~~~~~~~~~~~~~~ @@ -1666,48 +1620,6 @@ Mainly used with PCAP drivers to turn off the default behavior of flushing the f testpmd> set flush_rx off -set bypass mode -~~~~~~~~~~~~~~~ - -Set the bypass mode for the lowest port on bypass enabled NIC:: - - testpmd> set bypass mode (normal|bypass|isolate) (port_id) - -set bypass event -~~~~~~~~~~~~~~~~ - -Set the event required to initiate specified bypass mode for the lowest port on a bypass enabled:: - - testpmd> set bypass event (timeout|os_on|os_off|power_on|power_off) \ - mode (normal|bypass|isolate) (port_id) - -Where: - -* ``timeout``: Enable bypass after watchdog timeout. - -* ``os_on``: Enable bypass when OS/board is powered on. - -* ``os_off``: Enable bypass when OS/board is powered off. - -* ``power_on``: Enable bypass when power supply is turned on. - -* ``power_off``: Enable bypass when power supply is turned off. - - -set bypass timeout -~~~~~~~~~~~~~~~~~~ - -Set the bypass watchdog timeout to ``n`` seconds where 0 = instant:: - - testpmd> set bypass timeout (0|1.5|2|3|4|8|16|32) - -show bypass config -~~~~~~~~~~~~~~~~~~ - -Show the bypass configuration for a bypass enabled NIC using the lowest port on the NIC:: - - testpmd> show bypass config (port_id) - set link up ~~~~~~~~~~~ @@ -5720,3 +5632,5 @@ Driver specific commands Some drivers provide specific features. See: + +- :ref:`net_ixgbe_testpmd_commands` diff --git a/drivers/net/ixgbe/ixgbe_testpmd.c b/drivers/net/ixgbe/ixgbe_testpmd.c new file mode 100644 index 0000000000..a928d0fb55 --- /dev/null +++ b/drivers/net/ixgbe/ixgbe_testpmd.c @@ -0,0 +1,1008 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2016 Intel Corporation. + */ + +#include +#include "ixgbe_ethdev.h" +#include "rte_pmd_ixgbe.h" + +#include +#include +#include + +#include "testpmd.h" + +static uint8_t +hexa_digit_to_value(char hexa_digit) +{ + if ((hexa_digit >= '0') && (hexa_digit <= '9')) + return (uint8_t)(hexa_digit - '0'); + if ((hexa_digit >= 'a') && (hexa_digit <= 'f')) + return (uint8_t)((hexa_digit - 'a') + 10); + if ((hexa_digit >= 'A') && (hexa_digit <= 'F')) + return (uint8_t)((hexa_digit - 'A') + 10); + /* Invalid hexa digit */ + return 0xFF; +} + +static uint8_t +parse_and_check_key_hexa_digit(char *key, int idx) +{ + uint8_t hexa_v; + + hexa_v = hexa_digit_to_value(key[idx]); + if (hexa_v == 0xFF) + fprintf(stderr, + "invalid key: character %c at position %d is not a valid hexa digit\n", + key[idx], idx); + return hexa_v; +} + +static int +vf_tc_min_bw_parse_bw_list(uint8_t *bw_list, uint8_t *tc_num, char *str) +{ + uint32_t size; + const char *p, *p0 = str; + char s[256]; + char *end; + char *str_fld[16]; + uint16_t i; + int ret; + + p = strchr(p0, '('); + if (p == NULL) { + fprintf(stderr, "The bandwidth-list should be '(bw1, bw2, ...)'\n"); + return -1; + } + p++; + p0 = strchr(p, ')'); + if (p0 == NULL) { + fprintf(stderr, "The bandwidth-list should be '(bw1, bw2, ...)'\n"); + return -1; + } + size = p0 - p; + if (size >= sizeof(s)) { + fprintf(stderr, "The string size exceeds the internal buffer size\n"); + return -1; + } + snprintf(s, sizeof(s), "%.*s", size, p); + ret = rte_strsplit(s, sizeof(s), str_fld, 16, ','); + if (ret <= 0) { + fprintf(stderr, "Failed to get the bandwidth list.\n"); + return -1; + } + *tc_num = ret; + for (i = 0; i < ret; i++) + bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0); + + return 0; +} + +/* Common result structure for vf split drop enable */ +struct cmd_vf_split_drop_en_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t vf; + cmdline_fixed_string_t split; + cmdline_fixed_string_t drop; + portid_t port_id; + uint16_t vf_id; + cmdline_fixed_string_t on_off; +}; + +/* Common CLI fields for vf split drop enable disable */ +static cmdline_parse_token_string_t cmd_vf_split_drop_en_set = + TOKEN_STRING_INITIALIZER(struct cmd_vf_split_drop_en_result, + set, "set"); +static cmdline_parse_token_string_t cmd_vf_split_drop_en_vf = + TOKEN_STRING_INITIALIZER(struct cmd_vf_split_drop_en_result, + vf, "vf"); +static cmdline_parse_token_string_t cmd_vf_split_drop_en_split = + TOKEN_STRING_INITIALIZER(struct cmd_vf_split_drop_en_result, + split, "split"); +static cmdline_parse_token_string_t cmd_vf_split_drop_en_drop = + TOKEN_STRING_INITIALIZER(struct cmd_vf_split_drop_en_result, + drop, "drop"); +static cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_vf_split_drop_en_result, + port_id, RTE_UINT16); +static cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id = + TOKEN_NUM_INITIALIZER(struct cmd_vf_split_drop_en_result, + vf_id, RTE_UINT16); +static cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off = + TOKEN_STRING_INITIALIZER(struct cmd_vf_split_drop_en_result, + on_off, "on#off"); + +static void +cmd_set_vf_split_drop_en_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, __rte_unused void *data) +{ + struct cmd_vf_split_drop_en_result *res = parsed_result; + int ret = -ENOTSUP; + int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; + + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + + ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id, is_on); + switch (ret) { + case 0: + break; + case -EINVAL: + fprintf(stderr, "invalid vf_id %d or is_on %d\n", + res->vf_id, is_on); + break; + case -ENODEV: + fprintf(stderr, "invalid port_id %d\n", res->port_id); + break; + case -ENOTSUP: + fprintf(stderr, "not supported on port %d\n", res->port_id); + break; + default: + fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); + } +} + +static cmdline_parse_inst_t cmd_set_vf_split_drop_en = { + .f = cmd_set_vf_split_drop_en_parsed, + .data = NULL, + .help_str = "set vf split drop on|off", + .tokens = { + (void *)&cmd_vf_split_drop_en_set, + (void *)&cmd_vf_split_drop_en_vf, + (void *)&cmd_vf_split_drop_en_split, + (void *)&cmd_vf_split_drop_en_drop, + (void *)&cmd_vf_split_drop_en_port_id, + (void *)&cmd_vf_split_drop_en_vf_id, + (void *)&cmd_vf_split_drop_en_on_off, + NULL, + }, +}; + +/* MACsec configuration */ + +/* Common result structure for MACsec offload enable */ +struct cmd_macsec_offload_on_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t macsec; + cmdline_fixed_string_t offload; + portid_t port_id; + cmdline_fixed_string_t on; + cmdline_fixed_string_t encrypt; + cmdline_fixed_string_t en_on_off; + cmdline_fixed_string_t replay_protect; + cmdline_fixed_string_t rp_on_off; +}; + +/* Common CLI fields for MACsec offload disable */ +static cmdline_parse_token_string_t cmd_macsec_offload_on_set = + TOKEN_STRING_INITIALIZER(struct cmd_macsec_offload_on_result, + set, "set"); +static cmdline_parse_token_string_t cmd_macsec_offload_on_macsec = + TOKEN_STRING_INITIALIZER(struct cmd_macsec_offload_on_result, + macsec, "macsec"); +static cmdline_parse_token_string_t cmd_macsec_offload_on_offload = + TOKEN_STRING_INITIALIZER(struct cmd_macsec_offload_on_result, + offload, "offload"); +static cmdline_parse_token_num_t cmd_macsec_offload_on_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_macsec_offload_on_result, + port_id, RTE_UINT16); +static cmdline_parse_token_string_t cmd_macsec_offload_on_on = + TOKEN_STRING_INITIALIZER(struct cmd_macsec_offload_on_result, + on, "on"); +static cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt = + TOKEN_STRING_INITIALIZER(struct cmd_macsec_offload_on_result, + encrypt, "encrypt"); +static cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off = + TOKEN_STRING_INITIALIZER(struct cmd_macsec_offload_on_result, + en_on_off, "on#off"); +static cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect = + TOKEN_STRING_INITIALIZER(struct cmd_macsec_offload_on_result, + replay_protect, "replay-protect"); +static cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off = + TOKEN_STRING_INITIALIZER(struct cmd_macsec_offload_on_result, + rp_on_off, "on#off"); + +static void +cmd_set_macsec_offload_on_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, __rte_unused void *data) +{ + struct cmd_macsec_offload_on_result *res = parsed_result; + int ret = -ENOTSUP; + portid_t port_id = res->port_id; + int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0; + int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0; + struct rte_eth_dev_info dev_info; + + if (port_id_is_invalid(port_id, ENABLED_WARN)) + return; + if (!port_is_stopped(port_id)) { + fprintf(stderr, "Please stop port %d first\n", port_id); + return; + } + + ret = eth_dev_info_get_print_err(port_id, &dev_info); + if (ret != 0) + return; + + if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) + ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp); + + switch (ret) { + case 0: + ports[port_id].dev_conf.txmode.offloads |= + RTE_ETH_TX_OFFLOAD_MACSEC_INSERT; + cmd_reconfig_device_queue(port_id, 1, 1); + break; + case -ENODEV: + fprintf(stderr, "invalid port_id %d\n", port_id); + break; + case -ENOTSUP: + fprintf(stderr, "not supported on port %d\n", port_id); + break; + default: + fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); + } +} + +static cmdline_parse_inst_t cmd_set_macsec_offload_on = { + .f = cmd_set_macsec_offload_on_parsed, + .data = NULL, + .help_str = "set macsec offload on " + "encrypt on|off replay-protect on|off", + .tokens = { + (void *)&cmd_macsec_offload_on_set, + (void *)&cmd_macsec_offload_on_macsec, + (void *)&cmd_macsec_offload_on_offload, + (void *)&cmd_macsec_offload_on_port_id, + (void *)&cmd_macsec_offload_on_on, + (void *)&cmd_macsec_offload_on_encrypt, + (void *)&cmd_macsec_offload_on_en_on_off, + (void *)&cmd_macsec_offload_on_replay_protect, + (void *)&cmd_macsec_offload_on_rp_on_off, + NULL, + }, +}; + +/* Common result structure for MACsec offload disable */ +struct cmd_macsec_offload_off_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t macsec; + cmdline_fixed_string_t offload; + portid_t port_id; + cmdline_fixed_string_t off; +}; + +/* Common CLI fields for MACsec offload disable */ +static cmdline_parse_token_string_t cmd_macsec_offload_off_set = + TOKEN_STRING_INITIALIZER(struct cmd_macsec_offload_off_result, + set, "set"); +static cmdline_parse_token_string_t cmd_macsec_offload_off_macsec = + TOKEN_STRING_INITIALIZER(struct cmd_macsec_offload_off_result, + macsec, "macsec"); +static cmdline_parse_token_string_t cmd_macsec_offload_off_offload = + TOKEN_STRING_INITIALIZER(struct cmd_macsec_offload_off_result, + offload, "offload"); +static cmdline_parse_token_num_t cmd_macsec_offload_off_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_macsec_offload_off_result, + port_id, RTE_UINT16); +static cmdline_parse_token_string_t cmd_macsec_offload_off_off = + TOKEN_STRING_INITIALIZER(struct cmd_macsec_offload_off_result, + off, "off"); + +static void +cmd_set_macsec_offload_off_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, __rte_unused void *data) +{ + struct cmd_macsec_offload_off_result *res = parsed_result; + int ret = -ENOTSUP; + struct rte_eth_dev_info dev_info; + portid_t port_id = res->port_id; + + if (port_id_is_invalid(port_id, ENABLED_WARN)) + return; + if (!port_is_stopped(port_id)) { + fprintf(stderr, "Please stop port %d first\n", port_id); + return; + } + + ret = eth_dev_info_get_print_err(port_id, &dev_info); + if (ret != 0) + return; + + if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) + ret = rte_pmd_ixgbe_macsec_disable(port_id); + switch (ret) { + case 0: + ports[port_id].dev_conf.txmode.offloads &= + ~RTE_ETH_TX_OFFLOAD_MACSEC_INSERT; + cmd_reconfig_device_queue(port_id, 1, 1); + break; + case -ENODEV: + fprintf(stderr, "invalid port_id %d\n", port_id); + break; + case -ENOTSUP: + fprintf(stderr, "not supported on port %d\n", port_id); + break; + default: + fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); + } +} + +static cmdline_parse_inst_t cmd_set_macsec_offload_off = { + .f = cmd_set_macsec_offload_off_parsed, + .data = NULL, + .help_str = "set macsec offload off", + .tokens = { + (void *)&cmd_macsec_offload_off_set, + (void *)&cmd_macsec_offload_off_macsec, + (void *)&cmd_macsec_offload_off_offload, + (void *)&cmd_macsec_offload_off_port_id, + (void *)&cmd_macsec_offload_off_off, + NULL, + }, +}; + +/* Common result structure for MACsec secure connection configure */ +struct cmd_macsec_sc_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t macsec; + cmdline_fixed_string_t sc; + cmdline_fixed_string_t tx_rx; + portid_t port_id; + struct rte_ether_addr mac; + uint16_t pi; +}; + +/* Common CLI fields for MACsec secure connection configure */ +static cmdline_parse_token_string_t cmd_macsec_sc_set = + TOKEN_STRING_INITIALIZER(struct cmd_macsec_sc_result, + set, "set"); +static cmdline_parse_token_string_t cmd_macsec_sc_macsec = + TOKEN_STRING_INITIALIZER(struct cmd_macsec_sc_result, + macsec, "macsec"); +static cmdline_parse_token_string_t cmd_macsec_sc_sc = + TOKEN_STRING_INITIALIZER(struct cmd_macsec_sc_result, + sc, "sc"); +static cmdline_parse_token_string_t cmd_macsec_sc_tx_rx = + TOKEN_STRING_INITIALIZER(struct cmd_macsec_sc_result, + tx_rx, "tx#rx"); +static cmdline_parse_token_num_t cmd_macsec_sc_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_macsec_sc_result, + port_id, RTE_UINT16); +static cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac = + TOKEN_ETHERADDR_INITIALIZER(struct cmd_macsec_sc_result, + mac); +static cmdline_parse_token_num_t cmd_macsec_sc_pi = + TOKEN_NUM_INITIALIZER(struct cmd_macsec_sc_result, + pi, RTE_UINT16); + +static void +cmd_set_macsec_sc_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, __rte_unused void *data) +{ + struct cmd_macsec_sc_result *res = parsed_result; + int ret = -ENOTSUP; + int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; + + ret = is_tx ? + rte_pmd_ixgbe_macsec_config_txsc(res->port_id, + res->mac.addr_bytes) : + rte_pmd_ixgbe_macsec_config_rxsc(res->port_id, + res->mac.addr_bytes, res->pi); + switch (ret) { + case 0: + break; + case -ENODEV: + fprintf(stderr, "invalid port_id %d\n", res->port_id); + break; + case -ENOTSUP: + fprintf(stderr, "not supported on port %d\n", res->port_id); + break; + default: + fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); + } +} + +static cmdline_parse_inst_t cmd_set_macsec_sc = { + .f = cmd_set_macsec_sc_parsed, + .data = NULL, + .help_str = "set macsec sc tx|rx ", + .tokens = { + (void *)&cmd_macsec_sc_set, + (void *)&cmd_macsec_sc_macsec, + (void *)&cmd_macsec_sc_sc, + (void *)&cmd_macsec_sc_tx_rx, + (void *)&cmd_macsec_sc_port_id, + (void *)&cmd_macsec_sc_mac, + (void *)&cmd_macsec_sc_pi, + NULL, + }, +}; + +/* Common result structure for MACsec secure connection configure */ +struct cmd_macsec_sa_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t macsec; + cmdline_fixed_string_t sa; + cmdline_fixed_string_t tx_rx; + portid_t port_id; + uint8_t idx; + uint8_t an; + uint32_t pn; + cmdline_fixed_string_t key; +}; + +/* Common CLI fields for MACsec secure connection configure */ +static cmdline_parse_token_string_t cmd_macsec_sa_set = + TOKEN_STRING_INITIALIZER(struct cmd_macsec_sa_result, + set, "set"); +static cmdline_parse_token_string_t cmd_macsec_sa_macsec = + TOKEN_STRING_INITIALIZER(struct cmd_macsec_sa_result, + macsec, "macsec"); +static cmdline_parse_token_string_t cmd_macsec_sa_sa = + TOKEN_STRING_INITIALIZER(struct cmd_macsec_sa_result, + sa, "sa"); +static cmdline_parse_token_string_t cmd_macsec_sa_tx_rx = + TOKEN_STRING_INITIALIZER(struct cmd_macsec_sa_result, + tx_rx, "tx#rx"); +static cmdline_parse_token_num_t cmd_macsec_sa_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_macsec_sa_result, + port_id, RTE_UINT16); +static cmdline_parse_token_num_t cmd_macsec_sa_idx = + TOKEN_NUM_INITIALIZER(struct cmd_macsec_sa_result, + idx, RTE_UINT8); +static cmdline_parse_token_num_t cmd_macsec_sa_an = + TOKEN_NUM_INITIALIZER(struct cmd_macsec_sa_result, + an, RTE_UINT8); +static cmdline_parse_token_num_t cmd_macsec_sa_pn = + TOKEN_NUM_INITIALIZER(struct cmd_macsec_sa_result, + pn, RTE_UINT32); +static cmdline_parse_token_string_t cmd_macsec_sa_key = + TOKEN_STRING_INITIALIZER(struct cmd_macsec_sa_result, + key, NULL); + +static void +cmd_set_macsec_sa_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, __rte_unused void *data) +{ + struct cmd_macsec_sa_result *res = parsed_result; + int ret = -ENOTSUP; + int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; + uint8_t key[16] = { 0 }; + uint8_t xdgt0; + uint8_t xdgt1; + int key_len; + int i; + + key_len = strlen(res->key) / 2; + if (key_len > 16) + key_len = 16; + + for (i = 0; i < key_len; i++) { + xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); + if (xdgt0 == 0xFF) + return; + xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); + if (xdgt1 == 0xFF) + return; + key[i] = (uint8_t)((xdgt0 * 16) + xdgt1); + } + + ret = is_tx ? + rte_pmd_ixgbe_macsec_select_txsa(res->port_id, + res->idx, res->an, res->pn, key) : + rte_pmd_ixgbe_macsec_select_rxsa(res->port_id, + res->idx, res->an, res->pn, key); + + switch (ret) { + case 0: + break; + case -EINVAL: + fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an); + break; + case -ENODEV: + fprintf(stderr, "invalid port_id %d\n", res->port_id); + break; + case -ENOTSUP: + fprintf(stderr, "not supported on port %d\n", res->port_id); + break; + default: + fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); + } +} + +struct cmd_vf_tc_bw_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t tc; + cmdline_fixed_string_t tx; + cmdline_fixed_string_t min_bw; + portid_t port_id; + cmdline_fixed_string_t bw_list; +}; + +static cmdline_parse_token_string_t cmd_vf_tc_bw_set = + TOKEN_STRING_INITIALIZER(struct cmd_vf_tc_bw_result, + set, "set"); +static cmdline_parse_token_string_t cmd_vf_tc_bw_tc = + TOKEN_STRING_INITIALIZER(struct cmd_vf_tc_bw_result, + tc, "tc"); +static cmdline_parse_token_string_t cmd_vf_tc_bw_tx = + TOKEN_STRING_INITIALIZER(struct cmd_vf_tc_bw_result, + tx, "tx"); +static cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw = + TOKEN_STRING_INITIALIZER(struct cmd_vf_tc_bw_result, + min_bw, "min-bandwidth"); +static cmdline_parse_token_num_t cmd_vf_tc_bw_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_vf_tc_bw_result, + port_id, RTE_UINT16); +static cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list = + TOKEN_STRING_INITIALIZER(struct cmd_vf_tc_bw_result, + bw_list, NULL); + +static cmdline_parse_inst_t cmd_set_macsec_sa = { + .f = cmd_set_macsec_sa_parsed, + .data = NULL, + .help_str = "set macsec sa tx|rx ", + .tokens = { + (void *)&cmd_macsec_sa_set, + (void *)&cmd_macsec_sa_macsec, + (void *)&cmd_macsec_sa_sa, + (void *)&cmd_macsec_sa_tx_rx, + (void *)&cmd_macsec_sa_port_id, + (void *)&cmd_macsec_sa_idx, + (void *)&cmd_macsec_sa_an, + (void *)&cmd_macsec_sa_pn, + (void *)&cmd_macsec_sa_key, + NULL, + }, +}; + +static void +cmd_tc_min_bw_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, __rte_unused void *data) +{ + struct cmd_vf_tc_bw_result *res = parsed_result; + struct rte_port *port; + uint8_t tc_num; + uint8_t bw[16]; + int ret = -ENOTSUP; + + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + + port = &ports[res->port_id]; + /** Check if the port is not started **/ + if (port->port_status != RTE_PORT_STOPPED) { + fprintf(stderr, "Please stop port %d first\n", res->port_id); + return; + } + + ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); + if (ret) + return; + + ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw); + + switch (ret) { + case 0: + break; + case -EINVAL: + fprintf(stderr, "invalid bandwidth\n"); + break; + case -ENODEV: + fprintf(stderr, "invalid port_id %d\n", res->port_id); + break; + case -ENOTSUP: + fprintf(stderr, "function not implemented\n"); + break; + default: + fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); + } +} + +static cmdline_parse_inst_t cmd_tc_min_bw = { + .f = cmd_tc_min_bw_parsed, + .data = NULL, + .help_str = "set tc tx min-bandwidth ", + .tokens = { + (void *)&cmd_vf_tc_bw_set, + (void *)&cmd_vf_tc_bw_tc, + (void *)&cmd_vf_tc_bw_tx, + (void *)&cmd_vf_tc_bw_min_bw, + (void *)&cmd_vf_tc_bw_port_id, + (void *)&cmd_vf_tc_bw_bw_list, + NULL, + }, +}; + +/* The NIC bypass watchdog timeout. */ +uint32_t bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; + +/* *** SET NIC BYPASS MODE *** */ +struct cmd_set_bypass_mode_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t bypass; + cmdline_fixed_string_t mode; + cmdline_fixed_string_t value; + portid_t port_id; +}; + +static void +cmd_set_bypass_mode_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, __rte_unused void *data) +{ + struct cmd_set_bypass_mode_result *res = parsed_result; + uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; + portid_t port_id = res->port_id; + int32_t rc = -EINVAL; + + if (!strcmp(res->value, "bypass")) + bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; + else if (!strcmp(res->value, "isolate")) + bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; + else + bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; + + /* Set the bypass mode for the relevant port. */ + rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode); + if (rc != 0) + fprintf(stderr, "\t Failed to set bypass mode for port = %d.\n", + port_id); +} + +static cmdline_parse_token_string_t cmd_setbypass_mode_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, + set, "set"); +static cmdline_parse_token_string_t cmd_setbypass_mode_bypass = + TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, + bypass, "bypass"); +static cmdline_parse_token_string_t cmd_setbypass_mode_mode = + TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, + mode, "mode"); +static cmdline_parse_token_string_t cmd_setbypass_mode_value = + TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, + value, "normal#bypass#isolate"); +static cmdline_parse_token_num_t cmd_setbypass_mode_port = + TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result, + port_id, RTE_UINT16); + +static cmdline_parse_inst_t cmd_set_bypass_mode = { + .f = cmd_set_bypass_mode_parsed, + .help_str = "set bypass mode normal|bypass|isolate : " + "Set the NIC bypass mode for port_id", + .data = NULL, + .tokens = { + (void *)&cmd_setbypass_mode_set, + (void *)&cmd_setbypass_mode_bypass, + (void *)&cmd_setbypass_mode_mode, + (void *)&cmd_setbypass_mode_value, + (void *)&cmd_setbypass_mode_port, + NULL, + }, +}; + +/* *** SET NIC BYPASS EVENT *** */ +struct cmd_set_bypass_event_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t bypass; + cmdline_fixed_string_t event; + cmdline_fixed_string_t event_value; + cmdline_fixed_string_t mode; + cmdline_fixed_string_t mode_value; + portid_t port_id; +}; + +static void +cmd_set_bypass_event_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, __rte_unused void *data) +{ + int32_t rc = -EINVAL; + struct cmd_set_bypass_event_result *res = parsed_result; + portid_t port_id = res->port_id; + uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; + uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; + + if (!strcmp(res->event_value, "timeout")) + bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT; + else if (!strcmp(res->event_value, "os_on")) + bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON; + else if (!strcmp(res->event_value, "os_off")) + bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF; + else if (!strcmp(res->event_value, "power_on")) + bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON; + else if (!strcmp(res->event_value, "power_off")) + bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF; + else + bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; + + if (!strcmp(res->mode_value, "bypass")) + bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; + else if (!strcmp(res->mode_value, "isolate")) + bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; + else + bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; + + /* Set the watchdog timeout. */ + if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) { + rc = -EINVAL; + if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) { + rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id, + bypass_timeout); + } + if (rc != 0) { + fprintf(stderr, + "Failed to set timeout value %u for port %d, errto code: %d.\n", + bypass_timeout, port_id, rc); + } + } + + /* Set the bypass event to transition to bypass mode. */ + rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event, + bypass_mode); + if (rc != 0) + fprintf(stderr, "\t Failed to set bypass event for port = %d.\n", + port_id); +} + +static cmdline_parse_token_string_t cmd_setbypass_event_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, + set, "set"); +static cmdline_parse_token_string_t cmd_setbypass_event_bypass = + TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, + bypass, "bypass"); +static cmdline_parse_token_string_t cmd_setbypass_event_event = + TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, + event, "event"); +static cmdline_parse_token_string_t cmd_setbypass_event_event_value = + TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, + event_value, "none#timeout#os_off#os_on#power_on#power_off"); +static cmdline_parse_token_string_t cmd_setbypass_event_mode = + TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, + mode, "mode"); +static cmdline_parse_token_string_t cmd_setbypass_event_mode_value = + TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, + mode_value, "normal#bypass#isolate"); +static cmdline_parse_token_num_t cmd_setbypass_event_port = + TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result, + port_id, RTE_UINT16); + +static cmdline_parse_inst_t cmd_set_bypass_event = { + .f = cmd_set_bypass_event_parsed, + .help_str = "set bypass event none|timeout|os_on|os_off|power_on|" + "power_off mode normal|bypass|isolate : " + "Set the NIC bypass event mode for port_id", + .data = NULL, + .tokens = { + (void *)&cmd_setbypass_event_set, + (void *)&cmd_setbypass_event_bypass, + (void *)&cmd_setbypass_event_event, + (void *)&cmd_setbypass_event_event_value, + (void *)&cmd_setbypass_event_mode, + (void *)&cmd_setbypass_event_mode_value, + (void *)&cmd_setbypass_event_port, + NULL, + }, +}; + + +/* *** SET NIC BYPASS TIMEOUT *** */ +struct cmd_set_bypass_timeout_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t bypass; + cmdline_fixed_string_t timeout; + cmdline_fixed_string_t value; +}; + +static void +cmd_set_bypass_timeout_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, __rte_unused void *data) +{ + struct cmd_set_bypass_timeout_result *res = parsed_result; + + if (!strcmp(res->value, "1.5")) + bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC; + else if (!strcmp(res->value, "2")) + bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC; + else if (!strcmp(res->value, "3")) + bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC; + else if (!strcmp(res->value, "4")) + bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC; + else if (!strcmp(res->value, "8")) + bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC; + else if (!strcmp(res->value, "16")) + bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC; + else if (!strcmp(res->value, "32")) + bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC; + else + bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; +} + +static cmdline_parse_token_string_t cmd_setbypass_timeout_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, + set, "set"); +static cmdline_parse_token_string_t cmd_setbypass_timeout_bypass = + TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, + bypass, "bypass"); +static cmdline_parse_token_string_t cmd_setbypass_timeout_timeout = + TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, + timeout, "timeout"); +static cmdline_parse_token_string_t cmd_setbypass_timeout_value = + TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, + value, "0#1.5#2#3#4#8#16#32"); + +static cmdline_parse_inst_t cmd_set_bypass_timeout = { + .f = cmd_set_bypass_timeout_parsed, + .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: " + "Set the NIC bypass watchdog timeout in seconds", + .data = NULL, + .tokens = { + (void *)&cmd_setbypass_timeout_set, + (void *)&cmd_setbypass_timeout_bypass, + (void *)&cmd_setbypass_timeout_timeout, + (void *)&cmd_setbypass_timeout_value, + NULL, + }, +}; + +/* *** SHOW NIC BYPASS MODE *** */ +struct cmd_show_bypass_config_result { + cmdline_fixed_string_t show; + cmdline_fixed_string_t bypass; + cmdline_fixed_string_t config; + portid_t port_id; +}; + +static void +cmd_show_bypass_config_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, __rte_unused void *data) +{ + struct cmd_show_bypass_config_result *res = parsed_result; + portid_t port_id = res->port_id; + int rc = -EINVAL; + uint32_t event_mode; + uint32_t bypass_mode; + uint32_t timeout = bypass_timeout; + unsigned int i; + + static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] = { + "off", "1.5", "2", "3", "4", "8", "16", "32" + }; + static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] = { + "UNKNOWN", "normal", "bypass", "isolate" + }; + static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = { + "NONE", + "OS/board on", + "power supply on", + "OS/board off", + "power supply off", + "timeout"}; + + /* Display the bypass mode.*/ + if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) { + fprintf(stderr, "\tFailed to get bypass mode for port = %d\n", + port_id); + return; + } + if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode)) + bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; + + printf("\tbypass mode = %s\n", modes[bypass_mode]); + + /* Display the bypass timeout.*/ + if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout)) + timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; + + printf("\tbypass timeout = %s\n", timeouts[timeout]); + + /* Display the bypass events and associated modes. */ + for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) { + if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) { + fprintf(stderr, "\tFailed to get bypass mode for event = %s\n", + events[i]); + } else { + if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode)) + event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; + + printf("\tbypass event: %-16s = %s\n", events[i], + modes[event_mode]); + } + } + if (rc != 0) + fprintf(stderr, + "\tFailed to get bypass configuration for port = %d\n", + port_id); +} + +static cmdline_parse_token_string_t cmd_showbypass_config_show = + TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, + show, "show"); +static cmdline_parse_token_string_t cmd_showbypass_config_bypass = + TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, + bypass, "bypass"); +static cmdline_parse_token_string_t cmd_showbypass_config_config = + TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, + config, "config"); +static cmdline_parse_token_num_t cmd_showbypass_config_port = + TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result, + port_id, RTE_UINT16); + +static cmdline_parse_inst_t cmd_show_bypass_config = { + .f = cmd_show_bypass_config_parsed, + .help_str = "show bypass config : " + "Show the NIC bypass config for port_id", + .data = NULL, + .tokens = { + (void *)&cmd_showbypass_config_show, + (void *)&cmd_showbypass_config_bypass, + (void *)&cmd_showbypass_config_config, + (void *)&cmd_showbypass_config_port, + NULL, + }, +}; + +static struct testpmd_driver_commands ixgbe_cmds = { + .commands = { + { + &cmd_set_vf_split_drop_en, + "set vf split drop (port_id) (vf_id) (on|off)\n" + " Set split drop enable bit for a VF from the PF.\n", + }, + { + &cmd_set_macsec_offload_on, + "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n" + " Enable MACsec offload.\n", + }, + { + &cmd_set_macsec_offload_off, + "set macsec offload (port_id) off\n" + " Disable MACsec offload.\n", + }, + { + &cmd_set_macsec_sc, + "set macsec sc (tx|rx) (port_id) (mac) (pi)\n" + " Configure MACsec secure connection (SC).\n", + }, + { + &cmd_set_macsec_sa, + "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n" + " Configure MACsec secure association (SA).\n", + }, + { + &cmd_tc_min_bw, + "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n" + " Set all TCs' min bandwidth(%%) for all PF and VFs.\n", + }, + { + &cmd_set_bypass_mode, + "set bypass mode (normal|bypass|isolate) (port_id)\n" + " Set the bypass mode for the lowest port on bypass enabled NIC.\n", + }, + { + &cmd_set_bypass_event, + "set bypass event (timeout|os_on|os_off|power_on|power_off) " + "mode (normal|bypass|isolate) (port_id)\n" + " Set the event required to initiate specified bypass mode for" + " the lowest port on a bypass enabled NIC where:\n" + " timeout = enable bypass after watchdog timeout.\n" + " os_on = enable bypass when OS/board is powered on.\n" + " os_off = enable bypass when OS/board is powered off.\n" + " power_on = enable bypass when power supply is turned on.\n" + " power_off = enable bypass when power supply is turned off." + "\n", + }, + { + &cmd_set_bypass_timeout, + "set bypass timeout (0|1.5|2|3|4|8|16|32)\n" + " Set the bypass watchdog timeout to 'n' seconds where 0 = instant.\n", + }, + { + &cmd_show_bypass_config, + "show bypass config (port_id)\n" + " Show the bypass configuration for a bypass enabled NIC" + " using the lowest port on the NIC.\n", + }, + { NULL, NULL }, + }, +}; +TESTPMD_ADD_DRIVER_COMMANDS(ixgbe_cmds) diff --git a/drivers/net/ixgbe/meson.build b/drivers/net/ixgbe/meson.build index 162f8d5f46..a18908ef7c 100644 --- a/drivers/net/ixgbe/meson.build +++ b/drivers/net/ixgbe/meson.build @@ -20,6 +20,8 @@ sources = files( 'rte_pmd_ixgbe.c', ) +testpmd_sources = files('ixgbe_testpmd.c') + deps += ['hash', 'security'] if arch_subdir == 'x86' -- 2.36.1