From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id C65127FD3 for ; Fri, 21 Nov 2014 01:37:20 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 20 Nov 2014 16:45:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,426,1413270000"; d="scan'208";a="611514822" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 20 Nov 2014 16:47:51 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id sAL0lnca004709; Fri, 21 Nov 2014 08:47:49 +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 sAL0llrs002349; Fri, 21 Nov 2014 08:47:49 +0800 Received: (from wujingji@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id sAL0lkqO002345; Fri, 21 Nov 2014 08:47:46 +0800 From: Jingjing Wu To: dev@dpdk.org Date: Fri, 21 Nov 2014 08:46:56 +0800 Message-Id: <1416530816-2159-23-git-send-email-jingjing.wu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1416530816-2159-1-git-send-email-jingjing.wu@intel.com> References: <1414654006-7472-1-git-send-email-jingjing.wu@intel.com> <1416530816-2159-1-git-send-email-jingjing.wu@intel.com> Subject: [dpdk-dev] [PATCH v6 22/22] testpmd: add test command to configure flexible payload 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: Fri, 21 Nov 2014 00:37:22 -0000 Test command is added to configure flexible payload Signed-off-by: jingjing.wu --- app/test-pmd/cmdline.c | 120 +++++++++++++++++++++++++++++++++++++++++++++++++ app/test-pmd/config.c | 31 +++++++++++++ app/test-pmd/testpmd.h | 2 + 3 files changed, 153 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index bb10b9f..eed28b7 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -714,6 +714,10 @@ static void cmd_help_long_parsed(void *parsed_result, " flow (ip4|ip4-frag|tcp4|udp4|sctp4|ip6|ip6-frag|tcp6|udp6|sctp6|all)" " (mask)\n" " Configure mask of flex payload.\n\n" + + "flow_director_flex_payload (port_id)" + " (l2|l3|l4) (config)\n" + " Configure flex payload selection.\n\n" ); } } @@ -8264,6 +8268,121 @@ cmdline_parse_inst_t cmd_set_flow_director_flex_mask = { }, }; +/* *** deal with flow director flexible payload configuration *** */ +struct cmd_flow_director_flexpayload_result { + cmdline_fixed_string_t flow_director_flexpayload; + uint8_t port_id; + cmdline_fixed_string_t payload_layer; + cmdline_fixed_string_t payload_cfg; +}; + +static inline int +parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num) +{ + char s[256]; + const char *p, *p0 = q_arg; + char *end; + unsigned long int_fld; + char *str_fld[max_num]; + int i; + unsigned size; + int ret = -1; + + p = strchr(p0, '('); + if (p == NULL) + return -1; + ++p; + p0 = strchr(p, ')'); + if (p0 == NULL) + return -1; + + size = p0 - p; + if (size >= sizeof(s)) + return -1; + + snprintf(s, sizeof(s), "%.*s", size, p); + ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); + if (ret < 0 || ret > max_num) + return -1; + for (i = 0; i < ret; i++) { + errno = 0; + int_fld = strtoul(str_fld[i], &end, 0); + if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX) + return -1; + offsets[i] = (uint16_t)int_fld; + } + return ret; +} + +static void +cmd_flow_director_flxpld_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_flow_director_flexpayload_result *res = parsed_result; + struct rte_eth_flex_payload_cfg flex_cfg; + struct rte_port *port; + int ret = 0; + + if (res->port_id > nb_ports) { + printf("Invalid port, range is [0, %d]\n", nb_ports - 1); + return; + } + + port = &ports[res->port_id]; + /** Check if the port is not started **/ + if (port->port_status != RTE_PORT_STOPPED) { + printf("Please stop port %d first\n", res->port_id); + return; + } + + memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg)); + + if (!strcmp(res->payload_layer, "l2")) + flex_cfg.type = RTE_ETH_L2_PAYLOAD; + else if (!strcmp(res->payload_layer, "l3")) + flex_cfg.type = RTE_ETH_L3_PAYLOAD; + else if (!strcmp(res->payload_layer, "l4")) + flex_cfg.type = RTE_ETH_L4_PAYLOAD; + + ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset, + RTE_ETH_FDIR_MAX_FLEXLEN); + if (ret < 0) { + printf("error: Cannot parse flex payload input.\n"); + return; + } + + fdir_set_flex_payload(res->port_id, &flex_cfg); + cmd_reconfig_device_queue(res->port_id, 1, 0); +} + +cmdline_parse_token_string_t cmd_flow_director_flexpayload = + TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, + flow_director_flexpayload, + "flow_director_flex_payload"); +cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result, + port_id, UINT8); +cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer = + TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, + payload_layer, "l2#l3#l4"); +cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg = + TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, + payload_cfg, NULL); + +cmdline_parse_inst_t cmd_set_flow_director_flex_payload = { + .f = cmd_flow_director_flxpld_parsed, + .data = NULL, + .help_str = "set flow director's flex payload on NIC", + .tokens = { + (void *)&cmd_flow_director_flexpayload, + (void *)&cmd_flow_director_flexpayload_port_id, + (void *)&cmd_flow_director_flexpayload_payload_layer, + (void *)&cmd_flow_director_flexpayload_payload_cfg, + NULL, + }, +}; + /* ******************************************************************************** */ /* list of instructions */ @@ -8398,6 +8517,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director, (cmdline_parse_inst_t *)&cmd_flush_flow_director, (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask, + (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload, NULL, }; diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index e1ac901..694d630 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -2051,6 +2051,37 @@ fdir_set_flex_mask(portid_t port_id, struct rte_eth_fdir_flex_mask *cfg) } void +fdir_set_flex_payload(portid_t port_id, struct rte_eth_flex_payload_cfg *cfg) +{ + struct rte_port *port; + struct rte_eth_fdir_flex_conf *flex_conf; + int i, idx = 0; + + port = &ports[port_id]; + flex_conf = &port->dev_conf.fdir_conf.flex_conf; + for (i = 0; i < RTE_ETH_PAYLOAD_MAX; i++) { + if (cfg->type == flex_conf->flex_set[i].type) { + idx = i; + break; + } + } + if (i >= RTE_ETH_PAYLOAD_MAX) { + if (flex_conf->nb_payloads < RTE_DIM(flex_conf->flex_set)) { + idx = flex_conf->nb_payloads; + flex_conf->nb_payloads++; + } else { + printf("The flex payload table is full. Can not set" + " flex payload for type(%u).", cfg->type); + return; + } + } + (void)rte_memcpy(&flex_conf->flex_set[idx], + cfg, + sizeof(struct rte_eth_flex_payload_cfg)); + +} + +void set_vf_traffic(portid_t port_id, uint8_t is_rx, uint16_t vf, uint8_t on) { int diag; diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 05a65d4..072aa57 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -534,6 +534,8 @@ void fdir_remove_perfect_filter(portid_t port_id, uint16_t soft_id, void fdir_set_masks(portid_t port_id, struct rte_fdir_masks *fdir_masks); void fdir_set_flex_mask(portid_t port_id, struct rte_eth_fdir_flex_mask *cfg); +void fdir_set_flex_payload(portid_t port_id, + struct rte_eth_flex_payload_cfg *cfg); void port_rss_reta_info(portid_t port_id, struct rte_eth_rss_reta *reta_conf); void set_vf_traffic(portid_t port_id, uint8_t is_rx, uint16_t vf, uint8_t on); -- 1.8.1.4