net/udp and tcp: Yet another (cosmetic) change to UDP and TCP write buffer macro naming.

This commit is contained in:
Gregory Nutt 2018-01-22 19:33:14 -06:00
parent 2d4fa19a54
commit 289e4dde06
5 changed files with 70 additions and 70 deletions

View File

@ -77,25 +77,25 @@
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
/* TCP write buffer access macros */
# define TCPWB_SEQNO(wrb) ((wrb)->wb_seqno)
# define TCPWB_PKTLEN(wrb) ((wrb)->wb_iob->io_pktlen)
# define TCPWB_SENT(wrb) ((wrb)->wb_sent)
# define TCPWB_NRTX(wrb) ((wrb)->wb_nrtx)
# define TCPWB_IOB(wrb) ((wrb)->wb_iob)
# define TCPWB_COPYOUT(wrb,dest,n) (iob_copyout(dest,(wrb)->wb_iob,(n),0))
# define TCPWB_COPYIN(wrb,src,n) \
# define TCP_WBSEQNO(wrb) ((wrb)->wb_seqno)
# define TCP_WBPKTLEN(wrb) ((wrb)->wb_iob->io_pktlen)
# define TCP_WBSENT(wrb) ((wrb)->wb_sent)
# define TCP_WBNRTX(wrb) ((wrb)->wb_nrtx)
# define TCP_WBIOB(wrb) ((wrb)->wb_iob)
# define TCP_WBCOPYOUT(wrb,dest,n) (iob_copyout(dest,(wrb)->wb_iob,(n),0))
# define TCP_WBCOPYIN(wrb,src,n) \
(iob_copyin((wrb)->wb_iob,src,(n),0,false))
# define TCPWB_TRYCOPYIN(wrb,src,n) \
# define TCP_WBTRYCOPYIN(wrb,src,n) \
(iob_trycopyin((wrb)->wb_iob,src,(n),0,false))
# define TCPWB_TRIM(wrb,n) \
# define TCP_WBTRIM(wrb,n) \
do { (wrb)->wb_iob = iob_trimhead((wrb)->wb_iob,(n)); } while (0)
#ifdef CONFIG_DEBUG_FEATURES
# define TCPWB_DUMP(msg,wrb,len,offset) \
# define TCP_WBDUMP(msg,wrb,len,offset) \
tcp_wrbuffer_dump(msg,wrb,len,offset)
# else
# define TCPWB_DUMP(msg,wrb,len,offset)
# define TCP_WBDUMP(msg,wrb,len,offset)
# endif
#endif

View File

@ -98,8 +98,8 @@
# define BUF_DUMP(msg,buf,len) lib_dumpbuffer(msg,buf,len)
#else
# define BUF_DUMP(msg,buf,len)
# undef TCPWB_DUMP
# define TCPWB_DUMP(msg,wrb,len,offset)
# undef TCP_WBDUMP
# define TCP_WBDUMP(msg,wrb,len,offset)
#endif
/****************************************************************************
@ -135,7 +135,7 @@ static void psock_insert_segment(FAR struct tcp_wrbuffer_s *wrb,
for (itr = sq_peek(q); itr; itr = sq_next(itr))
{
FAR struct tcp_wrbuffer_s *wrb0 = (FAR struct tcp_wrbuffer_s *)itr;
if (TCPWB_SEQNO(wrb0) < TCPWB_SEQNO(wrb))
if (TCP_WBSEQNO(wrb0) < TCP_WBSEQNO(wrb))
{
insert = itr;
}
@ -417,13 +417,13 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
* the write buffer has been ACKed.
*/
if (ackno > TCPWB_SEQNO(wrb))
if (ackno > TCP_WBSEQNO(wrb))
{
/* Get the sequence number at the end of the data */
lastseq = TCPWB_SEQNO(wrb) + TCPWB_PKTLEN(wrb);
lastseq = TCP_WBSEQNO(wrb) + TCP_WBPKTLEN(wrb);
ninfo("ACK: wrb=%p seqno=%u lastseq=%u pktlen=%u ackno=%u\n",
wrb, TCPWB_SEQNO(wrb), lastseq, TCPWB_PKTLEN(wrb),
wrb, TCP_WBSEQNO(wrb), lastseq, TCP_WBPKTLEN(wrb),
ackno);
/* Has the entire buffer been ACKed? */
@ -450,24 +450,24 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
* buffers in the chain.
*/
trimlen = ackno - TCPWB_SEQNO(wrb);
if (trimlen > TCPWB_SENT(wrb))
trimlen = ackno - TCP_WBSEQNO(wrb);
if (trimlen > TCP_WBSENT(wrb))
{
/* More data has been ACKed then we have sent? */
trimlen = TCPWB_SENT(wrb);
trimlen = TCP_WBSENT(wrb);
}
ninfo("ACK: wrb=%p trim %u bytes\n", wrb, trimlen);
TCPWB_TRIM(wrb, trimlen);
TCPWB_SEQNO(wrb) = ackno;
TCPWB_SENT(wrb) -= trimlen;
TCP_WBTRIM(wrb, trimlen);
TCP_WBSEQNO(wrb) = ackno;
TCP_WBSENT(wrb) -= trimlen;
/* Set the new sequence number for what remains */
ninfo("ACK: wrb=%p seqno=%u pktlen=%u\n",
wrb, TCPWB_SEQNO(wrb), TCPWB_PKTLEN(wrb));
wrb, TCP_WBSEQNO(wrb), TCP_WBPKTLEN(wrb));
}
}
}
@ -478,31 +478,31 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
*/
wrb = (FAR struct tcp_wrbuffer_s *)sq_peek(&conn->write_q);
if (wrb && TCPWB_SENT(wrb) > 0 && ackno > TCPWB_SEQNO(wrb))
if (wrb && TCP_WBSENT(wrb) > 0 && ackno > TCP_WBSEQNO(wrb))
{
uint32_t nacked;
/* Number of bytes that were ACKed */
nacked = ackno - TCPWB_SEQNO(wrb);
if (nacked > TCPWB_SENT(wrb))
nacked = ackno - TCP_WBSEQNO(wrb);
if (nacked > TCP_WBSENT(wrb))
{
/* More data has been ACKed then we have sent? ASSERT? */
nacked = TCPWB_SENT(wrb);
nacked = TCP_WBSENT(wrb);
}
ninfo("ACK: wrb=%p seqno=%u nacked=%u sent=%u ackno=%u\n",
wrb, TCPWB_SEQNO(wrb), nacked, TCPWB_SENT(wrb), ackno);
wrb, TCP_WBSEQNO(wrb), nacked, TCP_WBSENT(wrb), ackno);
/* Trim the ACKed bytes from the beginning of the write buffer. */
TCPWB_TRIM(wrb, nacked);
TCPWB_SEQNO(wrb) = ackno;
TCPWB_SENT(wrb) -= nacked;
TCP_WBTRIM(wrb, nacked);
TCP_WBSEQNO(wrb) = ackno;
TCP_WBSENT(wrb) -= nacked;
ninfo("ACK: wrb=%p seqno=%u pktlen=%u sent=%u\n",
wrb, TCPWB_SEQNO(wrb), TCPWB_PKTLEN(wrb), TCPWB_SENT(wrb));
wrb, TCP_WBSEQNO(wrb), TCP_WBPKTLEN(wrb), TCP_WBSENT(wrb));
}
}
@ -544,16 +544,16 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
*/
wrb = (FAR struct tcp_wrbuffer_s *)sq_peek(&conn->write_q);
ninfo("REXMIT: wrb=%p sent=%u\n", wrb, wrb ? TCPWB_SENT(wrb) : 0);
ninfo("REXMIT: wrb=%p sent=%u\n", wrb, wrb ? TCP_WBSENT(wrb) : 0);
if (wrb != NULL && TCPWB_SENT(wrb) > 0)
if (wrb != NULL && TCP_WBSENT(wrb) > 0)
{
FAR struct tcp_wrbuffer_s *tmp;
uint16_t sent;
/* Yes.. Reset the number of bytes sent sent from the write buffer */
sent = TCPWB_SENT(wrb);
sent = TCP_WBSENT(wrb);
if (conn->unacked > sent)
{
conn->unacked -= sent;
@ -572,16 +572,16 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
conn->sent = 0;
}
TCPWB_SENT(wrb) = 0;
TCP_WBSENT(wrb) = 0;
ninfo("REXMIT: wrb=%p sent=%u, conn unacked=%d sent=%d\n",
wrb, TCPWB_SENT(wrb), conn->unacked, conn->sent);
wrb, TCP_WBSENT(wrb), conn->unacked, conn->sent);
/* Increment the retransmit count on this write buffer. */
if (++TCPWB_NRTX(wrb) >= TCP_MAXRTX)
if (++TCP_WBNRTX(wrb) >= TCP_MAXRTX)
{
nwarn("WARNING: Expiring wrb=%p nrtx=%u\n",
wrb, TCPWB_NRTX(wrb));
wrb, TCP_WBNRTX(wrb));
/* The maximum retry count as been exhausted. Remove the write
* buffer at the head of the queue.
@ -619,7 +619,7 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
/* Reset the number of bytes sent sent from the write buffer */
sent = TCPWB_SENT(wrb);
sent = TCP_WBSENT(wrb);
if (conn->unacked > sent)
{
conn->unacked -= sent;
@ -638,16 +638,16 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
conn->sent = 0;
}
TCPWB_SENT(wrb) = 0;
TCP_WBSENT(wrb) = 0;
ninfo("REXMIT: wrb=%p sent=%u, conn unacked=%d sent=%d\n",
wrb, TCPWB_SENT(wrb), conn->unacked, conn->sent);
wrb, TCP_WBSENT(wrb), conn->unacked, conn->sent);
/* Free any write buffers that have exceed the retry count */
if (++TCPWB_NRTX(wrb) >= TCP_MAXRTX)
if (++TCP_WBNRTX(wrb) >= TCP_MAXRTX)
{
nwarn("WARNING: Expiring wrb=%p nrtx=%u\n",
wrb, TCPWB_NRTX(wrb));
wrb, TCP_WBNRTX(wrb));
/* Return the write buffer to the free list */
@ -672,7 +672,7 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
* is pulled from the write_q again.
*/
ninfo("REXMIT: Moving wrb=%p nrtx=%u\n", wrb, TCPWB_NRTX(wrb));
ninfo("REXMIT: Moving wrb=%p nrtx=%u\n", wrb, TCP_WBNRTX(wrb));
psock_insert_segment(wrb, &conn->write_q);
}
@ -727,7 +727,7 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
* window size.
*/
sndlen = TCPWB_PKTLEN(wrb) - TCPWB_SENT(wrb);
sndlen = TCP_WBPKTLEN(wrb) - TCP_WBSENT(wrb);
if (sndlen > conn->mss)
{
sndlen = conn->mss;
@ -739,16 +739,16 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
}
ninfo("SEND: wrb=%p pktlen=%u sent=%u sndlen=%u\n",
wrb, TCPWB_PKTLEN(wrb), TCPWB_SENT(wrb), sndlen);
wrb, TCP_WBPKTLEN(wrb), TCP_WBSENT(wrb), sndlen);
/* Set the sequence number for this segment. If we are
* retransmitting, then the sequence number will already
* be set for this write buffer.
*/
if (TCPWB_SEQNO(wrb) == (unsigned)-1)
if (TCP_WBSEQNO(wrb) == (unsigned)-1)
{
TCPWB_SEQNO(wrb) = conn->isn + conn->sent;
TCP_WBSEQNO(wrb) = conn->isn + conn->sent;
}
/* The TCP stack updates sndseq on receipt of ACK *before*
@ -758,7 +758,7 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
* before the packet is sent.
*/
tcp_setsequence(conn->sndseq, TCPWB_SEQNO(wrb) + TCPWB_SENT(wrb));
tcp_setsequence(conn->sndseq, TCP_WBSEQNO(wrb) + TCP_WBSENT(wrb));
#ifdef NEED_IPDOMAIN_SUPPORT
/* If both IPv4 and IPv6 support are enabled, then we will need to
@ -774,7 +774,7 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
* won't actually happen until the polling cycle completes).
*/
devif_iob_send(dev, TCPWB_IOB(wrb), sndlen, TCPWB_SENT(wrb));
devif_iob_send(dev, TCP_WBIOB(wrb), sndlen, TCP_WBSENT(wrb));
/* Remember how much data we send out now so that we know
* when everything has been acknowledged. Just increment
@ -796,21 +796,21 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
}
ninfo("SEND: wrb=%p nrtx=%u unacked=%u sent=%u\n",
wrb, TCPWB_NRTX(wrb), conn->unacked, conn->sent);
wrb, TCP_WBNRTX(wrb), conn->unacked, conn->sent);
/* Increment the count of bytes sent from this write buffer */
TCPWB_SENT(wrb) += sndlen;
TCP_WBSENT(wrb) += sndlen;
ninfo("SEND: wrb=%p sent=%u pktlen=%u\n",
wrb, TCPWB_SENT(wrb), TCPWB_PKTLEN(wrb));
wrb, TCP_WBSENT(wrb), TCP_WBPKTLEN(wrb));
/* Remove the write buffer from the write queue if the
* last of the data has been sent from the buffer.
*/
DEBUGASSERT(TCPWB_SENT(wrb) <= TCPWB_PKTLEN(wrb));
if (TCPWB_SENT(wrb) >= TCPWB_PKTLEN(wrb))
DEBUGASSERT(TCP_WBSENT(wrb) <= TCP_WBPKTLEN(wrb));
if (TCP_WBSENT(wrb) >= TCP_WBPKTLEN(wrb))
{
FAR struct tcp_wrbuffer_s *tmp;
@ -1061,8 +1061,8 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf,
/* Initialize the write buffer */
TCPWB_SEQNO(wrb) = (unsigned)-1;
TCPWB_NRTX(wrb) = 0;
TCP_WBSEQNO(wrb) = (unsigned)-1;
TCP_WBNRTX(wrb) = 0;
/* Copy the user data into the write buffer. We cannot wait for
* buffer space if the socket was opened non-blocking.
@ -1070,16 +1070,16 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf,
if (_SS_ISNONBLOCK(psock->s_flags))
{
result = TCPWB_TRYCOPYIN(wrb, (FAR uint8_t *)buf, len);
result = TCP_WBTRYCOPYIN(wrb, (FAR uint8_t *)buf, len);
}
else
{
result = TCPWB_COPYIN(wrb, (FAR uint8_t *)buf, len);
result = TCP_WBCOPYIN(wrb, (FAR uint8_t *)buf, len);
}
/* Dump I/O buffer chain */
TCPWB_DUMP("I/O buffer chain", wrb, TCPWB_PKTLEN(wrb), 0);
TCP_WBDUMP("I/O buffer chain", wrb, TCP_WBPKTLEN(wrb), 0);
/* psock_send_eventhandler() will send data in FIFO order from the
* conn->write_q
@ -1087,7 +1087,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf,
sq_addlast(&wrb->wb_node, &conn->write_q);
ninfo("Queued WRB=%p pktlen=%u write_q(%p,%p)\n",
wrb, TCPWB_PKTLEN(wrb),
wrb, TCP_WBPKTLEN(wrb),
conn->write_q.head, conn->write_q.tail);
/* Notify the device driver of the availability of TX data */

View File

@ -64,8 +64,8 @@ void tcp_wrbuffer_dump(FAR const char *msg, FAR struct tcp_wrbuffer_s *wrb,
unsigned int len, unsigned int offset)
{
syslog(LOG_DEBUG, "%s: wrb=%p segno=%d sent=%d nrtx=%d\n",
msg, wrb, TCPWB_SEQNO(wrb), TCPWB_SENT(wrb), TCPWB_NRTX(wrb));
iob_dump("I/O Buffer Chain", TCPWB_IOB(wrb), len, offset);
msg, wrb, TCP_WBSEQNO(wrb), TCP_WBSENT(wrb), TCP_WBNRTX(wrb));
iob_dump("I/O Buffer Chain", TCP_WBIOB(wrb), len, offset);
}
#endif /* CONFIG_DEBUG_FEATURES */

View File

@ -71,10 +71,10 @@
/* UDP write buffer dump macros */
# ifdef CONFIG_DEBUG_FEATURES
# define UDPWB_DUMP(msg,wrb,len,offset) \
# define UDP_WBDUMP(msg,wrb,len,offset) \
udp_wrbuffer_dump(msg,wrb,len,offset)
# else
# define UDPWB_DUMP(msg,wrb,len,offset)
# define UDP_WBDUMP(msg,wrb,len,offset)
# endif
#endif

View File

@ -97,8 +97,8 @@
# define BUF_DUMP(msg,buf,len) lib_dumpbuffer(msg,buf,len)
#else
# define BUF_DUMP(msg,buf,len)
# undef UDPWB_DUMP
# define UDPWB_DUMP(msg,wrb,len,offset)
# undef UDP_WBDUMP
# define UDP_WBDUMP(msg,wrb,len,offset)
#endif
/****************************************************************************
@ -747,7 +747,7 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf,
/* Dump I/O buffer chain */
UDPWB_DUMP("I/O buffer chain", wrb, wrb->wb_iob->io_pktlen, 0);
UDP_WBDUMP("I/O buffer chain", wrb, wrb->wb_iob->io_pktlen, 0);
/* sendto_eventhandler() will send data in FIFO order from the
* conn->write_q