mirror of
https://github.com/espressif/openthread.git
synced 2026-09-13 12:40:05 +00:00
[radio-spinel] fix GetNextTid() (#7516)
This commit updates `GetNextTid()` in `RadioSpinel` so that it searches for the next unused TID. The current implementation only checked the `mCmdNextTid` and assumed that if it was in-use, then all other TIDs were also in-use. This may not be valid since a TID may be in-use for a pending radio tx in `mTxRadioTid` while TIDs after that are still available. This should help address the situation where while waiting for a pending radio tx (holding on to `mTxRadioTid`) 15 other radio API calls happen (each consuming a TID) causing the `mCmdNextTid` to wrap around back to `mTxRadioTid`.
This commit is contained in:
@@ -1699,15 +1699,25 @@ exit:
|
||||
template <typename InterfaceType, typename ProcessContextType>
|
||||
spinel_tid_t RadioSpinel<InterfaceType, ProcessContextType>::GetNextTid(void)
|
||||
{
|
||||
spinel_tid_t tid = 0;
|
||||
spinel_tid_t tid = mCmdNextTid;
|
||||
|
||||
if (((1 << mCmdNextTid) & mCmdTidsInUse) == 0)
|
||||
while (((1 << tid) & mCmdTidsInUse) != 0)
|
||||
{
|
||||
tid = mCmdNextTid;
|
||||
mCmdNextTid = SPINEL_GET_NEXT_TID(mCmdNextTid);
|
||||
mCmdTidsInUse |= (1 << tid);
|
||||
tid = SPINEL_GET_NEXT_TID(tid);
|
||||
|
||||
if (tid == mCmdNextTid)
|
||||
{
|
||||
// We looped back to `mCmdNextTid` indicating that all
|
||||
// TIDs are in-use.
|
||||
|
||||
ExitNow(tid = 0);
|
||||
}
|
||||
}
|
||||
|
||||
mCmdTidsInUse |= (1 << tid);
|
||||
mCmdNextTid = SPINEL_GET_NEXT_TID(tid);
|
||||
|
||||
exit:
|
||||
return tid;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user