From 5efd942396a47092a33176b0d1ae3d6f21e44eef Mon Sep 17 00:00:00 2001 From: Masayuki Ishikawa Date: Tue, 4 Jul 2017 10:56:54 +0900 Subject: [PATCH 01/31] FS: Remove DEBUGASSERT() in block_proxy() because the flags are cleared later. --- fs/driver/fs_blockproxy.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/driver/fs_blockproxy.c b/fs/driver/fs_blockproxy.c index b03aa4f95e..d08f497f73 100644 --- a/fs/driver/fs_blockproxy.c +++ b/fs/driver/fs_blockproxy.c @@ -167,7 +167,6 @@ int block_proxy(FAR const char *blkdev, int oflags) int fd; DEBUGASSERT(blkdev); - DEBUGASSERT((oflags & (O_CREAT | O_EXCL | O_APPEND | O_TRUNC)) == 0); /* Create a unique temporary file name for the character device */ From 10f5f8f192d23674f7f08d2527cd136164157ccc Mon Sep 17 00:00:00 2001 From: Jeff Date: Wed, 5 Jul 2017 11:38:37 -0600 Subject: [PATCH 02/31] configs/Board.mk: Remove comment form end of line. In windows native build, it appears to be trying to make that an extra parameter to the AR command --- configs/Board.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/Board.mk b/configs/Board.mk index 680b37ebcb..2fc49586d7 100644 --- a/configs/Board.mk +++ b/configs/Board.mk @@ -113,7 +113,7 @@ $(CXXOBJS) $(LINKOBJS): %$(OBJEXT): %.cxx $(call COMPILEXX, $<, $@) libboard$(LIBEXT): $(OBJS) $(CXXOBJS) - $(Q) $(AR) $@ # Create an empty archive + $(Q) $(AR) $@ ifneq ($(OBJS),) $(call ARCHIVE, $@, $(OBJS) $(CXXOBJS)) endif From edf16c580540946c1de31f8c49297cd0f53b72cc Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 5 Jul 2017 12:40:26 -0600 Subject: [PATCH 03/31] IP forwarding: In check it the Ethernet MAC address is in the ARP/Neighbor table, add an additional check to skip in the case of CONFIG_NET_MULTILINK and the devices is not an Ethernet device. --- net/icmpv6/icmpv6_forward.c | 15 ++++++++++++++- net/tcp/tcp_forward.c | 15 ++++++++++++++- net/tcp/tcp_send_buffered.c | 12 +++++++++++- net/tcp/tcp_send_unbuffered.c | 12 +++++++++++- net/udp/udp_forward.c | 15 ++++++++++++++- 5 files changed, 64 insertions(+), 5 deletions(-) diff --git a/net/icmpv6/icmpv6_forward.c b/net/icmpv6/icmpv6_forward.c index ea5ba544c1..74e882e09b 100644 --- a/net/icmpv6/icmpv6_forward.c +++ b/net/icmpv6/icmpv6_forward.c @@ -44,6 +44,7 @@ #include #include +#include #include #include #include @@ -51,6 +52,8 @@ #include "devif/ip_forward.h" #include "devif/devif.h" #include "netdev/netdev.h" +#include "arp/arp.h" +#include "neighbor/neighbor.h" #include "icmpv6/icmpv6.h" #if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_ICMPv6) && \ @@ -82,7 +85,8 @@ * fwd - The forwarding state structure * * Returned Value: - * None + * true - The Ethernet MAC address is in the ARP or Neighbor table (OR + * the network device is not Ethernet). * * Assumptions: * The network is locked. @@ -92,6 +96,15 @@ #ifdef CONFIG_NET_ETHERNET static inline bool icmpv6_forward_addrchck(FAR struct forward_s *fwd) { + /* REVISIT: Could the MAC address not also be in a routing table? */ + +#ifdef CONFIG_NET_MULTILINK + if (fwd->f_dev->d_lltype != NET_LL_ETHERNET) + { + return true; + } +#endif + #ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv6 if (conn->domain == PF_INET) diff --git a/net/tcp/tcp_forward.c b/net/tcp/tcp_forward.c index 22c021aa36..b2e9b1de07 100644 --- a/net/tcp/tcp_forward.c +++ b/net/tcp/tcp_forward.c @@ -45,6 +45,7 @@ #include #include +#include #include #include #include @@ -52,6 +53,8 @@ #include "devif/ip_forward.h" #include "devif/devif.h" #include "netdev/netdev.h" +#include "arp/arp.h" +#include "neighbor/neighbor.h" #include "tcp/tcp.h" #if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_TCP) && \ @@ -124,7 +127,8 @@ static inline void forward_ipselect(FAR struct forward_s *fwd) * fwd - The forwarding state structure * * Returned Value: - * None + * true - The Ethernet MAC address is in the ARP or Neighbor table (OR + * the network device is not Ethernet). * * Assumptions: * The network is locked. @@ -136,6 +140,15 @@ static inline bool tcp_forward_addrchck(FAR struct forward_s *fwd) { FAR struct tcp_conn_s *conn = &fwd->f_conn.tcp; + /* REVISIT: Could the MAC address not also be in a routing table? */ + +#ifdef CONFIG_NET_MULTILINK + if (fwd->f_dev->d_lltype != NET_LL_ETHERNET) + { + return true; + } +#endif + #ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv6 if (conn->domain == PF_INET) diff --git a/net/tcp/tcp_send_buffered.c b/net/tcp/tcp_send_buffered.c index 7b6d7e639e..7ecf990326 100644 --- a/net/tcp/tcp_send_buffered.c +++ b/net/tcp/tcp_send_buffered.c @@ -270,7 +270,8 @@ static inline void send_ipselect(FAR struct net_driver_s *dev, * conn - The TCP connection structure * * Returned Value: - * None + * true - The Ethernet MAC address is in the ARP or Neighbor table (OR + * the network device is not Ethernet). * * Assumptions: * Running at the interrupt level @@ -280,6 +281,15 @@ static inline void send_ipselect(FAR struct net_driver_s *dev, #ifdef CONFIG_NET_ETHERNET static inline bool psock_send_addrchck(FAR struct tcp_conn_s *conn) { + /* REVISIT: Could the MAC address not also be in a routing table? */ + +#ifdef CONFIG_NET_MULTILINK + if (conn->dev->d_lltype != NET_LL_ETHERNET) + { + return true; + } +#endif + #ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv6 if (conn->domain == PF_INET) diff --git a/net/tcp/tcp_send_unbuffered.c b/net/tcp/tcp_send_unbuffered.c index 2de4a5a975..e4d4a50d4f 100644 --- a/net/tcp/tcp_send_unbuffered.c +++ b/net/tcp/tcp_send_unbuffered.c @@ -221,7 +221,8 @@ static inline void tcpsend_ipselect(FAR struct net_driver_s *dev, * conn - The TCP connection structure * * Returned Value: - * None + * true - The Ethernet MAC address is in the ARP or Neighbor table (OR + * the network device is not Ethernet). * * Assumptions: * The network is locked. @@ -231,6 +232,15 @@ static inline void tcpsend_ipselect(FAR struct net_driver_s *dev, #ifdef CONFIG_NET_ETHERNET static inline bool psock_send_addrchck(FAR struct tcp_conn_s *conn) { + /* REVISIT: Could the MAC address not also be in a routing table? */ + +#ifdef CONFIG_NET_MULTILINK + if (conn->dev->d_lltype != NET_LL_ETHERNET) + { + return true; + } +#endif + #ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv6 if (conn->domain == PF_INET) diff --git a/net/udp/udp_forward.c b/net/udp/udp_forward.c index f264ec62be..fdba5b5c4a 100644 --- a/net/udp/udp_forward.c +++ b/net/udp/udp_forward.c @@ -44,6 +44,7 @@ #include #include +#include #include #include #include @@ -51,6 +52,8 @@ #include "devif/ip_forward.h" #include "devif/devif.h" #include "netdev/netdev.h" +#include "arp/arp.h" +#include "neighbor/neighbor.h" #include "udp/udp.h" #if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_UDP) && \ @@ -118,7 +121,8 @@ static inline void forward_ipselect(FAR struct forward_s *fwd) * fwd - The forwarding state structure * * Returned Value: - * None + * true - The Ethernet MAC address is in the ARP or Neighbor table (OR + * the network device is not Ethernet). * * Assumptions: * The network is locked. @@ -128,6 +132,15 @@ static inline void forward_ipselect(FAR struct forward_s *fwd) #ifdef CONFIG_NET_ETHERNET static inline bool udp_forward_addrchk(FAR struct forward_s *fwd) { + /* REVISIT: Could the MAC address not also be in a routing table? */ + +#ifdef CONFIG_NET_MULTILINK + if (fwd->f_dev->d_lltype != NET_LL_ETHERNET) + { + return true; + } +#endif + #ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv6 if (conn->domain == PF_INET) From dad1b57e0b156b1bd159aa3809680391a79bb070 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 5 Jul 2017 15:12:09 -0600 Subject: [PATCH 04/31] IP Forwarding: Add IPv4 packet forwarding logic. Initial commit is an untested clone of the IPv6 forwarding logic with a few minor logic changes for IPv4. --- net/devif/Make.defs | 3 + net/devif/devif.h | 33 +++ net/devif/ip_forward.h | 1 + net/devif/ipv4_forward.c | 553 ++++++++++++++++++++++++++++++++++++ net/devif/ipv4_input.c | 94 ++++-- net/devif/ipv6_forward.c | 18 +- net/icmpv6/icmpv6_forward.c | 2 +- net/tcp/tcp_forward.c | 8 +- net/udp/udp_forward.c | 4 +- 9 files changed, 668 insertions(+), 48 deletions(-) create mode 100644 net/devif/ipv4_forward.c diff --git a/net/devif/Make.defs b/net/devif/Make.defs index 4dcce7379b..6520b8430c 100644 --- a/net/devif/Make.defs +++ b/net/devif/Make.defs @@ -42,6 +42,9 @@ NET_CSRCS += devif_callback.c ifeq ($(CONFIG_NET_IPv4),y) NET_CSRCS += ipv4_input.c +ifeq ($(CONFIG_NET_IPFORWARD),y) +NET_CSRCS += ipv4_forward.c +endif endif ifeq ($(CONFIG_NET_IPv6),y) diff --git a/net/devif/devif.h b/net/devif/devif.h index 78fcce32e5..efacd00714 100644 --- a/net/devif/devif.h +++ b/net/devif/devif.h @@ -425,6 +425,39 @@ uint16_t devif_conn_event(FAR struct net_driver_s *dev, FAR void *pvconn, uint16_t devif_dev_event(FAR struct net_driver_s *dev, void *pvconn, uint16_t flags); +/**************************************************************************** + * Name: ipv4_forward + * + * Description: + * This function is called from ipv4_input when a packet is received that + * is not destined for us. In this case, the packet may need to be + * forwarded to another device (or sent back out the same device) + * depending configuration, routing table information, and the IPv4 + * networks served by various network devices. + * + * Input Parameters: + * dev - The device on which the packet was received and which contains + * the IPv4 packet. + * ipv4 - A convenience pointer to the IPv4 header in within the IPv4 + * packet + * + * On input: + * - dev->d_buf holds the received packet. + * - dev->d_len holds the length of the received packet MINUS the + * size of the L1 header. That was subtracted out by ipv4_input. + * - ipv4 points to the IPv4 header with dev->d_buf. + * + * Returned Value: + * Zero is returned if the packet was successfully forward; A negated + * errno value is returned if the packet is not forwardable. In that + * latter case, the caller (ipv4_input()) should drop the packet. + * + ****************************************************************************/ + +#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_IPv4) +int ipv4_forward(FAR struct net_driver_s *dev, FAR struct ipv4_hdr_s *ipv4); +#endif + /**************************************************************************** * Name: ipv6_forward * diff --git a/net/devif/ip_forward.h b/net/devif/ip_forward.h index c8cd65e4de..f7b88b4e2e 100644 --- a/net/devif/ip_forward.h +++ b/net/devif/ip_forward.h @@ -47,6 +47,7 @@ #include #include #include +#include #include #include "udp/udp.h" diff --git a/net/devif/ipv4_forward.c b/net/devif/ipv4_forward.c new file mode 100644 index 0000000000..ef8e8f971f --- /dev/null +++ b/net/devif/ipv4_forward.c @@ -0,0 +1,553 @@ +/**************************************************************************** + * net/devif/ipv4_forward.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include "netdev/netdev.h" +#include "sixlowpan/sixlowpan.h" +#include "udp/udp.h" +#include "tcp/tcp.h" +#include "icmp/icmp.h" +#include "devif/ip_forward.h" +#include "devif/devif.h" + +#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_IPv4) + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: ipv4_hdrsize + * + * Description: + * Return the size of the IPv4 header and the following. + * + * Input Parameters: + * ipv4 - A pointer to the IPv4 header in within the IPv4 packet. This + * is immeidately followed by the L3 header which may be TCP, UDP + * or ICMP. + * + * Returned Value: + * The size of the combined L2 + L3 headers is returned on success. An + * error is returned only if the prototype is not supported. + * + ****************************************************************************/ + +#ifdef CONFIG_NETDEV_MULTINIC +static int ipv4_hdrsize(FAR struct ipv4_hdr_s *ipv4) +{ + /* Size is determined by the following protocol header, */ + + switch (ipv4->proto) + { +#ifdef CONFIG_NET_TCP + case IP_PROTO_TCP: + { + FAR struct tcp_hdr_s *tcp = + (FAR struct tcp_hdr_s *)((FAR uintptr_t *)ipv4 + IPv4_HDRLEN); + unsigned int tcpsize; + + /* The TCP header length is encoded in the top 4 bits of the + * tcpoffset field (in units of 32-bit words). + */ + + tcpsize = ((uint16_t)tcp->tcpoffset >> 4) << 2; + return IPv4_HDRLEN + tcpsize; + } + break; +#endif + +#ifdef CONFIG_NET_UDP + case IP_PROTO_UDP: + return IPv4_HDRLEN + UDP_HDRLEN; + break; +#endif + +#ifdef CONFIG_NET_ICMP + case IP_PROTO_ICMP: + return IPv4_HDRLEN + ICMP_HDRLEN; + break; +#endif + + default: + nwarn("WARNING: Unrecognized proto: %u\n", ipv4->proto); + return -EPROTONOSUPPORT; + } +} +#endif + +/**************************************************************************** + * Name: ipv4_dev_forward + * + * Description: + * This function is called from ipv4_forward when it is necessary to + * forward a packet from the current device to different device. In this + * case, the forwarding operation must be performed asynchronously when + * the TX poll is received from the forwarding device. + * + * Input Parameters: + * dev - The device on which the packet was received and which + * contains the IPv4 packet. + * fwdddev - The device on which the packet must be forwarded. + * ipv4 - A pointer to the IPv4 header in within the IPv4 packet + * + * Returned Value: + * Zero is returned if the packet was successfully forward; A negated + * errno value is returned if the packet is not forwardable. In that + * latter case, the caller (ipv4_input()) should drop the packet. + * + ****************************************************************************/ + +#ifdef CONFIG_NETDEV_MULTINIC +static int ipv4_dev_forward(FAR struct net_driver_s *dev, + FAR struct net_driver_s *fwddev, + FAR struct ipv4_hdr_s *ipv4) +{ + FAR struct forward_s *fwd = NULL; + FAR uint8_t *payload; + unsigned int paysize; + int hdrsize; + int ret; + + /* Verify that the full packet will fit within the forwarding devices MTU. + * We provide no support for fragmenting forwarded packets. + */ + + if (NET_LL_HDRLEN(fwddev) + dev->d_len > NET_DEV_MTU(fwddev)) + { + nwarn("WARNING: Packet > MTU... Dropping\n"); + ret = -EFBIG; + goto errout; + } + + /* Get a pre-allocated forwarding structure, This structure will be + * completely zeroed when we receive it. + */ + + fwd = ip_forward_alloc(); + if (fwd == NULL) + { + nwarn("WARNING: Failed to allocate forwarding structure\n"); + ret = -ENOMEM; + goto errout; + } + + /* Initialize the easy stuff in the forwarding structure */ + + fwd->f_dev = fwddev; /* Forwarding device */ + + /* Get the size of the IPv4 + L3 header. Use this to determine start of + * the data payload. + * + * Remember that the size of the L1 header has already been subtracted + * from dev->d_len. + * + * REVISIT: Consider an alternative design that does not require data + * copying. This would require a pool of d_buf's that are managed by + * the network rather than the network device. + */ + + hdrsize = ipv4_hdrsize(ipv4); + if (hdrsize < IPv4_HDRLEN) + { + nwarn("WARNING: Could not determine L2+L3 header size\n"); + ret = -EPROTONOSUPPORT; + goto errout_with_fwd; + } + + /* Save the entire L2 and L3 headers in the state structure */ + + if (hdrsize > sizeof(union fwd_iphdr_u)) + { + nwarn("WARNING: Header is too big for pre-allocated structure\n"); + ret = -E2BIG; + goto errout_with_fwd; + } + + memcpy(&fwd->f_hdr, ipv4, hdrsize); + fwd->f_hdrsize = hdrsize; + + /* Use the L2 + L3 header size to determine start and size of the data + * payload. + * + * Remember that the size of the L1 header has already been subtracted + * from dev->d_len. + */ + + payload = (FAR uint8_t *)ipv4 + hdrsize; + paysize = dev->d_len - hdrsize; + + /* If there is a payload, then copy it into an IOB chain. + * + * REVISIT: Consider an alternative design that does not require data + * copying. This would require a pool of d_buf's that are managed by + * the network rather than the network device. + */ + + if (paysize > 0) + { + /* Try to allocate the head of an IOB chain. If this fails, the + * packet will be dropped; we are not operating in a context + * where waiting for an IOB is a good idea + */ + + fwd->f_iob = iob_tryalloc(false); + if (fwd->f_iob == NULL) + { + nwarn("WARNING: iob_tryalloc() failed\n"); + ret = -ENOMEM; + goto errout_with_fwd; + } + + /* Copy the packet data payload into an IOB chain. iob_trycopin() will + * not wait, but will fail there are no available IOBs. + */ + + ret = iob_trycopyin(fwd->f_iob, payload, paysize, 0, false); + if (ret < 0) + { + nwarn("WARNING: iob_trycopyin() failed: %d\n", ret); + goto errout_with_iobchain; + } + } + + /* Then set up to forward the packet according to the protocol. + * + * REVISIT: Are these protocol specific forwarders necessary? I think + * that this could be done with a single forwarding function for all + * protocols. + */ + + switch (ipv4->proto) + { +#ifdef CONFIG_NET_TCP + case IP_PROTO_TCP: + { + /* Forward a TCP packet. */ + + ret = tcp_forward(fwd); + } + break; +#endif + +#ifdef CONFIG_NET_UDP + case IP_PROTO_UDP: + { + /* Forward a UDP packet */ + + ret = udp_forward(fwd); + } + break; +#endif + + case IP_PROTO_ICMP: /* Not yet supported */ + default: + nwarn("WARNING: Unrecognized proto: %u\n", ipv4->proto); + ret = -EPROTONOSUPPORT; + break; + } + + if (ret >= 0) + { + dev->d_len = 0; + return OK; + } + +errout_with_iobchain: + if (fwd != NULL && fwd->f_iob != NULL) + { + iob_free_chain(fwd->f_iob); + } + +errout_with_fwd: + if (fwd != NULL) + { + ip_forward_free(fwd); + } + +errout: + return ret; +} +#endif /* CONFIG_NETDEV_MULTINIC */ + +/**************************************************************************** + * Name: ipv4_decr_ttl + * + * Description: + * Decrement the IPv4 TTL (time to live value). TTL field is set by the + * sender of the packet and reduced by every router on the route to its + * destination. If the TTL field reaches zero before the datagram arrives + * at its destination, then the datagram is discarded and an ICMP error + * packet (11 - Time Exceeded) is sent back to the sender. + * + * The purpose of the TTL field is to avoid a situation in which an + * undeliverable datagram keeps circulating on an Internet system, and + * such a system eventually becoming swamped by such "immortals". + * + * Input Parameters: + * ipv4 - A pointer to the IPv4 header in within the IPv4 packet to be + * forwarded. + * + * Returned Value: + * The new TTL value is returned. A value <= 0 means the hop limit has + * expired. + * + ****************************************************************************/ + +static int ipv4_decr_ttl(FAR struct ipv4_hdr_s *ipv4) +{ + int ttl = (int)ipv4->ttl - 1; + + if (ttl <= 0) + { +#ifdef CONFIG_NET_ICMP + /* Return an ICMP error packet back to the sender. */ +#warning Missing logic +#endif + + /* Return zero which must cause the packet to be dropped */ + + return 0; + } + + /* Save the updated TTL value */ + + ipv4->ttl = ttl; + + /* NOTE: We do not have to recalculate the IPv4 checksum because (1) the + * IPv4 header does not include a checksum itself and (2) the TTL is not + * included in the sum for the TCP and UDP headers. + */ + + return ttl; +} + +/**************************************************************************** + * Name: ipv4_dropstats + * + * Description: + * Update statistics for a dropped packet. + * + * Input Parameters: + * ipv4 - A convenience pointer to the IPv4 header in within the IPv4 + * packet to be dropped. + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_NET_STATISTICS +static void ipv4_dropstats(FAR struct ipv4_hdr_s *ipv4) +{ + switch (ipv4->proto) + { +#ifdef CONFIG_NET_TCP + case IP_PROTO_TCP: + g_netstats.tcp.drop++; + break; +#endif + +#ifdef CONFIG_NET_UDP + case IP_PROTO_UDP: + g_netstats.udp.drop++; + break; +#endif + +#ifdef CONFIG_NET_ICMP + case IP_PROTO_ICMP: + g_netstats.icmp.drop++; + break; +#endif + + default: + break; + } + + g_netstats.ipv4.drop++; +} +#else +# define ipv4_dropstats(ipv4) +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: ipv4_forward + * + * Description: + * This function is called from ipv4_input when a packet is received that + * is not destined for us. In this case, the packet may need to be + * forwarded to another device (or sent back out the same device) + * depending configuration, routing table information, and the IPv4 + * networks served by various network devices. + * + * Input Parameters: + * dev - The device on which the packet was received and which contains + * the IPv4 packet. + * ipv4 - A convenience pointer to the IPv4 header in within the IPv4 + * packet + * + * On input: + * - dev->d_buf holds the received packet. + * - dev->d_len holds the length of the received packet MINUS the + * size of the L1 header. That was subtracted out by ipv4_input. + * - ipv4 points to the IPv4 header with dev->d_buf. + * + * Returned Value: + * Zero is returned if the packet was successfully forward; A negated + * errno value is returned if the packet is not forwardable. In that + * latter case, the caller (ipv4_input()) should drop the packet. + * + ****************************************************************************/ + +int ipv4_forward(FAR struct net_driver_s *dev, FAR struct ipv4_hdr_s *ipv4) +{ + in_addr_t destipaddr; +#ifdef CONFIG_NETDEV_MULTINIC + in_addr_t srcipaddr; +#endif + FAR struct net_driver_s *fwddev; + int ret; + + /* Decrement the TTL. If it decrements to zero, then drop the packet */ + + ret = ipv4_decr_ttl(ipv4); + if (ret < 1) + { + nwarn("WARNING: Hop limit exceeded... Dropping!\n"); + ret = -EMULTIHOP; + goto drop; + } + + /* Re-calculate the IPv4 checksum. This checksum is the Internet checksum + * of the 20 bytes of the IPv4 header. This checksum will be different + * because we just modify the IPv4 TTL. + */ + + ipv4->ipchksum = 0; + ipv4->ipchksum = ~ipv4_chksum(dev); + + /* Search for a device that can forward this packet. This is a trivial + * search if there is only a single network device (CONFIG_NETDEV_MULTINIC + * not defined). But netdev_findby_ipv4addr() will still assure + * routability in that case. + */ + + destipaddr = net_ip4addr_conv32(ipv4->destipaddr); +#ifdef CONFIG_NETDEV_MULTINIC + srcipaddr = net_ip4addr_conv32(ipv4->srcipaddr); + + fwddev = netdev_findby_ipv4addr(srcipaddr, destipaddr); +#else + fwddev = netdev_findby_ipv4addr(destipaddr); +#endif + if (fwddev == NULL) + { + nwarn("WARNING: Not routable\n"); + return (ssize_t)-ENETUNREACH; + } + +#if defined(CONFIG_NETDEV_MULTINIC) + /* Check if we are forwarding on the same device that we received the + * packet from. + */ + + if (fwddev != dev) + { + /* Send the packet asynchrously on the forwarding device. */ + + ret = ipv4_dev_forward(dev, fwddev, ipv4); + if (ret < 0) + { + nwarn("WARNING: ipv4_dev_forward faield: %d\n", ret); + goto drop; + } + } + else +#endif /* CONFIG_NETDEV_MULTINIC */ + + { + /* Single network device. The use case here is where an endpoint acts + * as a hub in a star configuration. This is typical for a wireless star + * configuration where not all endpoints are accessible from all other + * endpoints, but seems less useful for a wired network. + */ + +#ifdef CONFIG_NET_ETHERNET + /* REVISIT: For Ethernet we may have to fix up the Ethernet header: + * - source MAC, the MAC of the current device. + * - dest MAC, the MAC associated with the destination IPv4 adress. + * This will involve ICMP. + */ + + /* Correct dev->d_buf by adding back the L1 header length */ +#endif + + nwarn("WARNING: Packet forwarding to same device not supportedN\n"); + ret = -ENOSYS; + goto drop; + } + + /* Return success. ipv4_input will return to the network driver with + * dev->d_len set to the packet size and the network driver will perform + * the transfer. + */ + + return OK; + +drop: + ipv4_dropstats(ipv4); + dev->d_len = 0; + return ret; +} + +#endif /* CONFIG_NET_IPFORWARD && CONFIG_NET_IPv4 */ diff --git a/net/devif/ipv4_input.c b/net/devif/ipv4_input.c index 2920aeba3b..c2f9fcb2ca 100644 --- a/net/devif/ipv4_input.c +++ b/net/devif/ipv4_input.c @@ -152,8 +152,8 @@ static uint8_t g_reassembly_flags; #if defined(CONFIG_NET_TCP_REASSEMBLY) && !defined(CONFIG_NET_IPv6) static uint8_t devif_reassembly(void) { - FAR struct ipv4_hdr_s *pbuf = BUF; - FAR struct ipv4_hdr_s *pfbuf = FBUF; + FAR struct ipv4_hdr_s *ipv4 = BUF; + FAR struct ipv4_hdr_s *fipv4 = FBUF; uint16_t offset; uint16_t len; uint16_t i; @@ -165,7 +165,7 @@ static uint8_t devif_reassembly(void) if (!g_reassembly_timer) { - memcpy(g_reassembly_buffer, &pbuf->vhl, IPv4_HDRLEN); + memcpy(g_reassembly_buffer, &ipv4->vhl, IPv4_HDRLEN); g_reassembly_timer = CONFIG_NET_TCP_REASS_MAXAGE; g_reassembly_flags = 0; @@ -179,12 +179,12 @@ static uint8_t devif_reassembly(void) * fragment into the buffer. */ - if (net_ipv4addr_hdrcmp(pbuf->srcipaddr, pfbuf->srcipaddr) && - net_ipv4addr_hdrcmp(pbuf->destipaddr, pfbuf->destipaddr) && - pbuf->g_ipid[0] == pfbuf->g_ipid[0] && pbuf->g_ipid[1] == pfbuf->g_ipid[1]) + if (net_ipv4addr_hdrcmp(ipv4->srcipaddr, fipv4->srcipaddr) && + net_ipv4addr_hdrcmp(ipv4->destipaddr, fipv4->destipaddr) && + ipv4->g_ipid[0] == fipv4->g_ipid[0] && ipv4->g_ipid[1] == fipv4->g_ipid[1]) { - len = (pbuf->len[0] << 8) + pbuf->len[1] - (pbuf->vhl & 0x0f) * 4; - offset = (((pbuf->ipoffset[0] & 0x3f) << 8) + pbuf->ipoffset[1]) * 8; + len = (ipv4->len[0] << 8) + ipv4->len[1] - (ipv4->vhl & 0x0f) * 4; + offset = (((ipv4->ipoffset[0] & 0x3f) << 8) + ipv4->ipoffset[1]) * 8; /* If the offset or the offset + fragment length overflows the * reassembly buffer, we discard the entire packet. @@ -198,7 +198,8 @@ static uint8_t devif_reassembly(void) /* Copy the fragment into the reassembly buffer, at the right offset. */ - memcpy(&g_reassembly_buffer[IPv4_HDRLEN + offset], (char *)pbuf + (int)((pbuf->vhl & 0x0f) * 4), len); + memcpy(&g_reassembly_buffer[IPv4_HDRLEN + offset], + (FAR char *)ipv4 + (int)((ipv4->vhl & 0x0f) * 4), len); /* Update the bitmap. */ @@ -235,7 +236,7 @@ static uint8_t devif_reassembly(void) * we have received the final fragment. */ - if ((pbuf->ipoffset[0] & IP_MF) == 0) + if ((ipv4->ipoffset[0] & IP_MF) == 0) { g_reassembly_flags |= TCP_REASS_LASTFRAG; g_reassembly_len = offset + len; @@ -271,22 +272,22 @@ static uint8_t devif_reassembly(void) } /* If we have come this far, we have a full packet in the buffer, - * so we allocate a pbuf and copy the packet into it. We also reset + * so we allocate a ipv4 and copy the packet into it. We also reset * the timer. */ g_reassembly_timer = 0; - memcpy(pbuf, pfbuf, g_reassembly_len); + memcpy(ipv4, fipv4, g_reassembly_len); /* Pretend to be a "normal" (i.e., not fragmented) IP packet from * now on. */ - pbuf->ipoffset[0] = pbuf->ipoffset[1] = 0; - pbuf->len[0] = g_reassembly_len >> 8; - pbuf->len[1] = g_reassembly_len & 0xff; - pbuf->ipchksum = 0; - pbuf->ipchksum = ~(ipv4_chksum(dev)); + ipv4->ipoffset[0] = ipv4->ipoffset[1] = 0; + ipv4->len[0] = g_reassembly_len >> 8; + ipv4->len[1] = g_reassembly_len & 0xff; + ipv4->ipchksum = 0; + ipv4->ipchksum = ~(ipv4_chksum(dev)); return g_reassembly_len; } @@ -316,7 +317,7 @@ nullreturn: int ipv4_input(FAR struct net_driver_s *dev) { - FAR struct ipv4_hdr_s *pbuf = BUF; + FAR struct ipv4_hdr_s *ipv4 = BUF; uint16_t hdrlen; uint16_t iplen; @@ -329,7 +330,7 @@ int ipv4_input(FAR struct net_driver_s *dev) /* Start of IP input header processing code. */ /* Check validity of the IP header. */ - if (pbuf->vhl != 0x45) + if (ipv4->vhl != 0x45) { /* IP version and header length. */ @@ -338,7 +339,7 @@ int ipv4_input(FAR struct net_driver_s *dev) g_netstats.ipv4.vhlerr++; #endif nwarn("WARNING: Invalid IP version or header length: %02x\n", - pbuf->vhl); + ipv4->vhl); goto drop; } @@ -360,7 +361,7 @@ int ipv4_input(FAR struct net_driver_s *dev) * we set d_len to the correct value. */ - iplen = (pbuf->len[0] << 8) + pbuf->len[1]; + iplen = (ipv4->len[0] << 8) + ipv4->len[1]; if (iplen <= dev->d_len) { dev->d_len = iplen; @@ -373,7 +374,7 @@ int ipv4_input(FAR struct net_driver_s *dev) /* Check the fragment flag. */ - if ((pbuf->ipoffset[0] & 0x3f) != 0 || pbuf->ipoffset[1] != 0) + if ((ipv4->ipoffset[0] & 0x3f) != 0 || ipv4->ipoffset[1] != 0) { #if defined(CONFIG_NET_TCP_REASSEMBLY) dev->d_len = devif_reassembly(); @@ -398,8 +399,8 @@ int ipv4_input(FAR struct net_driver_s *dev) * negotiating over DHCP for an address). */ - if (pbuf->proto == IP_PROTO_UDP && - net_ipv4addr_cmp(net_ip4addr_conv32(pbuf->destipaddr), + if (ipv4->proto == IP_PROTO_UDP && + net_ipv4addr_cmp(net_ip4addr_conv32(ipv4->destipaddr), INADDR_BROADCAST)) { return udp_ipv4_input(dev); @@ -416,23 +417,54 @@ int ipv4_input(FAR struct net_driver_s *dev) goto drop; } - /* Check if the packet is destined for out IP address */ + /* Check if the packet is destined for our IP address */ else #endif { /* Check if the packet is destined for our IP address. */ - if (!net_ipv4addr_cmp(net_ip4addr_conv32(pbuf->destipaddr), dev->d_ipaddr)) + if (!net_ipv4addr_cmp(net_ip4addr_conv32(ipv4->destipaddr), + dev->d_ipaddr)) { + /* Check for an IPv4 IGMP group address */ + #ifdef CONFIG_NET_IGMP - in_addr_t destip = net_ip4addr_conv32(pbuf->destipaddr); + in_addr_t destip = net_ip4addr_conv32(ipv4->destipaddr); if (igmp_grpfind(dev, &destip) == NULL) #endif { -#ifdef CONFIG_NET_STATISTICS - g_netstats.ipv4.drop++; + /* No.. The packet is not destined for us. */ + +#ifdef CONFIG_NET_IPFORWARD + /* Try to forward the packet */ + + int ret = ipv4_forward(dev, ipv4); + if (ret >= 0) + { + /* The packet was forwarded. Return success; d_len will + * be set appropriately by the forwarding logic: Cleared + * if the packet is forward via anoother device or non- + * zero if it will be forwarded by the same device that + * it was received on. + */ + + return OK; + } + else #endif - goto drop; + { + /* Not destined for us and not forwardable... Drop the + * packet. + */ + + nwarn("WARNING: Not destined for us; not forwardable... " + "Dropping!\n"); + +#ifdef CONFIG_NET_STATISTICS + g_netstats.ipv4.drop++; +#endif + goto drop; + } } } } @@ -457,7 +489,7 @@ int ipv4_input(FAR struct net_driver_s *dev) /* Now process the incoming packet according to the protocol. */ - switch (pbuf->proto) + switch (ipv4->proto) { #ifdef NET_TCP_HAVE_STACK case IP_PROTO_TCP: /* TCP input */ diff --git a/net/devif/ipv6_forward.c b/net/devif/ipv6_forward.c index fa2ec6f77e..222099e5a7 100644 --- a/net/devif/ipv6_forward.c +++ b/net/devif/ipv6_forward.c @@ -303,7 +303,7 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, if (paysize > 0) { /* Try to allocate the head of an IOB chain. If this fails, - * the the packet will be dropped; we are not operating in a + * the packet will be dropped; we are not operating in a * context where waiting for an IOB is a good idea */ @@ -382,15 +382,15 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, errout_with_iobchain: if (fwd != NULL && fwd->f_iob != NULL) - { - iob_free_chain(fwd->f_iob); - } + { + iob_free_chain(fwd->f_iob); + } errout_with_fwd: if (fwd != NULL) - { - ip_forward_free(fwd); - } + { + ip_forward_free(fwd); + } errout: return ret; @@ -532,8 +532,6 @@ static void ipv6_dropstats(FAR struct ipv6_hdr_s *ipv6) int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) { - /* Multiple network devices */ - FAR struct net_driver_s *fwddev; int ret; @@ -548,7 +546,7 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) } /* Search for a device that can forward this packet. This is a trivial - * serch if there is only a single network device (CONFIG_NETDEV_MULTINIC + * search if there is only a single network device (CONFIG_NETDEV_MULTINIC * not defined). But netdev_findby_ipv6addr() will still assure * routability in that case. */ diff --git a/net/icmpv6/icmpv6_forward.c b/net/icmpv6/icmpv6_forward.c index 74e882e09b..4004c3805d 100644 --- a/net/icmpv6/icmpv6_forward.c +++ b/net/icmpv6/icmpv6_forward.c @@ -107,7 +107,7 @@ static inline bool icmpv6_forward_addrchck(FAR struct forward_s *fwd) #ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv6 - if (conn->domain == PF_INET) + if ((fwd->f_hdr.ipv4.l2.vhl & IP_VERSION_MASK) == IPv4_VERSION) #endif { #if !defined(CONFIG_NET_ARP_IPIN) && !defined(CONFIG_NET_ARP_SEND) diff --git a/net/tcp/tcp_forward.c b/net/tcp/tcp_forward.c index b2e9b1de07..c67cac7a6e 100644 --- a/net/tcp/tcp_forward.c +++ b/net/tcp/tcp_forward.c @@ -93,14 +93,14 @@ static inline void forward_ipselect(FAR struct forward_s *fwd) { /* Select the IPv4 domain */ - tcp_ipv4_select(dev); + tcp_ipv4_select(fwd->f_dev); } else /* if (conn->domain == PF_INET6) */ { /* Select the IPv6 domain */ - DEBUGASSERT(conn->domain == PF_INET6); - tcp_ipv6_select(dev); + DEBUGASSERT(fwd->f_conn.tcp.domain == PF_INET6); + tcp_ipv6_select(fwd->f_dev); } } #endif @@ -306,7 +306,7 @@ static uint16_t tcp_forward_interrupt(FAR struct net_driver_s *dev, * place and we need do nothing. */ - forward_ipselect(dev, fwd); + forward_ipselect(fwd); #endif /* Copy the user data into d_appdata and send it. */ diff --git a/net/udp/udp_forward.c b/net/udp/udp_forward.c index fdba5b5c4a..b2c1363ab0 100644 --- a/net/udp/udp_forward.c +++ b/net/udp/udp_forward.c @@ -143,7 +143,7 @@ static inline bool udp_forward_addrchk(FAR struct forward_s *fwd) #ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv6 - if (conn->domain == PF_INET) + if ((fwd->f_hdr.ipv4.l2.vhl & IP_VERSION_MASK) == IPv4_VERSION) #endif { #if !defined(CONFIG_NET_ARP_IPIN) && !defined(CONFIG_NET_ARP_SEND) @@ -288,7 +288,7 @@ static uint16_t udp_forward_interrupt(FAR struct net_driver_s *dev, * place and we need do nothing. */ - forward_ipselect(dev, fwd); + forward_ipselect(fwd); #endif /* Copy the user data into d_appdata and send it. */ From b297066eb9cfac50c45312e4e87862274235a889 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 5 Jul 2017 15:12:29 -0600 Subject: [PATCH 05/31] IP Forwarding: Add IPv4 packet forwarding logic. Initial commit is an untested clone of the IPv6 forwarding logic with a few minor logic changes for IPv4. --- net/devif/Make.defs | 3 + net/devif/devif.h | 33 +++ net/devif/ip_forward.h | 1 + net/devif/ipv4_forward.c | 553 ++++++++++++++++++++++++++++++++++++ net/devif/ipv4_input.c | 94 ++++-- net/devif/ipv6_forward.c | 18 +- net/icmpv6/icmpv6_forward.c | 2 +- net/tcp/tcp_forward.c | 8 +- net/udp/udp_forward.c | 4 +- 9 files changed, 668 insertions(+), 48 deletions(-) create mode 100644 net/devif/ipv4_forward.c diff --git a/net/devif/Make.defs b/net/devif/Make.defs index 4dcce7379b..6520b8430c 100644 --- a/net/devif/Make.defs +++ b/net/devif/Make.defs @@ -42,6 +42,9 @@ NET_CSRCS += devif_callback.c ifeq ($(CONFIG_NET_IPv4),y) NET_CSRCS += ipv4_input.c +ifeq ($(CONFIG_NET_IPFORWARD),y) +NET_CSRCS += ipv4_forward.c +endif endif ifeq ($(CONFIG_NET_IPv6),y) diff --git a/net/devif/devif.h b/net/devif/devif.h index 78fcce32e5..efacd00714 100644 --- a/net/devif/devif.h +++ b/net/devif/devif.h @@ -425,6 +425,39 @@ uint16_t devif_conn_event(FAR struct net_driver_s *dev, FAR void *pvconn, uint16_t devif_dev_event(FAR struct net_driver_s *dev, void *pvconn, uint16_t flags); +/**************************************************************************** + * Name: ipv4_forward + * + * Description: + * This function is called from ipv4_input when a packet is received that + * is not destined for us. In this case, the packet may need to be + * forwarded to another device (or sent back out the same device) + * depending configuration, routing table information, and the IPv4 + * networks served by various network devices. + * + * Input Parameters: + * dev - The device on which the packet was received and which contains + * the IPv4 packet. + * ipv4 - A convenience pointer to the IPv4 header in within the IPv4 + * packet + * + * On input: + * - dev->d_buf holds the received packet. + * - dev->d_len holds the length of the received packet MINUS the + * size of the L1 header. That was subtracted out by ipv4_input. + * - ipv4 points to the IPv4 header with dev->d_buf. + * + * Returned Value: + * Zero is returned if the packet was successfully forward; A negated + * errno value is returned if the packet is not forwardable. In that + * latter case, the caller (ipv4_input()) should drop the packet. + * + ****************************************************************************/ + +#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_IPv4) +int ipv4_forward(FAR struct net_driver_s *dev, FAR struct ipv4_hdr_s *ipv4); +#endif + /**************************************************************************** * Name: ipv6_forward * diff --git a/net/devif/ip_forward.h b/net/devif/ip_forward.h index c8cd65e4de..f7b88b4e2e 100644 --- a/net/devif/ip_forward.h +++ b/net/devif/ip_forward.h @@ -47,6 +47,7 @@ #include #include #include +#include #include #include "udp/udp.h" diff --git a/net/devif/ipv4_forward.c b/net/devif/ipv4_forward.c new file mode 100644 index 0000000000..ef8e8f971f --- /dev/null +++ b/net/devif/ipv4_forward.c @@ -0,0 +1,553 @@ +/**************************************************************************** + * net/devif/ipv4_forward.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include "netdev/netdev.h" +#include "sixlowpan/sixlowpan.h" +#include "udp/udp.h" +#include "tcp/tcp.h" +#include "icmp/icmp.h" +#include "devif/ip_forward.h" +#include "devif/devif.h" + +#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_IPv4) + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: ipv4_hdrsize + * + * Description: + * Return the size of the IPv4 header and the following. + * + * Input Parameters: + * ipv4 - A pointer to the IPv4 header in within the IPv4 packet. This + * is immeidately followed by the L3 header which may be TCP, UDP + * or ICMP. + * + * Returned Value: + * The size of the combined L2 + L3 headers is returned on success. An + * error is returned only if the prototype is not supported. + * + ****************************************************************************/ + +#ifdef CONFIG_NETDEV_MULTINIC +static int ipv4_hdrsize(FAR struct ipv4_hdr_s *ipv4) +{ + /* Size is determined by the following protocol header, */ + + switch (ipv4->proto) + { +#ifdef CONFIG_NET_TCP + case IP_PROTO_TCP: + { + FAR struct tcp_hdr_s *tcp = + (FAR struct tcp_hdr_s *)((FAR uintptr_t *)ipv4 + IPv4_HDRLEN); + unsigned int tcpsize; + + /* The TCP header length is encoded in the top 4 bits of the + * tcpoffset field (in units of 32-bit words). + */ + + tcpsize = ((uint16_t)tcp->tcpoffset >> 4) << 2; + return IPv4_HDRLEN + tcpsize; + } + break; +#endif + +#ifdef CONFIG_NET_UDP + case IP_PROTO_UDP: + return IPv4_HDRLEN + UDP_HDRLEN; + break; +#endif + +#ifdef CONFIG_NET_ICMP + case IP_PROTO_ICMP: + return IPv4_HDRLEN + ICMP_HDRLEN; + break; +#endif + + default: + nwarn("WARNING: Unrecognized proto: %u\n", ipv4->proto); + return -EPROTONOSUPPORT; + } +} +#endif + +/**************************************************************************** + * Name: ipv4_dev_forward + * + * Description: + * This function is called from ipv4_forward when it is necessary to + * forward a packet from the current device to different device. In this + * case, the forwarding operation must be performed asynchronously when + * the TX poll is received from the forwarding device. + * + * Input Parameters: + * dev - The device on which the packet was received and which + * contains the IPv4 packet. + * fwdddev - The device on which the packet must be forwarded. + * ipv4 - A pointer to the IPv4 header in within the IPv4 packet + * + * Returned Value: + * Zero is returned if the packet was successfully forward; A negated + * errno value is returned if the packet is not forwardable. In that + * latter case, the caller (ipv4_input()) should drop the packet. + * + ****************************************************************************/ + +#ifdef CONFIG_NETDEV_MULTINIC +static int ipv4_dev_forward(FAR struct net_driver_s *dev, + FAR struct net_driver_s *fwddev, + FAR struct ipv4_hdr_s *ipv4) +{ + FAR struct forward_s *fwd = NULL; + FAR uint8_t *payload; + unsigned int paysize; + int hdrsize; + int ret; + + /* Verify that the full packet will fit within the forwarding devices MTU. + * We provide no support for fragmenting forwarded packets. + */ + + if (NET_LL_HDRLEN(fwddev) + dev->d_len > NET_DEV_MTU(fwddev)) + { + nwarn("WARNING: Packet > MTU... Dropping\n"); + ret = -EFBIG; + goto errout; + } + + /* Get a pre-allocated forwarding structure, This structure will be + * completely zeroed when we receive it. + */ + + fwd = ip_forward_alloc(); + if (fwd == NULL) + { + nwarn("WARNING: Failed to allocate forwarding structure\n"); + ret = -ENOMEM; + goto errout; + } + + /* Initialize the easy stuff in the forwarding structure */ + + fwd->f_dev = fwddev; /* Forwarding device */ + + /* Get the size of the IPv4 + L3 header. Use this to determine start of + * the data payload. + * + * Remember that the size of the L1 header has already been subtracted + * from dev->d_len. + * + * REVISIT: Consider an alternative design that does not require data + * copying. This would require a pool of d_buf's that are managed by + * the network rather than the network device. + */ + + hdrsize = ipv4_hdrsize(ipv4); + if (hdrsize < IPv4_HDRLEN) + { + nwarn("WARNING: Could not determine L2+L3 header size\n"); + ret = -EPROTONOSUPPORT; + goto errout_with_fwd; + } + + /* Save the entire L2 and L3 headers in the state structure */ + + if (hdrsize > sizeof(union fwd_iphdr_u)) + { + nwarn("WARNING: Header is too big for pre-allocated structure\n"); + ret = -E2BIG; + goto errout_with_fwd; + } + + memcpy(&fwd->f_hdr, ipv4, hdrsize); + fwd->f_hdrsize = hdrsize; + + /* Use the L2 + L3 header size to determine start and size of the data + * payload. + * + * Remember that the size of the L1 header has already been subtracted + * from dev->d_len. + */ + + payload = (FAR uint8_t *)ipv4 + hdrsize; + paysize = dev->d_len - hdrsize; + + /* If there is a payload, then copy it into an IOB chain. + * + * REVISIT: Consider an alternative design that does not require data + * copying. This would require a pool of d_buf's that are managed by + * the network rather than the network device. + */ + + if (paysize > 0) + { + /* Try to allocate the head of an IOB chain. If this fails, the + * packet will be dropped; we are not operating in a context + * where waiting for an IOB is a good idea + */ + + fwd->f_iob = iob_tryalloc(false); + if (fwd->f_iob == NULL) + { + nwarn("WARNING: iob_tryalloc() failed\n"); + ret = -ENOMEM; + goto errout_with_fwd; + } + + /* Copy the packet data payload into an IOB chain. iob_trycopin() will + * not wait, but will fail there are no available IOBs. + */ + + ret = iob_trycopyin(fwd->f_iob, payload, paysize, 0, false); + if (ret < 0) + { + nwarn("WARNING: iob_trycopyin() failed: %d\n", ret); + goto errout_with_iobchain; + } + } + + /* Then set up to forward the packet according to the protocol. + * + * REVISIT: Are these protocol specific forwarders necessary? I think + * that this could be done with a single forwarding function for all + * protocols. + */ + + switch (ipv4->proto) + { +#ifdef CONFIG_NET_TCP + case IP_PROTO_TCP: + { + /* Forward a TCP packet. */ + + ret = tcp_forward(fwd); + } + break; +#endif + +#ifdef CONFIG_NET_UDP + case IP_PROTO_UDP: + { + /* Forward a UDP packet */ + + ret = udp_forward(fwd); + } + break; +#endif + + case IP_PROTO_ICMP: /* Not yet supported */ + default: + nwarn("WARNING: Unrecognized proto: %u\n", ipv4->proto); + ret = -EPROTONOSUPPORT; + break; + } + + if (ret >= 0) + { + dev->d_len = 0; + return OK; + } + +errout_with_iobchain: + if (fwd != NULL && fwd->f_iob != NULL) + { + iob_free_chain(fwd->f_iob); + } + +errout_with_fwd: + if (fwd != NULL) + { + ip_forward_free(fwd); + } + +errout: + return ret; +} +#endif /* CONFIG_NETDEV_MULTINIC */ + +/**************************************************************************** + * Name: ipv4_decr_ttl + * + * Description: + * Decrement the IPv4 TTL (time to live value). TTL field is set by the + * sender of the packet and reduced by every router on the route to its + * destination. If the TTL field reaches zero before the datagram arrives + * at its destination, then the datagram is discarded and an ICMP error + * packet (11 - Time Exceeded) is sent back to the sender. + * + * The purpose of the TTL field is to avoid a situation in which an + * undeliverable datagram keeps circulating on an Internet system, and + * such a system eventually becoming swamped by such "immortals". + * + * Input Parameters: + * ipv4 - A pointer to the IPv4 header in within the IPv4 packet to be + * forwarded. + * + * Returned Value: + * The new TTL value is returned. A value <= 0 means the hop limit has + * expired. + * + ****************************************************************************/ + +static int ipv4_decr_ttl(FAR struct ipv4_hdr_s *ipv4) +{ + int ttl = (int)ipv4->ttl - 1; + + if (ttl <= 0) + { +#ifdef CONFIG_NET_ICMP + /* Return an ICMP error packet back to the sender. */ +#warning Missing logic +#endif + + /* Return zero which must cause the packet to be dropped */ + + return 0; + } + + /* Save the updated TTL value */ + + ipv4->ttl = ttl; + + /* NOTE: We do not have to recalculate the IPv4 checksum because (1) the + * IPv4 header does not include a checksum itself and (2) the TTL is not + * included in the sum for the TCP and UDP headers. + */ + + return ttl; +} + +/**************************************************************************** + * Name: ipv4_dropstats + * + * Description: + * Update statistics for a dropped packet. + * + * Input Parameters: + * ipv4 - A convenience pointer to the IPv4 header in within the IPv4 + * packet to be dropped. + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_NET_STATISTICS +static void ipv4_dropstats(FAR struct ipv4_hdr_s *ipv4) +{ + switch (ipv4->proto) + { +#ifdef CONFIG_NET_TCP + case IP_PROTO_TCP: + g_netstats.tcp.drop++; + break; +#endif + +#ifdef CONFIG_NET_UDP + case IP_PROTO_UDP: + g_netstats.udp.drop++; + break; +#endif + +#ifdef CONFIG_NET_ICMP + case IP_PROTO_ICMP: + g_netstats.icmp.drop++; + break; +#endif + + default: + break; + } + + g_netstats.ipv4.drop++; +} +#else +# define ipv4_dropstats(ipv4) +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: ipv4_forward + * + * Description: + * This function is called from ipv4_input when a packet is received that + * is not destined for us. In this case, the packet may need to be + * forwarded to another device (or sent back out the same device) + * depending configuration, routing table information, and the IPv4 + * networks served by various network devices. + * + * Input Parameters: + * dev - The device on which the packet was received and which contains + * the IPv4 packet. + * ipv4 - A convenience pointer to the IPv4 header in within the IPv4 + * packet + * + * On input: + * - dev->d_buf holds the received packet. + * - dev->d_len holds the length of the received packet MINUS the + * size of the L1 header. That was subtracted out by ipv4_input. + * - ipv4 points to the IPv4 header with dev->d_buf. + * + * Returned Value: + * Zero is returned if the packet was successfully forward; A negated + * errno value is returned if the packet is not forwardable. In that + * latter case, the caller (ipv4_input()) should drop the packet. + * + ****************************************************************************/ + +int ipv4_forward(FAR struct net_driver_s *dev, FAR struct ipv4_hdr_s *ipv4) +{ + in_addr_t destipaddr; +#ifdef CONFIG_NETDEV_MULTINIC + in_addr_t srcipaddr; +#endif + FAR struct net_driver_s *fwddev; + int ret; + + /* Decrement the TTL. If it decrements to zero, then drop the packet */ + + ret = ipv4_decr_ttl(ipv4); + if (ret < 1) + { + nwarn("WARNING: Hop limit exceeded... Dropping!\n"); + ret = -EMULTIHOP; + goto drop; + } + + /* Re-calculate the IPv4 checksum. This checksum is the Internet checksum + * of the 20 bytes of the IPv4 header. This checksum will be different + * because we just modify the IPv4 TTL. + */ + + ipv4->ipchksum = 0; + ipv4->ipchksum = ~ipv4_chksum(dev); + + /* Search for a device that can forward this packet. This is a trivial + * search if there is only a single network device (CONFIG_NETDEV_MULTINIC + * not defined). But netdev_findby_ipv4addr() will still assure + * routability in that case. + */ + + destipaddr = net_ip4addr_conv32(ipv4->destipaddr); +#ifdef CONFIG_NETDEV_MULTINIC + srcipaddr = net_ip4addr_conv32(ipv4->srcipaddr); + + fwddev = netdev_findby_ipv4addr(srcipaddr, destipaddr); +#else + fwddev = netdev_findby_ipv4addr(destipaddr); +#endif + if (fwddev == NULL) + { + nwarn("WARNING: Not routable\n"); + return (ssize_t)-ENETUNREACH; + } + +#if defined(CONFIG_NETDEV_MULTINIC) + /* Check if we are forwarding on the same device that we received the + * packet from. + */ + + if (fwddev != dev) + { + /* Send the packet asynchrously on the forwarding device. */ + + ret = ipv4_dev_forward(dev, fwddev, ipv4); + if (ret < 0) + { + nwarn("WARNING: ipv4_dev_forward faield: %d\n", ret); + goto drop; + } + } + else +#endif /* CONFIG_NETDEV_MULTINIC */ + + { + /* Single network device. The use case here is where an endpoint acts + * as a hub in a star configuration. This is typical for a wireless star + * configuration where not all endpoints are accessible from all other + * endpoints, but seems less useful for a wired network. + */ + +#ifdef CONFIG_NET_ETHERNET + /* REVISIT: For Ethernet we may have to fix up the Ethernet header: + * - source MAC, the MAC of the current device. + * - dest MAC, the MAC associated with the destination IPv4 adress. + * This will involve ICMP. + */ + + /* Correct dev->d_buf by adding back the L1 header length */ +#endif + + nwarn("WARNING: Packet forwarding to same device not supportedN\n"); + ret = -ENOSYS; + goto drop; + } + + /* Return success. ipv4_input will return to the network driver with + * dev->d_len set to the packet size and the network driver will perform + * the transfer. + */ + + return OK; + +drop: + ipv4_dropstats(ipv4); + dev->d_len = 0; + return ret; +} + +#endif /* CONFIG_NET_IPFORWARD && CONFIG_NET_IPv4 */ diff --git a/net/devif/ipv4_input.c b/net/devif/ipv4_input.c index 2920aeba3b..c2f9fcb2ca 100644 --- a/net/devif/ipv4_input.c +++ b/net/devif/ipv4_input.c @@ -152,8 +152,8 @@ static uint8_t g_reassembly_flags; #if defined(CONFIG_NET_TCP_REASSEMBLY) && !defined(CONFIG_NET_IPv6) static uint8_t devif_reassembly(void) { - FAR struct ipv4_hdr_s *pbuf = BUF; - FAR struct ipv4_hdr_s *pfbuf = FBUF; + FAR struct ipv4_hdr_s *ipv4 = BUF; + FAR struct ipv4_hdr_s *fipv4 = FBUF; uint16_t offset; uint16_t len; uint16_t i; @@ -165,7 +165,7 @@ static uint8_t devif_reassembly(void) if (!g_reassembly_timer) { - memcpy(g_reassembly_buffer, &pbuf->vhl, IPv4_HDRLEN); + memcpy(g_reassembly_buffer, &ipv4->vhl, IPv4_HDRLEN); g_reassembly_timer = CONFIG_NET_TCP_REASS_MAXAGE; g_reassembly_flags = 0; @@ -179,12 +179,12 @@ static uint8_t devif_reassembly(void) * fragment into the buffer. */ - if (net_ipv4addr_hdrcmp(pbuf->srcipaddr, pfbuf->srcipaddr) && - net_ipv4addr_hdrcmp(pbuf->destipaddr, pfbuf->destipaddr) && - pbuf->g_ipid[0] == pfbuf->g_ipid[0] && pbuf->g_ipid[1] == pfbuf->g_ipid[1]) + if (net_ipv4addr_hdrcmp(ipv4->srcipaddr, fipv4->srcipaddr) && + net_ipv4addr_hdrcmp(ipv4->destipaddr, fipv4->destipaddr) && + ipv4->g_ipid[0] == fipv4->g_ipid[0] && ipv4->g_ipid[1] == fipv4->g_ipid[1]) { - len = (pbuf->len[0] << 8) + pbuf->len[1] - (pbuf->vhl & 0x0f) * 4; - offset = (((pbuf->ipoffset[0] & 0x3f) << 8) + pbuf->ipoffset[1]) * 8; + len = (ipv4->len[0] << 8) + ipv4->len[1] - (ipv4->vhl & 0x0f) * 4; + offset = (((ipv4->ipoffset[0] & 0x3f) << 8) + ipv4->ipoffset[1]) * 8; /* If the offset or the offset + fragment length overflows the * reassembly buffer, we discard the entire packet. @@ -198,7 +198,8 @@ static uint8_t devif_reassembly(void) /* Copy the fragment into the reassembly buffer, at the right offset. */ - memcpy(&g_reassembly_buffer[IPv4_HDRLEN + offset], (char *)pbuf + (int)((pbuf->vhl & 0x0f) * 4), len); + memcpy(&g_reassembly_buffer[IPv4_HDRLEN + offset], + (FAR char *)ipv4 + (int)((ipv4->vhl & 0x0f) * 4), len); /* Update the bitmap. */ @@ -235,7 +236,7 @@ static uint8_t devif_reassembly(void) * we have received the final fragment. */ - if ((pbuf->ipoffset[0] & IP_MF) == 0) + if ((ipv4->ipoffset[0] & IP_MF) == 0) { g_reassembly_flags |= TCP_REASS_LASTFRAG; g_reassembly_len = offset + len; @@ -271,22 +272,22 @@ static uint8_t devif_reassembly(void) } /* If we have come this far, we have a full packet in the buffer, - * so we allocate a pbuf and copy the packet into it. We also reset + * so we allocate a ipv4 and copy the packet into it. We also reset * the timer. */ g_reassembly_timer = 0; - memcpy(pbuf, pfbuf, g_reassembly_len); + memcpy(ipv4, fipv4, g_reassembly_len); /* Pretend to be a "normal" (i.e., not fragmented) IP packet from * now on. */ - pbuf->ipoffset[0] = pbuf->ipoffset[1] = 0; - pbuf->len[0] = g_reassembly_len >> 8; - pbuf->len[1] = g_reassembly_len & 0xff; - pbuf->ipchksum = 0; - pbuf->ipchksum = ~(ipv4_chksum(dev)); + ipv4->ipoffset[0] = ipv4->ipoffset[1] = 0; + ipv4->len[0] = g_reassembly_len >> 8; + ipv4->len[1] = g_reassembly_len & 0xff; + ipv4->ipchksum = 0; + ipv4->ipchksum = ~(ipv4_chksum(dev)); return g_reassembly_len; } @@ -316,7 +317,7 @@ nullreturn: int ipv4_input(FAR struct net_driver_s *dev) { - FAR struct ipv4_hdr_s *pbuf = BUF; + FAR struct ipv4_hdr_s *ipv4 = BUF; uint16_t hdrlen; uint16_t iplen; @@ -329,7 +330,7 @@ int ipv4_input(FAR struct net_driver_s *dev) /* Start of IP input header processing code. */ /* Check validity of the IP header. */ - if (pbuf->vhl != 0x45) + if (ipv4->vhl != 0x45) { /* IP version and header length. */ @@ -338,7 +339,7 @@ int ipv4_input(FAR struct net_driver_s *dev) g_netstats.ipv4.vhlerr++; #endif nwarn("WARNING: Invalid IP version or header length: %02x\n", - pbuf->vhl); + ipv4->vhl); goto drop; } @@ -360,7 +361,7 @@ int ipv4_input(FAR struct net_driver_s *dev) * we set d_len to the correct value. */ - iplen = (pbuf->len[0] << 8) + pbuf->len[1]; + iplen = (ipv4->len[0] << 8) + ipv4->len[1]; if (iplen <= dev->d_len) { dev->d_len = iplen; @@ -373,7 +374,7 @@ int ipv4_input(FAR struct net_driver_s *dev) /* Check the fragment flag. */ - if ((pbuf->ipoffset[0] & 0x3f) != 0 || pbuf->ipoffset[1] != 0) + if ((ipv4->ipoffset[0] & 0x3f) != 0 || ipv4->ipoffset[1] != 0) { #if defined(CONFIG_NET_TCP_REASSEMBLY) dev->d_len = devif_reassembly(); @@ -398,8 +399,8 @@ int ipv4_input(FAR struct net_driver_s *dev) * negotiating over DHCP for an address). */ - if (pbuf->proto == IP_PROTO_UDP && - net_ipv4addr_cmp(net_ip4addr_conv32(pbuf->destipaddr), + if (ipv4->proto == IP_PROTO_UDP && + net_ipv4addr_cmp(net_ip4addr_conv32(ipv4->destipaddr), INADDR_BROADCAST)) { return udp_ipv4_input(dev); @@ -416,23 +417,54 @@ int ipv4_input(FAR struct net_driver_s *dev) goto drop; } - /* Check if the packet is destined for out IP address */ + /* Check if the packet is destined for our IP address */ else #endif { /* Check if the packet is destined for our IP address. */ - if (!net_ipv4addr_cmp(net_ip4addr_conv32(pbuf->destipaddr), dev->d_ipaddr)) + if (!net_ipv4addr_cmp(net_ip4addr_conv32(ipv4->destipaddr), + dev->d_ipaddr)) { + /* Check for an IPv4 IGMP group address */ + #ifdef CONFIG_NET_IGMP - in_addr_t destip = net_ip4addr_conv32(pbuf->destipaddr); + in_addr_t destip = net_ip4addr_conv32(ipv4->destipaddr); if (igmp_grpfind(dev, &destip) == NULL) #endif { -#ifdef CONFIG_NET_STATISTICS - g_netstats.ipv4.drop++; + /* No.. The packet is not destined for us. */ + +#ifdef CONFIG_NET_IPFORWARD + /* Try to forward the packet */ + + int ret = ipv4_forward(dev, ipv4); + if (ret >= 0) + { + /* The packet was forwarded. Return success; d_len will + * be set appropriately by the forwarding logic: Cleared + * if the packet is forward via anoother device or non- + * zero if it will be forwarded by the same device that + * it was received on. + */ + + return OK; + } + else #endif - goto drop; + { + /* Not destined for us and not forwardable... Drop the + * packet. + */ + + nwarn("WARNING: Not destined for us; not forwardable... " + "Dropping!\n"); + +#ifdef CONFIG_NET_STATISTICS + g_netstats.ipv4.drop++; +#endif + goto drop; + } } } } @@ -457,7 +489,7 @@ int ipv4_input(FAR struct net_driver_s *dev) /* Now process the incoming packet according to the protocol. */ - switch (pbuf->proto) + switch (ipv4->proto) { #ifdef NET_TCP_HAVE_STACK case IP_PROTO_TCP: /* TCP input */ diff --git a/net/devif/ipv6_forward.c b/net/devif/ipv6_forward.c index fa2ec6f77e..222099e5a7 100644 --- a/net/devif/ipv6_forward.c +++ b/net/devif/ipv6_forward.c @@ -303,7 +303,7 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, if (paysize > 0) { /* Try to allocate the head of an IOB chain. If this fails, - * the the packet will be dropped; we are not operating in a + * the packet will be dropped; we are not operating in a * context where waiting for an IOB is a good idea */ @@ -382,15 +382,15 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, errout_with_iobchain: if (fwd != NULL && fwd->f_iob != NULL) - { - iob_free_chain(fwd->f_iob); - } + { + iob_free_chain(fwd->f_iob); + } errout_with_fwd: if (fwd != NULL) - { - ip_forward_free(fwd); - } + { + ip_forward_free(fwd); + } errout: return ret; @@ -532,8 +532,6 @@ static void ipv6_dropstats(FAR struct ipv6_hdr_s *ipv6) int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) { - /* Multiple network devices */ - FAR struct net_driver_s *fwddev; int ret; @@ -548,7 +546,7 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) } /* Search for a device that can forward this packet. This is a trivial - * serch if there is only a single network device (CONFIG_NETDEV_MULTINIC + * search if there is only a single network device (CONFIG_NETDEV_MULTINIC * not defined). But netdev_findby_ipv6addr() will still assure * routability in that case. */ diff --git a/net/icmpv6/icmpv6_forward.c b/net/icmpv6/icmpv6_forward.c index 74e882e09b..4004c3805d 100644 --- a/net/icmpv6/icmpv6_forward.c +++ b/net/icmpv6/icmpv6_forward.c @@ -107,7 +107,7 @@ static inline bool icmpv6_forward_addrchck(FAR struct forward_s *fwd) #ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv6 - if (conn->domain == PF_INET) + if ((fwd->f_hdr.ipv4.l2.vhl & IP_VERSION_MASK) == IPv4_VERSION) #endif { #if !defined(CONFIG_NET_ARP_IPIN) && !defined(CONFIG_NET_ARP_SEND) diff --git a/net/tcp/tcp_forward.c b/net/tcp/tcp_forward.c index b2e9b1de07..c67cac7a6e 100644 --- a/net/tcp/tcp_forward.c +++ b/net/tcp/tcp_forward.c @@ -93,14 +93,14 @@ static inline void forward_ipselect(FAR struct forward_s *fwd) { /* Select the IPv4 domain */ - tcp_ipv4_select(dev); + tcp_ipv4_select(fwd->f_dev); } else /* if (conn->domain == PF_INET6) */ { /* Select the IPv6 domain */ - DEBUGASSERT(conn->domain == PF_INET6); - tcp_ipv6_select(dev); + DEBUGASSERT(fwd->f_conn.tcp.domain == PF_INET6); + tcp_ipv6_select(fwd->f_dev); } } #endif @@ -306,7 +306,7 @@ static uint16_t tcp_forward_interrupt(FAR struct net_driver_s *dev, * place and we need do nothing. */ - forward_ipselect(dev, fwd); + forward_ipselect(fwd); #endif /* Copy the user data into d_appdata and send it. */ diff --git a/net/udp/udp_forward.c b/net/udp/udp_forward.c index fdba5b5c4a..b2c1363ab0 100644 --- a/net/udp/udp_forward.c +++ b/net/udp/udp_forward.c @@ -143,7 +143,7 @@ static inline bool udp_forward_addrchk(FAR struct forward_s *fwd) #ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv6 - if (conn->domain == PF_INET) + if ((fwd->f_hdr.ipv4.l2.vhl & IP_VERSION_MASK) == IPv4_VERSION) #endif { #if !defined(CONFIG_NET_ARP_IPIN) && !defined(CONFIG_NET_ARP_SEND) @@ -288,7 +288,7 @@ static uint16_t udp_forward_interrupt(FAR struct net_driver_s *dev, * place and we need do nothing. */ - forward_ipselect(dev, fwd); + forward_ipselect(fwd); #endif /* Copy the user data into d_appdata and send it. */ From 24e9647156caf0b9545495a34f16412be7aa0e7e Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 5 Jul 2017 16:35:14 -0600 Subject: [PATCH 06/31] net/Kconfig: IP forwarding no long depends on only IPv6. Also update Kconfig comments. --- net/Kconfig | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/net/Kconfig b/net/Kconfig index 6a1ce6ab11..0a0d9830b6 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -288,24 +288,18 @@ source "net/sixlowpan/Kconfig" config NET_IPFORWARD bool "Enable L2 forwarding" default n - depends on NET_IPv6 ---help--- - Enable forwarding of IPv6 packets. Packets received with IPv6 - addresses which are not supported by this platform will be forwarded - to the appropriate network device. Routing table support may be - required. - - NOTE: L2 forwarding only supported for IPv6. There is no technical - reason why IPv4 forwarding has not been implemented, it just has - not yet been done. + Enable forwarding of packets. Packets received with IP addresses + that are not supported by this platform will be forwarded to the + appropriate network device. Routing table support may be required. config NET_IPFORWARD_NSTRUCT int "Number of pre-allocated forwarding structures" default 4 depends on NET_IPFORWARD && CONFIG_NETDEV_MULTINIC ---help--- - When packets are forward from on device to another, a structure must - be allocated to hold the state of forwarding across several + When packets are forwarded from on device to another, a structure + must be allocated to hold the state of forwarding across several asynchronous events. Those structures are pre-allocated for minimal, deterministic performance and to prevent hogging of memory (of course, that means that this value must be carefully selected @@ -314,7 +308,8 @@ config NET_IPFORWARD_NSTRUCT NOTE: This setting effectively puts a maximum on the number of packets that may be waiting to be forwarded from one network device - to another. + to another. CONFIG_IOB_NBUFFERS also limits the forward because the + payload of the packet (up to the MSS) is retain in IOBs. endmenu # Internet Protocol Selection From 04716a65a57334a6a063e1167da55106a0415545 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 6 Jul 2017 07:26:01 -0600 Subject: [PATCH 07/31] IP forwading: Add optional support to forward broadcast and multicast packets. --- net/Kconfig | 10 +- net/devif/devif.h | 60 -------- net/devif/ip_forward.h | 134 ++++++++++++++++- net/devif/ipv4_forward.c | 301 ++++++++++++++++++++++++++------------- net/devif/ipv4_input.c | 16 ++- net/devif/ipv6_forward.c | 279 ++++++++++++++++++++++++------------ net/devif/ipv6_input.c | 11 ++ 7 files changed, 563 insertions(+), 248 deletions(-) diff --git a/net/Kconfig b/net/Kconfig index 0a0d9830b6..663e159aea 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -293,10 +293,18 @@ config NET_IPFORWARD that are not supported by this platform will be forwarded to the appropriate network device. Routing table support may be required. +config NET_IPFORWARD_BROADCAST + bool "Forward broadcast/multicast packets" + default n + depends on NET_IPFORWARD && NETDEV_MULTINIC + ---help--- + If selected, broadcast packets received on one network device will + be forwarded though other network devices. + config NET_IPFORWARD_NSTRUCT int "Number of pre-allocated forwarding structures" default 4 - depends on NET_IPFORWARD && CONFIG_NETDEV_MULTINIC + depends on NET_IPFORWARD && NETDEV_MULTINIC ---help--- When packets are forwarded from on device to another, a structure must be allocated to hold the state of forwarding across several diff --git a/net/devif/devif.h b/net/devif/devif.h index efacd00714..e90377dd58 100644 --- a/net/devif/devif.h +++ b/net/devif/devif.h @@ -425,66 +425,6 @@ uint16_t devif_conn_event(FAR struct net_driver_s *dev, FAR void *pvconn, uint16_t devif_dev_event(FAR struct net_driver_s *dev, void *pvconn, uint16_t flags); -/**************************************************************************** - * Name: ipv4_forward - * - * Description: - * This function is called from ipv4_input when a packet is received that - * is not destined for us. In this case, the packet may need to be - * forwarded to another device (or sent back out the same device) - * depending configuration, routing table information, and the IPv4 - * networks served by various network devices. - * - * Input Parameters: - * dev - The device on which the packet was received and which contains - * the IPv4 packet. - * ipv4 - A convenience pointer to the IPv4 header in within the IPv4 - * packet - * - * On input: - * - dev->d_buf holds the received packet. - * - dev->d_len holds the length of the received packet MINUS the - * size of the L1 header. That was subtracted out by ipv4_input. - * - ipv4 points to the IPv4 header with dev->d_buf. - * - * Returned Value: - * Zero is returned if the packet was successfully forward; A negated - * errno value is returned if the packet is not forwardable. In that - * latter case, the caller (ipv4_input()) should drop the packet. - * - ****************************************************************************/ - -#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_IPv4) -int ipv4_forward(FAR struct net_driver_s *dev, FAR struct ipv4_hdr_s *ipv4); -#endif - -/**************************************************************************** - * Name: ipv6_forward - * - * Description: - * This function is called from ipv6_input when a packet is received that - * is not destined for us. In this case, the packet may need to be - * forwarded to another device (or sent back out the same device) - * depending configuration, routing table information, and the IPv6 - * networks served by various network devices. - * - * Input Parameters: - * dev - The device on which the packet was received and which contains - * the IPv6 packet. - * ipv6 - A convenience pointer to the IPv6 header in within the IPv6 - * packet - * - * Returned Value: - * Zero is returned if the packet was successfully forward; A negated - * errno value is returned if the packet is not forwardable. In that - * latter case, the caller (ipv6_input()) should drop the packet. - * - ****************************************************************************/ - -#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_IPv6) -int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6); -#endif - /**************************************************************************** * Send data on the current connection. * diff --git a/net/devif/ip_forward.h b/net/devif/ip_forward.h index f7b88b4e2e..5eed4d8bb3 100644 --- a/net/devif/ip_forward.h +++ b/net/devif/ip_forward.h @@ -55,7 +55,13 @@ #include "icmpv6/icmpv6.h" #undef HAVE_FWDALLOC -#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC) +#ifdef CONFIG_NET_IPFORWARD + +/* Must of the logic in this header file applies only for configurations + * will multiple network devices. + */ + +#ifdef CONFIG_NETDEV_MULTINIC /**************************************************************************** * Pre-processor Definitions @@ -205,6 +211,68 @@ FAR struct forward_s *ip_forward_alloc(void); void ip_forward_free(FAR struct forward_s *fwd); +/**************************************************************************** + * Name: ipv4_forward_broadcast + * + * Description: + * This function is called from ipv4_input when a broadcast or multicast + * packet is received. If CONFIG_NET_IPFORWARD_BROADCAST is enabled, this + * function will forward the broadcast packet to other networks through + * other network devices. + * + * Input Parameters: + * dev - The device on which the packet was received and which contains + * the IPv4 packet. + * ipv4 - A convenience pointer to the IPv4 header in within the IPv4 + * packet + * + * On input: + * - dev->d_buf holds the received packet. + * - dev->d_len holds the length of the received packet MINUS the + * size of the L1 header. That was subtracted out by ipv4_input. + * - ipv4 points to the IPv4 header with dev->d_buf. + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_NET_IPFORWARD_BROADCAST +void ipv4_forward_broadcast(FAR struct net_driver_s *dev, + FAR struct ipv4_hdr_s *ipv4); +#endif + +/**************************************************************************** + * Name: ipv6_forward_broadcast + * + * Description: + * This function is called from ipv6_input when a broadcast or multicast + * packet is received. If CONFIG_NET_IPFORWARD_BROADCAST is enabled, this + * function will forward the broadcast packet to other networks through + * other network devices. + * + * Input Parameters: + * dev - The device on which the packet was received and which contains + * the IPv6 packet. + * ipv6 - A convenience pointer to the IPv6 header in within the IPv6 + * packet + * + * On input: + * - dev->d_buf holds the received packet. + * - dev->d_len holds the length of the received packet MINUS the + * size of the L1 header. That was subtracted out by ipv6_input. + * - ipv6 points to the IPv6 header with dev->d_buf. + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_NET_IPFORWARD_BROADCAST +void ipv6_forward_broadcast(FAR struct net_driver_s *dev, + FAR struct ipv6_hdr_s *ipv6); +#endif + /**************************************************************************** * Name: devif_forward * @@ -225,5 +293,67 @@ void ip_forward_free(FAR struct forward_s *fwd); void devif_forward(FAR struct forward_s *fwd); -#endif /* CONFIG_NET_IPFORWARD && CONFIG_NETDEV_MULTINIC */ +#endif /* CONFIG_NETDEV_MULTINIC */ + +/**************************************************************************** + * Name: ipv4_forward + * + * Description: + * This function is called from ipv4_input when a packet is received that + * is not destined for us. In this case, the packet may need to be + * forwarded to another device (or sent back out the same device) + * depending configuration, routing table information, and the IPv4 + * networks served by various network devices. + * + * Input Parameters: + * dev - The device on which the packet was received and which contains + * the IPv4 packet. + * ipv4 - A convenience pointer to the IPv4 header in within the IPv4 + * packet + * + * On input: + * - dev->d_buf holds the received packet. + * - dev->d_len holds the length of the received packet MINUS the + * size of the L1 header. That was subtracted out by ipv4_input. + * - ipv4 points to the IPv4 header with dev->d_buf. + * + * Returned Value: + * Zero is returned if the packet was successfully forward; A negated + * errno value is returned if the packet is not forwardable. In that + * latter case, the caller (ipv4_input()) should drop the packet. + * + ****************************************************************************/ + +#ifdef CONFIG_NET_IPv4 +int ipv4_forward(FAR struct net_driver_s *dev, FAR struct ipv4_hdr_s *ipv4); +#endif + +/**************************************************************************** + * Name: ipv6_forward + * + * Description: + * This function is called from ipv6_input when a packet is received that + * is not destined for us. In this case, the packet may need to be + * forwarded to another device (or sent back out the same device) + * depending configuration, routing table information, and the IPv6 + * networks served by various network devices. + * + * Input Parameters: + * dev - The device on which the packet was received and which contains + * the IPv6 packet. + * ipv6 - A convenience pointer to the IPv6 header in within the IPv6 + * packet + * + * Returned Value: + * Zero is returned if the packet was successfully forward; A negated + * errno value is returned if the packet is not forwardable. In that + * latter case, the caller (ipv6_input()) should drop the packet. + * + ****************************************************************************/ + +#ifdef CONFIG_NET_IPv6 +int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6); +#endif + +#endif /* CONFIG_NET_IPFORWARD */ #endif /* __NET_DEVIF_IP_FORWARD_H */ diff --git a/net/devif/ipv4_forward.c b/net/devif/ipv4_forward.c index ef8e8f971f..500e040f19 100644 --- a/net/devif/ipv4_forward.c +++ b/net/devif/ipv4_forward.c @@ -49,6 +49,7 @@ #include #include "netdev/netdev.h" +#include "utils/utils.h" #include "sixlowpan/sixlowpan.h" #include "udp/udp.h" #include "tcp/tcp.h" @@ -122,6 +123,119 @@ static int ipv4_hdrsize(FAR struct ipv4_hdr_s *ipv4) } #endif +/**************************************************************************** + * Name: ipv4_decr_ttl + * + * Description: + * Decrement the IPv4 TTL (time to live value). TTL field is set by the + * sender of the packet and reduced by every router on the route to its + * destination. If the TTL field reaches zero before the datagram arrives + * at its destination, then the datagram is discarded and an ICMP error + * packet (11 - Time Exceeded) is sent back to the sender. + * + * The purpose of the TTL field is to avoid a situation in which an + * undeliverable datagram keeps circulating on an Internet system, and + * such a system eventually becoming swamped by such "immortals". + * + * Input Parameters: + * ipv4 - A pointer to the IPv4 header in within the IPv4 packet to be + * forwarded. + * + * Returned Value: + * The new TTL value is returned. A value <= 0 means the hop limit has + * expired. + * + ****************************************************************************/ + +static int ipv4_decr_ttl(FAR struct ipv4_hdr_s *ipv4) +{ + uint16_t sum; + int ttl = (int)ipv4->ttl - 1; + + if (ttl <= 0) + { +#ifdef CONFIG_NET_ICMP + /* Return an ICMP error packet back to the sender. */ +#warning Missing logic +#endif + + /* Return zero which must cause the packet to be dropped */ + + return 0; + } + + /* Save the updated TTL value */ + + ipv4->ttl = ttl; + + /* Re-calculate the IPv4 checksum. This checksum is the Internet checksum + * of the 20 bytes of the IPv4 header. This checksum will be different + * because we just modify the IPv4 TTL. + */ + + ipv4->ipchksum = 0; + sum = chksum(0, (FAR const uint8_t *)ipv4, IPv4_HDRLEN); + if (sum == 0) + { + sum = 0xffff; + } + else + { + sum = htons(sum); + } + + ipv4->ipchksum = ~sum; + return ttl; +} + +/**************************************************************************** + * Name: ipv4_dropstats + * + * Description: + * Update statistics for a dropped packet. + * + * Input Parameters: + * ipv4 - A convenience pointer to the IPv4 header in within the IPv4 + * packet to be dropped. + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_NET_STATISTICS +static void ipv4_dropstats(FAR struct ipv4_hdr_s *ipv4) +{ + switch (ipv4->proto) + { +#ifdef CONFIG_NET_TCP + case IP_PROTO_TCP: + g_netstats.tcp.drop++; + break; +#endif + +#ifdef CONFIG_NET_UDP + case IP_PROTO_UDP: + g_netstats.udp.drop++; + break; +#endif + +#ifdef CONFIG_NET_ICMP + case IP_PROTO_ICMP: + g_netstats.icmp.drop++; + break; +#endif + + default: + break; + } + + g_netstats.ipv4.drop++; +} +#else +# define ipv4_dropstats(ipv4) +#endif + /**************************************************************************** * Name: ipv4_dev_forward * @@ -210,9 +324,22 @@ static int ipv4_dev_forward(FAR struct net_driver_s *dev, goto errout_with_fwd; } - memcpy(&fwd->f_hdr, ipv4, hdrsize); + memcpy(&fwd->f_hdr.ipv4, ipv4, hdrsize); fwd->f_hdrsize = hdrsize; + /* Decrement the TTL in the copy of the IPv4 header (retaining the + * original TTL in the source). If it decrements to zero, then drop + * the packet. + */ + + ret = ipv4_decr_ttl(&fwd->f_hdr.ipv4.l2); + if (ret < 1) + { + nwarn("WARNING: Hop limit exceeded... Dropping!\n"); + ret = -EMULTIHOP; + goto errout_with_fwd; + } + /* Use the L2 + L3 header size to determine start and size of the data * payload. * @@ -317,103 +444,59 @@ errout: #endif /* CONFIG_NETDEV_MULTINIC */ /**************************************************************************** - * Name: ipv4_decr_ttl + * Name: ipv4_forward_callback * * Description: - * Decrement the IPv4 TTL (time to live value). TTL field is set by the - * sender of the packet and reduced by every router on the route to its - * destination. If the TTL field reaches zero before the datagram arrives - * at its destination, then the datagram is discarded and an ICMP error - * packet (11 - Time Exceeded) is sent back to the sender. - * - * The purpose of the TTL field is to avoid a situation in which an - * undeliverable datagram keeps circulating on an Internet system, and - * such a system eventually becoming swamped by such "immortals". + * This function is a callback from netdev_foreach. It implements the + * the broadcase forwarding action for each network device (other than, of + * course, the device that received the packet). * * Input Parameters: - * ipv4 - A pointer to the IPv4 header in within the IPv4 packet to be - * forwarded. + * dev - The device on which the packet was received and which contains + * the IPv4 packet. + * ipv4 - A convenience pointer to the IPv4 header in within the IPv4 + * packet * * Returned Value: - * The new TTL value is returned. A value <= 0 means the hop limit has - * expired. + * Typically returns zero (meaning to continue the enumeration), but will + * return a non-zero to stop the enumeration if an error occurs. * ****************************************************************************/ -static int ipv4_decr_ttl(FAR struct ipv4_hdr_s *ipv4) +#if defined(CONFIG_NET_IPFORWARD_BROADCAST) && \ + defined(CONFIG_NETDEV_MULTINIC) +int ipv4_forward_callback(FAR struct net_driver_s *fwddev, FAR void *arg) { - int ttl = (int)ipv4->ttl - 1; + FAR struct net_driver_s *dev = (FAR struct net_driver_s *)arg; + FAR struct ipv4_hdr_s *ipv4; + int ret; - if (ttl <= 0) - { -#ifdef CONFIG_NET_ICMP - /* Return an ICMP error packet back to the sender. */ -#warning Missing logic -#endif + DEBUGASSERT(fwddev != NULL && dev != NULL && dev->d_buf != NULL); - /* Return zero which must cause the packet to be dropped */ - - return 0; - } - - /* Save the updated TTL value */ - - ipv4->ttl = ttl; - - /* NOTE: We do not have to recalculate the IPv4 checksum because (1) the - * IPv4 header does not include a checksum itself and (2) the TTL is not - * included in the sum for the TCP and UDP headers. + /* Check if we are forwarding on the same device that we received the + * packet from. */ - return ttl; -} - -/**************************************************************************** - * Name: ipv4_dropstats - * - * Description: - * Update statistics for a dropped packet. - * - * Input Parameters: - * ipv4 - A convenience pointer to the IPv4 header in within the IPv4 - * packet to be dropped. - * - * Returned Value: - * None - * - ****************************************************************************/ - -#ifdef CONFIG_NET_STATISTICS -static void ipv4_dropstats(FAR struct ipv4_hdr_s *ipv4) -{ - switch (ipv4->proto) + if (fwddev != dev) { -#ifdef CONFIG_NET_TCP - case IP_PROTO_TCP: - g_netstats.tcp.drop++; - break; -#endif + /* Recover the pointer to the IPv4 header in the receiving device's + * d_buf. + */ -#ifdef CONFIG_NET_UDP - case IP_PROTO_UDP: - g_netstats.udp.drop++; - break; -#endif + ipv4 = (FAR struct ipv4_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)]; -#ifdef CONFIG_NET_ICMP - case IP_PROTO_ICMP: - g_netstats.icmp.drop++; - break; -#endif + /* Send the packet asynchrously on the forwarding device. */ - default: - break; + ret = ipv4_dev_forward(dev, fwddev, ipv4); + if (ret < 0) + { + nwarn("WARNING: ipv4_dev_forward failed: %d\n", ret); + return ret; + } } - g_netstats.ipv4.drop++; + return OK; } -#else -# define ipv4_dropstats(ipv4) #endif /**************************************************************************** @@ -458,24 +541,6 @@ int ipv4_forward(FAR struct net_driver_s *dev, FAR struct ipv4_hdr_s *ipv4) FAR struct net_driver_s *fwddev; int ret; - /* Decrement the TTL. If it decrements to zero, then drop the packet */ - - ret = ipv4_decr_ttl(ipv4); - if (ret < 1) - { - nwarn("WARNING: Hop limit exceeded... Dropping!\n"); - ret = -EMULTIHOP; - goto drop; - } - - /* Re-calculate the IPv4 checksum. This checksum is the Internet checksum - * of the 20 bytes of the IPv4 header. This checksum will be different - * because we just modify the IPv4 TTL. - */ - - ipv4->ipchksum = 0; - ipv4->ipchksum = ~ipv4_chksum(dev); - /* Search for a device that can forward this packet. This is a trivial * search if there is only a single network device (CONFIG_NETDEV_MULTINIC * not defined). But netdev_findby_ipv4addr() will still assure @@ -508,7 +573,7 @@ int ipv4_forward(FAR struct net_driver_s *dev, FAR struct ipv4_hdr_s *ipv4) ret = ipv4_dev_forward(dev, fwddev, ipv4); if (ret < 0) { - nwarn("WARNING: ipv4_dev_forward faield: %d\n", ret); + nwarn("WARNING: ipv4_dev_forward failed: %d\n", ret); goto drop; } } @@ -550,4 +615,48 @@ drop: return ret; } +/**************************************************************************** + * Name: ipv4_forward_broadcast + * + * Description: + * This function is called from ipv4_input when a broadcast or multicast + * packet is received. If CONFIG_NET_IPFORWARD_BROADCAST is enabled, this + * function will forward the broadcast packet to other networks through + * other network devices. + * + * Input Parameters: + * dev - The device on which the packet was received and which contains + * the IPv4 packet. + * ipv4 - A convenience pointer to the IPv4 header in within the IPv4 + * packet + * + * On input: + * - dev->d_buf holds the received packet. + * - dev->d_len holds the length of the received packet MINUS the + * size of the L1 header. That was subtracted out by ipv4_input. + * - ipv4 points to the IPv4 header with dev->d_buf. + * + * Returned Value: + * None + * + ****************************************************************************/ + +#if defined(CONFIG_NET_IPFORWARD_BROADCAST) && \ + defined(CONFIG_NETDEV_MULTINIC) +void ipv4_forward_broadcast(FAR struct net_driver_s *dev, + FAR struct ipv4_hdr_s *ipv4) +{ + /* Don't bother if the TTL would expire */ + + if (ipv4->ttl > 1) + { + /* Forward the the broadcast/multicast packet to all devices except, + * of course, the device that received the packet. + */ + + (void)netdev_foreach(ipv4_forward_callback, dev); + } +} +#endif + #endif /* CONFIG_NET_IPFORWARD && CONFIG_NET_IPv4 */ diff --git a/net/devif/ipv4_input.c b/net/devif/ipv4_input.c index c2f9fcb2ca..018f747dc0 100644 --- a/net/devif/ipv4_input.c +++ b/net/devif/ipv4_input.c @@ -99,6 +99,7 @@ #include "icmp/icmp.h" #include "igmp/igmp.h" +#include "devif/ip_forward.h" #include "devif/devif.h" /**************************************************************************** @@ -403,6 +404,11 @@ int ipv4_input(FAR struct net_driver_s *dev) net_ipv4addr_cmp(net_ip4addr_conv32(ipv4->destipaddr), INADDR_BROADCAST)) { +#ifdef CONFIG_NET_IPFORWARD_BROADCAST + /* Forward broadcast packets */ + + ipv4_forward_broadcast(dev, ipv4); +#endif return udp_ipv4_input(dev); } @@ -430,7 +436,15 @@ int ipv4_input(FAR struct net_driver_s *dev) #ifdef CONFIG_NET_IGMP in_addr_t destip = net_ip4addr_conv32(ipv4->destipaddr); - if (igmp_grpfind(dev, &destip) == NULL) + if (igmp_grpfind(dev, &destip) != NULL) + { +#ifdef CONFIG_NET_IPFORWARD_BROADCAST + /* Forward multicast packets */ + + ipv4_forward_broadcast(dev, ipv4); +#endif + } + else #endif { /* No.. The packet is not destined for us. */ diff --git a/net/devif/ipv6_forward.c b/net/devif/ipv6_forward.c index 222099e5a7..17fb197c93 100644 --- a/net/devif/ipv6_forward.c +++ b/net/devif/ipv6_forward.c @@ -186,6 +186,106 @@ static int ipv6_hdrsize(FAR struct ipv6_hdr_s *ipv6) } #endif +/**************************************************************************** + * Name: ipv6_decr_ttl + * + * Description: + * Decrement the IPv6 TTL (time to live value). TTL field is set by the + * sender of the packet and reduced by every router on the route to its + * destination. If the TTL field reaches zero before the datagram arrives + * at its destination, then the datagram is discarded and an ICMP error + * packet (11 - Time Exceeded) is sent back to the sender. + * + * The purpose of the TTL field is to avoid a situation in which an + * undeliverable datagram keeps circulating on an Internet system, and + * such a system eventually becoming swamped by such "immortals". + * + * Input Parameters: + * ipv6 - A pointer to the IPv6 header in within the IPv6 packet to be + * forwarded. + * + * Returned Value: + * The new TTL value is returned. A value <= 0 means the hop limit has + * expired. + * + ****************************************************************************/ + +static int ipv6_decr_ttl(FAR struct ipv6_hdr_s *ipv6) +{ + int ttl = (int)ipv6->ttl - 1; + + if (ttl <= 0) + { +#ifdef CONFIG_NET_ICMPv6 + /* Return an ICMPv6 error packet back to the sender. */ +#warning Missing logic +#endif + + /* Return zero which must cause the packet to be dropped */ + + return 0; + } + + /* Save the updated TTL value */ + + ipv6->ttl = ttl; + + /* NOTE: We do not have to recalculate the IPv6 checksum because (1) the + * IPv6 header does not include a checksum itself and (2) the TTL is not + * included in the sum for the TCP and UDP headers. + */ + + return ttl; +} + +/**************************************************************************** + * Name: ipv6_dropstats + * + * Description: + * Update statistics for a dropped packet. + * + * Input Parameters: + * ipv6 - A convenience pointer to the IPv6 header in within the IPv6 + * packet to be dropped. + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_NET_STATISTICS +static void ipv6_dropstats(FAR struct ipv6_hdr_s *ipv6) +{ + switch (ipv6->proto) + { +#ifdef CONFIG_NET_TCP + case IP_PROTO_TCP: + g_netstats.tcp.drop++; + break; +#endif + +#ifdef CONFIG_NET_UDP + case IP_PROTO_UDP: + g_netstats.udp.drop++; + break; +#endif + +#ifdef CONFIG_NET_ICMPv6 + case IP_PROTO_ICMP6: + g_netstats.icmpv6.drop++; + break; +#endif + + default: + break; + } + + g_netstats.ipv6.drop++; +} +#else +# define ipv6_dropstats(ipv6) +#endif + /**************************************************************************** * Name: ipv6_dev_forward * @@ -280,9 +380,22 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, goto errout_with_fwd; } - memcpy(&fwd->f_hdr, ipv6, hdrsize); + memcpy(&fwd->f_hdr.ipv6, ipv6, hdrsize); fwd->f_hdrsize = hdrsize; + /* Decrement the TTL in the copy of the IPv6 header (retaining the + * original TTL in the source). If it decrements to zero, then drop + * the packet. + */ + + ret = ipv6_decr_ttl(&fwd->f_hdr.ipv6.l2); + if (ret < 1) + { + nwarn("WARNING: Hop limit exceeded... Dropping!\n"); + ret = -EMULTIHOP; + goto errout_with_fwd; + } + /* Use the L2 + L3 header size to determine start and size of the data * payload. * @@ -398,103 +511,59 @@ errout: #endif /* CONFIG_NETDEV_MULTINIC */ /**************************************************************************** - * Name: ipv6_decr_ttl + * Name: ipv6_forward_callback * * Description: - * Decrement the IPv6 TTL (time to live value). TTL field is set by the - * sender of the packet and reduced by every router on the route to its - * destination. If the TTL field reaches zero before the datagram arrives - * at its destination, then the datagram is discarded and an ICMP error - * packet (11 - Time Exceeded) is sent back to the sender. - * - * The purpose of the TTL field is to avoid a situation in which an - * undeliverable datagram keeps circulating on an Internet system, and - * such a system eventually becoming swamped by such "immortals". + * This function is a callback from netdev_foreach. It implements the + * the broadcase forwarding action for each network device (other than, of + * course, the device that received the packet). * * Input Parameters: - * ipv6 - A pointer to the IPv6 header in within the IPv6 packet to be - * forwarded. + * dev - The device on which the packet was received and which contains + * the IPv6 packet. + * ipv6 - A convenience pointer to the IPv6 header in within the IPv6 + * packet * * Returned Value: - * The new TTL value is returned. A value <= 0 means the hop limit has - * expired. + * Typically returns zero (meaning to continue the enumeration), but will + * return a non-zero to stop the enumeration if an error occurs. * ****************************************************************************/ -static int ipv6_decr_ttl(FAR struct ipv6_hdr_s *ipv6) +#if defined(CONFIG_NET_IPFORWARD_BROADCAST) && \ + defined(CONFIG_NETDEV_MULTINIC) +int ipv6_forward_callback(FAR struct net_driver_s *fwddev, FAR void *arg) { - int ttl = (int)ipv6->ttl - 1; + FAR struct net_driver_s *dev = (FAR struct net_driver_s *)arg; + FAR struct ipv6_hdr_s *ipv6; + int ret; - if (ttl <= 0) - { -#ifdef CONFIG_NET_ICMPv6 - /* Return an ICMPv6 error packet back to the sender. */ -#warning Missing logic -#endif + DEBUGASSERT(fwddev != NULL && dev != NULL && dev->d_buf != NULL); - /* Return zero which must cause the packet to be dropped */ - - return 0; - } - - /* Save the updated TTL value */ - - ipv6->ttl = ttl; - - /* NOTE: We do not have to recalculate the IPv6 checksum because (1) the - * IPv6 header does not include a checksum itself and (2) the TTL is not - * included in the sum for the TCP and UDP headers. + /* Check if we are forwarding on the same device that we received the + * packet from. */ - return ttl; -} - -/**************************************************************************** - * Name: ipv6_dropstats - * - * Description: - * Update statistics for a dropped packet. - * - * Input Parameters: - * ipv6 - A convenience pointer to the IPv6 header in within the IPv6 - * packet to be dropped. - * - * Returned Value: - * None - * - ****************************************************************************/ - -#ifdef CONFIG_NET_STATISTICS -static void ipv6_dropstats(FAR struct ipv6_hdr_s *ipv6) -{ - switch (ipv6->proto) + if (fwddev != dev) { -#ifdef CONFIG_NET_TCP - case IP_PROTO_TCP: - g_netstats.tcp.drop++; - break; -#endif + /* Recover the pointer to the IPv6 header in the receiving device's + * d_buf. + */ -#ifdef CONFIG_NET_UDP - case IP_PROTO_UDP: - g_netstats.udp.drop++; - break; -#endif + ipv6 = (FAR struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)]; -#ifdef CONFIG_NET_ICMPv6 - case IP_PROTO_ICMP6: - g_netstats.icmpv6.drop++; - break; -#endif + /* Send the packet asynchrously on the forwarding device. */ - default: - break; + ret = ipv6_dev_forward(dev, fwddev, ipv6); + if (ret < 0) + { + nwarn("WARNING: ipv6_dev_forward failed: %d\n", ret); + return ret; + } } - g_netstats.ipv6.drop++; + return OK; } -#else -# define ipv6_dropstats(ipv6) #endif /**************************************************************************** @@ -535,16 +604,6 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) FAR struct net_driver_s *fwddev; int ret; - /* Decrement the TTL. If it decrements to zero, then drop the packet */ - - ret = ipv6_decr_ttl(ipv6); - if (ret < 1) - { - nwarn("WARNING: Hop limit exceeded... Dropping!\n"); - ret = -EMULTIHOP; - goto drop; - } - /* Search for a device that can forward this packet. This is a trivial * search if there is only a single network device (CONFIG_NETDEV_MULTINIC * not defined). But netdev_findby_ipv6addr() will still assure @@ -574,7 +633,7 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) ret = ipv6_dev_forward(dev, fwddev, ipv6); if (ret < 0) { - nwarn("WARNING: ipv6_dev_forward faield: %d\n", ret); + nwarn("WARNING: ipv6_dev_forward failed: %d\n", ret); goto drop; } } @@ -641,4 +700,48 @@ drop: return ret; } +/**************************************************************************** + * Name: ipv6_forward_broadcast + * + * Description: + * This function is called from ipv6_input when a broadcast or multicast + * packet is received. If CONFIG_NET_IPFORWARD_BROADCAST is enabled, this + * function will forward the broadcast packet to other networks through + * other network devices. + * + * Input Parameters: + * dev - The device on which the packet was received and which contains + * the IPv6 packet. + * ipv6 - A convenience pointer to the IPv6 header in within the IPv6 + * packet + * + * On input: + * - dev->d_buf holds the received packet. + * - dev->d_len holds the length of the received packet MINUS the + * size of the L1 header. That was subtracted out by ipv6_input. + * - ipv6 points to the IPv6 header with dev->d_buf. + * + * Returned Value: + * None + * + ****************************************************************************/ + +#if defined(CONFIG_NET_IPFORWARD_BROADCAST) && \ + defined(CONFIG_NETDEV_MULTINIC) +void ipv6_forward_broadcast(FAR struct net_driver_s *dev, + FAR struct ipv6_hdr_s *ipv6) +{ + /* Don't bother if the TTL would expire */ + + if (ipv6->ttl > 1) + { + /* Forward the the broadcast/multicast packet to all devices except, + * of course, the device that received the packet. + */ + + (void)netdev_foreach(ipv6_forward_callback, dev); + } +} +#endif + #endif /* CONFIG_NET_IPFORWARD && CONFIG_NET_IPv6 */ diff --git a/net/devif/ipv6_input.c b/net/devif/ipv6_input.c index 4d656f3749..b74f104677 100644 --- a/net/devif/ipv6_input.c +++ b/net/devif/ipv6_input.c @@ -100,6 +100,7 @@ #include "icmpv6/icmpv6.h" #include "netdev/netdev.h" +#include "devif/ip_forward.h" #include "devif/devif.h" /**************************************************************************** @@ -183,6 +184,11 @@ static bool check_destipaddr(FAR struct net_driver_s *dev, if (ipv6->destipaddr[0] == HTONS(0xff02)) { +#ifdef CONFIG_NET_IPFORWARD_BROADCAST + /* Forward multicast packets */ + + ipv6_forward_broadcast(dev, ipv6); +#endif return true; } @@ -322,6 +328,11 @@ int ipv6_input(FAR struct net_driver_s *dev) if (ipv6->proto == IP_PROTO_UDP && net_ipv6addr_cmp(ipv6->destipaddr, g_ipv6_alloneaddr)) { +#ifdef CONFIG_NET_IPFORWARD_BROADCAST + /* Forward broadcast packets */ + + ipv6_forward_broadcast(dev, ipv6); +#endif return udp_ipv6_input(dev); } From efdc5b0c29de3e0091a6ce54af85384c9c9bc3a4 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 6 Jul 2017 07:49:55 -0600 Subject: [PATCH 08/31] IP forwarding: Add missing ICMP support. --- net/devif/ipv4_forward.c | 13 +- net/devif/ipv6_forward.c | 2 +- net/icmp/Make.defs | 8 + net/icmp/icmp_foward.c | 297 ++++++++++++++++++++++++++++++++++++ net/icmpv6/Make.defs | 2 +- net/icmpv6/icmpv6_forward.c | 76 +++------ 6 files changed, 335 insertions(+), 63 deletions(-) create mode 100644 net/icmp/icmp_foward.c diff --git a/net/devif/ipv4_forward.c b/net/devif/ipv4_forward.c index 500e040f19..90042e4fbc 100644 --- a/net/devif/ipv4_forward.c +++ b/net/devif/ipv4_forward.c @@ -156,7 +156,7 @@ static int ipv4_decr_ttl(FAR struct ipv4_hdr_s *ipv4) { #ifdef CONFIG_NET_ICMP /* Return an ICMP error packet back to the sender. */ -#warning Missing logic +# warning Missing logic #endif /* Return zero which must cause the packet to be dropped */ @@ -413,7 +413,16 @@ static int ipv4_dev_forward(FAR struct net_driver_s *dev, break; #endif - case IP_PROTO_ICMP: /* Not yet supported */ +#ifdef CONFIG_NET_ICMP + case IP_PROTO_ICMP: + { + /* Forward an ICMP packet */ + + ret = icmp_forward(fwd); + } + break; +#endif + default: nwarn("WARNING: Unrecognized proto: %u\n", ipv4->proto); ret = -EPROTONOSUPPORT; diff --git a/net/devif/ipv6_forward.c b/net/devif/ipv6_forward.c index 17fb197c93..aa3d8c248c 100644 --- a/net/devif/ipv6_forward.c +++ b/net/devif/ipv6_forward.c @@ -218,7 +218,7 @@ static int ipv6_decr_ttl(FAR struct ipv6_hdr_s *ipv6) { #ifdef CONFIG_NET_ICMPv6 /* Return an ICMPv6 error packet back to the sender. */ -#warning Missing logic +# warning Missing logic #endif /* Return zero which must cause the packet to be dropped */ diff --git a/net/icmp/Make.defs b/net/icmp/Make.defs index d5a67c2065..6b002964e4 100644 --- a/net/icmp/Make.defs +++ b/net/icmp/Make.defs @@ -43,6 +43,14 @@ ifeq ($(CONFIG_NET_ICMP_PING),y) NET_CSRCS += icmp_ping.c icmp_poll.c icmp_send.c endif +# IP forwarding + +ifeq ($(CONFIG_NET_IPFORWARD),y) +ifeq ($(CONFIG_NETDEV_MULTINIC),y) +NET_CSRCS += icmp_forward.c +endif +endif + # Include ICMP build support DEPPATH += --dep-path icmp diff --git a/net/icmp/icmp_foward.c b/net/icmp/icmp_foward.c new file mode 100644 index 0000000000..c46b626889 --- /dev/null +++ b/net/icmp/icmp_foward.c @@ -0,0 +1,297 @@ +/**************************************************************************** + * net/icmp/icmp_forward.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include "devif/ip_forward.h" +#include "devif/devif.h" +#include "netdev/netdev.h" +#include "arp/arp.h" +#include "neighbor/neighbor.h" +#include "icmp/icmp.h" + +#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_ICMP) && \ + defined(CONFIG_NETDEV_MULTINIC) + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: icmp_forward_addrchck + * + * Description: + * Check if the destination IP address is in the IPv4 ARP table. If not, + * then the send won't actually make it out... it will be replaced with an + * ARP request (IPv4). + * + * NOTE 1: This could be an expensive check if there are a lot of + * entries in the ARP table. + * + * NOTE 2: If we are actually harvesting IP addresses on incoming IP + * packets, then this check should not be necessary; the MAC mapping + * should already be in the ARP table in many cases. + * + * NOTE 3: If CONFIG_NET_ARP_SEND then we can be assured that the IP + * address mapping is already in the ARP table. + * + * Parameters: + * fwd - The forwarding state structure + * + * Returned Value: + * true - The Ethernet MAC address is in the ARP table (OR the network + * device is not Ethernet). + * + * Assumptions: + * The network is locked. + * + ****************************************************************************/ + +#ifdef CONFIG_NET_ETHERNET +static inline bool icmp_forward_addrchck(FAR struct forward_s *fwd) +{ + /* REVISIT: Could the MAC address not also be in a routing table? */ + +#ifdef CONFIG_NET_MULTILINK + if (fwd->f_dev->d_lltype != NET_LL_ETHERNET) + { + return true; + } +#endif + +#if !defined(CONFIG_NET_ARP_IPIN) && !defined(CONFIG_NET_ARP_SEND) + return (arp_find(fwd->f_hdr.ipv4.l2.destipaddr) != NULL); +#else + return true; +#endif +} + +#else /* CONFIG_NET_ETHERNET */ +# define icmp_forward_addrchck(fwd) (true) +#endif /* CONFIG_NET_ETHERNET */ + +/**************************************************************************** + * Name: icmp_dropstats + * + * Description: + * Update statistics for a dropped packet. + * + * Input Parameters: + * fwd - The forwarding state structure + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_NET_STATISTICS +static inline void icmp_dropstats(FAR struct forward_s *fwd) +{ + /* Increment the count of dropped ICMP packets */ + + g_netstats.icmp.drop++; + g_netstats.ipv4.drop++; +} +#else +# define icmp_dropstats(fwd) +#endif + +/**************************************************************************** + * Name: icmp_forward_interrupt + * + * Description: + * This function is called from the interrupt level to perform the actual + * send operation when polled by the lower, device interfacing layer. + * + * Parameters: + * dev The structure of the network driver that caused the interrupt + * conn An instance of the ICMP connection structure cast to void * + * pvpriv An instance of struct forward_s cast to void* + * flags Set of events describing why the callback was invoked + * + * Returned Value: + * Modified value of the input flags + * + * Assumptions: + * The network is locked + * + ****************************************************************************/ + +static uint16_t icmp_forward_interrupt(FAR struct net_driver_s *dev, + FAR void *conn, FAR void *pvpriv, + uint16_t flags) +{ + FAR struct forward_s *fwd = (FAR struct forward_s *)pvpriv; + + ninfo("flags: %04x\n", flags); + DEBUGASSERT(fwd != NULL); + + /* Make sure that this is from the forwarding device */ + + if (dev == fwd->f_dev) + { + /* If the network device has gone down, then we will have terminate + * the wait now with an error. + */ + + if ((flags & NETDEV_DOWN) != 0) + { + /* Terminate the transfer with an error. */ + + nwarn("WARNING: Network is down... Dropping\n"); + icmp_dropstats(fwd); + } + + /* Check if the outgoing packet is available. It may have been claimed + * by another send interrupt serving a different thread -OR- if the output + * buffer currently contains unprocessed incoming data. In these cases + * we will just have to wait for the next polling cycle. + */ + + else if (dev->d_sndlen > 0 || (flags & ICMP_NEWDATA) != 0) + { + /* Another thread has beat us sending data or the buffer is busy, + * Wait for the next polling cycle and check again. + */ + + return flags; + } + + /* It looks like we are good to forward the data */ + + else + { + /* Copy the ICMP data into driver's packet buffer and send it. */ + + devif_forward(fwd); + + /* Check if the destination IP address is in the ARP or Neighbor + * table. If not, then the send won't actually make it out... it + * will be replaced with an ARP request or Neighbor Solicitation. + */ + + if (!icmp_forward_addrchck(fwd)) + { + return flags; + } + } + + /* Free the allocated callback structure */ + + fwd->f_cb->flags = 0; + fwd->f_cb->priv = NULL; + fwd->f_cb->event = NULL; + + icmp_callback_free(dev, fwd->f_cb); + + /* Free any IOBs */ + + if (fwd->f_iob != NULL) + { + iob_free_chain(fwd->f_iob); + } + + /* And release the forwarding state structure */ + + ip_forward_free(fwd); + } + + return flags; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: icmp_forward + * + * Description: + * Called by the IP forwarding logic when an ICMP packet is received on + * one network device, but must be forwarded on another network device. + * + * Set up to forward the ICMP packet on the specified device. This + * function will set up a send "interrupt" handler that will perform the + * actual send asynchronously and must return without waiting for the + * send to complete. + * + * Input Parameters: + * fwd - An initialized instance of the common forwarding structure that + * includes everything needed to perform the forwarding operation. + * + * Returned Value: + * Zero is returned if the packet was successfully forwarded; A negated + * errno value is returned if the packet is not forwardable. In that + * latter case, the caller should free the IOB list and drop the packet. + * + ****************************************************************************/ + +int icmp_forward(FAR struct forward_s *fwd) +{ + DEBUGASSERT(fwd != NULL && fwd->f_dev != NULL); + + /* Set up the callback in the connection */ + + fwd->f_cb = icmp_callback_alloc(fwd->f_dev); + if (fwd->f_cb != NULL) + { + fwd->f_cb->flags = (ICMP_POLL | NETDEV_DOWN); + fwd->f_cb->priv = (FAR void *)fwd; + fwd->f_cb->event = icmp_forward_interrupt; + + /* Notify the device driver of the availability of TX data */ + + netdev_txnotify_dev(fwd->f_dev); + return OK; + } + + return -EBUSY; +} + +#endif /* CONFIG_NET_IPFORWARD && CONFIG_NET_ICMP && CONFIG_NETDEV_MULTINIC */ diff --git a/net/icmpv6/Make.defs b/net/icmpv6/Make.defs index 92ac9cf234..b8231151fc 100644 --- a/net/icmpv6/Make.defs +++ b/net/icmpv6/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # net/icmpv6/Make.defs # -# Copyright (C) 2015 Gregory Nutt. All rights reserved. +# Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without diff --git a/net/icmpv6/icmpv6_forward.c b/net/icmpv6/icmpv6_forward.c index 4004c3805d..f1a6f8cb3d 100644 --- a/net/icmpv6/icmpv6_forward.c +++ b/net/icmpv6/icmpv6_forward.c @@ -67,26 +67,22 @@ * Name: icmpv6_forward_addrchck * * Description: - * Check if the destination IP address is in the IPv4 ARP or IPv6 Neighbor - * tables. If not, then the send won't actually make it out... it will be - * replaced with an ARP request (IPv4) or a Neighbor Solicitation (IPv6). + * Check if the destination IP address is in the Pv6 Neighbor table. If + * not, then the send won't actually make it out... it will be replaced + * with a Neighbor Solicitation. * * NOTE 1: This could be an expensive check if there are a lot of - * entries in the ARP or Neighbor tables. + * entries in the Neighbor table. * - * NOTE 2: If we are actually harvesting IP addresses on incoming IP - * packets, then this check should not be necessary; the MAC mapping - * should already be in the ARP table in many cases (IPv4 only). - * - * NOTE 3: If CONFIG_NET_ARP_SEND then we can be assured that the IP + * NOTE 2: If CONFIG_NET_ARP_SEND then we can be assured that the IP * address mapping is already in the ARP table. * * Parameters: * fwd - The forwarding state structure * * Returned Value: - * true - The Ethernet MAC address is in the ARP or Neighbor table (OR - * the network device is not Ethernet). + * true - The Ethernet MAC address is in the Neighbor table (OR the + * network device is not Ethernet). * * Assumptions: * The network is locked. @@ -105,35 +101,15 @@ static inline bool icmpv6_forward_addrchck(FAR struct forward_s *fwd) } #endif -#ifdef CONFIG_NET_IPv4 -#ifdef CONFIG_NET_IPv6 - if ((fwd->f_hdr.ipv4.l2.vhl & IP_VERSION_MASK) == IPv4_VERSION) -#endif - { -#if !defined(CONFIG_NET_ARP_IPIN) && !defined(CONFIG_NET_ARP_SEND) - return (arp_find(fwd->f_hdr.ipv4.l2.destipaddr) != NULL); -#else - return true; -#endif - } -#endif /* CONFIG_NET_IPv4 */ - -#ifdef CONFIG_NET_IPv6 -#ifdef CONFIG_NET_IPv4 - else -#endif - { #if !defined(CONFIG_NET_ICMPv6_NEIGHBOR) - return (neighbor_findentry(fwd->f_hdr.ipv6.l2.destipaddr) != NULL); + return (neighbor_findentry(fwd->f_hdr.ipv6.l2.destipaddr) != NULL); #else - return true; + return true; #endif - } -#endif /* CONFIG_NET_IPv6 */ } #else /* CONFIG_NET_ETHERNET */ -# define icmpv6_forward_addrchck(r) (true) +# define icmpv6_forward_addrchck(fwd) (true) #endif /* CONFIG_NET_ETHERNET */ /**************************************************************************** @@ -151,33 +127,15 @@ static inline bool icmpv6_forward_addrchck(FAR struct forward_s *fwd) ****************************************************************************/ #ifdef CONFIG_NET_STATISTICS -static void icmpv6_dropstats(FAR struct forward_s *fwd) +static inline void icmpv6_dropstats(FAR struct forward_s *fwd) { - /* Increment the count of dropped ICMPV6 packets */ + /* Increment the count of dropped ICMPv6 packets */ g_netstats.icmpv6.drop++; - - /* Increment the count of dropped IPv4 or IPv6 packets */ - -#ifdef CONFIG_NET_IPv4 -#ifdef CONFIG_NET_IPv6 - if ((fwd->f_hdr.ipv4.l2.vhl & IP_VERSION_MASK) == IPv4_VERSION) -#endif - { - g_netstats.ipv4.drop++; - } -#endif -#ifdef CONFIG_NET_IPv6 -#ifdef CONFIG_NET_IPv4 - else -#endif - { - g_netstats.ipv6.drop++; - } -#endif + g_netstats.ipv6.drop++; } #else -# define icmpv6_dropstats(ipv6) +# define icmpv6_dropstats(fwd) #endif /**************************************************************************** @@ -189,7 +147,7 @@ static void icmpv6_dropstats(FAR struct forward_s *fwd) * * Parameters: * dev The structure of the network driver that caused the interrupt - * conn An instance of the ICMPV6 connection structure cast to void * + * conn An instance of the ICMPv6 connection structure cast to void * * pvpriv An instance of struct forward_s cast to void* * flags Set of events describing why the callback was invoked * @@ -291,10 +249,10 @@ static uint16_t icmpv6_forward_interrupt(FAR struct net_driver_s *dev, * Name: icmpv6_forward * * Description: - * Called by the IP forwarding logic when an ICMPV6 packet is received on + * Called by the IP forwarding logic when an ICMPv6 packet is received on * one network device, but must be forwarded on another network device. * - * Set up to forward the ICMPV6 packet on the specified device. This + * Set up to forward the ICMPv6 packet on the specified device. This * function will set up a send "interrupt" handler that will perform the * actual send asynchronously and must return without waiting for the * send to complete. From 165ee0027a2d7f4dd48baf46197484ba2eb2d1c4 Mon Sep 17 00:00:00 2001 From: Julien Lecoeur Date: Thu, 6 Jul 2017 08:32:31 -0600 Subject: [PATCH 09/31] Eliminate a warning with arm-none-eabi-gcc 7.1.0 --- drivers/mmcsd/mmcsd_spi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/mmcsd/mmcsd_spi.c b/drivers/mmcsd/mmcsd_spi.c index 7bf4ecdee1..0ee84bb55b 100644 --- a/drivers/mmcsd/mmcsd_spi.c +++ b/drivers/mmcsd/mmcsd_spi.c @@ -326,7 +326,9 @@ static const struct mmcsd_cmdinfo_s g_cmd0 = {CMD0, MMCSD_CMDRESP_R1, 0x95}; static const struct mmcsd_cmdinfo_s g_cmd1 = {CMD1, MMCSD_CMDRESP_R1, 0xff}; static const struct mmcsd_cmdinfo_s g_cmd8 = {CMD8, MMCSD_CMDRESP_R7, 0x87}; static const struct mmcsd_cmdinfo_s g_cmd9 = {CMD9, MMCSD_CMDRESP_R1, 0xff}; +#if 0 /* Not used */ static const struct mmcsd_cmdinfo_s g_cmd10 = {CMD10, MMCSD_CMDRESP_R1, 0xff}; +#endif static const struct mmcsd_cmdinfo_s g_cmd12 = {CMD12, MMCSD_CMDRESP_R1, 0xff}; static const struct mmcsd_cmdinfo_s g_cmd16 = {CMD16, MMCSD_CMDRESP_R1, 0xff}; static const struct mmcsd_cmdinfo_s g_cmd17 = {CMD17, MMCSD_CMDRESP_R1, 0xff}; From 94f26828e9d6ab833f763a2fe89f68f3e2e51ec5 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 6 Jul 2017 09:45:52 -0600 Subject: [PATCH 10/31] Fix a TTL-related issue introduced with last commit. --- net/devif/ipv4_forward.c | 3 + net/devif/ipv6_forward.c | 190 ++++++++++++++++++++++++++------------- 2 files changed, 130 insertions(+), 63 deletions(-) diff --git a/net/devif/ipv4_forward.c b/net/devif/ipv4_forward.c index 90042e4fbc..6487a5fff8 100644 --- a/net/devif/ipv4_forward.c +++ b/net/devif/ipv4_forward.c @@ -147,6 +147,7 @@ static int ipv4_hdrsize(FAR struct ipv4_hdr_s *ipv4) * ****************************************************************************/ +#ifdef CONFIG_NETDEV_MULTINIC static int ipv4_decr_ttl(FAR struct ipv4_hdr_s *ipv4) { uint16_t sum; @@ -187,6 +188,7 @@ static int ipv4_decr_ttl(FAR struct ipv4_hdr_s *ipv4) ipv4->ipchksum = ~sum; return ttl; } +#endif /**************************************************************************** * Name: ipv4_dropstats @@ -227,6 +229,7 @@ static void ipv4_dropstats(FAR struct ipv4_hdr_s *ipv4) #endif default: + g_netstats.ipv4.protoerr++; break; } diff --git a/net/devif/ipv6_forward.c b/net/devif/ipv6_forward.c index aa3d8c248c..055968c7fb 100644 --- a/net/devif/ipv6_forward.c +++ b/net/devif/ipv6_forward.c @@ -59,73 +59,16 @@ #if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_IPv6) /**************************************************************************** - * Private Functions + * Pre-processor Definitions ****************************************************************************/ +#define PACKET_FORWARDED 0 +#define PACKET_NOT_FORWARDED 1 + /**************************************************************************** - * Name: ipv6_packet_conversion - * - * Description: - * Generic output conversion hook. Only needed for IEEE802.15.4 for now - * but this is a point where support for other conversions may be - * provided. - * + * Private Functions ****************************************************************************/ -#ifdef CONFIG_NET_6LOWPAN -static int ipv6_packet_conversion(FAR struct net_driver_s *dev, - FAR struct net_driver_s *fwddev, - FAR struct ipv6_hdr_s *ipv6) -{ -#ifdef CONFIG_NET_MULTILINK - /* Handle the case where multiple link layer protocols are supported */ - - if (dev->d_len > 0 && fwddev->d_lltype == NET_LL_IEEE802154) -#else - if (dev->d_len > 0) -#endif - { -#ifdef CONFIG_NET_TCP - if (ipv6->proto == IP_PROTO_TCP) - { - /* Let 6LoWPAN convert IPv6 TCP output into IEEE802.15.4 frames. */ - - sixlowpan_tcp_send(dev, fwddev, ipv6); - } - else -#endif -#ifdef CONFIG_NET_UDP - if (ipv6->proto == IP_PROTO_UDP) - { - /* Let 6LoWPAN convert IPv6 UDP output into IEEE802.15.4 frames. */ - - sixlowpan_udp_send(dev, fwddev, ipv6); - } - else -#endif - { - /* Otherwise, we will have to drop the packet */ - - nwarn("WARNING: Dropping. Unsupported 6LoWPAN protocol: %d\n", - ipv6->proto); - -#ifdef CONFIG_NET_STATISTICS - g_netstats.ipv6.drop++; -#endif - return -EPROTONOSUPPORT; - } - - dev->d_len = 0; - return OK; - } - - nwarn("WARNING: Dropping. Unsupported link layer\n"); - return -EPFNOSUPPORT; -} -#else -# define ipv6_packet_conversion(dev, ipv6) -#endif /* CONFIG_NET_6LOWPAN */ - /**************************************************************************** * Name: ipv6_hdrsize * @@ -210,6 +153,7 @@ static int ipv6_hdrsize(FAR struct ipv6_hdr_s *ipv6) * ****************************************************************************/ +#if defined(CONFIG_NETDEV_MULTINIC) || defined(CONFIG_NET_6LOWPAN) static int ipv6_decr_ttl(FAR struct ipv6_hdr_s *ipv6) { int ttl = (int)ipv6->ttl - 1; @@ -237,6 +181,7 @@ static int ipv6_decr_ttl(FAR struct ipv6_hdr_s *ipv6) return ttl; } +#endif /**************************************************************************** * Name: ipv6_dropstats @@ -277,6 +222,7 @@ static void ipv6_dropstats(FAR struct ipv6_hdr_s *ipv6) #endif default: + g_netstats.ipv6.protoerr++; break; } @@ -286,6 +232,114 @@ static void ipv6_dropstats(FAR struct ipv6_hdr_s *ipv6) # define ipv6_dropstats(ipv6) #endif +/**************************************************************************** + * Name: ipv6_packet_conversion + * + * Description: + * Generic output conversion hook. Only needed for IEEE802.15.4 for now + * but this is a point where support for other conversions may be + * provided. + * + * Returned value: + * PACKET_FORWARDED - Packet was forwarded + * PACKET_NOT_FORWARDED - Packet was not forwarded + * < 0 - And error occurred (and packet not fowarded). + * + ****************************************************************************/ + +#ifdef CONFIG_NET_6LOWPAN +static int ipv6_packet_conversion(FAR struct net_driver_s *dev, + FAR struct net_driver_s *fwddev, + FAR struct ipv6_hdr_s *ipv6) +{ + int ret = PACKET_NOT_FORWARDED; + + if (dev->d_len > 0) + { +#ifdef CONFIG_NET_MULTILINK + /* Handle the case where multiple link layer protocols are supported */ + + if (fwddev->d_lltype == NET_LL_IEEE802154) + { + nwarn("WARNING: Unsupported link layer... Not forwarded\n"); + } + else +#endif +#ifdef CONFIG_NET_TCP + if (ipv6->proto == IP_PROTO_TCP) + { + /* Decrement the TTL in the IPv6 header. If it decrements to + * zero, then drop the packet. + */ + + ret = ipv6_decr_ttl(ipv6); + if (ret < 1) + { + nwarn("WARNING: Hop limit exceeded... Dropping!\n"); + ret = -EMULTIHOP; + } + else + { + /* Let 6LoWPAN convert IPv6 TCP output into IEEE802.15.4 + * frames. + */ + + sixlowpan_tcp_send(dev, fwddev, ipv6); + + /* The packet was forwarded */ + + dev->d_len = 0; + return PACKET_FORWARDED; + } + } + else +#endif +#ifdef CONFIG_NET_UDP + if (ipv6->proto == IP_PROTO_UDP) + { + /* Decrement the TTL in the IPv6 header. If it decrements to + * zero, then drop the packet. + */ + + ret = ipv6_decr_ttl(ipv6); + if (ret < 1) + { + nwarn("WARNING: Hop limit exceeded... Dropping!\n"); + ret = -EMULTIHOP; + } + else + { + /* Let 6LoWPAN convert IPv6 UDP output into IEEE802.15.4 + * frames. + */ + + sixlowpan_udp_send(dev, fwddev, ipv6); + + /* The packet was forwarded */ + + dev->d_len = 0; + return PACKET_FORWARDED; + } + } + else +#endif + { + /* Otherwise, we cannot forward the packet */ + + nwarn("WARNING: Dropping. Unsupported 6LoWPAN protocol: %d\n", + ipv6->proto); + } + } + + /* The packet was not forwarded (or the HOP limit was exceeded) */ + + ipv6_dropstats(ipv6); + return ret; +} +#else +# define ipv6_packet_conversion(dev, ipv6) (PACKET_NOT_FORWARDED) +#endif /* CONFIG_NET_6LOWPAN */ + /**************************************************************************** * Name: ipv6_dev_forward * @@ -302,7 +356,7 @@ static void ipv6_dropstats(FAR struct ipv6_hdr_s *ipv6) * ipv6 - A pointer to the IPv6 header in within the IPv6 packet * * Returned Value: - * Zero is returned if the packet was successfully forward; A negated + * Zero is returned if the packet was successfully forwarded; A negated * errno value is returned if the packet is not forwardable. In that * latter case, the caller (ipv6_input()) should drop the packet. * @@ -321,6 +375,11 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, ret = ipv6_packet_conversion(dev, fwddev, ipv6); if (ret < 0) + { + nwarn("WARNING: ipv6_packet_conversion failed: %d\n", ret); + goto errout; + } + else if (ret == PACKET_NOT_FORWARDED) { FAR uint8_t *payload; unsigned int paysize; @@ -657,6 +716,11 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) ret = ipv6_packet_conversion(dev, dev, ipv6); if (ret < 0) { + nwarn("WARNING: ipv6_packet_conversion failed: %d\n", ret); + goto drop; + } + else if (ret == PACKET_NOT_FORWARDED) + { #ifdef CONFIG_NET_ETHERNET /* REVISIT: For Ethernet we may have to fix up the Ethernet header: * - source MAC, the MAC of the current device. From 15b85738e7b5b9df6377f56e2a6a629346f87964 Mon Sep 17 00:00:00 2001 From: "gwenhael.goavec" Date: Thu, 6 Jul 2017 09:52:21 -0600 Subject: [PATCH 11/31] In arch/arm/src/stm32/Kconfig when the CPU is a STM32F4, some STM32_HAVE_xx with xx = {OTGFS, TIM3, TIM4, SPI3, I2S3, I2C3} are selected by default. But for F410 these peripherals are absent. This change add tests to check if the target CPU is an F410 or not and selects according to the situation. This also adds a select for STM32_HAVE_DAC1 present on this STM32 flavor. --- arch/arm/src/stm32/Kconfig | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/arm/src/stm32/Kconfig b/arch/arm/src/stm32/Kconfig index ba6bdb4b79..514555cf82 100644 --- a/arch/arm/src/stm32/Kconfig +++ b/arch/arm/src/stm32/Kconfig @@ -1525,14 +1525,14 @@ config STM32_STM32F37XX config STM32_STM32F40XX bool default n - select STM32_HAVE_OTGFS - select STM32_HAVE_TIM3 - select STM32_HAVE_TIM4 + select STM32_HAVE_OTGFS if !STM32_STM32F410 + select STM32_HAVE_TIM3 if !STM32_STM32F410 + select STM32_HAVE_TIM4 if !STM32_STM32F410 select STM32_HAVE_SPI2 - select STM32_HAVE_SPI3 - select STM32_HAVE_I2S3 + select STM32_HAVE_SPI3 if !STM32_STM32F410 + select STM32_HAVE_I2S3 if !STM32_STM32F410 select STM32_HAVE_I2C2 - select STM32_HAVE_I2C3 + select STM32_HAVE_I2C3 if !STM32_STM32F410 config STM32_STM32F401 bool @@ -1557,6 +1557,7 @@ config STM32_STM32F410 select STM32_HAVE_TIM9 select STM32_HAVE_TIM11 select STM32_HAVE_SPI5 + select STM32_HAVE_DAC1 config STM32_STM32F411 bool From 47be509d797a012de40735e17d730891f72b3963 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 6 Jul 2017 10:20:14 -0600 Subject: [PATCH 12/31] Rename CONFIG_STM32_STM32F40XX to CONFIG_STM32_STM32FXXXX since it is used by F4 parts other than F40x --- arch/arm/include/stm32/chip.h | 136 +++++++++--------- arch/arm/include/stm32/irq.h | 2 +- arch/arm/src/stm32/Kconfig | 94 ++++++------ arch/arm/src/stm32/Make.defs | 2 +- arch/arm/src/stm32/chip.h | 4 +- arch/arm/src/stm32/chip/stm32_adc.h | 22 +-- arch/arm/src/stm32/chip/stm32_can.h | 12 +- arch/arm/src/stm32/chip/stm32_dbgmcu.h | 6 +- arch/arm/src/stm32/chip/stm32_eth.h | 16 +-- arch/arm/src/stm32/chip/stm32_exti.h | 4 +- arch/arm/src/stm32/chip/stm32_flash.h | 22 +-- arch/arm/src/stm32/chip/stm32_memorymap.h | 2 +- arch/arm/src/stm32/chip/stm32_pwr.h | 6 +- arch/arm/src/stm32/chip/stm32_spi.h | 18 +-- arch/arm/src/stm32/chip/stm32_tim.h | 8 +- arch/arm/src/stm32/chip/stm32f40xxx_syscfg.h | 4 +- arch/arm/src/stm32/gnu/stm32_vectors.S | 4 +- arch/arm/src/stm32/iar/stm32_vectors.S | 4 +- arch/arm/src/stm32/stm32_adc.c | 24 ++-- arch/arm/src/stm32/stm32_adc.h | 4 +- arch/arm/src/stm32/stm32_allocateheap.c | 2 +- arch/arm/src/stm32/stm32_bbsram.h | 2 +- arch/arm/src/stm32/stm32_can.c | 2 +- arch/arm/src/stm32/stm32_ccm.h | 2 +- arch/arm/src/stm32/stm32_dac.c | 10 +- arch/arm/src/stm32/stm32_dma.c | 2 +- arch/arm/src/stm32/stm32_dma.h | 6 +- arch/arm/src/stm32/stm32_dumpgpio.c | 2 +- arch/arm/src/stm32/stm32_eth.c | 8 +- arch/arm/src/stm32/stm32_flash.c | 26 ++-- arch/arm/src/stm32/stm32_fsmc.h | 2 +- arch/arm/src/stm32/stm32_gpio.c | 10 +- arch/arm/src/stm32/stm32_gpio.h | 4 +- arch/arm/src/stm32/stm32_i2c.c | 8 +- arch/arm/src/stm32/stm32_i2c_alt.c | 6 +- arch/arm/src/stm32/stm32_i2s.c | 6 +- arch/arm/src/stm32/stm32_iwdg.c | 2 +- arch/arm/src/stm32/stm32_lowputc.c | 2 +- arch/arm/src/stm32/stm32_pwm.c | 10 +- arch/arm/src/stm32/stm32_pwr.c | 2 +- arch/arm/src/stm32/stm32_pwr.h | 2 +- arch/arm/src/stm32/stm32_qencoder.c | 4 +- arch/arm/src/stm32/stm32_rcc.c | 2 +- arch/arm/src/stm32/stm32_rcc.h | 6 +- arch/arm/src/stm32/stm32_rtc.c | 2 +- arch/arm/src/stm32/stm32_rtc.h | 4 +- arch/arm/src/stm32/stm32_rtc_lowerhalf.c | 14 +- arch/arm/src/stm32/stm32_sdio.c | 10 +- arch/arm/src/stm32/stm32_serial.c | 10 +- arch/arm/src/stm32/stm32_spi.c | 6 +- arch/arm/src/stm32/stm32_syscfg.h | 2 +- arch/arm/src/stm32/stm32_tim_lowerhalf.c | 2 +- arch/arm/src/stm32/stm32_uart.h | 2 +- arch/arm/src/stm32/stm32_wwdg.c | 2 +- arch/arm/src/stm32/stm32f40xxx_dma.c | 4 +- arch/arm/src/stm32/stm32f40xxx_i2c.c | 6 +- configs/clicker2-stm32/knsh/defconfig | 2 +- .../clicker2-stm32/mrf24j40-6lowpan/defconfig | 2 +- configs/clicker2-stm32/mrf24j40-mac/defconfig | 2 +- .../clicker2-stm32/mrf24j40-starhub/defconfig | 2 +- .../mrf24j40-starpoint/defconfig | 2 +- configs/clicker2-stm32/nsh/defconfig | 2 +- configs/clicker2-stm32/usbnsh/defconfig | 2 +- configs/cloudctrl/nsh/defconfig | 2 +- configs/fire-stm32v2/nsh/defconfig | 2 +- configs/hymini-stm32v/nsh/defconfig | 2 +- configs/hymini-stm32v/nsh2/defconfig | 2 +- configs/hymini-stm32v/usbmsc/defconfig | 2 +- configs/hymini-stm32v/usbnsh/defconfig | 2 +- configs/hymini-stm32v/usbserial/defconfig | 2 +- configs/maple/nsh/defconfig | 2 +- configs/maple/nx/defconfig | 2 +- configs/maple/usbnsh/defconfig | 2 +- configs/mikroe-stm32f4/fulldemo/defconfig | 2 +- configs/mikroe-stm32f4/kostest/defconfig | 2 +- configs/mikroe-stm32f4/nsh/defconfig | 2 +- configs/mikroe-stm32f4/nx/defconfig | 2 +- configs/mikroe-stm32f4/nxlines/defconfig | 2 +- configs/mikroe-stm32f4/nxtext/defconfig | 2 +- configs/mikroe-stm32f4/usbnsh/defconfig | 2 +- configs/nucleo-f303re/adc/defconfig | 2 +- configs/nucleo-f303re/can/defconfig | 2 +- configs/nucleo-f303re/hello/defconfig | 2 +- configs/nucleo-f303re/nxlines/defconfig | 2 +- configs/nucleo-f303re/pwm/defconfig | 2 +- configs/nucleo-f303re/serialrx/defconfig | 2 +- configs/nucleo-f303re/uavcan/defconfig | 2 +- configs/nucleo-f334r8/adc/defconfig | 2 +- configs/nucleo-f334r8/nsh/defconfig | 2 +- .../nucleo-f4x1re/f401-nsh-clang/defconfig | 2 +- configs/nucleo-f4x1re/f401-nsh/defconfig | 2 +- configs/nucleo-f4x1re/f411-nsh/defconfig | 2 +- configs/olimex-stm32-e407/discover/defconfig | 2 +- configs/olimex-stm32-e407/netnsh/defconfig | 2 +- configs/olimex-stm32-e407/nsh/defconfig | 2 +- configs/olimex-stm32-e407/telnetd/defconfig | 2 +- configs/olimex-stm32-e407/usbnsh/defconfig | 2 +- configs/olimex-stm32-e407/webserver/defconfig | 2 +- configs/olimex-stm32-h405/usbnsh/defconfig | 2 +- configs/olimex-stm32-h407/nsh/defconfig | 2 +- configs/olimex-stm32-p107/nsh/defconfig | 2 +- configs/olimex-stm32-p207/nsh/defconfig | 2 +- configs/olimex-stm32-p407/knsh/defconfig | 2 +- configs/olimex-stm32-p407/nsh/defconfig | 2 +- configs/olimexino-stm32/can/defconfig | 2 +- configs/olimexino-stm32/composite/defconfig | 2 +- configs/olimexino-stm32/nsh/defconfig | 2 +- configs/olimexino-stm32/smallnsh/defconfig | 2 +- configs/olimexino-stm32/tiny/defconfig | 2 +- configs/photon/nsh/defconfig | 2 +- configs/photon/usbnsh/defconfig | 2 +- configs/photon/wlan/defconfig | 2 +- configs/shenzhou/nsh/defconfig | 2 +- configs/shenzhou/nxwm/defconfig | 2 +- configs/shenzhou/thttpd/defconfig | 2 +- configs/spark/composite/defconfig | 2 +- configs/spark/nsh/defconfig | 2 +- configs/spark/usbmsc/defconfig | 2 +- configs/spark/usbnsh/defconfig | 2 +- configs/spark/usbserial/defconfig | 2 +- configs/stm3210e-eval/composite/defconfig | 2 +- configs/stm3210e-eval/nsh/defconfig | 2 +- configs/stm3210e-eval/nsh2/defconfig | 2 +- configs/stm3210e-eval/nx/defconfig | 2 +- configs/stm3210e-eval/nxterm/defconfig | 2 +- configs/stm3210e-eval/pm/defconfig | 2 +- configs/stm3210e-eval/usbmsc/defconfig | 2 +- configs/stm3210e-eval/usbserial/defconfig | 2 +- configs/stm3220g-eval/dhcpd/defconfig | 2 +- configs/stm3220g-eval/nettest/defconfig | 2 +- configs/stm3220g-eval/nsh/defconfig | 2 +- configs/stm3220g-eval/nsh2/defconfig | 2 +- configs/stm3220g-eval/nxwm/defconfig | 2 +- configs/stm3220g-eval/telnetd/defconfig | 2 +- configs/stm3240g-eval/dhcpd/defconfig | 2 +- configs/stm3240g-eval/discover/defconfig | 2 +- configs/stm3240g-eval/knxwm/defconfig | 2 +- configs/stm3240g-eval/nettest/defconfig | 2 +- configs/stm3240g-eval/nsh/defconfig | 2 +- configs/stm3240g-eval/nsh2/defconfig | 2 +- configs/stm3240g-eval/nxterm/defconfig | 2 +- configs/stm3240g-eval/nxwm/defconfig | 2 +- configs/stm3240g-eval/telnetd/defconfig | 2 +- configs/stm3240g-eval/webserver/defconfig | 2 +- configs/stm3240g-eval/xmlrpc/defconfig | 2 +- configs/stm32_tiny/nsh/defconfig | 2 +- configs/stm32_tiny/usbnsh/defconfig | 2 +- configs/stm32butterfly2/nsh/defconfig | 2 +- configs/stm32butterfly2/nshnet/defconfig | 2 +- configs/stm32butterfly2/nshusbdev/defconfig | 2 +- configs/stm32butterfly2/nshusbhost/defconfig | 2 +- .../stm32f103-minimum/audio_tone/defconfig | 2 +- configs/stm32f103-minimum/buttons/defconfig | 2 +- configs/stm32f103-minimum/jlx12864g/defconfig | 2 +- configs/stm32f103-minimum/mcp2515/defconfig | 2 +- configs/stm32f103-minimum/nrf24/defconfig | 2 +- configs/stm32f103-minimum/nsh/defconfig | 2 +- configs/stm32f103-minimum/pwm/defconfig | 2 +- .../stm32f103-minimum/rfid-rc522/defconfig | 2 +- configs/stm32f103-minimum/rgbled/defconfig | 2 +- configs/stm32f103-minimum/usbnsh/defconfig | 2 +- configs/stm32f103-minimum/userled/defconfig | 2 +- configs/stm32f103-minimum/veml6070/defconfig | 2 +- configs/stm32f3discovery/nsh/defconfig | 2 +- configs/stm32f3discovery/usbnsh/defconfig | 2 +- configs/stm32f411e-disco/nsh/defconfig | 2 +- configs/stm32f429i-disco/extflash/defconfig | 2 +- configs/stm32f429i-disco/lcd/defconfig | 2 +- configs/stm32f429i-disco/ltdc/defconfig | 2 +- configs/stm32f429i-disco/nsh/defconfig | 2 +- configs/stm32f429i-disco/nxwm/defconfig | 2 +- configs/stm32f429i-disco/usbmsc/defconfig | 2 +- configs/stm32f429i-disco/usbnsh/defconfig | 2 +- configs/stm32f4discovery/canard/defconfig | 2 +- configs/stm32f4discovery/cxxtest/defconfig | 2 +- configs/stm32f4discovery/elf/defconfig | 2 +- configs/stm32f4discovery/ipv6/defconfig | 2 +- configs/stm32f4discovery/kostest/defconfig | 2 +- configs/stm32f4discovery/netnsh/defconfig | 2 +- configs/stm32f4discovery/nsh/defconfig | 2 +- configs/stm32f4discovery/nxlines/defconfig | 2 +- configs/stm32f4discovery/pm/defconfig | 2 +- .../stm32f4discovery/posix_spawn/defconfig | 2 +- configs/stm32f4discovery/pseudoterm/defconfig | 2 +- configs/stm32f4discovery/rgbled/defconfig | 2 +- configs/stm32f4discovery/uavcan/defconfig | 2 +- configs/stm32f4discovery/usbnsh/defconfig | 2 +- configs/stm32f4discovery/winbuild/defconfig | 2 +- configs/stm32f4discovery/xen1210/defconfig | 2 +- configs/stm32ldiscovery/nsh/defconfig | 2 +- configs/stm32vldiscovery/nsh/defconfig | 2 +- configs/viewtool-stm32f107/highpri/defconfig | 2 +- configs/viewtool-stm32f107/netnsh/defconfig | 2 +- configs/viewtool-stm32f107/nsh/defconfig | 2 +- 194 files changed, 431 insertions(+), 431 deletions(-) diff --git a/arch/arm/include/stm32/chip.h b/arch/arm/include/stm32/chip.h index a9eca2813f..bf3a742af6 100644 --- a/arch/arm/include/stm32/chip.h +++ b/arch/arm/include/stm32/chip.h @@ -92,7 +92,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 0 /* No advanced timers */ # define STM32_NGTIM 3 /* 16-bit general up/down timers TIM2-4 with DMA */ @@ -133,7 +133,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 0 /* No advanced timers */ # define STM32_NGTIM 3 /* 16-bit general up/down timers TIM2-4 with DMA */ @@ -174,7 +174,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 0 /* No advanced timers */ # define STM32_NGTIM 3 /* 16-bit general up/down timers TIM2-4 with DMA */ @@ -215,7 +215,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 0 /* No advanced timers */ # define STM32_NGTIM 3 /* 16-bit general up/down timers TIM2-4 with DMA */ @@ -256,7 +256,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 0 /* No advanced timers */ # define STM32_NGTIM 3 /* 16-bit general up/down timers TIM2-4 with DMA */ @@ -297,7 +297,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 0 /* No advanced timers */ # define STM32_NGTIM 3 /* 16-bit general up/down timers TIM2-4 with DMA */ @@ -337,7 +337,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 0 /* No advanced timers */ # define STM32_NGTIM 3 /* 16-bit general up/down timers TIM2-4 with DMA */ @@ -377,7 +377,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 0 /* No advanced timers */ # define STM32_NGTIM 3 /* 16-bit general up/down timers TIM2-4 with DMA */ @@ -417,7 +417,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 0 /* No advanced timers */ # define STM32_NGTIM 3 /* 16-bit general up/down timers TIM2-4 with DMA */ @@ -457,7 +457,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 0 /* No advanced timers */ # define STM32_NGTIM 4 /* 16-bit general timers TIM2-4 with DMA @@ -498,7 +498,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 0 /* No advanced timers */ # define STM32_NGTIM 4 /* 16-bit general timers TIM2-4 with DMA @@ -543,7 +543,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 1 /* One advanced timer TIM1 */ # define STM32_NGTIM 3 /* 16-bit general timers TIM2-4 with DMA */ @@ -582,7 +582,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* FSMC */ # define STM32_NATIM 1 /* One advanced timer TIM1 */ # define STM32_NGTIM 3 /* 16-bit general timers TIM2-4 with DMA */ @@ -624,7 +624,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* FSMC */ # define STM32_NATIM 1 /* One advanced timer TIM1 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM2-5 with DMA */ @@ -664,7 +664,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 1 /* One advanced timer TIM1 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM2-5 with DMA */ @@ -703,7 +703,7 @@ # undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */ # undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 0 /* No advanced timer TIM1 */ # define STM32_NGTIM 3 /* 16-bit general timers TIM2-4 */ @@ -743,7 +743,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* FSMC */ # define STM32_NATIM 1 /* One advanced timer TIM1 */ # define STM32_NGTIM 2 /* General timers TIM2,3 */ @@ -782,7 +782,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 1 /* One advanced timer TIM1 */ # define STM32_NGTIM 3 /* General timers TIM2-4 */ @@ -821,7 +821,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 1 /* One advanced timer TIM1 */ # define STM32_NGTIM 3 /* General timers TIM2-4 */ @@ -860,7 +860,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 1 /* One advanced timer TIM1 */ # define STM32_NGTIM 3 /* General timers TIM2-4 */ @@ -904,7 +904,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and TIM8 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM2-5 with DMA */ @@ -946,7 +946,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and TIM8 */ # define STM32_NGTIM 4 /* General timers TIM2-5 */ @@ -988,7 +988,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx families */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 1 /* One advanced timer TIM1 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM2-5 with DMA */ @@ -1028,7 +1028,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 1 /* One advanced timers TIM1 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM2-5 with DMA */ @@ -1066,7 +1066,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 1 /* One advanced timers TIM1 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM2-5 with DMA */ @@ -1104,7 +1104,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 1 /* One advanced timers TIM1 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM2-5 with DMA */ @@ -1144,7 +1144,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and 8 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -1183,7 +1183,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and 8 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -1222,7 +1222,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and 8 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -1269,7 +1269,7 @@ # undef CONFIG_STM32_CONNECTIVITYLINE /* STM32F105x and STM32F107x */ # undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */ # define CONFIG_STM32_STM32F30XX 1 /* STM32F30xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 1 /* (1) Advanced 16-bit timers with DMA: TIM1 (no TIM8) */ # define STM32_NGTIM 6 /* (2) 16-bit general timers with DMA: TIM3 and TIM4 @@ -1310,7 +1310,7 @@ # define CONFIG_STM32_STM32F30XX 1 /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 1 /* (1) Advanced 16-bit timers with DMA: TIM1 (no TIM8) */ # define STM32_NGTIM 6 /* (2) 16-bit general timers with DMA: TIM3 and TIM4 @@ -1351,7 +1351,7 @@ # define CONFIG_STM32_STM32F30XX 1 /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 1 /* (1) Advanced 16-bit timers with DMA: TIM1 (no TIM8) */ # define STM32_NGTIM 6 /* (2) 16-bit general timers with DMA: TIM3 and TIM4 @@ -1392,7 +1392,7 @@ # define CONFIG_STM32_STM32F30XX 1 /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 1 /* (1) Advanced 16-bit timers with DMA: TIM1 (no TIM8) */ # define STM32_NGTIM 6 /* (2) 16-bit general timers with DMA: TIM3 and TIM4 @@ -1433,7 +1433,7 @@ # define CONFIG_STM32_STM32F30XX 1 /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 1 /* (1) Advanced 16-bit timers with DMA: TIM1 */ @@ -1474,7 +1474,7 @@ # define CONFIG_STM32_STM32F30XX 1 /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 1 /* (1) Advanced 16-bit timers with DMA: TIM1 */ @@ -1515,7 +1515,7 @@ # define CONFIG_STM32_STM32F30XX 1 /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 2 /* (2) Advanced 16-bit timers with DMA: TIM1 and TIM8 */ @@ -1556,7 +1556,7 @@ # define CONFIG_STM32_STM32F30XX 1 /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 2 /* (2) Advanced 16-bit timers with DMA: TIM1 and TIM8 */ @@ -1597,7 +1597,7 @@ # define CONFIG_STM32_STM32F30XX 1 /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 2 /* (2) Advanced 16-bit timers with DMA: TIM1 and TIM8 */ @@ -1638,7 +1638,7 @@ # define CONFIG_STM32_STM32F30XX 1 /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 2 /* (2) Advanced 16-bit timers with DMA: TIM1 and TIM8 */ @@ -1679,7 +1679,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # define CONFIG_STM32_STM32F33XX 1 /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_HRTIM 1 /* (1) High-resolution timer 16-bit, 10 channels: HRTIM1 */ @@ -1723,7 +1723,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # define CONFIG_STM32_STM32F33XX 1 /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_HRTIM 1 /* (1) High-resolution timer 16-bit, 10 channels: HRTIM1 */ @@ -1767,7 +1767,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # define CONFIG_STM32_STM32F33XX 1 /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_HRTIM 1 /* (1) High-resolution timer 16-bit, 10 channels: HRTIM1 */ @@ -1810,7 +1810,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # define CONFIG_STM32_STM32F37XX 1 /* STM32F37xxx family */ -# undef CONFIG_STM32_STM32F40XX /* STM32F405xx and STM32407xx */ +# undef CONFIG_STM32_STM32F4XXX /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 0 /* (0) Advanced 16-bit timers with DMA: */ @@ -1856,7 +1856,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */ +# define CONFIG_STM32_STM32F4XXX 1 /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 1 /* One advanced timers TIM1 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -1894,7 +1894,7 @@ # undef CONFIG_STM32_STM32F20XX /* STM32F205x and STM32F207x */ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */ +# define CONFIG_STM32_STM32F4XXX 1 /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 1 /* One advanced timers TIM1 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -1933,7 +1933,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */ +# define CONFIG_STM32_STM32F4XXX 1 /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 1 /* One advanced timers TIM1 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -1972,7 +1972,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */ +# define CONFIG_STM32_STM32F4XXX 1 /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 1 /* One advanced timers TIM1 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -2011,7 +2011,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */ +# define CONFIG_STM32_STM32F4XXX 1 /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* No FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and 8 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -2050,7 +2050,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */ +# define CONFIG_STM32_STM32F4XXX 1 /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and 8 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -2089,7 +2089,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */ +# define CONFIG_STM32_STM32F4XXX 1 /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and 8 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -2128,7 +2128,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */ +# define CONFIG_STM32_STM32F4XXX 1 /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and 8 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -2167,7 +2167,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */ +# define CONFIG_STM32_STM32F4XXX 1 /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and 8 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -2206,7 +2206,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */ +# define CONFIG_STM32_STM32F4XXX 1 /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and 8 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -2245,7 +2245,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */ +# define CONFIG_STM32_STM32F4XXX 1 /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and 8 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -2284,7 +2284,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */ +# define CONFIG_STM32_STM32F4XXX 1 /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and 8 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -2323,7 +2323,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx and STM32407xx */ +# define CONFIG_STM32_STM32F4XXX 1 /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and 8 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -2362,7 +2362,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx, STM32407xx and STM32F427/437 */ +# define CONFIG_STM32_STM32F4XXX 1 /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and 8 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -2401,7 +2401,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx, STM32407xx and STM32F427/437 */ +# define CONFIG_STM32_STM32F4XXX 1 /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and 8 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -2440,7 +2440,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx, STM32407xx and STM32F427/437 */ +# define CONFIG_STM32_STM32F4XXX 1 /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and 8 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -2479,7 +2479,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx, STM32407xx and STM32F427/437 */ +# define CONFIG_STM32_STM32F4XXX 1 /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and 8 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -2518,7 +2518,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx, STM32407xx and STM32F427/437/429/439 */ +# define CONFIG_STM32_STM32F4XXX 1 /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and 8 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -2557,7 +2557,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx, STM32407xx and STM32F427/437 */ +# define CONFIG_STM32_STM32F4XXX 1 /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and 8 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -2596,7 +2596,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx, STM32407xx and STM32F427/437 STM32F466 */ +# define CONFIG_STM32_STM32F4XXX 1 /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and 8 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -2635,7 +2635,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx, STM32407xx and STM32F427/437 STM32F466 */ +# define CONFIG_STM32_STM32F4XXX 1 /* STM32F4xxxx family */ # define STM32_NFSMC 0 /* FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and 8 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -2674,7 +2674,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx, STM32407xx and STM32F427/437 STM32F466 */ +# define CONFIG_STM32_STM32F4XXX 1 /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and 8 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -2713,7 +2713,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx, STM32407xx and STM32F427/437 STM32F466 */ +# define CONFIG_STM32_STM32F4XXX 1 /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and 8 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -2752,7 +2752,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx, STM32407xx and STM32F427/437 */ +# define CONFIG_STM32_STM32F4XXX 1 /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and 8 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA @@ -2794,7 +2794,7 @@ # undef CONFIG_STM32_STM32F30XX /* STM32F30xxx family */ # undef CONFIG_STM32_STM32F33XX /* STM32F33xxx family */ # undef CONFIG_STM32_STM32F37XX /* STM32F37xxx family */ -# define CONFIG_STM32_STM32F40XX 1 /* STM32F405xx, STM32407xx and STM32F427/437 */ +# define CONFIG_STM32_STM32F4XXX 1 /* STM32F4xxxx family */ # define STM32_NFSMC 1 /* FSMC */ # define STM32_NATIM 2 /* Two advanced timers TIM1 and 8 */ # define STM32_NGTIM 4 /* 16-bit general timers TIM3 and 4 with DMA diff --git a/arch/arm/include/stm32/irq.h b/arch/arm/include/stm32/irq.h index ed369355a1..54e2d0f295 100644 --- a/arch/arm/include/stm32/irq.h +++ b/arch/arm/include/stm32/irq.h @@ -89,7 +89,7 @@ # include #elif defined(CONFIG_STM32_STM32F37XX) # include -#elif defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F4XXX) # include #else # error "Unsupported STM32 chip" diff --git a/arch/arm/src/stm32/Kconfig b/arch/arm/src/stm32/Kconfig index 514555cf82..b382deaa94 100644 --- a/arch/arm/src/stm32/Kconfig +++ b/arch/arm/src/stm32/Kconfig @@ -968,189 +968,189 @@ config ARCH_CHIP_STM32F373VC config ARCH_CHIP_STM32F401RE bool "STM32F401RE" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F401 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F410RB bool "STM32F410RB" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F410 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F411RE bool "STM32F411RE" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F411 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F411VE bool "STM32F411VE" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F411 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F405RG bool "STM32F405RG" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F405 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F405VG bool "STM32F405VG" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F405 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F405ZG bool "STM32F405ZG" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F405 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F407VE bool "STM32F407VE" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F407 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F407VG bool "STM32F407VG" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F407 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F407ZE bool "STM32F407ZE" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F407 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F407ZG bool "STM32F407ZG" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F407 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F407IE bool "STM32F407IE" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F407 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F407IG bool "STM32F407IG" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F407 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F427V bool "STM32F427V" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F427 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F427Z bool "STM32F427Z" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F427 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F427I bool "STM32F427I" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F427 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F429V bool "STM32F429V" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F429 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F429Z bool "STM32F429Z" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F429 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F429I bool "STM32F429I" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F429 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F429B bool "STM32F429B" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F429 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F429N bool "STM32F429N" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F429 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F446M bool "STM32F446M" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F446 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F446R bool "STM32F446R" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F446 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F446V bool "STM32F446V" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F446 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F446Z bool "STM32F446Z" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F446 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F469A bool "STM32F469A" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F469 select ARCH_HAVE_FPU config ARCH_CHIP_STM32F469I bool "STM32F469I" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F469 select ARCH_HAVE_FPU select STM32_HAVE_ETHMAC @@ -1158,7 +1158,7 @@ config ARCH_CHIP_STM32F469I config ARCH_CHIP_STM32F469B bool "STM32F469B" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F469 select ARCH_HAVE_FPU select STM32_HAVE_ETHMAC @@ -1166,7 +1166,7 @@ config ARCH_CHIP_STM32F469B config ARCH_CHIP_STM32F469N bool "STM32F469N" select ARCH_CORTEXM4 - select STM32_STM32F40XX + select STM32_STM32F4XXX select STM32_STM32F469 select ARCH_HAVE_FPU select STM32_HAVE_ETHMAC @@ -1522,7 +1522,7 @@ config STM32_STM32F37XX select STM32_HAVE_SPI3 select STM32_HAVE_USART3 -config STM32_STM32F40XX +config STM32_STM32F4XXX bool default n select STM32_HAVE_OTGFS if !STM32_STM32F410 @@ -2170,7 +2170,7 @@ config STM32_BKP config STM32_BKPSRAM bool "Enable BKP RAM Domain" default n - depends on STM32_STM32F207 || STM32_STM32F40XX + depends on STM32_STM32F207 || STM32_STM32F4XXX config STM32_CAN1 bool "CAN1" @@ -2189,7 +2189,7 @@ config STM32_CAN2 config STM32_CCMDATARAM bool "CMD/DATA RAM" default n - depends on STM32_STM32F40XX + depends on STM32_STM32F4XXX config STM32_AES bool "128-bit AES" @@ -2210,7 +2210,7 @@ config STM32_CRC config STM32_CRYP bool "CRYP" default n - depends on STM32_STM32F207 || STM32_STM32F40XX + depends on STM32_STM32F207 || STM32_STM32F4XXX config STM32_DMA1 bool "DMA1" @@ -2238,7 +2238,7 @@ config STM32_DAC2 config STM32_DCMI bool "DCMI" default n - depends on STM32_STM32F207 || STM32_STM32F40XX + depends on STM32_STM32F207 || STM32_STM32F4XXX config STM32_ETHMAC bool "Ethernet MAC" @@ -2255,7 +2255,7 @@ config STM32_FSMC config STM32_HASH bool "HASH" default n - depends on STM32_STM32F207 || STM32_STM32F40XX + depends on STM32_STM32F207 || STM32_STM32F4XXX config STM32_HRTIM1 bool "HRTIM1" @@ -2330,7 +2330,7 @@ config STM32_OTGFS config STM32_OTGHS bool "OTG HS" default n - depends on STM32_STM32F205 || STM32_STM32F207 || STM32_STM32F40XX || STM32_STM32F429 + depends on STM32_STM32F205 || STM32_STM32F207 || STM32_STM32F4XXX || STM32_STM32F429 select USBHOST_HAVE_ASYNCH if USBHOST config STM32_PWR @@ -2402,7 +2402,7 @@ config STM32_SPI6 config STM32_SYSCFG bool "SYSCFG" default y - depends on STM32_STM32L15XX || STM32_STM32F30XX || STM32_STM32F37XX || STM32_STM32F207 || STM32_STM32F40XX || STM32_CONNECTIVITYLINE + depends on STM32_STM32L15XX || STM32_STM32F30XX || STM32_STM32F37XX || STM32_STM32F207 || STM32_STM32F4XXX || STM32_CONNECTIVITYLINE config STM32_TIM1 bool "TIM1" @@ -2771,7 +2771,7 @@ endmenu config STM32_FLASH_PREFETCH bool "Enable FLASH Pre-fetch" - depends on STM32_STM32F207 || STM32_STM32F40XX + depends on STM32_STM32F207 || STM32_STM32F4XXX default y if STM32_STM32F427 || STM32_STM32F429 || STM32_STM32F446 default n ---help--- @@ -2869,8 +2869,8 @@ config STM32_CCM_PROCFS config STM32_DMACAPABLE bool "Workaround non-DMA capable memory" depends on ARCH_DMA - default y if STM32_STM32F40XX && !STM32_CCMEXCLUDE - default n if !STM32_STM32F40XX || STM32_CCMEXCLUDE + default y if STM32_STM32F4XXX && !STM32_CCMEXCLUDE + default n if !STM32_STM32F4XXX || STM32_CCMEXCLUDE ---help--- This option enables the DMA interface stm32_dmacapable that can be used to check if it is possible to do DMA from the selected address. @@ -6413,7 +6413,7 @@ config STM32_I2C_DUTY16_9 config STM32_I2C_DMA bool "I2C DMA Support" default n - depends on STM32_I2C && STM32_STM32F40XX && STM32_DMA1 && !I2C_POLLED + depends on STM32_I2C && STM32_STM32F4XXX && STM32_DMA1 && !I2C_POLLED ---help--- This option enables the DMA for I2C transfers. Note: The user can define CONFIG_I2C_DMAPRIO: a custom priority value for the @@ -6552,7 +6552,7 @@ config STM32_MII choice prompt "MII clock configuration" default STM32_MII_MCO if STM32_STM32F10XX - default STM32_MII_MCO1 if STM32_STM32F207 || STM32_STM32F40XX + default STM32_MII_MCO1 if STM32_STM32F207 || STM32_STM32F4XXX depends on STM32_MII config STM32_MII_MCO @@ -6563,13 +6563,13 @@ config STM32_MII_MCO config STM32_MII_MCO1 bool "Use MC01 as MII clock" - depends on (STM32_STM32F207 || STM32_STM32F40XX) + depends on (STM32_STM32F207 || STM32_STM32F4XXX) ---help--- Use MCO1 to clock the MII interface. Default: Use MC01 config STM32_MII_MCO2 bool "Use MC02 as MII clock" - depends on (STM32_STM32F207 || STM32_STM32F40XX) + depends on (STM32_STM32F207 || STM32_STM32F4XXX) ---help--- Use MCO2 to clock the MII interface. Default: Use MC01 @@ -6700,7 +6700,7 @@ config STM32_RMII choice prompt "RMII clock configuration" default STM32_RMII_MCO if STM32_STM32F10XX - default STM32_RMII_MCO1 if STM32_STM32F207 || STM32_STM32F40XX + default STM32_RMII_MCO1 if STM32_STM32F207 || STM32_STM32F4XXX depends on STM32_RMII config STM32_RMII_MCO @@ -6711,13 +6711,13 @@ config STM32_RMII_MCO config STM32_RMII_MCO1 bool "Use MC01 as RMII clock" - depends on (STM32_STM32F207 || STM32_STM32F40XX) + depends on (STM32_STM32F207 || STM32_STM32F4XXX) ---help--- Use MCO1 to clock the RMII interface. Default: Use MC01 config STM32_RMII_MCO2 bool "Use MC02 as RMII clock" - depends on (STM32_STM32F207 || STM32_STM32F40XX) + depends on (STM32_STM32F207 || STM32_STM32F4XXX) ---help--- Use MCO2 to clock the RMII interface. Default: Use MC01 diff --git a/arch/arm/src/stm32/Make.defs b/arch/arm/src/stm32/Make.defs index 11f5c3dc1d..e7817c8c53 100644 --- a/arch/arm/src/stm32/Make.defs +++ b/arch/arm/src/stm32/Make.defs @@ -140,7 +140,7 @@ else ifeq ($(CONFIG_STM32_STM32F30XX),y) CHIP_CSRCS += stm32f30xxx_i2c.c else ifeq ($(CONFIG_STM32_STM32F37XX),y) CHIP_CSRCS += stm32f30xxx_i2c.c -else ifeq ($(CONFIG_STM32_STM32F40XX),y) +else ifeq ($(CONFIG_STM32_STM32F4XXX),y) CHIP_CSRCS += stm32f40xxx_i2c.c else CHIP_CSRCS += stm32_i2c.c diff --git a/arch/arm/src/stm32/chip.h b/arch/arm/src/stm32/chip.h index 64ec1db604..58ede7d4be 100644 --- a/arch/arm/src/stm32/chip.h +++ b/arch/arm/src/stm32/chip.h @@ -134,7 +134,7 @@ /* STM32 F4 Family ******************************************************************/ -#elif defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F4XXX) # include "chip/stm32f40xxx_pinmap.h" #else # error "No pinmap file for this STM32 chip" @@ -157,7 +157,7 @@ # include "chip/stm32f33xxx_vectors.h" # elif defined(CONFIG_STM32_STM32F37XX) # include "chip/stm32f37xxx_vectors.h" -# elif defined(CONFIG_STM32_STM32F40XX) +# elif defined(CONFIG_STM32_STM32F4XXX) # include "chip/stm32f40xxx_vectors.h" # else # error "No vector file for this STM32 family" diff --git a/arch/arm/src/stm32/chip/stm32_adc.h b/arch/arm/src/stm32/chip/stm32_adc.h index 8a9eb956b6..6c84c513be 100644 --- a/arch/arm/src/stm32/chip/stm32_adc.h +++ b/arch/arm/src/stm32/chip/stm32_adc.h @@ -93,7 +93,7 @@ # define STM32_ADC_SMPR0_OFFSET 0X005c /* ADC sample time register 3 (32-bit) */ #endif -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) || defined(CONFIG_STM32_STM32L15XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) || defined(CONFIG_STM32_STM32L15XX) # define STM32_ADC_CSR_OFFSET 0x0000 /* Common status register */ # define STM32_ADC_CCR_OFFSET 0x0004 /* Common control register */ # ifndef CONFIG_STM32_STM32L15XX @@ -186,7 +186,7 @@ # define STM32_ADC3_DR (STM32_ADC3_BASE+STM32_ADC_DR_OFFSET) #endif -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) || defined(CONFIG_STM32_STM32L15XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) || defined(CONFIG_STM32_STM32L15XX) # define STM32_ADC_CSR (STM32_ADCCMN_BASE+STM32_ADC_CSR_OFFSET) # define STM32_ADC_CCR (STM32_ADCCMN_BASE+STM32_ADC_CCR_OFFSET) # ifndef CONFIG_STM32_STM32L15XX @@ -203,7 +203,7 @@ #define ADC_SR_JEOC (1 << 2) /* Bit 2 : Injected channel end of conversion */ #define ADC_SR_JSTRT (1 << 3) /* Bit 3 : Injected channel Start flag */ #define ADC_SR_STRT (1 << 4) /* Bit 4 : Regular channel Start flag */ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) || defined(CONFIG_STM32_STM32L15XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) || defined(CONFIG_STM32_STM32L15XX) # define ADC_SR_OVR (1 << 5) /* Bit 5 : Overrun */ #endif #if defined(CONFIG_STM32_STM32L15XX) @@ -253,7 +253,7 @@ #define ADC_CR1_JAWDEN (1 << 22) /* Bit 22: Analog watchdog enable on injected channels */ #define ADC_CR1_AWDEN (1 << 23) /* Bit 23: Analog watchdog enable on regular channels */ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) || defined(CONFIG_STM32_STM32L15XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) || defined(CONFIG_STM32_STM32L15XX) # define ADC_CR1_RES_SHIFT (24) /* Bits 24-25: Resolution */ # define ADC_CR1_RES_MASK (3 << ADC_CR1_RES_SHIFT) # define ADC_CR1_RES_12BIT (0 << ADC_CR1_RES_SHIFT) /* 15 ADCCLK cycles. For STM32L15XX: 12 ADCCLK cycles */ @@ -298,14 +298,14 @@ #define ADC_CR2_DMA (1 << 8) /* Bit 8: Direct Memory access mode */ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) || defined(CONFIG_STM32_STM32L15XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) || defined(CONFIG_STM32_STM32L15XX) # define ADC_CR2_DDS (1 << 9) /* Bit 9: DMA disable selection (for single ADC mode) */ # define ADC_CR2_EOCS (1 << 10) /* Bit 10: End of conversion selection */ #endif #define ADC_CR2_ALIGN (1 << 11) /* Bit 11: Data Alignment */ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) || defined(CONFIG_STM32_STM32L15XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) || defined(CONFIG_STM32_STM32L15XX) /* Bits 12-15: Reserved */ # define ADC_CR2_JEXTSEL_SHIFT (16) /* Bits 16-19: External event select for injected group */ # define ADC_CR2_JEXTSEL_MASK (0x0F << ADC_CR2_JEXTSEL_SHIFT) @@ -425,7 +425,7 @@ /* ADC sample time register 1 */ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define ADC_SMPR_3 0 /* 000: 3 cycles */ # define ADC_SMPR_15 1 /* 001: 15 cycles */ @@ -436,7 +436,7 @@ # define ADC_SMPR_144 6 /* 110: 144 cycles */ # define ADC_SMPR_480 7 /* 111: 480 cycles */ -#elif !defined(CONFIG_STM32_STM32L15XX) && !defined(CONFIG_STM32_STM32F20XX) && !defined(CONFIG_STM32_STM32F40XX) +#elif !defined(CONFIG_STM32_STM32L15XX) && !defined(CONFIG_STM32_STM32F20XX) && !defined(CONFIG_STM32_STM32F4XXX) # define ADC_SMPR_1p5 0 /* 000: 1.5 cycles */ # define ADC_SMPR_7p5 1 /* 001: 7.5 cycles */ @@ -477,7 +477,7 @@ # define ADC_SMPR1_SMP16_MASK (7 << ADC_SMPR1_SMP16_SHIFT) # define ADC_SMPR1_SMP17_SHIFT (21) /* Bits 21-23: Channel 17 Sample time selection */ # define ADC_SMPR1_SMP17_MASK (7 << ADC_SMPR1_SMP17_SHIFT) -# if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define ADC_SMPR1_SMP18_SHIFT (24) /* Bits 24-26: Channel 18 Sample time selection */ # define ADC_SMPR1_SMP18_MASK (7 << ADC_SMPR1_SMP17_SHIFT) # endif @@ -784,7 +784,7 @@ /* Common status register */ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) || defined(CONFIG_STM32_STM32L15XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) || defined(CONFIG_STM32_STM32L15XX) # # define ADC_CSR_AWD1 (1 << 0) /* Bit 0: Analog watchdog flag of ADC1 (copy of AWD in ADC1_SR) */ # define ADC_CSR_EOC1 (1 << 1) /* Bit 1: End of conversion of ADC1 (copy of EOC in ADC1_SR) */ @@ -818,7 +818,7 @@ /* Common control register */ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define ADC_CCR_MULTI_SHIFT (0) /* Bits 0-4: Multi ADC mode selection */ # define ADC_CCR_MULTI_MASK (31 << ADC_CCR_MULTI_SHIFT) # define ADC_CCR_MULTI_NONE (0 << ADC_CCR_MULTI_SHIFT) /* 00000: Independent mode */ diff --git a/arch/arm/src/stm32/chip/stm32_can.h b/arch/arm/src/stm32/chip/stm32_can.h index c1e3500d5e..2f45b8152b 100644 --- a/arch/arm/src/stm32/chip/stm32_can.h +++ b/arch/arm/src/stm32/chip/stm32_can.h @@ -62,7 +62,7 @@ /* Number of filters depends on silicon */ #if defined(CONFIG_STM32_CONNECTIVITYLINE) || defined(CONFIG_STM32_STM32F20XX) || \ - defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F4XXX) # define CAN_NFILTERS 28 #else # define CAN_NFILTERS 14 @@ -449,14 +449,14 @@ /* CAN filter master register */ #define CAN_FMR_FINIT (1 << 0) /* Bit 0: Filter Init Mode */ -#if defined(CONFIG_STM32_CONNECTIVITYLINE) || defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_CONNECTIVITYLINE) || defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define CAN_FMR_CAN2SB_SHIFT (8) /* Bits 13-8: CAN2 start bank */ # define CAN_FMR_CAN2SB_MASK (0x3f << CAN_FMR_CAN2SB_SHIFT) #endif /* CAN filter mode register */ -#if defined(CONFIG_STM32_CONNECTIVITYLINE) || defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_CONNECTIVITYLINE) || defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define CAN_FM1R_FBM_SHIFT (0) /* Bits 13:0: Filter Mode */ # define CAN_FM1R_FBM_MASK (0x3fff << CAN_FM1R_FBM_SHIFT) #else @@ -466,7 +466,7 @@ /* CAN filter scale register */ -#if defined(CONFIG_STM32_CONNECTIVITYLINE) || defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_CONNECTIVITYLINE) || defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define CAN_FS1R_FSC_SHIFT (0) /* Bits 13:0: Filter Scale Configuration */ # define CAN_FS1R_FSC_MASK (0x3fff << CAN_FS1R_FSC_SHIFT) #else @@ -476,7 +476,7 @@ /* CAN filter FIFO assignment register */ -#if defined(CONFIG_STM32_CONNECTIVITYLINE) || defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_CONNECTIVITYLINE) || defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define CAN_FFA1R_FFA_SHIFT (0) /* Bits 13:0: Filter FIFO Assignment */ # define CAN_FFA1R_FFA_MASK (0x3fff << CAN_FFA1R_FFA_SHIFT) #else @@ -486,7 +486,7 @@ /* CAN filter activation register */ -#if defined(CONFIG_STM32_CONNECTIVITYLINE) || defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_CONNECTIVITYLINE) || defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define CAN_FA1R_FACT_SHIFT (0) /* Bits 13:0: Filter Active */ # define CAN_FA1R_FACT_MASK (0x3fff << CAN_FA1R_FACT_SHIFT) #else diff --git a/arch/arm/src/stm32/chip/stm32_dbgmcu.h b/arch/arm/src/stm32/chip/stm32_dbgmcu.h index af80113a73..30e9d45960 100644 --- a/arch/arm/src/stm32/chip/stm32_dbgmcu.h +++ b/arch/arm/src/stm32/chip/stm32_dbgmcu.h @@ -53,7 +53,7 @@ #define STM32_DBGMCU_IDCODE 0xe0042000 /* MCU identifier */ #define STM32_DBGMCU_CR 0xe0042004 /* MCU debug */ #if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F30XX) || \ - defined(CONFIG_STM32_STM32F33XX) || defined(CONFIG_STM32_STM32F40XX) || \ + defined(CONFIG_STM32_STM32F33XX) || defined(CONFIG_STM32_STM32F4XXX) || \ defined(CONFIG_STM32_STM32L15XX) # define STM32_DBGMCU_APB1_FZ 0xe0042008 /* Debug MCU APB1 freeze register */ # define STM32_DBGMCU_APB2_FZ 0xe004200c /* Debug MCU APB2 freeze register */ @@ -101,7 +101,7 @@ /* Debug MCU APB1 freeze register */ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define DBGMCU_APB1_TIM2STOP (1 << 0) /* Bit 0: TIM2 stopped when core is halted */ # define DBGMCU_APB1_TIM3STOP (1 << 1) /* Bit 1: TIM3 stopped when core is halted */ # define DBGMCU_APB1_TIM4STOP (1 << 2) /* Bit 2: TIM4 stopped when core is halted */ @@ -138,7 +138,7 @@ /* Debug MCU APB2 freeze register */ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define DBGMCU_APB2_TIM1STOP (1 << 0) /* Bit 0: TIM1 stopped when core is halted */ # define DBGMCU_APB2_TIM8STOP (1 << 1) /* Bit 1: TIM8 stopped when core is halted */ # define DBGMCU_APB2_TIM9STOP (1 << 16) /* Bit 16: TIM9 stopped when core is halted */ diff --git a/arch/arm/src/stm32/chip/stm32_eth.h b/arch/arm/src/stm32/chip/stm32_eth.h index ac078aacbe..5ac1f752d0 100644 --- a/arch/arm/src/stm32/chip/stm32_eth.h +++ b/arch/arm/src/stm32/chip/stm32_eth.h @@ -62,7 +62,7 @@ #define STM32_ETH_MACVLANTR_OFFSET 0x001c /* Ethernet MAC VLAN tag register */ #define STM32_ETH_MACRWUFFR_OFFSET 0x0028 /* Ethernet MAC remote wakeup frame filter reg */ #define STM32_ETH_MACPMTCSR_OFFSET 0x002c /* Ethernet MAC PMT control and status register */ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define STM32_ETH_MACDBGR_OFFSET 0x0034 /* Ethernet MAC debug register */ #endif #define STM32_ETH_MACSR_OFFSET 0x0038 /* Ethernet MAC interrupt status register */ @@ -134,7 +134,7 @@ #define STM32_ETH_MACVLANTR (STM32_ETHERNET_BASE+STM32_ETH_MACVLANTR_OFFSET) #define STM32_ETH_MACRWUFFR (STM32_ETHERNET_BASE+STM32_ETH_MACRWUFFR_OFFSET) #define STM32_ETH_MACPMTCSR (STM32_ETHERNET_BASE+STM32_ETH_MACPMTCSR_OFFSET) -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define STM32_ETH_MACDBGR (STM32_ETHERNET_BASE+STM32_ETH_MACDBGR_OFFSET) #endif #define STM32_ETH_MACSR (STM32_ETHERNET_BASE+STM32_ETH_MACSR_OFFSET) @@ -220,7 +220,7 @@ # define ETH_MACCR_IFG(n) ((12-((n) >> 3)) << ETH_MACCR_IFG_SHIFT) /* n bit times, n=40,48,..96 */ #define ETH_MACCR_JD (1 << 22) /* Bit 22: Jabber disable */ #define ETH_MACCR_WD (1 << 23) /* Bit 23: Watchdog disable */ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define ETH_MACCR_CSTF (1 << 25) /* Bits 25: CRC stripping for Type frames */ #endif @@ -309,7 +309,7 @@ /* Ethernet MAC debug register */ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) #define ETH_MACDBGR_MMRPEA (1 << 0) /* Bit 0: MAC MII receive protocol engine active */ #define ETH_MACDBGR_MSFRWCS_SHIFT (1) /* Bits 1-2: MAC small FIFO read / write controllers status */ @@ -429,7 +429,7 @@ #define ETH_MMCCR_ROR (1 << 2) /* Bit 2: Reset on read */ #define ETH_MMCCR_MCF (1 << 3) /* Bit 3: MMC counter freeze */ #define ETH_MMCCR_MCP (1 << 4) /* Bit 4: MMC counter preset */ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define ETH_MMCCR_MCFHP (1 << 5) /* Bit 5: MMC counter Full-Half preset */ #endif @@ -466,7 +466,7 @@ #define ETH_PTPTSCR_TSITE (1 << 4) /* Bit 4: Time stamp interrupt trigger enable */ #define ETH_PTPTSCR_TSARU (1 << 5) /* Bit 5: Time stamp addend register update */ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) #define ETH_PTPTSCR_TSSARFE (1 << 8) /* Bit 8: Time stamp snapshot for all received frames enable */ #define ETH_PTPTSCR_TSSSR (1 << 9) /* Bit 9: Time stamp subsecond rollover: digital or binary rollover control */ #define ETH_PTPTSCR_TSPTPPSV2E (1 << 10) /* Bit 10: Time stamp PTP packet snooping for version2 format enable */ @@ -558,7 +558,7 @@ #define ETH_DMABMR_USP (1 << 23) /* Bit 23: Use separate PBL */ #define ETH_DMABMR_FPM (1 << 24) /* Bit 24: 4xPBL mode */ #define ETH_DMABMR_AAB (1 << 25) /* Bit 25: Address-aligned beats */ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define ETH_DMABMR_MB (1 << 26) /* Bit 26: Mixed burst */ #endif @@ -711,7 +711,7 @@ /* RDES0: Receive descriptor Word0 */ #define ETH_RDES0_PCE (1 << 0) /* Bit 0: Payload checksum error */ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define ETH_RDES0_ESA (1 << 0) /* Bit 0: Extended status available */ #endif #define ETH_RDES0_CE (1 << 1) /* Bit 1: CRC error */ diff --git a/arch/arm/src/stm32/chip/stm32_exti.h b/arch/arm/src/stm32/chip/stm32_exti.h index e18b60cf71..4475010107 100644 --- a/arch/arm/src/stm32/chip/stm32_exti.h +++ b/arch/arm/src/stm32/chip/stm32_exti.h @@ -60,7 +60,7 @@ # define STM32_EXTI1_MASK 0xffffffff # define STM32_NEXTI2 4 # define STM32_EXTI2_MASK 0x0000000f -#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define STM32_NEXTI 23 # define STM32_EXTI_MASK 0x007fffff #endif @@ -137,7 +137,7 @@ # define EXTI_RTC_CMP1 (1 << 21) /* EXTI line 21 is connected to the Comparator 1 wakeup event */ # define EXTI_RTC_CMP2 (1 << 22) /* EXTI line 22 is connected to the Comparator 2 wakeup event */ # define EXTI_RTC_ACQUIRE (1 << 23) /* EXTI line 23 is connected to the channel acquisition interrupt */ -#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define EXTI_PVD_LINE (1 << 16) /* EXTI line 16 is connected to the PVD output */ # define EXTI_RTC_ALARM (1 << 17) /* EXTI line 17 is connected to the RTC Alarm event */ # define EXTI_OTGFS_WAKEUP (1 << 18) /* EXTI line 18 is connected to the USB OTG FS Wakeup event */ diff --git a/arch/arm/src/stm32/chip/stm32_flash.h b/arch/arm/src/stm32/chip/stm32_flash.h index 89e60e39a5..6608ab99b3 100644 --- a/arch/arm/src/stm32/chip/stm32_flash.h +++ b/arch/arm/src/stm32/chip/stm32_flash.h @@ -115,7 +115,7 @@ # define STM32_FLASH_NPAGES 128 # define STM32_FLASH_PAGESIZE 2048 -# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define STM32_FLASH_NPAGES 8 # define STM32_FLASH_SIZE _K((4 * 16) + (1 * 64) + (3 * 128)) # define STM32_FLASH_SIZES {_K(16), _K(16), _K(16), _K(16), \ @@ -133,7 +133,7 @@ /* Define the Valid Configuration the F2 and F4 */ -# if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # if defined(CONFIG_STM32_FLASH_CONFIG_B) # define STM32_FLASH_NPAGES 5 @@ -147,7 +147,7 @@ # define STM32_FLASH_SIZES {_K(16), _K(16), _K(16), _K(16), \ _K(64), _K(128)} -# elif defined(CONFIG_STM32_FLASH_CONFIG_D) && defined(CONFIG_STM32_STM32F40XX) +# elif defined(CONFIG_STM32_FLASH_CONFIG_D) && defined(CONFIG_STM32_STM32F4XXX) # define STM32_FLASH_NPAGES 7 # define STM32_FLASH_SIZE _K((4 * 16) + (1 * 64) + (2 * 128)) # define STM32_FLASH_SIZES {_K(16), _K(16), _K(16), _K(16), \ @@ -173,7 +173,7 @@ _K(64), _K(128), _K(128), _K(128), \ _K(128), _K(128), _K(128), _K(128)} -# elif defined(CONFIG_STM32_FLASH_CONFIG_I) && defined(CONFIG_STM32_STM32F40XX) +# elif defined(CONFIG_STM32_FLASH_CONFIG_I) && defined(CONFIG_STM32_STM32F4XXX) # define STM32_FLASH_NPAGES 24 # define STM32_FLASH_SIZE _K((4 * 16) + (1 * 64) + (7 * 128)) + \ _K((4 * 16) + (1 * 64) + (7 * 128)) @@ -249,7 +249,7 @@ # define STM32_FLASH_AR_OFFSET 0x0014 # define STM32_FLASH_OBR_OFFSET 0x001c # define STM32_FLASH_WRPR_OFFSET 0x0020 -# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define STM32_FLASH_OPTCR_OFFSET 0x0014 # endif #endif @@ -285,7 +285,7 @@ # define STM32_FLASH_AR (STM32_FLASHIF_BASE+STM32_FLASH_AR_OFFSET) # define STM32_FLASH_OBR (STM32_FLASHIF_BASE+STM32_FLASH_OBR_OFFSET) # define STM32_FLASH_WRPR (STM32_FLASHIF_BASE+STM32_FLASH_WRPR_OFFSET) -# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define STM32_FLASH_OPTCR (STM32_FLASHIF_BASE+STM32_FLASH_OPTCR_OFFSET) # endif # if defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429) || \ @@ -324,7 +324,7 @@ defined(CONFIG_STM32_STM32F37XX) # define FLASH_ACR_PRFTBS (1 << 5) /* Bit 5: FLASH prefetch buffer status */ # endif -# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define FLASH_ACR_PRFTEN (1 << 8) /* FLASH prefetch enable */ # define FLASH_ACR_ICEN (1 << 9) /* Bit 9: Instruction cache enable */ # define FLASH_ACR_DCEN (1 << 10) /* Bit 10: Data cache enable */ @@ -341,7 +341,7 @@ # define FLASH_SR_PGERR (1 << 2) /* Programming Error */ # define FLASH_SR_WRPRT_ERR (1 << 4) /* Write Protection Error */ # define FLASH_SR_EOP (1 << 5) /* End of Operation */ -#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define FLASH_SR_EOP (1 << 0) /* Bit 0: End of operation */ # define FLASH_SR_OPERR (1 << 1) /* Bit 1: Operation error */ # define FLASH_SR_WRPERR (1 << 4) /* Bit 4: Write protection error */ @@ -397,7 +397,7 @@ defined(CONFIG_STM32_STM32F37XX) # define FLASH_CR_OBL_LAUNCH (1 << 13) /* Bit 13: Force option byte loading */ # endif -#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define FLASH_CR_PG (1 << 0) /* Bit 0: Programming */ # define FLASH_CR_SER (1 << 1) /* Bit 1: Sector Erase */ # define FLASH_CR_MER (1 << 2) /* Bit 2: Mass Erase sectors 0..11 */ @@ -426,7 +426,7 @@ /* Flash Option Control Register (OPTCR) */ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define FLASH_OPTCR_OPTLOCK (1 << 0) /* Bit 0: Option lock */ # define FLASH_OPTCR_OPTSTRT (1 << 1) /* Bit 1: Option start */ # define FLASH_OPTCR_BORLEV_SHIFT (2) /* Bits 2-3: BOR reset Level */ @@ -468,7 +468,7 @@ void stm32_flash_lock(void); void stm32_flash_unlock(void); -#ifdef CONFIG_STM32_STM32F40XX +#ifdef CONFIG_STM32_STM32F4XXX int stm32_flash_writeprotect(size_t page, bool enabled); #endif diff --git a/arch/arm/src/stm32/chip/stm32_memorymap.h b/arch/arm/src/stm32/chip/stm32_memorymap.h index 3e88405ca7..e32d5a647a 100644 --- a/arch/arm/src/stm32/chip/stm32_memorymap.h +++ b/arch/arm/src/stm32/chip/stm32_memorymap.h @@ -55,7 +55,7 @@ # include "chip/stm32f33xxx_memorymap.h" #elif defined(CONFIG_STM32_STM32F37XX) # include "chip/stm32f37xxx_memorymap.h" -#elif defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F4XXX) # include "chip/stm32f40xxx_memorymap.h" #else # error "Unsupported STM32 memory map" diff --git a/arch/arm/src/stm32/chip/stm32_pwr.h b/arch/arm/src/stm32/chip/stm32_pwr.h index 20209ee12c..3cbf852464 100644 --- a/arch/arm/src/stm32/chip/stm32_pwr.h +++ b/arch/arm/src/stm32/chip/stm32_pwr.h @@ -90,7 +90,7 @@ # endif #define PWR_CR_DBP (1 << 8) /* Bit 8: Disable Backup Domain write protection */ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define PWR_CR_FPDS (1 << 9) /* Bit 9: Flash power down in Stop mode */ # if defined(CONFIG_STM32_STM32F427) || defined(CONFIG_STM32_STM32F429) || \ defined(CONFIG_STM32_STM32F446) || defined(CONFIG_STM32_STM32F469) @@ -139,7 +139,7 @@ #define PWR_CSR_PVDO (1 << 2) /* Bit 2: PVD Output */ #if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F37XX) || \ - defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F4XXX) # define PWR_CSR_BRR (1 << 3) /* Bit 3: Backup regulator ready */ #elif defined(CONFIG_STM32_STM32L15XX) # define PWR_CSR_VREFINTRDYF (1 << 3) /* Bit 3: Internal voltage reference (VREFINT) ready flag */ @@ -159,7 +159,7 @@ # define PWR_CSR_EWUP (1 << 8) /* Bit 8: Enable WKUP pin */ #endif -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define PWR_CSR_BRE (1 << 9) /* Bit 9: Backup regulator enable */ # define PWR_CSR_VOSRDY (1 << 14) /* Bit 14: Regulator voltage scaling output selection ready bite */ #endif diff --git a/arch/arm/src/stm32/chip/stm32_spi.h b/arch/arm/src/stm32/chip/stm32_spi.h index 3e0a086b63..cf9a9e0118 100644 --- a/arch/arm/src/stm32/chip/stm32_spi.h +++ b/arch/arm/src/stm32/chip/stm32_spi.h @@ -49,7 +49,7 @@ /* Maximum allowed speed as per specifications for all SPIs */ -#if defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F4XXX) # define STM32_SPI_CLK_MAX 37500000UL #else # define STM32_SPI_CLK_MAX 18000000UL @@ -66,7 +66,7 @@ #define STM32_SPI_TXCRCR_OFFSET 0x0018 /* SPI Tx CRC register (16-bit) */ #if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F30XX) || \ - defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F4XXX) # define STM32_SPI_I2SCFGR_OFFSET 0x001c /* I2S configuration register */ # define STM32_SPI_I2SPR_OFFSET 0x0020 /* I2S prescaler register */ #endif @@ -92,7 +92,7 @@ # define STM32_SPI2_RXCRCR (STM32_SPI2_BASE+STM32_SPI_RXCRCR_OFFSET) # define STM32_SPI2_TXCRCR (STM32_SPI2_BASE+STM32_SPI_TXCRCR_OFFSET) #if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F30XX) || \ - defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F4XXX) # define STM32_SPI2_I2SCFGR (STM32_SPI2_BASE+STM32_SPI_I2SCFGR_OFFSET) # define STM32_SPI2_I2SPR (STM32_SPI2_BASE+STM32_SPI_I2SPR_OFFSET) # endif @@ -107,7 +107,7 @@ # define STM32_SPI3_RXCRCR (STM32_SPI3_BASE+STM32_SPI_RXCRCR_OFFSET) # define STM32_SPI3_TXCRCR (STM32_SPI3_BASE+STM32_SPI_TXCRCR_OFFSET) #if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F30XX) || \ - defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F4XXX) # define STM32_SPI3_I2SCFGR (STM32_SPI3_BASE+STM32_SPI_I2SCFGR_OFFSET) # define STM32_SPI3_I2SPR (STM32_SPI3_BASE+STM32_SPI_I2SPR_OFFSET) # endif @@ -152,7 +152,7 @@ #define SPI_CR2_SSOE (1 << 2) /* Bit 2: SS Output Enable */ #if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F30XX) || \ - defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F4XXX) # define SPI_CR2_FRF (1 << 4) /* Bit 4: Frame format */ #endif @@ -188,7 +188,7 @@ #define SPI_SR_TXE (1 << 1) /* Bit 1: Transmit buffer empty */ #if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F30XX) || \ - defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F4XXX) # define SPI_SR_CHSIDE (1 << 2) /* Bit 2: Channel side */ # define SPI_SR_UDR (1 << 3) /* Bit 3: Underrun flag */ #endif @@ -199,7 +199,7 @@ #define SPI_SR_BSY (1 << 7) /* Bit 7: Busy flag */ #if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F30XX) || \ - defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F4XXX) # define SPI_SR_FRE (1 << 8) /* Bit 8: TI frame format error */ #endif @@ -221,7 +221,7 @@ /* I2S configuration register */ #if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F30XX) || \ - defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F4XXX) # define SPI_I2SCFGR_CHLEN (1 << 0) /* Bit 0: Channel length (number of bits per audio channel) */ # define SPI_I2SCFGR_DATLEN_SHIFT (1) /* Bit 1-2: Data length to be transferred */ # define SPI_I2SCFGR_DATLEN_MASK (3 << SPI_I2SCFGR_DATLEN_SHIFT) @@ -249,7 +249,7 @@ /* I2S prescaler register */ #if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F30XX) || \ - defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F4XXX) # define SPI_I2SPR_I2SDIV_SHIFT (0) /* Bit 0-7: I2S Linear prescaler */ # define SPI_I2SPR_I2SDIV_MASK (0xff << SPI_I2SPR_I2SDIV_SHIFT) # define SPI_I2SPR_ODD (1 << 8) /* Bit 8: Odd factor for the prescaler */ diff --git a/arch/arm/src/stm32/chip/stm32_tim.h b/arch/arm/src/stm32/chip/stm32_tim.h index f4113cd6dd..c115dbb43a 100644 --- a/arch/arm/src/stm32/chip/stm32_tim.h +++ b/arch/arm/src/stm32/chip/stm32_tim.h @@ -214,7 +214,7 @@ # define STM32_TIM2_CCR4 (STM32_TIM2_BASE+STM32_GTIM_CCR4_OFFSET) # define STM32_TIM2_DCR (STM32_TIM2_BASE+STM32_GTIM_DCR_OFFSET) # define STM32_TIM2_DMAR (STM32_TIM2_BASE+STM32_GTIM_DMAR_OFFSET) -# if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define STM32_TIM2_OR (STM32_TIM2_BASE+STM32_GTIM_OR_OFFSET) # endif #endif @@ -280,7 +280,7 @@ # define STM32_TIM5_CCR4 (STM32_TIM5_BASE+STM32_GTIM_CCR4_OFFSET) # define STM32_TIM5_DCR (STM32_TIM5_BASE+STM32_GTIM_DCR_OFFSET) # define STM32_TIM5_DMAR (STM32_TIM5_BASE+STM32_GTIM_DMAR_OFFSET) -# if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define STM32_TIM5_OR (STM32_TIM5_BASE+STM32_GTIM_OR_OFFSET) # endif #endif @@ -829,7 +829,7 @@ #define ATIM_CCER_CC4P (1 << 13) /* Bit 13: Capture/Compare 4 output Polarity */ #if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F30XX) || \ - defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX) || \ + defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F4XXX) || \ defined(CONFIG_STM32_STM32L15XX) # define ATIM_CCER_CC4NP (1 << 15) /* Bit 15: Capture/Compare 4 Complementary output polarity */ #elif defined(CONFIG_STM32_STM32F30XX) @@ -1283,7 +1283,7 @@ /* Timer 2/5 option register */ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define TIM2_OR_ITR1_RMP_SHIFT (10) /* Bits 10-11: Internal trigger 1 remap */ # define TIM2_OR_ITR1_RMP_MASK (3 << TIM2_OR_ITR1_RMP_SHIFT) # define TIM2_OR_ITR1_TIM8_TRGOUT (0 << TIM2_OR_ITR1_RMP_SHIFT) /* 00: TIM2_ITR1 input connected to TIM8_TRGOUT */ diff --git a/arch/arm/src/stm32/chip/stm32f40xxx_syscfg.h b/arch/arm/src/stm32/chip/stm32f40xxx_syscfg.h index 57068a2b8d..98769f3dd4 100644 --- a/arch/arm/src/stm32/chip/stm32f40xxx_syscfg.h +++ b/arch/arm/src/stm32/chip/stm32f40xxx_syscfg.h @@ -46,7 +46,7 @@ #include #include "chip.h" -#ifdef CONFIG_STM32_STM32F40XX +#ifdef CONFIG_STM32_STM32F4XXX /**************************************************************************************************** * Pre-processor Definitions @@ -198,5 +198,5 @@ # define SYSCFG_CFGR_FMPI2C1_SDA (1 << 1) /* Bit 8: Forces FM+ drive capability on SDA */ #endif -#endif /* CONFIG_STM32_STM32F40XX */ +#endif /* CONFIG_STM32_STM32F4XXX */ #endif /* __ARCH_ARM_SRC_STM32_CHIP_STM32F40XXX_SYSCFG_H */ diff --git a/arch/arm/src/stm32/gnu/stm32_vectors.S b/arch/arm/src/stm32/gnu/stm32_vectors.S index 4943686dac..b322d9e6cd 100644 --- a/arch/arm/src/stm32/gnu/stm32_vectors.S +++ b/arch/arm/src/stm32/gnu/stm32_vectors.S @@ -181,7 +181,7 @@ _vectors: # include "chip/stm32f33xxx_vectors.h" #elif defined(CONFIG_STM32_STM32F37XX) # include "chip/stm32f37xxx_vectors.h" -#elif defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F4XXX) # include "chip/stm32f40xxx_vectors.h" #else # error "No vectors for STM32 chip" @@ -228,7 +228,7 @@ handlers: # include "chip/stm32f33xxx_vectors.h" #elif defined(CONFIG_STM32_STM32F37XX) # include "chip/stm32f37xxx_vectors.h" -#elif defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F4XXX) # include "chip/stm32f40xxx_vectors.h" #else # error "No handlers for STM32 chip" diff --git a/arch/arm/src/stm32/iar/stm32_vectors.S b/arch/arm/src/stm32/iar/stm32_vectors.S index 52fdfb3056..eeaa2836b7 100644 --- a/arch/arm/src/stm32/iar/stm32_vectors.S +++ b/arch/arm/src/stm32/iar/stm32_vectors.S @@ -469,7 +469,7 @@ __vector_table: # include "chip/stm32f42xxx_vectors.h" #elif defined(CONFIG_STM32_STM32F446) # include "chip/stm32f44xxx_vectors.h" -#elif defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F4XXX) # include "chip/stm32f40xxx_vectors.h" #else # error "No vectors for STM32 chip" @@ -788,7 +788,7 @@ handlers: # include "chip/stm32f42xxx_vectors.h" #elif defined(CONFIG_STM32_STM32F446) # include "chip/stm32f44xxx_vectors.h" -#elif defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F4XXX) # include "chip/stm32f40xxx_vectors.h" #else # error "No handlers for STM32 chip" diff --git a/arch/arm/src/stm32/stm32_adc.c b/arch/arm/src/stm32/stm32_adc.c index 43e349eff0..d3ec74fb3c 100644 --- a/arch/arm/src/stm32/stm32_adc.c +++ b/arch/arm/src/stm32/stm32_adc.c @@ -82,7 +82,7 @@ #if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F20XX) || \ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \ - defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX) || \ + defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F4XXX) || \ defined(CONFIG_STM32_STM32L15XX) /* At the moment there is no proper implementation for timers external @@ -125,7 +125,7 @@ #elif defined(CONFIG_STM32_STM32F37XX) # define STM32_RCC_RSTR STM32_RCC_APB2RSTR # define RCC_RSTR_ADC1RST RCC_APB2RSTR_ADCRST -#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define STM32_RCC_RSTR STM32_RCC_APB2RSTR # define RCC_RSTR_ADC1RST RCC_APB2RSTR_ADCRST # define RCC_RSTR_ADC2RST RCC_APB2RSTR_ADCRST @@ -205,7 +205,7 @@ # endif #endif -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define ADC_DMA_CONTROL_WORD (DMA_SCR_MSIZE_16BITS | \ DMA_SCR_PSIZE_16BITS | \ DMA_SCR_MINC | \ @@ -266,7 +266,7 @@ (ADC_SMPR_DEFAULT << ADC_SMPR2_SMP17_SHIFT) | \ (ADC_SMPR_DEFAULT << ADC_SMPR2_SMP18_SHIFT)) #elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F37XX) || \ - defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F4XXX) # if defined(CONFIG_STM32_STM32F37XX) # define ADC_SMPR_DEFAULT ADC_SMPR_239p5 /* TODO choose 1p5? */ # else @@ -353,7 +353,7 @@ struct stm32_dev_s #if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F30XX) || \ defined(CONFIG_STM32_STM32F33XX) || defined(CONFIG_STM32_STM32F37XX) || \ - defined(CONFIG_STM32_STM32F40XX) || defined(CONFIG_STM32_STM32L15XX) + defined(CONFIG_STM32_STM32F4XXX) || defined(CONFIG_STM32_STM32L15XX) static void stm32_modifyreg32(unsigned int addr, uint32_t clrbits, uint32_t setbits); #endif @@ -621,7 +621,7 @@ static struct adc_dev_s g_adcdev4 = #if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F30XX) || \ defined(CONFIG_STM32_STM32F33XX) || defined(CONFIG_STM32_STM32F37XX) || \ - defined(CONFIG_STM32_STM32F40XX) || defined(CONFIG_STM32_STM32L15XX) + defined(CONFIG_STM32_STM32F4XXX) || defined(CONFIG_STM32_STM32L15XX) static void stm32_modifyreg32(unsigned int addr, uint32_t clrbits, uint32_t setbits) { @@ -1154,7 +1154,7 @@ static int adc_timinit(FAR struct stm32_dev_s *priv) # if defined(CONFIG_STM32_STM32F20XX) || \ defined(CONFIG_STM32_STM32F30XX) || \ - defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F4XXX) ccer &= ~(ATIM_CCER_CC1NE | ATIM_CCER_CC1NP | ATIM_CCER_CC2NE | ATIM_CCER_CC2NP | ATIM_CCER_CC3NE | ATIM_CCER_CC3NP | @@ -1174,7 +1174,7 @@ static int adc_timinit(FAR struct stm32_dev_s *priv) } # if defined(CONFIG_STM32_STM32F20XX) || \ defined(CONFIG_STM32_STM32F30XX) || \ - defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F4XXX) else { ccer &= ~(GTIM_CCER_CC1NP | GTIM_CCER_CC2NP | GTIM_CCER_CC3NP); @@ -2000,12 +2000,12 @@ static void adc_reset(FAR struct adc_dev_s *dev) } #endif #elif defined(CONFIG_STM32_STM32F20XX) || \ - defined(CONFIG_STM32_STM32F40XX) || \ + defined(CONFIG_STM32_STM32F4XXX) || \ defined(CONFIG_STM32_STM32L15XX) clrbits = ADC_CCR_ADCPRE_MASK | ADC_CCR_TSVREFE; setbits = ADC_CCR_ADCPRE_DIV2; -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) clrbits |= ADC_CCR_MULTI_MASK | ADC_CCR_DELAY_MASK | ADC_CCR_DDS | ADC_CCR_DMA_MASK | ADC_CCR_VBATE; setbits |= ADC_CCR_MULTI_NONE | ADC_CCR_DMA_DISABLED; @@ -2103,7 +2103,7 @@ static void adc_reset(FAR struct adc_dev_s *dev) } #endif #elif defined(CONFIG_STM32_STM32F20XX) || \ - defined(CONFIG_STM32_STM32F40XX) || \ + defined(CONFIG_STM32_STM32F4XXX) || \ defined(CONFIG_STM32_STM32L15XX) ainfo("CCR: 0x%08x\n", getreg32(STM32_ADC_CCR)); #endif @@ -3104,7 +3104,7 @@ struct adc_dev_s *stm32_adcinitialize(int intf, FAR const uint8_t *chanlist, #endif /* CONFIG_STM32_STM32F10XX || CONFIG_STM32_STM32F20XX || * CONFIG_STM32_STM32F30XX || CONFIG_STM32_STM32F33XX || - * CONFIG_STM32_STM32F47XX || CONFIG_STM32_STM32F40XX || + * CONFIG_STM32_STM32F47XX || CONFIG_STM32_STM32F4XXX || * CONFIG_STM32_STM32L15XX */ #endif /* CONFIG_STM32_ADC1 || CONFIG_STM32_ADC2 || diff --git a/arch/arm/src/stm32/stm32_adc.h b/arch/arm/src/stm32/stm32_adc.h index 03ffaecbc0..53571eb99e 100644 --- a/arch/arm/src/stm32/stm32_adc.h +++ b/arch/arm/src/stm32/stm32_adc.h @@ -112,7 +112,7 @@ # undef CONFIG_STM32_TIM4_ADC4 #endif -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # ifndef CONFIG_STM32_TIM5 # undef CONFIG_STM32_TIM5_ADC # undef CONFIG_STM32_TIM5_ADC1 @@ -129,7 +129,7 @@ #endif #if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F30XX) || \ - defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F4XXX) # ifndef CONFIG_STM32_TIM8 # undef CONFIG_STM32_TIM8_ADC # undef CONFIG_STM32_TIM8_ADC1 diff --git a/arch/arm/src/stm32/stm32_allocateheap.c b/arch/arm/src/stm32/stm32_allocateheap.c index a6a9161244..fcf53ea329 100644 --- a/arch/arm/src/stm32/stm32_allocateheap.c +++ b/arch/arm/src/stm32/stm32_allocateheap.c @@ -348,7 +348,7 @@ * In addition, external FSMC SRAM may be available. */ -#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) /* The STM32 F2 and the STM32 F401/F411 have no CCM SRAM */ diff --git a/arch/arm/src/stm32/stm32_bbsram.h b/arch/arm/src/stm32/stm32_bbsram.h index bcb813d6fa..8edc3c60b1 100644 --- a/arch/arm/src/stm32/stm32_bbsram.h +++ b/arch/arm/src/stm32/stm32_bbsram.h @@ -59,7 +59,7 @@ * Pre-processor Definitions ****************************************************************************/ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define STM32_BBSRAM_SIZE 4096 #else # error No backup SRAM on this STM32 diff --git a/arch/arm/src/stm32/stm32_can.c b/arch/arm/src/stm32/stm32_can.c index 9e23a48f36..1f9a06b600 100644 --- a/arch/arm/src/stm32/stm32_can.c +++ b/arch/arm/src/stm32/stm32_can.c @@ -1952,7 +1952,7 @@ static int stm32can_filterinit(FAR struct stm32_can_s *priv) #if defined(CONFIG_STM32_CONNECTIVITYLINE) || \ defined(CONFIG_STM32_STM32F20XX) || \ - defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F4XXX) regval = stm32can_getfreg(priv, STM32_CAN_FMR_OFFSET); regval &= CAN_FMR_CAN2SB_MASK; regval |= (CAN_NFILTERS / 2) << CAN_FMR_CAN2SB_SHIFT; diff --git a/arch/arm/src/stm32/stm32_ccm.h b/arch/arm/src/stm32/stm32_ccm.h index 20cc650eee..2f73021cd4 100644 --- a/arch/arm/src/stm32/stm32_ccm.h +++ b/arch/arm/src/stm32/stm32_ccm.h @@ -58,7 +58,7 @@ #if defined(CONFIG_STM32_STM32F30XX) # define CCM_START 0x10000000 # define CCM_END 0x10002000 -#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) || \ +#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) || \ defined(CONFIG_STM32_STM32F33XX) # define CCM_START 0x10000000 # define CCM_END 0x10010000 diff --git a/arch/arm/src/stm32/stm32_dac.c b/arch/arm/src/stm32/stm32_dac.c index e12c9f65c5..bc997e48c3 100644 --- a/arch/arm/src/stm32/stm32_dac.c +++ b/arch/arm/src/stm32/stm32_dac.c @@ -100,7 +100,7 @@ # undef CONFIG_STM32_DAC1_DMA # undef CONFIG_STM32_DAC2_DMA # endif -# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # ifndef CONFIG_STM32_DMA1 # warning "STM32 F4 DAC DMA support requires CONFIG_STM32_DMA1" # undef CONFIG_STM32_DAC1_DMA @@ -153,7 +153,7 @@ # define DAC_DMA 2 # define DAC1_DMA_CHAN DMACHAN_DAC_CHAN1 # define DAC2_DMA_CHAN DMACHAN_DAC_CHAN2 -# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) || \ +# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) || \ defined(CONFIG_STM32_STM32F33XX) # define HAVE_DMA 1 # define DAC_DMA 1 @@ -320,7 +320,7 @@ /* DMA stream/channel configuration */ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define DAC_DMA_CONTROL_WORD (DMA_SCR_MSIZE_16BITS | \ DMA_SCR_PSIZE_16BITS | \ DMA_SCR_MINC | \ @@ -381,7 +381,7 @@ static void tim_putreg(FAR struct stm32_chan_s *chan, int offset, /* Interrupt handler */ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) static int dac_interrupt(int irq, FAR void *context, FAR void *arg); #endif @@ -620,7 +620,7 @@ static void tim_modifyreg(FAR struct stm32_chan_s *chan, int offset, * ****************************************************************************/ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) static int dac_interrupt(int irq, FAR void *context, FAR void *arg) { #warning "Missing logic" diff --git a/arch/arm/src/stm32/stm32_dma.c b/arch/arm/src/stm32/stm32_dma.c index 9118c586d4..64553a7d5c 100644 --- a/arch/arm/src/stm32/stm32_dma.c +++ b/arch/arm/src/stm32/stm32_dma.c @@ -62,6 +62,6 @@ # include "stm32f33xxx_dma.c" #elif defined(CONFIG_STM32_STM32F20XX) # include "stm32f20xxx_dma.c" -#elif defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F4XXX) # include "stm32f40xxx_dma.c" #endif diff --git a/arch/arm/src/stm32/stm32_dma.h b/arch/arm/src/stm32/stm32_dma.h index ceee4e0867..5a84034889 100644 --- a/arch/arm/src/stm32/stm32_dma.h +++ b/arch/arm/src/stm32/stm32_dma.h @@ -54,7 +54,7 @@ # include "chip/stm32f33xxx_dma.h" #elif defined(CONFIG_STM32_STM32F20XX) # include "chip/stm32f20xxx_dma.h" -#elif defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F4XXX) # include "chip/stm32f40xxx_dma.h" #else # error "Unknown STM32 DMA" @@ -72,7 +72,7 @@ # define DMA_STATUS_TEIF DMA_CHAN_TEIF_BIT /* Channel Transfer Error */ # define DMA_STATUS_HTIF DMA_CHAN_HTIF_BIT /* Channel Half Transfer */ # define DMA_STATUS_TCIF DMA_CHAN_TCIF_BIT /* Channel Transfer Complete */ -#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define DMA_STATUS_FEIF 0 /* Stream FIFO error (ignored) */ # define DMA_STATUS_DMEIF DMA_STREAM_DMEIF_BIT /* Stream direct mode error */ # define DMA_STATUS_TEIF DMA_STREAM_TEIF_BIT /* Stream Transfer Error */ @@ -119,7 +119,7 @@ struct stm32_dmaregs_s uint32_t cpar; uint32_t cmar; }; -#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) struct stm32_dmaregs_s { uint32_t lisr; diff --git a/arch/arm/src/stm32/stm32_dumpgpio.c b/arch/arm/src/stm32/stm32_dumpgpio.c index 2540ffdcbc..da1fbd0027 100644 --- a/arch/arm/src/stm32/stm32_dumpgpio.c +++ b/arch/arm/src/stm32/stm32_dumpgpio.c @@ -196,7 +196,7 @@ int stm32_dumpgpio(uint32_t pinset, const char *msg) getreg32(base + STM32_GPIO_AFRL_OFFSET), getreg32(base + STM32_GPIO_BRR_OFFSET)); -#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) DEBUGASSERT(port < STM32_NGPIO_PORTS); _info("GPIO%c pinset: %08x base: %08x -- %s\n", diff --git a/arch/arm/src/stm32/stm32_eth.c b/arch/arm/src/stm32/stm32_eth.c index 77493cd880..62e44a0ff2 100644 --- a/arch/arm/src/stm32/stm32_eth.c +++ b/arch/arm/src/stm32/stm32_eth.c @@ -125,7 +125,7 @@ #endif #ifdef CONFIG_STM32_MII -# if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # if !defined(CONFIG_STM32_MII_MCO1) && !defined(CONFIG_STM32_MII_MCO2) && !defined(CONFIG_STM32_MII_EXTCLK) # warning "Neither CONFIG_STM32_MII_MCO1, CONFIG_STM32_MII_MCO2, nor CONFIG_STM32_MII_EXTCLK defined" # endif @@ -140,7 +140,7 @@ #endif #ifdef CONFIG_STM32_RMII -# if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # if !defined(CONFIG_STM32_RMII_MCO1) && !defined(CONFIG_STM32_RMII_MCO2) && !defined(CONFIG_STM32_RMII_EXTCLK) # warning "Neither CONFIG_STM32_RMII_MCO1, CONFIG_STM32_RMII_MCO2, nor CONFIG_STM32_RMII_EXTCLK defined" # endif @@ -344,7 +344,7 @@ * ETH_MACCR_CSTF Bits 25: CRC stripping for Type frames (F2/F4 only) */ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) #define MACCR_CLEAR_BITS \ (ETH_MACCR_RE | ETH_MACCR_TE | ETH_MACCR_DC | ETH_MACCR_BL_MASK | \ ETH_MACCR_APCS | ETH_MACCR_RD | ETH_MACCR_IPCO | ETH_MACCR_DM | \ @@ -531,7 +531,7 @@ * ETH_DMABMR_MB Bit 26: Mixed burst (F2/F4 only) */ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) #define DMABMR_CLEAR_MASK \ (ETH_DMABMR_SR | ETH_DMABMR_DA | ETH_DMABMR_DSL_MASK | ETH_DMABMR_EDFE | \ ETH_DMABMR_PBL_MASK | ETH_DMABMR_RTPR_MASK | ETH_DMABMR_FB | ETH_DMABMR_RDP_MASK | \ diff --git a/arch/arm/src/stm32/stm32_flash.c b/arch/arm/src/stm32/stm32_flash.c index 6291154cc0..e43d4a5185 100644 --- a/arch/arm/src/stm32/stm32_flash.c +++ b/arch/arm/src/stm32/stm32_flash.c @@ -62,10 +62,10 @@ /* Only for the STM32F[1|3|4]0xx family and STM32L15xx (EEPROM only) for now */ #if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F30XX) || \ - defined (CONFIG_STM32_STM32F40XX) || defined(CONFIG_STM32_STM32L15XX) + defined (CONFIG_STM32_STM32F4XXX) || defined(CONFIG_STM32_STM32L15XX) #if defined(CONFIG_STM32_FLASH_CONFIG_DEFAULT) && \ - (defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)) + (defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX)) # warning "Default Flash Configuration Used - See Override Flash Size Designator" #endif @@ -86,7 +86,7 @@ #if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F30XX) # define FLASH_CR_PAGE_ERASE FLASH_CR_PER # define FLASH_SR_WRITE_PROTECTION_ERROR FLASH_SR_WRPRT_ERR -#elif defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F4XXX) # define FLASH_CR_PAGE_ERASE FLASH_CR_SER # define FLASH_SR_WRITE_PROTECTION_ERROR FLASH_SR_WRPERR #endif @@ -394,13 +394,13 @@ ssize_t stm32_eeprom_erase(size_t addr, size_t eraselen) * ************************************************************************************/ -#ifdef CONFIG_STM32_STM32F40XX +#ifdef CONFIG_STM32_STM32F4XXX int stm32_flash_writeprotect(size_t page, bool enabled) { uint32_t reg; uint32_t val; -#ifdef CONFIG_STM32_STM32F40XX +#ifdef CONFIG_STM32_STM32F4XXX if (page >= STM32_FLASH_NPAGES) { return -EFAULT; @@ -415,7 +415,7 @@ int stm32_flash_writeprotect(size_t page, bool enabled) { reg = STM32_FLASH_OPTCR; } -#if defined(CONFIG_STM32_FLASH_CONFIG_I) && defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_FLASH_CONFIG_I) && defined(CONFIG_STM32_STM32F4XXX) else { reg = STM32_FLASH_OPTCR1; @@ -500,7 +500,7 @@ size_t up_progmem_getaddress(size_t page) #endif /* defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F30XX) */ -#ifdef CONFIG_STM32_STM32F40XX +#ifdef CONFIG_STM32_STM32F4XXX size_t up_progmem_pagesize(size_t page) { @@ -561,7 +561,7 @@ size_t up_progmem_getaddress(size_t page) return base_address; } -#endif /* def CONFIG_STM32_STM32F40XX */ +#endif /* def CONFIG_STM32_STM32F4XXX */ #if !defined(CONFIG_STM32_STM32L15XX) @@ -592,7 +592,7 @@ ssize_t up_progmem_erasepage(size_t page) sem_lock(); -#if !defined(CONFIG_STM32_STM32F40XX) +#if !defined(CONFIG_STM32_STM32F4XXX) if (!(getreg32(STM32_RCC_CR) & RCC_CR_HSION)) { sem_unlock(); @@ -612,7 +612,7 @@ ssize_t up_progmem_erasepage(size_t page) page_address = up_progmem_getaddress(page); putreg32(page_address, STM32_FLASH_AR); -#elif defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F4XXX) modifyreg32(STM32_FLASH_CR, FLASH_CR_SNB_MASK, FLASH_CR_SNB(page)); #endif @@ -685,7 +685,7 @@ ssize_t up_progmem_write(size_t addr, const void *buf, size_t count) sem_lock(); -#if !defined(CONFIG_STM32_STM32F40XX) +#if !defined(CONFIG_STM32_STM32F4XXX) if (!(getreg32(STM32_RCC_CR) & RCC_CR_HSION)) { sem_unlock(); @@ -703,7 +703,7 @@ ssize_t up_progmem_write(size_t addr, const void *buf, size_t count) modifyreg32(STM32_FLASH_CR, 0, FLASH_CR_PG); -#if defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F4XXX) /* TODO: implement up_progmem_write() to support other sizes than 16-bits */ modifyreg32(STM32_FLASH_CR, FLASH_CR_PSIZE_MASK, FLASH_CR_PSIZE_X16); #endif @@ -746,4 +746,4 @@ ssize_t up_progmem_write(size_t addr, const void *buf, size_t count) #endif /* !defined(CONFIG_STM32_STM32L15XX) */ #endif /* defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F30XX) || \ - defined(CONFIG_STM32_STM32F40XX) || defined(CONFIG_STM32_STM32L15XX) */ + defined(CONFIG_STM32_STM32F4XXX) || defined(CONFIG_STM32_STM32L15XX) */ diff --git a/arch/arm/src/stm32/stm32_fsmc.h b/arch/arm/src/stm32/stm32_fsmc.h index f865c00b5a..330f47d062 100644 --- a/arch/arm/src/stm32/stm32_fsmc.h +++ b/arch/arm/src/stm32/stm32_fsmc.h @@ -187,7 +187,7 @@ #define FSMC_BCR_WREN (1 << 12) /* Write enable bit */ #define FSMC_BCR_WAITEN (1 << 13) /* Wait enable bit */ #define FSMC_BCR_EXTMOD (1 << 14) /* Extended mode enable */ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define FSMC_BCR_ASYNCWAIT (1 << 15) /* Wait signal during asynchronous transfers */ #endif #define FSMC_BCR_CBURSTRW (1 << 19) /* Write burst enable */ diff --git a/arch/arm/src/stm32/stm32_gpio.c b/arch/arm/src/stm32/stm32_gpio.c index 9eb5fb9597..727f0c943a 100644 --- a/arch/arm/src/stm32/stm32_gpio.c +++ b/arch/arm/src/stm32/stm32_gpio.c @@ -56,7 +56,7 @@ #if defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F20XX) || \ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \ - defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F4XXX) # include "chip/stm32_syscfg.h" #endif @@ -428,7 +428,7 @@ int stm32_configgpio(uint32_t cfgset) #if defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F20XX) || \ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \ - defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F4XXX) int stm32_configgpio(uint32_t cfgset) { uintptr_t base; @@ -683,7 +683,7 @@ int stm32_unconfiggpio(uint32_t cfgset) cfgset |= GPIO_INPUT | GPIO_CNF_INFLOAT | GPIO_MODE_INPUT; #elif defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F20XX) || \ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \ - defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F4XXX) cfgset |= GPIO_INPUT | GPIO_FLOAT; #else # error "Unsupported STM32 chip" @@ -709,7 +709,7 @@ void stm32_gpiowrite(uint32_t pinset, bool value) uint32_t offset; #elif defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F20XX) || \ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \ - defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F4XXX) uint32_t bit; #endif unsigned int port; @@ -743,7 +743,7 @@ void stm32_gpiowrite(uint32_t pinset, bool value) #elif defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F20XX) || \ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \ - defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F4XXX) if (value) { diff --git a/arch/arm/src/stm32/stm32_gpio.h b/arch/arm/src/stm32/stm32_gpio.h index 0385d1e951..c08b9a9298 100644 --- a/arch/arm/src/stm32/stm32_gpio.h +++ b/arch/arm/src/stm32/stm32_gpio.h @@ -62,7 +62,7 @@ #elif defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \ defined(CONFIG_STM32_STM32F37XX) # include "chip/stm32f30xxx_gpio.h" -#elif defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F4XXX) # include "chip/stm32f40xxx_gpio.h" #else # error "Unrecognized STM32 chip" @@ -203,7 +203,7 @@ #elif defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F20XX) || \ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \ - defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F4XXX) /* Each port bit of the general-purpose I/O (GPIO) ports can be individually configured * by software in several modes: diff --git a/arch/arm/src/stm32/stm32_i2c.c b/arch/arm/src/stm32/stm32_i2c.c index 5f3e1c2c5c..99b923eb15 100644 --- a/arch/arm/src/stm32/stm32_i2c.c +++ b/arch/arm/src/stm32/stm32_i2c.c @@ -105,7 +105,7 @@ /* Experimentally enabled for STM32L15XX */ #if defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F10XX) || \ - defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) /************************************************************************************ * Pre-processor Definitions @@ -155,7 +155,7 @@ #elif defined(CONFIG_STM32_STM32F10XX) # define I2C_OUTPUT (GPIO_OUTPUT | GPIO_OUTPUT_SET | GPIO_CNF_OUTOD | \ GPIO_MODE_50MHz) -#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define I2C_OUTPUT (GPIO_OUTPUT | GPIO_FLOAT | GPIO_OPENDRAIN |\ GPIO_SPEED_50MHz | GPIO_OUTPUT_SET) #endif @@ -1345,7 +1345,7 @@ static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv) * the F1 in that BTF is not set after data is received (only RXNE). */ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) || \ +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) || \ defined(CONFIG_STM32_STM32L15XX) if (priv->dcnt <= 0 && (status & (I2C_SR1_BTF | I2C_SR1_RXNE)) != 0) #else @@ -2003,5 +2003,5 @@ int stm32_i2cbus_uninitialize(FAR struct i2c_master_s *dev) return OK; } -#endif /* CONFIG_STM32_STM32F10XX || CONFIG_STM32_STM32F20XX || CONFIG_STM32_STM32F40XX */ +#endif /* CONFIG_STM32_STM32F10XX || CONFIG_STM32_STM32F20XX || CONFIG_STM32_STM32F4XXX */ #endif /* CONFIG_STM32_I2C1 || CONFIG_STM32_I2C2 || CONFIG_STM32_I2C3 */ diff --git a/arch/arm/src/stm32/stm32_i2c_alt.c b/arch/arm/src/stm32/stm32_i2c_alt.c index 21f6696732..6aba636db6 100644 --- a/arch/arm/src/stm32/stm32_i2c_alt.c +++ b/arch/arm/src/stm32/stm32_i2c_alt.c @@ -112,7 +112,7 @@ /* Experimentally enabled for STM32L15XX */ #if defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F10XX) || \ - defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) /************************************************************************************ * Pre-processor Definitions @@ -162,7 +162,7 @@ #elif defined(CONFIG_STM32_STM32F10XX) # define I2C_OUTPUT (GPIO_OUTPUT | GPIO_OUTPUT_SET | GPIO_CNF_OUTOD | \ GPIO_MODE_50MHz) -#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define I2C_OUTPUT (GPIO_OUTPUT | GPIO_FLOAT | GPIO_OPENDRAIN |\ GPIO_SPEED_50MHz | GPIO_OUTPUT_SET) #endif @@ -2451,5 +2451,5 @@ int stm32_i2cbus_uninitialize(FAR struct i2c_master_s *dev) return OK; } -#endif /* CONFIG_STM32_STM32F10XX || CONFIG_STM32_STM32F20XX || CONFIG_STM32_STM32F40XX */ +#endif /* CONFIG_STM32_STM32F10XX || CONFIG_STM32_STM32F20XX || CONFIG_STM32_STM32F4XXX */ #endif /* CONFIG_STM32_I2C1 || CONFIG_STM32_I2C2 || CONFIG_STM32_I2C3 */ diff --git a/arch/arm/src/stm32/stm32_i2s.c b/arch/arm/src/stm32/stm32_i2s.c index 1f5d348384..60d4a8174b 100644 --- a/arch/arm/src/stm32/stm32_i2s.c +++ b/arch/arm/src/stm32/stm32_i2s.c @@ -153,7 +153,7 @@ # define SPI_DMA_PRIO CONFIG_SPI_DMAPRIO # elif defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32L15XX) # define SPI_DMA_PRIO DMA_CCR_PRIMED -# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define SPI_DMA_PRIO DMA_SCR_PRIMED # else # error "Unknown STM32 DMA" @@ -163,7 +163,7 @@ # if (SPI_DMA_PRIO & ~DMA_CCR_PL_MASK) != 0 # error "Illegal value for CONFIG_SPI_DMAPRIO" # endif -# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # if (SPI_DMA_PRIO & ~DMA_SCR_PL_MASK) != 0 # error "Illegal value for CONFIG_SPI_DMAPRIO" # endif @@ -185,7 +185,7 @@ # define SPI_TXDMA8_CONFIG (SPI_DMA_PRIO|DMA_CCR_MSIZE_8BITS |DMA_CCR_PSIZE_8BITS |DMA_CCR_MINC|DMA_CCR_DIR) # define SPI_TXDMA16NULL_CONFIG (SPI_DMA_PRIO|DMA_CCR_MSIZE_8BITS |DMA_CCR_PSIZE_16BITS |DMA_CCR_DIR) # define SPI_TXDMA8NULL_CONFIG (SPI_DMA_PRIO|DMA_CCR_MSIZE_8BITS |DMA_CCR_PSIZE_8BITS |DMA_CCR_DIR) -#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define SPI_RXDMA16_CONFIG (SPI_DMA_PRIO|DMA_SCR_MSIZE_16BITS|DMA_SCR_PSIZE_16BITS|DMA_SCR_MINC|DMA_SCR_DIR_P2M) # define SPI_RXDMA8_CONFIG (SPI_DMA_PRIO|DMA_SCR_MSIZE_8BITS |DMA_SCR_PSIZE_8BITS |DMA_SCR_MINC|DMA_SCR_DIR_P2M) # define SPI_RXDMA16NULL_CONFIG (SPI_DMA_PRIO|DMA_SCR_MSIZE_8BITS |DMA_SCR_PSIZE_16BITS |DMA_SCR_DIR_P2M) diff --git a/arch/arm/src/stm32/stm32_iwdg.c b/arch/arm/src/stm32/stm32_iwdg.c index 7b114fefa5..d26ec9f71a 100644 --- a/arch/arm/src/stm32/stm32_iwdg.c +++ b/arch/arm/src/stm32/stm32_iwdg.c @@ -691,7 +691,7 @@ void stm32_iwdginitialize(FAR const char *devpath, uint32_t lsifreq) defined(CONFIG_STM32_JTAG_SW_ENABLE) { #if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F30XX) || \ - defined(CONFIG_STM32_STM32F40XX) || defined(CONFIG_STM32_STM32L15XX) + defined(CONFIG_STM32_STM32F4XXX) || defined(CONFIG_STM32_STM32L15XX) uint32_t cr = getreg32(STM32_DBGMCU_APB1_FZ); cr |= DBGMCU_APB1_IWDGSTOP; putreg32(cr, STM32_DBGMCU_APB1_FZ); diff --git a/arch/arm/src/stm32/stm32_lowputc.c b/arch/arm/src/stm32/stm32_lowputc.c index 856879454a..63e7090434 100644 --- a/arch/arm/src/stm32/stm32_lowputc.c +++ b/arch/arm/src/stm32/stm32_lowputc.c @@ -572,7 +572,7 @@ void stm32_lowsetup(void) #elif defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F20XX) || \ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \ - defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F4XXX) void stm32_lowsetup(void) { diff --git a/arch/arm/src/stm32/stm32_pwm.c b/arch/arm/src/stm32/stm32_pwm.c index 8f66239a11..0e9db50059 100644 --- a/arch/arm/src/stm32/stm32_pwm.c +++ b/arch/arm/src/stm32/stm32_pwm.c @@ -89,7 +89,7 @@ #else # define TIMTYPE_TIM2 TIMTYPE_GENERAL32 #endif -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define TIMTYPE_TIM3 TIMTYPE_GENERAL32 # define TIMTYPE_TIM4 TIMTYPE_GENERAL32 #else @@ -1719,7 +1719,7 @@ static int pwm_timer(FAR struct stm32_pwmtimer_s *priv, */ #if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F30XX) || \ - defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F4XXX) ccer &= ~(ATIM_CCER_CC1NE | ATIM_CCER_CC1NP | ATIM_CCER_CC2NE | ATIM_CCER_CC2NP | ATIM_CCER_CC3NE | ATIM_CCER_CC3NP | ATIM_CCER_CC4NP); #else @@ -1742,12 +1742,12 @@ static int pwm_timer(FAR struct stm32_pwmtimer_s *priv, pwm_putreg(priv, STM32_ATIM_BDTR_OFFSET, bdtr); } #if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F30XX) || \ - defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F4XXX) else #endif #endif #if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F30XX) || \ - defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F37XX) || defined(CONFIG_STM32_STM32F4XXX) { /* CCxNP must be cleared in any case */ @@ -2284,7 +2284,7 @@ static int pwm_shutdown(FAR struct pwm_lowerhalf_s *dev) #elif defined(CONFIG_STM32_STM32F20XX) || \ defined(CONFIG_STM32_STM32F30XX) || \ defined(CONFIG_STM32_STM32F37XX) || \ - defined(CONFIG_STM32_STM32F40XX) || \ + defined(CONFIG_STM32_STM32F4XXX) || \ defined(CONFIG_STM32_STM32L15XX) pincfg |= GPIO_INPUT | GPIO_FLOAT; #else diff --git a/arch/arm/src/stm32/stm32_pwr.c b/arch/arm/src/stm32/stm32_pwr.c index 2b0ed2a14c..be9f277115 100644 --- a/arch/arm/src/stm32/stm32_pwr.c +++ b/arch/arm/src/stm32/stm32_pwr.c @@ -248,7 +248,7 @@ void stm32_pwr_enablebkp(bool writable) * ************************************************************************************/ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) void stm32_pwr_enablebreg(bool regon) { uint16_t regval; diff --git a/arch/arm/src/stm32/stm32_pwr.h b/arch/arm/src/stm32/stm32_pwr.h index 19af928f14..dc4be9a1fe 100644 --- a/arch/arm/src/stm32/stm32_pwr.h +++ b/arch/arm/src/stm32/stm32_pwr.h @@ -146,7 +146,7 @@ void stm32_pwr_enablebkp(bool writable); * ************************************************************************************/ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) void stm32_pwr_enablebreg(bool regon); #else # define stm32_pwr_enablebreg(regon) diff --git a/arch/arm/src/stm32/stm32_qencoder.c b/arch/arm/src/stm32/stm32_qencoder.c index 126ef24987..09ed7669a0 100644 --- a/arch/arm/src/stm32/stm32_qencoder.c +++ b/arch/arm/src/stm32/stm32_qencoder.c @@ -115,7 +115,7 @@ /* On the F4 series, TIM2 and TIM5 are 32-bit. All of the rest are 16-bit */ -#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) /* If TIM2 or TIM5 are enabled, then we have 32-bit timers */ @@ -212,7 +212,7 @@ GPIO_MODE_INPUT) #elif defined(CONFIG_STM32_STM32F20XX) || \ defined(CONFIG_STM32_STM32F30XX) || \ - defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F4XXX) # define STM32_GPIO_INPUT_FLOAT (GPIO_INPUT | GPIO_FLOAT) #else # error "Unrecognized STM32 chip" diff --git a/arch/arm/src/stm32/stm32_rcc.c b/arch/arm/src/stm32/stm32_rcc.c index be152ff8d8..2ed39f9a5e 100644 --- a/arch/arm/src/stm32/stm32_rcc.c +++ b/arch/arm/src/stm32/stm32_rcc.c @@ -86,7 +86,7 @@ # include "stm32f33xxx_rcc.c" #elif defined(CONFIG_STM32_STM32F37XX) # include "stm32f37xxx_rcc.c" -#elif defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F4XXX) # include "stm32f40xxx_rcc.c" #else # error "Unsupported STM32 chip" diff --git a/arch/arm/src/stm32/stm32_rcc.h b/arch/arm/src/stm32/stm32_rcc.h index 79949cd60c..c1b7281578 100644 --- a/arch/arm/src/stm32/stm32_rcc.h +++ b/arch/arm/src/stm32/stm32_rcc.h @@ -57,7 +57,7 @@ # include "chip/stm32f33xxx_rcc.h" #elif defined(CONFIG_STM32_STM32F37XX) # include "chip/stm32f37xxx_rcc.h" -#elif defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F4XXX) # include "chip/stm32f40xxx_rcc.h" #endif @@ -113,7 +113,7 @@ extern uint32_t _vectors[]; /* See stm32_vectors.S */ * ************************************************************************************/ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) static inline void stm32_mco1config(uint32_t source, uint32_t div) { uint32_t regval; @@ -214,7 +214,7 @@ static inline void stm32_mcodivconfig(uint32_t source, uint32_t divider) * ************************************************************************************/ -#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) static inline void stm32_mco2config(uint32_t source, uint32_t div) { uint32_t regval; diff --git a/arch/arm/src/stm32/stm32_rtc.c b/arch/arm/src/stm32/stm32_rtc.c index 3e8dc0b0d7..f26417b0d9 100644 --- a/arch/arm/src/stm32/stm32_rtc.c +++ b/arch/arm/src/stm32/stm32_rtc.c @@ -66,6 +66,6 @@ #elif defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F20XX) || \ defined(CONFIG_STM32_STM32F30XX) # include "stm32_rtcc.c" -#elif defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F4XXX) # include "stm32f40xxx_rtcc.c" #endif diff --git a/arch/arm/src/stm32/stm32_rtc.h b/arch/arm/src/stm32/stm32_rtc.h index 6271a97ed7..81daa92659 100644 --- a/arch/arm/src/stm32/stm32_rtc.h +++ b/arch/arm/src/stm32/stm32_rtc.h @@ -60,13 +60,13 @@ */ #elif defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F20XX) || \ - defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F4XXX) # include "chip/stm32_rtcc.h" #endif /* Alarm function differs from part to part */ -#ifdef CONFIG_STM32_STM32F40XX +#ifdef CONFIG_STM32_STM32F4XXX # include "stm32f40xxx_alarm.h" #else # include "stm32_alarm.h" diff --git a/arch/arm/src/stm32/stm32_rtc_lowerhalf.c b/arch/arm/src/stm32/stm32_rtc_lowerhalf.c index 6a8c079399..29af5d8c15 100644 --- a/arch/arm/src/stm32/stm32_rtc_lowerhalf.c +++ b/arch/arm/src/stm32/stm32_rtc_lowerhalf.c @@ -60,7 +60,7 @@ * Pre-processor Definitions ****************************************************************************/ -#ifdef CONFIG_STM32_STM32F40XX +#ifdef CONFIG_STM32_STM32F4XXX # define STM32_NALARMS 2 #else # define STM32_NALARMS 1 @@ -75,7 +75,7 @@ struct stm32_cbinfo_s { volatile rtc_alarm_callback_t cb; /* Callback when the alarm expires */ volatile FAR void *priv; /* Private argurment to accompany callback */ -#ifdef CONFIG_STM32_STM32F40XX +#ifdef CONFIG_STM32_STM32F4XXX uint8_t id; /* Identifies the alarm */ #endif }; @@ -174,7 +174,7 @@ static struct stm32_lowerhalf_s g_rtc_lowerhalf = ****************************************************************************/ #ifdef CONFIG_RTC_ALARM -#ifdef CONFIG_STM32_STM32F40XX +#ifdef CONFIG_STM32_STM32F4XXX static void stm32_alarm_callback(FAR void *arg, unsigned int alarmid) { FAR struct stm32_lowerhalf_s *lower; @@ -229,7 +229,7 @@ static void stm32_alarm_callback(void) } } -#endif /* CONFIG_STM32_STM32F40XX */ +#endif /* CONFIG_STM32_STM32F4XXX */ #endif /* CONFIG_RTC_ALARM */ /**************************************************************************** @@ -393,7 +393,7 @@ static bool stm32_havesettime(FAR struct rtc_lowerhalf_s *lower) static int stm32_setalarm(FAR struct rtc_lowerhalf_s *lower, FAR const struct lower_setalarm_s *alarminfo) { -#ifdef CONFIG_STM32_STM32F40XX +#ifdef CONFIG_STM32_STM32F4XXX FAR struct stm32_lowerhalf_s *priv; FAR struct stm32_cbinfo_s *cbinfo; struct alm_setalarm_s lowerinfo; @@ -492,7 +492,7 @@ static int stm32_setalarm(FAR struct rtc_lowerhalf_s *lower, static int stm32_setrelative(FAR struct rtc_lowerhalf_s *lower, FAR const struct lower_setrelative_s *alarminfo) { -#ifdef CONFIG_STM32_STM32F40XX +#ifdef CONFIG_STM32_STM32F4XXX struct lower_setalarm_s setalarm; struct tm time; time_t seconds; @@ -643,7 +643,7 @@ static int stm32_setrelative(FAR struct rtc_lowerhalf_s *lower, #ifdef CONFIG_RTC_ALARM static int stm32_cancelalarm(FAR struct rtc_lowerhalf_s *lower, int alarmid) { -#ifdef CONFIG_STM32_STM32F40XX +#ifdef CONFIG_STM32_STM32F4XXX FAR struct stm32_lowerhalf_s *priv; FAR struct stm32_cbinfo_s *cbinfo; int ret = -EINVAL; diff --git a/arch/arm/src/stm32/stm32_sdio.c b/arch/arm/src/stm32/stm32_sdio.c index db95c008e9..e5d3c22ecb 100644 --- a/arch/arm/src/stm32/stm32_sdio.c +++ b/arch/arm/src/stm32/stm32_sdio.c @@ -126,7 +126,7 @@ # ifndef CONFIG_STM32_SDIO_DMAPRIO # if defined(CONFIG_STM32_STM32F10XX) # define CONFIG_STM32_SDIO_DMAPRIO DMA_CCR_PRIMED -# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define CONFIG_STM32_SDIO_DMAPRIO DMA_SCR_PRIVERYHI # else # error "Unknown STM32 DMA" @@ -136,7 +136,7 @@ # if (CONFIG_STM32_SDIO_DMAPRIO & ~DMA_CCR_PL_MASK) != 0 # error "Illegal value for CONFIG_STM32_SDIO_DMAPRIO" # endif -# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # if (CONFIG_STM32_SDIO_DMAPRIO & ~DMA_SCR_PL_MASK) != 0 # error "Illegal value for CONFIG_STM32_SDIO_DMAPRIO" # endif @@ -207,7 +207,7 @@ /* STM32 F4 stream configuration register (SCR) settings. */ -#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define SDIO_RXDMA32_CONFIG (DMA_SCR_PFCTRL | DMA_SCR_DIR_P2M|DMA_SCR_MINC | \ DMA_SCR_PSIZE_32BITS | DMA_SCR_MSIZE_32BITS | \ CONFIG_STM32_SDIO_DMAPRIO | DMA_SCR_PBURST_INCR4 | \ @@ -227,7 +227,7 @@ #if defined(CONFIG_STM32_STM32F10XX) # define SDIO_DMACHAN DMACHAN_SDIO -#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define SDIO_DMACHAN DMAMAP_SDIO #else # error "Unknown STM32 DMA" @@ -2649,7 +2649,7 @@ static int stm32_registercallback(FAR struct sdio_dev_s *dev, static int stm32_dmapreflight(FAR struct sdio_dev_s *dev, FAR const uint8_t *buffer, size_t buflen) { -#if !defined(CONFIG_STM32_STM32F40XX) +#if !defined(CONFIG_STM32_STM32F4XXX) struct stm32_dev_s *priv = (struct stm32_dev_s *)dev; DEBUGASSERT(priv != NULL && buffer != NULL && buflen > 0); diff --git a/arch/arm/src/stm32/stm32_serial.c b/arch/arm/src/stm32/stm32_serial.c index 7aa362c38f..8e484dc1a3 100644 --- a/arch/arm/src/stm32/stm32_serial.c +++ b/arch/arm/src/stm32/stm32_serial.c @@ -80,7 +80,7 @@ #ifdef SERIAL_HAVE_DMA -# if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) /* Verify that DMA has been enabled and the DMA channel has been defined. */ @@ -198,7 +198,7 @@ defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \ defined(CONFIG_STM32_STM32F37XX) # define CONFIG_USART_DMAPRIO DMA_CCR_PRIMED -# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define CONFIG_USART_DMAPRIO DMA_SCR_PRIMED # else # error "Unknown STM32 DMA" @@ -210,7 +210,7 @@ # if (CONFIG_USART_DMAPRIO & ~DMA_CCR_PL_MASK) != 0 # error "Illegal value for CONFIG_USART_DMAPRIO" # endif -# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # if (CONFIG_USART_DMAPRIO & ~DMA_SCR_PL_MASK) != 0 # error "Illegal value for CONFIG_USART_DMAPRIO" # endif @@ -220,7 +220,7 @@ /* DMA control word */ -# if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define SERIAL_DMA_CONTROL_WORD \ (DMA_SCR_DIR_P2M | \ DMA_SCR_CIRC | \ @@ -1265,7 +1265,7 @@ static void up_set_format(struct uart_dev_s *dev) fraction = (usartdiv32 - (mantissa << 5) + 1) >> 1; -#if defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F4XXX) /* The F4 supports 8 X in oversampling additional to the * standard oversampling by 16. * diff --git a/arch/arm/src/stm32/stm32_spi.c b/arch/arm/src/stm32/stm32_spi.c index 3a4a7c8bf9..cab5655be3 100644 --- a/arch/arm/src/stm32/stm32_spi.c +++ b/arch/arm/src/stm32/stm32_spi.c @@ -111,7 +111,7 @@ # define SPI_DMA_PRIO CONFIG_SPI_DMAPRIO # elif defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32L15XX) # define SPI_DMA_PRIO DMA_CCR_PRIMED -# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define SPI_DMA_PRIO DMA_SCR_PRIMED # else # error "Unknown STM32 DMA" @@ -121,7 +121,7 @@ # if (SPI_DMA_PRIO & ~DMA_CCR_PL_MASK) != 0 # error "Illegal value for CONFIG_SPI_DMAPRIO" # endif -# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # if (SPI_DMA_PRIO & ~DMA_SCR_PL_MASK) != 0 # error "Illegal value for CONFIG_SPI_DMAPRIO" # endif @@ -143,7 +143,7 @@ # define SPI_TXDMA8_CONFIG (SPI_DMA_PRIO|DMA_CCR_MSIZE_8BITS |DMA_CCR_PSIZE_8BITS |DMA_CCR_MINC|DMA_CCR_DIR) # define SPI_TXDMA16NULL_CONFIG (SPI_DMA_PRIO|DMA_CCR_MSIZE_8BITS |DMA_CCR_PSIZE_16BITS |DMA_CCR_DIR) # define SPI_TXDMA8NULL_CONFIG (SPI_DMA_PRIO|DMA_CCR_MSIZE_8BITS |DMA_CCR_PSIZE_8BITS |DMA_CCR_DIR) -#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define SPI_RXDMA16_CONFIG (SPI_DMA_PRIO|DMA_SCR_MSIZE_16BITS|DMA_SCR_PSIZE_16BITS|DMA_SCR_MINC|DMA_SCR_DIR_P2M) # define SPI_RXDMA8_CONFIG (SPI_DMA_PRIO|DMA_SCR_MSIZE_8BITS |DMA_SCR_PSIZE_8BITS |DMA_SCR_MINC|DMA_SCR_DIR_P2M) # define SPI_RXDMA16NULL_CONFIG (SPI_DMA_PRIO|DMA_SCR_MSIZE_8BITS |DMA_SCR_PSIZE_16BITS |DMA_SCR_DIR_P2M) diff --git a/arch/arm/src/stm32/stm32_syscfg.h b/arch/arm/src/stm32/stm32_syscfg.h index 9d832b0f2e..917de13031 100644 --- a/arch/arm/src/stm32/stm32_syscfg.h +++ b/arch/arm/src/stm32/stm32_syscfg.h @@ -53,7 +53,7 @@ # include "chip/stm32f33xxx_syscfg.h" #elif defined(CONFIG_STM32_STM32F37XX) # include "chip/stm32f37xxx_syscfg.h" -#elif defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F4XXX) # include "chip/stm32f40xxx_syscfg.h" #endif diff --git a/arch/arm/src/stm32/stm32_tim_lowerhalf.c b/arch/arm/src/stm32/stm32_tim_lowerhalf.c index cea5e2c272..21e7fbaf71 100644 --- a/arch/arm/src/stm32/stm32_tim_lowerhalf.c +++ b/arch/arm/src/stm32/stm32_tim_lowerhalf.c @@ -73,7 +73,7 @@ #else # define STM32_TIM2_RES 32 #endif -#if defined(CONFIG_STM32_STM32L20XX) || defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32L20XX) || defined(CONFIG_STM32_STM32F4XXX) # define STM32_TIM3_RES 32 # define STM32_TIM4_RES 32 #else diff --git a/arch/arm/src/stm32/stm32_uart.h b/arch/arm/src/stm32/stm32_uart.h index fe2542cfa6..e7c058ba6c 100644 --- a/arch/arm/src/stm32/stm32_uart.h +++ b/arch/arm/src/stm32/stm32_uart.h @@ -53,7 +53,7 @@ #elif defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX) || \ defined(CONFIG_STM32_STM32F37XX) # include "chip/stm32f30xxx_uart.h" -#elif defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F4XXX) # include "chip/stm32f40xxx_uart.h" #else # error "Unsupported STM32 UART" diff --git a/arch/arm/src/stm32/stm32_wwdg.c b/arch/arm/src/stm32/stm32_wwdg.c index c0cb34f1f7..79d34656da 100644 --- a/arch/arm/src/stm32/stm32_wwdg.c +++ b/arch/arm/src/stm32/stm32_wwdg.c @@ -790,7 +790,7 @@ void stm32_wwdginitialize(FAR const char *devpath) defined(CONFIG_STM32_JTAG_SW_ENABLE) { #if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F30XX) || \ - defined(CONFIG_STM32_STM32F40XX) || defined(CONFIG_STM32_STM32L15XX) + defined(CONFIG_STM32_STM32F4XXX) || defined(CONFIG_STM32_STM32L15XX) uint32_t cr = getreg32(STM32_DBGMCU_APB1_FZ); cr |= DBGMCU_APB1_WWDGSTOP; putreg32(cr, STM32_DBGMCU_APB1_FZ); diff --git a/arch/arm/src/stm32/stm32f40xxx_dma.c b/arch/arm/src/stm32/stm32f40xxx_dma.c index 1824c76bf4..54a0a97845 100644 --- a/arch/arm/src/stm32/stm32f40xxx_dma.c +++ b/arch/arm/src/stm32/stm32f40xxx_dma.c @@ -59,7 +59,7 @@ * as well?) */ -#if defined(CONFIG_STM32_STM32F40XX) +#if defined(CONFIG_STM32_STM32F4XXX) /**************************************************************************** * Pre-processor Definitions @@ -1050,4 +1050,4 @@ void stm32_dmadump(DMA_HANDLE handle, const struct stm32_dmaregs_s *regs, } #endif -#endif /* CONFIG_STM32_STM32F40XX */ +#endif /* CONFIG_STM32_STM32F4XXX */ diff --git a/arch/arm/src/stm32/stm32f40xxx_i2c.c b/arch/arm/src/stm32/stm32f40xxx_i2c.c index 1eccabd4cd..da50766f3f 100644 --- a/arch/arm/src/stm32/stm32f40xxx_i2c.c +++ b/arch/arm/src/stm32/stm32f40xxx_i2c.c @@ -105,7 +105,7 @@ /* Experimentally enabled for STM32L15XX */ #if defined(CONFIG_STM32_STM32L15XX) || defined(CONFIG_STM32_STM32F10XX) || \ - defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) + defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) /************************************************************************************ * Pre-processor Definitions @@ -155,7 +155,7 @@ #elif defined(CONFIG_STM32_STM32F10XX) # define I2C_OUTPUT (GPIO_OUTPUT | GPIO_OUTPUT_SET | GPIO_CNF_OUTOD | \ GPIO_MODE_50MHz) -#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) # define I2C_OUTPUT (GPIO_OUTPUT | GPIO_FLOAT | GPIO_OPENDRAIN |\ GPIO_SPEED_50MHz | GPIO_OUTPUT_SET) #endif @@ -2747,5 +2747,5 @@ int stm32_i2cbus_uninitialize(FAR struct i2c_master_s *dev) return OK; } -#endif /* CONFIG_STM32_STM32F10XX || CONFIG_STM32_STM32F20XX || CONFIG_STM32_STM32F40XX */ +#endif /* CONFIG_STM32_STM32F10XX || CONFIG_STM32_STM32F20XX || CONFIG_STM32_STM32F4XXX */ #endif /* CONFIG_STM32_I2C1 || CONFIG_STM32_I2C2 || CONFIG_STM32_I2C3 */ diff --git a/configs/clicker2-stm32/knsh/defconfig b/configs/clicker2-stm32/knsh/defconfig index b75ba40a8d..aa53f6e5c6 100644 --- a/configs/clicker2-stm32/knsh/defconfig +++ b/configs/clicker2-stm32/knsh/defconfig @@ -326,7 +326,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/clicker2-stm32/mrf24j40-6lowpan/defconfig b/configs/clicker2-stm32/mrf24j40-6lowpan/defconfig index 7a3d03e441..ff1954f9ea 100644 --- a/configs/clicker2-stm32/mrf24j40-6lowpan/defconfig +++ b/configs/clicker2-stm32/mrf24j40-6lowpan/defconfig @@ -318,7 +318,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/clicker2-stm32/mrf24j40-mac/defconfig b/configs/clicker2-stm32/mrf24j40-mac/defconfig index 7ee79a1d4a..7c17224ff8 100644 --- a/configs/clicker2-stm32/mrf24j40-mac/defconfig +++ b/configs/clicker2-stm32/mrf24j40-mac/defconfig @@ -319,7 +319,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/clicker2-stm32/mrf24j40-starhub/defconfig b/configs/clicker2-stm32/mrf24j40-starhub/defconfig index 45000c97af..b66d7ec7eb 100644 --- a/configs/clicker2-stm32/mrf24j40-starhub/defconfig +++ b/configs/clicker2-stm32/mrf24j40-starhub/defconfig @@ -318,7 +318,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/clicker2-stm32/mrf24j40-starpoint/defconfig b/configs/clicker2-stm32/mrf24j40-starpoint/defconfig index 99c76b0ead..f542507c13 100644 --- a/configs/clicker2-stm32/mrf24j40-starpoint/defconfig +++ b/configs/clicker2-stm32/mrf24j40-starpoint/defconfig @@ -318,7 +318,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/clicker2-stm32/nsh/defconfig b/configs/clicker2-stm32/nsh/defconfig index 0fb4bd7cdc..a81215fcf8 100644 --- a/configs/clicker2-stm32/nsh/defconfig +++ b/configs/clicker2-stm32/nsh/defconfig @@ -319,7 +319,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/clicker2-stm32/usbnsh/defconfig b/configs/clicker2-stm32/usbnsh/defconfig index 3db2eabaaf..11d5ac8032 100644 --- a/configs/clicker2-stm32/usbnsh/defconfig +++ b/configs/clicker2-stm32/usbnsh/defconfig @@ -319,7 +319,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/cloudctrl/nsh/defconfig b/configs/cloudctrl/nsh/defconfig index 6d04d18d25..fa60855177 100644 --- a/configs/cloudctrl/nsh/defconfig +++ b/configs/cloudctrl/nsh/defconfig @@ -328,7 +328,7 @@ CONFIG_STM32_CONNECTIVITYLINE=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/fire-stm32v2/nsh/defconfig b/configs/fire-stm32v2/nsh/defconfig index b1f0cb08c0..ff24314cc7 100644 --- a/configs/fire-stm32v2/nsh/defconfig +++ b/configs/fire-stm32v2/nsh/defconfig @@ -328,7 +328,7 @@ CONFIG_STM32_HIGHDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/hymini-stm32v/nsh/defconfig b/configs/hymini-stm32v/nsh/defconfig index 2178d7a29a..f3cb9a1b8a 100644 --- a/configs/hymini-stm32v/nsh/defconfig +++ b/configs/hymini-stm32v/nsh/defconfig @@ -313,7 +313,7 @@ CONFIG_STM32_HIGHDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/hymini-stm32v/nsh2/defconfig b/configs/hymini-stm32v/nsh2/defconfig index 4e3a6fdb4a..f27897f869 100644 --- a/configs/hymini-stm32v/nsh2/defconfig +++ b/configs/hymini-stm32v/nsh2/defconfig @@ -313,7 +313,7 @@ CONFIG_STM32_HIGHDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/hymini-stm32v/usbmsc/defconfig b/configs/hymini-stm32v/usbmsc/defconfig index 95ebfa83d3..19e19949ba 100644 --- a/configs/hymini-stm32v/usbmsc/defconfig +++ b/configs/hymini-stm32v/usbmsc/defconfig @@ -313,7 +313,7 @@ CONFIG_STM32_HIGHDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/hymini-stm32v/usbnsh/defconfig b/configs/hymini-stm32v/usbnsh/defconfig index 745d7c0730..b7bd587e78 100644 --- a/configs/hymini-stm32v/usbnsh/defconfig +++ b/configs/hymini-stm32v/usbnsh/defconfig @@ -313,7 +313,7 @@ CONFIG_STM32_HIGHDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/hymini-stm32v/usbserial/defconfig b/configs/hymini-stm32v/usbserial/defconfig index 045cdccaa0..bc8f076a10 100644 --- a/configs/hymini-stm32v/usbserial/defconfig +++ b/configs/hymini-stm32v/usbserial/defconfig @@ -313,7 +313,7 @@ CONFIG_STM32_HIGHDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/maple/nsh/defconfig b/configs/maple/nsh/defconfig index 3d3dc6c516..48719eb489 100644 --- a/configs/maple/nsh/defconfig +++ b/configs/maple/nsh/defconfig @@ -313,7 +313,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/maple/nx/defconfig b/configs/maple/nx/defconfig index 90d72dd22c..d166bf7fec 100644 --- a/configs/maple/nx/defconfig +++ b/configs/maple/nx/defconfig @@ -313,7 +313,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/maple/usbnsh/defconfig b/configs/maple/usbnsh/defconfig index fae6560d13..0c1afea5ea 100644 --- a/configs/maple/usbnsh/defconfig +++ b/configs/maple/usbnsh/defconfig @@ -313,7 +313,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/mikroe-stm32f4/fulldemo/defconfig b/configs/mikroe-stm32f4/fulldemo/defconfig index 8195102e45..2b653c380b 100644 --- a/configs/mikroe-stm32f4/fulldemo/defconfig +++ b/configs/mikroe-stm32f4/fulldemo/defconfig @@ -320,7 +320,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/mikroe-stm32f4/kostest/defconfig b/configs/mikroe-stm32f4/kostest/defconfig index 1acecc4281..fd4bc59b35 100644 --- a/configs/mikroe-stm32f4/kostest/defconfig +++ b/configs/mikroe-stm32f4/kostest/defconfig @@ -326,7 +326,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/mikroe-stm32f4/nsh/defconfig b/configs/mikroe-stm32f4/nsh/defconfig index 6ebe81c54c..abb5d3bf2e 100644 --- a/configs/mikroe-stm32f4/nsh/defconfig +++ b/configs/mikroe-stm32f4/nsh/defconfig @@ -320,7 +320,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/mikroe-stm32f4/nx/defconfig b/configs/mikroe-stm32f4/nx/defconfig index a90fc6ef0a..f59be60e5a 100644 --- a/configs/mikroe-stm32f4/nx/defconfig +++ b/configs/mikroe-stm32f4/nx/defconfig @@ -319,7 +319,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/mikroe-stm32f4/nxlines/defconfig b/configs/mikroe-stm32f4/nxlines/defconfig index 23e48763ec..8130023159 100644 --- a/configs/mikroe-stm32f4/nxlines/defconfig +++ b/configs/mikroe-stm32f4/nxlines/defconfig @@ -319,7 +319,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/mikroe-stm32f4/nxtext/defconfig b/configs/mikroe-stm32f4/nxtext/defconfig index c3575a1754..0fa6c4097b 100644 --- a/configs/mikroe-stm32f4/nxtext/defconfig +++ b/configs/mikroe-stm32f4/nxtext/defconfig @@ -319,7 +319,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/mikroe-stm32f4/usbnsh/defconfig b/configs/mikroe-stm32f4/usbnsh/defconfig index 98b77895a6..1155d13725 100644 --- a/configs/mikroe-stm32f4/usbnsh/defconfig +++ b/configs/mikroe-stm32f4/usbnsh/defconfig @@ -320,7 +320,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/nucleo-f303re/adc/defconfig b/configs/nucleo-f303re/adc/defconfig index b63a7eb712..c22d10454f 100644 --- a/configs/nucleo-f303re/adc/defconfig +++ b/configs/nucleo-f303re/adc/defconfig @@ -315,7 +315,7 @@ CONFIG_STM32_STM32F30XX=y CONFIG_STM32_STM32F303=y # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/nucleo-f303re/can/defconfig b/configs/nucleo-f303re/can/defconfig index 4fab471101..7bea847d7a 100644 --- a/configs/nucleo-f303re/can/defconfig +++ b/configs/nucleo-f303re/can/defconfig @@ -318,7 +318,7 @@ CONFIG_STM32_STM32F30XX=y CONFIG_STM32_STM32F303=y # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/nucleo-f303re/hello/defconfig b/configs/nucleo-f303re/hello/defconfig index c2ed153f8e..681e231868 100644 --- a/configs/nucleo-f303re/hello/defconfig +++ b/configs/nucleo-f303re/hello/defconfig @@ -314,7 +314,7 @@ CONFIG_STM32_STM32F30XX=y CONFIG_STM32_STM32F303=y # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/nucleo-f303re/nxlines/defconfig b/configs/nucleo-f303re/nxlines/defconfig index 5d3104d9b3..c3b06550d7 100644 --- a/configs/nucleo-f303re/nxlines/defconfig +++ b/configs/nucleo-f303re/nxlines/defconfig @@ -315,7 +315,7 @@ CONFIG_STM32_STM32F30XX=y CONFIG_STM32_STM32F303=y # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/nucleo-f303re/pwm/defconfig b/configs/nucleo-f303re/pwm/defconfig index 98720e69b6..02327b59a2 100644 --- a/configs/nucleo-f303re/pwm/defconfig +++ b/configs/nucleo-f303re/pwm/defconfig @@ -313,7 +313,7 @@ CONFIG_STM32_STM32F30XX=y CONFIG_STM32_STM32F303=y # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/nucleo-f303re/serialrx/defconfig b/configs/nucleo-f303re/serialrx/defconfig index 8b14405c4a..3cfbafe5c7 100644 --- a/configs/nucleo-f303re/serialrx/defconfig +++ b/configs/nucleo-f303re/serialrx/defconfig @@ -316,7 +316,7 @@ CONFIG_STM32_STM32F30XX=y CONFIG_STM32_STM32F303=y # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/nucleo-f303re/uavcan/defconfig b/configs/nucleo-f303re/uavcan/defconfig index 8a8f69e455..7e2cafee66 100644 --- a/configs/nucleo-f303re/uavcan/defconfig +++ b/configs/nucleo-f303re/uavcan/defconfig @@ -319,7 +319,7 @@ CONFIG_STM32_STM32F30XX=y CONFIG_STM32_STM32F303=y # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/nucleo-f334r8/adc/defconfig b/configs/nucleo-f334r8/adc/defconfig index 8e3bf15ba0..bec89c1f7b 100644 --- a/configs/nucleo-f334r8/adc/defconfig +++ b/configs/nucleo-f334r8/adc/defconfig @@ -346,7 +346,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set CONFIG_STM32_STM32F33XX=y # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/nucleo-f334r8/nsh/defconfig b/configs/nucleo-f334r8/nsh/defconfig index 86849afa1c..0117dbb5e5 100644 --- a/configs/nucleo-f334r8/nsh/defconfig +++ b/configs/nucleo-f334r8/nsh/defconfig @@ -344,7 +344,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set CONFIG_STM32_STM32F33XX=y # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/nucleo-f4x1re/f401-nsh-clang/defconfig b/configs/nucleo-f4x1re/f401-nsh-clang/defconfig index 1e70d31d46..4fe4a8f283 100644 --- a/configs/nucleo-f4x1re/f401-nsh-clang/defconfig +++ b/configs/nucleo-f4x1re/f401-nsh-clang/defconfig @@ -320,7 +320,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y CONFIG_STM32_STM32F401=y # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/nucleo-f4x1re/f401-nsh/defconfig b/configs/nucleo-f4x1re/f401-nsh/defconfig index 34b6503df7..d044d10eb1 100644 --- a/configs/nucleo-f4x1re/f401-nsh/defconfig +++ b/configs/nucleo-f4x1re/f401-nsh/defconfig @@ -320,7 +320,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y CONFIG_STM32_STM32F401=y # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/nucleo-f4x1re/f411-nsh/defconfig b/configs/nucleo-f4x1re/f411-nsh/defconfig index 65bbd4052e..3a63c316b4 100644 --- a/configs/nucleo-f4x1re/f411-nsh/defconfig +++ b/configs/nucleo-f4x1re/f411-nsh/defconfig @@ -320,7 +320,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set CONFIG_STM32_STM32F411=y diff --git a/configs/olimex-stm32-e407/discover/defconfig b/configs/olimex-stm32-e407/discover/defconfig index 67717307c5..de31c02891 100644 --- a/configs/olimex-stm32-e407/discover/defconfig +++ b/configs/olimex-stm32-e407/discover/defconfig @@ -321,7 +321,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/olimex-stm32-e407/netnsh/defconfig b/configs/olimex-stm32-e407/netnsh/defconfig index 06367d3c0f..5de8733eee 100644 --- a/configs/olimex-stm32-e407/netnsh/defconfig +++ b/configs/olimex-stm32-e407/netnsh/defconfig @@ -321,7 +321,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/olimex-stm32-e407/nsh/defconfig b/configs/olimex-stm32-e407/nsh/defconfig index aadadcc642..f59d4aa47e 100644 --- a/configs/olimex-stm32-e407/nsh/defconfig +++ b/configs/olimex-stm32-e407/nsh/defconfig @@ -320,7 +320,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/olimex-stm32-e407/telnetd/defconfig b/configs/olimex-stm32-e407/telnetd/defconfig index eaf4e161e3..80c75f2cba 100644 --- a/configs/olimex-stm32-e407/telnetd/defconfig +++ b/configs/olimex-stm32-e407/telnetd/defconfig @@ -321,7 +321,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/olimex-stm32-e407/usbnsh/defconfig b/configs/olimex-stm32-e407/usbnsh/defconfig index 97476cc594..8052505521 100644 --- a/configs/olimex-stm32-e407/usbnsh/defconfig +++ b/configs/olimex-stm32-e407/usbnsh/defconfig @@ -320,7 +320,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/olimex-stm32-e407/webserver/defconfig b/configs/olimex-stm32-e407/webserver/defconfig index a1587edd55..59ed1629ab 100644 --- a/configs/olimex-stm32-e407/webserver/defconfig +++ b/configs/olimex-stm32-e407/webserver/defconfig @@ -321,7 +321,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/olimex-stm32-h405/usbnsh/defconfig b/configs/olimex-stm32-h405/usbnsh/defconfig index e9e635c56e..22eff18b2a 100644 --- a/configs/olimex-stm32-h405/usbnsh/defconfig +++ b/configs/olimex-stm32-h405/usbnsh/defconfig @@ -326,7 +326,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/olimex-stm32-h407/nsh/defconfig b/configs/olimex-stm32-h407/nsh/defconfig index 9c63f28284..43f4cc1a21 100644 --- a/configs/olimex-stm32-h407/nsh/defconfig +++ b/configs/olimex-stm32-h407/nsh/defconfig @@ -320,7 +320,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/olimex-stm32-p107/nsh/defconfig b/configs/olimex-stm32-p107/nsh/defconfig index ad911d78c5..73b23d3263 100644 --- a/configs/olimex-stm32-p107/nsh/defconfig +++ b/configs/olimex-stm32-p107/nsh/defconfig @@ -320,7 +320,7 @@ CONFIG_STM32_CONNECTIVITYLINE=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/olimex-stm32-p207/nsh/defconfig b/configs/olimex-stm32-p207/nsh/defconfig index 9426e3101a..a15d8576b1 100644 --- a/configs/olimex-stm32-p207/nsh/defconfig +++ b/configs/olimex-stm32-p207/nsh/defconfig @@ -328,7 +328,7 @@ CONFIG_STM32_STM32F207=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/olimex-stm32-p407/knsh/defconfig b/configs/olimex-stm32-p407/knsh/defconfig index b1fdc541d1..b1fc998279 100644 --- a/configs/olimex-stm32-p407/knsh/defconfig +++ b/configs/olimex-stm32-p407/knsh/defconfig @@ -327,7 +327,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/olimex-stm32-p407/nsh/defconfig b/configs/olimex-stm32-p407/nsh/defconfig index ea3cb293ea..e3d5381f67 100644 --- a/configs/olimex-stm32-p407/nsh/defconfig +++ b/configs/olimex-stm32-p407/nsh/defconfig @@ -324,7 +324,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/olimexino-stm32/can/defconfig b/configs/olimexino-stm32/can/defconfig index 3546af6d67..76c9d6239b 100644 --- a/configs/olimexino-stm32/can/defconfig +++ b/configs/olimexino-stm32/can/defconfig @@ -324,7 +324,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/olimexino-stm32/composite/defconfig b/configs/olimexino-stm32/composite/defconfig index 1ac088cadd..2d60936813 100644 --- a/configs/olimexino-stm32/composite/defconfig +++ b/configs/olimexino-stm32/composite/defconfig @@ -319,7 +319,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/olimexino-stm32/nsh/defconfig b/configs/olimexino-stm32/nsh/defconfig index 5adb8a0072..68f598a02a 100644 --- a/configs/olimexino-stm32/nsh/defconfig +++ b/configs/olimexino-stm32/nsh/defconfig @@ -319,7 +319,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/olimexino-stm32/smallnsh/defconfig b/configs/olimexino-stm32/smallnsh/defconfig index 6eee73059c..3ddc8f9651 100644 --- a/configs/olimexino-stm32/smallnsh/defconfig +++ b/configs/olimexino-stm32/smallnsh/defconfig @@ -324,7 +324,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/olimexino-stm32/tiny/defconfig b/configs/olimexino-stm32/tiny/defconfig index 9c3336dde2..174cb07e13 100644 --- a/configs/olimexino-stm32/tiny/defconfig +++ b/configs/olimexino-stm32/tiny/defconfig @@ -324,7 +324,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/photon/nsh/defconfig b/configs/photon/nsh/defconfig index ec4b9b09da..c27104e8ad 100644 --- a/configs/photon/nsh/defconfig +++ b/configs/photon/nsh/defconfig @@ -319,7 +319,7 @@ CONFIG_STM32_STM32F205=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/photon/usbnsh/defconfig b/configs/photon/usbnsh/defconfig index 83aa8cc706..2b6748179f 100644 --- a/configs/photon/usbnsh/defconfig +++ b/configs/photon/usbnsh/defconfig @@ -319,7 +319,7 @@ CONFIG_STM32_STM32F205=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/photon/wlan/defconfig b/configs/photon/wlan/defconfig index a368939cd5..a53bb3e432 100644 --- a/configs/photon/wlan/defconfig +++ b/configs/photon/wlan/defconfig @@ -360,7 +360,7 @@ CONFIG_STM32_STM32F205=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/shenzhou/nsh/defconfig b/configs/shenzhou/nsh/defconfig index 19fd332296..fb824c4bc6 100644 --- a/configs/shenzhou/nsh/defconfig +++ b/configs/shenzhou/nsh/defconfig @@ -318,7 +318,7 @@ CONFIG_STM32_CONNECTIVITYLINE=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/shenzhou/nxwm/defconfig b/configs/shenzhou/nxwm/defconfig index 9dfa5ad375..bbca876c3a 100644 --- a/configs/shenzhou/nxwm/defconfig +++ b/configs/shenzhou/nxwm/defconfig @@ -329,7 +329,7 @@ CONFIG_STM32_CONNECTIVITYLINE=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/shenzhou/thttpd/defconfig b/configs/shenzhou/thttpd/defconfig index f2f2f74237..d5bbadb32d 100644 --- a/configs/shenzhou/thttpd/defconfig +++ b/configs/shenzhou/thttpd/defconfig @@ -319,7 +319,7 @@ CONFIG_STM32_CONNECTIVITYLINE=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/spark/composite/defconfig b/configs/spark/composite/defconfig index e0350b7852..c701bfd3e0 100644 --- a/configs/spark/composite/defconfig +++ b/configs/spark/composite/defconfig @@ -313,7 +313,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/spark/nsh/defconfig b/configs/spark/nsh/defconfig index a404c2bc70..925ab224fa 100644 --- a/configs/spark/nsh/defconfig +++ b/configs/spark/nsh/defconfig @@ -313,7 +313,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/spark/usbmsc/defconfig b/configs/spark/usbmsc/defconfig index 7face48d5c..35e14832bb 100644 --- a/configs/spark/usbmsc/defconfig +++ b/configs/spark/usbmsc/defconfig @@ -313,7 +313,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/spark/usbnsh/defconfig b/configs/spark/usbnsh/defconfig index 3d0184ad1f..4cf69d5db0 100644 --- a/configs/spark/usbnsh/defconfig +++ b/configs/spark/usbnsh/defconfig @@ -313,7 +313,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/spark/usbserial/defconfig b/configs/spark/usbserial/defconfig index 70835160d5..671433ae99 100644 --- a/configs/spark/usbserial/defconfig +++ b/configs/spark/usbserial/defconfig @@ -313,7 +313,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm3210e-eval/composite/defconfig b/configs/stm3210e-eval/composite/defconfig index cb7ad87fd0..f702057f8f 100644 --- a/configs/stm3210e-eval/composite/defconfig +++ b/configs/stm3210e-eval/composite/defconfig @@ -323,7 +323,7 @@ CONFIG_STM32_HIGHDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm3210e-eval/nsh/defconfig b/configs/stm3210e-eval/nsh/defconfig index 8207333ab1..087ccde397 100644 --- a/configs/stm3210e-eval/nsh/defconfig +++ b/configs/stm3210e-eval/nsh/defconfig @@ -324,7 +324,7 @@ CONFIG_STM32_HIGHDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm3210e-eval/nsh2/defconfig b/configs/stm3210e-eval/nsh2/defconfig index 83d246522d..2493dd648f 100644 --- a/configs/stm3210e-eval/nsh2/defconfig +++ b/configs/stm3210e-eval/nsh2/defconfig @@ -323,7 +323,7 @@ CONFIG_STM32_HIGHDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm3210e-eval/nx/defconfig b/configs/stm3210e-eval/nx/defconfig index 8208105130..bd267d89b0 100644 --- a/configs/stm3210e-eval/nx/defconfig +++ b/configs/stm3210e-eval/nx/defconfig @@ -323,7 +323,7 @@ CONFIG_STM32_HIGHDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm3210e-eval/nxterm/defconfig b/configs/stm3210e-eval/nxterm/defconfig index c6fa59410d..fb23520c19 100644 --- a/configs/stm3210e-eval/nxterm/defconfig +++ b/configs/stm3210e-eval/nxterm/defconfig @@ -323,7 +323,7 @@ CONFIG_STM32_HIGHDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm3210e-eval/pm/defconfig b/configs/stm3210e-eval/pm/defconfig index bc195374f6..e5b5278e11 100644 --- a/configs/stm3210e-eval/pm/defconfig +++ b/configs/stm3210e-eval/pm/defconfig @@ -323,7 +323,7 @@ CONFIG_STM32_HIGHDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm3210e-eval/usbmsc/defconfig b/configs/stm3210e-eval/usbmsc/defconfig index 47d7658081..bd1abad73f 100644 --- a/configs/stm3210e-eval/usbmsc/defconfig +++ b/configs/stm3210e-eval/usbmsc/defconfig @@ -314,7 +314,7 @@ CONFIG_STM32_HIGHDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm3210e-eval/usbserial/defconfig b/configs/stm3210e-eval/usbserial/defconfig index a586efc92f..55aa3079ee 100644 --- a/configs/stm3210e-eval/usbserial/defconfig +++ b/configs/stm3210e-eval/usbserial/defconfig @@ -314,7 +314,7 @@ CONFIG_STM32_HIGHDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm3220g-eval/dhcpd/defconfig b/configs/stm3220g-eval/dhcpd/defconfig index 5fdd9cd651..fc608f274c 100644 --- a/configs/stm3220g-eval/dhcpd/defconfig +++ b/configs/stm3220g-eval/dhcpd/defconfig @@ -329,7 +329,7 @@ CONFIG_STM32_STM32F207=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm3220g-eval/nettest/defconfig b/configs/stm3220g-eval/nettest/defconfig index df5782fe87..aeedffc2e8 100644 --- a/configs/stm3220g-eval/nettest/defconfig +++ b/configs/stm3220g-eval/nettest/defconfig @@ -328,7 +328,7 @@ CONFIG_STM32_STM32F207=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm3220g-eval/nsh/defconfig b/configs/stm3220g-eval/nsh/defconfig index 1ecef98b39..744a59511e 100644 --- a/configs/stm3220g-eval/nsh/defconfig +++ b/configs/stm3220g-eval/nsh/defconfig @@ -319,7 +319,7 @@ CONFIG_STM32_STM32F207=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm3220g-eval/nsh2/defconfig b/configs/stm3220g-eval/nsh2/defconfig index de128433be..85862d37d7 100644 --- a/configs/stm3220g-eval/nsh2/defconfig +++ b/configs/stm3220g-eval/nsh2/defconfig @@ -328,7 +328,7 @@ CONFIG_STM32_STM32F207=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm3220g-eval/nxwm/defconfig b/configs/stm3220g-eval/nxwm/defconfig index 847e4f77e8..5b774a672a 100644 --- a/configs/stm3220g-eval/nxwm/defconfig +++ b/configs/stm3220g-eval/nxwm/defconfig @@ -329,7 +329,7 @@ CONFIG_STM32_STM32F207=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm3220g-eval/telnetd/defconfig b/configs/stm3220g-eval/telnetd/defconfig index a0ab8932f4..9e7b12df3d 100644 --- a/configs/stm3220g-eval/telnetd/defconfig +++ b/configs/stm3220g-eval/telnetd/defconfig @@ -329,7 +329,7 @@ CONFIG_STM32_STM32F207=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm3240g-eval/dhcpd/defconfig b/configs/stm3240g-eval/dhcpd/defconfig index d3d3dcffff..0af9679653 100644 --- a/configs/stm3240g-eval/dhcpd/defconfig +++ b/configs/stm3240g-eval/dhcpd/defconfig @@ -330,7 +330,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm3240g-eval/discover/defconfig b/configs/stm3240g-eval/discover/defconfig index 1d9a91bb46..6d5e900e96 100644 --- a/configs/stm3240g-eval/discover/defconfig +++ b/configs/stm3240g-eval/discover/defconfig @@ -320,7 +320,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm3240g-eval/knxwm/defconfig b/configs/stm3240g-eval/knxwm/defconfig index 789f7631fc..c405722c55 100644 --- a/configs/stm3240g-eval/knxwm/defconfig +++ b/configs/stm3240g-eval/knxwm/defconfig @@ -337,7 +337,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm3240g-eval/nettest/defconfig b/configs/stm3240g-eval/nettest/defconfig index 1e890f329c..54feb7e252 100644 --- a/configs/stm3240g-eval/nettest/defconfig +++ b/configs/stm3240g-eval/nettest/defconfig @@ -329,7 +329,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm3240g-eval/nsh/defconfig b/configs/stm3240g-eval/nsh/defconfig index 99c8ece468..69e8ebd541 100644 --- a/configs/stm3240g-eval/nsh/defconfig +++ b/configs/stm3240g-eval/nsh/defconfig @@ -330,7 +330,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm3240g-eval/nsh2/defconfig b/configs/stm3240g-eval/nsh2/defconfig index 1c35e4babb..2e5939c027 100644 --- a/configs/stm3240g-eval/nsh2/defconfig +++ b/configs/stm3240g-eval/nsh2/defconfig @@ -329,7 +329,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm3240g-eval/nxterm/defconfig b/configs/stm3240g-eval/nxterm/defconfig index 411476cbd6..f70e9e86d1 100644 --- a/configs/stm3240g-eval/nxterm/defconfig +++ b/configs/stm3240g-eval/nxterm/defconfig @@ -330,7 +330,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm3240g-eval/nxwm/defconfig b/configs/stm3240g-eval/nxwm/defconfig index 467fd105a9..e08a81d10c 100644 --- a/configs/stm3240g-eval/nxwm/defconfig +++ b/configs/stm3240g-eval/nxwm/defconfig @@ -330,7 +330,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm3240g-eval/telnetd/defconfig b/configs/stm3240g-eval/telnetd/defconfig index a6e171b9e2..8d58341d60 100644 --- a/configs/stm3240g-eval/telnetd/defconfig +++ b/configs/stm3240g-eval/telnetd/defconfig @@ -330,7 +330,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm3240g-eval/webserver/defconfig b/configs/stm3240g-eval/webserver/defconfig index 8d4e93adb5..3bd0139d13 100644 --- a/configs/stm3240g-eval/webserver/defconfig +++ b/configs/stm3240g-eval/webserver/defconfig @@ -319,7 +319,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm3240g-eval/xmlrpc/defconfig b/configs/stm3240g-eval/xmlrpc/defconfig index 63ce7679db..163859adb8 100644 --- a/configs/stm3240g-eval/xmlrpc/defconfig +++ b/configs/stm3240g-eval/xmlrpc/defconfig @@ -320,7 +320,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm32_tiny/nsh/defconfig b/configs/stm32_tiny/nsh/defconfig index d1aacaf710..b94d3da940 100644 --- a/configs/stm32_tiny/nsh/defconfig +++ b/configs/stm32_tiny/nsh/defconfig @@ -314,7 +314,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm32_tiny/usbnsh/defconfig b/configs/stm32_tiny/usbnsh/defconfig index 3466aa3bf2..bb7587f8f6 100644 --- a/configs/stm32_tiny/usbnsh/defconfig +++ b/configs/stm32_tiny/usbnsh/defconfig @@ -313,7 +313,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm32butterfly2/nsh/defconfig b/configs/stm32butterfly2/nsh/defconfig index 91f4d1c2e2..58d93b48e4 100644 --- a/configs/stm32butterfly2/nsh/defconfig +++ b/configs/stm32butterfly2/nsh/defconfig @@ -319,7 +319,7 @@ CONFIG_STM32_CONNECTIVITYLINE=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm32butterfly2/nshnet/defconfig b/configs/stm32butterfly2/nshnet/defconfig index a2d0055386..6ceb5d6a61 100644 --- a/configs/stm32butterfly2/nshnet/defconfig +++ b/configs/stm32butterfly2/nshnet/defconfig @@ -319,7 +319,7 @@ CONFIG_STM32_CONNECTIVITYLINE=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm32butterfly2/nshusbdev/defconfig b/configs/stm32butterfly2/nshusbdev/defconfig index f57578e7d0..f28a8b05c9 100644 --- a/configs/stm32butterfly2/nshusbdev/defconfig +++ b/configs/stm32butterfly2/nshusbdev/defconfig @@ -316,7 +316,7 @@ CONFIG_STM32_CONNECTIVITYLINE=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm32butterfly2/nshusbhost/defconfig b/configs/stm32butterfly2/nshusbhost/defconfig index 91f4d1c2e2..58d93b48e4 100644 --- a/configs/stm32butterfly2/nshusbhost/defconfig +++ b/configs/stm32butterfly2/nshusbhost/defconfig @@ -319,7 +319,7 @@ CONFIG_STM32_CONNECTIVITYLINE=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm32f103-minimum/audio_tone/defconfig b/configs/stm32f103-minimum/audio_tone/defconfig index 2dd9628e9c..28b47a4908 100644 --- a/configs/stm32f103-minimum/audio_tone/defconfig +++ b/configs/stm32f103-minimum/audio_tone/defconfig @@ -313,7 +313,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm32f103-minimum/buttons/defconfig b/configs/stm32f103-minimum/buttons/defconfig index b6fa8ac7d1..75d256b646 100644 --- a/configs/stm32f103-minimum/buttons/defconfig +++ b/configs/stm32f103-minimum/buttons/defconfig @@ -313,7 +313,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm32f103-minimum/jlx12864g/defconfig b/configs/stm32f103-minimum/jlx12864g/defconfig index d0e48894b2..92335c76be 100644 --- a/configs/stm32f103-minimum/jlx12864g/defconfig +++ b/configs/stm32f103-minimum/jlx12864g/defconfig @@ -349,7 +349,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm32f103-minimum/mcp2515/defconfig b/configs/stm32f103-minimum/mcp2515/defconfig index 3298e2a838..4a323859f6 100644 --- a/configs/stm32f103-minimum/mcp2515/defconfig +++ b/configs/stm32f103-minimum/mcp2515/defconfig @@ -320,7 +320,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm32f103-minimum/nrf24/defconfig b/configs/stm32f103-minimum/nrf24/defconfig index 38dff042fc..b323b94907 100644 --- a/configs/stm32f103-minimum/nrf24/defconfig +++ b/configs/stm32f103-minimum/nrf24/defconfig @@ -345,7 +345,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm32f103-minimum/nsh/defconfig b/configs/stm32f103-minimum/nsh/defconfig index 4f44304393..cd62fe3c8f 100644 --- a/configs/stm32f103-minimum/nsh/defconfig +++ b/configs/stm32f103-minimum/nsh/defconfig @@ -313,7 +313,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm32f103-minimum/pwm/defconfig b/configs/stm32f103-minimum/pwm/defconfig index c9948199ad..b674a7fa22 100644 --- a/configs/stm32f103-minimum/pwm/defconfig +++ b/configs/stm32f103-minimum/pwm/defconfig @@ -313,7 +313,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm32f103-minimum/rfid-rc522/defconfig b/configs/stm32f103-minimum/rfid-rc522/defconfig index 7b3b9fdec1..634c594aaf 100644 --- a/configs/stm32f103-minimum/rfid-rc522/defconfig +++ b/configs/stm32f103-minimum/rfid-rc522/defconfig @@ -313,7 +313,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm32f103-minimum/rgbled/defconfig b/configs/stm32f103-minimum/rgbled/defconfig index 7f69a3fad9..0ec152fb49 100644 --- a/configs/stm32f103-minimum/rgbled/defconfig +++ b/configs/stm32f103-minimum/rgbled/defconfig @@ -313,7 +313,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm32f103-minimum/usbnsh/defconfig b/configs/stm32f103-minimum/usbnsh/defconfig index b7c50a79ab..9dae57fb22 100644 --- a/configs/stm32f103-minimum/usbnsh/defconfig +++ b/configs/stm32f103-minimum/usbnsh/defconfig @@ -313,7 +313,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm32f103-minimum/userled/defconfig b/configs/stm32f103-minimum/userled/defconfig index 8a37b7e1aa..27c1160864 100644 --- a/configs/stm32f103-minimum/userled/defconfig +++ b/configs/stm32f103-minimum/userled/defconfig @@ -313,7 +313,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm32f103-minimum/veml6070/defconfig b/configs/stm32f103-minimum/veml6070/defconfig index 1c6f89180b..3b306cad2b 100644 --- a/configs/stm32f103-minimum/veml6070/defconfig +++ b/configs/stm32f103-minimum/veml6070/defconfig @@ -313,7 +313,7 @@ CONFIG_STM32_MEDIUMDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm32f3discovery/nsh/defconfig b/configs/stm32f3discovery/nsh/defconfig index e21921d897..d1593a1a1f 100644 --- a/configs/stm32f3discovery/nsh/defconfig +++ b/configs/stm32f3discovery/nsh/defconfig @@ -330,7 +330,7 @@ CONFIG_STM32_STM32F30XX=y CONFIG_STM32_STM32F303=y # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm32f3discovery/usbnsh/defconfig b/configs/stm32f3discovery/usbnsh/defconfig index 95c5ec9610..ac0627e2f0 100644 --- a/configs/stm32f3discovery/usbnsh/defconfig +++ b/configs/stm32f3discovery/usbnsh/defconfig @@ -330,7 +330,7 @@ CONFIG_STM32_STM32F30XX=y CONFIG_STM32_STM32F303=y # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm32f411e-disco/nsh/defconfig b/configs/stm32f411e-disco/nsh/defconfig index bbab590c49..f9360ee1f7 100644 --- a/configs/stm32f411e-disco/nsh/defconfig +++ b/configs/stm32f411e-disco/nsh/defconfig @@ -314,7 +314,7 @@ CONFIG_STM32_FLASH_CONFIG_E=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set CONFIG_STM32_STM32F411=y # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm32f429i-disco/extflash/defconfig b/configs/stm32f429i-disco/extflash/defconfig index bcdb618783..80f7c558b3 100644 --- a/configs/stm32f429i-disco/extflash/defconfig +++ b/configs/stm32f429i-disco/extflash/defconfig @@ -320,7 +320,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm32f429i-disco/lcd/defconfig b/configs/stm32f429i-disco/lcd/defconfig index 61efc4cfff..9f5896da0d 100644 --- a/configs/stm32f429i-disco/lcd/defconfig +++ b/configs/stm32f429i-disco/lcd/defconfig @@ -321,7 +321,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm32f429i-disco/ltdc/defconfig b/configs/stm32f429i-disco/ltdc/defconfig index 41a2e7d396..31e248db63 100644 --- a/configs/stm32f429i-disco/ltdc/defconfig +++ b/configs/stm32f429i-disco/ltdc/defconfig @@ -321,7 +321,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm32f429i-disco/nsh/defconfig b/configs/stm32f429i-disco/nsh/defconfig index e2a1170c5e..d968905a62 100644 --- a/configs/stm32f429i-disco/nsh/defconfig +++ b/configs/stm32f429i-disco/nsh/defconfig @@ -320,7 +320,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm32f429i-disco/nxwm/defconfig b/configs/stm32f429i-disco/nxwm/defconfig index 13890fe609..f1c567259c 100644 --- a/configs/stm32f429i-disco/nxwm/defconfig +++ b/configs/stm32f429i-disco/nxwm/defconfig @@ -321,7 +321,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm32f429i-disco/usbmsc/defconfig b/configs/stm32f429i-disco/usbmsc/defconfig index 8025b772d4..2aba629180 100644 --- a/configs/stm32f429i-disco/usbmsc/defconfig +++ b/configs/stm32f429i-disco/usbmsc/defconfig @@ -323,7 +323,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm32f429i-disco/usbnsh/defconfig b/configs/stm32f429i-disco/usbnsh/defconfig index be48d86123..388b60a220 100644 --- a/configs/stm32f429i-disco/usbnsh/defconfig +++ b/configs/stm32f429i-disco/usbnsh/defconfig @@ -320,7 +320,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm32f4discovery/canard/defconfig b/configs/stm32f4discovery/canard/defconfig index b47022a351..5a2dea55c6 100644 --- a/configs/stm32f4discovery/canard/defconfig +++ b/configs/stm32f4discovery/canard/defconfig @@ -325,7 +325,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm32f4discovery/cxxtest/defconfig b/configs/stm32f4discovery/cxxtest/defconfig index 02cd0cbc2b..099491714f 100644 --- a/configs/stm32f4discovery/cxxtest/defconfig +++ b/configs/stm32f4discovery/cxxtest/defconfig @@ -330,7 +330,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm32f4discovery/elf/defconfig b/configs/stm32f4discovery/elf/defconfig index 8dea3c3a3c..10dee697a3 100644 --- a/configs/stm32f4discovery/elf/defconfig +++ b/configs/stm32f4discovery/elf/defconfig @@ -325,7 +325,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm32f4discovery/ipv6/defconfig b/configs/stm32f4discovery/ipv6/defconfig index bab7d7d7f7..96a906767d 100644 --- a/configs/stm32f4discovery/ipv6/defconfig +++ b/configs/stm32f4discovery/ipv6/defconfig @@ -330,7 +330,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm32f4discovery/kostest/defconfig b/configs/stm32f4discovery/kostest/defconfig index 8195826113..34362cb295 100644 --- a/configs/stm32f4discovery/kostest/defconfig +++ b/configs/stm32f4discovery/kostest/defconfig @@ -330,7 +330,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm32f4discovery/netnsh/defconfig b/configs/stm32f4discovery/netnsh/defconfig index c60861ec0b..64055c7dbf 100644 --- a/configs/stm32f4discovery/netnsh/defconfig +++ b/configs/stm32f4discovery/netnsh/defconfig @@ -330,7 +330,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm32f4discovery/nsh/defconfig b/configs/stm32f4discovery/nsh/defconfig index 3e3a60c3aa..056e2463c0 100644 --- a/configs/stm32f4discovery/nsh/defconfig +++ b/configs/stm32f4discovery/nsh/defconfig @@ -330,7 +330,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm32f4discovery/nxlines/defconfig b/configs/stm32f4discovery/nxlines/defconfig index af2533a39e..0d01a5084c 100644 --- a/configs/stm32f4discovery/nxlines/defconfig +++ b/configs/stm32f4discovery/nxlines/defconfig @@ -330,7 +330,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm32f4discovery/pm/defconfig b/configs/stm32f4discovery/pm/defconfig index 7cfc253fa7..192db75760 100644 --- a/configs/stm32f4discovery/pm/defconfig +++ b/configs/stm32f4discovery/pm/defconfig @@ -330,7 +330,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm32f4discovery/posix_spawn/defconfig b/configs/stm32f4discovery/posix_spawn/defconfig index e1a7bf6754..954c794c56 100644 --- a/configs/stm32f4discovery/posix_spawn/defconfig +++ b/configs/stm32f4discovery/posix_spawn/defconfig @@ -325,7 +325,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm32f4discovery/pseudoterm/defconfig b/configs/stm32f4discovery/pseudoterm/defconfig index 7ef11b8d2c..6eb552bf8a 100644 --- a/configs/stm32f4discovery/pseudoterm/defconfig +++ b/configs/stm32f4discovery/pseudoterm/defconfig @@ -320,7 +320,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm32f4discovery/rgbled/defconfig b/configs/stm32f4discovery/rgbled/defconfig index 8135278af2..9909f3eb7c 100644 --- a/configs/stm32f4discovery/rgbled/defconfig +++ b/configs/stm32f4discovery/rgbled/defconfig @@ -320,7 +320,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm32f4discovery/uavcan/defconfig b/configs/stm32f4discovery/uavcan/defconfig index ed52310f8a..7218e6f244 100644 --- a/configs/stm32f4discovery/uavcan/defconfig +++ b/configs/stm32f4discovery/uavcan/defconfig @@ -319,7 +319,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm32f4discovery/usbnsh/defconfig b/configs/stm32f4discovery/usbnsh/defconfig index 8528822d33..e29822f547 100644 --- a/configs/stm32f4discovery/usbnsh/defconfig +++ b/configs/stm32f4discovery/usbnsh/defconfig @@ -330,7 +330,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm32f4discovery/winbuild/defconfig b/configs/stm32f4discovery/winbuild/defconfig index 0deb8cd65b..c5b4713c80 100644 --- a/configs/stm32f4discovery/winbuild/defconfig +++ b/configs/stm32f4discovery/winbuild/defconfig @@ -281,7 +281,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F207 is not set # CONFIG_STM32_STM32F30XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm32f4discovery/xen1210/defconfig b/configs/stm32f4discovery/xen1210/defconfig index 161b69470a..e997a0bbe5 100644 --- a/configs/stm32f4discovery/xen1210/defconfig +++ b/configs/stm32f4discovery/xen1210/defconfig @@ -320,7 +320,7 @@ CONFIG_STM32_FLASH_CONFIG_DEFAULT=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F4XXX=y # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F410 is not set # CONFIG_STM32_STM32F411 is not set diff --git a/configs/stm32ldiscovery/nsh/defconfig b/configs/stm32ldiscovery/nsh/defconfig index ccb8f423a4..bc9572faf4 100644 --- a/configs/stm32ldiscovery/nsh/defconfig +++ b/configs/stm32ldiscovery/nsh/defconfig @@ -323,7 +323,7 @@ CONFIG_STM32_ENERGYLITE=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/stm32vldiscovery/nsh/defconfig b/configs/stm32vldiscovery/nsh/defconfig index 36bda9b888..e1eac671c7 100644 --- a/configs/stm32vldiscovery/nsh/defconfig +++ b/configs/stm32vldiscovery/nsh/defconfig @@ -323,7 +323,7 @@ CONFIG_STM32_VALUELINE=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/viewtool-stm32f107/highpri/defconfig b/configs/viewtool-stm32f107/highpri/defconfig index 156787a1b4..430c16fe3d 100644 --- a/configs/viewtool-stm32f107/highpri/defconfig +++ b/configs/viewtool-stm32f107/highpri/defconfig @@ -323,7 +323,7 @@ CONFIG_STM32_HIGHDENSITY=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/viewtool-stm32f107/netnsh/defconfig b/configs/viewtool-stm32f107/netnsh/defconfig index 576facbb20..a94fd147b7 100644 --- a/configs/viewtool-stm32f107/netnsh/defconfig +++ b/configs/viewtool-stm32f107/netnsh/defconfig @@ -328,7 +328,7 @@ CONFIG_STM32_CONNECTIVITYLINE=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set diff --git a/configs/viewtool-stm32f107/nsh/defconfig b/configs/viewtool-stm32f107/nsh/defconfig index a84458179e..bf19312856 100644 --- a/configs/viewtool-stm32f107/nsh/defconfig +++ b/configs/viewtool-stm32f107/nsh/defconfig @@ -323,7 +323,7 @@ CONFIG_STM32_CONNECTIVITYLINE=y # CONFIG_STM32_STM32F303 is not set # CONFIG_STM32_STM32F33XX is not set # CONFIG_STM32_STM32F37XX is not set -# CONFIG_STM32_STM32F40XX is not set +# CONFIG_STM32_STM32F4XXX is not set # CONFIG_STM32_STM32F401 is not set # CONFIG_STM32_STM32F411 is not set # CONFIG_STM32_STM32F405 is not set From 76587b2c6f0f6861bda44da0e668118e55a74fa0 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 6 Jul 2017 10:34:54 -0600 Subject: [PATCH 13/31] STM32 Kconfig: 'unfold' some of the dependencies to provide better long term configuration support. This also effective reverts the recent 15b85738e7b5b9df6377f56e2a6a629346f87964 --- arch/arm/src/stm32/Kconfig | 51 +++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/arch/arm/src/stm32/Kconfig b/arch/arm/src/stm32/Kconfig index b382deaa94..910922000b 100644 --- a/arch/arm/src/stm32/Kconfig +++ b/arch/arm/src/stm32/Kconfig @@ -1525,20 +1525,16 @@ config STM32_STM32F37XX config STM32_STM32F4XXX bool default n - select STM32_HAVE_OTGFS if !STM32_STM32F410 - select STM32_HAVE_TIM3 if !STM32_STM32F410 - select STM32_HAVE_TIM4 if !STM32_STM32F410 select STM32_HAVE_SPI2 - select STM32_HAVE_SPI3 if !STM32_STM32F410 - select STM32_HAVE_I2S3 if !STM32_STM32F410 select STM32_HAVE_I2C2 - select STM32_HAVE_I2C3 if !STM32_STM32F410 config STM32_STM32F401 bool default n select STM32_HAVE_USART6 select STM32_HAVE_TIM1 + select STM32_HAVE_TIM3 + select STM32_HAVE_TIM4 select STM32_HAVE_TIM5 select STM32_HAVE_TIM9 select STM32_HAVE_TIM10 @@ -1546,6 +1542,8 @@ config STM32_STM32F401 select STM32_HAVE_SPI2 select STM32_HAVE_SPI3 select STM32_HAVE_I2S3 + select STM32_HAVE_I2C3 + select STM32_HAVE_OTGFS config STM32_STM32F410 bool @@ -1564,15 +1562,19 @@ config STM32_STM32F411 default n select STM32_HAVE_USART6 select STM32_HAVE_TIM1 + select STM32_HAVE_TIM3 + select STM32_HAVE_TIM4 select STM32_HAVE_TIM5 select STM32_HAVE_TIM9 select STM32_HAVE_TIM10 select STM32_HAVE_TIM11 select STM32_HAVE_SPI2 select STM32_HAVE_SPI3 - select STM32_HAVE_I2S3 select STM32_HAVE_SPI4 select STM32_HAVE_SPI5 + select STM32_HAVE_I2S3 + select STM32_HAVE_I2C3 + select STM32_HAVE_OTGFS config STM32_STM32F405 bool @@ -1584,6 +1586,8 @@ config STM32_STM32F405 select STM32_HAVE_UART5 select STM32_HAVE_USART6 select STM32_HAVE_TIM1 + select STM32_HAVE_TIM3 + select STM32_HAVE_TIM4 select STM32_HAVE_TIM5 select STM32_HAVE_TIM6 select STM32_HAVE_TIM7 @@ -1600,7 +1604,11 @@ config STM32_STM32F405 select STM32_HAVE_CAN2 select STM32_HAVE_DAC1 select STM32_HAVE_DAC2 + select STM32_HAVE_SPI3 + select STM32_HAVE_I2S3 + select STM32_HAVE_I2C3 select STM32_HAVE_RNG + select STM32_HAVE_OTGFS config STM32_STM32F407 bool @@ -1613,6 +1621,8 @@ config STM32_STM32F407 select STM32_HAVE_USART6 select STM32_HAVE_TIM1 select STM32_HAVE_TIM2 + select STM32_HAVE_TIM3 + select STM32_HAVE_TIM4 select STM32_HAVE_TIM5 select STM32_HAVE_TIM6 select STM32_HAVE_TIM7 @@ -1629,10 +1639,15 @@ config STM32_STM32F407 select STM32_HAVE_CAN2 select STM32_HAVE_DAC1 select STM32_HAVE_DAC2 + select STM32_HAVE_SPI3 + select STM32_HAVE_I2S3 + select STM32_HAVE_I2C3 select STM32_HAVE_RNG select STM32_HAVE_ETHMAC + select STM32_HAVE_OTGFS # This is really 427/437, but we treat the two the same. + config STM32_STM32F427 bool default n @@ -1645,6 +1660,8 @@ config STM32_STM32F427 select STM32_HAVE_UART7 select STM32_HAVE_UART8 select STM32_HAVE_TIM1 + select STM32_HAVE_TIM3 + select STM32_HAVE_TIM4 select STM32_HAVE_TIM5 select STM32_HAVE_TIM6 select STM32_HAVE_TIM7 @@ -1665,12 +1682,15 @@ config STM32_STM32F427 select STM32_HAVE_ETHMAC select STM32_HAVE_SPI2 select STM32_HAVE_SPI3 - select STM32_HAVE_I2S3 select STM32_HAVE_SPI4 select STM32_HAVE_SPI5 + select STM32_HAVE_I2S3 + select STM32_HAVE_I2C3 + select STM32_HAVE_OTGFS select STM32_HAVE_SPI6 # This is really 429/439, but we treat the two the same. + config STM32_STM32F429 bool default n @@ -1684,6 +1704,8 @@ config STM32_STM32F429 select STM32_HAVE_UART7 select STM32_HAVE_UART8 select STM32_HAVE_TIM1 + select STM32_HAVE_TIM3 + select STM32_HAVE_TIM4 select STM32_HAVE_TIM5 select STM32_HAVE_TIM6 select STM32_HAVE_TIM7 @@ -1708,6 +1730,9 @@ config STM32_STM32F429 select STM32_HAVE_SPI4 select STM32_HAVE_SPI5 select STM32_HAVE_SPI6 + select STM32_HAVE_I2S3 + select STM32_HAVE_I2C3 + select STM32_HAVE_OTGFS config STM32_STM32F446 bool @@ -1736,11 +1761,16 @@ config STM32_STM32F446 select STM32_HAVE_CAN2 select STM32_HAVE_DAC1 select STM32_HAVE_DAC2 + select STM32_HAVE_SPI3 select STM32_HAVE_SPI4 + select STM32_HAVE_I2S3 + select STM32_HAVE_I2C3 + select STM32_HAVE_OTGFS select STM32_HAVE_SAIPLL select STM32_HAVE_I2SPLL # This is really 469/479, but we treat the two the same. + config STM32_STM32F469 bool default n @@ -1774,12 +1804,15 @@ config STM32_STM32F469 select STM32_HAVE_DAC1 select STM32_HAVE_DAC2 select STM32_HAVE_RNG + select STM32_HAVE_SPI3 select STM32_HAVE_SPI4 select STM32_HAVE_SPI5 select STM32_HAVE_SPI6 + select STM32_HAVE_OTGFS select STM32_HAVE_SAIPLL select STM32_HAVE_I2SPLL - + select STM32_HAVE_I2S3 + select STM32_HAVE_I2C3 config STM32_DFU bool "DFU bootloader" From a5f361e984311ef11b5420a65aaacc93f8e08589 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 6 Jul 2017 12:00:59 -0600 Subject: [PATCH 14/31] ICMPv6: Fix so that ICMPv6 can be used with 6LoWPAN. --- include/nuttx/net/icmpv6.h | 41 ++++++++++++++++---------- net/icmpv6/icmpv6_advertise.c | 16 ++++++---- net/icmpv6/icmpv6_input.c | 2 +- net/icmpv6/icmpv6_radvertise.c | 54 +++++++++++++--------------------- net/icmpv6/icmpv6_rsolicit.c | 19 +++++++----- net/icmpv6/icmpv6_solicit.c | 21 ++++++++----- net/neighbor/neighbor.h | 1 + 7 files changed, 84 insertions(+), 70 deletions(-) diff --git a/include/nuttx/net/icmpv6.h b/include/nuttx/net/icmpv6.h index e0e8ecba99..c576b2da9d 100644 --- a/include/nuttx/net/icmpv6.h +++ b/include/nuttx/net/icmpv6.h @@ -2,7 +2,7 @@ * include/nuttx/net/icmpv6.h * Header file for the NuttX ICMPv6 stack. * - * Copyright (C) 2007-2009, 2012, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2012, 2014, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * This logic was leveraged from uIP which also has a BSD-style license: @@ -123,6 +123,13 @@ #define ICMPv6_PRFX_FLAG_L (1 << 7) /* On-link flag */ #define ICMPv6_PRFX_FLAG_A (1 << 6) /* Autonomous address-configuration flag +/* Return with size of an option (in full octects) using the size of a link + * layer address taking into account a header of the two-bytes. + */ + +#define ICMPv6_OPT_SIZE(a) (((a) + 2 + 7) & ~7) +#define ICMPv6_OPT_OCTECTS(a) (((a) + 2 + 7) >> 3) + /**************************************************************************** * Public Type Definitions ****************************************************************************/ @@ -178,11 +185,12 @@ struct icmpv6_neighbor_solicit_s uint8_t opttype; /* Option Type: ICMPv6_OPT_SRCLLADDR */ uint8_t optlen; /* Option length: 1 octet */ -#ifdef CONFIG_NET_ETHERNET uint8_t srclladdr[6]; /* Options: Source link layer address */ -#endif }; +#define SIZEOF_ICMPV6_NEIGHBOR_SOLICIT_S(n) \ + (sizeof(struct icmpv6_neighbor_solicit_s) + ICMPv6_OPT_SIZE(n) - 8) + /* This the message format for the ICMPv6 Neighbor Advertisement message */ struct icmpv6_neighbor_advertise_s @@ -194,12 +202,14 @@ struct icmpv6_neighbor_advertise_s net_ipv6addr_t tgtaddr; /* Target IPv6 address */ uint8_t opttype; /* Option Type: ICMPv6_OPT_TGTLLADDR */ - uint8_t optlen; /* Option length: 1 octet */ -#ifdef CONFIG_NET_ETHERNET + uint8_t optlen; /* Option length in octets */ uint8_t tgtlladdr[6]; /* Options: Target link layer address */ -#endif + /* Actual size detemined by optlen */ }; +#define SIZEOF_ICMPV6_NEIGHBOR_ADVERTISE_S(n) \ + (sizeof(struct icmpv6_neighbor_advertise_s) + ICMPv6_OPT_SIZE(n) - 8) + /* This the message format for the ICMPv6 Router Solicitation message */ struct icmpv6_router_solicit_s @@ -210,12 +220,13 @@ struct icmpv6_router_solicit_s uint8_t flags[4]; /* See ICMPv6_RADV_FLAG_ definitions (must be zero) */ uint8_t opttype; /* Option Type: ICMPv6_OPT_SRCLLADDR */ - uint8_t optlen; /* Option length: 1 octet */ -#ifdef CONFIG_NET_ETHERNET + uint8_t optlen; /* Option length in octets */ uint8_t srclladdr[6]; /* Options: Source link layer address */ -#endif }; +#define SIZEOF_ICMPV6_ROUTER_SOLICIT_S(n) \ + (sizeof(struct icmpv6_router_solicit_s) + ICMPv6_OPT_SIZE(n) - 8) + /* This the message format for the ICMPv6 Router Advertisement message: * Options may include: ICMPv6_OPT_SRCLLADDR, ICMPv6_OPT_MTU, and/or * ICMPv6_OPT_PREFIX @@ -231,7 +242,7 @@ struct icmpv6_router_advertise_s uint16_t lifetime; /* Router lifetime */ uint16_t reachable[2]; /* Reachable time */ uint16_t retrans[2]; /* Retransmission timer */ - uint8_t options[1]; /* Options begin here */ + /* Options begin here */ }; #define ICMPv6_RADV_MINLEN (16) @@ -280,20 +291,20 @@ struct icmpv6_srclladdr_s { uint8_t opttype; /* Octet 1: Option Type: ICMPv6_OPT_SRCLLADDR */ uint8_t optlen; /* " " ": Option length: 1 octet */ -#ifdef CONFIG_NET_ETHERNET uint8_t srclladdr[6]; /* " " ": Options: Source link layer address */ -#endif }; +#define SIZEOF_ICMPV6_SRCLLADDR_S(n) ICMPv6_OPT_SIZE(n) + struct icmpv6_tgrlladdr_s { uint8_t opttype; /* Octet 1: Option Type: ICMPv6_OPT_TGTLLADDR */ - uint8_t optlen; /* " " ": Option length: 1 octet */ -#ifdef CONFIG_NET_ETHERNET + uint8_t optlen; /* " " ": Option length in octets */ uint8_t tgtlladdr[6]; /* " " ": Options: Target link layer address */ -#endif }; +#define SIZEOF_ICMPV6_TGRLLADDR_S(n) ICMPv6_OPT_SIZE(n) + struct icmpv6_prefixinfo_s { uint8_t opttype; /* Octet 1: Option Type: ICMPv6_OPT_PREFIX */ diff --git a/net/icmpv6/icmpv6_advertise.c b/net/icmpv6/icmpv6_advertise.c index 621b8d6c14..75c4615160 100644 --- a/net/icmpv6/icmpv6_advertise.c +++ b/net/icmpv6/icmpv6_advertise.c @@ -2,7 +2,7 @@ * net/icmpv6/icmpv6_advertise.c * Send an ICMPv6 Neighbor Advertisement * - * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Adapted for NuttX from logic in uIP which also has a BSD-like license: @@ -96,6 +96,8 @@ void icmpv6_advertise(FAR struct net_driver_s *dev, { FAR struct icmpv6_iphdr_s *icmp = ICMPv6BUF; FAR struct icmpv6_neighbor_advertise_s *adv; + uint16_t l1size; + uint16_t l3size; /* Set up the IPv6 header */ @@ -105,8 +107,10 @@ void icmpv6_advertise(FAR struct net_driver_s *dev, /* Length excludes the IPv6 header */ - icmp->len[0] = (sizeof(struct icmpv6_neighbor_advertise_s) >> 8); - icmp->len[1] = (sizeof(struct icmpv6_neighbor_advertise_s) & 0xff); + l1size = NET_LL_HDRLEN(dev); + l3size = SIZEOF_ICMPV6_NEIGHBOR_ADVERTISE_S(l1size); + icmp->len[0] = (l3size >> 8); + icmp->len[1] = (l3size & 0xff); icmp->proto = IP_PROTO_ICMP6; /* Next header */ icmp->ttl = 255; /* Hop limit */ @@ -133,13 +137,13 @@ void icmpv6_advertise(FAR struct net_driver_s *dev, /* Set up the options */ adv->opttype = ICMPv6_OPT_TGTLLADDR; /* Option type */ - adv->optlen = 1; /* Option length = 1 octet */ + adv->optlen = ICMPv6_OPT_OCTECTS(l1size); /* Option length in octets */ /* Copy our link layer address into the message * REVISIT: What if the link layer is not Ethernet? */ - memcpy(adv->tgtlladdr, &dev->d_mac.ether, IFHWADDRLEN); + memcpy(adv->tgtlladdr, &dev->d_mac, l1size); /* Calculate the checksum over both the ICMP header and payload */ @@ -148,7 +152,7 @@ void icmpv6_advertise(FAR struct net_driver_s *dev, /* Set the size to the size of the IPv6 header and the payload size */ - dev->d_len = IPv6_HDRLEN + sizeof(struct icmpv6_neighbor_advertise_s); + dev->d_len = IPv6_HDRLEN + l3size; #ifdef CONFIG_NET_ETHERNET /* Add the size of the Ethernet header */ diff --git a/net/icmpv6/icmpv6_input.c b/net/icmpv6/icmpv6_input.c index 21f171fbf8..7ced607b59 100644 --- a/net/icmpv6/icmpv6_input.c +++ b/net/icmpv6/icmpv6_input.c @@ -2,7 +2,7 @@ * net/icmpv6/icmpv6_input.c * Handling incoming ICMPv6 input * - * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Adapted for NuttX from logic in uIP which also has a BSD-like license: diff --git a/net/icmpv6/icmpv6_radvertise.c b/net/icmpv6/icmpv6_radvertise.c index cec05c51a8..b0765427b9 100644 --- a/net/icmpv6/icmpv6_radvertise.c +++ b/net/icmpv6/icmpv6_radvertise.c @@ -58,31 +58,6 @@ #ifdef CONFIG_NET_ICMPv6_ROUTER -/**************************************************************************** - * Private Types - ****************************************************************************/ -/* This is the same as struct icmpv6_router_advertise_s, but with the - * source address and prefix options included for simplicity. - */ - -struct icmpv6_radvertise_s -{ - uint8_t type; /* Message Type: ICMPV6_ROUTER_ADVERTISE */ - uint8_t code; /* Further qualifies the ICMP messages */ - uint16_t chksum; /* Checksum of ICMP header and data */ - uint8_t hoplimit; /* Current hop limit */ - uint8_t flags; /* See ICMPv6_RADV_FLAG_* definitions */ - uint16_t lifetime; /* Router lifetime */ - uint16_t reachable[2]; /* Reachable time */ - uint16_t retrans[2]; /* Retransmission timer */ - - /* Options */ - - struct icmpv6_srclladdr_s srcaddr; - struct icmpv6_mtu_s mtu; - struct icmpv6_prefixinfo_s prefix; -}; - /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -91,7 +66,7 @@ struct icmpv6_radvertise_s #define ICMPv6BUF ((struct icmpv6_iphdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)]) #define ICMPv6ADVERTISE \ - ((struct icmpv6_radvertise_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN]) + ((struct icmpv6_router_advertise_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN]) /**************************************************************************** * Private Data @@ -134,10 +109,12 @@ static const net_ipv6addr_t g_ipv6_prefix = void icmpv6_radvertise(FAR struct net_driver_s *dev) { FAR struct icmpv6_iphdr_s *icmp = ICMPv6BUF; - FAR struct icmpv6_radvertise_s *adv; + FAR struct icmpv6_router_advertise_s *adv; FAR struct icmpv6_srclladdr_s *srcaddr; FAR struct icmpv6_mtu_s *mtu; FAR struct icmpv6_prefixinfo_s *prefix; + uint16_t l1size; + uint16_t l3size; /* Set up the IPv6 header */ @@ -147,8 +124,14 @@ void icmpv6_radvertise(FAR struct net_driver_s *dev) /* Length excludes the IPv6 header */ - icmp->len[0] = (sizeof(struct icmpv6_radvertise_s) >> 8); - icmp->len[1] = (sizeof(struct icmpv6_radvertise_s) & 0xff); + l1size = NET_LL_HDRLEN(dev); + l3size = sizeof(icmpv6_router_advertise_s) + + SIZEOF_ICMPV6_SRCLLADDR_S(l1size) + + sizeof(struct icmpv6_mtu_s) + + sizeof(icmpv6_prefixinfo_s); + + icmp->len[0] = (l3size >> 8); + icmp->len[1] = (l3size & 0xff); icmp->proto = IP_PROTO_ICMP6; /* Next header */ icmp->ttl = 255; /* Hop limit */ @@ -173,13 +156,16 @@ void icmpv6_radvertise(FAR struct net_driver_s *dev) /* Set up the source address option */ - srcaddr = &adv->srcaddr; + srcaddr = (FAR struct icmpv6_srclladdr_s *) + ((FAR uint8_t *)adv + sizeof(icmpv6_router_advertise_s)); srcaddr->opttype = ICMPv6_OPT_SRCLLADDR; - srcaddr->optlen = 1; - memcpy(srcaddr->srclladdr, &dev->d_mac.ether.ether_addr_octet, ETHER_ADDR_LEN); + srcaddr->optlen = ICMPv6_OPT_OCTECTS(l1size); + memcpy(srcaddr->srclladdr, &dev->d_mac, l1size); /* Set up the MTU option */ + mtu = (FAR struct icmpv6_mtu_s *) + ((FAR uint8_t *)srcaddr + SIZEOF_ICMPV6_SRCLLADDR_S(l1size)); mtu = &adv->mtu; mtu->opttype = ICMPv6_OPT_MTU; mtu->optlen = 1; @@ -189,6 +175,8 @@ void icmpv6_radvertise(FAR struct net_driver_s *dev) /* Set up the prefix option */ + prefix = (FAR struct icmpv6_prefixinfo_s *) + ((FAR uint8_t *)mtu + sizeof(icmpv6_mtu_s)); prefix = &adv->prefix; prefix->opttype = ICMPv6_OPT_MTU; prefix->optlen = 4; @@ -210,7 +198,7 @@ void icmpv6_radvertise(FAR struct net_driver_s *dev) /* Set the size to the size of the IPv6 header and the payload size */ - dev->d_len = IPv6_HDRLEN + sizeof(struct icmpv6_radvertise_s); + dev->d_len = IPv6_HDRLEN + sizeof(struct icmpv6_router_advertise_s); #ifdef CONFIG_NET_ETHERNET /* Add the size of the Ethernet header */ diff --git a/net/icmpv6/icmpv6_rsolicit.c b/net/icmpv6/icmpv6_rsolicit.c index 93a2631432..723ed6c1cd 100644 --- a/net/icmpv6/icmpv6_rsolicit.c +++ b/net/icmpv6/icmpv6_rsolicit.c @@ -1,7 +1,7 @@ /**************************************************************************** * net/icmpv6/icmpv6_rsolicit.c * - * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -92,6 +92,8 @@ void icmpv6_rsolicit(FAR struct net_driver_s *dev) FAR struct icmpv6_iphdr_s *icmp; FAR struct icmpv6_router_solicit_s *sol; FAR struct eth_hdr_s *eth; + uint16_t l1size; + uint16_t l3size; /* Set up the IPv6 header (most is probably already in place) */ @@ -102,8 +104,10 @@ void icmpv6_rsolicit(FAR struct net_driver_s *dev) /* Length excludes the IPv6 header */ - icmp->len[0] = (sizeof(struct icmpv6_router_solicit_s) >> 8); - icmp->len[1] = (sizeof(struct icmpv6_router_solicit_s) & 0xff); + l1size = NET_LL_HDRLEN(dev); + l3size = SIZEOF_ICMPV6_ROUTER_SOLICIT_S(l1size); + icmp->len[0] = (l3size >> 8); + icmp->len[1] = (l3size & 0xff); icmp->proto = IP_PROTO_ICMP6; /* Next header */ icmp->ttl = 255; /* Hop limit */ @@ -130,14 +134,14 @@ void icmpv6_rsolicit(FAR struct net_driver_s *dev) /* Set up the options */ - sol->opttype = ICMPv6_OPT_SRCLLADDR; /* Option type */ - sol->optlen = 1; /* Option length = 1 octet */ + sol->opttype = ICMPv6_OPT_SRCLLADDR; /* Option type */ + sol->optlen = ICMPv6_OPT_OCTECTS(l1size); /* Option length in octets */ /* Copy our link layer address into the message * REVISIT: What if the link layer is not Ethernet? */ - memcpy(sol->srclladdr, dev->d_mac.ether.ether_addr_octet, sizeof(net_ipv6addr_t)); + memcpy(sol->srclladdr, &dev->d_mac, l1size); /* Calculate the checksum over both the ICMP header and payload */ @@ -146,7 +150,7 @@ void icmpv6_rsolicit(FAR struct net_driver_s *dev) /* Set the size to the size of the IPv6 header and the payload size */ - dev->d_len = IPv6_HDRLEN + sizeof(struct icmpv6_router_solicit_s); + dev->d_len = IPv6_HDRLEN + l3size; #ifdef CONFIG_NET_ETHERNET #ifdef CONFIG_NET_MULTILINK @@ -182,6 +186,7 @@ void icmpv6_rsolicit(FAR struct net_driver_s *dev) /* Add the size of the layer layer header to the total size of the * outgoing packet. */ + dev->d_len += netdev_ipv6_hdrlen(dev); ninfo("Outgoing ICMPv6 Router Solicitation length: %d (%d)\n", dev->d_len, (icmp->len[0] << 8) | icmp->len[1]); diff --git a/net/icmpv6/icmpv6_solicit.c b/net/icmpv6/icmpv6_solicit.c index 5eae392c52..71879609c9 100644 --- a/net/icmpv6/icmpv6_solicit.c +++ b/net/icmpv6/icmpv6_solicit.c @@ -1,7 +1,7 @@ /**************************************************************************** * net/icmpv6/icmpv6_solicit.c * - * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -102,7 +102,8 @@ void icmpv6_solicit(FAR struct net_driver_s *dev, { FAR struct icmpv6_iphdr_s *icmp; FAR struct icmpv6_neighbor_solicit_s *sol; - FAR struct eth_hdr_s *eth; + uint16_t l1size; + uint16_t l3size; /* Set up the IPv6 header (most is probably already in place) */ @@ -113,8 +114,10 @@ void icmpv6_solicit(FAR struct net_driver_s *dev, /* Length excludes the IPv6 header */ - icmp->len[0] = (sizeof(struct icmpv6_neighbor_solicit_s) >> 8); - icmp->len[1] = (sizeof(struct icmpv6_neighbor_solicit_s) & 0xff); + l1size = NET_LL_HDRLEN(dev); + l3size = SIZEOF_ICMPV6_NEIGHBOR_SOLICIT_S(l1size); + icmp->len[0] = (l3size >> 8); + icmp->len[1] = (l3size & 0xff); icmp->proto = IP_PROTO_ICMP6; /* Next header */ icmp->ttl = 255; /* Hop limit */ @@ -145,14 +148,14 @@ void icmpv6_solicit(FAR struct net_driver_s *dev, /* Set up the options */ - sol->opttype = ICMPv6_OPT_SRCLLADDR; /* Option type */ - sol->optlen = 1; /* Option length = 1 octet */ + sol->opttype = ICMPv6_OPT_SRCLLADDR; /* Option type */ + sol->optlen = ICMPv6_OPT_OCTECTS(l1size); /* Option length in octets */ /* Copy our link layer address into the message * REVISIT: What if the link layer is not Ethernet? */ - memcpy(sol->srclladdr, &dev->d_mac.ether, IFHWADDRLEN); + memcpy(sol->srclladdr, &dev->d_mac, l1size); /* Calculate the checksum over both the ICMP header and payload */ @@ -161,13 +164,15 @@ void icmpv6_solicit(FAR struct net_driver_s *dev, /* Set the size to the size of the IPv6 header and the payload size */ - dev->d_len = IPv6_HDRLEN + sizeof(struct icmpv6_neighbor_solicit_s); + dev->d_len = IPv6_HDRLEN + l3size; #ifdef CONFIG_NET_ETHERNET #ifdef CONFIG_NET_MULTILINK if (dev->d_lltype == NET_LL_ETHERNET) #endif { + FAR struct eth_hdr_s *eth; + /* Set the destination IPv6 multicast Ethernet address: * * For IPv6 multicast addresses, the Ethernet MAC is derived by diff --git a/net/neighbor/neighbor.h b/net/neighbor/neighbor.h index a8317f6d36..378b6fa211 100644 --- a/net/neighbor/neighbor.h +++ b/net/neighbor/neighbor.h @@ -67,6 +67,7 @@ /**************************************************************************** * Public Types ****************************************************************************/ + /* Describes the link layer address */ struct neighbor_addr_s From f323f758876bcdf571a6a198c5dbd805dbad90e1 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 6 Jul 2017 13:36:59 -0600 Subject: [PATCH 15/31] IPv6 Neighbor: Update table format to support IEEE 802.15.4 MAC addresses. --- net/icmpv6/icmpv6_input.c | 11 ++++- net/neighbor/Kconfig | 2 - net/neighbor/Make.defs | 4 ++ net/neighbor/neighbor.h | 67 +++++++++++++++++++++++++--- net/neighbor/neighbor_add.c | 56 +++++++++++++++++------ net/neighbor/neighbor_ethernet_out.c | 2 +- net/neighbor/neighbor_findentry.c | 22 +++------ net/neighbor/neighbor_lookup.c | 8 ---- 8 files changed, 122 insertions(+), 50 deletions(-) diff --git a/net/icmpv6/icmpv6_input.c b/net/icmpv6/icmpv6_input.c index 7ced607b59..ab584c65af 100644 --- a/net/icmpv6/icmpv6_input.c +++ b/net/icmpv6/icmpv6_input.c @@ -74,6 +74,14 @@ #define ICMPv6RADVERTISE \ ((struct icmpv6_router_advertise_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN]) +#if defined(CONFIG_NET_MULTILINK) +# define DEV_LLTYPE(d) ((d)->d_lltype) +#elif defined(CONFIG_NET_ETHERNET) +# define DEV_LLTYPE(d) NET_LL_ETHERNET +#elif defined(CONFIG_NET_6LOWPAN) +# define DEV_LLTYPE(d) NET_LL_IEEE802154 +#endif + /**************************************************************************** * Public Data ****************************************************************************/ @@ -167,8 +175,7 @@ void icmpv6_input(FAR struct net_driver_s *dev) { /* Save the sender's address mapping in our Neighbor Table. */ - neighbor_add(icmp->srcipaddr, - (FAR struct neighbor_addr_s *)adv->tgtlladdr); + neighbor_add(icmp->srcipaddr, DEV_LLTYPE(dev), adv->tgtlladdr); #ifdef CONFIG_NET_ICMPv6_NEIGHBOR /* Then notify any logic waiting for the Neighbor Advertisement */ diff --git a/net/neighbor/Kconfig b/net/neighbor/Kconfig index 6792e0846d..89405c4e48 100644 --- a/net/neighbor/Kconfig +++ b/net/neighbor/Kconfig @@ -9,6 +9,4 @@ config NET_IPv6_NCONF_ENTRIES int "Number of IPv6 neighbors" default 8 -#config NET_IPv6_NEIGHBOR_ADDRTYPE - endif # NET_IPv6 diff --git a/net/neighbor/Make.defs b/net/neighbor/Make.defs index 7f6b56244e..dd466a9c24 100644 --- a/net/neighbor/Make.defs +++ b/net/neighbor/Make.defs @@ -50,6 +50,10 @@ ifeq ($(CONFIG_NET_6LOWPAN),y) # NET_CSRCS += neighbor_6lowpan_out.c endif +ifeq ($(CONFIG_DEBUG_NET_INFO),y) +NET_CSRCS += neighbor_dumpentry.c +endif + # Include utility build support DEPPATH += --dep-path neighbor diff --git a/net/neighbor/neighbor.h b/net/neighbor/neighbor.h index 378b6fa211..bf9a3839d2 100644 --- a/net/neighbor/neighbor.h +++ b/net/neighbor/neighbor.h @@ -3,7 +3,7 @@ * Header file for database of link-local neighbors, used by IPv6 code and * to be used by future ARP code. * - * Copyright (C) 2007-2009, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2015, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * A leverage of logic from uIP which also has a BSD style license @@ -51,6 +51,7 @@ #include #include +#include #ifdef CONFIG_NET_IPv6 @@ -72,11 +73,19 @@ struct neighbor_addr_s { -#ifdef CONFIG_NET_IPv6_NEIGHBOR_ADDRTYPE - CONFIG_NET_IPv6_NEIGHBOR_ADDRTYPE na_addr; -#else - struct ether_addr na_addr; + union + { +#ifdef CONFIG_NET_MULTILINK + uint8_t na_lltype; #endif + +#ifdef CONFIG_NET_ETHERNET + struct ether_addr na_ethernet; +#endif +#ifdef CONFIG_NET_6LOWPAN + struct sixlowpan_addr_s na_sixlowpan; +#endif + } u; }; /* This structure describes on entry in the neighbor table. This is intended @@ -150,6 +159,7 @@ FAR struct neighbor_entry *neighbor_findentry(const net_ipv6addr_t ipaddr); * * Input Parameters: * ipaddr - The IPv6 address of the mapping. + * lltype - The link layer address type * addr - The link layer address of the mapping * * Returned Value: @@ -157,7 +167,8 @@ FAR struct neighbor_entry *neighbor_findentry(const net_ipv6addr_t ipaddr); * ****************************************************************************/ -void neighbor_add(FAR net_ipv6addr_t ipaddr, FAR struct neighbor_addr_s *addr); +void neighbor_add(FAR net_ipv6addr_t ipaddr, uint8_t lltype, + FAR uint8_t *addr); /**************************************************************************** * Name: neighbor_lookup @@ -212,6 +223,50 @@ void neighbor_update(const net_ipv6addr_t ipaddr); void neighbor_periodic(int hsec); +/**************************************************************************** + * Name: neighbor_dumpentry + * + * Description: + * Dump the conents of an entry Neighbor Table. + * + * Input Parameters: + * msg - Message to print with the entry + * neighbor - The table entry to dump + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_DEBUG_NET_INFO +void neighbor_dumpentry(FAR const char *msg, + FAR struct neighbor_entry *neighbor); +#else +# define neighbor_dumpentry(msg,neighbor) +#endif + +/**************************************************************************** + * Name: neighbor_dumpipaddr + * + * Description: + * Dump an IP address. + * + * Input Parameters: + * msg - Message to print with the entry + * ipaddr - The IP address to dump + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_DEBUG_NET_INFO +void neighbor_dumpipaddr(FAR const char *msg, + const net_ipv6addr_t ipaddr); +#else +# define neighbor_dumpipaddr(msg,ipaddr) +#endif + #endif /* CONFIG_NET_IPv6 */ #endif /* __NET_NEIGHBOR_NEIGHBOR_H */ diff --git a/net/neighbor/neighbor_add.c b/net/neighbor/neighbor_add.c index fed15353ae..61fe2ac7dd 100644 --- a/net/neighbor/neighbor_add.c +++ b/net/neighbor/neighbor_add.c @@ -1,7 +1,7 @@ /**************************************************************************** * net/neighbor/neighbor_add.c * - * Copyright (C) 2007-2009, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2015, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * A leverage of logic from uIP which also has a BSD style license @@ -43,6 +43,7 @@ #include +#include #include #include @@ -63,6 +64,7 @@ * * Input Parameters: * ipaddr - The IPv6 address of the mapping. + * lltype - The link layer address type * addr - The link layer address of the mapping * * Returned Value: @@ -70,23 +72,36 @@ * ****************************************************************************/ -void neighbor_add(FAR net_ipv6addr_t ipaddr, FAR struct neighbor_addr_s *addr) +void neighbor_add(FAR net_ipv6addr_t ipaddr, uint8_t lltype, + FAR uint8_t *addr) { + uint8_t addrlen; uint8_t oldest_time; int oldest_ndx; int i; - ninfo("Add neighbor: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", - ntohs(ipaddr[0]), ntohs(ipaddr[1]), ntohs(ipaddr[2]), - ntohs(ipaddr[3]), ntohs(ipaddr[4]), ntohs(ipaddr[5]), - ntohs(ipaddr[6]), ntohs(ipaddr[7])); - ninfo(" at: %02x:%02x:%02x:%02x:%02x:%02x\n", - addr->na_addr.ether_addr_octet[0], - addr->na_addr.ether_addr_octet[1], - addr->na_addr.ether_addr_octet[2], - addr->na_addr.ether_addr_octet[3], - addr->na_addr.ether_addr_octet[4], - addr->na_addr.ether_addr_octet[5]); + /* Get the length of the address for this link layer type */ + +#ifdef CONFIG_NET_ETHERNET +#ifdef CONFIG_NET_6LOWPAN + if (lltype == NET_LL_ETHERNET) +#endif + { + addrlen = IFHWADDRLEN; + } +#endif +#ifdef CONFIG_NET_6LOWPAN +#ifdef CONFIG_NET_ETHERNET + else +#endif + { +#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR + addrlen = NET_6LOWPAN_EADDRSIZE; +#else + addrlen = NET_6LOWPAN_SADDRSIZE; +#endif + } +#endif /* Find the first unused entry or the oldest used entry. */ @@ -101,7 +116,12 @@ void neighbor_add(FAR net_ipv6addr_t ipaddr, FAR struct neighbor_addr_s *addr) break; } +#ifdef CONFIG_NET_MULTILINK + if (g_neighbors[i].ne_addr.na_lltype == lltype && + net_ipv6addr_cmp(g_neighbors[i].ne_ipaddr, ipaddr)) +#else if (net_ipv6addr_cmp(g_neighbors[i].ne_ipaddr, ipaddr)) +#endif { oldest_ndx = i; break; @@ -120,5 +140,13 @@ void neighbor_add(FAR net_ipv6addr_t ipaddr, FAR struct neighbor_addr_s *addr) g_neighbors[oldest_ndx].ne_time = 0; net_ipv6addr_copy(g_neighbors[oldest_ndx].ne_ipaddr, ipaddr); - memcpy(&g_neighbors[oldest_ndx].ne_addr, addr, sizeof(struct neighbor_addr_s)); + +#ifdef CONFIG_NET_MULTILINK + g_neighbors[oldest_ndx].ne_addr.na_lltype = lltype; +#endif + memcpy(&g_neighbors[oldest_ndx].ne_addr.u, addr, addrlen); + + /* Dump the contents of the new entry */ + + neighbor_dumpentry("Added entry", &g_neighbors[oldest_ndx]); } diff --git a/net/neighbor/neighbor_ethernet_out.c b/net/neighbor/neighbor_ethernet_out.c index f342f7cc40..4da54e42fc 100644 --- a/net/neighbor/neighbor_ethernet_out.c +++ b/net/neighbor/neighbor_ethernet_out.c @@ -240,7 +240,7 @@ void neighbor_out(FAR struct net_driver_s *dev) /* Build an Ethernet header. */ - memcpy(eth->dest, naddr->na_addr.ether_addr_octet, ETHER_ADDR_LEN); + memcpy(eth->dest, naddr->u.na_ethernet.ether_addr_octet, ETHER_ADDR_LEN); } /* Finish populating the Ethernet header */ diff --git a/net/neighbor/neighbor_findentry.c b/net/neighbor/neighbor_findentry.c index fe6a7b7b31..7cd1e3fd76 100644 --- a/net/neighbor/neighbor_findentry.c +++ b/net/neighbor/neighbor_findentry.c @@ -1,7 +1,7 @@ /**************************************************************************** * net/neighbor/neighbor_findentry.c * - * Copyright (C) 2007-2009, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2015, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * A leverage of logic from uIP which also has a BSD style license @@ -49,7 +49,7 @@ #include "neighbor/neighbor.h" /**************************************************************************** - * Private Functions + * Public Functions ****************************************************************************/ /**************************************************************************** @@ -72,29 +72,17 @@ FAR struct neighbor_entry *neighbor_findentry(const net_ipv6addr_t ipaddr) { int i; - ninfo("Find neighbor: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", - ntohs(ipaddr[0]), ntohs(ipaddr[1]), ntohs(ipaddr[2]), - ntohs(ipaddr[3]), ntohs(ipaddr[4]), ntohs(ipaddr[5]), - ntohs(ipaddr[6]), ntohs(ipaddr[7])); - for (i = 0; i < CONFIG_NET_IPv6_NCONF_ENTRIES; ++i) { FAR struct neighbor_entry *neighbor = &g_neighbors[i]; if (net_ipv6addr_cmp(neighbor->ne_ipaddr, ipaddr)) { - ninfo(" at: %02x:%02x:%02x:%02x:%02x:%02x\n", - neighbor->ne_addr.na_addr.ether_addr_octet[0], - neighbor->ne_addr.na_addr.ether_addr_octet[1], - neighbor->ne_addr.na_addr.ether_addr_octet[2], - neighbor->ne_addr.na_addr.ether_addr_octet[3], - neighbor->ne_addr.na_addr.ether_addr_octet[4], - neighbor->ne_addr.na_addr.ether_addr_octet[5]); - - return &g_neighbors[i]; + neighbor_dumpentry("Entry found", neighbor); + return neighbor; } } - ninfo(" Not found\n"); + neighbor_dumpipaddr("Not found", ipaddr); return NULL; } diff --git a/net/neighbor/neighbor_lookup.c b/net/neighbor/neighbor_lookup.c index 01f029b69f..67d8764303 100644 --- a/net/neighbor/neighbor_lookup.c +++ b/net/neighbor/neighbor_lookup.c @@ -76,14 +76,6 @@ FAR const struct neighbor_addr_s *neighbor_lookup(const net_ipv6addr_t ipaddr) neighbor = neighbor_findentry(ipaddr); if (neighbor != NULL) { - ninfo("Lookup neighbor: %02x:%02x:%02x:%02x:%02x:%02x\n", - neighbor->ne_addr.na_addr.ether_addr_octet[0], - neighbor->ne_addr.na_addr.ether_addr_octet[1], - neighbor->ne_addr.na_addr.ether_addr_octet[2], - neighbor->ne_addr.na_addr.ether_addr_octet[3], - neighbor->ne_addr.na_addr.ether_addr_octet[4], - neighbor->ne_addr.na_addr.ether_addr_octet[5]); - return &neighbor->ne_addr; } From 9794672c0274252d99a9ec0bb98ad75225d3b7b7 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 6 Jul 2017 14:03:04 -0600 Subject: [PATCH 16/31] Forgot to add a file before the last commit --- net/neighbor/neighbor_dumpentry.c | 138 ++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 net/neighbor/neighbor_dumpentry.c diff --git a/net/neighbor/neighbor_dumpentry.c b/net/neighbor/neighbor_dumpentry.c new file mode 100644 index 0000000000..c66d998285 --- /dev/null +++ b/net/neighbor/neighbor_dumpentry.c @@ -0,0 +1,138 @@ +/**************************************************************************** + * net/neighbor/neighbor_dumpentry.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include "neighbor/neighbor.h" + +#ifdef CONFIG_DEBUG_NET_INFO + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: neighbor_dumpentry + * + * Description: + * Dump the conents of an entry Neighbor Table. + * + * Input Parameters: + * msg - Message to print with the entry + * neighbor - The table entry to dump + * + * Returned Value: + * None + * + ****************************************************************************/ + +void neighbor_dumpentry(FAR const char *msg, + FAR struct neighbor_entry *neighbor) +{ + ninfo("%s: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", + msg, + ntohs(neighbor->ne_ipaddr[0]), ntohs(neighbor->ne_ipaddr[1]), + ntohs(neighbor->ne_ipaddr[2]), ntohs(neighbor->ne_ipaddr[3]), + ntohs(neighbor->ne_ipaddr[4]), ntohs(neighbor->ne_ipaddr[5]), + ntohs(neighbor->ne_ipaddr[6]), ntohs(neighbor->ne_ipaddr[7])); + +#ifdef CONFIG_NET_ETHERNET +#ifdef CONFIG_NET_6LOWPAN + if (neighbor->ne_addr.na_lltype == NET_LL_ETHERNET) +#endif + { + ninfo(" at: %02x:%02x:%02x:%02x:%02x:%02x\n", + neighbor->ne_addr.u.na_ethernet.ether_addr_octet[0], + neighbor->ne_addr.u.na_ethernet.ether_addr_octet[1], + neighbor->ne_addr.u.na_ethernet.ether_addr_octet[2], + neighbor->ne_addr.u.na_ethernet.ether_addr_octet[3], + neighbor->ne_addr.u.na_ethernet.ether_addr_octet[4], + neighbor->ne_addr.u.na_ethernet.ether_addr_octet[5]); + } +#endif +#ifdef CONFIG_NET_6LOWPAN +#ifdef CONFIG_NET_ETHERNET + else +#endif + { +#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR + ninfo(" at: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n", + neighbor->ne_addr.u.na_sixlowpan.u8[0], + neighbor->ne_addr.u.na_sixlowpan.u8[1], + neighbor->ne_addr.u.na_sixlowpan.u8[2], + neighbor->ne_addr.u.na_sixlowpan.u8[3], + neighbor->ne_addr.u.na_sixlowpan.u8[4], + neighbor->ne_addr.u.na_sixlowpan.u8[5], + neighbor->ne_addr.u.na_sixlowpan.u8[6], + neighbor->ne_addr.u.na_sixlowpan.u8[7]); +#else + ninfo(" at: %02x:%02x\n", + neighbor->ne_addr.u.na_sixlowpan.u8[0], + neighbor->ne_addr.u.na_sixlowpan.u8[1]); + } +#endif +#endif +} + +/**************************************************************************** + * Name: neighbor_dumpipaddr + * + * Description: + * Dump an IP address. + * + * Input Parameters: + * msg - Message to print with the entry + * ipaddr - The IP address to dump + * + * Returned Value: + * None + * + ****************************************************************************/ + +void neighbor_dumpipaddr(FAR const char *msg, + const net_ipv6addr_t ipaddr) +{ + ninfo("%s: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", + msg, + ntohs(ipaddr[0]), ntohs(ipaddr[1]), ntohs(ipaddr[2]), + ntohs(ipaddr[3]), ntohs(ipaddr[4]), ntohs(ipaddr[5]), + ntohs(ipaddr[6]), ntohs(ipaddr[7])); +} + +#endif /* CONFIG_DEBUG_NET_INFO */ From 6c5e0d870c3360bc6822bce4d9e2b93380c92f4c Mon Sep 17 00:00:00 2001 From: Jeff Date: Thu, 6 Jul 2017 14:04:11 -0600 Subject: [PATCH 17/31] configs/Board.mk: Remove quotes from CONFIG_ARCH_FAMILY. Causes problems with Windows native build. --- configs/Board.mk | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/configs/Board.mk b/configs/Board.mk index 2fc49586d7..076de67c4e 100644 --- a/configs/Board.mk +++ b/configs/Board.mk @@ -50,6 +50,9 @@ OBJS = $(AOBJS) $(COBJS) SCHEDSRCDIR = $(TOPDIR)$(DELIM)sched ARCHSRCDIR = $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src +ifneq ($(CONFIG_ARCH_FAMILY),) + ARCH_FAMILY = $(patsubst "%",%,$(CONFIG_ARCH_FAMILY)) +endif ifneq ($(ZDSVERSION),) ifeq ($(WINTOOL),y) @@ -67,8 +70,8 @@ ifeq ($(CONFIG_ARCH_SIM),y) else CFLAGS += -I "${shell cygpath -w $(ARCHSRCDIR)$(DELIM)chip}" CFLAGS += -I "${shell cygpath -w $(ARCHSRCDIR)$(DELIM)common}" -ifneq ($(CONFIG_ARCH_FAMILY),) - CFLAGS += -I "${shell cygpath -w $(ARCHSRCDIR)$(DELIM)$(CONFIG_ARCH_FAMILY)}" +ifneq ($(ARCH_FAMILY),) + CFLAGS += -I "${shell cygpath -w $(ARCHSRCDIR)$(DELIM)$(ARCH_FAMILY)}" endif endif else @@ -78,8 +81,8 @@ ifeq ($(CONFIG_ARCH_SIM),y) else CFLAGS += -I$(ARCHSRCDIR)$(DELIM)chip CFLAGS += -I$(ARCHSRCDIR)$(DELIM)common -ifneq ($(CONFIG_ARCH_FAMILY),) - CFLAGS += -I$(ARCHSRCDIR)$(DELIM)$(CONFIG_ARCH_FAMILY) +ifneq ($(ARCH_FAMILY),) + CFLAGS += -I$(ARCHSRCDIR)$(DELIM)$(ARCH_FAMILY) endif endif endif From b5d7187df670d8ec0e2fe578b6ae5dfea9078830 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 6 Jul 2017 16:19:10 -0600 Subject: [PATCH 18/31] IP forwarding design simplication; might save some memory. Also fix some compile issues introduce with last commit in MULTINIC configration. --- net/devif/devif_forward.c | 24 ++++------ net/devif/ip_forward.h | 7 +-- net/devif/ipv4_forward.c | 73 ++++++++++++------------------ net/devif/ipv6_forward.c | 75 ++++++++++++------------------- net/icmp/icmp_foward.c | 17 ++++--- net/icmpv6/icmpv6_forward.c | 13 ++++-- net/neighbor/neighbor_add.c | 7 ++- net/neighbor/neighbor_dumpentry.c | 4 +- net/tcp/tcp_forward.c | 17 ++++--- net/udp/udp_forward.c | 26 ++++++++--- 10 files changed, 127 insertions(+), 136 deletions(-) diff --git a/net/devif/devif_forward.c b/net/devif/devif_forward.c index 87e4ad07e5..25fd323be7 100644 --- a/net/devif/devif_forward.c +++ b/net/devif/devif_forward.c @@ -75,26 +75,18 @@ void devif_forward(FAR struct forward_s *fwd) unsigned int offset; int ret; - DEBUGASSERT(fwd != NULL && fwd->f_dev != NULL); + DEBUGASSERT(fwd != NULL && fwd->f_iob != NULL && fwd->f_dev != NULL); offset = NET_LL_HDRLEN(fwd->f_dev); - /* Copy the saved L2 + L3 header */ + /* Copy the IOB chain that contains the L3L3 headers and any data payload */ - DEBUGASSERT(offset + fwd->f_hdrsize <= NET_DEV_MTU(fwd->f_dev)); - memcpy(&fwd->f_dev->d_buf[offset], &fwd->f_hdr, fwd->f_hdrsize); - offset += fwd->f_hdrsize; + DEBUGASSERT(fwd->f_iob->io_pktlen >= fwd->f_hdrsize); + DEBUGASSERT(offset + fwd->f_iob->io_pktlen <= NET_DEV_MTU(fwd->f_dev)); + ret = iob_copyout(&fwd->f_dev->d_buf[offset], fwd->f_iob, + fwd->f_iob->io_pktlen, 0); - /* Copy the IOB chain that contains the payload */ - - if (fwd->f_iob != NULL && fwd->f_iob->io_pktlen > 0) - { - DEBUGASSERT(offset + fwd->f_iob->io_pktlen <= NET_DEV_MTU(fwd->f_dev)); - ret = iob_copyout(&fwd->f_dev->d_buf[offset], fwd->f_iob, - fwd->f_iob->io_pktlen, 0); - - DEBUGASSERT(ret == fwd->f_iob->io_pktlen); - offset += fwd->f_iob->io_pktlen; - } + DEBUGASSERT(ret == fwd->f_iob->io_pktlen); + offset += fwd->f_iob->io_pktlen; fwd->f_dev->d_sndlen = offset; } diff --git a/net/devif/ip_forward.h b/net/devif/ip_forward.h index 5eed4d8bb3..3180f16ac7 100644 --- a/net/devif/ip_forward.h +++ b/net/devif/ip_forward.h @@ -73,6 +73,8 @@ # define CONFIG_NET_IPFORWARD_NSTRUCT 4 #endif +#define FWD_HEADER(fwd) (FAR union fwd_iphdr_u *)((fwd)->f_iob->io_data) + /**************************************************************************** * Public Types ****************************************************************************/ @@ -158,10 +160,9 @@ struct forward_s { FAR struct forward_s *f_flink; /* Supports a singly linked list */ FAR struct net_driver_s *f_dev; /* Forwarding device */ - FAR struct iob_s *f_iob; /* IOBs containing the data payload */ + FAR struct iob_s *f_iob; /* IOB chain containing the packet */ FAR struct devif_callback_s *f_cb; /* Reference to callback instance */ - union fwd_iphdr_u f_hdr; /* Copy of original L2+L3 headers */ - union fwd_conn_u f_conn; /* Protocol-specific connectin struct */ + union fwd_conn_u f_conn; /* Protocol-specific connection struct */ uint8_t f_hdrsize; /* The size of the L2+L3 headers */ }; diff --git a/net/devif/ipv4_forward.c b/net/devif/ipv4_forward.c index 6487a5fff8..2007749313 100644 --- a/net/devif/ipv4_forward.c +++ b/net/devif/ipv4_forward.c @@ -267,8 +267,6 @@ static int ipv4_dev_forward(FAR struct net_driver_s *dev, FAR struct ipv4_hdr_s *ipv4) { FAR struct forward_s *fwd = NULL; - FAR uint8_t *payload; - unsigned int paysize; int hdrsize; int ret; @@ -318,73 +316,58 @@ static int ipv4_dev_forward(FAR struct net_driver_s *dev, goto errout_with_fwd; } - /* Save the entire L2 and L3 headers in the state structure */ + /* The L2/L3 headers must fit within one, contiguous IOB. */ - if (hdrsize > sizeof(union fwd_iphdr_u)) + if (hdrsize > CONFIG_IOB_BUFSIZE) { nwarn("WARNING: Header is too big for pre-allocated structure\n"); ret = -E2BIG; goto errout_with_fwd; } - memcpy(&fwd->f_hdr.ipv4, ipv4, hdrsize); fwd->f_hdrsize = hdrsize; - /* Decrement the TTL in the copy of the IPv4 header (retaining the - * original TTL in the source). If it decrements to zero, then drop - * the packet. + /* Try to allocate the head of an IOB chain. If this fails, the + * packet will be dropped; we are not operating in a context + * where waiting for an IOB is a good idea */ - ret = ipv4_decr_ttl(&fwd->f_hdr.ipv4.l2); - if (ret < 1) + fwd->f_iob = iob_tryalloc(false); + if (fwd->f_iob == NULL) { - nwarn("WARNING: Hop limit exceeded... Dropping!\n"); - ret = -EMULTIHOP; + nwarn("WARNING: iob_tryalloc() failed\n"); + ret = -ENOMEM; goto errout_with_fwd; } - /* Use the L2 + L3 header size to determine start and size of the data - * payload. - * - * Remember that the size of the L1 header has already been subtracted - * from dev->d_len. - */ - - payload = (FAR uint8_t *)ipv4 + hdrsize; - paysize = dev->d_len - hdrsize; - - /* If there is a payload, then copy it into an IOB chain. + /* Copy the L2/L3 headers plus any following payload into an IOB chain. + * iob_trycopin() will not wait, but will fail there are no available + * IOBs. * * REVISIT: Consider an alternative design that does not require data * copying. This would require a pool of d_buf's that are managed by * the network rather than the network device. */ - if (paysize > 0) + ret = iob_trycopyin(fwd->f_iob, (FAR const uint8_t *)ipv4, + dev->d_len, 0, false); + if (ret < 0) { - /* Try to allocate the head of an IOB chain. If this fails, the - * packet will be dropped; we are not operating in a context - * where waiting for an IOB is a good idea - */ + nwarn("WARNING: iob_trycopyin() failed: %d\n", ret); + goto errout_with_iobchain; + } - fwd->f_iob = iob_tryalloc(false); - if (fwd->f_iob == NULL) - { - nwarn("WARNING: iob_tryalloc() failed\n"); - ret = -ENOMEM; - goto errout_with_fwd; - } + /* Decrement the TTL in the copy of the IPv4 header (retaining the + * original TTL in the source to handle the broadcast case). If the + * TLL decrements to zero, then do not forward the packet. + */ - /* Copy the packet data payload into an IOB chain. iob_trycopin() will - * not wait, but will fail there are no available IOBs. - */ - - ret = iob_trycopyin(fwd->f_iob, payload, paysize, 0, false); - if (ret < 0) - { - nwarn("WARNING: iob_trycopyin() failed: %d\n", ret); - goto errout_with_iobchain; - } + ret = ipv4_decr_ttl((FAR struct ipv4_hdr_s *)fwd->f_iob->io_data); + if (ret < 1) + { + nwarn("WARNING: Hop limit exceeded... Dropping!\n"); + ret = -EMULTIHOP; + goto errout_with_iobchain; } /* Then set up to forward the packet according to the protocol. diff --git a/net/devif/ipv6_forward.c b/net/devif/ipv6_forward.c index 055968c7fb..1ece8ccee7 100644 --- a/net/devif/ipv6_forward.c +++ b/net/devif/ipv6_forward.c @@ -381,9 +381,6 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, } else if (ret == PACKET_NOT_FORWARDED) { - FAR uint8_t *payload; - unsigned int paysize; - /* Verify that the full packet will fit within the forwarding devices * MTU. We provide no support for fragmenting forwarded packets. */ @@ -430,74 +427,58 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, goto errout_with_fwd; } - /* Save the entire L2 and L3 headers in the state structure */ + /* The L2/L3 headers must fit within one, contiguous IOB. */ - if (hdrsize > sizeof(union fwd_iphdr_u)) + if (hdrsize > CONFIG_IOB_BUFSIZE) { nwarn("WARNING: Header is too big for pre-allocated structure\n"); ret = -E2BIG; goto errout_with_fwd; } - memcpy(&fwd->f_hdr.ipv6, ipv6, hdrsize); fwd->f_hdrsize = hdrsize; - /* Decrement the TTL in the copy of the IPv6 header (retaining the - * original TTL in the source). If it decrements to zero, then drop - * the packet. + /* Try to allocate the head of an IOB chain. If this fails, the + * packet will be dropped; we are not operating in a context where + * waiting for an IOB is a good idea */ - ret = ipv6_decr_ttl(&fwd->f_hdr.ipv6.l2); - if (ret < 1) + fwd->f_iob = iob_tryalloc(false); + if (fwd->f_iob == NULL) { - nwarn("WARNING: Hop limit exceeded... Dropping!\n"); - ret = -EMULTIHOP; + nwarn("WARNING: iob_tryalloc() failed\n"); + ret = -ENOMEM; goto errout_with_fwd; } - /* Use the L2 + L3 header size to determine start and size of the data - * payload. - * - * Remember that the size of the L1 header has already been subtracted - * from dev->d_len. - */ - - payload = (FAR uint8_t *)ipv6 + hdrsize; - paysize = dev->d_len - hdrsize; - - /* If there is a payload, then copy it into an IOB chain. + /* Copy the L2/L3 headers plus any following payload into an IOB + * chain. iob_trycopin() will not wait, but will fail there are no + * available IOBs. * * REVISIT: Consider an alternative design that does not require data * copying. This would require a pool of d_buf's that are managed by * the network rather than the network device. */ - if (paysize > 0) + ret = iob_trycopyin(fwd->f_iob, (FAR const uint8_t *)ipv6, + dev->d_len, 0, false); + if (ret < 0) { - /* Try to allocate the head of an IOB chain. If this fails, - * the packet will be dropped; we are not operating in a - * context where waiting for an IOB is a good idea - */ + nwarn("WARNING: iob_trycopyin() failed: %d\n", ret); + goto errout_with_iobchain; + } - fwd->f_iob = iob_tryalloc(false); - if (fwd->f_iob == NULL) - { - nwarn("WARNING: iob_tryalloc() failed\n"); - ret = -ENOMEM; - goto errout_with_fwd; - } + /* Decrement the TTL in the copy of the IPv6 header (retaining the + * original TTL in the sourcee to handle the broadcast case). If the + * TTL decrements to zero, then do not forward the packet. + */ - /* Copy the packet data payload into an IOB chain. - * iob_trycopin() will not wait, but will fail there are no - * available IOBs. - */ - - ret = iob_trycopyin(fwd->f_iob, payload, paysize, 0, false); - if (ret < 0) - { - nwarn("WARNING: iob_trycopyin() failed: %d\n", ret); - goto errout_with_iobchain; - } + ret = ipv6_decr_ttl((FAR struct ipv6_hdr_s *)fwd->f_iob->io_data); + if (ret < 1) + { + nwarn("WARNING: Hop limit exceeded... Dropping!\n"); + ret = -EMULTIHOP; + goto errout_with_iobchain; } /* Then set up to forward the packet according to the protocol. diff --git a/net/icmp/icmp_foward.c b/net/icmp/icmp_foward.c index c46b626889..e1423907d6 100644 --- a/net/icmp/icmp_foward.c +++ b/net/icmp/icmp_foward.c @@ -96,6 +96,12 @@ #ifdef CONFIG_NET_ETHERNET static inline bool icmp_forward_addrchck(FAR struct forward_s *fwd) { +#if !defined(CONFIG_NET_ARP_IPIN) && !defined(CONFIG_NET_ARP_SEND) + FAR union fwd_iphdr_u *iphdr; +#endif + + DEBUGASSERT(fwd != NULL && fwd->f_iob != NULL && fwd->f_dev != NULL); + /* REVISIT: Could the MAC address not also be in a routing table? */ #ifdef CONFIG_NET_MULTILINK @@ -106,7 +112,8 @@ static inline bool icmp_forward_addrchck(FAR struct forward_s *fwd) #endif #if !defined(CONFIG_NET_ARP_IPIN) && !defined(CONFIG_NET_ARP_SEND) - return (arp_find(fwd->f_hdr.ipv4.l2.destipaddr) != NULL); + iphdr = FWD_HEADER(fwd); + return (arp_find(iphdr->ipv4.l2.destipaddr) != NULL); #else return true; #endif @@ -164,13 +171,13 @@ static inline void icmp_dropstats(FAR struct forward_s *fwd) ****************************************************************************/ static uint16_t icmp_forward_interrupt(FAR struct net_driver_s *dev, - FAR void *conn, FAR void *pvpriv, - uint16_t flags) + FAR void *conn, FAR void *pvpriv, + uint16_t flags) { FAR struct forward_s *fwd = (FAR struct forward_s *)pvpriv; ninfo("flags: %04x\n", flags); - DEBUGASSERT(fwd != NULL); + DEBUGASSERT(fwd != NULL && fwd->f_iob != NULL && fwd->f_dev != NULL); /* Make sure that this is from the forwarding device */ @@ -274,7 +281,7 @@ static uint16_t icmp_forward_interrupt(FAR struct net_driver_s *dev, int icmp_forward(FAR struct forward_s *fwd) { - DEBUGASSERT(fwd != NULL && fwd->f_dev != NULL); + DEBUGASSERT(fwd != NULL && fwd->f_iob != NULL && fwd->f_dev != NULL); /* Set up the callback in the connection */ diff --git a/net/icmpv6/icmpv6_forward.c b/net/icmpv6/icmpv6_forward.c index f1a6f8cb3d..17f35f2dd6 100644 --- a/net/icmpv6/icmpv6_forward.c +++ b/net/icmpv6/icmpv6_forward.c @@ -92,6 +92,12 @@ #ifdef CONFIG_NET_ETHERNET static inline bool icmpv6_forward_addrchck(FAR struct forward_s *fwd) { +#if !defined(CONFIG_NET_ARP_IPIN) && !defined(CONFIG_NET_ARP_SEND) + FAR union fwd_iphdr_u *iphdr; +#endif + + DEBUGASSERT(fwd != NULL && fwd->f_iob != NULL && fwd->f_dev != NULL); + /* REVISIT: Could the MAC address not also be in a routing table? */ #ifdef CONFIG_NET_MULTILINK @@ -102,7 +108,8 @@ static inline bool icmpv6_forward_addrchck(FAR struct forward_s *fwd) #endif #if !defined(CONFIG_NET_ICMPv6_NEIGHBOR) - return (neighbor_findentry(fwd->f_hdr.ipv6.l2.destipaddr) != NULL); + iphdr = FWD_HEADER(fwd); + return (arp_find(iphdr->ipv6.l2.destipaddr) != NULL); #else return true; #endif @@ -166,7 +173,7 @@ static uint16_t icmpv6_forward_interrupt(FAR struct net_driver_s *dev, FAR struct forward_s *fwd = (FAR struct forward_s *)pvpriv; ninfo("flags: %04x\n", flags); - DEBUGASSERT(fwd != NULL); + DEBUGASSERT(fwd != NULL && fwd->f_iob != NULL && fwd->f_dev != NULL); /* Make sure that this is from the forwarding device */ @@ -270,7 +277,7 @@ static uint16_t icmpv6_forward_interrupt(FAR struct net_driver_s *dev, int icmpv6_forward(FAR struct forward_s *fwd) { - DEBUGASSERT(fwd != NULL && fwd->f_dev != NULL); + DEBUGASSERT(fwd != NULL && fwd->f_iob != NULL && fwd->f_dev != NULL); /* Set up the callback in the connection */ diff --git a/net/neighbor/neighbor_add.c b/net/neighbor/neighbor_add.c index 61fe2ac7dd..f5c0487278 100644 --- a/net/neighbor/neighbor_add.c +++ b/net/neighbor/neighbor_add.c @@ -47,6 +47,9 @@ #include #include +#include + +#include #include #include "neighbor/neighbor.h" @@ -117,7 +120,7 @@ void neighbor_add(FAR net_ipv6addr_t ipaddr, uint8_t lltype, } #ifdef CONFIG_NET_MULTILINK - if (g_neighbors[i].ne_addr.na_lltype == lltype && + if (g_neighbors[i].ne_addr.u.na_lltype == lltype && net_ipv6addr_cmp(g_neighbors[i].ne_ipaddr, ipaddr)) #else if (net_ipv6addr_cmp(g_neighbors[i].ne_ipaddr, ipaddr)) @@ -142,7 +145,7 @@ void neighbor_add(FAR net_ipv6addr_t ipaddr, uint8_t lltype, net_ipv6addr_copy(g_neighbors[oldest_ndx].ne_ipaddr, ipaddr); #ifdef CONFIG_NET_MULTILINK - g_neighbors[oldest_ndx].ne_addr.na_lltype = lltype; + g_neighbors[oldest_ndx].ne_addr.u.na_lltype = lltype; #endif memcpy(&g_neighbors[oldest_ndx].ne_addr.u, addr, addrlen); diff --git a/net/neighbor/neighbor_dumpentry.c b/net/neighbor/neighbor_dumpentry.c index c66d998285..78369f0917 100644 --- a/net/neighbor/neighbor_dumpentry.c +++ b/net/neighbor/neighbor_dumpentry.c @@ -39,6 +39,8 @@ #include +#include + #include "neighbor/neighbor.h" #ifdef CONFIG_DEBUG_NET_INFO @@ -74,7 +76,7 @@ void neighbor_dumpentry(FAR const char *msg, #ifdef CONFIG_NET_ETHERNET #ifdef CONFIG_NET_6LOWPAN - if (neighbor->ne_addr.na_lltype == NET_LL_ETHERNET) + if (neighbor->ne_addr.u.na_lltype == NET_LL_ETHERNET) #endif { ninfo(" at: %02x:%02x:%02x:%02x:%02x:%02x\n", diff --git a/net/tcp/tcp_forward.c b/net/tcp/tcp_forward.c index c67cac7a6e..cc85f05eb6 100644 --- a/net/tcp/tcp_forward.c +++ b/net/tcp/tcp_forward.c @@ -259,7 +259,7 @@ static uint16_t tcp_forward_interrupt(FAR struct net_driver_s *dev, FAR struct forward_s *fwd = (FAR struct forward_s *)pvpriv; ninfo("flags: %04x\n", flags); - DEBUGASSERT(fwd != NULL); + DEBUGASSERT(fwd != NULL && fwd->f_iob != NULL && fwd->f_dev != NULL); /* Make sure that this is from the forwarding device */ @@ -375,22 +375,25 @@ static uint16_t tcp_forward_interrupt(FAR struct net_driver_s *dev, int tcp_forward(FAR struct forward_s *fwd) { - DEBUGASSERT(fwd != NULL && fwd->f_dev != NULL); FAR struct tcp_conn_s *conn = &fwd->f_conn.tcp; + FAR union fwd_iphdr_u *iphdr; + + DEBUGASSERT(fwd != NULL && fwd->f_iob != NULL && fwd->f_dev != NULL); /* Set up some minimal connection structure so that we appear to be a * real TCP connection. */ conn->dev = fwd->f_dev; + iphdr = FWD_HEADER(fwd); #ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv6 - if ((fwd->f_hdr.ipv4.l2.vhl & IP_VERSION_MASK) == IPv4_VERSION) + if ((iphdr->ipv4.l2.vhl & IP_VERSION_MASK) == IPv4_VERSION) #endif { - FAR struct ipv4_hdr_s *ipv4 = &fwd->f_hdr.ipv4.l2; - FAR struct tcp_hdr_s *tcp = &fwd->f_hdr.ipv4.l3.tcp; + FAR struct ipv4_hdr_s *ipv4 = &iphdr->ipv4.l2; + FAR struct tcp_hdr_s *tcp = &iphdr->ipv4.l3.tcp; #if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6) conn->domain = PF_INET; @@ -406,8 +409,8 @@ int tcp_forward(FAR struct forward_s *fwd) else #endif { - FAR struct ipv6_hdr_s *ipv6 = &fwd->f_hdr.ipv6.l2; - FAR struct tcp_hdr_s *tcp = &fwd->f_hdr.ipv6.l3.tcp; + FAR struct ipv6_hdr_s *ipv6 = &iphdr->ipv6.l2; + FAR struct tcp_hdr_s *tcp = &iphdr->ipv6.l3.tcp; #if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6) conn->domain = PF_INET6; diff --git a/net/udp/udp_forward.c b/net/udp/udp_forward.c index b2c1363ab0..8c0473592d 100644 --- a/net/udp/udp_forward.c +++ b/net/udp/udp_forward.c @@ -86,9 +86,11 @@ #if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6) static inline void forward_ipselect(FAR struct forward_s *fwd) { + FAR union fwd_iphdr_u *iphdr = FWD_HEADER(fwd); + /* Select IPv4 or IPv6 */ - if ((fwd->f_hdr.ipv4.l2.vhl & IP_VERSION_MASK) == IPv4_VERSION) + if ((iphdr->ipv4.l2.vhl & IP_VERSION_MASK) == IPv4_VERSION) { udp_ipv4_select(fwd->f_dev); } @@ -132,6 +134,10 @@ static inline void forward_ipselect(FAR struct forward_s *fwd) #ifdef CONFIG_NET_ETHERNET static inline bool udp_forward_addrchk(FAR struct forward_s *fwd) { + FAR union fwd_iphdr_u *iphdr; + + DEBUGASSERT(fwd != NULL && fwd->f_iob != NULL && fwd->f_dev != NULL); + /* REVISIT: Could the MAC address not also be in a routing table? */ #ifdef CONFIG_NET_MULTILINK @@ -141,13 +147,15 @@ static inline bool udp_forward_addrchk(FAR struct forward_s *fwd) } #endif + iphdr = FWD_HEADER(fwd); + #ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv6 - if ((fwd->f_hdr.ipv4.l2.vhl & IP_VERSION_MASK) == IPv4_VERSION) + if ((iphdr->ipv4.l2.vhl & IP_VERSION_MASK) == IPv4_VERSION) #endif { #if !defined(CONFIG_NET_ARP_IPIN) && !defined(CONFIG_NET_ARP_SEND) - return (arp_find(fwd->f_hdr.ipv4.l2.destipaddr) != NULL); + return (arp_find(iphdr->ipv4.l2.destipaddr) != NULL); #else return true; #endif @@ -160,7 +168,7 @@ static inline bool udp_forward_addrchk(FAR struct forward_s *fwd) #endif { #if !defined(CONFIG_NET_ICMPv6_NEIGHBOR) - return (neighbor_findentry(fwd->f_hdr.ipv6.l2.destipaddr) != NULL); + return (neighbor_findentry(iphdr->ipv6.l2.destipaddr) != NULL); #else return true; #endif @@ -189,6 +197,10 @@ static inline bool udp_forward_addrchk(FAR struct forward_s *fwd) #ifdef CONFIG_NET_STATISTICS static void udp_dropstats(FAR struct forward_s *fwd) { +#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6) + FAR union fwd_iphdr_u *iphdr = FWD_HEADER(fwd); +#endif + /* Increment the count of dropped UDP packets */ g_netstats.udp.drop++; @@ -197,7 +209,7 @@ static void udp_dropstats(FAR struct forward_s *fwd) #ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv6 - if ((fwd->f_hdr.ipv4.l2.vhl & IP_VERSION_MASK) == IPv4_VERSION) + if ((iphdr->ipv4.l2.vhl & IP_VERSION_MASK) == IPv4_VERSION) #endif { g_netstats.ipv4.drop++; @@ -244,7 +256,7 @@ static uint16_t udp_forward_interrupt(FAR struct net_driver_s *dev, FAR struct forward_s *fwd = (FAR struct forward_s *)pvpriv; ninfo("flags: %04x\n", flags); - DEBUGASSERT(fwd != NULL); + DEBUGASSERT(fwd != NULL && fwd->f_iob != NULL && fwd->f_dev != NULL); /* Make sure that this is from the forwarding device */ @@ -357,7 +369,7 @@ static uint16_t udp_forward_interrupt(FAR struct net_driver_s *dev, int udp_forward(FAR struct forward_s *fwd) { - DEBUGASSERT(fwd != NULL && fwd->f_dev != NULL); + DEBUGASSERT(fwd != NULL && fwd->f_iob != NULL && fwd->f_dev != NULL); /* Set up the callback in the connection */ From db69e4b09c2ab3ea1d7729b7390775b4de1c471b Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 6 Jul 2017 16:51:08 -0600 Subject: [PATCH 19/31] Another IP forwarding design simplification: Remove an unnecessary field from state structure. --- net/devif/devif_forward.c | 1 - net/devif/ip_forward.h | 1 - net/devif/ipv4_forward.c | 19 ++++++------------- net/devif/ipv6_forward.c | 19 ++++++------------- 4 files changed, 12 insertions(+), 28 deletions(-) diff --git a/net/devif/devif_forward.c b/net/devif/devif_forward.c index 25fd323be7..3e9aaf89aa 100644 --- a/net/devif/devif_forward.c +++ b/net/devif/devif_forward.c @@ -80,7 +80,6 @@ void devif_forward(FAR struct forward_s *fwd) /* Copy the IOB chain that contains the L3L3 headers and any data payload */ - DEBUGASSERT(fwd->f_iob->io_pktlen >= fwd->f_hdrsize); DEBUGASSERT(offset + fwd->f_iob->io_pktlen <= NET_DEV_MTU(fwd->f_dev)); ret = iob_copyout(&fwd->f_dev->d_buf[offset], fwd->f_iob, fwd->f_iob->io_pktlen, 0); diff --git a/net/devif/ip_forward.h b/net/devif/ip_forward.h index 3180f16ac7..40c7c757da 100644 --- a/net/devif/ip_forward.h +++ b/net/devif/ip_forward.h @@ -163,7 +163,6 @@ struct forward_s FAR struct iob_s *f_iob; /* IOB chain containing the packet */ FAR struct devif_callback_s *f_cb; /* Reference to callback instance */ union fwd_conn_u f_conn; /* Protocol-specific connection struct */ - uint8_t f_hdrsize; /* The size of the L2+L3 headers */ }; /**************************************************************************** diff --git a/net/devif/ipv4_forward.c b/net/devif/ipv4_forward.c index 2007749313..075f47bc7a 100644 --- a/net/devif/ipv4_forward.c +++ b/net/devif/ipv4_forward.c @@ -80,7 +80,7 @@ * ****************************************************************************/ -#ifdef CONFIG_NETDEV_MULTINIC +#if defined(CONFIG_NETDEV_MULTINIC) && defined(CONFIG_DEBUG_NET_WARN) static int ipv4_hdrsize(FAR struct ipv4_hdr_s *ipv4) { /* Size is determined by the following protocol header, */ @@ -267,7 +267,9 @@ static int ipv4_dev_forward(FAR struct net_driver_s *dev, FAR struct ipv4_hdr_s *ipv4) { FAR struct forward_s *fwd = NULL; +#ifdef CONFIG_DEBUG_NET_WARN int hdrsize; +#endif int ret; /* Verify that the full packet will fit within the forwarding devices MTU. @@ -297,16 +299,8 @@ static int ipv4_dev_forward(FAR struct net_driver_s *dev, fwd->f_dev = fwddev; /* Forwarding device */ - /* Get the size of the IPv4 + L3 header. Use this to determine start of - * the data payload. - * - * Remember that the size of the L1 header has already been subtracted - * from dev->d_len. - * - * REVISIT: Consider an alternative design that does not require data - * copying. This would require a pool of d_buf's that are managed by - * the network rather than the network device. - */ +#ifdef CONFIG_DEBUG_NET_WARN + /* Get the size of the IPv4 + L3 header. */ hdrsize = ipv4_hdrsize(ipv4); if (hdrsize < IPv4_HDRLEN) @@ -324,8 +318,7 @@ static int ipv4_dev_forward(FAR struct net_driver_s *dev, ret = -E2BIG; goto errout_with_fwd; } - - fwd->f_hdrsize = hdrsize; +#endif /* Try to allocate the head of an IOB chain. If this fails, the * packet will be dropped; we are not operating in a context diff --git a/net/devif/ipv6_forward.c b/net/devif/ipv6_forward.c index 1ece8ccee7..240ed6de6a 100644 --- a/net/devif/ipv6_forward.c +++ b/net/devif/ipv6_forward.c @@ -86,7 +86,7 @@ * ****************************************************************************/ -#ifdef CONFIG_NETDEV_MULTINIC +#if defined(CONFIG_NETDEV_MULTINIC) && defined(CONFIG_DEBUG_NET_WARN) static int ipv6_hdrsize(FAR struct ipv6_hdr_s *ipv6) { /* Size is determined by the following protocol header, */ @@ -368,7 +368,9 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) { FAR struct forward_s *fwd = NULL; +#ifdef CONFIG_DEBUG_NET_WARN int hdrsize; +#endif int ret; /* Perform any necessary packet conversions. */ @@ -408,16 +410,8 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, fwd->f_dev = fwddev; /* Forwarding device */ - /* Get the size of the IPv6 + L3 header. Use this to determine start - * of the data payload. - * - * Remember that the size of the L1 header has already been subtracted - * from dev->d_len. - * - * REVISIT: Consider an alternative design that does not require data - * copying. This would require a pool of d_buf's that are managed by - * the network rather than the network device. - */ +#ifdef CONFIG_DEBUG_NET_WARN + /* Get the size of the IPv6 + L3 header. */ hdrsize = ipv6_hdrsize(ipv6); if (hdrsize < IPv6_HDRLEN) @@ -435,8 +429,7 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, ret = -E2BIG; goto errout_with_fwd; } - - fwd->f_hdrsize = hdrsize; +#endif /* Try to allocate the head of an IOB chain. If this fails, the * packet will be dropped; we are not operating in a context where From 70c6b52132c1cc156200ce101aab1933dd8e5619 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 6 Jul 2017 19:37:01 -0600 Subject: [PATCH 20/31] ICMPv6: Fix an address size calculation that was bungled in a recent commit. --- net/devif/ip_forward.c | 9 ++- net/icmpv6/icmpv6_advertise.c | 33 +++++----- net/icmpv6/icmpv6_radvertise.c | 33 +++++----- net/icmpv6/icmpv6_rsolicit.c | 37 ++++++----- net/icmpv6/icmpv6_solicit.c | 41 ++++++------ net/neighbor/neighbor_add.c | 27 +------- net/netdev/Make.defs | 1 + net/netdev/netdev.h | 20 ++++++ net/netdev/netdev_l1size.c | 117 +++++++++++++++++++++++++++++++++ 9 files changed, 223 insertions(+), 95 deletions(-) create mode 100644 net/netdev/netdev_l1size.c diff --git a/net/devif/ip_forward.c b/net/devif/ip_forward.c index a1a59e23f5..4c5ac64ff2 100644 --- a/net/devif/ip_forward.c +++ b/net/devif/ip_forward.c @@ -40,8 +40,9 @@ #include #include -#include +#include #include +#include #include "devif/ip_forward.h" @@ -79,6 +80,12 @@ void ip_forward_initialize(void) FAR struct forward_s *fwd; int i; + /* The IOB size must be such that the maximum L2 and L3 headers fit into + * the contiguous memory of the first IOB in the IOB chain. + */ + + DEBUGASSERT(sizeof(union fwd_iphdr_u) <= CONFIG_IOB_BUFSIZE); + /* Add all pre-allocated forwarding structures to the free list */ g_fwdfree = NULL; diff --git a/net/icmpv6/icmpv6_advertise.c b/net/icmpv6/icmpv6_advertise.c index 75c4615160..3e5b6385be 100644 --- a/net/icmpv6/icmpv6_advertise.c +++ b/net/icmpv6/icmpv6_advertise.c @@ -54,6 +54,7 @@ #include #include +#include "netdev/netdev.h" #include "utils/utils.h" #include "icmpv6/icmpv6.h" @@ -63,8 +64,8 @@ * Pre-processor Definitions ****************************************************************************/ -#define ETHBUF ((struct eth_hdr_s *)&dev->d_buf[0]) -#define ICMPv6BUF ((struct icmpv6_iphdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)]) +#define ETHBUF ((struct eth_hdr_s *)&dev->d_buf[0]) +#define IPv6BUF ((struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)]) #define ICMPv6ADVERTISE \ ((struct icmpv6_neighbor_advertise_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN]) @@ -94,31 +95,31 @@ void icmpv6_advertise(FAR struct net_driver_s *dev, const net_ipv6addr_t destipaddr) { - FAR struct icmpv6_iphdr_s *icmp = ICMPv6BUF; + FAR struct ipv6_hdr_s *ipv6 = IPv6BUF; FAR struct icmpv6_neighbor_advertise_s *adv; uint16_t l1size; uint16_t l3size; /* Set up the IPv6 header */ - icmp->vtc = 0x60; /* Version/traffic class (MS) */ - icmp->tcf = 0; /* Traffic class (LS)/Flow label (MS) */ - icmp->flow = 0; /* Flow label (LS) */ + ipv6->vtc = 0x60; /* Version/traffic class (MS) */ + ipv6->tcf = 0; /* Traffic class (LS)/Flow label (MS) */ + ipv6->flow = 0; /* Flow label (LS) */ /* Length excludes the IPv6 header */ - l1size = NET_LL_HDRLEN(dev); + l1size = netdev_dev_l1size(dev); l3size = SIZEOF_ICMPV6_NEIGHBOR_ADVERTISE_S(l1size); - icmp->len[0] = (l3size >> 8); - icmp->len[1] = (l3size & 0xff); + ipv6->len[0] = (l3size >> 8); + ipv6->len[1] = (l3size & 0xff); - icmp->proto = IP_PROTO_ICMP6; /* Next header */ - icmp->ttl = 255; /* Hop limit */ + ipv6->proto = IP_PROTO_ICMP6; /* Next header */ + ipv6->ttl = 255; /* Hop limit */ /* Swap source for destination IP address, add our source IP address */ - net_ipv6addr_copy(icmp->destipaddr, destipaddr); - net_ipv6addr_copy(icmp->srcipaddr, dev->d_ipv6addr); + net_ipv6addr_copy(ipv6->destipaddr, destipaddr); + net_ipv6addr_copy(ipv6->srcipaddr, dev->d_ipv6addr); /* Set up the ICMPv6 Neighbor Advertise response */ @@ -147,8 +148,8 @@ void icmpv6_advertise(FAR struct net_driver_s *dev, /* Calculate the checksum over both the ICMP header and payload */ - icmp->chksum = 0; - icmp->chksum = ~icmpv6_chksum(dev); + adv->chksum = 0; + adv->chksum = ~icmpv6_chksum(dev); /* Set the size to the size of the IPv6 header and the payload size */ @@ -185,7 +186,7 @@ void icmpv6_advertise(FAR struct net_driver_s *dev, IFF_SET_NOARP(dev->d_flags); ninfo("Outgoing ICMPv6 Neighbor Advertise length: %d (%d)\n", - dev->d_len, (icmp->len[0] << 8) | icmp->len[1]); + dev->d_len, (ipv6->len[0] << 8) | ipv6->len[1]); #ifdef CONFIG_NET_STATISTICS g_netstats.icmpv6.sent++; diff --git a/net/icmpv6/icmpv6_radvertise.c b/net/icmpv6/icmpv6_radvertise.c index b0765427b9..c0690ad409 100644 --- a/net/icmpv6/icmpv6_radvertise.c +++ b/net/icmpv6/icmpv6_radvertise.c @@ -53,6 +53,7 @@ #include #include +#include "netdev/netdev.h" #include "utils/utils.h" #include "icmpv6/icmpv6.h" @@ -62,8 +63,8 @@ * Pre-processor Definitions ****************************************************************************/ -#define ETHBUF ((struct eth_hdr_s *)&dev->d_buf[0]) -#define ICMPv6BUF ((struct icmpv6_iphdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)]) +#define ETHBUF ((struct eth_hdr_s *)&dev->d_buf[0]) +#define IPv6BUF ((struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)]) #define ICMPv6ADVERTISE \ ((struct icmpv6_router_advertise_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN]) @@ -108,7 +109,7 @@ static const net_ipv6addr_t g_ipv6_prefix = void icmpv6_radvertise(FAR struct net_driver_s *dev) { - FAR struct icmpv6_iphdr_s *icmp = ICMPv6BUF; + FAR struct ipv6_hdr_s *ipv6 = IPv6BUF; FAR struct icmpv6_router_advertise_s *adv; FAR struct icmpv6_srclladdr_s *srcaddr; FAR struct icmpv6_mtu_s *mtu; @@ -118,28 +119,28 @@ void icmpv6_radvertise(FAR struct net_driver_s *dev) /* Set up the IPv6 header */ - icmp->vtc = 0x60; /* Version/traffic class (MS) */ - icmp->tcf = 0; /* Traffic class (LS)/Flow label (MS) */ - icmp->flow = 0; /* Flow label (LS) */ + ipv6->vtc = 0x60; /* Version/traffic class (MS) */ + ipv6->tcf = 0; /* Traffic class (LS)/Flow label (MS) */ + ipv6->flow = 0; /* Flow label (LS) */ /* Length excludes the IPv6 header */ - l1size = NET_LL_HDRLEN(dev); + l1size = netdev_dev_l1size(dev); l3size = sizeof(icmpv6_router_advertise_s) + SIZEOF_ICMPV6_SRCLLADDR_S(l1size) + sizeof(struct icmpv6_mtu_s) + sizeof(icmpv6_prefixinfo_s); - icmp->len[0] = (l3size >> 8); - icmp->len[1] = (l3size & 0xff); + ipv6->len[0] = (l3size >> 8); + ipv6->len[1] = (l3size & 0xff); - icmp->proto = IP_PROTO_ICMP6; /* Next header */ - icmp->ttl = 255; /* Hop limit */ + ipv6->proto = IP_PROTO_ICMP6; /* Next header */ + ipv6->ttl = 255; /* Hop limit */ /* Swap source for destination IP address, add our source IP address */ - net_ipv6addr_copy(icmp->destipaddr, g_ipv6_allnodes); - net_ipv6addr_copy(icmp->srcipaddr, dev->d_ipv6addr); + net_ipv6addr_copy(ipv6->destipaddr, g_ipv6_allnodes); + net_ipv6addr_copy(ipv6->srcipaddr, dev->d_ipv6addr); /* Set up the ICMPv6 Router Advertise response */ @@ -193,8 +194,8 @@ void icmpv6_radvertise(FAR struct net_driver_s *dev) /* Calculate the checksum over both the ICMP header and payload */ - icmp->chksum = 0; - icmp->chksum = ~icmpv6_chksum(dev); + adv->chksum = 0; + adv->chksum = ~icmpv6_chksum(dev); /* Set the size to the size of the IPv6 header and the payload size */ @@ -231,7 +232,7 @@ void icmpv6_radvertise(FAR struct net_driver_s *dev) IFF_SET_NOARP(dev->d_flags); ninfo("Outgoing ICMPv6 Router Advertise length: %d (%d)\n", - dev->d_len, (icmp->len[0] << 8) | icmp->len[1]); + dev->d_len, (ipv6->len[0] << 8) | ipv6->len[1]); #ifdef CONFIG_NET_STATISTICS g_netstats.icmpv6.sent++; diff --git a/net/icmpv6/icmpv6_rsolicit.c b/net/icmpv6/icmpv6_rsolicit.c index 723ed6c1cd..bbc48742d4 100644 --- a/net/icmpv6/icmpv6_rsolicit.c +++ b/net/icmpv6/icmpv6_rsolicit.c @@ -47,6 +47,7 @@ #include #include "devif/devif.h" +#include "netdev/netdev.h" #include "utils/utils.h" #include "icmpv6/icmpv6.h" @@ -56,8 +57,8 @@ * Pre-processor Definitions ****************************************************************************/ -#define ETHBUF ((struct eth_hdr_s *)&dev->d_buf[0]) -#define ICMPv6BUF ((struct icmpv6_iphdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)]) +#define ETHBUF ((struct eth_hdr_s *)&dev->d_buf[0]) +#define IPv6BUF ((struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)]) #define ICMPv6RSOLICIT \ ((struct icmpv6_router_solicit_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN]) @@ -89,7 +90,7 @@ void icmpv6_rsolicit(FAR struct net_driver_s *dev) { - FAR struct icmpv6_iphdr_s *icmp; + FAR struct ipv6_hdr_s *ipv6; FAR struct icmpv6_router_solicit_s *sol; FAR struct eth_hdr_s *eth; uint16_t l1size; @@ -97,30 +98,30 @@ void icmpv6_rsolicit(FAR struct net_driver_s *dev) /* Set up the IPv6 header (most is probably already in place) */ - icmp = ICMPv6BUF; - icmp->vtc = 0x60; /* Version/traffic class (MS) */ - icmp->tcf = 0; /* Traffic class (LS)/Flow label (MS) */ - icmp->flow = 0; /* Flow label (LS) */ + ipv6 = IPv6BUF; + ipv6->vtc = 0x60; /* Version/traffic class (MS) */ + ipv6->tcf = 0; /* Traffic class (LS)/Flow label (MS) */ + ipv6->flow = 0; /* Flow label (LS) */ /* Length excludes the IPv6 header */ - l1size = NET_LL_HDRLEN(dev); - l3size = SIZEOF_ICMPV6_ROUTER_SOLICIT_S(l1size); - icmp->len[0] = (l3size >> 8); - icmp->len[1] = (l3size & 0xff); + l1size = netdev_dev_l1size(dev); + l3size = SIZEOF_ICMPV6_ROUTER_SOLICIT_S(l1size); + ipv6->len[0] = (l3size >> 8); + ipv6->len[1] = (l3size & 0xff); - icmp->proto = IP_PROTO_ICMP6; /* Next header */ - icmp->ttl = 255; /* Hop limit */ + ipv6->proto = IP_PROTO_ICMP6; /* Next header */ + ipv6->ttl = 255; /* Hop limit */ /* Set the multicast destination IP address to the IPv6 all link- * loocal routers address: ff02::2 */ - net_ipv6addr_copy(icmp->destipaddr, g_ipv6_allrouters); + net_ipv6addr_copy(ipv6->destipaddr, g_ipv6_allrouters); /* Add our link local IPv6 address as the source address */ - net_ipv6addr_copy(icmp->srcipaddr, dev->d_ipv6addr); + net_ipv6addr_copy(ipv6->srcipaddr, dev->d_ipv6addr); /* Set up the ICMPv6 Router Solicitation message */ @@ -145,8 +146,8 @@ void icmpv6_rsolicit(FAR struct net_driver_s *dev) /* Calculate the checksum over both the ICMP header and payload */ - icmp->chksum = 0; - icmp->chksum = ~icmpv6_chksum(dev); + sol->chksum = 0; + sol->chksum = ~icmpv6_chksum(dev); /* Set the size to the size of the IPv6 header and the payload size */ @@ -189,7 +190,7 @@ void icmpv6_rsolicit(FAR struct net_driver_s *dev) dev->d_len += netdev_ipv6_hdrlen(dev); ninfo("Outgoing ICMPv6 Router Solicitation length: %d (%d)\n", - dev->d_len, (icmp->len[0] << 8) | icmp->len[1]); + dev->d_len, (ipv6->len[0] << 8) | ipv6->len[1]); #ifdef CONFIG_NET_STATISTICS g_netstats.icmpv6.sent++; diff --git a/net/icmpv6/icmpv6_solicit.c b/net/icmpv6/icmpv6_solicit.c index 71879609c9..c5d7338899 100644 --- a/net/icmpv6/icmpv6_solicit.c +++ b/net/icmpv6/icmpv6_solicit.c @@ -48,6 +48,7 @@ #include #include "devif/devif.h" +#include "netdev/netdev.h" #include "utils/utils.h" #include "icmpv6/icmpv6.h" @@ -57,8 +58,8 @@ * Pre-processor Definitions ****************************************************************************/ -#define ETHBUF ((struct eth_hdr_s *)&dev->d_buf[0]) -#define ICMPv6BUF ((struct icmpv6_iphdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)]) +#define ETHBUF ((struct eth_hdr_s *)&dev->d_buf[0]) +#define IPv6BUF ((struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)]) #define ICMPv6SOLICIT \ ((struct icmpv6_neighbor_solicit_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN]) @@ -100,37 +101,37 @@ static const uint16_t g_icmpv_mcastaddr[6] = void icmpv6_solicit(FAR struct net_driver_s *dev, FAR const net_ipv6addr_t ipaddr) { - FAR struct icmpv6_iphdr_s *icmp; + FAR struct ipv6_hdr_s *ipv6; FAR struct icmpv6_neighbor_solicit_s *sol; uint16_t l1size; uint16_t l3size; /* Set up the IPv6 header (most is probably already in place) */ - icmp = ICMPv6BUF; - icmp->vtc = 0x60; /* Version/traffic class (MS) */ - icmp->tcf = 0; /* Traffic class (LS)/Flow label (MS) */ - icmp->flow = 0; /* Flow label (LS) */ + ipv6 = IPv6BUF; + ipv6->vtc = 0x60; /* Version/traffic class (MS) */ + ipv6->tcf = 0; /* Traffic class (LS)/Flow label (MS) */ + ipv6->flow = 0; /* Flow label (LS) */ /* Length excludes the IPv6 header */ - l1size = NET_LL_HDRLEN(dev); + l1size = netdev_dev_l1size(dev); l3size = SIZEOF_ICMPV6_NEIGHBOR_SOLICIT_S(l1size); - icmp->len[0] = (l3size >> 8); - icmp->len[1] = (l3size & 0xff); + ipv6->len[0] = (l3size >> 8); + ipv6->len[1] = (l3size & 0xff); - icmp->proto = IP_PROTO_ICMP6; /* Next header */ - icmp->ttl = 255; /* Hop limit */ + ipv6->proto = IP_PROTO_ICMP6; /* Next header */ + ipv6->ttl = 255; /* Hop limit */ /* Set the multicast destination IP address */ - memcpy(icmp->destipaddr, g_icmpv_mcastaddr, 6*sizeof(uint16_t)); - icmp->destipaddr[6] = ipaddr[6] | HTONS(0xff00); - icmp->destipaddr[7] = ipaddr[7]; + memcpy(ipv6->destipaddr, g_icmpv_mcastaddr, 6*sizeof(uint16_t)); + ipv6->destipaddr[6] = ipaddr[6] | HTONS(0xff00); + ipv6->destipaddr[7] = ipaddr[7]; /* Add out IPv6 address as the source address */ - net_ipv6addr_copy(icmp->srcipaddr, dev->d_ipv6addr); + net_ipv6addr_copy(ipv6->srcipaddr, dev->d_ipv6addr); /* Set up the ICMPv6 Neighbor Solicitation message */ @@ -159,8 +160,8 @@ void icmpv6_solicit(FAR struct net_driver_s *dev, /* Calculate the checksum over both the ICMP header and payload */ - icmp->chksum = 0; - icmp->chksum = ~icmpv6_chksum(dev); + sol->chksum = 0; + sol->chksum = ~icmpv6_chksum(dev); /* Set the size to the size of the IPv6 header and the payload size */ @@ -215,9 +216,11 @@ void icmpv6_solicit(FAR struct net_driver_s *dev, /* Add the size of the layer layer header to the total size of the * outgoing packet. */ + dev->d_len += netdev_ipv6_hdrlen(dev); + ninfo("Outgoing ICMPv6 Neighbor Solicitation length: %d (%d)\n", - dev->d_len, (icmp->len[0] << 8) | icmp->len[1]); + dev->d_len, (ipv6->len[0] << 8) | ipv6->len[1]); #ifdef CONFIG_NET_STATISTICS g_netstats.icmpv6.sent++; diff --git a/net/neighbor/neighbor_add.c b/net/neighbor/neighbor_add.c index f5c0487278..5899408275 100644 --- a/net/neighbor/neighbor_add.c +++ b/net/neighbor/neighbor_add.c @@ -52,6 +52,7 @@ #include #include +#include "netdev/netdev.h" #include "neighbor/neighbor.h" /**************************************************************************** @@ -78,34 +79,10 @@ void neighbor_add(FAR net_ipv6addr_t ipaddr, uint8_t lltype, FAR uint8_t *addr) { - uint8_t addrlen; uint8_t oldest_time; int oldest_ndx; int i; - /* Get the length of the address for this link layer type */ - -#ifdef CONFIG_NET_ETHERNET -#ifdef CONFIG_NET_6LOWPAN - if (lltype == NET_LL_ETHERNET) -#endif - { - addrlen = IFHWADDRLEN; - } -#endif -#ifdef CONFIG_NET_6LOWPAN -#ifdef CONFIG_NET_ETHERNET - else -#endif - { -#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR - addrlen = NET_6LOWPAN_EADDRSIZE; -#else - addrlen = NET_6LOWPAN_SADDRSIZE; -#endif - } -#endif - /* Find the first unused entry or the oldest used entry. */ oldest_time = 0; @@ -147,7 +124,7 @@ void neighbor_add(FAR net_ipv6addr_t ipaddr, uint8_t lltype, #ifdef CONFIG_NET_MULTILINK g_neighbors[oldest_ndx].ne_addr.u.na_lltype = lltype; #endif - memcpy(&g_neighbors[oldest_ndx].ne_addr.u, addr, addrlen); + memcpy(&g_neighbors[oldest_ndx].ne_addr.u, addr, netdev_type_l1size(lltype)); /* Dump the contents of the new entry */ diff --git a/net/netdev/Make.defs b/net/netdev/Make.defs index c5262a1aac..e533f1278d 100644 --- a/net/netdev/Make.defs +++ b/net/netdev/Make.defs @@ -39,6 +39,7 @@ NETDEV_CSRCS += netdev_register.c netdev_ioctl.c netdev_txnotify.c NETDEV_CSRCS += netdev_findbyname.c netdev_findbyaddr.c netdev_findbyindex.c NETDEV_CSRCS += netdev_count.c netdev_foreach.c netdev_unregister.c NETDEV_CSRCS += netdev_carrier.c netdev_default.c netdev_verify.c +NETDEV_CSRCS += netdev_l1size.c ifeq ($(CONFIG_NET_RXAVAIL),y) NETDEV_CSRCS += netdev_rxnotify.c diff --git a/net/netdev/netdev.h b/net/netdev/netdev.h index 206a9e67fa..4080608c15 100644 --- a/net/netdev/netdev.h +++ b/net/netdev/netdev.h @@ -437,6 +437,26 @@ void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t ripaddr); int netdev_count(void); #endif +/**************************************************************************** + * Name: netdev_dev_l1size and netdev_type_llsize + * + * Description: + * Size of the MAC address associated with a device or with a link layer + * type. + * + * Parameters: + * dev - A reference to the device of interest + * OR + * lltype - link layer type code + * + * Returned Value: + * The size of the MAC address associated with this device + * + ****************************************************************************/ + +int netdev_type_l1size(uint8_t lltype); +int netdev_dev_l1size(FAR struct net_driver_s *dev); + #undef EXTERN #ifdef __cplusplus } diff --git a/net/netdev/netdev_l1size.c b/net/netdev/netdev_l1size.c new file mode 100644 index 0000000000..a16b6069ac --- /dev/null +++ b/net/netdev/netdev_l1size.c @@ -0,0 +1,117 @@ +/**************************************************************************** + * net/netdev/netdev_l1size.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include + +#include +#include + +#include "netdev/netdev.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: netdev_dev_l1size and netdev_type_llsize + * + * Description: + * Size of the MAC address associated with a device or with a link layer + * type. + * + * Parameters: + * dev - A reference to the device of interest + * OR + * lltype - link layer type code + * + * Returned Value: + * The size of the MAC address associated with this device + * + ****************************************************************************/ + +int netdev_type_l1size(uint8_t lltype) +{ + /* Get the length of the address for this link layer type */ + +#ifdef CONFIG_NET_ETHERNET + if (lltype == NET_LL_ETHERNET) + { + return IFHWADDRLEN; + } + else +#endif +#ifdef CONFIG_NET_6LOWPAN + if (lltype == NET_LL_IEEE802154) + { +#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR + return NET_6LOWPAN_EADDRSIZE; +#else + return NET_6LOWPAN_SADDRSIZE; +#endif + } + else +#endif + { + return 0; + } +} + +int netdev_dev_l1size(FAR struct net_driver_s *dev) +{ + /* Get the length of the address for this device */ + +#if defined(CONFIG_NET_MULTILINK) + return netdev_type_l1size(dev->d_lltype); +#elif defined(CONFIG_NET_ETHERNET) + return IFHWADDRLEN; +#elif defined(CONFIG_NET_6LOWPAN) +#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR + return NET_6LOWPAN_EADDRSIZE; +#else + return NET_6LOWPAN_SADDRSIZE; +#endif +#else + return 0; +#endif +} From b4a0ac53a889b267c0222367be51fdb5242d2aec Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 7 Jul 2017 06:51:52 -0600 Subject: [PATCH 21/31] Networking: Improve naming and simplify some logic of previous commit. --- net/icmpv6/icmpv6_advertise.c | 12 ++-- net/icmpv6/icmpv6_radvertise.c | 12 ++-- net/icmpv6/icmpv6_rsolicit.c | 12 ++-- net/icmpv6/icmpv6_solicit.c | 12 ++-- net/neighbor/neighbor_add.c | 2 +- net/netdev/Make.defs | 2 +- net/netdev/netdev.h | 55 ++++++++++++++++--- .../{netdev_l1size.c => netdev_lladdrsize.c} | 40 +++++--------- 8 files changed, 88 insertions(+), 59 deletions(-) rename net/netdev/{netdev_l1size.c => netdev_lladdrsize.c} (81%) diff --git a/net/icmpv6/icmpv6_advertise.c b/net/icmpv6/icmpv6_advertise.c index 3e5b6385be..3540720b75 100644 --- a/net/icmpv6/icmpv6_advertise.c +++ b/net/icmpv6/icmpv6_advertise.c @@ -97,7 +97,7 @@ void icmpv6_advertise(FAR struct net_driver_s *dev, { FAR struct ipv6_hdr_s *ipv6 = IPv6BUF; FAR struct icmpv6_neighbor_advertise_s *adv; - uint16_t l1size; + uint16_t lladdrsize; uint16_t l3size; /* Set up the IPv6 header */ @@ -108,8 +108,8 @@ void icmpv6_advertise(FAR struct net_driver_s *dev, /* Length excludes the IPv6 header */ - l1size = netdev_dev_l1size(dev); - l3size = SIZEOF_ICMPV6_NEIGHBOR_ADVERTISE_S(l1size); + lladdrsize = netdev_dev_lladdrsize(dev); + l3size = SIZEOF_ICMPV6_NEIGHBOR_ADVERTISE_S(lladdrsize); ipv6->len[0] = (l3size >> 8); ipv6->len[1] = (l3size & 0xff); @@ -137,14 +137,14 @@ void icmpv6_advertise(FAR struct net_driver_s *dev, /* Set up the options */ - adv->opttype = ICMPv6_OPT_TGTLLADDR; /* Option type */ - adv->optlen = ICMPv6_OPT_OCTECTS(l1size); /* Option length in octets */ + adv->opttype = ICMPv6_OPT_TGTLLADDR; /* Option type */ + adv->optlen = ICMPv6_OPT_OCTECTS(lladdrsize); /* Option length in octets */ /* Copy our link layer address into the message * REVISIT: What if the link layer is not Ethernet? */ - memcpy(adv->tgtlladdr, &dev->d_mac, l1size); + memcpy(adv->tgtlladdr, &dev->d_mac, lladdrsize); /* Calculate the checksum over both the ICMP header and payload */ diff --git a/net/icmpv6/icmpv6_radvertise.c b/net/icmpv6/icmpv6_radvertise.c index c0690ad409..5858c543b6 100644 --- a/net/icmpv6/icmpv6_radvertise.c +++ b/net/icmpv6/icmpv6_radvertise.c @@ -114,7 +114,7 @@ void icmpv6_radvertise(FAR struct net_driver_s *dev) FAR struct icmpv6_srclladdr_s *srcaddr; FAR struct icmpv6_mtu_s *mtu; FAR struct icmpv6_prefixinfo_s *prefix; - uint16_t l1size; + uint16_t lladdrsize; uint16_t l3size; /* Set up the IPv6 header */ @@ -125,9 +125,9 @@ void icmpv6_radvertise(FAR struct net_driver_s *dev) /* Length excludes the IPv6 header */ - l1size = netdev_dev_l1size(dev); + lladdrsize = netdev_dev_lladdrsize(dev); l3size = sizeof(icmpv6_router_advertise_s) + - SIZEOF_ICMPV6_SRCLLADDR_S(l1size) + + SIZEOF_ICMPV6_SRCLLADDR_S(lladdrsize) + sizeof(struct icmpv6_mtu_s) + sizeof(icmpv6_prefixinfo_s); @@ -160,13 +160,13 @@ void icmpv6_radvertise(FAR struct net_driver_s *dev) srcaddr = (FAR struct icmpv6_srclladdr_s *) ((FAR uint8_t *)adv + sizeof(icmpv6_router_advertise_s)); srcaddr->opttype = ICMPv6_OPT_SRCLLADDR; - srcaddr->optlen = ICMPv6_OPT_OCTECTS(l1size); - memcpy(srcaddr->srclladdr, &dev->d_mac, l1size); + srcaddr->optlen = ICMPv6_OPT_OCTECTS(lladdrsize); + memcpy(srcaddr->srclladdr, &dev->d_mac, lladdrsize); /* Set up the MTU option */ mtu = (FAR struct icmpv6_mtu_s *) - ((FAR uint8_t *)srcaddr + SIZEOF_ICMPV6_SRCLLADDR_S(l1size)); + ((FAR uint8_t *)srcaddr + SIZEOF_ICMPV6_SRCLLADDR_S(lladdrsize)); mtu = &adv->mtu; mtu->opttype = ICMPv6_OPT_MTU; mtu->optlen = 1; diff --git a/net/icmpv6/icmpv6_rsolicit.c b/net/icmpv6/icmpv6_rsolicit.c index bbc48742d4..d2c754099c 100644 --- a/net/icmpv6/icmpv6_rsolicit.c +++ b/net/icmpv6/icmpv6_rsolicit.c @@ -93,7 +93,7 @@ void icmpv6_rsolicit(FAR struct net_driver_s *dev) FAR struct ipv6_hdr_s *ipv6; FAR struct icmpv6_router_solicit_s *sol; FAR struct eth_hdr_s *eth; - uint16_t l1size; + uint16_t lladdrsize; uint16_t l3size; /* Set up the IPv6 header (most is probably already in place) */ @@ -105,8 +105,8 @@ void icmpv6_rsolicit(FAR struct net_driver_s *dev) /* Length excludes the IPv6 header */ - l1size = netdev_dev_l1size(dev); - l3size = SIZEOF_ICMPV6_ROUTER_SOLICIT_S(l1size); + lladdrsize = netdev_dev_lladdrsize(dev); + l3size = SIZEOF_ICMPV6_ROUTER_SOLICIT_S(lladdrsize); ipv6->len[0] = (l3size >> 8); ipv6->len[1] = (l3size & 0xff); @@ -135,14 +135,14 @@ void icmpv6_rsolicit(FAR struct net_driver_s *dev) /* Set up the options */ - sol->opttype = ICMPv6_OPT_SRCLLADDR; /* Option type */ - sol->optlen = ICMPv6_OPT_OCTECTS(l1size); /* Option length in octets */ + sol->opttype = ICMPv6_OPT_SRCLLADDR; /* Option type */ + sol->optlen = ICMPv6_OPT_OCTECTS(lladdrsize); /* Option length in octets */ /* Copy our link layer address into the message * REVISIT: What if the link layer is not Ethernet? */ - memcpy(sol->srclladdr, &dev->d_mac, l1size); + memcpy(sol->srclladdr, &dev->d_mac, lladdrsize); /* Calculate the checksum over both the ICMP header and payload */ diff --git a/net/icmpv6/icmpv6_solicit.c b/net/icmpv6/icmpv6_solicit.c index c5d7338899..c8e967cf48 100644 --- a/net/icmpv6/icmpv6_solicit.c +++ b/net/icmpv6/icmpv6_solicit.c @@ -103,7 +103,7 @@ void icmpv6_solicit(FAR struct net_driver_s *dev, { FAR struct ipv6_hdr_s *ipv6; FAR struct icmpv6_neighbor_solicit_s *sol; - uint16_t l1size; + uint16_t lladdrsize; uint16_t l3size; /* Set up the IPv6 header (most is probably already in place) */ @@ -115,8 +115,8 @@ void icmpv6_solicit(FAR struct net_driver_s *dev, /* Length excludes the IPv6 header */ - l1size = netdev_dev_l1size(dev); - l3size = SIZEOF_ICMPV6_NEIGHBOR_SOLICIT_S(l1size); + lladdrsize = netdev_dev_lladdrsize(dev); + l3size = SIZEOF_ICMPV6_NEIGHBOR_SOLICIT_S(lladdrsize); ipv6->len[0] = (l3size >> 8); ipv6->len[1] = (l3size & 0xff); @@ -149,14 +149,14 @@ void icmpv6_solicit(FAR struct net_driver_s *dev, /* Set up the options */ - sol->opttype = ICMPv6_OPT_SRCLLADDR; /* Option type */ - sol->optlen = ICMPv6_OPT_OCTECTS(l1size); /* Option length in octets */ + sol->opttype = ICMPv6_OPT_SRCLLADDR; /* Option type */ + sol->optlen = ICMPv6_OPT_OCTECTS(lladdrsize); /* Option length in octets */ /* Copy our link layer address into the message * REVISIT: What if the link layer is not Ethernet? */ - memcpy(sol->srclladdr, &dev->d_mac, l1size); + memcpy(sol->srclladdr, &dev->d_mac, lladdrsize); /* Calculate the checksum over both the ICMP header and payload */ diff --git a/net/neighbor/neighbor_add.c b/net/neighbor/neighbor_add.c index 5899408275..11e67ef568 100644 --- a/net/neighbor/neighbor_add.c +++ b/net/neighbor/neighbor_add.c @@ -124,7 +124,7 @@ void neighbor_add(FAR net_ipv6addr_t ipaddr, uint8_t lltype, #ifdef CONFIG_NET_MULTILINK g_neighbors[oldest_ndx].ne_addr.u.na_lltype = lltype; #endif - memcpy(&g_neighbors[oldest_ndx].ne_addr.u, addr, netdev_type_l1size(lltype)); + memcpy(&g_neighbors[oldest_ndx].ne_addr.u, addr, netdev_type_lladdrsize(lltype)); /* Dump the contents of the new entry */ diff --git a/net/netdev/Make.defs b/net/netdev/Make.defs index e533f1278d..8a329b0e30 100644 --- a/net/netdev/Make.defs +++ b/net/netdev/Make.defs @@ -39,7 +39,7 @@ NETDEV_CSRCS += netdev_register.c netdev_ioctl.c netdev_txnotify.c NETDEV_CSRCS += netdev_findbyname.c netdev_findbyaddr.c netdev_findbyindex.c NETDEV_CSRCS += netdev_count.c netdev_foreach.c netdev_unregister.c NETDEV_CSRCS += netdev_carrier.c netdev_default.c netdev_verify.c -NETDEV_CSRCS += netdev_l1size.c +NETDEV_CSRCS += netdev_lladdrsize.c ifeq ($(CONFIG_NET_RXAVAIL),y) NETDEV_CSRCS += netdev_rxnotify.c diff --git a/net/netdev/netdev.h b/net/netdev/netdev.h index 4080608c15..83aa7c5f80 100644 --- a/net/netdev/netdev.h +++ b/net/netdev/netdev.h @@ -47,6 +47,31 @@ #include +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/* If there is only one supported link layer, then the size of the link + * layer address is a constant. + * + * NOTE: Literal constants are used here to avoid bringing in all of the + * header files where they are correctly defined. + */ + +#ifndef CONFIG_NET_MULTILINK +# if defined(CONFIG_NET_ETHERNET) +# define NETDEV_LLADDRSIZE 6 /* IFHWADDRLEN */ +# elif defined(CONFIG_NET_6LOWPAN) +# ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR +# define NETDEV_LLADDRSIZE 10 /* NET_6LOWPAN_EADDRSIZE */ +# else +# define NETDEV_LLADDRSIZE 2 /* NET_6LOWPAN_SADDRSIZE */ +# endif +# else +# define NETDEV_LLADDRSIZE 0 /* No link layer address */ +# endif +#endif + /**************************************************************************** * Public Data ****************************************************************************/ @@ -438,15 +463,12 @@ int netdev_count(void); #endif /**************************************************************************** - * Name: netdev_dev_l1size and netdev_type_llsize + * Name: netdev_type_lladdrsize * * Description: - * Size of the MAC address associated with a device or with a link layer - * type. + * Returns the size of the MAC address associated with a link layer type. * * Parameters: - * dev - A reference to the device of interest - * OR * lltype - link layer type code * * Returned Value: @@ -454,8 +476,27 @@ int netdev_count(void); * ****************************************************************************/ -int netdev_type_l1size(uint8_t lltype); -int netdev_dev_l1size(FAR struct net_driver_s *dev); +int netdev_type_lladdrsize(uint8_t lltype); + +/**************************************************************************** + * Name: netdev_dev_lladdrsize + * + * Description: + * Returns the size of the MAC address associated with a network device. + * + * Parameters: + * dev - A reference to the device of interest + * + * Returned Value: + * The size of the MAC address associated with this device + * + ****************************************************************************/ + +#ifdef CONFIG_NET_MULTILINK +# define netdev_dev_lladdrsize(dev) netdev_type_lladdrsize((dev)->d_lltype) +#else +# define netdev_dev_lladdrsize(dev) NETDEV_LLADDRSIZE +#endif #undef EXTERN #ifdef __cplusplus diff --git a/net/netdev/netdev_l1size.c b/net/netdev/netdev_lladdrsize.c similarity index 81% rename from net/netdev/netdev_l1size.c rename to net/netdev/netdev_lladdrsize.c index a16b6069ac..f3e69d3905 100644 --- a/net/netdev/netdev_l1size.c +++ b/net/netdev/netdev_lladdrsize.c @@ -1,5 +1,5 @@ /**************************************************************************** - * net/netdev/netdev_l1size.c + * net/netdev/netdev_lladdrsize.c * * Copyright (C) 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -54,15 +54,12 @@ ****************************************************************************/ /**************************************************************************** - * Name: netdev_dev_l1size and netdev_type_llsize + * Name: netdev_type_lladdrsize * * Description: - * Size of the MAC address associated with a device or with a link layer - * type. + * Returns the size of the MAC address associated with a link layer type. * * Parameters: - * dev - A reference to the device of interest - * OR * lltype - link layer type code * * Returned Value: @@ -70,13 +67,15 @@ * ****************************************************************************/ -int netdev_type_l1size(uint8_t lltype) +int netdev_type_lladdrsize(uint8_t lltype) { /* Get the length of the address for this link layer type */ #ifdef CONFIG_NET_ETHERNET if (lltype == NET_LL_ETHERNET) { + /* size of the Ethernet MAC address */ + return IFHWADDRLEN; } else @@ -84,6 +83,10 @@ int netdev_type_l1size(uint8_t lltype) #ifdef CONFIG_NET_6LOWPAN if (lltype == NET_LL_IEEE802154) { + /* 6LoWPAN can be configured to use either extended or short + * addressing. + */ + #ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR return NET_6LOWPAN_EADDRSIZE; #else @@ -93,25 +96,10 @@ int netdev_type_l1size(uint8_t lltype) else #endif { + /* Either the link layer type associated with lltype has no address, + * or support for that link layer type is not enabled. + */ + return 0; } } - -int netdev_dev_l1size(FAR struct net_driver_s *dev) -{ - /* Get the length of the address for this device */ - -#if defined(CONFIG_NET_MULTILINK) - return netdev_type_l1size(dev->d_lltype); -#elif defined(CONFIG_NET_ETHERNET) - return IFHWADDRLEN; -#elif defined(CONFIG_NET_6LOWPAN) -#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR - return NET_6LOWPAN_EADDRSIZE; -#else - return NET_6LOWPAN_SADDRSIZE; -#endif -#else - return 0; -#endif -} From 8d81b35c4449c9abde4b0b98bec9d9eaf36e7809 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 7 Jul 2017 08:50:01 -0600 Subject: [PATCH 22/31] network: Correct some issues that prevent TCP from working correctly when both IPv4 and IPv6 are enabled. --- net/socket/send.c | 1 + net/tcp/tcp_input.c | 2 +- net/tcp/tcp_send_buffered.c | 2 +- net/tcp/tcp_send_unbuffered.c | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/net/socket/send.c b/net/socket/send.c index 33060b5a32..c47158aca2 100644 --- a/net/socket/send.c +++ b/net/socket/send.c @@ -255,6 +255,7 @@ ssize_t psock_send(FAR struct socket *psock, FAR const void *buf, size_t len, set_errno(-ret); ret = ERROR; } + return ret; } diff --git a/net/tcp/tcp_input.c b/net/tcp/tcp_input.c index 8b34988401..aefde83fd2 100644 --- a/net/tcp/tcp_input.c +++ b/net/tcp/tcp_input.c @@ -285,7 +285,7 @@ static void tcp_input(FAR struct net_driver_s *dev, uint8_t domain, } } - nwarn("WARNING: Old packet .. reset\n"); + nwarn("WARNING: SYN with no listener (or old packet) .. reset\n"); /* This is (1) an old duplicate packet or (2) a SYN packet but with * no matching listener found. Send RST packet in either case. diff --git a/net/tcp/tcp_send_buffered.c b/net/tcp/tcp_send_buffered.c index 7ecf990326..afb8355a34 100644 --- a/net/tcp/tcp_send_buffered.c +++ b/net/tcp/tcp_send_buffered.c @@ -243,7 +243,7 @@ static inline void send_ipselect(FAR struct net_driver_s *dev, /* Select the IPv6 domain */ DEBUGASSERT(conn->domain == PF_INET6); - tcp_ipv4_select(dev); + tcp_ipv6_select(dev); } } #endif diff --git a/net/tcp/tcp_send_unbuffered.c b/net/tcp/tcp_send_unbuffered.c index e4d4a50d4f..e9f2a92627 100644 --- a/net/tcp/tcp_send_unbuffered.c +++ b/net/tcp/tcp_send_unbuffered.c @@ -194,7 +194,7 @@ static inline void tcpsend_ipselect(FAR struct net_driver_s *dev, /* Select the IPv6 domain */ DEBUGASSERT(conn->domain == PF_INET6); - tcp_ipv4_select(dev); + tcp_ipv6_select(dev); } } #endif From 1bddccbc3c6bbbac94179147b2ccf58b3cc94918 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 7 Jul 2017 09:04:09 -0600 Subject: [PATCH 23/31] Update some board README files --- configs/dk-tm4c129x/README.txt | 12 +++++++++--- configs/sama5d4-ek/README.txt | 12 +++++++++--- configs/stm32f4discovery/README.txt | 12 +++++++++--- configs/tm4c1294-launchpad/README.txt | 12 +++++++++--- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/configs/dk-tm4c129x/README.txt b/configs/dk-tm4c129x/README.txt index 291323da4a..9e5aa4ebd0 100644 --- a/configs/dk-tm4c129x/README.txt +++ b/configs/dk-tm4c129x/README.txt @@ -757,7 +757,8 @@ Where is one of the following: configuration other than using IPv6. So all of the notes above regarding the nsh configuration apply. - Telnet does not work with IPv6. + Telnet does work with IPv6 but is not enabled in this + configuration (but could be). 2. This configuration can be modified to that both IPv4 and IPv6 are support. Here is a summary of the additional configuration @@ -788,9 +789,14 @@ Where is one of the following: ping6 fc00::2 (Linux) ping -6 fc00::2 (Windows cmd) - and Telnet again works from the host: + and Telnet is now enabled and works from the host... but only using + IPv6 addressing: - telnet 10.0.0.2 + telnet fc00::2 + + That is because the Telnet daemon will default to IPv6 and there is + no Telnet option to let you select which if both IPv4 and IPv6 are + enabled. 3. You can enable IPv6 autonomous address configuration with the following changes to the configuration: diff --git a/configs/sama5d4-ek/README.txt b/configs/sama5d4-ek/README.txt index 4ea1109f88..c8bb1c0192 100644 --- a/configs/sama5d4-ek/README.txt +++ b/configs/sama5d4-ek/README.txt @@ -3948,7 +3948,8 @@ Configurations configuration other than using IPv6. So all of the notes below regarding the nsh configuration apply. - Telnet does not work with IPv6. + Telnet does work with IPv6 but is not enabled in this + configuration (but could be). 2. This configuration can be modified to that both IPv4 and IPv6 are support. Here is a summary of the additional configuration @@ -3979,9 +3980,14 @@ Configurations ping6 fc00::2 (Linux) ping -6 fc00::2 (Windows cmd) - and Telnet again works from the host: + and Telnet is now enabled and works from the host... but only using + IPv6 addressing: - telent 10.0.0.2 + telnet fc00::2 + + That is because the Telnet daemon will default to IPv6 and there is + no Telnet option to let you select which if both IPv4 and IPv6 are + enabled. 3. You can enable IPv6 autonomous address configuration with the following changes to the configuration: diff --git a/configs/stm32f4discovery/README.txt b/configs/stm32f4discovery/README.txt index b748027d83..6cc16183ee 100644 --- a/configs/stm32f4discovery/README.txt +++ b/configs/stm32f4discovery/README.txt @@ -1349,7 +1349,8 @@ Where is one of the following: configuration other than using IPv6. So all of the notes above regarding the netnsh configuration apply. - a. Telnet does not work with IPv6. + a. Telnet does work with IPv6 but is not enabled in this + configuration (but could be). b. The network initialization thread was enabed in the netnsh configuration on 2015-09-28, but not in the ipv6 configuration. @@ -1382,9 +1383,14 @@ Where is one of the following: ping6 fc00::2 (Linux) ping -6 fc00::2 (Windows cmd) - and Telnet again works from the host: + and Telnet is now enabled and works from the host... but only using + IPv6 addressing: - telent 10.0.0.2 + telnet fc00::2 + + That is because the Telnet daemon will default to IPv6 and there is + no Telnet option to let you select which if both IPv4 and IPv6 are + enabled. 3. I have used this configuration to serve up IP address prefixes in a local network with these modifications to the configuration: diff --git a/configs/tm4c1294-launchpad/README.txt b/configs/tm4c1294-launchpad/README.txt index 1ed896c3e9..b45511d2cf 100644 --- a/configs/tm4c1294-launchpad/README.txt +++ b/configs/tm4c1294-launchpad/README.txt @@ -112,7 +112,8 @@ Where is one of the following: configuration other than using IPv6. So all of the notes above regarding the nsh configuration apply. - Telnet does not work with IPv6. + Telnet does work with IPv6 but is not enabled in this + configuration (but could be). 2. This configuration can be modified to that both IPv4 and IPv6 are support. Here is a summary of the additional configuration @@ -143,9 +144,14 @@ Where is one of the following: ping6 fc00::2 (Linux) ping -6 fc00::2 (Windows cmd) - and Telnet again works from the host: + and Telnet is now enabled and works from the host... but only using + IPv6 addressing: - telnet 10.0.0.2 + telnet fc00::2 + + That is because the Telnet daemon will default to IPv6 and there is + no Telnet option to let you select which if both IPv4 and IPv6 are + enabled. 3. You can enable IPv6 autonomous address configuration with the following changes to the configuration: From 570904375a8fb6685c21a50b6afeb6e1d5857358 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 7 Jul 2017 10:30:24 -0600 Subject: [PATCH 24/31] Add definitions that will permit TUN-only networking. --- configs/sim/nettest/defconfig | 12 ++++- include/nuttx/net/netconfig.h | 96 +++++++++++++++++++++++++++++++---- 2 files changed, 96 insertions(+), 12 deletions(-) diff --git a/configs/sim/nettest/defconfig b/configs/sim/nettest/defconfig index cd7d850534..61d6e14ff8 100644 --- a/configs/sim/nettest/defconfig +++ b/configs/sim/nettest/defconfig @@ -431,6 +431,7 @@ CONFIG_NET_ETHERNET=y # CONFIG_NET_IPv4=y # CONFIG_NET_IPv6 is not set +# CONFIG_NET_IPFORWARD is not set # # Socket Support @@ -497,6 +498,11 @@ CONFIG_NET_ARP_MAXAGE=120 # CONFIG_NET_ARCH_INCR32 is not set # CONFIG_NET_ARCH_CHKSUM is not set CONFIG_NET_STATISTICS=y +# CONFIG_NET_HAVE_STAR is not set + +# +# Network Topologies +# # # Routing Table Configuration @@ -718,14 +724,16 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # CONFIG_EXAMPLES_HIDKBD is not set # CONFIG_EXAMPLES_IGMP is not set # CONFIG_EXAMPLES_JSON is not set -# CONFIG_EXAMPLES_KEYPADTEST is not set # CONFIG_EXAMPLES_MEDIA is not set # CONFIG_EXAMPLES_MM is not set # CONFIG_EXAMPLES_MODBUS is not set # CONFIG_EXAMPLES_MOUNT is not set CONFIG_EXAMPLES_NETTEST=y +CONFIG_EXAMPLES_NETTEST_SENDSIZE=4096 CONFIG_EXAMPLES_NETTEST_STACKSIZE1=2048 CONFIG_EXAMPLES_NETTEST_PRIORITY1=100 +# CONFIG_EXAMPLES_NETTEST_SERVER1 is not set +# CONFIG_EXAMPLES_NETTEST_TARGET2 is not set CONFIG_EXAMPLES_NETTEST_DEVNAME="eth0" # CONFIG_EXAMPLES_NETTEST_PERFORMANCE is not set CONFIG_EXAMPLES_NETTEST_IPv4=y @@ -764,7 +772,6 @@ CONFIG_EXAMPLES_NETTEST_SERVER_PORTNO=5471 # CONFIG_EXAMPLES_SMP is not set # CONFIG_EXAMPLES_STAT is not set # CONFIG_EXAMPLES_TCPECHO is not set -# CONFIG_EXAMPLES_TELNETD is not set # CONFIG_EXAMPLES_TIFF is not set # CONFIG_EXAMPLES_TOUCHSCREEN is not set # CONFIG_EXAMPLES_WATCHDOG is not set @@ -812,6 +819,7 @@ CONFIG_EXAMPLES_NETTEST_SERVER_PORTNO=5471 # CONFIG_NETUTILS_JSON is not set CONFIG_NETUTILS_NETLIB=y # CONFIG_NETUTILS_SMTP is not set +# CONFIG_NETUTILS_TELNETC is not set # CONFIG_NETUTILS_TELNETD is not set # CONFIG_NETUTILS_WEBCLIENT is not set # CONFIG_NETUTILS_WEBSERVER is not set diff --git a/include/nuttx/net/netconfig.h b/include/nuttx/net/netconfig.h index 019fa663db..a4afb1b184 100644 --- a/include/nuttx/net/netconfig.h +++ b/include/nuttx/net/netconfig.h @@ -110,6 +110,12 @@ # endif #endif +#ifdef CONFIG_NET_TUN +# ifndef CONFIG_NET_TUN_MTU +# define CONFIG_NET_TUN_MTU 296 +# endif +#endif + #ifdef CONFIG_NET_ETHERNET # ifndef CONFIG_NET_ETH_MTU # define CONFIG_NET_ETH_MTU 590 @@ -165,12 +171,20 @@ # define _MAX_SLIP_MTU _MAX_LO_MTU # endif -# ifdef CONFIG_NET_6LOWPAN -# define _MIN_6LOWPAN_MTU MIN(_MIN_SLIP_MTU,CONFIG_NET_6LOWPAN_MTU) -# define _MAX_6LOWPAN_MTU MAX(_MAX_SLIP_MTU,CONFIG_NET_6LOWPAN_MTU) +# ifdef CONFIG_NET_TUN +# define _MIN_TUN_MTU MIN(_MIN_SLIP_MTU,CONFIG_NET_TUN_MTU) +# define _MAX_TUN_MTU MAX(_MAX_SLIP_MTU,CONFIG_NET_TUN_MTU) # else -# define _MIN_6LOWPAN_MTU _MIN_SLIP_MTU -# define _MAX_6LOWPAN_MTU _MAX_SLIP_MTU +# define _MIN_TUN_MTU _MIN_SLIP_MTU +# define _MAX_TUN_MTU _MAX_SLIP_MTU +# endif + +# ifdef CONFIG_NET_6LOWPAN +# define _MIN_6LOWPAN_MTU MIN(_MIN_TUN_MTU,CONFIG_NET_6LOWPAN_MTU) +# define _MAX_6LOWPAN_MTU MAX(_MAX_TUN_MTU,CONFIG_NET_6LOWPAN_MTU) +# else +# define _MIN_6LOWPAN_MTU _MIN_TUN_MTU +# define _MAX_6LOWPAN_MTU _MAX_TUN_MTU # endif # define MIN_NET_DEV_MTU _MIN_6LOWPAN_MTU @@ -192,6 +206,14 @@ # define MIN_NET_DEV_MTU CONFIG_NET_SLIP_MTU # define MAX_NET_DEV_MTU CONFIG_NET_SLIP_MTU +#elif defined(CONFIG_NET_TUN) + /* There is no link layer header with TUN */ + +# define NET_LL_HDRLEN(d) 0 +# define NET_DEV_MTU(d) CONFIG_NET_TUN_MTU +# define MIN_NET_DEV_MTU CONFIG_NET_TUN_MTU +# define MAX_NET_DEV_MTU CONFIG_NET_TUN_MTU + #elif defined(CONFIG_NET_ETHERNET) /* Assume standard Ethernet link layer header */ @@ -215,10 +237,10 @@ # define MAX_NET_DEV_MTU NET_LO_MTU #elif defined(CONFIG_NET_6LOWPAN) - /* There is no link layer header with SLIP */ + /* There is no link layer header with 6LoWPAN */ # ifndef CONFIG_NET_IPv6 -# error 6LoWPAN requires IPv support +# error 6LoWPAN requires IP6v support # endif # define NET_LL_HDRLEN(d) 0 @@ -240,7 +262,7 @@ # define MIN_NET_DEV_MTU 0 # define MAX_NET_DEV_MTU 0 -#endif /* MULTILINK or SLIP or ETHERNET */ +#endif /* MULTILINK, SLIP, TUN, LOOPBACK, 6LoWOPAN, or ETHERNET */ /* Layer 3/4 Configuration Options ******************************************/ @@ -332,6 +354,14 @@ # endif #endif +#ifdef CONFIG_NET_TUN +# define TUN_UDP_MSS(h) (CONFIG_NET_TUN_MTU - UDP_HDRLEN - (h)) +# ifndef CONFIG_NET_MULTILINK +# define __MIN_UDP_MSS(h) TUN_UDP_MSS(h) +# define __MAX_UDP_MSS(h) TUN_UDP_MSS(h) +# endif +#endif + #ifdef CONFIG_NET_MULTILINK # ifdef CONFIG_NET_ETHERNET # define __MIN_UDP_MSS(h) ETH_UDP_MSS(h) @@ -378,12 +408,25 @@ # define __SLIP_MIN_UDP_MSS(h) __LOOP_MIN_UDP_MSS(h) # define __SLIP_MAX_UDP_MSS(h) __LOOP_MAX_UDP_MSS(h) # endif + +# ifdef CONFIG_NET_TUN +# undef __MIN_UDP_MSS +# undef __MIN_UDP_MSS +# define __MIN_UDP_MSS(h) MIN(TUN_UDP_MSS(h),__SLIP_MIN_UDP_MSS(h)) +# define __MAX_UDP_MSS(h) MAX(TUN_UDP_MSS(h),__SLIP_MAX_UDP_MSS(h)) +# define __TUN_MIN_UDP_MSS(h) MIN(TUN_UDP_MSS(h),__SLIP_MIN_UDP_MSS(h)) +# define __TUN_MAX_UDP_MSS(h) MAX(TUN_UDP_MSS(h),__SLIP_MAX_UDP_MSS(h)) +# else +# define __TUN_MIN_UDP_MSS(h) __SLIP_MIN_UDP_MSS(h) +# define __TUN_MAX_UDP_MSS(h) __SLIP_MAX_UDP_MSS(h) +# endif #endif #ifdef CONFIG_NET_IPv4 # define UDP_IPv4_MSS(d) UDP_MSS(d,IPv4_HDRLEN) # define ETH_IPv4_UDP_MSS ETH_UDP_MSS(IPv4_HDRLEN) # define SLIP_IPv4_UDP_MSS SLIP_UDP_MSS(IPv4_HDRLEN) +# define TUN_IPv4_UDP_MSS TUN_UDP_MSS(IPv4_HDRLEN) # define MIN_IPv4_UDP_MSS __MIN_UDP_MSS(IPv4_HDRLEN) # define MIN_UDP_MSS __MIN_UDP_MSS(IPv4_HDRLEN) @@ -507,6 +550,14 @@ # endif #endif +#ifdef CONFIG_NET_TUN +# define TUN_TCP_MSS(h) (CONFIG_NET_TUN_MTU - TCP_HDRLEN - (h)) +# ifndef CONFIG_NET_MULTILINK +# define __MIN_TCP_MSS(h) TUN_TCP_MSS(h) +# define __MAX_TCP_MSS(h) TUN_TCP_MSS(h) +# endif +#endif + #ifdef CONFIG_NET_MULTILINK # ifdef CONFIG_NET_ETHERNET @@ -554,6 +605,18 @@ # define __SLIP_MIN_TCP_MSS(h) __LOOP_MIN_TCP_MSS(h) # define __SLIP_MAX_TCP_MSS(h) __LOOP_MAX_TCP_MSS(h) # endif + +# ifdef CONFIG_NET_TUN +# undef __MIN_TCP_MSS +# undef __MAX_TCP_MSS +# define __MIN_TCP_MSS(h) MIN(TUN_TCP_MSS(h),__SLIP_MIN_TCP_MSS(h)) +# define __MAX_TCP_MSS(h) MAX(TUN_TCP_MSS(h),__SLIP_MAX_TCP_MSS(h)) +# define __TUN_MIN_TCP_MSS(h) MIN(TUN_TCP_MSS(h),__SLIP_MIN_TCP_MSS(h)) +# define __TUN_MAX_TCP_MSS(h) MAX(TUN_TCP_MSS(h),__SLIP_MAX_TCP_MSS(h)) +# else +# define __TUN_MIN_TCP_MSS(h) __SLIP_MIN_TCP_MSS(h) +# define __TUN_MAX_TCP_MSS(h) __SLIP_MAX_TCP_MSS(h) +# endif #endif /* If IPv4 is supported, it will have the larger MSS. @@ -564,6 +627,7 @@ # define TCP_IPv6_MSS(d) TCP_MSS(d,IPv6_HDRLEN) # define ETH_IPv6_TCP_MSS ETH_TCP_MSS(IPv6_HDRLEN) # define SLIP_IPv6_TCP_MSS SLIP_TCP_MSS(IPv6_HDRLEN) +# define TUN_IPv6_TCP_MSS TUN_TCP_MSS(IPv6_HDRLEN) # define MAX_TCP_MSS __MAX_TCP_MSS(IPv6_HDRLEN) #endif @@ -571,6 +635,7 @@ # define TCP_IPv4_MSS(d) TCP_MSS(d,IPv4_HDRLEN) # define ETH_IPv4_TCP_MSS ETH_TCP_MSS(IPv4_HDRLEN) # define SLIP_IPv4_TCP_MSS SLIP_TCP_MSS(IPv4_HDRLEN) +# define TUN_IPv4_TCP_MSS TUN_TCP_MSS(IPv4_HDRLEN) # define MIN_TCP_MSS __MIN_TCP_MSS(IPv4_HDRLEN) # undef MAX_TCP_MSS # define MAX_TCP_MSS __MAX_TCP_MSS(IPv4_HDRLEN) @@ -600,6 +665,12 @@ # endif #endif +#ifdef CONFIG_NET_TUN +# ifndef CONFIG_NET_TUN_TCP_RECVWNDO +# define CONFIG_NET_TUN_TCP_RECVWNDO TUN_TCP_MSS(0) +# endif +#endif + #ifdef CONFIG_NET_ETHERNET # ifndef CONFIG_NET_ETH_TCP_RECVWNDO # define CONFIG_NET_ETH_TCP_RECVWNDO ETH_TCP_MSS(0) @@ -615,7 +686,7 @@ # define NET_DEV_RCVWNDO(d) ((d)->d_recvwndo) #elif defined(CONFIG_NET_ETHERNET) - /* Only Ethernet.. use the configured SLIP receive window size */ + /* Only Ethernet.. use the configured Ethernet receive window size */ # define NET_DEV_RCVWNDO(d) CONFIG_NET_ETH_TCP_RECVWNDO @@ -629,12 +700,17 @@ # define NET_DEV_RCVWNDO(d) CONFIG_NET_SLIP_TCP_RECVWNDO +#elif defined(CONFIG_NET_TUN) + /* Only SLIP.. use the configured SLIP receive window size */ + +# define NET_DEV_RCVWNDO(d) CONFIG_NET_TUN_TCP_RECVWNDO + #else /* if defined(CONFIG_NET_LOOPBACK) */ /* Only loal loopback.. use the fixed loopback receive window size */ # define NET_DEV_RCVWNDO(d) NET_LO_TCP_RECVWNDO -#endif /* MULTILINK or SLIP or ETHERNET */ +#endif /* MULTILINK, ETHERNET, 6LoWPAN, SLIP, TUN, or LOOPBACK */ /* How long a connection should stay in the TIME_WAIT state. * From cf5d1cb00d3a3a642f2a612f8bb4f12b23ae619b Mon Sep 17 00:00:00 2001 From: Simon Piriou Date: Fri, 7 Jul 2017 12:05:33 -0600 Subject: [PATCH 25/31] Networking: Fix typo in netconfig.h --- include/nuttx/net/netconfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/nuttx/net/netconfig.h b/include/nuttx/net/netconfig.h index a4afb1b184..202ae5e2ac 100644 --- a/include/nuttx/net/netconfig.h +++ b/include/nuttx/net/netconfig.h @@ -590,7 +590,7 @@ # define __LOOP_MIN_TCP_MSS(h) MIN(LO_TCP_MSS(h),__6LOWPAN_MIN_TCP_MSS(h)) # define __LOOP_MAX_TCP_MSS(h) MAX(LO_TCP_MSS(h),__6LOWPAN_MAX_TCP_MSS(h)) # else -# define __LOOP_MIN_TCP_MSS(h) _6LOWPAN_MIN_TCP_MSS(h) +# define __LOOP_MIN_TCP_MSS(h) __6LOWPAN_MIN_TCP_MSS(h) # define __LOOP_MAX_TCP_MSS(h) __6LOWPAN_MAX_TCP_MSS(h) # endif From b29c99fa6f7980a321f0f2491339ef8072e4656a Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 7 Jul 2017 13:03:04 -0600 Subject: [PATCH 26/31] Move TUN ioctl commnd to include/nuttx/net/ioctl.h so that it will always be unique. It a error in netdev_register: it was not handling device names properly when TUN is the only network device. --- drivers/net/tun.c | 2 +- include/nuttx/net/ioctl.h | 6 +++++- include/nuttx/net/tun.h | 6 ++---- net/netdev/netdev_register.c | 8 +++++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index c9425d8c40..2c3fe2990c 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1155,7 +1155,7 @@ static int tun_ioctl(FAR struct file *filep, int cmd, unsigned long arg) FAR struct tun_device_s *priv = filep->f_priv; int ret = OK; - if (cmd == TUNSETIFF && !priv) + if (cmd == TUNSETIFF && priv == NULL) { uint8_t free_tuns; int intf; diff --git a/include/nuttx/net/ioctl.h b/include/nuttx/net/ioctl.h index 69c513b489..7debbf66c0 100644 --- a/include/nuttx/net/ioctl.h +++ b/include/nuttx/net/ioctl.h @@ -119,9 +119,13 @@ #define SIOCINQ _SIOC(0x0025) /* Returns the amount of queued unread * data in the receive */ +/* TUN/TAP driver ***********************************************************/ + +#define TUNSETIFF _SIOC(0x0026) /* Set TUN/TAP interface */ + /* Telnet driver ************************************************************/ -#define SIOCTELNET _SIOC(0x0026) /* Create a Telnet sessions. +#define SIOCTELNET _SIOC(0x0027) /* Create a Telnet sessions. * See include/nuttx/net/telnet.h */ /**************************************************************************** diff --git a/include/nuttx/net/tun.h b/include/nuttx/net/tun.h index d8c4e68603..1255c33851 100644 --- a/include/nuttx/net/tun.h +++ b/include/nuttx/net/tun.h @@ -52,8 +52,6 @@ * Pre-processor Definitions ****************************************************************************/ -#define TUNSETIFF _SIOC(0x1001) - /* TUNSETIFF ifr flags */ #define IFF_TUN 0x01 @@ -85,12 +83,12 @@ extern "C" * Name: tun_initialize * * Description: - * Instantiate a SLIP network interface. + * Instantiate a TUN network interface. * * Parameters: * * Returned Value: - * OK on success; Negated errno on failure. + * OK on success; Negated errno value on failure. * * Assumptions: * diff --git a/net/netdev/netdev_register.c b/net/netdev/netdev_register.c index 745da4f50a..efe545fb18 100644 --- a/net/netdev/netdev_register.c +++ b/net/netdev/netdev_register.c @@ -68,14 +68,16 @@ #define NETDEV_WLAN_FORMAT "wlan%d" #define NETDEV_WPAN_FORMAT "wpan%d" -#if defined(CONFIG_NET_SLIP) -# define NETDEV_DEFAULT_FORMAT NETDEV_SLIP_FORMAT -#elif defined(CONFIG_DRIVERS_IEEE80211) /* Usually also has CONFIG_NET_ETHERNET */ +#if defined(CONFIG_DRIVERS_IEEE80211) /* Usually also has CONFIG_NET_ETHERNET */ # define NETDEV_DEFAULT_FORMAT NETDEV_WLAN_FORMAT #elif defined(CONFIG_NET_ETHERNET) # define NETDEV_DEFAULT_FORMAT NETDEV_ETH_FORMAT #elif defined(CONFIG_NET_6LOWPAN) # define NETDEV_DEFAULT_FORMAT NETDEV_WPAN_FORMAT +#elif defined(CONFIG_NET_SLIP) +# define NETDEV_DEFAULT_FORMAT NETDEV_SLIP_FORMAT +#elif defined(CONFIG_NET_TUN) +# define NETDEV_DEFAULT_FORMAT NETDEV_TUN_FORMAT #else /* if defined(CONFIG_NET_LOOPBACK) */ # define NETDEV_DEFAULT_FORMAT NETDEV_LO_FORMAT #endif From d61b551bca7461189eaa8bccf4fcb92673d3fea2 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 7 Jul 2017 13:06:25 -0600 Subject: [PATCH 27/31] sim/ipforward: Add an IP forwarding configuration using TUN devices and apps/examples/tun --- configs/sim/ipforward/Make.defs | 128 ++++ configs/sim/ipforward/defconfig | 1055 +++++++++++++++++++++++++++++++ 2 files changed, 1183 insertions(+) create mode 100644 configs/sim/ipforward/Make.defs create mode 100644 configs/sim/ipforward/defconfig diff --git a/configs/sim/ipforward/Make.defs b/configs/sim/ipforward/Make.defs new file mode 100644 index 0000000000..6f9f5fef4a --- /dev/null +++ b/configs/sim/ipforward/Make.defs @@ -0,0 +1,128 @@ +############################################################################ +# configs/sim/ipforward/Make.defs +# +# Copyright (C) 2017 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +include ${TOPDIR}/.config +include ${TOPDIR}/tools/Config.mk + +HOSTOS = ${shell uname -o 2>/dev/null || echo "Other"} + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + ARCHOPTIMIZATION = -g +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += -O2 +endif + +ARCHCPUFLAGS = -fno-builtin +ARCHCPUFLAGSXX = -fno-builtin -fno-exceptions -fcheck-new -fno-rtti +ARCHPICFLAGS = -fpic +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef +ARCHWARNINGSXX = -Wall -Wshadow -Wundef +ARCHDEFINES = +ARCHINCLUDES = -I. -isystem $(TOPDIR)/include +ARCHINCLUDESXX = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx +ARCHSCRIPT = + +ifeq ($(CONFIG_SIM_M32),y) + ARCHCPUFLAGS += -m32 + ARCHCPUFLAGSXX += -m32 +endif + +CROSSDEV = +CC = $(CROSSDEV)gcc +CXX = $(CROSSDEV)g++ +CPP = $(CROSSDEV)gcc -E +LD = $(CROSSDEV)ld +AR = $(CROSSDEV)ar rcs +NM = $(CROSSDEV)nm +OBJCOPY = $(CROSSDEV)objcopy +OBJDUMP = $(CROSSDEV)objdump + +CFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \ + $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CXXFLAGS = $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) \ + $(ARCHCPUFLAGSXX) $(ARCHINCLUDESXX) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) +AFLAGS = $(CFLAGS) -D__ASSEMBLY__ + + +# ELF module definitions + +CELFFLAGS = $(CFLAGS) +CXXELFFLAGS = $(CXXFLAGS) + +LDELFFLAGS = -r -e main +ifeq ($(WINTOOL),y) + LDELFFLAGS += -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/gnu-elf.ld}" +else + LDELFFLAGS += -T $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/gnu-elf.ld +endif + + +ASMEXT = .S +OBJEXT = .o +LIBEXT = .a + +ifeq ($(HOSTOS),Cygwin) + EXEEXT = .exe +else + EXEEXT = +endif + +LDLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(LD) +CCLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(CC) +LDFLAGS = $(ARCHSCRIPT) # For backward compatibility, same as CCLINKFLAGS + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDLINKFLAGS += -g + CCLINKFLAGS += -g + LDFLAGS += -g +endif + +ifeq ($(CONFIG_SIM_M32),y) + LDLINKFLAGS += -melf_i386 + CCLINKFLAGS += -m32 + LDFLAGS += -m32 +endif + + +MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT) + +HOSTCC = gcc +HOSTINCLUDES = -I. +HOSTCFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \ + $(ARCHCPUFLAGS) $(HOSTINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +HOSTLDFLAGS = diff --git a/configs/sim/ipforward/defconfig b/configs/sim/ipforward/defconfig new file mode 100644 index 0000000000..2ba63dee80 --- /dev/null +++ b/configs/sim/ipforward/defconfig @@ -0,0 +1,1055 @@ +# +# Automatically generated file; DO NOT EDIT. +# Nuttx/ Configuration +# + +# +# Build Setup +# +# CONFIG_EXPERIMENTAL is not set +# CONFIG_DEFAULT_SMALL is not set +CONFIG_HOST_LINUX=y +# CONFIG_HOST_OSX is not set +# CONFIG_HOST_WINDOWS is not set +# CONFIG_HOST_OTHER is not set + +# +# Build Configuration +# +# CONFIG_APPS_DIR="../apps" +CONFIG_BUILD_FLAT=y +# CONFIG_BUILD_2PASS is not set + +# +# Binary Output Formats +# +# CONFIG_RRLOAD_BINARY is not set +# CONFIG_INTELHEX_BINARY is not set +# CONFIG_MOTOROLA_SREC is not set +# CONFIG_RAW_BINARY is not set +# CONFIG_UBOOT_UIMAGE is not set +# CONFIG_DFU_BINARY is not set + +# +# Customize Header Files +# +# CONFIG_ARCH_STDINT_H is not set +# CONFIG_ARCH_STDBOOL_H is not set +# CONFIG_ARCH_MATH_H is not set +# CONFIG_ARCH_FLOAT_H is not set +# CONFIG_ARCH_STDARG_H is not set +# CONFIG_ARCH_DEBUG_H is not set + +# +# Debug Options +# +CONFIG_DEBUG_ALERT=y +CONFIG_DEBUG_FEATURES=y + +# +# Debug SYSLOG Output Controls +# +# CONFIG_DEBUG_ERROR is not set +CONFIG_DEBUG_ASSERTIONS=y + +# +# Subsystem Debug Options +# +# CONFIG_DEBUG_BINFMT is not set +# CONFIG_DEBUG_FS is not set +# CONFIG_DEBUG_GRAPHICS is not set +# CONFIG_DEBUG_LIB is not set +# CONFIG_DEBUG_MM is not set +# CONFIG_DEBUG_NET is not set +# CONFIG_DEBUG_SCHED is not set + +# +# OS Function Debug Options +# +# CONFIG_DEBUG_IRQ is not set + +# +# Driver Debug Options +# +# CONFIG_DEBUG_GPIO is not set +# CONFIG_DEBUG_TIMER is not set +# CONFIG_ARCH_HAVE_STACKCHECK is not set +# CONFIG_ARCH_HAVE_HEAPCHECK is not set +CONFIG_DEBUG_SYMBOLS=y +# CONFIG_ARCH_HAVE_CUSTOMOPT is not set +CONFIG_DEBUG_NOOPT=y +# CONFIG_DEBUG_FULLOPT is not set + +# +# System Type +# +# CONFIG_ARCH_ARM is not set +# CONFIG_ARCH_AVR is not set +# CONFIG_ARCH_HC is not set +# CONFIG_ARCH_MIPS is not set +# CONFIG_ARCH_MISOC is not set +# CONFIG_ARCH_RENESAS is not set +# CONFIG_ARCH_RISCV is not set +CONFIG_ARCH_SIM=y +# CONFIG_ARCH_X86 is not set +# CONFIG_ARCH_XTENSA is not set +# CONFIG_ARCH_Z16 is not set +# CONFIG_ARCH_Z80 is not set +CONFIG_ARCH="sim" + +# +# Simulation Configuration Options +# +CONFIG_HOST_X86_64=y +# CONFIG_HOST_X86 is not set +# CONFIG_SIM_M32 is not set +CONFIG_SIM_X8664_SYSTEMV=y +# CONFIG_SIM_X8664_MICROSOFT is not set +CONFIG_SIM_WALLTIME=y +CONFIG_SIM_NETDEV=y +CONFIG_SIM_NET_HOST_ROUTE=y +# CONFIG_SIM_NET_BRIDGE is not set +# CONFIG_SIM_FRAMEBUFFER is not set +# CONFIG_SIM_SPIFLASH is not set +# CONFIG_SIM_QSPIFLASH is not set +# CONFIG_ARCH_TOOLCHAIN_IAR is not set +# CONFIG_ARCH_TOOLCHAIN_GNU is not set + +# +# Architecture Options +# +# CONFIG_ARCH_NOINTC is not set +# CONFIG_ARCH_VECNOTIRQ is not set +# CONFIG_ARCH_DMA is not set +# CONFIG_ARCH_HAVE_IRQPRIO is not set +# CONFIG_ARCH_L2CACHE is not set +# CONFIG_ARCH_HAVE_COHERENT_DCACHE is not set +# CONFIG_ARCH_HAVE_ADDRENV is not set +# CONFIG_ARCH_NEED_ADDRENV_MAPPING is not set +CONFIG_ARCH_HAVE_MULTICPU=y +# CONFIG_ARCH_HAVE_VFORK is not set +# CONFIG_ARCH_HAVE_MMU is not set +# CONFIG_ARCH_HAVE_MPU is not set +# CONFIG_ARCH_NAND_HWECC is not set +# CONFIG_ARCH_HAVE_EXTCLK is not set +CONFIG_ARCH_HAVE_POWEROFF=y +# CONFIG_ARCH_HAVE_RESET is not set +# CONFIG_ARCH_HAVE_RTC_SUBSECONDS is not set +# CONFIG_ARCH_STACKDUMP is not set +# CONFIG_ENDIAN_BIG is not set +# CONFIG_ARCH_IDLE_CUSTOM is not set +# CONFIG_ARCH_HAVE_RAMFUNCS is not set +# CONFIG_ARCH_HAVE_RAMVECTORS is not set +# CONFIG_ARCH_MINIMAL_VECTORTABLE is not set + +# +# Board Settings +# +CONFIG_BOARD_LOOPSPERMSEC=0 +# CONFIG_ARCH_CALIBRATION is not set + +# +# Interrupt options +# +# CONFIG_ARCH_HAVE_INTERRUPTSTACK is not set +# CONFIG_ARCH_HAVE_HIPRI_INTERRUPT is not set + +# +# Boot options +# +CONFIG_BOOT_RUNFROMEXTSRAM=y +# CONFIG_BOOT_RUNFROMFLASH is not set +# CONFIG_BOOT_RUNFROMISRAM is not set +# CONFIG_BOOT_RUNFROMSDRAM is not set +# CONFIG_BOOT_COPYTORAM is not set + +# +# Boot Memory Configuration +# +CONFIG_RAM_START=0x0 +CONFIG_RAM_SIZE=0 +# CONFIG_ARCH_HAVE_SDRAM is not set + +# +# Board Selection +# +CONFIG_ARCH_BOARD_SIM=y +# CONFIG_ARCH_BOARD_CUSTOM is not set +CONFIG_ARCH_BOARD="sim" + +# +# Common Board Options +# + +# +# Board-Specific Options +# +# CONFIG_BOARD_CRASHDUMP is not set +CONFIG_LIB_BOARDCTL=y +CONFIG_BOARDCTL_POWEROFF=y +# CONFIG_BOARDCTL_UNIQUEID is not set +# CONFIG_BOARDCTL_APP_SYMTAB is not set +# CONFIG_BOARDCTL_TSCTEST is not set +# CONFIG_BOARDCTL_GRAPHICS is not set +# CONFIG_BOARDCTL_IOCTL is not set + +# +# RTOS Features +# +CONFIG_DISABLE_OS_API=y +# CONFIG_DISABLE_POSIX_TIMERS is not set +# CONFIG_DISABLE_PTHREAD is not set +# CONFIG_DISABLE_SIGNALS is not set +# CONFIG_DISABLE_MQUEUE is not set +# CONFIG_DISABLE_ENVIRON is not set + +# +# Clocks and Timers +# +CONFIG_ARCH_HAVE_TICKLESS=y +# CONFIG_SCHED_TICKLESS is not set +CONFIG_USEC_PER_TICK=10000 +# CONFIG_SYSTEM_TIME64 is not set +# CONFIG_CLOCK_MONOTONIC is not set +# CONFIG_ARCH_HAVE_TIMEKEEPING is not set +# CONFIG_JULIAN_TIME is not set +CONFIG_START_YEAR=2008 +CONFIG_START_MONTH=6 +CONFIG_START_DAY=1 +CONFIG_MAX_WDOGPARMS=4 +CONFIG_PREALLOC_WDOGS=32 +CONFIG_WDOG_INTRESERVE=4 +CONFIG_PREALLOC_TIMERS=8 + +# +# Tasks and Scheduling +# +# CONFIG_SPINLOCK is not set +# CONFIG_SMP is not set +# CONFIG_INIT_NONE is not set +CONFIG_INIT_ENTRYPOINT=y +# CONFIG_INIT_FILEPATH is not set +CONFIG_USER_ENTRYPOINT="nsh_main" +CONFIG_RR_INTERVAL=0 +# CONFIG_SCHED_SPORADIC is not set +CONFIG_TASK_NAME_SIZE=31 +CONFIG_MAX_TASKS=64 +CONFIG_SCHED_HAVE_PARENT=y +# CONFIG_SCHED_CHILD_STATUS is not set +CONFIG_SCHED_WAITPID=y + +# +# Pthread Options +# +# CONFIG_PTHREAD_MUTEX_TYPES is not set +CONFIG_PTHREAD_MUTEX_ROBUST=y +# CONFIG_PTHREAD_MUTEX_UNSAFE is not set +# CONFIG_PTHREAD_MUTEX_BOTH is not set +CONFIG_NPTHREAD_KEYS=4 +# CONFIG_PTHREAD_CLEANUP is not set +# CONFIG_CANCELLATION_POINTS is not set + +# +# Performance Monitoring +# +# CONFIG_SCHED_CPULOAD is not set +# CONFIG_SCHED_INSTRUMENTATION is not set + +# +# Files and I/O +# +CONFIG_DEV_CONSOLE=y +# CONFIG_FDCLONE_DISABLE is not set +# CONFIG_FDCLONE_STDIO is not set +CONFIG_SDCLONE_DISABLE=y +CONFIG_NFILE_DESCRIPTORS=32 +CONFIG_NFILE_STREAMS=16 +CONFIG_NAME_MAX=32 +# CONFIG_PRIORITY_INHERITANCE is not set + +# +# RTOS hooks +# +# CONFIG_BOARD_INITIALIZE is not set +# CONFIG_SCHED_STARTHOOK is not set +# CONFIG_SCHED_ATEXIT is not set +CONFIG_SCHED_ONEXIT=y +CONFIG_SCHED_ONEXIT_MAX=1 +# CONFIG_SIG_EVTHREAD is not set + +# +# Signal Numbers +# +CONFIG_SIG_SIGUSR1=1 +CONFIG_SIG_SIGUSR2=2 +CONFIG_SIG_SIGALARM=3 +CONFIG_SIG_SIGCHLD=4 +CONFIG_SIG_SIGCONDTIMEDOUT=16 +CONFIG_SIG_SIGWORK=17 + +# +# POSIX Message Queue Options +# +CONFIG_PREALLOC_MQ_MSGS=32 +CONFIG_MQ_MAXMSGSIZE=32 +# CONFIG_MODULE is not set + +# +# Work queue support +# +CONFIG_SCHED_WORKQUEUE=y +# CONFIG_SCHED_HPWORK is not set +CONFIG_SCHED_LPWORK=y +CONFIG_SCHED_LPNTHREADS=1 +CONFIG_SCHED_LPWORKPRIORITY=140 +CONFIG_SCHED_LPWORKPERIOD=50000 +CONFIG_SCHED_LPWORKSTACKSIZE=2048 + +# +# Stack and heap information +# +CONFIG_IDLETHREAD_STACKSIZE=4096 +CONFIG_USERMAIN_STACKSIZE=4096 +CONFIG_PTHREAD_STACK_MIN=256 +CONFIG_PTHREAD_STACK_DEFAULT=8192 +# CONFIG_LIB_SYSCALL is not set + +# +# Device Drivers +# +CONFIG_DISABLE_POLL=y +CONFIG_DEV_NULL=y +CONFIG_DEV_ZERO=y +# CONFIG_DEV_URANDOM is not set +CONFIG_DEV_LOOP=y + +# +# Buffering +# +# CONFIG_DRVR_WRITEBUFFER is not set +# CONFIG_DRVR_READAHEAD is not set +# CONFIG_RAMDISK is not set +# CONFIG_CAN is not set +# CONFIG_ARCH_HAVE_PWM_PULSECOUNT is not set +# CONFIG_ARCH_HAVE_PWM_MULTICHAN is not set +# CONFIG_PWM is not set +# CONFIG_ARCH_HAVE_I2CRESET is not set +# CONFIG_I2C is not set +# CONFIG_ARCH_HAVE_SPI_CRCGENERATION is not set +# CONFIG_ARCH_HAVE_SPI_CS_CONTROL is not set +# CONFIG_ARCH_HAVE_SPI_BITORDER is not set +# CONFIG_SPI is not set +# CONFIG_I2S is not set + +# +# Timer Driver Support +# +# CONFIG_TIMER is not set +# CONFIG_ONESHOT is not set +# CONFIG_RTC is not set +# CONFIG_WATCHDOG is not set +# CONFIG_ANALOG is not set +# CONFIG_AUDIO_DEVICES is not set +# CONFIG_VIDEO_DEVICES is not set +# CONFIG_BCH is not set +# CONFIG_INPUT is not set + +# +# IO Expander/GPIO Support +# +# CONFIG_IOEXPANDER is not set +# CONFIG_DEV_GPIO is not set + +# +# LCD Driver Support +# +# CONFIG_LCD is not set +# CONFIG_SLCD is not set + +# +# LED Support +# +# CONFIG_RGBLED is not set +# CONFIG_PCA9635PW is not set +# CONFIG_NCP5623C is not set +# CONFIG_MMCSD is not set +# CONFIG_MODEM is not set +# CONFIG_MTD is not set +# CONFIG_EEPROM is not set +# CONFIG_NETDEVICES is not set +CONFIG_ARCH_HAVE_NETDEV_STATISTICS=y +# CONFIG_NET_SLIP is not set +# CONFIG_PIPES is not set +# CONFIG_PM is not set +# CONFIG_POWER is not set +# CONFIG_SENSORS is not set +CONFIG_SERIAL=y +# CONFIG_DEV_LOWCONSOLE is not set +# CONFIG_SERIAL_REMOVABLE is not set +CONFIG_SERIAL_CONSOLE=y +# CONFIG_16550_UART is not set +# CONFIG_UART_SERIALDRIVER is not set +# CONFIG_UART0_SERIALDRIVER is not set +# CONFIG_UART1_SERIALDRIVER is not set +# CONFIG_UART2_SERIALDRIVER is not set +# CONFIG_UART3_SERIALDRIVER is not set +# CONFIG_UART4_SERIALDRIVER is not set +# CONFIG_UART5_SERIALDRIVER is not set +# CONFIG_UART6_SERIALDRIVER is not set +# CONFIG_UART7_SERIALDRIVER is not set +# CONFIG_UART8_SERIALDRIVER is not set +# CONFIG_SCI0_SERIALDRIVER is not set +# CONFIG_SCI1_SERIALDRIVER is not set +# CONFIG_USART0_SERIALDRIVER is not set +# CONFIG_USART1_SERIALDRIVER is not set +# CONFIG_USART2_SERIALDRIVER is not set +# CONFIG_USART3_SERIALDRIVER is not set +# CONFIG_USART4_SERIALDRIVER is not set +# CONFIG_USART5_SERIALDRIVER is not set +# CONFIG_USART6_SERIALDRIVER is not set +# CONFIG_USART7_SERIALDRIVER is not set +# CONFIG_USART8_SERIALDRIVER is not set +# CONFIG_OTHER_UART_SERIALDRIVER is not set +# CONFIG_MCU_SERIAL is not set +# CONFIG_STANDARD_SERIAL is not set +# CONFIG_SERIAL_IFLOWCONTROL is not set +# CONFIG_SERIAL_OFLOWCONTROL is not set +# CONFIG_SERIAL_DMA is not set +# CONFIG_ARCH_HAVE_SERIAL_TERMIOS is not set +# CONFIG_PSEUDOTERM is not set +# CONFIG_USBDEV is not set +# CONFIG_USBHOST is not set +# CONFIG_USBMISC is not set +# CONFIG_HAVE_USBTRACE is not set +# CONFIG_DRIVERS_WIRELESS is not set +# CONFIG_DRIVERS_CONTACTLESS is not set + +# +# System Logging +# +# CONFIG_ARCH_SYSLOG is not set +CONFIG_SYSLOG_WRITE=y +# CONFIG_RAMLOG is not set +# CONFIG_SYSLOG_BUFFER is not set +# CONFIG_SYSLOG_INTBUFFER is not set +# CONFIG_SYSLOG_TIMESTAMP is not set +CONFIG_SYSLOG_SERIAL_CONSOLE=y +# CONFIG_SYSLOG_CHAR is not set +CONFIG_SYSLOG_CONSOLE=y +# CONFIG_SYSLOG_NONE is not set +# CONFIG_SYSLOG_FILE is not set +# CONFIG_SYSLOG_CHARDEV is not set + +# +# Networking Support +# +CONFIG_ARCH_HAVE_NET=y +# CONFIG_ARCH_HAVE_PHY is not set +CONFIG_NET=y +# CONFIG_NET_PROMISCUOUS is not set + +# +# Driver buffer configuration +# +CONFIG_NET_GUARDSIZE=2 + +# +# Data link support +# +# CONFIG_NET_MULTILINK is not set +# CONFIG_NET_ETHERNET is not set +# CONFIG_NET_6LOWPAN is not set +# CONFIG_NET_LOOPBACK is not set +CONFIG_NET_TUN=y +CONFIG_TUN_NINTERFACES=2 +CONFIG_NET_TUN_MTU=296 +CONFIG_NET_TUN_TCP_RECVWNDO=256 +CONFIG_TUN_LPWORK=y +# CONFIG_NET_USRSOCK is not set + +# +# Network Device Operations +# +# CONFIG_NETDEV_IOCTL is not set +# CONFIG_NETDEV_PHY_IOCTL is not set + +# +# Internet Protocol Selection +# +# CONFIG_NET_IPv4 is not set +CONFIG_NET_IPv6=y +CONFIG_NET_IPv6_NCONF_ENTRIES=4 +CONFIG_NET_IPFORWARD=y + +# +# Socket Support +# +CONFIG_NSOCKET_DESCRIPTORS=8 +CONFIG_NET_NACTIVESOCKETS=16 +CONFIG_NET_SOCKOPTS=y +# CONFIG_NET_SOLINGER is not set + +# +# Raw Socket Support +# +# CONFIG_NET_PKT is not set + +# +# Unix Domain Socket Support +# +# CONFIG_NET_LOCAL is not set + +# +# TCP/IP Networking +# +CONFIG_NET_TCP=y +# CONFIG_NET_TCP_NO_STACK is not set +# CONFIG_NET_TCPURGDATA is not set +CONFIG_NET_TCP_CONNS=8 +CONFIG_NET_MAX_LISTENPORTS=16 +CONFIG_NET_TCP_READAHEAD=y +CONFIG_NET_TCP_WRITE_BUFFERS=y +CONFIG_NET_TCP_NWRBCHAINS=8 +# CONFIG_NET_TCP_WRBUFFER_DEBUG is not set +CONFIG_NET_TCP_RECVDELAY=0 +CONFIG_NET_TCPBACKLOG=y +# CONFIG_NET_SENDFILE is not set + +# +# UDP Networking +# +# CONFIG_NET_UDP is not set +# CONFIG_NET_UDP_NO_STACK is not set + +# +# ICMPv6 Networking Support +# +# CONFIG_NET_ICMPv6 is not set + +# +# IGMPv2 Client Support +# +# CONFIG_NET_IGMP is not set + +# +# ARP Configuration +# + +# +# User-space networking stack API +# +# CONFIG_NET_ARCH_INCR32 is not set +# CONFIG_NET_ARCH_CHKSUM is not set +# CONFIG_NET_STATISTICS is not set +# CONFIG_NET_HAVE_STAR is not set + +# +# Network Topologies +# + +# +# Routing Table Configuration +# +# CONFIG_NET_ROUTE is not set +CONFIG_NET_HOSTNAME="IP-Forward" + +# +# Crypto API +# +# CONFIG_CRYPTO is not set + +# +# File Systems +# + +# +# File system configuration +# +# CONFIG_DISABLE_MOUNTPOINT is not set +# CONFIG_FS_AUTOMOUNTER is not set +# CONFIG_DISABLE_PSEUDOFS_OPERATIONS is not set +# CONFIG_PSEUDOFS_SOFTLINKS is not set +CONFIG_FS_READABLE=y +CONFIG_FS_WRITABLE=y +# CONFIG_FS_AIO is not set +# 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 +CONFIG_FAT_LFN=y +CONFIG_FAT_MAXFNAME=32 +# CONFIG_FS_FATTIME is not set +# CONFIG_FAT_FORCE_INDIRECT is not set +# CONFIG_FAT_DMAMEMORY is not set +# CONFIG_FAT_DIRECT_RETRY is not set +# CONFIG_FS_NXFFS is not set +CONFIG_FS_ROMFS=y +# CONFIG_FS_TMPFS is not set +# CONFIG_FS_SMARTFS is not set +# CONFIG_FS_BINFS is not set +CONFIG_FS_PROCFS=y +# CONFIG_FS_PROCFS_REGISTER is not set + +# +# Exclude individual procfs entries +# +# CONFIG_FS_PROCFS_EXCLUDE_PROCESS is not set +# CONFIG_FS_PROCFS_EXCLUDE_UPTIME is not set +# CONFIG_FS_PROCFS_EXCLUDE_MOUNTS is not set +# CONFIG_FS_PROCFS_EXCLUDE_NET is not set +# CONFIG_FS_UNIONFS is not set +# CONFIG_FS_HOSTFS is not set + +# +# Graphics Support +# +# CONFIG_NX is not set + +# +# Memory Management +# +# CONFIG_MM_SMALL is not set +CONFIG_MM_REGIONS=1 +# CONFIG_ARCH_HAVE_HEAP2 is not set +# CONFIG_GRAN is not set + +# +# Common I/O Buffer Support +# +CONFIG_MM_IOB=y +CONFIG_IOB_NBUFFERS=36 +CONFIG_IOB_BUFSIZE=196 +CONFIG_IOB_NCHAINS=8 +CONFIG_IOB_THROTTLE=8 +# CONFIG_IOB_DEBUG is not set + +# +# Audio Support +# +# CONFIG_AUDIO is not set + +# +# Wireless Support +# +# CONFIG_WIRELESS is not set + +# +# Binary Loader +# +# CONFIG_BINFMT_DISABLE is not set +CONFIG_BINFMT_EXEPATH=y +CONFIG_PATH_INITIAL="/bin" +# CONFIG_NXFLAT is not set +# CONFIG_ELF is not set +CONFIG_BUILTIN=y +# CONFIG_PIC is not set +# CONFIG_SYMTAB_ORDEREDBYNAME is not set + +# +# Library Routines +# + +# +# Standard C Library Options +# + +# +# Standard C I/O +# +# CONFIG_STDIO_DISABLE_BUFFERING is not set +CONFIG_STDIO_BUFFER_SIZE=64 +CONFIG_STDIO_LINEBUFFER=y +CONFIG_NUNGET_CHARS=2 +# CONFIG_NOPRINTF_FIELDWIDTH is not set +# CONFIG_LIBC_FLOATINGPOINT is not set +CONFIG_LIBC_LONG_LONG=y +# CONFIG_LIBC_SCANSET is not set +# CONFIG_EOL_IS_CR is not set +# CONFIG_EOL_IS_LF is not set +# CONFIG_EOL_IS_BOTH_CRLF is not set +CONFIG_EOL_IS_EITHER_CRLF=y +# CONFIG_MEMCPY_VIK is not set +# CONFIG_LIBM is not set + +# +# Architecture-Specific Support +# +CONFIG_ARCH_LOWPUTC=y +# CONFIG_ARCH_ROMGETC is not set +# CONFIG_LIBC_ARCH_MEMCPY is not set +# CONFIG_LIBC_ARCH_MEMCMP is not set +# CONFIG_LIBC_ARCH_MEMMOVE is not set +# CONFIG_LIBC_ARCH_MEMSET is not set +# CONFIG_LIBC_ARCH_STRCHR is not set +# CONFIG_LIBC_ARCH_STRCMP is not set +# CONFIG_LIBC_ARCH_STRCPY is not set +# CONFIG_LIBC_ARCH_STRNCPY is not set +# CONFIG_LIBC_ARCH_STRLEN is not set +# CONFIG_LIBC_ARCH_STRNLEN is not set +# CONFIG_LIBC_ARCH_ELF is not set + +# +# stdlib Options +# +CONFIG_LIB_RAND_ORDER=1 +CONFIG_LIB_HOMEDIR="/" +CONFIG_LIBC_TMPDIR="/tmp" +CONFIG_LIBC_MAX_TMPFILE=32 + +# +# Program Execution Options +# +CONFIG_LIBC_EXECFUNCS=y +CONFIG_EXECFUNCS_HAVE_SYMTAB=y +CONFIG_EXECFUNCS_SYMTAB="g_symtab" +CONFIG_EXECFUNCS_NSYMBOLS=0 +CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=2048 +CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=2048 + +# +# errno Decode Support +# +# CONFIG_LIBC_STRERROR is not set +# CONFIG_LIBC_PERROR_STDOUT is not set + +# +# memcpy/memset Options +# +# CONFIG_MEMSET_OPTSPEED is not set +# CONFIG_LIBC_DLLFCN is not set +# CONFIG_LIBC_MODLIB is not set +# CONFIG_LIBC_WCHAR is not set +# CONFIG_LIBC_LOCALE is not set + +# +# Time/Time Zone Support +# +# CONFIG_LIBC_LOCALTIME is not set +CONFIG_TIME_EXTENDED=y +CONFIG_ARCH_HAVE_TLS=y + +# +# Thread Local Storage (TLS) +# +# CONFIG_TLS is not set + +# +# Network-Related Options +# +# CONFIG_LIBC_IPv4_ADDRCONV is not set +CONFIG_LIBC_NETDB=y + +# +# NETDB Support +# +# CONFIG_NETDB_HOSTFILE is not set +# CONFIG_LIBC_IOCTL_VARIADIC is not set +CONFIG_LIB_SENDFILE_BUFSIZE=512 + +# +# Non-standard Library Support +# +# CONFIG_LIB_CRC64_FAST is not set +# CONFIG_LIB_KBDCODEC is not set +# CONFIG_LIB_SLCDCODEC is not set +# CONFIG_LIB_HEX2BIN is not set + +# +# Basic CXX Support +# +# CONFIG_C99_BOOL8 is not set +# CONFIG_HAVE_CXX is not set + +# +# Application Configuration +# + +# +# Built-In Applications +# +CONFIG_BUILTIN_PROXY_STACKSIZE=1024 + +# +# CAN Utilities +# + +# +# Examples +# +# CONFIG_EXAMPLES_CCTYPE is not set +# CONFIG_EXAMPLES_CHAT is not set +# CONFIG_EXAMPLES_CONFIGDATA is not set +# CONFIG_EXAMPLES_DHCPD is not set +# CONFIG_EXAMPLES_ELF is not set +# CONFIG_EXAMPLES_FSTEST is not set +# CONFIG_EXAMPLES_FTPC is not set +# CONFIG_EXAMPLES_FTPD is not set +# CONFIG_EXAMPLES_HELLO is not set +# CONFIG_EXAMPLES_HIDKBD is not set +# CONFIG_EXAMPLES_IGMP is not set +CONFIG_EXAMPLES_IPFORWARD=y +CONFIG_EXAMPLES_IPFORWARD_PRIORITY=100 +CONFIG_EXAMPLES_IPFORWARD_STACKSIZE=2048 +# CONFIG_EXAMPLES_JSON is not set +# CONFIG_EXAMPLES_MEDIA is not set +# CONFIG_EXAMPLES_MM is not set +# CONFIG_EXAMPLES_MODBUS is not set +# CONFIG_EXAMPLES_MOUNT is not set +# CONFIG_EXAMPLES_NETTEST is not set +CONFIG_EXAMPLES_NSH=y +# CONFIG_EXAMPLES_NULL is not set +# CONFIG_EXAMPLES_NX is not set +# CONFIG_EXAMPLES_NXFFS is not set +# CONFIG_EXAMPLES_NXHELLO is not set +# CONFIG_EXAMPLES_NXIMAGE is not set +# CONFIG_EXAMPLES_NXLINES is not set +# CONFIG_EXAMPLES_NXTERM is not set +# CONFIG_EXAMPLES_NXTEXT is not set +# CONFIG_EXAMPLES_OSTEST is not set +# CONFIG_EXAMPLES_PCA9635 is not set +# CONFIG_EXAMPLES_POSIXSPAWN is not set +# CONFIG_EXAMPLES_PPPD is not set +# CONFIG_EXAMPLES_RFID_READUID is not set +# CONFIG_EXAMPLES_RGBLED is not set +# CONFIG_EXAMPLES_ROMFS is not set +# CONFIG_EXAMPLES_SENDMAIL is not set +# CONFIG_EXAMPLES_SERIALBLASTER is not set +# CONFIG_EXAMPLES_SERIALRX is not set +# CONFIG_EXAMPLES_SERLOOP is not set +# CONFIG_EXAMPLES_SLCD is not set +# CONFIG_EXAMPLES_SMART is not set +# CONFIG_EXAMPLES_SMART_TEST is not set +# CONFIG_EXAMPLES_SMP is not set +# CONFIG_EXAMPLES_STAT is not set +# CONFIG_EXAMPLES_TCPECHO is not set +# CONFIG_EXAMPLES_THTTPD is not set +# CONFIG_EXAMPLES_TIFF is not set +# CONFIG_EXAMPLES_TOUCHSCREEN is not set +# CONFIG_EXAMPLES_UNIONFS is not set +# CONFIG_EXAMPLES_USBSERIAL is not set +# CONFIG_EXAMPLES_WATCHDOG is not set +# CONFIG_EXAMPLES_WEBSERVER is not set +# CONFIG_EXAMPLES_XBC_TEST is not set + +# +# File System Utilities +# +# CONFIG_FSUTILS_INIFILE is not set +CONFIG_FSUTILS_PASSWD=y +CONFIG_FSUTILS_PASSWD_PATH="/etc/passwd" +CONFIG_FSUTILS_PASSWD_READONLY=y +CONFIG_FSUTILS_PASSWD_IOBUFFER_SIZE=512 +CONFIG_FSUTILS_PASSWD_KEY1=0x12345678 +CONFIG_FSUTILS_PASSWD_KEY2=0x9abcdef0 +CONFIG_FSUTILS_PASSWD_KEY3=0x12345678 +CONFIG_FSUTILS_PASSWD_KEY4=0x9abcdef0 + +# +# GPS Utilities +# +# CONFIG_GPSUTILS_MINMEA_LIB is not set + +# +# Graphics Support +# +# CONFIG_TIFF is not set +# CONFIG_GRAPHICS_TRAVELER is not set + +# +# Interpreters +# +# CONFIG_INTERPRETERS_BAS is not set +# CONFIG_INTERPRETERS_FICL is not set +# CONFIG_INTERPRETERS_MICROPYTHON is not set +# CONFIG_INTERPRETERS_MINIBASIC is not set +# CONFIG_INTERPRETERS_PCODE is not set + +# +# FreeModBus +# +# CONFIG_MODBUS is not set + +# +# Network Utilities +# +# CONFIG_NETUTILS_CODECS is not set +# CONFIG_NETUTILS_ESP8266 is not set +# CONFIG_NETUTILS_FTPC is not set +# CONFIG_NETUTILS_JSON is not set +CONFIG_NETUTILS_NETLIB=y +# CONFIG_NETUTILS_SMTP is not set +# CONFIG_NETUTILS_TELNETC is not set +# CONFIG_NETUTILS_TELNETD is not set +# CONFIG_NETUTILS_WEBCLIENT is not set +# CONFIG_NETUTILS_WEBSERVER is not set +# CONFIG_NETUTILS_XMLRPC is not set + +# +# NSH Library +# +CONFIG_NSH_LIBRARY=y +# CONFIG_NSH_MOTD is not set + +# +# Command Line Configuration +# +CONFIG_NSH_READLINE=y +# CONFIG_NSH_CLE is not set +CONFIG_NSH_LINELEN=80 +# CONFIG_NSH_DISABLE_SEMICOLON is not set +CONFIG_NSH_CMDPARMS=y +CONFIG_NSH_MAXARGUMENTS=6 +CONFIG_NSH_ARGCAT=y +CONFIG_NSH_NESTDEPTH=3 +# CONFIG_NSH_DISABLEBG is not set +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILE_APPS=y + +# +# Disable Individual commands +# +# CONFIG_NSH_DISABLE_ADDROUTE is not set +# CONFIG_NSH_DISABLE_BASENAME is not set +# CONFIG_NSH_DISABLE_CAT is not set +# CONFIG_NSH_DISABLE_CD is not set +# CONFIG_NSH_DISABLE_CP is not set +# CONFIG_NSH_DISABLE_CMP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_DD is not set +# CONFIG_NSH_DISABLE_DF is not set +# CONFIG_NSH_DISABLE_DELROUTE is not set +# CONFIG_NSH_DISABLE_DIRNAME is not set +# CONFIG_NSH_DISABLE_ECHO is not set +# CONFIG_NSH_DISABLE_EXEC is not set +# CONFIG_NSH_DISABLE_EXIT is not set +# CONFIG_NSH_DISABLE_FREE is not set +# CONFIG_NSH_DISABLE_GET is not set +# CONFIG_NSH_DISABLE_HELP is not set +# CONFIG_NSH_DISABLE_HEXDUMP is not set +# CONFIG_NSH_DISABLE_IFCONFIG is not set +# CONFIG_NSH_DISABLE_IFUPDOWN is not set +# CONFIG_NSH_DISABLE_KILL is not set +# CONFIG_NSH_DISABLE_LOSETUP is not set +CONFIG_NSH_DISABLE_LOSMART=y +# CONFIG_NSH_DISABLE_LS is not set +# CONFIG_NSH_DISABLE_MB is not set +# CONFIG_NSH_DISABLE_MKDIR is not set +# CONFIG_NSH_DISABLE_MKFATFS is not set +# CONFIG_NSH_DISABLE_MKRD is not set +# CONFIG_NSH_DISABLE_MH is not set +# CONFIG_NSH_DISABLE_MOUNT is not set +# CONFIG_NSH_DISABLE_MV is not set +# CONFIG_NSH_DISABLE_MW is not set +# CONFIG_NSH_DISABLE_POWEROFF is not set +CONFIG_NSH_DISABLE_PRINTF=y +# CONFIG_NSH_DISABLE_PS is not set +# CONFIG_NSH_DISABLE_PUT is not set +# CONFIG_NSH_DISABLE_PWD is not set +# CONFIG_NSH_DISABLE_RM is not set +# CONFIG_NSH_DISABLE_RMDIR is not set +# CONFIG_NSH_DISABLE_SET is not set +# CONFIG_NSH_DISABLE_SH is not set +CONFIG_NSH_DISABLE_SHUTDOWN=y +# CONFIG_NSH_DISABLE_SLEEP is not set +# CONFIG_NSH_DISABLE_TIME is not set +# CONFIG_NSH_DISABLE_TEST is not set +# CONFIG_NSH_DISABLE_TELNETD is not set +# CONFIG_NSH_DISABLE_UMOUNT is not set +# CONFIG_NSH_DISABLE_UNAME is not set +# CONFIG_NSH_DISABLE_UNSET is not set +# CONFIG_NSH_DISABLE_USLEEP is not set +# CONFIG_NSH_DISABLE_WGET is not set +# CONFIG_NSH_DISABLE_XD is not set +CONFIG_NSH_MMCSDMINOR=0 + +# +# Configure Command Options +# +# CONFIG_NSH_CMDOPT_DF_H is not set +# CONFIG_NSH_CMDOPT_DD_STATS is not set +CONFIG_NSH_CODECS_BUFSIZE=128 +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +CONFIG_NSH_PROC_MOUNTPOINT="/proc" +CONFIG_NSH_FILEIOSIZE=1024 + +# +# Scripting Support +# +# CONFIG_NSH_DISABLESCRIPT is not set +# CONFIG_NSH_DISABLE_ITEF is not set +# CONFIG_NSH_DISABLE_LOOPS is not set +CONFIG_NSH_ROMFSETC=y +# CONFIG_NSH_ROMFSRC is not set +CONFIG_NSH_ROMFSMOUNTPT="/etc" +CONFIG_NSH_INITSCRIPT="init.d/rcS" +CONFIG_NSH_ROMFSDEVNO=1 +CONFIG_NSH_ROMFSSECTSIZE=64 +# CONFIG_NSH_DEFAULTROMFS is not set +CONFIG_NSH_ARCHROMFS=y +# CONFIG_NSH_CUSTOMROMFS is not set +CONFIG_NSH_FATDEVNO=2 +CONFIG_NSH_FATSECTSIZE=512 +CONFIG_NSH_FATNSECTORS=1024 +CONFIG_NSH_FATMOUNTPT="/tmp" + +# +# Console Configuration +# +CONFIG_NSH_CONSOLE=y +# CONFIG_NSH_ALTCONDEV is not set +CONFIG_NSH_ARCHINIT=y + +# +# Networking Configuration +# +# CONFIG_NSH_NETINIT is not set +CONFIG_NSH_MAX_ROUNDTRIP=20 +# CONFIG_NSH_LOGIN is not set +# CONFIG_NSH_CONSOLE_LOGIN is not set + +# +# NxWidgets/NxWM +# + +# +# Platform-specific Support +# +# CONFIG_PLATFORM_CONFIGDATA is not set + +# +# System Libraries and NSH Add-Ons +# +# CONFIG_SYSTEM_CLE is not set +# CONFIG_SYSTEM_CUTERM is not set +# CONFIG_SYSTEM_FREE is not set +# CONFIG_SYSTEM_HEX2BIN is not set +# CONFIG_SYSTEM_HEXED is not set +# CONFIG_SYSTEM_INSTALL is not set +# CONFIG_SYSTEM_NETDB is not set +# CONFIG_SYSTEM_RAMTEST is not set +CONFIG_READLINE_HAVE_EXTMATCH=y +CONFIG_SYSTEM_READLINE=y +CONFIG_READLINE_ECHO=y +CONFIG_READLINE_TABCOMPLETION=y +CONFIG_READLINE_MAX_BUILTINS=64 +CONFIG_READLINE_MAX_EXTCMDS=64 +# CONFIG_READLINE_CMD_HISTORY is not set +# CONFIG_SYSTEM_SUDOKU is not set +# CONFIG_SYSTEM_SYMTAB is not set +# CONFIG_SYSTEM_SYSTEM is not set +# CONFIG_SYSTEM_TEE is not set +# CONFIG_SYSTEM_UBLOXMODEM is not set +# CONFIG_SYSTEM_VI is not set +# CONFIG_SYSTEM_ZMODEM is not set + +# +# Wireless Libraries and NSH Add-Ons +# + +# +# IEEE 802.15.4 applications +# +# CONFIG_IEEE802154_LIBMAC is not set +# CONFIG_IEEE802154_LIBUTILS is not set +# CONFIG_IEEE802154_I8SAK is not set From 99ef7c666900f45d86927fd7b8d6ee86c56ad412 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 7 Jul 2017 17:33:44 -0600 Subject: [PATCH 28/31] IP forwarding: A few fixes from early testing; In TUN driver, do all polling on worker thread. Otherwise, the stack gets very deep. --- configs/sim/ipforward/defconfig | 25 ++++++++++++++++++--- drivers/net/tun.c | 40 ++++++++++++++++++++++++++++----- net/devif/ipv4_forward.c | 2 +- net/devif/ipv6_forward.c | 4 ++-- net/netdev/netdev_txnotify.c | 2 +- 5 files changed, 61 insertions(+), 12 deletions(-) diff --git a/configs/sim/ipforward/defconfig b/configs/sim/ipforward/defconfig index 2ba63dee80..312519a65f 100644 --- a/configs/sim/ipforward/defconfig +++ b/configs/sim/ipforward/defconfig @@ -303,7 +303,7 @@ CONFIG_SCHED_LPWORK=y CONFIG_SCHED_LPNTHREADS=1 CONFIG_SCHED_LPWORKPRIORITY=140 CONFIG_SCHED_LPWORKPERIOD=50000 -CONFIG_SCHED_LPWORKSTACKSIZE=2048 +CONFIG_SCHED_LPWORKSTACKSIZE=8192 # # Stack and heap information @@ -376,9 +376,26 @@ CONFIG_DEV_LOOP=y # CONFIG_MODEM is not set # CONFIG_MTD is not set # CONFIG_EEPROM is not set -# CONFIG_NETDEVICES is not set +CONFIG_NETDEVICES=y + +# +# General Ethernet MAC Driver Options +# +# CONFIG_NETDEV_LOOPBACK is not set +# CONFIG_NETDEV_TELNET is not set +CONFIG_NETDEV_MULTINIC=y CONFIG_ARCH_HAVE_NETDEV_STATISTICS=y +# CONFIG_NETDEV_LATEINIT is not set +# CONFIG_NET_DUMPPACKET is not set + +# +# External Ethernet MAC Device Support +# +# CONFIG_NET_DM90x0 is not set +# CONFIG_ENC28J60 is not set +# CONFIG_ENCX24J600 is not set # CONFIG_NET_SLIP is not set +# CONFIG_NET_FTMAC100 is not set # CONFIG_PIPES is not set # CONFIG_PM is not set # CONFIG_POWER is not set @@ -480,6 +497,8 @@ CONFIG_TUN_LPWORK=y CONFIG_NET_IPv6=y CONFIG_NET_IPv6_NCONF_ENTRIES=4 CONFIG_NET_IPFORWARD=y +# CONFIG_NET_IPFORWARD_BROADCAST is not set +CONFIG_NET_IPFORWARD_NSTRUCT=4 # # Socket Support @@ -790,7 +809,7 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024 # CONFIG_EXAMPLES_IGMP is not set CONFIG_EXAMPLES_IPFORWARD=y CONFIG_EXAMPLES_IPFORWARD_PRIORITY=100 -CONFIG_EXAMPLES_IPFORWARD_STACKSIZE=2048 +CONFIG_EXAMPLES_IPFORWARD_STACKSIZE=8192 # CONFIG_EXAMPLES_JSON is not set # CONFIG_EXAMPLES_MEDIA is not set # CONFIG_EXAMPLES_MM is not set diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 2c3fe2990c..33fd566307 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -684,7 +684,7 @@ static int tun_ifdown(struct net_driver_s *dev) } /**************************************************************************** - * Name: tun_txavail + * Name: tun_txavail_work * * Description: * Driver callback invoked when new TX data is available. This is a @@ -702,9 +702,9 @@ static int tun_ifdown(struct net_driver_s *dev) * ****************************************************************************/ -static int tun_txavail(struct net_driver_s *dev) +static void tun_txavail_work(FAR void *arg) { - FAR struct tun_device_s *priv = (FAR struct tun_device_s *)dev->d_private; + FAR struct tun_device_s *priv = (FAR struct tun_device_s *)arg; tun_lock(priv); @@ -713,11 +713,10 @@ static int tun_txavail(struct net_driver_s *dev) if (priv->read_d_len != 0 || priv->write_d_len != 0) { tun_unlock(priv); - return OK; + return; } net_lock(); - if (priv->bifup) { /* Poll the network for new XMIT data */ @@ -728,6 +727,37 @@ static int tun_txavail(struct net_driver_s *dev) net_unlock(); tun_unlock(priv); +} + +/**************************************************************************** + * Name: tun_txavail + * + * Description: + * Driver callback invoked when new TX data is available. This is a + * stimulus perform an out-of-cycle poll and, thereby, reduce the TX + * latency. + * + * Parameters: + * dev - Reference to the NuttX driver state structure + * + * Returned Value: + * None + * + * Assumptions: + * Called from the network stack with the network locked. + * + ****************************************************************************/ + +static int tun_txavail(struct net_driver_s *dev) +{ + FAR struct tun_device_s *priv = (FAR struct tun_device_s *)dev->d_private; + + /* Schedule to perform the TX poll on the worker thread. */ + + if (work_available(&priv->work)) + { + work_queue(TUNWORK, &priv->work, tun_txavail_work, priv, 0); + } return OK; } diff --git a/net/devif/ipv4_forward.c b/net/devif/ipv4_forward.c index 075f47bc7a..1614808f9f 100644 --- a/net/devif/ipv4_forward.c +++ b/net/devif/ipv4_forward.c @@ -91,7 +91,7 @@ static int ipv4_hdrsize(FAR struct ipv4_hdr_s *ipv4) case IP_PROTO_TCP: { FAR struct tcp_hdr_s *tcp = - (FAR struct tcp_hdr_s *)((FAR uintptr_t *)ipv4 + IPv4_HDRLEN); + (FAR struct tcp_hdr_s *)((FAR uint8_t *)ipv4 + IPv4_HDRLEN); unsigned int tcpsize; /* The TCP header length is encoded in the top 4 bits of the diff --git a/net/devif/ipv6_forward.c b/net/devif/ipv6_forward.c index 240ed6de6a..cd33b54d86 100644 --- a/net/devif/ipv6_forward.c +++ b/net/devif/ipv6_forward.c @@ -97,7 +97,7 @@ static int ipv6_hdrsize(FAR struct ipv6_hdr_s *ipv6) case IP_PROTO_TCP: { FAR struct tcp_hdr_s *tcp = - (FAR struct tcp_hdr_s *)((FAR uintptr_t *)ipv6 + IPv6_HDRLEN); + (FAR struct tcp_hdr_s *)((FAR uint8_t *)ipv6 + IPv6_HDRLEN); unsigned int tcpsize; /* The TCP header length is encoded in the top 4 bits of the @@ -337,7 +337,7 @@ static int ipv6_packet_conversion(FAR struct net_driver_s *dev, return ret; } #else -# define ipv6_packet_conversion(dev, ipv6) (PACKET_NOT_FORWARDED) +# define ipv6_packet_conversion(dev, fwddev, ipv6) (PACKET_NOT_FORWARDED) #endif /* CONFIG_NET_6LOWPAN */ /**************************************************************************** diff --git a/net/netdev/netdev_txnotify.c b/net/netdev/netdev_txnotify.c index 72382e01df..fca1b9d070 100644 --- a/net/netdev/netdev_txnotify.c +++ b/net/netdev/netdev_txnotify.c @@ -167,7 +167,7 @@ void netdev_ipv6_txnotify(FAR const net_ipv6addr_t ripaddr) void netdev_txnotify_dev(FAR struct net_driver_s *dev) { - if (dev && dev->d_txavail) + if (dev != NULL && dev->d_txavail != NULL) { /* Notify the device driver that new TX data is available. */ From 7258f1cbfc6b635abd446ebd81658ccd4c16286d Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 7 Jul 2017 18:33:06 -0600 Subject: [PATCH 29/31] IP forwarding: Move to separate directory. A few fixes from early testing; In TUN driver, do all polling on worker thread. Otherwise, the stack gets very deep. --- net/Kconfig | 35 +-------------- net/Makefile | 3 +- net/README.txt | 31 +++++++------- net/devif/Make.defs | 10 ++--- net/devif/devif_forward.c | 2 +- net/devif/devif_initialize.c | 7 --- net/devif/ipv4_input.c | 2 +- net/devif/ipv6_input.c | 2 +- net/icmp/icmp_foward.c | 2 +- net/icmpv6/icmpv6_forward.c | 2 +- net/ipforward/Kconfig | 39 +++++++++++++++++ net/ipforward/Make.defs | 57 +++++++++++++++++++++++++ net/{devif => ipforward}/ip_forward.c | 4 +- net/{devif => ipforward}/ip_forward.h | 11 +++-- net/{devif => ipforward}/ipv4_forward.c | 9 ++-- net/{devif => ipforward}/ipv6_forward.c | 9 ++-- net/net_initialize.c | 7 +++ net/tcp/tcp.h | 6 ++- net/tcp/tcp_forward.c | 10 ++--- net/udp/udp_forward.c | 8 ++-- 20 files changed, 164 insertions(+), 92 deletions(-) create mode 100644 net/ipforward/Kconfig create mode 100644 net/ipforward/Make.defs rename net/{devif => ipforward}/ip_forward.c (98%) rename net/{devif => ipforward}/ip_forward.h (97%) rename net/{devif => ipforward}/ipv4_forward.c (98%) rename net/{devif => ipforward}/ipv6_forward.c (99%) diff --git a/net/Kconfig b/net/Kconfig index 663e159aea..b7f3531bc9 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -284,40 +284,7 @@ menuconfig NET_IPv6 source "net/neighbor/Kconfig" source "net/sixlowpan/Kconfig" - -config NET_IPFORWARD - bool "Enable L2 forwarding" - default n - ---help--- - Enable forwarding of packets. Packets received with IP addresses - that are not supported by this platform will be forwarded to the - appropriate network device. Routing table support may be required. - -config NET_IPFORWARD_BROADCAST - bool "Forward broadcast/multicast packets" - default n - depends on NET_IPFORWARD && NETDEV_MULTINIC - ---help--- - If selected, broadcast packets received on one network device will - be forwarded though other network devices. - -config NET_IPFORWARD_NSTRUCT - int "Number of pre-allocated forwarding structures" - default 4 - depends on NET_IPFORWARD && NETDEV_MULTINIC - ---help--- - When packets are forwarded from on device to another, a structure - must be allocated to hold the state of forwarding across several - asynchronous events. Those structures are pre-allocated for - minimal, deterministic performance and to prevent hogging of memory - (of course, that means that this value must be carefully selected - for your application). This setting defines the number of such pre- - allocated structures. - - NOTE: This setting effectively puts a maximum on the number of - packets that may be waiting to be forwarded from one network device - to another. CONFIG_IOB_NBUFFERS also limits the forward because the - payload of the packet (up to the MSS) is retain in IOBs. +source "net/ipforward/Kconfig" endmenu # Internet Protocol Selection diff --git a/net/Makefile b/net/Makefile index 25105b0c22..05dff875f5 100644 --- a/net/Makefile +++ b/net/Makefile @@ -1,7 +1,7 @@ ############################################################################ # net/Makefile # -# Copyright (C) 2007, 2008, 2011-2016 Gregory Nutt. All rights reserved. +# Copyright (C) 2007, 2008, 2011-2017 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -68,6 +68,7 @@ include tcp/Make.defs include udp/Make.defs include sixlowpan/Make.defs include devif/Make.defs +include ipforward/Make.defs include loopback/Make.defs include route/Make.defs include procfs/Make.defs diff --git a/net/README.txt b/net/README.txt index beda522959..683f93bebb 100644 --- a/net/README.txt +++ b/net/README.txt @@ -8,21 +8,22 @@ Directory Structure | `- net/ | - +- arp - Address resolution protocol (IPv4) - +- devif - Stack/device interface layer - +- icmp - Internet Control Message Protocol (IPv4) - +- icmpv6 - Internet Control Message Protocol (IPv6) - +- local - Unix domain (local) sockets - +- loopback - Local loopback - +- neighbor - Neighbor Discovery Protocol (IPv6) - +- netdev - Socket network device interface - +- pkt - "Raw" packet socket support - +- socket - BSD socket interface - +- route - Routing table support - +- tcp - Transmission Control Protocol - +- udp - User Datagram Protocol - +- usrsock - User socket API for user-space networking stack - `- utils - Miscellaneous utility functions + +- arp - Address resolution protocol (IPv4) + +- devif - Stack/device interface layer + +- icmp - Internet Control Message Protocol (IPv4) + +- icmpv6 - Internet Control Message Protocol (IPv6) + +- ipforward - IP forwarding logic + +- local - Unix domain (local) sockets + +- loopback - Local loopback + +- neighbor - Neighbor Discovery Protocol (IPv6) + +- netdev - Socket network device interface + +- pkt - "Raw" packet socket support + +- socket - BSD socket interface + +- route - Routing table support + +- tcp - Transmission Control Protocol + +- udp - User Datagram Protocol + +- usrsock - User socket API for user-space networking stack + `- utils - Miscellaneous utility functions +-------------------------------------------------------------------++------------------------+ diff --git a/net/devif/Make.defs b/net/devif/Make.defs index 6520b8430c..22d2ad05ab 100644 --- a/net/devif/Make.defs +++ b/net/devif/Make.defs @@ -42,21 +42,17 @@ NET_CSRCS += devif_callback.c ifeq ($(CONFIG_NET_IPv4),y) NET_CSRCS += ipv4_input.c -ifeq ($(CONFIG_NET_IPFORWARD),y) -NET_CSRCS += ipv4_forward.c -endif endif ifeq ($(CONFIG_NET_IPv6),y) NET_CSRCS += ipv6_input.c -ifeq ($(CONFIG_NET_IPFORWARD),y) -NET_CSRCS += ipv6_forward.c -endif endif +# IP forwarding + ifeq ($(CONFIG_NET_IPFORWARD),y) ifeq ($(CONFIG_NETDEV_MULTINIC),y) -NET_CSRCS += ip_forward.c devif_forward.c +NET_CSRCS += devif_forward.c endif endif diff --git a/net/devif/devif_forward.c b/net/devif/devif_forward.c index 3e9aaf89aa..a1471d4196 100644 --- a/net/devif/devif_forward.c +++ b/net/devif/devif_forward.c @@ -43,7 +43,7 @@ #include -#include "devif/ip_forward.h" +#include "ipforward/ip_forward.h" #include "devif/devif.h" #if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC) diff --git a/net/devif/devif_initialize.c b/net/devif/devif_initialize.c index be858e5920..68ba121afb 100644 --- a/net/devif/devif_initialize.c +++ b/net/devif/devif_initialize.c @@ -50,7 +50,6 @@ #include #include -#include "devif/ip_forward.h" #include "devif/devif.h" /**************************************************************************** @@ -168,11 +167,5 @@ void devif_initialize(void) /* Initialize callback support */ devif_callback_init(); - -#ifdef HAVE_FWDALLOC - /* Initialize IP forwarding support */ - - ip_forward_initialize(); -#endif } #endif /* CONFIG_NET */ diff --git a/net/devif/ipv4_input.c b/net/devif/ipv4_input.c index 018f747dc0..b86918516c 100644 --- a/net/devif/ipv4_input.c +++ b/net/devif/ipv4_input.c @@ -99,7 +99,7 @@ #include "icmp/icmp.h" #include "igmp/igmp.h" -#include "devif/ip_forward.h" +#include "ipforward/ip_forward.h" #include "devif/devif.h" /**************************************************************************** diff --git a/net/devif/ipv6_input.c b/net/devif/ipv6_input.c index b74f104677..ce8d4f3ea1 100644 --- a/net/devif/ipv6_input.c +++ b/net/devif/ipv6_input.c @@ -100,7 +100,7 @@ #include "icmpv6/icmpv6.h" #include "netdev/netdev.h" -#include "devif/ip_forward.h" +#include "ipforward/ip_forward.h" #include "devif/devif.h" /**************************************************************************** diff --git a/net/icmp/icmp_foward.c b/net/icmp/icmp_foward.c index e1423907d6..12591646e7 100644 --- a/net/icmp/icmp_foward.c +++ b/net/icmp/icmp_foward.c @@ -49,7 +49,7 @@ #include #include -#include "devif/ip_forward.h" +#include "ipforward/ip_forward.h" #include "devif/devif.h" #include "netdev/netdev.h" #include "arp/arp.h" diff --git a/net/icmpv6/icmpv6_forward.c b/net/icmpv6/icmpv6_forward.c index 17f35f2dd6..d4c1a67186 100644 --- a/net/icmpv6/icmpv6_forward.c +++ b/net/icmpv6/icmpv6_forward.c @@ -49,7 +49,7 @@ #include #include -#include "devif/ip_forward.h" +#include "ipforward/ip_forward.h" #include "devif/devif.h" #include "netdev/netdev.h" #include "arp/arp.h" diff --git a/net/ipforward/Kconfig b/net/ipforward/Kconfig new file mode 100644 index 0000000000..2fc3ddbdc7 --- /dev/null +++ b/net/ipforward/Kconfig @@ -0,0 +1,39 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config NET_IPFORWARD + bool "Enable L2 forwarding" + default n + ---help--- + Enable forwarding of packets. Packets received with IP addresses + that are not supported by this platform will be forwarded to the + appropriate network device. Routing table support may be required. + +config NET_IPFORWARD_BROADCAST + bool "Forward broadcast/multicast packets" + default n + depends on NET_IPFORWARD && NETDEV_MULTINIC + ---help--- + If selected, broadcast packets received on one network device will + be forwarded though other network devices. + +config NET_IPFORWARD_NSTRUCT + int "Number of pre-allocated forwarding structures" + default 4 + depends on NET_IPFORWARD && NETDEV_MULTINIC + ---help--- + When packets are forwarded from on device to another, a structure + must be allocated to hold the state of forwarding across several + asynchronous events. Those structures are pre-allocated for + minimal, deterministic performance and to prevent hogging of memory + (of course, that means that this value must be carefully selected + for your application). This setting defines the number of such pre- + allocated structures. + + NOTE: This setting effectively puts a maximum on the number of + packets that may be waiting to be forwarded from one network device + to another. CONFIG_IOB_NBUFFERS also limits the forward because the + payload of the packet (up to the MSS) is retain in IOBs. + diff --git a/net/ipforward/Make.defs b/net/ipforward/Make.defs new file mode 100644 index 0000000000..b2f661e2d2 --- /dev/null +++ b/net/ipforward/Make.defs @@ -0,0 +1,57 @@ +############################################################################ +# net/ipforward/Make.defs +# +# Copyright (C) 2017 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +# IP forwarding source files + +ifeq ($(CONFIG_NET_IPFORWARD),y) + +ifeq ($(CONFIG_NET_IPv4),y) +NET_CSRCS += ipv4_forward.c +endif + +ifeq ($(CONFIG_NET_IPv6),y) +NET_CSRCS += ipv6_forward.c +endif + +ifeq ($(CONFIG_NETDEV_MULTINIC),y) +NET_CSRCS += ip_forward.c +endif + +# Include IP forwaring build support + +DEPPATH += --dep-path ipforward +VPATH += :ipforward + +endif diff --git a/net/devif/ip_forward.c b/net/ipforward/ip_forward.c similarity index 98% rename from net/devif/ip_forward.c rename to net/ipforward/ip_forward.c index 4c5ac64ff2..baa9ebfe35 100644 --- a/net/devif/ip_forward.c +++ b/net/ipforward/ip_forward.c @@ -1,5 +1,5 @@ /**************************************************************************** - * net/devif/ip_forward.c + * net/ipforward/ip_forward.c * * Copyright (C) 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -44,7 +44,7 @@ #include #include -#include "devif/ip_forward.h" +#include "ipforward/ip_forward.h" #if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC) diff --git a/net/devif/ip_forward.h b/net/ipforward/ip_forward.h similarity index 97% rename from net/devif/ip_forward.h rename to net/ipforward/ip_forward.h index 40c7c757da..3a99ce30c8 100644 --- a/net/devif/ip_forward.h +++ b/net/ipforward/ip_forward.h @@ -1,5 +1,5 @@ /**************************************************************************** - * net/devif/ip_forward.h + * net/ipforward/ip_forward.h * * Copyright (C) 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -33,8 +33,8 @@ * ****************************************************************************/ -#ifndef __NET_DEVIF_IP_FORWARD_H -#define __NET_DEVIF_IP_FORWARD_H +#ifndef __NET_IPFORWARD_IP_FORWARD_H +#define __NET_IPFORWARD_IP_FORWARD_H /**************************************************************************** * Included Files @@ -163,6 +163,9 @@ struct forward_s FAR struct iob_s *f_iob; /* IOB chain containing the packet */ FAR struct devif_callback_s *f_cb; /* Reference to callback instance */ union fwd_conn_u f_conn; /* Protocol-specific connection struct */ +#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6) + uint8_t f_domain; /* Domain: PF_INET or PF_INET6 */ +#endif }; /**************************************************************************** @@ -356,4 +359,4 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6); #endif #endif /* CONFIG_NET_IPFORWARD */ -#endif /* __NET_DEVIF_IP_FORWARD_H */ +#endif /* __NET_IPFORWARD_IP_FORWARD_H */ diff --git a/net/devif/ipv4_forward.c b/net/ipforward/ipv4_forward.c similarity index 98% rename from net/devif/ipv4_forward.c rename to net/ipforward/ipv4_forward.c index 1614808f9f..303815553c 100644 --- a/net/devif/ipv4_forward.c +++ b/net/ipforward/ipv4_forward.c @@ -1,5 +1,5 @@ /**************************************************************************** - * net/devif/ipv4_forward.c + * net/ipforward/ipv4_forward.c * * Copyright (C) 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -54,7 +54,7 @@ #include "udp/udp.h" #include "tcp/tcp.h" #include "icmp/icmp.h" -#include "devif/ip_forward.h" +#include "ipforward/ip_forward.h" #include "devif/devif.h" #if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_IPv4) @@ -297,7 +297,10 @@ static int ipv4_dev_forward(FAR struct net_driver_s *dev, /* Initialize the easy stuff in the forwarding structure */ - fwd->f_dev = fwddev; /* Forwarding device */ + fwd->f_dev = fwddev; /* Forwarding device */ +#ifdef CONFIG_NET_IPv5 + fwd->f_domain = PF_INET; /* IPv64 address domain */ +#endif #ifdef CONFIG_DEBUG_NET_WARN /* Get the size of the IPv4 + L3 header. */ diff --git a/net/devif/ipv6_forward.c b/net/ipforward/ipv6_forward.c similarity index 99% rename from net/devif/ipv6_forward.c rename to net/ipforward/ipv6_forward.c index cd33b54d86..6fb33d5633 100644 --- a/net/devif/ipv6_forward.c +++ b/net/ipforward/ipv6_forward.c @@ -1,5 +1,5 @@ /**************************************************************************** - * net/devif/ipv6_forward.c + * net/ipforward/ipv6_forward.c * * Copyright (C) 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -53,7 +53,7 @@ #include "udp/udp.h" #include "tcp/tcp.h" #include "icmpv6/icmpv6.h" -#include "devif/ip_forward.h" +#include "ipforward/ip_forward.h" #include "devif/devif.h" #if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_IPv6) @@ -408,7 +408,10 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, /* Initialize the easy stuff in the forwarding structure */ - fwd->f_dev = fwddev; /* Forwarding device */ + fwd->f_dev = fwddev; /* Forwarding device */ +#ifdef CONFIG_NET_IPv4 + fwd->f_domain = PF_INET6; /* IPv6 address domain */ +#endif #ifdef CONFIG_DEBUG_NET_WARN /* Get the size of the IPv6 + L3 header. */ diff --git a/net/net_initialize.c b/net/net_initialize.c index a5e0c2d31e..ae8e1d25bc 100644 --- a/net/net_initialize.c +++ b/net/net_initialize.c @@ -47,6 +47,7 @@ #include "socket/socket.h" #include "devif/devif.h" #include "netdev/netdev.h" +#include "ipforward/ip_forward.h" #include "arp/arp.h" #include "sixlowpan/sixlowpan.h" #include "neighbor/neighbor.h" @@ -112,6 +113,12 @@ void net_setup(void) devif_initialize(); +#ifdef HAVE_FWDALLOC + /* Initialize IP forwarding support */ + + ip_forward_initialize(); +#endif + #ifdef CONFIG_NET_PKT /* Initialize packet socket support */ diff --git a/net/tcp/tcp.h b/net/tcp/tcp.h index 8b554fff86..9497e426ec 100644 --- a/net/tcp/tcp.h +++ b/net/tcp/tcp.h @@ -807,8 +807,10 @@ void tcp_send(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, * send to complete. * * Input Parameters: - * fwd - An initialized instance of the common forwarding structure that - * includes everything needed to perform the forwarding operation. + * domain - Either PF_INET or PF_INET6 + * fwd - An initialized instance of the common forwarding structure + * that includes everything needed to perform the forwarding + * operation. * * Returned Value: * Zero is returned if the packet was successfully forwarded; A negated diff --git a/net/tcp/tcp_forward.c b/net/tcp/tcp_forward.c index cc85f05eb6..d7c8ba01e5 100644 --- a/net/tcp/tcp_forward.c +++ b/net/tcp/tcp_forward.c @@ -50,7 +50,7 @@ #include #include -#include "devif/ip_forward.h" +#include "ipforward/ip_forward.h" #include "devif/devif.h" #include "netdev/netdev.h" #include "arp/arp.h" @@ -89,7 +89,7 @@ static inline void forward_ipselect(FAR struct forward_s *fwd) { /* Which domain the connection support */ - if (fwd->f_conn.tcp.domain == PF_INET) + if (fwd->f_domain == PF_INET) { /* Select the IPv4 domain */ @@ -151,7 +151,7 @@ static inline bool tcp_forward_addrchck(FAR struct forward_s *fwd) #ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv6 - if (conn->domain == PF_INET) + if (fwd->f_domain == PF_INET) #endif { #if !defined(CONFIG_NET_ARP_IPIN) && !defined(CONFIG_NET_ARP_SEND) @@ -207,7 +207,7 @@ static void tcp_dropstats(FAR struct forward_s *fwd) #ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv6 - if (fwd->f_conn.tcp.domain == PF_INET) + if (fwd->f_domain == PF_INET) #endif { g_netstats.ipv4.drop++; @@ -389,7 +389,7 @@ int tcp_forward(FAR struct forward_s *fwd) #ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv6 - if ((iphdr->ipv4.l2.vhl & IP_VERSION_MASK) == IPv4_VERSION) + if (fwd->f_domain == PF_INET) #endif { FAR struct ipv4_hdr_s *ipv4 = &iphdr->ipv4.l2; diff --git a/net/udp/udp_forward.c b/net/udp/udp_forward.c index 8c0473592d..86264637f3 100644 --- a/net/udp/udp_forward.c +++ b/net/udp/udp_forward.c @@ -49,7 +49,7 @@ #include #include -#include "devif/ip_forward.h" +#include "ipforward/ip_forward.h" #include "devif/devif.h" #include "netdev/netdev.h" #include "arp/arp.h" @@ -90,7 +90,7 @@ static inline void forward_ipselect(FAR struct forward_s *fwd) /* Select IPv4 or IPv6 */ - if ((iphdr->ipv4.l2.vhl & IP_VERSION_MASK) == IPv4_VERSION) + if (fwd->f_domain == PF_INET) { udp_ipv4_select(fwd->f_dev); } @@ -151,7 +151,7 @@ static inline bool udp_forward_addrchk(FAR struct forward_s *fwd) #ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv6 - if ((iphdr->ipv4.l2.vhl & IP_VERSION_MASK) == IPv4_VERSION) + if (fwd->f_domain == PF_INET) #endif { #if !defined(CONFIG_NET_ARP_IPIN) && !defined(CONFIG_NET_ARP_SEND) @@ -209,7 +209,7 @@ static void udp_dropstats(FAR struct forward_s *fwd) #ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv6 - if ((iphdr->ipv4.l2.vhl & IP_VERSION_MASK) == IPv4_VERSION) + if (fwd->f_domain == PF_INET) #endif { g_netstats.ipv4.drop++; From 803235ad4b7634213b12fa11829ccb02f750af91 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 7 Jul 2017 18:45:58 -0600 Subject: [PATCH 30/31] IP forwaring: Rename some files to get closer to other naming conventions. --- net/devif/devif_forward.c | 2 +- net/devif/ipv4_input.c | 2 +- net/devif/ipv6_input.c | 2 +- net/icmp/icmp_foward.c | 4 ++-- net/icmpv6/icmpv6_forward.c | 4 ++-- net/ipforward/Make.defs | 2 +- net/ipforward/{ip_forward.h => ipforward.h} | 20 +++++++++---------- net/ipforward/{ip_forward.c => ipfwd_alloc.c} | 16 +++++++-------- net/ipforward/ipv4_forward.c | 6 +++--- net/ipforward/ipv6_forward.c | 6 +++--- net/net_initialize.c | 4 ++-- net/tcp/tcp_forward.c | 4 ++-- net/udp/udp_forward.c | 4 ++-- 13 files changed, 38 insertions(+), 38 deletions(-) rename net/ipforward/{ip_forward.h => ipforward.h} (96%) rename net/ipforward/{ip_forward.c => ipfwd_alloc.c} (94%) diff --git a/net/devif/devif_forward.c b/net/devif/devif_forward.c index a1471d4196..00bf2e3690 100644 --- a/net/devif/devif_forward.c +++ b/net/devif/devif_forward.c @@ -43,7 +43,7 @@ #include -#include "ipforward/ip_forward.h" +#include "ipforward/ipforward.h" #include "devif/devif.h" #if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC) diff --git a/net/devif/ipv4_input.c b/net/devif/ipv4_input.c index b86918516c..82acb0544a 100644 --- a/net/devif/ipv4_input.c +++ b/net/devif/ipv4_input.c @@ -99,7 +99,7 @@ #include "icmp/icmp.h" #include "igmp/igmp.h" -#include "ipforward/ip_forward.h" +#include "ipforward/ipforward.h" #include "devif/devif.h" /**************************************************************************** diff --git a/net/devif/ipv6_input.c b/net/devif/ipv6_input.c index ce8d4f3ea1..d8bb34b793 100644 --- a/net/devif/ipv6_input.c +++ b/net/devif/ipv6_input.c @@ -100,7 +100,7 @@ #include "icmpv6/icmpv6.h" #include "netdev/netdev.h" -#include "ipforward/ip_forward.h" +#include "ipforward/ipforward.h" #include "devif/devif.h" /**************************************************************************** diff --git a/net/icmp/icmp_foward.c b/net/icmp/icmp_foward.c index 12591646e7..2730e35540 100644 --- a/net/icmp/icmp_foward.c +++ b/net/icmp/icmp_foward.c @@ -49,7 +49,7 @@ #include #include -#include "ipforward/ip_forward.h" +#include "ipforward/ipforward.h" #include "devif/devif.h" #include "netdev/netdev.h" #include "arp/arp.h" @@ -246,7 +246,7 @@ static uint16_t icmp_forward_interrupt(FAR struct net_driver_s *dev, /* And release the forwarding state structure */ - ip_forward_free(fwd); + ipfwd_free(fwd); } return flags; diff --git a/net/icmpv6/icmpv6_forward.c b/net/icmpv6/icmpv6_forward.c index d4c1a67186..866a67d6a0 100644 --- a/net/icmpv6/icmpv6_forward.c +++ b/net/icmpv6/icmpv6_forward.c @@ -49,7 +49,7 @@ #include #include -#include "ipforward/ip_forward.h" +#include "ipforward/ipforward.h" #include "devif/devif.h" #include "netdev/netdev.h" #include "arp/arp.h" @@ -242,7 +242,7 @@ static uint16_t icmpv6_forward_interrupt(FAR struct net_driver_s *dev, /* And release the forwarding state structure */ - ip_forward_free(fwd); + ipfwd_free(fwd); } return flags; diff --git a/net/ipforward/Make.defs b/net/ipforward/Make.defs index b2f661e2d2..56789ceb57 100644 --- a/net/ipforward/Make.defs +++ b/net/ipforward/Make.defs @@ -46,7 +46,7 @@ NET_CSRCS += ipv6_forward.c endif ifeq ($(CONFIG_NETDEV_MULTINIC),y) -NET_CSRCS += ip_forward.c +NET_CSRCS += ipfwd_alloc.c endif # Include IP forwaring build support diff --git a/net/ipforward/ip_forward.h b/net/ipforward/ipforward.h similarity index 96% rename from net/ipforward/ip_forward.h rename to net/ipforward/ipforward.h index 3a99ce30c8..ee27f46447 100644 --- a/net/ipforward/ip_forward.h +++ b/net/ipforward/ipforward.h @@ -1,5 +1,5 @@ /**************************************************************************** - * net/ipforward/ip_forward.h + * net/ipforward/ipforward.h * * Copyright (C) 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -33,8 +33,8 @@ * ****************************************************************************/ -#ifndef __NET_IPFORWARD_IP_FORWARD_H -#define __NET_IPFORWARD_IP_FORWARD_H +#ifndef __NET_IPFORWARD_IPFORWARD_H +#define __NET_IPFORWARD_IPFORWARD_H /**************************************************************************** * Included Files @@ -173,7 +173,7 @@ struct forward_s ****************************************************************************/ /**************************************************************************** - * Name: ip_forward_initialize + * Name: ipfwd_initialize * * Description: * Initialize the struct forward_s allocator. @@ -183,10 +183,10 @@ struct forward_s * ****************************************************************************/ -void ip_forward_initialize(void); +void ipfwd_initialize(void); /**************************************************************************** - * Name: ip_forward_alloc + * Name: ipfwd_alloc * * Description: * Allocate a forwarding structure by removing a pre-allocated entry from @@ -198,10 +198,10 @@ void ip_forward_initialize(void); * ****************************************************************************/ -FAR struct forward_s *ip_forward_alloc(void); +FAR struct forward_s *ipfwd_alloc(void); /**************************************************************************** - * Name: ip_forward_free + * Name: ipfwd_free * * Description: * Free a forwarding structure by adding it to a free list. @@ -212,7 +212,7 @@ FAR struct forward_s *ip_forward_alloc(void); * ****************************************************************************/ -void ip_forward_free(FAR struct forward_s *fwd); +void ipfwd_free(FAR struct forward_s *fwd); /**************************************************************************** * Name: ipv4_forward_broadcast @@ -359,4 +359,4 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6); #endif #endif /* CONFIG_NET_IPFORWARD */ -#endif /* __NET_IPFORWARD_IP_FORWARD_H */ +#endif /* __NET_IPFORWARD_IPFORWARD_H */ diff --git a/net/ipforward/ip_forward.c b/net/ipforward/ipfwd_alloc.c similarity index 94% rename from net/ipforward/ip_forward.c rename to net/ipforward/ipfwd_alloc.c index baa9ebfe35..01e34099e4 100644 --- a/net/ipforward/ip_forward.c +++ b/net/ipforward/ipfwd_alloc.c @@ -1,5 +1,5 @@ /**************************************************************************** - * net/ipforward/ip_forward.c + * net/ipforward/ipfwd_alloc.c * * Copyright (C) 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -44,7 +44,7 @@ #include #include -#include "ipforward/ip_forward.h" +#include "ipforward/ipforward.h" #if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC) @@ -65,7 +65,7 @@ static FAR struct forward_s *g_fwdfree; ****************************************************************************/ /**************************************************************************** - * Name: ip_forward_initialize + * Name: ipfwd_initialize * * Description: * Initialize the struct forward_s allocator. @@ -75,7 +75,7 @@ static FAR struct forward_s *g_fwdfree; * ****************************************************************************/ -void ip_forward_initialize(void) +void ipfwd_initialize(void) { FAR struct forward_s *fwd; int i; @@ -99,7 +99,7 @@ void ip_forward_initialize(void) } /**************************************************************************** - * Name: ip_forward_alloc + * Name: ipfwd_alloc * * Description: * Allocate a forwarding structure by removing a pre-allocated entry from @@ -111,7 +111,7 @@ void ip_forward_initialize(void) * ****************************************************************************/ -FAR struct forward_s *ip_forward_alloc(void) +FAR struct forward_s *ipfwd_alloc(void) { FAR struct forward_s *fwd; @@ -126,7 +126,7 @@ FAR struct forward_s *ip_forward_alloc(void) } /**************************************************************************** - * Name: ip_forward_free + * Name: ipfwd_free * * Description: * Free a forwarding structure by adding it to a free list. @@ -137,7 +137,7 @@ FAR struct forward_s *ip_forward_alloc(void) * ****************************************************************************/ -void ip_forward_free(FAR struct forward_s *fwd) +void ipfwd_free(FAR struct forward_s *fwd) { fwd->f_flink = g_fwdfree; g_fwdfree = fwd; diff --git a/net/ipforward/ipv4_forward.c b/net/ipforward/ipv4_forward.c index 303815553c..63dd5aae5b 100644 --- a/net/ipforward/ipv4_forward.c +++ b/net/ipforward/ipv4_forward.c @@ -54,7 +54,7 @@ #include "udp/udp.h" #include "tcp/tcp.h" #include "icmp/icmp.h" -#include "ipforward/ip_forward.h" +#include "ipforward/ipforward.h" #include "devif/devif.h" #if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_IPv4) @@ -287,7 +287,7 @@ static int ipv4_dev_forward(FAR struct net_driver_s *dev, * completely zeroed when we receive it. */ - fwd = ip_forward_alloc(); + fwd = ipfwd_alloc(); if (fwd == NULL) { nwarn("WARNING: Failed to allocate forwarding structure\n"); @@ -426,7 +426,7 @@ errout_with_iobchain: errout_with_fwd: if (fwd != NULL) { - ip_forward_free(fwd); + ipfwd_free(fwd); } errout: diff --git a/net/ipforward/ipv6_forward.c b/net/ipforward/ipv6_forward.c index 6fb33d5633..e50fe7c2b0 100644 --- a/net/ipforward/ipv6_forward.c +++ b/net/ipforward/ipv6_forward.c @@ -53,7 +53,7 @@ #include "udp/udp.h" #include "tcp/tcp.h" #include "icmpv6/icmpv6.h" -#include "ipforward/ip_forward.h" +#include "ipforward/ipforward.h" #include "devif/devif.h" #if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_IPv6) @@ -398,7 +398,7 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, * completely zeroed when we receive it. */ - fwd = ip_forward_alloc(); + fwd = ipfwd_alloc(); if (fwd == NULL) { nwarn("WARNING: Failed to allocate forwarding structure\n"); @@ -538,7 +538,7 @@ errout_with_iobchain: errout_with_fwd: if (fwd != NULL) { - ip_forward_free(fwd); + ipfwd_free(fwd); } errout: diff --git a/net/net_initialize.c b/net/net_initialize.c index ae8e1d25bc..597aaeb717 100644 --- a/net/net_initialize.c +++ b/net/net_initialize.c @@ -47,7 +47,7 @@ #include "socket/socket.h" #include "devif/devif.h" #include "netdev/netdev.h" -#include "ipforward/ip_forward.h" +#include "ipforward/ipforward.h" #include "arp/arp.h" #include "sixlowpan/sixlowpan.h" #include "neighbor/neighbor.h" @@ -116,7 +116,7 @@ void net_setup(void) #ifdef HAVE_FWDALLOC /* Initialize IP forwarding support */ - ip_forward_initialize(); + ipfwd_initialize(); #endif #ifdef CONFIG_NET_PKT diff --git a/net/tcp/tcp_forward.c b/net/tcp/tcp_forward.c index d7c8ba01e5..542b0e8e1c 100644 --- a/net/tcp/tcp_forward.c +++ b/net/tcp/tcp_forward.c @@ -50,7 +50,7 @@ #include #include -#include "ipforward/ip_forward.h" +#include "ipforward/ipforward.h" #include "devif/devif.h" #include "netdev/netdev.h" #include "arp/arp.h" @@ -340,7 +340,7 @@ static uint16_t tcp_forward_interrupt(FAR struct net_driver_s *dev, /* And release the forwarding state structure */ - ip_forward_free(fwd); + ipfwd_free(fwd); } return flags; diff --git a/net/udp/udp_forward.c b/net/udp/udp_forward.c index 86264637f3..e65cbe6ea1 100644 --- a/net/udp/udp_forward.c +++ b/net/udp/udp_forward.c @@ -49,7 +49,7 @@ #include #include -#include "ipforward/ip_forward.h" +#include "ipforward/ipforward.h" #include "devif/devif.h" #include "netdev/netdev.h" #include "arp/arp.h" @@ -334,7 +334,7 @@ static uint16_t udp_forward_interrupt(FAR struct net_driver_s *dev, /* And release the forwarding state structure */ - ip_forward_free(fwd); + ipfwd_free(fwd); } return flags; From aa2e9c15a5aed4e83a524277952d7c6b83b07c86 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 7 Jul 2017 20:19:26 -0600 Subject: [PATCH 31/31] IP forwarding: Major rearchitecting of the outgoing portion of the IP forwarding logic necessary into to properly received device-related forwarding events. --- net/devif/devif.h | 2 + net/devif/devif_forward.c | 3 +- net/devif/devif_poll.c | 31 ++ net/icmp/Make.defs | 8 - net/icmp/icmp_foward.c | 304 ------------ net/icmpv6/Make.defs | 8 - net/icmpv6/icmpv6.h | 28 -- net/icmpv6/icmpv6_forward.c | 300 ------------ net/ipforward/Make.defs | 6 + net/ipforward/ipforward.h | 103 +++- net/ipforward/ipfwd_dropstats.c | 192 ++++++++ .../ipfwd_forward.c} | 121 ++--- net/ipforward/ipv4_forward.c | 98 +--- net/ipforward/ipv6_forward.c | 106 +---- net/tcp/Make.defs | 8 - net/tcp/tcp.h | 31 -- net/tcp/tcp_forward.c | 443 ------------------ net/udp/Make.defs | 8 - net/udp/udp.h | 29 -- 19 files changed, 369 insertions(+), 1460 deletions(-) delete mode 100644 net/icmp/icmp_foward.c delete mode 100644 net/icmpv6/icmpv6_forward.c create mode 100644 net/ipforward/ipfwd_dropstats.c rename net/{udp/udp_forward.c => ipforward/ipfwd_forward.c} (78%) delete mode 100644 net/tcp/tcp_forward.c diff --git a/net/devif/devif.h b/net/devif/devif.h index e90377dd58..99b389c9b1 100644 --- a/net/devif/devif.h +++ b/net/devif/devif.h @@ -171,12 +171,14 @@ #define UDP_NEWDATA TCP_NEWDATA #define PKT_NEWDATA TCP_NEWDATA #define WPAN_NEWDATA TCP_NEWDATA +#define IPFWD_NEWDATA TCP_NEWDATA #define TCP_SNDACK (1 << 2) #define TCP_REXMIT (1 << 3) #define TCP_POLL (1 << 4) #define UDP_POLL TCP_POLL #define PKT_POLL TCP_POLL #define WPAN_POLL TCP_POLL +#define IPFWD_POLL TCP_POLL #define TCP_BACKLOG (1 << 5) #define TCP_CLOSE (1 << 6) #define TCP_ABORT (1 << 7) diff --git a/net/devif/devif_forward.c b/net/devif/devif_forward.c index 00bf2e3690..4f93ee3cbb 100644 --- a/net/devif/devif_forward.c +++ b/net/devif/devif_forward.c @@ -87,7 +87,8 @@ void devif_forward(FAR struct forward_s *fwd) DEBUGASSERT(ret == fwd->f_iob->io_pktlen); offset += fwd->f_iob->io_pktlen; - fwd->f_dev->d_sndlen = offset; + fwd->f_dev->d_sndlen = 0; + fwd->f_dev->d_len = offset; } #endif /* CONFIG_NET_IPFORWARD && CONFIG_NETDEV_MULTINIC */ diff --git a/net/devif/devif_poll.c b/net/devif/devif_poll.c index 08d6c99e8a..73c5050f58 100644 --- a/net/devif/devif_poll.c +++ b/net/devif/devif_poll.c @@ -251,6 +251,28 @@ static inline int devif_poll_icmpv6(FAR struct net_driver_s *dev, } #endif /* CONFIG_NET_ICMPv6_PING || CONFIG_NET_ICMPv6_NEIGHBOR*/ +/**************************************************************************** + * Name: devif_poll_forward + * + * Description: + * Poll the device event to see if any task is waiting to forward a packet. + * + ****************************************************************************/ + +#if defined(CONFIG_NET_IPFORWARD) || defined(CONFIG_NETDEV_MULTINIC) +static inline int devif_poll_forward(FAR struct net_driver_s *dev, + devif_poll_callback_t callback) +{ + /* Perform the ICMPv6 poll */ + + devif_dev_event(dev, NULL, IPFWD_POLL); + + /* Call back into the driver */ + + return callback(dev); +} +#endif /* CONFIG_NET_ICMPv6_PING || CONFIG_NET_ICMPv6_NEIGHBOR*/ + /**************************************************************************** * Name: devif_poll_igmp * @@ -506,6 +528,15 @@ int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback) bstop = devif_poll_icmpv6(dev, callback); } + if (!bstop) +#endif +#if defined(CONFIG_NET_IPFORWARD) || defined(CONFIG_NETDEV_MULTINIC) + { + /* Traverse all of the tasks waiting to forward a packet to this device. */ + + bstop = devif_poll_forward(dev, callback); + } + if (!bstop) #endif { diff --git a/net/icmp/Make.defs b/net/icmp/Make.defs index 6b002964e4..d5a67c2065 100644 --- a/net/icmp/Make.defs +++ b/net/icmp/Make.defs @@ -43,14 +43,6 @@ ifeq ($(CONFIG_NET_ICMP_PING),y) NET_CSRCS += icmp_ping.c icmp_poll.c icmp_send.c endif -# IP forwarding - -ifeq ($(CONFIG_NET_IPFORWARD),y) -ifeq ($(CONFIG_NETDEV_MULTINIC),y) -NET_CSRCS += icmp_forward.c -endif -endif - # Include ICMP build support DEPPATH += --dep-path icmp diff --git a/net/icmp/icmp_foward.c b/net/icmp/icmp_foward.c deleted file mode 100644 index 2730e35540..0000000000 --- a/net/icmp/icmp_foward.c +++ /dev/null @@ -1,304 +0,0 @@ -/**************************************************************************** - * net/icmp/icmp_forward.c - * - * Copyright (C) 2017 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include "ipforward/ipforward.h" -#include "devif/devif.h" -#include "netdev/netdev.h" -#include "arp/arp.h" -#include "neighbor/neighbor.h" -#include "icmp/icmp.h" - -#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_ICMP) && \ - defined(CONFIG_NETDEV_MULTINIC) - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: icmp_forward_addrchck - * - * Description: - * Check if the destination IP address is in the IPv4 ARP table. If not, - * then the send won't actually make it out... it will be replaced with an - * ARP request (IPv4). - * - * NOTE 1: This could be an expensive check if there are a lot of - * entries in the ARP table. - * - * NOTE 2: If we are actually harvesting IP addresses on incoming IP - * packets, then this check should not be necessary; the MAC mapping - * should already be in the ARP table in many cases. - * - * NOTE 3: If CONFIG_NET_ARP_SEND then we can be assured that the IP - * address mapping is already in the ARP table. - * - * Parameters: - * fwd - The forwarding state structure - * - * Returned Value: - * true - The Ethernet MAC address is in the ARP table (OR the network - * device is not Ethernet). - * - * Assumptions: - * The network is locked. - * - ****************************************************************************/ - -#ifdef CONFIG_NET_ETHERNET -static inline bool icmp_forward_addrchck(FAR struct forward_s *fwd) -{ -#if !defined(CONFIG_NET_ARP_IPIN) && !defined(CONFIG_NET_ARP_SEND) - FAR union fwd_iphdr_u *iphdr; -#endif - - DEBUGASSERT(fwd != NULL && fwd->f_iob != NULL && fwd->f_dev != NULL); - - /* REVISIT: Could the MAC address not also be in a routing table? */ - -#ifdef CONFIG_NET_MULTILINK - if (fwd->f_dev->d_lltype != NET_LL_ETHERNET) - { - return true; - } -#endif - -#if !defined(CONFIG_NET_ARP_IPIN) && !defined(CONFIG_NET_ARP_SEND) - iphdr = FWD_HEADER(fwd); - return (arp_find(iphdr->ipv4.l2.destipaddr) != NULL); -#else - return true; -#endif -} - -#else /* CONFIG_NET_ETHERNET */ -# define icmp_forward_addrchck(fwd) (true) -#endif /* CONFIG_NET_ETHERNET */ - -/**************************************************************************** - * Name: icmp_dropstats - * - * Description: - * Update statistics for a dropped packet. - * - * Input Parameters: - * fwd - The forwarding state structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -#ifdef CONFIG_NET_STATISTICS -static inline void icmp_dropstats(FAR struct forward_s *fwd) -{ - /* Increment the count of dropped ICMP packets */ - - g_netstats.icmp.drop++; - g_netstats.ipv4.drop++; -} -#else -# define icmp_dropstats(fwd) -#endif - -/**************************************************************************** - * Name: icmp_forward_interrupt - * - * Description: - * This function is called from the interrupt level to perform the actual - * send operation when polled by the lower, device interfacing layer. - * - * Parameters: - * dev The structure of the network driver that caused the interrupt - * conn An instance of the ICMP connection structure cast to void * - * pvpriv An instance of struct forward_s cast to void* - * flags Set of events describing why the callback was invoked - * - * Returned Value: - * Modified value of the input flags - * - * Assumptions: - * The network is locked - * - ****************************************************************************/ - -static uint16_t icmp_forward_interrupt(FAR struct net_driver_s *dev, - FAR void *conn, FAR void *pvpriv, - uint16_t flags) -{ - FAR struct forward_s *fwd = (FAR struct forward_s *)pvpriv; - - ninfo("flags: %04x\n", flags); - DEBUGASSERT(fwd != NULL && fwd->f_iob != NULL && fwd->f_dev != NULL); - - /* Make sure that this is from the forwarding device */ - - if (dev == fwd->f_dev) - { - /* If the network device has gone down, then we will have terminate - * the wait now with an error. - */ - - if ((flags & NETDEV_DOWN) != 0) - { - /* Terminate the transfer with an error. */ - - nwarn("WARNING: Network is down... Dropping\n"); - icmp_dropstats(fwd); - } - - /* Check if the outgoing packet is available. It may have been claimed - * by another send interrupt serving a different thread -OR- if the output - * buffer currently contains unprocessed incoming data. In these cases - * we will just have to wait for the next polling cycle. - */ - - else if (dev->d_sndlen > 0 || (flags & ICMP_NEWDATA) != 0) - { - /* Another thread has beat us sending data or the buffer is busy, - * Wait for the next polling cycle and check again. - */ - - return flags; - } - - /* It looks like we are good to forward the data */ - - else - { - /* Copy the ICMP data into driver's packet buffer and send it. */ - - devif_forward(fwd); - - /* Check if the destination IP address is in the ARP or Neighbor - * table. If not, then the send won't actually make it out... it - * will be replaced with an ARP request or Neighbor Solicitation. - */ - - if (!icmp_forward_addrchck(fwd)) - { - return flags; - } - } - - /* Free the allocated callback structure */ - - fwd->f_cb->flags = 0; - fwd->f_cb->priv = NULL; - fwd->f_cb->event = NULL; - - icmp_callback_free(dev, fwd->f_cb); - - /* Free any IOBs */ - - if (fwd->f_iob != NULL) - { - iob_free_chain(fwd->f_iob); - } - - /* And release the forwarding state structure */ - - ipfwd_free(fwd); - } - - return flags; -} - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: icmp_forward - * - * Description: - * Called by the IP forwarding logic when an ICMP packet is received on - * one network device, but must be forwarded on another network device. - * - * Set up to forward the ICMP packet on the specified device. This - * function will set up a send "interrupt" handler that will perform the - * actual send asynchronously and must return without waiting for the - * send to complete. - * - * Input Parameters: - * fwd - An initialized instance of the common forwarding structure that - * includes everything needed to perform the forwarding operation. - * - * Returned Value: - * Zero is returned if the packet was successfully forwarded; A negated - * errno value is returned if the packet is not forwardable. In that - * latter case, the caller should free the IOB list and drop the packet. - * - ****************************************************************************/ - -int icmp_forward(FAR struct forward_s *fwd) -{ - DEBUGASSERT(fwd != NULL && fwd->f_iob != NULL && fwd->f_dev != NULL); - - /* Set up the callback in the connection */ - - fwd->f_cb = icmp_callback_alloc(fwd->f_dev); - if (fwd->f_cb != NULL) - { - fwd->f_cb->flags = (ICMP_POLL | NETDEV_DOWN); - fwd->f_cb->priv = (FAR void *)fwd; - fwd->f_cb->event = icmp_forward_interrupt; - - /* Notify the device driver of the availability of TX data */ - - netdev_txnotify_dev(fwd->f_dev); - return OK; - } - - return -EBUSY; -} - -#endif /* CONFIG_NET_IPFORWARD && CONFIG_NET_ICMP && CONFIG_NETDEV_MULTINIC */ diff --git a/net/icmpv6/Make.defs b/net/icmpv6/Make.defs index b8231151fc..6c9b70aee7 100644 --- a/net/icmpv6/Make.defs +++ b/net/icmpv6/Make.defs @@ -63,14 +63,6 @@ ifeq ($(CONFIG_NET_ICMPv6_ROUTER),y) NET_CSRCS += icmpv6_radvertise.c endif -# IP forwarding - -ifeq ($(CONFIG_NET_IPFORWARD),y) -ifeq ($(CONFIG_NETDEV_MULTINIC),y) -NET_CSRCS += icmpv6_forward.c -endif -endif - # Include ICMPv6 build support DEPPATH += --dep-path icmpv6 diff --git a/net/icmpv6/icmpv6.h b/net/icmpv6/icmpv6.h index 8ff15abaee..d1150de698 100644 --- a/net/icmpv6/icmpv6.h +++ b/net/icmpv6/icmpv6.h @@ -178,34 +178,6 @@ int icmpv6_neighbor(const net_ipv6addr_t ipaddr); # define icmpv6_neighbor(i) (0) #endif -/**************************************************************************** - * Name: icmpv6_forward - * - * Description: - * Called by the IP forwarding logic when an ICMPv6 packet is received on - * one network device, but must be forwarded on another network device. - * - * Set up to forward the ICMPv6 packet on the specified device. The - * function will set up a send "interrupt" handler that will perform the - * actual send asynchronously and must return without waiting for the - * send to complete. - * - * Input Parameters: - * fwd - An initialized instance of the common forwarding structure that - * includes everything needed to perform the forwarding operation. - * - * Returned Value: - * Zero is returned if the packet was successfully forwarded; A negated - * errno value is returned if the packet is not forwardable. In that - * latter case, the caller should free the IOB list and drop the packet. - * - ****************************************************************************/ - -#if defined(CONFIG_NETDEV_MULTINIC) && defined(CONFIG_NET_IPFORWARD) -struct forward_s; -int icmpv6_forward(FAR struct forward_s *fwd); -#endif - /**************************************************************************** * Name: icmpv6_poll * diff --git a/net/icmpv6/icmpv6_forward.c b/net/icmpv6/icmpv6_forward.c deleted file mode 100644 index 866a67d6a0..0000000000 --- a/net/icmpv6/icmpv6_forward.c +++ /dev/null @@ -1,300 +0,0 @@ -/**************************************************************************** - * net/icmpv6/icmpv6_forward.c - * - * Copyright (C) 2017 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include "ipforward/ipforward.h" -#include "devif/devif.h" -#include "netdev/netdev.h" -#include "arp/arp.h" -#include "neighbor/neighbor.h" -#include "icmpv6/icmpv6.h" - -#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_ICMPv6) && \ - defined(CONFIG_NETDEV_MULTINIC) - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: icmpv6_forward_addrchck - * - * Description: - * Check if the destination IP address is in the Pv6 Neighbor table. If - * not, then the send won't actually make it out... it will be replaced - * with a Neighbor Solicitation. - * - * NOTE 1: This could be an expensive check if there are a lot of - * entries in the Neighbor table. - * - * NOTE 2: If CONFIG_NET_ARP_SEND then we can be assured that the IP - * address mapping is already in the ARP table. - * - * Parameters: - * fwd - The forwarding state structure - * - * Returned Value: - * true - The Ethernet MAC address is in the Neighbor table (OR the - * network device is not Ethernet). - * - * Assumptions: - * The network is locked. - * - ****************************************************************************/ - -#ifdef CONFIG_NET_ETHERNET -static inline bool icmpv6_forward_addrchck(FAR struct forward_s *fwd) -{ -#if !defined(CONFIG_NET_ARP_IPIN) && !defined(CONFIG_NET_ARP_SEND) - FAR union fwd_iphdr_u *iphdr; -#endif - - DEBUGASSERT(fwd != NULL && fwd->f_iob != NULL && fwd->f_dev != NULL); - - /* REVISIT: Could the MAC address not also be in a routing table? */ - -#ifdef CONFIG_NET_MULTILINK - if (fwd->f_dev->d_lltype != NET_LL_ETHERNET) - { - return true; - } -#endif - -#if !defined(CONFIG_NET_ICMPv6_NEIGHBOR) - iphdr = FWD_HEADER(fwd); - return (arp_find(iphdr->ipv6.l2.destipaddr) != NULL); -#else - return true; -#endif -} - -#else /* CONFIG_NET_ETHERNET */ -# define icmpv6_forward_addrchck(fwd) (true) -#endif /* CONFIG_NET_ETHERNET */ - -/**************************************************************************** - * Name: icmpv6_dropstats - * - * Description: - * Update statistics for a dropped packet. - * - * Input Parameters: - * fwd - The forwarding state structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -#ifdef CONFIG_NET_STATISTICS -static inline void icmpv6_dropstats(FAR struct forward_s *fwd) -{ - /* Increment the count of dropped ICMPv6 packets */ - - g_netstats.icmpv6.drop++; - g_netstats.ipv6.drop++; -} -#else -# define icmpv6_dropstats(fwd) -#endif - -/**************************************************************************** - * Name: icmpv6_forward_interrupt - * - * Description: - * This function is called from the interrupt level to perform the actual - * send operation when polled by the lower, device interfacing layer. - * - * Parameters: - * dev The structure of the network driver that caused the interrupt - * conn An instance of the ICMPv6 connection structure cast to void * - * pvpriv An instance of struct forward_s cast to void* - * flags Set of events describing why the callback was invoked - * - * Returned Value: - * Modified value of the input flags - * - * Assumptions: - * The network is locked - * - ****************************************************************************/ - -static uint16_t icmpv6_forward_interrupt(FAR struct net_driver_s *dev, - FAR void *conn, FAR void *pvpriv, - uint16_t flags) -{ - FAR struct forward_s *fwd = (FAR struct forward_s *)pvpriv; - - ninfo("flags: %04x\n", flags); - DEBUGASSERT(fwd != NULL && fwd->f_iob != NULL && fwd->f_dev != NULL); - - /* Make sure that this is from the forwarding device */ - - if (dev == fwd->f_dev) - { - /* If the network device has gone down, then we will have terminate - * the wait now with an error. - */ - - if ((flags & NETDEV_DOWN) != 0) - { - /* Terminate the transfer with an error. */ - - nwarn("WARNING: Network is down... Dropping\n"); - icmpv6_dropstats(fwd); - } - - /* Check if the outgoing packet is available. It may have been claimed - * by another send interrupt serving a different thread -OR- if the output - * buffer currently contains unprocessed incoming data. In these cases - * we will just have to wait for the next polling cycle. - */ - - else if (dev->d_sndlen > 0 || (flags & ICMPv6_NEWDATA) != 0) - { - /* Another thread has beat us sending data or the buffer is busy, - * Wait for the next polling cycle and check again. - */ - - return flags; - } - - /* It looks like we are good to forward the data */ - - else - { - /* Copy the ICMPv6 data into driver's packet buffer and send it. */ - - devif_forward(fwd); - - /* Check if the destination IP address is in the ARP or Neighbor - * table. If not, then the send won't actually make it out... it - * will be replaced with an ARP request or Neighbor Solicitation. - */ - - if (!icmpv6_forward_addrchck(fwd)) - { - return flags; - } - } - - /* Free the allocated callback structure */ - - fwd->f_cb->flags = 0; - fwd->f_cb->priv = NULL; - fwd->f_cb->event = NULL; - - icmpv6_callback_free(dev, fwd->f_cb); - - /* Free any IOBs */ - - if (fwd->f_iob != NULL) - { - iob_free_chain(fwd->f_iob); - } - - /* And release the forwarding state structure */ - - ipfwd_free(fwd); - } - - return flags; -} - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: icmpv6_forward - * - * Description: - * Called by the IP forwarding logic when an ICMPv6 packet is received on - * one network device, but must be forwarded on another network device. - * - * Set up to forward the ICMPv6 packet on the specified device. This - * function will set up a send "interrupt" handler that will perform the - * actual send asynchronously and must return without waiting for the - * send to complete. - * - * Input Parameters: - * fwd - An initialized instance of the common forwarding structure that - * includes everything needed to perform the forwarding operation. - * - * Returned Value: - * Zero is returned if the packet was successfully forwarded; A negated - * errno value is returned if the packet is not forwardable. In that - * latter case, the caller should free the IOB list and drop the packet. - * - ****************************************************************************/ - -int icmpv6_forward(FAR struct forward_s *fwd) -{ - DEBUGASSERT(fwd != NULL && fwd->f_iob != NULL && fwd->f_dev != NULL); - - /* Set up the callback in the connection */ - - fwd->f_cb = icmpv6_callback_alloc(fwd->f_dev); - if (fwd->f_cb != NULL) - { - fwd->f_cb->flags = (ICMPv6_POLL | NETDEV_DOWN); - fwd->f_cb->priv = (FAR void *)fwd; - fwd->f_cb->event = icmpv6_forward_interrupt; - - /* Notify the device driver of the availability of TX data */ - - netdev_txnotify_dev(fwd->f_dev); - return OK; - } - - return -EBUSY; -} - -#endif /* CONFIG_NET_IPFORWARD && CONFIG_NET_ICMPv6 && CONFIG_NETDEV_MULTINIC */ diff --git a/net/ipforward/Make.defs b/net/ipforward/Make.defs index 56789ceb57..cc46826da5 100644 --- a/net/ipforward/Make.defs +++ b/net/ipforward/Make.defs @@ -37,6 +37,8 @@ ifeq ($(CONFIG_NET_IPFORWARD),y) +NET_CSRCS += ipfwd_forward.c + ifeq ($(CONFIG_NET_IPv4),y) NET_CSRCS += ipv4_forward.c endif @@ -49,6 +51,10 @@ ifeq ($(CONFIG_NETDEV_MULTINIC),y) NET_CSRCS += ipfwd_alloc.c endif +ifeq ($(CONFIG_NET_STATISTICS),y) +NET_CSRCS += ipfwd_dropstats.c +endif + # Include IP forwaring build support DEPPATH += --dep-path ipforward diff --git a/net/ipforward/ipforward.h b/net/ipforward/ipforward.h index ee27f46447..52069b80ab 100644 --- a/net/ipforward/ipforward.h +++ b/net/ipforward/ipforward.h @@ -135,21 +135,6 @@ union fwd_iphdr_u #endif }; -/* Connection structures */ - -union fwd_conn_u -{ -#ifdef CONFIG_NET_TCP - struct tcp_conn_s tcp; -#endif -#ifdef CONFIG_NET_UDP - struct udp_conn_s udp; -#endif -#ifdef CONFIG_NET_ICMPv6 - struct icmpv6_conn_s icmpv6; -#endif -}; - /* This is the send state structure */ struct devif_callback_s; /* Forward refernce */ @@ -162,7 +147,6 @@ struct forward_s FAR struct net_driver_s *f_dev; /* Forwarding device */ FAR struct iob_s *f_iob; /* IOB chain containing the packet */ FAR struct devif_callback_s *f_cb; /* Reference to callback instance */ - union fwd_conn_u f_conn; /* Protocol-specific connection struct */ #if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6) uint8_t f_domain; /* Domain: PF_INET or PF_INET6 */ #endif @@ -296,6 +280,31 @@ void ipv6_forward_broadcast(FAR struct net_driver_s *dev, void devif_forward(FAR struct forward_s *fwd); +/**************************************************************************** + * Name: ipfwd_forward + * + * Description: + * Called by the IP forwarding logic when a packet is received on one + * network device, but must be forwarded on another network device. + * + * Set up to forward the packet on the specified device. This function + * will set up a send "interrupt" handler that will perform the actual + * send asynchronously and must return without waiting for the send to + * complete. + * + * Input Parameters: + * fwd - An initialized instance of the common forwarding structure that + * includes everything needed to perform the forwarding operation. + * + * Returned Value: + * Zero is returned if the packet was successfully forwarded; A negated + * errno value is returned if the packet is not forwardable. In that + * latter case, the caller should free the IOB list and drop the packet. + * + ****************************************************************************/ + +int ipfwd_forward(FAR struct forward_s *fwd); + #endif /* CONFIG_NETDEV_MULTINIC */ /**************************************************************************** @@ -358,5 +367,67 @@ int ipv4_forward(FAR struct net_driver_s *dev, FAR struct ipv4_hdr_s *ipv4); int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6); #endif +/**************************************************************************** + * Name: ipv6_dropstats + * + * Description: + * Update statistics for a dropped Ipv6 packet. + * + * Input Parameters: + * ipv6 - A pointer to the IPv6 header in within the IPv6 packet to be + * dropped. + * + * Returned Value: + * None + * + ****************************************************************************/ + +#if defined(CONFIG_NET_STATISTICS) && defined(CONFIG_NET_IPv6) +void ipv6_dropstats(FAR struct ipv6_hdr_s *ipv6); +#else +# define ipv6_dropstats(ipv6) +#endif + +/**************************************************************************** + * Name: ipv4_dropstats + * + * Description: + * Update statistics for a dropped Ipv4 packet. + * + * Input Parameters: + * ipv4 - A pointer to the IPv4 header in within the IPv4 packet to be + * dropped. + * + * Returned Value: + * None + * + ****************************************************************************/ + +#if defined(CONFIG_NET_STATISTICS) && defined(CONFIG_NET_IPv4) +void ipv4_dropstats(FAR struct ipv4_hdr_s *ipv4); +#else +# define ipv4_dropstats(ipv4) +#endif + +/**************************************************************************** + * Name: ipfwd_dropstats + * + * Description: + * Update statistics for a dropped packet. + * + * Input Parameters: + * fwd - The forwarding state structure + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_NET_STATISTICS +void ipfwd_dropstats(FAR struct forward_s *fwd) +#else +# define ipfwd_dropstats(fwd) +#endif + #endif /* CONFIG_NET_IPFORWARD */ #endif /* __NET_IPFORWARD_IPFORWARD_H */ diff --git a/net/ipforward/ipfwd_dropstats.c b/net/ipforward/ipfwd_dropstats.c new file mode 100644 index 0000000000..d743b17916 --- /dev/null +++ b/net/ipforward/ipfwd_dropstats.c @@ -0,0 +1,192 @@ +/**************************************************************************** + * net/ipforward/ipfwd_dropstats.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include "ipforward/ipforward.h" + +#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_STATISTICS) + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: proto_dropstats + * + * Description: + * Update statistics for a dropped L2 protocol packet. + * + * Input Parameters: + * proto - The protocol from the IPv4 or IPv6 header. + * + * Returned Value: + * On success, zero (OK) is returned. Otherwise, a negated errno value + * is returned. The only error is if th protocol is not recognized. + * + ****************************************************************************/ + +static int proto_dropstats(int proto) +{ + switch (proto) + { +#ifdef CONFIG_NET_TCP + case IP_PROTO_TCP: + g_netstats.tcp.drop++; + break; +#endif + +#ifdef CONFIG_NET_UDP + case IP_PROTO_UDP: + g_netstats.udp.drop++; + break; +#endif + +#ifdef CONFIG_NET_ICMPv6 + case IP_PROTO_ICMP6: + g_netstats.icmpv6.drop++; + break; +#endif + + default: + retrun -EPROTONOSUPPORT; + } + + return OK; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: ipv6_dropstats + * + * Description: + * Update statistics for a dropped Ipv6 packet. + * + * Input Parameters: + * ipv6 - A pointer to the IPv6 header in within the IPv6 packet to be + * dropped. + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_NET_IPv6 +void ipv6_dropstats(FAR struct ipv6_hdr_s *ipv6) +{ + int ret; + + ret = proto_dropstats(ipv6->proto); + if (ret < 0) + { + g_netstats.ipv6.protoerr++; + } + + g_netstats.ipv6.drop++; +} +#endif + +/**************************************************************************** + * Name: ipv4_dropstats + * + * Description: + * Update statistics for a dropped Ipv4 packet. + * + * Input Parameters: + * ipv4 - A pointer to the IPv4 header in within the IPv4 packet to be + * dropped. + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_NET_IPv4 +void ipv4_dropstats(FAR struct ipv4_hdr_s *ipv4) +{ + int ret; + + ret = proto_dropstats(ipv6->ipv4); + if (ret < 0) + { + g_netstats.ipv4.protoerr++; + } + + g_netstats.ipv4.drop++; +} +#endif + +/**************************************************************************** + * Name: ipfwd_dropstats + * + * Description: + * Update statistics for a dropped packet. + * + * Input Parameters: + * fwd - The forwarding state structure + * + * Returned Value: + * None + * + ****************************************************************************/ + +void ipfwd_dropstats(FAR struct forward_s *fwd) +{ +#ifdef CONFIG_NET_IPv4 +#ifdef CONFIG_NET_IPv6 + if (fwd->domain == PF_INET) +#endif + { + ipv4_dropstats((FAR struct ipv4_hdr_s *)fwd->f_iob->io_data); + } +#endif +#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NET_IPv4 + else +#endif + { + ipv6_dropstats((FAR struct ipv6_hdr_s *)fwd->f_iob->io_data); + } +#endif +} diff --git a/net/udp/udp_forward.c b/net/ipforward/ipfwd_forward.c similarity index 78% rename from net/udp/udp_forward.c rename to net/ipforward/ipfwd_forward.c index e65cbe6ea1..c7e1156b10 100644 --- a/net/udp/udp_forward.c +++ b/net/ipforward/ipfwd_forward.c @@ -1,5 +1,5 @@ /**************************************************************************** - * net/udp/udp_forward.c + * net/ipforward/ipfwd_forward.c * * Copyright (C) 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -49,15 +49,13 @@ #include #include -#include "ipforward/ipforward.h" #include "devif/devif.h" #include "netdev/netdev.h" #include "arp/arp.h" #include "neighbor/neighbor.h" -#include "udp/udp.h" +#include "ipforward/ipforward.h" -#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_UDP) && \ - defined(CONFIG_NETDEV_MULTINIC) +#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC) /**************************************************************************** * Public Functions @@ -86,23 +84,35 @@ #if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6) static inline void forward_ipselect(FAR struct forward_s *fwd) { - FAR union fwd_iphdr_u *iphdr = FWD_HEADER(fwd); + FAR struct net_driver_s *dev = fwd->f_dev; /* Select IPv4 or IPv6 */ if (fwd->f_domain == PF_INET) { - udp_ipv4_select(fwd->f_dev); + /* Clear a bit in the d_flags to distinguish this from an IPv6 packet */ + + IFF_SET_IPv4(dev->d_flags); + + /* Set the offset to the beginning of the UDP data payload */ + + dev->d_appdata = &dev->d_buf[IPv4UDP_HDRLEN + NET_LL_HDRLEN(dev)]; } else { - udp_ipv6_select(fwd->f_dev); + /* Set a bit in the d_flags to distinguish this from an IPv6 packet */ + + IFF_SET_IPv6(dev->d_flags); + + /* Set the offset to the beginning of the UDP data payload */ + + dev->d_appdata = &dev->d_buf[IPv6_HDRLEN + NET_LL_HDRLEN(dev)]; } } #endif /**************************************************************************** - * Name: udp_forward_addrchk + * Name: ipfwd_addrchk * * Description: * Check if the destination IP address is in the IPv4 ARP or IPv6 Neighbor @@ -132,7 +142,7 @@ static inline void forward_ipselect(FAR struct forward_s *fwd) ****************************************************************************/ #ifdef CONFIG_NET_ETHERNET -static inline bool udp_forward_addrchk(FAR struct forward_s *fwd) +static inline bool ipfwd_addrchk(FAR struct forward_s *fwd) { FAR union fwd_iphdr_u *iphdr; @@ -177,59 +187,11 @@ static inline bool udp_forward_addrchk(FAR struct forward_s *fwd) } #else /* CONFIG_NET_ETHERNET */ -# define udp_forward_addrchk(r) (true) +# define ipfwd_addrchk(r) (true) #endif /* CONFIG_NET_ETHERNET */ /**************************************************************************** - * Name: udp_dropstats - * - * Description: - * Update statistics for a dropped packet. - * - * Input Parameters: - * fwd - The forwarding state structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -#ifdef CONFIG_NET_STATISTICS -static void udp_dropstats(FAR struct forward_s *fwd) -{ -#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6) - FAR union fwd_iphdr_u *iphdr = FWD_HEADER(fwd); -#endif - - /* Increment the count of dropped UDP packets */ - - g_netstats.udp.drop++; - - /* Increment the count of dropped IPv4 or IPv6 packets */ - -#ifdef CONFIG_NET_IPv4 -#ifdef CONFIG_NET_IPv6 - if (fwd->f_domain == PF_INET) -#endif - { - g_netstats.ipv4.drop++; - } -#endif -#ifdef CONFIG_NET_IPv6 -#ifdef CONFIG_NET_IPv4 - else -#endif - { - g_netstats.ipv6.drop++; - } -#endif -} -#else -# define udp_dropstats(ipv6) -#endif - -/**************************************************************************** - * Name: udp_forward_interrupt + * Name: ipfwd_interrupt * * Description: * This function is called from the interrupt level to perform the actual @@ -237,7 +199,7 @@ static void udp_dropstats(FAR struct forward_s *fwd) * * Parameters: * dev The structure of the network driver that caused the interrupt - * conn An instance of the UDP connection structure cast to void * + * conn An instance of the forwarding structure cast to void * * pvpriv An instance of struct forward_s cast to void* * flags Set of events describing why the callback was invoked * @@ -249,9 +211,8 @@ static void udp_dropstats(FAR struct forward_s *fwd) * ****************************************************************************/ -static uint16_t udp_forward_interrupt(FAR struct net_driver_s *dev, - FAR void *conn, FAR void *pvpriv, - uint16_t flags) +static uint16_t ipfwd_interrupt(FAR struct net_driver_s *dev, FAR void *conn, + FAR void *pvpriv, uint16_t flags) { FAR struct forward_s *fwd = (FAR struct forward_s *)pvpriv; @@ -271,7 +232,7 @@ static uint16_t udp_forward_interrupt(FAR struct net_driver_s *dev, /* Terminate the transfer with an error. */ nwarn("WARNING: Network is down... Dropping\n"); - udp_dropstats(fwd); + ipfwd_dropstats(fwd); } /* Check if the outgoing packet is available. It may have been claimed @@ -280,7 +241,7 @@ static uint16_t udp_forward_interrupt(FAR struct net_driver_s *dev, * we will just have to wait for the next polling cycle. */ - else if (dev->d_sndlen > 0 || (flags & UDP_NEWDATA) != 0) + else if (dev->d_sndlen > 0 || (flags & IPFWD_NEWDATA) != 0) { /* Another thread has beat us sending data or the buffer is busy, * Wait for the next polling cycle and check again. @@ -311,7 +272,7 @@ static uint16_t udp_forward_interrupt(FAR struct net_driver_s *dev, * will be replaced with an ARP request or Neighbor Solicitation. */ - if (!udp_forward_addrchk(fwd)) + if (!ipfwd_addrchk(fwd)) { return flags; } @@ -323,7 +284,7 @@ static uint16_t udp_forward_interrupt(FAR struct net_driver_s *dev, fwd->f_cb->priv = NULL; fwd->f_cb->event = NULL; - udp_callback_free(dev, &fwd->f_conn.udp, fwd->f_cb); + devif_conn_callback_free(dev, fwd->f_cb, NULL); /* Free any IOBs */ @@ -345,16 +306,16 @@ static uint16_t udp_forward_interrupt(FAR struct net_driver_s *dev, ****************************************************************************/ /**************************************************************************** - * Name: udp_forward + * Name: ipfwd_forward * * Description: - * Called by the IP forwarding logic when an UDP packet is received on - * one network device, but must be forwarded on another network device. + * Called by the IP forwarding logic when a packet is received on one + * network device, but must be forwarded on another network device. * - * Set up to forward the UDP packet on the specified device. This - * function will set up a send "interrupt" handler that will perform the - * actual send asynchronously and must return without waiting for the - * send to complete. + * Set up to forward the packet on the specified device. This function + * will set up a send "interrupt" handler that will perform the actual + * send asynchronously and must return without waiting for the send to + * complete. * * Input Parameters: * fwd - An initialized instance of the common forwarding structure that @@ -367,18 +328,18 @@ static uint16_t udp_forward_interrupt(FAR struct net_driver_s *dev, * ****************************************************************************/ -int udp_forward(FAR struct forward_s *fwd) +int ipfwd_forward(FAR struct forward_s *fwd) { DEBUGASSERT(fwd != NULL && fwd->f_iob != NULL && fwd->f_dev != NULL); /* Set up the callback in the connection */ - fwd->f_cb = udp_callback_alloc(fwd->f_dev, &fwd->f_conn.udp); + fwd->f_cb = devif_callback_alloc(fwd->f_dev, NULL); if (fwd->f_cb != NULL) { - fwd->f_cb->flags = (UDP_POLL | NETDEV_DOWN); + fwd->f_cb->flags = (IPFWD_POLL | NETDEV_DOWN); fwd->f_cb->priv = (FAR void *)fwd; - fwd->f_cb->event = udp_forward_interrupt; + fwd->f_cb->event = ipfwd_interrupt; /* Notify the device driver of the availability of TX data */ @@ -389,4 +350,4 @@ int udp_forward(FAR struct forward_s *fwd) return -EBUSY; } -#endif /* CONFIG_NET_IPFORWARD && CONFIG_NET_UDP && CONFIG_NETDEV_MULTINIC */ +#endif /* CONFIG_NET_IPFORWARD && CONFIG_NETDEV_MULTINIC */ diff --git a/net/ipforward/ipv4_forward.c b/net/ipforward/ipv4_forward.c index 63dd5aae5b..2c1e5f8756 100644 --- a/net/ipforward/ipv4_forward.c +++ b/net/ipforward/ipv4_forward.c @@ -51,9 +51,6 @@ #include "netdev/netdev.h" #include "utils/utils.h" #include "sixlowpan/sixlowpan.h" -#include "udp/udp.h" -#include "tcp/tcp.h" -#include "icmp/icmp.h" #include "ipforward/ipforward.h" #include "devif/devif.h" @@ -190,55 +187,6 @@ static int ipv4_decr_ttl(FAR struct ipv4_hdr_s *ipv4) } #endif -/**************************************************************************** - * Name: ipv4_dropstats - * - * Description: - * Update statistics for a dropped packet. - * - * Input Parameters: - * ipv4 - A convenience pointer to the IPv4 header in within the IPv4 - * packet to be dropped. - * - * Returned Value: - * None - * - ****************************************************************************/ - -#ifdef CONFIG_NET_STATISTICS -static void ipv4_dropstats(FAR struct ipv4_hdr_s *ipv4) -{ - switch (ipv4->proto) - { -#ifdef CONFIG_NET_TCP - case IP_PROTO_TCP: - g_netstats.tcp.drop++; - break; -#endif - -#ifdef CONFIG_NET_UDP - case IP_PROTO_UDP: - g_netstats.udp.drop++; - break; -#endif - -#ifdef CONFIG_NET_ICMP - case IP_PROTO_ICMP: - g_netstats.icmp.drop++; - break; -#endif - - default: - g_netstats.ipv4.protoerr++; - break; - } - - g_netstats.ipv4.drop++; -} -#else -# define ipv4_dropstats(ipv4) -#endif - /**************************************************************************** * Name: ipv4_dev_forward * @@ -366,51 +314,9 @@ static int ipv4_dev_forward(FAR struct net_driver_s *dev, goto errout_with_iobchain; } - /* Then set up to forward the packet according to the protocol. - * - * REVISIT: Are these protocol specific forwarders necessary? I think - * that this could be done with a single forwarding function for all - * protocols. - */ - - switch (ipv4->proto) - { -#ifdef CONFIG_NET_TCP - case IP_PROTO_TCP: - { - /* Forward a TCP packet. */ - - ret = tcp_forward(fwd); - } - break; -#endif - -#ifdef CONFIG_NET_UDP - case IP_PROTO_UDP: - { - /* Forward a UDP packet */ - - ret = udp_forward(fwd); - } - break; -#endif - -#ifdef CONFIG_NET_ICMP - case IP_PROTO_ICMP: - { - /* Forward an ICMP packet */ - - ret = icmp_forward(fwd); - } - break; -#endif - - default: - nwarn("WARNING: Unrecognized proto: %u\n", ipv4->proto); - ret = -EPROTONOSUPPORT; - break; - } + /* Then set up to forward the packet according to the protocol. */ + ret = ipfwd_forward(fwd); if (ret >= 0) { dev->d_len = 0; diff --git a/net/ipforward/ipv6_forward.c b/net/ipforward/ipv6_forward.c index e50fe7c2b0..b76a219d81 100644 --- a/net/ipforward/ipv6_forward.c +++ b/net/ipforward/ipv6_forward.c @@ -50,11 +50,8 @@ #include "netdev/netdev.h" #include "sixlowpan/sixlowpan.h" -#include "udp/udp.h" -#include "tcp/tcp.h" -#include "icmpv6/icmpv6.h" -#include "ipforward/ipforward.h" #include "devif/devif.h" +#include "ipforward/ipforward.h" #if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_IPv6) @@ -183,55 +180,6 @@ static int ipv6_decr_ttl(FAR struct ipv6_hdr_s *ipv6) } #endif -/**************************************************************************** - * Name: ipv6_dropstats - * - * Description: - * Update statistics for a dropped packet. - * - * Input Parameters: - * ipv6 - A convenience pointer to the IPv6 header in within the IPv6 - * packet to be dropped. - * - * Returned Value: - * None - * - ****************************************************************************/ - -#ifdef CONFIG_NET_STATISTICS -static void ipv6_dropstats(FAR struct ipv6_hdr_s *ipv6) -{ - switch (ipv6->proto) - { -#ifdef CONFIG_NET_TCP - case IP_PROTO_TCP: - g_netstats.tcp.drop++; - break; -#endif - -#ifdef CONFIG_NET_UDP - case IP_PROTO_UDP: - g_netstats.udp.drop++; - break; -#endif - -#ifdef CONFIG_NET_ICMPv6 - case IP_PROTO_ICMP6: - g_netstats.icmpv6.drop++; - break; -#endif - - default: - g_netstats.ipv6.protoerr++; - break; - } - - g_netstats.ipv6.drop++; -} -#else -# define ipv6_dropstats(ipv6) -#endif - /**************************************************************************** * Name: ipv6_packet_conversion * @@ -477,58 +425,16 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, goto errout_with_iobchain; } - /* Then set up to forward the packet according to the protocol. - * - * REVISIT: Are these protocol specific forwarders necessary? I think - * that this could be done with a single forwarding function for all - * protocols. - */ + /* Then set up to forward the packet according to the protocol. */ - switch (ipv6->proto) + ret = ipfwd_forward(fwd); + if (ret >= 0) { -#ifdef CONFIG_NET_TCP - case IP_PROTO_TCP: - { - /* Forward a TCP packet. */ - - ret = tcp_forward(fwd); - } - break; -#endif - -#ifdef CONFIG_NET_UDP - case IP_PROTO_UDP: - { - /* Forward a UDP packet */ - - ret = udp_forward(fwd); - } - break; -#endif - -#ifdef CONFIG_NET_ICMPv6 - case IP_PROTO_ICMP6: - { - /* Forward an ICMPv6 packet */ - - ret = icmpv6_forward(fwd); - } - break; -#endif - - default: - nwarn("WARNING: Unrecognized proto: %u\n", ipv6->proto); - ret = -EPROTONOSUPPORT; - break; + dev->d_len = 0; + return OK; } } - if (ret >= 0) - { - dev->d_len = 0; - return OK; - } - errout_with_iobchain: if (fwd != NULL && fwd->f_iob != NULL) { diff --git a/net/tcp/Make.defs b/net/tcp/Make.defs index 7f3a88582b..c7b00b6040 100644 --- a/net/tcp/Make.defs +++ b/net/tcp/Make.defs @@ -60,14 +60,6 @@ NET_CSRCS += tcp_conn.c tcp_seqno.c tcp_devpoll.c tcp_finddev.c tcp_timer.c NET_CSRCS += tcp_send.c tcp_input.c tcp_appsend.c tcp_listen.c NET_CSRCS += tcp_callback.c tcp_backlog.c tcp_ipselect.c -# IP forwarding - -ifeq ($(CONFIG_NET_IPFORWARD),y) -ifeq ($(CONFIG_NETDEV_MULTINIC),y) -NET_CSRCS += tcp_forward.c -endif -endif - # TCP write buffering ifeq ($(CONFIG_NET_TCP_WRITE_BUFFERS),y) diff --git a/net/tcp/tcp.h b/net/tcp/tcp.h index 9497e426ec..f13170668d 100644 --- a/net/tcp/tcp.h +++ b/net/tcp/tcp.h @@ -794,37 +794,6 @@ int tcp_accept_connection(FAR struct net_driver_s *dev, void tcp_send(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, uint16_t flags, uint16_t len); -/**************************************************************************** - * Name: tcp_forward - * - * Description: - * Called by the IP forwarding logic when an TCP packet is received on - * one network device, but must be forwarded on another network device. - * - * Set up to forward the TCP packet on the specified device. This - * function will set up a send "interrupt" handler that will perform - * the actual send asynchronously and must return without waiting for the - * send to complete. - * - * Input Parameters: - * domain - Either PF_INET or PF_INET6 - * fwd - An initialized instance of the common forwarding structure - * that includes everything needed to perform the forwarding - * operation. - * - * Returned Value: - * Zero is returned if the packet was successfully forwarded; A negated - * errno value is returned if the packet is not forwardable. In that - * latter case, the caller should free the IOB list and drop the packet. - * - ****************************************************************************/ - -#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_IPv6) && \ - defined(CONFIG_NETDEV_MULTINIC) -struct forward_s; /* Forward reference */ -int tcp_forward(FAR struct forward_s *fwd); -#endif - /**************************************************************************** * Name: tcp_reset * diff --git a/net/tcp/tcp_forward.c b/net/tcp/tcp_forward.c deleted file mode 100644 index 542b0e8e1c..0000000000 --- a/net/tcp/tcp_forward.c +++ /dev/null @@ -1,443 +0,0 @@ -/**************************************************************************** - * net/tcp/tcp_forward.c - * - * Copyright (C) 2017 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include "ipforward/ipforward.h" -#include "devif/devif.h" -#include "netdev/netdev.h" -#include "arp/arp.h" -#include "neighbor/neighbor.h" -#include "tcp/tcp.h" - -#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_TCP) && \ - defined(CONFIG_NETDEV_MULTINIC) - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: forward_ipselect - * - * Description: - * If both IPv4 and IPv6 support are enabled, then we will need to select - * which one to use when generating the outgoing packet. If only one - * domain is selected, then the setup is already in place and we need do - * nothing. - * - * Parameters: - * fwd - The forwarding state structure - * - * Returned Value: - * None - * - * Assumptions: - * The network is locked. - * - ****************************************************************************/ - -#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6) -static inline void forward_ipselect(FAR struct forward_s *fwd) -{ - /* Which domain the connection support */ - - if (fwd->f_domain == PF_INET) - { - /* Select the IPv4 domain */ - - tcp_ipv4_select(fwd->f_dev); - } - else /* if (conn->domain == PF_INET6) */ - { - /* Select the IPv6 domain */ - - DEBUGASSERT(fwd->f_conn.tcp.domain == PF_INET6); - tcp_ipv6_select(fwd->f_dev); - } -} -#endif - -/**************************************************************************** - * Name: tcp_forward_addrchck - * - * Description: - * Check if the destination IP address is in the IPv4 ARP or IPv6 Neighbor - * tables. If not, then the send won't actually make it out... it will be - * replaced with an ARP request (IPv4) or a Neighbor Solicitation (IPv6). - * - * NOTE 1: This could be an expensive check if there are a lot of - * entries in the ARP or Neighbor tables. - * - * NOTE 2: If we are actually harvesting IP addresses on incoming IP - * packets, then this check should not be necessary; the MAC mapping - * should already be in the ARP table in many cases (IPv4 only). - * - * NOTE 3: If CONFIG_NET_ARP_SEND then we can be assured that the IP - * address mapping is already in the ARP table. - * - * Parameters: - * fwd - The forwarding state structure - * - * Returned Value: - * true - The Ethernet MAC address is in the ARP or Neighbor table (OR - * the network device is not Ethernet). - * - * Assumptions: - * The network is locked. - * - ****************************************************************************/ - -#ifdef CONFIG_NET_ETHERNET -static inline bool tcp_forward_addrchck(FAR struct forward_s *fwd) -{ - FAR struct tcp_conn_s *conn = &fwd->f_conn.tcp; - - /* REVISIT: Could the MAC address not also be in a routing table? */ - -#ifdef CONFIG_NET_MULTILINK - if (fwd->f_dev->d_lltype != NET_LL_ETHERNET) - { - return true; - } -#endif - -#ifdef CONFIG_NET_IPv4 -#ifdef CONFIG_NET_IPv6 - if (fwd->f_domain == PF_INET) -#endif - { -#if !defined(CONFIG_NET_ARP_IPIN) && !defined(CONFIG_NET_ARP_SEND) - return (arp_find(conn->u.ipv4.raddr) != NULL); -#else - return true; -#endif - } -#endif /* CONFIG_NET_IPv4 */ - -#ifdef CONFIG_NET_IPv6 -#ifdef CONFIG_NET_IPv4 - else -#endif - { -#if !defined(CONFIG_NET_ICMPv6_NEIGHBOR) - return (neighbor_findentry(conn->u.ipv6.raddr) != NULL); -#else - return true; -#endif - } -#endif /* CONFIG_NET_IPv6 */ - - UNUSED(conn); -} - -#else /* CONFIG_NET_ETHERNET */ -# define tcp_forward_addrchck(r) (true) -#endif /* CONFIG_NET_ETHERNET */ - -/**************************************************************************** - * Name: tcp_dropstats - * - * Description: - * Update statistics for a dropped packet. - * - * Input Parameters: - * fwd - The forwarding state structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -#ifdef CONFIG_NET_STATISTICS -static void tcp_dropstats(FAR struct forward_s *fwd) -{ - /* Increment the count of dropped TCP packets */ - - g_netstats.tcp.drop++; - - /* Increment the count of dropped IPv4 or IPv6 packets */ - -#ifdef CONFIG_NET_IPv4 -#ifdef CONFIG_NET_IPv6 - if (fwd->f_domain == PF_INET) -#endif - { - g_netstats.ipv4.drop++; - } -#endif -#ifdef CONFIG_NET_IPv6 -#ifdef CONFIG_NET_IPv4 - else -#endif - { - g_netstats.ipv6.drop++; - } -#endif -} -#else -# define tcp_dropstats(ipv6) -#endif - -/**************************************************************************** - * Name: tcp_forward_interrupt - * - * Description: - * This function is called from the interrupt level to perform the actual - * send operation when polled by the lower, device interfacing layer. - * - * NOTE: Our role here is just data passthrough. We don't really care - * about ACKing, dynamic windows or any of the other TCP complexities. - * That is really something between the two endpoints and does not matter - * the forwarding hub. - * - * Parameters: - * dev The structure of the network driver that caused the interrupt - * conn An instance of the TCP connection structure cast to void * - * pvpriv An instance of struct forward_s cast to void* - * flags Set of events describing why the callback was invoked - * - * Returned Value: - * Modified value of the input flags - * - * Assumptions: - * The network is locked - * - ****************************************************************************/ - -static uint16_t tcp_forward_interrupt(FAR struct net_driver_s *dev, - FAR void *conn, FAR void *pvpriv, - uint16_t flags) -{ - FAR struct forward_s *fwd = (FAR struct forward_s *)pvpriv; - - ninfo("flags: %04x\n", flags); - DEBUGASSERT(fwd != NULL && fwd->f_iob != NULL && fwd->f_dev != NULL); - - /* Make sure that this is from the forwarding device */ - - if (dev == fwd->f_dev) - { - /* If the network device has gone down, then we will have terminate - * the wait now with an error. - * - * REVISIT: TCP disconnection events should should not be recieved here. - * Rather the disconnection events will be handled by the TCP endpoints. - */ - - if ((flags & NETDEV_DOWN) != 0) - { - /* Terminate the transfer with an error. */ - - nwarn("WARNING: Network is down... Dropping\n"); - tcp_dropstats(fwd); - } - - /* Check if the outgoing packet is available. It may have been claimed - * by a sendto interrupt serving a different thread -OR- if the output - * buffer currently contains unprocessed incoming data. In these cases - * we will just have to wait for the next polling cycle. - */ - - else if (dev->d_sndlen > 0 || (flags & TCP_NEWDATA) != 0) - { - /* Another thread has beat us sending data or the buffer is busy, - * Wait for the next polling cycle and check again. - */ - - return flags; - } - - /* It looks like we are good to forward the data */ - - else - { -#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6) - /* If both IPv4 and IPv6 support are enabled, then we will need to - * select which one to use when generating the outgoing packet. - * If only one domain is selected, then the setup is already in - * place and we need do nothing. - */ - - forward_ipselect(fwd); -#endif - /* Copy the user data into d_appdata and send it. */ - - devif_forward(fwd); - - /* Check if the destination IP address is in the ARP or Neighbor - * table. If not, then the send won't actually make it out... it - * will be replaced with an ARP request or Neighbor Solicitation. - */ - - if (!tcp_forward_addrchck(fwd)) - { - return flags; - } - } - - /* Free the allocated callback structure */ - - fwd->f_cb->flags = 0; - fwd->f_cb->priv = NULL; - fwd->f_cb->event = NULL; - - tcp_callback_free(&fwd->f_conn.tcp, fwd->f_cb); - - /* Free any IOBs */ - - if (fwd->f_iob != NULL) - { - iob_free_chain(fwd->f_iob); - } - - /* And release the forwarding state structure */ - - ipfwd_free(fwd); - } - - return flags; -} - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: tcp_forward - * - * Description: - * Called by the IP forwarding logic when an TCP packet is received on - * one network device, but must be forwarded on another network device. - * - * Set up to forward the TCP packet on the specified device. This - * function will set up a send "interrupt" handler that will perform the - * actual send asynchronously and must return without waiting for the - * send to complete. - * - * Input Parameters: - * fwd - An initialized instance of the common forwarding structure that - * includes everything needed to perform the forwarding operation. - * - * Returned Value: - * Zero is returned if the packet was successfully forwarded; A negated - * errno value is returned if the packet is not forwardable. In that - * latter case, the caller should free the IOB list and drop the packet. - * - ****************************************************************************/ - -int tcp_forward(FAR struct forward_s *fwd) -{ - FAR struct tcp_conn_s *conn = &fwd->f_conn.tcp; - FAR union fwd_iphdr_u *iphdr; - - DEBUGASSERT(fwd != NULL && fwd->f_iob != NULL && fwd->f_dev != NULL); - - /* Set up some minimal connection structure so that we appear to be a - * real TCP connection. - */ - - conn->dev = fwd->f_dev; - iphdr = FWD_HEADER(fwd); - -#ifdef CONFIG_NET_IPv4 -#ifdef CONFIG_NET_IPv6 - if (fwd->f_domain == PF_INET) -#endif - { - FAR struct ipv4_hdr_s *ipv4 = &iphdr->ipv4.l2; - FAR struct tcp_hdr_s *tcp = &iphdr->ipv4.l3.tcp; - -#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6) - conn->domain = PF_INET; -#endif - conn->lport = tcp->srcport; - conn->rport = tcp->destport; - net_ipv4addr_copy(conn->u.ipv4.laddr, ipv4->srcipaddr); - net_ipv4addr_copy(conn->u.ipv4.raddr, ipv4->destipaddr); - } -#endif -#ifdef CONFIG_NET_IPv6 -#ifdef CONFIG_NET_IPv4 - else -#endif - { - FAR struct ipv6_hdr_s *ipv6 = &iphdr->ipv6.l2; - FAR struct tcp_hdr_s *tcp = &iphdr->ipv6.l3.tcp; - -#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6) - conn->domain = PF_INET6; -#endif - conn->lport = tcp->srcport; - conn->rport = tcp->destport; - net_ipv6addr_copy(conn->u.ipv6.laddr, ipv6->srcipaddr); - net_ipv6addr_copy(conn->u.ipv6.raddr, ipv6->destipaddr); - } -#endif - - /* Set up the callback in the connection */ - - fwd->f_cb = tcp_callback_alloc(conn); - if (fwd->f_cb != NULL) - { - fwd->f_cb->flags = (TCP_POLL | NETDEV_DOWN); - fwd->f_cb->priv = (FAR void *)fwd; - fwd->f_cb->event = tcp_forward_interrupt; - - /* Notify the device driver of the availability of TX data */ - - netdev_txnotify_dev(fwd->f_dev); - return OK; - } - - return -EBUSY; -} - -#endif /* CONFIG_NET_IPFORWARD && CONFIG_NET_TCP && CONFIG_NETDEV_MULTINIC */ diff --git a/net/udp/Make.defs b/net/udp/Make.defs index 9dda0a1604..4b3992911d 100644 --- a/net/udp/Make.defs +++ b/net/udp/Make.defs @@ -48,14 +48,6 @@ NET_CSRCS += udp_netpoll.c endif endif -# IP forwarding - -ifeq ($(CONFIG_NET_IPFORWARD),y) -ifeq ($(CONFIG_NETDEV_MULTINIC),y) -NET_CSRCS += udp_forward.c -endif -endif - # Transport layer NET_CSRCS += udp_conn.c udp_devpoll.c udp_send.c udp_input.c udp_finddev.c diff --git a/net/udp/udp.h b/net/udp/udp.h index 91a690f5fe..cb6ca378f5 100644 --- a/net/udp/udp.h +++ b/net/udp/udp.h @@ -428,35 +428,6 @@ FAR struct net_driver_s *udp_find_raddr_device(FAR struct udp_conn_s *conn); uint16_t udp_callback(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn, uint16_t flags); -/**************************************************************************** - * Name: udp_forward - * - * Description: - * Called by the IP forwarding logic when an UDP packet is received on - * one network device, but must be forwarded on another network device. - * - * Set up to forward the UDP packet on the specified device. This - * function will set up a send "interrupt" handler that will perform the - * actual send asynchronously and must return without waiting for the - * send to complete. - * - * Input Parameters: - * fwd - An initialized instance of the common forwarding structure that - * includes everything needed to perform the forwarding operation. - * - * Returned Value: - * Zero is returned if the packet was successfully forwarded; A negated - * errno value is returned if the packet is not forwardable. In that - * latter case, the caller should free the IOB list and drop the packet. - * - ****************************************************************************/ - -#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_IPv6) && \ - defined(CONFIG_NETDEV_MULTINIC) -struct forward_s; /* Forward reference */ -int udp_forward(FAR struct forward_s *fwd); -#endif - /**************************************************************************** * Name: psock_udp_send *