DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] kernel/kni: retry the xmit in case ring is full
@ 2021-12-17 15:00 Tudor Cornea
  2021-12-17 16:24 ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Tudor Cornea @ 2021-12-17 15:00 UTC (permalink / raw)
  To: ferruh.yigit; +Cc: thomas, stephen, dev, Tudor Cornea

This patch attempts to avoid dropping packets that are to be
transmitted, in case there is no space in the KNI ring.

We have a use case in which we leverage the Linux TCP / IP stack for
control plane, and some protocols might be sensitive to packet drops.

This might mean that the sender (Kernel) might be moving at a faster pace
than the receiver end (DPDK application), or it might have some brief
moments of bursty traffic patterns.

Requeuing the packets could add a kind of backpressure until a transmit
window is available to us.

The burden of retransmitting is shifted to the caller of ndo_start_xmit,
which in our case is the configured queuing discipline. This way, the
user should be able to influence the behavior w.r.t dropping packets,
by picking the desired queuing discipline.

Although it should technically be a good approach, from what
I have tested, stopping the queue prior to returning NETDEV_TX_BUSY seems
to add some extra overhead, and degrade the control-plane performance
a bit.

Signed-off-by: Tudor Cornea <tudor.cornea@gmail.com>
---
 kernel/linux/kni/kni_net.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c
index 29e5b9e..db0330f 100644
--- a/kernel/linux/kni/kni_net.c
+++ b/kernel/linux/kni/kni_net.c
@@ -321,10 +321,9 @@ kni_net_tx(struct sk_buff *skb, struct net_device *dev)
 	if (kni_fifo_free_count(kni->tx_q) == 0 ||
 			kni_fifo_count(kni->alloc_q) == 0) {
 		/**
-		 * If no free entry in tx_q or no entry in alloc_q,
-		 * drops skb and goes out.
+		 * Tell the caller to requeue, and retry at a later time.
 		 */
-		goto drop;
+		goto requeue;
 	}
 
 	/* dequeue a mbuf from alloc_q */
@@ -371,6 +370,10 @@ kni_net_tx(struct sk_buff *skb, struct net_device *dev)
 	dev->stats.tx_dropped++;
 
 	return NETDEV_TX_OK;
+
+requeue:
+	/* Signal the caller to re-transmit at a later time */
+	return NETDEV_TX_BUSY;
 }
 
 /*
-- 
2.7.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-17 15:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-17 15:00 [PATCH] kernel/kni: retry the xmit in case ring is full Tudor Cornea
2021-12-17 16:24 ` Stephen Hemminger
2022-01-17 15:29   ` Tudor Cornea

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).