commit 3dd1938aedb4be5a83572038a17bcdc4c1dce83f Author: Jiri Slaby Date: Mon Jun 25 11:01:57 2007 +0200 set_curmode diff --git a/ath/if_ath_pci.c b/ath/if_ath_pci.c index c09c0cb..6435a29 100644 --- a/ath/if_ath_pci.c +++ b/ath/if_ath_pci.c @@ -363,11 +363,11 @@ static int ath_getchannels(struct ieee80211_hw *hw) unsigned int i, max; int ret; enum { - A = 0, - B = 1, - G = 2, - T = 3, - TG = 4, + A = MODE_IEEE80211A, + B = MODE_IEEE80211B, + G = MODE_IEEE80211G, + T = MODE_ATHEROS_TURBO, + TG = MODE_ATHEROS_TURBOG, }; BUILD_BUG_ON(ARRAY_SIZE(sc->modes) < 5); @@ -422,15 +422,14 @@ static int ath_getchannels(struct ieee80211_hw *hw) err: return ret; } -#if 0 + static void ath_setcurmode(struct ath_softc *sc, unsigned int mode) { - /* NB: on/off times from the Atheros NDIS driver, w/ permission */ -#ifdef BLE + /* from Atheros NDIS driver, w/ permission */ static const struct { - u_int rate; /* tx/rx 802.11 rate */ - u_int16_t timeOn; /* LED on time (ms) */ - u_int16_t timeOff; /* LED off time (ms) */ + u16 rate; /* tx/rx 802.11 rate */ + u16 timeOn; /* LED on time (ms) */ + u16 timeOff; /* LED off time (ms) */ } blinkrates[] = { { 108, 40, 10 }, { 96, 44, 11 }, @@ -445,56 +444,42 @@ static void ath_setcurmode(struct ath_softc *sc, unsigned int mode) { 6, 240, 58 }, { 4, 267, 66 }, { 2, 400, 100 }, - { 0, 500, 130 }, + { 0, 500, 130 } }; -#endif - const struct ath5k_rate_table *rt; -// int i, j; - memset(sc->sc_rixmap, 0xff, sizeof(sc->sc_rixmap)); - rt = sc->sc_rates[mode]; + const struct ath5k_rate_table* rt=ath5k_hw_get_rate_table(sc->ah, mode); + unsigned int i, j; + KASSERT(rt != NULL, "no h/w rate set for phy mode %u", mode); -#ifdef BLE - for (i = 0; i < rt->rate_count; i++) - sc->sc_rixmap[rt->rates[i].dot11_rate & IEEE80211_RATE_VAL] = i; - memset(sc->sc_hwmap, 0, sizeof(sc->sc_hwmap)); + + memset(sc->hwmap, 0, sizeof(sc->hwmap)); for (i = 0; i < 32; i++) { - u_int8_t ix = rt->rate_code_to_index[i]; + u8 ix = rt->rate_code_to_index[i]; if (ix == 0xff) { - sc->sc_hwmap[i].ledon = (500 * HZ) / 1000; - sc->sc_hwmap[i].ledoff = (130 * HZ) / 1000; + sc->hwmap[i].ledon = msecs_to_jiffies(500); + sc->hwmap[i].ledoff = msecs_to_jiffies(130); continue; } - sc->sc_hwmap[i].ieeerate = - rt->rates[ix].dot11_rate & IEEE80211_RATE_VAL; - sc->sc_hwmap[i].txflags = IEEE80211_RADIOTAP_F_DATAPAD; - if (SHPREAMBLE_FLAG(ix) || - rt->rates[ix].modulation == MODULATION_OFDM) - sc->sc_hwmap[i].txflags |= IEEE80211_RADIOTAP_F_SHORTPRE; - /* NB: receive frames include FCS */ - sc->sc_hwmap[i].rxflags = sc->sc_hwmap[i].txflags | - IEEE80211_RADIOTAP_F_FCS; + sc->hwmap[i].txflags = IEEE80211_RADIOTAP_F_DATAPAD; + if (SHPREAMBLE_FLAG(ix) || rt->rates[ix].modulation == + MODULATION_OFDM) + sc->hwmap[i].txflags |= IEEE80211_RADIOTAP_F_SHORTPRE; + /* receive frames include FCS */ + sc->hwmap[i].rxflags = sc->hwmap[i].txflags | + IEEE80211_RADIOTAP_F_FCS; /* setup blink rate table to avoid per-packet lookup */ - for (j = 0; j < N(blinkrates)-1; j++) - if (blinkrates[j].rate == sc->sc_hwmap[i].ieeerate) + for (j = 0; j < ARRAY_SIZE(blinkrates) - 1; j++) + if (blinkrates[j].rate == /* XXX why 7f? */ + (rt->rates[ix].dot11_rate & 0x7f)) break; - /* NB: this uses the last entry if the rate isn't found */ - /* XXX beware of overlow */ - sc->sc_hwmap[i].ledon = (blinkrates[j].timeOn * HZ) / 1000; - sc->sc_hwmap[i].ledoff = (blinkrates[j].timeOff * HZ) / 1000; + + sc->hwmap[i].ledon = msecs_to_jiffies(blinkrates[j].timeOn); + sc->hwmap[i].ledoff = msecs_to_jiffies(blinkrates[j].timeOff); } -#endif - sc->sc_currates = rt; - sc->sc_curmode = mode; - /* - * All protection frames are transmited at 2Mb/s for - * 11g, otherwise at 1Mb/s. - * XXX select protection rate index from rate table. - */ - sc->sc_protrix = ((mode == MODE_IEEE80211G || mode == MODE_ATHEROS_TURBOG) ? 1 : 0); - /* NB: caller is responsible for reseting rate control state */ -} + sc->curmode = mode; +} +#if 0 static int ath_desc_alloc(struct ath_softc *sc) { #define DS2PHYS(_sc, _ds) \ @@ -625,9 +610,13 @@ static int ath_attach(struct pci_dev *pdev, struct ieee80211_hw *hw) dev_err(&pdev->dev, "can't get channels\n"); goto err; } -#ifdef BLE + /* NB: setup here so ath_rate_update is happy */ - ath_setcurmode(sc, MODE_IEEE80211A); + if (test_bit(MODE_IEEE80211A, ah->ah_modes)) + ath_setcurmode(sc, MODE_IEEE80211A); + else + ath_setcurmode(sc, MODE_IEEE80211B); +#ifdef BLE /* * Allocate tx+rx descriptors and populate the lists. diff --git a/ath/if_athvar.h b/ath/if_athvar.h index 6e84246..1f15e18 100644 --- a/ath/if_athvar.h +++ b/ath/if_athvar.h @@ -227,17 +227,21 @@ struct ath_softc { /* rate tables */ const struct ath5k_rate_table *sc_rates[NUM_IEEE80211_MODES]; const struct ath5k_rate_table *sc_currates; /* current rate table */ - unsigned int sc_curmode; /* current phy mode */ +#endif + unsigned int curmode; /* current phy mode */ +#ifdef BLE u16 sc_curtxpow; /* current tx power limit */ struct ieee80211_channel sc_curchan; /* current h/w channel */ u8 sc_rixmap[256]; /* IEEE to h/w rate table ix */ +#endif struct { - u8 ieeerate; /* IEEE rate */ +// int ieeerate; /* IEEE rate */ u8 rxflags; /* radiotap rx flags */ u8 txflags; /* radiotap tx flags */ u16 ledon; /* softled on time */ u16 ledoff; /* softled off time */ - } sc_hwmap[32]; /* h/w rate ix mappings */ + } hwmap[32]; /* h/w rate ix mappings */ +#ifdef BLE u8 sc_protrix; /* protection rate index */ u_int sc_txantenna; /* tx antenna (fixed or auto) */ #endif