Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/usb/wlan/if_upgt.c
Show First 20 Lines • Show All 142 Lines • ▼ Show 20 Lines | static struct ieee80211vap *upgt_vap_create(struct ieee80211com *, | ||||
const char [IFNAMSIZ], int, enum ieee80211_opmode, int, | const char [IFNAMSIZ], int, enum ieee80211_opmode, int, | ||||
const uint8_t [IEEE80211_ADDR_LEN], | const uint8_t [IEEE80211_ADDR_LEN], | ||||
const uint8_t [IEEE80211_ADDR_LEN]); | const uint8_t [IEEE80211_ADDR_LEN]); | ||||
static void upgt_vap_delete(struct ieee80211vap *); | static void upgt_vap_delete(struct ieee80211vap *); | ||||
static void upgt_update_mcast(struct ieee80211com *); | static void upgt_update_mcast(struct ieee80211com *); | ||||
static uint8_t upgt_rx_rate(struct upgt_softc *, const int); | static uint8_t upgt_rx_rate(struct upgt_softc *, const int); | ||||
static void upgt_set_multi(void *); | static void upgt_set_multi(void *); | ||||
static void upgt_stop(struct upgt_softc *); | static void upgt_stop(struct upgt_softc *); | ||||
static void upgt_setup_rates(struct ieee80211vap *, struct ieee80211com *); | static void upgt_setup_rates(struct ieee80211vap *); | ||||
static int upgt_set_macfilter(struct upgt_softc *, uint8_t); | static int upgt_set_macfilter(struct upgt_softc *, uint8_t); | ||||
static int upgt_newstate(struct ieee80211vap *, enum ieee80211_state, int); | static int upgt_newstate(struct ieee80211vap *, enum ieee80211_state, int); | ||||
static void upgt_set_chan(struct upgt_softc *, struct ieee80211_channel *); | static void upgt_set_chan(struct upgt_softc *, struct ieee80211_channel *); | ||||
static void upgt_set_led(struct upgt_softc *, int); | static void upgt_set_led(struct upgt_softc *, int); | ||||
static void upgt_set_led_blink(void *); | static void upgt_set_led_blink(void *); | ||||
static void upgt_get_stats(struct upgt_softc *); | static void upgt_get_stats(struct upgt_softc *); | ||||
static void upgt_mem_free(struct upgt_softc *, uint32_t); | static void upgt_mem_free(struct upgt_softc *, uint32_t); | ||||
static uint32_t upgt_mem_alloc(struct upgt_softc *); | static uint32_t upgt_mem_alloc(struct upgt_softc *); | ||||
▲ Show 20 Lines • Show All 514 Lines • ▼ Show 20 Lines | upgt_set_macfilter(struct upgt_softc *sc, uint8_t state) | ||||
mem->chksum = upgt_chksum_le((uint32_t *)filter, | mem->chksum = upgt_chksum_le((uint32_t *)filter, | ||||
data_cmd->buflen - sizeof(*mem)); | data_cmd->buflen - sizeof(*mem)); | ||||
upgt_bulk_tx(sc, data_cmd); | upgt_bulk_tx(sc, data_cmd); | ||||
return (0); | return (0); | ||||
} | } | ||||
static __inline uint8_t | |||||
rate_idx2value(uint16_t rate_idx) | |||||
{ | |||||
switch (rate_idx) { | |||||
case IEEE80211_RATE_INDEX_CCK1: return (0x10); | |||||
case IEEE80211_RATE_INDEX_CCK2: return (0x11); | |||||
case IEEE80211_RATE_INDEX_CCK5: return (0x12); | |||||
case IEEE80211_RATE_INDEX_CCK11: return (0x13); | |||||
case IEEE80211_RATE_INDEX_OFDM6: return (0x01); | |||||
case IEEE80211_RATE_INDEX_OFDM9: return (0x04); | |||||
case IEEE80211_RATE_INDEX_OFDM12: return (0x06); | |||||
case IEEE80211_RATE_INDEX_OFDM18: return (0x07); | |||||
case IEEE80211_RATE_INDEX_OFDM24: return (0x08); | |||||
case IEEE80211_RATE_INDEX_OFDM36: return (0x09); | |||||
case IEEE80211_RATE_INDEX_OFDM48: return (0x0a); | |||||
case IEEE80211_RATE_INDEX_OFDM54: return (0x0b); | |||||
default: | |||||
break; | |||||
} | |||||
return (0x10); | |||||
} | |||||
static void | static void | ||||
upgt_setup_rates(struct ieee80211vap *vap, struct ieee80211com *ic) | upgt_setup_rates(struct ieee80211vap *vap) | ||||
{ | { | ||||
struct upgt_softc *sc = ic->ic_softc; | struct upgt_softc *sc = vap->iv_ic->ic_softc; | ||||
const struct ieee80211_txparam *tp; | struct ieee80211com *ic = &sc->sc_ic; | ||||
const struct ieee80211_txparam_vht *tp; | |||||
uint8_t fixed_rate; | |||||
/* | /* | ||||
* 0x01 = OFMD6 0x10 = DS1 | * 0x01 = OFMD6 0x10 = DS1 | ||||
* 0x04 = OFDM9 0x11 = DS2 | * 0x04 = OFDM9 0x11 = DS2 | ||||
* 0x06 = OFDM12 0x12 = DS5 | * 0x06 = OFDM12 0x12 = DS5 | ||||
* 0x07 = OFDM18 0x13 = DS11 | * 0x07 = OFDM18 0x13 = DS11 | ||||
* 0x08 = OFDM24 | * 0x08 = OFDM24 | ||||
* 0x09 = OFDM36 | * 0x09 = OFDM36 | ||||
* 0x0a = OFDM48 | * 0x0a = OFDM48 | ||||
* 0x0b = OFDM54 | * 0x0b = OFDM54 | ||||
*/ | */ | ||||
const uint8_t rateset_auto_11b[] = | const uint8_t rateset_auto_11b[] = | ||||
{ 0x13, 0x13, 0x12, 0x11, 0x11, 0x10, 0x10, 0x10 }; | { 0x13, 0x13, 0x12, 0x11, 0x11, 0x10, 0x10, 0x10 }; | ||||
const uint8_t rateset_auto_11g[] = | const uint8_t rateset_auto_11g[] = | ||||
{ 0x0b, 0x0a, 0x09, 0x08, 0x07, 0x06, 0x04, 0x01 }; | { 0x0b, 0x0a, 0x09, 0x08, 0x07, 0x06, 0x04, 0x01 }; | ||||
const uint8_t rateset_fix_11bg[] = | |||||
{ 0x10, 0x11, 0x12, 0x13, 0x01, 0x04, 0x06, 0x07, | |||||
0x08, 0x09, 0x0a, 0x0b }; | |||||
tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)]; | tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)]; | ||||
/* XXX */ | /* XXX */ | ||||
if (tp->ucastrate == IEEE80211_FIXED_RATE_NONE) { | if (tp->ucastrate == IEEE80211_RATE_NONEXISTENT) { | ||||
/* | /* | ||||
* Automatic rate control is done by the device. | * Automatic rate control is done by the device. | ||||
* We just pass the rateset from which the device | * We just pass the rateset from which the device | ||||
* will pickup a rate. | * will pickup a rate. | ||||
*/ | */ | ||||
if (ic->ic_curmode == IEEE80211_MODE_11B) | if (ic->ic_curmode == IEEE80211_MODE_11B) | ||||
memcpy(sc->sc_cur_rateset, rateset_auto_11b, | memcpy(sc->sc_cur_rateset, rateset_auto_11b, | ||||
sizeof(sc->sc_cur_rateset)); | sizeof(sc->sc_cur_rateset)); | ||||
if (ic->ic_curmode == IEEE80211_MODE_11G || | if (ic->ic_curmode == IEEE80211_MODE_11G || | ||||
ic->ic_curmode == IEEE80211_MODE_AUTO) | ic->ic_curmode == IEEE80211_MODE_AUTO) | ||||
memcpy(sc->sc_cur_rateset, rateset_auto_11g, | memcpy(sc->sc_cur_rateset, rateset_auto_11g, | ||||
sizeof(sc->sc_cur_rateset)); | sizeof(sc->sc_cur_rateset)); | ||||
} else { | } else { | ||||
fixed_rate = rate_idx2value(tp->ucastrate); | |||||
/* set a fixed rate */ | /* set a fixed rate */ | ||||
memset(sc->sc_cur_rateset, rateset_fix_11bg[tp->ucastrate], | memset(sc->sc_cur_rateset, fixed_rate, | ||||
sizeof(sc->sc_cur_rateset)); | sizeof(sc->sc_cur_rateset)); | ||||
} | } | ||||
} | } | ||||
static void | static void | ||||
upgt_set_multi(void *arg) | upgt_set_multi(void *arg) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 234 Lines • ▼ Show 20 Lines | if (ieee80211_vap_setup(ic, vap, name, unit, opmode, | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
/* override state transition machine */ | /* override state transition machine */ | ||||
uvp->newstate = vap->iv_newstate; | uvp->newstate = vap->iv_newstate; | ||||
vap->iv_newstate = upgt_newstate; | vap->iv_newstate = upgt_newstate; | ||||
/* setup device rates */ | /* setup device rates */ | ||||
upgt_setup_rates(vap, ic); | upgt_setup_rates(vap); | ||||
/* complete setup */ | /* complete setup */ | ||||
ieee80211_vap_attach(vap, ieee80211_media_change, | ieee80211_vap_attach(vap, ieee80211_media_change, | ||||
ieee80211_media_status, mac); | ieee80211_media_status, mac); | ||||
ic->ic_opmode = opmode; | ic->ic_opmode = opmode; | ||||
return vap; | return vap; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,370 Lines • Show Last 20 Lines |