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:
Gregory Nutt
2014-11-15 08:22:51 -06:00
parent 8d00912207
commit 388ef8db1a
28 changed files with 359 additions and 237 deletions
+2 -2
View File
@@ -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>
+1 -1
View File
@@ -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 */
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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:
+41 -10
View File
@@ -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
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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);
}
/****************************************************************************
+1 -1
View File
@@ -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);
}
/****************************************************************************
+1 -1
View File
@@ -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;
}
+1 -12
View File
@@ -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
+201 -172
View File
File diff suppressed because it is too large Load Diff
+11 -2
View File
@@ -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
+14 -5
View File
@@ -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
+7 -1
View File
@@ -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
+7 -9
View File
@@ -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;
}
+56 -5
View File
@@ -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;
}