Commit graph

18755 commits

Author SHA1 Message Date
Fengming Ye 4f8c2e8f58 net: conn: fix supplicant l2 recv unexpected frame
Supplicant create AF_PACKET proto ETH_P_PAE socket but receive other
frames like ICMP, UDP and causes following issues.
1. When frame len exceeds MTU, net_pkt_clone cannot clone pkt.
   Thus dropped it and print warning log.
2. It will lower throughput performance as every packet is cloned.

Fix it by conn_raw_socket does not deliver pkts protocol not macted,
after l2 processed, unless conn is all packets.

Signed-off-by: Fengming Ye <frank.ye@nxp.com>
2024-06-03 09:48:32 +02:00
Mathieu Choplain a07d493c9d llext: relocate all symbols regardless of type
In the current implementation, the LLEXT linker will only apply
relocations targeting a given symbol if it has a specfic symbol type.
This is overzealous and causes issues on some platforms, as some symbols
that need to be relocated are skipped due to being of a "bad" type.

Ignore the symbol type when performing relocation to solve this problem,
but also add checks to ensure we don't attempt to relocate symbols with
an invalid section index. If such a relocation is found, return an error
instead of ignoring the relocation entry to ensure that it is impossible
to execute code from a (partially) unrelocated LLEXT.

Also remove all hacks added to circumvent this issue:
* qemu_cortex_r5 exclusion from test cases
* unnecessary exclusion of some flags when building with LLEXT EDK

Fixes #72832.

Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
2024-05-31 16:38:09 -05:00
Tomi Fontanilles c1342b3aa9 modules: mbedtls: remove the default enabling of features
In an effort to shave off code size, remove out-of-the-box
enabling of crypto features (except SHA-256).

Configurations are adjusted to enable what they need.

Bonuses:

- When enabled, AES now defaults to using a smaller version
(`CONFIG_MBEDTLS_AES_ROM_TABLES` isn't default enabled anymore,
and if enabled, `CONFIG_MBEDTLS_AES_FEWER_TABLES` defaults to y).

- Conditions around Mbed TLS Kconfig options have been improved
to reflect the reality of the dependencies.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2024-05-31 16:33:06 -05:00
Robert Lubos 8a808c40cc net: if: Remove redundant ifdef slicing
Some IPv4/IPv6 functions were ifdef-sliced internally, despite being
compiled in conditionally in top-level #ifdef block under the same
condition.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-31 09:58:59 -05:00
Robert Lubos c84444b681 net: if: Improve ifdef blocks matching
In some cases the comment after #endif did not match the opening #if, in
some cases it was missing.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-31 09:58:59 -05:00
Jukka Rissanen 08dc8f93fe net: http_server: Add wildcard support to resource strings
Allow user to specify resource string using wildcard characters
so that multiple URL paths can be served with just one handler.

Fixes #73367

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-31 09:57:22 -05:00
Patrick Patel 131a0fad04 Bluetooth: host: Update id.c to support id rst/del for CONFIG_BT_SMP=n
Currently calls to these two functions fail unnecessarily when
CONFIG_BT_SMP is disabled. This fix allows identity resets
without having the BT_SMP stack enabled. The primary use case
is enabling random mac address rotation for privacy in memory
constrained SOCs. Fixes #73313

Signed-off-by: Patrick Patel <ppatel@micro-design.com>
2024-05-31 09:55:06 -05:00
Vinayak Kariappa Chettimada 4b6d3f1e16 Bluetooth: Controller: Fix missing conn update ind PDU validation
Fix missing validation of Connection Update Ind PDU. Ignore
invalid connection update parameters and force a silent
local connection termination.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-05-31 04:39:34 -07:00
Kai Vehmanen 6509b8199b shell: add shell backend for audio DSP using shared memory window
Add a new shell backend implemented over a shared memory window
on the Intel audio DSPs. The implementation uses the Zephyr winstream
to manage the data streaming.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2024-05-31 08:07:03 +02:00
RAJAGOPALAN GANGADHARAN 65c4ca1f05 fs: open: Add Truncate flag to zfs open
This commit has added new flag FS_O_TRUNC to support truncation
during file open. Modified fs_open to handle truncation based on
provided flags. Included unit tests for flag behavior with common
filesystems.

Signed-off-by: RAJAGOPALAN GANGADHARAN <g.raju2000@gmail.com>
2024-05-31 08:06:05 +02:00
Emil Gydesen 6b6107ccd1 Bluetooth: Audio: Rename set_sirk to just sirk
The S in SIRK is for set, so set_sirk was effectively
"set set".

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-31 08:05:24 +02:00
Yong Cong Sin 13a5c8aad7 debug: symtab: fix linking issue due to variable redefinition
Employs the same linkonce magic of sw_isr_table to fix the
multiple definition of the symtab variables issue that I
get in my application build that doesn't use `west`.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-30 16:52:01 -05:00
Yong Cong Sin 043f595279 debug: symtab: rename start_addr to first_addr
`start_addr` is the address of the first symbol, rename it to
`first_addr` instead as it seems more intuitive and relatable
to the comments.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-30 16:52:01 -05:00
Yong Cong Sin f5934de8e5 build: symtab: Add a dummy entry at the end for the binary search
The `symtab_find_symbol_name()` is using an adapted binary
search function to get the entry between 2 addresses, we need
to add a dummy entry at the end so that the search function
can remain simple and straightforward without doing
out-of-bound checks:

   20  \
       |
       |
   50  x
       |
       |
   90  x
    .  |
    .  |
    .  |
dummy  /

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-30 16:52:01 -05:00
Emil Gydesen 6ed90f65a5 Bluetooth: Audio: Remove empty Kconfig.bass
The kconfig file is empty.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-30 16:49:06 -05:00
Emil Gydesen c57c857f9b Bluetooth: CAP: Add check for member in common_get_client
The function did not check if `member` was NULL before
dereferencing it.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-30 16:47:04 -05:00
Andries Kruithof b5ecb21447 Bluetooth: CAP: shell: add command for broadcast reception start
A shell command has been added for the new CAP procedure
'broadcast_reception_start'

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-05-30 16:44:17 -05:00
Guennadi Liakhovetski 518a712db0 llext: zero is a valid relocation offset
Zero offset in a relocation entry is valid, shouldn't ignore it.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2024-05-30 09:50:17 -05:00
Guennadi Liakhovetski 946fd3fda2 llext: (cosmetic) fix a misplaced space and re-use a variable
Use an existing variable instead of re-calculating and fix swapped
space and a paranthesis.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2024-05-30 09:50:17 -05:00
Guennadi Liakhovetski ebde53904d llext: fix handling of non-standard sections in relocatable case
When building partially linked / relocatable objects no ELF segments
are created and it becomes more difficult to predict which sections
the compiler will build and use. In this case a .data.rel.local
section is created by the compiler and it is needed to link .rodata
strings in a twister test. We can handle arbitrary sections at run-
time if .peek() is supported. If it isn't we need to allocate and
copy the section. For now we simply error out in such cases. Fixing
that would represent a larger change and can be done incrementally.

This also fixes the relocation calculation to point to the correct
symbol address instead of the memory location, where it's currently
residing, because that can be a temporary buffer as is the case with
SOF.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2024-05-30 09:50:17 -05:00
Emil Gydesen 3537c4614b Bluetooth: CAP: Shell: Fix minors bugs with unicast_stop
The cap_initiator unicast_stop shell command had the wrong
minimum parameter count (as it defaults to all).

Some indentation had also gone wrong for it in the
documentation.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-30 04:08:37 -07:00
Kapil Bhatt 8a52b64875 net: shell: Add random MAC address generation
Add option for setting a random MAC address to
the net iface set_mac command. With random option
a random MAC address can be assigned to an interface.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2024-05-30 11:55:27 +01:00
Yong Cong Sin c87dc641bc arch: generalize frame pointer via CONFIG_FRAME_POINTER introduction
Enabling `CONFIG_FRAME_POINTER` allows the users to build the
kernel with frame-pointer.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-30 03:00:40 -07:00
Tom Burdick d2ccc91d7d sensors: Add a blocking sensor_read call
Rename the current sensor_read to sensor_read_async_pool and create a
new blocking sensor_read helper.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2024-05-30 09:00:43 +02:00
Johan Hedberg f48a57b2a8 Bluetooth: drivers: Remove unmaintained B91 HCI driver
The driver isn't currently buildable due to "west blobs" support never
having been added for hal_telink. Furthermore, even if the blob
dependency is manually made available it turns out the code has
bitrotten to the point where it doesn't build anymore. This situation
has continued for several years without anyone taking action, so I think
it's safe to assume this is unmaintained and should be removed.

Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
2024-05-30 09:00:22 +02:00
Jukka Rissanen 99693bee5f net: socket: Change the protocol field for AF_PACKET sockets
In order to be compatible with Linux AF_PACKET socket calls, the
protocol field needs to be in network byte order.
So for example, if user wants to receive all packets, then the
protocol field needs to be set as "htons(ETH_P_ALL)".
See Linux manual page at
https://www.man7.org/linux/man-pages/man7/packet.7.html
for details.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-29 10:48:34 -07:00
Seppo Takalo b76683e4cb net: lwm2m: Allow setting RD context without starting
When tests control the LwM2M client entirely through
shell, we should be able to set the RD client context
from the application without causing RD client to
start registration.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-05-29 10:47:57 -07:00
Ajay Parida 91054be051 net: wifi: shell: Correction to connect command default case
For default case it should print the option character provided by user.
Extra shell_help removed as it's being called in the caller function.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2024-05-29 14:09:59 +02:00
Ajay Parida d4b22cd10e net: wifi_mgmt: Support to configure AP parameter max_num_sta
Support to set BSS parameter "max_num_sta" at compile and run time

Added support to configure `max_num_sta` BSS parameter.
Maximum number of stations allowed in station table. New stations will be
rejected after the station table is full.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2024-05-29 14:09:59 +02:00
Ajay Parida bedd38ce65 net: wifi_mgmt: Support AP parameter configuration "Skip inactivity poll"
Support for configuration of AP parameter "Skip inactivity poll".
Only build time setting is supported.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2024-05-29 14:09:59 +02:00
Ajay Parida c6d1a91372 net: wifi_mgmt: Support to configure AP mode parameter
Support to set BSS parameter at compile and run time.

Added support to configure `max_inactivity` BSS parameter.
Station inactivity timeout is the period for which AP may keep a client
in associated state while there is no traffic from that particular client.
If a non-zero value is set, AP may choose to disassociate the
client after the timeout.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2024-05-29 14:09:59 +02:00
Ajay Parida 180c22a4fc net: wifi: shell: Support to print name
Support to print name of the argument along with the value.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2024-05-29 14:09:59 +02:00
Johann Fischer 2f272b2d79 usb: device_next: fix BOS descriptor request
Return protocol error if bcdUSB is less than 0x0201. Fix typo in number
of capabilities.

Fixes: b0d7d70834 ("usb: device_next: add initial BOS support")

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-29 12:03:12 +02:00
Tom Burdick 054f453ea7 rtio: Callback chaining and testing
Callbacks were a bit neglected in terms of test coverage, especially
when used in chains. It was clear from the code that chained callbacks
may not actually work, and callback ordering then was hard to verify.
Test callbacks chained to transactions work as expected.

The test iodev had built up some cruft over time and in the process
showed a few bugs once callback chaining was fixed so the test iodev now
better matches typical iodev implementations at this point.

Cancellation testing now includes an added case for cancelling a the
second submission in the chain prior to calling submit noting that no
completions notifications should be given back for those.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2024-05-29 08:41:12 +02:00
Tomi Fontanilles 3efdbe6c0c modules: mbedtls: rename CONFIG_MBEDTLS_MAC_*_ENABLED and rm duplicates
Remove the `_MAC` part because those Kconfig options enable only hash
algorithms, nothing MAC-related, and the `_ENABLED` part to align the
naming to the Mbed TLS defines (plus we don't need such a part).

As a bonus, enabling SHA-256 does not automatically enable SHA-224
anymore.

See the migration guide entries for more details on the practical
changes.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2024-05-29 08:39:26 +02:00
Dominik Ermel 25138ff99c storeage/stream_flash: Cache write_block_size to ctx on init
The commit caches write_block_size and erase_value to stream flash
context, at init, to avoid calling Flash API multiple times
to get these values at various stages of code exectuion,
at run-time.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-05-29 07:35:19 +02:00
Ravi Dondaputi 9e38bcc173 wifi: utils: Get correct channel count
When channel range is configured in scan params, get the
channel count from `chan_idx` instead of taking a difference
of start and end of the channel range. The `difference` method
fails in case of 5GHz band since channels may not be consecutive
numbers.

Signed-off-by: Ravi Dondaputi <ravi.dondaputi@nordicsemi.no>
2024-05-29 07:32:09 +02:00
Daniel DeGrasse 0767fd97f8 sd: sd_ops: fix DISK_IOCTL_CTRL_SYNC return code
SD IOCTL handling for DISK_IOCTL_CTRL_SYNC was falling through to the
default return statement, and returning an error when disk sync
succeeded. Fix this issue by properly breaking in IOCTL handler.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-05-29 07:31:39 +02:00
Yong Cong Sin 3570408db5 build: namespace syscall sources to zephyr/
Namespace the `syscall_dispatch.c` & `syscall_export_llext.c`
to `zephyr/` as well

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-28 22:03:55 +02:00
Yong Cong Sin bbe5e1e6eb build: namespace the generated headers with zephyr/
Namespaced the generated headers with `zephyr` to prevent
potential conflict with other headers.

Introduce a temporary Kconfig `LEGACY_GENERATED_INCLUDE_PATH`
that is enabled by default. This allows the developers to
continue the use of the old include paths for the time being
until it is deprecated and eventually removed. The Kconfig will
generate a build-time warning message, similar to the
`CONFIG_TIMER_RANDOM_GENERATOR`.

Updated the includes path of in-tree sources accordingly.

Most of the changes here are scripted, check the PR for more
info.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-28 22:03:55 +02:00
Tomasz Moń d034106b40 usb: device: cdc_acm: Warn once about full ring buffer
Generating separate log entry at INFO level for every single character
dropped is excessive and leads to log flood. Logging dropped character
in no way helps end user and is really a delayed performance killer that
triggers when CDC ACM buffer gets full.

If user does not want to lose outgoing characters then the solution is
to enable hardware flow control which properly blocks in the case the
output buffer is full.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2024-05-28 18:58:55 +02:00
Tomasz Moń 20983c7ced usb: device_next: uac2: Fix integer handling issues
Fix integer handling issues found out by Coverity Scan.

Coverity-CID: 363729
Coverity-CID: 363737

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2024-05-28 18:58:25 +02:00
Alexander Kozhinov bf77d74e91 usb: device: usb_descriptor.c
fix cbprintf_package warning.
cbprintf_package complains about char usage for %p
string argument and suggests void * usage.

Signed-off-by: Alexander Kozhinov <ak.alexander.kozhinov@gmail.com>
2024-05-28 18:57:22 +02:00
Seppo Takalo 4049e17c62 net: lwm2m: Fix null dereference when post-write cb is set
When opaque resources have post-write callback set, but
the write is not a Block-Wise write, there is no block_ctx
and the code causes null pointer dereference when calculating
the offset of the data.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-05-28 18:54:31 +02:00
Rubin Gerritsen ff80c0b926 Bluetooth: Host: Fix connection establishment upon RPA timeout
Before this commit, the following bugs were present:
- When `CONFIG_BT_FILTER_ACCEPT_LIST` was set, connection establishment
  was cancelled upon RPA timeout. This required the application
  to restart the initiator every RPA timeout.
- When `CONFIG_BT_FILTER_ACCEPT_LIST` was not set, the RPA was not updated
  while the initiator was running.

This commit unifies the RPA timeout handling for both these cases.
Upon RPA timeout the initiator is cancelled and restarted when
the controller raises the LE Connection Complete event.
The workqueue state is checked when restarting the initiator to prevent
it being restarted when the timeout is hit.

Corresponding test cases have been added to ensure that this
feature works.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-05-28 09:12:05 -07:00
Rubin Gerritsen 3ce106c620 Bluetooth: Host: Fix not clearing IDs and keys upon bt_disable()
Expectation: After calling `bt_disable()` it is possible to
use the Bluetooth APIs as if `bt_enable()` was never called.

This was not the case for `bt_id_create()`, it was not possible
to set the default identity. This prevented an application
developer to restart the stack as a different identity.

Keys also need to be cleared to avoid the following pattern:
1. Pair two devices
2. Central calls `bt_disable()` and `bt_enable()`.
   The central will now generate a new identity address.
3. Connect the two devices.
4. Re-establish encryption. Now the central will try to use
   the previously used keys. The procedure will fail
   because the peripheral does not have any keys associated
   with the new central address.

The API documentation is updated accordingly.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-05-28 09:11:52 -07:00
Fin Maaß 8c37f14b98 tracing: add k_realloc trace
For `k_realloc` add tracing feature.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-05-28 17:55:12 +02:00
Jukka Rissanen 96c26c2268 shell: backend: telnet: Rename write and read functions
Rename write() to telnet_write(), and read() to telnet_read() so
that if we enable CONFIG_POSIX_API, the compiler will not complain
about those two functions as they conflict with POSIX API ones.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-28 17:49:59 +02:00
Jukka Rissanen 3f96a87d1c net: dns: Fix resolver debug print
Make sure that we are not trying to print NULL pointer string.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-28 17:49:59 +02:00
Jukka Rissanen 74f9a1c482 net: sockets_service: Add build check for using zephyr libc
Add checks to make sure that we are not trying to use the socket
service library with eventfd if CONFIG_POSIX_API is not set and if
using native_sim based board. The reason is that we should always
use zephyr libc based eventfd implementation instead of host libc one.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-28 17:49:59 +02:00
Jukka Rissanen aa458a279a Revert "net: sockets: Check eventfd errors better"
This reverts commit b56297bf16
because it is causing problems when using native_sim and not
having CONFIG_POSIX_API set.

The proper fix is to set CONFIG_POSIX_API when using eventfd
and native_sim so that picolibc is used instead of host libc.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-28 17:49:59 +02:00
Robert Lubos 87bacf378d net: l2: ethernet: arp: Fix ARP probe target HW address matching
According to RFC3927 and RFC5227, an ARP probe target HW address should
be set to all-zeroes:

"The 'target hardware address' field is ignored and
SHOULD be set to all zeroes."

Hence, we should allow the ARP probes to have all-zeroes target HW
address as well.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-28 17:49:03 +02:00
Mark Wang c56183529c tests: bluetooth: shell: add a2dp shell test
implement the current a2dp APIs test.
update the document.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2024-05-28 12:56:42 +02:00
Mark Wang bdca41d0bf Bluetooth: A2DP: Implement the a2dp and avdtp
implement a2dp.c and avdtp.c
add a2dp related Kconfig:
BT_AVDTP_RTP_VERSION, BT_A2DP_SOURCE and BT_A2DP_SINK
a2dp_codec_sbc.c/h are used to provide some APIs to get
A2DP SBC codec information. (like: channel num).

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2024-05-28 12:56:42 +02:00
Emil Gydesen 0b654c1502 Bluetooth: BAP: Fix conn checks for bcast assistant notifications
The notify handle in the BAP broadcast assistant did not handle
conn == NULL properly, and neither did delayed_bap_read_handler.

Add better NULL checks, which also fixes a coverity issue.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-28 12:53:48 +02:00
alperen sener 0b220dd6a6 bluetooth: mesh: increase the friend adv latency range
Increasing the adv latency range to the minimum valid
ReceiveDelay value, 10ms. 4ms might be small for some
target systems.

Signed-off-by: alperen sener <alperen.sener@nordicsemi.no>
2024-05-28 10:08:47 +02:00
Bjarki Arge Andreasen 000784b91d modem: chat: Add runtime APIs for chat scripts
Add runtime APIs for chat scripts.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-05-28 10:02:06 +02:00
Bjarki Arge Andreasen 2a575a6bf5 modem: chat: Add runtime API to modem_chat_script_chat
Add APIs allowing for modifying the modem_chat_script_chat
safely at runtime.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-05-28 10:02:06 +02:00
Bjarki Arge Andreasen 8b4822861b modem: chat: Add runtime API to modem chat matches
Add APIs for changing the contents of modem chat matches
safely at runtime.

This allows for reusing a single modem_chat_match at the cost
of placing the match and its buffers in RAM.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-05-28 10:02:06 +02:00
Jungo Lin fa716d9842 shell: fix index out bound issue
In order to prevent index out of bounds access of the sh->ctx->cmd_buff
array when sh->ctx->cmd_buff_pos is 0, it has been added a check for the
value of sh->ctx->cmd_buff_pos.

This ensures that the array will not be accessed beyond its boundaries.

Signed-off-by: Jungo Lin <jungolin.tw@gmail.com>
2024-05-27 08:16:36 -07:00
Jordan Yates 251ddf0ab5 net: l2: ethernet: arp: improve debug output
Improve the ARP debug output by printing:
 * Sending ARP query
 * Queuing packets due to pending ARP query
 * Receiving ARP query response

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-05-27 08:16:22 -07:00
Tomasz Moń c30ac4dfd8 usb: device_next: CDC ACM: Process TX on configuration enable
If CDC ACM uart side has TX enabled when the configuration gets enabled,
depending on fifo state following has to happen:
  * if the fifo is empty - trigger TX ready interrupt
  * if the fifo is not empty - queue TX data on IN endpoint

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2024-05-27 14:04:35 +01:00
Tomasz Moń 1784446c8d usb: device_next: Fix string descriptors response
Commit 2f31ee63b5 ("usb: device_next: convert ASCII7 strings to
UTF16LE on the fly") made string descriptors respond with twice as much
of the actual string data.

Fix the issue by taking into account that USB string descriptor length
is already multiplied by two. Additionally, make it possible to return
odd number of bytes if host requested so.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2024-05-27 14:04:26 +01:00
Andries Kruithof 3122296e1c Bluetooth: CAP: fix bug in reception start
The wrong number of subgroups was used in copying subgroups

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-05-27 05:01:49 -07:00
Jukka Rissanen 2a16f4d2bc net: dns: responder: No need to double the socket count
The socket allocation count was incorrectly calculated as
we have only one socket per listened port.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-27 05:01:28 -07:00
Jukka Rissanen ecda6b190f net: dns: The DNS_EAI_ALLDONE is not an error
If DNS_EAI_ALLDONE is returned, it indicates that the request
was done and should not be considered an error.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-27 05:01:28 -07:00
Emil Gydesen f5fd2cf49e Bluetooth: ISO: Avoid bt_iso_chan_disconnected in bt_iso_reset
The bt_iso_chan_disconnected function will attempt to
remote ISO data paths as the central.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-27 03:27:15 -07:00
Flavio Ceolin 4c5ee9b2db pm: system: Restore clock after sleep
sys_clock_idle_exits was being called *only* when the system
was resumed from interruption.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-05-27 02:10:03 -07:00
Flavio Ceolin 1860dd9153 pm: system: Resume devices in pm_system_resume
pm_system_resume() can be called directly from ISR and because of this
devices should be resumed before calling pm_state_exit_post_ops().

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-05-27 02:10:03 -07:00
Flavio Ceolin f7437ac3b1 pm: Move z_pm_save_idle_exit to pm subsys
There is no need to this function be defined inside the kernel since
all places using it are protecting the call under ifdef PM guards.

This way we can also remove the ifdef condition inside the implementation.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-05-27 02:10:03 -07:00
Younghyun Park ea29ef36bb debug: coredump: Move COREDUMP_*_STR strings to the public header
This allows a customized coredump_backend_other API to re-use the
COREDUMP_*_STR without re-defining the same strings.

Signed-off-by: Younghyun Park <younghyunpark@google.com>
2024-05-25 14:39:18 -04:00
Lyle Zhu 2d665c1c14 bluetooth: keys_br: Improve bt_foreach_bond
The BR Keys cannot be scanned by function
bt_foreach_bond.

Add function bt_foreach_bond_br for br.

The function bt_foreach_bond_br will be
called by bt_foreach_bond if the BR is
enabled.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-05-25 14:39:06 -04:00
Fin Maaß f9819dc010 mgmt: hawkbit: option for cold reboot
add option for cold reboot.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-05-24 18:04:13 -04:00
Babak Arisian b0dceffacc Bluetooth: Audio: add bt_audio_get_chan_count
Implement a function bt_audio_get_chan_count that takes an enum
bt_audio_location and returns the number of channels in that value.

This PR fixes #69617
(https://github.com/zephyrproject-rtos/zephyr/issues/69617)

Signed-off-by: Babak Arisian <bbaa@demant.com>
2024-05-24 09:55:37 -05:00
Ping Wang 1339ce4bf0 Bluetooth: Audio: Get function for bt_audio_codec_qos_pref.
Get the preferred QoS settings via bt_bap_ep_get_info()
Therefore no need to use the internal header file to get it.

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

Signed-off-by: Ping Wang <pinw@demant.com>
2024-05-24 08:04:45 -04:00
Marcin Niestroj c6fd2a1ddf net: dns: don't request address in recvfrom()
Source address is not used anywhere, so don't request it with recvfrom()
API.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2024-05-24 07:48:17 -04:00
Aurelien Jarno 44f86dd67d usb: dfu: fix detach happening too fast
In some relatively rare conditions, the DFU detach/attach happens to
fast, which cause the host to not notice it. It seems to to be the case
for instance on STM32 when no endpoint are being used.

Adding a 1 ms delay (i.e. one SOF period) between the detach and the
attach fixes the issue.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2024-05-24 07:48:03 -04:00
Andrzej Głąbek e9256135d6 Bluetooth: Controller: nrf5: Allocate GPIOTE channels
Allocate the GPIOTE channels that the Bluetooth Controller needs to use
with the dedicated function provided by the nrfx_gpiote driver instead
of using hard-coded indexes of these channels, as now, when the driver
supports multiple GPIOTE instances, it would be much more difficult to
properly inform the driver which channels should be reserved.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2024-05-24 07:47:15 -04:00
Morten Priess 06870146e6 Bluetooth: controller: Allow any valid ISO sync receiver BIG handle
The BIG handle for an ISO sync receiver is provided by the host. The
valid range is [0x00..0xEF], and this requires the controller to allow
non-consecutive handle numbering. This means that even if only one sync
set is supported, a BIG handle of ex. value 2 must be supported.

As the code uses indexing and range checking directly by handle, this
needs to be changed. Introducing the handle index, which sequnces the
handles such that index = 0 is always the "first handle", regardless
of value.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2024-05-23 11:53:22 -04:00
Valerio Setti 210e08be5d bluetooth: mesh: update BT_MESH_USES_MBEDTLS_PSA selected symbols
Instead of selecting legacy MBEDTLS symbols, use corresponding
PSA_WANT ones when possible (note: some legacy symbols do not
have a PSA correspondance).

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-05-23 11:53:02 -04:00
Valerio Setti 2adb4cac17 mbedtls: default enable USE_PSA_CRYPTO when CRYPTO_C
Now that support for all PSA_WANT symbols is in place, we can
enable MBEDTLS_USE_PSA_CRYPTO when MBEDTLS_PSA_CRYPTO_C is
enabled as well.

Note: this commit also moves USE_PSA_CRYPTO out of CRYPTO_C
dependency in config-tls-generic.h because TLS/DTLS/X509 modules
of MbedTLS can rely on *any* implementation of PSA crypto APIs
not only the MbedTLS one. TFM is for example an alternative
to this.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-05-23 11:53:02 -04:00
Yong Cong Sin c118cd5a13 arch: make the max stack frames configurable
Current on x86 & risc-v that implement stack trace, the
maximum depth of the stack trace is defined by a macro.

Introduce a new Kconfig:EXCEPTION_STACK_TRACE_MAX_FRAMES
so that this is configurable in software.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-23 11:52:08 -04:00
Yong Cong Sin c1a925de98 arch: riscv: use symtab to print function name in stack trace
Selecting `CONFIG_EXCEPTION_STACK_TRACE_SYMTAB` will
enable the symtab generation which will be used in the
stack trace to print the function name of the return
address.

Updated the `stack_unwind` test to test the symbols in a
stack trace.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-23 11:52:08 -04:00
Yong Cong Sin e1ce0aefff debug: implement symtab generation
Use pyelftools to extract the symbol table from the
link stage executable. Then, filter out the function names
and sort them based on their offsets before writing into the
`symtab.c`, this is similar to how the `isr_tables` works.

To access the structure, simply include the new header:
```c
#include <zephyr/debug/symtab.h>
```

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-23 11:52:08 -04:00
Roger Wang e79f7135af logging: backend: uart: fix coverity warning
This commit is to fix a warning which is reported in Coverity scan
after device runtime pm is enabled.

Signed-off-by: Roger Wang <roger1.wang@intel.com>
2024-05-23 08:22:32 -04:00
Robert Lubos 1e3f14476b net: tls_credentials: Add missing base64.h header inclusion
base64_encode() was used w/o including the base64.h header. This commit
fixes it.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-23 07:47:41 -04:00
Jordan Yates 0f56974c9d net: lib: dhcpv4: goto INIT on IF down, not RENEWING
When the interface goes down, the safest thing to do is to return to
the INIT state, as there is no guarantee that any state is preserved
upon the interface coming back up again.

This is particularly the case with WiFi.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-05-22 21:34:44 -04:00
Flavio Ceolin 6569ae1798 pm: device_runtime: Fix usage API
Fix pm_device_runtime_usage() API for isr safe devices.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-05-22 15:08:39 -05:00
Ravi Dondaputi d8c89f2b08 wifi: shell: Support configuration of timeout in connect command
Add support for configuring timeout in `wifi connect` command.

Signed-off-by: Ravi Dondaputi <ravi.dondaputi@nordicsemi.no>
2024-05-22 13:46:40 -05:00
Vinayak Kariappa Chettimada 1b7fe792e0 Bluetooth: Controller: Support Link Time Optimizations (LTO)
Support for using Link Time Optimization (LTO) when
building application with open source Bluetooth Low
Energy Controller. This reduces code space usage.

Current Memory Usage at the time of this PR (hci_ipc):

BT_CTLR_OPTIMIZE_FOR_SPEED:
Memory region         Used Size  Region Size  %age Used
           FLASH:      260112 B       256 KB     99.22%
             RAM:       60136 B        64 KB     91.76%
           SRAM1:           0 B        64 KB      0.00%
        IDT_LIST:           0 B        32 KB      0.00%

BT_CTLR_OPTIMIZE_FOR_SIZE:
Memory region         Used Size  Region Size  %age Used
           FLASH:      232292 B       256 KB     88.61%
             RAM:       60128 B        64 KB     91.75%
           SRAM1:           0 B        64 KB      0.00%
        IDT_LIST:           0 B        32 KB      0.00%

BT_CTLR_OPTIMIZE_FOR_APP_DEFAULT:
Memory region         Used Size  Region Size  %age Used
           FLASH:      232292 B       256 KB     88.61%
             RAM:       60128 B        64 KB     91.75%
           SRAM1:           0 B        64 KB      0.00%
        IDT_LIST:           0 B        32 KB      0.00%

BT_CTLR_LTO:
Memory region         Used Size  Region Size  %age Used
           FLASH:      221484 B       256 KB     84.49%
             RAM:       60120 B        64 KB     91.74%
           SRAM1:           0 B        64 KB      0.00%
        IDT_LIST:           0 B        32 KB      0.00%

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-05-22 13:38:14 -05:00
Vinayak Kariappa Chettimada 31c048f4e3 Bluetooth: Controller: Remove legacy LL optimize for speed dependency
Remove legacy LL optimize for speed dependency required to
support encryption feature in Controller where crypto was
performed in highest priority ISRs to setup encryption in 3
radio events (this now requires 5 radio events in split LL).

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-05-22 13:38:14 -05:00
Dong Wang ea288283a3 logging: log_output: Prevent redundant flush with zero-length data
There's such a case captured. When log immediate mode is enabled, each log
message is output per character. However, "log_output_flush()" function is
still called with zero data length at the end of "log_output_process()".
Better to make "buffer_write()" returns immediatley if buffer data
length is zero.

Signed-off-by: Dong Wang <dong.d.wang@intel.com>
2024-05-21 20:54:29 -04:00
Jean-Nicolas Graux c2f65cddfc net: gptp: fix race condition on timestamp callback
If time aware system has more than 1 gptp port, because there is only
one boolean to handle callback registering, a race condition can occur
for instance in case 2 master ports are waiting for a timestamp following
sending of sync message. More in details, callback may be unregistered
by port 1 while port 2 is waiting for timestamp event.

The issue is solved by declaring as much as boolean and struct
net_if_timestamp_cb as the number of declared ports
(=CONFIG_NET_GPTP_NUM_PORTS).

Signed-off-by: Jean-Nicolas Graux <jean-nicolas.graux@st.com>
2024-05-21 16:49:05 -04:00
Jean-Nicolas Graux 64aa577c92 net: gptp: fix rate_ratio in gptp_mi_set_ps_sync_cmss()
Setting a ration of 0 breaks the computation of scaled_rate_offset
in gptp_md_follow_up_prepare().

According to IEEE802.1AS 10.2.2.3.9, when sent by clock master
entity, rate_ratio shall be equal to gmRateRatio. But since
in gptp_md_follow_up_prepare(), in case we are the grand master
clock, we take the assumption that clock source is the local clock,
we may set this ratio to 1.0.

Signed-off-by: Jean-Nicolas Graux <jean-nicolas.graux@st.com>
2024-05-21 16:49:05 -04:00
Jean-Nicolas Graux cec4818fde net: gptp: do not run clock master sync send SM if we are not the GM clock
Without this patch, in case time aware system is grand master capable
but is not the grand master clock and behave as a bridge so that it
shall ONLY relay SYNC and FUP messages from slave port to master port(s),
SYNC and FUP are mistakenly generated by ClockMasterSyncSend state
machine.

This patch only call ClockMasterSyncSend state machine in case a Grand
Master clock is present and is this time aware system.
This check is not described by IEEE802.1AS. Instead, according to
10.2.9.3, the SiteSyncSync state machine shall not take into account
information from ClockMasterSyncSend in case this time aware system is
not grand-master capable. Current implementation of ClockMasterSyncSend
state machine sends sync indication to the PortSync entities, instead of
sending it to the SiteSyncSync entity. And the SiteSyncSync state machine
does not make any check.

Signed-off-by: Jean-Nicolas Graux <jean-nicolas.graux@st.com>
2024-05-21 16:49:05 -04:00
Jean-Nicolas Graux c2cd0fe3ed net: gptp: fix again computation of follow up correction field
Commit 413eceeddb ("net: gptp: fix follow_up message correction_field")
breaks computation of follow up correction field in case time aware system
is not the grand master clock but behave as a transparent clock which relay
sync and follow-up messages from one slave port to one or several master
port(s). In this case, according to IEEE802.AS 11.1.3 and 11.2.14.2.3,
md sync send state machine shall compute the sum of link propagation delay
and residence time, expressed in grand master time base. Then this quantity
shall be added to last received fup correction field to build value of
correction field. This patch checks whether time aware system is the grand
master clock or not, and computes value correction field accordingly.

Signed-off-by: Jean-Nicolas Graux <jean-nicolas.graux@st.com>
2024-05-21 16:49:05 -04:00
Krzysztof Chruściński 299b52d1a7 debug: Add MIPI STPv2 data stream decoder
Add a decoder of STPv2 stream.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-05-21 16:48:28 -04:00
Benjamin Lindqvist ed025b2f04 net: lib: coap_client: observe-related fixes
An earlier pull request implementing observe support was merged too
hastily. It had a few issues:

1. The predicate for whether a request should be marked not ongoing was
wrong (it checked ret != 0 instead of ret < 0)
2. Without observes in mind, MID-based deduplication is not a required
feature. Deduplication was handled implicitly - the exchange would get
dropped after the first response anyway, so duplicate responses would
not get matched to anything. But with observes, there are several
responses in an exchange. This commit adds this.
3. Using coap_request_is_observe(&internal_req->request) in the response
handler requires the whole request to stay in scope for the lifetime of
the observation, which I observed was not always the case. Adding an
is_observe bool to the internal struct improved stability significantly.

With these fixes, GETs with observe option works very well.

Signed-off-by: Benjamin Lindqvist <benjamin@eub.se>
2024-05-21 16:42:38 -04:00
Aleksander Wasaznik 93d0eac834 Bluetooth: Host: Forbid holding on to buf given to stack
These are safety checks to guard against silent data corruption. The
implementation currently does not clobber bufs, but soon it will. The
bufs will be zero-copy segmented and fragmented, which involves
overwriting already-sent contents with headers for the next fragment.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-05-21 11:51:20 +01:00
Anders Storrø 261b358dc3 Bluetooth: Mesh: Shell: Update DFD start bool parse
Changes the parsing of boolean input parameter "PolicyApply"
to DFD start command to use shell boolean parse library.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2024-05-21 11:51:10 +01:00
Jamie McCrae b3ffe0aede mgmt: mcumgr: transport: Add missing net include file
Adds a missing network include file which was causing an undefined
function build failure, likely caused by a recent change affecting
includes in other header files

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-05-21 09:36:24 +02:00
Johan Hedberg 274507fc52 Bluetooth: Controller: Add BT_CTLR_HCI Kconfig option
Add a new option to split off the building of the HCI layer of the
controller. This layer is not needed by the controller unit tests, and
becomes problematic with the planned change to use devicetree for HCI
drivers.

Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
2024-05-20 15:16:54 +01:00
Bjarki Arge Andreasen 5e193edbc3 modem: chat: implement buffer stats
implement buffer statistics for modem_chat module.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-05-20 14:40:06 +03:00
Bjarki Arge Andreasen 88bb45082a modem: ppp: implement modem_statistics
Implement modem buffer statistics for ppp module.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-05-20 14:40:06 +03:00
Bjarki Arge Andreasen b636327601 modem: cmux: Implement modem backend statistics
Implement modem backend statistics into modem CMUX DLCI
channel receive buffer and CMUX transmit and receive buffers.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-05-20 14:40:06 +03:00
Bjarki Arge Andreasen 9f45102299 modem: backend: uart: async: Implement modem backend stat
Implement modem backend statistics in async uart modem backend.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-05-20 14:40:06 +03:00
Bjarki Arge Andreasen beeb769bb1 modem: backend: uart: isr: Implement modem backend stat
Implement modem backend statistics into isr uart modem backend.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-05-20 14:40:06 +03:00
Bjarki Arge Andreasen aba5580af3 modem: backend: Add statistics module
Add statistics module which tracks the usage of modem backend
transmit/receive buffers if implemented by a backend.

A modem backend may register itself to the modem backend
stat module, and advertise its transmit and receive buffer
sizes and momentary usage (length).

The modem backend module tracks the maximum usage, which can be
output to the shell using the "modem_stats buffer" shell command.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-05-20 14:40:06 +03:00
Anders Storrø f8bbf753fc Bluetooth: Mesh: Change log lvl for element_model_recv
Changes the log level from ERR to DBG for element_model_recv for the
following cases:
- Element does not have the appkey for incoming message.
- Element does not have destination address for incoming meesage.

When the received message is for a group address, element_model_recv
is called for all elements on the device. One or more elements may contain
a model that is subscribing to this address. If more than one element
contains the same model. but they do not all share the same application
key as the incoming message is encrypted with, or they do not all
subscribe to the same group address, then the log will show error
message for these elements, which is misleading.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2024-05-20 14:37:46 +03:00
Robert Lubos 0874f609f1 net: ipv6: Fix DAD conflict detection
Filtering out received packets which source address matches one of our
own addresses has broken the duplicate address detection conflict
reporting.

In case Neighbor Advertisement is sent during DAD collision, the source
address of such packet might be set to the address that triggered the
collision. This address would also be set on our interface, marked as
tentative. Therefore in order to make duplicate address detection work,
we cannot filter out packets in case our own address is still in
tentative state.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-20 14:26:24 +03:00
Robert Lubos 62a55d03af net: ipv6: Fix RA RDNSS and DNS_RESOLVER interdependencies
A support for RDNSS option should not force DNS subsystem being enabled
in the system, especially that the option is enabled by default. It
should work the other way around - the option is supported only if DNS
was enabled by the user.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-20 14:25:44 +03:00
Jukka Rissanen b042c5796a logging: Fix network backend compilation
Because of include file changes, we now need to include both
hostname.h and net_if.h in the syslog logging module directly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-20 14:25:44 +03:00
Jukka Rissanen b56297bf16 net: sockets: Check eventfd errors better
With native_sim, this error is seen a lot when socket
service API is used.

  <dbg> net_sock: get_sock_vtable: (net_socket_service):
    Invalid access on sock 3 by thread 0x807a8e0 (net_socket_service)

If we just ignore the error, then we might get into forever
loop which is not good. So if this happens, mark the eventfd
fd as not pollable to basically ignore the eventfd support in
this case.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-20 14:25:44 +03:00
Jukka Rissanen 3f1bd6b29e net: sockets: Add extra debug print for invalid socket access
Print also thread name when printing socket access error.
This helps debugging what thread caused it.
Lowering the Error to Debug as we could be missing vtable
for example for eventfd descriptors, this is easily seen when using
socket service API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-20 14:25:44 +03:00
Jukka Rissanen d5cd41a0fe net: llmnr_responder: Convert LLMNR responder to use socket service API
Instead of using net_context API directly, the LLMNR responder is
changed to use the socket service API. This allows DNS access
for offloaded sockets and can lower overall memory consumption.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-20 14:25:44 +03:00
Jukka Rissanen 94433b9ce2 net: mdns_responder: Convert mDNS responder to use socket service API
Instead of using net_context API directly, the mDNS responder is
changed to use the socket service API. This allows DNS access
for offloaded sockets and can lower overall memory consumption.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-20 14:25:44 +03:00
Jukka Rissanen 9a40066b4f net: dns: Convert resolver to use socket service API
Instead of using net_context API directly, the DNS resolver is
changed to use the socket service API. This allows DNS access
for offloaded sockets and can lower overall memory consumption.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-20 14:25:44 +03:00
Erik Brockhoff 9d8059b6e5 Bluetooth: controller: minor cleanup and a fix-up re. LLCP
Only perform retention if not already done.
Ensure 'sched' is performed on phy ntf even if dle is not.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2024-05-20 10:56:17 +03:00
Erik Brockhoff 806a4fcf92 Bluetooth: controller: fix node_rx retention mechanism
Ensure that in LLCP reference to node_rx is cleared when
retention is NOT used, to avoid corruption of node_rx later
re-allocated

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2024-05-20 10:56:17 +03:00
Erik Brockhoff edef1b7cf4 Bluetooth: controller: fixing rx node leak on CPR reject of parallel CPR
In case a CPR is intiated but rejected due to CPR active on
other connection, rx nodes are leaked due to retained node not
being properly released.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2024-05-20 10:56:17 +03:00
Emil Gydesen 7c96743fae Bluetooth: ISO: Upgrade from experimental to unstable
The ISO API and implementation have existed in Zephyr
for several years, and while not fully qualified, stable
or tested yet, it's not experimental anymore (and have
not been for a long time).

This commit removes any references to it being experimental
and instead defines it as unstable by setting the version to
> 0.1.0. 0.8.0 is being used as the initial version, as that
is what other unstable modules was defined to have as their
initial version if they were not stable (>= 1.0.0).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-18 15:54:31 +03:00
Emil Gydesen 4a97746312 Bluetooth: Host: Guard set state in conn_destroy
If bt_conn_set_state(conn, BT_CONN_DISCONNECTED) is called
while the connection is already disconnected, this triggers
a warning. This is likely to happen when bt_conn_cleanup_all
is called as part of bt_disable.

Added the state check to avoid unnecessary warnings in the log.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-18 15:54:19 +03:00
Emil Gydesen c40856e5aa Bluetooth: ISO: Support bt_disable
Add support for bt_disable in the ISO implementation.
This involves clearing all information related to states
in the controller, such as the BIGs and CIGs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-18 15:54:19 +03:00
Emil Gydesen f58ac3476f Bluetooth: CAP: Add reference to the set member for CAP discover
Since the CSIP API expects a set member struct for nearly all
functionality, the reference to the full set member (along with
the CAS specific CSIS) should be given to the application.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-18 15:51:26 +03:00
Taras Zaporozhets a20e962340 net: if: Fix potential unaligned word access
The input address originates from an RX net_buf which may
be unaligned. Consequently, word access to this unaligned buffer
can trigger an unaligned access exception on certain platforms,
such as the ARMv7 Cortex-A9.

Signed-off-by: Taras Zaporozhets <zaporozhets.taras@gmail.com>
2024-05-18 15:50:37 +03:00
Dominik Ermel cda52f80b5 mgmt/MCUmgr/img: Fix img_mgmt_get_unused_slot_area_id checks
Remove image == -1 check that can not happen anymore.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-05-17 14:48:24 -05:00
Johann Fischer b0d7d70834 usb: device_next: add initial BOS support
Use the same scheme as for string descriptors. Descriptors can be added
or removed using the existend interface.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-17 16:25:02 +01:00
Johann Fischer 29003ff264 usb: bos: cleanup Binary Device Object Store header
We could reuse the BOS header, but there are parts that are only needed
in the legacy device support or used internally and the tests. Move this
parts to the appropriate places.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-17 16:25:02 +01:00
Johann Fischer 4f17bc6051 usb: device_next: store bDescriptorType and bLength in descriptor node
It simplifies the macros to create the string descriptors. We also no
longer need placeholders for the SerialNumber descriptor when it is
generated from hwid. In the future, we can store other descriptor types
in the same list.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-17 16:25:02 +01:00
Johann Fischer 9b8796400a usb: device_next: rework SerialNumber generation from HWINFO
Do not use application-provided placeholder buffers. Generate
SerialNumber just before ASCII string is converted to UTF16LE. Make
dependency on HWINFO optional, but enabled by default.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-17 16:25:02 +01:00
Johann Fischer 48ca72326b usb: device_next: move string descriptor data to a separate structure
Move and rework string descriptor data to a separate structure so we can
share memory with another type. Also add description to the
USBD_DESC_STRING_DEFINE macro.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-17 16:25:02 +01:00
Johann Fischer 2f31ee63b5 usb: device_next: convert ASCII7 strings to UTF16LE on the fly
This is slower but should have no real effect. In the future we can
support more than ASCII7 format and store it in other memory areas.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-17 16:25:02 +01:00
Johann Fischer f110766072 usb: device_next: add few more string descriptor helpers
Add function to get string descriptor index and function
to remove linked descriptor from a device. This abstracts
it a bit so that the user does not need to know how it is
handled internally.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-17 16:25:02 +01:00
Ederson de Souza 967168a536 subsys/llext: Generate syscalls stubs for EDK exclusively for userspace
A new Kconfig option which generates syscall stubs assuming that
extensions will always run on userspace, thus simplifying linking
them, as there's no need for z_impl_ stubs (used for direct syscalls),
CONFIG_LLEXT_EDK_USERSPACE_ONLY.

While defining __ZEPHYR_USER__ could have the same effect for optmised
builds, people building extensions on debug environments - thus
non-optimised - would suffer, as they'd need to somehow make the stubs
available (by either exporting the symbol or implementing dummy stubs).

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2024-05-17 16:21:48 +01:00
Ederson de Souza d156a03074 cmake: New target which generates a sort of development kit for llext
Loadable extensions need access to Zephyr (and Zephyr application)
includes and some CFLAGS to be properly built. This patch adds a new
target, `llext-edk`, which generates a tar file with those includes and
flags that can be loaded from cmake and make files.

A Zephyr application willing to expose some API to extensions it loads
only need to add the include directories describing such APIs to the
Zephyr ones via zephyr_include_directories() CMake call.

A new Kconfig option, CONFIG_LLEXT_EDK_NAME allows one to control some
aspects of the generated file, which enables some customization - think
of an application called ACME, willing to have a ACME_EXTENSION_KIT or
something.

All EDK Kconfig options are behind CONFIG_LLEXT_EDK, which doesn't
depend on LLEXT directly - so that EDK features can be leveraged by
downstream variations of loadable extensions.

Also, each arch may need different compiler flags for extensions: those
are handled by the `LLEXT_CFLAGS` cmake flag. An example is set for GCC
ARM.

Finally, EDK throughout this patch means Extension Development Kit,
which is a bad name, but at least doesn't conflict with SDK.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2024-05-17 16:21:48 +01:00
Krzysztof Chruściński 24082d582f arch: arm: cortex_m: pm_s2ram: Add option for custom marking
s2ram procedure used RAM magic word for marking suspend-to-RAM. This
method may not work in some cases, e.g. when global reset does not
reset RAM content. In that case resuming from s2ram is detected when
global reset occurred.

RAM magic word method is the default but with
CONFIG_PM_S2RAM_CUSTOM_MARKING a custom implementation can be provided.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-05-17 14:33:47 +02:00
Emil Gydesen c547079cc2 Bluetooth: Audio: Upgrade from experimental to unstable
This commit upgrades the LE audio API and implementation
from experimental to unstable.

LE Audio have existing for quite a few years in Zephyr
and is not going anywhere, but at the same time it still
has significant effort remaining before it can be
considered stable.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-17 14:33:39 +02:00
Pete Skeggs f04f8b2422 net: lib: coap_client: Improve cancel function
Improve coap_client_cancel_requests(). Ensure it can be
called from a callback. Report error to waiting callbacks.
Clear active flag.

This is useful when the network becomes unavailable
or prior to disconnecting in order to save power.

Signed-off-by: Pete Skeggs <peter.skeggs@nordicsemi.no>
2024-05-17 10:34:12 +02:00
Daniel DeGrasse 05c84ccb2d sd: sd_ops: take card lock when issuing IOCTL command
Take card lock when running IOCTL command, to avoid race conditions that
could occur within the lower SDHC transfer implementations (as these
will be called by sdmmc_wait_ready)

Fixes #72368

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-05-16 18:54:21 -04:00
Johann Fischer 4c4ff20383 usb: device_next: prevent recursive logging loop
Apply the commit 21975231e2
("usb: device: cdc_acm: Prevent recursive logging loop")
to the new CDC ACM implementation.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-16 16:23:07 +01:00
Emil Gydesen f573c3eb01 Bluetooth: Audio: Shell: Fix build errors for USB=n
When CONFIG_USB_DEVICE_STACK=n then the sine wave
generator was enabled, which caused build errors.

This commit fixes those errors and also adds the
nRF5340 as a build target for the USB tests.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-16 15:51:45 +02:00
Emil Gydesen 0a89ce0bf5 Bluetooth: Controller: Add missing guard for mic_state in ull_conn_iso
The mic_state is a guarded field in event_done_extra where it was
accessed outside of its guard.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-16 11:00:15 +02:00
Daniel DeGrasse 6d7a6ea8a8 sd: sd_ops: remove additional unlock call within card_read()
SD ops card_read() implementation does not need to unlock mutex, as this
is managed by the calling function card_write_blocks. Remove this stray
k_mutex_unlock() call.

Fixes #72287

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-05-16 09:21:18 +02:00
Daniel DeGrasse ed64818565 sd: sdio: rework frequency and timing selection logic
Reword frequency and timing selection logic for SDIO framework so that
the maximum supported timing mode between the card and host will be
selected, even if the maximum frequency supported by the host is not
equal to the maximum frequency for that mode.

Also, resolve an issue where a host and card combo only supporting HS
mode or worse would still use legacy timing mode, because the CCCR flags
were not being checked when checking if HS bus speed could be used.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-05-16 09:21:03 +02:00
Daniel DeGrasse 82ce2b412d sd: sdmmc: rework frequency and timing selection logic
SDMMC framework frequency and timing selection logic has several
longstanding issues, including:
- requiring that SD hosts support the maximum frequency possible for a
  given UHS mode in order to apply that timing
- selecting SDHC_TIMING_SDR25 for high speed mode, when SDHC_TIMING_HS
  would be correct

Rework the frequency and timing selection logic within the SD framework
to resolve these issues.

Fixes #52589
Fixes #67943

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-05-16 09:21:03 +02:00
Lyle Zhu fa6df6a51a Bluetooth: HFP_AG: Protect the consistency of AG state/value
Use hfp_ag_lock/hfp_ag_unlock to protect the consistency
of AG state or value.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-05-16 09:15:49 +02:00
Lyle Zhu 5da8916ad5 Bluetooth: classic: Kconfig: Move Kconfig of classic to classic/Kconfig
Create classic/Kconfig, and move all of classic from Kconfig to
classic/Kconfig.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-05-16 09:15:49 +02:00
Lyle Zhu 615fe2466b Bluetooth: RFCOMM: Kconfig: Add configure BT_RFCOMM_DLC_STACK_SIZE
The default stack size of RFCOMM DLC is 256.
The default value is sufficient for basic operation.

If more stack space is used (such as call function printk)
in context of callback disconnected of RFCOMM DLC, the
default stack size is not sufficient.

Add a configuration BT_RFCOMM_DLC_STACK_SIZE to configure
the RFCOMM DLC stack size.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-05-16 09:15:49 +02:00
Lyle Zhu 804dbdd43c Bluetooth: host: Kconfig: Change default value of BT_RFCOMM_TX_MAX
To avoid the case that CONN_TX is available but RFCOMM_TX is
unavailable, set the default value of BT_RFCOMM_TX_MAX to
BT_CONN_TX_MAX.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-05-16 09:15:49 +02:00
Lyle Zhu c3ac857438 Bluetooth: Kconfig: Set BT_BUF_EVT_RX_SIZE to 255 for BR/EDR
The maximum data length of event packet is 255 for BR/EDR.
Such as the data length of event Remote Name Request
Complete is 255.

Set BT_BUF_EVT_RX_SIZE to 255 to avoid error "Not enough
space in buffer" from bt_hci driver.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-05-16 09:15:49 +02:00
Lyle Zhu 84144c6833 Bluetooth: HFP_AG: Initialize HFP AG
Implement basic functions for HFP AG.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-05-16 09:15:49 +02:00
Johann Fischer eb9b46c118 usb: device_next: lock scheduler in usbd_init()
Lock the scheduler to ensure that the context is not preempted before it
is fully initialized.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-15 17:29:24 +01:00
Johann Fischer c3ec41bdf8 usb: device_next: remove unused API function
Remove unused and not required usbd_ep_ctrl_buf_alloc().

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-15 17:29:24 +01:00
Johann Fischer 4c360f38d1 usb: device_next: add controller can detect VBUS state change capability
There are controllers with capability to detect VBUS state change. This
can be used in a generic application to explicitly handle the VBUS
detected event after usbd_init() and for example allow the PMIC to
detect to what type of port device controller is connected.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-15 17:29:24 +01:00
Johann Fischer 48f2a4bc1a usb: device_next: remove initialized state checks in event processing
For the simple events, do not check whether the device driver and stack
are marked as initialized. USB device notification will reschedule
delivery if the stack is not yet marked initialized.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-15 17:29:24 +01:00
Johann Fischer 693191467d usb: device_next: add USB device context to message delivery callback
Add USB device context argument to message delivery callback.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-15 17:29:24 +01:00
Johann Fischer 22d574cb3c usb: device_next: tweak USB device notification support
Since no threads are waiting for the FIFO and we do not need any k_fifo
features, we can just use slist.

Some notifications (caused by interrupts), especially "VBUS ready", can
be triggered very quickly right after UDC initialization if the USB
controller is already connected. Depending on the global thread
configuration, messsage publishing work can be executed before the
context is marked as initialized. Use delayed work to reschedule
publishing when the context is not initialized.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-15 17:29:24 +01:00
Ayush Singh 56882e2d91 net: zperf: Fix upload ping timeout error
Fixes remote address for ping before upload. This caused the ping in zperf
upload to timeout as shown in the following output:

```
uart:~$ zperf udp upload 2001:db8::2 5001 10 50 1M
Remote port is 5001
Connecting to 2001:db8::2
Duration:       10.00 s
Packet size:    50 bytes
Rate:           1000 kbps
Starting...
ping 2001:db8::2 timeout
Rate:           1.00 Mbps
Packet duration 390 us
```

Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/68674

Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-05-15 17:07:58 +02:00
Seppo Takalo 37f6803833 net: lwm2m: Allow Block-Wise write without callbacks
Allow Block-Wise writes to resources that have enough buffer for
the whole content. Calculate the offset before calling the
content specific write handlers when callback is not set.

Previously only resources with post-write callback were able to
assemble the content.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-05-15 14:58:15 +02:00
Seppo Takalo a9e91af375 test: lwm2m: Add tests for Block-Wise transfers
Block-Wise GET, PUT and SEND

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-05-15 14:58:15 +02:00
Seppo Takalo 01b57b4999 net: lwm2m: Add offset to post-write callback
When Block-Wise transfer restarts, the post-write callback should
receive some indication that the block is actually a beginning of new,
instead of part of previous transfer.

Fixes #71351

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-05-15 14:58:15 +02:00
Emil Gydesen a6a14360a9 Bluetooth: BAP: Remove err from recv_state_removed callback
The callback is only ever called when we received a
notification from the BASS server that the receive state is
removed, which cannot contain an error code.
Thus it does not make sense for the callback to have an
error code.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-15 14:57:20 +02:00
Pisit Sawangvonganan 557ad8e45c shell: devmem: address cmd_dump multiple call problem
Call `getopt_init()` to reset `state->optind` instead of directly setting
`optind = 1`. The `getopt()` function uses `getopt_state` from
`getopt_state_get` for state handling, so `getopt_init()` should be called
to correctly run the command again.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-05-15 10:13:23 +02:00
Pisit Sawangvonganan 93ee60fe87 shell: devmem: correct number of mand and opt of cmd_dump
According to the `SHELL_CMD_ARG` macro, the `mand` argument of `cmd_dump`
should be 5, including the command name itself, `dump`.
Meanwhile, the `opt` should be 2, as this value describes the optional
field, which is [-w <width>].

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-05-15 10:13:23 +02:00
Troels Nilsson 769409d41c Bluetooth: Controller: Add parameter to ISOALs sdu_write
For vendor datapaths that do not use a netbuffer to write SDUs
into, the callee of sdu_write currently has to keep track itself
of how much data has been written to the current SDU; This is wasteful
since ISOAL already keeps track of that. Add an sdu_written parameter
to the callback to inform the callee how much has been written to the
current SDU already so the callee can write using the correct offset

Signed-off-by: Troels Nilsson <trnn@demant.com>
2024-05-15 09:26:36 +02:00
Jukka Rissanen 6d129b2a2d net: http_server: Add support for specifying Content-Type
Allow user to specify the Content-Type header field for the
HTTP response.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-14 20:22:58 -04:00
Johann Fischer c0e8f0d96b usb: device_next: add initial HID device support
Add initial HID device support. Unlike the existing HID implementation,
the new implementation uses a devicetree to instantiate a HID device.
To the user, the HID device appears as a normal Zephyr RTOS device.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-14 18:24:45 -04:00
Johann Fischer 92fc5316a4 usb: device_next: allow Get Descriptor with recipient interface
If the recipient is not the device then it is probably a
class specific  request where wIndex is the interface
number or endpoing and not the language ID. e.g. HID
Class Get Descriptor request.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-14 18:24:45 -04:00
Johan Hedberg 484fe3f06c Bluetooth: Remove bt_read_static_addr() "hack"
This function was used to shortcut HCI for combined host + controller
builds. It doesn't provide much value and adds complexity to the HCI
driver interface, so just remove it. This means vendor-specific HCI
commands is now the only way for the host to access the same
information.

Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
2024-05-14 18:21:11 -04:00
Johan Hedberg 35897ee66c Bluetooth: Kconfig: Get rid of BT_HCI_VS_EVT
Enabling vendor-specific extensions also implies support for vendor
events, so a separate Kconfig option for that is unnecessary.

One small additional thing this requires is the use of the
__maybe_unused annotation, since there's no-longer a single Kconfig
option that the controller hci.c can use to know that the vendor event
helper symbols are needed.

Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
2024-05-14 18:21:11 -04:00
Johan Hedberg 18c23daee3 Bluetooth: Kconfig: Merge BT_HCI_VS_EXT into BT_HCI_VS
The naming of these two options was problematic, since it's both of them
are about vendor extensions, even though one has _EXT in the name and
the other doesn't. Just merge one option into the other. This has a
slight overhead on the controller side of enabling some more vendor
features if BT_HCI_VS is enabled, but that should hopefully be
acceptable.

Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
2024-05-14 18:21:11 -04:00
Robert Lubos 50c523636b net: ipv6: Clear joined flag on all mcast address when operational down
When the network inteface goes operational DOWN (for example cable
unplugged), clear "joined" flag on all registered multicast addresses,
so that MLD report is sent for them when the interface goes back up.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-14 18:20:56 -04:00
Robert Lubos 3e046626c1 net: ipv6: Rejoin all solicited node mcast addresses
When bringing interface down, all IPv6 multicast addresses are removed
from the interface. However, when the interface was brought back up,
rejoin_ipv6_mcast_groups() would look only for solicited node mcast
addresses already present on the interface. In result, after going back
up, the interface was missing solicited-node mcast addresses for those
unicast addresses, that were already present on the interface when
bringing up.

As net_ipv6_mld_join() does similar checks to skip MLD when not needed,
we can just skip the lookup when rejoining, and use already defined
join_mcast_nodes().

Additionally, check for IPV6 and NO_ND flags on the interface before
attempting to add the address back, those multicast addresses are not
needed if ND is disabled on the interface.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-14 18:20:56 -04:00
Robert Lubos d48da4cfd1 net: ipv6: Fix missing DAD for link-local address
In case a network interface is brought down and back up, DAD was not
performed for link-local unicast address.

This happens because the logic in the network interface code assumed
that DAD for link-local address is triggered when the address is added,
and it's explicitly omited when looping over IPv6 address. This wasn't
the case however when interface was brought back up, as the address was
already present on the interface, hence DAD skipped.

In Linux, the link-local address is removed from the interface when the
interface is brought down. Such approach solves the issue described,
hence implement it in a similar way in Zephyr.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-14 18:20:56 -04:00
Jukka Rissanen 1d7970be04 net: context: Do not check our own ports
There is no need to check our own context when going through
the used ports in the system. This prevents error when binding
in some corner cases.

Fixes #72035

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-14 18:19:54 -04:00
Jukka Rissanen 3d1b8c6116 net: shell: Add command to show HTTP server information
The new command is "net http" which shows all services and
related resources defined in the system.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-14 15:51:20 +02:00
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
Jonathan Rico 28d7d14571 Bluetooth: ATT: add debug log for timeout override
Nice to know the stack's ain't having none of your timeouts.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-05-04 15:21:45 +01:00
Jonathan Rico 24c7ad344f Bluetooth: conn: check k_work_submit() retcode
We still don't know how to handle it but at least it's checked now.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-05-04 15:21:14 +01:00
Szymon Janc 9631cd14b0 Bluetooth: OTS: Fix calling obj_created callback with NULL conn
Callback was always called with NULL conn. Now it is called with proper
pointer or NULL conforming to description.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2024-05-04 13:23:34 +03:00
Rubin Gerritsen 44199f3a48 Bluetooth: Host: Fix auto-connect/sync establishment on Coded PHY
As documented in bt_le_scan_update(), the host may start scanning
automatically for various reasons.

Until now scanning was only done on 1M PHY, making it impossible
to use auto-connect/sync establishment if the advertiser was using
Coded PHY as its primary PHY.

Auto-connection would never work. Sync establishment would work if
the scanner was started by the application.

This commit fixes this by instructing the controller to scan on
both 1M and Coded PHY if the controller supports Coded PHY.
The application may see increased power consumption as a result
of this change as the controller may now spend 2*scan_window
listening for advertising packets.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-05-03 14:44:31 +01:00
Jeferson Fernando c0a17a9a5e lorawan: add channels mask configuration.
Add channels mask configuration for LoRaWAN, creating a request for
 LoRaMAC. This change is needed because using LoRaWAN with ABP
activation without configuring channels mask will provide no acceptable
 channels on data transmit, causing data loss.

Signed-off-by: Jeferson Fernando <jeferson.santos@edge.ufal.br>
2024-05-03 09:51:46 +02:00
Jose Alberto Meza 30eda2058b treewide: drivers: espi: Adjust terms per eSPI specification 1.5
1) Replace master/slave in API for new terms in eSPI spec 1.5
2) Reflect eSPI VW change and macro changes across eSPI drivers
3) Update terms in eSPI driver sample and eSPI test driver

Signed-off-by: Jose Alberto Meza <jose.a.meza.arellano@intel.com>
2024-05-02 13:56:46 -04:00
Fin Maaß fb3704665a mgmt: hawkbit: use shell macros
use short shell macros for printing.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-05-02 13:55:28 -04:00
Bogdan Marinescu da708e232a ipc_rpmsg_static_vrings: use names for WQ threads
This patch adds names to the threads created by `mbox_init` via
`k_work_queue_start`. The name of the thread is the same as the name in
the device instance.

The main reason for this has to do with how `mcumgr` reports [thread
information](https://docs.zephyrproject.org/latest/services/device_mgmt/smp_groups/smp_group_0.html#task-statistics-command).
Specifically, data about threads is sent in a CBOR encoded map where the
map keys are the thread names (at least in the default configuration). If
there's more than one IPC channel defined (one example of this being
`samples/subsys/logging/multidomain`), both threads would be created
with an empty name and `mcumgr` will only return the data associated
with the thread created by the last call to `mbox_init`.

Signed-off-by: Bogdan Marinescu <bogdan.marinescu@gmail.com>
2024-05-02 20:47:38 +03:00
Aleksander Wasaznik 2dd987713b Bluetooth: Coverity fix dereference before null check
https://scan9.scan.coverity.com/reports.htm#v45144/p12996/fileInstanceId=132890135&defectInstanceId=9972463&mergedDefectId=363710

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-05-02 16:59:08 +02:00
Aleksander Wasaznik 34f78b8fde Bluetooth: Coverity fix untrusted value
https://scan9.scan.coverity.com/reports.htm#v45144/p12996/fileInstanceId=132890129&defectInstanceId=9972487&mergedDefectId=330721

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-05-02 16:59:08 +02:00
Aleksander Wasaznik 2e702e3065 Bluetooth: Coverity fix dereference before null check
https://scan9.scan.coverity.com/reports.htm#v45144/p12996/fileInstanceId=132878471&defectInstanceId=9972432&mergedDefectId=330636

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-05-02 16:59:08 +02:00
Aleksander Wasaznik 272af07279 Bluetooth: Coverity fix dereference before null check
https://scan9.scan.coverity.com/reports.htm#v45144/p12996/fileInstanceId=132878471&defectInstanceId=9972464&mergedDefectId=330625

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-05-02 16:59:08 +02:00
Martin Jäger f3e41c6a25 lorawan: services: add Fragmented Data Block Transport
This service receives fragmented data (usually firmware images) and
stores them in the slot1_partition in the flash.

Also update CMakeLists.txt in loramac-node module to be able to use
FragDecoder.c

Signed-off-by: Martin Jäger <martin@libre.solar>
2024-05-02 16:54:43 +02:00
Vinayak Kariappa Chettimada 64f41309d1 Bluetooth: Controller: Use reschedule margin as minimum ticks_slot
Use reschedule margin as minimum ticks_slot when ticker with
reschedule expires. This will ensure not too many unreserved
tickers expire in close proximity that can lead of pile up
of CPU processing time and eventually causing timeout
callbacks to be delayed. This mitigate possible LL asserts
due to overhead in start of radio events.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-05-02 12:18:49 +01:00
Vinayak Kariappa Chettimada 263357e042 Bluetooth: Controller: Enable ticker slot window yield for mesh
Enable use of ticker slow window yield feature under mesh
usecase. This is make sure scan window either slides within
is window or skips to next interval so that it does not
lead to advertising event being skipped.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-05-02 12:18:49 +01:00
Vinayak Kariappa Chettimada 7d1bc1789e Bluetooth: Controller: Fix short prepare preempt timeout start
Fix short prepare preempt timeout start, such that if there
are any normal prepare before a short prepare in the
pipeline, then find the short prepare and start its preempt
timeout.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-05-02 12:18:49 +01:00
Vinayak Kariappa Chettimada acc806889f Bluetooth: Controller: Add prepare pipeline assertion checks
Add prepare pipeline assertion checks to detect faults
like stopping preempt timeout without prior start. Also,
check if the preemptor param is correct when preemption
is performed. Check that the prepare pipeline is not
infinitely looping.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-05-02 12:18:49 +01:00
Vinayak Kariappa Chettimada 0e0cb3033a Bluetooth: Controller: Add assertion check for use of scan aux context
Add assertion check for use of scan aux context so that
scan aux context is not assigned again while there is
already an existing LLL scheduling in use by the scan
context.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-05-02 12:18:49 +01:00
Vinayak Kariappa Chettimada 9383e4fbf8 Bluetooth: Controller: Fix BT_CTLR_EARLY_ABORT_PREVIOUS_PREPARE
Fix BT_CTLR_EARLY_ABORT_PREVIOUS_PREPARE to setup new
shorter preempt timeout irrespective of whether there
is a previous prepare enqueued in the prepare pipeline.

Relates to commit d573951f0d ("Bluetooth: Controller:
Revert back early abort of previous prepare").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-05-02 12:18:49 +01:00
Gerson Fernando Budke 5fb62ca960 mgmt: updatehub: Fix json arrays
After the changes introduced by #50816 the UpdateHub could not decode
anymore the JSON object. This introduce missing parsing definitions
to allow JSON parser undertood the correct UpdateHub probe object.

Fixes #69297

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2024-05-02 10:55:34 +02:00
Fin Maaß 0012e1ff76 mgmt: hawkbit: reset action id
Be able to reset the hawkBit action id.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-05-02 09:32:18 +01:00
Aurelien Jarno ea995f6378 lorawan/nvm: do not call settings_save() after writing individual settings
The lorawan subsystem do not use settings handler, and instead uses
individual calls to settings_save_one(). With this strategy there is no
need to call settings_save() at the end.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2024-05-01 22:56:34 +01:00
Aurelien Jarno e94fe44805 subsys/settings: add a function to save subtree
When running multiple subsystems or applications on a MCU, the usual
strategy is to use different settings subtrees.

The API provides a way to load or commit a subtree, to avoid adding
dependencies between subsystems or applications, but lacks the way to
save a subtree only. Fix that by adding a settings_save_subtree()
function.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2024-05-01 22:56:19 +01:00
Omkar Kulkarni 11eed84775 Bluetooth: Mesh: Update models metadata API
This commit updates models metadata API to simplify the usage and
removes the metadata pointer in health server model context.

Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
2024-05-01 10:54:50 -04:00
Fabio Baltieri 4257fb6a3d shell: device_service: show the usage conter when pm runtime is enabled
Add an extra "usage=%d" to the device status to show the current usage
counter when PM runtime is enabled.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-05-01 10:31:03 +02:00
Fabio Baltieri df819a8609 pm: device_runtime: add an access function to get the usage counter
Add a pm_device_usage_get() to get the current usage counter.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-05-01 10:31:03 +02:00
Fabio Baltieri d5c773d373 pm: shell: filter out non PM enabled devices
Add a device lookup filter to only suggest devices that are PM enabled.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-04-30 19:30:15 -05:00
Fabio Baltieri 48e2f67869 shell: add a callback-filter variant of shell_device_lookup
Add a shell_device_filter variant of the shell device lookup helper that
takes a callback as an argument. This allows more complex filtering on
the device than the existing name prefix.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-04-30 19:30:15 -05:00
Emil Gydesen 353a05b116 Bluetooth: BAP: Unicast server depend on PACS
When in the BAP unicast server role, at least PAC sink
or PAC source shall be set.

In order to fulfill this new requirement, a few other Kconfig
options had to be changed to a `depends on` from `select` to
avoid recursive Kconfig requirements. This change may require
some applications to update their configurations according
to the migration guide.

The change from `select` to `depends on` is ideal anyhow
as that is the recommended way to add dependencies.

This can checked via the combined BT_PACS Kconfig value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-04-30 14:30:45 -04:00
Jonathan Rico 55154e226c Bluetooth: Classic: make SMP use L2CAP BR API
Make `l2cap_br_send_cb()` semi-public, and make SMP use it when it talks
over a BR channel.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-04-30 18:01:34 +02:00
Jonathan Rico f661773e2c Bluetooth: L2CAP: l2cap_send() -> l2cap_send_sig()
This function is only ever used to send on the signalling channel.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-04-30 18:00:52 +02:00
Jukka Rissanen 4b157b9099 net: lib: http_server: Initial HTTP server support
Original code developed as a GSoC 2023 project by Emna Rekik.

Code refactored in order to provide better bisectability
as the origical commits were not bisectable.

The server supports static and dynamic resources, managed by
HTTP_SERVICE/HTTP_RESOURCE macros.

Fixes #59685
Fixes #59686
Fixes #59688
Fixes #59690
Fixes #59670
Fixes #59700
Fixes #59684
Fixes #59693
Fixes #59693
Fixes #59694
Fixes #59699
Fixes #59696
Fixes #59688
Fixes #59690
Fixes #59670
Fixes #59700
Fixes #59685
Fixes #59686
Fixes #59688
Fixes #59691

Signed-off-by: Emna Rekik <emna.rekik007@gmail.com>
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-04-30 13:25:22 +02:00
Robert Lubos 318dcb6336 net: lib: http_server: Add HPACK and Huffman code encoder/decoder
Add HTTP/2 helper libraries to encode and decode HPACK encoded headers,
according to RFC7541.

HPACK string encoding requires to support certain set of Huffman codes,
therefore implement Huffman encoder/decoder as well.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-04-30 13:25:22 +02:00
Anas Nashif 0510e081a3 testsuite: ztress: fix doxygen command
Fix doxygen command.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-04-30 12:00:58 +02:00
Rubin Gerritsen ebae4b8cf7 Bluetooth: Controller: Default stream 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.

Without this change the samples iso_receive and iso_broadcast
will fail to run on NRF52 series devices as the samples
try to set up two streams but the controller is configured
to support only one.

Controller unit tests that were previously only enabling the
controller specific ISO configurations now also enable the
top-level ISO configurations to ensure that the default
stream count is properly configured.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-04-30 11:45:47 +02:00
Chaitanya Tata 09048e0a16 net: ipv6: mld: Fix improper reference drop
In case of successful submission, the reference shouldn't be put down,
this only should done on error cases.

As reference is put down on success, during the buffer unref, no action
is taken due to an uint8 overflow (ref is now 255), so, the buf->frags
isn't cleared properly and the next time the frags is used and when L2
inserts a second frag, the first head frag and next frag are same (due
to buffer re-use) causing an infinite loop in either net_buf_frag_last
or net_pkt_get_len.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-04-30 11:45:38 +02:00
Flavio Ceolin a458d892e6 pm: device_runtime: Check busy status in runtime_enable
We can't enable device runtime power management in a device that is
set busy since it may suspend this device.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-04-30 08:53:18 +02:00
Troels Nilsson 9b7d176b70 Bluetooth: Controller: Minor cleanup of struct proc_ctx
Remove unused collision field

Change type of done to uint8_t and move it to avoid padding bytes

Signed-off-by: Troels Nilsson <trnn@demant.com>
2024-04-29 15:55:13 +02:00
Ajay Parida 1542140e4e net: wifi: Unicast frames statistics
Unicast RX stats
It represents total number of unicast (any type data, action or
any other unicast frames) frames received at firmware level.
The actual frames passed to host will be different as firmware
may drop packets or some packets may be dropped because of
errors.

Unicast TX stats
Transmission side the unicast packets count states the packets
handed over to firmware. The stats taken at firmware level.
Actual packets transmission may vary depending upon various factors.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2024-04-29 12:17:18 +03:00
Emil Gydesen 65e787be58 Bluetooth: BAP: Shell: Add USB out support for the BAP shell
Add USB out support for the BAP shell, so that decoded LC3
data can be sent to the host (e.g. a PC).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-04-29 11:04:09 +02:00
Emil Gydesen 55ea78f30b Bluetooth: VCP: Remove bad busy flag set for vol ctlr
The volume controller always set the busy flag in
bt_vcp_vol_ctlr_set_vol, where it should only set it
if the GATT operation succeeds.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-04-29 11:02:29 +02:00
Théo Battrel a0198fe420 Bluetooth: Host: Check max adv data len from ctrl
Send a `READ_MAX_ADV_DATA_LEN` command to the controller at the
initialization of the host to fetch the maximum advertising data length
the host can accept.

This is done because even if the Zephyr controller provide the
`CONFIG_BT_CTLR_ADV_DATA_LEN_MAX` Kconfig symbol, other controllers may
not have such Kconfig symbol. So this is a way for the host to be more
controller-agnostic and provide useful feedback to the users.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2024-04-29 11:02:02 +02:00
Johan Hedberg d590bcb5e0 Bluetooth: Remove BT_HCI_RESERVE and BT_HCI_RAW_RESERVE
In most cases these were defined as 1. Saving one byte for the rest
doesn't really justify the added complexity that comes with these
options. Removing them also simplifies the interface between HCI
transports/drivers and the host stack, which in turn helps pave the way
for having HCI as a proper Zephyr driver API.

Fixes #71907

Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
2024-04-29 11:01:27 +02:00
Aleksandr Khromykh dad7c31e7f Bluetooth: Mesh: use bt_rand instead of sys_rand
Commit adds using host\controller based random number
generator instead of zephyr driver.
No mesh dependency anymore on zephyr system
random driver.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2024-04-29 11:00:00 +02:00
Rubin Gerritsen 0a19c18f85 Bluetooth: Host: Document bt_le_scan_update()
This function is used in many places, but just by reading its
name it is not obvious why it is needed.
By adding some documentation it will hopefully become a bit more
clear that this function is mainly used for auto connection
establishment.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-04-29 10:59:28 +02:00
Johan Hedberg ac804c6211 Bluetooth: shell: Fix incorrect check for error return
This line was clearly intended to check for the value returned by
ad_init(). The ad_len is unsigned, so checking for a negative value
showed up in a recent Coverity run (no GitHub issue for it yet).

Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
2024-04-29 10:59:20 +02:00
Théo Battrel 83d6cd4710 Bluetooth: Controller: BT_CTLR_ADV_DATA_CHAIN doc
Update the documentation of `BT_CTLR_ADV_DATA_CHAIN` Kconfig symbol to
say that it's only supported in *non-connectable* extended advertising.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2024-04-28 17:23:10 +03:00
Jonathan Rico 6435262284 Bluetooth: L2CAP: Handle REJECT_RSP for ECRED
We can (and do) open multiple channels with a single L2CAP command. If the
remote doesn't support dynamic channels at all, then it sends back a
REJECT_RSP.

We only destroyed the first channel that matched the command PDU
identifier. Fix that and remove all channels that match.

Also add a test that verifies the patch.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-04-26 19:21:46 -04:00
Alberto Escolar Piedras b304c26c10 logging: Default to IMMEDIATE mode for native targets
Instead of having the boards override the default
in their Kconfig.defconfig
let's just default to IMMEDIATE logging mode in the main
definition if we are building for a ARCH POSIX board.

This avoid issues w dependencies being lost if not duplicated
correctly.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-04-26 19:48:49 +01:00
Aleksandr Khromykh 0015ab0f77 Bluetooth: Mesh: fix dfu srv applying phase
Commit fixes bug if dfu server failed to deliver
apply response it gets stuck in applying phase.
In this phase it skips all further client attempts
to apply image again.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2024-04-26 16:11:20 +02:00
Torsten Robitzki c1b07eda84 logging: fix backend index caluculation
Backend index must also be incremented, when backend is not an autostart
backend. Otherwise, the resulting bit field can not be used to address
a backend by index; autostart field would have to be taken into account.

Signed-off-by: Torsten Robitzki <Torsten@Robitzki.de>
2024-04-26 16:09:24 +02:00
Vinayak Kariappa Chettimada 8fa75e2ada Bluetooth: Controller: Ignore failure to Broadcast ISO remove data path
Ignore failure to Broadcast ISO remove data path when
terminating a BIG without a data path being setup.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-04-26 15:30:26 +02:00
Vinayak Kariappa Chettimada a1e8af0936 Bluetooth: Controller: Fix missing Broadcast ISO HCI reset
Fix missing Broadcast ISO implementation for HCI reset.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-04-26 15:30:26 +02:00
Vinayak Kariappa Chettimada ddce23b447 Bluetooth: Controller: Fix multiple advertiser assertion
When multiple advertisers overlap over time, the random
delay being applied need many ticker operation context.
This causes the ticker_update interface to return error
causing assertion in the Controller.

This is fixed by not applying random_delay value to the
overlapping advertiser that does not get to use the radio.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-04-26 15:30:14 +02:00
Vinayak Kariappa Chettimada fd15e89ae8 Bluetooth: Controller: Increase ull_sched ticker_next_slot_get retries
Increase retries for ull_sched use of ticker_next_slot_get.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-04-26 15:30:14 +02:00
Hang Fan 247ac7fce9 Bluetooth: Classic: Add SDP records for HFP
Add SDP records for HFP Hands-Free

Signed-off-by: Hang Fan <fanhang8@gmail.com>
2024-04-25 18:05:40 -04:00
Fabio Baltieri c5003e0eb1 pm: add device shell commands
Add support for a "pm" shell command to trigger suspend/resume as well
as runtime-get/put on devices. This is useful for testing during driver
development.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-04-25 18:00:05 -04:00
Flavio Ceolin ec83ab333d pm: policy: Fix event integer overflow
In the follow expression:

cyc_evt += UINT32_MAX + 1U

first it is evaluated (UINT32_MAX + 1U), since both types
interpreted as uint32_t, this operation causes an overflow resulting
in 0U.Then we have

cyc_evt = (uint64_t)cyc_evt + 0U

Fix it casting of the operands in the first operation to uint64_t.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-04-25 17:58:04 -04:00
Aleksander Wasaznik 2a7adae6c1 Bluetooth: Rename num_complete_pool -> sync_evt_pool
Refactor only. The surrounding ifdefs are intentionally not changed in
this patch. They will be in the near future.

Rename the pool and generalize the documentation to allow using this
pool for other events that fit the same criteria. This pool can be used
for any buffer that is processed synchronously, without negatively
affecting 'num complete' messages. E.g. 'cmd complete/status' can be put
in this pool already.

We will be working towards making the host process all event buffers
synchronously. This is because events have no dedicated flow control,
and discarding events in the driver without informing the host creates
problems. Discarding should instead happen in the host higher layers
when unavoidable.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-04-25 15:10:50 +02:00
Szymon Janc e4747b28a8 Bluetooth: OTS: Fix checksum calculation support
There was a typo in Kconfig check (missing CONFIG_ prefix) which
resulted in not setting OACP_FEAT_BIT_CRC bit in features.

This also resulted in checksum feature being disabled due to check
in bt_ots_init().

This was affecting OTS/SR/OASP/BV-03-C qualificatio test case.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2024-04-25 07:44:08 -04:00
Jukka Rissanen 07599e3a53 net: vlan: Add a function to check if interface is VLAN one
We were missing a helper function that can be used to check
whether the given function is the virtual VLAN interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-04-25 11:06:23 +00:00
Nithin Ramesh Myliattil 92417967cf Bluetooth: BAP: Shell: Add BASS service data to ext-adv
As per the BAP spec, the scan delegator device should add the BASS service
data in the extended advertising data when it requests a broadcast
assistant to scan for it. For testing purposes that's usually the case
with the shell, extended advertising data shall be populated with the
BASS service data.

Signed-off-by: Nithin Ramesh Myliattil <niym@demant.com>
2024-04-25 09:56:25 +00:00
Galen Krulce 1cfe90d825 tracing: full reset during init
I am using the tracing module using the RAM backend on a system with
limited RAM & a buffer that can only store 300ms of tracing data. Current
tracing module starts recording during boot-up & we run out of memory prior
to executing code we actually want to trace.

By reseting buffer metadata here, I can call init() at an arbitrary point
of program execution & the tracing module will reset & start tracing.

I tested on E2E on an ARM M-class MCU by calling init & then reading
buffered tracing data via GDB

Signed-off-by: Galen Krulce <gkrulce@meta.com>
2024-04-24 17:08:24 -04:00
Al Semjonovs 0bca04635d shell: Allow extension of shell APIs
Similar to logging module, allow application specific extension of
shell fprintf APIs at a macro level.

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2024-04-24 16:04:03 -04:00
Joakim Andersson 24264ad4af shell: Improve the default serial backend init level
Improve the default serial backend init level.
The documentation says to be bigger than the init level of the serial
device used. Since serial devices default to the kernel device init
level (50) then put this to default of application level drivers (90).

Signed-off-by: Joakim Andersson <joerchan@gmail.com>
2024-04-24 19:42:23 +00:00
Vinayak Kariappa Chettimada 2329a2f0a1 Bluetooth: Controller: Aux offset population assertion check
Add aux offset population assertion check, to ensure the
aux offset calculation is completed before the primary
PDU is setup for transmission.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-04-24 15:02:28 -04:00
Aleksandr Khromykh fe13209eb1 Bluetooth: Mesh: fix start rx transaction before tx is ended
Commit fixes behavior when provisioning protocol accepts
incoming transaction before ongoing tx transaction is
still active (device didn't receive acknowledgement yet).
Incoming data are ignored until ack is not received.

Specification:
5.3.3 Generic Provisioning behavior
...
If the sender receives a Transaction Acknowledgement
message, then the transaction has completed.
If the sender receives a message with other PDU types,
then the message shall be ignored.
...

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2024-04-24 15:01:43 -04:00
Tomi Fontanilles a986905df5 modem: chat: implement helper defines/structs
Those helpers allow to define some typical kinds of chat matches and
scripts with more ease/less boilerplate.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2024-04-24 15:00:10 -04:00
Dominik Ermel c007e717d4 mcumgr/img_mgmt: Fix zcbor logic in os_mgmt_bootloader_info
There have been to problems with the code where zcbor_bool_encode
has been fed value instead of expected pointer and the result
of previous zcbor_encode operations has not been taken to evaluate
value of ok status.
The change also replaces usage of  #if IS_ENABLED with #ifdef, as
IS_ENABLED should not be used outside if().

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-04-24 14:55:57 -04:00
Henrik Brix Andersen 7390740c29 canbus: isotp: use proper CAN ID masks
Use CAN ID masks matching the flags used in the CAN RX filter.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2024-04-24 09:53:06 +02:00
Ajay Parida 02f4e71633 net: l2: wifi: Fix for wrong return type
The function should return NULL instead of false in case of failure.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2024-04-24 09:52:48 +02:00
Ajay Parida b93002655e net: l2: wifi: Protect processing of nm data
Use lock while accessing nm data.
One of the use case is while setting regulatory, it accesses nm data,
while from some other place also it can be accessed same time.
Protected the nm data processing.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2024-04-24 09:52:48 +02:00
Jonathan Rico b08b1c21a0 net: buf: Disallow blocking allocation in syswq
Work items on the syswq should always run-to-completion.

Override the timeout value to always be K_NO_WAIT.

Allocating with K_FOREVER leads to deadlocks if the freeing also happens
from the syswq. Non-zero timeouts are also not nice for the other users
of the syswq.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-04-23 19:47:24 -04:00
Chaitanya Tata b29dff09fa net: wifi: Check for mandatory args
Even though we are passing mandatory args from the shell registration,
due to use of getopt the check can be bypassed without the hyphenated
options.

So, enforce and fail if mandatory parameters aren't passed through
getopt.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-04-23 19:46:57 -04:00