diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-06-23 07:31:55 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-06-23 07:31:55 -0600 |
commit | dfabacd895d51aca29f41743d691ce5ddbff7515 (patch) | |
tree | ee27145a0bb45504c78c57dfaac2513c0583c447 /nuttx | |
parent | 6b6026feba4b5ce279197f18872927cdc56ce5a1 (diff) | |
download | px4-nuttx-dfabacd895d51aca29f41743d691ce5ddbff7515.tar.gz px4-nuttx-dfabacd895d51aca29f41743d691ce5ddbff7515.tar.bz2 px4-nuttx-dfabacd895d51aca29f41743d691ce5ddbff7515.zip |
TCP write buffering: Add length to buffer dumping instrumentation
Diffstat (limited to 'nuttx')
-rw-r--r-- | nuttx/include/nuttx/net/iob.h | 2 | ||||
-rw-r--r-- | nuttx/include/nuttx/net/uip/uip-tcp.h | 8 | ||||
-rw-r--r-- | nuttx/net/iob/iob_dump.c | 16 | ||||
-rw-r--r-- | nuttx/net/net_send_buffered.c | 69 | ||||
-rw-r--r-- | nuttx/net/tcp/tcp.h | 2 | ||||
-rw-r--r-- | nuttx/net/tcp/tcp_wrbuffer_dump.c | 5 |
6 files changed, 73 insertions, 29 deletions
diff --git a/nuttx/include/nuttx/net/iob.h b/nuttx/include/nuttx/net/iob.h index 1a18ac934..1c0e2b338 100644 --- a/nuttx/include/nuttx/net/iob.h +++ b/nuttx/include/nuttx/net/iob.h @@ -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 diff --git a/nuttx/include/nuttx/net/uip/uip-tcp.h b/nuttx/include/nuttx/net/uip/uip-tcp.h index 7f10e204b..f1ccf67dc 100644 --- a/nuttx/include/nuttx/net/uip/uip-tcp.h +++ b/nuttx/include/nuttx/net/uip/uip-tcp.h @@ -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 diff --git a/nuttx/net/iob/iob_dump.c b/nuttx/net/iob/iob_dump.c index b56477071..d76705740 100644 --- a/nuttx/net/iob/iob_dump.c +++ b/nuttx/net/iob/iob_dump.c @@ -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) { diff --git a/nuttx/net/net_send_buffered.c b/nuttx/net/net_send_buffered.c index 93220b64e..1c75f44db 100644 --- a/nuttx/net/net_send_buffered.c +++ b/nuttx/net/net_send_buffered.c @@ -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 diff --git a/nuttx/net/tcp/tcp.h b/nuttx/net/tcp/tcp.h index 8da77d61f..f855a8044 100644 --- a/nuttx/net/tcp/tcp.h +++ b/nuttx/net/tcp/tcp.h @@ -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 diff --git a/nuttx/net/tcp/tcp_wrbuffer_dump.c b/nuttx/net/tcp/tcp_wrbuffer_dump.c index c7ac3d657..f91bf2052 100644 --- a/nuttx/net/tcp/tcp_wrbuffer_dump.c +++ b/nuttx/net/tcp/tcp_wrbuffer_dump.c @@ -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 */ |