Bluetooth: Iso: Add BT_ISO_SDU_BUF_SIZE macro

Add the BT_ISO_SDU_BUF_SIZE which can be used to declare
the TX buffers for ISO, similar to the BT_L2CAP_SDU_BUF_SIZE
macro for L2CAP.

This also updates the ISO samples to use this as well
updating the SDU check to use
CONFIG_BT_ISO_TX_MTU/CONFIG_BT_ISO_RX_MTU without
subtracting the BT_ISO_CHAN_SEND_RESERVE to make the
API more clear.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2021-09-16 15:48:29 +02:00 committed by Christopher Friedt
commit 5a11a19713
10 changed files with 47 additions and 28 deletions

View file

@ -68,6 +68,11 @@ struct bt_buf_data {
/** Helper to calculate needed buffer size for HCI Command packets. */
#define BT_BUF_CMD_SIZE(size) BT_BUF_SIZE(BT_HCI_CMD_HDR_SIZE + (size))
/** Helper to calculate needed buffer size for HCI ISO packets. */
#define BT_BUF_ISO_SIZE(size) BT_BUF_SIZE(BT_HCI_ISO_HDR_SIZE + \
BT_HCI_ISO_DATA_HDR_SIZE + \
(size))
/** Data size needed for HCI ACL RX buffers */
#define BT_BUF_ACL_RX_SIZE BT_BUF_ACL_SIZE(CONFIG_BT_BUF_ACL_RX_SIZE)

View file

@ -28,11 +28,20 @@ extern "C" {
#include <bluetooth/hci.h>
/** @def BT_ISO_CHAN_SEND_RESERVE
* @brief Headroom needed for outgoing buffers
* @brief Headroom needed for outgoing ISO SDUs
*/
#define BT_ISO_CHAN_SEND_RESERVE (CONFIG_BT_HCI_RESERVE + \
BT_HCI_ISO_HDR_SIZE + \
BT_HCI_ISO_DATA_HDR_SIZE)
#define BT_ISO_CHAN_SEND_RESERVE BT_BUF_ISO_SIZE(0)
/** @def BT_ISO_SDU_BUF_SIZE
*
* @brief Helper to calculate needed buffer size for ISO SDUs.
* Useful for creating buffer pools.
*
* @param mtu Required ISO SDU size
*
* @return Needed buffer size to match the requested ISO SDU MTU.
*/
#define BT_ISO_SDU_BUF_SIZE(mtu) BT_BUF_ISO_SIZE(mtu)
/** Value to set the ISO data path over HCi. */
#define BT_ISO_DATA_PATH_HCI 0x00