Connecting sometimes hung with an endless flood of
"nl80211: send_and_recv->nl_recvmsgs failed: -4 (Try again)". -4 is
libnl NLE_AGAIN: the non-blocking netlink socket has no data and
hostap's send_and_recv() busy-loops until the command's ACK arrives.
The host adapter runs two threads: the eloop thread (host_handler)
services the nl80211 event sockets, including bss->nl_connect, while the
Zephyr supplicant thread issued the authenticate/associate/deauthenticate
ops with send_and_recv() on that same bss->nl_connect socket. When a
connect command ran on the Zephyr thread while the eloop thread was also
reading bss->nl_connect, the eloop could consume the command's ACK,
leaving send_and_recv() spinning on NLE_AGAIN forever. It was
intermittent because it is a race over which thread reads the socket
first.
Run those three MLME commands on the thread that owns the netlink
sockets instead. A small command-handoff (cmd_fd/cmd_done_fd socketpair
plus pending_cmd) lets the Zephyr caller publish a request, wake the
eloop, and block until the eloop thread has executed the op; the
argument is passed by pointer since both threads share one address
space. With a single thread doing the netlink I/O there is no concurrent
reader to steal the ACK.
Only the bss->nl_connect commands are marshalled. Scan and the other
ops use global->nl, which the eloop does not service, so they are not
raced and stay on the Zephyr thread; moving the scan path onto the eloop
thread was observed to starve event processing and perturb scan timing.
Tested on native_sim against the net-tools mac80211_hwsim setup: the
interop test passes 5/5 across repeated runs and rapid connect/disconnect
cycles no longer produce the "Try again" flood.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add a Wi-Fi driver for the native_sim board so the Zephyr Wi-Fi stack
(network manager / wpa_supplicant, net_mgmt, the wifi shell) can be
exercised on the host against the Linux mac80211_hwsim simulated radio.
It is meant for development and verification of the Wi-Fi APIs, not as a
driver for any real hardware.
The Zephyr wpa_supplicant is the sole SME. The driver's host side brings
up only the Linux nl80211 driver (compiled for the native_simulator
runner) and runs its event loop in a thread; it does not run a second,
host-side supplicant. It provides its own wpa_supplicant_event() that
forwards nl80211 driver events (scan results, auth, assoc, deauth,
disassoc, mgmt rx) to the Zephyr supplicant over an in-process
socketpair, read by the interface RX thread and dispatched to the
supplicant callbacks. The supplicant driver ops (scan, authenticate,
associate, set_key, get_capa, ...) call the nl80211 ops table directly.
Data frames, including the EAPOL 4-way handshake, flow over an AF_PACKET
socket bound to the host interface and the Zephyr networking stack.
Notes on the host integration:
- The Zephyr interface adopts the host radio MAC address, so frames
addressed to the associated STA are accepted by the Ethernet L2 and
the frames it transmits are not rejected by the AP.
- control-port-over-nl80211 is disabled in the driver capabilities so the
kernel delivers EAPOL as data frames to the supplicant's l2_packet.
- The interface uses carrier-up plus dormant, leaving dormant on
association so the handshake can use the data path, and re-entering it
on disconnect.
- A small supp_api hook lets the supplicant connect path notify this
proxy driver; the connection itself is driven by the Zephyr SME.
Tested on native_sim with mac80211_hwsim: scan, connect (open and
WPA2-PSK), status, disconnect and data transfer all work.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The driver selected EXPERIMENTAL only for a subset of host SoCs. A
Kconfig symbol's maturity is a property of the whole driver, it cannot
be experimental on one SoC and supported on another. Drop the
conditional select and mark the nRF70 driver supported everywhere.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Assisted-by: Cursor:Auto
wifi_shell.c carried a private wifi_freq_to_channel() and the
hwsim driver open coded the same conversion twice, as a plain
(freq - 2407) / 5. Neither matches wifi_utils_chan_to_freq() at
channel 14: 2484 MHz maps back to channel 15, which has no
frequency, so a radio set up from a frequency alone ends up off
the medium.
Add wifi_utils_freq_to_chan() as the inverse of the forward
helper. A candidate channel is only returned once it converts
back to the frequency asked for, so the two directions cannot
drift and a frequency between two channel centers is rejected.
No band argument is needed because a center frequency is unique
across the bands. Drop the shell copy and use the helper in both
places.
The shell copy resolved neither the 5 GHz channels 32, 68 and 96
nor any 6 GHz channel, and printed the raw frequency in the
channel column for those. They now resolve, and a frequency that
belongs to no channel prints as 0 rather than as itself.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Replace the local 2.4 GHz channel to frequency macros with
wifi_utils_chan_to_freq(). The remaining conversions in this
driver go through the vendor HAL and are left alone.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Drop the two local mhz_from_2g_channel() and
mhz_from_5g_channel() helpers in favour of
wifi_utils_chan_to_freq(), so the band tables are built from the
same conversion as the rest of the tree.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Replace the open coded channel to frequency conversion with
wifi_utils_chan_to_freq().
The old code clamped every frequency above 2472 MHz to 2484 MHz,
so a channel beyond 14 was reported as channel 14. The helper
returns 0 for a channel that is not valid in the band, and such a
channel is now left out of the reported list instead of being
emitted with a zero center frequency.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Replace the open coded 2.4 GHz channel to frequency arithmetic,
which was spread over a macro in one file and five separate
expressions in the others, with wifi_utils_chan_to_freq().
None of the copies handled channel 14, so they reported it as
2477 MHz instead of 2484 MHz. The base frequency define stays for
the two frequency to channel conversions in wifi_hwsim_supp.c,
which a later commit converts as well.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
The IW416 and IW61X module choices only covered the AzureWave and
Murata modules, so the u-blox and Quectel modules had no way to
be selected from Zephyr.
Signed-off-by: Sanjay Yadav <sanjay.yadav@nxp.com>
NXP_WIFI_COMPRESS_TX_PWTBL was not selectable for IW416, so IW416 kept
using the legacy per-channel TRPC tx power tables. Add NXP_IW416 to the
if block and to its depends on, and give NXP_WIFI_CLOCKSYNC an explicit
depends on so it stays disabled for IW416.
Also drop the NXP_IW416_REGION and NXP_IW61X_REGION choices. The driver
now selects the region table at runtime from the country code, and one
WW header already carries the WW, JP, US, EU and CA tables, so the
per-region headers are redundant. The header is selected per chip in the
wifi_nxp CMakeLists instead, as RW610 already does.
Signed-off-by: Gaofeng Zhang <gaofeng.zhang@nxp.com>
Add a Kconfig choice for the station power save mode applied
when the driver starts: minimum modem sleep, maximum modem
sleep or none. The default keeps the current behaviour, where
the Wi-Fi library starts in minimum modem sleep. The mode can
still be changed at runtime through the Wi-Fi power save
management request.
Assisted-by: Claude:fable-5.1
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
"Enhanced Max PS" is supposed to provide a workaround for AP which does not
support PS-Poll frames.
This mode take place of the Fast PS mode. In practice, users enabling this
compile time option will never be able to restore Fast PS behavior.
Considering the PS-Poll algorithm is very bandwidth limited (2Mbps Rx in
the best case), most of the users want Fast PS. So, enabling this option by
default is confusing for most of the users.
Change the default and update the description.
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Implement the reg_domain management op so the country code can be
read and set through the Wi-Fi management API and the wifi
reg_domain shell command.
Zephyr names the worldwide domain "00" while the Espressif
regulatory table uses "01", so the code is translated in both
directions. The third octet of the country string selects the
operating environment and is set to ' ' to accept a plain alpha-2
code. A forced domain is mapped to disabling 802.11d so the
configured country is not overridden by the surrounding APs.
On get, the 2.4 GHz channels are reported first and the 5 GHz ones
after them, as the other dual-band drivers do. The 5 GHz set comes
from the country channel mask, where an all-zero mask means every
channel the regulatory rules allow. Channel 14 is flagged passive
only and the 5 GHz channels 52 to 144 are flagged as DFS. The list
is clamped to MAX_REG_CHAN_NUM because callers report the filled
count back in num_channels rather than passing the buffer capacity
in it, and a NULL chan_info returns the channel count alone.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
The slim ring buffer API is now header-only and always available and the
tree has already migrated from the _claim/_finish API, so the RING_BUFFER
symbol no longer gates any code.
Remove the now-redundant "select RING_BUFFER" and CONFIG_RING_BUFFER=y
entries across drivers, subsystems, samples and tests.
Signed-off-by: Måns Ansgariusson <mansgariusson@gmail.com>
Made some items runtime configurable such as the SSID and PSK
In addition, the channel and mesh id can be configured during runtime
Removed Kconfigs relating to these items
Signed-off-by: Humphrey Chiramba <humphrey@plentify.co.za>
When CONFIG_NXP_WIFI_RECOVERY is enabled, wlcmgr_mon_task handles
WIFI_RECOVERY_REQ by calling wlan_reset(CLI_RESET_WIFI) directly on
its stack. This performs a full WiFi disable+re-enable sequence whose
cumulative stack consumption (~4200 bytes) exceeds the default 3072
byte limit, causing a stack overflow:
ZEPHYR FATAL ERROR 2: Stack overflow on CPU 0
Current thread: wlcmgr_mon_task
Increase the default stack size to 5120 bytes when NXP_WIFI_RECOVERY
is selected. Verified with kernel thread stacks: usage 4200/5120
(82%). Keep 3072 bytes for non-recovery builds to avoid wasting RAM.
Signed-off-by: Han Zhao <han.zhao@nxp.com>
The NXP Wi-Fi driver should use the Zephyr Kconfig symbol
CONFIG_NXP_WIFI_5GHz_SUPPORT instead of the internal wifi_nxp
symbol CONFIG_5GHz_SUPPORT which is only available through
an indirect macro alias.
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
When a passive scan is requested without an explicit channel
list (full-band scan), the per-channel scan_type assignment
loop is skipped because band_chan[0].channel is zero. This
leaves chan_list[].scan_type at MLAN_SCAN_TYPE_UNCHANGED (0),
so the requested scan type is not propagated to the lower
layer for non-DFS channels.
Fix this by setting chan_list[0].scan_type after the channel
loop when no explicit channels are provided.
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
The init event is a list of {tag, length, value} triplets, and which tags
the slave sends varies between firmware versions, so reading them at fixed
offsets logs the wrong values.
Look them up by tag, and check the event length against the frame length
before walking.
Signed-off-by: Ibrahim Abdalkader <i.abdalkader@gmail.com>
The slave boots in WIFI_MODE_NULL and leaves the mode to the host, but
the driver never selected one.
Set the mode to APSTA so that MAC address queries also succeed.
Signed-off-by: Ibrahim Abdalkader <i.abdalkader@gmail.com>
Move radio test and FICR programming shell commands into the nRF70
Wi-Fi driver. Register the command sets behind NRF70_RADIO_TEST_SHELL
and NRF70_RADIO_TEST_FICR_SHELL Kconfig options so radio test builds
can use the built-in shell or provide a custom integration.
Signed-off-by: Sachin D Kulkarni <Sachin.Kulkarni@nordicsemi.no>
Assisted-by: Cursor:cursor-agent
Enable the esp32 Wi-Fi driver on the ESP32-C61: extend the FTM
and mesh Kconfig gates, add the wifi devicetree node and enable
it on the esp32c61_devkitc board.
Assisted-by: Claude:opus-4-8
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
The simulated radio derives its centre frequency as 2407 + channel * 5,
so it only ever operates in the 2.4 GHz band and the constant is
correct.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The channel getter and both interface status handlers split the band at
channel 14, which reports a 6 GHz channel as 5 GHz. Use the shared
helper so the split is done in one place and an out of range channel
reports WIFI_FREQ_BAND_UNKNOWN.
The scan handler is left alone. It takes the band from the band field
the firmware reports for the BSS rather than deriving it, which is the
better source where it is available.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The scan handler and both interface status handlers derived the band
with an open coded "channel > 14", which reports a 6 GHz channel as
5 GHz and a channel of 0 as 2.4 GHz. Use the shared helper instead, so
an interface whose channel is not known reports
WIFI_FREQ_BAND_UNKNOWN.
The softAP status handler also assigned acs_band, a driver internal
0/1 value, straight into the band field. That happens to produce the
right answer only because the two enumerations start with the same two
values, so spell the conversion out.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The interface status handler decided the band with "channel > 11",
which places channels 12, 13 and 14 in the 5 GHz band. Those are valid
2.4 GHz channels in several regulatory domains, so a station connected
on one of them reported the wrong band. The scan handler in the same
driver used "channel > 14", so the two disagreed about the same BSS.
Use the shared helper in both places. That fixes the 12-14 range, makes
scan and status agree, and reports 6 GHz channels as 6 GHz instead of
folding them into 5 GHz. A channel the driver never filled in now reads
as WIFI_FREQ_BAND_UNKNOWN rather than 2.4 GHz.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The other Wi-Fi drivers now derive the interface status band from the
channel rather than reporting a constant. This one cannot: the part is
2.4 GHz only and the driver reports channel 0, so deriving the band
would replace a correct answer with an unknown one.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The +CWJAP: response handler set the band to WIFI_FREQ_BAND_2_4_GHZ
before parsing anything, overwriting the WIFI_FREQ_BAND_UNKNOWN that
esp_mgmt_iface_status() had deliberately set, even when the response
turned out to be unparseable and the handler returned an error.
Derive the band from the channel once the channel has been parsed. The
scan handler never set the band at all, so every scan result carried a
zero, which is WIFI_FREQ_BAND_2_4_GHZ rather than an unknown band;
derive it there too. The supported parts are 2.4 GHz only, so the band
reported for a connection does not change.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The interface status handler reported WIFI_FREQ_BAND_2_4_GHZ
unconditionally, before it had asked the co-processor anything, so a
disconnected interface and any future dual band part would both be
described as being on 2.4 GHz.
Derive the band from the channel once the channel is known, for both
the station and the access point case, and leave it as
WIFI_FREQ_BAND_UNKNOWN until then. The scan handler filled in the
channel but never the band at all, which left every scan result
looking like a 2.4 GHz one, so fill it in there as well.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The interface status band was set from the interface flags, and only
when the 2.4 GHz flag was present. Everywhere else it was left at the
value the initial memset() produced, which is WIFI_FREQ_BAND_2_4_GHZ
rather than an unknown band. An interface that is not up yet returns
early from the handler and so reported 2.4 GHz without ever looking at
the radio.
The scan handler had its own open coded version of the same conversion:
it defaulted the band to 2.4 GHz and replaced it with an unknown band
when the channel fell outside 1-14. rf_channel is a uint8_t, so the
"<= 0" half of that range test could only ever match channel 0.
Derive the band from the channel in both places, once the channel is
known, and leave it as WIFI_FREQ_BAND_UNKNOWN until then. The scan
warning is kept, now driven by the derived band, so a channel the part
cannot be on is still reported. The part is 2.4 GHz only, so the band
does not change for an interface that is actually connected.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The interface status handler reported WIFI_FREQ_BAND_2_4_GHZ
unconditionally, so on the dual band ESP32-C5 a connection on a 5 GHz
channel was shown as 2.4 GHz by "wifi status" while "wifi scan" showed
the same BSS as 5 GHz. The constant was harmless while every supported
part was 2.4 GHz only.
Derive the band from the channel once the channel is known, in both the
station and the access point case, and default to
WIFI_FREQ_BAND_UNKNOWN so that a status query that cannot determine the
channel no longer claims 2.4 GHz. The scan path already derived the
band, but only distinguished 2.4 from 5 GHz, so let it use the same
helper.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
In net_stack_buffer_alloc_rx(), the first fragment reserves headroom
with net_buf_pull(offset), but alloc_len is decremented by p->len only,
omitting the pulled offset. alloc_len stays larger than the space left,
so a multi-fragment packet gets over-filled and its buffer ends up
longer than requested, corrupting the SDIO scatter-gather RX path.
Decrement alloc_len by p->size, the full space this fragment consumes,
so the accounting stays correct regardless of the reserved headroom.
Signed-off-by: Gang Li <gang.li_1@nxp.com>
Expose the firmware version obtained during ESP-Hosted initialization
through the Wi-Fi management version API.
Signed-off-by: Daniele Cloralio <d.cloralio@arduino.cc>
nxp_wifi_cpu_reset() previously required both sd-gpios and pwr-gpios to
be present in devicetree before any reset logic ran, silently making
the function a no-op on boards that only wire sd-gpios (e.g. an SDIO
module using its reset line as WL_EN with no separate power-enable
GPIO). Make pwr-gpios independently optional so sd-gpios alone is
sufficient to drive reset.
Also fix the enable path: reset was previously asserted and left
asserted while pwr-gpios was raised, with no release step, so the
module never actually came out of reset before communication started.
Explicitly release sdio_reset after the assert delay, before waiting
out the release hold time.
Signed-off-by: Ryan Erickson <ryan.erickson@ezurio.com>
Use controller/peripheral and SDO/SDI terminology in the remaining
SPI-using drivers (audio, auxdisplay, bluetooth HCI, dac, eeprom,
ethernet, flash, fpga, gpio, haptics, hdlc_rcp_if, ieee802154,
input, led, led_strip, lora, mfd, misc, mux, rtc, sdhc, stepper,
video, watchdog, wifi) and the ec_host_cmd SPI STM32 backend,
following coding guideline rule A.2: switch to
SPI_OP_MODE_CONTROLLER/PERIPHERAL and SPI_SDO_OVERRUN_DT, rename
Zephyr-owned identifiers (the HCI SPI header buffers, the winc1500
bus wrapper transfer parameters), and update comments, log messages
and Kconfig help prose.
Vendor and out-of-scope identifiers keep their names: STM32
LL_SPI_MODE_SLAVE in the ec_host_cmd backend, the ATWINC1500 SDK I2C
SLAVE_ADDRESS definition, and the I2S codec clock-role variable in
tlv320aic26.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
siwx91x_on_join runs on the WiseConnect event-engine thread. Sync NWP
commands from that context (multicast filter via net_if_dormant_off,
DHCP, power-save) block the engine so BLE RX buffers cannot be freed and
the shared pool exhausts. Defer that work to the system workqueue.
Signed-off-by: Devika Raju <Devika.Raju@silabs.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Devika Raju <Devika.Raju@silabs.com>
Move esp_hosted_mcu_ap_authmode() into the soft-AP Kconfig guard
next to its only caller. Station-only builds compile out the AP
management code and emitted an unused-function warning.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Add a new NXP_WIFI_SUPP_DEBUG Kconfig option to control the
supplicant interface debug logs. It defaults to enabled when
WIFI_NM_WPA_SUPPLICANT_LOG_LEVEL_DBG is set. Previously the
CONFIG_SUPP_DEBUG macro had no Kconfig entry to enable it.
Assisted-by: WChat:Claude
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
Remove NXP_WIFI_DEBUG_BUILD and NXP_WIFI_OS_DEBUG Kconfig
options that are not referenced anywhere in the source code.
Also remove the depends on NXP_WIFI_DEBUG_BUILD from
NXP_WIFI_NET_DEBUG and NXP_WIFI_WLCMGR_DEBUG so that
individual debug options can be enabled independently
without the unnecessary intermediate toggle.
Assisted-by: WChat:Claude
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
Enable Wireless Location Service (WLS) by default when NXP IW61X SoC
and WIFI_NM_WPA_SUPPLICANT are enabled. WLS supports 802.11mc (FTM)
and 802.11az (Next Generation Positioning) features.
Signed-off-by: Keval Thakker <keval.thakker@nxp.com>
This commit updates the usage of ring_buf to utilize the new
put_ptr/commit/get_ptr/consume pattern instead of the traditional
claim/finish approach. This change is part of a larger refactor aimed at
streamlining the ring_buf API and improving its efficiency.
Signed-off-by: Måns Ansgariusson <mansgariusson@gmail.com>
Without CONFIG_PM the Wi-Fi SLP IRAM optimization path calls
esp_wifi_internal_update_modem_sleep_default_params(), which is
only provided by the Wi-Fi blobs. Builds on Wi-Fi 6 SoCs with
CONFIG_BUILD_ONLY_NO_BLOBS=y fail to link, so keep the option
default off there until a stub is available.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Report the station IPv4 address to the Wi-Fi stack from the interface
address events, and from the station connect handler for an address
configured before the association, so that a static address and a DHCP
lease behave the same.
Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
Add Wi-Fi status support to the ST67W611M1 Wi-Fi driver.
Supported for both interfaces (STA and SoftAP).
Signed-off-by: Eliott Speyser <eliott.speyser@st.com>