1 /* 2 * Copyright (c) 2021 Demant 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /* BIS Broadcaster */ 8 #if defined(CONFIG_BT_CTLR_ADV_ISO) 9 #define LL_BIS_ADV_HANDLE_BASE BT_CTLR_ADV_ISO_STREAM_HANDLE_BASE 10 #define LL_BIS_ADV_IDX_FROM_HANDLE(conn_handle) \ 11 ((conn_handle) - (LL_BIS_ADV_HANDLE_BASE)) 12 /* Conditional compile to prevent coverity issue CWE570, comparison of unsigned int to 0 */ 13 #if (LL_BIS_ADV_HANDLE_BASE > 0) 14 #define IS_ADV_ISO_HANDLE(conn_handle) \ 15 (((conn_handle) >= (LL_BIS_ADV_HANDLE_BASE)) && \ 16 ((conn_handle) <= ((LL_BIS_ADV_HANDLE_BASE) + \ 17 (BT_CTLR_ADV_ISO_STREAM_MAX) - 1U))) 18 #else 19 #define IS_ADV_ISO_HANDLE(conn_handle) \ 20 ((conn_handle) <= ((LL_BIS_ADV_HANDLE_BASE) + \ 21 (BT_CTLR_ADV_ISO_STREAM_MAX) - 1U)) 22 #endif /* LL_BIS_ADV_HANDLE_BASE */ 23 #else 24 #define LL_BIS_ADV_IDX_FROM_HANDLE(conn_handle) 0U 25 #define IS_ADV_ISO_HANDLE(conn_handle) 0U 26 #endif /* CONFIG_BT_CTLR_ADV_ISO */ 27 28 /* BIS Synchronized Receiver */ 29 #if defined(CONFIG_BT_CTLR_SYNC_ISO) 30 #define LL_BIS_SYNC_HANDLE_BASE BT_CTLR_SYNC_ISO_STREAM_HANDLE_BASE 31 #define LL_BIS_SYNC_IDX_FROM_HANDLE(conn_handle) \ 32 ((conn_handle) - (LL_BIS_SYNC_HANDLE_BASE)) 33 /* Conditional compile to prevent coverity issue CWE570, comparison of unsigned int to 0 */ 34 #if (LL_BIS_SYNC_HANDLE_BASE > 0) 35 #define IS_SYNC_ISO_HANDLE(conn_handle) \ 36 (((conn_handle) >= (LL_BIS_SYNC_HANDLE_BASE)) && \ 37 ((conn_handle) <= ((LL_BIS_SYNC_HANDLE_BASE) + \ 38 (BT_CTLR_SYNC_ISO_STREAM_MAX) - 1U))) 39 #else 40 #define IS_SYNC_ISO_HANDLE(conn_handle) \ 41 ((conn_handle) <= ((LL_BIS_SYNC_HANDLE_BASE) + \ 42 (BT_CTLR_SYNC_ISO_STREAM_MAX) - 1U)) 43 #endif /* LL_BIS_SYNC_HANDLE_BASE */ 44 #else 45 #define LL_BIS_SYNC_IDX_FROM_HANDLE(conn_handle) 0U 46 #define IS_SYNC_ISO_HANDLE(conn_handle) 0U 47 #endif /* CONFIG_BT_CTLR_SYNC_ISO */ 48 49 /* CIS */ 50 #if defined(CONFIG_BT_CTLR_CONN_ISO) 51 #define LL_CIS_HANDLE_LAST \ 52 (CONFIG_BT_CTLR_CONN_ISO_STREAMS + LL_CIS_HANDLE_BASE - 1) 53 #define IS_CIS_HANDLE(_handle) \ 54 (((_handle) >= LL_CIS_HANDLE_BASE) && \ 55 ((_handle) <= LL_CIS_HANDLE_LAST)) 56 #else 57 #define IS_CIS_HANDLE(_handle) 0 58 #endif /* CONFIG_BT_CTLR_CONN_ISO */ 59 60 struct ll_iso_tx_test_mode { 61 uint64_t sdu_counter:53; /* 39 + 22 - 8 */ 62 uint64_t enabled:1; 63 uint64_t payload_type:4; /* Support up to 16 payload types (BT 5.3: 3, VS: 13) */ 64 }; 65 66 struct ll_iso_rx_test_mode { 67 uint32_t received_cnt; 68 uint32_t missed_cnt; 69 uint32_t failed_cnt; 70 uint32_t sdu_counter; 71 uint8_t enabled:1; 72 uint8_t payload_type:4; /* Support up to 16 payload types (BT 5.3: 3, VS: 13) */ 73 }; 74 75 struct ll_iso_test_mode_data { 76 struct ll_iso_rx_test_mode rx; 77 struct ll_iso_tx_test_mode tx; 78 }; 79 80 struct ll_iso_link_quality { 81 uint32_t tx_unacked_packets; 82 uint32_t tx_flushed_packets; 83 uint32_t tx_last_subevent_packets; 84 uint32_t retransmitted_packets; 85 uint32_t crc_error_packets; 86 uint32_t rx_unreceived_packets; 87 uint32_t duplicate_packets; 88 }; 89 90 /* Common members for ll_conn_iso_stream and ll_broadcast_iso_stream */ 91 struct ll_iso_stream_hdr { 92 struct ll_iso_test_mode_data test_mode; 93 struct ll_iso_datapath *datapath_in; 94 struct ll_iso_datapath *datapath_out; 95 #if defined(CONFIG_BT_CTLR_READ_ISO_LINK_QUALITY) 96 struct ll_iso_link_quality link_quality; 97 #endif /* CONFIG_BT_CTLR_READ_ISO_LINK_QUALITY */ 98 }; 99 100 101 struct ll_iso_datapath { 102 uint8_t path_dir; 103 uint8_t path_id; 104 uint8_t coding_format; 105 uint16_t company_id; 106 isoal_sink_handle_t sink_hdl; 107 isoal_source_handle_t source_hdl; 108 }; 109