Skip to contentSkip to conversation

net/tap: fix blocked rx packets error

PATCH Superseded Marcin Smoczynski 5 participants 8 messages Sep 2, 2019 – Oct 10, 2019 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/tap: fix blocked rx packets error

When OS sends more packets than are beaing read with a single 'rte_eth_rx_burst' call, rx packets are getting stucked in the tap pmd and are unable to receive, because trigger_seen is getting updated and consecutive calls are not getting any packets.

Do not update trigger_seen unless less than a max number of packets were received allowing next call to receive the rest.

Fixes a0d8e807d9 ("net/tap: add Rx trigger")
---
 drivers/net/tap/rte_eth_tap.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/tap/rte_eth_tap.c +4 -2
index 64bd04911..60121ae56 100644
@@ -353,8 +353,7 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 
 	if (trigger == rxq->trigger_seen)
 		return 0;
-	if (trigger)
-		rxq->trigger_seen = trigger;
+
 	process_private = rte_eth_devices[rxq->in_port].process_private;
 	rte_compiler_barrier();
 	for (num_rx = 0; num_rx < nb_pkts; ) {
@@ -433,6 +432,9 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	rxq->stats.ipackets += num_rx;
 	rxq->stats.ibytes += num_rx_bytes;
 
+	if (trigger && num_rx < nb_pkts)
+		rxq->trigger_seen = trigger;
+
 	return num_rx;
 }
 
Signature · 1 line
2.17.1
Acked-by Tested-by on v1 1/1
#1 lore raw
Quoted 41 lines

-----Original Message-----
From: Smoczynski, MarcinX
Sent: Monday, September 2, 2019 12:43 PM
To: Ananyev, Konstantin <[email protected]>; Wiles, Keith <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Smoczynski, MarcinX <[email protected]>; Drost, MariuszX <[email protected]>
Subject: [PATCH v1] net/tap: fix blocked rx packets error

When OS sends more packets than are beaing read with a single 'rte_eth_rx_burst' call, rx packets are getting stucked in the tap pmd and are unable to receive, because trigger_seen is getting updated and consecutive calls are not getting any packets.

Do not update trigger_seen unless less than a max number of packets were received allowing next call to receive the rest.

Fixes a0d8e807d9 ("net/tap: add Rx trigger")
---
 drivers/net/tap/rte_eth_tap.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/tap/rte_eth_tap.c +1 -2
index 64bd04911..60121ae56 100644
@@ -353,8 +353,7 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 
 	if (trigger == rxq->trigger_seen)
 		return 0;
-	if (trigger)
-		rxq->trigger_seen = trigger;
+
 	process_private = rte_eth_devices[rxq->in_port].process_private;
 	rte_compiler_barrier();
 	for (num_rx = 0; num_rx < nb_pkts; ) {

drivers/net/tap/rte_eth_tap.c pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)

Quoted 10 lines
drivers/net/tap/rte_eth_tap.c +3 -1
@@ -433,6 +432,9 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	rxq->stats.ipackets += num_rx;
 	rxq->stats.ibytes += num_rx_bytes;
 
+	if (trigger && num_rx < nb_pkts)
+		rxq->trigger_seen = trigger;
+
 	return num_rx;
 }
 
--
Quoted 1 line

2.17.1

#2 lore raw
In reply to Marcin Smoczynski

HI Marcin,

Quoted 11 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Marcin Smoczynski
Sent: Monday, September 2, 2019 7:43 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; Marcin Smoczynski <[email protected]>; Mariusz Drost <[email protected]>
Subject: [dpdk-dev] [PATCH v1] net/tap: fix blocked rx packets error

When OS sends more packets than are beaing read with a single

s/ beaing/being

Quoted 21 lines

'rte_eth_rx_burst' call, rx packets are getting stucked in the tap pmd and are unable to receive, because trigger_seen is getting updated and consecutive calls are not getting any packets.

Do not update trigger_seen unless less than a max number of packets were received allowing next call to receive the rest.

Fixes a0d8e807d9 ("net/tap: add Rx trigger")
---
 drivers/net/tap/rte_eth_tap.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/tap/rte_eth_tap.c +0 -0
index 64bd04911..60121ae56 100644

drivers/net/tap/rte_eth_tap.c pmd_rx_burst(void *queue, struct rte_mbuf **bufs, · line 359

Quoted 9 lines
drivers/net/tap/rte_eth_tap.c +1 -2
@@ -353,8 +353,7 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs,
 uint16_t nb_pkts)
 
      if (trigger == rxq->trigger_seen)
              return 0;
-     if (trigger)
-             rxq->trigger_seen = trigger;
+
      process_private = rte_eth_devices[rxq->in_port].process_private;
      rte_compiler_barrier();

I see this compiler barrier was added together with the above "rxq->trigger_seen = trigger", should it be removed or moved together downwards?

Quoted 13 lines
      for (num_rx = 0; num_rx < nb_pkts; ) {
drivers/net/tap/rte_eth_tap.c +3 -1
@@ -433,6 +432,9 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs,
 uint16_t nb_pkts)
      rxq->stats.ipackets += num_rx;
      rxq->stats.ibytes += num_rx_bytes;
 
+     if (trigger && num_rx < nb_pkts)
+             rxq->trigger_seen = trigger;
+
      return num_rx;
 }
 
--
Quoted 1 line

2.17.1

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

#3 lore raw
Quoted 24 lines

-----Original Message-----
From: Gavin Hu (Arm Technology China) [mailto:[email protected]]
Sent: Thursday, September 5, 2019 7:44 AM
To: Smoczynski, MarcinX <[email protected]>; Ananyev, Konstantin <[email protected]>; Wiles, Keith <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Drost, MariuszX <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v1] net/tap: fix blocked rx packets error

HI Marcin,

Quoted 10 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Marcin Smoczynski
Sent: Monday, September 2, 2019 7:43 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; Marcin Smoczynski <[email protected]>; Mariusz Drost <[email protected]>
Subject: [dpdk-dev] [PATCH v1] net/tap: fix blocked rx packets error

Quoted 2 lines
Quoted 1 line

When OS sends more packets than are beaing read with a single

s/ beaing/being

Thanks for that, will be corrected in the v2.

Quoted 32 lines

drivers/net/tap/rte_eth_tap.c pmd_rx_burst(void *queue, struct rte_mbuf

Quoted 22 lines

'rte_eth_rx_burst' call, rx packets are getting stucked in the tap pmd and are unable to receive, because trigger_seen is getting updated and consecutive calls are not getting any packets.

Do not update trigger_seen unless less than a max number of packets were received allowing next call to receive the rest.

Fixes a0d8e807d9 ("net/tap: add Rx trigger")
---
 drivers/net/tap/rte_eth_tap.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/net/tap/rte_eth_tap.c index 64bd04911..60121ae56 100644

drivers/net/tap/rte_eth_tap.c +0 -0
@@ -353,8 +353,7 @@ pmd_rx_burst(void *queue, struct rte_mbuf

**bufs,

drivers/net/tap/rte_eth_tap.c pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) · line 358

Quoted 9 lines
drivers/net/tap/rte_eth_tap.c +1 -2
 uint16_t nb_pkts)
 
      if (trigger == rxq->trigger_seen)
              return 0;
-     if (trigger)
-             rxq->trigger_seen = trigger;
+
      process_private = rte_eth_devices[rxq->in_port].process_private;
      rte_compiler_barrier();
Quoted 3 lines

I see this compiler barrier was added together with the above "rxq-

Quoted 1 line

trigger_seen = trigger", should it be removed or moved together

downwards?

I think it could be removed, but it is best to ask author of the original code. Adrien, what do you think about removing this barrier?

Quoted 20 lines
Quoted 13 lines
      for (num_rx = 0; num_rx < nb_pkts; ) { @@ -433,6 +432,9 @@
pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
      rxq->stats.ipackets += num_rx;
      rxq->stats.ibytes += num_rx_bytes;
drivers/net/tap/rte_eth_tap.c +3 -1
+     if (trigger && num_rx < nb_pkts)
+             rxq->trigger_seen = trigger;
+
      return num_rx;
 }
 
--
Quoted 1 line

2.17.1

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

#4 lore raw

v2 cover net/tap: fix blocked rx packets error

In reply to Marcin Smoczynski

When OS sends more packets than are being read with a single 'rte_eth_rx_burst' call, rx packets are getting stucked in the tap pmd and are unable to receive, because trigger_seen is getting updated and consecutive calls are not getting any packets.

Do not update trigger_seen unless less than a max number of packets were received allowing next call to receive the rest.

v1 to v2 changes:
- fix typo in commit description
- remove unnecessary compiler barrier

Marcin Smoczynski (1):
net/tap: fix blocked rx packets error

 drivers/net/tap/rte_eth_tap.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

--
2.17.1

#5 lore raw

PATCH v2 1/1 net/tap: fix blocked rx packets error

When OS sends more packets than are being read with a single 'rte_eth_rx_burst' call, rx packets are getting stucked in the tap pmd and are unable to receive, because trigger_seen is getting updated and consecutive calls are not getting any packets.

Do not update trigger_seen unless less than a max number of packets were received allowing next call to receive the rest.

Remove unnecessary compiler barrier.

Fixes a0d8e807d9 ("net/tap: add Rx trigger")
---
 drivers/net/tap/rte_eth_tap.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/tap/rte_eth_tap.c +4 -3
index 64bd04911..9c3adb832 100644
@@ -353,10 +353,8 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 
 	if (trigger == rxq->trigger_seen)
 		return 0;
-	if (trigger)
-		rxq->trigger_seen = trigger;
+
 	process_private = rte_eth_devices[rxq->in_port].process_private;
-	rte_compiler_barrier();
 	for (num_rx = 0; num_rx < nb_pkts; ) {
 		struct rte_mbuf *mbuf = rxq->pool;
 		struct rte_mbuf *seg = NULL;
@@ -433,6 +431,9 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	rxq->stats.ipackets += num_rx;
 	rxq->stats.ibytes += num_rx_bytes;
 
+	if (trigger && num_rx < nb_pkts)
+		rxq->trigger_seen = trigger;
+
 	return num_rx;
 }
 
Signature · 1 line
2.17.1
Reviewed-by on v2 1/1
#6 lore raw
Quoted 41 lines · MarcinX

When OS sends more packets than are being read with a single 'rte_eth_rx_burst' call, rx packets are getting stucked in the tap pmd and are unable to receive, because trigger_seen is getting updated and consecutive calls are not getting any packets.

Do not update trigger_seen unless less than a max number of packets were received allowing next call to receive the rest.

Remove unnecessary compiler barrier.

Fixes a0d8e807d9 ("net/tap: add Rx trigger")

---
drivers/net/tap/rte_eth_tap.c | 7 ++++---

1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/tap/rte_eth_tap.c +1 -3
index 64bd04911..9c3adb832 100644
@@ -353,10 +353,8 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 
 	if (trigger == rxq->trigger_seen)
 		return 0;
-	if (trigger)
-		rxq->trigger_seen = trigger;
+
 	process_private = rte_eth_devices[rxq->in_port].process_private;
-	rte_compiler_barrier();
 	for (num_rx = 0; num_rx < nb_pkts; ) {
 		struct rte_mbuf *mbuf = rxq->pool;
 		struct rte_mbuf *seg = NULL;

drivers/net/tap/rte_eth_tap.c pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) · line 437

Quoted 7 lines
drivers/net/tap/rte_eth_tap.c +3 -0
@@ -433,6 +431,9 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	rxq->stats.ipackets += num_rx;
 	rxq->stats.ibytes += num_rx_bytes;
 
+	if (trigger && num_rx < nb_pkts)
+		rxq->trigger_seen = trigger;
+
 	return num_rx;

Looks reasonable to me. I was looking at the code for this patch and noticed what I believe is a bit odd.

The line around 1352 does set req->trigger_seen = 1;, but the tap_trigger global variable is always set to tap_trigger = (tap_trigger + 1) | 0x80000000; in the signal handler. Just seems the line around 1352 should be set to at least 0x80000001 to begin with just to be constant. Not for this patch and maybe it does not matter in the long run.

Quoted 5 lines
drivers/net/tap/rte_eth_tap.c +0 -0
 }
 
Signature · 1 line
2.17.1

Regards,
Keith

Applied
#7 lore raw
Quoted 51 lines · Keith
Quoted 41 lines · MarcinX

When OS sends more packets than are being read with a single 'rte_eth_rx_burst' call, rx packets are getting stucked in the tap pmd and are unable to receive, because trigger_seen is getting updated and consecutive calls are not getting any packets.

Do not update trigger_seen unless less than a max number of packets were received allowing next call to receive the rest.

Remove unnecessary compiler barrier.

Fixes a0d8e807d9 ("net/tap: add Rx trigger")

---
drivers/net/tap/rte_eth_tap.c | 7 ++++---

1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/tap/rte_eth_tap.c +1 -3
index 64bd04911..9c3adb832 100644
@@ -353,10 +353,8 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 
 	if (trigger == rxq->trigger_seen)
 		return 0;
-	if (trigger)
-		rxq->trigger_seen = trigger;
+
 	process_private = rte_eth_devices[rxq->in_port].process_private;
-	rte_compiler_barrier();
 	for (num_rx = 0; num_rx < nb_pkts; ) {
 		struct rte_mbuf *mbuf = rxq->pool;
 		struct rte_mbuf *seg = NULL;

drivers/net/tap/rte_eth_tap.c pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) · line 437

Quoted 7 lines
drivers/net/tap/rte_eth_tap.c +3 -0
@@ -433,6 +431,9 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	rxq->stats.ipackets += num_rx;
 	rxq->stats.ibytes += num_rx_bytes;
 
+	if (trigger && num_rx < nb_pkts)
+		rxq->trigger_seen = trigger;
+
 	return num_rx;

Looks reasonable to me. I was looking at the code for this patch and noticed what I believe is a bit odd.

Quoted 5 lines

The line around 1352 does set req->trigger_seen = 1;, but the tap_trigger global variable is always set to tap_trigger = (tap_trigger + 1) | 0x80000000; in the signal handler. Just seems the line around 1352 should be set to at least 0x80000001 to begin with just to be constant. Not for this patch and maybe it does not matter in the long run.

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