Merge branch 'backport/openthread_related_mr_v51' into 'release/v5.1'

Backport openthread fix to v5.1

See merge request espressif/esp-idf!28819
This commit is contained in:
Jiang Jiang Jian
2024-02-05 14:15:00 +08:00
7 changed files with 37 additions and 8 deletions

View File

@@ -89,6 +89,7 @@ typedef enum {
} ieee802154_ll_rx_abort_reason_t; } ieee802154_ll_rx_abort_reason_t;
typedef uint32_t ieee802154_ll_rx_abort_events; typedef uint32_t ieee802154_ll_rx_abort_events;
#define IEEE802154_RX_ABORT_ALL 0x7fffffff
/** /**
* @brief IEEE802154 transmission failed reason. * @brief IEEE802154 transmission failed reason.
@@ -112,6 +113,7 @@ typedef enum {
} ieee802154_ll_tx_abort_reason_t; } ieee802154_ll_tx_abort_reason_t;
typedef uint32_t ieee802154_ll_tx_abort_events; typedef uint32_t ieee802154_ll_tx_abort_events;
#define IEEE802154_TX_ABORT_ALL 0x7fffffff
/** /**
* @brief IEEE802154 CCA mode. * @brief IEEE802154 CCA mode.

View File

@@ -351,6 +351,8 @@ static IRAM_ATTR void next_operation(void)
{ {
#if !CONFIG_IEEE802154_TEST #if !CONFIG_IEEE802154_TEST
if (s_pending_tx.frame) { if (s_pending_tx.frame) {
// Here the driver needs to recover the setting of rx aborts, see function `ieee802154_transmit`.
ieee802154_ll_enable_rx_abort_events(BIT(IEEE802154_RX_ABORT_BY_TX_ACK_TIMEOUT - 1) | BIT(IEEE802154_RX_ABORT_BY_TX_ACK_COEX_BREAK - 1));
ieee802154_transmit_internal(s_pending_tx.frame, s_pending_tx.cca); ieee802154_transmit_internal(s_pending_tx.frame, s_pending_tx.cca);
s_pending_tx.frame = NULL; s_pending_tx.frame = NULL;
} else } else
@@ -482,18 +484,18 @@ static IRAM_ATTR void isr_handle_rx_abort(void)
IEEE802154_ASSERT(s_ieee802154_state == IEEE802154_STATE_RX); IEEE802154_ASSERT(s_ieee802154_state == IEEE802154_STATE_RX);
#if CONFIG_IEEE802154_TEST #if CONFIG_IEEE802154_TEST
esp_ieee802154_receive_failed(rx_status); esp_ieee802154_receive_failed(rx_status);
next_operation();
#endif #endif
break; break;
case IEEE802154_RX_ABORT_BY_COEX_BREAK: case IEEE802154_RX_ABORT_BY_COEX_BREAK:
IEEE802154_ASSERT(s_ieee802154_state == IEEE802154_STATE_RX); IEEE802154_ASSERT(s_ieee802154_state == IEEE802154_STATE_RX);
#if CONFIG_IEEE802154_TEST
esp_ieee802154_receive_failed(rx_status); esp_ieee802154_receive_failed(rx_status);
#endif
break; break;
case IEEE802154_RX_ABORT_BY_ED_ABORT: case IEEE802154_RX_ABORT_BY_ED_ABORT:
case IEEE802154_RX_ABORT_BY_ED_COEX_REJECT: case IEEE802154_RX_ABORT_BY_ED_COEX_REJECT:
IEEE802154_ASSERT(s_ieee802154_state == IEEE802154_STATE_ED || s_ieee802154_state == IEEE802154_STATE_CCA); IEEE802154_ASSERT(s_ieee802154_state == IEEE802154_STATE_ED || s_ieee802154_state == IEEE802154_STATE_CCA);
esp_ieee802154_ed_failed(rx_status); esp_ieee802154_ed_failed(rx_status);
next_operation();
break; break;
case IEEE802154_RX_ABORT_BY_TX_ACK_TIMEOUT: case IEEE802154_RX_ABORT_BY_TX_ACK_TIMEOUT:
case IEEE802154_RX_ABORT_BY_TX_ACK_COEX_BREAK: case IEEE802154_RX_ABORT_BY_TX_ACK_COEX_BREAK:
@@ -503,7 +505,6 @@ static IRAM_ATTR void isr_handle_rx_abort(void)
#else #else
esp_ieee802154_receive_failed(rx_status); esp_ieee802154_receive_failed(rx_status);
#endif #endif
next_operation();
break; break;
case IEEE802154_RX_ABORT_BY_ENHACK_SECURITY_ERROR: case IEEE802154_RX_ABORT_BY_ENHACK_SECURITY_ERROR:
IEEE802154_ASSERT(s_ieee802154_state == IEEE802154_STATE_TX_ENH_ACK); IEEE802154_ASSERT(s_ieee802154_state == IEEE802154_STATE_TX_ENH_ACK);
@@ -512,11 +513,11 @@ static IRAM_ATTR void isr_handle_rx_abort(void)
#else #else
esp_ieee802154_receive_failed(rx_status); esp_ieee802154_receive_failed(rx_status);
#endif #endif
next_operation();
break; break;
default: default:
IEEE802154_ASSERT(false); IEEE802154_ASSERT(false);
} }
next_operation();
} }
static IRAM_ATTR void isr_handle_tx_abort(void) static IRAM_ATTR void isr_handle_tx_abort(void)
@@ -816,6 +817,7 @@ static inline esp_err_t ieee802154_transmit_internal(const uint8_t *frame, bool
esp_err_t ieee802154_transmit(const uint8_t *frame, bool cca) esp_err_t ieee802154_transmit(const uint8_t *frame, bool cca)
{ {
#if !CONFIG_IEEE802154_TEST #if !CONFIG_IEEE802154_TEST
ieee802154_enter_critical();
if ((s_ieee802154_state == IEEE802154_STATE_RX && ieee802154_ll_is_current_rx_frame()) if ((s_ieee802154_state == IEEE802154_STATE_RX && ieee802154_ll_is_current_rx_frame())
|| s_ieee802154_state == IEEE802154_STATE_TX_ACK || s_ieee802154_state == IEEE802154_STATE_TX_ENH_ACK) { || s_ieee802154_state == IEEE802154_STATE_TX_ACK || s_ieee802154_state == IEEE802154_STATE_TX_ENH_ACK) {
// If the current radio is processing an RX frame or sending an ACK, do not shut down the ongoing process. // If the current radio is processing an RX frame or sending an ACK, do not shut down the ongoing process.
@@ -824,8 +826,13 @@ esp_err_t ieee802154_transmit(const uint8_t *frame, bool cca)
s_pending_tx.frame = frame; s_pending_tx.frame = frame;
s_pending_tx.cca = cca; s_pending_tx.cca = cca;
IEEE802154_TX_DEFERRED_NUMS_UPDATE(); IEEE802154_TX_DEFERRED_NUMS_UPDATE();
// Here we enable all rx interrupts due to the driver needs to know when the current RX has finished.
// Will recover the setting of rx abort in function `next_operation`.
ieee802154_ll_enable_rx_abort_events(IEEE802154_RX_ABORT_ALL);
ieee802154_exit_critical();
return ESP_OK; return ESP_OK;
} }
ieee802154_exit_critical();
#endif #endif
return ieee802154_transmit_internal(frame, cca); return ieee802154_transmit_internal(frame, cca);
} }

View File

@@ -114,6 +114,7 @@ menu "OpenThread"
Select this to use the native 15.4 radio. Select this to use the native 15.4 radio.
config OPENTHREAD_RADIO_SPINEL_UART config OPENTHREAD_RADIO_SPINEL_UART
select UART_ISR_IN_IRAM
bool "Connect via UART" bool "Connect via UART"
help help
Select this to connect to a Radio Co-Processor via UART. Select this to connect to a Radio Co-Processor via UART.
@@ -157,6 +158,7 @@ menu "OpenThread"
default OPENTHREAD_RCP_UART default OPENTHREAD_RCP_UART
config OPENTHREAD_RCP_UART config OPENTHREAD_RCP_UART
select UART_ISR_IN_IRAM
bool "UART RCP" bool "UART RCP"
help help
Select this to enable UART connection to host. Select this to enable UART connection to host.
@@ -293,7 +295,7 @@ menu "OpenThread"
config OPENTHREAD_UART_BUFFER_SIZE config OPENTHREAD_UART_BUFFER_SIZE
int "The uart received buffer size of openthread" int "The uart received buffer size of openthread"
depends on OPENTHREAD_ENABLED depends on OPENTHREAD_ENABLED
default 256 default 768
range 128 1024 range 128 1024
help help
Set the OpenThread UART buffer size. Set the OpenThread UART buffer size.
@@ -374,6 +376,15 @@ menu "OpenThread"
default n default n
help help
Select this option to enable the OpenThread Radio Spinel for external protocol stack, such as Zigbee. Select this option to enable the OpenThread Radio Spinel for external protocol stack, such as Zigbee.
config OPENTHREAD_RX_ON_WHEN_IDLE
bool "Enable OpenThread radio capibility rx on when idle"
default y if !ESP_COEX_SW_COEXIST_ENABLE
default n if ESP_COEX_SW_COEXIST_ENABLE
help
Select this option to enable OpenThread radio capibility rx on when idle. Do not support this feature when
SW coexistence is enabled.
menu "Thread Address Query Config" menu "Thread Address Query Config"
config OPENTHREAD_ADDRESS_QUERY_TIMEOUT config OPENTHREAD_ADDRESS_QUERY_TIMEOUT
int "Timeout value (in seconds) for a address notification response after sending an address query." int "Timeout value (in seconds) for a address notification response after sending an address query."

View File

@@ -343,7 +343,11 @@ int8_t otPlatRadioGetRssi(otInstance *aInstance)
otRadioCaps otPlatRadioGetCaps(otInstance *aInstance) otRadioCaps otPlatRadioGetCaps(otInstance *aInstance)
{ {
return (otRadioCaps)(OT_RADIO_CAPS_ENERGY_SCAN | OT_RADIO_CAPS_RX_ON_WHEN_IDLE | // FIXME: Remove `CONFIG_OPENTHREAD_RX_ON_WHEN_IDLE` when JIRA: TZ-609 fixed.
return (otRadioCaps)(OT_RADIO_CAPS_ENERGY_SCAN |
#if CONFIG_OPENTHREAD_RX_ON_WHEN_IDLE
OT_RADIO_CAPS_RX_ON_WHEN_IDLE |
#endif
OT_RADIO_CAPS_TRANSMIT_SEC | OT_RADIO_CAPS_RECEIVE_TIMING | OT_RADIO_CAPS_TRANSMIT_TIMING | OT_RADIO_CAPS_TRANSMIT_SEC | OT_RADIO_CAPS_RECEIVE_TIMING | OT_RADIO_CAPS_TRANSMIT_TIMING |
OT_RADIO_CAPS_ACK_TIMEOUT | OT_RADIO_CAPS_SLEEP_TO_TX); OT_RADIO_CAPS_ACK_TIMEOUT | OT_RADIO_CAPS_SLEEP_TO_TX);
} }
@@ -771,8 +775,10 @@ otError otPlatRadioSetChannelMaxTransmitPower(otInstance *aInstance, uint8_t aCh
return OT_ERROR_NONE; return OT_ERROR_NONE;
} }
#if CONFIG_OPENTHREAD_RX_ON_WHEN_IDLE
void otPlatRadioSetRxOnWhenIdle(otInstance *aInstance, bool aEnable) void otPlatRadioSetRxOnWhenIdle(otInstance *aInstance, bool aEnable)
{ {
OT_UNUSED_VARIABLE(aInstance); OT_UNUSED_VARIABLE(aInstance);
esp_ieee802154_set_rx_when_idle(aEnable); esp_ieee802154_set_rx_when_idle(aEnable);
} }
#endif

View File

@@ -6,6 +6,7 @@
#include "esp_openthread_radio.h" #include "esp_openthread_radio.h"
#include "sdkconfig.h"
#include "esp_check.h" #include "esp_check.h"
#include "esp_err.h" #include "esp_err.h"
#include "esp_openthread_border_router.h" #include "esp_openthread_border_router.h"
@@ -413,7 +414,9 @@ otError otPlatRadioConfigureEnhAckProbing(otInstance *aInstance, otLinkMetrics a
} }
#endif #endif
#if CONFIG_OPENTHREAD_RX_ON_WHEN_IDLE
void otPlatRadioSetRxOnWhenIdle(otInstance *aInstance, bool aEnable) void otPlatRadioSetRxOnWhenIdle(otInstance *aInstance, bool aEnable)
{ {
s_radio.SetRxOnWhenIdle(aEnable); s_radio.SetRxOnWhenIdle(aEnable);
} }
#endif