Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
562cba7
Bluetooth: nRF Connect SDK v2.6.4 NCSIDB-1718 cherry-picks
cvinayak Sep 30, 2025
cb7beb7
Bluetooth: nRF Connect SDK v2.6.4 NCSIDB-1718 cherry-pick fixes
cvinayak Sep 30, 2025
1f88a3b
Bluetooth: L2CAP: Fix leaking tx metadata
Tronil Nov 22, 2023
96073b8
Bluetooth: L2CAP: stop stealing buffers from SDU pool
jori-nordic Jan 11, 2024
e2961ee
Bluetooth: L2CAP: Don't try to send on disconnected channel
jori-nordic Apr 17, 2024
aa6fd02
Bluetooth: host: handle not getting a buffer
jori-nordic May 2, 2024
b2a5527
Bluetooth: Host: Guard set state in conn_destroy
Thalley May 14, 2024
e5b66a7
Bluetooth: host: extract sending of host num complete
jori-nordic Jul 11, 2024
cafacb8
Bluetooth: host: Send host num completes as early as possible
jori-nordic Jul 11, 2024
bba5d23
Bluetooth: Host: Free ACL RX fragments on disconnection
jori-nordic Aug 8, 2024
1ddb58d
Bluetooth: host: Fix bug in disconnected handling
jthm-ot Nov 15, 2024
06ae8a9
Bluetooth: Host: Use actual user_data size
LingaoM Dec 6, 2023
ce11e85
Bluetooth: Host: Remove use of `bt_buf_get_cmd_complete`
alwa-nordic Jan 22, 2024
180b51d
Bluetooth: Host: Remove `bt_buf_get_cmd_complete`
alwa-nordic Jan 24, 2024
f3cda7d
Bluetooth: Host: Refactor `bt_buf_get_evt`
alwa-nordic Jan 25, 2024
13c4e70
Bluetooth: ISO: Add CONFIG_BT_ISO_{RX/TX}
Thalley Feb 28, 2024
f8ac289
Bluetooth: Rename `num_complete_pool` -> `sync_evt_pool`
alwa-nordic Apr 23, 2024
948652a
Bluetooth: host: Use correct user_data size for hci_rx_pool
jori-nordic Jul 11, 2024
1e9d7b6
Bluetooth: buf: Put command complete/status in sync buf pool
jori-nordic Sep 13, 2024
2a5a711
Bluetooth: Host: Deprecate `BT_BUF_ACL_RX_COUNT` symbol
theob-pro Nov 21, 2024
c76220d
Bluetooth: Controller: Fix HCI command buffer allocation failure
cvinayak Jan 10, 2025
15d753d
bluetooth: buf: Add a callback for freed buffer in rx pool
PavelVPV Nov 7, 2024
ebd8ab1
Bluetoth: Host: Fix buffer allocation warnings in system workqueue
jhedberg Feb 21, 2025
3b0a51d
Bluetooth: Host: Fix deadlock when failing to alloc on BT RX thread
KyraLengfeld Feb 27, 2025
e94b91d
Revert "Bluetooth: host: Send host num completes as early as possible"
PavelVPV May 6, 2025
cd13a8d
Revert "Bluetooth: host: extract sending of host num complete"
PavelVPV May 6, 2025
3abac90
Bluetooth: nRF Connect SDK v2.6.4 NCSIDB-1718 cherry-pick revised
cvinayak Sep 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/releases/migration-guide-3.6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ Bluetooth
Any pointer to a UUID must be prefixed with `const`, otherwise there will be a compilation warning.
For example change ``struct bt_uuid *uuid = BT_UUID_DECLARE_16(xx)`` to
``const struct bt_uuid *uuid = BT_UUID_DECLARE_16(xx)``. (:github:`66136`)
* The :c:func:`bt_l2cap_chan_send` API no longer allocates buffers from the same pool as its `buf`
parameter when segmenting SDUs into PDUs. In order to reproduce the previous behavior, the
application should register the `alloc_seg` channel callback and allocate from the same pool as
`buf`.

* Mesh

Expand Down
73 changes: 58 additions & 15 deletions include/zephyr/bluetooth/buf.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,47 @@ struct bt_buf_data {
#define BT_BUF_ISO_RX_COUNT 0
#endif /* CONFIG_BT_ISO */

/* see Core Spec v6.0 vol.4 part E 7.4.5 */
#define BT_BUF_ACL_RX_COUNT_MAX 65535

#if defined(CONFIG_BT_CONN) && defined(CONFIG_BT_HCI_HOST)
/* The host needs more ACL buffers than maximum ACL links. This is because of
* the way we re-assemble ACL packets into L2CAP PDUs.
*
* We keep around the first buffer (that comes from the driver) to do
* re-assembly into, and if all links are re-assembling, there will be no buffer
* available for the HCI driver to allocate from.
*
* TODO: When CONFIG_BT_BUF_ACL_RX_COUNT is removed,
* remove the MAX and only keep the 1.
*/
#define BT_BUF_ACL_RX_COUNT_EXTRA CONFIG_BT_BUF_ACL_RX_COUNT_EXTRA
#define BT_BUF_ACL_RX_COUNT (MAX(CONFIG_BT_BUF_ACL_RX_COUNT, 1) + BT_BUF_ACL_RX_COUNT_EXTRA)
#else
#define BT_BUF_ACL_RX_COUNT_EXTRA 0
#define BT_BUF_ACL_RX_COUNT 0
#endif /* CONFIG_BT_CONN && CONFIG_BT_HCI_HOST */

#if defined(CONFIG_BT_BUF_ACL_RX_COUNT) && CONFIG_BT_BUF_ACL_RX_COUNT > 0
#warning "CONFIG_BT_BUF_ACL_RX_COUNT is deprecated, see Zephyr 4.1 migration guide"
#endif /* CONFIG_BT_BUF_ACL_RX_COUNT && CONFIG_BT_BUF_ACL_RX_COUNT > 0 */

BUILD_ASSERT(BT_BUF_ACL_RX_COUNT <= BT_BUF_ACL_RX_COUNT_MAX,
"Maximum number of ACL RX buffer is 65535, reduce CONFIG_BT_BUF_ACL_RX_COUNT_EXTRA");

/** Data size needed for HCI ACL, HCI ISO or Event RX buffers */
#define BT_BUF_RX_SIZE (MAX(MAX(BT_BUF_ACL_RX_SIZE, BT_BUF_EVT_RX_SIZE), \
BT_BUF_ISO_RX_SIZE))

/** Buffer count needed for HCI ACL, HCI ISO or Event RX buffers */
#define BT_BUF_RX_COUNT (MAX(MAX(CONFIG_BT_BUF_EVT_RX_COUNT, \
CONFIG_BT_BUF_ACL_RX_COUNT), \
BT_BUF_ISO_RX_COUNT))
/* Controller can generate up to CONFIG_BT_BUF_ACL_TX_COUNT number of unique HCI Number of Completed
* Packets events.
*/
BUILD_ASSERT(CONFIG_BT_BUF_EVT_RX_COUNT > CONFIG_BT_BUF_ACL_TX_COUNT,
"Increase Event RX buffer count to be greater than ACL TX buffer count");

/** Buffer count needed for HCI ACL or HCI ISO plus Event RX buffers */
#define BT_BUF_RX_COUNT (CONFIG_BT_BUF_EVT_RX_COUNT + \
MAX(BT_BUF_ACL_RX_COUNT, BT_BUF_ISO_RX_COUNT))

/** Data size needed for HCI Command buffers. */
#define BT_BUF_CMD_TX_SIZE BT_BUF_CMD_SIZE(CONFIG_BT_BUF_CMD_TX_SIZE)
Expand All @@ -113,6 +146,27 @@ struct bt_buf_data {
*/
struct net_buf *bt_buf_get_rx(enum bt_buf_type type, k_timeout_t timeout);

/** A callback to notify about freed buffer in the incoming data pool.
*
* This callback is called when a buffer of a given type is freed and can be requested through the
* @ref bt_buf_get_rx function. However, this callback is called from the context of the buffer
* freeing operation and must not attempt to allocate a new buffer from the same pool.
*
* @warning When this callback is called, the scheduler is locked and the callee must not perform
* any action that makes the current thread unready. This callback must only be used for very
* short non-blocking operation (e.g. submitting a work item).
*
* @param type_mask A bit mask of buffer types that have been freed.
*/
typedef void (*bt_buf_rx_freed_cb_t)(enum bt_buf_type type_mask);

/** Set the callback to notify about freed buffer in the incoming data pool.
*
* @param cb Callback to notify about freed buffer in the incoming data pool. If NULL, the callback
* is disabled.
*/
void bt_buf_rx_freed_cb_set(bt_buf_rx_freed_cb_t cb);

/** Allocate a buffer for outgoing data
*
* This will set the buffer type so bt_buf_set_type() does not need to
Expand All @@ -129,17 +183,6 @@ struct net_buf *bt_buf_get_rx(enum bt_buf_type type, k_timeout_t timeout);
struct net_buf *bt_buf_get_tx(enum bt_buf_type type, k_timeout_t timeout,
const void *data, size_t size);

/** Allocate a buffer for an HCI Command Complete/Status Event
*
* This will set the buffer type so bt_buf_set_type() does not need to
* be explicitly called before bt_recv_prio().
*
* @param timeout Non-negative waiting period to obtain a buffer or one of the
* special values K_NO_WAIT and K_FOREVER.
* @return A new buffer.
*/
struct net_buf *bt_buf_get_cmd_complete(k_timeout_t timeout);

/** Allocate a buffer for an HCI Event
*
* This will set the buffer type so bt_buf_set_type() does not need to
Expand Down
7 changes: 4 additions & 3 deletions include/zephyr/bluetooth/l2cap.h
Original file line number Diff line number Diff line change
Expand Up @@ -585,9 +585,10 @@ int bt_l2cap_chan_disconnect(struct bt_l2cap_chan *chan);
* If the application is reserving the bytes it should use the
* BT_L2CAP_BUF_SIZE() helper to correctly size the buffers for the for the
* outgoing buffer pool.
* When segmenting an L2CAP SDU into L2CAP PDUs the stack will first attempt
* to allocate buffers from the original buffer pool of the L2CAP SDU before
* using the stacks own buffer pool.
* When segmenting an L2CAP SDU into L2CAP PDUs the stack will first attempt to
* allocate buffers from the channel's `alloc_seg` callback and will fallback
* on the stack's global buffer pool (sized
* @kconfig{CONFIG_BT_L2CAP_TX_BUF_COUNT}).
*
* @note Buffer ownership is transferred to the stack in case of success, in
* case of an error the caller retains the ownership of the buffer.
Expand Down
Loading
Loading