New radio capability to indicate CSMA backoff support by radio layer (#1395)

- This commit adds a new radio capability `kRadioCapsCsmaBackOff` to
  indicate that the radio supports CSMA backoff logic for frame
  transmission (but no frame retry).

- The existing capability `kRadioCapsTransmitRetries` is not changed
  and still indicates that the radio supports transmission retry logic
  along with collision avoidance (CSMA).

- `Mac` implementation is updated accordingly.
This commit is contained in:
Abtin Keshavarzian
2017-02-27 14:28:20 -08:00
committed by Jonathan Hui
parent df3c775e17
commit d38a329eb9
3 changed files with 29 additions and 11 deletions
+2 -1
View File
@@ -91,7 +91,8 @@ typedef enum otRadioCaps
kRadioCapsNone = 0, ///< None
kRadioCapsAckTimeout = 1, ///< Radio supports AckTime event
kRadioCapsEnergyScan = 2, ///< Radio supports Energy Scans
kRadioCapsTransmitRetries = 4, ///< Radio supports transmission retry logic with collision avoidance
kRadioCapsTransmitRetries = 4, ///< Radio supports transmission retry logic with collision avoidance (CSMA).
kRadioCapsCsmaBackOff = 8, ///< Radio supports CSMA backoff for frame transmission (but no retry).
} otRadioCaps;
/**
+14 -6
View File
@@ -81,10 +81,9 @@ static_assert(kMinBackoffSum > 0, "The min backoff value should be greater than
void Mac::StartCsmaBackoff(void)
{
if (RadioSupportsRetriesAndCsmaBackoff())
if (RadioSupportsCsmaBackoff())
{
// If the radio supports the retry and back off logic, immediately schedule the send,
// and the radio will take care of everything.
// If the radio supports CSMA back off logic, immediately schedule the send.
HandleBeginTransmit();
}
else
@@ -856,7 +855,7 @@ void Mac::TransmitDoneTask(RadioPacket *aPacket, bool aRxPending, ThreadError aE
mCounters.mTxErrAbort++;
}
if (!RadioSupportsRetriesAndCsmaBackoff() &&
if (!RadioSupportsCsmaBackoff() &&
aError == kThreadError_ChannelAccessFailure &&
mCsmaAttempts < kMaxCSMABackoffs)
{
@@ -989,7 +988,7 @@ void Mac::SentFrame(ThreadError aError)
case kThreadError_NoAck:
otDumpDebgMac("NO ACK", sendFrame.GetHeader(), 16);
if (!RadioSupportsRetriesAndCsmaBackoff() &&
if (!RadioSupportsRetries() &&
mTransmitAttempts < kMaxFrameAttempts)
{
mTransmitAttempts++;
@@ -1540,7 +1539,16 @@ void Mac::SetPromiscuous(bool aPromiscuous)
}
}
bool Mac::RadioSupportsRetriesAndCsmaBackoff(void)
bool Mac::RadioSupportsCsmaBackoff(void)
{
/* Check either of the following conditions:
* 1) Radio provides the CSMA backoff capability (i.e., `kRadioCapsCsmaBackOff` bit is set) or;
* 2) It provides `kRadioCapsTransmitRetries` which indicates support for MAC retries along with CSMA backoff.
*/
return (otPlatRadioGetCaps(mNetif.GetInstance()) & (kRadioCapsTransmitRetries | kRadioCapsCsmaBackOff)) != 0;
}
bool Mac::RadioSupportsRetries(void)
{
return (otPlatRadioGetCaps(mNetif.GetInstance()) & kRadioCapsTransmitRetries) != 0;
}
+13 -4
View File
@@ -560,13 +560,22 @@ public:
void ClearSrcMatchEntries(void);
/**
* This method indicates whether or not transmit retries and CSMA backoff logic is supported by the radio layer.
* This method indicates whether or not CSMA backoff is supported by the radio layer.
*
* @retval true Retries and CSMA are supported by the radio.
* @retval false Retries and CSMA are not supported by the radio.
* @retval true CSMA backoff is supported by the radio.
* @retval false CSMA backoff is not supported by the radio.
*
*/
bool RadioSupportsRetriesAndCsmaBackoff(void);
bool RadioSupportsCsmaBackoff(void);
/**
* This method indicates whether or not transmit retries is supported by the radio layer.
*
* @retval true Retries (and CSMA) are supported by the radio.
* @retval false Retries (and CSMA) are not supported by the radio.
*
*/
bool RadioSupportsRetries(void);
private:
enum ScanType