From 026deb28069ca27dfbeaf2687d10636bbb578056 Mon Sep 17 00:00:00 2001 From: Eduardo Montoya Date: Tue, 14 Nov 2023 15:11:27 +0100 Subject: [PATCH 1/2] drivers: ieee802154: add `IEEE802154_RX_ON_WHEN_IDLE` capability Introduce `IEEE802154_RX_ON_WHEN_IDLE` capability. Signed-off-by: Eduardo Montoya --- include/zephyr/net/ieee802154_radio.h | 37 ++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/include/zephyr/net/ieee802154_radio.h b/include/zephyr/net/ieee802154_radio.h index 71519dfe839fab..59608fac391ba7 100644 --- a/include/zephyr/net/ieee802154_radio.h +++ b/include/zephyr/net/ieee802154_radio.h @@ -515,13 +515,16 @@ enum ieee802154_hw_caps { /** TX security supported (key management, encryption and authentication) */ IEEE802154_HW_TX_SEC = BIT(11), + /** RxOnWhenIdle handling supported */ + IEEE802154_RX_ON_WHEN_IDLE = BIT(12), + /* Note: Update also IEEE802154_HW_CAPS_BITS_COMMON_COUNT when changing * the ieee802154_hw_caps type. */ }; /** @brief Number of bits used by ieee802154_hw_caps type. */ -#define IEEE802154_HW_CAPS_BITS_COMMON_COUNT (12) +#define IEEE802154_HW_CAPS_BITS_COMMON_COUNT (13) /** @brief This and higher values are specific to the protocol- or driver-specific extensions. */ #define IEEE802154_HW_CAPS_BITS_PRIV_START IEEE802154_HW_CAPS_BITS_COMMON_COUNT @@ -1057,6 +1060,35 @@ enum ieee802154_config_type { */ IEEE802154_CONFIG_ENH_ACK_HEADER_IE, + /** + * Enable/disable RxOnWhenIdle MAC PIB attribute (Table 8-94). + * + * Since there is no clear guidance in IEEE 802.15.4 specification about the definition of + * an "idle period", this implementation expects that drivers use the RxOnWhenIdle attribute + * to determine next radio state (false --> off, true --> receive) in the following + * scenarios: + * - Finalization of a regular frame reception task, provided that: + * - The frame is received without errors and passes the filtering and it's not an + * spurious ACK. + * - ACK is not requested or transmission of ACK is not possible due to internal + * conditions. + * - Finalization of a frame transmission or transmission of an ACK frame, when ACK is not + * requested in the transmitted frame. + * - Finalization of the reception operation of a requested ACK due to: + * - ACK timeout expiration. + * - Reception of an invalid ACK or not an ACK frame. + * - Reception of the proper ACK, unless the transmitted frame was a Data Request Command + * and the frame pending bit on the received ACK is set to true. In this case the radio + * platform implementation SHOULD keep the receiver on until a determined timeout which + * triggers an idle period start. + * - Finalization of a stand alone CCA task. + * - Finalization of a CCA operation with busy result during CSMA/CA procedure. + * - Finalization of an Energy Detection task. + * - Finalization of a scheduled radio reception window + * (see @ref IEEE802154_CONFIG_RX_SLOT). + */ + IEEE802154_CONFIG_RX_ON_WHEN_IDLE, + /** Number of types defined in ieee802154_config_type. */ IEEE802154_CONFIG_COMMON_COUNT, @@ -1103,6 +1135,9 @@ struct ieee802154_config { /** see @ref IEEE802154_CONFIG_PROMISCUOUS */ bool promiscuous; + /** see @ref IEEE802154_CONFIG_RX_ON_WHEN_IDLE */ + bool rx_on_when_idle; + /** see @ref IEEE802154_CONFIG_EVENT_HANDLER */ ieee802154_event_cb_t event_handler; From abb4b2ad0be9dca263c77b940960eb0ceb274d83 Mon Sep 17 00:00:00 2001 From: Eduardo Montoya Date: Tue, 14 Nov 2023 14:57:02 +0100 Subject: [PATCH 2/2] net: openthread: implement `otPlatRadioSetRxOnWhenIdle` OpenThread upmerge to commit `193e77e`. Implement `otPlatRadioSetRxOnWhenIdle` radio platform API. Signed-off-by: Eduardo Montoya --- modules/openthread/platform/radio.c | 17 +++++++++++++++++ west.yml | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/modules/openthread/platform/radio.c b/modules/openthread/platform/radio.c index 391ffba395dc56..9c5de3c9d69f71 100644 --- a/modules/openthread/platform/radio.c +++ b/modules/openthread/platform/radio.c @@ -890,9 +890,26 @@ otRadioCaps otPlatRadioGetCaps(otInstance *aInstance) caps |= OT_RADIO_CAPS_RECEIVE_TIMING; } + if (radio_caps & IEEE802154_RX_ON_WHEN_IDLE) { + caps |= OT_RADIO_CAPS_RX_ON_WHEN_IDLE; + } + return caps; } +void otPlatRadioSetRxOnWhenIdle(otInstance *aInstance, bool aRxOnWhenIdle) +{ + struct ieee802154_config config = { + .rx_on_when_idle = aRxOnWhenIdle + }; + + ARG_UNUSED(aInstance); + + LOG_DBG("RxOnWhenIdle=%d", aRxOnWhenIdle ? 1 : 0); + + radio_api->configure(radio_dev, IEEE802154_CONFIG_RX_ON_WHEN_IDLE, &config); +} + bool otPlatRadioGetPromiscuous(otInstance *aInstance) { ARG_UNUSED(aInstance); diff --git a/west.yml b/west.yml index f7b40860645430..3c50603e8c8248 100644 --- a/west.yml +++ b/west.yml @@ -301,7 +301,7 @@ manifest: revision: 214f9fc1539f8e5937c0474cb6ee29b6dcb2d4b8 path: modules/lib/open-amp - name: openthread - revision: 6edb06e4e0472411200ce2a084a783eaf3faffe3 + revision: 193e77e40ec2387d458eaebd1e03902d86f484a5 path: modules/lib/openthread - name: percepio path: modules/debug/percepio