svn commit: r290048 - head/sys/dev/usb/wlan
Andriy Voskoboinyk
avos at FreeBSD.org
Tue Oct 27 14:21:25 UTC 2015
Author: avos
Date: Tue Oct 27 14:21:24 2015
New Revision: 290048
URL: https://svnweb.freebsd.org/changeset/base/290048
Log:
urtwn(4): fix scanning from AUTH state
Tested with RTL8188EU, STA mode.
Reviewed by: kevlo
Approved by: adrian (mentor)
Differential Revision: https://reviews.freebsd.org/D3968
Modified:
head/sys/dev/usb/wlan/if_urtwn.c
Modified: head/sys/dev/usb/wlan/if_urtwn.c
==============================================================================
--- head/sys/dev/usb/wlan/if_urtwn.c Tue Oct 27 13:44:13 2015 (r290047)
+++ head/sys/dev/usb/wlan/if_urtwn.c Tue Oct 27 14:21:24 2015 (r290048)
@@ -264,6 +264,8 @@ static void urtwn_r88e_get_txpower(stru
static void urtwn_set_txpower(struct urtwn_softc *,
struct ieee80211_channel *,
struct ieee80211_channel *);
+static void urtwn_set_rx_bssid_all(struct urtwn_softc *, int);
+static void urtwn_set_gain(struct urtwn_softc *, uint8_t);
static void urtwn_scan_start(struct ieee80211com *);
static void urtwn_scan_end(struct ieee80211com *);
static void urtwn_set_channel(struct ieee80211com *);
@@ -1544,7 +1546,6 @@ urtwn_newstate(struct ieee80211vap *vap,
struct urtwn_softc *sc = ic->ic_softc;
struct ieee80211_node *ni;
enum ieee80211_state ostate;
- uint32_t reg;
ostate = vap->iv_state;
DPRINTF("%s -> %s\n", ieee80211_state_name[ostate],
@@ -1585,38 +1586,11 @@ urtwn_newstate(struct ieee80211vap *vap,
urtwn_set_led(sc, URTWN_LED_LINK, 0);
break;
case IEEE80211_S_SCAN:
- if (ostate != IEEE80211_S_SCAN) {
- /* Allow Rx from any BSSID. */
- urtwn_write_4(sc, R92C_RCR,
- urtwn_read_4(sc, R92C_RCR) &
- ~(R92C_RCR_CBSSID_DATA | R92C_RCR_CBSSID_BCN));
-
- /* Set gain for scanning. */
- reg = urtwn_bb_read(sc, R92C_OFDM0_AGCCORE1(0));
- reg = RW(reg, R92C_OFDM0_AGCCORE1_GAIN, 0x20);
- urtwn_bb_write(sc, R92C_OFDM0_AGCCORE1(0), reg);
-
- if (!(sc->chip & URTWN_CHIP_88E)) {
- reg = urtwn_bb_read(sc, R92C_OFDM0_AGCCORE1(1));
- reg = RW(reg, R92C_OFDM0_AGCCORE1_GAIN, 0x20);
- urtwn_bb_write(sc, R92C_OFDM0_AGCCORE1(1), reg);
- }
- }
/* Pause AC Tx queues. */
urtwn_write_1(sc, R92C_TXPAUSE,
urtwn_read_1(sc, R92C_TXPAUSE) | 0x0f);
break;
case IEEE80211_S_AUTH:
- /* Set initial gain under link. */
- reg = urtwn_bb_read(sc, R92C_OFDM0_AGCCORE1(0));
- reg = RW(reg, R92C_OFDM0_AGCCORE1_GAIN, 0x32);
- urtwn_bb_write(sc, R92C_OFDM0_AGCCORE1(0), reg);
-
- if (!(sc->chip & URTWN_CHIP_88E)) {
- reg = urtwn_bb_read(sc, R92C_OFDM0_AGCCORE1(1));
- reg = RW(reg, R92C_OFDM0_AGCCORE1_GAIN, 0x32);
- urtwn_bb_write(sc, R92C_OFDM0_AGCCORE1(1), reg);
- }
urtwn_set_chan(sc, ic->ic_curchan, NULL);
break;
case IEEE80211_S_RUN:
@@ -3079,15 +3053,58 @@ urtwn_set_txpower(struct urtwn_softc *sc
}
static void
+urtwn_set_rx_bssid_all(struct urtwn_softc *sc, int enable)
+{
+ uint32_t reg;
+
+ reg = urtwn_read_4(sc, R92C_RCR);
+ if (enable)
+ reg &= ~R92C_RCR_CBSSID_BCN;
+ else
+ reg |= R92C_RCR_CBSSID_BCN;
+ urtwn_write_4(sc, R92C_RCR, reg);
+}
+
+static void
+urtwn_set_gain(struct urtwn_softc *sc, uint8_t gain)
+{
+ uint32_t reg;
+
+ reg = urtwn_bb_read(sc, R92C_OFDM0_AGCCORE1(0));
+ reg = RW(reg, R92C_OFDM0_AGCCORE1_GAIN, gain);
+ urtwn_bb_write(sc, R92C_OFDM0_AGCCORE1(0), reg);
+
+ if (!(sc->chip & URTWN_CHIP_88E)) {
+ reg = urtwn_bb_read(sc, R92C_OFDM0_AGCCORE1(1));
+ reg = RW(reg, R92C_OFDM0_AGCCORE1_GAIN, gain);
+ urtwn_bb_write(sc, R92C_OFDM0_AGCCORE1(1), reg);
+ }
+}
+
+static void
urtwn_scan_start(struct ieee80211com *ic)
{
- /* XXX do nothing? */
+ struct urtwn_softc *sc = ic->ic_softc;
+
+ URTWN_LOCK(sc);
+ /* Receive beacons / probe responses from any BSSID. */
+ urtwn_set_rx_bssid_all(sc, 1);
+ /* Set gain for scanning. */
+ urtwn_set_gain(sc, 0x20);
+ URTWN_UNLOCK(sc);
}
static void
urtwn_scan_end(struct ieee80211com *ic)
{
- /* XXX do nothing? */
+ struct urtwn_softc *sc = ic->ic_softc;
+
+ URTWN_LOCK(sc);
+ /* Restore limitations. */
+ urtwn_set_rx_bssid_all(sc, 0);
+ /* Set gain under link. */
+ urtwn_set_gain(sc, 0x32);
+ URTWN_UNLOCK(sc);
}
static void
More information about the svn-src-all
mailing list