Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/bwi/bwimac.c
Show First 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | |||||
}; | }; | ||||
static int bwi_mac_test(struct bwi_mac *); | static int bwi_mac_test(struct bwi_mac *); | ||||
static int bwi_mac_get_property(struct bwi_mac *); | static int bwi_mac_get_property(struct bwi_mac *); | ||||
static void bwi_mac_set_retry_lim(struct bwi_mac *, | static void bwi_mac_set_retry_lim(struct bwi_mac *, | ||||
const struct bwi_retry_lim *); | const struct bwi_retry_lim *); | ||||
static void bwi_mac_set_ackrates(struct bwi_mac *, | static void bwi_mac_set_ackrates(struct bwi_mac *, | ||||
const struct ieee80211_rate_table *rt, | |||||
const struct ieee80211_rateset *); | const struct ieee80211_rateset *); | ||||
static int bwi_mac_gpio_init(struct bwi_mac *); | static int bwi_mac_gpio_init(struct bwi_mac *); | ||||
static int bwi_mac_gpio_fini(struct bwi_mac *); | static int bwi_mac_gpio_fini(struct bwi_mac *); | ||||
static void bwi_mac_opmode_init(struct bwi_mac *); | static void bwi_mac_opmode_init(struct bwi_mac *); | ||||
static void bwi_mac_hostflags_init(struct bwi_mac *); | static void bwi_mac_hostflags_init(struct bwi_mac *); | ||||
static void bwi_mac_bss_param_init(struct bwi_mac *); | static void bwi_mac_bss_param_init(struct bwi_mac *); | ||||
▲ Show 20 Lines • Show All 1,227 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static void | static void | ||||
bwi_mac_bss_param_init(struct bwi_mac *mac) | bwi_mac_bss_param_init(struct bwi_mac *mac) | ||||
{ | { | ||||
struct bwi_softc *sc = mac->mac_sc; | struct bwi_softc *sc = mac->mac_sc; | ||||
struct bwi_phy *phy = &mac->mac_phy; | struct bwi_phy *phy = &mac->mac_phy; | ||||
struct ieee80211com *ic = &sc->sc_ic; | struct ieee80211com *ic = &sc->sc_ic; | ||||
const struct ieee80211_rate_table *rt; | enum ieee80211_phymode mode; | ||||
struct bwi_retry_lim lim; | struct bwi_retry_lim lim; | ||||
uint16_t cw_min; | uint16_t cw_min; | ||||
/* | /* | ||||
* Set short/long retry limits | * Set short/long retry limits | ||||
*/ | */ | ||||
bzero(&lim, sizeof(lim)); | bzero(&lim, sizeof(lim)); | ||||
lim.shretry = BWI_SHRETRY; | lim.shretry = BWI_SHRETRY; | ||||
lim.shretry_fb = BWI_SHRETRY_FB; | lim.shretry_fb = BWI_SHRETRY_FB; | ||||
lim.lgretry = BWI_LGRETRY; | lim.lgretry = BWI_LGRETRY; | ||||
lim.lgretry_fb = BWI_LGRETRY_FB; | lim.lgretry_fb = BWI_LGRETRY_FB; | ||||
bwi_mac_set_retry_lim(mac, &lim); | bwi_mac_set_retry_lim(mac, &lim); | ||||
/* | /* | ||||
* Implicitly prevent firmware from sending probe response | * Implicitly prevent firmware from sending probe response | ||||
* by setting its "probe response timeout" to 1us. | * by setting its "probe response timeout" to 1us. | ||||
*/ | */ | ||||
MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_PROBE_RESP_TO, 1); | MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_PROBE_RESP_TO, 1); | ||||
/* | /* | ||||
* XXX MAC level acknowledge and CW min/max should depend | * XXX MAC level acknowledge and CW min/max should depend | ||||
* on the char rateset of the IBSS/BSS to join. | * on the char rateset of the IBSS/BSS to join. | ||||
* XXX this is all wrong; should be done on channel change | * XXX this is all wrong; should be done on channel change | ||||
*/ | */ | ||||
if (phy->phy_mode == IEEE80211_MODE_11B) { | if (phy->phy_mode == IEEE80211_MODE_11B) | ||||
rt = ieee80211_get_ratetable( | mode = IEEE80211_MODE_11B; | ||||
ieee80211_find_channel(ic, 2412, IEEE80211_CHAN_B)); | else | ||||
bwi_mac_set_ackrates(mac, rt, | mode = IEEE80211_MODE_11G; | ||||
&ic->ic_sup_rates[IEEE80211_MODE_11B]); | bwi_mac_set_ackrates(mac, ic->ic_sup_rates[mode]); | ||||
} else { | |||||
rt = ieee80211_get_ratetable( | |||||
ieee80211_find_channel(ic, 2412, IEEE80211_CHAN_G)); | |||||
bwi_mac_set_ackrates(mac, rt, | |||||
&ic->ic_sup_rates[IEEE80211_MODE_11G]); | |||||
} | |||||
/* | /* | ||||
* Set CW min | * Set CW min | ||||
*/ | */ | ||||
if (phy->phy_mode == IEEE80211_MODE_11B) | if (phy->phy_mode == IEEE80211_MODE_11B) | ||||
cw_min = IEEE80211_CW_MIN_0; | cw_min = IEEE80211_CW_MIN_0; | ||||
else | else | ||||
cw_min = IEEE80211_CW_MIN_1; | cw_min = IEEE80211_CW_MIN_1; | ||||
Show All 18 Lines | bwi_mac_set_retry_lim(struct bwi_mac *mac, const struct bwi_retry_lim *lim) | ||||
/* Short/Long retry fallback limit */ | /* Short/Long retry fallback limit */ | ||||
MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_SHRETRY_FB, | MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_SHRETRY_FB, | ||||
lim->shretry_fb); | lim->shretry_fb); | ||||
MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_LGRETEY_FB, | MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, BWI_COMM_MOBJ_LGRETEY_FB, | ||||
lim->lgretry_fb); | lim->lgretry_fb); | ||||
} | } | ||||
static void | static void | ||||
bwi_mac_set_ackrates(struct bwi_mac *mac, const struct ieee80211_rate_table *rt, | bwi_mac_set_ackrates(struct bwi_mac *mac, const struct ieee80211_rateset *rs) | ||||
const struct ieee80211_rateset *rs) | |||||
{ | { | ||||
int i; | int i; | ||||
/* XXX not standard conforming */ | /* XXX not standard conforming */ | ||||
for (i = 0; i < rs->rs_nrates; ++i) { | for (i = 0; i < rs->rs_nrates; ++i) { | ||||
const struct ieee80211_rate_t *rate; | |||||
enum ieee80211_phytype modtype; | enum ieee80211_phytype modtype; | ||||
uint16_t ofs; | uint16_t ofs; | ||||
modtype = ieee80211_rate2phytype(rt, | rate = ieee80211_get_rate(rs->rates[i].rs_index); | ||||
rs->rs_rates[i] & IEEE80211_RATE_VAL); | modtype = rate->type; | ||||
switch (modtype) { | switch (modtype) { | ||||
case IEEE80211_T_DS: | case IEEE80211_T_DS: | ||||
ofs = 0x4c0; | ofs = 0x4c0; | ||||
break; | break; | ||||
case IEEE80211_T_OFDM: | case IEEE80211_T_OFDM: | ||||
ofs = 0x480; | ofs = 0x480; | ||||
break; | break; | ||||
default: | default: | ||||
panic("unsupported modtype %u\n", modtype); | panic("unsupported modtype %u\n", modtype); | ||||
} | } | ||||
ofs += 2*(ieee80211_rate2plcp( | ofs += 2 * (ieee80211_rate2plcp(rate->value, modtype) & 0xf); | ||||
rs->rs_rates[i] & IEEE80211_RATE_VAL, | |||||
modtype) & 0xf); | |||||
MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, ofs + 0x20, | MOBJ_WRITE_2(mac, BWI_COMM_MOBJ, ofs + 0x20, | ||||
MOBJ_READ_2(mac, BWI_COMM_MOBJ, ofs)); | MOBJ_READ_2(mac, BWI_COMM_MOBJ, ofs)); | ||||
} | } | ||||
} | } | ||||
int | int | ||||
bwi_mac_start(struct bwi_mac *mac) | bwi_mac_start(struct bwi_mac *mac) | ||||
▲ Show 20 Lines • Show All 530 Lines • Show Last 20 Lines |