mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
Add configuration support for TCP Write Buffering
This commit is contained in:
@@ -294,7 +294,7 @@
|
|||||||
# define CONFIG_NET_NTCP_READAHEAD_BUFFERS 4
|
# define CONFIG_NET_NTCP_READAHEAD_BUFFERS 4
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/* The size of the TCP read buffer size */
|
/* The size of one TCP read buffer */
|
||||||
|
|
||||||
# ifndef CONFIG_NET_TCP_READAHEAD_BUFSIZE
|
# ifndef CONFIG_NET_TCP_READAHEAD_BUFSIZE
|
||||||
# define CONFIG_NET_TCP_READAHEAD_BUFSIZE UIP_TCP_MSS
|
# define CONFIG_NET_TCP_READAHEAD_BUFSIZE UIP_TCP_MSS
|
||||||
@@ -305,6 +305,24 @@
|
|||||||
# undef CONFIG_NET_NTCP_READAHEAD_BUFFERS
|
# undef CONFIG_NET_NTCP_READAHEAD_BUFFERS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
|
||||||
|
/* Number of TCP write buffers */
|
||||||
|
|
||||||
|
# ifndef CONFIG_NET_NTCP_WRITE_BUFFERS
|
||||||
|
# define CONFIG_NET_NTCP_WRITE_BUFFERS 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* The size of one TCP write buffer */
|
||||||
|
|
||||||
|
# ifndef CONFIG_NET_TCP_WRITE_BUFSIZE
|
||||||
|
# define CONFIG_NET_TCP_WRITE_BUFSIZE UIP_TCP_MSS
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
# undef CONFIG_NET_TCP_WRITE_BUFSIZE
|
||||||
|
# undef CONFIG_NET_NTCP_WRITE_BUFFERS
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Delay after receive to catch a following packet. No delay should be
|
/* Delay after receive to catch a following packet. No delay should be
|
||||||
* required if TCP/IP read-ahead buffering is enabled.
|
* required if TCP/IP read-ahead buffering is enabled.
|
||||||
*/
|
*/
|
||||||
|
|||||||
+43
-5
@@ -103,6 +103,7 @@ config NET_TCP
|
|||||||
TCP support on or off
|
TCP support on or off
|
||||||
|
|
||||||
if NET_TCP
|
if NET_TCP
|
||||||
|
|
||||||
config NET_TCP_CONNS
|
config NET_TCP_CONNS
|
||||||
int "Number of TCP/IP connections"
|
int "Number of TCP/IP connections"
|
||||||
default 8
|
default 8
|
||||||
@@ -118,6 +119,14 @@ config NET_MAX_LISTENPORTS
|
|||||||
config NET_TCP_READAHEAD
|
config NET_TCP_READAHEAD
|
||||||
bool "Enabled TCP/IP read-ahead buffering"
|
bool "Enabled TCP/IP read-ahead buffering"
|
||||||
default y
|
default y
|
||||||
|
---help---
|
||||||
|
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.
|
||||||
|
|
||||||
|
You might want to disable TCP/IP read-ahead buffering on a highly
|
||||||
|
memory constrained system that does not have any TCP/IP packet rate
|
||||||
|
issues.
|
||||||
|
|
||||||
if NET_TCP_READAHEAD
|
if NET_TCP_READAHEAD
|
||||||
|
|
||||||
@@ -140,14 +149,43 @@ config NET_NTCP_READAHEAD_BUFFERS
|
|||||||
receive in place to catch the TCP packet. In that case, the packet
|
receive in place to catch the TCP packet. In that case, the packet
|
||||||
will be retained in the NuttX read-ahead buffers.
|
will be retained in the NuttX read-ahead buffers.
|
||||||
|
|
||||||
This setting specifies the number of TCP/IP read-ahead buffers This
|
This setting specifies the number of TCP/IP read-ahead buffers.
|
||||||
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.
|
|
||||||
|
|
||||||
endif # NET_TCP_READAHEAD
|
endif # NET_TCP_READAHEAD
|
||||||
|
|
||||||
|
config NET_TCP_WRITE_BUFFERS
|
||||||
|
bool "Enabled TCP/IP write buffering"
|
||||||
|
default n
|
||||||
|
---help---
|
||||||
|
Write buffers allows buffering of ongoing TCP/IP packets, providing
|
||||||
|
for higher performance, streamed output.
|
||||||
|
|
||||||
|
You might want to disable TCP/IP write buffering on a highly memory
|
||||||
|
memory constrained system where there are no performance issues.
|
||||||
|
|
||||||
|
if NET_TCP_WRITE_BUFFERS
|
||||||
|
|
||||||
|
config NET_TCP_WRITE_BUFSIZE
|
||||||
|
int "TCP/IP write buffer size"
|
||||||
|
default 562
|
||||||
|
---help---
|
||||||
|
Write buffers allows buffering of ongoing TCP/IP packets, providing
|
||||||
|
for higher performance, streamed output.
|
||||||
|
|
||||||
|
This setting specifies the size of one TCP/IP write buffer. This
|
||||||
|
should best be a equal to the maximum packet size (NET_BUFSIZE).
|
||||||
|
|
||||||
|
config NET_NTCP_WRITE_BUFFERS
|
||||||
|
int "Number of TCP/IP write buffers"
|
||||||
|
default 8
|
||||||
|
---help---
|
||||||
|
Write buffers allows buffering of ongoing TCP/IP packets, providing
|
||||||
|
for higher performance, streamed output.
|
||||||
|
|
||||||
|
This setting specifies the number of TCP/IP write buffers.
|
||||||
|
|
||||||
|
endif # NET_TCP_WRITE_BUFFERS
|
||||||
|
|
||||||
config NET_TCP_RECVDELAY
|
config NET_TCP_RECVDELAY
|
||||||
int "TCP Rx delay"
|
int "TCP Rx delay"
|
||||||
default 0
|
default 0
|
||||||
|
|||||||
+23
-10
@@ -47,17 +47,30 @@
|
|||||||
|
|
||||||
#include "uip_internal.h"
|
#include "uip_internal.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* Package all globals used by this logic into a structure */
|
||||||
|
|
||||||
|
struct readahead_s
|
||||||
|
{
|
||||||
|
/* This is the list of available write buffers */
|
||||||
|
|
||||||
|
sq_queue_t freebuffers;
|
||||||
|
|
||||||
|
/* These are the pre-allocated write buffers */
|
||||||
|
|
||||||
|
struct uip_readahead_s buffers[CONFIG_NET_NTCP_READAHEAD_BUFFERS];
|
||||||
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* These are the pre-allocated read-ahead buffers */
|
/* This is the state of the global read-ahead resource */
|
||||||
|
|
||||||
static struct uip_readahead_s g_buffers[CONFIG_NET_NTCP_READAHEAD_BUFFERS];
|
static struct readahead_s g_readahead;
|
||||||
|
|
||||||
/* This is the list of available read-ahead buffers */
|
|
||||||
|
|
||||||
static sq_queue_t g_freebuffers;
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
@@ -82,10 +95,10 @@ void uip_tcpreadaheadinit(void)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
sq_init(&g_freebuffers);
|
sq_init(&g_readahead.freebuffers);
|
||||||
for (i = 0; i < CONFIG_NET_NTCP_READAHEAD_BUFFERS; i++)
|
for (i = 0; i < CONFIG_NET_NTCP_READAHEAD_BUFFERS; i++)
|
||||||
{
|
{
|
||||||
sq_addfirst(&g_buffers[i].rh_node, &g_freebuffers);
|
sq_addfirst(&g_readahead.buffers[i].rh_node, &g_readahead.freebuffers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +119,7 @@ void uip_tcpreadaheadinit(void)
|
|||||||
|
|
||||||
struct uip_readahead_s *uip_tcpreadaheadalloc(void)
|
struct uip_readahead_s *uip_tcpreadaheadalloc(void)
|
||||||
{
|
{
|
||||||
return (struct uip_readahead_s*)sq_remfirst(&g_freebuffers);
|
return (struct uip_readahead_s*)sq_remfirst(&g_readahead.freebuffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -124,7 +137,7 @@ struct uip_readahead_s *uip_tcpreadaheadalloc(void)
|
|||||||
|
|
||||||
void uip_tcpreadaheadrelease(struct uip_readahead_s *buf)
|
void uip_tcpreadaheadrelease(struct uip_readahead_s *buf)
|
||||||
{
|
{
|
||||||
sq_addfirst(&buf->rh_node, &g_freebuffers);
|
sq_addfirst(&buf->rh_node, &g_readahead.freebuffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_NET && CONFIG_NET_TCP && CONFIG_NET_TCP_READAHEAD */
|
#endif /* CONFIG_NET && CONFIG_NET_TCP && CONFIG_NET_TCP_READAHEAD */
|
||||||
|
|||||||
Reference in New Issue
Block a user