net/wrb: add tcp/udp_inqueue_wrb_size() interface

Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an 2021-07-14 17:30:44 +08:00 committed by Xiang Xiao
parent 011c938116
commit f52757f90a
2 changed files with 70 additions and 0 deletions

View File

@ -94,6 +94,44 @@
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: tcp_inqueue_wrb_size
*
* Description:
* Get the in-queued write buffer size from connection
*
* Input Parameters:
* conn - The TCP connection of interest
*
* Assumptions:
* Called from user logic with the network locked.
*
****************************************************************************/
static uint32_t tcp_inqueue_wrb_size(FAR struct tcp_conn_s *conn)
{
FAR struct tcp_wrbuffer_s *wrb;
FAR sq_entry_t *entry;
uint32_t total = 0;
if (conn)
{
for (entry = sq_peek(&conn->unacked_q); entry; entry = sq_next(entry))
{
wrb = (FAR struct tcp_wrbuffer_s *)entry;
total += TCP_WBPKTLEN(wrb);
}
for (entry = sq_peek(&conn->write_q); entry; entry = sq_next(entry))
{
wrb = (FAR struct tcp_wrbuffer_s *)entry;
total += TCP_WBPKTLEN(wrb);
}
}
return total;
}
/****************************************************************************
* Name: psock_insert_segment
*

View File

@ -105,6 +105,38 @@ static uint16_t sendto_eventhandler(FAR struct net_driver_s *dev,
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: udp_inqueue_wrb_size
*
* Description:
* Get the in-queued write buffer size from connection
*
* Input Parameters:
* conn - The UDP connection of interest
*
* Assumptions:
* Called from user logic with the network locked.
*
****************************************************************************/
static uint32_t udp_inqueue_wrb_size(FAR struct udp_conn_s *conn)
{
FAR struct udp_wrbuffer_s *wrb;
FAR sq_entry_t *entry;
uint32_t total = 0;
if (conn)
{
for (entry = sq_peek(&conn->write_q); entry; entry = sq_next(entry))
{
wrb = (FAR struct udp_wrbuffer_s *)entry;
total += wrb->wb_iob->io_pktlen;
}
}
return total;
}
/****************************************************************************
* Name: sendto_writebuffer_release
*