Merge branch 'feature/config_csmabackoff_in_spinel' into 'master'

feat(openthread): add max csmabackoffs for transmission

Closes TZ-627

See merge request espressif/esp-idf!29767
This commit is contained in:
Zhang Wen Xu 2024-03-25 14:41:26 +08:00
commit 8edaa94e89
7 changed files with 70 additions and 11 deletions

View File

@ -266,6 +266,14 @@ menu "OpenThread"
default 1024
range 512 8192
config OPENTHREAD_MAC_MAX_CSMA_BACKOFFS_DIRECT
int "Maximum backoffs times before declaring a channel access failure."
depends on OPENTHREAD_ENABLED || OPENTHREAD_SPINEL_ONLY
default 4
help
The maximum number of backoffs the CSMA-CA algorithm will attempt before declaring a channel access
failure.
config OPENTHREAD_MLE_MAX_CHILDREN
int "The size of max MLE children entries"
depends on OPENTHREAD_ENABLED

View File

@ -6,15 +6,16 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "sdkconfig.h"
#include <sys/select.h>
#include "esp_ieee802154_types.h"
#include "driver/uart.h"
#include "soc/gpio_num.h"
#ifdef __cplusplus
extern "C" {
#endif
#define ESP_SPINEL_LOG_TAG "ESP_RADIO_SPINEL"
#define SPINEL_PROP_VENDOR_ESP_SET_COORDINATOR (SPINEL_PROP_VENDOR_ESP__BEGIN + 1) /* Vendor command for coordinator.*/
@ -55,11 +56,11 @@ typedef struct
void (*transmit_started)(const uint8_t *frame); /* Callback for Transmit Started.*/
void (*switchover_done)(bool success); /* Callback for Switchover Done.*/
#if OPENTHREAD_CONFIG_DIAG_ENABLE
#if CONFIG_OPENTHREAD_DIAG
void (*diag_receive_done)(const uint8_t *frame, esp_ieee802154_frame_info_t *frame_info); /* Callback for Receive Done (diag).*/
void (*diag_transmit_done)(const uint8_t *frame, esp_ieee802154_frame_info_t *frame_info); /* Callback for Transmit Done (diag).*/
void (*diag_transmit_failed)(esp_ieee802154_tx_error_t error); /* Callback for Transmit Failed (diag).*/
#endif // OPENTHREAD_CONFIG_DIAG_ENABLE
#endif // CONFIG_OPENTHREAD_DIAG
} esp_radio_spinel_callbacks_t; /* ESP Radio Spinel Callbacks.*/
/**

View File

@ -620,4 +620,16 @@
#define OPENTHREAD_CONFIG_TMF_ADDRESS_QUERY_MAX_RETRY_DELAY CONFIG_OPENTHREAD_ADDRESS_QUERY_MAX_RETRY_DELAY
#endif
/**
* @def OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_DIRECT
*
* The maximum number of backoffs the CSMA-CA algorithm will attempt before declaring a channel access failure.
*
* Equivalent to macMaxCSMABackoffs in IEEE 802.15.4-2006, default value is 4.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_DIRECT
#define OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_DIRECT CONFIG_OPENTHREAD_MAC_MAX_CSMA_BACKOFFS_DIRECT
#endif
#define OPENTHREAD_FTD 1

View File

@ -304,4 +304,16 @@
#define OPENTHREAD_CONFIG_TMF_ADDRESS_QUERY_MAX_RETRY_DELAY CONFIG_OPENTHREAD_ADDRESS_QUERY_MAX_RETRY_DELAY
#endif
/**
* @def OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_DIRECT
*
* The maximum number of backoffs the CSMA-CA algorithm will attempt before declaring a channel access failure.
*
* Equivalent to macMaxCSMABackoffs in IEEE 802.15.4-2006, default value is 4.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_DIRECT
#define OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_DIRECT CONFIG_OPENTHREAD_MAC_MAX_CSMA_BACKOFFS_DIRECT
#endif
#define OPENTHREAD_MTD 1

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -230,3 +230,15 @@
#define OPENTHREAD_ENABLE_NCP_VENDOR_HOOK 1
#endif
#endif //CONFIG_OPENTHREAD_NCP_VENDOR_HOOK
/**
* @def OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_DIRECT
*
* The maximum number of backoffs the CSMA-CA algorithm will attempt before declaring a channel access failure.
*
* Equivalent to macMaxCSMABackoffs in IEEE 802.15.4-2006, default value is 4.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_DIRECT
#define OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_DIRECT CONFIG_OPENTHREAD_MAC_MAX_CSMA_BACKOFFS_DIRECT
#endif

View File

@ -46,3 +46,15 @@
*
*/
#define OPENTHREAD_CONFIG_PLATFORM_RADIO_SPINEL_RX_FRAME_BUFFER_SIZE CONFIG_OPENTHREAD_SPINEL_RX_FRAME_BUFFER_SIZE
/**
* @def OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_DIRECT
*
* The maximum number of backoffs the CSMA-CA algorithm will attempt before declaring a channel access failure.
*
* Equivalent to macMaxCSMABackoffs in IEEE 802.15.4-2006, default value is 4.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_DIRECT
#define OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_DIRECT CONFIG_OPENTHREAD_MAC_MAX_CSMA_BACKOFFS_DIRECT
#endif

View File

@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include "esp_check.h"
#include "esp_log.h"
#include "platform/exit_code.h"
@ -123,7 +124,7 @@ void SwitchoverDone(otInstance *aInstance, bool aSuccess)
s_esp_radio_spinel_callbacks[idx].switchover_done(aSuccess);
}
#if OPENTHREAD_CONFIG_DIAG_ENABLE
#if CONFIG_OPENTHREAD_DIAG
void DiagReceiveDone(otInstance *aInstance, otRadioFrame *aFrame, otError aError)
{
esp_radio_spinel_idx_t idx = get_index_from_instance(aInstance);
@ -172,7 +173,7 @@ void DiagTransmitDone(otInstance *aInstance, otRadioFrame *aFrame, otError aErro
}
}
}
#endif // OPENTHREAD_CONFIG_DIAG_ENABLE
#endif // CONFIG_OPENTHREAD_DIAG
void esp_radio_spinel_set_callbacks(const esp_radio_spinel_callbacks_t aCallbacks, esp_radio_spinel_idx_t idx)
@ -184,10 +185,10 @@ void esp_radio_spinel_set_callbacks(const esp_radio_spinel_callbacks_t aCallback
Callbacks.mEnergyScanDone = EnergyScanDone;
Callbacks.mTxStarted = TxStarted;
Callbacks.mSwitchoverDone = SwitchoverDone;
#if OPENTHREAD_CONFIG_DIAG_ENABLE
#if CONFIG_OPENTHREAD_DIAG
Callbacks.mDiagReceiveDone = DiagReceiveDone;
Callbacks.mDiagTransmitDone = DiagTransmitDone;
#endif // OPENTHREAD_CONFIG_DIAG_ENABLE
#endif // CONFIG_OPENTHREAD_DIAG
s_radio[idx].SetCallbacks(Callbacks);
}
@ -268,6 +269,7 @@ esp_err_t esp_radio_spinel_transmit(uint8_t *frame, uint8_t channel, bool cca, e
s_transmit_frame.mLength = frame[0];
s_transmit_frame.mPsdu = frame + 1;
s_transmit_frame.mInfo.mTxInfo.mCsmaCaEnabled = cca;
s_transmit_frame.mInfo.mTxInfo.mMaxCsmaBackoffs = CONFIG_OPENTHREAD_MAC_MAX_CSMA_BACKOFFS_DIRECT;
s_transmit_frame.mChannel = channel;
s_transmit_frame.mInfo.mTxInfo.mRxChannelAfterTxDone = channel;
return (s_radio[idx].Transmit(s_transmit_frame) == OT_ERROR_NONE) ? ESP_OK : ESP_FAIL;