Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/usb/wlan/if_uath.c
Show First 20 Lines • Show All 1,882 Lines • ▼ Show 20 Lines | uath_set_rxfilter(sc, | ||||
UATH_FILTER_RX_PROM, UATH_FILTER_OP_SET); | UATH_FILTER_RX_PROM, UATH_FILTER_OP_SET); | ||||
} | } | ||||
UATH_UNLOCK(sc); | UATH_UNLOCK(sc); | ||||
} | } | ||||
static int | static int | ||||
uath_create_connection(struct uath_softc *sc, uint32_t connid) | uath_create_connection(struct uath_softc *sc, uint32_t connid) | ||||
{ | { | ||||
const struct ieee80211_rate_t *rate; | |||||
const struct ieee80211_rateset *rs; | const struct ieee80211_rateset *rs; | ||||
struct ieee80211com *ic = &sc->sc_ic; | struct ieee80211com *ic = &sc->sc_ic; | ||||
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); | struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); | ||||
struct ieee80211_node *ni; | struct ieee80211_node *ni; | ||||
struct uath_cmd_create_connection create; | struct uath_cmd_create_connection create; | ||||
struct uath_cmd_rateset *uath_rs; | |||||
int i; | |||||
ni = ieee80211_ref_node(vap->iv_bss); | ni = ieee80211_ref_node(vap->iv_bss); | ||||
memset(&create, 0, sizeof(create)); | memset(&create, 0, sizeof(create)); | ||||
create.connid = htobe32(connid); | create.connid = htobe32(connid); | ||||
create.bssid = htobe32(0); | create.bssid = htobe32(0); | ||||
/* XXX packed or not? */ | /* XXX packed or not? */ | ||||
create.size = htobe32(sizeof(struct uath_cmd_rateset)); | create.size = htobe32(sizeof(struct uath_cmd_rateset)); | ||||
rs = &ni->ni_rates; | rs = &ni->ni_rates; | ||||
create.connattr.rateset.length = rs->rs_nrates; | uath_rs = &create.connattr.rateset; | ||||
bcopy(rs->rs_rates, &create.connattr.rateset.set[0], | |||||
rs->rs_nrates); | |||||
uath_rs->length = MIN(rs->rs_nrates, nitems(uath_rs->set)); | |||||
for (i = 0; i < uath_rs->length; i++) { | |||||
rate = ieee80211_get_rate(rs->rates[i].rs_index); | |||||
uath_rs->set[i] = rate->value; | |||||
} | |||||
/* XXX turbo */ | /* XXX turbo */ | ||||
if (IEEE80211_IS_CHAN_A(ni->ni_chan)) | if (IEEE80211_IS_CHAN_A(ni->ni_chan)) | ||||
create.connattr.wlanmode = htobe32(WLAN_MODE_11a); | create.connattr.wlanmode = htobe32(WLAN_MODE_11a); | ||||
else if (IEEE80211_IS_CHAN_ANYG(ni->ni_chan)) | else if (IEEE80211_IS_CHAN_ANYG(ni->ni_chan)) | ||||
create.connattr.wlanmode = htobe32(WLAN_MODE_11g); | create.connattr.wlanmode = htobe32(WLAN_MODE_11g); | ||||
else | else | ||||
create.connattr.wlanmode = htobe32(WLAN_MODE_11b); | create.connattr.wlanmode = htobe32(WLAN_MODE_11b); | ||||
ieee80211_free_node(ni); | ieee80211_free_node(ni); | ||||
return uath_cmd_write(sc, WDCMSG_CREATE_CONNECTION, &create, | return uath_cmd_write(sc, WDCMSG_CREATE_CONNECTION, &create, | ||||
sizeof create, 0); | sizeof create, 0); | ||||
} | } | ||||
static int | static int | ||||
uath_set_rates(struct uath_softc *sc, const struct ieee80211_rateset *rs) | uath_set_rates(struct uath_softc *sc, const struct ieee80211_rateset *rs) | ||||
{ | { | ||||
const struct ieee80211_rate_t *rate; | |||||
struct uath_cmd_rates rates; | struct uath_cmd_rates rates; | ||||
int i; | |||||
memset(&rates, 0, sizeof(rates)); | memset(&rates, 0, sizeof(rates)); | ||||
rates.connid = htobe32(UATH_ID_BSS); /* XXX */ | rates.connid = htobe32(UATH_ID_BSS); /* XXX */ | ||||
rates.size = htobe32(sizeof(struct uath_cmd_rateset)); | rates.size = htobe32(sizeof(struct uath_cmd_rateset)); | ||||
/* XXX bounds check rs->rs_nrates */ | rates.rateset.length = MIN(rs->rs_nrates, nitems(rates.rateset.set)); | ||||
rates.rateset.length = rs->rs_nrates; | for (i = 0; i < rates.rateset.length; i++) { | ||||
bcopy(rs->rs_rates, &rates.rateset.set[0], rs->rs_nrates); | rate = ieee80211_get_rate(rs->rates[i].rs_index); | ||||
rates.rateset.set[i] = rate->value; | |||||
} | |||||
DPRINTF(sc, UATH_DEBUG_RATES, | DPRINTF(sc, UATH_DEBUG_RATES, | ||||
"setting supported rates nrates=%d\n", rs->rs_nrates); | "setting supported rates nrates=%d\n", rs->rs_nrates); | ||||
return uath_cmd_write(sc, WDCMSG_SET_BASIC_RATE, | return uath_cmd_write(sc, WDCMSG_SET_BASIC_RATE, | ||||
&rates, sizeof rates, 0); | &rates, sizeof rates, 0); | ||||
} | } | ||||
static int | static int | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | DPRINTF(sc, UATH_DEBUG_LED, "set %s led %s (blink)\n", | ||||
(lednum == UATH_LED_LINK) ? "link" : "activity", | (lednum == UATH_LED_LINK) ? "link" : "activity", | ||||
ledmode ? "on" : "off"); | ledmode ? "on" : "off"); | ||||
return uath_cmd_write(sc, WDCMSG_SET_LED_BLINK, &led, sizeof led, 0); | return uath_cmd_write(sc, WDCMSG_SET_LED_BLINK, &led, sizeof led, 0); | ||||
} | } | ||||
static int | static int | ||||
uath_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) | uath_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) | ||||
{ | { | ||||
const struct ieee80211_rateset *rs; | |||||
enum ieee80211_state ostate = vap->iv_state; | enum ieee80211_state ostate = vap->iv_state; | ||||
int error; | int error; | ||||
struct ieee80211_node *ni; | struct ieee80211_node *ni; | ||||
struct ieee80211com *ic = vap->iv_ic; | struct ieee80211com *ic = vap->iv_ic; | ||||
struct uath_softc *sc = ic->ic_softc; | struct uath_softc *sc = ic->ic_softc; | ||||
struct uath_vap *uvp = UATH_VAP(vap); | struct uath_vap *uvp = UATH_VAP(vap); | ||||
DPRINTF(sc, UATH_DEBUG_STATE, | DPRINTF(sc, UATH_DEBUG_STATE, | ||||
"%s: %s -> %s\n", __func__, ieee80211_state_name[vap->iv_state], | "%s: %s -> %s\n", __func__, ieee80211_state_name[vap->iv_state], | ||||
ieee80211_state_name[nstate]); | ieee80211_state_name[nstate]); | ||||
IEEE80211_UNLOCK(ic); | IEEE80211_UNLOCK(ic); | ||||
UATH_LOCK(sc); | UATH_LOCK(sc); | ||||
callout_stop(&sc->stat_ch); | callout_stop(&sc->stat_ch); | ||||
callout_stop(&sc->watchdog_ch); | callout_stop(&sc->watchdog_ch); | ||||
ni = ieee80211_ref_node(vap->iv_bss); | ni = ieee80211_ref_node(vap->iv_bss); | ||||
rs = &ni->ni_rates; | |||||
switch (nstate) { | switch (nstate) { | ||||
case IEEE80211_S_INIT: | case IEEE80211_S_INIT: | ||||
if (ostate == IEEE80211_S_RUN) { | if (ostate == IEEE80211_S_RUN) { | ||||
/* turn link and activity LEDs off */ | /* turn link and activity LEDs off */ | ||||
uath_set_ledstate(sc, 0); | uath_set_ledstate(sc, 0); | ||||
} | } | ||||
break; | break; | ||||
Show All 18 Lines | case IEEE80211_S_AUTH: | ||||
if (uath_create_connection(sc, UATH_ID_BSS) != 0) { | if (uath_create_connection(sc, UATH_ID_BSS) != 0) { | ||||
device_printf(sc->sc_dev, | device_printf(sc->sc_dev, | ||||
"could not create connection\n"); | "could not create connection\n"); | ||||
break; | break; | ||||
} | } | ||||
break; | break; | ||||
case IEEE80211_S_ASSOC: | case IEEE80211_S_ASSOC: | ||||
if (uath_set_rates(sc, &ni->ni_rates) != 0) { | if (uath_set_rates(sc, rs) != 0) { | ||||
device_printf(sc->sc_dev, | device_printf(sc->sc_dev, | ||||
"could not set negotiated rate set\n"); | "could not set negotiated rate set\n"); | ||||
break; | break; | ||||
} | } | ||||
break; | break; | ||||
case IEEE80211_S_RUN: | case IEEE80211_S_RUN: | ||||
/* XXX monitor mode doesn't be tested */ | /* XXX monitor mode doesn't be tested */ | ||||
if (ic->ic_opmode == IEEE80211_M_MONITOR) { | if (ic->ic_opmode == IEEE80211_M_MONITOR) { | ||||
uath_set_ledstate(sc, 1); | uath_set_ledstate(sc, 1); | ||||
break; | break; | ||||
} | } | ||||
/* | /* | ||||
* Tx rate is controlled by firmware, report the maximum | * Tx rate is controlled by firmware, report the maximum | ||||
* negotiated rate in ifconfig output. | * negotiated rate in ifconfig output. | ||||
*/ | */ | ||||
ni->ni_txrate = ni->ni_rates.rs_rates[ni->ni_rates.rs_nrates-1]; | ni->ni_txrate = rs->rates[rs->rs_nrates - 1].rs_index; | ||||
if (uath_write_associd(sc) != 0) { | if (uath_write_associd(sc) != 0) { | ||||
device_printf(sc->sc_dev, | device_printf(sc->sc_dev, | ||||
"could not write association id\n"); | "could not write association id\n"); | ||||
break; | break; | ||||
} | } | ||||
/* turn link LED on */ | /* turn link LED on */ | ||||
uath_set_ledsteady(sc, UATH_LED_LINK, UATH_LED_ON); | uath_set_ledsteady(sc, UATH_LED_LINK, UATH_LED_ON); | ||||
▲ Show 20 Lines • Show All 810 Lines • Show Last 20 Lines |