Index: sys/net80211/ieee80211_output.c =================================================================== --- sys/net80211/ieee80211_output.c +++ sys/net80211/ieee80211_output.c @@ -850,6 +850,15 @@ return (ret); } +static void +ieee80211_nulldata_transmitted(struct ieee80211_node *ni, void *arg, + int status) +{ + struct ieee80211vap *vap = ni->ni_vap; + + wakeup(vap); +} + /* * Send a null data frame to the specified node. If the station * is setup for QoS then a QoS Null Data frame is constructed. @@ -938,6 +947,11 @@ vap->iv_opmode != IEEE80211_M_HOSTAP) wh->i_fc[1] |= IEEE80211_FC1_PWR_MGT; } + if ((ic->ic_flags & IEEE80211_F_SCAN) && + (ni->ni_flags & IEEE80211_NODE_PWR_MGT)) { + ieee80211_add_callback(m, ieee80211_nulldata_transmitted, + NULL); + } m->m_len = m->m_pkthdr.len = hdrlen; m->m_flags |= M_ENCAP; /* mark encapsulated */ Index: sys/net80211/ieee80211_scan_sw.c =================================================================== --- sys/net80211/ieee80211_scan_sw.c +++ sys/net80211/ieee80211_scan_sw.c @@ -630,13 +630,9 @@ if ((vap->iv_bss->ni_flags & IEEE80211_NODE_PWR_MGT) == 0) { /* Enable station power save mode */ vap->iv_sta_ps(vap, 1); - /* - * Use an 1ms delay so the null data frame has a chance - * to go out. - * XXX Should use M_TXCB mechanism to eliminate this. - */ + /* Wait until null data frame will be ACK'ed */ mtx_sleep(vap, IEEE80211_LOCK_OBJ(ic), PCATCH, - "sta_ps", msecs_to_ticks(1)); + "sta_ps", msecs_to_ticks(10)); if (ss_priv->ss_iflags & ISCAN_ABORT) { scan_done(ss, 0); return;