nuttx icon indicating copy to clipboard operation
nuttx copied to clipboard

netdev_upperhalf: convert Kconfig to variable

Open zhhyu7 opened this issue 2 weeks ago • 5 comments

Summary

convert Kconfig to variable, upperhalf can supports multiple working modes at the same time, which is specified by NIC when register, the multi-network card scenario will be more flexible.

Impact

All network card drivers implemented using struct netdev_lowerhalf_s. It is necessary to initialize appropriate rxtype and priority according to the business scenario during network card initialization.

Testing

sim:matter with ping and iperf2.

nsh> ifconfig
eth0	Link encap:Ethernet HWaddr 42:00:d7:82:13:6b at RUNNING mtu 1500
	inet addr:10.0.1.2 DRaddr:10.0.0.1 Mask:255.255.255.0
	inet6 addr: 3380::4000:d7ff:fe82:136b/64
	inet6 DRaddr: fe80::a096:6ff:fe65:382a

lo	Link encap:Local Loopback at RUNNING mtu 1518
	inet addr:127.0.0.1 DRaddr:127.0.0.1 Mask:255.0.0.0
	inet6 addr: ::1/128
	inet6 DRaddr: ::1

nsh> ping -c 5 10.0.1.1
PING 10.0.1.1 56 bytes of data
56 bytes from 10.0.1.1: icmp_seq=0 time=0.0 ms
56 bytes from 10.0.1.1: icmp_seq=1 time=0.0 ms
56 bytes from 10.0.1.1: icmp_seq=2 time=0.0 ms
56 bytes from 10.0.1.1: icmp_seq=3 time=0.0 ms
56 bytes from 10.0.1.1: icmp_seq=4 time=0.0 ms
5 packets transmitted, 5 received, 0% packet loss, time 5050 ms
rtt min/avg/max/mdev = 0.000/0.000/0.000/0.000 ms
nsh> ipe
  iperf
  iperf2
nsh> iperf2 -c 10.0.1.1 -i 1 -t 5
------------------------------------------------------------
Client connecting to 10.0.1.1, TCP port 5001
TCP window size: 16.0 KByte
------------------------------------------------------------
[  2] local 10.0.1.2 port 17206 connected with 10.0.1.1 port 5001
[ ID] Interval       Transfer     Bandwidth
[  2] 0.00-1.00 sec  49.1 MBytes   412 Mbits/sec
[  2] 1.00-2.00 sec  49.2 MBytes   412 Mbits/sec
[  2] 2.00-3.00 sec  48.8 MBytes   409 Mbits/sec
[  2] 3.00-4.00 sec  49.8 MBytes   418 Mbits/sec
[  2] 4.00-5.00 sec  51.6 MBytes   433 Mbits/sec
[  2] 0.00-5.01 sec   249 MBytes   416 Mbits/sec
nsh> 
nsh> iperf2 -s -i 1 
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 16.0 KByte
------------------------------------------------------------
tcpnodelay failed: Unknown error 38
[  3] local 10.0.1.2 port 5001 connected with 10.0.1.1 port 60610
[ ID] Interval       Transfer     Bandwidth
[  3] 0.00-1.00 sec  44.9 MBytes   377 Mbits/sec
[  3] 1.00-2.00 sec  43.9 MBytes   368 Mbits/sec
[  3] 2.00-3.00 sec  49.6 MBytes   416 Mbits/sec
[  3] 3.00-4.00 sec  47.6 MBytes   399 Mbits/sec
[  3] 4.00-5.00 sec  48.6 MBytes   407 Mbits/sec
[  3] 0.00-5.00 sec   235 MBytes   394 Mbits/sec

zhhyu7 avatar Dec 09 '25 13:12 zhhyu7

I'm confused about what's been removed? Is there no longer a netdev work thread? Why? Am I correct in thinking that users can't choose between HPWORK and LPWORK queues anymore?

Why not split the commits into multiple PRs? The PR title is misleading since this is much more than modifying a Kconfig variable. Can you please update it?

@linguini1 As mentioned in the Summary, it is change the configuration from defconfig to be specified by the code when the network card is initialized. The relevant configuration methods have also been updated in the documentation.

dev->rxtype = NETDEV_RX_WORK;
dev->priority = HPWORK;

Now rx direct has been removed from patch chain. Previously, I just wanted to synchronously demonstrate how to do the related extension support in the new upperhalf.

zhhyu7 avatar Dec 09 '25 15:12 zhhyu7

The relevant configuration methods have also been updated in the documentation.

I don't see any documentation updates in this PR. Is it in a separate PR?

dev->rxtype = NETDEV_RX_WORK;
dev->priority = HPWORK;

This looks fine but is it accessible from the external API when registering? Sorry I haven't looked very closely at the code change yet.

linguini1 avatar Dec 11 '25 16:12 linguini1

The relevant configuration methods have also been updated in the documentation.

I don't see any documentation updates in this PR. Is it in a separate PR?

dev->rxtype = NETDEV_RX_WORK;
dev->priority = HPWORK;

This looks fine but is it accessible from the external API when registering? Sorry I haven't looked very closely at the code change yet.

He included the documentation at Documentation/components/net/netdriver.rst but as you noticed it is missing the new API: netdev_upper_exit_thread()

acassis avatar Dec 11 '25 17:12 acassis

The relevant configuration methods have also been updated in the documentation.

I don't see any documentation updates in this PR. Is it in a separate PR?

dev->rxtype = NETDEV_RX_WORK;
dev->priority = HPWORK;

This looks fine but is it accessible from the external API when registering? Sorry I haven't looked very closely at the code change yet.

He included the documentation at Documentation/components/net/netdriver.rst but as you noticed it is missing the new API: netdev_upper_exit_thread()

@acassis but netdev_upper_exit_thread is an internal static function, which isn't callable from lowerhalf driver.

xiaoxiang781216 avatar Dec 13 '25 08:12 xiaoxiang781216

The relevant configuration methods have also been updated in the documentation.

I don't see any documentation updates in this PR. Is it in a separate PR?

dev->rxtype = NETDEV_RX_WORK;
dev->priority = HPWORK;

This looks fine but is it accessible from the external API when registering? Sorry I haven't looked very closely at the code change yet.

He included the documentation at Documentation/components/net/netdriver.rst but as you noticed it is missing the new API: netdev_upper_exit_thread()

@acassis but netdev_upper_exit_thread is an internal static function, which isn't callable from lowerhalf driver.

Hmm, ok in this case it is not a visible API. Thank you @xiaoxiang781216

acassis avatar Dec 13 '25 21:12 acassis