TCP write buffering: Add an offset to buffer dumping logic
This commit is contained in:
parent
963f8f49c5
commit
30843cf46d
@ -304,7 +304,8 @@ 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, unsigned int len);
|
||||
void iob_dump(FAR const char *msg, FAR struct iob_s *iob, unsigned int len,
|
||||
unsigned int offset);
|
||||
#else
|
||||
# define iob_dump(wrb)
|
||||
#endif
|
||||
|
@ -163,7 +163,7 @@ struct uip_driver_s
|
||||
|
||||
uint16_t d_len;
|
||||
|
||||
/* When d_buf contains outgoing xmit data, xmtlen is nonzero and represents
|
||||
/* When d_buf contains outgoing xmit data, d_sndlen is nonzero and represents
|
||||
* the amount of appllcation data after d_snddata
|
||||
*/
|
||||
|
||||
|
@ -139,9 +139,10 @@
|
||||
do { (wrb)->wb_iob = iob_trimhead((wrb)->wb_iob,(n)); } while (0)
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
# define WRB_DUMP(msg,wrb,len) tcp_wrbuffer_dump(msg,wrb,len)
|
||||
# define WRB_DUMP(msg,wrb,len,offset) \
|
||||
tcp_wrbuffer_dump(msg,wrb,len,offset)
|
||||
#else
|
||||
# define WRB_DUMP(msg,wrb,len)
|
||||
# define WRB_DUMP(msg,wrb,len,offset)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -82,37 +82,68 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void iob_dump(FAR const char *msg, FAR struct iob_s *iob, unsigned int len)
|
||||
void iob_dump(FAR const char *msg, FAR struct iob_s *iob, unsigned int len,
|
||||
unsigned int offset)
|
||||
{
|
||||
FAR struct iob_s *head;
|
||||
uint8_t data[32];
|
||||
unsigned int maxlen;
|
||||
unsigned int nbytes;
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
unsigned int lndx;
|
||||
unsigned int cndx;
|
||||
|
||||
message("%s: iob=%p len = %d pktlen=%d\n", msg, iob, len, iob->io_pktlen);
|
||||
len = MIN(len, iob->io_pktlen);
|
||||
head = iob;
|
||||
message("%s: iob=%p pktlen=%d\n", msg, head, head->io_pktlen);
|
||||
|
||||
for (i = 0; i < len; i += 32)
|
||||
/* Check if the offset is beyond the data in the I/O buffer chain */
|
||||
|
||||
if (offset > head->io_pktlen)
|
||||
{
|
||||
/* Copy 32-bytes into our local buffer */
|
||||
ndbg("ERROR: offset is past the end of data: %u > %u\n",
|
||||
offset, head->io_pktlen);
|
||||
return;
|
||||
}
|
||||
|
||||
nbytes = iob_copyout(data, iob, 32, i);
|
||||
/* Dump I/O buffer headers */
|
||||
|
||||
for (; iob; iob = iob->io_flink)
|
||||
{
|
||||
message(" iob=%p len=%d offset=%d\n", iob, iob->io_len, iob->io_offset);
|
||||
}
|
||||
|
||||
/* Get the amount of data to be displayed, limited by the amount that we
|
||||
* have beyond the offset.
|
||||
*/
|
||||
|
||||
maxlen = head->io_pktlen - offset;
|
||||
len = MIN(len, maxlen);
|
||||
|
||||
/* Then beginning printing with the buffer containing the offset in groups
|
||||
* of 32 bytes.
|
||||
*/
|
||||
|
||||
for (lndx = 0; lndx < len; lndx += 32, offset += 32)
|
||||
{
|
||||
/* Copy 32-bytes into our local buffer from the current offset */
|
||||
|
||||
nbytes = iob_copyout(data, head, 32, offset);
|
||||
|
||||
/* Make sure that we have something to print */
|
||||
|
||||
if (nbytes > 0)
|
||||
{
|
||||
message("%04x: ", i);
|
||||
for (j = 0; j < 32; j++)
|
||||
message(" %04x: ", offset);
|
||||
|
||||
for (cndx = 0; cndx < 32; cndx++)
|
||||
{
|
||||
if (j == 16)
|
||||
if (cndx == 16)
|
||||
{
|
||||
message(" ");
|
||||
}
|
||||
|
||||
if (i + j < len)
|
||||
if ((lndx + cndx) < len)
|
||||
{
|
||||
message("%02x", data[j]);
|
||||
message("%02x", data[cndx]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -121,18 +152,18 @@ void iob_dump(FAR const char *msg, FAR struct iob_s *iob, unsigned int len)
|
||||
}
|
||||
|
||||
message(" ");
|
||||
for (j = 0; j < 32; j++)
|
||||
for (cndx = 0; cndx < 32; cndx++)
|
||||
{
|
||||
if (j == 16)
|
||||
if (cndx == 16)
|
||||
{
|
||||
message(" ");
|
||||
}
|
||||
|
||||
if (i + j < len)
|
||||
if ((lndx + cndx) < len)
|
||||
{
|
||||
if (data[j] >= 0x20 && data[j] < 0x7f)
|
||||
if (data[cndx] >= 0x20 && data[cndx] < 0x7f)
|
||||
{
|
||||
message("%c", data[j]);
|
||||
message("%c", data[cndx]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -82,9 +82,9 @@
|
||||
#ifdef CONFIG_NET_TCP_WRBUFFER_DUMP
|
||||
# define BUF_DUMP(msg,buf,len) lib_dumpbuffer(msg,buf,len)
|
||||
#else
|
||||
# define BUF_DUMP(msg,buf,len)
|
||||
# define BUF_DUMP(msg,buf,len,offset)
|
||||
# undef WRB_DUMP
|
||||
# define WRB_DUMP(msg,wrb,len)
|
||||
# define WRB_DUMP(msg,wrb,len,offset)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
@ -285,12 +285,21 @@ static uint16_t send_interrupt(FAR struct uip_driver_s *dev, FAR void *pvconn,
|
||||
*/
|
||||
|
||||
trimlen = ackno - WRB_SEQNO(wrb);
|
||||
if (trimlen > WRB_SENT(wrb))
|
||||
{
|
||||
/* More data has been ACKed then we have sent? */
|
||||
|
||||
trimlen = WRB_SENT(wrb);
|
||||
}
|
||||
|
||||
nllvdbg("ACK: wrb=%p trim %u bytes\n", wrb, trimlen);
|
||||
|
||||
WRB_TRIM(wrb, trimlen);
|
||||
WRB_SEQNO(wrb) = ackno;
|
||||
WRB_SENT(wrb) -= trimlen;
|
||||
|
||||
/* Set the new sequence number for what remains */
|
||||
|
||||
WRB_SEQNO(wrb) = ackno;
|
||||
nllvdbg("ACK: wrb=%p seqno=%u pktlen=%u\n",
|
||||
wrb, WRB_SEQNO(wrb), WRB_PKTLEN(wrb));
|
||||
}
|
||||
@ -312,7 +321,7 @@ static uint16_t send_interrupt(FAR struct uip_driver_s *dev, FAR void *pvconn,
|
||||
nacked = ackno - WRB_SEQNO(wrb);
|
||||
if (nacked > WRB_SENT(wrb))
|
||||
{
|
||||
/* More data has been ACKed then we have sent? */
|
||||
/* More data has been ACKed then we have sent? ASSERT? */
|
||||
|
||||
nacked = WRB_SENT(wrb);
|
||||
}
|
||||
@ -793,7 +802,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_PKTLEN(wrb));
|
||||
WRB_DUMP("I/O buffer chain", wrb, WRB_PKTLEN(wrb), 0);
|
||||
|
||||
/* send_interrupt() will send data in FIFO order from the
|
||||
* conn->write_q
|
||||
|
@ -129,7 +129,8 @@ 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, unsigned int len);
|
||||
void tcp_wrbuffer_dump(FAR const char *msg, FAR struct tcp_wrbuffer_s *wrb,
|
||||
unsigned int len, unsigned int offset);
|
||||
#else
|
||||
# define tcp_wrbuffer_dump(msg,wrb)
|
||||
#endif
|
||||
|
@ -80,11 +80,11 @@
|
||||
****************************************************************************/
|
||||
|
||||
void tcp_wrbuffer_dump(FAR const char *msg, FAR struct tcp_wrbuffer_s *wrb,
|
||||
unsigned int len)
|
||||
unsigned int len, unsigned int offset)
|
||||
{
|
||||
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), len);
|
||||
iob_dump("I/O Buffer Chain", WRB_IOB(wrb), len, offset);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_DEBUG */
|
||||
|
Loading…
Reference in New Issue
Block a user