From 14b4e30cdf62b8dda157986e4b2299e673125c72 Mon Sep 17 00:00:00 2001 From: Pavel Vasilyev Date: Tue, 29 Apr 2025 13:41:03 +0200 Subject: [PATCH] bluetooth: host: Deprecated BT_CONN_TX_MAX After https://github.com/zephyrproject-rtos/zephyr/pull/72090, `conn_tx_alloc` no longer blocks, and each buffer always has a corresponding `bt_conn_tx` object. This eliminates the need to configure the number of `bt_conn_tx` objects via `CONFIG_BT_CONN_TX_MAX`, since every buffer now carries its own context even when no callback is used. This commit deprecates `CONFIG_BT_CONN_TX_MAX` as it is no longer necessary. Instead, `CONFIG_BT_BUF_ACL_TX_COUNT` is used to allocate `bt_conn_tx` objects for outgoing ACL data. ZLL already uses `CONFIG_BT_BUF_ACL_TX_COUNT` to configure the number of outgoing ACL packets. With this change, modifying the packet count will automatically adjust the number of corresponding contexts, preventing both context starvatoin and underutilization. This approach also aligns with ISO, where the number of `bt_conn_tx` objects for outgoing ISOdata matches `CONFIG_BT_ISO_TX_BUF_COUNT`. Signed-off-by: Pavel Vasilyev --- doc/releases/release-notes-4.2.rst | 4 ++++ include/zephyr/bluetooth/gatt.h | 4 ---- subsys/bluetooth/host/Kconfig | 2 +- subsys/bluetooth/host/classic/Kconfig | 4 ++-- subsys/bluetooth/host/conn.c | 2 +- tests/bluetooth/host/conn/prj.conf | 1 - tests/bsim/bluetooth/host/l2cap/stress/prj.conf | 2 +- tests/bsim/bluetooth/host/misc/acl_tx_frag/prj.conf | 4 ---- 8 files changed, 9 insertions(+), 14 deletions(-) diff --git a/doc/releases/release-notes-4.2.rst b/doc/releases/release-notes-4.2.rst index d36c85ded1c..595d5ce3239 100644 --- a/doc/releases/release-notes-4.2.rst +++ b/doc/releases/release-notes-4.2.rst @@ -103,6 +103,10 @@ Deprecated APIs and options deprecated, because support for anonymous authentication had been removed from the hawkBit server in version 0.8.0. +* The :kconfig:option:`CONFIG_BT_CONN_TX_MAX` Kconfig option has been deprecated. The number of + pending TX buffers is now aligned with the :kconfig:option:`CONFIG_BT_BUF_ACL_TX_COUNT` Kconfig + option. + New APIs and options ==================== diff --git a/include/zephyr/bluetooth/gatt.h b/include/zephyr/bluetooth/gatt.h index e149ea577c7..3597c7c5fdb 100644 --- a/include/zephyr/bluetooth/gatt.h +++ b/include/zephyr/bluetooth/gatt.h @@ -1383,8 +1383,6 @@ struct bt_gatt_notify_params { * The callback is run from System Workqueue context. * When called from the System Workqueue context this API will not wait for * resources for the callback but instead return an error. - * The number of pending callbacks can be increased with the - * @kconfig{CONFIG_BT_CONN_TX_MAX} option. * * Alternatively it is possible to notify by UUID by setting it on the * parameters, when using this method the attribute if provided is used as the @@ -2078,8 +2076,6 @@ int bt_gatt_write(struct bt_conn *conn, struct bt_gatt_write_params *params); * The callback is run from System Workqueue context. * When called from the System Workqueue context this API will not wait for * resources for the callback but instead return an error. - * The number of pending callbacks can be increased with the - * @kconfig{CONFIG_BT_CONN_TX_MAX} option. * * @param conn Connection object. * @param handle Attribute handle. diff --git a/subsys/bluetooth/host/Kconfig b/subsys/bluetooth/host/Kconfig index ce15c5b7cc3..7611761bb45 100644 --- a/subsys/bluetooth/host/Kconfig +++ b/subsys/bluetooth/host/Kconfig @@ -325,7 +325,7 @@ config BT_CONN_FRAG_COUNT if BT_CONN config BT_CONN_TX_MAX - int "Maximum number of pending TX buffers with a callback" + int "Maximum number of pending TX buffers with a callback [DEPRECATED]" default BT_BUF_ACL_TX_COUNT range BT_BUF_ACL_TX_COUNT $(UINT8_MAX) help diff --git a/subsys/bluetooth/host/classic/Kconfig b/subsys/bluetooth/host/classic/Kconfig index 1fbf45f9099..3c76cb7f590 100644 --- a/subsys/bluetooth/host/classic/Kconfig +++ b/subsys/bluetooth/host/classic/Kconfig @@ -140,8 +140,8 @@ config BT_RFCOMM_L2CAP_MTU config BT_RFCOMM_TX_MAX int "Maximum number of pending TX buffers for RFCOMM" - default BT_CONN_TX_MAX - range BT_CONN_TX_MAX $(UINT8_MAX) + default BT_BUF_ACL_TX_COUNT + range BT_BUF_ACL_TX_COUNT $(UINT8_MAX) help Maximum number of pending TX buffers that have an associated sending buf. Normally this can be left to the default value, which diff --git a/subsys/bluetooth/host/conn.c b/subsys/bluetooth/host/conn.c index 510bdfa8a9d..2b12618cfb4 100644 --- a/subsys/bluetooth/host/conn.c +++ b/subsys/bluetooth/host/conn.c @@ -120,7 +120,7 @@ sys_slist_t bt_auth_info_cbs = SYS_SLIST_STATIC_INIT(&bt_auth_info_cbs); static sys_slist_t conn_cbs = SYS_SLIST_STATIC_INIT(&conn_cbs); -static struct bt_conn_tx conn_tx[CONFIG_BT_CONN_TX_MAX]; +static struct bt_conn_tx conn_tx[CONFIG_BT_BUF_ACL_TX_COUNT]; #if defined(CONFIG_BT_CLASSIC) static struct bt_conn sco_conns[CONFIG_BT_MAX_SCO_CONN]; diff --git a/tests/bluetooth/host/conn/prj.conf b/tests/bluetooth/host/conn/prj.conf index f63ccd0a939..eb8d5a0fdbf 100644 --- a/tests/bluetooth/host/conn/prj.conf +++ b/tests/bluetooth/host/conn/prj.conf @@ -12,7 +12,6 @@ CONFIG_BT_PER_ADV_SYNC=y CONFIG_BT_MAX_CONN=1 CONFIG_BT_L2CAP_TX_MTU=23 -CONFIG_BT_CONN_TX_MAX=3 CONFIG_BT_CONN_PARAM_UPDATE_TIMEOUT=5000 CONFIG_BT_L2CAP_TX_BUF_COUNT=3 CONFIG_BT_ID_MAX=1 diff --git a/tests/bsim/bluetooth/host/l2cap/stress/prj.conf b/tests/bsim/bluetooth/host/l2cap/stress/prj.conf index fecd8ba08d1..f984d840e3b 100644 --- a/tests/bsim/bluetooth/host/l2cap/stress/prj.conf +++ b/tests/bsim/bluetooth/host/l2cap/stress/prj.conf @@ -32,7 +32,7 @@ CONFIG_BT_BUF_ACL_TX_COUNT=4 # L2AP MPS + L2CAP header (4) CONFIG_BT_BUF_ACL_RX_SIZE=81 -# Governs BT_CONN_TX_MAX, and so must be >= than the max number of +# Governs CONFIG_BT_BUF_ACL_TX_COUNT, and so must be >= than the max number of # peers, since we attempt to send one SDU per peer. The test execution # is a bit slowed down by having this at the very minimum, but we want # to keep it that way as to stress the stack as much as possible. diff --git a/tests/bsim/bluetooth/host/misc/acl_tx_frag/prj.conf b/tests/bsim/bluetooth/host/misc/acl_tx_frag/prj.conf index 6bd02c8b645..a520656fcf4 100644 --- a/tests/bsim/bluetooth/host/misc/acl_tx_frag/prj.conf +++ b/tests/bsim/bluetooth/host/misc/acl_tx_frag/prj.conf @@ -26,10 +26,6 @@ CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n CONFIG_BT_MAX_CONN=1 -# We don't want to be constrained on the number of TX -# contexts, rather on the number of LL TX buffers. -CONFIG_BT_CONN_TX_MAX=10 - # Outgoing ATT buffers CONFIG_BT_ATT_TX_COUNT=1