Add configuration support for TCP Write Buffering

This commit is contained in:
Gregory Nutt 2014-01-13 14:40:21 -06:00
parent f47b3d04d9
commit 486314ad05
3 changed files with 85 additions and 16 deletions

View File

@ -294,7 +294,7 @@
# define CONFIG_NET_NTCP_READAHEAD_BUFFERS 4
# endif
/* The size of the TCP read buffer size */
/* The size of one TCP read buffer */
# ifndef CONFIG_NET_TCP_READAHEAD_BUFSIZE
# define CONFIG_NET_TCP_READAHEAD_BUFSIZE UIP_TCP_MSS
@ -305,6 +305,24 @@
# undef CONFIG_NET_NTCP_READAHEAD_BUFFERS
#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
* required if TCP/IP read-ahead buffering is enabled.
*/

View File

@ -103,6 +103,7 @@ config NET_TCP
TCP support on or off
if NET_TCP
config NET_TCP_CONNS
int "Number of TCP/IP connections"
default 8
@ -118,6 +119,14 @@ config NET_MAX_LISTENPORTS
config NET_TCP_READAHEAD
bool "Enabled TCP/IP read-ahead buffering"
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
@ -140,14 +149,43 @@ config NET_NTCP_READAHEAD_BUFFERS
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.
This setting specifies the number of TCP/IP read-ahead buffers.
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
int "TCP Rx delay"
default 0

View File

@ -47,17 +47,30 @@
#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
****************************************************************************/
/* 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];
/* This is the list of available read-ahead buffers */
static sq_queue_t g_freebuffers;
static struct readahead_s g_readahead;
/****************************************************************************
* Private Functions
@ -82,10 +95,10 @@ void uip_tcpreadaheadinit(void)
{
int i;
sq_init(&g_freebuffers);
sq_init(&g_readahead.freebuffers);
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)
{
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)
{
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 */