From d8f35cf1b620cf10be30924e61fd30c9828a6006 Mon Sep 17 00:00:00 2001 From: Zhe Weng Date: Mon, 17 Oct 2022 11:45:02 +0800 Subject: [PATCH] arch/sim: calling txdone callback after devif_loopback in netdriver When devif_loopback handles a packet (like a ping targeting at this dev), it does not call the txdone callback, breaking the tx pipeline and may left some packets unhandled, delayed until next transmit on the network interface. Signed-off-by: Zhe Weng --- arch/sim/src/sim/up_netdriver.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/arch/sim/src/sim/up_netdriver.c b/arch/sim/src/sim/up_netdriver.c index 7697ce9579f..93c294d5d13 100644 --- a/arch/sim/src/sim/up_netdriver.c +++ b/arch/sim/src/sim/up_netdriver.c @@ -72,6 +72,12 @@ #include "up_internal.h" +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static void netdriver_txdone_interrupt(void *priv); + /**************************************************************************** * Private Data ****************************************************************************/ @@ -290,6 +296,17 @@ static int netdriver_txpoll(struct net_driver_s *dev) netdev_send(devidx, dev->d_buf, dev->d_len); NETDEV_TXDONE(dev); } + else + { + /* Calling txdone callback after loopback. NETDEV_TXDONE macro is + * already called in devif_loopback. + * + * TODO: Maybe a unified interface with txdone callback registered + * is needed, then we can let devif_loopback call this callback. + */ + + netdriver_txdone_interrupt(dev); + } } /* If zero is returned, the polling will continue until all connections