summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-11-15 08:22:51 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-11-15 08:22:51 -0600
commitb68b625556543fd9a9c9ba40ed5ca5c4b725f7ed (patch)
treeae5f590da1302541d30c3a26f4a9ffc7d599b338
parentc43a244ee4d243ab3429a39ed90408eeb02a864c (diff)
downloadpx4-nuttx-b68b625556543fd9a9c9ba40ed5ca5c4b725f7ed.tar.gz
px4-nuttx-b68b625556543fd9a9c9ba40ed5ca5c4b725f7ed.tar.bz2
px4-nuttx-b68b625556543fd9a9c9ba40ed5ca5c4b725f7ed.zip
Netwoek: Ada a parameter to netdev_register() to indicate the link protocol supported by the driver. Use this value to replace some logic commited yesterday
-rw-r--r--nuttx/Documentation/NuttxPortingGuide.html4
-rw-r--r--nuttx/arch/arm/src/c5471/c5471_ethernet.c2
-rw-r--r--nuttx/arch/arm/src/kinetis/kinetis_enet.c2
-rw-r--r--nuttx/arch/arm/src/lpc17xx/lpc17_ethernet.c2
-rw-r--r--nuttx/arch/arm/src/sam34/sam_emac.c2
-rw-r--r--nuttx/arch/arm/src/sama5/sam_emaca.c2
-rw-r--r--nuttx/arch/arm/src/sama5/sam_emacb.c2
-rw-r--r--nuttx/arch/arm/src/sama5/sam_gmac.c2
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_eth.c2
-rw-r--r--nuttx/arch/arm/src/tiva/tiva_ethernet.c2
-rw-r--r--nuttx/arch/hc/src/m9s12/m9s12_ethernet.c2
-rw-r--r--nuttx/arch/mips/src/pic32mx/pic32mx-ethernet.c2
-rw-r--r--nuttx/arch/sim/src/up_netdriver.c2
-rw-r--r--nuttx/arch/z80/src/ez80/ez80_emac.c2
-rw-r--r--nuttx/configs/stm32f4discovery/netnsh/defconfig51
-rw-r--r--nuttx/drivers/net/cs89x0.c2
-rw-r--r--nuttx/drivers/net/dm90x0.c2
-rw-r--r--nuttx/drivers/net/e1000.c2
-rw-r--r--nuttx/drivers/net/enc28j60.c2
-rw-r--r--nuttx/drivers/net/encx24j600.c2
-rw-r--r--nuttx/drivers/net/skeleton.c2
-rw-r--r--nuttx/drivers/net/slip.c13
-rw-r--r--nuttx/drivers/net/vnet.c379
-rw-r--r--nuttx/include/nuttx/net/net.h13
-rw-r--r--nuttx/include/nuttx/net/netdev.h19
-rw-r--r--nuttx/net/Kconfig8
-rw-r--r--nuttx/net/arp/arp_send.c16
-rw-r--r--nuttx/net/netdev/netdev_register.c61
28 files changed, 362 insertions, 240 deletions
diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html
index 3bfd4021f..7aebea676 100644
--- a/nuttx/Documentation/NuttxPortingGuide.html
+++ b/nuttx/Documentation/NuttxPortingGuide.html
@@ -12,7 +12,7 @@
<h1><big><font color="#3c34ec">
<i>NuttX RTOS Porting Guide</i>
</font></big></h1>
- <p>Last Updated: October 14, 2014</p>
+ <p>Last Updated: November 15, 2014</p>
</td>
</tr>
</table>
@@ -4315,7 +4315,7 @@ void board_led_off(int led);
</li>
<li>
<p>
- <b><code>int netdev_register(FAR struct net_driver_s *dev);</code></b>.
+ <b><code>int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype);</code></b>.
Each Ethernet driver registers itself by calling <code>netdev_register()</code>.
</p>
</li>
diff --git a/nuttx/arch/arm/src/c5471/c5471_ethernet.c b/nuttx/arch/arm/src/c5471/c5471_ethernet.c
index 12a15eee7..abf608cf0 100644
--- a/nuttx/arch/arm/src/c5471/c5471_ethernet.c
+++ b/nuttx/arch/arm/src/c5471/c5471_ethernet.c
@@ -2156,7 +2156,7 @@ void up_netinitialize(void)
/* Register the device with the OS so that socket IOCTLs can be performed */
- (void)netdev_register(&g_c5471[0].c_dev);
+ (void)netdev_register(&g_c5471[0].c_dev, NET_LL_ETHERNET);
}
#endif /* CONFIG_NET */
diff --git a/nuttx/arch/arm/src/kinetis/kinetis_enet.c b/nuttx/arch/arm/src/kinetis/kinetis_enet.c
index 096d3fbd0..9042fca40 100644
--- a/nuttx/arch/arm/src/kinetis/kinetis_enet.c
+++ b/nuttx/arch/arm/src/kinetis/kinetis_enet.c
@@ -1541,7 +1541,7 @@ int kinetis_netinitialize(int intf)
/* Register the device with the OS so that socket IOCTLs can be performed */
- (void)netdev_register(&priv->dev);
+ (void)netdev_register(&priv->dev, NET_LL_ETHERNET);
return OK;
}
diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_ethernet.c b/nuttx/arch/arm/src/lpc17xx/lpc17_ethernet.c
index 46c857ed2..05108d3cf 100644
--- a/nuttx/arch/arm/src/lpc17xx/lpc17_ethernet.c
+++ b/nuttx/arch/arm/src/lpc17xx/lpc17_ethernet.c
@@ -2587,7 +2587,7 @@ static inline int lpc17_ethinitialize(int intf)
/* Register the device with the OS so that socket IOCTLs can be performed */
- (void)netdev_register(&priv->lp_dev);
+ (void)netdev_register(&priv->lp_dev, NET_LL_ETHERNET);
return OK;
}
diff --git a/nuttx/arch/arm/src/sam34/sam_emac.c b/nuttx/arch/arm/src/sam34/sam_emac.c
index bb0e1ff2d..2573778a4 100644
--- a/nuttx/arch/arm/src/sam34/sam_emac.c
+++ b/nuttx/arch/arm/src/sam34/sam_emac.c
@@ -3108,7 +3108,7 @@ void up_netinitialize(void)
/* Register the device with the OS so that socket IOCTLs can be performed */
- ret = netdev_register(&priv->dev);
+ ret = netdev_register(&priv->dev, NET_LL_ETHERNET);
if (ret >= 0)
{
return;
diff --git a/nuttx/arch/arm/src/sama5/sam_emaca.c b/nuttx/arch/arm/src/sama5/sam_emaca.c
index f7df54fd6..ecfa5a45c 100644
--- a/nuttx/arch/arm/src/sama5/sam_emaca.c
+++ b/nuttx/arch/arm/src/sama5/sam_emaca.c
@@ -3157,7 +3157,7 @@ int sam_emac_initialize(void)
/* Register the device with the OS so that socket IOCTLs can be performed */
- ret = netdev_register(&priv->dev);
+ ret = netdev_register(&priv->dev, NET_LL_ETHERNET);
if (ret >= 0)
{
return ret;
diff --git a/nuttx/arch/arm/src/sama5/sam_emacb.c b/nuttx/arch/arm/src/sama5/sam_emacb.c
index b52144cef..a32174512 100644
--- a/nuttx/arch/arm/src/sama5/sam_emacb.c
+++ b/nuttx/arch/arm/src/sama5/sam_emacb.c
@@ -3851,7 +3851,7 @@ int sam_emac_initialize(int intf)
/* Register the device with the OS so that socket IOCTLs can be performed */
- ret = netdev_register(&priv->dev);
+ ret = netdev_register(&priv->dev, NET_LL_ETHERNET);
if (ret >= 0)
{
return ret;
diff --git a/nuttx/arch/arm/src/sama5/sam_gmac.c b/nuttx/arch/arm/src/sama5/sam_gmac.c
index fb18c8953..7f112b04c 100644
--- a/nuttx/arch/arm/src/sama5/sam_gmac.c
+++ b/nuttx/arch/arm/src/sama5/sam_gmac.c
@@ -3229,7 +3229,7 @@ int sam_gmac_initialize(void)
/* Register the device with the OS so that socket IOCTLs can be performed */
- ret = netdev_register(&priv->dev);
+ ret = netdev_register(&priv->dev, NET_LL_ETHERNET);
if (ret >= 0)
{
return ret;
diff --git a/nuttx/arch/arm/src/stm32/stm32_eth.c b/nuttx/arch/arm/src/stm32/stm32_eth.c
index 729e034f5..e72a008af 100644
--- a/nuttx/arch/arm/src/stm32/stm32_eth.c
+++ b/nuttx/arch/arm/src/stm32/stm32_eth.c
@@ -3610,7 +3610,7 @@ int stm32_ethinitialize(int intf)
/* Register the device with the OS so that socket IOCTLs can be performed */
- (void)netdev_register(&priv->dev);
+ (void)netdev_register(&priv->dev, NET_LL_ETHERNET);
return OK;
}
diff --git a/nuttx/arch/arm/src/tiva/tiva_ethernet.c b/nuttx/arch/arm/src/tiva/tiva_ethernet.c
index a235fe0c1..1fb19f882 100644
--- a/nuttx/arch/arm/src/tiva/tiva_ethernet.c
+++ b/nuttx/arch/arm/src/tiva/tiva_ethernet.c
@@ -1448,7 +1448,7 @@ static inline int tiva_ethinitialize(int intf)
/* Register the device with the OS so that socket IOCTLs can be performed */
- (void)netdev_register(&priv->ld_dev);
+ (void)netdev_register(&priv->ld_dev, NET_LL_ETHERNET);
return OK;
}
diff --git a/nuttx/arch/hc/src/m9s12/m9s12_ethernet.c b/nuttx/arch/hc/src/m9s12/m9s12_ethernet.c
index 023bc922b..b179fb728 100644
--- a/nuttx/arch/hc/src/m9s12/m9s12_ethernet.c
+++ b/nuttx/arch/hc/src/m9s12/m9s12_ethernet.c
@@ -685,7 +685,7 @@ int emac_initialize(int intf)
/* Register the device with the OS so that socket IOCTLs can be performed */
- (void)netdev_register(&priv->d_dev);
+ (void)netdev_register(&priv->d_dev, NET_LL_ETHERNET);
return OK;
}
diff --git a/nuttx/arch/mips/src/pic32mx/pic32mx-ethernet.c b/nuttx/arch/mips/src/pic32mx/pic32mx-ethernet.c
index eeaf3ad5c..f1633f752 100644
--- a/nuttx/arch/mips/src/pic32mx/pic32mx-ethernet.c
+++ b/nuttx/arch/mips/src/pic32mx/pic32mx-ethernet.c
@@ -3143,7 +3143,7 @@ static inline int pic32mx_ethinitialize(int intf)
/* Register the device with the OS so that socket IOCTLs can be performed */
- (void)netdev_register(&priv->pd_dev);
+ (void)netdev_register(&priv->pd_dev, NET_LL_ETHERNET);
return OK;
}
diff --git a/nuttx/arch/sim/src/up_netdriver.c b/nuttx/arch/sim/src/up_netdriver.c
index c6636a045..90ff0bb3e 100644
--- a/nuttx/arch/sim/src/up_netdriver.c
+++ b/nuttx/arch/sim/src/up_netdriver.c
@@ -215,7 +215,7 @@ int netdriver_init(void)
/* Register the device with the OS so that socket IOCTLs can be performed */
- (void)netdev_register(&g_sim_dev);
+ (void)netdev_register(&g_sim_dev, NET_LL_ETHERNET);
return OK;
}
diff --git a/nuttx/arch/z80/src/ez80/ez80_emac.c b/nuttx/arch/z80/src/ez80/ez80_emac.c
index baaa953cf..f0f1797eb 100644
--- a/nuttx/arch/z80/src/ez80/ez80_emac.c
+++ b/nuttx/arch/z80/src/ez80/ez80_emac.c
@@ -2148,7 +2148,7 @@ int up_netinitialize(void)
/* Register the device with the OS so that socket IOCTLs can be performed */
- (void)netdev_register(&priv->dev);
+ (void)netdev_register(&priv->dev, NET_LL_ETHERNET);
return OK;
errout:
diff --git a/nuttx/configs/stm32f4discovery/netnsh/defconfig b/nuttx/configs/stm32f4discovery/netnsh/defconfig
index eb0813cbe..9adfd163e 100644
--- a/nuttx/configs/stm32f4discovery/netnsh/defconfig
+++ b/nuttx/configs/stm32f4discovery/netnsh/defconfig
@@ -76,6 +76,7 @@ CONFIG_ARCH="arm"
# CONFIG_ARCH_CHIP_C5471 is not set
# CONFIG_ARCH_CHIP_CALYPSO is not set
# CONFIG_ARCH_CHIP_DM320 is not set
+# CONFIG_ARCH_CHIP_EFM32 is not set
# CONFIG_ARCH_CHIP_IMX is not set
# CONFIG_ARCH_CHIP_KINETIS is not set
# CONFIG_ARCH_CHIP_KL is not set
@@ -120,7 +121,7 @@ CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y
# CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL is not set
# CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW is not set
# CONFIG_ARMV7M_TOOLCHAIN_RAISONANCE is not set
-# CONFIG_SERIAL_TERMIOS is not set
+# CONFIG_ARMV7M_ITMSYSLOG is not set
CONFIG_SDIO_DMA=y
CONFIG_SDIO_DMAPRIO=0x00010000
# CONFIG_SDIO_WIDTH_D1_ONLY is not set
@@ -170,6 +171,7 @@ CONFIG_SDIO_DMAPRIO=0x00010000
# CONFIG_ARCH_CHIP_STM32F103RC is not set
# CONFIG_ARCH_CHIP_STM32F103RD is not set
# CONFIG_ARCH_CHIP_STM32F103RE is not set
+# CONFIG_ARCH_CHIP_STM32F103RG is not set
# CONFIG_ARCH_CHIP_STM32F103V8 is not set
# CONFIG_ARCH_CHIP_STM32F103VB is not set
# CONFIG_ARCH_CHIP_STM32F103VC is not set
@@ -192,6 +194,7 @@ CONFIG_SDIO_DMAPRIO=0x00010000
# CONFIG_ARCH_CHIP_STM32F303VB is not set
# CONFIG_ARCH_CHIP_STM32F303VC is not set
# CONFIG_ARCH_CHIP_STM32F401RE is not set
+# CONFIG_ARCH_CHIP_STM32F411RE is not set
# CONFIG_ARCH_CHIP_STM32F405RG is not set
# CONFIG_ARCH_CHIP_STM32F405VG is not set
# CONFIG_ARCH_CHIP_STM32F405ZG is not set
@@ -223,6 +226,7 @@ CONFIG_ARCH_CHIP_STM32F407VG=y
# CONFIG_STM32_STM32F30XX is not set
CONFIG_STM32_STM32F40XX=y
# CONFIG_STM32_STM32F401 is not set
+# CONFIG_STM32_STM32F411 is not set
# CONFIG_STM32_STM32F405 is not set
CONFIG_STM32_STM32F407=y
# CONFIG_STM32_STM32F427 is not set
@@ -263,6 +267,10 @@ CONFIG_STM32_HAVE_CAN1=y
CONFIG_STM32_HAVE_CAN2=y
CONFIG_STM32_HAVE_RNG=y
CONFIG_STM32_HAVE_ETHMAC=y
+CONFIG_STM32_HAVE_SPI2=y
+CONFIG_STM32_HAVE_SPI3=y
+# CONFIG_STM32_HAVE_SPI4 is not set
+# CONFIG_STM32_HAVE_SPI5 is not set
# CONFIG_STM32_ADC1 is not set
# CONFIG_STM32_ADC2 is not set
# CONFIG_STM32_ADC3 is not set
@@ -370,7 +378,15 @@ CONFIG_STM32_RMII=y
CONFIG_STM32_RMII_EXTCLK=y
#
-# USB Host Configuration
+# USB FS Host Configuration
+#
+
+#
+# USB HS Host Configuration
+#
+
+#
+# USB Host Debug Configuration
#
#
@@ -543,6 +559,16 @@ CONFIG_PREALLOC_MQ_MSGS=4
CONFIG_MQ_MAXMSGSIZE=32
#
+# Work Queue Support
+#
+CONFIG_SCHED_WORKQUEUE=y
+CONFIG_SCHED_HPWORK=y
+CONFIG_SCHED_HPWORKPRIORITY=192
+CONFIG_SCHED_HPWORKPERIOD=50000
+CONFIG_SCHED_HPWORKSTACKSIZE=2048
+# CONFIG_SCHED_LPWORK is not set
+
+#
# Stack and heap information
#
CONFIG_IDLETHREAD_STACKSIZE=1024
@@ -657,6 +683,7 @@ CONFIG_SERIAL=y
CONFIG_ARCH_HAVE_USART6=y
# CONFIG_ARCH_HAVE_USART7 is not set
# CONFIG_ARCH_HAVE_USART8 is not set
+# CONFIG_ARCH_HAVE_OTHER_UART is not set
#
# USART Configuration
@@ -664,7 +691,10 @@ CONFIG_ARCH_HAVE_USART6=y
CONFIG_USART6_ISUART=y
CONFIG_MCU_SERIAL=y
CONFIG_STANDARD_SERIAL=y
+CONFIG_ARCH_HAVE_SERIAL_TERMIOS=y
+# CONFIG_SERIAL_TERMIOS is not set
CONFIG_USART6_SERIAL_CONSOLE=y
+# CONFIG_OTHER_SERIAL_CONSOLE is not set
# CONFIG_NO_SERIAL_CONSOLE is not set
#
@@ -786,6 +816,7 @@ CONFIG_IOB_THROTTLE=8
# Routing Table Configuration
#
# CONFIG_NET_ROUTE is not set
+# CONFIG_NET_MULTILINK is not set
CONFIG_NET_ETHERNET=y
#
@@ -805,6 +836,8 @@ CONFIG_NET_ETHERNET=y
# CONFIG_DISABLE_PSEUDOFS_OPERATIONS is not set
CONFIG_FS_READABLE=y
CONFIG_FS_WRITABLE=y
+# CONFIG_FS_NAMED_SEMAPHORES is not set
+CONFIG_FS_MQUEUE_MPATH="/var/mqueue"
# CONFIG_FS_RAMMAP is not set
CONFIG_FS_FAT=y
CONFIG_FAT_LCNAMES=y
@@ -822,8 +855,8 @@ CONFIG_FAT_MAXFNAME=32
#
# System Logging
#
-
# CONFIG_SYSLOG is not set
+# CONFIG_SYSLOG_TIMESTAMP is not set
#
# Graphics Support
@@ -844,7 +877,7 @@ CONFIG_MM_REGIONS=1
# CONFIG_AUDIO is not set
#
-# Binary Formats
+# Binary Loader
#
# CONFIG_BINFMT_DISABLE is not set
# CONFIG_BINFMT_EXEPATH is not set
@@ -878,6 +911,8 @@ CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=1024
CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=2048
# CONFIG_LIBC_STRERROR is not set
# CONFIG_LIBC_PERROR_STDOUT is not set
+CONFIG_LIBC_TMPDIR="/tmp"
+CONFIG_LIBC_MAX_TMPFILE=32
CONFIG_ARCH_LOWPUTC=y
# CONFIG_LIBC_LOCALTIME is not set
CONFIG_LIB_SENDFILE_BUFSIZE=512
@@ -887,12 +922,6 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512
#
# Non-standard Library Support
#
-CONFIG_SCHED_WORKQUEUE=y
-CONFIG_SCHED_HPWORK=y
-CONFIG_SCHED_HPWORKPRIORITY=192
-CONFIG_SCHED_HPWORKPERIOD=50000
-CONFIG_SCHED_HPWORKSTACKSIZE=2048
-# CONFIG_SCHED_LPWORK is not set
# CONFIG_LIB_KBDCODEC is not set
# CONFIG_LIB_SLCDCODEC is not set
@@ -986,6 +1015,7 @@ CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y
# Interpreters
#
# CONFIG_INTERPRETERS_FICL is not set
+# CONFIG_INTERPRETERS_BAS is not set
# CONFIG_INTERPRETERS_PCODE is not set
#
@@ -1011,6 +1041,7 @@ CONFIG_NETUTILS_TFTPC=y
CONFIG_NETUTILS_NETLIB=y
CONFIG_NETUTILS_WEBCLIENT=y
CONFIG_NSH_WGET_USERAGENT="NuttX/6.xx.x (; http://www.nuttx.org/)"
+CONFIG_WEBCLIENT_TIMEOUT=10
# CONFIG_NETUTILS_WEBSERVER is not set
# CONFIG_NETUTILS_NTPCLIENT is not set
# CONFIG_NETUTILS_DISCOVER is not set
diff --git a/nuttx/drivers/net/cs89x0.c b/nuttx/drivers/net/cs89x0.c
index 9e386af49..069e708cd 100644
--- a/nuttx/drivers/net/cs89x0.c
+++ b/nuttx/drivers/net/cs89x0.c
@@ -951,7 +951,7 @@ int cs89x0_initialize(FAR const cs89x0_driver_s *cs89x0, int devno)
/* Register the device with the OS so that socket IOCTLs can be performed */
- (void)netdev_register(&cs89x0->cs_dev);
+ (void)netdev_register(&cs89x0->cs_dev, NET_LL_ETHERNET);
return OK;
}
diff --git a/nuttx/drivers/net/dm90x0.c b/nuttx/drivers/net/dm90x0.c
index 80885b49e..13aaa38ec 100644
--- a/nuttx/drivers/net/dm90x0.c
+++ b/nuttx/drivers/net/dm90x0.c
@@ -1803,7 +1803,7 @@ int dm9x_initialize(void)
/* Register the device with the OS so that socket IOCTLs can be performed */
- (void)netdev_register(&g_dm9x[0].dm_dev);
+ (void)netdev_register(&g_dm9x[0].dm_dev, NET_LL_ETHERNET);
return OK;
}
diff --git a/nuttx/drivers/net/e1000.c b/nuttx/drivers/net/e1000.c
index eb695a466..5a1861642 100644
--- a/nuttx/drivers/net/e1000.c
+++ b/nuttx/drivers/net/e1000.c
@@ -1097,7 +1097,7 @@ static int e1000_probe(uint16_t addr, pci_id_t id)
/* Register the device with the OS so that socket IOCTLs can be performed */
- err = netdev_register(&dev->netdev);
+ err = netdev_register(&dev->netdev, NET_LL_ETHERNET);
if (err)
{
goto err2;
diff --git a/nuttx/drivers/net/enc28j60.c b/nuttx/drivers/net/enc28j60.c
index a2ec009db..5c045f1de 100644
--- a/nuttx/drivers/net/enc28j60.c
+++ b/nuttx/drivers/net/enc28j60.c
@@ -2595,7 +2595,7 @@ int enc_initialize(FAR struct spi_dev_s *spi,
/* Register the device with the OS so that socket IOCTLs can be performed */
- return netdev_register(&priv->dev);
+ return netdev_register(&priv->dev, NET_LL_ETHERNET);
}
/****************************************************************************
diff --git a/nuttx/drivers/net/encx24j600.c b/nuttx/drivers/net/encx24j600.c
index 69e683fb2..d4eb7095e 100644
--- a/nuttx/drivers/net/encx24j600.c
+++ b/nuttx/drivers/net/encx24j600.c
@@ -2859,7 +2859,7 @@ int enc_initialize(FAR struct spi_dev_s *spi,
/* Register the device with the OS so that socket IOCTLs can be performed */
- return netdev_register(&priv->dev);
+ return netdev_register(&priv->dev, NET_LL_ETHERNET);
}
/****************************************************************************
diff --git a/nuttx/drivers/net/skeleton.c b/nuttx/drivers/net/skeleton.c
index ae9358f91..061e8df3d 100644
--- a/nuttx/drivers/net/skeleton.c
+++ b/nuttx/drivers/net/skeleton.c
@@ -685,7 +685,7 @@ int skel_initialize(int intf)
/* Register the device with the OS so that socket IOCTLs can be performed */
- (void)netdev_register(&priv->sk_dev);
+ (void)netdev_register(&priv->sk_dev, NET_LL_ETHERNET);
return OK;
}
diff --git a/nuttx/drivers/net/slip.c b/nuttx/drivers/net/slip.c
index ed1b0d9d6..f1533be80 100644
--- a/nuttx/drivers/net/slip.c
+++ b/nuttx/drivers/net/slip.c
@@ -935,17 +935,6 @@ int slip_initialize(int intf, FAR const char *devname)
#endif
priv->dev.d_private = priv; /* Used to recover private state from dev */
-#ifdef CONFIG_NET_ETHERNET
- /* If ARP is supported, indicate that it is not required for this interface.
- * ARP is only built of CONFIG_NET_ETHERNET is enabled which always
- * requires ARP support. The following can happening only there multiple
- * network interfaces enabled (CONFIG_NET_MULTINIC) and one of the
- * interfaces is Ethernet and another is SLIP.
- */
-
- priv->dev.d_flags = IFF_NOARP;
-#endif
-
/* Open the device */
priv->fd = open(devname, O_RDWR, 0666);
@@ -1003,7 +992,7 @@ int slip_initialize(int intf, FAR const char *devname)
/* Register the device with the OS so that socket IOCTLs can be performed */
- (void)netdev_register(&priv->dev);
+ (void)netdev_register(&priv->dev, NET_LL_SLIP);
/* When the RX and TX tasks were created, the TTY file descriptor was
* dup'ed for each task. This task no longer needs the file descriptor
diff --git a/nuttx/drivers/net/vnet.c b/nuttx/drivers/net/vnet.c
index bda4c62c9..7d97d5538 100644
--- a/nuttx/drivers/net/vnet.c
+++ b/nuttx/drivers/net/vnet.c
@@ -71,7 +71,7 @@
*/
#ifndef CONFIG_VNET_NINTERFACES
-# define CONFIG_VNET_NINTERFACES 1
+# define CONFIG_VNET_NINTERFACES 1
#endif
/* TX poll deley = 1 seconds. CLK_TCK is the number of clock ticks per second */
@@ -97,13 +97,14 @@
struct vnet_driver_s
{
- bool sk_bifup; /* true:ifup false:ifdown */
- WDOG_ID sk_txpoll; /* TX poll timer */
- //WDOG_ID sk_txtimeout; /* TX timeout timer */
+ bool sk_bifup; /* true:ifup false:ifdown */
+ WDOG_ID sk_txpoll; /* TX poll timer */
+ //WDOG_ID sk_txtimeout; /* TX timeout timer */
- /* This holds the information visible to uIP/NuttX */
- struct rgmp_vnet *vnet;
- struct net_driver_s sk_dev; /* Interface understood by uIP */
+ /* This holds the information visible to uIP/NuttX */
+
+ struct rgmp_vnet *vnet;
+ struct net_driver_s sk_dev; /* Interface understood by uIP */
};
/****************************************************************************
@@ -166,35 +167,42 @@ static int vnet_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac);
static int vnet_transmit(FAR struct vnet_driver_s *vnet)
{
- int err;
+ int err;
+
+ /* Verify that the hardware is ready to send another packet. If we get
+ * here, then we are committed to sending a packet; Higher level logic
+ * must have assured that there is not transmission in progress.
+ */
+
+ /* Increment statistics */
- /* Verify that the hardware is ready to send another packet. If we get
- * here, then we are committed to sending a packet; Higher level logic
- * must have assured that there is not transmission in progress.
- */
+ /* Send the packet: address=vnet->sk_dev.d_buf, length=vnet->sk_dev.d_len */
+
+ err = vnet_xmit(vnet->vnet, (char *)vnet->sk_dev.d_buf, vnet->sk_dev.d_len);
+ if (err)
+ {
+ /* Setup the TX timeout watchdog (perhaps restarting the timer) */
- /* Increment statistics */
+ //(void)wd_start(vnet->sk_txtimeout, VNET_TXTIMEOUT, vnet_txtimeout, 1, (uint32_t)vnet);
- /* Send the packet: address=vnet->sk_dev.d_buf, length=vnet->sk_dev.d_len */
- err = vnet_xmit(vnet->vnet, (char *)vnet->sk_dev.d_buf, vnet->sk_dev.d_len);
- if (err) {
- /* Setup the TX timeout watchdog (perhaps restarting the timer) */
- //(void)wd_start(vnet->sk_txtimeout, VNET_TXTIMEOUT, vnet_txtimeout, 1, (uint32_t)vnet);
+ /* When vnet_xmit fail, it means TX buffer is full. Watchdog
+ * is of no use here because no TX done INT will happen. So
+ * we reset the TX buffer directly.
+ */
- // When vnet_xmit fail, it means TX buffer is full. Watchdog
- // is of no use here because no TX done INT will happen. So
- // we reset the TX buffer directly.
#ifdef CONFIG_DEBUG
- cprintf("VNET: TX buffer is full\n");
+ cprintf("VNET: TX buffer is full\n");
#endif
- return ERROR;
+ return ERROR;
}
- else {
- // this step may be unnecessary here
- vnet_txdone(vnet);
+ else
+ {
+ /* This step may be unnecessary here */
+
+ vnet_txdone(vnet);
}
- return OK;
+ return OK;
}
/****************************************************************************
@@ -223,29 +231,32 @@ static int vnet_transmit(FAR struct vnet_driver_s *vnet)
static int vnet_txpoll(struct net_driver_s *dev)
{
- FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
+ FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
- /* 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 the polling resulted in data that should be sent out on the network,
+ * the field d_len is set to a value > 0.
+ */
- if (vnet->sk_dev.d_len > 0)
+ if (vnet->sk_dev.d_len > 0)
{
- arp_out(&vnet->sk_dev);
- vnet_transmit(vnet);
-
- /* Check if there is room in the device to hold another packet. If not,
- * return a non-zero value to terminate the poll.
- */
- if (vnet_is_txbuff_full(vnet->vnet))
- return 1;
+ arp_out(&vnet->sk_dev);
+ vnet_transmit(vnet);
+
+ /* Check if there is room in the device to hold another packet. If not,
+ * return a non-zero value to terminate the poll.
+ */
+
+ if (vnet_is_txbuff_full(vnet->vnet))
+ {
+ return 1;
+ }
}
- /* If zero is returned, the polling will continue until all connections have
- * been examined.
- */
+ /* If zero is returned, the polling will continue until all connections have
+ * been examined.
+ */
- return 0;
+ return 0;
}
/****************************************************************************
@@ -267,53 +278,65 @@ static int vnet_txpoll(struct net_driver_s *dev)
void rtos_vnet_recv(struct rgmp_vnet *rgmp_vnet, char *data, int len)
{
- struct vnet_driver_s *vnet = rgmp_vnet->priv;
+ struct vnet_driver_s *vnet = rgmp_vnet->priv;
- do {
- /* Check for errors and update statistics */
+ do
+ {
+ /* Check for errors and update statistics */
+
+ /* Check if the packet is a valid size for the uIP buffer configuration */
- /* Check if the packet is a valid size for the uIP buffer configuration */
- if (len > CONFIG_NET_BUFSIZE || len < 14) {
+ if (len > CONFIG_NET_BUFSIZE || len < 14)
+ {
#ifdef CONFIG_DEBUG
- cprintf("VNET: receive invalid packet of size %d\n", len);
+ cprintf("VNET: receive invalid packet of size %d\n", len);
#endif
- return;
- }
+ return;
+ }
+
+ /* Copy the data data from the hardware to vnet->sk_dev.d_buf. Set
+ * amount of data in vnet->sk_dev.d_len
+ */
- // Copy the data data from the hardware to vnet->sk_dev.d_buf. Set
- // amount of data in vnet->sk_dev.d_len
- memcpy(vnet->sk_dev.d_buf, data, len);
- vnet->sk_dev.d_len = len;
+ memcpy(vnet->sk_dev.d_buf, data, len);
+ vnet->sk_dev.d_len = len;
- /* We only accept IP packets of the configured type and ARP packets */
+ /* We only accept IP packets of the configured type and ARP packets */
#ifdef CONFIG_NET_IPv6
- if (BUF->type == HTONS(ETHTYPE_IP6))
+ if (BUF->type == HTONS(ETHTYPE_IP6))
#else
- if (BUF->type == HTONS(ETHTYPE_IP))
+ if (BUF->type == HTONS(ETHTYPE_IP))
#endif
- {
- arp_ipin(&vnet->sk_dev);
- devif_input(&vnet->sk_dev);
-
- // If the above function invocation resulted in data that should be
- // sent out on the network, the field d_len will set to a value > 0.
- if (vnet->sk_dev.d_len > 0) {
- arp_out(&vnet->sk_dev);
- vnet_transmit(vnet);
- }
- }
- else if (BUF->type == htons(ETHTYPE_ARP)) {
- arp_arpin(&vnet->sk_dev);
-
- // If the above function invocation resulted in data that should be
- // sent out on the network, the field d_len will set to a value > 0.
- if (vnet->sk_dev.d_len > 0) {
- vnet_transmit(vnet);
- }
- }
+ {
+ arp_ipin(&vnet->sk_dev);
+ devif_input(&vnet->sk_dev);
+
+ /* If the above function invocation resulted in data that should be
+ * sent out on the network, the field d_len will set to a value > 0.
+ */
+
+ if (vnet->sk_dev.d_len > 0)
+ {
+ arp_out(&vnet->sk_dev);
+ vnet_transmit(vnet);
+ }
+ }
+ else if (BUF->type == htons(ETHTYPE_ARP))
+ {
+ arp_arpin(&vnet->sk_dev);
+
+ /* If the above function invocation resulted in data that should be
+ * sent out on the network, the field d_len will set to a value > 0.
+ */
+
+ if (vnet->sk_dev.d_len > 0)
+ {
+ vnet_transmit(vnet);
+ }
+ }
}
- while (0); /* While there are more packets to be processed */
+ while (0); /* While there are more packets to be processed */
}
/****************************************************************************
@@ -335,17 +358,17 @@ void rtos_vnet_recv(struct rgmp_vnet *rgmp_vnet, char *data, int len)
static void vnet_txdone(FAR struct vnet_driver_s *vnet)
{
- /* Check for errors and update statistics */
+ /* Check for errors and update statistics */
- /* If no further xmits are pending, then cancel the TX timeout and
- * disable further Tx interrupts.
- */
+ /* If no further xmits are pending, then cancel the TX timeout and
+ * disable further Tx interrupts.
+ */
- //wd_cancel(vnet->sk_txtimeout);
+ //wd_cancel(vnet->sk_txtimeout);
- /* Then poll uIP for new XMIT data */
+ /* Then poll uIP for new XMIT data */
- (void)devif_poll(&vnet->sk_dev, vnet_txpoll);
+ (void)devif_poll(&vnet->sk_dev, vnet_txpoll);
}
/****************************************************************************
@@ -369,15 +392,15 @@ static void vnet_txdone(FAR struct vnet_driver_s *vnet)
static void vnet_txtimeout(int argc, uint32_t arg, ...)
{
- FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)arg;
+ FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)arg;
- /* Increment statistics and dump debug info */
+ /* Increment statistics and dump debug info */
- /* Then reset the hardware */
+ /* Then reset the hardware */
- /* Then poll uIP for new XMIT data */
+ /* Then poll uIP for new XMIT data */
- (void)devif_poll(&vnet->sk_dev, vnet_txpoll);
+ (void)devif_poll(&vnet->sk_dev, vnet_txpoll);
}
/****************************************************************************
@@ -400,28 +423,30 @@ static void vnet_txtimeout(int argc, uint32_t arg, ...)
static void vnet_polltimer(int argc, uint32_t arg, ...)
{
- FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)arg;
+ FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)arg;
- /* Check if there is room in the send another TX packet. We cannot perform
- * the TX poll if he are unable to accept another packet for transmission.
- */
- if (vnet_is_txbuff_full(vnet->vnet)) {
+ /* Check if there is room in the send another TX packet. We cannot perform
+ * the TX poll if he are unable to accept another packet for transmission.
+ */
+
+ if (vnet_is_txbuff_full(vnet->vnet))
+ {
#ifdef CONFIG_DEBUG
- cprintf("VNET: TX buffer is full\n");
+ cprintf("VNET: TX buffer is full\n");
#endif
- return;
- }
+ return;
+ }
- /* If so, update TCP timing states and poll uIP for new XMIT data. Hmmm..
- * might be bug here. Does this mean if there is a transmit in progress,
- * we will missing TCP time state updates?
- */
+ /* If so, update TCP timing states and poll uIP for new XMIT data. Hmmm..
+ * might be bug here. Does this mean if there is a transmit in progress,
+ * we will missing TCP time state updates?
+ */
- (void)devif_timer(&vnet->sk_dev, vnet_txpoll, VNET_POLLHSEC);
+ (void)devif_timer(&vnet->sk_dev, vnet_txpoll, VNET_POLLHSEC);
- /* Setup the watchdog poll timer again */
+ /* Setup the watchdog poll timer again */
- (void)wd_start(vnet->sk_txpoll, VNET_WDDELAY, vnet_polltimer, 1, arg);
+ (void)wd_start(vnet->sk_txpoll, VNET_WDDELAY, vnet_polltimer, 1, arg);
}
/****************************************************************************
@@ -443,20 +468,20 @@ static void vnet_polltimer(int argc, uint32_t arg, ...)
static int vnet_ifup(struct net_driver_s *dev)
{
- FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
+ FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
- ndbg("Bringing up: %d.%d.%d.%d\n",
- dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff,
- (dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24 );
+ ndbg("Bringing up: %d.%d.%d.%d\n",
+ dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff,
+ (dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24 );
- /* Initialize PHYs, the Ethernet interface, and setup up Ethernet interrupts */
+ /* Initialize PHYs, the Ethernet interface, and setup up Ethernet interrupts */
- /* Set and activate a timer process */
+ /* Set and activate a timer process */
- (void)wd_start(vnet->sk_txpoll, VNET_WDDELAY, vnet_polltimer, 1, (uint32_t)vnet);
+ (void)wd_start(vnet->sk_txpoll, VNET_WDDELAY, vnet_polltimer, 1, (uint32_t)vnet);
- vnet->sk_bifup = true;
- return OK;
+ vnet->sk_bifup = true;
+ return OK;
}
/****************************************************************************
@@ -477,28 +502,28 @@ static int vnet_ifup(struct net_driver_s *dev)
static int vnet_ifdown(struct net_driver_s *dev)
{
- FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
- irqstate_t flags;
+ FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
+ irqstate_t flags;
- /* Disable the Ethernet interrupt */
+ /* Disable the Ethernet interrupt */
- flags = irqsave();
+ flags = irqsave();
- /* Cancel the TX poll timer and TX timeout timers */
+ /* Cancel the TX poll timer and TX timeout timers */
- wd_cancel(vnet->sk_txpoll);
- //wd_cancel(vnet->sk_txtimeout);
+ wd_cancel(vnet->sk_txpoll);
+ //wd_cancel(vnet->sk_txtimeout);
- /* Put the EMAC is its reset, non-operational state. This should be
- * a known configuration that will guarantee the vnet_ifup() always
- * successfully brings the interface back up.
- */
+ /* Put the EMAC is its reset, non-operational state. This should be
+ * a known configuration that will guarantee the vnet_ifup() always
+ * successfully brings the interface back up.
+ */
- /* Mark the device "down" */
+ /* Mark the device "down" */
- vnet->sk_bifup = false;
- irqrestore(flags);
- return OK;
+ vnet->sk_bifup = false;
+ irqrestore(flags);
+ return OK;
}
/****************************************************************************
@@ -522,35 +547,37 @@ static int vnet_ifdown(struct net_driver_s *dev)
static int vnet_txavail(struct net_driver_s *dev)
{
- FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
- irqstate_t flags;
+ FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
+ irqstate_t flags;
- /* Disable interrupts because this function may be called from interrupt
- * level processing.
- */
+ /* Disable interrupts because this function may be called from interrupt
+ * level processing.
+ */
- flags = irqsave();
+ flags = irqsave();
- /* Ignore the notification if the interface is not yet up */
+ /* Ignore the notification if the interface is not yet up */
- if (vnet->sk_bifup)
+ if (vnet->sk_bifup)
{
- /* Check if there is room in the hardware to hold another outgoing packet. */
- if (vnet_is_txbuff_full(vnet->vnet)) {
+ /* Check if there is room in the hardware to hold another outgoing packet. */
+
+ if (vnet_is_txbuff_full(vnet->vnet))
+ {
#ifdef CONFIG_DEBUG
- cprintf("VNET: TX buffer is full\n");
+ cprintf("VNET: TX buffer is full\n");
#endif
- goto out;
- }
+ goto out;
+ }
- /* If so, then poll uIP for new XMIT data */
+ /* If so, then poll uIP for new XMIT data */
- (void)devif_poll(&vnet->sk_dev, vnet_txpoll);
+ (void)devif_poll(&vnet->sk_dev, vnet_txpoll);
}
out:
- irqrestore(flags);
- return OK;
+ irqrestore(flags);
+ return OK;
}
/****************************************************************************
@@ -574,11 +601,11 @@ out:
#ifdef CONFIG_NET_IGMP
static int vnet_addmac(struct net_driver_s *dev, FAR const uint8_t *mac)
{
- FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
+ FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
- /* Add the MAC address to the hardware multicast routing table */
+ /* Add the MAC address to the hardware multicast routing table */
- return OK;
+ return OK;
}
#endif
@@ -603,11 +630,11 @@ static int vnet_addmac(struct net_driver_s *dev, FAR const uint8_t *mac)
#ifdef CONFIG_NET_IGMP
static int vnet_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac)
{
- FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
+ FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
- /* Add the MAC address to the hardware multicast routing table */
+ /* Add the MAC address to the hardware multicast routing table */
- return OK;
+ return OK;
}
#endif
@@ -634,39 +661,41 @@ static int vnet_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac)
int vnet_init(struct rgmp_vnet *vnet)
{
- struct vnet_driver_s *priv;
- static int i = 0;
+ struct vnet_driver_s *priv;
+ static int i = 0;
- if (i >= CONFIG_VNET_NINTERFACES)
- return -1;
+ if (i >= CONFIG_VNET_NINTERFACES)
+ {
+ return -1;
+ }
- priv = &g_vnet[i++];
+ priv = &g_vnet[i++];
- /* Initialize the driver structure */
+ /* Initialize the driver structure */
- memset(priv, 0, sizeof(struct vnet_driver_s));
- priv->sk_dev.d_ifup = vnet_ifup; /* I/F down callback */
- priv->sk_dev.d_ifdown = vnet_ifdown; /* I/F up (new IP address) callback */
- priv->sk_dev.d_txavail = vnet_txavail; /* New TX data callback */
+ memset(priv, 0, sizeof(struct vnet_driver_s));
+ priv->sk_dev.d_ifup = vnet_ifup; /* I/F down callback */
+ priv->sk_dev.d_ifdown = vnet_ifdown; /* I/F up (new IP address) callback */
+ priv->sk_dev.d_txavail = vnet_txavail; /* New TX data callback */
#ifdef CONFIG_NET_IGMP
- priv->sk_dev.d_addmac = vnet_addmac; /* Add multicast MAC address */
- priv->sk_dev.d_rmmac = vnet_rmmac; /* Remove multicast MAC address */
+ priv->sk_dev.d_addmac = vnet_addmac; /* Add multicast MAC address */
+ priv->sk_dev.d_rmmac = vnet_rmmac; /* Remove multicast MAC address */
#endif
- priv->sk_dev.d_private = (void*)priv; /* Used to recover private state from dev */
+ priv->sk_dev.d_private = (void*)priv; /* Used to recover private state from dev */
- /* Create a watchdog for timing polling for and timing of transmisstions */
+ /* Create a watchdog for timing polling for and timing of transmisstions */
- priv->sk_txpoll = wd_create(); /* Create periodic poll timer */
- //priv->sk_txtimeout = wd_create(); /* Create TX timeout timer */
+ priv->sk_txpoll = wd_create(); /* Create periodic poll timer */
+ //priv->sk_txtimeout = wd_create(); /* Create TX timeout timer */
- priv->vnet = vnet;
- vnet->priv = priv;
+ priv->vnet = vnet;
+ vnet->priv = priv;
- /* Register the device with the OS */
+ /* Register the device with the OS */
- (void)netdev_register(&priv->sk_dev);
+ (void)netdev_register(&priv->sk_dev), NET_LL_ETHERNET;
- return 0;
+ return 0;
}
#endif /* CONFIG_NET && CONFIG_NET_VNET */
diff --git a/nuttx/include/nuttx/net/net.h b/nuttx/include/nuttx/net/net.h
index 23558b427..b077b7371 100644
--- a/nuttx/include/nuttx/net/net.h
+++ b/nuttx/include/nuttx/net/net.h
@@ -67,6 +67,14 @@
/****************************************************************************
* Public Types
****************************************************************************/
+/* Data link layer type */
+
+enum net_lltype_e
+{
+ NET_LL_ETHERNET = 0, /* Ethernet */
+ NET_LL_SLIP, /* Serial Line Internet Protocol (SLIP) */
+ NET_LL_PPP /* Point-to-Point Protocol (PPP) */
+};
/* This defines a bitmap big enough for one bit for each socket option */
@@ -1003,7 +1011,8 @@ int net_vfcntl(int sockfd, int cmd, va_list ap);
* be found in subsequent network ioctl operations on the device.
*
* Parameters:
- * dev - The device driver structure to register
+ * dev - The device driver structure to be registered.
+ * lltype - Link level protocol used by the driver (Ethernet, SLIP, PPP, ...
*
* Returned Value:
* 0:Success; negated errno on failure
@@ -1013,7 +1022,7 @@ int net_vfcntl(int sockfd, int cmd, va_list ap);
*
****************************************************************************/
-int netdev_register(FAR struct net_driver_s *dev);
+int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype);
/****************************************************************************
* Function: netdev_unregister
diff --git a/nuttx/include/nuttx/net/netdev.h b/nuttx/include/nuttx/net/netdev.h
index e71e446e1..5aeeb59be 100644
--- a/nuttx/include/nuttx/net/netdev.h
+++ b/nuttx/include/nuttx/net/netdev.h
@@ -96,17 +96,26 @@ struct net_driver_s
uint8_t d_flags;
- /* Ethernet device identity */
+#ifdef CONFIG_NET_MULTILINK
+ /* Multi network devices using multiple data links protocols are selected */
+
+ uint8_t d_lltype; /* See enum net_datalink_e */
+#if 0 /* Not yet */
+ uint8_t d_llhdrlen; /* Link layer header size */
+#endif
+#endif
#ifdef CONFIG_NET_ETHERNET
+ /* Ethernet device identity */
+
struct ether_addr d_mac; /* Device MAC address */
#endif
/* Network identity */
- net_ipaddr_t d_ipaddr; /* Host IP address assigned to the network interface */
- net_ipaddr_t d_draddr; /* Default router IP address */
- net_ipaddr_t d_netmask; /* Network subnet mask */
+ net_ipaddr_t d_ipaddr; /* Host IP address assigned to the network interface */
+ net_ipaddr_t d_draddr; /* Default router IP address */
+ net_ipaddr_t d_netmask; /* Network subnet mask */
/* The d_buf array is used to hold incoming and outgoing packets. The device
* driver should place incoming data into this buffer. When sending data,
@@ -171,9 +180,9 @@ struct net_driver_s
uint16_t d_sndlen;
+#ifdef CONFIG_NET_IGMP
/* IGMP group list */
-#ifdef CONFIG_NET_IGMP
sq_queue_t grplist;
#endif
diff --git a/nuttx/net/Kconfig b/nuttx/net/Kconfig
index 85b71c576..bb4d421a5 100644
--- a/nuttx/net/Kconfig
+++ b/nuttx/net/Kconfig
@@ -114,13 +114,18 @@ config NET_MULTICAST
---help---
Outgoing multi-cast address support
-# Select Transport (should be a choice)
+# Select Data Link
+
+config NET_MULTILINK
+ bool
+ default n
config NET_ETHERNET
bool
default y if !NET_SLIP
default n if NET_SLIP
select NETDEV_MULTINIC if NET_SLIP
+ select NET_MULTILINK if NET_SLIP
---help---
If NET_SLIP is not selected, then Ethernet will be used (there is
no need to define anything special in the configuration file to use
@@ -130,6 +135,7 @@ config NET_SLIP
bool "SLIP support"
default n
select NETDEV_MULTINIC if NET_ETHERNET
+ select NET_MULTILINK if NET_ETHERNET
---help---
Enables building of the SLIP driver. SLIP requires
at least one IP protocol selected and the following additional
diff --git a/nuttx/net/arp/arp_send.c b/nuttx/net/arp/arp_send.c
index 2a7694d5d..d03c6005e 100644
--- a/nuttx/net/arp/arp_send.c
+++ b/nuttx/net/arp/arp_send.c
@@ -229,17 +229,15 @@ int arp_send(in_addr_t ipaddr)
goto errout;
}
-#ifdef CONFIG_NET_SLIP
- /* If this device does not require ARP bail out. ARP is only built of
- * CONFIG_NET_ETHERNET is enabled which always requires ARP support. The
- * following can happening only there multiple network interfaces enabled
- * (CONFIG_NET_MULTINIC) and one of the interfaces is not Ethernet. At
- * present, this is possible only if one of the interfaces is SLIP.
- *
- * REVISIT: This will need to be extended if PPP is ever incorporated.
+#ifdef CONFIG_NET_MULTILINK
+ /* ARP support is only built if the Ethernet data link is supported.
+ * However, if we are supporting multiple network devices and using
+ * different link level protocols then we can get here for other
+ * link protocals as well. Continue and send the ARP request only
+ * if this device uses the Ethernet data link protocol.
*/
- if (dev->d_flags & IFF_NOARP)
+ if (dev->d_lltype != NET_LL_ETHERNET)
{
return OK;
}
diff --git a/nuttx/net/netdev/netdev_register.c b/nuttx/net/netdev/netdev_register.c
index dbe155cad..818a3c7d9 100644
--- a/nuttx/net/netdev/netdev_register.c
+++ b/nuttx/net/netdev/netdev_register.c
@@ -1,7 +1,7 @@
/****************************************************************************
* net/netdev/netdev_register.c
*
- * Copyright (C) 2007-2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2012, 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -51,6 +51,7 @@
#include <net/if.h>
#include <net/ethernet.h>
#include <nuttx/net/netdev.h>
+#include <nuttx/net/arp.h>
#include "netdev/netdev.h"
#include "igmp/igmp.h"
@@ -99,7 +100,9 @@ struct net_driver_s *g_netdevices = NULL;
* be found in subsequent network ioctl operations on the device.
*
* Parameters:
- * dev - The device driver structure to register
+ * dev - The device driver structure to be registered.
+ * lltype - Link level protocol used by the driver (Ethernet, SLIP, PPP, ...
+ * ...
*
* Returned Value:
* 0:Success; negated errno on failure
@@ -109,15 +112,62 @@ struct net_driver_s *g_netdevices = NULL;
*
****************************************************************************/
-int netdev_register(FAR struct net_driver_s *dev)
+int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype)
{
+ int devnum;
+
if (dev)
{
- int devnum;
- netdev_semtake();
+#ifdef CONFIG_NET_MULTILINK
+ /* We are supporting multiple network devices and using different link
+ * level protocols. Set the protocol usd by the device and the size
+ * of the link header used by this protocol.
+ */
+
+ switch (lltype)
+ {
+#ifdef CONFIG_NET_ETHERNET
+ case NET_LL_ETHERNET: /* Ethernet */
+#if 0 /* REVISIT: Not yet supported */
+ dev->d_llhdrlen = ETH_HDRLEN;
+#endif
+ break;
+#endif
+
+#ifdef CONFIG_NET_SLIP
+ case NET_LL_SLIP: /* Serial Line Internet Protocol (SLIP) */
+#if 0 /* REVISIT: Not yet supported */
+ dev->d_llhdrlen = 0;
+#endif
+ break;
+#endif
+
+#if 0 /* REVISIT: Not yet supported */
+ case NET_LL_PPP: /* Point-to-Point Protocol (PPP) */
+ dev->d_llhdrlen = 0;
+ break;
+#endif
+ break;
+
+ /* REVISIT: Here we must also set the size of the link header
+ * header the precedes network layer headers.
+ */
+
+ break;
+
+ default:
+ nlldbg("ERROR: Unrecognized link type: %d\n", lltype);
+ return -EINVAL;
+ }
+
+ /* Remember the verified link type */
+
+ dev->d_lltype = (uint8_t)lltype
+#endif
/* Assign a device name to the interface */
+ netdev_semtake();
devnum = g_next_devnum++;
snprintf(dev->d_ifname, IFNAMSIZ, NETDEV_FORMAT, devnum );
@@ -144,6 +194,7 @@ int netdev_register(FAR struct net_driver_s *dev)
#endif
return OK;
}
+
return -EINVAL;
}