Add definitions to support a local loopback link layer

This commit is contained in:
Gregory Nutt 2015-08-24 08:25:08 -06:00
parent 47bab42498
commit ea2fafb024
5 changed files with 37 additions and 8 deletions

@ -1 +1 @@
Subproject commit ce750c0899c2138b37b52a48d020a3eceb92fd04 Subproject commit cae6e67e0534485cd42119346a2e0121d6652965

View File

@ -5,12 +5,21 @@
comment "General Ethernet MAC Driver Options" comment "General Ethernet MAC Driver Options"
config NETDEV_MULTINIC config NETDEV_LOOPBACK
bool "Multiple network interface support" bool "Local loopback support"
default n default n
---help---
Add support for the local network loopback device, lo.
config NETDEV_MULTINIC
bool "Multiple network interface support"
default n if !NETDEV_LOOPBACK
default y if NETDEV_LOOPBACK
---help--- ---help---
Select this option if you board and/or MCU are capable of supporting Select this option if you board and/or MCU are capable of supporting
multiple Ethernet MAC drivers. multiple link layer drivers. NOTE that the local loopback device
is considered to be a a link layer driver so if local loopback
support is used you probably need to select this option.
config NETDEV_LATEINIT config NETDEV_LATEINIT
bool "Late driver initialization" bool "Late driver initialization"

View File

@ -76,6 +76,7 @@
enum net_lltype_e enum net_lltype_e
{ {
NET_LL_ETHERNET = 0, /* Ethernet */ NET_LL_ETHERNET = 0, /* Ethernet */
NET_LL_LOOPBACK, /* Local loopback */
NET_LL_SLIP, /* Serial Line Internet Protocol (SLIP) */ NET_LL_SLIP, /* Serial Line Internet Protocol (SLIP) */
NET_LL_PPP, /* Point-to-Point Protocol (PPP) */ NET_LL_PPP, /* Point-to-Point Protocol (PPP) */
NET_LL_TUN, /* TUN Virtual Network Device */ NET_LL_TUN, /* TUN Virtual Network Device */

View File

@ -157,7 +157,7 @@
# define MAX_NET_DEV_MTU CONFIG_NET_ETH_MTU # define MAX_NET_DEV_MTU CONFIG_NET_ETH_MTU
#else #else
/* Perhaps only Unix domain sockets */ /* Perhaps only Unix domain sockets of the loopback device */
# define NET_LL_HDRLEN(d) 0 # define NET_LL_HDRLEN(d) 0
# define NET_DEV_MTU(d) 0 # define NET_DEV_MTU(d) 0
@ -166,6 +166,10 @@
#endif /* MULTILINK or SLIP or ETHERNET */ #endif /* MULTILINK or SLIP or ETHERNET */
/* For the loopback device, we will use the largest representable MTU */
#define NET_LO_MTU UINT16_MAX
/* Layer 3/4 Configuration Options ******************************************/ /* Layer 3/4 Configuration Options ******************************************/
/* IP configuration options */ /* IP configuration options */
@ -346,6 +350,7 @@
*/ */
#define TCP_MSS(d,h) (NET_DEV_MTU(d) - NET_LL_HDRLEN(d) - TCP_HDRLEN - (h)) #define TCP_MSS(d,h) (NET_DEV_MTU(d) - NET_LL_HDRLEN(d) - TCP_HDRLEN - (h))
#define LO_TCP_MSS(h) (NET_LO_MTU - (h))
/* If Ethernet is supported, then it will have the smaller MSS */ /* If Ethernet is supported, then it will have the smaller MSS */
@ -402,15 +407,17 @@
* See the note above regarding the TCP MSS and CONFIG_NET_MULTILINK. * See the note above regarding the TCP MSS and CONFIG_NET_MULTILINK.
*/ */
#define NET_LO_TCP_RECVWNDO LO_TCP_MSS(0)
#ifdef CONFIG_NET_SLIP #ifdef CONFIG_NET_SLIP
# ifndef CONFIG_NET_SLIP_TCP_RECVWNDO # ifndef CONFIG_NET_SLIP_TCP_RECVWNDO
# define CONFIG_NET_SLIP_TCP_RECVWNDO SLIP_TCP_MSS # define CONFIG_NET_SLIP_TCP_RECVWNDO SLIP_TCP_MSS(0)
# endif # endif
#endif #endif
#ifdef CONFIG_NET_ETHERNET #ifdef CONFIG_NET_ETHERNET
# ifndef CONFIG_NET_ETH_TCP_RECVWNDO # ifndef CONFIG_NET_ETH_TCP_RECVWNDO
# define CONFIG_NET_ETH_TCP_RECVWNDO ETH_TCP_MSS # define CONFIG_NET_ETH_TCP_RECVWNDO ETH_TCP_MSS(0)
# endif # endif
#endif #endif

View File

@ -61,8 +61,9 @@
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
#define NETDEV_SLIP_FORMAT "sl%d"
#define NETDEV_ETH_FORMAT "eth%d" #define NETDEV_ETH_FORMAT "eth%d"
#define NETDEV_LO_FORMAT "lo"
#define NETDEV_SLIP_FORMAT "sl%d"
#define NETDEV_TUN_FORMAT "tun%d" #define NETDEV_TUN_FORMAT "tun%d"
#if defined(CONFIG_NET_SLIP) #if defined(CONFIG_NET_SLIP)
@ -190,6 +191,17 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype)
switch (lltype) switch (lltype)
{ {
#ifdef CONFIG_NETDEV_LOOPBACK
case NET_LL_LOOPBACK: /* Local loopback */
dev->d_llhdrlen = 0;
dev->d_mtu = NET_LO_MTU;
#ifdef CONFIG_NET_TCP
dev->d_recvwndo = NET_LO_TCP_RECVWNDO;
#endif
devfmt = NETDEV_LO_FORMAT;
break;
#endif
#ifdef CONFIG_NET_ETHERNET #ifdef CONFIG_NET_ETHERNET
case NET_LL_ETHERNET: /* Ethernet */ case NET_LL_ETHERNET: /* Ethernet */
dev->d_llhdrlen = ETH_HDRLEN; dev->d_llhdrlen = ETH_HDRLEN;