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_CENTRAL_ISO) 181 #define LL_FEAT_BIT_CIS_CENTRAL BIT64(BT_LE_FEAT_BIT_CIS_CENTRAL) 182 #else /* !CONFIG_BT_CTLR_CENTRAL_ISO */ 183 #define LL_FEAT_BIT_CIS_CENTRAL 0 184 #endif /* !CONFIG_BT_CTLR_CENTRAL_ISO */ 185 186 #if defined(CONFIG_BT_CTLR_PERIPHERAL_ISO) 187 #define LL_FEAT_BIT_CIS_PERIPHERAL BIT64(BT_LE_FEAT_BIT_CIS_PERIPHERAL) 188 #else /* !CONFIG_BT_CTLR_PERIPHERAL_ISO */ 189 #define LL_FEAT_BIT_CIS_PERIPHERAL 0 190 #endif /* !CONFIG_BT_CTLR_PERIPHERAL_ISO */ 191 192 #if defined(CONFIG_BT_CTLR_ADV_ISO) || defined(CONFIG_BT_CTLR_CONN_ISO) 193 #if defined(CONFIG_BT_ISO_TX_MTU) 194 #define BT_CTLR_ISO_TX_BUFFER_SIZE MIN((CONFIG_BT_ISO_TX_MTU + \ 195 BT_HCI_ISO_SDU_TS_HDR_SIZE), \ 196 MAX(CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE, \ 197 (BT_HCI_ISO_SDU_TS_HDR_SIZE + 1U))) 198 #else 199 #define BT_CTLR_ISO_TX_BUFFER_SIZE MAX(CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE, \ 200 (BT_HCI_ISO_SDU_TS_HDR_SIZE + 1U)) 201 #endif /* CONFIG_BT_ISO_TX_MTU */ 202 #endif /* CONFIG_BT_CTLR_ADV_ISO || CONFIG_BT_CTLR_CONN_ISO */ 203 204 #if defined(CONFIG_BT_CTLR_CENTRAL_ISO) || \ 205 defined(CONFIG_BT_CTLR_PERIPHERAL_ISO) 206 #define LL_CIS_OCTETS_TX_MAX MIN(CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX, \ 207 (BT_CTLR_ISO_TX_BUFFER_SIZE - \ 208 BT_HCI_ISO_SDU_TS_HDR_SIZE)) 209 #define LL_CIS_OCTETS_RX_MAX CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX 210 #else /* !CONFIG_BT_CTLR_CENTRAL_ISO && !CONFIG_BT_CTLR_PERIPHERAL_ISO */ 211 #define LL_CIS_OCTETS_TX_MAX 0 212 #define LL_CIS_OCTETS_RX_MAX 0 213 #endif /* !CONFIG_BT_CTLR_CENTRAL_ISO && !CONFIG_BT_CTLR_PERIPHERAL_ISO */ 214 215 #if defined(CONFIG_BT_CTLR_ADV_ISO) 216 #define LL_FEAT_BIT_ISO_BROADCASTER BIT64(BT_LE_FEAT_BIT_ISO_BROADCASTER) 217 #define LL_BIS_OCTETS_TX_MAX MIN(CONFIG_BT_CTLR_ADV_ISO_PDU_LEN_MAX, \ 218 (BT_CTLR_ISO_TX_BUFFER_SIZE - \ 219 BT_HCI_ISO_SDU_TS_HDR_SIZE)) 220 #else /* !CONFIG_BT_CTLR_ADV_ISO */ 221 #define LL_FEAT_BIT_ISO_BROADCASTER 0 222 #define LL_BIS_OCTETS_TX_MAX 0 223 #endif /* !CONFIG_BT_CTLR_ADV_ISO */ 224 225 #if defined(CONFIG_BT_CTLR_SYNC_ISO) 226 #define LL_FEAT_BIT_SYNC_RECEIVER BIT64(BT_LE_FEAT_BIT_SYNC_RECEIVER) 227 #define LL_BIS_OCTETS_RX_MAX CONFIG_BT_CTLR_SYNC_ISO_PDU_LEN_MAX 228 #else /* !CONFIG_BT_CTLR_SYNC_ISO */ 229 #define LL_FEAT_BIT_SYNC_RECEIVER 0 230 #define LL_BIS_OCTETS_RX_MAX 0 231 #endif /* !CONFIG_BT_CTLR_SYNC_ISO */ 232 233 #if defined(CONFIG_BT_CTLR_ADV_PERIODIC_ADI_SUPPORT) || \ 234 defined(CONFIG_BT_CTLR_SYNC_PERIODIC_ADI_SUPPORT) 235 #define LL_FEAT_BIT_PERIODIC_ADI_SUPPORT BIT64(BT_LE_FEAT_BIT_PER_ADV_ADI_SUPP) 236 #else /* !CONFIG_BT_CTLR_ADV_PERIODIC_ADI_SUPPORT && 237 * !CONFIG_BT_CTLR_SYNC_PERIODIC_ADI_SUPPORT 238 */ 239 #define LL_FEAT_BIT_PERIODIC_ADI_SUPPORT 0U 240 #endif /* !CONFIG_BT_CTLR_ADV_PERIODIC_ADI_SUPPORT && 241 * !CONFIG_BT_CTLR_SYNC_PERIODIC_ADI_SUPPORT 242 */ 243 244 /* All defined feature bits */ 245 #define LL_FEAT_BIT_MASK 0xFFFFFFFFFFULL 246 247 /* 248 * LL_FEAT_BIT_MASK_VALID is defined as per 249 * Core Spec V5.3 Volume 6, Part B, chapter 4.6 250 */ 251 #define LL_FEAT_BIT_MASK_VALID 0xEFF787CF2FULL 252 253 /* Mask to filter away octet 0 for feature exchange */ 254 #define LL_FEAT_FILTER_OCTET0 (LL_FEAT_BIT_MASK & ~0xFFULL) 255 256 /* Feature bits of this controller */ 257 #define LL_FEAT (LL_FEAT_BIT_ENC | \ 258 LL_FEAT_BIT_CONN_PARAM_REQ | \ 259 LL_FEAT_BIT_EXT_REJ_IND | \ 260 LL_FEAT_BIT_PER_INIT_FEAT_XCHG | \ 261 LL_FEAT_BIT_PING | \ 262 LL_FEAT_BIT_DLE | \ 263 LL_FEAT_BIT_PRIVACY | \ 264 LL_FEAT_BIT_EXT_SCAN | \ 265 LL_FEAT_BIT_PHY_2M | \ 266 LL_FEAT_BIT_SMI_TX | \ 267 LL_FEAT_BIT_SMI_RX | \ 268 LL_FEAT_BIT_PHY_CODED | \ 269 LL_FEAT_BIT_EXT_ADV | \ 270 LL_FEAT_BIT_PER_ADV | \ 271 LL_FEAT_BIT_CONNECTION_CTE_REQ | \ 272 LL_FEAT_BIT_CONNECTION_CTE_RESP | \ 273 LL_FEAT_BIT_CONNECTIONLESS_CTE_TX | \ 274 LL_FEAT_BIT_CONNECTIONLESS_CTE_RX | \ 275 LL_FEAT_BIT_ANT_SWITCH_TX_AOD | \ 276 LL_FEAT_BIT_ANT_SWITCH_RX_AOA | \ 277 LL_FEAT_BIT_RX_CTE | \ 278 LL_FEAT_BIT_SCA_UPDATE | \ 279 LL_FEAT_BIT_CHAN_SEL_2 | \ 280 LL_FEAT_BIT_MIN_USED_CHAN | \ 281 LL_FEAT_BIT_CIS_CENTRAL | \ 282 LL_FEAT_BIT_CIS_PERIPHERAL | \ 283 LL_FEAT_BIT_ISO_BROADCASTER | \ 284 LL_FEAT_BIT_SYNC_RECEIVER | \ 285 LL_FEAT_BIT_PERIODIC_ADI_SUPPORT) 286 287 /* Connected Isochronous Stream (Host Support) bit is controlled by host */ 288 #if defined(CONFIG_BT_CTLR_CONN_ISO) 289 #define LL_FEAT_HOST_BITS_ISO_CHANNELS BIT64(BT_LE_FEAT_BIT_ISO_CHANNELS) 290 #else /* !CONFIG_BT_CTLR_CONN_ISO */ 291 #define LL_FEAT_HOST_BITS_ISO_CHANNELS 0U 292 #endif /* !CONFIG_BT_CTLR_CONN_ISO */ 293 294 /* Connection subrating not supported and bit thus cannot be set by host */ 295 #define LL_FEAT_HOST_BITS_CONN_SUBRATING 0U 296 297 /* Mask for host controlled features */ 298 #define LL_FEAT_HOST_BIT_MASK (LL_FEAT_HOST_BITS_ISO_CHANNELS |\ 299 LL_FEAT_HOST_BITS_CONN_SUBRATING) 300