From 4b9134d5e19995bf9f98f65a0a531fec6c76b142 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Mon, 25 Nov 2024 09:27:39 -0800 Subject: [PATCH] [mac] define `Mac::kCslRequestAhead` constant (#10963) This commit defines the `Mac::kCslRequestAhead` constant, which maps to `OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US`. This constant is used within the core modules. --- src/core/mac/mac.cpp | 5 +++-- src/core/mac/mac.hpp | 6 ++++++ src/core/mac/wakeup_tx_scheduler.cpp | 2 +- src/core/mac/wakeup_tx_scheduler.hpp | 3 +-- src/core/thread/csl_tx_scheduler.cpp | 2 +- src/core/thread/csl_tx_scheduler.hpp | 3 +-- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/core/mac/mac.cpp b/src/core/mac/mac.cpp index 28d0f18bf..d41856e41 100644 --- a/src/core/mac/mac.cpp +++ b/src/core/mac/mac.cpp @@ -2629,9 +2629,10 @@ Error Mac::HandleWakeupFrame(const RxFrame &aFrame) radioNowUs = otPlatRadioGetNow(&GetInstance()); rvTimeUs = aFrame.GetRendezvousTimeIe()->GetRendezvousTime() * kUsPerTenSymbols; rvTimestampUs = aFrame.GetTimestamp() + kRadioHeaderPhrDuration + aFrame.GetLength() * kOctetDuration + rvTimeUs; - if (rvTimestampUs > radioNowUs + OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US) + + if (rvTimestampUs > radioNowUs + kCslRequestAhead) { - attachDelayMs = static_cast(rvTimestampUs - radioNowUs - OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US); + attachDelayMs = static_cast(rvTimestampUs - radioNowUs - kCslRequestAhead); attachDelayMs = attachDelayMs / 1000; } else diff --git a/src/core/mac/mac.hpp b/src/core/mac/mac.hpp index b96e0dae7..40322a0c8 100644 --- a/src/core/mac/mac.hpp +++ b/src/core/mac/mac.hpp @@ -87,6 +87,12 @@ constexpr uint8_t kMaxFrameRetriesCsl = 0; constexpr uint8_t kTxNumBcast = OPENTHREAD_CONFIG_MAC_TX_NUM_BCAST; ///< Num of times broadcast frame is tx. +/** + * Specifies the number of microseconds ahead of time that the MAC layer should deliver a CSL frame to the sub-MAC + * layer. + */ +constexpr uint16_t kCslRequestAhead = OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US; + constexpr uint16_t kMinCslIePeriod = OPENTHREAD_CONFIG_MAC_CSL_MIN_PERIOD; constexpr uint32_t kDefaultWedListenInterval = OPENTHREAD_CONFIG_WED_LISTEN_INTERVAL; diff --git a/src/core/mac/wakeup_tx_scheduler.cpp b/src/core/mac/wakeup_tx_scheduler.cpp index 17816ee34..74207ea96 100644 --- a/src/core/mac/wakeup_tx_scheduler.cpp +++ b/src/core/mac/wakeup_tx_scheduler.cpp @@ -167,7 +167,7 @@ void WakeupTxScheduler::UpdateFrameRequestAhead(void) busSpeedHz = DivideAndRoundUp(kWakeupFrameWeight * 8 * 1000000, busSpeedHz); } - mTxRequestAheadTimeUs = OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US + busTxTimeUs + busLatency; + mTxRequestAheadTimeUs = Mac::kCslRequestAhead + busTxTimeUs + busLatency; } } // namespace ot diff --git a/src/core/mac/wakeup_tx_scheduler.hpp b/src/core/mac/wakeup_tx_scheduler.hpp index ee724f016..548321e3b 100644 --- a/src/core/mac/wakeup_tx_scheduler.hpp +++ b/src/core/mac/wakeup_tx_scheduler.hpp @@ -95,8 +95,7 @@ public: void Stop(void); /** - * Updates the value of `mTxRequestAheadTimeUs`, based on bus speed, bus latency and - * `OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US`. + * Updates the value of `mTxRequestAheadTimeUs`, based on bus speed, bus latency and `Mac::kCslRequestAhead`. */ void UpdateFrameRequestAhead(void); diff --git a/src/core/thread/csl_tx_scheduler.cpp b/src/core/thread/csl_tx_scheduler.cpp index 956c70f73..4b4e026f2 100644 --- a/src/core/thread/csl_tx_scheduler.cpp +++ b/src/core/thread/csl_tx_scheduler.cpp @@ -59,7 +59,7 @@ void CslTxScheduler::UpdateFrameRequestAhead(void) busTxTime = DivideAndRoundUp(150 * 8 * 1000000, busSpeedHz); } - mCslFrameRequestAheadUs = OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US + busTxTime + busLatency; + mCslFrameRequestAheadUs = Mac::kCslRequestAhead + busTxTime + busLatency; LogInfo("Bus TX Time: %lu usec, Latency: %lu usec. Calculated CSL Frame Request Ahead: %lu usec", ToUlong(busTxTime), ToUlong(busLatency), ToUlong(mCslFrameRequestAheadUs)); diff --git a/src/core/thread/csl_tx_scheduler.hpp b/src/core/thread/csl_tx_scheduler.hpp index 0636ecb0f..91e8249fa 100644 --- a/src/core/thread/csl_tx_scheduler.hpp +++ b/src/core/thread/csl_tx_scheduler.hpp @@ -178,8 +178,7 @@ public: void Clear(void); /** - * Updates the value of `mCslFrameRequestAheadUs`, based on bus speed, bus latency - * and `OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US`. + * Updates the value of `mCslFrameRequestAheadUs`, based on bus speed, bus latency and `Mac::kCslRequestAhead`. */ void UpdateFrameRequestAhead(void);