1 /* 2 * Copyright (c) 2019, The OpenThread Authors. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 3. Neither the name of the copyright holder nor the 13 * names of its contributors may be used to endorse or promote products 14 * derived from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /** 30 * @file 31 * This file includes compile-time configurations for the MAC. 32 * 33 */ 34 35 #ifndef CONFIG_MAC_H_ 36 #define CONFIG_MAC_H_ 37 38 #include "config/time_sync.h" 39 40 /** 41 * @def OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_DIRECT 42 * 43 * The maximum number of backoffs the CSMA-CA algorithm will attempt before declaring a channel access failure. 44 * 45 * Equivalent to macMaxCSMABackoffs in IEEE 802.15.4-2006, default value is 4. 46 * 47 */ 48 #ifndef OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_DIRECT 49 #define OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_DIRECT 4 50 #endif 51 52 /** 53 * @def OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_INDIRECT 54 * 55 * The maximum number of backoffs the CSMA-CA algorithm will attempt before declaring a channel access failure. 56 * 57 * Equivalent to macMaxCSMABackoffs in IEEE 802.15.4-2006, default value is 4. 58 * 59 */ 60 #ifndef OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_INDIRECT 61 #define OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_INDIRECT 4 62 #endif 63 64 /** 65 * @def OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_DIRECT 66 * 67 * The default maximum number of retries allowed after a transmission failure for direct transmissions. 68 * 69 * Equivalent to macMaxFrameRetries, default value is 15. 70 * 71 */ 72 #ifndef OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_DIRECT 73 #define OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_DIRECT 15 74 #endif 75 76 /** 77 * @def OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_INDIRECT 78 * 79 * The default maximum number of retries allowed after a transmission failure for indirect transmissions. 80 * 81 * Equivalent to macMaxFrameRetries, default value is 0. 82 * 83 */ 84 #ifndef OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_INDIRECT 85 #define OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_INDIRECT 0 86 #endif 87 88 /** 89 * @def OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE 90 * 91 * Define to 1 to enable MAC retry packets histogram analysis. 92 * 93 */ 94 #ifndef OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE 95 #define OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE 0 96 #endif 97 98 /** 99 * @def OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_MAX_SIZE_COUNT_DIRECT 100 * 101 * The default size of MAC histogram array for success message retry direct transmission. 102 * 103 * Default value is (OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_DIRECT + 1). 104 * 105 */ 106 #ifndef OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_MAX_SIZE_COUNT_DIRECT 107 #define OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_MAX_SIZE_COUNT_DIRECT \ 108 (OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_DIRECT + 1) 109 #endif 110 111 /** 112 * @def OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_MAX_SIZE_COUNT_INDIRECT 113 * 114 * The default size of MAC histogram array for success message retry direct transmission. 115 * 116 * Default value is (OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_INDIRECT + 1). 117 * 118 */ 119 #ifndef OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_MAX_SIZE_COUNT_INDIRECT 120 #define OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_MAX_SIZE_COUNT_INDIRECT \ 121 (OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_INDIRECT + 1) 122 #endif 123 124 /** 125 * @def OPENTHREAD_CONFIG_MAC_MAX_TX_ATTEMPTS_INDIRECT_POLLS 126 * 127 * Maximum number of received IEEE 802.15.4 Data Requests for a queued indirect transaction. 128 * 129 * The indirect frame remains in the transaction queue until it is successfully transmitted or until the indirect 130 * transmission fails after the maximum number of IEEE 802.15.4 Data Request messages have been received. 131 * 132 * Takes the place of macTransactionPersistenceTime. The time period is specified in units of IEEE 802.15.4 Data 133 * Request receptions, rather than being governed by macBeaconOrder. 134 * 135 * @sa OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_INDIRECT 136 * 137 */ 138 #ifndef OPENTHREAD_CONFIG_MAC_MAX_TX_ATTEMPTS_INDIRECT_POLLS 139 #define OPENTHREAD_CONFIG_MAC_MAX_TX_ATTEMPTS_INDIRECT_POLLS 4 140 #endif 141 142 /** 143 * @def OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US 144 * 145 * Define how many microseconds ahead should MAC deliver CSL frame to SubMac. 146 * 147 */ 148 #ifndef OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US 149 #define OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US 2000 150 #endif 151 152 /** 153 * @def OPENTHREAD_CONFIG_MAC_FILTER_ENABLE 154 * 155 * Define to 1 to enable MAC filter support. 156 * 157 */ 158 #ifndef OPENTHREAD_CONFIG_MAC_FILTER_ENABLE 159 #define OPENTHREAD_CONFIG_MAC_FILTER_ENABLE 0 160 #endif 161 162 /** 163 * @def OPENTHREAD_CONFIG_MAC_FILTER_SIZE 164 * 165 * The number of MAC Filter entries. 166 * 167 */ 168 #ifndef OPENTHREAD_CONFIG_MAC_FILTER_SIZE 169 #define OPENTHREAD_CONFIG_MAC_FILTER_SIZE 32 170 #endif 171 172 /** 173 * @def OPENTHREAD_CONFIG_MAC_TX_NUM_BCAST 174 * 175 * The number of times each IEEE 802.15.4 broadcast frame is transmitted. 176 * 177 * The minimum value is 1. Values larger than 1 may improve broadcast reliability by increasing redundancy, but may 178 * also increase congestion. 179 * 180 */ 181 #ifndef OPENTHREAD_CONFIG_MAC_TX_NUM_BCAST 182 #define OPENTHREAD_CONFIG_MAC_TX_NUM_BCAST 1 183 #endif 184 185 /** 186 * @def OPENTHREAD_CONFIG_MAC_STAY_AWAKE_BETWEEN_FRAGMENTS 187 * 188 * Define as 1 to stay awake between fragments while transmitting a large packet, 189 * and to stay awake after receiving a packet with frame pending set to true. 190 * 191 */ 192 #ifndef OPENTHREAD_CONFIG_MAC_STAY_AWAKE_BETWEEN_FRAGMENTS 193 #define OPENTHREAD_CONFIG_MAC_STAY_AWAKE_BETWEEN_FRAGMENTS 0 194 #endif 195 196 /** 197 * @def OPENTHREAD_CONFIG_MAC_JOIN_BEACON_VERSION 198 * 199 * The Beacon version to use when the beacon join flag is set. 200 * 201 */ 202 #ifndef OPENTHREAD_CONFIG_MAC_JOIN_BEACON_VERSION 203 #define OPENTHREAD_CONFIG_MAC_JOIN_BEACON_VERSION OPENTHREAD_CONFIG_THREAD_VERSION 204 #endif 205 206 /** 207 * @def OPENTHREAD_CONFIG_MAC_BEACON_RSP_WHEN_JOINABLE_ENABLE 208 * 209 * Define to 1 to enable IEEE 802.15.4 Beacons when joining is enabled. 210 * 211 * @note When this feature is enabled, the device will transmit IEEE 802.15.4 Beacons in response to IEEE 802.15.4 212 * Beacon Requests even while the device is not router capable and detached. 213 * 214 */ 215 #ifndef OPENTHREAD_CONFIG_MAC_BEACON_RSP_WHEN_JOINABLE_ENABLE 216 #define OPENTHREAD_CONFIG_MAC_BEACON_RSP_WHEN_JOINABLE_ENABLE 0 217 #endif 218 219 /** 220 * @def OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT 221 * 222 * Define as 1 to support IEEE 802.15.4-2015 Header IE (Information Element) generation and parsing, it must be set 223 * to support following features: 224 * 1. Time synchronization service feature (i.e., OPENTHREAD_CONFIG_TIME_SYNC_ENABLE is set). 225 * 2. Thread 1.2. 226 * 227 * @note If it's enabled, platform must support interrupt context and concurrent access AES. 228 * 229 */ 230 #ifndef OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT 231 #if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE || (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2) 232 #define OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT 1 233 #else 234 #define OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT 0 235 #endif 236 #endif 237 238 /** 239 * @def OPENTHREAD_CONFIG_MAC_ATTACH_DATA_POLL_PERIOD 240 * 241 * The Data Poll period during attach in milliseconds. 242 * 243 */ 244 #ifndef OPENTHREAD_CONFIG_MAC_ATTACH_DATA_POLL_PERIOD 245 #define OPENTHREAD_CONFIG_MAC_ATTACH_DATA_POLL_PERIOD 100 246 #endif 247 248 /** 249 * @def OPENTHREAD_CONFIG_MAC_MINIMUM_POLL_PERIOD 250 * 251 * This setting configures the minimum poll period in milliseconds. 252 * 253 */ 254 #ifndef OPENTHREAD_CONFIG_MAC_MINIMUM_POLL_PERIOD 255 #define OPENTHREAD_CONFIG_MAC_MINIMUM_POLL_PERIOD 10 256 #endif 257 258 /** 259 * @def OPENTHREAD_CONFIG_MAC_RETX_POLL_PERIOD 260 * 261 * This setting configures the retx poll period in milliseconds. 262 * 263 */ 264 #ifndef OPENTHREAD_CONFIG_MAC_RETX_POLL_PERIOD 265 #define OPENTHREAD_CONFIG_MAC_RETX_POLL_PERIOD 1000 266 #endif 267 268 /** 269 * @def OPENTHREAD_CONFIG_MAC_SOFTWARE_ACK_TIMEOUT_ENABLE 270 * 271 * Define to 1 to enable software ACK timeout logic. 272 * 273 */ 274 #ifndef OPENTHREAD_CONFIG_MAC_SOFTWARE_ACK_TIMEOUT_ENABLE 275 #define OPENTHREAD_CONFIG_MAC_SOFTWARE_ACK_TIMEOUT_ENABLE 0 276 #endif 277 278 /** 279 * @def OPENTHREAD_CONFIG_MAC_SOFTWARE_RETRANSMIT_ENABLE 280 * 281 * Define to 1 to enable software retransmission logic. 282 * 283 */ 284 #ifndef OPENTHREAD_CONFIG_MAC_SOFTWARE_RETRANSMIT_ENABLE 285 #define OPENTHREAD_CONFIG_MAC_SOFTWARE_RETRANSMIT_ENABLE 0 286 #endif 287 288 /** 289 * @def OPENTHREAD_CONFIG_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE 290 * 291 * Define to 1 to enable software CSMA-CA backoff logic. 292 * 293 */ 294 #ifndef OPENTHREAD_CONFIG_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE 295 #define OPENTHREAD_CONFIG_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE 0 296 #endif 297 298 /** 299 * @def OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE 300 * 301 * Define to 1 to enable software transmission security logic. 302 * 303 */ 304 #ifndef OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE 305 #define OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE 0 306 #endif 307 308 /** 309 * @def OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_TIMING_ENABLE 310 * 311 * Define to 1 to enable software transmission target time logic. 312 * 313 */ 314 #ifndef OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_TIMING_ENABLE 315 #define OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_TIMING_ENABLE 0 316 #endif 317 318 /** 319 * @def OPENTHREAD_CONFIG_MAC_SOFTWARE_RX_TIMING_ENABLE 320 * 321 * Define to 1 to enable software reception target time logic. 322 * 323 */ 324 #ifndef OPENTHREAD_CONFIG_MAC_SOFTWARE_RX_TIMING_ENABLE 325 #define OPENTHREAD_CONFIG_MAC_SOFTWARE_RX_TIMING_ENABLE 0 326 #endif 327 328 /** 329 * @def OPENTHREAD_CONFIG_MAC_SOFTWARE_ENERGY_SCAN_ENABLE 330 * 331 * Define to 1 to enable software energy scanning logic. 332 * 333 */ 334 #ifndef OPENTHREAD_CONFIG_MAC_SOFTWARE_ENERGY_SCAN_ENABLE 335 #define OPENTHREAD_CONFIG_MAC_SOFTWARE_ENERGY_SCAN_ENABLE 0 336 #endif 337 338 /** 339 * @def OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE 340 * 341 * Define to 1 to enable csl transmitter logic. 342 * 343 */ 344 #ifndef OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE 345 #define OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2) 346 #endif 347 348 /** 349 * @def OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE 350 * 351 * This setting configures the CSL receiver feature in Thread 1.2. 352 * 353 */ 354 #ifndef OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE 355 #define OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE 0 356 #endif 357 358 /** 359 * @def OPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE 360 * 361 * This setting configures CSL auto synchronization based on data poll mechanism in Thread 1.2. 362 * 363 */ 364 #ifndef OPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE 365 #define OPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE 366 #endif 367 368 /** 369 * @def OPENTHREAD_CONFIG_MAC_CSL_MIN_PERIOD 370 * 371 * This setting configures the minimum CSL period that could be used, in units of milliseconds. 372 * 373 */ 374 #ifndef OPENTHREAD_CONFIG_MAC_CSL_MIN_PERIOD 375 #define OPENTHREAD_CONFIG_MAC_CSL_MIN_PERIOD 10 376 #endif 377 378 /** 379 * @def OPENTHREAD_CONFIG_MAC_CSL_MAX_TIMEOUT 380 * 381 * This setting configures the maximum CSL timeout that could be used, in units of seconds. 382 * 383 */ 384 #ifndef OPENTHREAD_CONFIG_MAC_CSL_MAX_TIMEOUT 385 #define OPENTHREAD_CONFIG_MAC_CSL_MAX_TIMEOUT 10000 386 #endif 387 388 /** 389 * @def OPENTHREAD_CONFIG_CSL_TIMEOUT 390 * 391 * The default CSL timeout in seconds. 392 * 393 */ 394 #ifndef OPENTHREAD_CONFIG_CSL_TIMEOUT 395 #define OPENTHREAD_CONFIG_CSL_TIMEOUT 100 396 #endif 397 398 /** 399 * @def OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE 400 * 401 * CSL receiver debug option. When this option is enabled, a CSL receiver wouldn't actually sleep in CSL state so it 402 * can still receive packets from the CSL transmitter. 403 * 404 */ 405 #ifndef OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE 406 #define OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE 0 407 #endif 408 409 /** 410 * @def OPENTHREAD_CONFIG_CSL_RECEIVE_TIME_AHEAD 411 * 412 * Reception scheduling and ramp up time needed for the CSL receiver to be ready, in units of microseconds. 413 * 414 */ 415 #ifndef OPENTHREAD_CONFIG_CSL_RECEIVE_TIME_AHEAD 416 #define OPENTHREAD_CONFIG_CSL_RECEIVE_TIME_AHEAD 320 417 #endif 418 419 /** 420 * @def OPENTHREAD_CONFIG_CSL_MIN_RECEIVE_ON 421 * 422 * The minimum CSL receive window (in microseconds) required to receive an IEEE 802.15.4 frame. 423 * - Maximum frame size with preamble: 6*2+127*2 symbols 424 * - AIFS: 12 symbols 425 * - Maximum ACK size with preamble: 6*2+33*2 symbols 426 * 427 */ 428 #ifndef OPENTHREAD_CONFIG_CSL_MIN_RECEIVE_ON 429 #define OPENTHREAD_CONFIG_CSL_MIN_RECEIVE_ON 356 * 16 430 #endif 431 432 /** 433 * @def OPENTHREAD_CONFIG_MAC_SCAN_DURATION 434 * 435 * This setting configures the default scan duration in milliseconds. 436 * 437 */ 438 #ifndef OPENTHREAD_CONFIG_MAC_SCAN_DURATION 439 #define OPENTHREAD_CONFIG_MAC_SCAN_DURATION 300 440 #endif 441 442 #endif // CONFIG_MAC_H_ 443