692 Commits

Author SHA1 Message Date
Piyush Patle 0dccc8ba21 include/debug.h: Move to include/nuttx/debug.h
debug.h is a NuttX-specific, non-POSIX header. Placing it in the
top-level include/ directory creates naming conflicts with external
projects that define their own debug.h.
This commit moves the canonical header to include/nuttx/debug.h,
following the NuttX convention for non-POSIX/non-standard headers,
and updates all in-tree references.

A backward-compatibility shim is left at include/debug.h that
emits a deprecation #warning and re-includes <nuttx/debug.h>,
allowing out-of-tree code to continue building while migrating.

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
2026-04-07 07:50:06 -03:00
Shunchao Hu 7b60f6dfec drivers/net/telnet: Fix typo.
This commit fixed code comment typo in telnet.c.

Signed-off-by: Shunchao Hu <ankohuu@gmail.com>
2026-03-25 20:49:43 +08:00
Shunchao Hu b86b309eea drivers/net/telnet: Ignore unsupported subnegotiation data.
Ignore unsupported telnet subnegotiation payload until `IAC SE` so
option bytes do not leak into the first NSH command.

Keep existing NAWS handling intact and also treat `IAC IAC` inside
subnegotiation payload as an escaped `0xFF` data byte rather than a
subnegotiation terminator.

This makes subnegotiation parsing RFC-compliant for both unsupported
options and NAWS payload processing.

Signed-off-by: Shunchao Hu <ankohuu@gmail.com>
2026-03-25 19:21:30 +08:00
wangchengdong 784a469e02 drivers/net: remove nxsig_notification when signal support is disabled
When all signals are disabled, nxsig_notification is not available and
should not be invoked. Remove the call to avoid build and runtime issues
in no-signal configurations.

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-02-26 20:03:05 +08:00
zhanghongyu a7567677a8 netdev_driver: add carrier_on to xxx_ifup where carrier_on is absent
since the judgment for network card selection was changed from IS_UP to
IS_RUNNING, drivers that lack carrier_on need to add the carrier_on
operation; otherwise, network access issues will occur.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-02-02 13:23:05 +08:00
yinshengkai 2c1a615442 net: access the serial port in raw format to avoid character escaping
If the serial port is set to isconsole,
\n will be escaped as \r\n, causing communication failure.

Signed-off-by: yinshengkai <yinshengkai@bytedance.com>
2026-01-22 23:17:08 +08:00
zhanghongyu be74eec727 rpmsgdrv.c: add spinlock to protect rxqueue
avoid race conditions when the rpmsg thread and network card thread
access the rxqueue simultaneously.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-16 09:42:01 +08:00
zhanghongyu ba4361ccd8 drivers/net/rpmsgdrv.c: rename priv to drv and priv_ to priv
optimize variable naming to improve code readability

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-16 09:42:01 +08:00
zhanghongyu be3ad13260 drivers/net/rpmsgdrv.c: add bidirectional data netdev support, server side
Server side: when ns_bind, create the netdev.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-16 09:42:01 +08:00
zhanghongyu 34b350e66e drivers/net/rpmsgdrv.c: add bidirectional data netdev support, clien side
It's the first simple version of rpmsg-net, include:
- Transfer command with data copy (maybe optimize later), no need to ack
- Control command with ack, but only ifup/ifdown no need to ack
- Client side: Another module can call `net_rpmsg_drv_alloc` to
  create netdev and register it.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2026-01-16 09:42:01 +08:00
zhanghongyu f914bb8f03 drivers/net/rpmsgdrv.c: add response flag to distinguish message direction
control messages add a confirmation mechanism.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-16 09:42:01 +08:00
zhanghongyu 1f48d4d940 drivers/net/rpmsgdrv.c: adaptation netdev_upperhalf
simplify the code logic of rpmsgdrv.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-16 09:42:01 +08:00
liqinhui 3843f7b4fe wifi: Support the wifi operations based on the bss file.
Add support for BSS file-based WiFi simulation.

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2026-01-14 09:22:54 +08:00
liqinhui 58110f3d1a drivers/net: Fix crash in wifi_sim disconnect.
Add WLAN_STA_STATE_DISCONNECTED state to prevent race conditions or invalid state handling during disconnect.

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2026-01-14 09:22:40 +08:00
zhanghongyu 3bb8749672 drivers/net/igc.c: fix build error
otherwise, enable CONFIG_NETDEV_STATISTICS will result in a compile error

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-13 02:17:15 +08:00
zhanghongyu 02645974cb drivers/net/igc.c: add device id 0x15f3 support
add the network card models whose functions have been confirmed to the
id table.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-08 09:49:07 -03:00
zhanghongyu 446aecdd61 drivers/net/e1000.c: add PIDVID of e1000 NIC
add the network card models whose functions have been confirmed to the
id table.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-08 09:49:07 -03:00
zhanghongyu fa6c8579dd driver/net: replace net_lock with netdev_lock
modify the code of the adapted protocol stack to avoid deadlocks and the
logic that cannot be protected by locks after modification.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-06 16:08:30 +08:00
zhanghongyu b0ab56aca2 netdev_upperhalf: add direct rx mode
avoid packet processing delays caused by task switching,
to support those applications that are extremely time-sensitive.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-12-29 14:29:24 +08:00
zhanghongyu 3e18d72661 netdev_upperhalf.c: add vlan lock in rxpoll flow
Protect the RX process of the VLAN network card.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-12-29 09:42:18 +08:00
zhanghongyu eb60667561 net/utils/net_lock.c: add api to lock conn and netdev
add new api to protect access and operation to conn and dev

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-12-29 09:42:18 +08:00
gaohedong 292276101b net/vlan: make a judgment before calling fuction
Make a judgment before calling fuction.

Signed-off-by: gaohedong <gaohedong@xiaomi.com>
2025-12-27 20:46:04 +08:00
zhanghongyu 6144b51848 netdev_upperhalf.c: support alloc iob from CAN buffer pool
when the network card type is NET_LL_CAN, packets are defaultly
allocated from the can buffer.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-12-25 08:56:12 -03:00
wangchen fac6c2a82c loopback:setting loopback network driver sending task to the HPWORK queue
Build Documentation / build-html (push) Has been cancelled
The loopback network driver sending task is placed in the LPWORK queue, which may result in delayed scheduling when the CPU usage reaches 100%, leading to the timely sending of cached messages from the loopback network driver and causing issues with post waitsem being too late​.we decied to set loopback sending task to the HPWORK queue.

Signed-off-by: wangchen <wangchen41@xiaomi.com>
2025-12-23 09:27:20 -03:00
wangchen 07247be9f6 wifi_sim.c:resolve issue in wapi save_config & wapi reconnect command
resolve issue in wapi save_config & wapi reconnect command in qemu

Signed-off-by: wangchen <wangchen41@xiaomi.com>
2025-12-23 09:06:11 -03:00
zhanghongyu 2ebb08e78f netdev_upperhalf: avoid recursion during transmission
to avoid uncontrollable stack overhead, we actively
avoid scenarios where recursion occurs.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-12-20 10:58:16 +08:00
zhanghongyu 16947ddacd netdev_upperhalf: modify txavail to be sent directly in the current thread
avoid packet processing delays caused by task switching,
to support those applications that are extremely time-sensitive.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-12-20 10:58:16 +08:00
zhanghongyu aa8ffea3cf netdev_upperhalf: convert Kconfig to variable
Build Documentation / build-html (push) Has been cancelled
Upperhalf supports multiple working modes at the same time,
which is specified by NIC when register

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-12-14 10:01:22 +08:00
zhanghongyu 84895c8e70 Revert "e1000: add polling mode support for tx/rx"
Remove the previously supported polling mode. If necessary in the
future, switch to a new solution for implementation.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-12-14 10:01:22 +08:00
zhangkai25 ad422684d4 drivers/net: Ethernet protocol stack key abnormal point pile for DFX
add log output for error flow

Signed-off-by: zhangkai25 <zhangkai25@xiaomi.com>
2025-12-09 07:56:20 -03:00
zhanghongyu 4f7e03db2e netdev_upperhalf.c: add net_lock when vlan_foreach
avoid illegal address access caused by removing vlan
network cards during the traversal of vlan network cards

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-12-09 07:56:20 -03:00
gaohedong 00dfb5d1f3 ethernet: Release iob when dropping ethernet packets
Release iob when dropping ethernet packets

Signed-off-by: gaohedong <gaohedong@xiaomi.com>
2025-12-09 07:56:20 -03:00
Zhe Weng 8d7799d6c1 net/vlan: Allow setting default priority (PCP)
1. We add default PCP because some of our apps may not want to set PCP
   manually (e.g. Our user may just ping with pre-set PCP)
2. The `vlan_qos` is used as PCP when setting Linux's priority mapping:
   https://github.com/torvalds/linux/blob/v6.12/net/8021q/vlan.c#L590
   Although `vlan_qos` is not used when creating VLAN on Linux, we can
   use it as PCP on creating VLAN (without changing its meaning), and
   keep compatible with Linux's creating (Exactly the same when
   `vlan_qos` is 0).

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2025-12-09 07:56:20 -03:00
Zhe Weng 2b34bcfcb1 netdev/ioctl: Add support for simple VLAN ioctl
Supporting ADD_VLAN_CMD and DEL_VLAN_CMD of SIOCSIFVLAN
Ref: https://github.com/torvalds/linux/blob/v6.12/net/8021q/vlan.c#L621

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2025-12-09 07:56:20 -03:00
Zhe Weng 242c253178 net: Add VLAN device support
Inspired by Linux's way, we also create VLAN devices for managing VLAN,
which will become interfaces like `eth0.58`.

QinQ is also supported, we can create VLAN devices above another VLAN
devices, like `eth0.100.101` (or even `eth0.1.2.3.4`, also supported on
Linux).

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2025-12-09 07:56:20 -03:00
Zhe Weng 750fae4cca netdev/lower: Support share quota between devices
To prepare for VLAN device support, a VLAN device will share quota with
its real device.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2025-12-09 07:56:20 -03:00
daichuan afc210667d netdev_upperhalf.c: modify for maybe use after free with upper pointer
avoid continuing to access the released memory after the netdev_register
error occurs.

Signed-off-by: daichuan <daichuan@xiaomi.com>
2025-12-09 07:56:20 -03:00
Zhe Weng b2db3a6430 net/netdev: Add netdev_iob_replace_l2 for netdev to avoid misuse
And fix wrong `d_len` for IOBs from `upper->txq` in TX.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2025-12-09 07:56:20 -03:00
zhanghongyu 521e319aa3 drivers/net: replace critical_section with spinlock
so as to better support multi-core scenarios

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-12-09 14:43:59 +08:00
wangchen fe822145a3 tun:modify issue of repeatly tun_close failed
after the network card is turned off, read and write operations need
to return -ENETDOWN, and it is necessary to wake up the waiting read
and write operations.

Signed-off-by: wangchen <wangchen41@xiaomi.com>
2025-12-09 14:43:59 +08:00
chao an 87f134cfaa sched/sleep: replace all Signal-based sleep implement to Scheduled sleep
Nuttx currently has 2 types of sleep interfaces:

1. Signal-scheduled sleep: nxsig_sleep() / nxsig_usleep() / nxsig_nanosleep()
Weaknesses:
a. Signal-dependent: The signal-scheduled sleep method is bound to the signal framework, while some driver sleep operations do not depend on signals.
b. Timespec conversion: Signal-scheduled sleep involves timespec conversion, which has a significant impact on performance.

2. Busy sleep: up_mdelay() / up_udelay()
Weaknesses:
a. Does not actively trigger scheduling, occupy the CPU loading.

3. New interfaces: Scheduled sleep: nxsched_sleep() / nxsched_usleep() / nxsched_msleep() / nxsched_ticksleep()
Strengths:
a. Does not depend on the signal framework.
b. Tick-based, without additional computational overhead.

Currently, the Nuttx driver framework extensively uses nxsig_* interfaces. However, the driver does not need to rely on signals or timespec conversion.
Therefore, a new set of APIs is added to reduce dependencies on other modules.

(This PR also aims to make signals optional, further reducing the code size of Nuttx.)

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-10-17 14:05:02 +08:00
LuchianMihai 95efa6f7cf net/mdio: add mdio bus
Currently the mdio communication is part of the monolithic 'full netdevs'.
This commit serves as an way to add modularity for the netdevs drivers.
A new upperhalf/lowerhalf mdio device comes with this commit that manages the data transfer ofer mdio interface.

Signed-off-by: Luchian Mihai <luchiann.mihai@gmail.com>
2025-09-25 16:24:18 +08:00
michal matias 0f498005f0 drivers/net/oa_tc6: Add driver for the Microchip LAN865x SPI MAC-PHY
Add driver for the LAN865x 10BASE-T1S SPI MAC-PHY.
The driver is a lower-half driver to the OA-TC6 base driver.

Signed-off-by: michal matias <mich4l.matias@gmail.com>
2025-09-03 00:53:03 +08:00
michal matias fbb3b6d07b drivers/net/oa_tc6: Add driver for the Onsemi NCV7410 (NCN26010) SPI MAC-PHY
Add driver for the Onsemi NCV7410 10BASE-T1S SPI MAC-PHY.
The driver also works for the NCN26010, which is an identical chip.
The driver is a lower-half driver to the OA-TC6 base driver.

Signed-off-by: michal matias <mich4l.matias@gmail.com>
2025-09-03 00:53:03 +08:00
michal matias 95b3b65778 drivers/net: Add base driver for the OA-T6 protocol MAC-PHYs
Add base driver common for OPEN Alliance 10BASE-T1x MAC-PHY Serial Interface (OA-TC6)
protocol SPI MAC-PHYs.

Signed-off-by: michal matias <mich4l.matias@gmail.com>
2025-09-03 00:53:03 +08:00
simbit18 aadb929526 drivers/net/CMakeLists.txt: Aligned Cmake with Make
Add KSZ9477 driver #10503

Signed-off-by: simbit18 <simbit18@gmail.com>
2025-08-27 11:05:32 +08:00
Jani Paalijarvi e2b1d186d7 drivers/net/ksz9477.c: Errata 16, reset SGMII always on init 2025-08-26 09:10:43 -03:00
Jari Nippula 56870fb0ea ksz9477: MMD indirect access check fix
Instead of verifying MMD indirect access by checking
EEE ADVERTISEMENT register has value 0x6 (which may be changed),
the verification is done by write and check LED MODE register.
1. Backup current LED_MODE register value
2. Write value Single-LED mode (0x10) to LED_MODE
3. Read LED_MODE register and verify it returns value 0x10
4. Write original (backup) value to LED_MODE
2025-08-26 09:10:43 -03:00
Jani Paalijarvi fcab00d3a8 drivers/net/ksz9477: Implement errata fixes
From the ksz9477 errata, setup the configuration which is tested to work.

- Improve PHY receive performance
- Disable EEE for ports 1-5
- Fix supply current values

Signed-off-by: Jani Paalijarvi <jani.paalijarvi@unikie.com>
2025-08-26 09:10:43 -03:00
michal matias 4a4235b5a2 drivers/net: Remove the NCV7410 10BASE-T1S MAC-PHY driver
This commit removes existing support for the NCV7410 10BASE-T1S MAC-PHY.
The driver will be replaced by its generalized version with different organization.
The new driver has naming clashes with the old, therefore the old has to be removed first.

Signed-off-by: michal matias <mich4l.matias@gmail.com>
2025-08-25 20:32:35 +08:00