From 53deb13ff650dc1f710132ff52d6c14b17593b77 Mon Sep 17 00:00:00 2001 From: Parag Balbudhe Date: Wed, 17 Jan 2024 22:56:25 -0500 Subject: [PATCH] [multipan] Fix for multipan use case to handle tx timeout. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are two changes: 1. Address the issue of handling tx timeout in case of multipan enabled. When RCP recovery initiates due to a timeout, the SPINEL attempts to transition to the Rx state and switch channels to initialize the RCP. However, these actions should be ignored when operating as Multiprotocol RCP, as another host/protocol might be scanning, and encountering the Rx state or channel switch could result in an error. Considering such scenarios, ignore the error rather than assert it for multipan. 2. Make the CMake option OT_MULTIPAN_RCP depend on the compile time value OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE, rather than being initialized to OFF. --- etc/cmake/options.cmake | 2 +- src/lib/spinel/radio_spinel.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/etc/cmake/options.cmake b/etc/cmake/options.cmake index ecb2d52d3a5..05176dea26f 100644 --- a/etc/cmake/options.cmake +++ b/etc/cmake/options.cmake @@ -218,6 +218,7 @@ ot_option(OT_MESH_DIAG OPENTHREAD_CONFIG_MESH_DIAG_ENABLE "mesh diag") ot_option(OT_MESSAGE_USE_HEAP OPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE "heap allocator for message buffers") ot_option(OT_MLE_LONG_ROUTES OPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE "MLE long routes extension (experimental)") ot_option(OT_MLR OPENTHREAD_CONFIG_MLR_ENABLE "Multicast Listener Registration (MLR)") +ot_option(OT_MULTIPAN_RCP OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE "enable multi-PAN RCP") ot_option(OT_MULTIPLE_INSTANCE OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE "multiple instances") ot_option(OT_NAT64_BORDER_ROUTING OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE "border routing NAT64") ot_option(OT_NAT64_TRANSLATOR OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE "NAT64 translator support") @@ -248,7 +249,6 @@ ot_option(OT_UDP_FORWARD OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE "UDP forward") ot_option(OT_UPTIME OPENTHREAD_CONFIG_UPTIME_ENABLE "uptime") option(OT_DOC "build OpenThread documentation") -option(OT_MULTIPAN_RCP "Multi-PAN RCP" OFF) message(STATUS "- - - - - - - - - - - - - - - - ") # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/lib/spinel/radio_spinel.cpp b/src/lib/spinel/radio_spinel.cpp index 15d90b542c2..6b03b5b30e9 100644 --- a/src/lib/spinel/radio_spinel.cpp +++ b/src/lib/spinel/radio_spinel.cpp @@ -2138,12 +2138,22 @@ void RadioSpinel::RecoverFromRcpFailure(void) case kStateSleep: break; case kStateReceive: +#if OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE + // In case multiple PANs are running, don't force RCP to receive state. + IgnoreError(Set(SPINEL_PROP_MAC_RAW_STREAM_ENABLED, SPINEL_DATATYPE_BOOL_S, true)); +#else SuccessOrDie(Set(SPINEL_PROP_MAC_RAW_STREAM_ENABLED, SPINEL_DATATYPE_BOOL_S, true)); +#endif mState = kStateReceive; break; case kStateTransmitting: case kStateTransmitDone: +#if OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE + // In case multiple PANs are running, don't force RCP to receive state. + IgnoreError(Set(SPINEL_PROP_MAC_RAW_STREAM_ENABLED, SPINEL_DATATYPE_BOOL_S, true)); +#else SuccessOrDie(Set(SPINEL_PROP_MAC_RAW_STREAM_ENABLED, SPINEL_DATATYPE_BOOL_S, true)); +#endif mTxError = OT_ERROR_ABORT; mState = kStateTransmitDone; break; @@ -2168,7 +2178,12 @@ void RadioSpinel::RestoreProperties(void) SuccessOrDie(Set(SPINEL_PROP_MAC_15_4_PANID, SPINEL_DATATYPE_UINT16_S, mPanId)); SuccessOrDie(Set(SPINEL_PROP_MAC_15_4_SADDR, SPINEL_DATATYPE_UINT16_S, mShortAddress)); SuccessOrDie(Set(SPINEL_PROP_MAC_15_4_LADDR, SPINEL_DATATYPE_EUI64_S, mExtendedAddress.m8)); +#if OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE + // In case multiple PANs are running, don't force RCP to change channel. + IgnoreError(Set(SPINEL_PROP_PHY_CHAN, SPINEL_DATATYPE_UINT8_S, mChannel)); +#else SuccessOrDie(Set(SPINEL_PROP_PHY_CHAN, SPINEL_DATATYPE_UINT8_S, mChannel)); +#endif if (mMacKeySet) {