From d3b8065e416a0c5d7c67596062df0b1303c77a8e Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Tue, 26 Nov 2024 09:16:55 +0100 Subject: [PATCH] fixup! Bluetooth: Controller: Fix ISO Tx PDU buffer counts for fragmentation Fix ISO Tx PDU buffer count required when SDUs fragmentation is used. Signed-off-by: Vinayak Kariappa Chettimada --- .../controller/ll_sw/ull_iso_internal.h | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/subsys/bluetooth/controller/ll_sw/ull_iso_internal.h b/subsys/bluetooth/controller/ll_sw/ull_iso_internal.h index 81a86e2083dd96a..b03c2567dbbbffe 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_iso_internal.h +++ b/subsys/bluetooth/controller/ll_sw/ull_iso_internal.h @@ -5,19 +5,30 @@ */ /* Calculate ISO PDU buffers required considering SDU fragmentation */ +#if defined(CONFIG_BT_CTLR_ADV_ISO) || defined(CONFIG_BT_CTLR_CONN_ISO) +#define BT_CTLR_ISO_SDU_LEN_MAX ((CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE * \ + CONFIG_BT_CTLR_ISO_TX_BUFFERS) - \ + BT_HCI_ISO_SDU_HDR_SIZE) #if defined(CONFIG_BT_CTLR_ADV_ISO) && defined(CONFIG_BT_CTLR_CONN_ISO) -#define BT_CTLR_ISO_TX_BUFFERS (DIV_ROUND_UP((CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE - 4U), \ - MIN(CONFIG_BT_CTLR_ADV_ISO_PDU_LEN_MAX, \ - CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX)) * \ +#define BT_CTLR_ISO_TX_BUFFERS (DIV_ROUND_UP(BT_CTLR_ISO_SDU_LEN_MAX, \ + MIN((CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE - \ + BT_HCI_ISO_SDU_HDR_SIZE), \ + MIN(CONFIG_BT_CTLR_ADV_ISO_PDU_LEN_MAX, \ + CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX))) * \ CONFIG_BT_CTLR_ISO_TX_BUFFERS) #elif defined(CONFIG_BT_CTLR_ADV_ISO) -#define BT_CTLR_ISO_TX_BUFFERS (DIV_ROUND_UP((CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE - 4U), \ - CONFIG_BT_CTLR_ADV_ISO_PDU_LEN_MAX) * \ +#define BT_CTLR_ISO_TX_BUFFERS (DIV_ROUND_UP(BT_CTLR_ISO_SDU_LEN_MAX, \ + MIN((CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE - \ + BT_HCI_ISO_SDU_HDR_SIZE), \ + CONFIG_BT_CTLR_ADV_ISO_PDU_LEN_MAX)) * \ CONFIG_BT_CTLR_ISO_TX_BUFFERS) -#elif defined(CONFIG_BT_CTLR_CONN_ISO) -#define BT_CTLR_ISO_TX_BUFFERS (DIV_ROUND_UP((CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE - 4U), \ - CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX) * \ +#else /* CONFIG_BT_CTLR_CONN_ISO */ +#define BT_CTLR_ISO_TX_BUFFERS (DIV_ROUND_UP(BT_CTLR_ISO_SDU_LEN_MAX, \ + MIN((CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE - \ + BT_HCI_ISO_SDU_HDR_SIZE), \ + CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX)) * \ CONFIG_BT_CTLR_ISO_TX_BUFFERS) +#endif /* CONFIG_BT_CTLR_CONN_ISO */ #else /* !CONFIG_BT_CTLR_ADV_ISO && !CONFIG_BT_CTLR_CONN_ISO */ #define BT_CTLR_ISO_TX_BUFFERS 0 #endif /* !CONFIG_BT_CTLR_ADV_ISO && !CONFIG_BT_CTLR_CONN_ISO */