net/tcp: dynamic calculation of available iobs

Change-Id: I4b0d01204af74f1692ae061914617dbb4e8698c0
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an
2021-02-07 16:56:57 +08:00
committed by chao an
parent 6f39a980f5
commit 65b95eea6f
+43 -1
View File
@@ -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? */