Skip to contentSkip to conversation

app/testpmd: fix protocol headers display for Rx buffer split

PATCH Superseded Yuan Wang 3 participants 15 messages Oct 17, 2022 – Nov 10, 2022

lore
Share & tools
lore

Yuan Wang

author
#0 lore raw

PATCH 1/1 app/testpmd: fix protocol headers display for Rx buffer split

The "show config rxhdrs" cmd displays the configured protocol headers that are used for protocol-based buffer split.
However, it shows "inner-ipv6" as "inner-ipv4".

This patch fixes that by adjusting the order of condition judgments.

---
 app/test-pmd/config.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
app/test-pmd/config.c +12 -12
index dec16a9049..e5fbc3a491 100644
@@ -4922,15 +4922,6 @@ static const char *get_ptype_str(uint32_t ptype)
 	else if ((ptype & RTE_PTYPE_L2_ETHER) == RTE_PTYPE_L2_ETHER)
 		return "eth";
 
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP)) ==
-		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP))
-		return "inner-ipv4-tcp";
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP)) ==
-		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP))
-		return "inner-ipv4-udp";
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP)) ==
-		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP))
-		return "inner-ipv4-sctp";
 	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP)) ==
 		(RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP))
 		return "inner-ipv6-tcp";
@@ -4940,18 +4931,27 @@ static const char *get_ptype_str(uint32_t ptype)
 	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP)) ==
 		(RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP))
 		return "inner-ipv6-sctp";
+	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP)) ==
+		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP))
+		return "inner-ipv4-tcp";
+	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP)) ==
+		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP))
+		return "inner-ipv4-udp";
+	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP)) ==
+		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP))
+		return "inner-ipv4-sctp";
 	else if ((ptype & RTE_PTYPE_INNER_L4_TCP) == RTE_PTYPE_INNER_L4_TCP)
 		return "inner-tcp";
 	else if ((ptype & RTE_PTYPE_INNER_L4_UDP) == RTE_PTYPE_INNER_L4_UDP)
 		return "inner-udp";
 	else if ((ptype & RTE_PTYPE_INNER_L4_SCTP) == RTE_PTYPE_INNER_L4_SCTP)
 		return "inner-sctp";
+	else if ((ptype & RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN) ==
+		RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN)
+		return "inner-ipv6";
 	else if ((ptype & RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN) ==
 		RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN)
 		return "inner-ipv4";
-	else if ((ptype & RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN) ==
-		RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN)
-		return "inner-ipv6";
 	else if ((ptype & RTE_PTYPE_INNER_L2_ETHER) == RTE_PTYPE_INNER_L2_ETHER)
 		return "inner-eth";
 	else if ((ptype & RTE_PTYPE_TUNNEL_GRENAT) == RTE_PTYPE_TUNNEL_GRENAT)
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH v2 1/1 app/testpmd: fix protocol headers display for Rx buffer split

The "show config rxhdrs" cmd displays the configured protocol headers that are used for protocol-based buffer split.
However, it shows "inner-ipv6" as "inner-ipv4".

This patch fixes that by adjusting the order of condition judgments.

Fixes 52e2e7edcf48 ("app/testpmd: add protocol-based buffer split")

---
v2: add fixline.

---
 app/test-pmd/config.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
app/test-pmd/config.c +12 -12
index 0f7dbd698f..82fbbc9944 100644
@@ -4937,15 +4937,6 @@ static const char *get_ptype_str(uint32_t ptype)
 	else if ((ptype & RTE_PTYPE_L2_ETHER) == RTE_PTYPE_L2_ETHER)
 		return "eth";
 
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP)) ==
-		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP))
-		return "inner-ipv4-tcp";
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP)) ==
-		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP))
-		return "inner-ipv4-udp";
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP)) ==
-		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP))
-		return "inner-ipv4-sctp";
 	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP)) ==
 		(RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP))
 		return "inner-ipv6-tcp";
@@ -4955,18 +4946,27 @@ static const char *get_ptype_str(uint32_t ptype)
 	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP)) ==
 		(RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP))
 		return "inner-ipv6-sctp";
+	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP)) ==
+		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP))
+		return "inner-ipv4-tcp";
+	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP)) ==
+		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP))
+		return "inner-ipv4-udp";
+	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP)) ==
+		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP))
+		return "inner-ipv4-sctp";
 	else if ((ptype & RTE_PTYPE_INNER_L4_TCP) == RTE_PTYPE_INNER_L4_TCP)
 		return "inner-tcp";
 	else if ((ptype & RTE_PTYPE_INNER_L4_UDP) == RTE_PTYPE_INNER_L4_UDP)
 		return "inner-udp";
 	else if ((ptype & RTE_PTYPE_INNER_L4_SCTP) == RTE_PTYPE_INNER_L4_SCTP)
 		return "inner-sctp";
+	else if ((ptype & RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN) ==
+		RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN)
+		return "inner-ipv6";
 	else if ((ptype & RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN) ==
 		RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN)
 		return "inner-ipv4";
-	else if ((ptype & RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN) ==
-		RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN)
-		return "inner-ipv6";
 	else if ((ptype & RTE_PTYPE_INNER_L2_ETHER) == RTE_PTYPE_INNER_L2_ETHER)
 		return "inner-eth";
 	else if ((ptype & RTE_PTYPE_TUNNEL_GRENAT) == RTE_PTYPE_TUNNEL_GRENAT)
Signature · 1 line
2.25.1
#2 lore raw

Hi All,

Could you please review and provide suggestions if any.

Thanks,
Yuan

Quoted 102 lines

-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Tuesday, October 18, 2022 10:50 PM
To: [email protected]; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>
Cc: [email protected]; Ding, Xuan <[email protected]>; Tang, Yaqi <[email protected]>; Wang, YuanX <[email protected]>
Subject: [PATCH v2] app/testpmd: fix protocol headers display for Rx buffer split

The "show config rxhdrs" cmd displays the configured protocol headers that are used for protocol-based buffer split.
However, it shows "inner-ipv6" as "inner-ipv4".

This patch fixes that by adjusting the order of condition judgments.

Fixes 52e2e7edcf48 ("app/testpmd: add protocol-based buffer split")

---
v2: add fixline.

---
 app/test-pmd/config.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
app/test-pmd/config.c index renamed from app/test-pmd/config.c +0 -0

0f7dbd698f..82fbbc9944 100644

app/test-pmd/config.c +0 -1
@@ -4937,15 +4937,6 @@ static const char *get_ptype_str(uint32_t ptype)
 	else if ((ptype & RTE_PTYPE_L2_ETHER) == RTE_PTYPE_L2_ETHER)
 		return "eth";
 
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_INNER_L4_TCP)) ==

app/test-pmd/config.c +0 -1
-		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_INNER_L4_TCP))

app/test-pmd/config.c +0 -2
-		return "inner-ipv4-tcp";
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_INNER_L4_UDP)) ==

app/test-pmd/config.c +0 -1
-		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_INNER_L4_UDP))

app/test-pmd/config.c +0 -2
-		return "inner-ipv4-udp";
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_INNER_L4_SCTP)) ==

app/test-pmd/config.c +0 -1
-		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_INNER_L4_SCTP))

app/test-pmd/config.c +0 -1
-		return "inner-ipv4-sctp";
 	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |

RTE_PTYPE_INNER_L4_TCP)) ==
(RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
RTE_PTYPE_INNER_L4_TCP))

app/test-pmd/config.c +0 -0
 		return "inner-ipv6-tcp";
@@ -4955,18 +4946,27 @@ static const char *get_ptype_str(uint32_t ptype)
 	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |

RTE_PTYPE_INNER_L4_SCTP)) ==
(RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
RTE_PTYPE_INNER_L4_SCTP))

app/test-pmd/config.c +1 -0
 		return "inner-ipv6-sctp";
+	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_INNER_L4_TCP)) ==

app/test-pmd/config.c +1 -0
+		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_INNER_L4_TCP))

app/test-pmd/config.c +2 -0
+		return "inner-ipv4-tcp";
+	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_INNER_L4_UDP)) ==

app/test-pmd/config.c +1 -0
+		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_INNER_L4_UDP))

app/test-pmd/config.c +2 -0
+		return "inner-ipv4-udp";
+	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_INNER_L4_SCTP)) ==

app/test-pmd/config.c +1 -0
+		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_INNER_L4_SCTP))

app/test-pmd/config.c +1 -0
+		return "inner-ipv4-sctp";
 	else if ((ptype & RTE_PTYPE_INNER_L4_TCP) ==

RTE_PTYPE_INNER_L4_TCP)

app/test-pmd/config.c +0 -0
 		return "inner-tcp";
 	else if ((ptype & RTE_PTYPE_INNER_L4_UDP) ==

RTE_PTYPE_INNER_L4_UDP)

app/test-pmd/config.c +0 -0
 		return "inner-udp";
 	else if ((ptype & RTE_PTYPE_INNER_L4_SCTP) ==

RTE_PTYPE_INNER_L4_SCTP)

app/test-pmd/config.c +3 -3
 		return "inner-sctp";
+	else if ((ptype & RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN) ==
+		RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN)
+		return "inner-ipv6";
 	else if ((ptype & RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN) ==
 		RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN)
 		return "inner-ipv4";
-	else if ((ptype & RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN) ==
-		RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN)
-		return "inner-ipv6";
 	else if ((ptype & RTE_PTYPE_INNER_L2_ETHER) ==

RTE_PTYPE_INNER_L2_ETHER)

app/test-pmd/config.c +0 -0
 		return "inner-eth";
 	else if ((ptype & RTE_PTYPE_TUNNEL_GRENAT) ==

RTE_PTYPE_TUNNEL_GRENAT)
--
2.25.1

#3 lore raw
In reply to Yuan Wang
Quoted 23 lines · Yuan Wang

The "show config rxhdrs" cmd displays the configured protocol headers that are used for protocol-based buffer split.
However, it shows "inner-ipv6" as "inner-ipv4".

This patch fixes that by adjusting the order of condition judgments.

Fixes 52e2e7edcf48 ("app/testpmd: add protocol-based buffer split")

---
v2: add fixline.

---
  app/test-pmd/config.c | 24 ++++++++++++------------
  1 file changed, 12 insertions(+), 12 deletions(-)
app/test-pmd/config.c +0 -0
index 0f7dbd698f..82fbbc9944 100644

app/test-pmd/config.c static const char *get_ptype_str(uint32_t ptype) · line 4941

Quoted 5 lines
app/test-pmd/config.c +0 -2
@@ -4937,15 +4937,6 @@ static const char *get_ptype_str(uint32_t ptype)
  	else if ((ptype & RTE_PTYPE_L2_ETHER) == RTE_PTYPE_L2_ETHER)
  		return "eth";
 
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP)) ==
-		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP))

I realize that the patch solves the problem, but it is still wrong. Why are RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN and RTE_PTYPE_INNER_L4_TCP used as masks instead of RTE_PTYPE_L3_MASK and RTE_PTYPE_L4_MASK?

It is simply incorrect from the very beginning and all conditions must be fixed to use appropriate masks instead.

#4 lore raw

Hi Andrew,

Quoted 42 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Sunday, November 6, 2022 5:58 PM
To: Wang, YuanX <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>
Cc: [email protected]; Ding, Xuan <[email protected]>; Tang, Yaqi <[email protected]>
Subject: Re: [PATCH v2] app/testpmd: fix protocol headers display for Rx buffer split

Quoted 23 lines · Yuan Wang

The "show config rxhdrs" cmd displays the configured protocol headers that are used for protocol-based buffer split.
However, it shows "inner-ipv6" as "inner-ipv4".

This patch fixes that by adjusting the order of condition judgments.

Fixes 52e2e7edcf48 ("app/testpmd: add protocol-based buffer split")

---
v2: add fixline.

---
  app/test-pmd/config.c | 24 ++++++++++++------------
  1 file changed, 12 insertions(+), 12 deletions(-)
app/test-pmd/config.c index renamed from app/test-pmd/config.c +0 -0

0f7dbd698f..82fbbc9944 100644

app/test-pmd/config.c static const char *get_ptype_str(uint32_t ptype) · line 4940

Quoted 4 lines
app/test-pmd/config.c +0 -1
@@ -4937,15 +4937,6 @@ static const char *get_ptype_str(uint32_t ptype)
  	else if ((ptype & RTE_PTYPE_L2_ETHER) == RTE_PTYPE_L2_ETHER)
  		return "eth";
 
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_INNER_L4_TCP)) ==

app/test-pmd/config.c static const char *get_ptype_str(uint32_t ptype) · line 4941

Quoted 1 line
app/test-pmd/config.c +0 -1
-		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_INNER_L4_TCP))

Quoted 7 lines

I realize that the patch solves the problem, but it is still wrong. Why are RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN and
RTE_PTYPE_INNER_L4_TCP used as masks instead of RTE_PTYPE_L3_MASK and RTE_PTYPE_L4_MASK?

It is simply incorrect from the very beginning and all conditions must be fixed to use appropriate masks instead.

Thanks for your comments. I will update the patch with the appropriate mask.

Thanks,
Yuan

Tested-by on v1 1/1
#5 lore raw
In reply to Yuan Wang
Quoted 11 lines

-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Tuesday, October 18, 2022 1:41 AM
To: Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>
Cc: [email protected]; [email protected]; Ding, Xuan <[email protected]>; Tang, Yaqi <[email protected]>; Wang, YuanX <[email protected]>
Subject: [PATCH] app/testpmd: fix protocol headers display for Rx buffer split

Quoted 8 lines

The "show config rxhdrs" cmd displays the configured protocol headers that are used for protocol-based buffer split.
However, it shows "inner-ipv6" as "inner-ipv4".

This patch fixes that by adjusting the order of condition judgments.

---

author
#6 lore raw

PATCH v3 1/1 app/testpmd: fix protocol header display for Rx buffer split

In reply to Yuan Wang

The "show config rxhdrs" cmd displays the configured protocol headers that are used for protocol-based buffer split.
However, it shows inner-ipv6 as inner-ipv4.

This patch fixes that by adjusting the order of condition judgments. This patch also uses RTE_PTYPE_*_MASK as masks.

Fixes 52e2e7edcf48 ("app/testpmd: add protocol-based buffer split")

---
v3:
- use RTE_PTYPE_*_MASK as masks.
- refactor to use switch statement.
v2:
- add fixline.

---
 app/test-pmd/config.c | 89 +++++++++++++++++++++----------------------
 1 file changed, 44 insertions(+), 45 deletions(-)
app/test-pmd/config.c +44 -45
index e8a1b77c2a..8638dfed11 100644
@@ -5070,73 +5070,72 @@ show_rx_pkt_segments(void)
 
 static const char *get_ptype_str(uint32_t ptype)
 {
-	if ((ptype & (RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP)) ==
-		(RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP))
+	switch (ptype & (RTE_PTYPE_L3_MASK | RTE_PTYPE_L4_MASK)) {
+	case RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP:
 		return "ipv4-tcp";
-	else if ((ptype & (RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP)) ==
-		(RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP))
+	case RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP:
 		return "ipv4-udp";
-	else if ((ptype & (RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP)) ==
-		(RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP))
+	case RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP:
 		return "ipv4-sctp";
-	else if ((ptype & (RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP)) ==
-		(RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP))
+	case RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP:
 		return "ipv6-tcp";
-	else if ((ptype & (RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP)) ==
-		(RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP))
+	case RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP:
 		return "ipv6-udp";
-	else if ((ptype & (RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP)) ==
-		(RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP))
+	case RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP:
 		return "ipv6-sctp";
-	else if ((ptype & RTE_PTYPE_L4_TCP) == RTE_PTYPE_L4_TCP)
+	case RTE_PTYPE_L4_TCP:
 		return "tcp";
-	else if ((ptype & RTE_PTYPE_L4_UDP) == RTE_PTYPE_L4_UDP)
+	case RTE_PTYPE_L4_UDP:
 		return "udp";
-	else if ((ptype & RTE_PTYPE_L4_SCTP) == RTE_PTYPE_L4_SCTP)
+	case RTE_PTYPE_L4_SCTP:
 		return "sctp";
-	else if ((ptype & RTE_PTYPE_L3_IPV4_EXT_UNKNOWN) == RTE_PTYPE_L3_IPV4_EXT_UNKNOWN)
+	case RTE_PTYPE_L3_IPV4_EXT_UNKNOWN:
 		return "ipv4";
-	else if ((ptype & RTE_PTYPE_L3_IPV6_EXT_UNKNOWN) == RTE_PTYPE_L3_IPV6_EXT_UNKNOWN)
+	case RTE_PTYPE_L3_IPV6_EXT_UNKNOWN:
 		return "ipv6";
-	else if ((ptype & RTE_PTYPE_L2_ETHER) == RTE_PTYPE_L2_ETHER)
+	}
+
+	switch (ptype & RTE_PTYPE_L2_MASK) {
+	case RTE_PTYPE_L2_ETHER:
 		return "eth";
+	}
 
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP)) ==
-		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP))
-		return "inner-ipv4-tcp";
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP)) ==
-		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP))
-		return "inner-ipv4-udp";
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP)) ==
-		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP))
-		return "inner-ipv4-sctp";
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP)) ==
-		(RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP))
+	switch (ptype & (RTE_PTYPE_INNER_L3_MASK | RTE_PTYPE_INNER_L4_MASK)) {
+	case RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP:
 		return "inner-ipv6-tcp";
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP)) ==
-		(RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP))
+	case RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP:
 		return "inner-ipv6-udp";
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP)) ==
-		(RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP))
+	case RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP:
 		return "inner-ipv6-sctp";
-	else if ((ptype & RTE_PTYPE_INNER_L4_TCP) == RTE_PTYPE_INNER_L4_TCP)
+	case RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP:
+		return "inner-ipv4-tcp";
+	case RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP:
+		return "inner-ipv4-udp";
+	case RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP:
+		return "inner-ipv4-sctp";
+	case RTE_PTYPE_INNER_L4_TCP:
 		return "inner-tcp";
-	else if ((ptype & RTE_PTYPE_INNER_L4_UDP) == RTE_PTYPE_INNER_L4_UDP)
+	case RTE_PTYPE_INNER_L4_UDP:
 		return "inner-udp";
-	else if ((ptype & RTE_PTYPE_INNER_L4_SCTP) == RTE_PTYPE_INNER_L4_SCTP)
+	case RTE_PTYPE_INNER_L4_SCTP:
 		return "inner-sctp";
-	else if ((ptype & RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN) ==
-		RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN)
-		return "inner-ipv4";
-	else if ((ptype & RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN) ==
-		RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN)
+	case RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN:
 		return "inner-ipv6";
-	else if ((ptype & RTE_PTYPE_INNER_L2_ETHER) == RTE_PTYPE_INNER_L2_ETHER)
+	case RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN:
+		return "inner-ipv4";
+	}
+
+	switch (ptype & RTE_PTYPE_INNER_L2_MASK) {
+	case RTE_PTYPE_INNER_L2_ETHER:
 		return "inner-eth";
-	else if ((ptype & RTE_PTYPE_TUNNEL_GRENAT) == RTE_PTYPE_TUNNEL_GRENAT)
+	}
+
+	switch (ptype & RTE_PTYPE_TUNNEL_MASK) {
+	case RTE_PTYPE_TUNNEL_GRENAT:
 		return "grenat";
-	else
-		return "unsupported";
+	}
+
+	return "unsupported";
 }
 
 void
Signature · 1 line
2.25.1
Tested-by on v3 1/1
#7 lore raw

RE: [PATCH v3] app/testpmd: fix protocol header display for Rx buffer split

Quoted 22 lines

-----Original Message-----
From: Wang, YuanX <[email protected]>
Sent: Monday, November 7, 2022 4:45 PM
To: [email protected]; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>
Cc: Ding, Xuan <[email protected]>; Tang, Yaqi <[email protected]>; [email protected]; Wang, YuanX <[email protected]>
Subject: [PATCH v3] app/testpmd: fix protocol header display for Rx buffer split

The "show config rxhdrs" cmd displays the configured protocol headers that are used for protocol-based buffer split.
However, it shows inner-ipv6 as inner-ipv4.

This patch fixes that by adjusting the order of condition judgments. This patch also uses RTE_PTYPE_*_MASK as masks.

Fixes 52e2e7edcf48 ("app/testpmd: add protocol-based buffer split")
Quoted 8 lines

---
v3:
- use RTE_PTYPE_*_MASK as masks.
- refactor to use switch statement.
v2:
- add fixline.

---

#8 lore raw

Re: [PATCH v3] app/testpmd: fix protocol header display for Rx buffer split

In reply to Yuan Wang
Quoted 27 lines · Yuan Wang

The "show config rxhdrs" cmd displays the configured protocol headers that are used for protocol-based buffer split.
However, it shows inner-ipv6 as inner-ipv4.

This patch fixes that by adjusting the order of condition judgments. This patch also uses RTE_PTYPE_*_MASK as masks.

Fixes 52e2e7edcf48 ("app/testpmd: add protocol-based buffer split")

---
v3:
- use RTE_PTYPE_*_MASK as masks.
- refactor to use switch statement.
v2:
- add fixline.

---
  app/test-pmd/config.c | 89 +++++++++++++++++++++----------------------
  1 file changed, 44 insertions(+), 45 deletions(-)
app/test-pmd/config.c +0 -0
index e8a1b77c2a..8638dfed11 100644

app/test-pmd/config.c show_rx_pkt_segments(void) · line 5075

Quoted 8 lines
app/test-pmd/config.c +2 -2
@@ -5070,73 +5070,72 @@ show_rx_pkt_segments(void)
 
  static const char *get_ptype_str(uint32_t ptype)
  {
-	if ((ptype & (RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP)) ==
-		(RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP))
+	switch (ptype & (RTE_PTYPE_L3_MASK | RTE_PTYPE_L4_MASK)) {
+	case RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP:
  		return "ipv4-tcp";

If I map "ipv4-tcp" to packets types, I get:
RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP but vice versa it is sufficient to have just RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP
I think such asymmetry in mapping is bad.

Quoted 29 lines
app/test-pmd/config.c +8 -13
-	else if ((ptype & (RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP)) ==
-		(RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP))
+	case RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP:
  		return "ipv4-udp";
-	else if ((ptype & (RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP)) ==
-		(RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP))
+	case RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP:
  		return "ipv4-sctp";
-	else if ((ptype & (RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP)) ==
-		(RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP))
+	case RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP:
  		return "ipv6-tcp";
-	else if ((ptype & (RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP)) ==
-		(RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP))
+	case RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP:
  		return "ipv6-udp";
-	else if ((ptype & (RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP)) ==
-		(RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP))
+	case RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP:
  		return "ipv6-sctp";
-	else if ((ptype & RTE_PTYPE_L4_TCP) == RTE_PTYPE_L4_TCP)
+	case RTE_PTYPE_L4_TCP:
  		return "tcp";
-	else if ((ptype & RTE_PTYPE_L4_UDP) == RTE_PTYPE_L4_UDP)
+	case RTE_PTYPE_L4_UDP:
  		return "udp";
-	else if ((ptype & RTE_PTYPE_L4_SCTP) == RTE_PTYPE_L4_SCTP)
+	case RTE_PTYPE_L4_SCTP:
  		return "sctp";

app/test-pmd/config.c show_rx_pkt_segments(void) · line 5098

Quoted 10 lines
app/test-pmd/config.c +5 -3
-	else if ((ptype & RTE_PTYPE_L3_IPV4_EXT_UNKNOWN) == RTE_PTYPE_L3_IPV4_EXT_UNKNOWN)
+	case RTE_PTYPE_L3_IPV4_EXT_UNKNOWN:
  		return "ipv4";
-	else if ((ptype & RTE_PTYPE_L3_IPV6_EXT_UNKNOWN) == RTE_PTYPE_L3_IPV6_EXT_UNKNOWN)
+	case RTE_PTYPE_L3_IPV6_EXT_UNKNOWN:
  		return "ipv6";
-	else if ((ptype & RTE_PTYPE_L2_ETHER) == RTE_PTYPE_L2_ETHER)
+	}
+
+	switch (ptype & RTE_PTYPE_L2_MASK) {

Having many switches here looks confusing. Who defines priorities? IMHO it should be single switch here and values should be in exactly the same order as get_ptype(). Ideally both function should be close to each other.

Quoted 8 lines
app/test-pmd/config.c +2 -4
+	case RTE_PTYPE_L2_ETHER:
  		return "eth";
+	}
 
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP)) ==
-		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP))
-		return "inner-ipv4-tcp";
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP)) ==

app/test-pmd/config.c show_rx_pkt_segments(void) · line 5105

Quoted 10 lines
app/test-pmd/config.c +2 -7
-		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP))
-		return "inner-ipv4-udp";
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP)) ==
-		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP))
-		return "inner-ipv4-sctp";
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP)) ==
-		(RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP))
+	switch (ptype & (RTE_PTYPE_INNER_L3_MASK | RTE_PTYPE_INNER_L4_MASK)) {
+	case RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP:
  		return "inner-ipv6-tcp";

get_ptype():
inner-ipv6-tcp -> RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP

So, mapping is asymmetric again.

Out of topic for the patch:
Also I'm wondering why inner-ipv6-tcp is a grenat. Why not VxLAN, not GENEVE?

Quoted 52 lines
app/test-pmd/config.c +25 -16
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP)) ==
-		(RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP))
+	case RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP:
  		return "inner-ipv6-udp";
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP)) ==
-		(RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP))
+	case RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP:
  		return "inner-ipv6-sctp";
-	else if ((ptype & RTE_PTYPE_INNER_L4_TCP) == RTE_PTYPE_INNER_L4_TCP)
+	case RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP:
+		return "inner-ipv4-tcp";
+	case RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP:
+		return "inner-ipv4-udp";
+	case RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP:
+		return "inner-ipv4-sctp";
+	case RTE_PTYPE_INNER_L4_TCP:
  		return "inner-tcp";
-	else if ((ptype & RTE_PTYPE_INNER_L4_UDP) == RTE_PTYPE_INNER_L4_UDP)
+	case RTE_PTYPE_INNER_L4_UDP:
  		return "inner-udp";
-	else if ((ptype & RTE_PTYPE_INNER_L4_SCTP) == RTE_PTYPE_INNER_L4_SCTP)
+	case RTE_PTYPE_INNER_L4_SCTP:
  		return "inner-sctp";
-	else if ((ptype & RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN) ==
-		RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN)
-		return "inner-ipv4";
-	else if ((ptype & RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN) ==
-		RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN)
+	case RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN:
  		return "inner-ipv6";
-	else if ((ptype & RTE_PTYPE_INNER_L2_ETHER) == RTE_PTYPE_INNER_L2_ETHER)
+	case RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN:
+		return "inner-ipv4";
+	}
+
+	switch (ptype & RTE_PTYPE_INNER_L2_MASK) {
+	case RTE_PTYPE_INNER_L2_ETHER:
  		return "inner-eth";
-	else if ((ptype & RTE_PTYPE_TUNNEL_GRENAT) == RTE_PTYPE_TUNNEL_GRENAT)
+	}
+
+	switch (ptype & RTE_PTYPE_TUNNEL_MASK) {
+	case RTE_PTYPE_TUNNEL_GRENAT:
  		return "grenat";
-	else
-		return "unsupported";
+	}
+
+	return "unsupported";
  }
 
  void
#9 lore raw

RE: [PATCH v3] app/testpmd: fix protocol header display for Rx buffer split

Hi Andrew,

Quoted 45 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, November 7, 2022 7:31 PM
To: Wang, YuanX <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>
Cc: Ding, Xuan <[email protected]>; Tang, Yaqi <[email protected]>; [email protected]
Subject: Re: [PATCH v3] app/testpmd: fix protocol header display for Rx buffer split

Quoted 27 lines · Yuan Wang

The "show config rxhdrs" cmd displays the configured protocol headers that are used for protocol-based buffer split.
However, it shows inner-ipv6 as inner-ipv4.

This patch fixes that by adjusting the order of condition judgments. This patch also uses RTE_PTYPE_*_MASK as masks.

Fixes 52e2e7edcf48 ("app/testpmd: add protocol-based buffer split")

---
v3:
- use RTE_PTYPE_*_MASK as masks.
- refactor to use switch statement.
v2:
- add fixline.

---
  app/test-pmd/config.c | 89 +++++++++++++++++++++----------------------
  1 file changed, 44 insertions(+), 45 deletions(-)
app/test-pmd/config.c index renamed from app/test-pmd/config.c +0 -0

e8a1b77c2a..8638dfed11 100644

app/test-pmd/config.c show_rx_pkt_segments(void) · line 5073

Quoted 4 lines
app/test-pmd/config.c +0 -1
@@ -5070,73 +5070,72 @@ show_rx_pkt_segments(void)
 
  static const char *get_ptype_str(uint32_t ptype)
  {
-	if ((ptype & (RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_L4_TCP)) ==

app/test-pmd/config.c show_rx_pkt_segments(void) · line 5074

Quoted 1 line
app/test-pmd/config.c +0 -1
-		(RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_L4_TCP))

Quoted 9 lines

app/test-pmd/config.c show_rx_pkt_segments(void) · line 5075

Quoted 3 lines
app/test-pmd/config.c +2 -0
+	switch (ptype & (RTE_PTYPE_L3_MASK | RTE_PTYPE_L4_MASK)) {
+	case RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP:
  		return "ipv4-tcp";

If I map "ipv4-tcp" to packets types, I get:
RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP but vice versa it is sufficient to have just RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP I think such asymmetry in mapping is bad.

The reason for the asymmetric is that the lib requires that each segment cannot be repeated with the previous one. For example "set rxhdrs eth,ipv4-udp", seg[0]=RTE_PTYPE_L2_ETHER,seg[1]=RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP. In order not to duplicate, seg[1] is truncated to RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP.
In this way we can use the truncated seg[1] to map to "ipv4-udp". The same goes for tunneled packets.

Quoted 46 lines

app/test-pmd/config.c show_rx_pkt_segments(void) · line 5076

Quoted 2 lines
app/test-pmd/config.c +0 -1
-	else if ((ptype & (RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_L4_UDP)) ==

app/test-pmd/config.c show_rx_pkt_segments(void) · line 5077

Quoted 1 line
app/test-pmd/config.c +0 -1
-		(RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_L4_UDP))

app/test-pmd/config.c show_rx_pkt_segments(void)

Quoted 3 lines
app/test-pmd/config.c +1 -1
+	case RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP:
  		return "ipv4-udp";
-	else if ((ptype & (RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_L4_SCTP)) ==

app/test-pmd/config.c show_rx_pkt_segments(void) · line 5080

Quoted 1 line
app/test-pmd/config.c +0 -1
-		(RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_L4_SCTP))

app/test-pmd/config.c show_rx_pkt_segments(void)

Quoted 3 lines
app/test-pmd/config.c +1 -1
+	case RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP:
  		return "ipv4-sctp";
-	else if ((ptype & (RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |

RTE_PTYPE_L4_TCP)) ==

app/test-pmd/config.c show_rx_pkt_segments(void) · line 5083

Quoted 1 line
app/test-pmd/config.c +0 -1
-		(RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |

RTE_PTYPE_L4_TCP))

app/test-pmd/config.c show_rx_pkt_segments(void)

Quoted 3 lines
app/test-pmd/config.c +1 -1
+	case RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP:
  		return "ipv6-tcp";
-	else if ((ptype & (RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |

RTE_PTYPE_L4_UDP)) ==

app/test-pmd/config.c show_rx_pkt_segments(void) · line 5086

Quoted 1 line
app/test-pmd/config.c +0 -1
-		(RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |

RTE_PTYPE_L4_UDP))

app/test-pmd/config.c show_rx_pkt_segments(void)

Quoted 3 lines
app/test-pmd/config.c +1 -1
+	case RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP:
  		return "ipv6-udp";
-	else if ((ptype & (RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |

RTE_PTYPE_L4_SCTP)) ==

app/test-pmd/config.c show_rx_pkt_segments(void) · line 5089

Quoted 1 line
app/test-pmd/config.c +0 -1
-		(RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |

RTE_PTYPE_L4_SCTP))

app/test-pmd/config.c show_rx_pkt_segments(void)

Quoted 12 lines
app/test-pmd/config.c +4 -4
+	case RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP:
  		return "ipv6-sctp";
-	else if ((ptype & RTE_PTYPE_L4_TCP) == RTE_PTYPE_L4_TCP)
+	case RTE_PTYPE_L4_TCP:
  		return "tcp";
-	else if ((ptype & RTE_PTYPE_L4_UDP) == RTE_PTYPE_L4_UDP)
+	case RTE_PTYPE_L4_UDP:
  		return "udp";
-	else if ((ptype & RTE_PTYPE_L4_SCTP) == RTE_PTYPE_L4_SCTP)
+	case RTE_PTYPE_L4_SCTP:
  		return "sctp";
-	else if ((ptype & RTE_PTYPE_L3_IPV4_EXT_UNKNOWN) ==

RTE_PTYPE_L3_IPV4_EXT_UNKNOWN)

app/test-pmd/config.c show_rx_pkt_segments(void)

Quoted 3 lines
app/test-pmd/config.c +1 -1
+	case RTE_PTYPE_L3_IPV4_EXT_UNKNOWN:
  		return "ipv4";
-	else if ((ptype & RTE_PTYPE_L3_IPV6_EXT_UNKNOWN) ==

RTE_PTYPE_L3_IPV6_EXT_UNKNOWN)

Quoted 11 lines

app/test-pmd/config.c show_rx_pkt_segments(void) · line 5098

Quoted 6 lines
app/test-pmd/config.c +4 -1
+	case RTE_PTYPE_L3_IPV6_EXT_UNKNOWN:
  		return "ipv6";
-	else if ((ptype & RTE_PTYPE_L2_ETHER) == RTE_PTYPE_L2_ETHER)
+	}
+
+	switch (ptype & RTE_PTYPE_L2_MASK) {

Having many switches here looks confusing. Who defines priorities? IMHO it should be single switch here and values should be in exactly the same order as get_ptype().
Ideally both function should be close to each other.

The order of switch statement (and if statement as well) is to correctly map ptype to string. For example set rxhdrs ipv4-udp corresponds to RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN UNKNOWN | RTE_PTYPE_L4_UDP; we need to prioritize RTE_PTYPE_L3_IPV4_EXT_UNKNOWN|RTE_PTYPE_L4_UDP over RTE_PTYPE_L2_ETHER.

I have an idea to solve the multiple switches and asymmetry issue by adding a variable to hold the original ptypes. Please see v4.

Quoted 35 lines

app/test-pmd/config.c show_rx_pkt_segments(void)

Quoted 6 lines
app/test-pmd/config.c +2 -1
+	case RTE_PTYPE_L2_ETHER:
  		return "eth";
+	}
 
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_INNER_L4_TCP)) ==

app/test-pmd/config.c show_rx_pkt_segments(void) · line 5105

Quoted 1 line
app/test-pmd/config.c +0 -1
-		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_INNER_L4_TCP))

app/test-pmd/config.c show_rx_pkt_segments(void) · line 5107

Quoted 2 lines
app/test-pmd/config.c +0 -2
-		return "inner-ipv4-tcp";
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_INNER_L4_UDP)) ==

app/test-pmd/config.c show_rx_pkt_segments(void) · line 5108

Quoted 1 line
app/test-pmd/config.c +0 -1
-		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_INNER_L4_UDP))

app/test-pmd/config.c show_rx_pkt_segments(void) · line 5110

Quoted 2 lines
app/test-pmd/config.c +0 -2
-		return "inner-ipv4-udp";
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_INNER_L4_SCTP)) ==

app/test-pmd/config.c show_rx_pkt_segments(void) · line 5111

Quoted 1 line
app/test-pmd/config.c +0 -1
-		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |

RTE_PTYPE_INNER_L4_SCTP))

app/test-pmd/config.c show_rx_pkt_segments(void) · line 5113

Quoted 2 lines
app/test-pmd/config.c +0 -2
-		return "inner-ipv4-sctp";
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |

RTE_PTYPE_INNER_L4_TCP)) ==

app/test-pmd/config.c show_rx_pkt_segments(void) · line 5114

Quoted 1 line
app/test-pmd/config.c +0 -1
-		(RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |

RTE_PTYPE_INNER_L4_TCP))

app/test-pmd/config.c show_rx_pkt_segments(void) · line 5103

Quoted 1 line
app/test-pmd/config.c +1 -0
+	switch (ptype & (RTE_PTYPE_INNER_L3_MASK |

RTE_PTYPE_INNER_L4_MASK)) {

app/test-pmd/config.c show_rx_pkt_segments(void) · line 5104

Quoted 1 line
app/test-pmd/config.c +1 -0
+	case RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |

RTE_PTYPE_INNER_L4_TCP:

app/test-pmd/config.c show_rx_pkt_segments(void) · line 5105

Quoted 1 line
app/test-pmd/config.c +0 -0
  		return "inner-ipv6-tcp";

get_ptype():
inner-ipv6-tcp -> RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP

Quoted 5 lines

So, mapping is asymmetric again.

Out of topic for the patch:
Also I'm wondering why inner-ipv6-tcp is a grenat. Why not VxLAN, not GENEVE?

The reason inner-ipv6-tcp is grenat is to simplify the expression.
If add VxLAN/GENEVE, then the setting command needs to be changed to grenat-ipv6-tcp,VxLAN-ipv6-tcp,GENEVE-ipv6-tcp, and so on grenat-ipv6,VxLANX-ipv6... This increases the complexity of the command.
So, for simplicity we choose grenat as the default for tunneled packets.
Any thoughts?

Thanks,
Yuan

author
#10 lore raw

PATCH v4 1/1 app/testpmd: fix protocol header display for Rx buffer split

In reply to Yuan Wang

The "show config rxhdrs" cmd displays the configured protocol headers that are used for protocol-based buffer split.
However, it shows inner-ipv6 as inner-ipv4.

This patch fixes that by redefining rx_pkt_hdr_protos to hold the full ptypes, and the show and set commands therefore remain symmetrical.

Fixes 52e2e7edcf48 ("app/testpmd: add protocol-based buffer split")

---
v4:
- redefine rx_pkt_hdr_protos to hold the full ptypes.
- use single switch in get_ptype_str().
v3:
- use RTE_PTYPE_*_MASK as masks.
- refactor to use switch statement.
v2:
- add fixline.

---
 app/test-pmd/cmdline.c |  12 ++--
 app/test-pmd/config.c  | 141 +++++++++++++++++++++--------------------
 app/test-pmd/testpmd.c |   5 +-
 3 files changed, 82 insertions(+), 76 deletions(-)
app/test-pmd/cmdline.c +4 -8
index 3fbcb6ca8f..f7df24f105 100644
@@ -3443,20 +3443,16 @@ parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items,
 				unsigned int *parsed_items)
 {
 	unsigned int nb_item;
-	char *cur;
-	char *tmp;
-	unsigned int cur_item, prev_items = 0;
+	char *cur, *tmp;
+	char *str2;
 
 	nb_item = 0;
-	char *str2 = strdup(str);
+	str2 = strdup(str);
 	cur = strtok_r(str2, ",", &tmp);
 	while (cur != NULL) {
-		cur_item = get_ptype(cur);
-		cur_item &= ~prev_items;
-		parsed_items[nb_item] = cur_item;
+		parsed_items[nb_item] = get_ptype(cur);
 		cur = strtok_r(NULL, ",", &tmp);
 		nb_item++;
-		prev_items |= cur_item;
 	}
 	if (nb_item > max_items)
 		fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
app/test-pmd/config.c +74 -67

153 lines not on this page · raw message

app/test-pmd/testpmd.c +4 -1
index 7381dfd9e5..b4a1fb360f 100644
@@ -2654,6 +2654,7 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 {
 	union rte_eth_rxseg rx_useg[MAX_SEGS_BUFFER_SPLIT] = {};
 	unsigned int i, mp_n;
+	uint32_t prev_hdrs = 0;
 	int ret;
 
 	if (rx_pkt_nb_segs <= 1 ||
@@ -2668,6 +2669,7 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 	for (i = 0; i < rx_pkt_nb_segs; i++) {
 		struct rte_eth_rxseg_split *rx_seg = &rx_useg[i].split;
 		struct rte_mempool *mpx;
+
 		/*
 		 * Use last valid pool for the segments with number
 		 * exceeding the pool index.
@@ -2679,7 +2681,8 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 				   rx_pkt_seg_offsets[i] : 0;
 		rx_seg->mp = mpx ? mpx : mp;
 		if (rx_pkt_hdr_protos[i] != 0 && rx_pkt_seg_lengths[i] == 0) {
-			rx_seg->proto_hdr = rx_pkt_hdr_protos[i];
+			rx_seg->proto_hdr = rx_pkt_hdr_protos[i] & ~prev_hdrs;
+			prev_hdrs |= rx_seg->proto_hdr;
 		} else {
 			rx_seg->length = rx_pkt_seg_lengths[i] ?
 					rx_pkt_seg_lengths[i] :
Signature · 1 line
2.25.1
#11 lore raw

Re: [PATCH v4] app/testpmd: fix protocol header display for Rx buffer split

Quoted 33 lines · Yuan Wang

The "show config rxhdrs" cmd displays the configured protocol headers that are used for protocol-based buffer split.
However, it shows inner-ipv6 as inner-ipv4.

This patch fixes that by redefining rx_pkt_hdr_protos to hold the full ptypes, and the show and set commands therefore remain symmetrical.

Fixes 52e2e7edcf48 ("app/testpmd: add protocol-based buffer split")

---
v4:
- redefine rx_pkt_hdr_protos to hold the full ptypes.
- use single switch in get_ptype_str().
v3:
- use RTE_PTYPE_*_MASK as masks.
- refactor to use switch statement.
v2:
- add fixline.

---
  app/test-pmd/cmdline.c |  12 ++--
  app/test-pmd/config.c  | 141 +++++++++++++++++++++--------------------
  app/test-pmd/testpmd.c |   5 +-
  3 files changed, 82 insertions(+), 76 deletions(-)
app/test-pmd/cmdline.c +0 -0
index 3fbcb6ca8f..f7df24f105 100644

app/test-pmd/cmdline.c parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items, · line 3446

Quoted 7 lines
app/test-pmd/cmdline.c +1 -3
@@ -3443,20 +3443,16 @@ parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items,
  				unsigned int *parsed_items)
  {
  	unsigned int nb_item;
-	char *cur;
-	char *tmp;
-	unsigned int cur_item, prev_items = 0;
+	char *cur, *tmp;

above line is unrelated changes

app/test-pmd/cmdline.c parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items, · line 3450

Quoted 5 lines
app/test-pmd/cmdline.c +2 -1
+	char *str2;
 
  	nb_item = 0;
-	char *str2 = strdup(str);
+	str2 = strdup(str);

I've failed to find where str2 is freed.

Quoted 184 lines
app/test-pmd/cmdline.c +1 -4
  	cur = strtok_r(str2, ",", &tmp);
  	while (cur != NULL) {
-		cur_item = get_ptype(cur);
-		cur_item &= ~prev_items;
-		parsed_items[nb_item] = cur_item;
+		parsed_items[nb_item] = get_ptype(cur);
  		cur = strtok_r(NULL, ",", &tmp);
  		nb_item++;
-		prev_items |= cur_item;
  	}
  	if (nb_item > max_items)
  		fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
app/test-pmd/config.c +74 -67
index e8a1b77c2a..755728966b 100644
@@ -5070,73 +5070,79 @@ show_rx_pkt_segments(void)
 
  static const char *get_ptype_str(uint32_t ptype)
  {
-	if ((ptype & (RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP)) ==
-		(RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP))
-		return "ipv4-tcp";
-	else if ((ptype & (RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP)) ==
-		(RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP))
-		return "ipv4-udp";
-	else if ((ptype & (RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP)) ==
-		(RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP))
-		return "ipv4-sctp";
-	else if ((ptype & (RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP)) ==
-		(RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP))
-		return "ipv6-tcp";
-	else if ((ptype & (RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP)) ==
-		(RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP))
-		return "ipv6-udp";
-	else if ((ptype & (RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP)) ==
-		(RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP))
-		return "ipv6-sctp";
-	else if ((ptype & RTE_PTYPE_L4_TCP) == RTE_PTYPE_L4_TCP)
-		return "tcp";
-	else if ((ptype & RTE_PTYPE_L4_UDP) == RTE_PTYPE_L4_UDP)
-		return "udp";
-	else if ((ptype & RTE_PTYPE_L4_SCTP) == RTE_PTYPE_L4_SCTP)
-		return "sctp";
-	else if ((ptype & RTE_PTYPE_L3_IPV4_EXT_UNKNOWN) == RTE_PTYPE_L3_IPV4_EXT_UNKNOWN)
-		return "ipv4";
-	else if ((ptype & RTE_PTYPE_L3_IPV6_EXT_UNKNOWN) == RTE_PTYPE_L3_IPV6_EXT_UNKNOWN)
-		return "ipv6";
-	else if ((ptype & RTE_PTYPE_L2_ETHER) == RTE_PTYPE_L2_ETHER)
-		return "eth";
-
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP)) ==
-		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP))
-		return "inner-ipv4-tcp";
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP)) ==
-		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP))
-		return "inner-ipv4-udp";
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP)) ==
-		(RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP))
-		return "inner-ipv4-sctp";
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP)) ==
-		(RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP))
-		return "inner-ipv6-tcp";
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP)) ==
-		(RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP))
-		return "inner-ipv6-udp";
-	else if ((ptype & (RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP)) ==
-		(RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP))
-		return "inner-ipv6-sctp";
-	else if ((ptype & RTE_PTYPE_INNER_L4_TCP) == RTE_PTYPE_INNER_L4_TCP)
-		return "inner-tcp";
-	else if ((ptype & RTE_PTYPE_INNER_L4_UDP) == RTE_PTYPE_INNER_L4_UDP)
-		return "inner-udp";
-	else if ((ptype & RTE_PTYPE_INNER_L4_SCTP) == RTE_PTYPE_INNER_L4_SCTP)
-		return "inner-sctp";
-	else if ((ptype & RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN) ==
-		RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN)
-		return "inner-ipv4";
-	else if ((ptype & RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN) ==
-		RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN)
-		return "inner-ipv6";
-	else if ((ptype & RTE_PTYPE_INNER_L2_ETHER) == RTE_PTYPE_INNER_L2_ETHER)
-		return "inner-eth";
-	else if ((ptype & RTE_PTYPE_TUNNEL_GRENAT) == RTE_PTYPE_TUNNEL_GRENAT)
-		return "grenat";
-	else
-		return "unsupported";
+	const char *str;
+
+	switch (ptype) {
+	case RTE_PTYPE_L2_ETHER:
+		str = "eth";
+		break;
+	case RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN:
+		str = "ipv4";
+		break;
+	case RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN:
+		str = "ipv6";
+		break;
+	case RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP:
+		str = "ipv4-tcp";
+		break;
+	case RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP:
+		str = "ipv4-udp";
+		break;
+	case RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP:
+		str = "ipv4-sctp";
+		break;
+	case RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP:
+		str = "ipv6-tcp";
+		break;
+	case RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP:
+		str = "ipv6-udp";
+		break;
+	case RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP:
+		str = "ipv6-sctp";
+		break;
+	case RTE_PTYPE_TUNNEL_GRENAT:
+		str = "grenat";
+		break;
+	case RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER:
+		str = "inner-eth";
+		break;
+	case RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER
+			| RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN:
+		str = "inner-ipv4";
+		break;
+	case RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER
+			| RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN:
+		str = "inner-ipv6";
+		break;
+	case RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
+			RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP:
+		str = "inner-ipv4-tcp";
+		break;
+	case RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
+			RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP:
+		str = "inner-ipv4-udp";
+		break;
+	case RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
+			RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP:
+		str = "inner-ipv4-sctp";
+		break;
+	case RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
+			RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP:
+		str = "inner-ipv6-tcp";
+		break;
+	case RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
+			RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP:
+		str = "inner-ipv6-udp";
+		break;
+	case RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
+			RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP:
+		str = "inner-ipv6-sctp";
+		break;
+	default:
+		str = "unsupported";
+	}
+
+	return str;
  }
 
  void
@@ -5169,6 +5175,7 @@ set_rx_pkt_hdrs(unsigned int *seg_hdrs, unsigned int nb_segs)
 
  	for (i = 0; i < nb_segs; i++)
  		rx_pkt_hdr_protos[i] = (uint32_t)seg_hdrs[i];
+
  	/*
  	 * We calculate the number of hdrs, but payload is not included,
  	 * so rx_pkt_nb_segs would increase 1.
app/test-pmd/testpmd.c +1 -0
index 7381dfd9e5..b4a1fb360f 100644
@@ -2654,6 +2654,7 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
  {
  	union rte_eth_rxseg rx_useg[MAX_SEGS_BUFFER_SPLIT] = {};
  	unsigned int i, mp_n;
+	uint32_t prev_hdrs = 0;
  	int ret;
 
  	if (rx_pkt_nb_segs <= 1 ||

app/test-pmd/testpmd.c rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 2672

Quoted 4 lines
app/test-pmd/testpmd.c +1 -0
@@ -2668,6 +2669,7 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
  	for (i = 0; i < rx_pkt_nb_segs; i++) {
  		struct rte_eth_rxseg_split *rx_seg = &rx_useg[i].split;
  		struct rte_mempool *mpx;
+

unrelated changes, avoid it

Quoted 13 lines
app/test-pmd/testpmd.c +2 -1
  		/*
  		 * Use last valid pool for the segments with number
  		 * exceeding the pool index.
@@ -2679,7 +2681,8 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
  				   rx_pkt_seg_offsets[i] : 0;
  		rx_seg->mp = mpx ? mpx : mp;
  		if (rx_pkt_hdr_protos[i] != 0 && rx_pkt_seg_lengths[i] == 0) {
-			rx_seg->proto_hdr = rx_pkt_hdr_protos[i];
+			rx_seg->proto_hdr = rx_pkt_hdr_protos[i] & ~prev_hdrs;
+			prev_hdrs |= rx_seg->proto_hdr;
  		} else {
  			rx_seg->length = rx_pkt_seg_lengths[i] ?
  					rx_pkt_seg_lengths[i] :
#12 lore raw

RE: [PATCH v4] app/testpmd: fix protocol header display for Rx buffer split

Hi Andrew,

Quoted 44 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Thursday, November 10, 2022 2:56 PM
To: Wang, YuanX <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>
Cc: Ding, Xuan <[email protected]>; Tang, Yaqi <[email protected]>; [email protected]
Subject: Re: [PATCH v4] app/testpmd: fix protocol header display for Rx buffer split

app/test-pmd/cmdline.c parse_hdrs_list(const char *str, const char

Quoted 32 lines · Yuan Wang

The "show config rxhdrs" cmd displays the configured protocol headers that are used for protocol-based buffer split.
However, it shows inner-ipv6 as inner-ipv4.

This patch fixes that by redefining rx_pkt_hdr_protos to hold the full ptypes, and the show and set commands therefore remain symmetrical.

Fixes 52e2e7edcf48 ("app/testpmd: add protocol-based buffer split")

---
v4:
- redefine rx_pkt_hdr_protos to hold the full ptypes.
- use single switch in get_ptype_str().
v3:
- use RTE_PTYPE_*_MASK as masks.
- refactor to use switch statement.
v2:
- add fixline.

---
  app/test-pmd/cmdline.c |  12 ++--
  app/test-pmd/config.c  | 141 +++++++++++++++++++++--------------------
  app/test-pmd/testpmd.c |   5 +-
  3 files changed, 82 insertions(+), 76 deletions(-)
app/test-pmd/cmdline.c index renamed from app/test-pmd/cmdline.c +0 -0

3fbcb6ca8f..f7df24f105 100644

app/test-pmd/cmdline.c +0 -0
@@ -3443,20 +3443,16 @@ parse_hdrs_list(const char *str, const char

*item_name, unsigned int max_items,

Quoted 9 lines

app/test-pmd/cmdline.c parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items, · line 3446

Quoted 7 lines
app/test-pmd/cmdline.c +1 -3
  				unsigned int *parsed_items)
  {
  	unsigned int nb_item;
-	char *cur;
-	char *tmp;
-	unsigned int cur_item, prev_items = 0;
+	char *cur, *tmp;

above line is unrelated changes

Sorry for the unrelated changes, they will be removed in the new version.

Quoted 8 lines

app/test-pmd/cmdline.c parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items, · line 3450

Quoted 6 lines
app/test-pmd/cmdline.c +2 -1
+	char *str2;
 
  	nb_item = 0;
-	char *str2 = strdup(str);
+	str2 = strdup(str);

I've failed to find where str2 is freed.

This is also an unrelated change to make the code to follow the code style. It is not a new variable that has been freed in the code. The change will be removed to make the patch clean.

Quoted 14 lines

app/test-pmd/cmdline.c parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items,

Quoted 13 lines
app/test-pmd/cmdline.c +1 -4
  	cur = strtok_r(str2, ",", &tmp);
  	while (cur != NULL) {
-		cur_item = get_ptype(cur);
-		cur_item &= ~prev_items;
-		parsed_items[nb_item] = cur_item;
+		parsed_items[nb_item] = get_ptype(cur);
  		cur = strtok_r(NULL, ",", &tmp);
  		nb_item++;
-		prev_items |= cur_item;
  	}
  	if (nb_item > max_items)
  		fprintf(stderr, "Number of %s = %u > %u (maximum

items)\n", diff

[...]

Quoted 27 lines

app/test-pmd/cmdline.c set_rx_pkt_hdrs(unsigned int *seg_hdrs,

Quoted 3 lines

void

app/test-pmd/cmdline.c +0 -0
@@ -5169,6 +5175,7 @@ set_rx_pkt_hdrs(unsigned int *seg_hdrs,

unsigned

app/test-pmd/testpmd.c rx_queue_setup(uint16_t port_id, uint16_t

Quoted 13 lines
app/test-pmd/cmdline.c +1 -0
 int nb_segs)
 
  	for (i = 0; i < nb_segs; i++)
  		rx_pkt_hdr_protos[i] = (uint32_t)seg_hdrs[i];
+
  	/*
  	 * We calculate the number of hdrs, but payload is not included,

* so rx_pkt_nb_segs would increase 1.

app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0 -0

7381dfd9e5..b4a1fb360f 100644

app/test-pmd/testpmd.c +0 -0
@@ -2654,6 +2654,7 @@ rx_queue_setup(uint16_t port_id, uint16_t

rx_queue_id,

app/test-pmd/testpmd.c rx_queue_setup(uint16_t port_id, uint16_t

Quoted 8 lines
app/test-pmd/testpmd.c +1 -0
  {
  	union rte_eth_rxseg rx_useg[MAX_SEGS_BUFFER_SPLIT] = {};
  	unsigned int i, mp_n;
+	uint32_t prev_hdrs = 0;
  	int ret;
 
  	if (rx_pkt_nb_segs <= 1 ||
@@ -2668,6 +2669,7 @@ rx_queue_setup(uint16_t port_id, uint16_t

rx_queue_id,

Quoted 6 lines

app/test-pmd/testpmd.c rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 2672

Quoted 4 lines
app/test-pmd/testpmd.c +1 -0
  	for (i = 0; i < rx_pkt_nb_segs; i++) {
  		struct rte_eth_rxseg_split *rx_seg = &rx_useg[i].split;
  		struct rte_mempool *mpx;
+

unrelated changes, avoid it

Will fix in v5.

Thanks,
Yuan

author
#13 lore raw

PATCH v5 1/1 app/testpmd: fix protocol header display for Rx buffer split

In reply to Yuan Wang

The "show config rxhdrs" cmd displays the configured protocol headers that are used for protocol-based buffer split.
However, it shows inner-ipv6 as inner-ipv4.

This patch fixes that by redefining rx_pkt_hdr_protos to hold the full ptypes, and the show and set commands therefore remain symmetrical.

Fixes 52e2e7edcf48 ("app/testpmd: add protocol-based buffer split")

---
v5:
- remove unrelated changes.
v4:
- redefine rx_pkt_hdr_protos to hold the full ptypes.
- use single switch in get_ptype_str().
v3:
- use RTE_PTYPE_*_MASK as masks.
- refactor to use switch statement.
v2:
- add fixline.

---
 app/test-pmd/cmdline.c |   6 +-
 app/test-pmd/config.c  | 140 +++++++++++++++++++++--------------------
 app/test-pmd/testpmd.c |   4 +-
 3 files changed, 77 insertions(+), 73 deletions(-)
app/test-pmd/cmdline.c +1 -5
index 8dc60e9388..8ffd62cac9 100644
@@ -3445,18 +3445,14 @@ parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items,
 	unsigned int nb_item;
 	char *cur;
 	char *tmp;
-	unsigned int cur_item, prev_items = 0;
 
 	nb_item = 0;
 	char *str2 = strdup(str);
 	cur = strtok_r(str2, ",", &tmp);
 	while (cur != NULL) {
-		cur_item = get_ptype(cur);
-		cur_item &= ~prev_items;
-		parsed_items[nb_item] = cur_item;
+		parsed_items[nb_item] = get_ptype(cur);
 		cur = strtok_r(NULL, ",", &tmp);
 		nb_item++;
-		prev_items |= cur_item;
 	}
 	if (nb_item > max_items)
 		fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
app/test-pmd/config.c +73 -67

146 lines not on this page · raw message

app/test-pmd/testpmd.c +3 -1
index aa7ea29f15..401ac8b280 100644
@@ -2654,6 +2654,7 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 {
 	union rte_eth_rxseg rx_useg[MAX_SEGS_BUFFER_SPLIT] = {};
 	unsigned int i, mp_n;
+	uint32_t prev_hdrs = 0;
 	int ret;
 
 	if (rx_pkt_nb_segs <= 1 ||
@@ -2679,7 +2680,8 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 				   rx_pkt_seg_offsets[i] : 0;
 		rx_seg->mp = mpx ? mpx : mp;
 		if (rx_pkt_hdr_protos[i] != 0 && rx_pkt_seg_lengths[i] == 0) {
-			rx_seg->proto_hdr = rx_pkt_hdr_protos[i];
+			rx_seg->proto_hdr = rx_pkt_hdr_protos[i] & ~prev_hdrs;
+			prev_hdrs |= rx_seg->proto_hdr;
 		} else {
 			rx_seg->length = rx_pkt_seg_lengths[i] ?
 					rx_pkt_seg_lengths[i] :
Signature · 1 line
2.25.1
Reviewed-by on v5 1/1 Applied
#14 lore raw

Re: [PATCH v5] app/testpmd: fix protocol header display for Rx buffer split

Quoted 11 lines · Yuan Wang

The "show config rxhdrs" cmd displays the configured protocol headers that are used for protocol-based buffer split.
However, it shows inner-ipv6 as inner-ipv4.

This patch fixes that by redefining rx_pkt_hdr_protos to hold the full ptypes, and the show and set commands therefore remain symmetrical.

Fixes 52e2e7edcf48 ("app/testpmd: add protocol-based buffer split")

Applied to dpdk-next-net/main, thanks.