[v12,11/12] net/tap: do not mark queue full as error

Message ID 20240502213618.11391-12-stephen@networkplumber.org (mailing list archive)
State New
Delegated to: Ferruh Yigit
Headers
Series net/tap: RSS and other fixes |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger May 2, 2024, 9:31 p.m. UTC
  If tap device in kernel returns EAGAIN that means it is full.
That is not an error.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/tap/rte_eth_tap.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
  

Patch

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 2484a82ccb..485bd35912 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -542,7 +542,6 @@  tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs,
 		struct rte_mbuf *seg = mbuf;
 		uint64_t l4_ol_flags;
 		int proto;
-		int n;
 		int j;
 		int k; /* current index in iovecs for copying segments */
 
@@ -647,14 +646,18 @@  tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs,
 		}
 
 		/* copy the tx frame data */
-		n = writev(process_private->fds[txq->queue_id], iovecs, k);
-		if (n <= 0)
-			return -1;
+		if (unlikely(writev(process_private->fds[txq->queue_id], iovecs, k) < 0)) {
+			TAP_LOG(DEBUG, "writev (qid=%u fd=%d) %s",
+				txq->queue_id, process_private->fds[txq->queue_id],
+				strerror(errno));
+			return (errno == EAGAIN) ? 0 : -1;
+		}
 
 		(*num_packets)++;
 		(*num_tx_bytes) += rte_pktmbuf_pkt_len(mbuf);
 	}
-	return 0;
+
+	return 1;
 }
 
 /* Callback to handle sending packets from the tap interface