Skip to content

Commit

Permalink
[mac] remove the out-of-band frame tx API (openthread#6778)
Browse files Browse the repository at this point in the history
This commit removes the API to enqueue an out of band frame for
transmission by MAC layer. This API was added as a work-around to
enable legacy (non-Thread based) frames to be sent along with Thread
frames. This model is no longer used and generally not recommended.
The preferred way to handle multi-radio/multi-protocol is to add
support for it in radio platform layer.
  • Loading branch information
abtink authored Jul 1, 2021
1 parent e2205fb commit 2124d9d
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 91 deletions.
2 changes: 1 addition & 1 deletion include/openthread/instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extern "C" {
* @note This number versions both OpenThread platform and user APIs.
*
*/
#define OPENTHREAD_API_VERSION (130)
#define OPENTHREAD_API_VERSION (131)

/**
* @addtogroup api-instance
Expand Down
16 changes: 0 additions & 16 deletions include/openthread/link.h
Original file line number Diff line number Diff line change
Expand Up @@ -506,22 +506,6 @@ otError otLinkSendDataRequest(otInstance *aInstance);
*/
bool otLinkIsInTransmitState(otInstance *aInstance);

/**
* This function enqueues an IEEE 802.15.4 out of band Frame for transmission.
*
* An Out of Band frame is one that was generated outside of OpenThread.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aOobFrame A pointer to the frame to transmit.
*
* @retval OT_ERROR_NONE Successfully scheduled the frame transmission.
* @retval OT_ERROR_ALREADY MAC layer is busy sending a previously requested frame.
* @retval OT_ERROR_INVALID_STATE The MAC layer is not enabled.
* @retval OT_ERROR_INVALID_ARGS The argument @p aOobFrame is NULL.
*
*/
otError otLinkOutOfBandTransmitRequest(otInstance *aInstance, otRadioFrame *aOobFrame);

/**
* Get the IEEE 802.15.4 channel.
*
Expand Down
7 changes: 0 additions & 7 deletions src/core/api/link_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,6 @@ bool otLinkIsInTransmitState(otInstance *aInstance)
return instance.Get<Mac::Mac>().IsInTransmitState();
}

otError otLinkOutOfBandTransmitRequest(otInstance *aInstance, otRadioFrame *aOobFrame)
{
Instance &instance = *static_cast<Instance *>(aInstance);

return instance.Get<Mac::Mac>().RequestOutOfBandFrameTransmission(aOobFrame);
}

uint16_t otLinkGetCcaFailureRate(otInstance *aInstance)
{
Instance &instance = *static_cast<Instance *>(aInstance);
Expand Down
53 changes: 4 additions & 49 deletions src/core/mac/mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ Mac::Mac(Instance &aInstance)
#endif
#endif
, mPendingTransmitPoll(false)
, mPendingTransmitOobFrame(false)
, mPendingWaitingForData(false)
, mShouldTxPollBeforeData(false)
, mRxOnWhenIdle(false)
Expand Down Expand Up @@ -120,7 +119,6 @@ Mac::Mac(Instance &aInstance)
, mLinks(aInstance)
, mOperationTask(aInstance, Mac::HandleOperationTask)
, mTimer(aInstance, Mac::HandleTimer)
, mOobFrame(nullptr)
, mKeyIdMode2FrameCounter(0)
, mCcaSampleCount(0)
#if OPENTHREAD_CONFIG_MULTI_RADIO
Expand Down Expand Up @@ -216,7 +214,6 @@ bool Mac::IsInTransmitState(void) const
#endif
case kOperationTransmitBeacon:
case kOperationTransmitPoll:
case kOperationTransmitOutOfBandFrame:
retval = true;
break;

Expand Down Expand Up @@ -571,22 +568,6 @@ void Mac::RequestCslFrameTransmission(uint32_t aDelay)
#endif
#endif // OPENTHREAD_FTD

Error Mac::RequestOutOfBandFrameTransmission(otRadioFrame *aOobFrame)
{
Error error = kErrorNone;

VerifyOrExit(aOobFrame != nullptr, error = kErrorInvalidArgs);
VerifyOrExit(IsEnabled(), error = kErrorInvalidState);
VerifyOrExit(!mPendingTransmitOobFrame && (mOperation != kOperationTransmitOutOfBandFrame), error = kErrorAlready);

mOobFrame = static_cast<TxFrame *>(aOobFrame);

StartOperation(kOperationTransmitOutOfBandFrame);

exit:
return error;
}

Error Mac::RequestDataPollTransmission(void)
{
Error error = kErrorNone;
Expand Down Expand Up @@ -715,10 +696,6 @@ void Mac::StartOperation(Operation aOperation)
case kOperationWaitingForData:
mPendingWaitingForData = true;
break;

case kOperationTransmitOutOfBandFrame:
mPendingTransmitOobFrame = true;
break;
}

if (mOperation == kOperationIdle)
Expand All @@ -739,7 +716,6 @@ void Mac::PerformNextOperation(void)
if (!IsEnabled())
{
mPendingWaitingForData = false;
mPendingTransmitOobFrame = false;
mPendingActiveScan = false;
mPendingEnergyScan = false;
mPendingTransmitBeacon = false;
Expand Down Expand Up @@ -774,11 +750,6 @@ void Mac::PerformNextOperation(void)
mOperation = kOperationTransmitDataCsl;
}
#endif
else if (mPendingTransmitOobFrame)
{
mPendingTransmitOobFrame = false;
mOperation = kOperationTransmitOutOfBandFrame;
}
else if (mPendingActiveScan)
{
mPendingActiveScan = false;
Expand Down Expand Up @@ -849,7 +820,6 @@ void Mac::PerformNextOperation(void)
#endif
#endif
case kOperationTransmitPoll:
case kOperationTransmitOutOfBandFrame:
BeginTransmit();
break;

Expand Down Expand Up @@ -1141,12 +1111,6 @@ void Mac::BeginTransmit(void)
#endif
#endif // OPENTHREAD_FTD

case kOperationTransmitOutOfBandFrame:
frame = &txFrames.GetBroadcastTxFrame();
frame->CopyFrom(*mOobFrame);
frame->SetIsSecurityProcessed(true);
break;

default:
OT_ASSERT(false);
OT_UNREACHABLE_CODE(break);
Expand Down Expand Up @@ -1583,13 +1547,6 @@ void Mac::HandleTransmitDone(TxFrame &aFrame, RxFrame *aAckFrame, Error aError)
break;
#endif

case kOperationTransmitOutOfBandFrame:
// count Oob frames
mCounters.mTxOther++;
FinishOperation();
PerformNextOperation();
break;

default:
OT_ASSERT(false);
OT_UNREACHABLE_CODE(ExitNow()); // Added to suppress "unused label exit" warning (in TREL radio only).
Expand Down Expand Up @@ -2293,11 +2250,10 @@ const char *Mac::OperationToString(Operation aOperation)
"TransmitDataDirect", // (4) kOperationTransmitDataDirect
"TransmitPoll", // (5) kOperationTransmitPoll
"WaitingForData", // (6) kOperationWaitingForData
"TransmitOobFrame", // (7) kOperationTransmitOutOfBandFrame
#if OPENTHREAD_FTD
"TransmitDataIndirect", // (8) kOperationTransmitDataIndirect
"TransmitDataIndirect", // (7) kOperationTransmitDataIndirect
#if OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE
"TransmitDataCsl", // (9) kOperationTransmitDataCsl
"TransmitDataCsl", // (8) kOperationTransmitDataCsl
#endif
#endif
};
Expand All @@ -2309,11 +2265,10 @@ const char *Mac::OperationToString(Operation aOperation)
static_assert(kOperationTransmitDataDirect == 4, "kOperationTransmitDataDirect value is incorrect");
static_assert(kOperationTransmitPoll == 5, "kOperationTransmitPoll value is incorrect");
static_assert(kOperationWaitingForData == 6, "kOperationWaitingForData value is incorrect");
static_assert(kOperationTransmitOutOfBandFrame == 7, "kOperationTransmitOutOfBandFrame value is incorrect");
#if OPENTHREAD_FTD
static_assert(kOperationTransmitDataIndirect == 8, "kOperationTransmitDataIndirect value is incorrect");
static_assert(kOperationTransmitDataIndirect == 7, "kOperationTransmitDataIndirect value is incorrect");
#if OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE
static_assert(kOperationTransmitDataCsl == 9, "TransmitDataCsl value is incorrect");
static_assert(kOperationTransmitDataCsl == 8, "TransmitDataCsl value is incorrect");
#endif
#endif

Expand Down
18 changes: 0 additions & 18 deletions src/core/mac/mac.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,21 +233,6 @@ class Mac : public InstanceLocator, private NonCopyable

#endif

/**
* This method requests an Out of Band frame for MAC Transmission.
*
* An Out of Band frame is one that was generated outside of OpenThread.
*
* @param[in] aOobFrame A pointer to the frame.
*
* @retval kErrorNone Successfully scheduled the frame transmission.
* @retval kErrorAlready MAC layer is busy sending a previously requested frame.
* @retval kErrorInvalidState The MAC layer is not enabled.
* @retval kErrorInvalidArgs The argument @p aOobFrame is nullptr.
*
*/
Error RequestOutOfBandFrameTransmission(otRadioFrame *aOobFrame);

/**
* This method requests transmission of a data poll (MAC Data Request) frame.
*
Expand Down Expand Up @@ -747,7 +732,6 @@ class Mac : public InstanceLocator, private NonCopyable
kOperationTransmitDataDirect,
kOperationTransmitPoll,
kOperationWaitingForData,
kOperationTransmitOutOfBandFrame,
#if OPENTHREAD_FTD
kOperationTransmitDataIndirect,
#if OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE
Expand Down Expand Up @@ -843,7 +827,6 @@ class Mac : public InstanceLocator, private NonCopyable
#endif
#endif
bool mPendingTransmitPoll : 1;
bool mPendingTransmitOobFrame : 1;
bool mPendingWaitingForData : 1;
bool mShouldTxPollBeforeData : 1;
bool mRxOnWhenIdle : 1;
Expand Down Expand Up @@ -890,7 +873,6 @@ class Mac : public InstanceLocator, private NonCopyable
Links mLinks;
Tasklet mOperationTask;
TimerMilli mTimer;
TxFrame * mOobFrame;
otMacCounters mCounters;
uint32_t mKeyIdMode2FrameCounter;
SuccessRateTracker mCcaSuccessRateTracker;
Expand Down

0 comments on commit 2124d9d

Please sign in to comment.