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/02/12 14:04:46 UTC

[incubator-nuttx] branch pr249 updated (882c82a -> 3ef7a6d)

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

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


    from 882c82a  Fix typos in comments
     new 294b9a5  arch/sim: Change syslog to printf in up_tapdev.c
     new dbc33fa  arch/sim: Change the return type of netdriver_setmacaddr to void
     new a95f50b  arch/sim: Change CONFIG_NET_ETHERNET to CONFIG_SIM_NETDEV
     new f087e10  sim/net: Replace the busy polling with work
     new 3ef7a6d  boards/sim: Update README.txt for network setup

The 5 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/Kconfig                               |   3 +-
 arch/sim/src/Makefile                          |   6 +-
 arch/sim/src/sim/up_idle.c                     |   2 +-
 arch/sim/src/sim/up_initialize.c               |   2 +-
 arch/sim/src/sim/up_internal.h                 |  17 +-
 arch/sim/src/sim/up_netdev.c                   |  60 -----
 arch/sim/src/sim/up_netdriver.c                | 297 +++++++++++--------------
 arch/sim/src/sim/up_tapdev.c                   |  75 +++----
 arch/sim/src/sim/up_wpcap.c                    |  18 +-
 boards/sim/sim/sim/README.txt                  |  10 +
 boards/sim/sim/sim/configs/bluetooth/defconfig |   1 -
 boards/sim/sim/sim/configs/rpserver/defconfig  |   1 -
 boards/sim/sim/sim/configs/udgram/defconfig    |   1 -
 boards/sim/sim/sim/configs/userfs/defconfig    |   1 -
 boards/sim/sim/sim/configs/ustream/defconfig   |   1 -
 15 files changed, 199 insertions(+), 296 deletions(-)
 delete mode 100644 arch/sim/src/sim/up_netdev.c


[incubator-nuttx] 01/05: arch/sim: Change syslog to printf in up_tapdev.c

Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 294b9a5fc5851dcb9c416ae419eabe74476c946d
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Mon Feb 10 15:07:54 2020 +0800

    arch/sim: Change syslog to printf in up_tapdev.c
    
    since this file is compiled with host environment, can't call NuttX's syslog
    
    Change-Id: Icc91aae8ee019e721c29df53bb5425e3ebdbaeb7
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 arch/sim/src/sim/up_tapdev.c | 44 +++++++++++++++++---------------------------
 1 file changed, 17 insertions(+), 27 deletions(-)

diff --git a/arch/sim/src/sim/up_tapdev.c b/arch/sim/src/sim/up_tapdev.c
index 7c96a32..5a09ef3 100644
--- a/arch/sim/src/sim/up_tapdev.c
+++ b/arch/sim/src/sim/up_tapdev.c
@@ -72,11 +72,6 @@
 
 #define DEVTAP        "/dev/net/tun"
 
-/* Syslog priority (must match definitions in nuttx/include/syslog.h) */
-
-#define LOG_INFO      1  /* Informational message */
-#define LOG_ERR       4  /* Error conditions */
-
 /****************************************************************************
  * Private Types
  ****************************************************************************/
@@ -96,7 +91,6 @@ struct sel_arg_struct
  * NuttX Domain Public Function Prototypes
  ****************************************************************************/
 
-int syslog(int priority, const char *format, ...);
 int netdriver_setmacaddr(unsigned char *macaddr);
 
 /****************************************************************************
@@ -121,9 +115,8 @@ static struct rtentry ghostroute;
 static inline void dump_ethhdr(const char *msg, unsigned char *buf,
                                int buflen)
 {
-  syslog(LOG_INFO, "TAPDEV: %s %d bytes\n", msg, buflen);
-  syslog(LOG_INFO,
-         "        %02x:%02x:%02x:%02x:%02x:%02x "
+  printf("TAPDEV: %s %d bytes\n", msg, buflen);
+  printf("        %02x:%02x:%02x:%02x:%02x:%02x "
          "%02x:%02x:%02x:%02x:%02x:%02x %02x%02x\n",
          buf[0], buf[1], buf[2], buf[3], buf[4],  buf[5],
          buf[6], buf[7], buf[8], buf[9], buf[10], buf[11],
@@ -187,7 +180,7 @@ void tapdev_init(void)
   gtapdevfd = open(DEVTAP, O_RDWR, 0644);
   if (gtapdevfd < 0)
     {
-      syslog(LOG_ERR, "TAPDEV: open failed: %d\n", -gtapdevfd);
+      printf("TAPDEV: open failed: %d\n", -gtapdevfd);
       return;
     }
 
@@ -198,7 +191,7 @@ void tapdev_init(void)
   ret = ioctl(gtapdevfd, TUNSETIFF, (unsigned long) &ifr);
   if (ret < 0)
     {
-      syslog(LOG_ERR, "TAPDEV: ioctl failed: %d\n", -ret);
+      printf("TAPDEV: ioctl failed: %d\n", -ret);
       return;
     }
 
@@ -214,7 +207,7 @@ void tapdev_init(void)
   sockfd = socket(AF_INET, SOCK_DGRAM, 0);
   if (sockfd < 0)
     {
-      syslog(LOG_ERR, "TAPDEV: Can't open socket: %d\n", -sockfd);
+      printf("TAPDEV: Can't open socket: %d\n", -sockfd);
       return;
     }
 
@@ -227,8 +220,8 @@ void tapdev_init(void)
   ret = ioctl(sockfd, SIOCBRADDIF, &ifr);
   if (ret < 0)
     {
-      syslog(LOG_ERR, "TAPDEV: ioctl failed (can't add interface %s to "
-                      "bridge %s): %d\n",
+      printf("TAPDEV: ioctl failed (can't add interface %s to "
+             "bridge %s): %d\n",
              gdevname, CONFIG_SIM_NET_BRIDGE_DEVICE, -ret);
     }
 
@@ -270,7 +263,7 @@ unsigned int tapdev_read(unsigned char *buf, unsigned int buflen)
   ret = read(gtapdevfd, buf, buflen);
   if (ret < 0)
     {
-      syslog(LOG_ERR, "TAPDEV: read failed: %d\n", -ret);
+      printf("TAPDEV: read failed: %d\n", -ret);
       return 0;
     }
 
@@ -282,12 +275,12 @@ void tapdev_send(unsigned char *buf, unsigned int buflen)
 {
   int ret;
 #ifdef TAPDEV_DEBUG
-  syslog(LOG_INFO, "tapdev_send: sending %d bytes\n", buflen);
+  printf("tapdev_send: sending %d bytes\n", buflen);
 
   gdrop++;
   if (gdrop % 8 == 7)
     {
-      syslog(LOG_ERR, "TAPDEV: Dropped a packet!\n");
+      printf("TAPDEV: Dropped a packet!\n");
       return;
     }
 #endif
@@ -295,7 +288,7 @@ void tapdev_send(unsigned char *buf, unsigned int buflen)
   ret = write(gtapdevfd, buf, buflen);
   if (ret < 0)
     {
-      syslog(LOG_ERR, "TAPDEV: write failed: %d", -ret);
+      printf("TAPDEV: write failed: %d", -ret);
       exit(1);
     }
 
@@ -317,7 +310,7 @@ void tapdev_ifup(in_addr_t ifaddr)
   sockfd = socket(AF_INET, SOCK_DGRAM, 0);
   if (sockfd < 0)
     {
-      syslog(LOG_ERR, "TAPDEV: Can't open socket: %d\n", -sockfd);
+      printf("TAPDEV: Can't open socket: %d\n", -sockfd);
       return;
     }
 
@@ -328,8 +321,7 @@ void tapdev_ifup(in_addr_t ifaddr)
   ret = ioctl(sockfd, SIOCGIFFLAGS, (unsigned long)&ifr);
   if (ret < 0)
     {
-      syslog(LOG_ERR, "TAPDEV: ioctl failed (can't get interface flags): %d\n",
-             -ret);
+      printf("TAPDEV: ioctl failed (can't get interface flags): %d\n", -ret);
       close(sockfd);
       return;
     }
@@ -338,8 +330,7 @@ void tapdev_ifup(in_addr_t ifaddr)
   ret = ioctl(sockfd, SIOCSIFFLAGS, (unsigned long)&ifr);
   if (ret < 0)
     {
-      syslog(LOG_ERR, "TAPDEV: ioctl failed (can't set interface flags): %d\n",
-             -ret);
+      printf("TAPDEV: ioctl failed (can't set interface flags): %d\n", -ret);
       close(sockfd);
       return;
     }
@@ -360,7 +351,7 @@ void tapdev_ifup(in_addr_t ifaddr)
   ret = ioctl(sockfd, SIOCADDRT, (unsigned long)&ghostroute);
   if (ret < 0)
     {
-      syslog(LOG_ERR, "TAPDEV: ioctl failed (can't add host route): %d\n", -ret);
+      printf("TAPDEV: ioctl failed (can't add host route): %d\n", -ret);
       close(sockfd);
       return;
     }
@@ -382,15 +373,14 @@ void tapdev_ifdown(void)
       sockfd = socket(AF_INET, SOCK_DGRAM, 0);
       if (sockfd < 0)
         {
-          syslog(LOG_ERR, "TAPDEV: Can't open socket: %d\n", -sockfd);
+          printf("TAPDEV: Can't open socket: %d\n", -sockfd);
           return;
         }
 
       ret = ioctl(sockfd, SIOCDELRT, (unsigned long)&ghostroute);
       if (ret < 0)
         {
-          syslog(LOG_ERR, "TAPDEV: ioctl failed (can't delete host route): %d\n",
-                 -ret);
+          printf("TAPDEV: ioctl failed (can't delete host route): %d\n", -ret);
         }
 
       close(sockfd);


[incubator-nuttx] 04/05: sim/net: Replace the busy polling with work

Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit f087e108a3330afb1594ec92fed297be9ef5a89a
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Mon Feb 10 11:21:27 2020 +0800

    sim/net: Replace the busy polling with work
    
    netdriver_loop should check there is data to read before queue the work
    
    Change-Id: If88db978c802e2269553f20a3403a6fe2a4e01c7
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 arch/sim/Kconfig                               |   1 +
 arch/sim/src/Makefile                          |   4 +-
 arch/sim/src/sim/up_internal.h                 |   9 +-
 arch/sim/src/sim/up_netdev.c                   |  60 -----
 arch/sim/src/sim/up_netdriver.c                | 294 ++++++++++++-------------
 arch/sim/src/sim/up_tapdev.c                   |  19 +-
 boards/sim/sim/sim/configs/bluetooth/defconfig |   1 -
 boards/sim/sim/sim/configs/rpserver/defconfig  |   1 -
 boards/sim/sim/sim/configs/udgram/defconfig    |   1 -
 boards/sim/sim/sim/configs/userfs/defconfig    |   1 -
 boards/sim/sim/sim/configs/ustream/defconfig   |   1 -
 11 files changed, 153 insertions(+), 239 deletions(-)

diff --git a/arch/sim/Kconfig b/arch/sim/Kconfig
index 00b3d3c..1803713 100644
--- a/arch/sim/Kconfig
+++ b/arch/sim/Kconfig
@@ -116,6 +116,7 @@ config SIM_NETDEV
 	depends on NET_ETHERNET
 	select ARCH_HAVE_NETDEV_STATISTICS
 	select SCHED_LPWORK
+	select SIM_WALLTIME
 	---help---
 		Build in support for a simulated network device using a TAP device on Linux or
 		WPCAP on Windows.
diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile
index b82d531..96a7078 100644
--- a/arch/sim/src/Makefile
+++ b/arch/sim/src/Makefile
@@ -167,7 +167,7 @@ ifeq ($(CONFIG_SIM_NETDEV),y)
   CSRCS += up_netdriver.c
   HOSTCFLAGS += -DNETDEV_BUFSIZE=$(CONFIG_NET_ETH_PKTSIZE)
 ifneq ($(HOSTOS),Cygwin)
-  HOSTSRCS += up_tapdev.c up_netdev.c
+  HOSTSRCS += up_tapdev.c
 ifeq ($(CONFIG_SIM_NET_BRIDGE),y)
   HOSTCFLAGS += -DCONFIG_SIM_NET_BRIDGE
   HOSTCFLAGS += -DCONFIG_SIM_NET_BRIDGE_DEVICE=\"$(CONFIG_SIM_NET_BRIDGE_DEVICE)\"
@@ -176,7 +176,7 @@ ifeq ($(CONFIG_SIM_NET_HOST_ROUTE),y)
   HOSTCFLAGS += -DCONFIG_SIM_NET_HOST_ROUTE
 endif
 else # HOSTOS != Cygwin
-  HOSTSRCS += up_wpcap.c up_netdev.c
+  HOSTSRCS += up_wpcap.c
   DRVLIB = /lib/w32api/libws2_32.a /lib/w32api/libiphlpapi.a
 endif # HOSTOS != Cygwin
 endif # CONFIG_SIM_NETDEV
diff --git a/arch/sim/src/sim/up_internal.h b/arch/sim/src/sim/up_internal.h
index f87e709..a7fd589 100644
--- a/arch/sim/src/sim/up_internal.h
+++ b/arch/sim/src/sim/up_internal.h
@@ -272,12 +272,6 @@ bool simuart_checkc(void);
 char *up_deviceimage(void);
 void up_registerblockdevice(void);
 
-/* up_netdev.c **************************************************************/
-
-#ifdef CONFIG_NET
-unsigned long up_getwalltime(void);
-#endif
-
 /* up_x11framebuffer.c ******************************************************/
 
 #ifdef CONFIG_SIM_X11FB
@@ -324,12 +318,14 @@ FAR struct ioexpander_dev_s *sim_ioexpander_initialize(void);
 
 #if defined(CONFIG_SIM_NETDEV) && !defined(__CYGWIN__)
 void tapdev_init(void);
+int tapdev_avail(void);
 unsigned int tapdev_read(unsigned char *buf, unsigned int buflen);
 void tapdev_send(unsigned char *buf, unsigned int buflen);
 void tapdev_ifup(in_addr_t ifaddr);
 void tapdev_ifdown(void);
 
 #  define netdev_init()           tapdev_init()
+#  define netdev_avail()          tapdev_avail()
 #  define netdev_read(buf,buflen) tapdev_read(buf,buflen)
 #  define netdev_send(buf,buflen) tapdev_send(buf,buflen)
 #  define netdev_ifup(ifaddr)     tapdev_ifup(ifaddr)
@@ -344,6 +340,7 @@ unsigned int wpcap_read(unsigned char *buf, unsigned int buflen);
 void wpcap_send(unsigned char *buf, unsigned int buflen);
 
 #  define netdev_init()           wpcap_init()
+#  define netdev_avail()          1
 #  define netdev_read(buf,buflen) wpcap_read(buf,buflen)
 #  define netdev_send(buf,buflen) wpcap_send(buf,buflen)
 #  define netdev_ifup(ifaddr)     {}
diff --git a/arch/sim/src/sim/up_netdev.c b/arch/sim/src/sim/up_netdev.c
deleted file mode 100644
index 2df0d9a..0000000
--- a/arch/sim/src/sim/up_netdev.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************************
- * arch/sim/src/sim/up_tapdev.c
- *
- *   Copyright (C) 2011 Gregory Nutt. All rights reserved.
- *   Author: Gregory Nutt <gn...@nuttx.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- *    used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <sys/types.h>
-#include <sys/time.h>
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#ifndef NULL
-#  define NULL (void*)0
-#endif
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-unsigned long up_getwalltime(void)
-{
-  struct timeval tm;
-  gettimeofday(&tm, NULL);
-  return tm.tv_sec*1000 + tm.tv_usec/1000;
-}
diff --git a/arch/sim/src/sim/up_netdriver.c b/arch/sim/src/sim/up_netdriver.c
index d816b96..fff5e0c 100644
--- a/arch/sim/src/sim/up_netdriver.c
+++ b/arch/sim/src/sim/up_netdriver.c
@@ -44,14 +44,11 @@
 
 #include <nuttx/config.h>
 
-#include <stdint.h>
-#include <stdbool.h>
+#include <debug.h>
 #include <string.h>
-#include <sched.h>
+
 #include <nuttx/wqueue.h>
 #include <nuttx/net/net.h>
-
-#include <net/ethernet.h>
 #include <nuttx/net/netdev.h>
 #include <nuttx/net/arp.h>
 
@@ -62,30 +59,14 @@
 #include "up_internal.h"
 
 /****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#define BUF ((struct eth_hdr_s *)g_sim_dev.d_buf)
-
-/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-struct timer
-{
-  uint32_t interval;
-  uint32_t start;
-};
-
-/****************************************************************************
  * Private Data
  ****************************************************************************/
 
-static struct timer g_periodic_timer;
-
 /* Net driver worker */
 
-static struct work_s g_network;
+static struct work_s g_timer_work;
+static struct work_s g_avail_work;
+static struct work_s g_recv_work;
 
 /* A single packet buffer is used */
 
@@ -99,29 +80,13 @@ static struct net_driver_s g_sim_dev;
  * Private Functions
  ****************************************************************************/
 
-static void timer_set(struct timer *t, unsigned int interval)
-{
-  t->interval = interval;
-  t->start    = up_getwalltime();
-}
-
-static bool timer_expired(struct timer *t)
-{
-  return (up_getwalltime() - t->start) >= t->interval;
-}
-
-void timer_reset(struct timer *t)
+static void netdriver_reply(FAR struct net_driver_s *dev)
 {
-  t->start += t->interval;
-}
-
-static int sim_txpoll(struct net_driver_s *dev)
-{
-  /* If the polling resulted in data that should be sent out on the network,
+  /* If the receiving resulted in data that should be sent out on the network,
    * the field d_len is set to a value > 0.
    */
 
-  if (g_sim_dev.d_len > 0)
+  if (dev->d_len > 0)
     {
       /* Look up the destination MAC address and add it to the Ethernet
        * header.
@@ -129,10 +94,10 @@ static int sim_txpoll(struct net_driver_s *dev)
 
 #ifdef CONFIG_NET_IPv4
 #ifdef CONFIG_NET_IPv6
-      if (IFF_IS_IPv4(g_sim_dev.d_flags))
+      if (IFF_IS_IPv4(dev->d_flags))
 #endif
         {
-          arp_out(&g_sim_dev);
+          arp_out(dev);
         }
 #endif /* CONFIG_NET_IPv4 */
 
@@ -141,65 +106,46 @@ static int sim_txpoll(struct net_driver_s *dev)
       else
 #endif
         {
-          neighbor_out(&g_sim_dev);
+          neighbor_out(dev);
         }
 #endif /* CONFIG_NET_IPv6 */
 
-      if (!devif_loopback(&g_sim_dev))
-        {
-          /* Send the packet */
+      /* Send the packet */
 
-          NETDEV_TXPACKETS(dev);
-          netdev_send(g_sim_dev.d_buf, g_sim_dev.d_len);
-          NETDEV_TXDONE(dev);
-        }
+      NETDEV_TXPACKETS(dev);
+      netdev_send(dev->d_buf, dev->d_len);
+      NETDEV_TXDONE(dev);
     }
-
-  /* If zero is returned, the polling will continue until all connections have
-   * been examined.
-   */
-
-  return 0;
 }
 
-static void netdriver_work(FAR void *arg)
+static void netdriver_recv_work(FAR void *arg)
 {
+  FAR struct net_driver_s *dev = arg;
   FAR struct eth_hdr_s *eth;
 
-  /* Check for new frames.  If so, then poll the network for new XMIT data */
-
   net_lock();
-  devif_poll(&g_sim_dev, sim_txpoll);
-  net_unlock();
 
   /* netdev_read will return 0 on a timeout event and >0 on a data received event */
 
-  g_sim_dev.d_len = netdev_read((FAR unsigned char *)g_sim_dev.d_buf,
-                                CONFIG_NET_ETH_PKTSIZE);
-
-  /* Disable preemption through to the following so that it behaves a little more
-   * like an interrupt (otherwise, the following logic gets pre-empted an behaves
-   * oddly.
-   */
-
-  sched_lock();
-  if (g_sim_dev.d_len > 0)
+  dev->d_len = netdev_read((FAR unsigned char *)dev->d_buf,
+                           CONFIG_NET_ETH_PKTSIZE);
+  if (dev->d_len > 0)
     {
-      NETDEV_RXPACKETS(&g_sim_dev);
+      NETDEV_RXPACKETS(dev);
 
       /* Data received event.  Check for valid Ethernet header with
        * destination == our MAC address
        */
 
-      eth = BUF;
-      if (g_sim_dev.d_len > ETH_HDRLEN)
+      eth = (FAR struct eth_hdr_s *)dev->d_buf;
+      if (dev->d_len > ETH_HDRLEN)
         {
 #ifdef CONFIG_NET_PKT
           /* When packet sockets are enabled, feed the frame into the packet
            * tap.
            */
 
-          pkt_input(&g_sim_dev);
+          pkt_input(dev);
 #endif /* CONFIG_NET_PKT */
 
           /* We only accept IP packets of the configured type and ARP packets */
@@ -208,41 +154,18 @@ static void netdriver_work(FAR void *arg)
           if (eth->type == HTONS(ETHTYPE_IP))
             {
               ninfo("IPv4 frame\n");
-              NETDEV_RXIPV4(&g_sim_dev);
+              NETDEV_RXIPV4(dev);
 
               /* Handle ARP on input then give the IPv4 packet to the network
                * layer
                */
 
-              arp_ipin(&g_sim_dev);
-              ipv4_input(&g_sim_dev);
+              arp_ipin(dev);
+              ipv4_input(dev);
 
-              /* If the above function invocation resulted in data that
-               * should be sent out on the network, the global variable
-               * d_len is set to a value > 0.
-               */
+              /* Check for a reply to the IPv4 packet */
 
-              if (g_sim_dev.d_len > 0)
-                {
-                  /* Update the Ethernet header with the correct MAC address */
-
-#ifdef CONFIG_NET_IPv6
-                  if (IFF_IS_IPv4(g_sim_dev.d_flags))
-#endif
-                    {
-                      arp_out(&g_sim_dev);
-                    }
-#ifdef CONFIG_NET_IPv6
-                  else
-                    {
-                      neighbor_out(&g_sim_dev);
-                    }
-#endif
-
-                  /* And send the packet */
-
-                  netdev_send(g_sim_dev.d_buf, g_sim_dev.d_len);
-                }
+              netdriver_reply(dev);
             }
           else
 #endif /* CONFIG_NET_IPv4 */
@@ -250,38 +173,15 @@ static void netdriver_work(FAR void *arg)
           if (eth->type == HTONS(ETHTYPE_IP6))
             {
               ninfo("Iv6 frame\n");
-              NETDEV_RXIPV6(&g_sim_dev);
+              NETDEV_RXIPV6(dev);
 
               /* Give the IPv6 packet to the network layer */
 
-              ipv6_input(&g_sim_dev);
+              ipv6_input(dev);
 
-              /* If the above function invocation resulted in data that
-               * should be sent out on the network, the global variable
-               * d_len is set to a value > 0.
-               */
+              /* Check for a reply to the IPv6 packet */
 
-              if (g_sim_dev.d_len > 0)
-                {
-                  /* Update the Ethernet header with the correct MAC address */
-
-#ifdef CONFIG_NET_IPv4
-                  if (IFF_IS_IPv4(g_sim_dev.d_flags))
-                    {
-                      arp_out(&g_sim_dev);
-                    }
-                  else
-#endif
-#ifdef CONFIG_NET_IPv6
-                    {
-                      neighbor_out(&g_sim_dev);
-                    }
-#endif /* CONFIG_NET_IPv6 */
-
-                  /* And send the packet */
-
-                  netdev_send(g_sim_dev.d_buf, g_sim_dev.d_len);
-                }
+              netdriver_reply(dev);
             }
           else
 #endif/* CONFIG_NET_IPv6 */
@@ -289,88 +189,164 @@ static void netdriver_work(FAR void *arg)
           if (eth->type == htons(ETHTYPE_ARP))
             {
               ninfo("ARP frame\n");
-              NETDEV_RXARP(&g_sim_dev);
+              NETDEV_RXARP(dev);
 
-              arp_arpin(&g_sim_dev);
+              arp_arpin(dev);
 
               /* If the above function invocation resulted in data that
                * should be sent out on the network, the global variable
                * d_len is set to a value > 0.
                */
 
-              if (g_sim_dev.d_len > 0)
+              if (dev->d_len > 0)
                 {
-                  netdev_send(g_sim_dev.d_buf, g_sim_dev.d_len);
+                  netdev_send(dev->d_buf, dev->d_len);
                 }
             }
           else
 #endif
             {
-              NETDEV_RXDROPPED(&g_sim_dev);
+              NETDEV_RXDROPPED(dev);
               nwarn("WARNING: Unsupported Ethernet type %u\n", eth->type);
             }
         }
       else
         {
-          NETDEV_RXERRORS(&g_sim_dev);
+          NETDEV_RXERRORS(dev);
         }
     }
 
-  /* Otherwise, it must be a timeout event */
+  net_unlock();
+}
 
-  else if (timer_expired(&g_periodic_timer))
+static int netdriver_txpoll(FAR struct net_driver_s *dev)
+{
+  /* If the polling resulted in data that should be sent out on the network,
+   * the field d_len is set to a value > 0.
+   */
+
+  if (dev->d_len > 0)
     {
-      timer_reset(&g_periodic_timer);
-      devif_timer(&g_sim_dev, MSEC2TICK(g_periodic_timer.interval), sim_txpoll);
+      /* Look up the destination MAC address and add it to the Ethernet
+       * header.
+       */
+
+#ifdef CONFIG_NET_IPv4
+#ifdef CONFIG_NET_IPv6
+      if (IFF_IS_IPv4(dev->d_flags))
+#endif
+        {
+          arp_out(dev);
+        }
+#endif /* CONFIG_NET_IPv4 */
+
+#ifdef CONFIG_NET_IPv6
+#ifdef CONFIG_NET_IPv4
+      else
+#endif
+        {
+          neighbor_out(dev);
+        }
+#endif /* CONFIG_NET_IPv6 */
+
+      if (!devif_loopback(dev))
+        {
+          /* Send the packet */
+
+          NETDEV_TXPACKETS(dev);
+          netdev_send(dev->d_buf, dev->d_len);
+          NETDEV_TXDONE(dev);
+        }
     }
 
-  sched_unlock();
-}
+  /* If zero is returned, the polling will continue until all connections have
+   * been examined.
+   */
 
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
+  return 0;
+}
 
-void netdriver_loop(void)
+static void netdriver_timer_work(FAR void *arg)
 {
-  if (work_available(&g_network))
+  FAR struct net_driver_s *dev = arg;
+
+  net_lock();
+  if (IFF_IS_UP(dev->d_flags))
     {
-      work_queue(LPWORK, &g_network, netdriver_work, NULL, 0);
+      work_queue(LPWORK, &g_timer_work, netdriver_timer_work, dev, CLK_TCK);
+      devif_timer(dev, CLK_TCK, netdriver_txpoll);
     }
+  net_unlock();
 }
 
-int netdriver_ifup(struct net_driver_s *dev)
+static int netdriver_ifup(FAR struct net_driver_s *dev)
 {
   netdev_ifup(dev->d_ipaddr);
+  work_queue(LPWORK, &g_timer_work, netdriver_timer_work, dev, CLK_TCK);
   return OK;
 }
 
-int netdriver_ifdown(struct net_driver_s *dev)
+static int netdriver_ifdown(FAR struct net_driver_s *dev)
 {
+  work_cancel(LPWORK, &g_timer_work);
   netdev_ifdown();
   return OK;
 }
 
+static void netdriver_txavail_work(FAR void *arg)
+{
+  FAR struct net_driver_s *dev = arg;
+
+  net_lock();
+  if (IFF_IS_UP(dev->d_flags))
+    {
+      devif_poll(dev, netdriver_txpoll);
+    }
+  net_unlock();
+}
+
+static int netdriver_txavail(FAR struct net_driver_s *dev)
+{
+  if (work_available(&g_avail_work))
+    {
+      work_queue(LPWORK, &g_avail_work, netdriver_txavail_work, dev, 0);
+    }
+  return OK;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
 int netdriver_init(void)
 {
+  FAR struct net_driver_s *dev = &g_sim_dev;
+
   /* Internal initialization */
 
-  timer_set(&g_periodic_timer, 500);
   netdev_init();
 
   /* Set callbacks */
 
-  g_sim_dev.d_buf    = g_pktbuf;         /* Single packet buffer */
-  g_sim_dev.d_ifup   = netdriver_ifup;
-  g_sim_dev.d_ifdown = netdriver_ifdown;
+  dev->d_buf     = g_pktbuf;         /* Single packet buffer */
+  dev->d_ifup    = netdriver_ifup;
+  dev->d_ifdown  = netdriver_ifdown;
+  dev->d_txavail = netdriver_txavail;
 
   /* Register the device with the OS so that socket IOCTLs can be performed */
 
-  netdev_register(&g_sim_dev, NET_LL_ETHERNET);
-  return OK;
+  return netdev_register(dev, NET_LL_ETHERNET);
 }
 
 void netdriver_setmacaddr(unsigned char *macaddr)
 {
   memcpy(g_sim_dev.d_mac.ether.ether_addr_octet, macaddr, IFHWADDRLEN);
 }
+
+void netdriver_loop(void)
+{
+  if (work_available(&g_recv_work) && netdev_avail())
+    {
+      work_queue(LPWORK, &g_recv_work, netdriver_recv_work, &g_sim_dev, 0);
+    }
+}
diff --git a/arch/sim/src/sim/up_tapdev.c b/arch/sim/src/sim/up_tapdev.c
index 463e453..7d2eef9 100644
--- a/arch/sim/src/sim/up_tapdev.c
+++ b/arch/sim/src/sim/up_tapdev.c
@@ -231,11 +231,10 @@ void tapdev_init(void)
   set_macaddr();
 }
 
-unsigned int tapdev_read(unsigned char *buf, unsigned int buflen)
+int tapdev_avail(void)
 {
-  fd_set                fdset;
-  struct timeval        tv;
-  int                   ret;
+  struct timeval tv;
+  fd_set fdset;
 
   /* We can't do anything if we failed to open the tap device */
 
@@ -247,13 +246,19 @@ unsigned int tapdev_read(unsigned char *buf, unsigned int buflen)
   /* Wait for data on the tap device (or a timeout) */
 
   tv.tv_sec  = 0;
-  tv.tv_usec = 1000;
+  tv.tv_usec = 0;
 
   FD_ZERO(&fdset);
   FD_SET(gtapdevfd, &fdset);
 
-  ret = select(gtapdevfd + 1, &fdset, NULL, NULL, &tv);
-  if (ret == 0)
+  return select(gtapdevfd + 1, &fdset, NULL, NULL, &tv) > 0;
+}
+
+unsigned int tapdev_read(unsigned char *buf, unsigned int buflen)
+{
+  int ret;
+
+  if (!tapdev_avail())
     {
       return 0;
     }
diff --git a/boards/sim/sim/sim/configs/bluetooth/defconfig b/boards/sim/sim/sim/configs/bluetooth/defconfig
index 54e5c9b..2dca351 100644
--- a/boards/sim/sim/sim/configs/bluetooth/defconfig
+++ b/boards/sim/sim/sim/configs/bluetooth/defconfig
@@ -66,7 +66,6 @@ CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SDCLONE_DISABLE=y
-CONFIG_SIM_WALLTIME=y
 CONFIG_START_DAY=3
 CONFIG_START_MONTH=4
 CONFIG_SYSTEM_NSH=y
diff --git a/boards/sim/sim/sim/configs/rpserver/defconfig b/boards/sim/sim/sim/configs/rpserver/defconfig
index 59e6aa2..f355d8d 100644
--- a/boards/sim/sim/sim/configs/rpserver/defconfig
+++ b/boards/sim/sim/sim/configs/rpserver/defconfig
@@ -57,7 +57,6 @@ CONFIG_SCHED_WAITPID=y
 CONFIG_SIM_M32=y
 CONFIG_SIM_NET_BRIDGE=y
 CONFIG_SIM_RPTUN_MASTER=y
-CONFIG_SIM_WALLTIME=y
 CONFIG_SYSLOG_PREFIX=y
 CONFIG_SYSLOG_PREFIX_STRING="server: "
 CONFIG_SYSLOG_RPMSG_SERVER=y
diff --git a/boards/sim/sim/sim/configs/udgram/defconfig b/boards/sim/sim/sim/configs/udgram/defconfig
index cc54d7c..20f7986 100644
--- a/boards/sim/sim/sim/configs/udgram/defconfig
+++ b/boards/sim/sim/sim/configs/udgram/defconfig
@@ -48,7 +48,6 @@ CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SDCLONE_DISABLE=y
-CONFIG_SIM_WALLTIME=y
 CONFIG_START_MONTH=6
 CONFIG_START_YEAR=2008
 CONFIG_SYSTEM_NSH=y
diff --git a/boards/sim/sim/sim/configs/userfs/defconfig b/boards/sim/sim/sim/configs/userfs/defconfig
index 41fc752..86a1214 100644
--- a/boards/sim/sim/sim/configs/userfs/defconfig
+++ b/boards/sim/sim/sim/configs/userfs/defconfig
@@ -57,7 +57,6 @@ CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SDCLONE_DISABLE=y
-CONFIG_SIM_WALLTIME=y
 CONFIG_START_MONTH=6
 CONFIG_START_YEAR=2008
 CONFIG_SYSTEM_NSH=y
diff --git a/boards/sim/sim/sim/configs/ustream/defconfig b/boards/sim/sim/sim/configs/ustream/defconfig
index 208f2f9..109351a 100644
--- a/boards/sim/sim/sim/configs/ustream/defconfig
+++ b/boards/sim/sim/sim/configs/ustream/defconfig
@@ -48,7 +48,6 @@ CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_ONEXIT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SDCLONE_DISABLE=y
-CONFIG_SIM_WALLTIME=y
 CONFIG_START_MONTH=6
 CONFIG_START_YEAR=2008
 CONFIG_SYSTEM_NSH=y


[incubator-nuttx] 03/05: arch/sim: Change CONFIG_NET_ETHERNET to CONFIG_SIM_NETDEV

Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a95f50b5060e270f067e6d37aa5af9e43dd4321a
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Mon Feb 10 15:27:36 2020 +0800

    arch/sim: Change CONFIG_NET_ETHERNET to CONFIG_SIM_NETDEV
    
    Change-Id: I349ab96aa58f7cfdfc8d252854a19c6868f2e648
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 arch/sim/Kconfig                 | 2 +-
 arch/sim/src/Makefile            | 2 --
 arch/sim/src/sim/up_idle.c       | 2 +-
 arch/sim/src/sim/up_initialize.c | 2 +-
 arch/sim/src/sim/up_internal.h   | 6 +++---
 5 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/arch/sim/Kconfig b/arch/sim/Kconfig
index f85c460..00b3d3c 100644
--- a/arch/sim/Kconfig
+++ b/arch/sim/Kconfig
@@ -113,7 +113,7 @@ config SIM_WALLTIME
 config SIM_NETDEV
 	bool "Simulated Network Device"
 	default y
-	depends on NET
+	depends on NET_ETHERNET
 	select ARCH_HAVE_NETDEV_STATISTICS
 	select SCHED_LPWORK
 	---help---
diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile
index 2841b35..b82d531 100644
--- a/arch/sim/src/Makefile
+++ b/arch/sim/src/Makefile
@@ -164,7 +164,6 @@ ifeq ($(CONFIG_ARCH_ROMGETC),y)
 endif
 
 ifeq ($(CONFIG_SIM_NETDEV),y)
-ifeq ($(CONFIG_NET_ETHERNET),y)
   CSRCS += up_netdriver.c
   HOSTCFLAGS += -DNETDEV_BUFSIZE=$(CONFIG_NET_ETH_PKTSIZE)
 ifneq ($(HOSTOS),Cygwin)
@@ -180,7 +179,6 @@ else # HOSTOS != Cygwin
   HOSTSRCS += up_wpcap.c up_netdev.c
   DRVLIB = /lib/w32api/libws2_32.a /lib/w32api/libiphlpapi.a
 endif # HOSTOS != Cygwin
-endif # CONFIG_NET_ETHERNET
 endif # CONFIG_SIM_NETDEV
 
 ifeq ($(CONFIG_RPTUN),y)
diff --git a/arch/sim/src/sim/up_idle.c b/arch/sim/src/sim/up_idle.c
index 0aae79b..27bfa7e 100644
--- a/arch/sim/src/sim/up_idle.c
+++ b/arch/sim/src/sim/up_idle.c
@@ -96,7 +96,7 @@ void up_idle(void)
   up_x11events();
 #endif
 
-#if defined(CONFIG_NET_ETHERNET) && defined(CONFIG_SIM_NETDEV)
+#ifdef CONFIG_SIM_NETDEV
   /* Run the network if enabled */
 
   netdriver_loop();
diff --git a/arch/sim/src/sim/up_initialize.c b/arch/sim/src/sim/up_initialize.c
index 681bedc..a967e71 100644
--- a/arch/sim/src/sim/up_initialize.c
+++ b/arch/sim/src/sim/up_initialize.c
@@ -270,7 +270,7 @@ void up_initialize(void)
   up_registerblockdevice(); /* Our FAT ramdisk at /dev/ram0 */
 #endif
 
-#if defined(CONFIG_NET_ETHERNET) && defined(CONFIG_SIM_NETDEV)
+#ifdef CONFIG_SIM_NETDEV
   netdriver_init();         /* Our "real" network driver */
 #endif
 
diff --git a/arch/sim/src/sim/up_internal.h b/arch/sim/src/sim/up_internal.h
index 17e3118..f87e709 100644
--- a/arch/sim/src/sim/up_internal.h
+++ b/arch/sim/src/sim/up_internal.h
@@ -322,7 +322,7 @@ FAR struct ioexpander_dev_s *sim_ioexpander_initialize(void);
 
 /* up_tapdev.c **************************************************************/
 
-#if defined(CONFIG_NET_ETHERNET) && !defined(__CYGWIN__)
+#if defined(CONFIG_SIM_NETDEV) && !defined(__CYGWIN__)
 void tapdev_init(void);
 unsigned int tapdev_read(unsigned char *buf, unsigned int buflen);
 void tapdev_send(unsigned char *buf, unsigned int buflen);
@@ -338,7 +338,7 @@ void tapdev_ifdown(void);
 
 /* up_wpcap.c ***************************************************************/
 
-#if defined(CONFIG_NET_ETHERNET) && defined(__CYGWIN__)
+#if defined(CONFIG_SIM_NETDEV) && defined(__CYGWIN__)
 void wpcap_init(void);
 unsigned int wpcap_read(unsigned char *buf, unsigned int buflen);
 void wpcap_send(unsigned char *buf, unsigned int buflen);
@@ -352,7 +352,7 @@ void wpcap_send(unsigned char *buf, unsigned int buflen);
 
 /* up_netdriver.c ***********************************************************/
 
-#ifdef CONFIG_NET_ETHERNET
+#ifdef CONFIG_SIM_NETDEV
 int netdriver_init(void);
 void netdriver_setmacaddr(unsigned char *macaddr);
 void netdriver_loop(void);


[incubator-nuttx] 02/05: arch/sim: Change the return type of netdriver_setmacaddr to void

Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit dbc33fa64f485b8e0e9c32bbb0364ebd36248e0e
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Mon Feb 10 15:10:38 2020 +0800

    arch/sim: Change the return type of netdriver_setmacaddr to void
    
    Change-Id: Idad8e411c58223c6e4f6250aa616c1a94ce61780
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 arch/sim/src/sim/up_internal.h  |  2 +-
 arch/sim/src/sim/up_netdriver.c |  3 +--
 arch/sim/src/sim/up_tapdev.c    | 12 +++++-------
 arch/sim/src/sim/up_wpcap.c     | 18 ++++++------------
 4 files changed, 13 insertions(+), 22 deletions(-)

diff --git a/arch/sim/src/sim/up_internal.h b/arch/sim/src/sim/up_internal.h
index e0b2f91..17e3118 100644
--- a/arch/sim/src/sim/up_internal.h
+++ b/arch/sim/src/sim/up_internal.h
@@ -354,7 +354,7 @@ void wpcap_send(unsigned char *buf, unsigned int buflen);
 
 #ifdef CONFIG_NET_ETHERNET
 int netdriver_init(void);
-int netdriver_setmacaddr(unsigned char *macaddr);
+void netdriver_setmacaddr(unsigned char *macaddr);
 void netdriver_loop(void);
 #endif
 
diff --git a/arch/sim/src/sim/up_netdriver.c b/arch/sim/src/sim/up_netdriver.c
index 88e4f73..d816b96 100644
--- a/arch/sim/src/sim/up_netdriver.c
+++ b/arch/sim/src/sim/up_netdriver.c
@@ -370,8 +370,7 @@ int netdriver_init(void)
   return OK;
 }
 
-int netdriver_setmacaddr(unsigned char *macaddr)
+void netdriver_setmacaddr(unsigned char *macaddr)
 {
   memcpy(g_sim_dev.d_mac.ether.ether_addr_octet, macaddr, IFHWADDRLEN);
-  return 0;
 }
diff --git a/arch/sim/src/sim/up_tapdev.c b/arch/sim/src/sim/up_tapdev.c
index 5a09ef3..463e453 100644
--- a/arch/sim/src/sim/up_tapdev.c
+++ b/arch/sim/src/sim/up_tapdev.c
@@ -88,10 +88,10 @@ struct sel_arg_struct
 };
 
 /****************************************************************************
- * NuttX Domain Public Function Prototypes
+ * Public Function Prototypes
  ****************************************************************************/
 
-int netdriver_setmacaddr(unsigned char *macaddr);
+void netdriver_setmacaddr(unsigned char *macaddr);
 
 /****************************************************************************
  * Private Data
@@ -131,10 +131,9 @@ static inline void dump_ethhdr(const char *msg, unsigned char *buf,
 #  define dump_ethhdr(m,b,l)
 #endif
 
-static int up_setmacaddr(void)
+static void set_macaddr(void)
 {
   unsigned char mac[7];
-  int ret = -1;
 
   /* Assign a random locally-created MAC address.
    *
@@ -158,8 +157,7 @@ static int up_setmacaddr(void)
   mac[5] = rand() % 256;
   mac[6] = 0;
 
-  ret = netdriver_setmacaddr(mac);
-  return ret;
+  netdriver_setmacaddr(mac);
 }
 
 /****************************************************************************
@@ -230,7 +228,7 @@ void tapdev_init(void)
 
   /* Set the MAC address */
 
-  up_setmacaddr();
+  set_macaddr();
 }
 
 unsigned int tapdev_read(unsigned char *buf, unsigned int buflen)
diff --git a/arch/sim/src/sim/up_wpcap.c b/arch/sim/src/sim/up_wpcap.c
index 8bc4526..0cf9138 100644
--- a/arch/sim/src/sim/up_wpcap.c
+++ b/arch/sim/src/sim/up_wpcap.c
@@ -69,8 +69,6 @@
  * Private Types
  ****************************************************************************/
 
-__attribute__ ((dllimport)) extern char **__argv[];
-
 struct pcap;
 
 struct pcap_if
@@ -111,22 +109,18 @@ typedef int (*pcap_sendpacket_t)(struct pcap *, unsigned char *, int);
 HMODULE wpcap;
 static struct pcap *pcap;
 
-/****************************************************************************
- * Public Function Prototypes
- ****************************************************************************/
-
-extern int netdriver_setmacaddr(unsigned char *macaddr);
-
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
-
 static pcap_findalldevs_t pcap_findalldevs;
 static pcap_open_live_t   pcap_open_live;
 static pcap_next_ex_t     pcap_next_ex;
 static pcap_sendpacket_t  pcap_sendpacket;
 
 /****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+void netdriver_setmacaddr(unsigned char *macaddr);
+
+/****************************************************************************
  * Private Functions
  ****************************************************************************/
 


[incubator-nuttx] 05/05: boards/sim: Update README.txt for network setup

Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 3ef7a6dea1f1be0afa5ddbfa038facfbc23ec59f
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Tue Feb 11 11:37:22 2020 +0800

    boards/sim: Update README.txt for network setup
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 boards/sim/sim/sim/README.txt | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/boards/sim/sim/sim/README.txt b/boards/sim/sim/sim/README.txt
index cc0c287..4a12e3e 100644
--- a/boards/sim/sim/sim/README.txt
+++ b/boards/sim/sim/sim/README.txt
@@ -199,6 +199,16 @@ REVISIT: This may not long be an issue even with NSH because of the recent
 redesign of how the stdio devices are handled in the simulation (they should
 no longer freeze the simulation).
 
+Update: Please issue these commands to setup the reliable network on Ubuntu:
+
+  sudo apt-get -y install net-tools
+  sudo nuttx/tools/simbridge.sh eth0 on
+
+Here is some tips you may need:
+  1.Must launch the exectuable with the root permission
+  2.Have to use virtual machine if host is in corporation network
+  3.Configure the network adpater in NAT mode if virtual machine is used
+
 X11 Issues
 ----------
 There is an X11-based framebuffer driver that you can use to exercise the