You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/10/18 03:16:41 UTC

[incubator-nuttx] 02/02: arch/sim: calling txdone callback after devif_loopback in netdriver

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit d8f35cf1b620cf10be30924e61fd30c9828a6006
Author: Zhe Weng <we...@xiaomi.com>
AuthorDate: Mon Oct 17 11:45:02 2022 +0800

    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 <we...@xiaomi.com>
---
 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 7697ce9579..93c294d5d1 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