From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 64E87FB07 for ; Tue, 20 Dec 2016 10:21:33 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP; 20 Dec 2016 01:21:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,378,1477983600"; d="scan'208";a="1084495963" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga001.fm.intel.com with ESMTP; 20 Dec 2016 01:21:31 -0800 Received: from fmsmsx111.amr.corp.intel.com (10.18.116.5) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 20 Dec 2016 01:21:31 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx111.amr.corp.intel.com (10.18.116.5) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 20 Dec 2016 01:21:31 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.54]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.97]) with mapi id 14.03.0248.002; Tue, 20 Dec 2016 17:21:29 +0800 From: "Pei, Yulong" To: Adrien Mazarguil , "dev@dpdk.org" CC: "Xing, Beilei" Thread-Topic: [dpdk-dev] [PATCH v3 21/25] app/testpmd: add items ipv4/ipv6 to flow command Thread-Index: AQHSWiEaan071aHvBEe+27PFU6ka3KEQj9HQ Date: Tue, 20 Dec 2016 09:21:28 +0000 Message-ID: <188971FCDA171749BED5DA74ABF3E6F03B66D4AB@shsmsx102.ccr.corp.intel.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMTY0ZjhkZTAtZTdjMi00NDU3LTlmNzktYzg4NDNkZTFiOTE3IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6InVNbWxXdlM5eHNkV0tZRjJEekd1YzYyNG1tTlM4OG1pMlFJUWFMMjlnWWc9In0= x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v3 21/25] app/testpmd: add items ipv4/ipv6 to flow command X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Dec 2016 09:21:34 -0000 Hi adrien, Is it possible to support to set ipv4 TOS, ipv4 PROTO, ipv4 TTL and ipv6 tc= , ipv6 next-header, ipv6 hop-limits since=20 previous FDIR for i40e already support it. Best Regards Yulong Pei -----Original Message----- From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Adrien Mazarguil Sent: Tuesday, December 20, 2016 1:49 AM To: dev@dpdk.org Subject: [dpdk-dev] [PATCH v3 21/25] app/testpmd: add items ipv4/ipv6 to fl= ow command Add the ability to match basic fields from IPv4 and IPv6 headers (source an= d destination addresses only). Signed-off-by: Adrien Mazarguil Acked-by: Olga Shern --- app/test-pmd/cmdline_flow.c | 177 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 177 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c inde= x 53709fe..c2725a5 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -38,6 +38,7 @@ #include #include #include +#include =20 #include #include @@ -61,6 +62,8 @@ enum index { BOOLEAN, STRING, MAC_ADDR, + IPV4_ADDR, + IPV6_ADDR, RULE_ID, PORT_ID, GROUP_ID, @@ -123,6 +126,12 @@ enum index { ITEM_VLAN, ITEM_VLAN_TPID, ITEM_VLAN_TCI, + ITEM_IPV4, + ITEM_IPV4_SRC, + ITEM_IPV4_DST, + ITEM_IPV6, + ITEM_IPV6_SRC, + ITEM_IPV6_DST, =20 /* Validate/create actions. */ ACTIONS, @@ -348,6 +357,8 @@ static const enum index next_item[] =3D { ITEM_RAW, ITEM_ETH, ITEM_VLAN, + ITEM_IPV4, + ITEM_IPV6, ZERO, }; =20 @@ -394,6 +405,20 @@ static const enum index item_vlan[] =3D { ZERO, }; =20 +static const enum index item_ipv4[] =3D { + ITEM_IPV4_SRC, + ITEM_IPV4_DST, + ITEM_NEXT, + ZERO, +}; + +static const enum index item_ipv6[] =3D { + ITEM_IPV6_SRC, + ITEM_IPV6_DST, + ITEM_NEXT, + ZERO, +}; + static const enum index next_action[] =3D { ACTION_END, ACTION_VOID, @@ -439,6 +464,12 @@ static int parse_string(struct context *, const struct= token *, static int parse_mac_addr(struct context *, const struct token *= , const char *, unsigned int, void *, unsigned int); +static int parse_ipv4_addr(struct context *, const struct token *, + const char *, unsigned int, + void *, unsigned int); +static int parse_ipv6_addr(struct context *, const struct token *, + const char *, unsigned int, + void *, unsigned int); static int parse_port(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); @@ -509,6 +540,20 @@ static const struct token token_list[] =3D { .call =3D parse_mac_addr, .comp =3D comp_none, }, + [IPV4_ADDR] =3D { + .name =3D "{IPv4 address}", + .type =3D "IPV4 ADDRESS", + .help =3D "standard IPv4 address notation", + .call =3D parse_ipv4_addr, + .comp =3D comp_none, + }, + [IPV6_ADDR] =3D { + .name =3D "{IPv6 address}", + .type =3D "IPV6 ADDRESS", + .help =3D "standard IPv6 address notation", + .call =3D parse_ipv6_addr, + .comp =3D comp_none, + }, [RULE_ID] =3D { .name =3D "{rule id}", .type =3D "RULE ID", @@ -843,6 +888,48 @@ static const struct token token_list[] =3D { .next =3D NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param), .args =3D ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)), }, + [ITEM_IPV4] =3D { + .name =3D "ipv4", + .help =3D "match IPv4 header", + .priv =3D PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)), + .next =3D NEXT(item_ipv4), + .call =3D parse_vc, + }, + [ITEM_IPV4_SRC] =3D { + .name =3D "src", + .help =3D "source address", + .next =3D NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param), + .args =3D ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4, + hdr.src_addr)), + }, + [ITEM_IPV4_DST] =3D { + .name =3D "dst", + .help =3D "destination address", + .next =3D NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param), + .args =3D ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4, + hdr.dst_addr)), + }, + [ITEM_IPV6] =3D { + .name =3D "ipv6", + .help =3D "match IPv6 header", + .priv =3D PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)), + .next =3D NEXT(item_ipv6), + .call =3D parse_vc, + }, + [ITEM_IPV6_SRC] =3D { + .name =3D "src", + .help =3D "source address", + .next =3D NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param), + .args =3D ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6, + hdr.src_addr)), + }, + [ITEM_IPV6_DST] =3D { + .name =3D "dst", + .help =3D "destination address", + .next =3D NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param), + .args =3D ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6, + hdr.dst_addr)), + }, /* Validate/create actions. */ [ACTIONS] =3D { .name =3D "actions", @@ -1514,6 +1601,96 @@ parse_mac_addr(struct context *ctx, const struct tok= en *token, return -1; } =20 +/** + * Parse an IPv4 address. + * + * Last argument (ctx->args) is retrieved to determine storage size and + * location. + */ +static int +parse_ipv4_addr(struct context *ctx, const struct token *token, + const char *str, unsigned int len, + void *buf, unsigned int size) +{ + const struct arg *arg =3D pop_args(ctx); + char str2[len + 1]; + struct in_addr tmp; + int ret; + + /* Argument is expected. */ + if (!arg) + return -1; + size =3D arg->size; + /* Bit-mask fill is not supported. */ + if (arg->mask || size !=3D sizeof(tmp)) + goto error; + /* Only network endian is supported. */ + if (!arg->hton) + goto error; + memcpy(str2, str, len); + str2[len] =3D '\0'; + ret =3D inet_pton(AF_INET, str2, &tmp); + if (ret !=3D 1) { + /* Attempt integer parsing. */ + push_args(ctx, arg); + return parse_int(ctx, token, str, len, buf, size); + } + if (!ctx->object) + return len; + buf =3D (uint8_t *)ctx->object + arg->offset; + memcpy(buf, &tmp, size); + if (ctx->objmask) + memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size); + return len; +error: + push_args(ctx, arg); + return -1; +} + +/** + * Parse an IPv6 address. + * + * Last argument (ctx->args) is retrieved to determine storage size and + * location. + */ +static int +parse_ipv6_addr(struct context *ctx, const struct token *token, + const char *str, unsigned int len, + void *buf, unsigned int size) +{ + const struct arg *arg =3D pop_args(ctx); + char str2[len + 1]; + struct in6_addr tmp; + int ret; + + (void)token; + /* Argument is expected. */ + if (!arg) + return -1; + size =3D arg->size; + /* Bit-mask fill is not supported. */ + if (arg->mask || size !=3D sizeof(tmp)) + goto error; + /* Only network endian is supported. */ + if (!arg->hton) + goto error; + memcpy(str2, str, len); + str2[len] =3D '\0'; + ret =3D inet_pton(AF_INET6, str2, &tmp); + if (ret !=3D 1) + goto error; + if (!ctx->object) + return len; + buf =3D (uint8_t *)ctx->object + arg->offset; + memcpy(buf, &tmp, size); + if (ctx->objmask) + memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size); + return len; +error: + push_args(ctx, arg); + return -1; +} + /** Boolean values (even indices stand for false). */ static const char *= const boolean_name[] =3D { "0", "1", -- 2.1.4