Skip to content

Commit

Permalink
Bluetooth: Controller: build assert if comand buffer is too small
Browse files Browse the repository at this point in the history
Host Number of Completed Packets command does not follow normal flow
control of HCI commands and the Controller side HCI drivers that
allocates HCI command buffers with K_NO_WAIT can end up running out of
command buffers.

Host will generate up to acl_pkts number of Host Number of Completed
Packets command plus a number of normal HCI commands.

Normal HCI commands follow the HCI command flow control using
Num_HCI_Command_Packets return in HCI command complete and status.

When Controller to Host data flow control is supported, this commit
ensures that BT_BUF_CMD_TX_COUNT is greater than or equal to
(BT_BUF_ACL_RX_COUNT + Ncmd), where Ncmd is the supported maximum
Num_HCI_Command_Packets.

Note: The SDC controller (currently) does not support
Num_HCI_Command_Packets > 1, which means Ncmd is always 1.

Signed-off-by: Kyra Lengfeld <[email protected]>
  • Loading branch information
KyraLengfeld committed Jan 13, 2025
1 parent 7f1e6c6 commit 7e4cf76
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions doc/nrf/releases_and_maturity/known_issues.rst
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,14 @@ Bluetooth LE

.. rst-class:: v2-9-0-nRF54H20-rc1 v2-9-0 v2-8-0 v2-7-0 v2-6-2 v2-6-1 v2-6-0

DRGN-24352: hci_ipc and ipc_radio samples do not support stream flow control and drop bytes
With the deferred disconnection complete generation added in v2-6-0, we see in cases of CONFIG_BT_HCI_ACL_FLOW_CONTROL=y, and the CONFIG_BT_BUF_CMD_TX_COUNT < (CONFIG_BT_BUF_ACL_RX_COUNT + 1), we may drop HCI command packets.
The symptom visible is a missing disconnect event, and subsequent failure in connection, if a peripheral device falls out of range / is powered off.

**Workaround:** Build Assert added to ensure CONFIG_BT_CTLR_RX_BUFFERS < BT_BUF_CMD_TX_COUNT.

.. rst-class:: v2-9-0-nRF54H20-rc1 v2-9-0 v2-8-0 v2-7-0 v2-6-2 v2-6-1 v2-6-0

NCSDK-31095: Issues with the :kconfig:option:`CONFIG_SEGGER_SYSVIEW` Kconfig option
Using this Kconfig option causes the data parameter in the macros :c:macro:`k_fifo_put`, :c:macro:`k_fifo_alloc_put`, :c:macro:`k_lifo_put`, and :c:macro:`k_lifo_alloc_put` to be evaluated multiple times.
This can cause problems if the data parameter is a function call incrementing a reference counter.
Expand Down
17 changes: 17 additions & 0 deletions subsys/bluetooth/controller/hci_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,23 @@ BUILD_ASSERT(!IS_ENABLED(CONFIG_BT_CENTRAL) ||
BUILD_ASSERT(!IS_ENABLED(CONFIG_BT_PERIPHERAL) ||
(CONFIG_BT_CTLR_SDC_PERIPHERAL_COUNT > 0));

#if defined(CONFIG_BT_HCI_ACL_FLOW_CONTROL)
/*
* The Host will generate up to acl_pkts number of Host Number of Completed Packets command plus a
* number of normal HCI commands, as such we need to ensure the tx command buffer count is big
* enough to not block incoming ACKs from the host.
*
* When Controller to Host data flow control is supported, ensure that BT_BUF_CMD_TX_COUNT is
* greater than or equal to (BT_BUF_ACL_RX_COUNT + Ncmd), where Ncmd is the supported maximum
* Num_HCI_Command_Packets.
*
* The SDC controller (currently) does not support Num_HCI_Command_Packets > 1, which means Ncmd
* is always 1.
*/
BUILD_ASSERT(CONFIG_BT_CTLR_RX_BUFFERS < BT_BUF_CMD_TX_COUNT,
"Too low HCI command buffers compared to ACL Rx buffers.");
#endif

#if defined(CONFIG_BT_BROADCASTER)
#if defined(CONFIG_BT_CTLR_ADV_EXT)
#define SDC_ADV_SET_COUNT CONFIG_BT_CTLR_ADV_SET
Expand Down

0 comments on commit 7e4cf76

Please sign in to comment.