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
This commit is contained in:
parent
8d00912207
commit
388ef8db1a
@ -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>
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
#
|
||||
|
||||
#
|
||||
@ -542,6 +558,16 @@ CONFIG_SIG_SIGWORK=17
|
||||
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
|
||||
#
|
||||
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
*/
|
||||
/* 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 */
|
||||
/* Increment statistics */
|
||||
|
||||
/* 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);
|
||||
/* 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);
|
||||
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;
|
||||
/* 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 */
|
||||
if (len > CONFIG_NET_BUFSIZE || len < 14) {
|
||||
/* Check if the packet is a valid size for the uIP buffer configuration */
|
||||
|
||||
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
|
||||
memcpy(vnet->sk_dev.d_buf, data, len);
|
||||
vnet->sk_dev.d_len = len;
|
||||
/* Copy the data data from the hardware to vnet->sk_dev.d_buf. Set
|
||||
* amount of data in vnet->sk_dev.d_len
|
||||
*/
|
||||
|
||||
/* We only accept IP packets of the configured type and ARP packets */
|
||||
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 */
|
||||
|
||||
#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);
|
||||
{
|
||||
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 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);
|
||||
}
|
||||
}
|
||||
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 */
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user