From c053a22b7fd3cc8778ed891f3626300949a1c378 Mon Sep 17 00:00:00 2001 From: adrian Date: Sun, 3 May 2015 23:28:54 +0000 Subject: [PATCH] Try to fix passive scanning hang on beacon miss. PR: kern/197143 Submitted by: Andriy Voskoboinyk --- sys/dev/wpi/if_wpi.c | 27 +++++++++++++++++++-------- sys/dev/wpi/if_wpi_debug.h | 1 + sys/dev/wpi/if_wpireg.h | 4 ++++ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/sys/dev/wpi/if_wpi.c b/sys/dev/wpi/if_wpi.c index d23eb0262959..454d91cf2605 100644 --- a/sys/dev/wpi/if_wpi.c +++ b/sys/dev/wpi/if_wpi.c @@ -2135,11 +2135,18 @@ wpi_notif_intr(struct wpi_softc *sc) __func__, misses, le32toh(miss->total), received, expected); - if (vap->iv_state == IEEE80211_S_RUN && - (ic->ic_flags & IEEE80211_F_SCAN) == 0 && - (misses >= threshold || - (received == 0 && expected >= threshold))) - ieee80211_beacon_miss(ic); + if (misses >= threshold || + (received == 0 && expected >= threshold)) { + WPI_RXON_LOCK(sc); + if (callout_pending(&sc->scan_timeout)) { + wpi_cmd(sc, WPI_CMD_SCAN_ABORT, NULL, + 0, 1); + } + WPI_RXON_UNLOCK(sc); + if (vap->iv_state == IEEE80211_S_RUN && + (ic->ic_flags & IEEE80211_F_SCAN) == 0) + ieee80211_beacon_miss(ic); + } break; } @@ -2202,17 +2209,21 @@ wpi_notif_intr(struct wpi_softc *sc) { bus_dmamap_sync(sc->rxq.data_dmat, data->map, BUS_DMASYNC_POSTREAD); -#ifdef WPI_DEBUG + struct wpi_stop_scan *scan = (struct wpi_stop_scan *)(desc + 1); + DPRINTF(sc, WPI_DEBUG_SCAN, "scan finished nchan=%d status=%d chan=%d\n", scan->nchan, scan->status, scan->chan); -#endif + WPI_RXON_LOCK(sc); callout_stop(&sc->scan_timeout); WPI_RXON_UNLOCK(sc); - ieee80211_scan_next(vap); + if (scan->status == WPI_SCAN_ABORTED) + ieee80211_cancel_scan(vap); + else + ieee80211_scan_next(vap); break; } } diff --git a/sys/dev/wpi/if_wpi_debug.h b/sys/dev/wpi/if_wpi_debug.h index e4f313b683b6..deeb4a2d8076 100644 --- a/sys/dev/wpi/if_wpi_debug.h +++ b/sys/dev/wpi/if_wpi_debug.h @@ -86,6 +86,7 @@ static const char *wpi_cmd_str(int cmd) WPI_DESC(WPI_CMD_SET_LED); WPI_DESC(WPI_CMD_SET_POWER_MODE); WPI_DESC(WPI_CMD_SCAN); + WPI_DESC(WPI_CMD_SCAN_ABORT); WPI_DESC(WPI_CMD_SET_BEACON); WPI_DESC(WPI_CMD_TXPOWER); WPI_DESC(WPI_CMD_BT_COEX); diff --git a/sys/dev/wpi/if_wpireg.h b/sys/dev/wpi/if_wpireg.h index f2704fd9499c..b0aa35c992d5 100644 --- a/sys/dev/wpi/if_wpireg.h +++ b/sys/dev/wpi/if_wpireg.h @@ -352,6 +352,7 @@ struct wpi_tx_cmd { #define WPI_CMD_SET_LED 72 #define WPI_CMD_SET_POWER_MODE 119 #define WPI_CMD_SCAN 128 +#define WPI_CMD_SCAN_ABORT 129 #define WPI_CMD_SET_BEACON 145 #define WPI_CMD_TXPOWER 151 #define WPI_CMD_BT_COEX 155 @@ -725,6 +726,9 @@ struct wpi_start_scan { struct wpi_stop_scan { uint8_t nchan; uint8_t status; +#define WPI_SCAN_COMPLETED 1 +#define WPI_SCAN_ABORTED 2 + uint8_t reserved; uint8_t chan; uint64_t tsf;