Commit graph

18329 commits

Author SHA1 Message Date
Emil Gydesen 0cb828d443 Bluetooth: CAP: Fix check for volume_mute_changed callback
The callback was guarded by a wrong check.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-14 10:56:26 +02:00
Emil Gydesen 36c1aeaf19 Bluetooth: BAP: Shell: Add support for USB audio in
Add support for receiving audio data from e.g. a PC
over USB and LC3 encode it before sending it
on BAP audio streams.

This refactores the entire TX path, as it has moved
from only support the sine wave generator, to also
supporting USB.

The encoding and sending of data is now in it's own
thread, instead of relying on the system workqueue thread
and k_work items.

Several other refactors have taken place to reduce lines
of codec (such as the introduction of the bap_foreach_stream
function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-14 09:34:19 +02:00
Troels Nilsson 01b4f9d263 Bluetooth: Controller: Fix BIS IRC range check
Maximum possible value for IRC is 15, not 7

Signed-off-by: Troels Nilsson <trnn@demant.com>
2024-05-14 09:33:11 +02:00
Jordan Yates 23ca74b756 convert: use k_uptime_seconds
Replace usage of `k_uptime_get() / MSEC_PER_SEC` and
`k_uptime_get() / 1000` with dedicated function.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-05-14 09:32:01 +02:00
Jukka Rissanen 70ab0e65a5 net: websocket: Add a way to unregister a websocket connection
Doing a normal close for a websocket does not close the underlying
real socket. If we do not have fd for the real socket, then it is
not possible to fully close a websocket connection. As we are allocating
a websocket using websocket_register() in HTTP server use case,
create a websocket_unregister() that will close both the real
socket and the websocket socket.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-14 09:31:37 +02:00
Jukka Rissanen 4d9d0ee64c net: websocket: Ignore error during close if we are disconnected
No need to return an error during a close if we are already
disconnected.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-14 09:31:37 +02:00
Corey Wharton bf114c6b1a logging: add API to trigger immediate processing of logs
There are use cases where it's beneficial to trigger the log
thread to process log messages as soon as able instead of waiting
for the processing timer or threshold triggers. An example would be
to flush the log buffer before entering the idle thread after
forcing a system power state.

Signed-off-by: Corey Wharton <xodus7@cwharton.com>
2024-05-13 16:06:11 -04:00
Jordan Yates af515ef87b logging: log_cache: ensure cache contains an entry
Return an error if the provided cache configuration is not large enough
to hold a single entry. An empty `active` and `idle` list causes NULL
dereferences in `log_cache_get`.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-05-13 16:05:18 -04:00
Nicolas Pitre 57305971d1 kernel: mmu: abstract access to page frame flags and address
Introduce z_page_frame_set() and z_page_frame_clear() to manipulate
flags. Obtain the virtual address using the existing
z_page_frame_to_virt(). This will make changes to the page frame
structure easier.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2024-05-13 16:04:40 -04:00
Fin Maaß 9bd0170aad net: http: client: mark as unstable
As the http client API is currently used by two applications
(websocket and hawkbit), it should be marked as unstable, according
to the docs:
https://docs.zephyrproject.org/latest/develop/api/api_lifecycle.html

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-05-13 16:02:55 -04:00
Marek Pieta b8fedfb6c1 bluetooth: host: conn: Fix assertion failure in wait_for_tx_work
Calling bt_disable in system workqueue context while BLE connected may
lead to calling wait_for_tx_work in this context. Fix check in code to
avoid assertion failure.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2024-05-13 09:51:59 -05:00
Daniel Apperloo 9fc26804fb linker: decouple KERNEL_WHOLE_ARCHIVE from LLEXT
Dynamic code execution applications not using LLEXT for "extension"
loading are subject to the same linker optimization symbol resolution
issue described in commit 321e395 (in summary, libkernel.a syscalls
not used directly by the application result in weak symbol resolution
of their z_mrsh_ wrapper).

To support usecases where an application is using alternative methods
to load and execute code calling syscalls (likely from userspace) or
is using a mechanism where the linker may not be aware, the configuration
option has been decoupled from CONFIG_LLEXT (who is now a selector) to
KERNEL_WHOLE_ARCHIVE.

Signed-off-by: Daniel Apperloo <daniel.apperloo@intel.com>
2024-05-13 14:23:38 +02:00
Michael Stumpf 854685dfbc Fixes small typo in log_backend_fs.c
Signed-off-by: Michael Stumpf <michaelstumpf585@gmail.com>
2024-05-12 11:04:22 -04:00
Aurelien Jarno a6fbfc0612 lorawan: make possible to send empty frames
Empty frames are allowed by the LoRaWAN protocol and are actually useful
to open new RX slots or flush MAC commands in stack. Therefore allow the
data pointer to be NULL if len is 0.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2024-05-12 11:01:18 -04:00
Tomi Fontanilles 6002abe519 mgmt: mcumgr: replace Tinycrypt by PSA
As part of ongoing work to move away from TinyCrypt and towards PSA
(#43712), make fs_mgmt use either PSA (when available) or MbedTLS
(as a fallback) for SHA-256.

The use of PSA is guarded by CONFIG_MBEDTLS_PSA_CRYPTO_CLIENT
which requires a locally-built PSA core for devices without TF-M.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2024-05-10 18:24:38 -04:00
Tomi Fontanilles 2d61db9a60 mbedtls: introduce PSA-specific Kconfig file
It is meant specifically for configuration of the PSA crypto library.

The underlying PSA configuration items are guarded by the condition
that a PSA crypto provider must be present, which is the case when
either TF-M is in use or MbedTLS's PSA core is built as part of
the application image.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2024-05-10 18:24:38 -04:00
Keith Short bfe8020c4c Revert "shell: backends: uart: avoid unnecessary TX IRQs"
This reverts commit d2e5eeb51d.

PR zephyrproject-rtos/zephyr#71172 is causing the bug reported on
issue zephyrproject-rtos/zephyr#72598.

Signed-off-by: Keith Short <keithshort@google.com>
2024-05-10 18:23:50 -04:00
Emil Gydesen 7d4c13f55f Bluetooth: CAP: Shell: Initiator fix chan_alloc
When using the CAP initiator shell AC commands, the channel
allocation were not done correctly, leading to cases where
we attempted to set e.g. 2 LEFT streams for the same device.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-10 18:09:14 -04:00
Adam Matus 684a28656e net: zperf: Add periodic reporting for upload
Add option for zperf tcp upload that will enable periodic result reporting.
This is useful for monitoring performance swings during a longer session.

Signed-off-by: Adam Matus <adam.matus@nxp.com>
2024-05-10 14:45:48 -05:00
Adam Matus a6ededcc9f net: zperf: Move TCP nodelay socket option
TCP nodelay option is part of zperf upload params, but was not being
set in common zperf_prepare_upload_sock function. Move it there
to align with how other options are set.

Signed-off-by: Adam Matus <adam.matus@nxp.com>
2024-05-10 14:45:48 -05:00
Robert Lubos 0ba6a20896 net: sockets: Move TLS sockets out of experimental
TLS socket have now been in Zephyr for a few years already and are
widely adopted across the codebase. Given above, they should no longer
be considered an experimental feature.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-10 14:42:03 -05:00
Théo Battrel 76559f27fd Bluetooth: Host: Map HCI cmd disallowed to errno
Make `bt_hci_cmd_send_sync` return `-EACCES` when receiving
`BT_HCI_ERR_CMD_DISALLOWED`.

Update some tests that were expecting `-EIO` when
getting `BT_HCI_ERR_CMD_DISALLOWED`.

Add a warning in `set_random_address` when getting that new error. This
is done in case someone try to set a new random address while legacy
advertising, scanning or initiating is enabled. This is illegal behavior
according to the Core Spec (see Vol 4, Part E 7.8.4).

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2024-05-10 17:38:06 +03:00
Vinayak Kariappa Chettimada 2c6306d099 Bluetooth: Controller: BT_CTLR_ISO_TX_BUFFER_SIZE from BT_ISO_TX_MTU
Derive BT_CTLR_ISO_TX_BUFFER_SIZE from BT_ISO_TX_MTU to have
optimal Controller memory allocations.
BT_CTLR_ISO_TX_BUFFER_SIZE can be set lower than
BT_ISO_TX_MTU in which case upper layer can send fragmented
SDU to the Controller.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-05-10 15:02:10 +02:00
Vinayak Kariappa Chettimada 3997479b49 Bluetooth: HCI: Rename to bt_hci_iso_sdu_hdr and bt_hci_iso_sdu_ts_hdr
Rename struct bt_hci_iso_data_hdr to bt_hci_iso_sdu_hdr, and
struct bt_hci_iso_ts_data_hdr to bt_hci_iso_sdu_ts_hdr.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-05-10 15:02:10 +02:00
Yong Cong Sin 2e072ad017 ztest: include: unittest: relocate cpu.h and include only if unit-test
The `cpu.h` is meant to be a hack around Zephyr's dependencies
for unit-test, relocate it to a folder that's included only by
unit-test.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-10 11:50:36 +02:00
Yong Cong Sin af78efaa4d subsys/testsuite/ztest: create stub headers at CMake configure time
Create unittest stub headers at CMake configure time.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-10 11:50:36 +02:00
Morten Priess 7f82b6a219 Bluetooth: controller: Prevent invalid compiler code reordering
In ull_disable, it is imperative that the callback is set up before a
second reference counter check, otherwise it may happen that an LLL done
event has already passed when the disable callback and semaphore is
assigned.

This causes the HCI thread to wait until timeout and assert after
ull_ticker_stop_with_mark.

For certain compilers, due to compiler optimizations, it can be seen
from the assembler code that the callback is assigned after the second
reference counter check.

By adding memory barriers, the code correctly reorders code to the
expected sequence.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2024-05-10 11:49:50 +02:00
Konrad Derda 9074c07ae7 net: ipv6: mld: use proper MLDv2 modes
According to the RFC, MODE_IS_INCLUDE/MODE_IS_EXCLUDE codes should be
used while sendling Multicast Listener Reports in response to a query.
When performing a transition between states (e.g., when joining or
leaving a multicast group) CHANGE_TO_INCLUDE_MODE/CHANGE_TO_EXCLUDE_MODE
have to be used.

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
2024-05-10 11:44:50 +02:00
Konrad Derda 7f5a481ec7 net: ipv6: mld: remove addition of unspecified source in MLDv2 report
From RFC:
* "source list" is an unordered list of zero or more unicast
addresses from which multicast reception is desired or not desired [...]

It means that there is no need to add any special address to specify
"block all" and "allow all" states explicitly. This commit removes the
unnecessary addition.

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
2024-05-10 11:44:50 +02:00
Aleksander Wasaznik 2ec7a46d0f Bluetooth: Assert alignof bt_addr types
I got some feedback about confusion as to why the bt_addr types are not
packed. This commit adds a note about it.

This commit also adds a check for the alignof of the structs to verify
the statement 'their members are bytes or byte arrays' to thoroughly
prove that the struct is effectively as-if packed.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-05-10 11:07:26 +02:00
Flavio Ceolin cbbb64a3aa ipc: icmsg_me: Fix possible integer overflow
Fix possible integer overflow and underflow.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-05-09 12:40:24 -04:00
Robert Hancock d2e5eeb51d shell: backends: uart: avoid unnecessary TX IRQs
The shell UART TX code would only disable the TX IRQ when no data was
available in the TX ring buffer. However, it should also disable the IRQ
when all data retrieved from the buffer has been written. Otherwise it
will just result in another immediate TX IRQ which results in the IRQ
finally being disabled.

For this to work, since ring_buf_get_claim may not always return all
available data in the ring buffer on a single call, we need to loop
until either no data is left in the ring buffer or the UART was unable
to consume any of the data.

Signed-off-by: Robert Hancock <robert.hancock@calian.com>
2024-05-09 15:46:25 +02:00
Valerio Setti f539b661d6 mbedtls: add specific Kconfig option for MBEDTLS_USE_PSA_CRYPTO
MBEDTLS_PSA_CRYPTO_C and MBEDTLS_USE_PSA_CRYPTO are 2 different
things and the former should not automatically enable the
latter. The reson is that the user might want the MbedTLS
PSA crypto toolbox to be built, but at the same time he/she
does not want TLS/DTLS (and other intermediate modules such
as PK, MD and Cipher) to use PSA APIs.

For this reason this commit introduces a new Kconfig option
named CONFIG_MBEDTLS_USE_PSA_CRYPTO to enable the corresponding
build symbol. By default USE_PSA_CRYPTO is disabled. It is
only explicilty enabled in tests/samples that were previously
setting CRYPTO_C (since in those cases USE_PSA was set).

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-05-09 10:27:30 +02:00
Valerio Setti d068982005 net: tcp: use PSA for SHA256 when BUILD_WITH_TFM
When BUILD_WITH_TFM is enabled we can dispatch hash computation
to TFM. This allows to remove the built-in support of SHA256 from
the non-secure side (if it's not used for any other purpose, of course).

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-05-09 10:27:30 +02:00
Valerio Setti b25f322b73 net: tcp: use CS random generators to generate ISN
Use only cryptographically secure random number generators for ISN.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-05-09 10:27:30 +02:00
Valerio Setti e6281c9d21 tls_credentials: remove TinyCrypt implementation of digest_raw
Moving toward the adoption of PSA crypto APIs, TinyCrypt is going
to be deprecated so we can remove it in favor of newer APIs.

Moreover tls_credentials is mostly meant to store data in the
protected storage meaning that there is a TFM implementation
providing this service. The same TFM can of course be used to
compute sha256 hashing thus saving memory footprint on the NS
side by removing TC.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-05-08 22:14:19 -07:00
Valerio Setti 34c4b54473 net: tls_credentials: use PSA to compute SHA256 when BUILD_WITH_TFM
When using the TLS_CREDENTIALS_BACKEND_PROTECTED_STORAGE there is
BUILD_WITH_TFM enabled which means that we can take advantage of
TFM (thorugh PSA interface) to compute the SHA256 hash.

This removes the need for the built-in implementation of
mbedtls_sha256() on the non-secure image (unless it's used somewhere
else, of course) and therefore it helps in reducing the memory
footprint.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-05-08 22:14:19 -07:00
Robert Lubos 6551e6f5ba net: arp: Add support for gratuitous ARP transmission
Add support for gratuitous ARP transmission by Zephyr network stack.
This allows to prematurely fill the peer ARP table, so there's no need
to send an explicit request when peer needs to send an actual packet.

The gratuitous ARP is send when the network interface is brought up
(joins the network) or a new IP address is added. The gratuitous ARP
request is also sent periodically, with a configurable interval time.
The gratuitous ARP should also be sent whenever MAC address of the
interface is changed, but as Zephyr only allows to do this when
interface is down, this is already covered by the first case (interface
brought up).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-08 16:09:31 -04:00
Morten Priess ef7ddc07d3 Bluetooth: controller: Implement macros for vendor assert information
Implement LL_ASSERT_INFO1 and LL_ASSERT_INFO2 for triggering assertions
with parameter information provided for vendor core dump.

Adds Kconfig CONFIG_BT_CTLR_ASSERT_VENDOR by which the new LL asserts
map to BT_ASSERT_VND macros, which shall be implemented in the
debug_vendor_hal.h of the platform. If not enabled, LL_ASSERT_INFO will
map to existing BT_ASSERT_MSG with parameters printed.

Add use of LL_ASSERT_INFO2 where ull_ticker_stop_with_mark() result may
assert.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2024-05-08 15:03:08 -05:00
Jukka Rissanen f9ac565f12 net: shell: Pretty print websocket output
Fixing the websocket command output to align the fields and
printing interface index instead of a pointer value.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-08 15:02:16 -05:00
Jukka Rissanen 85e9b0b274 net: websocket: Add socket statistics collection
Add socket obj_core support to websocket so that the socket
information can be viewed by "net sockets" command.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-08 15:02:16 -05:00
Jukka Rissanen 3c9513e9cc net: http_server: Add websocket support
After upgrading the HTTP connection to websocket, call the
application registered callback to transfer the ownership of
the socket to the application.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-08 15:02:16 -05:00
Jukka Rissanen dedd30e140 net: websocket: Do not print error in closing
If the other end closes the connection, it is not exactly an
error so downgrade the print to debug level.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-08 15:02:16 -05:00
Jukka Rissanen 13118cf3c0 net: websocket: Create websocket_register() for http_server use
The http_server needs a way to bind a websocket socket to the
upgraded http connection socket. So websocket_register() is used
for that.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-08 15:02:16 -05:00
Jukka Rissanen 97caab6396 net: websocket: Do not use menuconfig
Use normal "config" in order to avoid this error from compliance
check script:

    Found pointless 'menuconfig' symbols without children.
    Use regular 'config' symbols instead.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-08 15:02:16 -05:00
Jukka Rissanen 535d4b40a8 net: lib: http_server: Upgrade from HTTP/1.1 to websocket
Allow connection to be upgraded from HTTP/1.1 to websocket.
This commit does nothing yet with the upgraded connection.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-08 15:02:16 -05:00
Jukka Rissanen 37956465e1 net: lib: http_server: Check HTTP/1.1 Upgrade field
Check what kind of upgrading we are doing and return error
if we receive upgrade that we do not support.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-08 15:02:16 -05:00
Kamil Piszczek 1e6e6a228f ipc: ipc_service: icbmsg backend: workaround endpoint binding deadlock
This change works around the issue with the semaphore timeout during
the Bluetooth HCI driver initialization when the bt_enable function
is called in the context of the System Workqueue thread. This issue
only affects platform that use the IPC service and its ICBMsg backend
(e.g. the nRF54H20 DK target).

The bt_enable function, when called in the System Workqueue context,
results in a deadlock, as the waiting semaphore of the Bluetooth HCI
driver times out:

bt_hci_driver: Endpoint binding failed with -11

During the Bluetooth HCI driver open operation in the context of the
bt_enable function, the driver code waits using the semaphore for the
endpoint binding process of the IPC service module to finalize. The
issue occurs when the  waiting occurs in the System Workqueue context.
The ICBMsg backend from the IPC service schedules a system work during
the endpoint registration, in which it finalizes the binding operation
- also in the System Workqueue context. As the Bluetooth HCI driver
with its wait operation keeps the System Workqueue context busy, the
endpoint binding cannot be completed by the ICBMsg backend before the
HCI driver semaphore timeout.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2024-05-08 19:11:09 +01:00
Rubin Gerritsen e4ea597a77 Bluetooth: Controller: BIG/CIG count based upon app configs
When building ISO applications on a device that has the host
and controller on the same core, the application developer
shouldn't have to set controller specific configurations.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-05-08 09:25:29 -04:00
Maciej Baczmanski 479e957b79 kconfig: openthread: Fix PSA Key Ref config for RCP architecture
`OPENTHREAD_PLATFORM_KEY_REF` should not be selected for RCP
architecture, as keys are handled on host's side and passed to
device over Spinel, and therefore they cannot be exported
on platform from reference with PSA Crypto API.

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2024-05-08 09:25:15 -04:00
Benjamin Cabé a4c2b848c4 mgmt: fix bad SPDX-License-Identifier header
fix typo in SPDX header

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2024-05-08 09:23:16 -04:00
Morten Priess 425dcc4678 Bluetooth: controller: Sync ISO Establishment fixes
- Introduce variable in lll_sync_iso for sync establishment timeout
- Introduce estab_failed flag in event_done_extra struct to convey
  establishment failure from LLL.
- Fix ull_sync_iso_estab_done always sending success
- Return correct HCI error depending on prepare state

Signed-off-by: Morten Priess <mtpr@oticon.com>
2024-05-08 12:05:30 +02:00
Nithin Ramesh Myliattil 0d479a0091 Bluetoioth: CAP: Shell: Added qos config to unicast_start cmd
For cap_initiator unicast_start command, qos configuration is
added.

Signed-off-by: Nithin Ramesh Myliattil <niym@demant.com>
2024-05-08 12:01:29 +02:00
Philippe Schumacher 67db6f69f3 net: lwm2m: efficent cbor record data structure
The record data structure is better aligned. Each record saves
24 bytes.

Signed-off-by: Philippe Schumacher <philippe.schumacher@husqvarnagroup.com>
2024-05-08 12:00:57 +02:00
Johann Fischer 3eec2a56d5 usb: device: get rid of the partial initialization called by SYS_INIT
Part of the initialization is done in the static usb_device_init()
function called by SYS_INIT(). We can move part of it, which initialize
the descriptor and calls usb_set_config(), to usb_enable(). This allow
some usb_get_device_descriptor() dependencies called at application
desired point.

Also make sure that usb_fix_descriptor() is called only once.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-08 12:00:46 +02:00
Pieter De Gendt db8bb9ef56 cmake: linker: Use kconfig for iterable section subalign
Replace the hard-coded 4 with the Kconfig symbol
CONFIG_LINKER_ITERABLE_SECTION_SUBALIGN .

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-05-07 18:01:37 -04:00
Guennadi Liakhovetski 78a3aa7769 llext: add support for STT_OBJECT relocations
These relocations are needed e.g. when an LLEXT is built from
multiple files and they share data objects.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2024-05-07 17:56:19 -04:00
Tomasz Moń 3850c92570 usb: device_next: Properly store enumeration speed
Add missing break inside switch statement to allow UDC context to
indicate that current operating speed is High-Speed. Due to missing
break statement, the stack always assumed Full-Speed.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2024-05-07 15:20:13 -05:00
Seppo Takalo e2ab41b625 net: lwm2m: Fix pull-context on queue mode
Two issues fixed:
When pull-context is created, it does not have to wake up the RD
client context. Ignore the EPERM warning.

When new pull-context creates a new socket, sometimes socket-loop
gets to recvfrom() before we have set O_NONBLOCK on the socket.
So use ZSOCK_MSG_DONTWAIT on zsock_recvfrom() so it does not
block the socket loop.

Fixes #71450

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-05-07 15:10:09 -05:00
Bjarki Arge Andreasen 2e9279f369 modem_chat: Allow timeout script chat commands
Modem chat scripts should be able to add a script command which
is simply a delay. The validation of chat scripts currently
disallows chat script commands which only have a timeout set.

Update modem_chat to allow modem chat script commands which
only have a timeout. Additionally do a bit of cleanup to
remove duplicate code.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-05-07 15:09:21 -05:00
Jonathan Rico aa30d07563 Bluetooth: host: handle not getting a buffer
net_buf_alloc(K_FOREVER) can now fail (if run from the syswq). Propagate to
the caller instead of asserting.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-05-07 15:08:04 -05:00
Marcin Kajor b571e45d80 net: if: Extend the usage of rejoining the multicast groups
It may happen that the interface is up but not yet running
when we issue the rejoin_ipv6_mcast_groups(). This can be
fixed by calling this function again right after the iface
is set to 'running' state in the notify_iface_up handler.

Signed-off-by: Marcin Kajor <marcin.kajor@nordicsemi.no>
2024-05-07 15:07:14 -05:00
Fin Maaß 7d83a8a68a lib: smf: constant number of arguments for SMF_CREATE_STATE()
This sets the number of arguments for SMF_CREATE_STATE() to always
be the same, independent of the selected Kconfig options.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-05-07 17:46:21 +02:00
Théo Battrel b2e235d530 Bluetooth: Remove legacy debug symbols
The `BT_DEBUG_*` Kconfig symbols have been deprecated for more than 2
versions, remove them.

Update code that was still using them.

Remove the Bluetooth specific `Kconfig.template.log_config_bt` and use
`Kconfig.template.log_config_inherit` from the logging subsystem
instead, now that the legacy symbols can be removed.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2024-05-07 09:49:27 +02:00
Andries Kruithof 6a0cdb4eaa Bluetooth: CAP: Commander Reception start procedure
Add the CAP commander reception start procedure which starts reception
on one or more CAP acceptors

With the implementation of broadcast reception start procedure we also need
some mockups for unit testing

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-05-07 09:34:01 +02:00
Gerson Fernando Budke 94cd46d6ef mgmt: updatehub: Fix mark for update
This fixes compatibility with recent bootutils API.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2024-05-07 09:31:08 +02:00
Russ Webber 3d76e498e9 fs: fuse: fix fuse include path
This commit fixes the incorrect include path for the fuse library.
pkg_search_module populates the <XXX>_INCLUDE_DIRS cmake var.

Signed-off-by: Russ Webber <russ@rw.id.au>
2024-05-06 22:53:27 +01:00
Fin Maaß afff8a16dc net: config: correct dependency of NET_CONFIG*
Corrects the dependencies of NET_CONFIG*

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-05-06 22:51:19 +01:00
Fin Maaß 571ad19b0d mgmt: hawkbit: change the tls certificate tag
Be able to change the tls certicicate tag.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-05-06 22:50:44 +01:00
Jukka Rissanen 8d077ca66d net: if: Print warning if there are no network interfaces
When calling net_if_get_default(), print a warning if no
network interfaces are found. This helps debugging mysterious
crashes.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-06 22:50:18 +01:00
Jukka Rissanen 17f852f3cf net: if: ipv6: Do not crash if there are no network interfaces
When trying to get IPv6 prefix, if there are no network interfaces
then the net_if_get_default() will return NULL but we should not
crash at that point but return gracefully.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-06 22:50:18 +01:00
Jukka Rissanen 2711e12039 net: ipv6: Tailor PE values for Zephyr
Making default preferred time much closer to default valid time
so that the served addresses are much shorter time in deprecated
state where they cannot be utilized. This is important in Zephyr
as there are limited number of IPv6 addresses that can be allocated
to the network interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-06 22:50:18 +01:00
Jukka Rissanen 39ab0bb002 net: sockets: Fix getsockname() for TCP
The local address used for established TCP socket needs to be
dig out from TCP internals and not from context->local.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-06 22:50:18 +01:00
Jukka Rissanen c6c021b1f8 net: context: Add helpers for figuring out local endpoint address
We usually cannot use context->local for established TCP connections
because the local address is not updated for TCP if we are bound to
any address. So create helper that try to figure out the end point
addresses.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-06 22:50:18 +01:00
Jukka Rissanen d47e0dd93e net: Add IPv6 source address selection support
Add support for IPv6 Source Address Selection defined in RFC 5014.
This commit does not add any address selection support to getaddrinfo()
as described in the RFC. The AI_EXTFLAGS symbol and also the ai_eflags
to hints is added but they are not used by the code.
The public/temporary address selection is only done internally by
the net_if_ipv6_select_src_addr_hint() according to flags set by
setsockopt().

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-06 22:50:18 +01:00
Jukka Rissanen bd496541d7 net: shell: Print ref count information for IPv4 and IPv6 addresses
When printing IPv4 and IPv6 address information in "net ipv4" and
"net ipv6" commands, print also reference count of the IP address.
This is useful for debugging purposes.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-06 22:50:18 +01:00
Jukka Rissanen f96087e257 net: Add ref counting to net_if_addr struct
Add reference counting to network interface address (for both
IPv4 and IPv6) so that the address is not removed if there are
sockets using it. If the interface address is removed while there
are sockets using it, the connectivity will fail for the said
socket.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-06 22:50:18 +01:00
Jukka Rissanen c69357a8b4 net: if: Remove IPv6 address when it expires
No need to keep the expired addresses around, just remove it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-06 22:50:18 +01:00
Jukka Rissanen a7e332dc18 net: ipv6: Add Privacy Extension events to net_mgmt
Add events to be generated when privacy extension is enabled
or disabled, or when allow/deny filter is added or deleted.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-06 22:50:18 +01:00
Jukka Rissanen c741c524ae net: shell: Add information about IPv6 privacy extension
When executing "net iface" command, print current status of
IPv6 privacy extension if it is enabled in config file.

The "net ipv6 ..." command prints IPv6 privacy extension
information, and can add or delete IPv6 prefix filters.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-06 22:50:18 +01:00
Jukka Rissanen 0d085d74c4 net: ipv6: Select proper IPv6 source address for privacy extension
If IPv6 privacy extension is enabled, then we need to select
proper public or temporary IPv6 source address when sending the
packet.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-06 22:50:18 +01:00
Jukka Rissanen ed9a983837 net: ipv6: Initial support for privacy extension
This creates support for IPv6 privacy extensions which is described
in RFC 8981. This will also add API that can be used to add IPv6
prefixes to a allow or deny list privacy extension filter.

The code will create temporary IPv6 addresses from prefixes that
are advertised by Router Advertisement messages. The temporary
IPv6 addresses are then expired according to lifetime and removed.

Fixes #9349

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-06 22:50:18 +01:00
Jukka Rissanen ce4a13ae79 net: ipv6: Generate an event for deprecated address
If IPv6 address expires and moves to deprecated state, then
send a mgmt event so that listeners can act on it.
One such action is to close a socket bound to that source address
so that the address can be released.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-06 22:50:18 +01:00
Konrad Derda 5c0d7390f1 net: ipv6: mcast_routing: send MLDv2 reports on changes
This commit adds transmission of MLDv2 reports whenever a multicast
routing entry is added or removed when suitable (it checks if the
given interface itself has joined the group).

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
2024-05-06 22:50:01 +01:00
Konrad Derda 356a42587c net: ipv6: mld: add option to include multicast routes in MLDv2 reports
This commit introduces a new option CONFIG_NET_MCAST_ROUTE_MLD_REPORTS
which appends multiacst routes to MLDv2 reports. These records are
intended to inform reports' recipients about potential listeners on
the other interfaces.

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
2024-05-06 22:50:01 +01:00
Konrad Derda 486f895a54 net: ipv6: mld: allow to send unsolicited MLDv2 reports on demand
This commit exposes net_ipv6_mld_send_single() function to be used
by other modules.

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
2024-05-06 22:50:01 +01:00
Marcin Szymczyk 671bf6619e testsuite: interrupt_util: add trigger_irq for VPR CLIC
Enable triggering IRQs in tests for VPR CLIC.

Signed-off-by: Marcin Szymczyk <marcin.szymczyk@nordicsemi.no>
2024-05-06 19:06:19 +02:00
Dong Wang 6a962fb50a pm: re-program timer HW only when the exit latency is not zero
Avoid re-programming timer unnecessarily.

Signed-off-by: Dong Wang <dong.d.wang@intel.com>
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-05-06 17:31:40 +01:00
Benjamin Lindqvist 0d14143926 net: coap_client: handle observe requests as intended
The coap_client lib only handled "one-shot" requests properly. This
patch allows it to keep listening for additional responses to a request,
if the request was made with the CoAP OBSERVE option appended.

An API for canceling such requests is also added.

Signed-off-by: Benjamin Lindqvist <benjamin@eub.se>
2024-05-06 17:31:19 +01:00
Jukka Rissanen aecac68179 net: Do not directly use net_buf size field
The size field in net_buf should not be used directly as then
the optional headroom will not be taken into account.
There is the net_buf_max_len() API that should be used instead.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-06 17:31:09 +01:00
Ping Wang 1188305c1e Bluetooth: Audio: Shell: adds support for BIS index parameter
When calling bap_broadcast_assistant add_pa_sync, it should only
set the BIS index field as optional parameters and not to whatever
is in the BASE.

If setting BIS index which the BASE does not support, then the
command should be rejected.

This PR fixes https://github.com/zephyrproject-rtos/zephyr/issues/70835

Signed-off-by: Ping Wang <pinw@demant.com>
2024-05-06 17:30:04 +01:00
Ping Wang 6a027634cd Bluetooth: Audio: Shell: adds support for BIS index parameter
When calling bap_broadcast_assistant add_pa_sync, it should only
set the BIS index field as optional parameters and not to whatever
is in the BASE.

If setting BIS index which the BASE does not support, then the
command should be rejected.

This PR fixes https://github.com/zephyrproject-rtos/zephyr/issues/70835

Signed-off-by: Ping Wang <pinw@demant.com>
2024-05-06 17:30:04 +01:00
Troels Nilsson 5d44e36779 Bluetooth: Controller: Fix BIS target_event truncated to 8 bits
The target_event value is up to 39-bits but was put into a uint8_t

Signed-off-by: Troels Nilsson <trnn@demant.com>
2024-05-06 15:03:56 +01:00
Pieter De Gendt f147a5fec2 spelling: Replace occurrences of "iff" with "if and only if"
Spell checking tools do not recognize "iff", replace with "if and only if".
See https://en.wikipedia.org/wiki/If_and_only_if

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-05-06 14:58:08 +01:00
Seppo Takalo 553e5d2e0c net: lwm2m: Move one Kconfig to engine features submenu
Kconfig option to enable object version reporting should
be moved into sub section "Engine features" so
it does not clutter up the main LwM2M menu.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-05-06 14:55:42 +01:00
Chaitanya Tata 2277451e9a hostap: Increase the stack size for net_mgmt
Due to recent changes in hostap to move few buffers from heap->stack (to
improve the reliability of allocations) this has increased the stack
size and with another recent change to increase the max polling sockets
this puts over the 4096 stack size for net_mgmt causing stack overflow.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-06 14:55:09 +01:00
Tomasz Moń 2f24adbe0f usb: device: Do not claim to be USB 3.2 device
The bcdUSB value 0x0210 defined in USB 3.2 Specification indicates USB
3.2 device operating in one of the USB 2.0 modes. USB 2.0 Link Power
Management Addendum defines bcdUSB value 0x0201 to indicate that USB 2.0
device supports the request to read the BOS Descriptor.

The main difference between bcdUSB 0x0210 and 0x0201 is that the USB 3.2
device must support LPM, while USB 2.0 devices can (but are not required
to) support LPM.

The difference is respected by USB 3 Gen X Command Verifier (2.3.0.0)
Chapter 9 Tests [USB 2 devices], where the test behaves as follows:
  * For bcdUSB 0x0200:
      Checking Device Under Test for LPM L1 Compatibility...
      USB version of device is 2.00.
      DUT is NOT compatible with LPM.
      LPM is NOT required for DUT
      LPM is only supported in USB version 2.01 and above.

  * For bcdUSB 0x0201:
      Checking Device Under Test for LPM L1 Compatibility...
      USB version of device is 2.01.
      DUT IS compatible with LPM.
      LPM is NOT required for DUT
      USB 2.0 Extension Descriptor bmAttributes:
        LPM Capable = 0
        BESL and Alternate HIRD Supported = 0
        Baseline BESL Valid = 0
        Deep BESL Valid = 0
        Baseline BESL: 0d
        Deep BESL:  0d
      LPM is not supported

  * For bcdUSB 0x0210:
      Checking Device Under Test for LPM L1 Compatibility...
      USB version of device is 2.10.
      DUT IS compatible with LPM.
      LPM IS required for DUT
      USB 2.0 Extension Descriptor bmAttributes:
        LPM Capable = 0
        BESL and Alternate HIRD Supported = 0
        Baseline BESL Valid = 0
        Deep BESL Valid = 0
        Baseline BESL: 0d
        Deep BESL:  0d
      (USB: 9.6.2.1.6) Bit 1 in Attributes field of a USB 2.0 Extension
      descriptor returned in response to a GetDescriptor(BOS) request
      must be 1 for LS/FS/HS devices that support LPM L1.

The test fails when LPM bit is not set in USB 2.0 Extension Descriptor
only when bcdUSB is 0x0210. The test failure was incorrectly fixed in
commit 312429be3c ("usb: samples: Add Extension descriptor to webUSB
sample."). Properly fix the issue by changing bcdUSB to 0x0201 and
removing the false LPM support claim.

The false LPM claim was leading to device ceasing to work after some
time if there was no traffic from host to device (when the host is
likely to have executed the LPM L1 transition that was not properly
handled by the device).

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2024-05-06 14:54:23 +01:00
Markus Lassila dcb3704bc7 net: l2: ppp: Fix terminate requests
When PPP moves to the 'Closing' state it sends up to configured number
of 'Terminate-Request' packets. It only moves to the 'Initial' state,
after running out of retransmits or when it receives a 'Terminate-Ack'
packet.

Signed-off-by: Markus Lassila <markus.lassila@nordicsemi.no>
2024-05-06 14:54:12 +01:00
Emil Gydesen 68ea1c4fe4 Bluetooth: CAP: Fix issue with parallel CAP discover
The bt_cap_common_discover function relied on a global variable
used to  indicate that a discovery was in process.
This global variable prevented multiple discoveries to take place
on multiple ACL connections, where the intention was to stop
multiple discoveries on the same ACL.
This has been fixed by moving the variable into the
struct bt_cap_common_client, so that it applies per
connection, rather than a global check.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-06 11:48:31 +02:00
Emil Gydesen d45b462f23 Bluetooth: CSIP: Set Coordinator move data to instances
Moved the busy flag and the GATT paramters to the
individual CSIP Set Coordinator instances.

This allows to use multiple instances in parallel,
and thus in turn allow CAP to do things in parallel.

This commit has been done with minimal amount of changes,
even if there are multiple pieces of code that could likely
be refactored to be better.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-06 11:48:31 +02:00