From 969d7c5814a8fc3dd403b36063ca650ce63a0231 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 21 Aug 2017 06:27:29 -0600 Subject: [PATCH] Networking: Remove driver based backlog support. This affects the entire network, but is used by only one driver. The only supported with of supported RX backlog is via common read-ahead buffering. --- .../stm32f769i-disco/nsh-ethernet/defconfig | 1 - drivers/net/Kconfig | 1 - drivers/net/encx24j600.c | 63 +-------- include/nuttx/net/netdev.h | 3 - net/inet/inet_recvfrom.c | 53 ------- net/netdev/Make.defs | 4 - net/netdev/netdev.h | 59 -------- net/netdev/netdev_rxnotify.c | 130 ------------------ net/pkt/pkt_recvfrom.c | 28 ---- net/udp/Kconfig | 16 --- 10 files changed, 5 insertions(+), 353 deletions(-) delete mode 100644 net/netdev/netdev_rxnotify.c diff --git a/configs/stm32f769i-disco/nsh-ethernet/defconfig b/configs/stm32f769i-disco/nsh-ethernet/defconfig index 1b3383624fa..7fdba0ec38c 100644 --- a/configs/stm32f769i-disco/nsh-ethernet/defconfig +++ b/configs/stm32f769i-disco/nsh-ethernet/defconfig @@ -33,7 +33,6 @@ CONFIG_NET_ETH_MTU=1500 CONFIG_NET_HOSTNAME="stntest" CONFIG_NET_ICMP_PING=y CONFIG_NET_ICMP=y -CONFIG_NET_RXAVAIL=y CONFIG_NET_SOCKOPTS=y CONFIG_NET_SOLINGER=y CONFIG_NET_STATISTICS=y diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index a41d7ef1ea4..d6dc66f629e 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -295,7 +295,6 @@ menuconfig ENCX24J600 bool "Microchip ENCX24J600 support" default n select SPI - select NET_RXAVAIL select ARCH_HAVE_NETDEV_STATISTICS ---help--- References: diff --git a/drivers/net/encx24j600.c b/drivers/net/encx24j600.c index 719661a9ace..8fbc2c6ef16 100644 --- a/drivers/net/encx24j600.c +++ b/drivers/net/encx24j600.c @@ -156,10 +156,6 @@ #define ENC_TXTIMEOUT (60*CLK_TCK) -/* RX timeout (Time packets are held in the RX queue until they are dropped) */ - -#define ENC_RXTIMEOUT MSEC2TICK(2000) - /* Poll timeout */ #define ENC_POLLTIMEOUT MSEC2TICK(50) @@ -228,7 +224,6 @@ struct enc_descr_s struct enc_descr_next *flink; uint16_t addr; uint16_t len; - uint32_t ts; /* Timestamp of reception for timeout */ }; /* The enc_driver_s encapsulates all state information for a single hardware @@ -360,7 +355,6 @@ static void enc_polltimer(int argc, uint32_t arg, ...); static int enc_ifup(struct net_driver_s *dev); static int enc_ifdown(struct net_driver_s *dev); static int enc_txavail(struct net_driver_s *dev); -static int enc_rxavail(struct net_driver_s *dev); #ifdef CONFIG_NET_IGMP static int enc_addmac(struct net_driver_s *dev, FAR const uint8_t *mac); static int enc_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac); @@ -1497,16 +1491,11 @@ static void enc_rxdispatch(FAR struct enc_driver_s *priv) */ arp_ipin(&priv->dev); - ret = ipv4_input(&priv->dev); + (void)ipv4_input(&priv->dev); - if (ret == OK || (clock_systimer() - (systime_t)descr->ts) > ENC_RXTIMEOUT) - { - /* If packet has been successfully processed or has timed out, - * free it. - */ + /* Free the packet */ - enc_rxrmpkt(priv, descr); - } + enc_rxrmpkt(priv, descr); /* If the above function invocation resulted in data that should be * sent out on the network, the field d_len will set to a value > 0. @@ -1546,14 +1535,9 @@ static void enc_rxdispatch(FAR struct enc_driver_s *priv) ret = ipv6_input(&priv->dev); - if (ret == OK || (clock_systimer() - (systime_t)descr->ts) > ENC_RXTIMEOUT) - { - /* If packet has been successfully processed or has timed out, - * free it. - */ + /* Free the packet */ - enc_rxrmpkt(priv, descr); - } + enc_rxrmpkt(priv, descr); /* If the above function invocation resulted in data that should be * sent out on the network, the field d_len will set to a value > 0. @@ -1692,10 +1676,6 @@ static void enc_pktif(FAR struct enc_driver_s *priv) descr = enc_rxgetdescr(priv); - /* Set current timestamp */ - - descr->ts = (uint32_t)clock_systimer(); - /* Store the start address of the frame without the enc's header */ descr->addr = curpkt + 8; @@ -2391,38 +2371,6 @@ static int enc_txavail(struct net_driver_s *dev) return OK; } -/**************************************************************************** - * Name: enc_rxavail - * - * 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 in normal user mode - * - ****************************************************************************/ - -static int enc_rxavail(struct net_driver_s *dev) -{ - FAR struct enc_driver_s *priv = (FAR struct enc_driver_s *)dev->d_private; - - if (!sq_empty(&priv->rxqueue)) - { - ninfo("RX queue not empty, trying to dispatch\n"); - enc_rxdispatch(priv); - } - - return OK; -} - /**************************************************************************** * Name: enc_addmac * @@ -2858,7 +2806,6 @@ int enc_initialize(FAR struct spi_dev_s *spi, priv->dev.d_ifup = enc_ifup; /* I/F up (new IP address) callback */ priv->dev.d_ifdown = enc_ifdown; /* I/F down callback */ priv->dev.d_txavail = enc_txavail; /* New TX data callback */ - priv->dev.d_rxavail = enc_rxavail; /* RX wating callback */ #ifdef CONFIG_NET_IGMP priv->dev.d_addmac = enc_addmac; /* Add multicast MAC address */ priv->dev.d_rmmac = enc_rmmac; /* Remove multicast MAC address */ diff --git a/include/nuttx/net/netdev.h b/include/nuttx/net/netdev.h index ac30990ce05..0693dab1fb5 100644 --- a/include/nuttx/net/netdev.h +++ b/include/nuttx/net/netdev.h @@ -368,9 +368,6 @@ struct net_driver_s int (*d_ifup)(FAR struct net_driver_s *dev); int (*d_ifdown)(FAR struct net_driver_s *dev); int (*d_txavail)(FAR struct net_driver_s *dev); -#ifdef CONFIG_NET_RXAVAIL - int (*d_rxavail)(FAR struct net_driver_s *dev); -#endif #ifdef CONFIG_NET_IGMP int (*d_addmac)(FAR struct net_driver_s *dev, FAR const uint8_t *mac); int (*d_rmmac)(FAR struct net_driver_s *dev, FAR const uint8_t *mac); diff --git a/net/inet/inet_recvfrom.c b/net/inet/inet_recvfrom.c index a91cfc91b39..55a0c1e3207 100644 --- a/net/inet/inet_recvfrom.c +++ b/net/inet/inet_recvfrom.c @@ -1165,55 +1165,6 @@ static ssize_t inet_recvfrom_result(int result, struct inet_recvfrom_s *pstate) } #endif /* NET_UDP_HAVE_STACK || NET_TCP_HAVE_STACK */ -/**************************************************************************** - * Name: inet_udp_rxnotify - * - * Description: - * Notify the appropriate device driver that we are ready to receive a - * packet (UDP) - * - * Parameters: - * psock - Socket state structure - * conn - The UDP connection structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -#ifdef NET_UDP_HAVE_STACK -static inline void inet_udp_rxnotify(FAR struct socket *psock, - FAR struct udp_conn_s *conn) -{ -#ifdef CONFIG_NET_IPv4 -#ifdef CONFIG_NET_IPv6 - /* If both IPv4 and IPv6 support are enabled, then we will need to select - * the device driver using the appropriate IP domain. - */ - - if (psock->s_domain == PF_INET) -#endif - { - /* Notify the device driver of the receive ready */ - - netdev_ipv4_rxnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr); - } -#endif /* CONFIG_NET_IPv4 */ - -#ifdef CONFIG_NET_IPv6 -#ifdef CONFIG_NET_IPv4 - else /* if (psock->s_domain == PF_INET6) */ -#endif /* CONFIG_NET_IPv4 */ - { - /* Notify the device driver of the receive ready */ - - DEBUGASSERT(psock->s_domain == PF_INET6); - netdev_ipv6_rxnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr); - } -#endif /* CONFIG_NET_IPv6 */ -} -#endif /* NET_UDP_HAVE_STACK */ - /**************************************************************************** * Name: inet_udp_recvfrom * @@ -1323,10 +1274,6 @@ static ssize_t inet_udp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t state.ir_cb->priv = (FAR void *)&state; state.ir_cb->event = inet_udp_interrupt; - /* Notify the device driver of the receive call */ - - inet_udp_rxnotify(psock, conn); - /* Wait for either the receive to complete or for an error/timeout * to occur. NOTES: (1) net_lockedwait will also terminate if a * signal is received, (2) interrupts are disabled! They will be diff --git a/net/netdev/Make.defs b/net/netdev/Make.defs index 8a329b0e30c..3719861edae 100644 --- a/net/netdev/Make.defs +++ b/net/netdev/Make.defs @@ -41,10 +41,6 @@ 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_lladdrsize.c -ifeq ($(CONFIG_NET_RXAVAIL),y) -NETDEV_CSRCS += netdev_rxnotify.c -endif - # Include netdev build support DEPPATH += --dep-path netdev diff --git a/net/netdev/netdev.h b/net/netdev/netdev.h index 8e8311e3b46..fc1290d8459 100644 --- a/net/netdev/netdev.h +++ b/net/netdev/netdev.h @@ -323,65 +323,6 @@ void netdev_ipv6_txnotify(FAR const net_ipv6addr_t lipaddr, void netdev_txnotify_dev(FAR struct net_driver_s *dev); -/**************************************************************************** - * Name: netdev_ipv4_rxnotify - * - * Description: - * Notify the device driver that forwards the IPv4 address that the - * application waits for RX data. - * - * Parameters: - * lipaddr - The local board IPv6 address of the socket - * ripaddr - The remote IPv4 address to send the data - * - * Returned Value: - * None - * - * Assumptions: - * Called from normal user mode - * - ****************************************************************************/ - -#if CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET_RXAVAIL) - -#ifdef CONFIG_NET_IPv4 -void netdev_ipv4_rxnotify(in_addr_t lipaddr, in_addr_t ripaddr); -#endif /* CONFIG_NET_IPv4 */ - -/**************************************************************************** - * Name: netdev_ipv6_rxnotify - * - * Description: - * Notify the device driver that forwards the IPv6 address that the - * application waits for RX data. - * - * Parameters: - * lipaddr - The local board IPv6 address of the socket - * ripaddr - The remote IPv6 address to send the data - * - * Returned Value: - * None - * - * Assumptions: - * Called from normal user mode - * - ****************************************************************************/ - -#ifdef CONFIG_NET_IPv6 -void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t lipaddr, - FAR const net_ipv6addr_t ripaddr); -#endif /* CONFIG_NET_IPv6 */ - -#else -#ifdef CONFIG_NET_IPv4 -# define netdev_ipv4_rxnotify(lipaddr,ripaddr) -#endif /* CONFIG_NET_IPv4 */ - -#ifdef CONFIG_NET_IPv6 -# define netdev_ipv6_rxnotify(lipaddr,ripaddr) -#endif /* CONFIG_NET_IPv6 */ -#endif - /**************************************************************************** * Name: netdev_count * diff --git a/net/netdev/netdev_rxnotify.c b/net/netdev/netdev_rxnotify.c deleted file mode 100644 index b497788243c..00000000000 --- a/net/netdev/netdev_rxnotify.c +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** - * net/netdev/netdev_rxnotify.c - * - * Copyright (C) 2013-2015 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 -#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET_RXAVAIL) - -#include -#include -#include -#include - -#include -#include - -#include "netdev/netdev.h" - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: netdev_ipv4_rxnotify - * - * Description: - * Notify the device driver that forwards the IPv4 address that the - * application waits for RX data. - * - * Parameters: - * lipaddr - The local board IPv6 address of the socket - * ripaddr - The remote IPv4 address to send the data - * - * Returned Value: - * None - * - * Assumptions: - * Called from normal user mode - * - ****************************************************************************/ - -#ifdef CONFIG_NET_IPv4 -void netdev_ipv4_rxnotify(in_addr_t lipaddr, in_addr_t ripaddr) -{ - FAR struct net_driver_s *dev; - - /* Find the device driver that serves the subnet of the remote address */ - - dev = netdev_findby_ipv4addr(lipaddr, ripaddr); - if (dev && dev->d_rxavail) - { - /* Notify the device driver that new RX data is available. */ - - (void)dev->d_rxavail(dev); - } -} -#endif /* CONFIG_NET_IPv4 */ - -/**************************************************************************** - * Name: netdev_ipv6_rxnotify - * - * Description: - * Notify the device driver that forwards the IPv6 address that the - * application waits for RX data. - * - * Parameters: - * lipaddr - The local board IPv6 address of the socket - * ripaddr - The remote IPv6 address to send the data - * - * Returned Value: - * None - * - * Assumptions: - * Called from normal user mode - * - ****************************************************************************/ - -#ifdef CONFIG_NET_IPv6 -void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t lipaddr, - FAR const net_ipv6addr_t ripaddr) -{ - FAR struct net_driver_s *dev; - - /* Find the device driver that serves the subnet of the remote address */ - - dev = netdev_findby_ipv6addr(lipaddr, ripaddr); - if (dev && dev->d_rxavail) - { - /* Notify the device driver that new RX data is available. */ - - (void)dev->d_rxavail(dev); - } -} -#endif /* CONFIG_NET_IPv6 */ - -#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS && CONFIG_NET_RXAVAIL */ diff --git a/net/pkt/pkt_recvfrom.c b/net/pkt/pkt_recvfrom.c index eb4c79485a7..ccda96ec5a5 100644 --- a/net/pkt/pkt_recvfrom.c +++ b/net/pkt/pkt_recvfrom.c @@ -323,28 +323,6 @@ static ssize_t pkt_recvfrom_result(int result, struct pkt_recvfrom_s *pstate) return pstate->pr_recvlen; } -/**************************************************************************** - * Name: pkt_recvfrom_rxnotify - * - * Description: - * Notify the appropriate device driver that we are ready to receive a - * packet (PKT) - * - * Parameters: - * conn - The PKT connection structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -#if 0 /* Not implemented */ -static void pkt_recvfrom_rxnotify(FAR struct pkt_conn_s *conn) -{ -# warning Missing logic -} -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -447,12 +425,6 @@ ssize_t pkt_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, state.pr_cb->priv = (FAR void *)&state; state.pr_cb->event = pkt_recvfrom_interrupt; - /* Notify the device driver of the receive call */ - -#if 0 /* Not implemented */ - pkt_recvfrom_rxnotify(conn); -#endif - /* Wait for either the receive to complete or for an error/timeout to * occur. NOTES: (1) net_lockedwait will also terminate if a signal * is received, (2) the network is locked! It will be un-locked while diff --git a/net/udp/Kconfig b/net/udp/Kconfig index a4a16fde088..ba710b8629e 100644 --- a/net/udp/Kconfig +++ b/net/udp/Kconfig @@ -41,22 +41,6 @@ config NET_BROADCAST ---help--- Incoming UDP broadcast support -config NET_RXAVAIL - bool "Driver-based UDP backlog" - default n - ---help--- - One problem with UDP communications is that, unlike TCP/IP, there is - no backlog of UDP packets. So if you are listening at the precise - moment that the UDP packet is sent, it will not be received. This - is not incompatible with the properties of UDP, but can result in - bad performance if packets are missed, time out, and are resent. - - Some Ethernet controllers have built-in RAM and the drivers can - support retention of UDP packets in that RAM. If the drivers - supports such a capability, this option may be enabled to use it. - NOTE: If this option is enabled, the driver must support the - rxavail() method in the net_driver_s structure. - config NET_UDP_READAHEAD bool "Enable UDP/IP read-ahead buffering" default y