1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-30 16:51:41 +00:00

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
This commit is contained in:
Andriy Voskoboinyk 2015-10-27 14:21:24 +00:00
parent fe920528c1
commit 240dd2906d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=290048

View File

@ -264,6 +264,8 @@ static void urtwn_r88e_get_txpower(struct urtwn_softc *, int,
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, enum ieee80211_state nstate, int arg)
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, enum ieee80211_state nstate, int arg)
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:
@ -3078,16 +3052,59 @@ urtwn_set_txpower(struct urtwn_softc *sc, struct ieee80211_channel *c,
}
}
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