Replace pkdrv with nvnetdrv
This is a replacement network driver that intends to improve network performance of nxdk and replace pktdrv. Will close https://github.com/XboxDev/nxdk/issues/460 and https://github.com/XboxDev/nxdk/issues/129. This work was started by @thrimbor and I kind of took it over.
~Relies on https://github.com/XboxDev/nxdk/pull/610.~
It has a few key improvements over pktdrv:
- Zero-copy TX and RX transmission
- Automatic scatter gather of TX packets that cross page boundaries so the user doesnt need to worry about it (Up to one page crossing, which should cover all ethernet frame lengths required for 100Mbit)
- Multithreaded buffer manager
- Supports different ring sizes for TX and RX so you can optimise your application for specifc directions to reduce RAM usage. Defaults to 64/64 which seems like a reasonable all around mode even under heavy loads.
As a comparison running lwip iperf server on the same Xbox and PC network config:
Current master (rx then tx test):
[ 4] local 192.168.1.115 port 52244 connected with 192.168.1.113 port 5001
[ ID] Interval Transfer Bandwidth
[ 4] 0.0-10.0 sec 39.4 MBytes 33.0 Mbits/sec
[ 4] local 192.168.1.115 port 5001 connected with 192.168.1.113 port 51705
[ 4] 0.0-10.3 sec 25.2 KBytes 20.1 Kbits/sec
nvnetdrv (rx then tx test)::
[ 4] local 192.168.1.115 port 51764 connected with 192.168.1.113 port 5001
[ ID] Interval Transfer Bandwidth
[ 4] 0.0-10.0 sec 112 MBytes 94.2 Mbits/sec
[ 4] local 192.168.1.115 port 5001 connected with 192.168.1.113 port 51715
[ 4] 0.0-10.0 sec 111 MBytes 92.9 Mbits/sec
It also performs quite well in full duplex mode (tx/rx in parallel):
[ 4] local 192.168.1.115 port 57034 connected with 192.168.1.113 port 5001
[ 5] local 192.168.1.115 port 5001 connected with 192.168.1.113 port 51704
[ ID] Interval Transfer Bandwidth
[ 4] 0.0-10.0 sec 108 MBytes 90.3 Mbits/sec
[ 5] 0.0-10.0 sec 106 MBytes 88.9 Mbits/sec
Current PRd as draft mainly due to it being a fairly large change and subject to feedback. I have tested this quite extensively and currently use it on my homebrew dashboard in the form of an FTP server.
The lwipopt.h tweak is as per https://lwip.fandom.com/wiki/Tuning_TCP, which improved tx speed from ~60mbits to 90+mbits in my test with nvnetdrv. It made little impact to pktdrv perf.
Send-buffer (TCP_SND_BUF):
... For maximum throughput, set this to the same value as TCP_WND
Also fixes a bug in our network init function. We should be using tcpip_input instead of ethernet_input for OS mode (threaded) operation. Ref https://www.nongnu.org/lwip/2_0_x/group__netif.html#gade5498543e74067f28cc6bef0209e3be