From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 7CB3658D7 for ; Mon, 13 Oct 2014 17:51:00 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 13 Oct 2014 08:58:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,711,1406617200"; d="scan'208";a="613705320" Received: from irsmsx103.ger.corp.intel.com ([163.33.3.157]) by fmsmga002.fm.intel.com with ESMTP; 13 Oct 2014 08:58:38 -0700 Received: from irsmsx154.ger.corp.intel.com (163.33.192.96) by IRSMSX103.ger.corp.intel.com (163.33.3.157) with Microsoft SMTP Server (TLS) id 14.3.195.1; Mon, 13 Oct 2014 16:58:11 +0100 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.21]) by IRSMSX154.ger.corp.intel.com ([169.254.12.124]) with mapi id 14.03.0195.001; Mon, 13 Oct 2014 16:58:11 +0100 From: "De Lara Guarch, Pablo" To: "Wu, Jingjing" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v3 20/20] app/test-pmd: add test command to configure flexible masks Thread-Index: AQHP2U/5rw2OJohV00mVac8iT5JN4JwuRXyQ Date: Mon, 13 Oct 2014 15:58:10 +0000 Message-ID: References: <1411711418-12881-1-git-send-email-jingjing.wu@intel.com> <1411711418-12881-21-git-send-email-jingjing.wu@intel.com> In-Reply-To: <1411711418-12881-21-git-send-email-jingjing.wu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v3 20/20] app/test-pmd: add test command to configure flexible masks 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: Mon, 13 Oct 2014 15:51:01 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jingjing Wu > Sent: Friday, September 26, 2014 7:04 AM > To: dev@dpdk.org > Subject: [dpdk-dev] [PATCH v3 20/20] app/test-pmd: add test command to > configure flexible masks >=20 > add test command to configure flexible masks for each flow type >=20 > Signed-off-by: Jingjing Wu > Acked-by: Chen Jing D(Mark) > Acked-by: Helin Zhang > --- > app/test-pmd/cmdline.c | 173 > +++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 173 insertions(+) >=20 > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c > index da77752..073b929 100644 > --- a/app/test-pmd/cmdline.c > +++ b/app/test-pmd/cmdline.c > @@ -690,6 +690,11 @@ static void cmd_help_long_parsed(void > *parsed_result, > "flow_director_flex_payload (port_id)" > " (l2|l3|l4) (config)\n" > " configure flexible payload selection.\n\n" > + > + "flow_director_flex_mask (port_id)" > + " flow > (ether|ip4|tcp4|udp4|sctp4|ip6|tcp6|udp6|sctp6)" > + " words_mask (words) (word_mask_list)" > + " configure masks of flexible payload.\n\n" > ); > } > } > @@ -8046,6 +8051,173 @@ cmdline_parse_inst_t > cmd_set_flow_director_flex_payload =3D { > }, > }; >=20 > +/* *** deal with flow director mask on flexible payload *** */ > +struct cmd_flow_director_flex_mask_result { > + cmdline_fixed_string_t flow_director_flexmask; > + uint8_t port_id; > + cmdline_fixed_string_t flow; > + cmdline_fixed_string_t flow_type; > + cmdline_fixed_string_t words_mask; > + uint8_t words; > + cmdline_fixed_string_t word_mask_list; > +}; > + > +static inline int > +parse_word_masks_cfg(const char *q_arg, > + struct rte_eth_fdir_flex_masks *masks) > +{ > + char s[256]; > + const char *p, *p0 =3D q_arg; > + char *end; > + enum fieldnames { > + FLD_OFFSET =3D 0, > + FLD_MASK, > + _NUM_FLD > + }; > + unsigned long int_fld[_NUM_FLD]; > + char *str_fld[_NUM_FLD]; > + int i; > + unsigned size; > + > + masks->nb_field =3D 0; > + p =3D strchr(p0, '('); > + while (p !=3D NULL) { > + ++p; > + p0 =3D strchr(p, ')'); > + if (p0 =3D=3D NULL) > + return -1; > + > + size =3D p0 - p; > + if (size >=3D sizeof(s)) > + return -1; > + > + snprintf(s, sizeof(s), "%.*s", size, p); > + if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') !=3D > _NUM_FLD) > + return -1; > + for (i =3D 0; i < _NUM_FLD; i++) { > + errno =3D 0; > + int_fld[i] =3D strtoul(str_fld[i], &end, 0); > + if (errno !=3D 0 || end =3D=3D str_fld[i] || int_fld[i] > > UINT16_MAX) > + return -1; > + } > + masks->field[masks->nb_field].offset =3D > + (uint16_t)int_fld[FLD_OFFSET]; > + masks->field[masks->nb_field].bitmask =3D > + ~(uint16_t)int_fld[FLD_MASK]; > + masks->nb_field++; > + if (masks->nb_field > 2) { > + printf("exceeded max number of fields: %hu\n", > + masks->nb_field); masks->nb_field is an uint8_t, so you should change from %hu to %hhu or %PR= Iu8. > + return -1; > + } > + p =3D strchr(p0, '('); > + } > + return 0; > +} > + > +static void > +cmd_flow_director_flex_mask_parsed(void *parsed_result, > + __attribute__((unused)) struct cmdline *cl, > + __attribute__((unused)) void *data) > +{ > + struct cmd_flow_director_flex_mask_result *res =3D parsed_result; > + struct rte_eth_fdir_flex_masks *flex_masks; > + struct rte_eth_fdir_cfg fdir_cfg; > + int ret =3D 0; > + int cfg_size =3D 2 * sizeof(struct rte_eth_flex_mask) + > + offsetof(struct rte_eth_fdir_flex_masks, field); > + > + ret =3D rte_eth_dev_filter_supported(res->port_id, > RTE_ETH_FILTER_FDIR); > + if (ret < 0) { > + printf("flow director is not supported on port %u.\n", > + res->port_id); > + return; > + } > + > + memset(&fdir_cfg, 0, sizeof(struct rte_eth_fdir_cfg)); > + > + flex_masks =3D (struct rte_eth_fdir_flex_masks > *)rte_zmalloc_socket("CLI", > + cfg_size, CACHE_LINE_SIZE, rte_socket_id()); > + > + if (flex_masks =3D=3D NULL) { > + printf("fail to malloc memory to configure flexi masks\n"); > + return; > + } > + > + if (!strcmp(res->flow_type, "ip4")) > + flex_masks->flow_type =3D > RTE_ETH_FLOW_TYPE_IPV4_OTHER; > + else if (!strcmp(res->flow_type, "udp4")) > + flex_masks->flow_type =3D RTE_ETH_FLOW_TYPE_UDPV4; > + else if (!strcmp(res->flow_type, "tcp4")) > + flex_masks->flow_type =3D RTE_ETH_FLOW_TYPE_TCPV4; > + else if (!strcmp(res->flow_type, "sctp4")) > + flex_masks->flow_type =3D RTE_ETH_FLOW_TYPE_SCTPV4; > + else if (!strcmp(res->flow_type, "ip6")) > + flex_masks->flow_type =3D > RTE_ETH_FLOW_TYPE_IPV6_OTHER; > + else if (!strcmp(res->flow_type, "udp6")) > + flex_masks->flow_type =3D RTE_ETH_FLOW_TYPE_UDPV6; > + else if (!strcmp(res->flow_type, "tcp6")) > + flex_masks->flow_type =3D RTE_ETH_FLOW_TYPE_TCPV6; > + else if (!strcmp(res->flow_type, "sctp6")) > + flex_masks->flow_type =3D RTE_ETH_FLOW_TYPE_SCTPV6; > + > + flex_masks->words_mask =3D res->words; > + ret =3D parse_word_masks_cfg(res->word_mask_list, flex_masks); > + if (ret < 0) { > + printf("fdir flex masks error\n"); > + rte_free(flex_masks); > + return; > + } > + > + fdir_cfg.cmd =3D RTE_ETH_FDIR_CFG_FLX_MASK; > + fdir_cfg.cfg =3D flex_masks; > + ret =3D rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, > + RTE_ETH_FILTER_OP_SET, &fdir_cfg); > + if (ret < 0) > + printf("fdir flex mask setting error: (%s)\n", strerror(-ret)); > + rte_free(flex_masks); > +} > + > +cmdline_parse_token_string_t cmd_flow_director_flexmask =3D > + TOKEN_STRING_INITIALIZER(struct > cmd_flow_director_flex_mask_result, > + flow_director_flexmask, > + "flow_director_flex_mask"); > +cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =3D > + TOKEN_NUM_INITIALIZER(struct > cmd_flow_director_flex_mask_result, > + port_id, UINT8); > +cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =3D > + TOKEN_STRING_INITIALIZER(struct > cmd_flow_director_flex_mask_result, > + flow, "flow"); > +cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =3D > + TOKEN_STRING_INITIALIZER(struct > cmd_flow_director_flex_mask_result, > + flow_type, > + > "ip4#tcp4#udp4#sctp4#ip6#tcp6#udp6#sctp6"); > +cmdline_parse_token_string_t cmd_flow_director_flexmask_words_mask > =3D > + TOKEN_STRING_INITIALIZER(struct > cmd_flow_director_flex_mask_result, > + words_mask, "words_mask"); > +cmdline_parse_token_num_t cmd_flow_director_flexmask_words =3D > + TOKEN_NUM_INITIALIZER(struct > cmd_flow_director_flex_mask_result, > + words, UINT8); > +cmdline_parse_token_string_t > cmd_flow_director_flexmask_word_mask_list =3D > + TOKEN_STRING_INITIALIZER(struct > cmd_flow_director_flex_mask_result, > + word_mask_list, NULL); > + > +cmdline_parse_inst_t cmd_set_flow_director_flex_mask =3D { > + .f =3D cmd_flow_director_flex_mask_parsed, > + .data =3D NULL, > + .help_str =3D "set flow director's flex masks on NIC", > + .tokens =3D { > + (void *)&cmd_flow_director_flexmask, > + (void *)&cmd_flow_director_flexmask_port_id, > + (void *)&cmd_flow_director_flexmask_flow, > + (void *)&cmd_flow_director_flexmask_flow_type, > + (void *)&cmd_flow_director_flexmask_words_mask, > + (void *)&cmd_flow_director_flexmask_words, > + (void *)&cmd_flow_director_flexmask_word_mask_list, > + NULL, > + }, > +}; > + > /* > ********************************************************** > ********************** */ >=20 > /* list of instructions */ > @@ -8177,6 +8349,7 @@ cmdline_parse_ctx_t main_ctx[] =3D { > (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_payload, > + (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask, > NULL, > }; >=20 > -- > 1.8.1.4