Skip to content

Commit 66ff97e

Browse files
theob-prokartben
authored andcommitted
Bluetooth: Host: Deprecate BT_BUF_ACL_RX_COUNT symbol
Because the number of ACL RX buffers must be at least the number of maximum connections plus one, increasing `CONFIG_BT_MAX_CONN` could inadvertently lead to a build failure if the number of ACL RX buffers is not also increased. This dependency may not be obvious to users. To address this issue, this commit deprecates the `CONFIG_BT_BUF_RX_COUNT` Kconfig symbol and computes the value in `buf.h` using the new `BT_BUF_RX_COUNT` define. Note that the default value and the minimum range value have been changed to 0 to "disable" the option. Additionally, to allow users to increase the number of ACL RX buffers, this commit introduces the new `CONFIG_BT_BUF_RX_COUNT_EXTRA` Kconfig symbol. The value of this symbol will be added to the computed value of `BT_BUF_RX_COUNT`. The configurations of tests and samples have been updated to reflect these changes. Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
1 parent 9b19a90 commit 66ff97e

File tree

26 files changed

+68
-53
lines changed

26 files changed

+68
-53
lines changed

doc/releases/migration-guide-4.1.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,19 @@ Bluetooth Classic
153153
Bluetooth Host
154154
==============
155155

156+
* :kconfig:option:`CONFIG_BT_BUF_ACL_RX_COUNT` has been deprecated. The number of ACL RX buffers is
157+
now computed internally and is equal to :kconfig:option:`CONFIG_BT_MAX_CONN` + 1. If an application
158+
needs more buffers, it can use the new :kconfig:option:`CONFIG_BT_BUF_ACL_RX_COUNT_EXTRA` to add
159+
additional ones.
160+
161+
e.g. if :kconfig:option:`CONFIG_BT_MAX_CONN` was ``3`` and
162+
:kconfig:option:`CONFIG_BT_BUF_ACL_RX_COUNT` was ``7`` then
163+
:kconfig:option:`CONFIG_BT_BUF_ACL_RX_COUNT_EXTRA` should be set to ``7 - (3 + 1) = 3``.
164+
165+
.. warning::
166+
167+
The default value of :kconfig:option:`CONFIG_BT_BUF_ACL_RX_COUNT` has been set to 0.
168+
156169
Bluetooth Crypto
157170
================
158171

doc/releases/release-notes-4.1.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ Bluetooth
7777

7878
* Host
7979

80+
* :kconfig:option:`CONFIG_BT_BUF_ACL_RX_COUNT` has been deprecated and
81+
:kconfig:option:`CONFIG_BT_BUF_ACL_RX_COUNT_EXTRA` has been added.
82+
8083
* HCI Drivers
8184

8285
Boards & SoC Support

include/zephyr/bluetooth/buf.h

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,41 @@ struct bt_buf_data {
8585
#define BT_BUF_ISO_RX_COUNT 0
8686
#endif /* CONFIG_BT_ISO */
8787

88+
/* see Core Spec v6.0 vol.4 part E 7.4.5 */
89+
#define BT_BUF_ACL_RX_COUNT_MAX 65535
90+
91+
#if defined(CONFIG_BT_CONN) && defined(CONFIG_BT_HCI_HOST)
92+
/* The host needs more ACL buffers than maximum ACL links. This is because of
93+
* the way we re-assemble ACL packets into L2CAP PDUs.
94+
*
95+
* We keep around the first buffer (that comes from the driver) to do
96+
* re-assembly into, and if all links are re-assembling, there will be no buffer
97+
* available for the HCI driver to allocate from.
98+
*
99+
* TODO: When CONFIG_BT_BUF_ACL_RX_COUNT is removed,
100+
* remove the MAX and only keep (CONFIG_BT_MAX_CONN + 1)
101+
*/
102+
#define BT_BUF_ACL_RX_COUNT \
103+
(MAX(CONFIG_BT_BUF_ACL_RX_COUNT, (CONFIG_BT_MAX_CONN + 1)) + \
104+
CONFIG_BT_BUF_ACL_RX_COUNT_EXTRA)
105+
#else
106+
#define BT_BUF_ACL_RX_COUNT 0
107+
#endif /* CONFIG_BT_CONN && CONFIG_BT_HCI_HOST */
108+
109+
#if defined(CONFIG_BT_BUF_ACL_RX_COUNT) && CONFIG_BT_BUF_ACL_RX_COUNT > 0
110+
#warning "CONFIG_BT_BUF_ACL_RX_COUNT is deprecated, see Zephyr 4.1 migration guide"
111+
#endif /* CONFIG_BT_BUF_ACL_RX_COUNT && CONFIG_BT_BUF_ACL_RX_COUNT > 0 */
112+
113+
BUILD_ASSERT(BT_BUF_ACL_RX_COUNT <= BT_BUF_ACL_RX_COUNT_MAX,
114+
"Maximum number of ACL RX buffer is 65535, reduce CONFIG_BT_BUF_ACL_RX_COUNT_EXTRA");
115+
88116
/** Data size needed for HCI ACL, HCI ISO or Event RX buffers */
89117
#define BT_BUF_RX_SIZE (MAX(MAX(BT_BUF_ACL_RX_SIZE, BT_BUF_EVT_RX_SIZE), \
90118
BT_BUF_ISO_RX_SIZE))
91119

92120
/** Buffer count needed for HCI ACL, HCI ISO or Event RX buffers */
93121
#define BT_BUF_RX_COUNT (MAX(MAX(CONFIG_BT_BUF_EVT_RX_COUNT, \
94-
CONFIG_BT_BUF_ACL_RX_COUNT), \
122+
BT_BUF_ACL_RX_COUNT), \
95123
BT_BUF_ISO_RX_COUNT))
96124

97125
/** Data size needed for HCI Command buffers. */

samples/bluetooth/central_hr/prj_minimal.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ CONFIG_BT_CTLR_PHY_2M=n
9494
# Reduce Bluetooth buffers
9595
CONFIG_BT_BUF_EVT_DISCARDABLE_COUNT=1
9696
CONFIG_BT_BUF_EVT_DISCARDABLE_SIZE=45
97-
CONFIG_BT_BUF_ACL_RX_COUNT=2
9897
CONFIG_BT_BUF_EVT_RX_COUNT=2
9998

10099
CONFIG_BT_L2CAP_TX_BUF_COUNT=2

samples/bluetooth/central_multilink/prj.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ CONFIG_BT_AUTO_PHY_UPDATE=n
44
CONFIG_BT_PRIVACY=y
55

66
CONFIG_BT_MAX_CONN=62
7-
CONFIG_BT_BUF_ACL_RX_COUNT=63
87

98
# CONFIG_BT_GATT_CLIENT=y
109

samples/bluetooth/hci_uart_async/prj.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ CONFIG_BT_HCI_RAW_H4_ENABLE=y
1010

1111
# Controller configuration. Modify these for your application's needs.
1212
CONFIG_BT_MAX_CONN=16
13-
CONFIG_BT_BUF_ACL_RX_COUNT=17
1413
CONFIG_BT_BUF_ACL_RX_SIZE=255
1514
CONFIG_BT_BUF_CMD_TX_SIZE=255
1615
CONFIG_BT_BUF_EVT_DISCARDABLE_SIZE=255

samples/bluetooth/mesh/boards/bbc_microbit.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ CONFIG_BT_PERIPHERAL=n
1313
CONFIG_BT_EXT_ADV=n
1414
CONFIG_BT_RX_STACK_SIZE=1100
1515
CONFIG_BT_BUF_EVT_RX_COUNT=3
16-
CONFIG_BT_BUF_ACL_RX_COUNT=3
16+
CONFIG_BT_BUF_ACL_RX_COUNT_EXTRA=1
1717
CONFIG_BT_BUF_EVT_DISCARDABLE_COUNT=3
1818

1919
CONFIG_BT_CTLR_ADV_EXT=n

samples/bluetooth/peripheral_hr/prj_minimal.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ CONFIG_BT_CTLR_PHY_2M=n
100100
# Reduce Bluetooth buffers
101101
CONFIG_BT_BUF_EVT_DISCARDABLE_COUNT=1
102102
CONFIG_BT_BUF_EVT_DISCARDABLE_SIZE=45
103-
CONFIG_BT_BUF_ACL_RX_COUNT=2
104103
CONFIG_BT_BUF_EVT_RX_COUNT=2
105104

106105
CONFIG_BT_L2CAP_TX_BUF_COUNT=2

samples/bluetooth/peripheral_identity/prj.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n
88

99
CONFIG_BT_MAX_CONN=62
1010
CONFIG_BT_ID_MAX=62
11-
CONFIG_BT_BUF_ACL_RX_COUNT=63
1211

1312
# CONFIG_BT_SMP=y
1413
# CONFIG_BT_MAX_PAIRED=62

subsys/bluetooth/common/Kconfig

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,21 @@ config BT_BUF_ACL_RX_SIZE
7777
In a Controller only build this will determine the maximum ACL size
7878
that the Controller will send to the Host.
7979

80+
config BT_BUF_ACL_RX_COUNT_EXTRA
81+
int "Number of extra incoming ACL data buffers"
82+
default 0
83+
range 0 65535
84+
help
85+
Number of incoming extra ACL data buffers sent from the Controller to
86+
the Host.
87+
88+
By default, the number of incoming ACL data buffers is equal to
89+
CONFIG_BT_MAX_CONN + 1.
90+
8091
config BT_BUF_ACL_RX_COUNT
81-
int "Number of incoming ACL data buffers"
82-
default 6
83-
range 2 256
92+
int "[DEPRECATED] Number of incoming ACL data buffers"
93+
default 0
94+
range 0 256
8495
help
8596
Number or incoming ACL data buffers sent from the Controller to the
8697
Host.

0 commit comments

Comments
 (0)