[v5] net/iavf: support outer IP hash for no inner GTPU

Message ID 20200914090316.49740-1-alvinx.zhang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers
Series [v5] net/iavf: support outer IP hash for no inner GTPU |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation fail apply issues

Commit Message

Alvin Zhang Sept. 14, 2020, 9:03 a.m. UTC
  From: Alvin Zhang <alvinx.zhang@intel.com>

Outer IP hash can be configured as input sets for no inner GTPU packets.

Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
---

V2: Modify codes according to comments.
V3: Refact all codes.
V4: Fix compatibility issues.
V5: Modify codes according to comments.

 drivers/net/iavf/iavf_hash.c | 48 ++++++++++++++++++++++++++------------------
 1 file changed, 28 insertions(+), 20 deletions(-)
  

Comments

Qi Zhang Sept. 14, 2020, 10:33 a.m. UTC | #1
> -----Original Message-----
> From: Zhang, AlvinX <alvinx.zhang@intel.com>
> Sent: Monday, September 14, 2020 5:03 PM
> To: Guo, Jia <jia.guo@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>
> Cc: dev@dpdk.org; Zhang, AlvinX <alvinx.zhang@intel.com>
> Subject: [PATCH v5] net/iavf: support outer IP hash for no inner GTPU
> 
> From: Alvin Zhang <alvinx.zhang@intel.com>
> 
> Outer IP hash can be configured as input sets for no inner GTPU packets.
> 
> Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
> ---
> 
> V2: Modify codes according to comments.
> V3: Refact all codes.
> V4: Fix compatibility issues.
> V5: Modify codes according to comments.
> 
>  drivers/net/iavf/iavf_hash.c | 48 ++++++++++++++++++++++++++------------------
>  1 file changed, 28 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/net/iavf/iavf_hash.c b/drivers/net/iavf/iavf_hash.c index
> ff77d71..d0a6396 100644
> --- a/drivers/net/iavf/iavf_hash.c
> +++ b/drivers/net/iavf/iavf_hash.c
> @@ -348,6 +348,7 @@ struct virtchnl_proto_hdrs ipv6_pfcp_tmplt = {
>  	{iavf_pattern_eth_vlan_ipv4_udp,		IAVF_RSS_TYPE_VLAN_IPV4_UDP,
> 	&outer_ipv4_udp_tmplt},
>  	{iavf_pattern_eth_vlan_ipv4_tcp,		IAVF_RSS_TYPE_VLAN_IPV4_TCP,
> 	&outer_ipv4_tcp_tmplt},
>  	{iavf_pattern_eth_vlan_ipv4_sctp,		IAVF_RSS_TYPE_VLAN_IPV4_SCTP,
> 	&outer_ipv4_sctp_tmplt},
> +	{iavf_pattern_eth_ipv4_gtpu,			ETH_RSS_IPV4,
> 	&outer_ipv4_udp_tmplt},
>  	{iavf_pattern_eth_ipv4_gtpu_ipv4,		IAVF_RSS_TYPE_GTPU_IPV4,
> 	&inner_ipv4_tmplt},
>  	{iavf_pattern_eth_ipv4_gtpu_ipv4_udp,
> 	IAVF_RSS_TYPE_GTPU_IPV4_UDP,	&inner_ipv4_udp_tmplt},
>  	{iavf_pattern_eth_ipv4_gtpu_ipv4_tcp,
> 	IAVF_RSS_TYPE_GTPU_IPV4_TCP,	&inner_ipv4_tcp_tmplt},
> @@ -374,6 +375,7 @@ struct virtchnl_proto_hdrs ipv6_pfcp_tmplt = {
>  	{iavf_pattern_eth_vlan_ipv6_udp,		IAVF_RSS_TYPE_VLAN_IPV6_UDP,
> 	&outer_ipv6_udp_tmplt},
>  	{iavf_pattern_eth_vlan_ipv6_tcp,		IAVF_RSS_TYPE_VLAN_IPV6_TCP,
> 	&outer_ipv6_tcp_tmplt},
>  	{iavf_pattern_eth_vlan_ipv6_sctp,		IAVF_RSS_TYPE_VLAN_IPV6_SCTP,
> 	&outer_ipv6_sctp_tmplt},
> +	{iavf_pattern_eth_ipv6_gtpu,			ETH_RSS_IPV6,
> 	&outer_ipv6_udp_tmplt},
>  	{iavf_pattern_eth_ipv4_gtpu_ipv6,		IAVF_RSS_TYPE_GTPU_IPV6,
> 	&inner_ipv6_tmplt},
>  	{iavf_pattern_eth_ipv4_gtpu_ipv6_udp,
> 	IAVF_RSS_TYPE_GTPU_IPV6_UDP,	&inner_ipv6_udp_tmplt},
>  	{iavf_pattern_eth_ipv4_gtpu_ipv6_tcp,
> 	IAVF_RSS_TYPE_GTPU_IPV6_TCP,	&inner_ipv6_tcp_tmplt},
> @@ -698,31 +700,37 @@ struct virtchnl_proto_hdrs
> *iavf_hash_default_hdrs[] = {
>  	struct virtchnl_proto_hdr *hdr2;
>  	int i;
> 
> -	if (!(phint & IAVF_PHINT_GTPU_MSK) ||
> -	    proto_hdrs->tunnel_level == 0)
> +	if (!(phint & IAVF_PHINT_GTPU_MSK))
>  		return;
> 
> -	/* shift headers 1 layer */
> -	for (i = proto_hdrs->count; i > 0; i--) {
> -		hdr1 = &proto_hdrs->proto_hdr[i];
> -		hdr2 = &proto_hdrs->proto_hdr[i - 1];
> +	if (proto_hdrs->tunnel_level == TUNNEL_LEVEL_INNER) {
> +		/* shift headers 1 layer */
> +		for (i = proto_hdrs->count; i > 0; i--) {
> +			hdr1 = &proto_hdrs->proto_hdr[i];
> +			hdr2 = &proto_hdrs->proto_hdr[i - 1];
> 
> -		*hdr1 = *hdr2;
> -	}
> +			*hdr1 = *hdr2;
> +		}
> 
> -	/* adding gtpu header at layer 0 */
> -	proto_hdrs->count++;
> -	hdr1 = &proto_hdrs->proto_hdr[0];
> -	hdr1->field_selector = 0;
> -
> -	if (phint & IAVF_PHINT_GTPU_EH_DWN)
> -		VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_EH_PDU_DWN);
> -	else if (phint & IAVF_PHINT_GTPU_EH_UP)
> -		VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_EH_PDU_UP);
> -	else if (phint & IAVF_PHINT_GTPU_EH)
> -		VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_EH);
> -	else if (phint & IAVF_PHINT_GTPU)
> +		/* adding gtpu header at layer 0 */
> +		proto_hdrs->count++;
> +		hdr1 = &proto_hdrs->proto_hdr[0];
> +		hdr1->field_selector = 0;
> +
> +		if (phint & IAVF_PHINT_GTPU_EH_DWN)
> +			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_EH_PDU_DWN);
> +		else if (phint & IAVF_PHINT_GTPU_EH_UP)
> +			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_EH_PDU_UP);
> +		else if (phint & IAVF_PHINT_GTPU_EH)
> +			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_EH);
> +		else if (phint & IAVF_PHINT_GTPU)
> +			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_IP);
> +	} else {
> +		hdr1 = &proto_hdrs->proto_hdr[proto_hdrs->count];
> +		hdr1->field_selector = 0;
> +		proto_hdrs->count++;
>  		VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_IP);

Its better to also check phint for outer case, could be implemented as below

If (inner) {
	Shift 
	Hdr = hdrs[0]
}
else {
	Hdr = hdrs[count]
}

hdr-count++

if (phint & IAVF_PHINT_GTPU_EH_DWN)
	VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_EH_PDU_DWN);
else if (phint & IAVF_PHINT_GTPU_EH_UP)
	VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_EH_PDU_UP);
else if (phint & IAVF_PHINT_GTPU_EH)			
	VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_EH);
else if (phint & IAVF_PHINT_GTPU)
	VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_IP);


> +	}
>  }
> 
>  static void iavf_refine_proto_hdrs(struct virtchnl_proto_hdrs *proto_hdrs,
> --
> 1.8.3.1
  
Alvin Zhang Sept. 15, 2020, 1:54 a.m. UTC | #2
Thanks Zhangqi.

> -----Original Message-----
> From: Zhang, Qi Z <qi.z.zhang@intel.com>
> Sent: Monday, September 14, 2020 6:33 PM
> To: Zhang, AlvinX <alvinx.zhang@intel.com>; Guo, Jia <jia.guo@intel.com>
> Cc: dev@dpdk.org
> Subject: RE: [PATCH v5] net/iavf: support outer IP hash for no inner GTPU
> 
> 
> 
> > -----Original Message-----
> > From: Zhang, AlvinX <alvinx.zhang@intel.com>
> > Sent: Monday, September 14, 2020 5:03 PM
> > To: Guo, Jia <jia.guo@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>
> > Cc: dev@dpdk.org; Zhang, AlvinX <alvinx.zhang@intel.com>
> > Subject: [PATCH v5] net/iavf: support outer IP hash for no inner GTPU
> >
> > From: Alvin Zhang <alvinx.zhang@intel.com>
> >
> > Outer IP hash can be configured as input sets for no inner GTPU packets.
> >
> > Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
> > ---
> >
> > V2: Modify codes according to comments.
> > V3: Refact all codes.
> > V4: Fix compatibility issues.
> > V5: Modify codes according to comments.
> >
> >  drivers/net/iavf/iavf_hash.c | 48
> > ++++++++++++++++++++++++++------------------
> >  1 file changed, 28 insertions(+), 20 deletions(-)
> >
> > diff --git a/drivers/net/iavf/iavf_hash.c
> > b/drivers/net/iavf/iavf_hash.c index
> > ff77d71..d0a6396 100644
> > --- a/drivers/net/iavf/iavf_hash.c
> > +++ b/drivers/net/iavf/iavf_hash.c
> > @@ -348,6 +348,7 @@ struct virtchnl_proto_hdrs ipv6_pfcp_tmplt = {
> > {iavf_pattern_eth_vlan_ipv4_udp,IAVF_RSS_TYPE_VLAN_IPV4_UDP,
> > &outer_ipv4_udp_tmplt},
> >  {iavf_pattern_eth_vlan_ipv4_tcp,IAVF_RSS_TYPE_VLAN_IPV4_TCP,
> > &outer_ipv4_tcp_tmplt},
> >  {iavf_pattern_eth_vlan_ipv4_sctp,IAVF_RSS_TYPE_VLAN_IPV4_SCTP,
> > &outer_ipv4_sctp_tmplt},
> > +{iavf_pattern_eth_ipv4_gtpu,ETH_RSS_IPV4,
> > &outer_ipv4_udp_tmplt},
> >  {iavf_pattern_eth_ipv4_gtpu_ipv4,IAVF_RSS_TYPE_GTPU_IPV4,
> > &inner_ipv4_tmplt},
> >  {iavf_pattern_eth_ipv4_gtpu_ipv4_udp,
> > IAVF_RSS_TYPE_GTPU_IPV4_UDP,&inner_ipv4_udp_tmplt},
> >  {iavf_pattern_eth_ipv4_gtpu_ipv4_tcp,
> > IAVF_RSS_TYPE_GTPU_IPV4_TCP,&inner_ipv4_tcp_tmplt},
> > @@ -374,6 +375,7 @@ struct virtchnl_proto_hdrs ipv6_pfcp_tmplt = {
> > {iavf_pattern_eth_vlan_ipv6_udp,IAVF_RSS_TYPE_VLAN_IPV6_UDP,
> > &outer_ipv6_udp_tmplt},
> >  {iavf_pattern_eth_vlan_ipv6_tcp,IAVF_RSS_TYPE_VLAN_IPV6_TCP,
> > &outer_ipv6_tcp_tmplt},
> >  {iavf_pattern_eth_vlan_ipv6_sctp,IAVF_RSS_TYPE_VLAN_IPV6_SCTP,
> > &outer_ipv6_sctp_tmplt},
> > +{iavf_pattern_eth_ipv6_gtpu,ETH_RSS_IPV6,
> > &outer_ipv6_udp_tmplt},
> >  {iavf_pattern_eth_ipv4_gtpu_ipv6,IAVF_RSS_TYPE_GTPU_IPV6,
> > &inner_ipv6_tmplt},
> >  {iavf_pattern_eth_ipv4_gtpu_ipv6_udp,
> > IAVF_RSS_TYPE_GTPU_IPV6_UDP,&inner_ipv6_udp_tmplt},
> >  {iavf_pattern_eth_ipv4_gtpu_ipv6_tcp,
> > IAVF_RSS_TYPE_GTPU_IPV6_TCP,&inner_ipv6_tcp_tmplt},
> > @@ -698,31 +700,37 @@ struct virtchnl_proto_hdrs
> > *iavf_hash_default_hdrs[] = {  struct virtchnl_proto_hdr *hdr2;  int
> > i;
> >
> > -if (!(phint & IAVF_PHINT_GTPU_MSK) ||
> > -    proto_hdrs->tunnel_level == 0)
> > +if (!(phint & IAVF_PHINT_GTPU_MSK))
> >  return;
> >
> > -/* shift headers 1 layer */
> > -for (i = proto_hdrs->count; i > 0; i--) {
> > -hdr1 = &proto_hdrs->proto_hdr[i];
> > -hdr2 = &proto_hdrs->proto_hdr[i - 1];
> > +if (proto_hdrs->tunnel_level == TUNNEL_LEVEL_INNER) {
> > +/* shift headers 1 layer */
> > +for (i = proto_hdrs->count; i > 0; i--) {
> > +hdr1 = &proto_hdrs->proto_hdr[i];
> > +hdr2 = &proto_hdrs->proto_hdr[i - 1];
> >
> > -*hdr1 = *hdr2;
> > -}
> > +*hdr1 = *hdr2;
> > +}
> >
> > -/* adding gtpu header at layer 0 */
> > -proto_hdrs->count++;
> > -hdr1 = &proto_hdrs->proto_hdr[0];
> > -hdr1->field_selector = 0;
> > -
> > -if (phint & IAVF_PHINT_GTPU_EH_DWN)
> > -VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_EH_PDU_DWN); -else if
> (phint &
> > IAVF_PHINT_GTPU_EH_UP) -VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1,
> > GTPU_EH_PDU_UP); -else if (phint & IAVF_PHINT_GTPU_EH)
> > -VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_EH); -else if (phint &
> > IAVF_PHINT_GTPU)
> > +/* adding gtpu header at layer 0 */
> > +proto_hdrs->count++;
> > +hdr1 = &proto_hdrs->proto_hdr[0];
> > +hdr1->field_selector = 0;
> > +
> > +if (phint & IAVF_PHINT_GTPU_EH_DWN)
> > +VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_EH_PDU_DWN); else if
> (phint &
> > +IAVF_PHINT_GTPU_EH_UP) VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1,
> > +GTPU_EH_PDU_UP); else if (phint & IAVF_PHINT_GTPU_EH)
> > +VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_EH); else if (phint &
> > +IAVF_PHINT_GTPU) VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_IP); }
> else {
> > +hdr1 = &proto_hdrs->proto_hdr[proto_hdrs->count];
> > +hdr1->field_selector = 0;
> > +proto_hdrs->count++;
> >  VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_IP);
> 
> Its better to also check phint for outer case, could be implemented as below
> 
> If (inner) {
> Shift
> Hdr = hdrs[0]
> }
> else {
> Hdr = hdrs[count]
> }
> 
> hdr-count++
> 
> if (phint & IAVF_PHINT_GTPU_EH_DWN)
> VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_EH_PDU_DWN); else if (phint &
> IAVF_PHINT_GTPU_EH_UP) VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1,
> GTPU_EH_PDU_UP); else if (phint & IAVF_PHINT_GTPU_EH)
> VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_EH); else if (phint &
> IAVF_PHINT_GTPU) VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_IP);
> 
> 
> > +}
> >  }
> >
> >  static void iavf_refine_proto_hdrs(struct virtchnl_proto_hdrs
> > *proto_hdrs,
> > --
> > 1.8.3.1
>
  

Patch

diff --git a/drivers/net/iavf/iavf_hash.c b/drivers/net/iavf/iavf_hash.c
index ff77d71..d0a6396 100644
--- a/drivers/net/iavf/iavf_hash.c
+++ b/drivers/net/iavf/iavf_hash.c
@@ -348,6 +348,7 @@  struct virtchnl_proto_hdrs ipv6_pfcp_tmplt = {
 	{iavf_pattern_eth_vlan_ipv4_udp,		IAVF_RSS_TYPE_VLAN_IPV4_UDP,	&outer_ipv4_udp_tmplt},
 	{iavf_pattern_eth_vlan_ipv4_tcp,		IAVF_RSS_TYPE_VLAN_IPV4_TCP,	&outer_ipv4_tcp_tmplt},
 	{iavf_pattern_eth_vlan_ipv4_sctp,		IAVF_RSS_TYPE_VLAN_IPV4_SCTP,	&outer_ipv4_sctp_tmplt},
+	{iavf_pattern_eth_ipv4_gtpu,			ETH_RSS_IPV4,			&outer_ipv4_udp_tmplt},
 	{iavf_pattern_eth_ipv4_gtpu_ipv4,		IAVF_RSS_TYPE_GTPU_IPV4,	&inner_ipv4_tmplt},
 	{iavf_pattern_eth_ipv4_gtpu_ipv4_udp,		IAVF_RSS_TYPE_GTPU_IPV4_UDP,	&inner_ipv4_udp_tmplt},
 	{iavf_pattern_eth_ipv4_gtpu_ipv4_tcp,		IAVF_RSS_TYPE_GTPU_IPV4_TCP,	&inner_ipv4_tcp_tmplt},
@@ -374,6 +375,7 @@  struct virtchnl_proto_hdrs ipv6_pfcp_tmplt = {
 	{iavf_pattern_eth_vlan_ipv6_udp,		IAVF_RSS_TYPE_VLAN_IPV6_UDP,	&outer_ipv6_udp_tmplt},
 	{iavf_pattern_eth_vlan_ipv6_tcp,		IAVF_RSS_TYPE_VLAN_IPV6_TCP,	&outer_ipv6_tcp_tmplt},
 	{iavf_pattern_eth_vlan_ipv6_sctp,		IAVF_RSS_TYPE_VLAN_IPV6_SCTP,	&outer_ipv6_sctp_tmplt},
+	{iavf_pattern_eth_ipv6_gtpu,			ETH_RSS_IPV6,			&outer_ipv6_udp_tmplt},
 	{iavf_pattern_eth_ipv4_gtpu_ipv6,		IAVF_RSS_TYPE_GTPU_IPV6,	&inner_ipv6_tmplt},
 	{iavf_pattern_eth_ipv4_gtpu_ipv6_udp,		IAVF_RSS_TYPE_GTPU_IPV6_UDP,	&inner_ipv6_udp_tmplt},
 	{iavf_pattern_eth_ipv4_gtpu_ipv6_tcp,		IAVF_RSS_TYPE_GTPU_IPV6_TCP,	&inner_ipv6_tcp_tmplt},
@@ -698,31 +700,37 @@  struct virtchnl_proto_hdrs *iavf_hash_default_hdrs[] = {
 	struct virtchnl_proto_hdr *hdr2;
 	int i;
 
-	if (!(phint & IAVF_PHINT_GTPU_MSK) ||
-	    proto_hdrs->tunnel_level == 0)
+	if (!(phint & IAVF_PHINT_GTPU_MSK))
 		return;
 
-	/* shift headers 1 layer */
-	for (i = proto_hdrs->count; i > 0; i--) {
-		hdr1 = &proto_hdrs->proto_hdr[i];
-		hdr2 = &proto_hdrs->proto_hdr[i - 1];
+	if (proto_hdrs->tunnel_level == TUNNEL_LEVEL_INNER) {
+		/* shift headers 1 layer */
+		for (i = proto_hdrs->count; i > 0; i--) {
+			hdr1 = &proto_hdrs->proto_hdr[i];
+			hdr2 = &proto_hdrs->proto_hdr[i - 1];
 
-		*hdr1 = *hdr2;
-	}
+			*hdr1 = *hdr2;
+		}
 
-	/* adding gtpu header at layer 0 */
-	proto_hdrs->count++;
-	hdr1 = &proto_hdrs->proto_hdr[0];
-	hdr1->field_selector = 0;
-
-	if (phint & IAVF_PHINT_GTPU_EH_DWN)
-		VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_EH_PDU_DWN);
-	else if (phint & IAVF_PHINT_GTPU_EH_UP)
-		VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_EH_PDU_UP);
-	else if (phint & IAVF_PHINT_GTPU_EH)
-		VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_EH);
-	else if (phint & IAVF_PHINT_GTPU)
+		/* adding gtpu header at layer 0 */
+		proto_hdrs->count++;
+		hdr1 = &proto_hdrs->proto_hdr[0];
+		hdr1->field_selector = 0;
+
+		if (phint & IAVF_PHINT_GTPU_EH_DWN)
+			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_EH_PDU_DWN);
+		else if (phint & IAVF_PHINT_GTPU_EH_UP)
+			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_EH_PDU_UP);
+		else if (phint & IAVF_PHINT_GTPU_EH)
+			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_EH);
+		else if (phint & IAVF_PHINT_GTPU)
+			VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_IP);
+	} else {
+		hdr1 = &proto_hdrs->proto_hdr[proto_hdrs->count];
+		hdr1->field_selector = 0;
+		proto_hdrs->count++;
 		VIRTCHNL_SET_PROTO_HDR_TYPE(hdr1, GTPU_IP);
+	}
 }
 
 static void iavf_refine_proto_hdrs(struct virtchnl_proto_hdrs *proto_hdrs,