Commit Graph

596 Commits

Author SHA1 Message Date
Petro Karashchenko d499ac9d58 nuttx: fix multiple 'FAR', 'CODE' and style issues
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2024-08-25 19:22:15 +08:00
guoshichao cd52edd6d7 greenhills: fix enumerated type mixed with another type warning
"net/netdev_upperhalf.c", line 133: warning #188-D: enumerated type mixed with
          another type
        total += netdev_lower_quota_load(lower, type);

CC:  dirent/lib_alphasort.c "spi/spi_transfer.c", line 83: warning #188-D: enumerated type mixed with
          another type
    SPI_SETMODE(spi, seq->mode);
    ^

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2024-08-24 20:43:53 +08:00
daichuan a9e2942d8f support mutil thread with netdev upperhalf
Signed-off-by: daichuan <daichuan@xiaomi.com>
2024-08-24 20:41:40 +08:00
Zhe Weng acbddd11d5 net/netdev: Add periodic log for netdev statistics
Work for every network device using `CONFIG_NETDEV_STATISTICS`.

Log style:
<interface>:T{done}/{total},R({v4}+{v6})/{total} {Protocol}:T{tx},R{rx},D{drop}
Example:
wlan0:T10/10,R(10+20)/31 TCP:T0,R0,D0 UDP:T0,R10,D0 ICMP:T0,R0,D0 ICMP6:T0,R0,D0

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-08-22 16:17:56 +08:00
chenrun1 cfcf347515 nuttx/atomic.h:replace ALL stdatomic.h with nuttx/stdatomic.h in nuttx/
Summary:
 1. use nuttx/atomic.h instead of stdatomic
 2. remove CONFIG_HAVE_ATOMIC,because we now support atomic on all platforms

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-08-22 01:44:29 +08:00
liqinhui 4fa5451595 simwifi: Fix the error of the return value in wifidriver_set_txpower.
Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2024-08-21 23:36:26 +08:00
liqinhui ae2ebce42b qemuwifi: Support the ioctl SIOCGIWENCODEEXT.
Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2024-08-21 13:25:53 +08:00
liqinhui e04aa9ac51 wifisim: Support the setting of the number of simulated WiFi interfaces.
Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2024-08-21 13:25:53 +08:00
liqinhui f1a566f7f6 wifisim: Fix the problem of scan crash.
Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2024-08-21 13:25:53 +08:00
liqinhui 10eaf1eafe wifisim:Modify the problem of password verification.
Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2024-08-21 13:25:53 +08:00
liqinhui 2e9f00d0db wifisim:Fix an assignment error.
Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2024-08-21 13:25:53 +08:00
liqinhui f53f4fb32f wifisim: set carrier on only when wifidriver_start_connect returns OK.
Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2024-08-21 13:25:53 +08:00
liqinhui e9ba55818f wifisim:Modify the down operation logic of the wlan interface.
Align with the linux ifconfig down behavior.

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2024-08-21 13:25:53 +08:00
liqinhui c3df7c5b00 wifisim: Modify the connection logic based on BSSID.
Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2024-08-21 13:25:53 +08:00
liqinhui 06c1db81ff wifisim: Open the bss file with O_RDONLY.
Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2024-08-21 13:25:53 +08:00
zhanghongyu ccf60a7bab netdev_upperhalf: add polling mode support for tx/rx
support more work modes to support more scenarios

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2024-08-21 02:31:53 +08:00
zhanghongyu d740a8e73c netdev_lowerhalf: add reclaim callback in netdev_ops_s
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2024-08-21 01:39:34 +08:00
wangchen a18aebc2c6 wifi_sim.c:fix compile warning
Signed-off-by: wangchen <wangchen41@xiaomi.com>
2024-08-20 14:46:15 +08:00
Zhe Weng 4b5585a316 netdev/upper: Delay replied packets to prevent TX quota become negated
When our netstack is replying packets when processing RX, the replied
packets will be sent without considering of TX quota because we don't
want to drop them. Now we may delay them by pushing them to a queue and
send them later, which can always keep quota working.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-08-20 06:37:46 +08:00
chenxiaoyi 538582ede1 convert pointer string to number in base 16
Co-authored-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
Co-authored-by: xuxin19 <xuxin19@xiaomi.com>
2024-08-14 22:36:57 +08:00
zhangshuai39 a1f9a6624e net/tun:Remove unused variables in read & write
Signed-off-by: zhangshuai39 <zhangshuai39@xiaomi.com>
2024-08-13 16:34:14 +08:00
chenwen@espressif.com e0b99216b0 driver/net/lan9250: Add lan9250_ioctl and lan9250_uninitialize APIs
- use 'lan9250_ioctl' to set and get the value of lan9250 phy register
    - use `lan9250_uninitialize` to un-initialize the ethernet driver

Signed-off-by: chenwen@espressif.com <chenwen@espressif.com>
2024-07-15 19:41:15 +08:00
Jani Paalijarvi 92747b7529 drivers/net/ksz9477: Add port mirroring support
Signed-off-by: Jani Paalijarvi <jani.paalijarvi@unikie.com>
2024-06-27 18:09:57 +08:00
Zhe Weng c234fac910 net/netdev: Check quota when registering lower-half devices
Some drivers may set too big quota by accident and consume all of our
buffers, so we add a check when registering devices.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-05-14 17:43:26 -03:00
meijian 667b9eabdd [driver][tun]: add tx packets dump
Signed-off-by: meijian <meijian@xiaomi.com>
2024-05-14 22:05:08 +08:00
Jukka Laitinen 9277be2503 Add configuration option for RTL8211F RGMII PHY
Also extend the "struct phy_desc_s" to support for 1GB PHY's, the speed
detection always needs more than one bit.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2024-05-02 16:30:41 -03:00
zhanghongyu 92cd1c3742 netdev_upperhalf: add L3 packet handle
To provide support for the received L3 network packets

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2024-04-22 23:44:37 +08:00
chenwen@espressif.com 252e0f8a97 drivers/net/lan9250: Fix crash issue of sending packets by lan9250 driver under SMP and multi-thread
Signed-off-by: chenwen@espressif.com <chenwen@espressif.com>
2024-04-03 10:06:43 -03:00
zhanghongyu e93bdfe089 tun: in tun_write, try to release iob before iob_prepare
io_pktlen will incorrect when two packets are received in a row and the packet length decreases.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2024-03-13 22:23:52 +08:00
Bowen Wang 169f47beec rpmsg: make all the rpmsg services deponds on RPMSG
After decoupled the rpmsg and rptun, all the rpmsg service should
depends on the RPMSG.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-02-18 04:09:34 -08:00
David Sidrane 93f37ab1da net:Add support for multi PHY
Support runtime phy selection based on a list
   supplied by board.h
   For Example:

   #define BOARD_ETH0_PHY_LIST                   \
	{                                        \
		"LAN8742A",                      \
		MII_PHYID1_LAN8742A,             \
		MII_PHYID2_LAN8742A,             \
		MII_LAN8740_SCSR,                \
		0,                               \
		0xffff,                          \
		MII_LAN8720_SPSCR_10MBPS,        \
		MII_LAN8720_SPSCR_100MBPS,       \
		MII_LAN8720_SPSCR_DUPLEX,        \
		22,                              \
	},                                       \
	{                                        \
		"TJA1103",                       \
		MII_PHYID1_TJA1103,              \
		MII_PHYID2_TJA1103,              \
		0xffff,                          \
		18,                              \
		0xffff,                          \
		0,                               \
		MII_LAN8720_SPSCR_100MBPS,       \
		MII_LAN8720_SPSCR_DUPLEX,        \
		45,                              \
	},                                       \
2024-01-06 04:26:12 -08:00
Jukka Laitinen ebe961df9e drivers/net/ksz9477: Add simple port-based static VLAN configuration
Add a static port-based VLAN configuration for KSZ9477 switch. This doesn't
use the VLAN tagging, but is a switch's internal mechanism to simply configure
if the packet forwarding is allowed from one port to another.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2023-12-20 01:30:54 -08:00
Zhe Weng 5aeb15469a netdev/ipv6: Move `xxx_ipv6multicast` from arch to common code
The `xxx_ipv6multicast` function in each driver is not adapted to
multiple IPv6 addresses yet, and they're redundant, so try to take them
into common code.

Change:
1. Add MAC `g_ipv6_ethallnodes` and `g_ipv6_ethallrouters` in
   `icmpv6_devinit` and call them in `netdev_register`
2. Add multicast MAC for Neighbor Solicitation when adding any IPv6
   address, and remove them when IPv6 address is removed
3. Select `NET_MCASTGROUP` when `NET_ICMPv6` because now we need
   `d_addmac` when we have ICMPv6

Note:
We want modules outside net stack to call functions like
`netdev_ipv6_add` and never touch the related MAC address, so these MAC
functions are added as internal functions to `net/netdev/netdev.h`

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-12-16 05:26:16 -08:00
liqinhui 98e3615b60 net/netdev: Modify the logic for setting the IFF_RUNNING status of interfaces.
Refer to the logic of the `netif_carrier_on` on linux.
https://github.com/torvalds/linux/blob/master/net/sched/sch_generic.c#L575

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2023-12-15 18:24:23 -08:00
liqinhui 6a8c638d57 qemu/wifi: Add the virtual wifi function on the emulator.
-The qemu wifi fucntion only supports the STA mode and the following
 operations:
 wapi mode wlan0 2
 wapi scan wlan0
 wapi psk wlan0 password 3
 wapi essid wlan0 wifi_name 1
 wapi show wlan0
 wapi disconnect wlan0
-Eanble the virtual wifi function with the MACRO `CONFIG_DRIVERS_WIFI_SIM`.

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2023-12-14 20:22:12 -08:00
Zhe Weng 22b6076f26 net/udp: Add check when sending too big packet without IP frag
Commit 8a63d29c removed `devif_iob_send` from `udp_sendto_buffered`
workflow, `devif_iob_send` drops too big packet. Now we still need a
place to check the packet length, otherwise a packet larger than MTU
may be sent to the net driver.

In case of similar problem happens somewhere else, this commit also
adds a check in `netdev_upperhalf`, and count these cases into
`NETDEV_TXERRORS`.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-12-12 06:42:33 -08:00
Xiang Xiao ca5a9c711a Remove @ and % tag from all comments
and format the multiple line comments

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-12-11 17:00:10 -03:00
Dong Heng bf54a5ae50 driver/net/lan9250: Add LAN9250 driver(SPI and QSPI mode) 2023-12-07 19:53:05 -08:00
Zhe Weng bd19065933 net/loopback: Fix flags of lo device
netdev_register will set IFF_LOOPBACK in d_flags, we should not just
change it into IFF_UP only.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-11-29 07:57:01 -08:00
Xiang Xiao eddd90de78 poll: pollsetup should notify only one fd passd by caller
since it's redundant to iterate the whole fds array in setup

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-11-21 09:07:17 +01:00
Jonathan Kimmitt f4b77f078b skeleton.c doesn't compile without this patch if ioctls are enabled 2023-11-18 17:05:53 -08:00
Zhe Weng 3e4d847f42 net/netdev: Support managing multiple IPv6 addresses by ioctl
1. Supporting `SIOCSIFADDR` and `SIOCDIFADDR` with Linux in6_ifreq struct to manage ipv6 addresses.
   Ref: https://man7.org/linux/man-pages/man7/netdevice.7.html
2. Supporting alias like 'eth0:0' for multiple IPv6 addresses, to keep previous ioctl `SIOCGLIFADDR`, `SIOCSLIFADDR`, `SIOCGLIFNETMASK` and `SIOCSLIFNETMASK` working.
   Ref: https://man7.org/linux/man-pages/man8/ifconfig.8.html

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-11-07 19:30:36 +08:00
raiden00pl b565e28da3 Kconfigs: rename {Rpmsg|rpmsg} to RPMGS 2023-10-28 13:58:56 +08:00
zhanghongyu 5374af077b tun: Fix the error of calling tun_close when tun_txavail or tun_txavail_work is executed
When tun_txavail_work is running, switch to tun_close thread and priv->lock will be destroyed, then switch back to tun_txavail_work thread, an error will occur when nxmutex_unlock(&priv->lock)

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-10-25 01:13:21 +08:00
zhanghongyu 3b469271d7 Revert "tun: Fix the error of calling tun_close when tun_txavail or tun_txavail_work is executed"
This reverts commit 0f1a49bba5.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-10-25 01:13:21 +08:00
zhanghongyu 0f1a49bba5 tun: Fix the error of calling tun_close when tun_txavail or tun_txavail_work is executed
When tun_txavail_work is running, switch to tun_close thread and priv->lock will be destroyed, then switch back to tun_txavail_work thread, an error will occur when nxmutex_unlock(&priv->lock)

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-10-21 06:29:21 +08:00
liqinhui d27ca03b6c wifi/simdriver: Support the sim wifi.
Add the Sim WiFi function, which can provide the wifi operating on nuttx sim emulator,
  and support two modes that simulate wifi, HWSIM and RNC(real network card).

 - In the HWSIM mode, we simulates two wlan interfaces. The wlan0 is STA and
   the wlan1 is AP. The wlan0 can connect to the wlan1 in the nuttx simulator.
 - In the RNC mode, we can use the same wlan interface name on the nuttx simulator
   to control the connection behavior of the real wireless card.

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2023-10-12 17:08:25 +08:00
wanggang26 e930476b4b enable O_CLOEXEC explicit
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2023-09-22 13:51:00 +08:00
Jani Paalijarvi c8540a1f9b drivers/net/rpmsgdrv.c: Improve init error handling
Signed-off-by: Jani Paalijarvi <jani.paalijarvi@unikie.com>
2023-09-20 19:23:14 +08:00
Jani Paalijarvi 999970b820 drivers/net/rpmsgdrv.c: Take netdev_register() return value into account
Signed-off-by: Jani Paalijarvi <jani.paalijarvi@unikie.com>
2023-09-20 19:23:14 +08:00