Commit graph

21541 commits

Author SHA1 Message Date
Piotr Pryga
4a13b8b4c7 Bluetooth: controller: ULL: Add sending of number of CTEs in per adv chain
Direction finding functionality allows to send a number of periodic
advertising PDUs in a chain that have CTE.
ll_df_set_cl_cte_tx_enable function was changed to update periodic
advertising chain to include cte_info field. If the chain is too short,
there is less PDUs in the chain than requested number of CTEs,
the function will add new empty PDUs to the chain end.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-08-07 20:50:03 -04:00
Piotr Pryga
616ebcf8f7 Bluetooth: controller: ULL: ull_adv_sync_hdr_set_clear update PDU in place
Enabling or disabling transmission of Constant Tone Extension with
periodic advertising PDUs requires update of a PDU content.
CTE_INFO field of periodic advertising PDU must be filled with
appropriate data. That operation may be done for periodic
advertising PDU (or chain of PDUs) filled with other payload that
wasn't enqueued towards LLL. In that situation PDUs are updated
in place, to avoid increase of memory consumption.

The commit changes ull_adv_sync_pdu_set_clear function to
make possible update of the advertising PDU in place.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-08-07 20:50:03 -04:00
Piotr Pryga
151a32db7a Bluetooth: controller: ULL: Make API for per adv sync PDU change global
Some functions, provided to handle changing content of periodic
advertising PDUs, were defined as static.
Code responsible for handling direction finding updates periodic
advertising PDUs also. For that purposes, those functions were mede
globally accessible.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-08-07 20:50:03 -04:00
Piotr Pryga
2d71b2d82c Bluetooth: controller: LLL: Add CTE confing for per. adv. chain TX
Add configuration of CTE for periodic advertising chain transmission.
The commit provides configuration of radio in prepare stage and
in handle of Tx ISR. CTE is configured only for PDUs that
have cte_info field in extended advertising header.

During prepare of periodic advertising event there are updated
aux_ptr fields in extended advertising header in other PDUs from
a periodic advertising chain. aux_ptr offset value also depends
on CTE length. CTE configuration is always the same for every
PDU in periodic advertising chain.
CTE may be added to requested number of PDUs in periodic
advertising chain. Although it is possible that there are PDUs
that don't have CTE. PDUs that have CTE are alsways at the beginning
of a periodic advertising chain.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-08-07 20:50:03 -04:00
Piotr Pryga
8a5a88ce96 Bluetooth: controller: LLL: Add peek extra_data related with lll_adv_sync
Configuration of CTE for transmission is stored in extra_date member
of a lll_adv_sync object. PDUs in periodic advertising chain share the
same CTE configuration, so there is single instance of the extra_data.
To configure CTE transmission for every PDU in periodic advertising
chain a new function was introduced to peek extra_data instance without
peeking new PDU.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-08-07 20:50:03 -04:00
Piotr Pryga
6cc97e7a32 Bluetooth: controller: df: Add const to antenna patterns pointer
Add const qualifier in radio API related with setting antenna
switch pattern.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-08-07 20:50:03 -04:00
Piotr Pryga
2dad068545 Bluetooth: controller: radio: Add back2back TX switch after PHYEND event
Transmission of Constant Tone Extension is done after END event
triggered by radio. To correctly switch from TX to TX (back 2 back
TX) after transmission of CTE PHYEND event must be used instead of
END event.

The commit provides required function that allows LLL to correctly
setup radio to do back to back switch of TX when CTE transmission
is enabled.

The radio_switch_complete_and_phy_end_b2b_tx cannot be implemented
in radio.c source file. It will fail build of unit tests targeted
for NRFBSIM simulator board. There is no RADIO_SHORTS_PHYEND_DISABLE_Msk
macro defined in bsim_hw_models module.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-08-07 20:50:03 -04:00
Piotr Pryga
1e2ad5a590 Bluetooth: controller: Make per. adv. PDUs count related to max CTE num
Amount of memory allocated for advertising PDUs (including
periodic advertising) depends on two factors:
- maximum advertising data length
- maximum number of CTE in a periodic advertising chain.

Maximum advertising data length is divided by maximum size
of a single fragment (number of payload bytes that single
advertising PDU may hold) to get required number of fragments.

Actual number of PDUs allocated for advertising is maximum
of acutal number of advertising payload fragments and maximum
number of CTEs.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-08-07 20:50:03 -04:00
Piotr Pryga
f01b77f3c9 Bluetooth: controller: Add conf max num of PDUs with CTE in per adv chain
Add possiblity to configure maximum number of PDUs with Constant Tone
Extension in a single periodic advertising chain.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-08-07 20:50:03 -04:00
Przemyslaw Bida
678a170925 net: openthread: Add capability to disable properly CSL.
This commit adds capability to disable CSL sampling by setting
CSL period to 0.

Signed-off-by: Przemyslaw Bida <przemyslaw.bida@nordicsemi.no>
2021-08-07 20:27:25 -04:00
Ramesh Babu B
d40d963bef net: fix for assert on enabling socket CAN
Socket CAN does not require interface link address to be
assigned, check is not applicable for socket CAN
interfaces. As this address is NULL for socket CAN interface
it results in assertion.

Signed-off-by: Ramesh Babu B <ramesh.babu.b@intel.com>
2021-08-07 20:10:48 -04:00
Gerard Marull-Paretas
8b0d3450a0 pm: device: use z_device_get_all_static
Use the internal function z_device_get_all_static helper function
instead of using __device_start and __device_end directly. Some other
minor adjustments have been done (e.g. reduce *dev scope to the for
loop). An issue on the range of the for loop in _pm_devices has also
been fixed.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-07 19:59:48 -04:00
Gerard Marull-Paretas
7e7b222d84 pm: device: simplify suspend checks
The shared _pm_devices function used should_suspend check function to
see if a device had to be suspended or not. Some of the logic inside
that function was redundant since the pm_device_state_set function
already performs similar checks, e.g. if the device is already at the
given state or the state transition is not supported it will return
error codes appropriately.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-07 19:59:48 -04:00
Gerard Marull-Paretas
f93778f2d2 pm: device: do not allow suspending a turned off device
A device that is turned off should not be suspended. A device that has
been turned off can only be resumed. This action is currently forbidden
by the "should_suspend" function in the device PM code.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-07 19:59:48 -04:00
Emil Lindqvist
dab4616e45 net: socket: fix regression causing corrupted poll timeout
k_timeout_t was converted to ticks using a nonsense function
causing poll timeout corruption for offloaded sockets; this
commit uses ticks directly from the struct instead.

Fixes #37472

Signed-off-by: Emil Lindqvist <emil@lindq.gr>
2021-08-06 19:20:48 -04:00
Emil Lindqvist
f9023d2c41 net: sockets: dtls: reset mbedtls session on timed out handshake
According to MbedTLS API documentation, its session must be
reset if mbedtls_ssl_handshake returns timeout error. This
commit resets the session for said return value, and that
allows us to call send() multiple times even if handshake
times out for previous calls.

Fixes #35711

Signed-off-by: Emil Lindqvist <emil@lindq.gr>
2021-08-06 19:19:26 -04:00
Emil Gydesen
57fc354f6c Bluetooth: ISO: Fix iso channels not disconnecting properly
We had added a break in a switch statement that stopped
ISO channels from setting the BT_CONN_CLEANUP flag
which in turn stopped them from disconnecting (in the
eyes of the upper layers) properly.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-08-05 15:08:06 -04:00
Emil Gydesen
b1f4764f4f Bluetooth: ISO: Add clearer error message on iso accept failure
Instead of just writing "err" we make it clear that it is
the ISO server that failed to accept.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-08-05 15:08:06 -04:00
Emil Gydesen
7f3a085a7a Bluetooth: shell: ISO change to use shell_print instead of printk
shell_print is preffered for the shell as printk may appear
in a different terminal.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-08-05 15:08:06 -04:00
Lukasz Maciejonczyk
53531a7682 openthread: implement missing time service functionality
Add missing otPlatTimeGet implementation which is needed for proper
calculation the time offset in host-RCP communication.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2021-08-05 16:14:24 +02:00
Johann Fischer
5a35745b44 usb: fix SetInterface handling for interfaces without any endpoints
With the last changes in USB device stack it was unfortunately
not considered that an interface can have no endpoints.
This caused the USB DFU class to stop working in DFU mode.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-05 16:13:10 +02:00
Johann Fischer
3aa48613b1 usb: cdc_acm: add support for poll in to UART driver
Use cdc_acm_fifo_read() to support poll in.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-05 16:08:39 +02:00
Johann Fischer
9973314ea2 usb: cdc_acm: fix CDC ACM IAD initialization
CONFIG_CDC_ACM_IAD option should also be considered.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-05 16:08:39 +02:00
Johann Fischer
ef18329051 usb: cdc_acm: rework descriptors, config, and data definitions macros
Simplify and rearrange the macros, remove unnecessary arguments.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-05 16:08:39 +02:00
Lingao Meng
524d2e2b27 Bluetooth: audio: Fix -Wunused-function
Fix -Wunused-function

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-08-05 16:07:44 +02:00
Lingao Meng
e0dfdd6723 Bluetooth: Fix -Wunused-but-set-variable
Fix -Wunused-but-set-variable

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-08-05 16:07:44 +02:00
Lingao Meng
4cbe77dbdb Bluetooth: Fix -Wunused-variable
Fix unused variable but defined, this will be
appear when dbg disabled.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-08-05 16:07:44 +02:00
Vinayak Kariappa Chettimada
239a663c40 Bluetooth: Controller: Fix tag name should be unique violation
Fix tag name should be unique violation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-05 11:45:41 +02:00
Vinayak Kariappa Chettimada
c091e267ff Bluetooth: Controller: Resume primary PDU scanning after Auxiliary PDU
Add implementation to resume primary PDU scanning window
after use of LLL scheduling to receive auxiliary PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-05 11:45:41 +02:00
Vinayak Kariappa Chettimada
9b4e1849f5 Bluetooth: Controller: Flush Aux PDUs being in LLL scheduling
When Auxiliary PDUs are scanning by the primary scan's LLL
scheduling, then flush the Auxiliary PDUs when processing
them in the ULL instead of using the disabled callback.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-05 11:45:41 +02:00
Vinayak Kariappa Chettimada
3ce651fe7b Bluetooth: controller: Extended scanning with LLL scheduling
Extended scanning with LLL scheduling.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-08-05 11:45:41 +02:00
Andrzej Kaczmarek
51173f9f40 Bluetooth: controller: Add ull_scan_aux_is_valid_get helper
This can be used to check if pointer is a valid lll_scan_aux pointer,
e.g. if we need to decide what kind of struct is attached to RX node
for further processing.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-08-05 11:45:41 +02:00
Andrzej Kaczmarek
c9fca499b2 Bluetooth: controller: Fix isr_done_cleanup
We need to reset isr status before returning as otherwise irq will be
triggered over and over again.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-05 11:45:41 +02:00
Eduardo Montoya
3872812ffc net: openthread: fix error codes for TX done
Fix potential bug when returning error codes not handled by
OpenThread in `otPlatRadioTxDone`.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-08-05 11:26:27 +02:00
Lingao Meng
c85640edf3 Bluetooth: adv: Fix wrong assert
Fixes wrong ASSERT usage cause abnormal failed.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-08-05 11:25:39 +02:00
Joakim Andersson
2a2523ce74 Bluetooth: host: Fix bug in adv timeout for limited advertiser
Fix bug in adv timeout for limited advertiser when extended advertising
features has been enabled. The advertiser was only stopped when
configured as an extended advertiser. It should be stopped when
configured as a legacy advertiser also.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-08-05 11:25:11 +02:00
Jordan Yates
fdeaa9103e random: deprecate XOROSHIRO_RANDOM_GENERATOR
Deprecate the xoroshiro128+ PRNG algorithm in favour of xoshiro128++.
xoshiro128++ is a drop-in replacement which is invisible from the user
perspective.

xoroshiro128+ is unsuitable because it is explicitly a floating-point
PRNG, not a general-purpose PRNG. This means that the lower 4 bits of
the output are actually linear, not random (from the designers,
https://prng.di.unimi.it/). This means 1/8th of the generated data is
not random.

Additionally, xoroshiro128+ is not a 32bit algorithm, it operates on
64bit numbers. For the vast majority of Zephyr devices, this makes the
PRNG slower than it needs to be. The replacement (xoshiro128++) is
32bit, with no loss in state space (still 128 bit).

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-08-05 11:24:44 +02:00
Jordan Yates
688fc737a8 random: add xoshiro128++ PRNG source
Adds an implementation of xoshiro128++ as a pseudo random number
generator from https://prng.di.unimi.it/ that operates on 32bit words.

The algorithm postfix signifies the main operation in the generation
function. Therefore xoshiro++ is chosen over xoshiro** as we would
prefer to do 2 additions isntead of 2 multiplications on embedded
hardware. The quality of the generators appears to be the same in all
other respects.

xoshiro+ is not chosen despite being faster as it generates random
floating-point values, not general purpose random values (The lower 4
bits are linear).

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-08-05 11:24:44 +02:00
Robert Lubos
bbc6c66ed8 net: websocket: Fix poll handling for offloaded sockets
ZFD_IOCTL_POLL_OFFLOAD operation needed special handling, as it needed
to modify the fds table for the offloaded implementation, overwriting
websocket file descriptors with the underlying offloaded ones. This is
only needed for the offloaded sockets, as the native implmentation use
POLL_PREPARE/UPDATE operations instead.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-08-04 16:58:15 +02:00
Robert Lubos
a6a9d7a368 net: websocket: Fix ioctl implementation for websocket
The websocket implementation of ioctl wrongly passed websocket context
to the undrelying `ioctl` implementation instead of the context of the
underlying socket.

Additionally, currentl implementation used the vtable of the native
socket implementation unconditionally, making it unusable with an
offloaded underlying socket.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-08-04 16:58:15 +02:00
Gerard Marull-Paretas
9e8e88aee4 pm: device: add compatibility for force suspend and low power
Add support for FORCE_SUSPEND and LOW_POWER actions. Even though these
actions have no clear meaning, they are added for compatibility until
their associated states are discussed. Their usage in new code should be
discouraged until the associated states are clarified.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas
2ccf41a6d9 pm: device: handle devices not supporting requested state
If a device does not support, for example, the suspend action the
subsystem should just ignore the device.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas
7ccc1a41bc pm: use actions for device PM control
Instead of passing target states, use actions for device PM control.
Actions represent better the meaning of the callback argument.
Furthermore, they are more future proof as they can be suitable for
other PM actions that have no direct mapping to a state. If we compare
with Linux, we could have a multi-stage suspend/resume. Such scenario
would not have a good mapping when using target states.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas
d41dadc569 pm: rename PM_DEVICE_STATE_SUSPEND to PM_DEVICE_STATE_SUSPENDED
The verb tense for the suspended state was not consistent with other
states. The likely reason: state was being used as a command/action.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas
bc2990f82d pm: device: do not call device if already on the given state
If the device is already at the given state, do not call the device PM
control function. This makes sure that devices are only called to change
from one state to another.

Even though asynchronous device PM is completely broken, transitional
states are considered too.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas
abbb8b7c91 pm: device: improve docs and arg names for state set
Improve the docstrings of the pm_device_state_set function and change to
shorter argument variable names.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas
11eef4d8c8 pm: device: remove pointer usage for state
Since the state is no longer modified by the device PM callback, just
use the state value.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas
9e7d545bb4 pm: device: remove ctrl_command callback argument
The ctrl_command is not used anymore, so remove it from the callback
signature.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas
c2cf1ad203 pm: device: remove usage of local states
The device PM subsystem already holds the device state, so there is no
need to keep duplicates inside the device. The pm_device_state_get has
been refactored to just return the device state. Note that this is still
not safe, but the same applied to the previous implementation. This
problem will be addressed later.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Vinayak Kariappa Chettimada
4661ae3c21 Bluetooth: Controller: Fix Extended Scanning Address Resolution
Fix the received Extended Advertising PDU's address
resolution latency due to missing reset of pending IRQ in
the NVIC which caused the wait loop from not exit correctly.

Fixes #30243.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-04 10:37:08 +02:00