You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/01/16 17:01:53 UTC
[incubator-nuttx] branch master updated: sim/net: do not do any
critical operations in idle
This is an automated email from the ASF dual-hosted git repository.
gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 1ff4109 sim/net: do not do any critical operations in idle
1ff4109 is described below
commit 1ff410957f91d7fcdffadb0a1479567637d96b3c
Author: chao.an <an...@xiaomi.com>
AuthorDate: Wed Jan 15 14:05:52 2020 +0800
sim/net: do not do any critical operations in idle
Change-Id: Ia9011b62ea61d15bd66aa063e4165d9d3baacb51
Signed-off-by: chao.an <an...@xiaomi.com>
---
arch/sim/src/sim/up_netdriver.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/arch/sim/src/sim/up_netdriver.c b/arch/sim/src/sim/up_netdriver.c
index 10e2ebe..a974027 100644
--- a/arch/sim/src/sim/up_netdriver.c
+++ b/arch/sim/src/sim/up_netdriver.c
@@ -50,6 +50,7 @@
#include <stdbool.h>
#include <string.h>
#include <sched.h>
+#include <nuttx/wqueue.h>
#include <nuttx/net/net.h>
#include <net/ethernet.h>
@@ -84,6 +85,10 @@ struct timer
static struct timer g_periodic_timer;
+/* Net driver worker */
+
+static struct work_s g_network;
+
/* A single packet buffer is used */
static uint8_t g_pktbuf[MAX_NETDEV_PKTSIZE + CONFIG_NET_GUARDSIZE];
@@ -159,11 +164,7 @@ static int sim_txpoll(struct net_driver_s *dev)
return 0;
}
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-void netdriver_loop(void)
+static void netdriver_work(FAR void *arg)
{
FAR struct eth_hdr_s *eth;
@@ -328,6 +329,18 @@ void netdriver_loop(void)
sched_unlock();
}
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+void netdriver_loop(void)
+{
+ if (work_available(&g_network))
+ {
+ work_queue(LPWORK, &g_network, netdriver_work, NULL, 0);
+ }
+}
+
int netdriver_ifup(struct net_driver_s *dev)
{
netdev_ifup(dev->d_ipaddr);