sim/net: do not do any critical operations in idle

Change-Id: Ia9011b62ea61d15bd66aa063e4165d9d3baacb51
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an 2020-01-15 14:05:52 +08:00 committed by patacongo
parent e23d58e86d
commit 1ff410957f

View File

@ -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);