wifi: Allow aborting RX to switch to sleep mode

This commit is contained in:
Stefano Avallone
2024-07-03 11:39:39 +02:00
parent 28030d39b0
commit aa51bd9342
4 changed files with 22 additions and 8 deletions

View File

@@ -175,7 +175,7 @@ DefaultEmlsrManager::NotifyMainPhySwitch(std::optional<uint8_t> currLinkId,
{
// aux PHY can be put into sleep mode when the main PHY completes the channel switch
m_auxPhyToSleepEvent =
Simulator::Schedule(duration, &WifiPhy::SetSleepMode, m_auxPhyToReconnect);
Simulator::Schedule(duration, &WifiPhy::SetSleepMode, m_auxPhyToReconnect, false);
}
}
}

View File

@@ -540,8 +540,11 @@ WifiPhyStateHelper::SwitchToSleep()
case WifiPhyState::CCA_BUSY:
LogPreviousIdleAndCcaBusyStates();
break;
case WifiPhyState::RX:
DoSwitchFromRx();
break;
default:
NS_FATAL_ERROR("Invalid WifiPhy state.");
NS_FATAL_ERROR("Invalid WifiPhy state: " << GetState());
break;
}
m_previousStateChangeTime = now;

View File

@@ -1414,7 +1414,7 @@ WifiPhy::GetBssMembershipSelectorList() const
}
void
WifiPhy::SetSleepMode()
WifiPhy::SetSleepMode(bool forceSleepInRx)
{
NS_LOG_FUNCTION(this);
m_powerRestricted = false;
@@ -1423,15 +1423,24 @@ WifiPhy::SetSleepMode()
{
case WifiPhyState::TX:
NS_LOG_DEBUG("setting sleep mode postponed until end of current transmission");
Simulator::Schedule(GetDelayUntilIdle(), &WifiPhy::SetSleepMode, this);
Simulator::Schedule(GetDelayUntilIdle(), &WifiPhy::SetSleepMode, this, forceSleepInRx);
break;
case WifiPhyState::RX:
NS_LOG_DEBUG("setting sleep mode postponed until end of current reception");
Simulator::Schedule(GetDelayUntilIdle(), &WifiPhy::SetSleepMode, this);
NS_LOG_DEBUG("setting sleep mode"
<< (forceSleepInRx ? "" : "postponed until end of current reception"));
if (forceSleepInRx)
{
AbortCurrentReception(WifiPhyRxfailureReason::SLEEPING);
m_state->SwitchToSleep();
}
else
{
Simulator::Schedule(GetDelayUntilIdle(), &WifiPhy::SetSleepMode, this, forceSleepInRx);
}
break;
case WifiPhyState::SWITCHING:
NS_LOG_DEBUG("setting sleep mode postponed until end of channel switching");
Simulator::Schedule(GetDelayUntilIdle(), &WifiPhy::SetSleepMode, this);
Simulator::Schedule(GetDelayUntilIdle(), &WifiPhy::SetSleepMode, this, forceSleepInRx);
break;
case WifiPhyState::CCA_BUSY:
case WifiPhyState::IDLE:

View File

@@ -165,8 +165,10 @@ class WifiPhy : public Object
/**
* Put in sleep mode.
*
* \param forceSleepWhileInRx force setting sleep mode if state is RX
*/
void SetSleepMode();
void SetSleepMode(bool forceSleepWhileInRx = false);
/**
* Resume from sleep mode.
*/