From a44919038c76fe01f8f7412db8c14dca47c7cc96 Mon Sep 17 00:00:00 2001 From: Eduardo Montoya Date: Wed, 17 May 2023 22:29:14 +0200 Subject: [PATCH] [csl] split min receive window into MHR ahead and after times (#9041) Existing `kMinCslWindow` does not account for needed radio on time before MHR. Solve it by splitting the configuration option into both ahead and after minimum times. --- src/core/config/mac.h | 25 +++++++++++++------ .../config/openthread-core-config-check.h | 5 ++++ src/core/mac/sub_mac.cpp | 4 +-- src/core/mac/sub_mac.hpp | 6 ++--- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/core/config/mac.h b/src/core/config/mac.h index 0358b22eb..2694e0dc8 100644 --- a/src/core/config/mac.h +++ b/src/core/config/mac.h @@ -489,16 +489,27 @@ #endif /** - * @def OPENTHREAD_CONFIG_CSL_MIN_RECEIVE_ON + * @def OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AHEAD * - * The minimum CSL receive window (in microseconds) required to receive an IEEE 802.15.4 frame. - * - Maximum frame size with preamble: 6*2+127*2 symbols - * - AIFS: 12 symbols - * - Maximum ACK size with preamble: 6*2+33*2 symbols + * The minimum time (in microseconds) before the MHR start that the radio should be in receive state and ready to + * properly receive in order to properly receive any IEEE 802.15.4 frame. Defaults to the duration of SHR + PHR. * */ -#ifndef OPENTHREAD_CONFIG_CSL_MIN_RECEIVE_ON -#define OPENTHREAD_CONFIG_CSL_MIN_RECEIVE_ON 356 * 16 +#ifndef OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AHEAD +#define OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AHEAD (6 * 32) +#endif + +/** + * @def OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AFTER + * + * The minimum time (in microseconds) after the MHR start that the radio should be in receive state in order + * to properly receive any IEEE 802.15.4 frame. Defaults to the duration of a maximum size frame, plus AIFS, + * plus the duration of maximum enh-ack frame. Platforms are encouraged to improve this value for energy + * efficiency purposes. + * + */ +#ifndef OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AFTER +#define OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AFTER ((127 + 6 + 39) * 32) #endif /** diff --git a/src/core/config/openthread-core-config-check.h b/src/core/config/openthread-core-config-check.h index 67976e149..5d26a6e0f 100644 --- a/src/core/config/openthread-core-config-check.h +++ b/src/core/config/openthread-core-config-check.h @@ -668,4 +668,9 @@ "OPENTHREAD_CONFIG_SRP_SERVER_DEFAULT_ADDRESS_MODE." #endif +#ifdef OPENTHREAD_CONFIG_CSL_MIN_RECEIVE_ON +#error "OPENTHREAD_CONFIG_CSL_MIN_RECEIVE_ON was replaced with "\ + "OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AHEAD and OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AFTER" +#endif + #endif // OPENTHREAD_CORE_CONFIG_CHECK_H_ diff --git a/src/core/mac/sub_mac.cpp b/src/core/mac/sub_mac.cpp index 7d7ac1750..755931cd2 100644 --- a/src/core/mac/sub_mac.cpp +++ b/src/core/mac/sub_mac.cpp @@ -1195,8 +1195,8 @@ void SubMac::GetCslWindowEdges(uint32_t &aAhead, uint32_t &aAfter) (Get().GetCslAccuracy() + mCslParentAccuracy.GetClockAccuracy()) / 1000000); semiWindow += mCslParentAccuracy.GetUncertaintyInMicrosec() + Get().GetCslUncertainty() * 10; - aAhead = Min(semiPeriod, semiWindow + kCslReceiveTimeAhead); - aAfter = Min(semiPeriod, semiWindow + kMinCslWindow); + aAhead = Min(semiPeriod, semiWindow + kMinReceiveOnAhead + kCslReceiveTimeAhead); + aAfter = Min(semiPeriod, semiWindow + kMinReceiveOnAfter); } #endif // OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE diff --git a/src/core/mac/sub_mac.hpp b/src/core/mac/sub_mac.hpp index e56321058..a4c55de80 100644 --- a/src/core/mac/sub_mac.hpp +++ b/src/core/mac/sub_mac.hpp @@ -573,9 +573,9 @@ private: }; #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE - // CSL receive window for the longest possible frame and - // ack duration. - static constexpr uint32_t kMinCslWindow = OPENTHREAD_CONFIG_CSL_MIN_RECEIVE_ON; + // Radio on times needed before and after MHR time for proper frame detection + static constexpr uint32_t kMinReceiveOnAhead = OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AHEAD; + static constexpr uint32_t kMinReceiveOnAfter = OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AFTER; // CSL receivers would wake up `kCslReceiveTimeAhead` earlier // than expected sample window. The value is in usec.