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:39 UTC

[incubator-nuttx] branch master updated (4fab2b9501 -> d8f35cf1b6)

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

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


    from 4fab2b9501 arch/armv7-[a|r]: Don't define fiq stack if CONFIG_ARMV7A_DECODEFIQ=n
     new cb25a9dee3 arch/sim: change g_avail_work and g_recv_work to array in netdriver
     new d8f35cf1b6 arch/sim: calling txdone callback after devif_loopback in netdriver

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 arch/sim/src/sim/up_netdriver.c | 46 ++++++++++++++++++++++++++++++-----------
 1 file changed, 34 insertions(+), 12 deletions(-)


[incubator-nuttx] 01/02: arch/sim: change g_avail_work and g_recv_work to array in netdriver

Posted by xi...@apache.org.
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 cb25a9dee30838b66d5f7834fffa9e5449d7014a
Author: Zhe Weng <we...@xiaomi.com>
AuthorDate: Fri Oct 14 14:25:45 2022 +0800

    arch/sim: change g_avail_work and g_recv_work to array in netdriver
    
    Share one worker between multiple simulated network devices may work most of the time, but sometimes breaks the tx pipeline when sending packets on more than one interface at the same time, and leaves some packets unprocessed in network stack, delayed until next transmit on the network interface. The rx process is likely delayed in packet processing under similar situation, so keep g_avail_work and g_recv_work the same number as interfaces.
    
    dev0 tx1 avail              tx1 done
            v                      v
    work dev0 tx1 -> dev0 tx1 -> empty -> dev1 tx2 -> dev1 tx3 -> empty
                        ^                    ^           ^          ^
    dev1     tx2 avail (failed to queue)  tx3 avail   tx2 done   tx3 done
    
    Signed-off-by: Zhe Weng <we...@xiaomi.com>
---
 arch/sim/src/sim/up_netdriver.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/arch/sim/src/sim/up_netdriver.c b/arch/sim/src/sim/up_netdriver.c
index 168142730a..7697ce9579 100644
--- a/arch/sim/src/sim/up_netdriver.c
+++ b/arch/sim/src/sim/up_netdriver.c
@@ -78,8 +78,8 @@
 
 /* Net driver worker */
 
-static struct work_s g_avail_work;
-static struct work_s g_recv_work;
+static struct work_s g_avail_work[CONFIG_SIM_NETDEV_NUMBER];
+static struct work_s g_recv_work[CONFIG_SIM_NETDEV_NUMBER];
 
 /* Ethernet peripheral state */
 
@@ -334,9 +334,11 @@ static void netdriver_txavail_work(void *arg)
 
 static int netdriver_txavail(struct net_driver_s *dev)
 {
-  if (work_available(&g_avail_work))
+  int devidx = (intptr_t)dev->d_private;
+  if (work_available(&g_avail_work[devidx]))
     {
-      work_queue(LPWORK, &g_avail_work, netdriver_txavail_work, dev, 0);
+      work_queue(LPWORK, &g_avail_work[devidx], netdriver_txavail_work,
+                 dev, 0);
     }
 
   return OK;
@@ -344,19 +346,22 @@ static int netdriver_txavail(struct net_driver_s *dev)
 
 static void netdriver_txdone_interrupt(void *priv)
 {
-  if (work_available(&g_avail_work))
+  struct net_driver_s *dev = (struct net_driver_s *)priv;
+  int devidx = (intptr_t)dev->d_private;
+  if (work_available(&g_avail_work[devidx]))
     {
-      struct net_driver_s *dev = (struct net_driver_s *)priv;
-      work_queue(LPWORK, &g_avail_work, netdriver_txavail_work, dev, 0);
+      work_queue(LPWORK, &g_avail_work[devidx], netdriver_txavail_work,
+                 dev, 0);
     }
 }
 
 static void netdriver_rxready_interrupt(void *priv)
 {
-  if (work_available(&g_recv_work))
+  struct net_driver_s *dev = (struct net_driver_s *)priv;
+  int devidx = (intptr_t)dev->d_private;
+  if (work_available(&g_recv_work[devidx]))
     {
-      struct net_driver_s *dev = (struct net_driver_s *)priv;
-      work_queue(LPWORK, &g_recv_work, netdriver_recv_work, dev, 0);
+      work_queue(LPWORK, &g_recv_work[devidx], netdriver_recv_work, dev, 0);
     }
 }
 
@@ -427,9 +432,9 @@ void netdriver_loop(void)
   int devidx;
   for (devidx = 0; devidx < CONFIG_SIM_NETDEV_NUMBER; devidx++)
     {
-      if (work_available(&g_recv_work) && netdev_avail(devidx))
+      if (work_available(&g_recv_work[devidx]) && netdev_avail(devidx))
         {
-          work_queue(LPWORK, &g_recv_work, netdriver_recv_work,
+          work_queue(LPWORK, &g_recv_work[devidx], netdriver_recv_work,
                      &g_sim_dev[devidx], 0);
         }
     }


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

Posted by xi...@apache.org.
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