1 /* 2 * Copyright (c) 2016-2021 Nordic Semiconductor ASA 3 * Copyright (c) 2016 Vinayak Kariappa Chettimada 4 * 5 * SPDX-License-Identifier: Apache-2.0 6 */ 7 8 #define LL_VERSION_NUMBER BT_HCI_VERSION_5_4 9 10 #if defined(CONFIG_BT_CTLR_LE_ENC) 11 #define LL_FEAT_BIT_ENC BIT64(BT_LE_FEAT_BIT_ENC) 12 #else /* !CONFIG_BT_CTLR_LE_ENC */ 13 #define LL_FEAT_BIT_ENC 0 14 #endif /* !CONFIG_BT_CTLR_LE_ENC */ 15 16 #if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ) 17 #define LL_FEAT_BIT_CONN_PARAM_REQ BIT64(BT_LE_FEAT_BIT_CONN_PARAM_REQ) 18 #else /* !CONFIG_BT_CTLR_CONN_PARAM_REQ */ 19 #define LL_FEAT_BIT_CONN_PARAM_REQ 0 20 #endif /* !CONFIG_BT_CTLR_CONN_PARAM_REQ */ 21 22 #if defined(CONFIG_BT_CTLR_EXT_REJ_IND) 23 #define LL_FEAT_BIT_EXT_REJ_IND BIT64(BT_LE_FEAT_BIT_EXT_REJ_IND) 24 #else /* !CONFIG_BT_CTLR_EXT_REJ_IND */ 25 #define LL_FEAT_BIT_EXT_REJ_IND 0 26 #endif /* !CONFIG_BT_CTLR_EXT_REJ_IND */ 27 28 #if defined(CONFIG_BT_CTLR_PER_INIT_FEAT_XCHG) 29 #define LL_FEAT_BIT_PER_INIT_FEAT_XCHG BIT64(BT_LE_FEAT_BIT_PER_INIT_FEAT_XCHG) 30 #else /* !CONFIG_BT_CTLR_PER_INIT_FEAT_XCHG */ 31 #define LL_FEAT_BIT_PER_INIT_FEAT_XCHG 0 32 #endif /* !CONFIG_BT_CTLR_PER_INIT_FEAT_XCHG */ 33 34 #if defined(CONFIG_BT_CTLR_LE_PING) 35 #define LL_FEAT_BIT_PING BIT64(BT_LE_FEAT_BIT_PING) 36 #else /* !CONFIG_BT_CTLR_LE_PING */ 37 #define LL_FEAT_BIT_PING 0 38 #endif /* !CONFIG_BT_CTLR_LE_PING */ 39 40 /* Maximum supported ACL Tx fragment size is limited by uint8_t len field in 41 * the PDU structure of the Controller implementation. 4 octets reserved for 42 * MIC in encrypted ACL PDUs, hence ACL Tx fragment maximum size of 251 octets. 43 */ 44 #define LL_LENGTH_OCTETS_TX_MAX MIN(CONFIG_BT_BUF_ACL_TX_SIZE, 251U) 45 46 #if defined(CONFIG_BT_CTLR_DATA_LENGTH_MAX) 47 #define LL_FEAT_BIT_DLE BIT64(BT_LE_FEAT_BIT_DLE) 48 #define LL_LENGTH_OCTETS_RX_MAX CONFIG_BT_CTLR_DATA_LENGTH_MAX 49 #else 50 #define LL_FEAT_BIT_DLE 0 51 #define LL_LENGTH_OCTETS_RX_MAX 27 52 #endif /* CONFIG_BT_CTLR_DATA_LENGTH_MAX */ 53 54 #if defined(CONFIG_BT_CTLR_PRIVACY) 55 #define LL_FEAT_BIT_PRIVACY BIT64(BT_LE_FEAT_BIT_PRIVACY) 56 #else /* !CONFIG_BT_CTLR_PRIVACY */ 57 #define LL_FEAT_BIT_PRIVACY 0 58 #endif /* !CONFIG_BT_CTLR_PRIVACY */ 59 60 #if defined(CONFIG_BT_CTLR_EXT_SCAN_FP) 61 #define LL_FEAT_BIT_EXT_SCAN BIT64(BT_LE_FEAT_BIT_EXT_SCAN) 62 #else /* !CONFIG_BT_CTLR_EXT_SCAN_FP */ 63 #define LL_FEAT_BIT_EXT_SCAN 0 64 #endif /* !CONFIG_BT_CTLR_EXT_SCAN_FP */ 65 66 #if defined(CONFIG_BT_CTLR_PHY_2M) 67 #define LL_FEAT_BIT_PHY_2M BIT64(BT_LE_FEAT_BIT_PHY_2M) 68 #else /* !CONFIG_BT_CTLR_PHY_2M */ 69 #define LL_FEAT_BIT_PHY_2M 0 70 #endif /* !CONFIG_BT_CTLR_PHY_2M */ 71 72 #if defined(CONFIG_BT_CTLR_SMI_TX) 73 #if defined(CONFIG_BT_CTLR_SMI_TX_SETTING) 74 #define LL_FEAT_BIT_SMI_TX (ll_settings_smi_tx() ? \ 75 BIT64(BT_LE_FEAT_BIT_SMI_TX) : 0) 76 #else /* !CONFIG_BT_CTLR_SMI_TX_SETTING */ 77 #define LL_FEAT_BIT_SMI_TX BIT64(BT_LE_FEAT_BIT_SMI_TX) 78 #endif /* !CONFIG_BT_CTLR_SMI_TX_SETTING */ 79 #else /* !CONFIG_BT_CTLR_SMI_TX */ 80 #define LL_FEAT_BIT_SMI_TX 0 81 #endif /* !CONFIG_BT_CTLR_SMI_TX */ 82 83 #if defined(CONFIG_BT_CTLR_SMI_RX) 84 #define LL_FEAT_BIT_SMI_RX BIT64(BT_LE_FEAT_BIT_SMI_RX) 85 #else /* !CONFIG_BT_CTLR_SMI_RX */ 86 #define LL_FEAT_BIT_SMI_RX 0 87 #endif /* !CONFIG_BT_CTLR_SMI_RX */ 88 89 #if defined(CONFIG_BT_CTLR_PHY_CODED) 90 #define LL_FEAT_BIT_PHY_CODED BIT64(BT_LE_FEAT_BIT_PHY_CODED) 91 #else /* !CONFIG_BT_CTLR_PHY_CODED */ 92 #define LL_FEAT_BIT_PHY_CODED 0 93 #endif /* !CONFIG_BT_CTLR_PHY_CODED */ 94 95 #if defined(CONFIG_BT_CTLR_ADV_EXT) 96 #define LL_FEAT_BIT_EXT_ADV BIT64(BT_LE_FEAT_BIT_EXT_ADV) 97 #if defined(CONFIG_BT_OBSERVER) 98 #define LL_EXT_OCTETS_RX_MAX CONFIG_BT_CTLR_ADV_EXT_RX_PDU_LEN_MAX 99 #else /* !CONFIG_BT_OBSERVER */ 100 #define LL_EXT_OCTETS_RX_MAX 0 101 #endif /* !CONFIG_BT_OBSERVER */ 102 #else /* !CONFIG_BT_CTLR_ADV_EXT */ 103 #define LL_FEAT_BIT_EXT_ADV 0 104 #define LL_EXT_OCTETS_RX_MAX 0 105 #endif /* !CONFIG_BT_CTLR_ADV_EXT */ 106 107 #if defined(CONFIG_BT_CTLR_ADV_PERIODIC) || \ 108 defined(CONFIG_BT_CTLR_SYNC_PERIODIC) 109 #define LL_FEAT_BIT_PER_ADV BIT64(BT_LE_FEAT_BIT_PER_ADV) 110 #else /* !CONFIG_BT_CTLR_ADV_PERIODIC && !CONFIG_BT_CTLR_SYNC_PERIODIC */ 111 #define LL_FEAT_BIT_PER_ADV 0 112 #endif /* !CONFIG_BT_CTLR_ADV_PERIODIC && !CONFIG_BT_CTLR_SYNC_PERIODIC */ 113 114 #if defined(CONFIG_BT_CTLR_CHAN_SEL_2) 115 #define LL_FEAT_BIT_CHAN_SEL_2 BIT64(BT_LE_FEAT_BIT_CHAN_SEL_ALGO_2) 116 #else /* !CONFIG_BT_CTLR_CHAN_SEL_2 */ 117 #define LL_FEAT_BIT_CHAN_SEL_2 0 118 #endif /* !CONFIG_BT_CTLR_CHAN_SEL_2 */ 119 120 #if defined(CONFIG_BT_CTLR_MIN_USED_CHAN) 121 #define LL_FEAT_BIT_MIN_USED_CHAN \ 122 BIT64(BT_LE_FEAT_BIT_MIN_USED_CHAN_PROC) 123 #else /* !CONFIG_BT_CTLR_MIN_USED_CHAN */ 124 #define LL_FEAT_BIT_MIN_USED_CHAN 0 125 #endif /* !CONFIG_BT_CTLR_MIN_USED_CHAN */ 126 127 #if defined(CONFIG_BT_CTLR_DF) && defined(CONFIG_BT_CTLR_DF_CONN_CTE_REQ) 128 #define LL_FEAT_BIT_CONNECTION_CTE_REQ BIT64(BT_LE_FEAT_BIT_CONN_CTE_REQ) 129 #else /* !CONFIG_BT_CTLR_DF && !CONFIG_BT_CTLR_DF_CONN_CTE_REQ */ 130 #define LL_FEAT_BIT_CONNECTION_CTE_REQ 0 131 #endif /* !CONFIG_BT_CTLR_DF && !CONFIG_BT_CTLR_DF_CONN_CTE_REQ */ 132 133 #if defined(CONFIG_BT_CTLR_DF) && defined(CONFIG_BT_CTLR_DF_CONN_CTE_RSP) 134 #define LL_FEAT_BIT_CONNECTION_CTE_RESP BIT64(BT_LE_FEAT_BIT_CONN_CTE_RESP) 135 #else /* !CONFIG_BT_CTLR_DF && !CONFIG_BT_CTLR_DF_CONN_CTE_RSP */ 136 #define LL_FEAT_BIT_CONNECTION_CTE_RESP 0 137 #endif /* !CONFIG_BT_CTLR_DF && !CONFIG_BT_CTLR_DF_CONN_CTE_RSP */ 138 139 140 #if defined(CONFIG_BT_CTLR_DF) && defined(CONFIG_BT_CTLR_DF_ADV_CTE_TX) 141 #define LL_FEAT_BIT_CONNECTIONLESS_CTE_TX \ 142 BIT64(BT_LE_FEAT_BIT_CONNECTIONLESS_CTE_TX) 143 #else /* !CONFIG_BT_CTLR_DF && !CONFIG_BT_CTLR_DF_ADV_CTE_TX */ 144 #define LL_FEAT_BIT_CONNECTIONLESS_CTE_TX 0 145 #endif /* !CONFIG_BT_CTLR_DF && !CONFIG_BT_CTLR_DF_ADV_CTE_TX */ 146 147 #if defined(CONFIG_BT_CTLR_DF) && defined(CONFIG_BT_CTLR_DF_SCAN_CTE_RX) 148 #define LL_FEAT_BIT_CONNECTIONLESS_CTE_RX \ 149 BIT64(BT_LE_FEAT_BIT_CONNECTIONLESS_CTE_RX) 150 #else /* !CONFIG_BT_CTLR_DF && !CONFIG_BT_CTLR_DF_SCAN_CTE_RX */ 151 #define LL_FEAT_BIT_CONNECTIONLESS_CTE_RX 0 152 #endif /* !CONFIG_BT_CTLR_DF && !CONFIG_BT_CTLR_DF_SCAN_CTE_RX */ 153 154 #if defined(CONFIG_BT_CTLR_DF) && defined(CONFIG_BT_CTLR_DF_ANT_SWITCH_TX) 155 #define LL_FEAT_BIT_ANT_SWITCH_TX_AOD \ 156 BIT64(BT_LE_FEAT_BIT_ANT_SWITCH_TX_AOD) 157 #else /* !CONFIG_BT_CTLR_DF && !CONFIG_BT_CTLR_DF_ANT_SWITCH_TX */ 158 #define LL_FEAT_BIT_ANT_SWITCH_TX_AOD 0 159 #endif /* !CONFIG_BT_CTLR_DF && !CONFIG_BT_CTLR_DF_ANT_SWITCH_TX */ 160 161 #if defined(CONFIG_BT_CTLR_DF) && defined(CONFIG_BT_CTLR_DF_ANT_SWITCH_RX) 162 #define LL_FEAT_BIT_ANT_SWITCH_RX_AOA \ 163 BIT64(BT_LE_FEAT_BIT_ANT_SWITCH_RX_AOA) 164 #else /* !CONFIG_BT_CTLR_DF && !CONFIG_BT_CTLR_DF_ANT_SWITCH_RX */ 165 #define LL_FEAT_BIT_ANT_SWITCH_RX_AOA 0 166 #endif /* !CONFIG_BT_CTLR_DF && !CONFIG_BT_CTLR_DF_ANT_SWITCH_RX */ 167 168 #if defined(CONFIG_BT_CTLR_DF) && defined(CONFIG_BT_CTLR_DF_CTE_RX) 169 #define LL_FEAT_BIT_RX_CTE BIT64(BT_LE_FEAT_BIT_RX_CTE) 170 #else /* !CONFIG_BT_CTLR_DF && !CONFIG_BT_CTLR_DF_CTE_RX */ 171 #define LL_FEAT_BIT_RX_CTE 0 172 #endif /* !CONFIG_BT_CTLR_DF && !CONFIG_BT_CTLR_DF_CTE_RX */ 173 174 #if defined(CONFIG_BT_CTLR_SCA_UPDATE) 175 #define LL_FEAT_BIT_SCA_UPDATE BIT64(BT_LE_FEAT_BIT_SCA_UPDATE) 176 #else /* !CONFIG_BT_CTLR_SCA_UPDATE */ 177 #define LL_FEAT_BIT_SCA_UPDATE 0 178 #endif /* !CONFIG_BT_CTLR_SCA_UPDATE */ 179 180 #if defined(CONFIG_BT_CTLR_SYNC_TRANSFER_SENDER) 181 #define LL_FEAT_BIT_SYNC_TRANSFER_SENDER BIT64(BT_LE_FEAT_BIT_PAST_SEND) 182 #else /* !CONFIG_BT_CTLR_SYNC_TRANSFER_SENDER */ 183 #define LL_FEAT_BIT_SYNC_TRANSFER_SENDER 0 184 #endif /* !CONFIG_BT_CTLR_SYNC_TRANSFER_SENDER */ 185 186 #if defined(CONFIG_BT_CTLR_SYNC_TRANSFER_RECEIVER) 187 #define LL_FEAT_BIT_SYNC_TRANSFER_RECEIVER BIT64(BT_LE_FEAT_BIT_PAST_RECV) 188 #else /* !CONFIG_BT_CTLR_SYNC_TRANSFER_RECEIVER */ 189 #define LL_FEAT_BIT_SYNC_TRANSFER_RECEIVER 0 190 #endif /* !CONFIG_BT_CTLR_SYNC_TRANSFER_RECEIVER */ 191 192 #if defined(CONFIG_BT_CTLR_CENTRAL_ISO) 193 #define LL_FEAT_BIT_CIS_CENTRAL BIT64(BT_LE_FEAT_BIT_CIS_CENTRAL) 194 #else /* !CONFIG_BT_CTLR_CENTRAL_ISO */ 195 #define LL_FEAT_BIT_CIS_CENTRAL 0 196 #endif /* !CONFIG_BT_CTLR_CENTRAL_ISO */ 197 198 #if defined(CONFIG_BT_CTLR_PERIPHERAL_ISO) 199 #define LL_FEAT_BIT_CIS_PERIPHERAL BIT64(BT_LE_FEAT_BIT_CIS_PERIPHERAL) 200 #else /* !CONFIG_BT_CTLR_PERIPHERAL_ISO */ 201 #define LL_FEAT_BIT_CIS_PERIPHERAL 0 202 #endif /* !CONFIG_BT_CTLR_PERIPHERAL_ISO */ 203 204 #if defined(CONFIG_BT_CTLR_ADV_ISO) || defined(CONFIG_BT_CTLR_CONN_ISO) 205 #if defined(CONFIG_BT_ISO_TX_MTU) 206 #define BT_CTLR_ISO_TX_BUFFER_SIZE MIN((CONFIG_BT_ISO_TX_MTU + \ 207 BT_HCI_ISO_SDU_TS_HDR_SIZE), \ 208 MAX(CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE, \ 209 (BT_HCI_ISO_SDU_TS_HDR_SIZE + 1U))) 210 #else 211 #define BT_CTLR_ISO_TX_BUFFER_SIZE MAX(CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE, \ 212 (BT_HCI_ISO_SDU_TS_HDR_SIZE + 1U)) 213 #endif /* CONFIG_BT_ISO_TX_MTU */ 214 #endif /* CONFIG_BT_CTLR_ADV_ISO || CONFIG_BT_CTLR_CONN_ISO */ 215 216 #if defined(CONFIG_BT_CTLR_CENTRAL_ISO) || \ 217 defined(CONFIG_BT_CTLR_PERIPHERAL_ISO) 218 #define LL_CIS_OCTETS_TX_MAX MIN(CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX, \ 219 (BT_CTLR_ISO_TX_BUFFER_SIZE - \ 220 BT_HCI_ISO_SDU_TS_HDR_SIZE)) 221 #define LL_CIS_OCTETS_RX_MAX CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX 222 #else /* !CONFIG_BT_CTLR_CENTRAL_ISO && !CONFIG_BT_CTLR_PERIPHERAL_ISO */ 223 #define LL_CIS_OCTETS_TX_MAX 0 224 #define LL_CIS_OCTETS_RX_MAX 0 225 #endif /* !CONFIG_BT_CTLR_CENTRAL_ISO && !CONFIG_BT_CTLR_PERIPHERAL_ISO */ 226 227 #if defined(CONFIG_BT_CTLR_ADV_ISO) 228 #define LL_FEAT_BIT_ISO_BROADCASTER BIT64(BT_LE_FEAT_BIT_ISO_BROADCASTER) 229 #define LL_BIS_OCTETS_TX_MAX MIN(CONFIG_BT_CTLR_ADV_ISO_PDU_LEN_MAX, \ 230 (BT_CTLR_ISO_TX_BUFFER_SIZE - \ 231 BT_HCI_ISO_SDU_TS_HDR_SIZE)) 232 #else /* !CONFIG_BT_CTLR_ADV_ISO */ 233 #define LL_FEAT_BIT_ISO_BROADCASTER 0 234 #define LL_BIS_OCTETS_TX_MAX 0 235 #endif /* !CONFIG_BT_CTLR_ADV_ISO */ 236 237 #if defined(CONFIG_BT_CTLR_SYNC_ISO) 238 #define LL_FEAT_BIT_SYNC_RECEIVER BIT64(BT_LE_FEAT_BIT_SYNC_RECEIVER) 239 #define LL_BIS_OCTETS_RX_MAX CONFIG_BT_CTLR_SYNC_ISO_PDU_LEN_MAX 240 #else /* !CONFIG_BT_CTLR_SYNC_ISO */ 241 #define LL_FEAT_BIT_SYNC_RECEIVER 0 242 #define LL_BIS_OCTETS_RX_MAX 0 243 #endif /* !CONFIG_BT_CTLR_SYNC_ISO */ 244 245 #if defined(CONFIG_BT_CTLR_ADV_PERIODIC_ADI_SUPPORT) || \ 246 defined(CONFIG_BT_CTLR_SYNC_PERIODIC_ADI_SUPPORT) 247 #define LL_FEAT_BIT_PERIODIC_ADI_SUPPORT BIT64(BT_LE_FEAT_BIT_PER_ADV_ADI_SUPP) 248 #else /* !CONFIG_BT_CTLR_ADV_PERIODIC_ADI_SUPPORT && 249 * !CONFIG_BT_CTLR_SYNC_PERIODIC_ADI_SUPPORT 250 */ 251 #define LL_FEAT_BIT_PERIODIC_ADI_SUPPORT 0U 252 #endif /* !CONFIG_BT_CTLR_ADV_PERIODIC_ADI_SUPPORT && 253 * !CONFIG_BT_CTLR_SYNC_PERIODIC_ADI_SUPPORT 254 */ 255 256 /* All defined feature bits */ 257 #define LL_FEAT_BIT_MASK 0xFFFFFFFFFFULL 258 259 /* 260 * LL_FEAT_BIT_MASK_VALID is defined as per 261 * Core Spec V5.3 Volume 6, Part B, chapter 4.6 262 */ 263 #define LL_FEAT_BIT_MASK_VALID 0xEFF787CF2FULL 264 265 /* Mask to filter away octet 0 for feature exchange */ 266 #define LL_FEAT_FILTER_OCTET0 (LL_FEAT_BIT_MASK & ~0xFFULL) 267 268 /* Feature bits of this controller */ 269 #define LL_FEAT (LL_FEAT_BIT_ENC | \ 270 LL_FEAT_BIT_CONN_PARAM_REQ | \ 271 LL_FEAT_BIT_EXT_REJ_IND | \ 272 LL_FEAT_BIT_PER_INIT_FEAT_XCHG | \ 273 LL_FEAT_BIT_PING | \ 274 LL_FEAT_BIT_DLE | \ 275 LL_FEAT_BIT_PRIVACY | \ 276 LL_FEAT_BIT_EXT_SCAN | \ 277 LL_FEAT_BIT_PHY_2M | \ 278 LL_FEAT_BIT_SMI_TX | \ 279 LL_FEAT_BIT_SMI_RX | \ 280 LL_FEAT_BIT_PHY_CODED | \ 281 LL_FEAT_BIT_EXT_ADV | \ 282 LL_FEAT_BIT_PER_ADV | \ 283 LL_FEAT_BIT_CONNECTION_CTE_REQ | \ 284 LL_FEAT_BIT_CONNECTION_CTE_RESP | \ 285 LL_FEAT_BIT_CONNECTIONLESS_CTE_TX | \ 286 LL_FEAT_BIT_CONNECTIONLESS_CTE_RX | \ 287 LL_FEAT_BIT_ANT_SWITCH_TX_AOD | \ 288 LL_FEAT_BIT_ANT_SWITCH_RX_AOA | \ 289 LL_FEAT_BIT_RX_CTE | \ 290 LL_FEAT_BIT_SCA_UPDATE | \ 291 LL_FEAT_BIT_CHAN_SEL_2 | \ 292 LL_FEAT_BIT_MIN_USED_CHAN | \ 293 LL_FEAT_BIT_CIS_CENTRAL | \ 294 LL_FEAT_BIT_CIS_PERIPHERAL | \ 295 LL_FEAT_BIT_ISO_BROADCASTER | \ 296 LL_FEAT_BIT_SYNC_RECEIVER | \ 297 LL_FEAT_BIT_PERIODIC_ADI_SUPPORT | \ 298 LL_FEAT_BIT_SYNC_TRANSFER_RECEIVER | \ 299 LL_FEAT_BIT_SYNC_TRANSFER_SENDER) 300 301 /* Connected Isochronous Stream (Host Support) bit is controlled by host */ 302 #if defined(CONFIG_BT_CTLR_CONN_ISO) 303 #define LL_FEAT_HOST_BITS_ISO_CHANNELS BIT64(BT_LE_FEAT_BIT_ISO_CHANNELS) 304 #else /* !CONFIG_BT_CTLR_CONN_ISO */ 305 #define LL_FEAT_HOST_BITS_ISO_CHANNELS 0U 306 #endif /* !CONFIG_BT_CTLR_CONN_ISO */ 307 308 /* Connection subrating not supported and bit thus cannot be set by host */ 309 #define LL_FEAT_HOST_BITS_CONN_SUBRATING 0U 310 311 /* Mask for host controlled features */ 312 #define LL_FEAT_HOST_BIT_MASK (LL_FEAT_HOST_BITS_ISO_CHANNELS |\ 313 LL_FEAT_HOST_BITS_CONN_SUBRATING) 314