Commit graph

12757 commits

Author SHA1 Message Date
Chen Peng1 5a23383ad6 tests: interrupt: remove unused macro TRIGGER_IRQ_INT.
On X86 platforms, the interrupt trigger method has been
changed to use APIC IPI, we don't use INT command to trigger
interrupt, so remove this unused macro.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2022-06-23 09:08:43 +02:00
Chen Peng1 40fb6fca05 tests: interrupt: add some nop operations in trigger_irq function.
On X86 platforms, the interrupt trigger method has been changed
from using INT command to using APIC IPI, we need to make sure
the IPI interrupt is handled before do our check, so add some
nop operations.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2022-06-23 09:08:43 +02:00
Emil Gydesen b2cbd9f58c Bluetooth: CSIS: Client use const for conn lookup funcs
`bt_conn_index` has been changed to take a `const bt_conn`
which allows our functions that use this to also take a
`const` parameter.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-23 09:08:05 +02:00
Emil Gydesen 7148146348 Bluetooth: CSIS: Implement ordered access procedure for CSIS client
the CSIS client now has a ordered access procedure function.
The function implements the procedure as per the CSIP spec,
where it will verify that 1 or more members are unlocked,
and the execture a procedure on each member in ascending
order of rank.

The procedure can be anything (even a non-BT procedure),
and it will be up to the applicaiton to implement
what to do in that.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-23 09:08:05 +02:00
Emil Gydesen 0558b3af95 Bluetooth: CSIS: Stored actives members by rank
Instead of getting doing look ups for each member
for the CSIS client procedures, we store the active
members ordered by rank.

This is slightly less efficient in cases of error,
but for some procedures as the upcoming Ordered
access procedure where we need to access each
member twice, ordering them once is more
efficient.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-23 09:08:05 +02:00
Emil Gydesen d995901a76 Bluetooth: CSIS: Remove const for members in API
Having the members array being const causes a lot of
limitations in the implementatation, and was
occasionally even disregarded. Removed to make the
implementation more flexible.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-23 09:08:05 +02:00
Benjamin Gwin ee22ae79a4 testsuite: Make ztest_error_hook compatible with C++
This lets ztest error hooks be used from C++ based tests.

Signed-off-by: Benjamin Gwin <bgwin@google.com>
2022-06-22 19:30:06 -04:00
Lingao Meng e6d27c77ef Bluetooth: Host: Fix ATT security vulnerabilities
When the client receives att error rsp, but the error code
is an illegal value, such as 0, an exception will be triggered.

gatt_read_type --> gatt_read_type_rsp --> parse_characteristic

`switch (rsp->len) {` null address access.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-06-22 12:29:26 +02:00
Andrei Emeltchenko b970c4daef net: capture: Remove unneeded variable
Remove unused remote_addr_len variable.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-22 12:28:35 +02:00
Andrei Emeltchenko 3d42168c74 net: ipv4: Remove double assignment
Remove double assignment of cfg variable.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-22 12:28:35 +02:00
Andrei Emeltchenko e0e1a12eba net: ipv6: Remove double assignment
Value of nexthdr is already assigned several lines above.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-22 12:28:35 +02:00
Andrei Emeltchenko c27b72b331 net: ethernet: Remove double assignment
Variable type would be assigned at the block end.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-22 12:28:35 +02:00
Andrei Emeltchenko 77c694178f net: ppp: Fix stored value never read warning
Move declarations to the debug block where they are actually used.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-22 12:28:35 +02:00
Emil Gydesen b2c8fa9c53 Bluetooth: Shell: Fix unused variable in iso.c
The `iso_qos` was only used for connected ISO, but
was placed outside of the CONFIG_BT_ISO_UNICAST
guard, such that for broadcast ISO-only it was unused.

Move the declaration and renamed to cis_iso_qos.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-22 12:28:21 +02:00
Vinayak Kariappa Chettimada 048619639d boards: nrf5340dk_nrf5340_cpunet: Disable BT_ECC support
Disable BT_ECC support in network core to reduce RAM usage.
ECC implementation can instead be supported in the Host
running in the application core.

This is also to keep hci_uart (nRF52 Series) and hci_rpmsg
(nRF53 Series) have the same support features. ECC is not
enabled in hci_uart sample.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-06-22 12:28:05 +02:00
Sjors Hettinga 4243e8e99c net: tcp: Do not capture tx_sem during retransmission
As the stack can safely keep allocating data during retransmission mode
there is no need to take the tx_sem during retransmission any more.

Data stored in the send_data buffer will be transmitted upon the ack of
the data for which an ack is pending. This the application being fully
stalled when the TCP connection enters retransmission mode.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-06-22 12:25:40 +02:00
Sjors Hettinga 17f94d3f96 net: tcp: Revert: Do not accept new data in retransmission mode
After the window_full function has been fixed by looking at the
send_data_total instead of the unacked_len. There is no risk
in sending data in transmission mode.

This reverts commit 0088aaefa0.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-06-22 12:25:40 +02:00
Troels Nilsson eabdf16087 Bluetooth: host: Fix resume failing with extended advertising
Fix advertising failing to resume with BT_ADV_PERSIST set in
bt_hci_le_adv_set_terminated due to BT_ADV_ENABLED not getting
cleared before bt_le_adv_resume gets called

Signed-off-by: Troels Nilsson <trnn@demant.com>
2022-06-22 12:25:10 +02:00
Troels Nilsson 0f892ff8c8 Bluetooth: host: Fix missing endianness conversions
Fix missing endianness conversion for props in le_ext_adv_param_set
and bt_le_per_adv_set_param

Signed-off-by: Troels Nilsson <trnn@demant.com>
2022-06-22 12:25:10 +02:00
Carlo Caione 1608c8adba pm: Introduce CONFIG_PM_DEVICE_RUNTIME_EXCLUSIVE
Sometimes we want to entirely decouple the system PM from the device PM,
leaving the devices to manage its own power states using the runtime PM.

This is currently not possible because the suspend / resume code path is
triggering the device PM hooks even when the runtime PM is enabled.

Introduce a new PM_DEVICE_RUNTIME_EXCLUSIVE symbol to allow the platform
to skip the device PM triggers on suspend / resume.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-22 12:24:43 +02:00
Vinayak Kariappa Chettimada e994ec1557 Bluetooth: Controller: Fix Tx Buffer allocation for Encryption Request
Encryption request is enqueued in thread context from the Tx
buffer pool, so that it is serialized alongwith the already
enqueued data buffers ensuring they are transmitted out to
peer before encryption is setup. Allocate additional Tx
buffers to accommodate simultaneous encryption setup across
active connections.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-06-22 12:22:29 +02:00
Morten Priess ca8457d882 Bluetooth: controller: Fixes for ISO from IAL testing
- Prevent NULL-pointer dereferencing if datapath is created late
- Support SDU fragment complete-counting for framed case

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-06-22 12:21:16 +02:00
Nirosharn Amarasinghe fc107a0775 Bluetooth: controller: Unified ISO-AL TX SDU fragment count
Implemented incrementing TX SDU fragment count such that it indicates
the number of completed SDU fragments in the PDU being emitted for both
unframed and framed transmission.

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2022-06-22 12:21:16 +02:00
Nirosharn Amarasinghe af37b444d4 Bluetooth: controller: fix for some problems in ISO-AL RX and HCI
HCI:
-- Discarded data from HCI ISO Data packets from controller to host if
   data has been lost

ISO-AL:
-- Corrected iso_interval in latency calculations
-- Updated handling and release of SDUs for error conditions / padding
   at the last PDU for the SDU
-- Updated prioritisation of error status in released PDUs
-- Included error spooling exit on based on payload number to SDU
   mapping for unframed reassembly
-- Updated sequence number handling for framed recombination

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2022-06-22 12:21:16 +02:00
Morten Priess ef28184af2 Bluetooth: controller: Asynch stop of ISO resume ticker in disable
Do not use ull_ticker_stop_with_mark for ISO one-shot resume ticker, but
stop without checking result. If active this will stop it, otherwise it
is ignored. Also, this prevents calling lll_disable twice.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-06-22 12:21:16 +02:00
Morten Priess 3d4215d6a3 Bluetooth: controller: LLCP and ISOAL Fixes for EBQ LL tests
- Prioritize CIS_REQ handling in (old) LLCP
- Reject if CIS_REQ uses exisiting CIS ID

These fixes prevent assertions in /LL/CIS/PER/BV-38-C.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-06-22 12:21:16 +02:00
Ola Tangen Kulseng 38628f409e net: lwm2m: Add LwM2M shell commands for start&stop
Added start, stop and update to the shell.
Refactored the event_cb of the rd_client_info struct into the ctx,
as it was needed in the shell script.

Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
2022-06-22 12:17:52 +02:00
Ola Tangen Kulseng 3e50624e39 net: lwm2m: Added commands to the lwm2m_client shell
Added read, write and execute commands to the shell.

Signed-off-by: Ola Tangen Kulseng <ola.kulseng@nordicsemi.no>
2022-06-22 12:17:52 +02:00
Dominik Ermel f9d69c34c9 mgmt/mcumgr/lib: Remove dead code from img_mgmt_upload
The img_mgmt_impl_erase_if_needed was only called when
CONFIG_IMG_ERASE_PROGRESSIVELY is y, and it does nothing anyway;
because the function always returns 0, and does nothing,
neither the function no result processing, from a call to the
function, is needed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-21 13:42:24 +02:00
Dominik Ermel 0a5525358c mgmt/mcumgr/lib: Add BUSY error code
The commit reserves adds MGMT_ERR_EBUSY (10) error code and adds
documentaiton for it.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-21 11:55:19 +02:00
Dominik Ermel 185630e387 mgmt/mcumgr/lib: Correct comment alignment
Some of comments have not been aligned to tabs.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-21 11:55:19 +02:00
Dominik Ermel d261c3b891 mgmt/mcumgr/lib: Remove flash_area_open_ex
The function is no longer needed with fix provided by commit
aa5d20aaef (storage/flash_map: Return -ENODEV from flash_area_open).

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-21 11:48:23 +02:00
Dominik Ermel 4aea359f27 mgmt/mcumgr/lib: Remove unused state variables from image management
Image management state, struct img_mgmt_state, has been defining
sector_id and sector_end variables, supposed to be used by
progressive erase feature, that have no use in code.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-21 11:48:04 +02:00
Dominik Ermel 8b7b81d0f2 mgmt/mcumgr/lib: Fix overriding returned error code
The img_mgmt_upload has been overriding return codes of several
utility function calls with MGMT_ERR_EUNKNOWN, even though
these utility functions would be returning MGMT_ERR_* type codes
already, overshadowing real reason of failure.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-21 11:47:43 +02:00
Dominik Ermel 1243bf6d15 mgmt/mcumgr/lib: Change image, size and offset types
The commit changes types of image, size and offset elements of
img_mgmt_upload_req structure from unsigned long long to size_t.

This commit also fixes comments and conditional statements, where
these identifiers have been compared against -1, although they have
been clearly defined as unsigned.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-21 11:47:10 +02:00
Aleksandr Khromykh c0749bef83 Bluetooth: Mesh: fix not initialized uuid in model publication
uuid wasn't initialized in the publication setting command.
It caused wrong the configuration clietn behavior.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2022-06-21 10:49:01 +02:00
Morten Priess 4e3aeeddde Bluetooth: host: Fix endianness error in L2CAP
Recent code change asserts on ECRED psm being consistent in
l2cap_ecred_conn_req. However, the values are compared between
endianness converted value and non-converted value, which fails on BE
archs.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-06-21 10:47:48 +02:00
Audun Korneliussen db78d04a96 Bluetooth: ISO: Add function for reading TX sync
This function retrieves TX sync information
(timestamp, offset, and sequence number)
from controller using HCI command HCI_LE_Read_ISO_TX_Sync.

Signed-off-by: Audun Korneliussen <audun.korneliussen@nordicsemi.no>
2022-06-21 10:46:56 +02:00
Martin Jäger 65eede8194 lorawan: add LoRaWAN Class C support
The functions for Class C mode are already provided by LoRaMAC layer.

A device in this mode is listening for incoming downlink messages almost
continuously, which results in higher energy consumption.

Class C mode is required for FUOTA.

Signed-off-by: Martin Jäger <martin@libre.solar>
2022-06-20 09:17:33 -04:00
Juha Heiskanen 6d42ded565 net: lwm2m: LwM2M message allocation update
Allocated own message buffer for RD client interface.
This helps to cover if all messages are queued and need to do
registration or update.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
(cherry picked from commit 8dca91109d73a4a697e074c58ee9430d56c01a51)
2022-06-20 09:13:41 -04:00
Juha Heiskanen ad1960625a net: lwm2m: Fix Possible Notification send blocker
If Notification build fail there was possible that Notification
are blocked after failure.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
(cherry picked from commit 6dfa242c7d891b3458ab88df46b69b3a9621ee82)
2022-06-20 09:13:41 -04:00
Juha Heiskanen e4ce689de2 net: lwm2m: Coap Pending clear update
Fixed couple possible place for leak Coap pending entry.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
(cherry picked from commit 3c175951383be56fa9c1451845a15b66df41ff64)
2022-06-20 09:13:41 -04:00
Erik Brockhoff 96817164ea Bluetooth: controller: llcp: phy update proc, validate phys and instant
Implementing proper validation of PHY selection for PHY UPDATE procedure
Implement connection termination on PHY UPDATE with instant in the past

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-06-20 14:01:23 +02:00
Vinayak Kariappa Chettimada 7ff8581916 Bluetooth: Controller: Replace k_sem_take loop with k_sem_reset
Replace k_sem_take loop used for consuming the remaining
sem give counts with k_sem_reset.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-06-20 10:27:08 +02:00
Vinayak Kariappa Chettimada ae8e7f4c22 Bluetooth: Controller: Fix pdu_free_sem_give assertion under ZLI use
Fix assertion due to multiple mayfly_enqueue calls used
under ZLI when pdu_free_sem_give is invoked from the LLL.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-06-20 10:27:08 +02:00
Stephanos Ioannidis 33f87408c4 global: Correct extern K_KERNEL_STACK_ARRAY_DEFINE usage
This commit corrects all `extern K_KERNEL_STACK_ARRAY_DEFINE` macro
usages to use the `K_KERNEL_STACK_ARRAY_DECLARE` macro instead.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-06-20 10:25:52 +02:00
Seppo Takalo 4a8efbb1bc net: lwm2m: Allow longer lifetimes than uint16_t
Lifetimes are really 32 bit values, so the limitation
did not make sense, and it did not allow 24 hour lifetime.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-06-20 10:25:41 +02:00
Rubin Gerritsen 860592698b bluetooth: kconfig: Hide host options if not available
When performing a combined host and controller build, there is no point
in presenting the option to enable a given host feature if the
controller does not support it. This reduces the list of presented
features to enable/disable.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-06-17 10:49:51 -05:00
Azizah Ibrahim 2a175b6abd bluetooth: host: Revert "Avoid sending duplicate device to resolving list."
This reverts commit e11ff7df48.
This patch causes some PTS failure.
Another patch to address duplicate device will follow.

Signed-off-by: Azizah Ibrahim <azizah.ibrahim@nordicsemi.no>
2022-06-17 13:18:25 +02:00
Flavio Ceolin f232db4630 pm: Avoid unnecessary check in SMP
_current_cpu is a macro that expands to an assert that checks if the
current context can be migrated to a another cpu. Since this
pm_system_suspend() is called from the idle thread (each cpu has its
own) and  with locked this check is redundant. Just use
arch_curr_cpu() to avoid it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-06-16 19:53:20 -04:00
Flavio Ceolin 2cd49ca0fe pm: Fix possible assertion when resuming
pm_system_resume() can be called from the idle thread with
interruptions unmasked. In this situation, _current_cpu will call
z_smp_cpu_mobile() that will return true and cause an assert.

In this function we don't need to check if the current context can be
preempted, we just need the information about which cpu is executing
it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-06-16 19:53:20 -04:00
Yuval Peress d813e9b39f ztest: Fix incorrect use of this as fixture
Update `this` to `fixture` to avoid C++ keyword error.

Fixes #46459

Signed-off-by: Yuval Peress <peress@google.com>
2022-06-16 16:13:18 -04:00
Yuval Peress 3634456e6b ztest: re-format header
Run clang-format on ztest_test_new.h to clean up some style issues

Signed-off-by: Yuval Peress <peress@google.com>
2022-06-16 12:31:27 -04:00
Yuval Peress beecf051d9 ztest: cleanup old linker script
A reminant of the old linker script was left in a previous PR.
Remove it.

Signed-off-by: Yuval Peress <peress@google.com>
2022-06-16 12:31:27 -04:00
Krzysztof Chruscinski c5f2cdef09 logging: Remove logging v1 from the logging
Remove v1 implementation from log_core and all references in the tree.
Remove modules used by v1: log_list and log_msg.
Remove Kconfig v1 specific options.
Remove Kconfig flags used for distinction between v1 and v2.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-16 10:51:15 -04:00
Wolfgang Puffitsch 9a4c3f1afa Bluetooth: controller: Tie Configure Data Path to Read Supported Codecs
The Configure Data Path command must be included when the read Local
Supported Codecs [v2] command is supported. The Configure Data Path
command is needed when vendor-specific ISO data paths are supported,
but not otherwise tied to ISO. The respective weak function is
therefore moved to ull.c.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2022-06-16 11:26:03 +02:00
Anders Storrø b28e024fdb Bluetooth: Mesh: Configurable RPL module
Introduce configuration options for chosen RPL implementations.

This will allow introducing alternate persistent storage schemes
for the replay protection list.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-06-16 10:29:38 +02:00
Szymon Janc 253070b76b Bluetooth: host: Fix L2CAP reconfigure response with invalid CID
When an L2CAP_CREDIT_BASED_RECONFIGURE_REQ packet is received with
invalid parameters, the recipient shall send an
L2CAP_CREDIT_BASED_RECONFIGURE_RSP PDU with a non-zero Result field
and not change any MTU and MPS values.

This fix incorrectly reconfiguring valid channels while responding with
0x003 (Reconfiguration failed - one or more Destination CIDs invalid)
result code.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2022-06-16 10:28:44 +02:00
Szymon Janc 266394dea4 Bluetooth: host: Fix L2CAP reconfigure response with invalid MTU
TSE18813 clarified IUT behavior and rejecting reconfiguration which
would result in MTU decrease is enough. There is no need to disconnect
L2CAP channel(s).

This was affecting L2CAP/ECFC/BI-03-C qualification test case
(TCRL 2022-2).

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2022-06-16 10:28:44 +02:00
Al Semjonovs 0411aa666c ztest: Add CLI arguments to filter test/suites ran
Added test command line arguments to filter
which tests are executed. Filtered tests should follow
suiteA::test1,suiteB::test2 format.

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2022-06-15 18:06:54 -04:00
Krzysztof Chruscinski 907cd8a54f bluetooth: Remove support for logging v1
Remove support for logging v1 from bluetooth monitor log backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Krzysztof Chruscinski 747d6ffdb0 shell: Remove support for logging v1
Remove support for logging v1 from shell log backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Krzysztof Chruscinski 3faee83748 logging: log_backend_xtensa: Remove LOG1 support
Remove support for LOG1 from Xtensa backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Krzysztof Chruscinski 34a725e89d logging: log_backend_uart: Remove LOG1 support
Remove support for LOG1 from UART backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Krzysztof Chruscinski 7c48063a1f logging: log_backend_swo: Remove LOG1 support
Remove support for LOG1 from SWO backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Krzysztof Chruscinski 28e9f4a559 logging: log_backend_spinel: Remove LOG1 support
Remove support for LOG1 from spinel backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Krzysztof Chruscinski ca24cb8948 logging: log_backend_rtt: Remove LOG1 support
Remove support for LOG1 from RTT backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Krzysztof Chruscinski 2bb3e64f89 logging: log_backend_net: Remove LOG1 support
Remove support for LOG1 from net backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Krzysztof Chruscinski e550a5ccda logging: log_backend_native_posix: Remove LOG1 support
Remove support for LOG1 from native_posix backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Krzysztof Chruscinski eb3756c2be logging: log_backend_fs: Remove LOG1 support
Remove support for LOG1 from filesystem backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Krzysztof Chruscinski 31971a5593 logging: log_backend_adsp: Remove LOG1 support
Remove support for LOG1 from ADSP backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Vinayak Kariappa Chettimada ec286d0227 Bluetooth: Controller: Fix missing PDU next pointer initialization
When supporting chain PDUs, after HCI reset the first PDU
allocated did not initialize its next pointer causing use
of unallocated PDUs for chaining while a duplicate of such
PDU buffer being allocated for other states/roles. This
causes in certain cases both Extended and Periodic PDUs
having same data, the Extended Advertising PDU being
transmitted at the instant of the Periodic Advertising.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-06-15 09:13:22 +02:00
Gerard Marull-Paretas 8cb33df108 pm: remove redundant <zephyr/zephyr.h> includes
Files including <zephyr/kernel.h> do not have to include
<zephyr/zephyr.h>, a shim to <zephyr/kernel.h>.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-06-15 09:13:11 +02:00
Gerard Marull-Paretas e207b39404 mgmt: osdp: remove redundant <zephyr/zephyr.h> includes
Files including <zephyr/kernel.h> do not have to include
<zephyr/zephyr.h>, a shim to <zephyr/kernel.h>.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-06-15 09:13:11 +02:00
Krzysztof Chruscinski ad12e4be32 logging: Add guards for v1 frontend API
Prevent of linking of v1 frontend API when it is not being used.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 09:12:04 +02:00
Martin Jäger ad55227903 lorawan: make function and variable names consistent
Use Zephyr coding style for variable names and functions where possible.

The function BoardGetUniqueId has to be kept as is to match LoRaMAC
library declarations.

Signed-off-by: Martin Jäger <martin@libre.solar>
2022-06-15 09:11:34 +02:00
Vinayak Kariappa Chettimada 1578dc699b Bluetooth: Controller: Fix RX_ENQUEUE_HOLD for LOW_LAT_ULL
Fix BT_CTLR_RX_ENQUEUE_HOLD implementation that stalled
generating the CONN_UPDATE and PHY_UPDATE when there were
no Rx data or Tx acknowledgements to be processed when
the controller was built with BT_CTLR_LOW_LAT_ULL.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-06-14 10:21:24 +02:00
Veijo Pesonen fbef82c9c0 net: lwm2m: SenML JSON bootstrap exceptions
In bootstrap mode write to a non-exisisting optinal resource must not
cause an error.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-06-14 09:31:23 +02:00
Veijo Pesonen a5eae6f898 net: lwm2m: adds preferred content...
...format to bootstrap registration message with LwM2M v1.1.

SenML CBOR takes precedence, followed by SenML JSON and OMA TLV.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-06-14 09:31:23 +02:00
Veijo Pesonen db602fd81d net: lwm2m: Missing optional resource does not ...
...trigger write to the error log

Uses debug-level instead.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-06-14 09:31:23 +02:00
Veijo Pesonen 7f54aea934 net: lwm2m: SenML CBOR opaque write fixed
Write to an opaque resource failed and it has been fixed. Support for
blockwise transfer is still missing.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-06-14 09:31:23 +02:00
Veijo Pesonen 4177aa21ec net: lwm2m: SenML CBOR bootstrap exceptions
In bootstrap mode write to a non-exisisting optinal resource must not
cause an error.

Signed-off-by: Veijo Pesonen <veijo.pesonen@nordicsemi.no>
2022-06-14 09:31:23 +02:00
Jedrzej Ciupis adca70c0fa net: lib: openthread: use ieee802154_txpwr property
This commit aligns openthread radio platform to use `ieee802154_txpwr`
of the packet to transmit instead of setting power through a separate
API call, if possible.

Signed-off-by: Jedrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
2022-06-14 09:30:43 +02:00
Jedrzej Ciupis 644da741f4 net: pkt: add IEEE 802.15.4 TX power field
This commit extends the `struct net_pkt` structure with
`ieee802154_txpwr` field that contains signed value of the desired
transmission power of a IEEE 802.15.4 frame in dBm.

Signed-off-by: Jedrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
2022-06-14 09:30:43 +02:00
Keith Packard abac6ccfaf subsys/usb: Fix use of 'abs' in computing when to report on_idle
idle_rate is uint8_t, sof_cnt is uint32_t. The result is uint32_t, which
is the wrong type for 'abs'. Explicitly cast idle_rate to uint32_t,
subtract sof_cnt and then explicitly cast to int32_t and then use abs,
storing the result in another int32_t which matches the return type for
abs.

This quiets clang warnings about passing unsigned values to abs.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-14 01:50:36 +09:00
Lingao Meng bfec3b2ab4 Bluetooth: host: ASCS: Correction code comments
Audio Stream Control Service Revision: v1.0

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-06-13 12:12:50 +02:00
Lingao Meng 5af553d0d0 bluetooth: audio: pacs: Fix missing CONFIG_
`BT_PAC_SRC_LOC_WRITEABLE` should be `CONFIG_BT_PAC_SRC_LOC_WRITEABLE`

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-06-13 12:12:50 +02:00
Mariusz Skamra 790b73773e Bluetooth: audio: Allow user to set supported context as available only
This adds checks to avoid setting context that is not indicated as
supported to be available.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-13 12:12:11 +02:00
Mariusz Skamra e5cfb1ca4a Bluetooth: audio: Add getter for available audio context
Extend API with available audio contexts getter method.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-13 12:12:11 +02:00
Andrei Emeltchenko a4fe0edfdc net: dns: Return error code
Return ret error code instead of always returning zero causing
warnings:

...
subsys/net/lib/dns/resolve.c:975:6: warning: variable 'ret' set but
not used [-Wunused-but-set-variable]
        int ret = 0;
            ^
...

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-13 12:11:54 +02:00
Andrei Emeltchenko 4874910465 net: dns: Remove unused variable
Fix compilation warnings:
...
subsys/net/lib/dns/dns_pack.c:548:6: warning: variable
'remaining_size' set but not used [-Wunused-but-set-variable]
        int remaining_size;
            ^
...

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-13 12:11:54 +02:00
Andrei Emeltchenko be2340ab96 net: net_context: Remove double assignment
Remove double assignment, the value is stored in initialization.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-13 12:11:54 +02:00
Dominik Ermel f52085dc54 mgmt/mcumgr/lib: Fix loop when image write fails
The img_mgmt_upload was getting into loop with requesting
offset 0 from mcumgr, when requested to re-try upload after
write fails.
Because it is not really possible to recover from write fail,
at least currently, the commit changes code to reset upload
state in a case of write error and return an error code.
Now, when write fails, an error will be returned and upload
process will be stopped and reset; upload re-try will behave
as a new upload has been requested.

Fixes #44219

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-10 09:48:31 +02:00
Dominik Ermel 3d8960ffe3 mgmt/mcumgr/lib: Remove redundant offset check
The offset is checked, for correctness, before the function
img_mgmt_impl_write_image_data is called, so it is redundant to
do the same check within it.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-10 09:48:31 +02:00
Lars Knudsen c27532eec4 Bluetooth: csis: add RSI advertising callback
Makes it possible for an application to
handle CSIS RSI advertising by registering a
callback, which will disable the internal
CSIS advertising.

Also fixes registering callbacks in CSIS.

Signed-off-by: Lars Knudsen <larsgk@gmail.com>
2022-06-10 09:47:40 +02:00
Andrei Emeltchenko 766358461c net: lwm2m: Fix NULL pointer dereference
It does make sense to goto to cleanup part.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-10 09:47:05 +02:00
David Palchak b4a7f0f2ca linker: ensure global constructors only run once
Rename the symbols used to denote the locations of the global
constructor lists and modify the Zephyr start-up code accordingly.
On POSIX systems this ensures that the native libc init code won't
find any constructors to run before Zephyr loads.

Fixes #39347, #36858

Signed-off-by: David Palchak <palchak@google.com>
2022-06-09 11:33:36 +02:00
Sjors Hettinga e097d95c66 net: tcp: Implement Nagle's algorithm
To improve the performance with small chunks send, implement Nagle's
algorithm. Provide the option TCP_NODELAY to disable the algorithm.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-06-09 11:32:50 +02:00
Mariusz Skamra c44ef044b8 Bluetooth: monitor: Avoid sending corrupted packets over RTT
This fixes sending corrupted (incomplete) packets over RTT. Additional
helper buffer has been added to ensure the complete packet before it
can be sent over RTT. Once the complete packet is collected it is sent
to the RTT control block in non-blocking manner. From now there will
be no situation that only part of the packet (e.g. header) is sent
which lead btmon to fail to parse the corrupted data.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-09 11:32:39 +02:00
Mariusz Skamra e7b66d1b73 Bluetooth: monitor: Fix sending logs over RTT
This fixes Bluetooth logs that were not sent over RTT.
Minor cleanup has been made to limit the number of ifdefs.

> ACL Data RX: Handle 0 flags 0x02 dlen 11      #1049 83.117000
      ATT: Handle Value Indication (0x1d) len 6
        Handle: 0x0003
          Data: 0100ffff
= bt: bt_att: Unhandled ATT code 0x1d                 83.117100
> HCI Event: Disconnect Complete (0x05) plen 4  #1050 84.247700
        Status: Success (0x00)
        Handle: 0
        Reason: Remote User Terminated Connection (0x13)

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-09 11:32:39 +02:00
Vinayak Kariappa Chettimada 1a56f766bc Bluetooth: Controller: Config ticker with slot window to yield
Add Kconfig option to conditionally enable tickers with slot
window to yield to normal tickers and be placed at the end
of their slot window if possible.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-06-09 11:32:33 +02:00
Markus Rekdal 3d8f938929 net: lwm2m: Fix range of integers in SenML CBOR
This fixes a minor bug that caused an error if one attempted to encode
or decode INT64_MIN in SenML CBOR

Signed-off-by: Markus Rekdal <markus.rekdal@nordicsemi.no>
2022-06-09 11:32:01 +02:00
Markus Rekdal 0006f2c93e net: lwm2m: Fix decoding of objlnk in SenML CBOR
This fixes a bug in the decoding of objlinks. Without this the object
instance id is not retrieved correctly as it tries to read the second id
starting from the colon.

Signed-off-by: Markus Rekdal <markus.rekdal@nordicsemi.no>
2022-06-09 11:32:01 +02:00
Seppo Takalo e0296ca0b9 net: lwm2m: Allow initializing opaque and string data to zero length
By default, any string or opaque data that LwM2M engine initializes
sets data lenght to same value as given buffer length for that
resource.

However, on run time, engine keeps track how much data is written
to each resource, so when reading from any resource, should only
return data that has been written there. But uninitialized resources
return the content of the whole buffer.

Fixed the problem by introducing macros INIT_OBJ_RES_LEN(),
INIT_OBJ_RES_MULTI_DATA_LEN() and INIT_OBJ_RES_DATA_LEN() that
allows you to give the amount of data existing in buffer when
the resource is initialized. This sets the data_len and max_data_len
variables correctly.

Also introduced new functions lwm2m_engine_get_res_buf() and
lwm2m_engine_set_res_buf() that distinct between data size and
buffer size. Deprecated the previous functions
lwm2m_engine_get_res_data() and lwm2m_engine_set_res_data()

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2022-06-09 11:30:37 +02:00
Krzysztof Chruscinski d660492914 logging: Add option for prolonged backend initialization
Extended logging backend API with log_backend_is_ready call which
returns 0 is backend is ready. Logging core will make sure that
all autostarted backends are ready before they are enabled.

This option allows to handle backends which are not yet ready
after init function is called (e.g. usb backend that is not plugged
in). If this is the only backend in the system, logging processing
will not start util first backend is ready.

Function for checking readiness is optional and when backend has
no such function it is assumed that backend is ready after
initialization function returns which makes this feature backward
compatible.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-09 09:40:01 +02:00
Mariusz Skamra 868b180d64 Bluetooth: Make use of BT_CODEC_LC3_CHAN_COUNT_SUPPORT macro
Use the BT_CODEC_LC3_CHAN_COUNT_SUPPORT macro to define the supported
channel counts.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-08 12:45:34 +02:00
Mariusz Skamra 132ad4ac89 csis: Remove check causing assertion
This removes the check that was causing missalignment in
csis->srv.conn_cnt conunting. The csis->srv.conn_cnt was increased for
each connected device while decreased for bonded only. This caused
assertion in csis_connected when reconnected.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-08 12:45:07 +02:00
Mariusz Skamra 2dff20fe4b csis: Simplify the current connections counting
This makes the code cleaner.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-08 12:45:07 +02:00
Jordan Yates 319ffaed0a pm: device: helper to query power state
Adds a helper function to query whether a device is currently powered.
This can be used to determine if the chip can be initialised now, or if
it needs to be deferred.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-06-08 12:43:00 +02:00
Krzysztof Chruscinski 0829610bbc lib: os: spsc_pbuf: Add option to use cache
Add flags option to init call and a flag to use cache.
Add Kconfig choice to pick how to approach cache. Cache can be
enforced in all spsc_pbuf instances, disable in all, or runtime selected
based on configuration flag. Option is added to allow memory footprint
savings.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-07 19:04:35 +02:00
Krzysztof Chruscinski 2f189e39a5 lib: os: Rename icmsg_buf to spsc_pbuf
Move icmsg_buf to lib/os and rename to spsc_pbuf (Single Producer
Single Consumer Packet Buffer). It is a generic module and initially
was created as internal module for ipc service.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-07 19:04:35 +02:00
Sjors Hettinga e3b8fad9fa net: tcp: Fix accidental removal of data from send_data
In the function net_tcp_queue_data. When an -ENOBUFS by
tcp_send_queued_data is returned, it throws away the whole block of size
len from the send_data. If the len is > MSS, it could happen that the
first section is transmitted, but at the second an -ENOBUFS occurs.
In that case the data is transmitted, but later on removed from the
send_data.

To circumvent this problem, check if the len + unacked_len is smaller
then the send_data_total. If so, the data can safely be removed from
send_data. Otherwise, just pretend the transmission went OK. The
acknowledgment and retransmit path will eventually take care of it.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-06-07 18:55:44 +02:00
Sjors Hettinga ebf8b6d3da net: tcp: Fix the polling implementation with corrected window filling
The window full computation was corrected to use the send_total instead
of the unacked_len. This conflicted with the new polling implementation
due to the moment when these values are changed.

Move taking the tx_sem outside of tcp_send_queued_data to handle the
-ENOBUF situation properly in case called from net_tcp_queue_data.
net_tcp_queue_data removes data from the send_data in case the
transmission failed with -ENOBUF. This cause the buffer to be not full
any more.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-06-07 18:55:44 +02:00
Sjors Hettinga d49d06735a net: tcp: Explicitly notify buffer allocation failures in retransmission
Log an error to explicitly log a failed buffer allocation in TCP
retransmission. This avoids silently failing retransmissions due to
repeating buffer allocation failures.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-06-07 18:55:44 +02:00
Sjors Hettinga 0a9b2ed391 net: tcp: Avoid new packets from causing killing the pending send_timer
When there was no room to transmit the a next packet to be transmitted,
the -ENOBUFS could cause the retransmission to fail.

Secondly the conn->unacked_len can be set to 0 in the retransmission
process, causing the subscribtion to the transmit timer to fail. Use the
variable send_data_total instead.

Make sure that is the send_data buffer becomes empty the send_timer is
cancelled, but make sure any pending data still keeps on being transmitted.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-06-07 18:55:44 +02:00
Sjors Hettinga d74bd3d7d1 net: tcp: Avoid deadlock in updating the TCP receive window
The function tcp_data_get tries to update the TCP receive window using
net_context_update_recv_wnd. This function graps the context lock while
the tcp_data_get is called from a situation where it already has tcp lock
is already. Transmission actions do first grab the the context lock and
try to grab the tcp lock afterwards. The combination of both can cause a
deadlock.

By taking the shortcut to directly update the tcp receive window without
going through the net context, the context lock is not required avoiding a
possible deadlock situation.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-06-07 18:55:44 +02:00
Sjors Hettinga f5679ab73e net: tcp: Use our MTU to determine the mss for transmission
In the existing the value received from the other side by the TCP options
is used as MSS for transmission. Since the MSS options are an
announcement rather then a negotionation, it is likely the receiver will
have a different and possibly bigger MSS than allowed by our side.
This allow potentially for different a MSS in the receive and transmit
path.

Directly using the received MSS could cause problems when our MSS is only
allowed to be small. At transmission, for that reason take the minimum of
the received MSS and our desired MSS to find a value compatible to both
sides of the link.

Rename the function to net_tcp_get_recv_mss to net_tcp_get_supported_mss
to better reflect its function in the new situation.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-06-07 18:55:44 +02:00
Mariusz Skamra cf59606883 Bluetooth: has: Allocate context for client once link is encrypted
The HAS sends notifications to paired devices. Thus the client context
has to be initialized once the link has required security.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-07 18:55:36 +02:00
Mariusz Skamra a4d9c82fca Bluetooth: pacs: Make location characteristics non-writable by default
The Sink Audio Locations and Source Audio Locations characteristics are
optionally writtable as defined in PACS_v1.0.
If the property is not mandatory in the specification it should be
disabled in implementation by default. It is more likely that the
location value will not change over time, as the end-product would
be designed to be used in specific way (in specific location).
If the user wants to make use of the writtable location feature, then
one has to enable it explicitly.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-07 18:55:23 +02:00
Mariusz Skamra 146124e7f9 tests: has: Extend tests with preset selection commands
The commands are used to change the active preset.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-07 18:55:04 +02:00
Mariusz Skamra 4e15cbe456 Bluetooth: has: Handle active preset selection
This adds handling of active preset selection in HAS.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-07 18:55:04 +02:00
Dominik Ermel 0c290864d7 mgmt/mcumgr/lib: Remove no longer needed mgmt_streamer_trim_front
Special function for supporting various types of buffers,
via provided callbacks, is no longer needed when net_buf is the
only type of transport buffer used by mcumgr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-07 18:54:11 +02:00
Dominik Ermel 3528c1ee30 mgmt/mcumgr: Replace zephyr_smp_trim_front with net_buf_pull
The additional logic of zephyr_smp_trim_front is no longer needed
and net_buf_pul can be directly used to trim front of net_buf
response when fragmenting.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-07 18:54:11 +02:00
Emil Gydesen c513fd87e1 Bluetooth: ISO: Rename sn to seq_num
Rename the `sn` field(s) to `seq_num` to be more readable
and clear what the value covers.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-07 18:53:44 +02:00
Emil Gydesen 65b5db6e3a Bluetooth: ISO: Rename ISO_INTERVAL_MIN/MAX
Rename the BT_ISO_INTERVAL_MIN/MAX to
BT_ISO_SDU_INTERVAL_MIN/MAX to avoid confusing this
the the ISO interval which is different from the SDU
interval.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-07 18:53:44 +02:00
Emil Gydesen 6786bbdb32 Bluetooth: ISO: Add sn and ts to bt_iso_chan_send
Add two new parameters to bt_iso_chan_send:
sn: The packet sequence number which shall be incremeted
per SDU interval.
ts: An optional timestamp value used to synchronize SDUs.

The sequence number in the API uses a 32-bit value even though
the sequence number for the HCI command is 16-bit. This is to
properly handle wrapping of sequence numbers, which is much
easier to do with additional bits allocated.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-07 18:53:44 +02:00
Daniel Leung 125b33c185 logging: remove CONFIG_LOG2_MSG_PKG_ALWAYS_ADD_RO_STRING_IDXS
CONFIG_LOG2_MSG_PKG_ALWAYS_ADD_RO_STRING_IDXS was added as
a stop-gap measure to support Sys-T catalog messages. Since
the Sys-T backend has envolved to use tagged argument, this
kconfig and its effect are no longer needed. So remove it.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-06-08 00:15:55 +09:00
Daniel Leung 134d26bade logging: syst: extend catalog messages support for other archs
This extends Sys-T catalog messages support for other architectures,
by utilizing tagged arguments to prepare the catalog messages. So
this is no longer limited to architectures where the printf
argument list has the exact format as the catalog message argument
list.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-06-08 00:15:55 +09:00
Daniel Leung fe0aa4c167 logging: support tagged argument in log message packaging
This adds support for packaging with tagged arguments for log
messages so that backends can make use of this information
when they process messages.

Note that currently tagged arguments must be used with
CONFIG_LOG2_ALWAYS_RUNTIME where log messages are created via
z_log_msg2_runtime_{v,}create(). For some reason, using C++ on
Cortex-M (mps2_an385) results in an additional empty string
argument being added to the list. This does not happen if only
doing C on mps2_an385, or on other architectures.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-06-08 00:15:55 +09:00
Andrei Emeltchenko bdafd89c12 net: 6lo: Remove dead statement
Value stored to compressed_hdr_size is never read.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-07 11:54:20 +02:00
Andrei Emeltchenko 38b40f2ed1 net: utils: Remove dead statement
Value stored to needcolon is overwritten later before loop ends.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-07 11:54:20 +02:00
Benjamin Gwin 0cc9ad4f50 testsuite: Make ztress header C++ compatible
This allows ztress to be linked correctly from C++ based tests.

Signed-off-by: Benjamin Gwin <bgwin@google.com>
2022-06-07 11:53:41 +02:00
Pavel Vasilyev 953f8ee0d6 Bluetooth: Mesh: Fix RPL fragmentation
`bt_mesh_rpl_check` stops iterating `replay_list` if either it found an
entry with the requested source address or unassigned address. When IV
index updated, `bt_mesh_rpl_reset` is called. It will set `old_iv` to 1
for all entries with fresh IV index and remove entries with old IV index.
If the entries with old IV index are mixed with other entries, this will
cause fragmentation of `replay_list`. The next time `bt_mesh_rpl_check`
is called, it may stop iterating `replay_list` earlier than it should
because it will meet an empty entry before it iterates over all entries
in the list.

This commit does defragmentatino of `replay_list` on every
`bt_mesh_rpl_reset` by shiting existing entries to the vacated places.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-06-07 11:53:31 +02:00
Carlo Caione 4ef13f7ecd ipc_service: static_vrings: Set WQ priority back to PRIO_PREEMPT
This reverts commit 7f51907fda.

The problem with setting the priority at the highest priority possible
is that when the IPC is under high traffic, the WQ could starve the
scheduler.

Move back to a more sane preemptive priority as default value.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-07 11:53:22 +02:00
Yong Cong Sin ae587f8e50 subsys/mgmt/hawkbit: format for readability
Formatted the code so that it is easier to read.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-06-07 11:52:10 +02:00
Andrei Emeltchenko a9b3c936e2 shell: uart: Fix compilation warning
Use ARG_UNUSED() to fix compilation warning unused-but-set-variable.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-06 22:47:11 +02:00
Juha Heiskanen 7ffc95c430 net: lwm2m: Composite Observation refactor
Json library parser modify data so thats why we can't parse same
data again. Now Composite observation handler parse SenML Json or
CBOR resource path which is given to new API composite Read API
which not need any new data parser.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-06-06 12:06:43 +02:00
Juha Heiskanen 2da8df8b7e net: lwm2m: Integrate JSON lib to LwM2M 1.0 JSON
Integrated updated JSON library to LwM2M 1.0 JSON.
Removed Old Json format default choice.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-06-06 12:06:43 +02:00
Juha Heiskanen a9035ebe5e net: lwm2m: Integrate JSON lib to SenML-JSON
Integrated updated JSON library to SenML-JSON.
This integrate affect that Coap Block wise transfer is not
supported.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-06-06 12:06:43 +02:00
Dominik Ermel 37dd4fb775 mgmt/mcumgr/lib: Fix parasitic use of heap by image management
The commit fixes issue where image management would switch to using
heap, whether developer wanted or not, when CONFIG_HEAP_MEM_POOL
gets value greater than zero.
Now when heap is enabled the user can select whether image management
will keep on using static variable, taking static RAM, or will use
heap to allocate the flash image context only when needed.
For this purpose CONFIG_IMG_MGMT_USE_HEAP_FOR_FLASH_IMG_CONTEXT
has been added, which is available when CONFIG_HEAP_MEM_POOL is enabled.

Fixes #44214

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-06 12:05:29 +02:00
Carles Cufi b41d7f0f0c Bluetooth: Controller: Implement bt_hci_driver::close
The open source controller did not expose support for shutting it down
via the close() API in the HCI driver. Add support for it, which
completes the support for disabling and enabling the Bluetooth stack in
Zephyr.

Closes #3192.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-06-06 12:04:30 +02:00
Carles Cufi 4349a475a8 Bluetooth: Controller: Add deinit() infrastructure
Allow the controller to be deinitialized, adding the whole chain of
calls:

- ll_deinit()
- lll_deinit()
- lll_clock_deinit()

in order to be able to turn everything off, including the controller's
refcount of the LF clock.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-06-06 12:04:30 +02:00
Carles Cufi 11da95bb4d Bluetooth: Host: Properly handle disable()/enable() cycles
When bt_disable() was introduced, some of the global variables that
handle key aspects of Bluetooth were not converted to be also
re-initialized every time that the stack was disabled and the enabled
again. This meant that the FIFO and semaphore in the device structure
were not reset whenever the corresponding threads using them were shut
down and then restarted.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-06-06 12:04:30 +02:00
Carlo Caione 2bf678af1b ipc: static_vrings: Fix timeout management
The ipc_service_get_tx_buffer() has a timeout parameter that can be used
to wait a certain amount of time for a TX buffer to be available.

Unfortunately, for the static vrings backend, an asymmetry
between remote and host exists that makes the usage of this parameter
confusing when the user requests a buffer when no buffers are available
at that time.

When the remote endpoints requests a TX buffer specifying a certain
size and there are no TX buffers available, the function ignores the
parameter and ipc_service_get_tx_buffer() immediately returns -ENOMEM.

The same case on the host endpoint works correctly only when the
specified timeout is <= 15 seconds. All timeouts > 15 seconds simply
returns -EIO after 15 seconds.

This patch is reworking the timeout management trying to behave
correctly in all the cases.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-05 14:49:26 +02:00
Yong Cong Sin 57b1f6622d fs/nvs: Fix comment typo
Minor fix to a comment typo.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-06-05 14:49:20 +02:00
Yong Cong Sin 267b4ae6b8 fs/nvs: removed extra empty lines
Minor edit to the code style.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-06-05 14:49:20 +02:00
Yong Cong Sin 85f54380f6 fs/nvs: Remove unused variable
ate_size doesn't seem to be used in the function, removed.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-06-05 14:49:20 +02:00
Berend Ozceri a9376174cd net: websocket: Allow building with POSIX API
If the POSIX API is selected via the POSIX_API option, use the POSIX
headers instead.

Signed-off-by: Berend Ozceri <berend@recogni.com>
2022-06-05 14:48:52 +02:00
Kamil Gawor 0843ef1cfa bluetooth: host: Fix reading current PHY when using extended advertising
The current PHY is read only when automatic PHY
update procedure is enabled, 2M PHY is supported and
extended advertising is enabled and this is done after
application is notified about connection. This leads
to invalid connection info PHY data which always returns
1M PHY because when using extended advertising the connection
can be established on different PHY and host does not read
this value from the controller in most cases. In order to
have a current PHY value updated we need to read it in
connection complete event before the user application
is notified about connection.

Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
2022-06-05 14:48:14 +02:00
Dominik Ermel e15523d198 mgmt/mcumgr/lib: Use flash_img_bytes_written to check context
The commit replaces direct access to flash_img_context, for the
purpose of checking how much data has been written, with call
to the flash_img_bytes_written.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-05 14:47:35 +02:00
Carlo Caione 01305942f6 ipc: static_vrings: Support DT-defined buffer size
Recently OpenAMP introduced the possibility to set the sizes for TX and
RX buffers per created instance. Expose this also to Zephyr users by
using a DT property "zephyr,buffer-size".

For the sake of simplicity use the same DT property to set the buffer
size for both TX and RX buffers.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-05 14:46:18 +02:00
Herman Berget c3c7b54ccf Bluetooth: Host: Option for disabling of ATT auto retry
The automatic elevation of security and retry of ATT requests interferes
with some tests that expect authentication failures.

Affecting GATT/CL/GAR/BI-42-C

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-06-05 14:45:32 +02:00
Yuriy Vynnychek cca221e928 drivers: bluetooth: hci: introduce new Telink B91 HCI driver
Telink B91 Bluetooth HCI driver basic support.

Signed-off-by: Yuriy Vynnychek <yura.vynnychek@telink-semi.com>
2022-06-05 14:45:10 +02:00
Herman Berget 5febfac02c Bluetooth: Allow support for Multiple Variable Length Read without EATT
EATT is not a requirement for the Multiple Variable Length Read
procedure, but previously one had to enable CONFIG_BT_EATT to enable
support for it.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-06-05 14:44:58 +02:00
Mariusz Skamra 33991f2dde Bluetooth: audio: Expose API methods to change the available contexts
This exposes API methods to change the available context types.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-05 14:44:21 +02:00
Mariusz Skamra 893f49ea88 Bluetooth: audio: Build PACS only if Sink or Source enabled
This fixes Kconfig that allowed to build PACS without support for sink
or source PACS. Few conditionals that no longer apply were removed.
Enabling ASCS support in specific direction enables related PACS
support.
Since PACS does `depends on` anything, it's safe to make use of `select`
statement.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-05 14:44:21 +02:00
Mariusz Skamra eddfc89ebf Bluetooth: uuid: Rename PACS Available Contexts UUID define
This renames the UUID to follow the same naming scheme as for
BT_UUID_PACS_SUPPORTED_CONTEXT.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-05 14:44:21 +02:00
Damian Krolik 74e4ac0883 nvs: implement NVS cache
The NVS data lookup time grows linearly with the number of
allocation table entries to walk through, meaning that if
some data pair in the NVS changes frequently, access to
other data pairs that change rarely can take a lot of time.

It is particularly visible when the NVS is used as the
settings backend since the backend needs to perform multiple
NVS reads to find a requested key.

Implement a simple cache that stores an address of the most
recent ATE for all NVS IDs that fall into the given cache
position. CRC8/16 is used as a hash function used to
distribute NVS IDs across the cache entries.

The cache entries are only invalidated when an NVS sector
is erased as part of the garbage collector task.

Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
2022-06-05 14:43:59 +02:00
Eduardo Montoya e6f3b8a296 net: openthread: fix wrong configuration
Fix wrong OpenThread config.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2022-06-05 14:42:33 +02:00
Gerhard Jörges d99827f0a5 shell: suppress newlines on boot when promt is an empty string
If the user sets the default_prompt to an empty string no newlines will
be printed during boot.

Signed-off-by: Gerhard Jörges <joerges@metratec.com>
2022-06-05 14:42:26 +02:00
Emil Gydesen 0eb5b3ac03 Bluetooth: Shell: Add gatt notify-mult command
Add GATT command to test the bt_gatt_notify_multiple
function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:29:33 +02:00
Andriy Gelman f12f9d5e95 net: pkt: Fix leak when using shallow clone
Currently a shallow clone of a packet will bump the reference count on
all the fragments. The net_pkt_unref() function, however, only drops the
reference count on the head fragment. Fix this by only bumping the ref
count on the head buf during shallow clone.

Only bumping the ref count of head is more in line with the idea that
head buf is not responsible for the fragments of its child.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2022-06-05 14:29:19 +02:00
Dominik Ermel aa5d20aaef storage/flash_map: Return -ENODEV from flash_area_open
The commit adds check, to flash_area_open, whether there is any
device driver attached and returns -ENODEV if there isn't any.
This works around a problem where flash_area_open succeeds but
consecutive read/write causes crash.
It is enough to check the condition, and return error, here as
the flash_area_open has to precede, and be checked for success,
any read/write operations.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-05 14:28:58 +02:00
Mark Holden 44c388fb33 coredump: drivers: Add coredump device
Add a pseudo device diver with device tree bindings for coredump.
The device tree bindings exposes memory address/size values to be
included in any dump. And the driver exposes an API to add/remove
dump memory regions at runtime.

Signed-off-by: Mark Holden <mholden@fb.com>
2022-06-05 14:28:34 +02:00
Markus Rekdal cf43c49b5f net: lwm2m: Fix decoding of objlnk
This fixes a bug in the decoding of objlinks. Without  this the object
instance id is not retrieved correctly as it tries to read the second id
starting from the colon.

Signed-off-by: Markus Rekdal <markus.rekdal@nordicsemi.no>
2022-06-05 14:27:39 +02:00
Emil Gydesen edb30d53d9 Bluetooth: Audio: Fix issues with unicast audio group lifetime
The unicast audio group can not have streams removed after the
CIG has been created as part of the QoS set procedure.

The bt_audio_unicast_group_remove_streams function may
leave the unicast group without streams, and thus the
check for "free" group was not correct, and has been replaced
with a simple boolean value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:13:33 +02:00
Emil Gydesen 2baa0ba710 Bluetooth: Audio: Use bidirectional CIS for unicast audio
The unicast client and server will attempt to use a
bidirectional CIS instead of two unidirectional CIS
whenever possible.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:13:33 +02:00
Emil Gydesen cc94fa763b Bluetooth: Audio: Make bt_audio_codec_qos_to_iso_qos return void
Change the return type of bt_audio_codec_qos_to_iso_qos to
void as it cannot fail, and this will make it easier to use.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:13:33 +02:00
Emil Gydesen f77355aaa5 Bluetooth: Audio: Add sink/source ep ref to bt_audio_iso
Add supporting for referercing either a sink endpoint,
a source endpoint or both in the bt_audio_iso struct.

This way a single bt_audio_iso can have references to up
to 2 endpoints.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:13:33 +02:00
Emil Gydesen e8e1920577 Bluetooth: Audio: Move ISO struct from audio_endpoint
Moves the bt_iso_chan and bt_iso_chan_qos structs
out from the bt_audio_ep struct, and instead use a
reference.

This is due to the fact that an endpoint can ever
only be unidirectional, and a CIS can be bidrectional.

The support for using a single bididrectional CIS
for two audio streams/endpoints is not implemented
in this commit.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:13:33 +02:00
Emil Gydesen 73e8fd6684 Bluetooth: ISO: Move iso_server NULL check for inc. reqs
Move the NULL-check for the iso_server to an earlier point.
There's no need to do anything on the device if no iso_server
has been registered.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:12:50 +02:00
Emil Gydesen e2e56da061 Bluetooth: Shell: Add security level option to "iso connect"
The "iso connect" now also takes a security level option like
"iso listen", so that the central can easily encrypt
and connect a CIS in a single command.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:12:50 +02:00
Emil Gydesen 57e1056bef Bluetooth: ISO: Guard sec_level with CONFIG_BT_SMP
The ISO security implementation works by verifying
against the acl (bt_conn) sec_level field. The
bt_conn sec_level field is only available
if CONFIG_BT_SMP is enabled, so this commit
adds guards for all ISO security checks as well.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:12:50 +02:00
Emil Gydesen b3cddc6d27 Bluetooth: ISO: Central security request
If the required_sec_level is lower than the
conn->sec_level, the central will now initialize the
security procecure to ensure that the CIS is encrypted
properly.

The algorithm implemented is as follows:
1) Check security levels for each (acl, iso) pair
2) For those with insufficient security,
   call bt_conn_set_security
3) For those with sufficient security, connect the CIS
4) Once the ISO from 2) has been encrypted, connect the
   CIS for the specific ACL

The idea behind this was to implement similar support
for autonomous encryption as we have for L2CAP.
It is more complex for ISO as we are dealing with
an array of (acl, iso) pairs, meaning more can go
wrong.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:12:50 +02:00
Emil Gydesen 2ace9cb256 Bluetooth: ISO: Add server security check
Add check for connection and server security
levels, and reject the CIS if the ACL security
level is too low.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:12:50 +02:00
Vinayak Kariappa Chettimada f31b974243 Bluetooth: Host: Fix incorrect ACL buffer count
Fix incorrect ACL buffer count use when Controller used
supports separate ISO buffers.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-06-03 15:11:33 +02:00
Herman Berget ed0dfb9dd2 Bluetooth: Host: Fix ATT PDU alloc being non-blocking.
The API is documented as being blocking. Making it nonblocking was an
unintentional API change.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-06-03 14:41:09 +02:00
Herman Berget e494d9c072 Bluetooth: Host: Handle err in l2cap_chan_sdu_sent and l2cap_chan_seg_sent
The error will be propagated to the higher levels.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-06-03 12:52:16 +02:00
Herman Berget eff10664bd Bluetooth: Host: Do not require the ops->sent callback
The L2CAP channel ops->sent callback was required to call the
l2cap_chan_sdu_sent callback.

Previously, the only difference between the l2cap_chan_sdu_sent and
l2cap_chan_seg_sent callbacks was that l2cap_chan_sdu_sent called
ops->sent. This is no longer true and l2cap_chan_sdu_sent should always
be called when an SDU is sent.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-06-03 12:52:16 +02:00
Herman Berget bbe5143b95 Bluetooth: Host: Call bt_conn_tx callback with error in error cases
This allows the higher layers to to any required cleanup.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-06-03 12:52:16 +02:00
Herman Berget 5e93b3f192 Bluetooth: Host: Free ATT metadata before calling user callback
In case the user callback tries to allocate metadata for a new ATT PDU.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-06-03 12:52:16 +02:00
Herman Berget 695e5915f8 Bluetooth: Host: Add err parameter to bt_conn_tx_cb_t
This gives more information back to the supplier of the callback.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-06-03 12:52:16 +02:00
Herman Berget 03f941ccb0 Bluetooth: Host: Use correct type for func in ATT metadata
The type should be the user-facing gatt callback, not the internal conn
callback.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-06-03 12:52:16 +02:00
Marcin Niestroj c00fdcb518 net: context: prevent truncating outgoing datagrams
Datagrams should either be fully sent or not sent at all if networking
buffers or network interface MTU does not allow that. So far the behavior
was to truncate outgoing packets, even for datagram sockets.

When there is not enough available payload buffer to fit all requested
data, fail if that happens for datagram socket.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-06-01 11:17:07 +02:00
Mariusz Skamra 0492ef5bbf Bluetooth: audio: Fix call control client build
error: 'CONFIG_BT_TBS_MAX_PROVIDER_NAME_LENGTH' undeclared (first use
			in this function); did you mean
			'CONFIG_BT_TBS_CLIENT_MAX_PROVIDER_NAME_LENGTH'?
  292 |            CONFIG_BT_TBS_MAX_PROVIDER_NAME_LENGTH);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |            CONFIG_BT_TBS_CLIENT_MAX_PROVIDER_NAME_LENGTH
etc.

This fixes build errors that were seen while building call control
client without server side (`CONFIG_BT_TBS`) enabled.
The options like BT_TBS_CLIENT_MAX_URI_LENGTH and
BT_TBS_CLIENT_MAX_PROVIDER_NAME_LENGTH have been removed because those
were not used in the code. In fact the client implementation used the
common options for BT_TBS_MAX_URI_LENGTH and
BT_TBS_MAX_PROVIDER_NAME_LENGTH that were moved in this patch to the
common Kconfig section.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-05-27 17:47:58 -07:00
Olof Winge dea9343d61 net: ipv4: Accept unspecified src address if dst is broadcast
To be able to accept DHCP discover/request incoming packets the ip stack
neeeds to accept unspecified src addr if the destination is broadcast
address.

Signed-off-by: Olof Winge <olof@skyshaper.net>
2022-05-27 15:46:44 -07:00
Ryan Erickson 67598965fb lwm2m: software management: Fix URI value not being written
Create the URI resource when creating the object if
PULL support is enabled.

URI write callback should be post-write instead to ensure
the URI value is updated for the resource.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2022-05-27 15:45:14 -07:00
Robert Lubos 0516d75d84 net: ethernet: Add Kconfig option to forward unrecognized EtherType frames
Add Kconfig option to the Ethernet L2 which allows to forward frames
with unknown EtherType further into the stack. This can be useful for
packet sockets, where further frame processing is application dependent.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-27 15:40:29 -07:00
Robert Lubos eddb6c8111 net: sockets: packet: Remove obsolete TODO
It turns out that all of the items listed under TODO section for packet
socket implmeentation has been adressed over time, threfore remove the
obsolete TODO.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-27 15:40:29 -07:00
Robert Lubos 96cc85146d net: conn: Add proper processing of DGRAM packet sockets
Datagram AF_PACKET sockets were not processed properly by the net stack.
Instead of receving a packet already processed L2, and thus with L2
header trimmed, it was receiving a raw, unprocessed packet.

Fix this by calling net_packet_socket_input() for the second time, after
L2 has processed the packet. An updated connection handler module will
forward the packet correctly based on the corresponding socket type and
packet L2 processing status.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-27 15:40:29 -07:00
Robert Lubos 5ab0d54f79 net: context: Improve packet socket interface selection on sendto()
Currently, the packet socket implementation in net_context required that
netowrk interface to transmit the packet to was set on every sendto()
call. This spoils the whole idea of binding a socket. Fix this, by
checking first if the net_conext is already bound to a particular
interface, and if so, do not throw an error in case sll_ifindex field is
not a valid interface.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-27 15:40:29 -07:00
Keith Packard b7313f85fe subsys/img_mgmt: Add zephyr/toolchain.h for STRINGIFY [v2]
Somehow two files in subsys/mgmt/mcumgr/lib/cmd/img_mgmt/src ended up
using STRINGIFY but nothing in their include path ended up pulling in
zephyr/toolchain/common.h. Include that via zephyr/toolchain.h.

v2:
	Use non-internal zephyr/toolchain.h header

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-05-27 15:34:34 -07:00
Emil Gydesen 0813966545 Bluetooth: GATT: Remove use of BT_GATT_ATTRIBUTE macro for discover results
The macro was remove for the GATT discover callbacks,
as only 2 out of 5 parameters for
BT_GATT_ATTRIBUTE were used.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-27 15:29:36 -07:00
Dominik Ermel 38e554846a mgmt/mcumgr/lib: Improve CONFIG_IMG_MGMT_VERBOSE_ERR description
The description suggested logging information while it never
was the case: it was about adding additional "rsn":value pair
to an SMP response.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-05-27 15:21:24 -07:00
Fabio Baltieri e24314f10f include: add more missing zephyr/ prefixes
Adds few missing zephyr/ prefixes to leftover #include statements that
either got added recently or were using double quote format.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-05-27 15:20:27 -07:00
Vinayak Kariappa Chettimada 192e2a8f94 Bluetooth: Controller: Fix Data Length Request Cmd parameter checking
Fix Data Length Request CMD parameter checking to not
restrict invalid maximum Tx time values. This addresses
conformance test cases that provide maximum Tx time values
of 2128 us when not supporting Coded PHY in the Controller
implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-27 15:19:06 -07:00
Jonathan Rico d3138c937f Bluetooth: host: don't timeout when reconfiguring an l2cap channel
The request timer started on the first l2cap channel when doing an MTU
reconfiguration has to be stopped when the response is received. Else the
channel will get into a bad state.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-05-27 16:03:33 +02:00
Dominik Ermel 19259ab7db mgmt/mcumgr/lib: Fix image list command crashing when no device
It is possible, in case of two application images, to have no access
to one of devices of the secondary image.
When asserts are enabled, such situation causes crash even though the
image list command can handle it with no problem.
The commit removes the assert and adds additional swap type:
IMG_MGMT_SWAP_TYPE_UNKNOWN to indicate situations where it was
not possible to obtain swap type from boot_util.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-05-26 13:08:35 -07:00
Piotr Pryga 131c089aaf Bluetooth: Controller: llcp: Fix wrong eff time calc if PHY changed
If there is a PHY change on a connection it may happen that effective
RX and TX time changes also. That change is applied after an instant.

Implemented handling of effective time calculation is based on the
maximum PDU length, new PHY and local (default) maximum TX or RX time.

The maximum TX value is set to default one that corresponds to PHY 1M
during the Controller initialization. It can be updated by host to other
value. By default Zephyr Host updates it to max possible TX time for all
supported PHYs. If PHY CODED is enabled, it is the longest possible TX
duration 17040 us.

The maximum RX value is set to default during connection creation.
In case of use of legacy advertising, the value is also related with
PHY 1M. It can be updated by data length extension procedure.

If the maximum RX value is set to some value and there is a change
of a PHY to one that requires more time to send a PDU with the same
length, then the maximum RX value is wrongly calculated.

Function pu_calc_eff_time returns a value that is the default_time
argument. The problem is that the default_time should be adjusted
to new maximum RX time required for a new PHY.

To solve that there should be an evaluation of a new maximum RX and
TX time based on new PHY.

The commit adds missing evaluation.

The problem occurred in DF tests that check collision mitigation
between PHY update control procedure and CTE request control procedure.

There was missing CONFIG_BT_CTLR_PHY_CODED option in CTE request
unit tests. The code was working because the ULL implementation of
PHY change control procedure does not verify if PHY CODED is supported.

When missing support was enabled, tests showed wrong evaluation of
maximum RX time. It also unveiled error in CTE request unit tests
implementation. The default_tx_time was set to wrong value 2120 us
as if PHY CODED was not supported. To fix it, the value was changed
to PDU_DC_PAYLOAD_TIME_MAX_CODED.

There was also added a mock for a feature exchange procedure done
during unit tests setup step. That allows to correctly calculate
maximum TX time by ull_dle_max_time_get function.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-26 16:29:10 +02:00
Vinayak Kariappa Chettimada e79c48f7c6 Bluetooth: Controller: Fix missing DUP_FILTER_ADV_SET_MAX dependency
Fix missing BT_CTLR_DUP_FILTER_ADV_SET_MAX dependency on
BT_CTLR_ADV_EXT.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-26 12:26:43 +02:00
Vinayak Kariappa Chettimada 59eef60665 Bluetooth: Controller: Fix filter accept list and privacy default
Fix filter accept list and privacy feature Kconfig default
based on whether host has them enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-26 12:26:43 +02:00
Vinayak Kariappa Chettimada 1791a154dc Bluetooth: Controller: nRF5: Fix missing BT_CTLR_PRIVACY cond compile
Fix missing BT_CTLR_PRIVACY conditional compilations that
included redundant HAL code when Controller privacy is
disabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-26 12:26:43 +02:00
Vinayak Kariappa Chettimada 5f670fa9c3 Bluetooth: Controller: openisa/RV32M1: Fix BT_CTLR_PRIVACY cond compile
Fix missing BT_CTLR_PRIVACY conditional compilations that
causes compile errors when Controller Privacy is disabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-26 12:26:43 +02:00
Vinayak Kariappa Chettimada 620a5524a5 Bluetooth: Controller: Fix PHY update for unsupported PHY
Fix PHY update procedure to handle unsupported PHY requested
by peer central device. PHY update complete will not be
generated to Host, connection is maintained on the old
PHY and the Controller will not respond to PDUs received on
the unsupported PHY.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-26 12:24:54 +02:00
Dominik Ermel 1bd5665b89 mgmt/mcumgr/lib: Fix usage of MGMT_ERR_ENOMEM
The commit replaces MGMT_ERR_ENOMEM with MGMT_ERR_EMSGSIZE where it
was used to indicate that SMP response does not fit in response
buffer.

Fixes #44535

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-05-25 13:56:03 -07:00
Erik Brockhoff 25e6279493 Bluetooth: controller: llcp: fix for failing LL qualification tests
Fixes issue re. sending packets after sending TERMINATE_IND.
Fixes issue re. erroneous error code on 'timed out' termination (ie
when peer does not ack terminate_ind)

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-05-25 16:29:24 +02:00
Erik Brockhoff 7daba33f2d Bluetooth: controller: llcp: update max dle times on feature exchange
On a completion of feature exchange the max DLE times needs to be
updated if Coded PHY has become supported.
For this now also keep a separate store of the default_tx_octets/time
for the sake of re-calculation of local versions of DLE values

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-05-25 16:29:18 +02:00
Dominik Ermel 550f1b096d mgmt/mcumgr/lib: Fix OS taskstat passing incorrect value
The commit fixes incorrect value being passed as used stack
information and also prevents compilation error when
CONFIG_INIT_STACKS is n.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-05-25 16:09:12 +02:00
Achatzi Julian 90236b0650 fs: fcb: Make FCB work with sectors larger than 16K
Enhance FCB to also work with sectors larger than 16K and
to handle larger flash alignment constraints correctly.

use fcb_len_in_flash when setting the offset of the data
and use buffers sizes of at least the alignment value.

The test in fcb_test_append_to_big has been altered, as it
would otherwise not come to a data length which fits the
fcb on sectors larger than 16K.

Closes: https://github.com/zephyrproject-rtos/zephyr/issues/45345

Signed-off-by: Achatzi Julian <jachatzi@baumer.com>
2022-05-25 14:57:45 +02:00
Casper Bonde e2dad8fa11 Bluetooth: Broadcast: Fix codec and meta data encoding
Length filed was 1 off.

Signed-off-by: Casper Bonde <casper_bonde@bose.com>
2022-05-25 14:57:33 +02:00
Vinayak Kariappa Chettimada 742173c314 Bluetooth: Controller: Fix prepare pipeline stall
Fix prepare pipeline from not resuming non-resume events
in pipeline when more than one resume events are present
before a non-resume event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-25 14:38:18 +02:00
Azizah Ibrahim e11ff7df48 bluetooth: host: Avoid sending duplicate device to resolving list.
Core v5.3, Vol 4, Part E, 7.8.38
Controller has the option to accept or reject when the same device
is added to RL.
If a remote device has been added to RL before, then local device
change it's advertsing address, and the remote device tries to pair
with the new address, we could end up trying to add the same data to RL.
If a remote device's public/static address is known, this patch deletes
the old entry from RL before adding it.

Signed-off-by: Azizah Ibrahim <azizah.ibrahim@nordicsemi.no>
2022-05-25 14:25:14 +02:00
Damian Krolik 7e02e8c9f4 mcumgr: fix invalid condition for calling img_mgmt_dfu_stopped
In other places, img_mgmt_dfu_stopped() is called when
a failure occurs and the DFU cannot be continued. In this
place, however, the function is called on success which
does not seem to be correct.

Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
2022-05-25 14:21:19 +02:00
Szymon Janc b3de861d15 Bluetooth: Controller: Fix not clearing Static Random Address on reset
When host issue HCI Reset controller should clear LE Static Random
address. Otherwise controller may incorrectly use one from before
HCI reset insread of rejecting HCI commands.

This was affecting following qualification test cases:
HCI/CCO/BI-51-C
HCI/CCO/BI-53-C
HCI/CCO/BI-54-C
HCI/CCO/BI-56-C
HCI/DDI/BI-06-C
HCI/DDI/BI-07-C

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2022-05-25 14:20:21 +02:00
Marcin Niestroj 900137ef32 net: sockets: tls: prevent sending fragmented datagrams with sendmsg()
Fragmented data passed to sendmsg() should be sent as a single datagram in
case of datagram sockets (i.e. DTLS connection). Right now that is not
happening now, as each fragment is sent separately, which works fine only
for stream sockets.

There is no mbedTLS API for 'gather' write at this moment. This means that
implementing sendmsg() would require allocating contiguous memory area at
Zephyr TLS socket level and copying all data fragments before passing to
mbedTLS library. While this might be a good option for future, let's just
check if data passed to sendmsg() API consists of a single memory region
and can be sent using single send request. Return EMSGSIZE error if there
are more then one data fragments.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-05-25 14:20:09 +02:00
Szymon Janc 42d461d3a2 Bluetooth: Controller: Fix HCI supported commands bitmask
This was affecting HCI/GEV/BV-01-C qualification test case.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2022-05-25 14:19:59 +02:00
Szymon Janc f0b6774191 Bluetooth: Controller: Fix validating PHY bitmask in HCI
At least one supported PHY bit shall be set and none of
non-supported or RFU bits should be set.

This was affecting HCI/DDI/BI-05-C qualification test case.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2022-05-25 14:19:41 +02:00
Piotr Pryga f3d460ff5a Bluetooth: Controller: df: Remove experimental for direction finding
Removes label experimental for direction finding feature in
Bluetooth Controller.

The feature stays disabled by default because it requires additional
dedicated hardware to be used. Besides that it significantly enlarges
amount of memory used by the Controller.

End user has to enable the feature explicitly by use of configuration
options.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-25 11:48:43 +02:00
Vinayak Kariappa Chettimada 0d7bd277a9 Bluetooth: Controller: Fix preempt timeout not skip first in pipeline
Fix preempt timeout scheduling to not skip first prepare in
pipeline when there are no previous preempt timeout
scheduled already.

Fix related to commit 27b8beaa22 ("Bluetooth: Controller:
Fix to handle relative short preempt timeout").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-25 11:14:58 +02:00
Piotr Pryga 729e4f5b1e Bluetooth: Controller: df: Fix check for max CTE num to sample or adv
Maximum number of CTE to be send in a periodic advertising chain is
limited by BT 5.3 Vol 4 Part E, section 7.8.80 and is 16.
Maximum number of samples CTE in a periodic advertising chain is
limited by BT 5.3 Vol 4 Part E, section 7.8.82 and is also 16.
Both values are limited by amount of memory reserved in Controller
by Kcofigs, respectfully: CONFIG_BT_CTLR_DF_PER_ADV_CTE_NUM_MAX and
CONFIG_BT_CTLR_DF_PER_SCAN_CTE_NUM_MAX.

Functions ll_df_set_cl_cte_tx_params and ll_df_set_cl_iq_sampling_enable
check limits against Bluetooth specification provided values.
That can end with memory overwrite if number of requested CTEs is
greater that number provided in configuration.

The commit changes mentioned functions to validate HCI commands
parameters against configuration values.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-25 11:09:48 +02:00
Piotr Pryga 1d89b271fb Bluetooth: Controller: llcp: Fix assert if reject while loc and rem pend
In case there are pending two control procedures: local and remote,
and remote device sends LL_REJECT_IND PDU then assertion happened.
ull_cp_rx function triggers assertion because LL_REJECT_IND is
considered as expected packet for all local and remote control
procedures.

That is not correct. It does not allow local procedure to handle
a response and stops a device on assert.

A remote device should not send LL_REJECT_IND PDU for locally initiated
control procedures, hence local device should not expect to receive
LL_REJECT_IND PDU to be expected one for pending remote control
procedure.

Remote device is allowed to send LL_REJECT_EXT_IND PDU for a locally
initiated control procedures. The LL_REJECT_EXT_IND PDU has a Reject-
Opcode that identifies rejected control procedure, hence is may be
expected by local device.

The commit provides changes that prevent the Controller assertion
in described case.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-25 11:09:38 +02:00
Piotr Pryga f3deccda91 Bluetooth: Controller: CCM read data to early when DF enabled on PHY 1M
CCM during on-the-fly decryption of a received packet starts decryption
when Radio triggers EVETNS_ADDRESS. In case there is possibility a
packet may include Constant Tone Extension, on-the-fly parsing of a
received packet for CTEInfo is enabled.

If there is a PHY 1M enabled the Radio stores received bits with a
delay, that is equal to time required to receive 3 bits. CCM TASKS_CRYPT
related with packet decryption should be delayed by the time the Radio
needs to store received data.

The commit provides changes required to delay start of the CCM
TASKS_CRYPT. It uses NRF_RADIO Bit counter feature. The Bit counter is
configured to trigger NRF_RADIO->EVENTS_BCMATCH on reception of 3rd bit.
The event is connected through PPI with CCM TASKS_CRYPT.

The PPI used is shared with Radio Rate override. That is possible because
direction finding feature is not allowed on PHY Coded and CCM needs a delay
only when used PHY 1M.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-25 11:09:15 +02:00
Piotr Pryga 6f7e58e347 Bluetooth: Controller: lll: Move packet setup after call to sw switch
lll_conn_rx_pkt_set function is called before one of radio_switch-
_complete_XXX functions calls in lll_peripheral.c. That prevents
lll_conn_rx_pkt to call any Radio setup related function that touches
NRF_RADIO->SHORTS. NRF_RADIO->SHORTS are assigned in radio_switch_-
complete_XXX functions, hence any change operation on the register done
before is overwritten.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-25 11:09:15 +02:00
Yuval Peress 138f399e6c ztest: run clang-format on ztest_new.c
Clang-format was updated to allow 100 column lines.

Signed-off-by: Yuval Peress <peress@google.com>
2022-05-25 11:20:13 +09:00
Yuval Peress 86cadf9283 ztest: Fix userspace ztests in new API
Update the new API to use K_USER as the flags for both
CONFIG_USERSPACE and CONFIG_TEST_USERSPACE. Also, fix the linker
script to properly include the suites, tests, and rules.

Fixes #44108

Signed-off-by: Yuval Peress <peress@google.com>
2022-05-25 11:20:13 +09:00
Vinayak Kariappa Chettimada 4cc5c56d8c Bluetooth: Controller: Fix setting fragment when Periodic Adv is active
Fix implementation to reject setting fragment when periodic
advertising is enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-23 10:45:57 +02:00
Vinayak Kariappa Chettimada fe18625f77 Bluetooth: Controller: Initial Periodic Adv Data fragment op support
Add initial support for Periodic Advertising Data fragment
operation support.

This commit is limited to detection of partial data if used
before Periodic Advertising is enabled, which will lead to
HCI error reason of command disallowed.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-23 10:45:57 +02:00
Vinayak Kariappa Chettimada 8888681aa8 Bluetooth: Remove deprecated BT_WHITELIST KConfig option
Remove the deprecated BT_WHITELIST Kconfig option. Also,
remove a mention of the deleted bt_conn_create_auto_le API.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-23 10:45:44 +02:00
Vinayak Kariappa Chettimada 8b5c84e2aa Bluetooth: Controller: Collision resolution to use ticks_slot_window
When resolving collision if ticks_slot_window is set for
either of the ticker then skip and such ticker be
rescheduled outside the collision within the
ticks_slot_window.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-23 10:18:29 +02:00
Marc Lasch fa84da588d net: lib: lwm2m: Cancel firmware DOWNLOADED state with NULL byte
Allow to cancel a firmware update in DOWNLOADED state by writing a
NULL byte as described in the Firmware Update object version 1.1
(urn:oma:lwm2m:oma:5:1.1). Keep object version 1.0 mechanism with
an `empty string`.

Signed-off-by: Marc Lasch <marc.lasch@husqvarnagroup.com>
2022-05-23 10:17:52 +02:00
Szymon Janc ab6d3d36a3 Bluetooth: Controller: lll: Fix warning when building for Nordic
[140/235] Building C object zephyr/subsys/bluetooth/controller/
    CMakeFiles/subsys__bluetooth__controller.dir/ll_sw/ull_sched.c.obj
In file included from zephyr/subsys/bluetooth/controller/ll_sw/
    ull_sched.c:28:
zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_pdu.h:
     In function 'lll_adv_pdu_linked_next_get':
zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_pdu.h:8:32:
     warning: implicit declaration of function 'MROUND'
     [-Wimplicit-function-declaration]
    8 | #define PDU_ADV_MEM_SIZE       MROUND(PDU_AC_LL_HEADER_SIZE + \
      |                                ^~~~~~
zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_pdu.h:12:11:
     note: in expansion of macro 'PDU_ADV_MEM_SIZE'
   12 |           PDU_ADV_MEM_SIZE - \
      |           ^~~~~~~~~~~~~~~~
zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_pdu.h:197:9:
     note: in expansion of macro 'PDU_ADV_NEXT_PTR'
  197 |  return PDU_ADV_NEXT_PTR(pdu);

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2022-05-23 10:05:39 +02:00
Sjors Hettinga c668199b5d net: tcp: Correctly determine when the TCP transmit window is full
In the stack both unacked_len and send_data_total track the amount
of data for retransmission. send_data_total actually accounts the
total bytes in the buffer, where unacked_len is used to control the
retransmission progress.

Using unacked_len is sometimes reset to 0, this can lead to more data
being allowd in the send_data buffer. In worse case this can cause
depletion of the net buffers, causing a stall and crash of the connection.

The value send_data_total actually accounts the total amount of data in
the send_data buffer, so it is the proper value to used in the
tcp_window_full function.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-05-20 19:24:26 -07:00
Vinayak Kariappa Chettimada ca2701d6d8 Bluetooth: Controller: Rework instant based procedure complete event
Rework instant based procedure complete event generation to be
held until after the on-air instant has elapsed, to have
conditional compilation around the code where the event
generation be held or immediately dispatched so that it
improves readability.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-20 19:22:59 -07:00
Vinayak Kariappa Chettimada 4c674aa1f2 Bluetooth: Controller: Fix instant based procedure complete event
Fix instant based procedure complete event generation to be
held until after the on-air instant has elapsed.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-20 19:22:59 -07:00
Marek Pieta 903672c394 bluetooth: att: Fix L2CAP channel section order
The L2CAP channel section is sorted lexicographically. Make sure
that ATT fixed channel will be placed as the last one to ensure
that SMP channel is properly initialized before bt_att_connected
tries to send security request.

Fixes #45820

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2022-05-20 12:43:16 +02:00
Szymon Janc 6a9243c13e Bluetooth: Controller: LLCP: Fix handling of invalid DLE parameters
If peer sents invalid value in DLE request or response just ignore
those and keep using old values when calculating effective DLE.

This was affecting following qualification test cases:
LL/CON/PER/BI-10-C
LL/CON/PER/BI-11-C
LL/CON/PER/BI-12-C
LL/CON/CEN/BI-07-C
LL/CON/CEN/BI-08-C
LL/CON/CEN/BI-09-C

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2022-05-20 12:38:30 +02:00
Sjors Hettinga 2d824f4811 net: tcp: Removed copy of conn->unacked_len
In the function tcp_send_data, the variable conn->unacked_len in copied
into a local variable pos. This value is only used in one location and
used mixed with the original conn->unacked_len.

This fix removes pos and switches to use conn->unacked_len everywhere
to reduce the chance of confusion. This does not functionally change the
code.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-05-20 12:38:24 +02:00
Thomas Ebert Hansen 5d80dbd388 Bluetooth: controller: llcp: Fix terminate timer
Add the missing terminate timer for the ACL Termination procedure.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-05-20 12:37:49 +02:00
Flavio Ceolin ac2e13b9a1 net: tcp: Fix possible buffer underflow
Fix possible underflow in tcp flags parse.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-05-20 12:36:42 +02:00
Erik Brockhoff 843a24924f Bluetooth: controller: llcp: terminate conn on conn update past instant
Terminate connection when Connection Update with instant in the past
Fix type re. win_offset calc in conn update ind pdu decoder
Remove feature bit on unsupported in peer

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-05-20 12:33:59 +02:00
Andries Kruithof c2e07a304b Bluetooth: controller: llcp: send correct collision code
Upon collision either the error code for different procedure
collision or same procedure collision must be transmitted,
which is fixed in this PR. Previously always the error code
for same procedure collision was sent

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-05-20 10:29:46 +02:00
Vinayak Kariappa Chettimada d84c5496a6 Bluetooth: Controller: Add Extended Advertising Type Validations
Add Extended Advertising Type validation when associated
Periodic Advertising is enable, and Extended Advertising
set is re-configured to other advertising types.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-19 16:05:35 +02:00
Piotr Pryga 364a8c2786 Bluetooth: Controller: df: CTE req not disabled if run in single shot
There is an error. CTE request control procedure can be run in single
shot or periodic mode. In case of run in single show, it is not
disabled after completion.

The code responsible for the disable was deleted by commit:
ac7d0506f88508e7440288c1ec4319a9f7d0ad44.

The cte_req.is_enabled should be set to zero if the CTE request
completes and cte_req.req_interval is zero.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-19 13:22:11 +02:00
Piotr Pryga 9e6f566858 Bluetooth: Controller: llcp: Add handling of unexpe CTRL PDU by CTE req
There was missing code responsible for handling of unexpected response
for CTE request. The commit adds code that will terminate connection
in case a peer device reposnes with unexpected control PDU that is not
a remote procedure reques.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-19 13:21:58 +02:00
Piotr Pryga 2890f42545 Bluetooth: Controller: df: Fix CTE reqest proc enable if feat supported
The CTE request procedure should be enabled only if a peer supports
CTE response feature. That information can be obtained by feature
exchange procedure. If there were no feature exchange then CTE
request feature may be disabled if a peer responses with LL_UNKNOWN_RSP
for a CTE request.

The implementation of ll_df_set_conn_cte_req_enable was checking if
CTE response feature is supported only when there was feature exchange.
There was missing possibility to stop CTE request if a peer responded
with LL_UNKNOWN_RSP for an earlier CTE request.

The commit changes the implementation of ll_df_set_conn_cte_req_enable.
The CTE response feature check is moved to ull_cp_cte_req function,
because it belongs more to control procedure than to function that
handles Host request to start the procedure.
Second change is related with use of conn->llcp.fex.features_used.
It stores information about features supported by peer. It does
not depend on execution of the feature exchange control procedure.

By the way, there were removed else statement in ll_df_set_conn_cte_-
req_enable because it was not needed.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-19 13:21:58 +02:00
Piotr Pryga 40cdd65901 Bluetooth: Controller: llcp: add missing handling LL_UNKNOWN in CTE llcp
There was missing handling of LL_UNKNOWN_RSP in CTE request control
procedure.In case there is a pending CTE request and peer responses
with LL_UNKNOWN_RSP then Host should be notified with HCI_LE_CTE_-
Request_Failed event. The pending CTE request procedure should be
completed.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-19 13:21:58 +02:00
Vinayak Kariappa Chettimada 4b7146bf18 Bluetooth: Controller: Add missing void in memcpy calls
Minor convention changes to have void in memcpy function
calls.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-18 13:56:53 +02:00
Vinayak Kariappa Chettimada 6976b03fe4 Bluetooth: Controller: Fix handling of AD Data unchanged operation
Fix handling of AD Data set with operation type of
unchanged data with respect to invalid parameter and
state of Periodic Advertising.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-18 13:56:53 +02:00
Vinayak Kariappa Chettimada a57e284201 Bluetooth: Controller: Fix nRF51x advertising channel PDU regression
Fix nRF51x series advertising channel PDU S1 byte
configuration regression, that causes corrupted advertising
PDUs being reported to Host, by adding the missing bits_s1
local variable initialization.

Regression introduced in commit 1dcbe73cc8 ("Bluetooth:
controller: radio: add setting of S1 byte in radio packet").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-18 13:56:36 +02:00
Robert Lubos 8ba5990766 net: sockets: Implement POLLOUT for stream sockets
Implement POLLOUT for stream sockets, based on newly introduced tx_sem
functionality of the TCP stack.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-18 11:09:17 +02:00