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 2B78EA00C3; Fri, 13 May 2022 09:57:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1CFB2427F1; Fri, 13 May 2022 09:57:41 +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 56C0D40DDE for ; Fri, 13 May 2022 09:57:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652428658; 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=C1FXXZmuHTq+JOcb/pshooBQKeID1uv3KdGCsIKrZwg=; b=KlgljyU2/QjTwoEjBwMiHbTTTPKFVBAp5E662sbQA//XAZp6wRsDbRv7JwsngDlGRja1yz XtKAm9/nytzEihPSCqzBtwMPsR5N7r1x25rMyGmJl4mmnIpnP1mQhBQeo6Vbma4mClb4i6 EFIYDwry2m0BFrRCzKc1ObFhkW7eu0U= 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-581-EtKFw5ohO8mop5AsGgJFfQ-1; Fri, 13 May 2022 03:57:35 -0400 X-MC-Unique: EtKFw5ohO8mop5AsGgJFfQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 333B2185A794; Fri, 13 May 2022 07:57:35 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.193.195]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF498416361; Fri, 13 May 2022 07:57:32 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Xiaoyun Li , Aman Singh , Yuying Zhang , Beilei Xing Subject: [RFC PATCH 3/4] net/i40e: move testpmd commands Date: Fri, 13 May 2022 09:57:17 +0200 Message-Id: <20220513075718.18674-4-david.marchand@redhat.com> In-Reply-To: <20220513075718.18674-1-david.marchand@redhat.com> References: <20220513075718.18674-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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. Signed-off-by: David Marchand --- app/test-pmd/cmdline.c | 665 -------------------------------- drivers/net/i40e/i40e_testpmd.c | 655 +++++++++++++++++++++++++++++++ drivers/net/i40e/meson.build | 2 + 3 files changed, 657 insertions(+), 665 deletions(-) create mode 100644 drivers/net/i40e/i40e_testpmd.c diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index ae4759fbfe..fee05c1a0c 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -637,21 +637,6 @@ static void cmd_help_long_parsed(void *parsed_result, "set port (port_id) ptype_mask (ptype_mask)\n" " set packet types classification for a specific port\n\n" - "set port (port_id) queue-region region_id (value) " - "queue_start_index (value) queue_num (value)\n" - " Set a queue region on a port\n\n" - - "set port (port_id) queue-region region_id (value) " - "flowtype (value)\n" - " Set a flowtype region index on a port\n\n" - - "set port (port_id) queue-region UP (value) region_id (value)\n" - " Set the mapping of User Priority to " - "queue region on a port\n\n" - - "set port (port_id) queue-region flush (on|off)\n" - " flush all queue region related configuration\n\n" - "show port meter cap (port_id)\n" " Show port meter capability information\n\n" @@ -702,9 +687,6 @@ static void cmd_help_long_parsed(void *parsed_result, "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n" " meter update stats\n\n" - "show port (port_id) queue-region\n" - " show all queue region related configuration info\n\n" - "set port (port_id) fec_mode auto|off|rs|baser\n" " set fec mode for a specific port\n\n" @@ -912,13 +894,6 @@ static void cmd_help_long_parsed(void *parsed_result, "filters:\n" "--------\n\n" -#ifdef RTE_NET_I40E - "flow_director_filter (port_id) mode raw (add|del|update)" - " flow (flow_id) (drop|fwd) queue (queue_id)" - " fd_id (fd_id_value) packet (packet file name)\n" - " Add/Del a raw type flow director filter.\n\n" -#endif - "flow_director_mask (port_id) mode IP vlan (vlan_value)" " src_mask (ipv4_src) (ipv6_src) (src_port)" " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n" @@ -9094,450 +9069,6 @@ cmdline_parse_inst_t cmd_dump_one = { }, }; -/* *** queue region set *** */ -struct cmd_queue_region_result { - cmdline_fixed_string_t set; - cmdline_fixed_string_t port; - portid_t port_id; - cmdline_fixed_string_t cmd; - cmdline_fixed_string_t region; - uint8_t region_id; - cmdline_fixed_string_t queue_start_index; - uint8_t queue_id; - cmdline_fixed_string_t queue_num; - uint8_t queue_num_value; -}; - -static void -cmd_queue_region_parsed(void *parsed_result, - __rte_unused struct cmdline *cl, - __rte_unused void *data) -{ - struct cmd_queue_region_result *res = parsed_result; - int ret = -ENOTSUP; -#ifdef RTE_NET_I40E - struct rte_pmd_i40e_queue_region_conf region_conf; - enum rte_pmd_i40e_queue_region_op op_type; -#endif - - if (port_id_is_invalid(res->port_id, ENABLED_WARN)) - return; - -#ifdef RTE_NET_I40E - memset(®ion_conf, 0, sizeof(region_conf)); - op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET; - region_conf.region_id = res->region_id; - region_conf.queue_num = res->queue_num_value; - region_conf.queue_start_index = res->queue_id; - - ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, - op_type, ®ion_conf); -#endif - - switch (ret) { - case 0: - break; - case -ENOTSUP: - fprintf(stderr, "function not implemented or supported\n"); - break; - default: - fprintf(stderr, "queue region config error: (%s)\n", - strerror(-ret)); - } -} - -cmdline_parse_token_string_t cmd_queue_region_set = -TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, - set, "set"); -cmdline_parse_token_string_t cmd_queue_region_port = - TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port"); -cmdline_parse_token_num_t cmd_queue_region_port_id = - TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, - port_id, RTE_UINT16); -cmdline_parse_token_string_t cmd_queue_region_cmd = - TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, - cmd, "queue-region"); -cmdline_parse_token_string_t cmd_queue_region_id = - TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, - region, "region_id"); -cmdline_parse_token_num_t cmd_queue_region_index = - TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, - region_id, RTE_UINT8); -cmdline_parse_token_string_t cmd_queue_region_queue_start_index = - TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, - queue_start_index, "queue_start_index"); -cmdline_parse_token_num_t cmd_queue_region_queue_id = - TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, - queue_id, RTE_UINT8); -cmdline_parse_token_string_t cmd_queue_region_queue_num = - TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, - queue_num, "queue_num"); -cmdline_parse_token_num_t cmd_queue_region_queue_num_value = - TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, - queue_num_value, RTE_UINT8); - -cmdline_parse_inst_t cmd_queue_region = { - .f = cmd_queue_region_parsed, - .data = NULL, - .help_str = "set port queue-region region_id " - "queue_start_index queue_num : Set a queue region", - .tokens = { - (void *)&cmd_queue_region_set, - (void *)&cmd_queue_region_port, - (void *)&cmd_queue_region_port_id, - (void *)&cmd_queue_region_cmd, - (void *)&cmd_queue_region_id, - (void *)&cmd_queue_region_index, - (void *)&cmd_queue_region_queue_start_index, - (void *)&cmd_queue_region_queue_id, - (void *)&cmd_queue_region_queue_num, - (void *)&cmd_queue_region_queue_num_value, - NULL, - }, -}; - -/* *** queue region and flowtype set *** */ -struct cmd_region_flowtype_result { - cmdline_fixed_string_t set; - cmdline_fixed_string_t port; - portid_t port_id; - cmdline_fixed_string_t cmd; - cmdline_fixed_string_t region; - uint8_t region_id; - cmdline_fixed_string_t flowtype; - uint8_t flowtype_id; -}; - -static void -cmd_region_flowtype_parsed(void *parsed_result, - __rte_unused struct cmdline *cl, - __rte_unused void *data) -{ - struct cmd_region_flowtype_result *res = parsed_result; - int ret = -ENOTSUP; -#ifdef RTE_NET_I40E - struct rte_pmd_i40e_queue_region_conf region_conf; - enum rte_pmd_i40e_queue_region_op op_type; -#endif - - if (port_id_is_invalid(res->port_id, ENABLED_WARN)) - return; - -#ifdef RTE_NET_I40E - memset(®ion_conf, 0, sizeof(region_conf)); - - op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET; - region_conf.region_id = res->region_id; - region_conf.hw_flowtype = res->flowtype_id; - - ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, - op_type, ®ion_conf); -#endif - - switch (ret) { - case 0: - break; - case -ENOTSUP: - fprintf(stderr, "function not implemented or supported\n"); - break; - default: - fprintf(stderr, "region flowtype config error: (%s)\n", - strerror(-ret)); - } -} - -cmdline_parse_token_string_t cmd_region_flowtype_set = -TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, - set, "set"); -cmdline_parse_token_string_t cmd_region_flowtype_port = - TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, - port, "port"); -cmdline_parse_token_num_t cmd_region_flowtype_port_index = - TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, - port_id, RTE_UINT16); -cmdline_parse_token_string_t cmd_region_flowtype_cmd = - TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, - cmd, "queue-region"); -cmdline_parse_token_string_t cmd_region_flowtype_index = - TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, - region, "region_id"); -cmdline_parse_token_num_t cmd_region_flowtype_id = - TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, - region_id, RTE_UINT8); -cmdline_parse_token_string_t cmd_region_flowtype_flow_index = - TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, - flowtype, "flowtype"); -cmdline_parse_token_num_t cmd_region_flowtype_flow_id = - TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, - flowtype_id, RTE_UINT8); -cmdline_parse_inst_t cmd_region_flowtype = { - .f = cmd_region_flowtype_parsed, - .data = NULL, - .help_str = "set port queue-region region_id " - "flowtype : Set a flowtype region index", - .tokens = { - (void *)&cmd_region_flowtype_set, - (void *)&cmd_region_flowtype_port, - (void *)&cmd_region_flowtype_port_index, - (void *)&cmd_region_flowtype_cmd, - (void *)&cmd_region_flowtype_index, - (void *)&cmd_region_flowtype_id, - (void *)&cmd_region_flowtype_flow_index, - (void *)&cmd_region_flowtype_flow_id, - NULL, - }, -}; - -/* *** User Priority (UP) to queue region (region_id) set *** */ -struct cmd_user_priority_region_result { - cmdline_fixed_string_t set; - cmdline_fixed_string_t port; - portid_t port_id; - cmdline_fixed_string_t cmd; - cmdline_fixed_string_t user_priority; - uint8_t user_priority_id; - cmdline_fixed_string_t region; - uint8_t region_id; -}; - -static void -cmd_user_priority_region_parsed(void *parsed_result, - __rte_unused struct cmdline *cl, - __rte_unused void *data) -{ - struct cmd_user_priority_region_result *res = parsed_result; - int ret = -ENOTSUP; -#ifdef RTE_NET_I40E - struct rte_pmd_i40e_queue_region_conf region_conf; - enum rte_pmd_i40e_queue_region_op op_type; -#endif - - if (port_id_is_invalid(res->port_id, ENABLED_WARN)) - return; - -#ifdef RTE_NET_I40E - memset(®ion_conf, 0, sizeof(region_conf)); - op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET; - region_conf.user_priority = res->user_priority_id; - region_conf.region_id = res->region_id; - - ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, - op_type, ®ion_conf); -#endif - - switch (ret) { - case 0: - break; - case -ENOTSUP: - fprintf(stderr, "function not implemented or supported\n"); - break; - default: - fprintf(stderr, "user_priority region config error: (%s)\n", - strerror(-ret)); - } -} - -cmdline_parse_token_string_t cmd_user_priority_region_set = - TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, - set, "set"); -cmdline_parse_token_string_t cmd_user_priority_region_port = - TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, - port, "port"); -cmdline_parse_token_num_t cmd_user_priority_region_port_index = - TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, - port_id, RTE_UINT16); -cmdline_parse_token_string_t cmd_user_priority_region_cmd = - TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, - cmd, "queue-region"); -cmdline_parse_token_string_t cmd_user_priority_region_UP = - TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, - user_priority, "UP"); -cmdline_parse_token_num_t cmd_user_priority_region_UP_id = - TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, - user_priority_id, RTE_UINT8); -cmdline_parse_token_string_t cmd_user_priority_region_region = - TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, - region, "region_id"); -cmdline_parse_token_num_t cmd_user_priority_region_region_id = - TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, - region_id, RTE_UINT8); - -cmdline_parse_inst_t cmd_user_priority_region = { - .f = cmd_user_priority_region_parsed, - .data = NULL, - .help_str = "set port queue-region UP " - "region_id : Set the mapping of User Priority (UP) " - "to queue region (region_id) ", - .tokens = { - (void *)&cmd_user_priority_region_set, - (void *)&cmd_user_priority_region_port, - (void *)&cmd_user_priority_region_port_index, - (void *)&cmd_user_priority_region_cmd, - (void *)&cmd_user_priority_region_UP, - (void *)&cmd_user_priority_region_UP_id, - (void *)&cmd_user_priority_region_region, - (void *)&cmd_user_priority_region_region_id, - NULL, - }, -}; - -/* *** flush all queue region related configuration *** */ -struct cmd_flush_queue_region_result { - cmdline_fixed_string_t set; - cmdline_fixed_string_t port; - portid_t port_id; - cmdline_fixed_string_t cmd; - cmdline_fixed_string_t flush; - cmdline_fixed_string_t what; -}; - -static void -cmd_flush_queue_region_parsed(void *parsed_result, - __rte_unused struct cmdline *cl, - __rte_unused void *data) -{ - struct cmd_flush_queue_region_result *res = parsed_result; - int ret = -ENOTSUP; -#ifdef RTE_NET_I40E - struct rte_pmd_i40e_queue_region_conf region_conf; - enum rte_pmd_i40e_queue_region_op op_type; -#endif - - if (port_id_is_invalid(res->port_id, ENABLED_WARN)) - return; - -#ifdef RTE_NET_I40E - memset(®ion_conf, 0, sizeof(region_conf)); - - if (strcmp(res->what, "on") == 0) - op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON; - else - op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF; - - ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, - op_type, ®ion_conf); -#endif - - switch (ret) { - case 0: - break; - case -ENOTSUP: - fprintf(stderr, "function not implemented or supported\n"); - break; - default: - fprintf(stderr, "queue region config flush error: (%s)\n", - strerror(-ret)); - } -} - -cmdline_parse_token_string_t cmd_flush_queue_region_set = - TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, - set, "set"); -cmdline_parse_token_string_t cmd_flush_queue_region_port = - TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, - port, "port"); -cmdline_parse_token_num_t cmd_flush_queue_region_port_index = - TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result, - port_id, RTE_UINT16); -cmdline_parse_token_string_t cmd_flush_queue_region_cmd = - TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, - cmd, "queue-region"); -cmdline_parse_token_string_t cmd_flush_queue_region_flush = - TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, - flush, "flush"); -cmdline_parse_token_string_t cmd_flush_queue_region_what = - TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, - what, "on#off"); - -cmdline_parse_inst_t cmd_flush_queue_region = { - .f = cmd_flush_queue_region_parsed, - .data = NULL, - .help_str = "set port queue-region flush on|off" - ": flush all queue region related configuration", - .tokens = { - (void *)&cmd_flush_queue_region_set, - (void *)&cmd_flush_queue_region_port, - (void *)&cmd_flush_queue_region_port_index, - (void *)&cmd_flush_queue_region_cmd, - (void *)&cmd_flush_queue_region_flush, - (void *)&cmd_flush_queue_region_what, - NULL, - }, -}; - -/* *** get all queue region related configuration info *** */ -struct cmd_show_queue_region_info { - cmdline_fixed_string_t show; - cmdline_fixed_string_t port; - portid_t port_id; - cmdline_fixed_string_t cmd; -}; - -static void -cmd_show_queue_region_info_parsed(void *parsed_result, - __rte_unused struct cmdline *cl, - __rte_unused void *data) -{ - struct cmd_show_queue_region_info *res = parsed_result; - int ret = -ENOTSUP; -#ifdef RTE_NET_I40E - struct rte_pmd_i40e_queue_regions rte_pmd_regions; - enum rte_pmd_i40e_queue_region_op op_type; -#endif - - if (port_id_is_invalid(res->port_id, ENABLED_WARN)) - return; - -#ifdef RTE_NET_I40E - memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions)); - - op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET; - - ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, - op_type, &rte_pmd_regions); - - port_queue_region_info_display(res->port_id, &rte_pmd_regions); -#endif - - switch (ret) { - case 0: - break; - case -ENOTSUP: - fprintf(stderr, "function not implemented or supported\n"); - break; - default: - fprintf(stderr, "queue region config info show error: (%s)\n", - strerror(-ret)); - } -} - -cmdline_parse_token_string_t cmd_show_queue_region_info_get = -TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, - show, "show"); -cmdline_parse_token_string_t cmd_show_queue_region_info_port = - TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, - port, "port"); -cmdline_parse_token_num_t cmd_show_queue_region_info_port_index = - TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info, - port_id, RTE_UINT16); -cmdline_parse_token_string_t cmd_show_queue_region_info_cmd = - TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, - cmd, "queue-region"); - -cmdline_parse_inst_t cmd_show_queue_region_info_all = { - .f = cmd_show_queue_region_info_parsed, - .data = NULL, - .help_str = "show port queue-region" - ": show all queue region related configuration info", - .tokens = { - (void *)&cmd_show_queue_region_info_get, - (void *)&cmd_show_queue_region_info_port, - (void *)&cmd_show_queue_region_info_port_index, - (void *)&cmd_show_queue_region_info_cmd, - NULL, - }, -}; - /* *** Filters Control *** */ #define IPV4_ADDR_TO_UINT(ip_addr, ip) \ @@ -9562,194 +9093,6 @@ do { \ } \ } while (0) -#ifdef RTE_NET_I40E - -static uint16_t -str2flowtype(char *string) -{ - uint8_t i = 0; - static const struct { - char str[32]; - uint16_t type; - } flowtype_str[] = { - {"raw", RTE_ETH_FLOW_RAW}, - {"ipv4", RTE_ETH_FLOW_IPV4}, - {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, - {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, - {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, - {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, - {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, - {"ipv6", RTE_ETH_FLOW_IPV6}, - {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, - {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, - {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, - {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, - {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, - {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, - {"ipv6-ex", RTE_ETH_FLOW_IPV6_EX}, - {"ipv6-tcp-ex", RTE_ETH_FLOW_IPV6_TCP_EX}, - {"ipv6-udp-ex", RTE_ETH_FLOW_IPV6_UDP_EX}, - {"gtpu", RTE_ETH_FLOW_GTPU}, - }; - - for (i = 0; i < RTE_DIM(flowtype_str); i++) { - if (!strcmp(flowtype_str[i].str, string)) - return flowtype_str[i].type; - } - - if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64) - return (uint16_t)atoi(string); - - return RTE_ETH_FLOW_UNKNOWN; -} - -/* *** deal with flow director filter *** */ -struct cmd_flow_director_result { - cmdline_fixed_string_t flow_director_filter; - portid_t port_id; - cmdline_fixed_string_t mode; - cmdline_fixed_string_t mode_value; - cmdline_fixed_string_t ops; - cmdline_fixed_string_t flow; - cmdline_fixed_string_t flow_type; - cmdline_fixed_string_t drop; - cmdline_fixed_string_t queue; - uint16_t queue_id; - cmdline_fixed_string_t fd_id; - uint32_t fd_id_value; - cmdline_fixed_string_t packet; - char filepath[]; -}; - -static void -cmd_flow_director_filter_parsed(void *parsed_result, - __rte_unused struct cmdline *cl, - __rte_unused void *data) -{ - struct cmd_flow_director_result *res = parsed_result; - int ret = 0; - struct rte_pmd_i40e_flow_type_mapping - mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; - struct rte_pmd_i40e_pkt_template_conf conf; - uint16_t flow_type = str2flowtype(res->flow_type); - uint16_t i, port = res->port_id; - uint8_t add; - - memset(&conf, 0, sizeof(conf)); - - if (flow_type == RTE_ETH_FLOW_UNKNOWN) { - fprintf(stderr, "Invalid flow type specified.\n"); - return; - } - ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, - mapping); - if (ret) - return; - if (mapping[flow_type].pctype == 0ULL) { - fprintf(stderr, "Invalid flow type specified.\n"); - return; - } - for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) { - if (mapping[flow_type].pctype & (1ULL << i)) { - conf.input.pctype = i; - break; - } - } - - conf.input.packet = open_file(res->filepath, - &conf.input.length); - if (!conf.input.packet) - return; - if (!strcmp(res->drop, "drop")) - conf.action.behavior = - RTE_PMD_I40E_PKT_TEMPLATE_REJECT; - else - conf.action.behavior = - RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT; - conf.action.report_status = - RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID; - conf.action.rx_queue = res->queue_id; - conf.soft_id = res->fd_id_value; - add = strcmp(res->ops, "del") ? 1 : 0; - ret = rte_pmd_i40e_flow_add_del_packet_template(port, - &conf, - add); - if (ret < 0) - fprintf(stderr, "flow director config error: (%s)\n", - strerror(-ret)); - close_file(conf.input.packet); -} - -cmdline_parse_token_string_t cmd_flow_director_filter = - TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, - flow_director_filter, "flow_director_filter"); -cmdline_parse_token_num_t cmd_flow_director_port_id = - TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, - port_id, RTE_UINT16); -cmdline_parse_token_string_t cmd_flow_director_ops = - TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, - ops, "add#del#update"); -cmdline_parse_token_string_t cmd_flow_director_flow = - TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, - flow, "flow"); -cmdline_parse_token_string_t cmd_flow_director_flow_type = - TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, - flow_type, NULL); -cmdline_parse_token_string_t cmd_flow_director_drop = - TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, - drop, "drop#fwd"); -cmdline_parse_token_string_t cmd_flow_director_queue = - TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, - queue, "queue"); -cmdline_parse_token_num_t cmd_flow_director_queue_id = - TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, - queue_id, RTE_UINT16); -cmdline_parse_token_string_t cmd_flow_director_fd_id = - TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, - fd_id, "fd_id"); -cmdline_parse_token_num_t cmd_flow_director_fd_id_value = - TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, - fd_id_value, RTE_UINT32); - -cmdline_parse_token_string_t cmd_flow_director_mode = - TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, - mode, "mode"); -cmdline_parse_token_string_t cmd_flow_director_mode_raw = - TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, - mode_value, "raw"); -cmdline_parse_token_string_t cmd_flow_director_packet = - TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, - packet, "packet"); -cmdline_parse_token_string_t cmd_flow_director_filepath = - TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, - filepath, NULL); - -cmdline_parse_inst_t cmd_add_del_raw_flow_director = { - .f = cmd_flow_director_filter_parsed, - .data = NULL, - .help_str = "flow_director_filter ... : Add or delete a raw flow " - "director entry on NIC", - .tokens = { - (void *)&cmd_flow_director_filter, - (void *)&cmd_flow_director_port_id, - (void *)&cmd_flow_director_mode, - (void *)&cmd_flow_director_mode_raw, - (void *)&cmd_flow_director_ops, - (void *)&cmd_flow_director_flow, - (void *)&cmd_flow_director_flow_type, - (void *)&cmd_flow_director_drop, - (void *)&cmd_flow_director_queue, - (void *)&cmd_flow_director_queue_id, - (void *)&cmd_flow_director_fd_id, - (void *)&cmd_flow_director_fd_id_value, - (void *)&cmd_flow_director_packet, - (void *)&cmd_flow_director_filepath, - NULL, - }, -}; - -#endif /* RTE_NET_I40E */ - /* *** deal with flow director mask *** */ struct cmd_flow_director_mask_result { cmdline_fixed_string_t flow_director_mask; @@ -16939,9 +16282,6 @@ static cmdline_parse_ctx_t builtin_ctx[] = { (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs, (cmdline_parse_inst_t *)&cmd_dump, (cmdline_parse_inst_t *)&cmd_dump_one, -#ifdef RTE_NET_I40E - (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director, -#endif (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask, (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask, (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask, @@ -17023,11 +16363,6 @@ static cmdline_parse_ctx_t builtin_ctx[] = { (cmdline_parse_inst_t *)&cmd_pctype_mapping_get, (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset, (cmdline_parse_inst_t *)&cmd_pctype_mapping_update, - (cmdline_parse_inst_t *)&cmd_queue_region, - (cmdline_parse_inst_t *)&cmd_region_flowtype, - (cmdline_parse_inst_t *)&cmd_user_priority_region, - (cmdline_parse_inst_t *)&cmd_flush_queue_region, - (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all, (cmdline_parse_inst_t *)&cmd_show_port_tm_cap, (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap, (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap, diff --git a/drivers/net/i40e/i40e_testpmd.c b/drivers/net/i40e/i40e_testpmd.c new file mode 100644 index 0000000000..09cd4ff72d --- /dev/null +++ b/drivers/net/i40e/i40e_testpmd.c @@ -0,0 +1,655 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2016 Intel Corporation. + */ +#include + +#include +#include + +#include "testpmd.h" + +/* *** queue region set *** */ +struct cmd_queue_region_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t port; + portid_t port_id; + cmdline_fixed_string_t cmd; + cmdline_fixed_string_t region; + uint8_t region_id; + cmdline_fixed_string_t queue_start_index; + uint8_t queue_id; + cmdline_fixed_string_t queue_num; + uint8_t queue_num_value; +}; + +static void +cmd_queue_region_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_queue_region_result *res = parsed_result; + int ret = -ENOTSUP; + struct rte_pmd_i40e_queue_region_conf region_conf; + enum rte_pmd_i40e_queue_region_op op_type; + + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + + memset(®ion_conf, 0, sizeof(region_conf)); + op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET; + region_conf.region_id = res->region_id; + region_conf.queue_num = res->queue_num_value; + region_conf.queue_start_index = res->queue_id; + + ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, + op_type, ®ion_conf); + switch (ret) { + case 0: + break; + case -ENOTSUP: + fprintf(stderr, "function not implemented or supported\n"); + break; + default: + fprintf(stderr, "queue region config error: (%s)\n", + strerror(-ret)); + } +} + +cmdline_parse_token_string_t cmd_queue_region_set = +TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, + set, "set"); +cmdline_parse_token_string_t cmd_queue_region_port = + TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port"); +cmdline_parse_token_num_t cmd_queue_region_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, + port_id, RTE_UINT16); +cmdline_parse_token_string_t cmd_queue_region_cmd = + TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, + cmd, "queue-region"); +cmdline_parse_token_string_t cmd_queue_region_id = + TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, + region, "region_id"); +cmdline_parse_token_num_t cmd_queue_region_index = + TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, + region_id, RTE_UINT8); +cmdline_parse_token_string_t cmd_queue_region_queue_start_index = + TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, + queue_start_index, "queue_start_index"); +cmdline_parse_token_num_t cmd_queue_region_queue_id = + TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, + queue_id, RTE_UINT8); +cmdline_parse_token_string_t cmd_queue_region_queue_num = + TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, + queue_num, "queue_num"); +cmdline_parse_token_num_t cmd_queue_region_queue_num_value = + TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, + queue_num_value, RTE_UINT8); + +cmdline_parse_inst_t cmd_queue_region = { + .f = cmd_queue_region_parsed, + .data = NULL, + .help_str = "set port queue-region region_id " + "queue_start_index queue_num : Set a queue region", + .tokens = { + (void *)&cmd_queue_region_set, + (void *)&cmd_queue_region_port, + (void *)&cmd_queue_region_port_id, + (void *)&cmd_queue_region_cmd, + (void *)&cmd_queue_region_id, + (void *)&cmd_queue_region_index, + (void *)&cmd_queue_region_queue_start_index, + (void *)&cmd_queue_region_queue_id, + (void *)&cmd_queue_region_queue_num, + (void *)&cmd_queue_region_queue_num_value, + NULL, + }, +}; + +/* *** queue region and flowtype set *** */ +struct cmd_region_flowtype_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t port; + portid_t port_id; + cmdline_fixed_string_t cmd; + cmdline_fixed_string_t region; + uint8_t region_id; + cmdline_fixed_string_t flowtype; + uint8_t flowtype_id; +}; + +static void +cmd_region_flowtype_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_region_flowtype_result *res = parsed_result; + int ret = -ENOTSUP; + struct rte_pmd_i40e_queue_region_conf region_conf; + enum rte_pmd_i40e_queue_region_op op_type; + + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + + memset(®ion_conf, 0, sizeof(region_conf)); + + op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET; + region_conf.region_id = res->region_id; + region_conf.hw_flowtype = res->flowtype_id; + + ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, + op_type, ®ion_conf); + switch (ret) { + case 0: + break; + case -ENOTSUP: + fprintf(stderr, "function not implemented or supported\n"); + break; + default: + fprintf(stderr, "region flowtype config error: (%s)\n", + strerror(-ret)); + } +} + +cmdline_parse_token_string_t cmd_region_flowtype_set = +TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, + set, "set"); +cmdline_parse_token_string_t cmd_region_flowtype_port = + TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, + port, "port"); +cmdline_parse_token_num_t cmd_region_flowtype_port_index = + TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, + port_id, RTE_UINT16); +cmdline_parse_token_string_t cmd_region_flowtype_cmd = + TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, + cmd, "queue-region"); +cmdline_parse_token_string_t cmd_region_flowtype_index = + TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, + region, "region_id"); +cmdline_parse_token_num_t cmd_region_flowtype_id = + TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, + region_id, RTE_UINT8); +cmdline_parse_token_string_t cmd_region_flowtype_flow_index = + TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, + flowtype, "flowtype"); +cmdline_parse_token_num_t cmd_region_flowtype_flow_id = + TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, + flowtype_id, RTE_UINT8); +cmdline_parse_inst_t cmd_region_flowtype = { + .f = cmd_region_flowtype_parsed, + .data = NULL, + .help_str = "set port queue-region region_id " + "flowtype : Set a flowtype region index", + .tokens = { + (void *)&cmd_region_flowtype_set, + (void *)&cmd_region_flowtype_port, + (void *)&cmd_region_flowtype_port_index, + (void *)&cmd_region_flowtype_cmd, + (void *)&cmd_region_flowtype_index, + (void *)&cmd_region_flowtype_id, + (void *)&cmd_region_flowtype_flow_index, + (void *)&cmd_region_flowtype_flow_id, + NULL, + }, +}; + +/* *** User Priority (UP) to queue region (region_id) set *** */ +struct cmd_user_priority_region_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t port; + portid_t port_id; + cmdline_fixed_string_t cmd; + cmdline_fixed_string_t user_priority; + uint8_t user_priority_id; + cmdline_fixed_string_t region; + uint8_t region_id; +}; + +static void +cmd_user_priority_region_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_user_priority_region_result *res = parsed_result; + int ret = -ENOTSUP; + struct rte_pmd_i40e_queue_region_conf region_conf; + enum rte_pmd_i40e_queue_region_op op_type; + + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + + memset(®ion_conf, 0, sizeof(region_conf)); + op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET; + region_conf.user_priority = res->user_priority_id; + region_conf.region_id = res->region_id; + + ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, + op_type, ®ion_conf); + switch (ret) { + case 0: + break; + case -ENOTSUP: + fprintf(stderr, "function not implemented or supported\n"); + break; + default: + fprintf(stderr, "user_priority region config error: (%s)\n", + strerror(-ret)); + } +} + +cmdline_parse_token_string_t cmd_user_priority_region_set = + TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, + set, "set"); +cmdline_parse_token_string_t cmd_user_priority_region_port = + TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, + port, "port"); +cmdline_parse_token_num_t cmd_user_priority_region_port_index = + TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, + port_id, RTE_UINT16); +cmdline_parse_token_string_t cmd_user_priority_region_cmd = + TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, + cmd, "queue-region"); +cmdline_parse_token_string_t cmd_user_priority_region_UP = + TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, + user_priority, "UP"); +cmdline_parse_token_num_t cmd_user_priority_region_UP_id = + TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, + user_priority_id, RTE_UINT8); +cmdline_parse_token_string_t cmd_user_priority_region_region = + TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, + region, "region_id"); +cmdline_parse_token_num_t cmd_user_priority_region_region_id = + TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, + region_id, RTE_UINT8); + +cmdline_parse_inst_t cmd_user_priority_region = { + .f = cmd_user_priority_region_parsed, + .data = NULL, + .help_str = "set port queue-region UP " + "region_id : Set the mapping of User Priority (UP) " + "to queue region (region_id) ", + .tokens = { + (void *)&cmd_user_priority_region_set, + (void *)&cmd_user_priority_region_port, + (void *)&cmd_user_priority_region_port_index, + (void *)&cmd_user_priority_region_cmd, + (void *)&cmd_user_priority_region_UP, + (void *)&cmd_user_priority_region_UP_id, + (void *)&cmd_user_priority_region_region, + (void *)&cmd_user_priority_region_region_id, + NULL, + }, +}; + +/* *** flush all queue region related configuration *** */ +struct cmd_flush_queue_region_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t port; + portid_t port_id; + cmdline_fixed_string_t cmd; + cmdline_fixed_string_t flush; + cmdline_fixed_string_t what; +}; + +static void +cmd_flush_queue_region_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_flush_queue_region_result *res = parsed_result; + int ret = -ENOTSUP; + struct rte_pmd_i40e_queue_region_conf region_conf; + enum rte_pmd_i40e_queue_region_op op_type; + + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + + memset(®ion_conf, 0, sizeof(region_conf)); + + if (strcmp(res->what, "on") == 0) + op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON; + else + op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF; + + ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, + op_type, ®ion_conf); + switch (ret) { + case 0: + break; + case -ENOTSUP: + fprintf(stderr, "function not implemented or supported\n"); + break; + default: + fprintf(stderr, "queue region config flush error: (%s)\n", + strerror(-ret)); + } +} + +cmdline_parse_token_string_t cmd_flush_queue_region_set = + TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, + set, "set"); +cmdline_parse_token_string_t cmd_flush_queue_region_port = + TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, + port, "port"); +cmdline_parse_token_num_t cmd_flush_queue_region_port_index = + TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result, + port_id, RTE_UINT16); +cmdline_parse_token_string_t cmd_flush_queue_region_cmd = + TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, + cmd, "queue-region"); +cmdline_parse_token_string_t cmd_flush_queue_region_flush = + TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, + flush, "flush"); +cmdline_parse_token_string_t cmd_flush_queue_region_what = + TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, + what, "on#off"); + +cmdline_parse_inst_t cmd_flush_queue_region = { + .f = cmd_flush_queue_region_parsed, + .data = NULL, + .help_str = "set port queue-region flush on|off" + ": flush all queue region related configuration", + .tokens = { + (void *)&cmd_flush_queue_region_set, + (void *)&cmd_flush_queue_region_port, + (void *)&cmd_flush_queue_region_port_index, + (void *)&cmd_flush_queue_region_cmd, + (void *)&cmd_flush_queue_region_flush, + (void *)&cmd_flush_queue_region_what, + NULL, + }, +}; + +/* *** get all queue region related configuration info *** */ +struct cmd_show_queue_region_info { + cmdline_fixed_string_t show; + cmdline_fixed_string_t port; + portid_t port_id; + cmdline_fixed_string_t cmd; +}; + +static void +cmd_show_queue_region_info_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_show_queue_region_info *res = parsed_result; + int ret = -ENOTSUP; + struct rte_pmd_i40e_queue_regions rte_pmd_regions; + enum rte_pmd_i40e_queue_region_op op_type; + + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + + memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions)); + + op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET; + + ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, + op_type, &rte_pmd_regions); + + port_queue_region_info_display(res->port_id, &rte_pmd_regions); + switch (ret) { + case 0: + break; + case -ENOTSUP: + fprintf(stderr, "function not implemented or supported\n"); + break; + default: + fprintf(stderr, "queue region config info show error: (%s)\n", + strerror(-ret)); + } +} + +cmdline_parse_token_string_t cmd_show_queue_region_info_get = +TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, + show, "show"); +cmdline_parse_token_string_t cmd_show_queue_region_info_port = + TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, + port, "port"); +cmdline_parse_token_num_t cmd_show_queue_region_info_port_index = + TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info, + port_id, RTE_UINT16); +cmdline_parse_token_string_t cmd_show_queue_region_info_cmd = + TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, + cmd, "queue-region"); + +cmdline_parse_inst_t cmd_show_queue_region_info_all = { + .f = cmd_show_queue_region_info_parsed, + .data = NULL, + .help_str = "show port queue-region" + ": show all queue region related configuration info", + .tokens = { + (void *)&cmd_show_queue_region_info_get, + (void *)&cmd_show_queue_region_info_port, + (void *)&cmd_show_queue_region_info_port_index, + (void *)&cmd_show_queue_region_info_cmd, + NULL, + }, +}; + +static uint16_t +str2flowtype(char *string) +{ + uint8_t i = 0; + static const struct { + char str[32]; + uint16_t type; + } flowtype_str[] = { + {"raw", RTE_ETH_FLOW_RAW}, + {"ipv4", RTE_ETH_FLOW_IPV4}, + {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, + {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, + {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, + {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, + {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, + {"ipv6", RTE_ETH_FLOW_IPV6}, + {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, + {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, + {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, + {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, + {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, + {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, + {"ipv6-ex", RTE_ETH_FLOW_IPV6_EX}, + {"ipv6-tcp-ex", RTE_ETH_FLOW_IPV6_TCP_EX}, + {"ipv6-udp-ex", RTE_ETH_FLOW_IPV6_UDP_EX}, + {"gtpu", RTE_ETH_FLOW_GTPU}, + }; + + for (i = 0; i < RTE_DIM(flowtype_str); i++) { + if (!strcmp(flowtype_str[i].str, string)) + return flowtype_str[i].type; + } + + if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64) + return (uint16_t)atoi(string); + + return RTE_ETH_FLOW_UNKNOWN; +} + +/* *** deal with flow director filter *** */ +struct cmd_flow_director_result { + cmdline_fixed_string_t flow_director_filter; + portid_t port_id; + cmdline_fixed_string_t mode; + cmdline_fixed_string_t mode_value; + cmdline_fixed_string_t ops; + cmdline_fixed_string_t flow; + cmdline_fixed_string_t flow_type; + cmdline_fixed_string_t drop; + cmdline_fixed_string_t queue; + uint16_t queue_id; + cmdline_fixed_string_t fd_id; + uint32_t fd_id_value; + cmdline_fixed_string_t packet; + char filepath[]; +}; + +static void +cmd_flow_director_filter_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_flow_director_result *res = parsed_result; + int ret = 0; + struct rte_pmd_i40e_flow_type_mapping + mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; + struct rte_pmd_i40e_pkt_template_conf conf; + uint16_t flow_type = str2flowtype(res->flow_type); + uint16_t i, port = res->port_id; + uint8_t add; + + memset(&conf, 0, sizeof(conf)); + + if (flow_type == RTE_ETH_FLOW_UNKNOWN) { + fprintf(stderr, "Invalid flow type specified.\n"); + return; + } + ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, + mapping); + if (ret) + return; + if (mapping[flow_type].pctype == 0ULL) { + fprintf(stderr, "Invalid flow type specified.\n"); + return; + } + for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) { + if (mapping[flow_type].pctype & (1ULL << i)) { + conf.input.pctype = i; + break; + } + } + + conf.input.packet = open_file(res->filepath, + &conf.input.length); + if (!conf.input.packet) + return; + if (!strcmp(res->drop, "drop")) + conf.action.behavior = + RTE_PMD_I40E_PKT_TEMPLATE_REJECT; + else + conf.action.behavior = + RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT; + conf.action.report_status = + RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID; + conf.action.rx_queue = res->queue_id; + conf.soft_id = res->fd_id_value; + add = strcmp(res->ops, "del") ? 1 : 0; + ret = rte_pmd_i40e_flow_add_del_packet_template(port, + &conf, + add); + if (ret < 0) + fprintf(stderr, "flow director config error: (%s)\n", + strerror(-ret)); + close_file(conf.input.packet); +} + +cmdline_parse_token_string_t cmd_flow_director_filter = + TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, + flow_director_filter, "flow_director_filter"); +cmdline_parse_token_num_t cmd_flow_director_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, + port_id, RTE_UINT16); +cmdline_parse_token_string_t cmd_flow_director_ops = + TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, + ops, "add#del#update"); +cmdline_parse_token_string_t cmd_flow_director_flow = + TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, + flow, "flow"); +cmdline_parse_token_string_t cmd_flow_director_flow_type = + TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, + flow_type, NULL); +cmdline_parse_token_string_t cmd_flow_director_drop = + TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, + drop, "drop#fwd"); +cmdline_parse_token_string_t cmd_flow_director_queue = + TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, + queue, "queue"); +cmdline_parse_token_num_t cmd_flow_director_queue_id = + TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, + queue_id, RTE_UINT16); +cmdline_parse_token_string_t cmd_flow_director_fd_id = + TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, + fd_id, "fd_id"); +cmdline_parse_token_num_t cmd_flow_director_fd_id_value = + TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, + fd_id_value, RTE_UINT32); + +cmdline_parse_token_string_t cmd_flow_director_mode = + TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, + mode, "mode"); +cmdline_parse_token_string_t cmd_flow_director_mode_raw = + TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, + mode_value, "raw"); +cmdline_parse_token_string_t cmd_flow_director_packet = + TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, + packet, "packet"); +cmdline_parse_token_string_t cmd_flow_director_filepath = + TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, + filepath, NULL); + +cmdline_parse_inst_t cmd_add_del_raw_flow_director = { + .f = cmd_flow_director_filter_parsed, + .data = NULL, + .help_str = "flow_director_filter ... : Add or delete a raw flow " + "director entry on NIC", + .tokens = { + (void *)&cmd_flow_director_filter, + (void *)&cmd_flow_director_port_id, + (void *)&cmd_flow_director_mode, + (void *)&cmd_flow_director_mode_raw, + (void *)&cmd_flow_director_ops, + (void *)&cmd_flow_director_flow, + (void *)&cmd_flow_director_flow_type, + (void *)&cmd_flow_director_drop, + (void *)&cmd_flow_director_queue, + (void *)&cmd_flow_director_queue_id, + (void *)&cmd_flow_director_fd_id, + (void *)&cmd_flow_director_fd_id_value, + (void *)&cmd_flow_director_packet, + (void *)&cmd_flow_director_filepath, + NULL, + }, +}; + +static struct testpmd_cmdline_parser driver_parser = { + .ctx = (cmdline_parse_ctx_t[]) { + (cmdline_parse_inst_t *)&cmd_queue_region, + (cmdline_parse_inst_t *)&cmd_region_flowtype, + (cmdline_parse_inst_t *)&cmd_user_priority_region, + (cmdline_parse_inst_t *)&cmd_flush_queue_region, + (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all, + (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director, + NULL + }, + .help = { + "set port (port_id) queue-region region_id (value) " + "queue_start_index (value) queue_num (value)\n" + " Set a queue region on a port\n", + + "set port (port_id) queue-region region_id (value) " + "flowtype (value)\n" + " Set a flowtype region index on a port\n", + + "set port (port_id) queue-region UP (value) region_id (value)\n" + " Set the mapping of User Priority to " + "queue region on a port\n", + + "set port (port_id) queue-region flush (on|off)\n" + " flush all queue region related configuration\n", + + "show port (port_id) queue-region\n" + " show all queue region related configuration info\n", + + "flow_director_filter (port_id) mode raw (add|del|update)" + " flow (flow_id) (drop|fwd) queue (queue_id)" + " fd_id (fd_id_value) packet (packet file name)\n" + " Add/Del a raw type flow director filter.\n", + + NULL + }, +}; + +RTE_INIT(i40e_testpmd) +{ + testpmd_add_commands(&driver_parser); +} diff --git a/drivers/net/i40e/meson.build b/drivers/net/i40e/meson.build index efc5f93e35..b282ec7213 100644 --- a/drivers/net/i40e/meson.build +++ b/drivers/net/i40e/meson.build @@ -21,6 +21,8 @@ sources = files( 'rte_pmd_i40e.c', ) +testpmd_sources = files('i40e_testpmd.c') + deps += ['hash'] includes += include_directories('base') -- 2.23.0