Skip to content

Commit

Permalink
Remove CONFIG_NETDEV_MULTINIC. This increases code size by a little, …
Browse files Browse the repository at this point in the history
…but greatly reduces the complexity of the network code.
  • Loading branch information
gregory-nutt committed Aug 8, 2017
1 parent d49d6a6 commit bd7c84b
Show file tree
Hide file tree
Showing 55 changed files with 84 additions and 776 deletions.
4 changes: 0 additions & 4 deletions arch/arm/src/sama5/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -649,15 +649,13 @@ config SAMA5_GMAC
default n
depends on SAMA5_HAVE_GMAC
select NETDEVICES
select NETDEV_MULTINIC if SAMA5_EMAC
select ARCH_HAVE_PHY

config SAMA5_EMACA
bool "10/100MBps Ethernet MAC (EMAC)"
default n
depends on SAMA5_HAVE_EMACA
select NETDEVICES
select NETDEV_MULTINIC if SAMA5_GMAC
select ARCH_HAVE_PHY

config SAMA5_EMACB
Expand All @@ -670,7 +668,6 @@ config SAMA5_EMAC0
depends on SAMA5_HAVE_EMACB
select SAMA5_EMACB
select NETDEVICES
select NETDEV_MULTINIC if SAMA5_EMAC1
select ARCH_HAVE_PHY

config SAMA5_EMAC1
Expand All @@ -679,7 +676,6 @@ config SAMA5_EMAC1
depends on SAMA5_HAVE_EMACB && SAMA5_HAVE_EMAC1
select SAMA5_EMACB
select NETDEVICES
select NETDEV_MULTINIC if SAMA5_EMAC0
select ARCH_HAVE_PHY

config SAMA5_LCDC
Expand Down
1 change: 0 additions & 1 deletion configs/sim/ipforward/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TUN=y
CONFIG_NET=y
CONFIG_NETDEV_MULTINIC=y
CONFIG_NETDEVICES=y
CONFIG_NFILE_DESCRIPTORS=32
CONFIG_NSH_ARCHINIT=y
Expand Down
1 change: 0 additions & 1 deletion configs/sim/pktradio/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_UDP=y
CONFIG_NET=y
CONFIG_NETDB_DNSCLIENT=y
CONFIG_NETDEV_MULTINIC=y
CONFIG_NETDEV_PHY_IOCTL=y
CONFIG_NETDEV_STATISTICS=y
CONFIG_NETDEV_TELNET=y
Expand Down
1 change: 0 additions & 1 deletion configs/sim/sixlowpan/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_UDP=y
CONFIG_NET=y
CONFIG_NETDB_DNSCLIENT=y
CONFIG_NETDEV_MULTINIC=y
CONFIG_NETDEV_PHY_IOCTL=y
CONFIG_NETDEV_STATISTICS=y
CONFIG_NETDEV_TELNET=y
Expand Down
11 changes: 0 additions & 11 deletions drivers/net/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,6 @@ config TELNET_DUMPBUFFER

endif # NETDEV_TELNET

config NETDEV_MULTINIC
bool "Multiple network interface support"
default n if !NETDEV_LOOPBACK
default y if NETDEV_LOOPBACK
---help---
Select this option if you board and/or MCU are capable of supporting
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 ARCH_HAVE_NETDEV_STATISTICS
bool
default n
Expand Down Expand Up @@ -525,7 +515,6 @@ endchoice
choice
prompt "Board PHY Selection (ETH1)"
default ETH1_PHY_NONE
depends on NETDEV_MULTINIC
---help---
Identify the PHY on your board. This setting is not used by all Ethernet
drivers nor do all Ethernet drivers support all PHYs.
Expand Down
15 changes: 2 additions & 13 deletions drivers/net/phy_notify.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ struct phy_notify_s
{
bool assigned;
uint8_t signo;
#ifdef CONFIG_NETDEV_MULTINIC
char intf[CONFIG_PHY_NOTIFICATION_MAXINTFLEN+1];
#endif
pid_t pid;
FAR void *arg;
phy_enable_t enable;
Expand Down Expand Up @@ -174,9 +172,7 @@ static FAR struct phy_notify_s *phy_find_unassigned(void)

client->assigned = true;
client->signo = 0;
#ifdef CONFIG_NETDEV_MULTINIC
client->intf[0] = '\0';
#endif
client->pid = -1;
client->arg = NULL;
client->enable = NULL;
Expand Down Expand Up @@ -210,11 +206,8 @@ static FAR struct phy_notify_s *phy_find_assigned(FAR const char *intf,
for (i = 0; i < CONFIG_PHY_NOTIFICATION_NCLIENTS; i++)
{
client = &g_notify_clients[i];
if (client->assigned && client->pid == pid
#ifdef CONFIG_NETDEV_MULTINIC
&& strncmp(client->intf, intf, CONFIG_PHY_NOTIFICATION_MAXINTFLEN) == 0
#endif
)
if (client->assigned && client->pid == pid &&
strncmp(client->intf, intf, CONFIG_PHY_NOTIFICATION_MAXINTFLEN) == 0)
{
/* Return the matching client entry to the caller */

Expand Down Expand Up @@ -344,10 +337,8 @@ int phy_notify_subscribe(FAR const char *intf, pid_t pid, int signo,
client->signo = signo;
client->pid = pid;
client->arg = arg;
#ifdef CONFIG_NETDEV_MULTINIC
snprintf(client->intf, CONFIG_PHY_NOTIFICATION_MAXINTFLEN+1, intf);
client->intf[CONFIG_PHY_NOTIFICATION_MAXINTFLEN] = '\0';
#endif

/* Attach/re-attach the PHY interrupt */

Expand Down Expand Up @@ -407,9 +398,7 @@ int phy_notify_unsubscribe(FAR const char *intf, pid_t pid)

client->assigned = false;
client->signo = 0;
#ifdef CONFIG_NETDEV_MULTINIC
client->intf[0] = '\0';
#endif
client->pid = -1;
client->arg = NULL;

Expand Down
4 changes: 0 additions & 4 deletions include/nuttx/net/ip.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,7 @@ union ip_binding_u

struct
{
#ifdef CONFIG_NETDEV_MULTINIC
in_addr_t laddr; /* The bound local IPv4 address */
#endif
in_addr_t raddr; /* The IPv4 address of the remote host */
} ipv4;
#endif /* CONFIG_NET_IPv4 */
Expand All @@ -141,9 +139,7 @@ union ip_binding_u

struct
{
#ifdef CONFIG_NETDEV_MULTINIC
net_ipv6addr_t laddr; /* The bound local IPv6 address */
#endif
net_ipv6addr_t raddr; /* The IPv6 address of the remote host */
} ipv6;
#endif /* CONFIG_NET_IPv6 */
Expand Down
5 changes: 2 additions & 3 deletions include/nuttx/net/sixlowpan.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,8 @@ struct sixlowpan_properties_s
* This is accomplished by "inheriting" the standard 'struct net_driver_s'
* and appending the frame buffer as well as other metadata needed to
* manage the fragmentation. 'struct sixlowpan_driver_s' is cast
* compatible with 'struct net_driver_s' when CONFIG_NET_MULTINIC is not
* defined or when dev->d_lltype == NET_LL_IEEE802154 or dev->d_lltype ==
* NET_LL_PKTRADIO.
* compatible with 'struct net_driver_s' when dev->d_lltype ==
* NET_LL_IEEE802154 or dev->d_lltype == NET_LL_PKTRADIO.
*
* The radio network driver has reponsibility for initializing this
* structure. In general, all fields must be set to NULL. In addition:
Expand Down
5 changes: 0 additions & 5 deletions net/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ config NET_USER_DEVFMT
config NET_ETHERNET
bool "Ethernet support"
default y
select NETDEV_MULTINIC if NET_6LOWPAN || NET_LOOPBACK || NET_SLIP || NET_TUN
select NET_MULTILINK if NET_6LOWPAN || NET_LOOPBACK || NET_SLIP || NET_TUN
---help---
If NET_SLIP is not selected, then Ethernet will be used (there is
Expand All @@ -134,7 +133,6 @@ config NET_ETHERNET
config NET_6LOWPAN
bool "6LoWPAN support"
default n
select NETDEV_MULTINIC if NET_ETHERNET || NET_LOOPBACK || NET_SLIP || NET_TUN
select NET_MULTILINK if NET_ETHERNET || NET_LOOPBACK || NET_SLIP || NET_TUN
select NET_MULTILINK if WIRELESS_IEEE802 && WIRELESS_PKTRADIO
select NETDEV_IOCTL
Expand All @@ -147,15 +145,13 @@ config NET_6LOWPAN
config NET_LOOPBACK
bool "Local loopback"
default n
select NETDEV_MULTINIC if NET_ETHERNET || NET_6LOWPAN || NET_SLIP || NET_TUN
select NET_MULTILINK if NET_ETHERNET || NET_6LOWPAN || NET_SLIP || NET_TUN
---help---
Add support for the local network loopback device, lo.

config NET_SLIP
bool "SLIP support"
default n
select NETDEV_MULTINIC if NET_ETHERNET || NET_6LOWPAN || NET_LOOPBACK || NET_TUN
select NET_MULTILINK if NET_ETHERNET || NET_6LOWPAN || NET_LOOPBACK || NET_TUN
---help---
Enables building of the SLIP driver. SLIP requires
Expand Down Expand Up @@ -202,7 +198,6 @@ endif # NET_SLIP
config NET_TUN
bool "TUN Virtual Network Device support"
default n
select NETDEV_MULTINIC if NET_ETHERNET || NET_6LOWPAN || NET_LOOPBACK || NET_SLIP
select NET_MULTILINK if NET_ETHERNET || NET_6LOWPAN || NET_LOOPBACK || NET_SLIP
select ARCH_HAVE_NETDEV_STATISTICS

Expand Down
2 changes: 0 additions & 2 deletions net/arp/arp.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,7 @@ struct arp_send_s
sem_t snd_sem; /* Used to wake up the waiting thread */
uint8_t snd_retries; /* Retry count */
volatile bool snd_sent; /* True: if request sent */
#ifdef CONFIG_NETDEV_MULTINIC
uint8_t snd_ifname[IFNAMSIZ]; /* Interface name */
#endif
int16_t snd_result; /* The result of the send operation */
in_addr_t snd_ipaddr; /* The IP address to be queried */
};
Expand Down
12 changes: 2 additions & 10 deletions net/arp/arp_send.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,7 @@ int arp_send(in_addr_t ipaddr)

/* Get the device that can route this request */

#ifdef CONFIG_NETDEV_MULTINIC
dev = netdev_findby_ipv4addr(INADDR_ANY, ipaddr);
#else
dev = netdev_findby_ipv4addr(ipaddr);
#endif
if (!dev)
{
nerr("ERROR: Unreachable: %08lx\n", (unsigned long)ipaddr);
Expand All @@ -237,10 +233,8 @@ int arp_send(in_addr_t ipaddr)

#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 protocols as well. Continue and send the ARP request only
* if this device uses the Ethernet data link protocol.
* Continue and send the ARP request only if this device uses the
* Ethernet data link protocol.
*/

if (dev->d_lltype != NET_LL_ETHERNET)
Expand Down Expand Up @@ -304,11 +298,9 @@ int arp_send(in_addr_t ipaddr)
state.snd_retries = 0; /* No retries yet */
state.snd_ipaddr = ipaddr; /* IP address to query */

#ifdef CONFIG_NETDEV_MULTINIC
/* Remember the routing device name */

strncpy((FAR char *)state.snd_ifname, (FAR const char *)dev->d_ifname, IFNAMSIZ);
#endif

/* Now loop, testing if the address mapping is in the ARP table and re-sending the ARP request if it is not.
*/
Expand Down
2 changes: 0 additions & 2 deletions net/devif/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ endif
# IP forwarding

ifeq ($(CONFIG_NET_IPFORWARD),y)
ifeq ($(CONFIG_NETDEV_MULTINIC),y)
NET_CSRCS += devif_forward.c
endif
endif

# I/O buffer chain support required?

Expand Down
4 changes: 2 additions & 2 deletions net/devif/devif_forward.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#include "ipforward/ipforward.h"
#include "devif/devif.h"

#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC)
#ifdef CONFIG_NET_IPFORWARD

/****************************************************************************
* Public Functions
Expand Down Expand Up @@ -92,4 +92,4 @@ void devif_forward(FAR struct forward_s *fwd)
fwd->f_dev->d_len = offset;
}

#endif /* CONFIG_NET_IPFORWARD && CONFIG_NETDEV_MULTINIC */
#endif /* CONFIG_NET_IPFORWARD */
4 changes: 2 additions & 2 deletions net/devif/devif_poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ static inline int devif_poll_icmpv6(FAR struct net_driver_s *dev,
*
****************************************************************************/

#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC)
#ifdef CONFIG_NET_IPFORWARD
static inline int devif_poll_forward(FAR struct net_driver_s *dev,
devif_poll_callback_t callback)
{
Expand Down Expand Up @@ -575,7 +575,7 @@ int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback)

if (!bstop)
#endif
#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC)
#ifdef CONFIG_NET_IPFORWARD
{
/* Traverse all of the tasks waiting to forward a packet to this device. */

Expand Down
16 changes: 0 additions & 16 deletions net/devif/ipv6_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@
*
****************************************************************************/

#ifdef CONFIG_NETDEV_MULTINIC
static int check_dev_destipaddr(FAR struct net_driver_s *dev, FAR void *arg)
{
FAR struct ipv6_hdr_s *ipv6 = (FAR struct ipv6_hdr_s *)arg;
Expand All @@ -146,7 +145,6 @@ static int check_dev_destipaddr(FAR struct net_driver_s *dev, FAR void *arg)

return 0;
}
#endif

/****************************************************************************
* Name: check_destipaddr
Expand All @@ -171,9 +169,7 @@ static int check_dev_destipaddr(FAR struct net_driver_s *dev, FAR void *arg)
static bool check_destipaddr(FAR struct net_driver_s *dev,
FAR struct ipv6_hdr_s *ipv6)
{
#ifdef CONFIG_NETDEV_MULTINIC
int ret;
#endif

/* For IPv6, packet reception is a little trickier as we need to make sure
* that we listen to certain multicast addresses (all hosts multicast
Expand All @@ -192,7 +188,6 @@ static bool check_destipaddr(FAR struct net_driver_s *dev,
return true;
}

#ifdef CONFIG_NETDEV_MULTINIC
/* We will also allow for a perverse case where we receive a packet
* addressed to us, but on a different device. Can that really happen?
*/
Expand All @@ -207,17 +202,6 @@ static bool check_destipaddr(FAR struct net_driver_s *dev,

return true;
}
#else
/* There is only one network device. If this packet is addressed to us,
* then the IPv6 destination address must be the address of assigned to
* this device.
*/

if (net_ipv6addr_cmp(ipv6->destipaddr, dev->d_ipv6addr))
{
return true;
}
#endif

return false;
}
Expand Down
4 changes: 0 additions & 4 deletions net/icmp/icmp_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,7 @@ int icmp_ping(in_addr_t addr, uint16_t id, uint16_t seqno, uint16_t datalen,

/* Get the device that will be used to route this ICMP ECHO request */

#ifdef CONFIG_NETDEV_MULTINIC
dev = netdev_findby_ipv4addr(INADDR_ANY, addr);
#else
dev = netdev_findby_ipv4addr(addr);
#endif
if (dev == 0)
{
nerr("ERROR: Not reachable\n");
Expand Down
4 changes: 0 additions & 4 deletions net/icmpv6/icmpv6_autoconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ struct icmpv6_router_s
sem_t snd_sem; /* Used to wake up the waiting thread */
volatile bool snd_sent; /* True: if request sent */
bool snd_advertise; /* True: Send Neighbor Advertisement */
#ifdef CONFIG_NETDEV_MULTINIC
uint8_t snd_ifname[IFNAMSIZ]; /* Interface name */
#endif
int16_t snd_result; /* Result of the send */
};

Expand Down Expand Up @@ -217,12 +215,10 @@ static int icmpv6_send_message(FAR struct net_driver_s *dev, bool advertise)
(void)sem_init(&state.snd_sem, 0, 0); /* Doesn't really fail */
sem_setprotocol(&state.snd_sem, SEM_PRIO_NONE);

#ifdef CONFIG_NETDEV_MULTINIC
/* Remember the routing device name */

strncpy((FAR char *)state.snd_ifname, (FAR const char *)dev->d_ifname,
IFNAMSIZ);
#endif

/* Allocate resources to receive a callback. This and the following
* initialization is performed with the network lock because we don't
Expand Down
Loading

0 comments on commit bd7c84b

Please sign in to comment.