[dpdk-dev] [PATCH v3 2/2] net/i40e: improve packet type parser

Zhang, Qi Z qi.z.zhang at intel.com
Thu Jan 4 12:54:30 CET 2018



> -----Original Message-----
> From: Xing, Beilei
> Sent: Thursday, January 4, 2018 6:46 PM
> To: Zhang, Qi Z <qi.z.zhang at intel.com>
> Cc: dev at dpdk.org; Wu, Jingjing <jingjing.wu at intel.com>; Chilikin, Andrey
> <andrey.chilikin at intel.com>
> Subject: [PATCH v3 2/2] net/i40e: improve packet type parser
> 
> Add support for PPPoE and L2TP packet types parser.
> Change parser as new metadata 'OIPV4' and 'OIPV6'
> added in profile to distinguish outer IP and inner IP.
> 
> Signed-off-by: Beilei Xing <beilei.xing at intel.com>
> ---
>  drivers/net/i40e/i40e_ethdev.c | 83
> ++++++++++++++++++++++++++++++------------
>  1 file changed, 60 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
> index 811cc9f..c6f7ce7 100644
> --- a/drivers/net/i40e/i40e_ethdev.c
> +++ b/drivers/net/i40e/i40e_ethdev.c
> @@ -11078,7 +11078,7 @@ i40e_update_customized_ptype(struct
> rte_eth_dev *dev, uint8_t *pkg,
>  	uint8_t proto_id;
>  	char name[RTE_PMD_I40E_DDP_NAME_SIZE];
>  	uint32_t i, j, n;
> -	bool inner_ip;
> +	bool in_tunnel;
>  	int ret;
> 
>  	/* get information about new ptype num */ @@ -11123,7 +11123,7 @@
> i40e_update_customized_ptype(struct rte_eth_dev *dev, uint8_t *pkg,
>  	for (i = 0; i < ptype_num; i++) {
>  		ptype_mapping[i].hw_ptype = ptype[i].ptype_id;
>  		ptype_mapping[i].sw_ptype = 0;
> -		inner_ip = false;
> +		in_tunnel = false;
>  		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
>  			proto_id = ptype[i].protocols[j];
>  			if (proto_id == RTE_PMD_I40E_PROTO_UNUSED) @@ -11133,54
> +11133,91 @@ i40e_update_customized_ptype(struct rte_eth_dev *dev,
> uint8_t *pkg,
>  					continue;
>  				memset(name, 0, sizeof(name));
>  				strcpy(name, proto[n].name);
> -				if (!strncmp(name, "IPV4", 4) && !inner_ip) {
> +				if (!strncmp(name, "PPPOE", 5))
> +					ptype_mapping[i].sw_ptype |=
> +						RTE_PTYPE_L2_ETHER_PPPOE;
> +				else if (!strncmp(name, "OIPV4", 5)) {
>  					ptype_mapping[i].sw_ptype |=
>  						RTE_PTYPE_L3_IPV4_EXT_UNKNOWN;
> -					inner_ip = true;
> -				} else if (!strncmp(name, "IPV4FRAG", 8) &&
> -					   inner_ip) {
> +					in_tunnel = true;
> +				} else if (!strncmp(name, "IPV4", 4) &&
> +					   !in_tunnel)
> +					ptype_mapping[i].sw_ptype |=
> +						RTE_PTYPE_L3_IPV4_EXT_UNKNOWN;
> +				else if (!strncmp(name, "IPV4FRAG", 8) &&
> +					 in_tunnel) {
>  					ptype_mapping[i].sw_ptype |=
>  					    RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN;
>  					ptype_mapping[i].sw_ptype |=
>  						RTE_PTYPE_INNER_L4_FRAG;
>  				} else if (!strncmp(name, "IPV4", 4) &&
> -					   inner_ip)
> +					   in_tunnel)
>  					ptype_mapping[i].sw_ptype |=
>  					    RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN;
> -				else if (!strncmp(name, "IPV6", 4) &&
> -					 !inner_ip) {
> +				else if (!strncmp(name, "OIPV6", 5)) {
> +					ptype_mapping[i].sw_ptype |=
> +						RTE_PTYPE_L3_IPV6_EXT_UNKNOWN;
> +					in_tunnel = true;
> +				} else if (!strncmp(name, "IPV6", 4) &&
> +					   !in_tunnel)
>  					ptype_mapping[i].sw_ptype |=
>  						RTE_PTYPE_L3_IPV6_EXT_UNKNOWN;
> -					inner_ip = true;
> -				} else if (!strncmp(name, "IPV6FRAG", 8) &&
> -					   inner_ip) {
> +				else if (!strncmp(name, "IPV6FRAG", 8) &&
> +					 in_tunnel) {
>  					ptype_mapping[i].sw_ptype |=
>  					    RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN;
>  					ptype_mapping[i].sw_ptype |=
>  						RTE_PTYPE_INNER_L4_FRAG;
>  				} else if (!strncmp(name, "IPV6", 4) &&
> -					   inner_ip)
> +					   in_tunnel)
>  					ptype_mapping[i].sw_ptype |=
>  					    RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN;
> -				else if (!strncmp(name, "GTPC", 4))
> +				else if (!strncmp(name, "UDP", 3) && !in_tunnel)
>  					ptype_mapping[i].sw_ptype |=
> -						RTE_PTYPE_TUNNEL_GTPC;
> -				else if (!strncmp(name, "GTPU", 4))
> -					ptype_mapping[i].sw_ptype |=
> -						RTE_PTYPE_TUNNEL_GTPU;
> -				else if (!strncmp(name, "UDP", 3))
> +						RTE_PTYPE_L4_UDP;
> +				else if (!strncmp(name, "UDP", 3) && in_tunnel)
>  					ptype_mapping[i].sw_ptype |=
>  						RTE_PTYPE_INNER_L4_UDP;
> -				else if (!strncmp(name, "TCP", 3))
> +				else if (!strncmp(name, "TCP", 3) && !in_tunnel)
> +					ptype_mapping[i].sw_ptype |=
> +						RTE_PTYPE_L4_TCP;
> +				else if (!strncmp(name, "TCP", 3) && in_tunnel)
>  					ptype_mapping[i].sw_ptype |=
>  						RTE_PTYPE_INNER_L4_TCP;
> -				else if (!strncmp(name, "SCTP", 4))
> +				else if (!strncmp(name, "SCTP", 4) &&
> +					 !in_tunnel)
> +					ptype_mapping[i].sw_ptype |=
> +						RTE_PTYPE_L4_SCTP;
> +				else if (!strncmp(name, "SCTP", 4) && in_tunnel)
>  					ptype_mapping[i].sw_ptype |=
>  						RTE_PTYPE_INNER_L4_SCTP;
> -				else if (!strncmp(name, "ICMP", 4) ||
> -					 !strncmp(name, "ICMPV6", 6))
> +				else if ((!strncmp(name, "ICMP", 4) ||
> +					  !strncmp(name, "ICMPV6", 6)) &&
> +					 !in_tunnel)
> +					ptype_mapping[i].sw_ptype |=
> +						RTE_PTYPE_L4_ICMP;
> +				else if ((!strncmp(name, "ICMP", 4) ||
> +					  !strncmp(name, "ICMPV6", 6)) &&
> +					 in_tunnel)
>  					ptype_mapping[i].sw_ptype |=
>  						RTE_PTYPE_INNER_L4_ICMP;
> +				else if (!strncmp(name, "GTPC", 4)) {
> +					ptype_mapping[i].sw_ptype |=
> +						RTE_PTYPE_TUNNEL_GTPC;
> +					in_tunnel = true;
> +				} else if (!strncmp(name, "GTPU", 4)) {
> +					ptype_mapping[i].sw_ptype |=
> +						RTE_PTYPE_TUNNEL_GTPU;
> +					in_tunnel = true;
> +				} else if (!strncmp(name, "GRENAT", 6)) {
> +					ptype_mapping[i].sw_ptype |=
> +						RTE_PTYPE_TUNNEL_GRENAT;
> +					in_tunnel = true;
> +				} else if (!strncmp(name, "L2TPv2CTL", 9)) {
> +					ptype_mapping[i].sw_ptype |=
> +						RTE_PTYPE_TUNNEL_L2TP;
> +					in_tunnel = true;
> +				}
> 
>  				break;
>  			}
> --
> 2.5.5


Acked-by: Qi Zhang <qi.z.zhang at intel.com>


More information about the dev mailing list