From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 02B61374D for ; Sat, 31 Oct 2015 17:24:27 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 31 Oct 2015 09:24:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,224,1444719600"; d="scan'208";a="591631070" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by FMSMGA003.fm.intel.com with ESMTP; 31 Oct 2015 09:24:26 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t9VGOOhJ022291; Sun, 1 Nov 2015 00:24:24 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t9VGOL2Z002433; Sun, 1 Nov 2015 00:24:23 +0800 Received: (from wujingji@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t9VGOLL9002429; Sun, 1 Nov 2015 00:24:21 +0800 From: Jingjing Wu To: dev@dpdk.org Date: Sun, 1 Nov 2015 00:24:13 +0800 Message-Id: <1446308653-2378-4-git-send-email-jingjing.wu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1446308653-2378-1-git-send-email-jingjing.wu@intel.com> References: <1446021688-17544-1-git-send-email-jingjing.wu@intel.com> <1446308653-2378-1-git-send-email-jingjing.wu@intel.com> Subject: [dpdk-dev] [PATCH v3 3/3] testpmd: extend commands X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2015 16:24:28 -0000 This patch extends commands to support filtering in VFs of flow director. Signed-off-by: Jingjing Wu --- app/test-pmd/cmdline.c | 41 ++++++++++++++++++++++++++--- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 15 ++++++----- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index b3c36f3..7824d5c 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -631,7 +631,8 @@ static void cmd_help_long_parsed(void *parsed_result, " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)" " src (src_ip_address) dst (dst_ip_address)" " vlan (vlan_value) flexbytes (flexbytes_value)" - " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n" + " (drop|fwd) pf|vf(vf_id) queue (queue_id)" + " fd_id (fd_id_value)\n" " Add/Del an IP type flow director filter.\n\n" "flow_director_filter (port_id) (add|del|update)" @@ -639,7 +640,8 @@ static void cmd_help_long_parsed(void *parsed_result, " src (src_ip_address) (src_port)" " dst (dst_ip_address) (dst_port)" " vlan (vlan_value) flexbytes (flexbytes_value)" - " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n" + " (drop|fwd) pf|vf(vf_id) queue (queue_id)" + " fd_id (fd_id_value)\n" " Add/Del an UDP/TCP type flow director filter.\n\n" "flow_director_filter (port_id) (add|del|update)" @@ -648,13 +650,13 @@ static void cmd_help_long_parsed(void *parsed_result, " dst (dst_ip_address) (dst_port)" " tag (verification_tag) vlan (vlan_value)" " flexbytes (flexbytes_value) (drop|fwd)" - " queue (queue_id) fd_id (fd_id_value)\n" + " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" " Add/Del a SCTP type flow director filter.\n\n" "flow_director_filter (port_id) (add|del|update)" " flow l2_payload ether (ethertype)" " flexbytes (flexbytes_value) (drop|fwd)" - " queue (queue_id) fd_id (fd_id_value)\n" + " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" " Add/Del a l2 payload type flow director filter.\n\n" "flush_flow_director (port_id)\n" @@ -7744,6 +7746,7 @@ struct cmd_flow_director_result { uint16_t vlan_value; cmdline_fixed_string_t flexbytes; cmdline_fixed_string_t flexbytes_value; + cmdline_fixed_string_t pf_vf; cmdline_fixed_string_t drop; cmdline_fixed_string_t queue; uint16_t queue_id; @@ -7876,6 +7879,8 @@ cmd_flow_director_filter_parsed(void *parsed_result, struct cmd_flow_director_result *res = parsed_result; struct rte_eth_fdir_filter entry; uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN]; + char *end; + unsigned long vf_id; int ret = 0; ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); @@ -8002,6 +8007,27 @@ cmd_flow_director_filter_parsed(void *parsed_result, entry.action.behavior = RTE_ETH_FDIR_REJECT; else entry.action.behavior = RTE_ETH_FDIR_ACCEPT; + + if (!strcmp(res->pf_vf, "pf")) + entry.input.flow_ext.is_vf = 0; + else if (!strncmp(res->pf_vf, "vf", 2)) { + struct rte_eth_dev_info dev_info; + + memset(&dev_info, 0, sizeof(dev_info)); + rte_eth_dev_info_get(res->port_id, &dev_info); + errno = 0; + vf_id = strtoul(res->pf_vf + 2, &end, 10); + if (errno != 0 || *end != '\0' || vf_id >= dev_info.max_vfs) { + printf("invalid parameter %s.\n", res->pf_vf); + return; + } + entry.input.flow_ext.is_vf = 1; + entry.input.flow_ext.dst_id = (uint16_t)vf_id; + } else { + printf("invalid parameter %s.\n", res->pf_vf); + return; + } + /* set to report FD ID by default */ entry.action.report_status = RTE_ETH_FDIR_REPORT_ID; entry.action.rx_queue = res->queue_id; @@ -8081,6 +8107,9 @@ cmdline_parse_token_string_t cmd_flow_director_flexbytes_value = 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_pf_vf = + TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, + pf_vf, NULL); cmdline_parse_token_string_t cmd_flow_director_queue = TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, queue, "queue"); @@ -8146,6 +8175,7 @@ cmdline_parse_inst_t cmd_add_del_ip_flow_director = { (void *)&cmd_flow_director_flexbytes, (void *)&cmd_flow_director_flexbytes_value, (void *)&cmd_flow_director_drop, + (void *)&cmd_flow_director_pf_vf, (void *)&cmd_flow_director_queue, (void *)&cmd_flow_director_queue_id, (void *)&cmd_flow_director_fd_id, @@ -8177,6 +8207,7 @@ cmdline_parse_inst_t cmd_add_del_udp_flow_director = { (void *)&cmd_flow_director_flexbytes, (void *)&cmd_flow_director_flexbytes_value, (void *)&cmd_flow_director_drop, + (void *)&cmd_flow_director_pf_vf, (void *)&cmd_flow_director_queue, (void *)&cmd_flow_director_queue_id, (void *)&cmd_flow_director_fd_id, @@ -8210,6 +8241,7 @@ cmdline_parse_inst_t cmd_add_del_sctp_flow_director = { (void *)&cmd_flow_director_flexbytes, (void *)&cmd_flow_director_flexbytes_value, (void *)&cmd_flow_director_drop, + (void *)&cmd_flow_director_pf_vf, (void *)&cmd_flow_director_queue, (void *)&cmd_flow_director_queue_id, (void *)&cmd_flow_director_fd_id, @@ -8235,6 +8267,7 @@ cmdline_parse_inst_t cmd_add_del_l2_flow_director = { (void *)&cmd_flow_director_flexbytes, (void *)&cmd_flow_director_flexbytes_value, (void *)&cmd_flow_director_drop, + (void *)&cmd_flow_director_pf_vf, (void *)&cmd_flow_director_queue, (void *)&cmd_flow_director_queue_id, (void *)&cmd_flow_director_fd_id, diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 71d831b..eae5249 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -1644,14 +1644,16 @@ Different NICs may have different capabilities, command show port fdir (port_id) flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag) src (src_ip_address) dst (dst_ip_address) \ vlan (vlan_value) flexbytes (flexbytes_value) \ - (drop|fwd) queue (queue_id) fd_id (fd_id_value) + (drop|fwd) pf|vf(vf_id) queue (queue_id) \ + fd_id (fd_id_value) flow_director_filter (port_id) (add|del|update) \ flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp) \ src (src_ip_address) (src_port) \ dst (dst_ip_address) (dst_port) \ vlan (vlan_value) flexbytes (flexbytes_value) \ - (drop|fwd) queue (queue_id) fd_id (fd_id_value) + (drop|fwd) queue pf|vf(vf_id) (queue_id) \ + fd_id (fd_id_value) flow_director_filter (port_id) (add|del|update) \ flow (ipv4-sctp|ipv6-sctp) \ @@ -1659,21 +1661,22 @@ Different NICs may have different capabilities, command show port fdir (port_id) dst (dst_ip_address) (dst_port) tag (verification_tag) vlan (vlan_value) \ flexbytes (flexbytes_value) (drop|fwd) \ - queue (queue_id) fd_id (fd_id_value) + pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value) flow_director_filter (port_id) (add|del|update) flow l2_payload \ ether (ethertype) flexbytes (flexbytes_value) \ - (drop|fwd) queue (queue_id) fd_id (fd_id_value) + (drop|fwd) pf|vf(vf_id) queue (queue_id) + fd_id (fd_id_value) For example, to add an ipv4-udp flow type filter:: testpmd> flow_director_filter 0 add flow ipv4-udp src 2.2.2.3 32 \ - dst 2.2.2.5 33 vlan 0x1 flexbytes (0x88,0x48) fwd queue 1 fd_id 1 + dst 2.2.2.5 33 vlan 0x1 flexbytes (0x88,0x48) fwd pf queue 1 fd_id 1 For example, add an ipv4-other flow type filter:: testpmd> flow_director_filter 0 add flow ipv4-other src 2.2.2.3 \ - dst 2.2.2.5 vlan 0x1 flexbytes (0x88,0x48) fwd queue 1 fd_id 1 + dst 2.2.2.5 vlan 0x1 flexbytes (0x88,0x48) fwd pf queue 1 fd_id 1 flush_flow_director ~~~~~~~~~~~~~~~~~~~ -- 2.4.0