`_current` is now functionally equals to `arch_curr_thread()`, remove
its usage in-tree and deprecate it instead of removing it outright,
as it has been with us since forever.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
The eswifi driver uses an integer to identify the socket used for each
connection, which must be cast to and from a `void *`. This causes
warnings on 64 bit platforms, as precision is lost when casting from a
`void *` to `int`. Use a `intptr_t` type to store the socket value to
resolve this warning. Also, fix a function signature for the `accept_cb`
to use `size_t` instead of `int` for the length
Fixes#80242
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
`eswifi-uart` uses the ring buffer library, but the dependency is
not indicated.
Specify `select RING_BUFFER` to resolve the dependency.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
`_POSIX_C_SOURCE` must be specified to use the `strnlen()` function
in string.h. Make sure to specify this explicitly.
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
When receiving data over the eswifi module, we currently read the data
first, then allocate a buffer, and finally write the data into the
buffer. The issue is that if we can't allocate the buffer, the data
that was read is lost. To fix this, we should first attempt to allocate
the buffer before reading any data. If we can't allocate the buffer, we
should not proceed with reading the data. By allocating a buffer with
the MTU size, we can read the packet, write it into the allocated buffer
and then resize by removing unused allocated buffer with
net_pkt_trim_buffer().
Signed-off-by: Léo BRIAND <leo.briand@smile.fr>
For each of the fdtable.h functions listed below, convert the
z_ prefixed semi-private functions to use the zvfs_ prefix.
ZVFS stands for Zephyr Virtual File System and
is intended to be a common library used by the C library,
POSIX API, Networking, Filesystem, and other areas.
There are already a few functions in fdtable.h that use the
zvfs_ prefix, so this change is mostly about unifying them in
a way that uses a suitable prefix ("namespace") so that it can
be considered a public API.
- z_alloc_fd
- z_fdtable_call_ioctl
- z_finalize_fd
- z_finalize_typed_fd
- z_free_fd
- z_get_fd_obj
- z_get_fd_obj_and_vtable
- z_get_obj_lock_and_cond
- z_reserve_fd
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Fill-in the mode field of the fd_entry so that the
implementation can be made aware that the specific file
descriptors created are sockets.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Default MAX_DATA_SIZE might be too small depending
on application (e.g. handling the scan result with 12 APs detected)
Added config option for MAX_DATA_SIZE and warning for the user
Signed-off-by: Samy Francelet <samy.francelet@ik.me>
Bind WiFi network devices to the generic WiFi connectivity backend if
the appropriate option is set.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Fix the data acquisition thread function signatures to avoid a stack
corruption on thread exit.
Fixes#62637
Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
Limit the number of the copied ssid to WIFI_SSID_MAX_LEN
and avoid a possible one byte overflow.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
The eswifi spi driver sets up spi buffer length as number of frames,
but the length shall be number of bytes. Because eswifi use 16 bit as
frame size, so this turns out reading and writing half of data and
fails to sending any at command request and getting any responds from
eswifi module.
Fix it by setting up length as number of bytes.
Fixes#62056
Signed-off-by: Chien Hung Lin <chienhung.lin.tw@gmail.com>
Fix few mismatched CONTAINER_OF, one missing k_work_delayable_from_work
conversion and few cases where the target should be pointing at the
first element explicitly.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Decouple interface and Wi-Fi APIs, Wi-Fi APIs are common independent of
Wi-Fi offload or implemented natively (This is preparation for
introducing Native Wi-Fi).
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Default scan mode is Active. User can force the scan mode to passive
through Kconfig option or using 'passive' option from shell.
Using either of this option will override regulatory settings and
forces all scan channels to be passive only.
Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
Identify the Wi-Fi capability to the networking stack and also the type
of Wi-Fi (Native vs Offloaded), this helps identifying Wi-Fi interfaces
that can be used by applications.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
MISRA Rule 5.7 requires uniqueness of tag identifiers. Shell is
frequently problematic because many code uses `const struct shell
*shell`. This causes CI noise every time one of these shell files is
edited, so let's update all of them with `const struct shell *sh`
instead.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
There is no event reporting WiFi disconnect, create a polling
work for this and report the event.
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
It has been observed that sockets can be in bad state after
boot. Be sure to correctly reset local port and any 'server'
mode before configuring client mode.
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
- We should wait indefinitely if msecs is -1 (FOREVER).
- We can directly return if data is already available in FIFO.
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
There is no listen or accept for UDP, we need to enable the UDP
server mode (P5=1) as soon as bind is complete.
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Adds dummy link layer for offloaded ifaces, allowing
ifaces to directly receive l2_enable calls
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Previously, a call to set the net_context state was added here to
accommodate a new KConfig scenario that permitted disabling offload
sockets. This code path is used by both local and offloaded sockets.
While it is necessary to update the state of the net_context for a
locally managed socket, setting the net_context for an offloaded socket
is an error, as the net_context is invalid (in fact, it points to a
hard-coded dummy socket), as observed in #52346 and #38544.
A prior commit (a9ac0a88) attempting to remedy the offload socket
scenario removed this line, which resulted in problems for the local
socket scenario. The socket never got updated to the connected state,
and thus was unusable.
Adding this guard allows the eswifi socket to set the socket net_context
only if the socket is NOT offloaded.
Signed-off-by: Brian Dunlay <brian@nubix.io>
`spi_is_ready` function is being deprecated in favor of
`spi_is_ready_dt` so let's replace the old usage in the tree.
Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
This change fixes a regression from commit 1cbc0acd.
Socket offload uses a dummy socket context, and setting
the socket state in this dummy context is invalid.
Fixes#52317
Signed-off-by: Brian Dunlay <brian@nubix.io>
This fixes a random crash caused by race condition in the eswifi
driver used by the disco L475 iot1 board.
Signed-off-by: Michał Zając <m.zajac@avsystem.com>
Update Wifi drivers to use DT_HAS_<compat>_ENABLED Kconfig symbol
to expose the driver and enable it by default based on devicetree.
Signed-off-by: Kumar Gala <galak@kernel.org>
wifi drivers that depends on native ethernet stack cannot perform
wifi API calls missing availability. This changes adds the ethernet_api
interface in wifi_mgmt so that it becomes possible.
Naming "offload" in "struct net_wifi_mgmt_offload" is kept because
Zephyr still has no supplicant to handle a full non-offloaded driver.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
This change reverts a portion of a prior change that results
in an uninitialized eswifi_spi_data struct to be passed to
the `is_spi_ready` function.
See commit 48c87f2bf8
Signed-off-by: Brian Dunlay <brian.dunlay@gmail.com>
Following zephyr's style guideline, all if statements, including single
line statements shall have braces.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace eswifi_gpio with gpio_dt_spec. We can replace devicetree
label based access with this change as we try and phase out the
usage of the 'label' property.
Signed-off-by: Kumar Gala <galak@kernel.org>
Logging v1 has been removed and log_strdup wrapper function is no
longer needed. Removing the function and its use in the tree.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Files including <zephyr/kernel.h> do not have to include
<zephyr/zephyr.h>, a shim to <zephyr/kernel.h>.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
In order to bring consistency in-tree, migrate all drivers to the new
prefix <zephyr/...>. Note that the conversion has been scripted, refer
to #45388 for more details.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Add a separate macro for registering offloaded sockets implementation,
along with information in the structure whether the implementation is
offloaded or not. This allows to differentiate between native and
offloaded socket implementations, which is critical for binding socket
API with an interface.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Instead of keeping a boolean informing whether a network interface is
offloaded at socket layer or not, keep a pointer to a function which
allows to create an offloaded socket. Native interfaces keep this as
NULL, while for offloaded interfaces it allows to connect an offloaded
socket implementation with an interface.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Check if requested socket family, type and protocol are all supported by
the driver, instead of blindly acknowledging every possible variant.
There is explicit support for UDP, TCP and TLS on top of IPv4.
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
Use NET_SOCKETS_OFFLOAD_PRIORITY instead of
NET_SOCKETS_OFFLOAD_PRIORITY, so that by default offloaded sockets will
be used instead of native sockets.
Addiitonally this allows to select relative priority of offloaded TLS
versus native TLS when used together with NET_SOCKETS_TLS_PRIORITY.
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>