mirror of
https://github.com/apache/nuttx.git
synced 2026-08-21 05:28:19 +00:00
net/tcp: dynamic calculation of available iobs
Change-Id: I4b0d01204af74f1692ae061914617dbb4e8698c0 Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
6f39a980f5
commit
65b95eea6f
1 changed files with 43 additions and 1 deletions
|
|
@ -52,6 +52,48 @@
|
|||
|
||||
#include "tcp/tcp.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Static Functions
|
||||
****************************************************************************/
|
||||
|
||||
static int tcp_iob_navail(FAR struct net_driver_s *dev,
|
||||
FAR struct tcp_conn_s *conn)
|
||||
{
|
||||
FAR struct tcp_conn_s *next = NULL;
|
||||
int avail = iob_navail(true);
|
||||
int count = 0;
|
||||
|
||||
while ((next = tcp_nextconn(next)) != NULL)
|
||||
{
|
||||
if (!IOB_QEMPTY(&next->readahead))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
return avail;
|
||||
}
|
||||
|
||||
if (avail > CONFIG_IOB_NBUFFERS / count)
|
||||
{
|
||||
avail = CONFIG_IOB_NBUFFERS / count;
|
||||
}
|
||||
|
||||
count = iob_get_queue_count(&conn->readahead);
|
||||
if (avail > count)
|
||||
{
|
||||
avail -= count;
|
||||
}
|
||||
else
|
||||
{
|
||||
avail = 0;
|
||||
}
|
||||
|
||||
return avail;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
|
@ -112,7 +154,7 @@ uint16_t tcp_get_recvwindow(FAR struct net_driver_s *dev,
|
|||
* (ignoring competition with other IOB consumers).
|
||||
*/
|
||||
|
||||
niob_avail = iob_navail(true);
|
||||
niob_avail = tcp_iob_navail(dev, conn);
|
||||
nqentry_avail = iob_qentry_navail();
|
||||
|
||||
/* Is there a a queue entry and IOBs available for read-ahead buffering? */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue