diff --git a/ChangeLog b/ChangeLog
index 9e0ca4b68aa..5f27953c96f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3274,4 +3274,10 @@
* Kconfig: Verify configuration settings for the LPC43xx. This includes
some corrections to configuration variable names and defconfig settings.
* Kconfig: Add and verify configuration settings for the LPC31xx.
-
+ * arch/arm/src/stm32/stm32_uart.h and stm32_serial.c: Add logic to
+ re-initialize the console UART as needed to enable DMA on the
+ console UART (contributed by Mike Smith).
+ * net/recvfrom.c, net/Kconfig, include/nuttx/net/uipopt.h: Remove delay
+ after receiving data. That has historical reasons to be there (it
+ was needed before read-ahead buffering was added), but kills performance.
+ (Noted by Max Holtzberg).
diff --git a/Documentation/NuttxPortingGuide.html b/Documentation/NuttxPortingGuide.html
index a03d9810fc8..b5473549ae0 100644
--- a/Documentation/NuttxPortingGuide.html
+++ b/Documentation/NuttxPortingGuide.html
@@ -5037,7 +5037,12 @@ build
CONFIG_NET_TCP_READAHEAD_BUFSIZE: Size of TCP read-ahead buffers
CONFIG_NET_NTCP_READAHEAD_BUFFERS: Number of TCP read-ahead buffers (may be zero)
+ CONFIG_NET_NTCP_READAHEAD_BUFFERS: Number of TCP read-ahead buffers (may be zero to disable TCP/IP read-ahead buffering)
+ CONFIG_NET_TCP_RECVDELAY: Delay (in deciseconds) after a TCP/IP packet is received.
+ This delay may allow catching of additional packets when TCP/IP read-ahead is disabled.
+ Default: 0
CONFIG_NET_MAX_LISTENPORTS: Maximum number of listening TCP ports (all tasks).
diff --git a/arch/arm/src/stm32/stm32_uart.h b/arch/arm/src/stm32/stm32_uart.h
index 7888d63163e..a70923cbf91 100644
--- a/arch/arm/src/stm32/stm32_uart.h
+++ b/arch/arm/src/stm32/stm32_uart.h
@@ -198,11 +198,11 @@
# define SERIAL_HAVE_CONSOLE_DMA 1
#elif defined(CONFIG_USART3_SERIAL_CONSOLE) && defined(CONFIG_USART3_RXDMA)
# define SERIAL_HAVE_CONSOLE_DMA 1
-#elif defined(CONFIG_UART4_SERIAL_CONSOLE) && !efined(CONFIG_UART4_RXDMA)
+#elif defined(CONFIG_UART4_SERIAL_CONSOLE) && defined(CONFIG_UART4_RXDMA)
# define SERIAL_HAVE_CONSOLE_DMA 1
#elif defined(CONFIG_UART5_SERIAL_CONSOLE) && defined(CONFIG_UART5_RXDMA)
# define SERIAL_HAVE_CONSOLE_DMA 1
-#elif defined(CONFIG_USART6_SERIAL_CONSOLE) && !efined(CONFIG_USART6_RXDMA)
+#elif defined(CONFIG_USART6_SERIAL_CONSOLE) && defined(CONFIG_USART6_RXDMA)
# define SERIAL_HAVE_CONSOLE_DMA 1
#endif
diff --git a/configs/README.txt b/configs/README.txt
index 7ad2825d0cb..6cd5eef3f94 100644
--- a/configs/README.txt
+++ b/configs/README.txt
@@ -990,7 +990,10 @@ defconfig -- This is a configuration file similar to the Linux
CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers
- (may be zero)
+ (may be zero to disable TCP/IP read-ahead buffering)
+ CONFIG_NET_TCP_RECVDELAY - Delay (in deciseconds) after a TCP/IP packet
+ is received. This delay may allow catching of additional packets
+ when TCP/IP read-ahead is disabled. Default: 0
CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until
accept() is called. The size of the backlog is selected when listen()
is called.
diff --git a/configs/olimex-stm32-p107/nsh/defconfig b/configs/olimex-stm32-p107/nsh/defconfig
index 18858d5df24..c7c71018aa8 100644
--- a/configs/olimex-stm32-p107/nsh/defconfig
+++ b/configs/olimex-stm32-p107/nsh/defconfig
@@ -365,7 +365,7 @@ CONFIG_NET_MULTICAST=n
#
# STM32F107vc Ethernet device driver settings
#
-CONFIG_STM32_PHYADDR=0x01
+CONFIG_STM32_PHYADDR=1
CONFIG_STM32_MII=n
CONFIG_STM32_RMII=y
CONFIG_STM32_RMII_MCO=y
diff --git a/configs/stm3220g-eval/dhcpd/defconfig b/configs/stm3220g-eval/dhcpd/defconfig
index 848121e04cf..433fe97d27f 100644
--- a/configs/stm3220g-eval/dhcpd/defconfig
+++ b/configs/stm3220g-eval/dhcpd/defconfig
@@ -197,7 +197,7 @@ CONFIG_CAN2_BAUD=700000
#
# STM32F20xxx Ethernet device driver settings
#
-CONFIG_STM32_PHYADDR=0x01
+CONFIG_STM32_PHYADDR=1
CONFIG_STM32_MII=y
CONFIG_STM32_MII_MCO1=y
CONFIG_STM32_MII_MCO2=n
diff --git a/configs/stm3220g-eval/nettest/defconfig b/configs/stm3220g-eval/nettest/defconfig
index 7e660ad027c..ef5c2da9649 100644
--- a/configs/stm3220g-eval/nettest/defconfig
+++ b/configs/stm3220g-eval/nettest/defconfig
@@ -197,7 +197,7 @@ CONFIG_CAN2_BAUD=700000
#
# STM32F20xxx Ethernet device driver settings
#
-CONFIG_STM32_PHYADDR=0x01
+CONFIG_STM32_PHYADDR=1
CONFIG_STM32_MII=y
CONFIG_STM32_MII_MCO1=y
CONFIG_STM32_MII_MCO2=n
diff --git a/configs/stm3220g-eval/nsh/defconfig b/configs/stm3220g-eval/nsh/defconfig
index 48912bd8b94..591f246163a 100644
--- a/configs/stm3220g-eval/nsh/defconfig
+++ b/configs/stm3220g-eval/nsh/defconfig
@@ -197,7 +197,7 @@ CONFIG_CAN2_BAUD=700000
#
# STM32F20xxx Ethernet device driver settings
#
-CONFIG_STM32_PHYADDR=0x01
+CONFIG_STM32_PHYADDR=1
CONFIG_STM32_MII=y
CONFIG_STM32_MII_MCO1=y
CONFIG_STM32_MII_MCO2=n
diff --git a/configs/stm3220g-eval/nsh2/defconfig b/configs/stm3220g-eval/nsh2/defconfig
index c2ede9c67f4..03ee777f4f8 100644
--- a/configs/stm3220g-eval/nsh2/defconfig
+++ b/configs/stm3220g-eval/nsh2/defconfig
@@ -197,7 +197,7 @@ CONFIG_CAN2_BAUD=700000
#
# STM32F20xxx Ethernet device driver settings
#
-CONFIG_STM32_PHYADDR=0x01
+CONFIG_STM32_PHYADDR=1
CONFIG_STM32_MII=y
CONFIG_STM32_MII_MCO1=y
CONFIG_STM32_MII_MCO2=n
diff --git a/configs/stm3220g-eval/nxwm/defconfig b/configs/stm3220g-eval/nxwm/defconfig
index 6e69333255b..bd59f47de9a 100644
--- a/configs/stm3220g-eval/nxwm/defconfig
+++ b/configs/stm3220g-eval/nxwm/defconfig
@@ -197,7 +197,7 @@ CONFIG_CAN2_BAUD=700000
#
# STM32F20xxx Ethernet device driver settings
#
-CONFIG_STM32_PHYADDR=0x01
+CONFIG_STM32_PHYADDR=1
CONFIG_STM32_MII=y
CONFIG_STM32_MII_MCO1=y
CONFIG_STM32_MII_MCO2=n
diff --git a/configs/stm3220g-eval/ostest/defconfig b/configs/stm3220g-eval/ostest/defconfig
index d0ace11bce7..30ec69419dc 100644
--- a/configs/stm3220g-eval/ostest/defconfig
+++ b/configs/stm3220g-eval/ostest/defconfig
@@ -197,7 +197,7 @@ CONFIG_CAN2_BAUD=700000
#
# STM32F20xxx Ethernet device driver settings
#
-CONFIG_STM32_PHYADDR=0x01
+CONFIG_STM32_PHYADDR=1
CONFIG_STM32_MII=y
CONFIG_STM32_MII_MCO1=y
CONFIG_STM32_MII_MCO2=n
diff --git a/configs/stm3220g-eval/telnetd/defconfig b/configs/stm3220g-eval/telnetd/defconfig
index 2ff215afcfa..550f654ba01 100644
--- a/configs/stm3220g-eval/telnetd/defconfig
+++ b/configs/stm3220g-eval/telnetd/defconfig
@@ -197,7 +197,7 @@ CONFIG_CAN2_BAUD=700000
#
# STM32F20xxx Ethernet device driver settings
#
-CONFIG_STM32_PHYADDR=0x01
+CONFIG_STM32_PHYADDR=1
CONFIG_STM32_MII=y
CONFIG_STM32_MII_MCO1=y
CONFIG_STM32_MII_MCO2=n
diff --git a/configs/stm3240g-eval/dhcpd/defconfig b/configs/stm3240g-eval/dhcpd/defconfig
index 382ce61553d..4e22244bb51 100644
--- a/configs/stm3240g-eval/dhcpd/defconfig
+++ b/configs/stm3240g-eval/dhcpd/defconfig
@@ -203,7 +203,7 @@ CONFIG_CAN2_BAUD=700000
#
# STM32F40xxx Ethernet device driver settings
#
-CONFIG_STM32_PHYADDR=0x01
+CONFIG_STM32_PHYADDR=1
CONFIG_STM32_MII=y
CONFIG_STM32_MII_MCO1=y
CONFIG_STM32_MII_MCO2=n
diff --git a/configs/stm3240g-eval/nettest/defconfig b/configs/stm3240g-eval/nettest/defconfig
index 9eb8f3d5ce3..e21c1070bd2 100644
--- a/configs/stm3240g-eval/nettest/defconfig
+++ b/configs/stm3240g-eval/nettest/defconfig
@@ -203,7 +203,7 @@ CONFIG_CAN2_BAUD=700000
#
# STM32F40xxx Ethernet device driver settings
#
-CONFIG_STM32_PHYADDR=0x01
+CONFIG_STM32_PHYADDR=1
CONFIG_STM32_MII=y
CONFIG_STM32_MII_MCO1=y
CONFIG_STM32_MII_MCO2=n
diff --git a/configs/stm3240g-eval/nsh/defconfig b/configs/stm3240g-eval/nsh/defconfig
index 8b2617ec053..34f84db0743 100644
--- a/configs/stm3240g-eval/nsh/defconfig
+++ b/configs/stm3240g-eval/nsh/defconfig
@@ -203,7 +203,7 @@ CONFIG_CAN2_BAUD=700000
#
# STM32F40xxx Ethernet device driver settings
#
-CONFIG_STM32_PHYADDR=0x01
+CONFIG_STM32_PHYADDR=1
CONFIG_STM32_MII=y
CONFIG_STM32_MII_MCO1=y
CONFIG_STM32_MII_MCO2=n
diff --git a/configs/stm3240g-eval/nsh2/defconfig b/configs/stm3240g-eval/nsh2/defconfig
index 00d9dac0a2f..dfb837e8a59 100644
--- a/configs/stm3240g-eval/nsh2/defconfig
+++ b/configs/stm3240g-eval/nsh2/defconfig
@@ -204,7 +204,7 @@ CONFIG_CAN2_BAUD=700000
#
# STM32F40xxx Ethernet device driver settings
#
-CONFIG_STM32_PHYADDR=0x01
+CONFIG_STM32_PHYADDR=1
CONFIG_STM32_MII=y
CONFIG_STM32_MII_MCO1=y
CONFIG_STM32_MII_MCO2=n
diff --git a/configs/stm3240g-eval/nxconsole/defconfig b/configs/stm3240g-eval/nxconsole/defconfig
index 172d17b6fff..417201f3ea7 100644
--- a/configs/stm3240g-eval/nxconsole/defconfig
+++ b/configs/stm3240g-eval/nxconsole/defconfig
@@ -203,7 +203,7 @@ CONFIG_CAN2_BAUD=700000
#
# STM32F40xxx Ethernet device driver settings
#
-CONFIG_STM32_PHYADDR=0x01
+CONFIG_STM32_PHYADDR=1
CONFIG_STM32_MII=y
CONFIG_STM32_MII_MCO1=y
CONFIG_STM32_MII_MCO2=n
diff --git a/configs/stm3240g-eval/nxwm/defconfig b/configs/stm3240g-eval/nxwm/defconfig
index 07bc408dcc7..88d3ecb8d31 100644
--- a/configs/stm3240g-eval/nxwm/defconfig
+++ b/configs/stm3240g-eval/nxwm/defconfig
@@ -203,7 +203,7 @@ CONFIG_CAN2_BAUD=700000
#
# STM32F40xxx Ethernet device driver settings
#
-CONFIG_STM32_PHYADDR=0x01
+CONFIG_STM32_PHYADDR=1
CONFIG_STM32_MII=y
CONFIG_STM32_MII_MCO1=y
CONFIG_STM32_MII_MCO2=n
diff --git a/configs/stm3240g-eval/ostest/defconfig b/configs/stm3240g-eval/ostest/defconfig
index 1f23047306e..2b95735bb4b 100644
--- a/configs/stm3240g-eval/ostest/defconfig
+++ b/configs/stm3240g-eval/ostest/defconfig
@@ -203,7 +203,7 @@ CONFIG_CAN2_BAUD=700000
#
# STM32F40xxx Ethernet device driver settings
#
-CONFIG_STM32_PHYADDR=0x01
+CONFIG_STM32_PHYADDR=1
CONFIG_STM32_MII=y
CONFIG_STM32_MII_MCO1=y
CONFIG_STM32_MII_MCO2=n
diff --git a/configs/stm3240g-eval/telnetd/defconfig b/configs/stm3240g-eval/telnetd/defconfig
index 44a0f27baa5..9dc5bfc28fd 100644
--- a/configs/stm3240g-eval/telnetd/defconfig
+++ b/configs/stm3240g-eval/telnetd/defconfig
@@ -203,7 +203,7 @@ CONFIG_CAN2_BAUD=700000
#
# STM32F40xxx Ethernet device driver settings
#
-CONFIG_STM32_PHYADDR=0x01
+CONFIG_STM32_PHYADDR=1
CONFIG_STM32_MII=y
CONFIG_STM32_MII_MCO1=y
CONFIG_STM32_MII_MCO2=n
diff --git a/configs/stm3240g-eval/webserver/defconfig b/configs/stm3240g-eval/webserver/defconfig
index 7bd8e52ceb5..8f3ea36dc74 100644
--- a/configs/stm3240g-eval/webserver/defconfig
+++ b/configs/stm3240g-eval/webserver/defconfig
@@ -203,7 +203,7 @@ CONFIG_CAN2_BAUD=700000
#
# STM32F40xxx Ethernet device driver settings
#
-CONFIG_STM32_PHYADDR=0x01
+CONFIG_STM32_PHYADDR=1
CONFIG_STM32_MII=y
CONFIG_STM32_MII_MCO1=y
CONFIG_STM32_MII_MCO2=n
diff --git a/configs/stm32f4discovery/nsh/defconfig b/configs/stm32f4discovery/nsh/defconfig
index 0a07e848954..12848ddee82 100644
--- a/configs/stm32f4discovery/nsh/defconfig
+++ b/configs/stm32f4discovery/nsh/defconfig
@@ -197,7 +197,7 @@ CONFIG_CAN2_BAUD=700000
#
# STM32F40xxx Ethernet device driver settings
#
-CONFIG_STM32_PHYADDR=0x01
+CONFIG_STM32_PHYADDR=1
CONFIG_STM32_MII=y
CONFIG_STM32_MII_MCO1=y
CONFIG_STM32_MII_MCO2=n
diff --git a/configs/stm32f4discovery/nxlines/defconfig b/configs/stm32f4discovery/nxlines/defconfig
index 52705977ab9..f99af0233d2 100644
--- a/configs/stm32f4discovery/nxlines/defconfig
+++ b/configs/stm32f4discovery/nxlines/defconfig
@@ -197,7 +197,7 @@ CONFIG_CAN2_BAUD=700000
#
# STM32F40xxx Ethernet device driver settings
#
-CONFIG_STM32_PHYADDR=0x01
+CONFIG_STM32_PHYADDR=1
CONFIG_STM32_MII=y
CONFIG_STM32_MII_MCO1=y
CONFIG_STM32_MII_MCO2=n
diff --git a/configs/stm32f4discovery/ostest/defconfig b/configs/stm32f4discovery/ostest/defconfig
index 5c120c61445..8657d7edfda 100644
--- a/configs/stm32f4discovery/ostest/defconfig
+++ b/configs/stm32f4discovery/ostest/defconfig
@@ -192,7 +192,7 @@ CONFIG_CAN2_BAUD=700000
#
# STM32F40xxx Ethernet device driver settings
#
-CONFIG_STM32_PHYADDR=0x01
+CONFIG_STM32_PHYADDR=1
CONFIG_STM32_MII=y
CONFIG_STM32_MII_MCO1=y
CONFIG_STM32_MII_MCO2=n
diff --git a/configs/stm32f4discovery/pm/defconfig b/configs/stm32f4discovery/pm/defconfig
index 592ce5701c7..4608c16c680 100644
--- a/configs/stm32f4discovery/pm/defconfig
+++ b/configs/stm32f4discovery/pm/defconfig
@@ -198,7 +198,7 @@ CONFIG_CAN2_BAUD=700000
#
# STM32F40xxx Ethernet device driver settings
#
-CONFIG_STM32_PHYADDR=0x01
+CONFIG_STM32_PHYADDR=1
CONFIG_STM32_MII=y
CONFIG_STM32_MII_MCO1=y
CONFIG_STM32_MII_MCO2=n
diff --git a/include/nuttx/net/uip/uipopt.h b/include/nuttx/net/uip/uipopt.h
index 4eff56fe853..9797e0482b8 100644
--- a/include/nuttx/net/uip/uipopt.h
+++ b/include/nuttx/net/uip/uipopt.h
@@ -296,7 +296,23 @@
/* The size of the TCP read buffer size */
#ifndef CONFIG_NET_TCP_READAHEAD_BUFSIZE
-# define CONFIG_NET_TCP_READAHEAD_BUFSIZE UIP_TCP_MSS
+# if CONFIG_NET_NTCP_READAHEAD_BUFFERS < 1
+# define CONFIG_NET_TCP_READAHEAD_BUFSIZE 0
+# else
+# define CONFIG_NET_TCP_READAHEAD_BUFSIZE UIP_TCP_MSS
+# endif
+#endif
+
+/* Delay after receive to catch a following packet. No delay should be
+ * required if TCP/IP read-ahead buffering is enabled.
+ */
+
+#ifndef CONFIG_NET_TCP_RECVDELAY
+# if CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0
+# define CONFIG_NET_TCP_RECVDELAY 0
+# else
+# define CONFIG_NET_TCP_RECVDELAY 5
+# endif
#endif
/****************************************************************************
diff --git a/net/Kconfig b/net/Kconfig
index b6e10a2e0f6..3d39dc1d7bc 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -112,16 +112,43 @@ config NET_MAX_LISTENPORTS
Maximum number of listening TCP/IP ports (all tasks). Default: 20
config NET_TCP_READAHEAD_BUFSIZE
- bool "TCP/IP read-ahead buffer size"
+ int "TCP/IP read-ahead buffer size"
default 562
---help---
- Size of TCP/IP read-ahead buffers
+ Read-ahead buffers allows buffering of TCP/IP packets when there is no
+ receive in place to catch the TCP packet. In that case, the packet
+ will be retained in the NuttX read-ahead buffers.
+
+ This setting specifies the size of one TCP/IP read-ahead buffer.
+ This should best be a equal to the maximum packet size (NET_BUFSIZE).
config NET_NTCP_READAHEAD_BUFFERS
int "Number of TCP/IP read-ahead buffers"
default 8
---help---
- Number of TCP/IP read-ahead buffers (may be zero)
+ Read-ahead buffers allows buffering of TCP/IP packets when there is no
+ receive in place to catch the TCP packet. In that case, the packet
+ will be retained in the NuttX read-ahead buffers.
+
+ This setting specifies the number of TCP/IP read-ahead buffers This
+ value can be set to zero to disable all TCP/IP read-ahead buffering.
+ You might want to disable TCP/IP read-ahead buffering on a highly
+ memory constained system that does not have any TCP/IP packet rate
+ issues.
+
+config NET_TCP_RECVDELAY
+ int "TCP Rx delay"
+ default 0
+ ---help---
+ If NET_NTCP_READAHEAD_BUFFERS is zero, then there will be no buffering
+ of TCP/IP packets: Any TCP/IP packet received will be ACKed, but its contents
+ will be dropped in the bit-bucket.
+
+ One low-performance option is delay for a short period of time after a
+ TCP/IP packet is received to see if another comes right behind it. Then
+ the packet data from both can be combined. This option only makes since
+ if performance is not an issue and you need to handle short bursts of
+ small, back-to-back packets. The delay is in units of deciseconds.
config NET_TCPBACKLOG
bool "TCP/IP backlog support"
diff --git a/net/recvfrom.c b/net/recvfrom.c
index 741cd4c7279..6b9eb9a9084 100644
--- a/net/recvfrom.c
+++ b/net/recvfrom.c
@@ -59,8 +59,6 @@
* Definitions
****************************************************************************/
-#define TCP_TIMEO 10 /* Deciseconds after data received before recv() returns */
-
#define UDPBUF ((struct uip_udpip_hdr *)&dev->d_buf[UIP_LLH_LEN])
#define TCPBUF ((struct uip_tcpip_hdr *)&dev->d_buf[UIP_LLH_LEN])
@@ -354,31 +352,39 @@ static int recvfrom_timeout(struct recvfrom_s *pstate)
FAR struct socket *psock = 0;
socktimeo_t timeo = 0;
- /* If this is a TCP socket that has already received some data,
- * than we will always use a short timeout.
+ /* Check for a timeout configured via setsockopts(SO_RCVTIMEO). If none...
+ * we well let the read hang forever (except for the special case below).
*/
- if (pstate->rf_recvlen > 0)
- {
- /* Use the short timeout */
+ /* Get the socket reference from the private data */
- timeo = TCP_TIMEO;
+ psock = pstate->rf_sock;
+ if (psock)
+ {
+ /* Recover the timeout value (zero if no timeout) */
+
+ timeo = psock->s_rcvtimeo;
}
- /* No.. check for a timeout configured via setsockopts(SO_RCVTIMEO).
- * If none... we well let the read hang forever.
+ /* Use a fixed, configurable delay under the following circumstances:
+ *
+ * 1) This delay function has been enabled with CONFIG_NET_TCP_RECVDELAY > 0
+ * 2) Some data has already been received from the socket. Since this can
+ * only be true for a TCP/IP socket, this logic applies only to TCP/IP
+ * sockets, and either
+ * 3) There is no configured receive timeout, or
+ * 4) The configured receive timeout is greater than than the delay
*/
- else
+#if CONFIG_NET_TCP_RECVDELAY > 0
+ if ((timeo == 0 || timeo > CONFIG_NET_TCP_RECVDELAY) &&
+ pstate->rf_recvlen > 0)
{
- /* Get the socket reference from the private data */
+ /* Use the configured timeout */
- psock = pstate->rf_sock;
- if (psock)
- {
- timeo = psock->s_rcvtimeo;
- }
+ timeo = CONFIG_NET_TCP_RECVDELAY;
}
+#endif
/* Is there an effective timeout? */
@@ -389,7 +395,7 @@ static int recvfrom_timeout(struct recvfrom_s *pstate)
return net_timeo(pstate->rf_starttime, timeo);
}
- /* No timeout */
+ /* No timeout -- hang forever waiting for data. */
return FALSE;
}
@@ -489,9 +495,28 @@ static uint16_t recvfrom_tcpinterrupt(struct uip_driver_s *dev, void *conn,
flags = (flags & ~UIP_NEWDATA) | UIP_SNDACK;
- /* If the user buffer has been filled, then we are finished. */
+ /* Check for transfer complete. We will consider the transfer
+ * complete in own of two different ways, depending on the setting
+ * of CONFIG_NET_TCP_RECVDELAY.
+ *
+ * 1) If CONFIG_NET_TCP_RECVDELAY == 0 then we will consider the
+ * TCP/IP transfer complete as soon as any data has been received.
+ * This is safe because if any additional data is received, it
+ * will be retained inthe TCP/IP read-ahead buffer until the
+ * next receive is performed.
+ * 2) CONFIG_NET_TCP_RECVDELAY > 0 may be set to wait a little
+ * bit to determine if more data will be received. You might
+ * do this if read-ahead buffereing is disabled and we want to
+ * minimize the loss of back-to-back packets. In this case,
+ * the transfer is complete when either a) the entire user buffer
+ * is full or 2) when the receive timeout occurs (below).
+ */
+#if CONFIG_NET_TCP_RECVDELAY > 0
if (pstate->rf_buflen == 0)
+#else
+ if (pstate->rf_recvlen > 0)
+#endif
{
nllvdbg("TCP resume\n");