[radio] add GetBusSpeed() and GetBusLatency() methods (#10959)

This commit adds `GetBusSpeed()` and `GetBusLatency()` methods to the
`Radio` class, which map to the corresponding `otPlatRadio` platform
APIs.
This commit is contained in:
Abtin Keshavarzian
2024-11-22 16:49:30 -08:00
committed by GitHub
parent c44538e4df
commit b29b6433d9
3 changed files with 30 additions and 4 deletions
+2 -2
View File
@@ -158,8 +158,8 @@ void WakeupTxScheduler::UpdateFrameRequestAhead(void)
// This is used to make sure that a wake-up frame is received by the radio early enough to be transmitted on time.
constexpr uint32_t kWakeupFrameWeight = 100;
uint32_t busSpeedHz = otPlatRadioGetBusSpeed(&GetInstance());
uint32_t busLatency = otPlatRadioGetBusLatency(&GetInstance());
uint32_t busSpeedHz = Get<Radio>().GetBusSpeed();
uint32_t busLatency = Get<Radio>().GetBusLatency();
uint32_t busTxTimeUs = ((busSpeedHz == 0) ? 0 : (kWakeupFrameWeight * 8 * 1000000 + busSpeedHz - 1) / busSpeedHz);
mTxRequestAheadTimeUs = OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US + busTxTimeUs + busLatency;
+26
View File
@@ -812,6 +812,24 @@ public:
return mask;
}
/**
* Get the bus speed in bits/second between the host and the radio chip.
*
* @returns The bus speed in bits/second between the host and the radio chip.
* Return 0 when the MAC and above layer and Radio layer resides on the same chip.
*/
uint32_t GetBusSpeed(void);
/**
* Get the bus latency in microseconds between the host and the radio chip.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @returns The bus latency in microseconds between the host and the radio chip.
* Return 0 when the MAC and above layer and Radio layer resides on the same chip.
*/
uint32_t GetBusLatency(void);
private:
otInstance *GetInstancePtr(void) const { return reinterpret_cast<otInstance *>(&InstanceLocator::GetInstance()); }
@@ -995,6 +1013,10 @@ inline void Radio::ClearSrcMatchShortEntries(void) { otPlatRadioClearSrcMatchSho
inline void Radio::ClearSrcMatchExtEntries(void) { otPlatRadioClearSrcMatchExtEntries(GetInstancePtr()); }
inline uint32_t Radio::GetBusSpeed(void) { return otPlatRadioGetBusSpeed(GetInstancePtr()); }
inline uint32_t Radio::GetBusLatency(void) { return otPlatRadioGetBusLatency(GetInstancePtr()); }
#else //----------------------------------------------------------------------------------------------------------------
inline otRadioCaps Radio::GetCaps(void)
@@ -1095,6 +1117,10 @@ inline void Radio::ClearSrcMatchShortEntries(void) {}
inline void Radio::ClearSrcMatchExtEntries(void) {}
inline uint32_t Radio::GetBusSpeed(void) { return 0; }
inline uint32_t Radio::GetBusLatency(void) { return 0; }
#endif // #if OPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE
} // namespace ot
+2 -2
View File
@@ -47,8 +47,8 @@ CslTxScheduler::CslTxScheduler(Instance &aInstance)
void CslTxScheduler::UpdateFrameRequestAhead(void)
{
uint32_t busSpeedHz = otPlatRadioGetBusSpeed(&GetInstance());
uint32_t busLatency = otPlatRadioGetBusLatency(&GetInstance());
uint32_t busSpeedHz = Get<Radio>().GetBusSpeed();
uint32_t busLatency = Get<Radio>().GetBusLatency();
// longest frame on bus is 127 bytes with some metadata, use 150 bytes for bus Tx time estimation
uint32_t busTxTimeUs = ((busSpeedHz == 0) ? 0 : (150 * 8 * 1000000 + busSpeedHz - 1) / busSpeedHz);