[BUG] IOB not clearing and dropping Wi-Fi throughput
- Dominant language
- C
- Stars
- 4k
- Forks
- 1.7k
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 237
Description
### Description / Steps to reproduce the issue
Hi all,
I have a problem where running NuttX as IPERF server (Wi-Fi on ESP32-C6) shows decreasing speed with time.
Here's an example:
```
nsh> iperf -s
IP: 192.168.0.127
mode=tcp-server sip=192.168.0.127:5001,dip=0.0.0.0:5001, interval=3, time=0
accept: 192.168.0.125:45774
Interval Transfer Bandwidth
0.00- 3.01 sec 2127280 Bytes 5.65 Mbits/sec
3.01- 6.02 sec 1353420 Bytes 3.60 Mbits/sec
6.02- 9.03 sec 1907980 Bytes 5.07 Mbits/sec
9.03- 12.04 sec 3239980 Bytes 8.61 Mbits/sec
12.04- 15.05 sec 2899560 Bytes 7.71 Mbits/sec
15.05- 18.06 sec 3048480 Bytes 8.10 Mbits/sec
[...]
57.19- 60.20 sec 3043784 Bytes 8.09 Mbits/sec
60.20- 63.21 sec 2988936 Bytes 7.94 Mbits/sec
[...]
84.28- 87.29 sec 2409316 Bytes 6.40 Mbits/sec
87.29- 90.30 sec 1941800 Bytes 5.16 Mbits/sec
90.30- 93.31 sec 3131700 Bytes 8.32 Mbits/sec
93.31- 96.32 sec 3387200 Bytes 9.00 Mbits/sec
96.32- 99.33 sec 3267480 Bytes 8.68 Mbits/sec
[...]
186.62- 189.63 sec 2698548 Bytes 7.17 Mbits/sec
189.63- 192.64 sec 2264460 Bytes 6.02 Mbits/sec
192.64- 195.65 sec 1603080 Bytes 4.26 Mbits/sec
195.65- 198.66 sec 2619764 Bytes 6.96 Mbits/sec
198.66- 201.67 sec 1997748 Bytes 5.31 Mbits/sec
201.67- 204.68 sec 2153968 Bytes 5.72 Mbits/sec
204.68- 207.69 sec 2072264 Bytes 5.51 Mbits/sec
207.69- 210.70 sec 1608396 Bytes 4.27 Mbits/sec
210.70- 213.71 sec 2559380 Bytes 6.80 Mbits/sec
213.71- 216.72 sec 2267380 Bytes 6.03 Mbits/sec
216.72- 219.73 sec 2454260 Bytes 6.52 Mbits/sec
219.73- 222.74 sec 1909136 Bytes 5.07 Mbits/sec
222.74- 225.75 sec 1861576 Bytes 4.95 Mbits/sec
[...]
291.97- 294.98 sec 1363640 Bytes 3.62 Mbits/sec
294.98- 297.99 sec 908740 Bytes 2.42 Mbits/sec
297.99- 301.00 sec 1564936 Bytes 4.16 Mbits/sec
301.00- 304.01 sec 1582824 Bytes 4.21 Mbits/sec
304.01- 307.02 sec 1648340 Bytes 4.38 Mbits/sec
[...]
379.26- 382.27 sec 1125660 Bytes 2.99 Mbits/sec
[...]
490.63- 493.64 sec 1353420 Bytes 3.60 Mbits/sec
[...]
586.95- 589.96 sec 955196 Bytes 2.54 Mbits/sec
589.96- 592.97 sec 1147560 Bytes 3.05 Mbits/sec
592.97- 595.98 sec 1001204 Bytes 2.66 Mbits/sec
595.98- 598.99 sec 1028196 Bytes 2.73 Mbits/sec
closed by the peer: 192.168.0.125:45774
iperf exit
```
You can see the average throughput dropping.
I understand why the speed drops, and that is because **I don't have enough IOBs**, and that is expected right? Less IOBs, less throughput. Problem with that is that I started with 160 free IOBs and after the IPERF run finalizes, some of those IOBs are missing:
**Before IPERF test:**
```
nsh> cat /proc/iobinfo
ntotal nfree nwait nthrottle
160 160 0 136
```
**After IPERF test:**
```
nsh> cat /proc/iobinfo
ntotal nfree nwait nthrottle
160 62 0 38
```
My question is: what would cause those IOBs to go missing? I'm running the Wi-Fi driver based on `netdev_lowerhalf.h` so the upper-half driver is managing those buffers, with the exception of my `rx_done` callback:
```c
static int wlan_rx_done(struct esp_wlan_priv_s *priv,
void *buffer, uint16_t len, void *eb)
{
int ret = OK;
netpkt_t *pkt = NULL;
pkt = netpkt_alloc(&priv->dev, NETPKT_RX);
if (pkt == NULL)
{
ret = -ENOMEM;
goto out;
}
ret = netpkt_copyin(&priv->dev, pkt, buffer, len, 0);
if (ret < 0)
{
wlerr("ERROR: Failed to copy packet\n");
goto out;
}
ret = netpkt_tryadd_queue(pkt, &priv->netdev_rx_queue);
if (ret < 0)
{
wlerr("ERROR: Failed to add packet to queue\n");
netpkt_free_queue(&priv->netdev_rx_queue);
goto out;
}
out:
if (eb != NULL)
{
esp_wifi_api_free_rx_buffer(eb);
}
if (ret != OK && pkt != NULL)
{
netpkt_free(&priv->dev, pkt, NETPKT_RX);
}
netdev_lower_rxready(&priv->dev);
return ret;
}
```
This behavior is not present when using IPERF as client, just reinforcing that the issue is on receive side.
I would like to discuss this further since I've exhausted my test ideas for now.
Thanks in advance.
### On which OS does this issue occur?
[OS: Linux]
### What is the version of your OS?
Mint 22.1
### NuttX Version
feature/riscv-wifi-refactor
### Issue Architecture
[Arch: risc-v]
### Issue Area
[Area: Networking]
### Host information
_No response_
### Verification
- [x] I have verified before submitting the report.
Contributor guide
Assessment
This issue has not been assessed yet.