Skip to content

Conversation

@carlescufi
Copy link
Contributor

Do not merge.

lylezhu2012 and others added 30 commits August 1, 2024 09:30
The BR Keys cannot be scanned by function
bt_foreach_bond.

Add function bt_foreach_bond_br for br.

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

Signed-off-by: Lyle Zhu <[email protected]>
(cherry picked from commit 2d665c1)
…so_reset

The bt_iso_chan_disconnected function will attempt to
remote ISO data paths as the central.

Signed-off-by: Emil Gydesen <[email protected]>
(cherry picked from commit f5fd2cf)
`bt_conn_send_cb` used to allocate a TX context (K_FOREVER).
Instead, we now put the context in the userdata of the buffer.

This means that now this fn will never block and always succeed since the
tx_queue is a FIFO (infinite size). It just puts the buf on the queue.

The metadata is stored safely in there until we have acquired all the
necessary resources to send it to the controller without failing: TX
context and controller buffer.

I.e. when `bt_conn_process_tx` is called, that's when a TX context is
try-allocated and the contents of `buf->userdata` is moved into it.
The buffer is now ready to be sent to the lower layer.

`bt_conn_process_tx` will return -EWOULDBLOCK if it's not able to acquire a
TX context, this PR modifies `bt_conn_prepare_events` to respond to this by
also waiting on the TX context pool.

Unfortunately, this increases the required userdata size for any buffers
handed to `bt_conn_send_cb`. This will be fixed in a later commit.

Signed-off-by: Aleksander Wasaznik <[email protected]>
(cherry picked from commit 52dc64f)
Instead of allocating segments/fragments and copying data into them, we
allocate segments as "views" (or slices) into the original buffer.

The view also gives access to the headroom of the original buffer, allowing
lower layers to push their headers.

We choose not to allow multiple views into the same buffer as the headroom
of a view would overlap with the data of the previous view.

We mark a buffer as locked (or "in-view") by temporarily setting its
headroom to zero. This effectively stops create_view because the requested
headroom is not available.

Each layer that does some kind of fragmentation and wants to use views for
that needs to maintain a buffer pool (bufsize 0, count = max views) and a
metadata array (size = max views) for the view mechanism to work.

Maximum number of views: number of parallel buffers from the upper layer,
e.g. number of L2CAP channels for L2CAP segmentation or number of ACL
connections for HCI fragmentation.

Reason for the change:
1. prevent deadlocks or (ATT/SMP) requests timing out
2. save time (zero-copy)
3. save memory (gets rid of frag pools)

L2CAP CoC: would either allocate from the `alloc_seg` application callback,
or worse _steal_ from the same pool, or allocate from the global ACL pool.

Conn/HCI: would either allocate from `frag_pool` or the global ACL pool.

Signed-off-by: Jonathan Rico <[email protected]>
Co-authored-by: Aleksander Wasaznik <[email protected]>
(cherry picked from commit 1c8cae3)
…_send_cb"

This reverts commit 178b807.

Signed-off-by: Rubin Gerritsen <[email protected]>
The current TX pattern in the host is to try to push a buffer through all
the layers up until it is ingested by the controller.

Since sending can fail at any layer, we need error-handling and separate
retry logic on pretty much all layers. That logic obscures the "happy path"
for people trying ot understand the code.

This commit inverts the control, in a way that doesn't require changing the
host or HCI driver API (yet):

Layers don't send buffers synchronously, they instead put their buffer in a
private queue of their own and raise a TX flag on the lower layer. Think of
it as a `READY` interrupt line that has to be serviced by the lower layer.

Sending is now non-blocking, rate depends on the size of buffer pools.

There is a single TX processing function. This can be thought as the
Interrupt Service Routine that will handle the `READY` interrupt from the
layers above.

That `tx_processor()` will then attempt to allocate enough resources in
order to send the buffer through to the controller. This allocation logic
does not block.

After acquiring all the resources, the TX processor will attempt to pull
data from the upper layer. The upper layer has to figure out which buffer
to pass to the controller. This is a good spot to put scheduling or QoS
logic in the upper layer.

Notes:

- user-facing API for tuning QoS will be implemented in a future patch

- this scheme could (and probably will) be extended to upper layers (e.g.
  ATT, L2CAP CoC segmentation).

- this patch removes the `pending_no_cb()` memory optimization for
  clarity/correctness. It might get re-implemented after a stabilization
  period. Hopefully with more documentation.

Signed-off-by: Jonathan Rico <[email protected]>
Co-authored-by: Aleksander Wasaznik <[email protected]>
(cherry picked from commit 28535fe)
… TX is done"

This reverts commit d74e0b5.

Signed-off-by: Rubin Gerritsen <[email protected]>
This API replaces `bt_l2cap_send()` and `bt_l2cap_send_cb()`.

The difference is that it takes the `struct bt_l2cap_le_chan` object
directly instead of a connection + CID.

We need the channel object in order to put the PDU on the TX queue. It
is inefficient to do a search for every PDU when the caller knows the
channel object's address and can just pass it down.

Signed-off-by: Jonathan Rico <[email protected]>
(cherry picked from commit 38820ef)
We don't need it thanks to the new TX architecture.

Signed-off-by: Jonathan Rico <[email protected]>
(cherry picked from commit 48d1cff)
We don't need the TX thread anymore.

Generalizing the pull-based architecture (ie. `tx_processor`) to HCI
commands makes it possible to run the whole TX path from the the system
workqueue, or any workqueue really.

There is an edge-case, where we call `bt_hci_cmd_send_sync()` from the
syswq, stalling the system. The proposed mitigation is to attempt to drain
the command queue from within `bt_hci_cmd_send_sync()`.

My spidey sense tingles however, and it would be better to just remove the
capability of calling this fn from the syswq. But doing this requires
refactoring a bunch of synchronous procedures in the stack (e.g. stack
init, connection establishment, address setting etc), dragging in more
work. I will do it, but in a later patch.

Signed-off-by: Jonathan Rico <[email protected]>
(cherry picked from commit 28be890)
We can get rid of the view pool for SDU segments :)
We have to make the code slightly more complex :'(

The basic idea is always giving the original SDU buffer to `conn.c` for it
to pull ACL fragments from.

In order to do this, we need to add the PDU headers just-in-time.
`bt_l2cap_send_pdu()` does not add them before putting the PDU on the queue
anymore. They are added by `l2cap_data_pull()` right before the data leaves
`l2cap.c` for `conn.c`.

We also have to inform `conn.c` "out of band" of the real L2CAP PDU size so
it doesn't fragment across segment boundaries. This oob is the new `length`
parameter to the `.pull()` method.

This is the added complexity mentioned above.

Since SDU segmentation concerns only LE-L2CAP, ISO and Classic L2CAP don't
need this extra logic.

Signed-off-by: Jonathan Rico <[email protected]>
(cherry picked from commit b6cdf10)
…variables

In order to suppress compiler warnings w/o using void/ifdef.

Suggested in #72854

Signed-off-by: Jonathan Rico <[email protected]>
(cherry picked from commit 5a7ef42)
View buffers are now also a limited resource. Acquire them before
attempting to pull data. `CONFIG_BT_CONN_FRAG_COUNT` should be tuned on
a per-application basis to avoid this.

A possible optimization, that was present before, is to not create a
frag when the original buffer fits the controller's HCI size.

I prefer deferring this optimization to a future patchset.

Signed-off-by: Jonathan Rico <[email protected]>
(cherry picked from commit 9b3f41d)
The same way as `bt_hci_get_adv_handle` and `bt_hci_get_conn_handle` add
a function to get the handle of a periodic advertising sync.

Signed-off-by: Théo Battrel <[email protected]>
(cherry picked from commit 7c3a5d5)
Adds missing doc on public member.

Signed-off-by: Knut Eldhuset <[email protected]>
(cherry picked from commit db9308d)
…I APIs

Add versioning to the new HCI API so that it shows up officially as
unstable, and add a reference to the new API from the old API.

Signed-off-by: Johan Hedberg <[email protected]>
(cherry picked from commit 1c53726)
ISO connections that were in the TX queue were not getting serviced in
time. This happens because `iso_data_pull()` returns `NULL` when that
particular connection (`conn`) is done sending.

But it doesn't trigger the TX processor again to process other channels in
the queue. This patch fixes that by calling `bt_tx_irq_raise()`.

We can't do this from `conn.c` as we don't know if the `NULL` returned is
because the current channel is out of data or because it has data but it
can't send it (e.g. the current buf is being "viewed" already).

Fixes zephyrproject-rtos/zephyr#74321

Signed-off-by: Jonathan Rico <[email protected]>
(cherry picked from commit 8af7180)
Similar to ISO connections, ACL connections are not serviced as fast as
possible. Change this, and try to send as much as we have resources for.

Signed-off-by: Jonathan Rico <[email protected]>
(cherry picked from commit c6345c6)
This API converts a SMP error code to a string.
This can be useful if application developers want
to print them in the applications.

BT_SMP_ERR_SUCCESS was added for completeness.

Later we can also use them in the host to improve debuggability.

Signed-off-by: Rubin Gerritsen <[email protected]>
(cherry picked from commit b25985a)
This can be useful if application developers
want to print them in the applications.

Later we can also use them in
the host to improve debuggability.

Signed-off-by: Rubin Gerritsen <[email protected]>
(cherry picked from commit 69fb606)
Use K_WORK defined. This delayed work is never used with any
other timeout than K_NO_WAIT, so the "delayed" part of it
is never actually needed

Signed-off-by: Lingao Meng <[email protected]>
(cherry picked from commit cfd79e8)
…end_sync`

`cmd(buf)` depends on this since it uses `net_buf_id`, which would alias
multiple pools.

Signed-off-by: Aleksander Wasaznik <[email protected]>
(cherry picked from commit a9c95c5)
The `rsp` params actually not used, so removed.

Signed-off-by: Lingao Meng <[email protected]>
(cherry picked from commit b11c43c)
…sage

If func:`bt_hci_cmd_send_sync` return no-zero value, indicate
that `cmd(buf)->status` not zero, in this condition, rsp not
to assign anything, so remove it.

Signed-off-by: Lingao Meng <[email protected]>
(cherry picked from commit f6480db)
Fix Bluetooth initialization problem caused by PR#72090
for at least ST boards that are using BlueNRG BLE modules.

For more information, please refer to issue #74528.

Signed-off-by: Ali Hozhabri <[email protected]>
(cherry picked from commit 3b726de)
Modified to check the length of the remaining data in buffer
before processing the next report. The length check is missing
in the cont routine.

Signed-off-by: Eunkyu Lee <[email protected]>
(cherry picked from commit e491f22)
…d warnings

This commit fixes compilation warnings that are present when compiling
with CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY as can be seen in this
compiler log:

"""
In file included from /zephyr-sdk-0.16.1/arm-zephyr-eabi/picolibc/
include/string.h:215,
                 from /zephyr/subsys/bluetooth/host/smp.c:15:
In function '__memcpy_ichk',
    inlined from 'sc_send_public_key' at /zephyr/subsys/bluetooth/host/
smp.c:3006:2:
/zephyr-sdk-0.16.1/arm-zephyr-eabi/picolibc/include/ssp/string.h:83:1:
warning: argument 2 null where non-null expected [-Wnonnull]
   83 | __ssp_bos_icheck3_restrict(memcpy, void *, const void *)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~
/zephyr-sdk-0.16.1/arm-zephyr-eabi/picolibc/include/ssp/string.h:83:1:
note: in a call to built-in function '__builtin_memcpy'
/zephyr/subsys/bluetooth/host/smp.c: In function 'smp_public_key':
/zephyr/subsys/bluetooth/host/smp.c:4214:21: warning: argument 2
null where non-null expected [-Wnonnull]
 4214 | memcmp(smp->pkey, sc_public_key, BT_PUB_KEY_COORD_LEN) == 0) {
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/zephyr-sdk-0.16.1/arm-zephyr-eabi/picolibc/include/string.h:62:10: note:
in a call to function 'memcmp' declared 'nonnull'
   62 | int memcmp (const void *, const void *, size_t);
      |     ^~~~~~
"""

The warning is caused by the potential use of NULL "sc_public_key"
global pointer that is not assigned a value in "smp_init()" if
CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY is enabled. This commit
conditionally changes the behavior of function "smp_public_key()"
if CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY is activated to simply return
and not use the "sc_public_key" variable. Other functions that are not
called anymore by "smp_public_key()" are also conditionally
deactivated when CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY is enabled

Signed-off-by: Sebastian Panceac <[email protected]>
(cherry picked from commit 9ce338d)
`bt_le_ext_adv_start` does not modify the `param` argument, which can
therefore be marked as `const`. This allows the struct to exist purely
in ROM.

Signed-off-by: Jordan Yates <[email protected]>
(cherry picked from commit 40eeded)
The rationale behind that change is that the Application can use the
`bt_conn_le_param_update()` API to signal the controller to reschedule
the link.

Even if the new connection params are within the old ones, the
controller would be free to choose an e.g. smaller interval. The host
API should not prevent this usage.

Fixes zephyrproject-rtos/zephyr#74292

Co-authored-by: Knut Eldhuset <[email protected]>
Signed-off-by: Jonathan Rico <[email protected]>
(cherry picked from commit ac37d64)
When syncing to a PA using PAST then the sync_info.recv_enabled
was always just set to true, regardless of what mode was set
during the subscribe parameters.

The mode(s) are now stored in an array (with the default value
as well) so that we can retrieve that information when the PA
has synced via PAST.

It was considered to put the `mode` value into the `bt_conn`
struct, but that would require an API change as the `bt_conn`
parameter for the subcribe function uses `const`.

This commit also modifies the guard for PAST to be the more
correct value CONFIG_BT_PER_ADV_SYNC_TRANSFER_RECEIVER instead
of just CONFIG_BT_CONN.

Signed-off-by: Emil Gydesen <[email protected]>
(cherry picked from commit 711b42a)
57300 and others added 6 commits September 13, 2024 12:19
…mask

GPIOTE131 channels are reserved in the same way as the GPIOTE130 ones.

Signed-off-by: Grzegorz Swiderski <[email protected]>
(cherry picked from commit 5cb49dc)
Add overlays for booting PPR on the `nrf9280pdk/nrf9280/cpuapp` target.
They are identical to the nRF54H ones because of similar DT structure.

Signed-off-by: Grzegorz Swiderski <[email protected]>
(cherry picked from commit 17a7735)
Booting VPRs requires changing the default value of CONFIG_RV_BOOT_HART.
This must be reverted (back to zero) for a future nRF9230 SoC revision,
which will align more closely with the RISC-V spec.

Signed-off-by: Grzegorz Swiderski <[email protected]>
(cherry picked from commit 57ce595)
PMIC service should be supported on Application and Radiocore, whereas
DVFS service is currently unsupported.

Signed-off-by: Grzegorz Swiderski <[email protected]>
(cherry picked from commit 3b56ef0)
…tform

VPR addresses are platform-dependent, so let's use a common symbol -
CONFIG_NRF_PLATFORM_HALTIUM - to cover both nRF54H and nRF92 series.

Signed-off-by: Grzegorz Swiderski <[email protected]>
(cherry picked from commit 26c99a6)
…INTERRUPT=n

Verify NRF GPIO driver with NRFX interrupts disabled.
Verify that driver handles properly 'get' and 'set' api methods.
When calling interrupt enable driver should report
'function not implemented' error.

Signed-off-by: Bartosz Miller <[email protected]>
(cherry picked from commit bb3efaa)
@Thalley Thalley removed their request for review September 16, 2024 13:21
adamkondraciuk and others added 6 commits September 18, 2024 12:39
GRTC needs to use direct clock source path instead of system clock path
to support ELV mode for nRF54L targets.

Upstream PR: zephyrproject-rtos/zephyr#78082

Signed-off-by: Adam Kondraciuk <[email protected]>
While Partition Manager is enabled, it manages the offset
by itself.

Signed-off-by: Andrzej Puzdrowski <[email protected]>
DVFS medlow oppoint should use trim entry index 2,
this needs to be updated in hal/hal_nordic.
Currently this is not possible because of time
constraints that is why this temporary patch
is applied. This is the only point where
new_f_trim_entry is used.

Upstream PR: zephyrproject-rtos/zephyr#78665

Signed-off-by: Lukasz Stepnicki <[email protected]>
Demultiplexer was not ready to handle case when log message was
incomplete which was followed by other log messages. Such scenario
could occur if there was a fault that happen during logging of
a message. In that case incomplete message was followed by valid
messages (fault report) and this fault report was not handled
because processing was blocked waiting for completion of a
message which preceeded fault report.

Since it is expected that some messages may be incomplete a
garbage collection mechanism is added. When start of a message is
received timestamp is logged and list of incomplete messages
is checked for 'old' messages which persist in incomplete state
for long. When message timeouts it is closed and marked as
invalid. It unblocks processing of following messages.

Upstream PR: zephyrproject-rtos/zephyr#78333

Signed-off-by: Krzysztof Chruściński <[email protected]>
Apply clang-format formatting.

Upstream PR: zephyrproject-rtos/zephyr#78332

Signed-off-by: Krzysztof Chruściński <[email protected]>
write_data function which was writing to STMESP data registers was
starting by writing words and tail was written using byte access.
However, RISCV core does not support unaligned access and on Cortex-M33
even if supported it is faster to do aligned access. Reworked
write_data to start first by writing data using byte or half word
access until data pointer is word aligned, then word access is used
and finally tail is written using byte or half word access.

Upstream PR: zephyrproject-rtos/zephyr#78332

Signed-off-by: Krzysztof Chruściński <[email protected]>
carlescufi and others added 3 commits October 4, 2024 09:19
Given that `isr_tables` cannot use `--whole-archive`, the ISR table
sections are at risk of being dropped by the linker. Example:

   $ west build -b qemu_cortex_m3 -DCONFIG_GEN_SW_ISR_TABLE=n
   ...
   gen_isr_tables.py: error: Cannot find the intlist section!

Even when the sections are marked as used, they can be discarded when
linking against `libisr_tables.a`. This is fixed by changing the CMake
library type from `STATIC` (default) to `OBJECT`, which lets us link
with `isr_tables.c.obj` directly and keep the required sections.

Upstream PR: zephyrproject-rtos/zephyr#73905

Signed-off-by: Grzegorz Swiderski <[email protected]>
Added the SMP service and characteristic UUIDs to the smp_bt module
header and used those definitions.

Signed-off-by: Mateusz Kapala <[email protected]>
(cherry picked from commit 7755589)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.