From 151316ce68aed3a23dc5cd5078cb00ba6c5ec275 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Thu, 23 Nov 2023 19:00:23 +0100 Subject: [PATCH] wifi: Block channel access when aux PHYs change channel width --- src/wifi/model/eht/emlsr-manager.cc | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/wifi/model/eht/emlsr-manager.cc b/src/wifi/model/eht/emlsr-manager.cc index a8a3c5820..4f11ff55b 100644 --- a/src/wifi/model/eht/emlsr-manager.cc +++ b/src/wifi/model/eht/emlsr-manager.cc @@ -926,19 +926,23 @@ EmlsrManager::ApplyMaxChannelWidthAndModClassOnAuxPhys() auto cam = m_staMac->GetChannelAccessManager(linkId); cam->NotifySwitchingEmlsrLink(auxPhy, channel, linkId); - void (WifiPhy::*fp)(const WifiPhyOperatingChannel&) = &WifiPhy::SetOperatingChannel; - Simulator::ScheduleNow(fp, auxPhy, channel); + auxPhy->SetOperatingChannel(channel); // the way the ChannelAccessManager handles EMLSR link switch implies that a PHY listener // is removed when the channel switch starts and another one is attached when the channel - // switch ends. In the meantime, no PHY is connected to the ChannelAccessManager. Inform - // the ChannelAccessManager that this channel switch is related to EMLSR operations, so - // that the ChannelAccessManager does not complain if events requiring access to the PHY - // occur during the channel switch. - cam->NotifyStartUsingOtherEmlsrLink(); - Simulator::Schedule(auxPhy->GetChannelSwitchDelay(), - &ChannelAccessManager::NotifyStopUsingOtherEmlsrLink, - cam); + // switch ends. In the meantime, no PHY is connected to the ChannelAccessManager. Thus, + // reset all backoffs (so that access timeout is also cancelled) when the channel switch + // starts and request channel access (if needed) when the channel switch ends. + cam->ResetAllBackoffs(); + Simulator::Schedule(auxPhy->GetChannelSwitchDelay(), [=, this]() { + for (const auto& [acIndex, ac] : wifiAcList) + { + m_staMac->GetQosTxop(acIndex)->StartAccessAfterEvent( + linkId, + Txop::DIDNT_HAVE_FRAMES_TO_TRANSMIT, + Txop::CHECK_MEDIUM_BUSY); + } + }); } }