More TCP write buffer code. Part of big change from Jason Jiang

This commit is contained in:
Gregory Nutt 2014-01-13 17:26:11 -06:00
parent a9e44cdfe0
commit 375b683860

View File

@ -306,7 +306,10 @@ void uip_tcpfree(struct uip_conn *conn)
FAR struct uip_callback_s *cb; FAR struct uip_callback_s *cb;
FAR struct uip_callback_s *next; FAR struct uip_callback_s *next;
#ifdef CONFIG_NET_TCP_READAHEAD #ifdef CONFIG_NET_TCP_READAHEAD
struct uip_readahead_s *readahead; FAR struct uip_readahead_s *readahead;
#endif
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
FAR struct uip_wrbuffer_s *wrbuffer;
#endif #endif
uip_lock_t flags; uip_lock_t flags;
@ -339,18 +342,32 @@ void uip_tcpfree(struct uip_conn *conn)
dq_rem(&conn->node, &g_active_tcp_connections); dq_rem(&conn->node, &g_active_tcp_connections);
} }
#ifdef CONFIG_NET_TCP_READAHEAD
/* Release any read-ahead buffers attached to the connection */ /* Release any read-ahead buffers attached to the connection */
#ifdef CONFIG_NET_TCP_READAHEAD
while ((readahead = (struct uip_readahead_s *)sq_remfirst(&conn->readahead)) != NULL) while ((readahead = (struct uip_readahead_s *)sq_remfirst(&conn->readahead)) != NULL)
{ {
uip_tcpreadaheadrelease(readahead); uip_tcpreadaheadrelease(readahead);
} }
#endif #endif
/* Remove any backlog attached to this connection */ #ifdef CONFIG_NET_TCP_WRITE_BUFFERS
/* Release any write buffers attached to the connection */
while ((wrbuffer = (struct uip_wrbuffer_s *)sq_remfirst(&conn->write_q)) != NULL)
{
uip_tcpwrbuffer_release(wrbuffer);
}
while ((wrbuffer = (struct uip_wrbuffer_s *)sq_remfirst(&conn->unacked_q)) != NULL)
{
uip_tcpwrbuffer_release(wrbuffer);
}
#endif
#ifdef CONFIG_NET_TCPBACKLOG #ifdef CONFIG_NET_TCPBACKLOG
/* Remove any backlog attached to this connection */
if (conn->backlog) if (conn->backlog)
{ {
uip_backlogdestroy(conn); uip_backlogdestroy(conn);
@ -503,17 +520,29 @@ struct uip_conn *uip_tcpaccept(struct uip_tcpip_hdr *buf)
uip_tcpinitsequence(conn->sndseq); uip_tcpinitsequence(conn->sndseq);
conn->unacked = 1; conn->unacked = 1;
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
conn->expired = 0;
conn->isn = 0;
conn->sent = 0;
#endif
/* rcvseq should be the seqno from the incoming packet + 1. */ /* rcvseq should be the seqno from the incoming packet + 1. */
memcpy(conn->rcvseq, buf->seqno, 4); memcpy(conn->rcvseq, buf->seqno, 4);
#ifdef CONFIG_NET_TCP_READAHEAD
/* Initialize the list of TCP read-ahead buffers */ /* Initialize the list of TCP read-ahead buffers */
#ifdef CONFIG_NET_TCP_READAHEAD
sq_init(&conn->readahead); sq_init(&conn->readahead);
#endif #endif
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
/* Initialize the write buffer lists */
sq_init(&conn->write_q);
sq_init(&conn->unacked_q);
#endif
/* And, finally, put the connection structure into the active list. /* And, finally, put the connection structure into the active list.
* Interrupts should already be disabled in this context. * Interrupts should already be disabled in this context.
*/ */
@ -642,6 +671,11 @@ int uip_tcpconnect(struct uip_conn *conn, const struct sockaddr_in *addr)
conn->sa = 0; conn->sa = 0;
conn->sv = 16; /* Initial value of the RTT variance. */ conn->sv = 16; /* Initial value of the RTT variance. */
conn->lport = htons((uint16_t)port); conn->lport = htons((uint16_t)port);
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
conn->expired = 0;
conn->isn = 0;
conn->sent = 0;
#endif
/* The sockaddr port is 16 bits and already in network order */ /* The sockaddr port is 16 bits and already in network order */
@ -651,12 +685,19 @@ int uip_tcpconnect(struct uip_conn *conn, const struct sockaddr_in *addr)
uip_ipaddr_copy(conn->ripaddr, addr->sin_addr.s_addr); uip_ipaddr_copy(conn->ripaddr, addr->sin_addr.s_addr);
#ifdef CONFIG_NET_TCP_READAHEAD
/* Initialize the list of TCP read-ahead buffers */ /* Initialize the list of TCP read-ahead buffers */
#ifdef CONFIG_NET_TCP_READAHEAD
sq_init(&conn->readahead); sq_init(&conn->readahead);
#endif #endif
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
/* Initialize the TCP write buffer lists */
sq_init(&conn->write_q);
sq_init(&conn->unacked_q);
#endif
/* And, finally, put the connection structure into the active /* And, finally, put the connection structure into the active
* list. Because g_active_tcp_connections is accessed from user level and * list. Because g_active_tcp_connections is accessed from user level and
* interrupt level, code, it is necessary to keep interrupts disabled during * interrupt level, code, it is necessary to keep interrupts disabled during