mirror of
https://github.com/espressif/openthread.git
synced 2026-08-20 09:29:51 +00:00
[mac] move auxiliary frame counter from Mac to SubMac (#4976)
In Thread 1.2, it is possible to receive an IEEE 802.15.4-2015 packet. Per specification, receiver should acknowledge this packet with an IEEE 802.15.4-2015 ACK(Enh-ACK). This Enh-ACK can include header IE with it and requires security enabled bit in FCF be set to true. It is impractical for the host to generate the Enh-ACK and send to RCP for transmission within AIFS time(192us). So RCP should prepare the Enh-ACK by itself, which requires it to fill in the frame counter and do the encryption/authentication. This commit tries to address the need of filling auxiliary frame counter in RCP by including the following changes: - Move frame counter related functions from MAC layer to SubMac layer, which is mirrored in RCP. - Set mMacFrameCounter to RCP using newly added spinel properties. - RCP reports last used frame counter to host in TxDone and RxDone. - Add a simulation test for reset verification.
This commit is contained in:
@@ -53,7 +53,7 @@ extern "C" {
|
||||
* @note This number versions both OpenThread platform and user APIs.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_API_VERSION (1)
|
||||
#define OPENTHREAD_API_VERSION (2)
|
||||
|
||||
/**
|
||||
* @addtogroup api-instance
|
||||
|
||||
@@ -351,6 +351,18 @@ otError otLinkRawSetMacKey(otInstance * aInstance,
|
||||
const otMacKey *aCurrKey,
|
||||
const otMacKey *aNextKey);
|
||||
|
||||
/**
|
||||
* Sets the current MAC frame counter value.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aMacFrameCounter The MAC frame counter value.
|
||||
*
|
||||
* @retval OT_ERROR_NONE If successful.
|
||||
* @retval OT_ERROR_INVALID_STATE If the raw link-layer isn't enabled.
|
||||
*
|
||||
*/
|
||||
otError otLinkRawSetMacFrameCounter(otInstance *aInstance, uint32_t aMacFrameCounter);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
|
||||
@@ -234,11 +234,14 @@ typedef struct otRadioFrame
|
||||
*/
|
||||
uint64_t mTimestamp;
|
||||
|
||||
int8_t mRssi; ///< Received signal strength indicator in dBm for received frames.
|
||||
uint8_t mLqi; ///< Link Quality Indicator for received frames.
|
||||
uint32_t mAckFrameCounter; ///< ACK security frame counter (applicable when `mAckedWithSecEnhAck` is set).
|
||||
uint8_t mAckKeyId; ///< ACK security key index (applicable when `mAckedWithSecEnhAck` is set).
|
||||
int8_t mRssi; ///< Received signal strength indicator in dBm for received frames.
|
||||
uint8_t mLqi; ///< Link Quality Indicator for received frames.
|
||||
|
||||
// Flags
|
||||
bool mAckedWithFramePending : 1; /// This indicates if this frame was acknowledged with frame pending set.
|
||||
bool mAckedWithFramePending : 1; ///< This indicates if this frame was acknowledged with frame pending set.
|
||||
bool mAckedWithSecEnhAck : 1; ///< This indicates if this frame was acknowledged with secured enhance ACK.
|
||||
} mRxInfo;
|
||||
} mInfo;
|
||||
} otRadioFrame;
|
||||
@@ -475,6 +478,17 @@ void otPlatRadioSetMacKey(otInstance * aInstance,
|
||||
const otMacKey *aCurrKey,
|
||||
const otMacKey *aNextKey);
|
||||
|
||||
/**
|
||||
* This method sets the current MAC frame counter value.
|
||||
*
|
||||
* This function is used when radio provides `OT_RADIO_CAPS_TRANSMIT_SEC` capability.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aMacFrameCounter The MAC frame counter value.
|
||||
*
|
||||
*/
|
||||
void otPlatRadioSetMacFrameCounter(otInstance *aInstance, uint32_t aMacFrameCounter);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
@@ -635,6 +649,9 @@ extern void otPlatRadioTxStarted(otInstance *aInstance, otRadioFrame *aFrame);
|
||||
* The radio driver calls this function to notify OpenThread that the transmit operation has completed,
|
||||
* providing both the transmitted frame and, if applicable, the received ack frame.
|
||||
*
|
||||
* When radio provides `OT_RADIO_CAPS_TRANSMIT_SEC` capability, radio platform layer updates @p aFrame
|
||||
* with the security frame counter and key index values maintained by the radio.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
* @param[in] aFrame A pointer to the frame that was transmitted.
|
||||
* @param[in] aAckFrame A pointer to the ACK frame, NULL if no ACK was received.
|
||||
|
||||
Reference in New Issue
Block a user