From 815dd27d8cdb11602c5a72cbde4e312fd8d90147 Mon Sep 17 00:00:00 2001 From: Emil Gydesen Date: Wed, 8 Dec 2021 15:36:57 +0100 Subject: [PATCH] Bluetooth: buf: Update BT_BUF_RX_SIZE with ISO The BT_BUF_RX_SIZE did not take the CONFIG_BT_ISO_RX_MTU into account. Add BT_BUF_ISO_RX_SIZE which depend on CONFIG_BT_ISO and use that for the BT_BUF_RX_SIZE macro. Furthermore, move the BT_BUF_RX_COUNT macro definitions into buf.h and update that to account for ISO RX as well. Signed-off-by: Emil Gydesen --- include/bluetooth/buf.h | 18 ++++++++++++++++-- subsys/bluetooth/host/buf.c | 1 - subsys/bluetooth/host/hci_raw.c | 1 - 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/include/bluetooth/buf.h b/include/bluetooth/buf.h index 9f0910a6554..03855daf6b3 100644 --- a/include/bluetooth/buf.h +++ b/include/bluetooth/buf.h @@ -79,8 +79,22 @@ struct bt_buf_data { /** Data size needed for HCI Event RX buffers */ #define BT_BUF_EVT_RX_SIZE BT_BUF_EVT_SIZE(CONFIG_BT_BUF_EVT_RX_SIZE) -/** Data size needed for HCI ACL or Event RX buffers */ -#define BT_BUF_RX_SIZE (MAX(BT_BUF_ACL_RX_SIZE, BT_BUF_EVT_RX_SIZE)) +#if defined(CONFIG_BT_ISO) +#define BT_BUF_ISO_RX_SIZE BT_BUF_ISO_SIZE(CONFIG_BT_ISO_RX_MTU) +#define BT_BUF_ISO_RX_COUNT CONFIG_BT_ISO_RX_BUF_COUNT +#else +#define BT_BUF_ISO_RX_SIZE 0 +#define BT_BUF_ISO_RX_COUNT 0 +#endif /* CONFIG_BT_ISO */ + +/** 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)) /** Data size needed for HCI Command buffers. */ #define BT_BUF_CMD_TX_SIZE BT_BUF_CMD_SIZE(CONFIG_BT_BUF_CMD_TX_SIZE) diff --git a/subsys/bluetooth/host/buf.c b/subsys/bluetooth/host/buf.c index 8171502d2fb..159a60065c2 100644 --- a/subsys/bluetooth/host/buf.c +++ b/subsys/bluetooth/host/buf.c @@ -53,7 +53,6 @@ NET_BUF_POOL_FIXED_DEFINE(evt_pool, CONFIG_BT_BUF_EVT_RX_COUNT, BT_BUF_EVT_RX_SIZE, 8, NULL); #else -#define BT_BUF_RX_COUNT MAX(CONFIG_BT_BUF_EVT_RX_COUNT, CONFIG_BT_BUF_ACL_RX_COUNT) NET_BUF_POOL_FIXED_DEFINE(hci_rx_pool, BT_BUF_RX_COUNT, BT_BUF_RX_SIZE, 8, NULL); diff --git a/subsys/bluetooth/host/hci_raw.c b/subsys/bluetooth/host/hci_raw.c index 7036e23cd01..e3d765bed02 100644 --- a/subsys/bluetooth/host/hci_raw.c +++ b/subsys/bluetooth/host/hci_raw.c @@ -38,7 +38,6 @@ static uint8_t raw_mode = BT_HCI_RAW_MODE_H4; static uint8_t raw_mode; #endif -#define BT_BUF_RX_COUNT MAX(CONFIG_BT_BUF_EVT_RX_COUNT, CONFIG_BT_BUF_ACL_RX_COUNT) NET_BUF_POOL_FIXED_DEFINE(hci_rx_pool, BT_BUF_RX_COUNT, BT_BUF_RX_SIZE, 8, NULL); NET_BUF_POOL_FIXED_DEFINE(hci_cmd_pool, CONFIG_BT_BUF_CMD_TX_COUNT,