From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Pei, Yulong" Subject: Re: [PATCH v3 22/25] app/testpmd: add L4 items to flow command Date: Tue, 20 Dec 2016 09:14:55 +0000 Message-ID: <188971FCDA171749BED5DA74ABF3E6F03B66D499@shsmsx102.ccr.corp.intel.com> References: <11827edfa78272fe967e5a53451a3f48c6d7d17a.1482168851.git.adrien.mazarguil@6wind.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: "Xing, Beilei" To: Adrien Mazarguil , "dev@dpdk.org" Return-path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 97529FB00 for ; Tue, 20 Dec 2016 10:15:00 +0100 (CET) In-Reply-To: <11827edfa78272fe967e5a53451a3f48c6d7d17a.1482168851.git.adrien.mazarguil@6wind.com> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Adrien, For SCTP, it may need support to set 'tag' since in FDIR (--pkt-filter-mo= de=3Dperfect) need set it when filter sctp flow. struct sctp_hdr { uint16_t src_port; /**< Source port. */ uint16_t dst_port; /**< Destin port. */ uint32_t tag; /**< Validation tag. */ uint32_t cksum; /**< Checksum. */ } __attribute__((__packed__)); testpmd> flow create 0 ingress pattern eth / ipv4 src is 192.168.0.1 dst is= 192.168.0.2 / sctp src [TOKEN]: SCTP source port dst [TOKEN]: SCTP destination port / [TOKEN]: specify next pattern item 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 22/25] app/testpmd: add L4 items to flow comm= and Add the ability to match a few properties of common L4[.5] protocol headers: - ICMP: type and code. - UDP: source and destination ports. - TCP: source and destination ports. - SCTP: source and destination ports. - VXLAN: network identifier. Signed-off-by: Adrien Mazarguil Acked-by: Olga Shern --- app/test-pmd/cmdline_flow.c | 163 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c inde= x c2725a5..a340a75 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -132,6 +132,20 @@ enum index { ITEM_IPV6, ITEM_IPV6_SRC, ITEM_IPV6_DST, + ITEM_ICMP, + ITEM_ICMP_TYPE, + ITEM_ICMP_CODE, + ITEM_UDP, + ITEM_UDP_SRC, + ITEM_UDP_DST, + ITEM_TCP, + ITEM_TCP_SRC, + ITEM_TCP_DST, + ITEM_SCTP, + ITEM_SCTP_SRC, + ITEM_SCTP_DST, + ITEM_VXLAN, + ITEM_VXLAN_VNI, =20 /* Validate/create actions. */ ACTIONS, @@ -359,6 +373,11 @@ static const enum index next_item[] =3D { ITEM_VLAN, ITEM_IPV4, ITEM_IPV6, + ITEM_ICMP, + ITEM_UDP, + ITEM_TCP, + ITEM_SCTP, + ITEM_VXLAN, ZERO, }; =20 @@ -419,6 +438,40 @@ static const enum index item_ipv6[] =3D { ZERO, }; =20 +static const enum index item_icmp[] =3D { + ITEM_ICMP_TYPE, + ITEM_ICMP_CODE, + ITEM_NEXT, + ZERO, +}; + +static const enum index item_udp[] =3D { + ITEM_UDP_SRC, + ITEM_UDP_DST, + ITEM_NEXT, + ZERO, +}; + +static const enum index item_tcp[] =3D { + ITEM_TCP_SRC, + ITEM_TCP_DST, + ITEM_NEXT, + ZERO, +}; + +static const enum index item_sctp[] =3D { + ITEM_SCTP_SRC, + ITEM_SCTP_DST, + ITEM_NEXT, + ZERO, +}; + +static const enum index item_vxlan[] =3D { + ITEM_VXLAN_VNI, + ITEM_NEXT, + ZERO, +}; + static const enum index next_action[] =3D { ACTION_END, ACTION_VOID, @@ -930,6 +983,103 @@ static const struct token token_list[] =3D { .args =3D ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6, hdr.dst_addr)), }, + [ITEM_ICMP] =3D { + .name =3D "icmp", + .help =3D "match ICMP header", + .priv =3D PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)), + .next =3D NEXT(item_icmp), + .call =3D parse_vc, + }, + [ITEM_ICMP_TYPE] =3D { + .name =3D "type", + .help =3D "ICMP packet type", + .next =3D NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param), + .args =3D ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp, + hdr.icmp_type)), + }, + [ITEM_ICMP_CODE] =3D { + .name =3D "code", + .help =3D "ICMP packet code", + .next =3D NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param), + .args =3D ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp, + hdr.icmp_code)), + }, + [ITEM_UDP] =3D { + .name =3D "udp", + .help =3D "match UDP header", + .priv =3D PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)), + .next =3D NEXT(item_udp), + .call =3D parse_vc, + }, + [ITEM_UDP_SRC] =3D { + .name =3D "src", + .help =3D "UDP source port", + .next =3D NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param), + .args =3D ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp, + hdr.src_port)), + }, + [ITEM_UDP_DST] =3D { + .name =3D "dst", + .help =3D "UDP destination port", + .next =3D NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param), + .args =3D ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp, + hdr.dst_port)), + }, + [ITEM_TCP] =3D { + .name =3D "tcp", + .help =3D "match TCP header", + .priv =3D PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)), + .next =3D NEXT(item_tcp), + .call =3D parse_vc, + }, + [ITEM_TCP_SRC] =3D { + .name =3D "src", + .help =3D "TCP source port", + .next =3D NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param), + .args =3D ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp, + hdr.src_port)), + }, + [ITEM_TCP_DST] =3D { + .name =3D "dst", + .help =3D "TCP destination port", + .next =3D NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param), + .args =3D ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp, + hdr.dst_port)), + }, + [ITEM_SCTP] =3D { + .name =3D "sctp", + .help =3D "match SCTP header", + .priv =3D PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)), + .next =3D NEXT(item_sctp), + .call =3D parse_vc, + }, + [ITEM_SCTP_SRC] =3D { + .name =3D "src", + .help =3D "SCTP source port", + .next =3D NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param), + .args =3D ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp, + hdr.src_port)), + }, + [ITEM_SCTP_DST] =3D { + .name =3D "dst", + .help =3D "SCTP destination port", + .next =3D NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param), + .args =3D ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp, + hdr.dst_port)), + }, + [ITEM_VXLAN] =3D { + .name =3D "vxlan", + .help =3D "match VXLAN header", + .priv =3D PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)), + .next =3D NEXT(item_vxlan), + .call =3D parse_vc, + }, + [ITEM_VXLAN_VNI] =3D { + .name =3D "vni", + .help =3D "VXLAN identifier", + .next =3D NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param), + .args =3D ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)), + }, /* Validate/create actions. */ [ACTIONS] =3D { .name =3D "actions", @@ -1491,6 +1641,19 @@ parse_int(struct context *ctx, const struct token *t= oken, case sizeof(uint16_t): *(uint16_t *)buf =3D arg->hton ? rte_cpu_to_be_16(u) : u; break; + case sizeof(uint8_t [3]): +#if RTE_BYTE_ORDER =3D=3D RTE_LITTLE_ENDIAN + if (!arg->hton) { + ((uint8_t *)buf)[0] =3D u; + ((uint8_t *)buf)[1] =3D u >> 8; + ((uint8_t *)buf)[2] =3D u >> 16; + break; + } +#endif + ((uint8_t *)buf)[0] =3D u >> 16; + ((uint8_t *)buf)[1] =3D u >> 8; + ((uint8_t *)buf)[2] =3D u; + break; case sizeof(uint32_t): *(uint32_t *)buf =3D arg->hton ? rte_cpu_to_be_32(u) : u; break; -- 2.1.4