From 124f0508cb2d4e4a81a98f7840fb189ada3419e8 Mon Sep 17 00:00:00 2001 From: Zhanglong Xia Date: Tue, 10 Dec 2024 23:42:29 +0800 Subject: [PATCH] [spinel] add an API to enable/disable the RCP restoration feature (#11011) --- src/lib/spinel/radio_spinel.cpp | 3 +++ src/lib/spinel/radio_spinel.hpp | 10 ++++++++++ .../platform/include/openthread/openthread-system.h | 7 +++++++ src/posix/platform/radio.cpp | 4 ++++ 4 files changed, 24 insertions(+) diff --git a/src/lib/spinel/radio_spinel.cpp b/src/lib/spinel/radio_spinel.cpp index 4ab2fd138..52fec803d 100644 --- a/src/lib/spinel/radio_spinel.cpp +++ b/src/lib/spinel/radio_spinel.cpp @@ -90,6 +90,7 @@ RadioSpinel::RadioSpinel(void) , mSrcMatchShortEntryCount(0) , mSrcMatchExtEntryCount(0) , mSrcMatchEnabled(false) + , mRcpRestorationEnabled(true) , mMacKeySet(false) , mCcaEnergyDetectThresholdSet(false) , mTransmitPowerSet(false) @@ -2039,6 +2040,8 @@ void RadioSpinel::RecoverFromRcpFailure(void) State recoveringState = mState; bool skipReset = false; + VerifyOrExit(mRcpRestorationEnabled); + if (mRcpFailure == kRcpFailureNone) { ExitNow(); diff --git a/src/lib/spinel/radio_spinel.hpp b/src/lib/spinel/radio_spinel.hpp index f773ead5b..90de94ce7 100644 --- a/src/lib/spinel/radio_spinel.hpp +++ b/src/lib/spinel/radio_spinel.hpp @@ -1078,6 +1078,15 @@ public: */ void SetTimeSyncState(bool aOn) { mTimeSyncOn = aOn; } +#if OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT > 0 + /** + * Enables or disables the RCP restoration feature. + * + * @param[in] aEnabled TRUE to enable the RCP restoration feature, FALSE otherwise. + */ + void SetRcpRestorationEnabled(bool aEnabled) { mRcpRestorationEnabled = aEnabled; } +#endif + private: enum { @@ -1283,6 +1292,7 @@ private: int8_t mFemLnaGain; bool mCoexEnabled : 1; bool mSrcMatchEnabled : 1; + bool mRcpRestorationEnabled : 1; bool mMacKeySet : 1; ///< Whether MAC key has been set. bool mCcaEnergyDetectThresholdSet : 1; ///< Whether CCA energy detect threshold has been set. diff --git a/src/posix/platform/include/openthread/openthread-system.h b/src/posix/platform/include/openthread/openthread-system.h index c286d074a..168d5f6c2 100644 --- a/src/posix/platform/include/openthread/openthread-system.h +++ b/src/posix/platform/include/openthread/openthread-system.h @@ -320,6 +320,13 @@ void otSysTrelInit(const char *aInterfaceName); */ void otSysTrelDeinit(void); +/** + * Enables or disables the RCP restoration feature. + * + * @param[in] aEnabled TRUE to enable the RCP restoration feature, FALSE otherwise. + */ +void otSysSetRcpRestorationEnabled(bool aEnabled); + #ifdef __cplusplus } // end of extern "C" #endif diff --git a/src/posix/platform/radio.cpp b/src/posix/platform/radio.cpp index a0a6597ae..823af6784 100644 --- a/src/posix/platform/radio.cpp +++ b/src/posix/platform/radio.cpp @@ -1070,3 +1070,7 @@ const otRcpInterfaceMetrics *otSysGetRcpInterfaceMetrics(void) { return sRadio.GetSpinelInterface().GetRcpInterfaceMetrics(); } + +#if OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT > 0 +void otSysSetRcpRestorationEnabled(bool aEnabled) { return GetRadioSpinel().SetRcpRestorationEnabled(aEnabled); } +#endif