TCP write buffering: Add length to buffer dumping instrumentation

This commit is contained in:
Gregory Nutt 2014-06-23 07:31:55 -06:00
parent 6f1651d5f2
commit 963f8f49c5
6 changed files with 73 additions and 29 deletions

View File

@ -304,7 +304,7 @@ int iob_contig(FAR struct iob_s *iob, unsigned int len);
****************************************************************************/
#ifdef CONFIG_DEBUG
void iob_dump(FAR const char *msg, FAR struct iob_s *iob);
void iob_dump(FAR const char *msg, FAR struct iob_s *iob, unsigned int len);
#else
# define iob_dump(wrb)
#endif

View File

@ -139,9 +139,9 @@
do { (wrb)->wb_iob = iob_trimhead((wrb)->wb_iob,(n)); } while (0)
#ifdef CONFIG_DEBUG
# define WRB_DUMP(msg,wrb) tcp_wrbuffer_dump(msg,wrb)
# define WRB_DUMP(msg,wrb,len) tcp_wrbuffer_dump(msg,wrb,len)
#else
# define WRB_DUMP(msg,wrb)
# define WRB_DUMP(msg,wrb,len)
#endif
#endif
@ -153,7 +153,7 @@
*
* The uip_conn structure is used for identifying a connection. All
* but one field in the structure are to be considered read-only by an
* application. The only exception is the "private: field whos purpose
* application. The only exception is the 'private' fields whose purpose
* is to let the application store application-specific state (e.g.,
* file pointers) for the connection.
*/
@ -213,7 +213,7 @@ struct uip_conn
sq_queue_t unacked_q; /* Write buffering for un-ACKed segments */
uint16_t expired; /* Number segments retransmitted but not yet ACKed,
* it can only be updated at UIP_ESTABLISHED state */
uint16_t sent; /* The number of bytes sent */
uint16_t sent; /* The number of bytes sent (ACKed and un-ACKed) */
uint32_t isn; /* Initial sequence number */
#endif

View File

@ -50,6 +50,10 @@
* Pre-processor definitions
****************************************************************************/
#ifndef MIN
# define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
/* Select the lowest level debug interface available */
#ifdef CONFIG_CPP_HAVE_VARARGS
@ -78,17 +82,17 @@
*
****************************************************************************/
void iob_dump(FAR const char *msg, FAR struct iob_s *iob)
void iob_dump(FAR const char *msg, FAR struct iob_s *iob, unsigned int len)
{
FAR struct iob_s *head = iob;
uint8_t data[32];
unsigned int nbytes;
unsigned int i;
unsigned int j;
message("%s: iob=%p pktlen=%d\n", msg, head, head->io_pktlen);
message("%s: iob=%p len = %d pktlen=%d\n", msg, iob, len, iob->io_pktlen);
len = MIN(len, iob->io_pktlen);
for (i = 0; i < head->io_pktlen; i += 32)
for (i = 0; i < len; i += 32)
{
/* Copy 32-bytes into our local buffer */
@ -106,7 +110,7 @@ void iob_dump(FAR const char *msg, FAR struct iob_s *iob)
message(" ");
}
if (i + j < head->io_pktlen)
if (i + j < len)
{
message("%02x", data[j]);
}
@ -124,7 +128,7 @@ void iob_dump(FAR const char *msg, FAR struct iob_s *iob)
message(" ");
}
if (i + j < head->io_pktlen)
if (i + j < len)
{
if (data[j] >= 0x20 && data[j] < 0x7f)
{

View File

@ -84,7 +84,7 @@
#else
# define BUF_DUMP(msg,buf,len)
# undef WRB_DUMP
# define WRB_DUMP(msg,wrb)
# define WRB_DUMP(msg,wrb,len)
#endif
/****************************************************************************
@ -188,7 +188,6 @@ static inline void lost_connection(FAR struct socket *psock,
sq_init(&conn->unacked_q);
sq_init(&conn->write_q);
conn->expired = 0;
conn->sent = 0;
}
@ -367,11 +366,32 @@ static uint16_t send_interrupt(FAR struct uip_driver_s *dev, FAR void *pvconn,
if (wrb != NULL && WRB_SENT(wrb) > 0)
{
FAR struct tcp_wrbuffer_s *tmp;
uint16_t sent;
/* Yes.. Reset the number of bytes sent sent from the write buffer */
sent = WRB_SENT(wrb);
if (conn->unacked > sent)
{
conn->unacked -= sent;
}
else
{
conn->unacked = 0;
}
if (conn->sent > sent)
{
conn->sent -= sent;
}
else
{
conn->sent = 0;
}
WRB_SENT(wrb) = 0;
nllvdbg("REXMIT: wrb=%p sent=%u\n", wrb, WRB_SENT(wrb));
nllvdbg("REXMIT: wrb=%p sent=%u, conn unacked=%d sent=%d\n",
wrb, WRB_SENT(wrb), conn->unacked, conn->sent);
/* Increment the retransmit count on this write buffer. */
@ -411,6 +431,32 @@ static uint16_t send_interrupt(FAR struct uip_driver_s *dev, FAR void *pvconn,
while ((entry = sq_remlast(&conn->unacked_q)) != NULL)
{
wrb = (FAR struct tcp_wrbuffer_s*)entry;
uint16_t sent;
/* Reset the number of bytes sent sent from the write buffer */
sent = WRB_SENT(wrb);
if (conn->unacked > sent)
{
conn->unacked -= sent;
}
else
{
conn->unacked = 0;
}
if (conn->sent > sent)
{
conn->sent -= sent;
}
else
{
conn->sent = 0;
}
WRB_SENT(wrb) = 0;
nllvdbg("REXMIT: wrb=%p sent=%u, conn unacked=%d sent=%d\n",
wrb, WRB_SENT(wrb), conn->unacked, conn->sent);
/* Free any write buffers that have exceed the retry count */
@ -441,9 +487,7 @@ static uint16_t send_interrupt(FAR struct uip_driver_s *dev, FAR void *pvconn,
* is pulled from the write_q again.
*/
WRB_SENT(wrb) = 0;
nllvdbg("REXMIT: wrb=%p Move to write_q, sent=%u nrtx=%u\n",
wrb, WRB_SENT(wrb), WRB_NRTX(wrb));
nllvdbg("REXMIT: Moving wrb=%p nrtx=%u\n", wrb, WRB_NRTX(wrb));
send_insert_seqment(wrb, &conn->write_q);
}
@ -556,16 +600,11 @@ static uint16_t send_interrupt(FAR struct uip_driver_s *dev, FAR void *pvconn,
/* Remember how much data we send out now so that we know
* when everything has been acknowledged. Just increment
* the amount of data sent. This will be needed in
* sequence number calculations and we know that this is
* not a re-transmission. Re-transmissions do not go through
* this path.
* sequence number calculations.
*/
if (WRB_NRTX(wrb) == 0)
{
conn->unacked += sndlen;
conn->sent += sndlen;
}
conn->unacked += sndlen;
conn->sent += sndlen;
nllvdbg("SEND: wrb=%p nrtx=%u unacked=%u sent=%u\n",
wrb, WRB_NRTX(wrb), conn->unacked, conn->sent);
@ -754,7 +793,7 @@ ssize_t psock_send(FAR struct socket *psock, FAR const void *buf, size_t len,
/* Dump I/O buffer chain */
WRB_DUMP("I/O buffer chain", wrb);
WRB_DUMP("I/O buffer chain", wrb, WRB_PKTLEN(wrb));
/* send_interrupt() will send data in FIFO order from the
* conn->write_q

View File

@ -129,7 +129,7 @@ void tcp_wrbuffer_release(FAR struct tcp_wrbuffer_s *wrb);
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
#ifdef CONFIG_DEBUG
void tcp_wrbuffer_dump(FAR const char *msg, FAR struct tcp_wrbuffer_s *wrb);
void tcp_wrbuffer_dump(FAR const char *msg, FAR struct tcp_wrbuffer_s *wrb, unsigned int len);
#else
# define tcp_wrbuffer_dump(msg,wrb)
#endif

View File

@ -79,11 +79,12 @@
*
****************************************************************************/
void tcp_wrbuffer_dump(FAR const char *msg, FAR struct tcp_wrbuffer_s *wrb)
void tcp_wrbuffer_dump(FAR const char *msg, FAR struct tcp_wrbuffer_s *wrb,
unsigned int len)
{
message("%s: wrb=%p segno=%d sent=%d nrtx=%d\n",
msg, wrb, WRB_SEQNO(wrb), WRB_SENT(wrb), WRB_NRTX(wrb));
iob_dump("I/O Buffer Chain", WRB_IOB(wrb));
iob_dump("I/O Buffer Chain", WRB_IOB(wrb), len);
}
#endif /* CONFIG_DEBUG */