if_ath.c (165185) | if_ath.c (165571) |
---|---|
1/*- 2 * Copyright (c) 2002-2006 Sam Leffler, Errno Consulting 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 21 unchanged lines hidden (view full) --- 30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 32 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 34 * THE POSSIBILITY OF SUCH DAMAGES. 35 */ 36 37#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2002-2006 Sam Leffler, Errno Consulting 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 21 unchanged lines hidden (view full) --- 30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 32 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 34 * THE POSSIBILITY OF SUCH DAMAGES. 35 */ 36 37#include <sys/cdefs.h> |
38__FBSDID("$FreeBSD: head/sys/dev/ath/if_ath.c 165185 2006-12-13 19:34:35Z sam $"); | 38__FBSDID("$FreeBSD: head/sys/dev/ath/if_ath.c 165571 2006-12-27 19:07:09Z sam $"); |
39 40/* 41 * Driver for the Atheros Wireless LAN controller. 42 * 43 * This software is derived from work of Atsushi Onoe; his contribution 44 * is greatly appreciated. 45 */ 46 --- 118 unchanged lines hidden (view full) --- 165static void ath_stoprecv(struct ath_softc *); 166static int ath_startrecv(struct ath_softc *); 167static void ath_chan_change(struct ath_softc *, struct ieee80211_channel *); 168static void ath_next_scan(void *); 169static void ath_calibrate(void *); 170static int ath_newstate(struct ieee80211com *, enum ieee80211_state, int); 171static void ath_setup_stationkey(struct ieee80211_node *); 172static void ath_newassoc(struct ieee80211_node *, int); | 39 40/* 41 * Driver for the Atheros Wireless LAN controller. 42 * 43 * This software is derived from work of Atsushi Onoe; his contribution 44 * is greatly appreciated. 45 */ 46 --- 118 unchanged lines hidden (view full) --- 165static void ath_stoprecv(struct ath_softc *); 166static int ath_startrecv(struct ath_softc *); 167static void ath_chan_change(struct ath_softc *, struct ieee80211_channel *); 168static void ath_next_scan(void *); 169static void ath_calibrate(void *); 170static int ath_newstate(struct ieee80211com *, enum ieee80211_state, int); 171static void ath_setup_stationkey(struct ieee80211_node *); 172static void ath_newassoc(struct ieee80211_node *, int); |
173static int ath_getchannels(struct ath_softc *, u_int cc, 174 HAL_BOOL outdoor, HAL_BOOL xchanmode); | 173static int ath_getchannels(struct ath_softc *, 174 HAL_REG_DOMAIN, HAL_CTRY_CODE, HAL_BOOL, HAL_BOOL); |
175static void ath_led_event(struct ath_softc *, int); 176static void ath_update_txpow(struct ath_softc *); 177 178static int ath_rate_setup(struct ath_softc *, u_int mode); 179static void ath_setcurmode(struct ath_softc *, enum ieee80211_phymode); 180 181static void ath_sysctlattach(struct ath_softc *); 182static int ath_raw_xmit(struct ieee80211_node *, --- 6 unchanged lines hidden (view full) --- 189/* XXX validate sysctl values */ 190static int ath_dwelltime = 200; /* 5 channels/second */ 191SYSCTL_INT(_hw_ath, OID_AUTO, dwell, CTLFLAG_RW, &ath_dwelltime, 192 0, "channel dwell time (ms) for AP/station scanning"); 193static int ath_calinterval = 30; /* calibrate every 30 secs */ 194SYSCTL_INT(_hw_ath, OID_AUTO, calibrate, CTLFLAG_RW, &ath_calinterval, 195 0, "chip calibration interval (secs)"); 196static int ath_outdoor = AH_TRUE; /* outdoor operation */ | 175static void ath_led_event(struct ath_softc *, int); 176static void ath_update_txpow(struct ath_softc *); 177 178static int ath_rate_setup(struct ath_softc *, u_int mode); 179static void ath_setcurmode(struct ath_softc *, enum ieee80211_phymode); 180 181static void ath_sysctlattach(struct ath_softc *); 182static int ath_raw_xmit(struct ieee80211_node *, --- 6 unchanged lines hidden (view full) --- 189/* XXX validate sysctl values */ 190static int ath_dwelltime = 200; /* 5 channels/second */ 191SYSCTL_INT(_hw_ath, OID_AUTO, dwell, CTLFLAG_RW, &ath_dwelltime, 192 0, "channel dwell time (ms) for AP/station scanning"); 193static int ath_calinterval = 30; /* calibrate every 30 secs */ 194SYSCTL_INT(_hw_ath, OID_AUTO, calibrate, CTLFLAG_RW, &ath_calinterval, 195 0, "chip calibration interval (secs)"); 196static int ath_outdoor = AH_TRUE; /* outdoor operation */ |
197SYSCTL_INT(_hw_ath, OID_AUTO, outdoor, CTLFLAG_RD, &ath_outdoor, | 197SYSCTL_INT(_hw_ath, OID_AUTO, outdoor, CTLFLAG_RW, &ath_outdoor, |
198 0, "outdoor operation"); 199TUNABLE_INT("hw.ath.outdoor", &ath_outdoor); 200static int ath_xchanmode = AH_TRUE; /* extended channel use */ | 198 0, "outdoor operation"); 199TUNABLE_INT("hw.ath.outdoor", &ath_outdoor); 200static int ath_xchanmode = AH_TRUE; /* extended channel use */ |
201SYSCTL_INT(_hw_ath, OID_AUTO, xchanmode, CTLFLAG_RD, &ath_xchanmode, | 201SYSCTL_INT(_hw_ath, OID_AUTO, xchanmode, CTLFLAG_RW, &ath_xchanmode, |
202 0, "extended channel mode"); 203TUNABLE_INT("hw.ath.xchanmode", &ath_xchanmode); 204static int ath_countrycode = CTRY_DEFAULT; /* country code */ | 202 0, "extended channel mode"); 203TUNABLE_INT("hw.ath.xchanmode", &ath_xchanmode); 204static int ath_countrycode = CTRY_DEFAULT; /* country code */ |
205SYSCTL_INT(_hw_ath, OID_AUTO, countrycode, CTLFLAG_RD, &ath_countrycode, | 205SYSCTL_INT(_hw_ath, OID_AUTO, countrycode, CTLFLAG_RW, &ath_countrycode, |
206 0, "country code"); 207TUNABLE_INT("hw.ath.countrycode", &ath_countrycode); 208static int ath_regdomain = 0; /* regulatory domain */ 209SYSCTL_INT(_hw_ath, OID_AUTO, regdomain, CTLFLAG_RD, &ath_regdomain, 210 0, "regulatory domain"); 211 212static int ath_rxbuf = ATH_RXBUF; /* # rx buffers to allocate */ | 206 0, "country code"); 207TUNABLE_INT("hw.ath.countrycode", &ath_countrycode); 208static int ath_regdomain = 0; /* regulatory domain */ 209SYSCTL_INT(_hw_ath, OID_AUTO, regdomain, CTLFLAG_RD, &ath_regdomain, 210 0, "regulatory domain"); 211 212static int ath_rxbuf = ATH_RXBUF; /* # rx buffers to allocate */ |
213SYSCTL_INT(_hw_ath, OID_AUTO, rxbuf, CTLFLAG_RD, &ath_rxbuf, | 213SYSCTL_INT(_hw_ath, OID_AUTO, rxbuf, CTLFLAG_RW, &ath_rxbuf, |
214 0, "rx buffers allocated"); 215TUNABLE_INT("hw.ath.rxbuf", &ath_rxbuf); 216static int ath_txbuf = ATH_TXBUF; /* # tx buffers to allocate */ | 214 0, "rx buffers allocated"); 215TUNABLE_INT("hw.ath.rxbuf", &ath_rxbuf); 216static int ath_txbuf = ATH_TXBUF; /* # tx buffers to allocate */ |
217SYSCTL_INT(_hw_ath, OID_AUTO, txbuf, CTLFLAG_RD, &ath_txbuf, | 217SYSCTL_INT(_hw_ath, OID_AUTO, txbuf, CTLFLAG_RW, &ath_txbuf, |
218 0, "tx buffers allocated"); 219TUNABLE_INT("hw.ath.txbuf", &ath_txbuf); 220 221#ifdef ATH_DEBUG 222static int ath_debug = 0; 223SYSCTL_INT(_hw_ath, OID_AUTO, debug, CTLFLAG_RW, &ath_debug, 224 0, "control debugging printfs"); 225TUNABLE_INT("hw.ath.debug", &ath_debug); --- 120 unchanged lines hidden (view full) --- 346 ath_hal_keyreset(ah, i); 347 348 /* 349 * Collect the channel list using the default country 350 * code and including outdoor channels. The 802.11 layer 351 * is resposible for filtering this list based on settings 352 * like the phy mode. 353 */ | 218 0, "tx buffers allocated"); 219TUNABLE_INT("hw.ath.txbuf", &ath_txbuf); 220 221#ifdef ATH_DEBUG 222static int ath_debug = 0; 223SYSCTL_INT(_hw_ath, OID_AUTO, debug, CTLFLAG_RW, &ath_debug, 224 0, "control debugging printfs"); 225TUNABLE_INT("hw.ath.debug", &ath_debug); --- 120 unchanged lines hidden (view full) --- 346 ath_hal_keyreset(ah, i); 347 348 /* 349 * Collect the channel list using the default country 350 * code and including outdoor channels. The 802.11 layer 351 * is resposible for filtering this list based on settings 352 * like the phy mode. 353 */ |
354 error = ath_getchannels(sc, ath_countrycode, 355 ath_outdoor, ath_xchanmode); | 354 error = ath_getchannels(sc, ath_regdomain, ath_countrycode, 355 ath_xchanmode != 0, ath_outdoor != 0); |
356 if (error != 0) 357 goto bad; 358 359 /* 360 * Setup rate tables for all potential media types. 361 */ 362 ath_rate_setup(sc, IEEE80211_MODE_11A); 363 ath_rate_setup(sc, IEEE80211_MODE_11B); 364 ath_rate_setup(sc, IEEE80211_MODE_11G); 365 ath_rate_setup(sc, IEEE80211_MODE_TURBO_A); 366 ath_rate_setup(sc, IEEE80211_MODE_TURBO_G); | 356 if (error != 0) 357 goto bad; 358 359 /* 360 * Setup rate tables for all potential media types. 361 */ 362 ath_rate_setup(sc, IEEE80211_MODE_11A); 363 ath_rate_setup(sc, IEEE80211_MODE_11B); 364 ath_rate_setup(sc, IEEE80211_MODE_11G); 365 ath_rate_setup(sc, IEEE80211_MODE_TURBO_A); 366 ath_rate_setup(sc, IEEE80211_MODE_TURBO_G); |
367 ath_rate_setup(sc, IEEE80211_MODE_11A_HALF); 368 ath_rate_setup(sc, IEEE80211_MODE_11A_QUARTER); 369 |
|
367 /* NB: setup here so ath_rate_update is happy */ 368 ath_setcurmode(sc, IEEE80211_MODE_11A); 369 370 /* 371 * Allocate tx+rx descriptors and populate the lists. 372 */ 373 error = ath_desc_alloc(sc); 374 if (error != 0) { --- 519 unchanged lines hidden (view full) --- 894 0, /* IEEE80211_MODE_FH */ 895 CHANNEL_ST, /* IEEE80211_MODE_TURBO_A */ 896 CHANNEL_108G /* IEEE80211_MODE_TURBO_G */ 897 }; 898 enum ieee80211_phymode mode = ieee80211_chan2mode(ic, chan); 899 900 KASSERT(mode < N(modeflags), ("unexpected phy mode %u", mode)); 901 KASSERT(modeflags[mode] != 0, ("mode %u undefined", mode)); | 370 /* NB: setup here so ath_rate_update is happy */ 371 ath_setcurmode(sc, IEEE80211_MODE_11A); 372 373 /* 374 * Allocate tx+rx descriptors and populate the lists. 375 */ 376 error = ath_desc_alloc(sc); 377 if (error != 0) { --- 519 unchanged lines hidden (view full) --- 897 0, /* IEEE80211_MODE_FH */ 898 CHANNEL_ST, /* IEEE80211_MODE_TURBO_A */ 899 CHANNEL_108G /* IEEE80211_MODE_TURBO_G */ 900 }; 901 enum ieee80211_phymode mode = ieee80211_chan2mode(ic, chan); 902 903 KASSERT(mode < N(modeflags), ("unexpected phy mode %u", mode)); 904 KASSERT(modeflags[mode] != 0, ("mode %u undefined", mode)); |
905 if (IEEE80211_IS_CHAN_HALF(chan)) 906 return modeflags[mode] | CHANNEL_HALF; 907 if (IEEE80211_IS_CHAN_QUARTER(chan)) 908 return modeflags[mode] | CHANNEL_QUARTER; |
|
902 return modeflags[mode]; 903#undef N 904} 905 906static void 907ath_init(void *arg) 908{ 909 struct ath_softc *sc = (struct ath_softc *) arg; --- 935 unchanged lines hidden (view full) --- 1845/* 1846 * Set the slot time based on the current setting. 1847 */ 1848static void 1849ath_setslottime(struct ath_softc *sc) 1850{ 1851 struct ieee80211com *ic = &sc->sc_ic; 1852 struct ath_hal *ah = sc->sc_ah; | 909 return modeflags[mode]; 910#undef N 911} 912 913static void 914ath_init(void *arg) 915{ 916 struct ath_softc *sc = (struct ath_softc *) arg; --- 935 unchanged lines hidden (view full) --- 1852/* 1853 * Set the slot time based on the current setting. 1854 */ 1855static void 1856ath_setslottime(struct ath_softc *sc) 1857{ 1858 struct ieee80211com *ic = &sc->sc_ic; 1859 struct ath_hal *ah = sc->sc_ah; |
1860 u_int usec; |
|
1853 | 1861 |
1854 if (ic->ic_flags & IEEE80211_F_SHSLOT) 1855 ath_hal_setslottime(ah, HAL_SLOT_TIME_9); | 1862 if (IEEE80211_IS_CHAN_A(ic->ic_curchan)) { 1863 if (IEEE80211_IS_CHAN_HALF(ic->ic_curchan)) 1864 usec = 13; 1865 else if (IEEE80211_IS_CHAN_QUARTER(ic->ic_curchan)) 1866 usec = 21; 1867 else 1868 usec = HAL_SLOT_TIME_9; 1869 } else if (ic->ic_flags & IEEE80211_F_SHSLOT) 1870 usec = HAL_SLOT_TIME_9; |
1856 else | 1871 else |
1857 ath_hal_setslottime(ah, HAL_SLOT_TIME_20); | 1872 usec = HAL_SLOT_TIME_20; 1873 1874 DPRINTF(sc, ATH_DEBUG_RESET, 1875 "%s: chan %u MHz flags 0x%x %s slot, %u usec\n", 1876 __func__, ic->ic_curchan->ic_freq, ic->ic_curchan->ic_flags, 1877 ic->ic_flags & IEEE80211_F_SHSLOT ? "short" : "long", usec); 1878 1879 ath_hal_setslottime(ah, usec); |
1858 sc->sc_updateslot = OK; 1859} 1860 1861/* 1862 * Callback from the 802.11 layer to update the 1863 * slot time based on the current setting. 1864 */ 1865static void --- 2426 unchanged lines hidden (view full) --- 4292 enum ieee80211_phymode mode; 4293 u_int16_t flags; 4294 4295 /* 4296 * Change channels and update the h/w rate map 4297 * if we're switching; e.g. 11a to 11b/g. 4298 */ 4299 mode = ieee80211_chan2mode(ic, chan); | 1880 sc->sc_updateslot = OK; 1881} 1882 1883/* 1884 * Callback from the 802.11 layer to update the 1885 * slot time based on the current setting. 1886 */ 1887static void --- 2426 unchanged lines hidden (view full) --- 4314 enum ieee80211_phymode mode; 4315 u_int16_t flags; 4316 4317 /* 4318 * Change channels and update the h/w rate map 4319 * if we're switching; e.g. 11a to 11b/g. 4320 */ 4321 mode = ieee80211_chan2mode(ic, chan); |
4322 if (mode == IEEE80211_MODE_11A) { 4323 if (IEEE80211_IS_CHAN_HALF(chan)) 4324 mode = IEEE80211_MODE_11A_HALF; 4325 else if (IEEE80211_IS_CHAN_QUARTER(chan)) 4326 mode = IEEE80211_MODE_11A_QUARTER; 4327 } |
|
4300 if (mode != sc->sc_curmode) 4301 ath_setcurmode(sc, mode); 4302 /* 4303 * Update BPF state. NB: ethereal et. al. don't handle 4304 * merged flags well so pick a unique mode for their use. 4305 */ 4306 if (IEEE80211_IS_CHAN_A(chan)) 4307 flags = IEEE80211_CHAN_A; 4308 /* XXX 11g schizophrenia */ | 4328 if (mode != sc->sc_curmode) 4329 ath_setcurmode(sc, mode); 4330 /* 4331 * Update BPF state. NB: ethereal et. al. don't handle 4332 * merged flags well so pick a unique mode for their use. 4333 */ 4334 if (IEEE80211_IS_CHAN_A(chan)) 4335 flags = IEEE80211_CHAN_A; 4336 /* XXX 11g schizophrenia */ |
4309 else if (IEEE80211_IS_CHAN_G(chan) || 4310 IEEE80211_IS_CHAN_PUREG(chan)) | 4337 else if (IEEE80211_IS_CHAN_ANYG(chan)) |
4311 flags = IEEE80211_CHAN_G; 4312 else 4313 flags = IEEE80211_CHAN_B; 4314 if (IEEE80211_IS_CHAN_T(chan)) 4315 flags |= IEEE80211_CHAN_TURBO; 4316 sc->sc_tx_th.wt_chan_freq = sc->sc_rx_th.wr_chan_freq = 4317 htole16(chan->ic_freq); 4318 sc->sc_tx_th.wt_chan_flags = sc->sc_rx_th.wr_chan_flags = --- 417 unchanged lines hidden (view full) --- 4736 KASSERT(ni->ni_ucastkey.wk_keyix == IEEE80211_KEYIX_NONE, 4737 ("new assoc with a unicast key already setup (keyix %u)", 4738 ni->ni_ucastkey.wk_keyix)); 4739 ath_setup_stationkey(ni); 4740 } 4741} 4742 4743static int | 4338 flags = IEEE80211_CHAN_G; 4339 else 4340 flags = IEEE80211_CHAN_B; 4341 if (IEEE80211_IS_CHAN_T(chan)) 4342 flags |= IEEE80211_CHAN_TURBO; 4343 sc->sc_tx_th.wt_chan_freq = sc->sc_rx_th.wr_chan_freq = 4344 htole16(chan->ic_freq); 4345 sc->sc_tx_th.wt_chan_flags = sc->sc_rx_th.wr_chan_flags = --- 417 unchanged lines hidden (view full) --- 4763 KASSERT(ni->ni_ucastkey.wk_keyix == IEEE80211_KEYIX_NONE, 4764 ("new assoc with a unicast key already setup (keyix %u)", 4765 ni->ni_ucastkey.wk_keyix)); 4766 ath_setup_stationkey(ni); 4767 } 4768} 4769 4770static int |
4744ath_getchannels(struct ath_softc *sc, u_int cc, 4745 HAL_BOOL outdoor, HAL_BOOL xchanmode) | 4771ath_getchannels(struct ath_softc *sc, 4772 HAL_REG_DOMAIN rd, HAL_CTRY_CODE cc, HAL_BOOL outdoor, HAL_BOOL xchanmode) |
4746{ | 4773{ |
4747#define COMPAT (CHANNEL_ALL_NOTURBO|CHANNEL_PASSIVE) | 4774#define COMPAT \ 4775 (CHANNEL_ALL_NOTURBO|CHANNEL_PASSIVE|CHANNEL_HALF|CHANNEL_QUARTER) |
4748#define IS_CHAN_PUBLIC_SAFETY(_c) \ 4749 (((_c)->channelFlags & CHANNEL_5GHZ) && \ 4750 ((_c)->channel > 4940 && (_c)->channel < 4990)) 4751 struct ieee80211com *ic = &sc->sc_ic; 4752 struct ifnet *ifp = sc->sc_ifp; 4753 struct ath_hal *ah = sc->sc_ah; 4754 HAL_CHANNEL *chans; 4755 int i, ix, nchan; | 4776#define IS_CHAN_PUBLIC_SAFETY(_c) \ 4777 (((_c)->channelFlags & CHANNEL_5GHZ) && \ 4778 ((_c)->channel > 4940 && (_c)->channel < 4990)) 4779 struct ieee80211com *ic = &sc->sc_ic; 4780 struct ifnet *ifp = sc->sc_ifp; 4781 struct ath_hal *ah = sc->sc_ah; 4782 HAL_CHANNEL *chans; 4783 int i, ix, nchan; |
4784 u_int32_t regdomain; |
|
4756 4757 chans = malloc(IEEE80211_CHAN_MAX * sizeof(HAL_CHANNEL), 4758 M_TEMP, M_NOWAIT); 4759 if (chans == NULL) { 4760 if_printf(ifp, "unable to allocate channel table\n"); 4761 return ENOMEM; 4762 } 4763 if (!ath_hal_init_channels(ah, chans, IEEE80211_CHAN_MAX, &nchan, | 4785 4786 chans = malloc(IEEE80211_CHAN_MAX * sizeof(HAL_CHANNEL), 4787 M_TEMP, M_NOWAIT); 4788 if (chans == NULL) { 4789 if_printf(ifp, "unable to allocate channel table\n"); 4790 return ENOMEM; 4791 } 4792 if (!ath_hal_init_channels(ah, chans, IEEE80211_CHAN_MAX, &nchan, |
4764 NULL, 0, NULL, 4765 cc, HAL_MODE_ALL, outdoor, xchanmode)) { 4766 u_int32_t rd; 4767 4768 ath_hal_getregdomain(ah, &rd); | 4793 NULL, 0, NULL, cc, HAL_MODE_ALL, outdoor, xchanmode)) { 4794 ath_hal_getregdomain(ah, ®domain); |
4769 if_printf(ifp, "unable to collect channel list from hal; " | 4795 if_printf(ifp, "unable to collect channel list from hal; " |
4770 "regdomain likely %u country code %u\n", rd, cc); | 4796 "regdomain likely %u country code %u\n", regdomain, cc); |
4771 free(chans, M_TEMP); 4772 return EINVAL; 4773 } 4774 4775 /* 4776 * Convert HAL channels to ieee80211 ones and insert 4777 * them in the table according to their channel number. 4778 */ | 4797 free(chans, M_TEMP); 4798 return EINVAL; 4799 } 4800 4801 /* 4802 * Convert HAL channels to ieee80211 ones and insert 4803 * them in the table according to their channel number. 4804 */ |
4805 memset(ic->ic_channels, 0, sizeof(ic->ic_channels)); |
|
4779 for (i = 0; i < nchan; i++) { 4780 HAL_CHANNEL *c = &chans[i]; 4781 u_int16_t flags; 4782 4783 /* 4784 * XXX we're not ready to handle the ieee number mapping 4785 * for public safety channels as they overlap with any | 4806 for (i = 0; i < nchan; i++) { 4807 HAL_CHANNEL *c = &chans[i]; 4808 u_int16_t flags; 4809 4810 /* 4811 * XXX we're not ready to handle the ieee number mapping 4812 * for public safety channels as they overlap with any |
4786 * 2GHz channels; for now use the non-public safety 4787 * numbering which is non-overlapping. | 4813 * 2GHz channels; for now use a non-public safety 4814 * numbering that is non-overlapping. |
4788 */ | 4815 */ |
4816 ix = ath_hal_mhz2ieee(ah, c->channel, c->channelFlags); |
|
4789 if (IS_CHAN_PUBLIC_SAFETY(c)) | 4817 if (IS_CHAN_PUBLIC_SAFETY(c)) |
4790 ix = (c->channel - 4000) / 5; 4791 else 4792 ix = ath_hal_mhz2ieee(ah, c->channel, c->channelFlags); | 4818 ix += 37; /* XXX */ |
4793 if (ix > IEEE80211_CHAN_MAX) { 4794 if_printf(ifp, "bad hal channel %d (%u/%x) ignored\n", 4795 ix, c->channel, c->channelFlags); 4796 continue; 4797 } 4798 if (ix < 0) { 4799 /* XXX can't handle stuff <2400 right now */ 4800 if (bootverbose) --- 15 unchanged lines hidden (view full) --- 4816 ic->ic_channels[ix].ic_freq = c->channel; 4817 ic->ic_channels[ix].ic_flags = flags; 4818 } else { 4819 /* channels overlap; e.g. 11g and 11b */ 4820 ic->ic_channels[ix].ic_flags |= flags; 4821 } 4822 } 4823 free(chans, M_TEMP); | 4819 if (ix > IEEE80211_CHAN_MAX) { 4820 if_printf(ifp, "bad hal channel %d (%u/%x) ignored\n", 4821 ix, c->channel, c->channelFlags); 4822 continue; 4823 } 4824 if (ix < 0) { 4825 /* XXX can't handle stuff <2400 right now */ 4826 if (bootverbose) --- 15 unchanged lines hidden (view full) --- 4842 ic->ic_channels[ix].ic_freq = c->channel; 4843 ic->ic_channels[ix].ic_flags = flags; 4844 } else { 4845 /* channels overlap; e.g. 11g and 11b */ 4846 ic->ic_channels[ix].ic_flags |= flags; 4847 } 4848 } 4849 free(chans, M_TEMP); |
4850 ath_hal_getregdomain(ah, &sc->sc_regdomain); 4851 ath_hal_getcountrycode(ah, &sc->sc_countrycode); 4852 sc->sc_xchanmode = xchanmode; 4853 sc->sc_outdoor = outdoor; |
|
4824 return 0; 4825#undef IS_CHAN_PUBLIC_SAFETY 4826#undef COMPAT 4827} 4828 4829static void 4830ath_led_done(void *arg) 4831{ --- 66 unchanged lines hidden (view full) --- 4898 } 4899 /* 4900 * Fetch max tx power level for status requests. 4901 */ 4902 ath_hal_getmaxtxpow(sc->sc_ah, &txpow); 4903 ic->ic_bss->ni_txpower = txpow; 4904} 4905 | 4854 return 0; 4855#undef IS_CHAN_PUBLIC_SAFETY 4856#undef COMPAT 4857} 4858 4859static void 4860ath_led_done(void *arg) 4861{ --- 66 unchanged lines hidden (view full) --- 4928 } 4929 /* 4930 * Fetch max tx power level for status requests. 4931 */ 4932 ath_hal_getmaxtxpow(sc->sc_ah, &txpow); 4933 ic->ic_bss->ni_txpower = txpow; 4934} 4935 |
4906static void 4907rate_setup(struct ath_softc *sc, 4908 const HAL_RATE_TABLE *rt, struct ieee80211_rateset *rs) 4909{ 4910 int i, maxrates; 4911 4912 if (rt->rateCount > IEEE80211_RATE_MAXSIZE) { 4913 DPRINTF(sc, ATH_DEBUG_ANY, 4914 "%s: rate table too small (%u > %u)\n", 4915 __func__, rt->rateCount, IEEE80211_RATE_MAXSIZE); 4916 maxrates = IEEE80211_RATE_MAXSIZE; 4917 } else 4918 maxrates = rt->rateCount; 4919 for (i = 0; i < maxrates; i++) 4920 rs->rs_rates[i] = rt->info[i].dot11Rate; 4921 rs->rs_nrates = maxrates; 4922} 4923 | |
4924static int 4925ath_rate_setup(struct ath_softc *sc, u_int mode) 4926{ 4927 struct ath_hal *ah = sc->sc_ah; | 4936static int 4937ath_rate_setup(struct ath_softc *sc, u_int mode) 4938{ 4939 struct ath_hal *ah = sc->sc_ah; |
4928 struct ieee80211com *ic = &sc->sc_ic; | |
4929 const HAL_RATE_TABLE *rt; 4930 4931 switch (mode) { 4932 case IEEE80211_MODE_11A: 4933 rt = ath_hal_getratetable(ah, HAL_MODE_11A); 4934 break; | 4940 const HAL_RATE_TABLE *rt; 4941 4942 switch (mode) { 4943 case IEEE80211_MODE_11A: 4944 rt = ath_hal_getratetable(ah, HAL_MODE_11A); 4945 break; |
4946 case IEEE80211_MODE_11A_HALF: 4947 rt = ath_hal_getratetable(ah, HAL_MODE_11A_HALF_RATE); 4948 break; 4949 case IEEE80211_MODE_11A_QUARTER: 4950 rt = ath_hal_getratetable(ah, HAL_MODE_11A_QUARTER_RATE); 4951 break; |
|
4935 case IEEE80211_MODE_11B: 4936 rt = ath_hal_getratetable(ah, HAL_MODE_11B); 4937 break; 4938 case IEEE80211_MODE_11G: 4939 rt = ath_hal_getratetable(ah, HAL_MODE_11G); 4940 break; 4941 case IEEE80211_MODE_TURBO_A: 4942 /* XXX until static/dynamic turbo is fixed */ 4943 rt = ath_hal_getratetable(ah, HAL_MODE_TURBO); 4944 break; 4945 case IEEE80211_MODE_TURBO_G: 4946 rt = ath_hal_getratetable(ah, HAL_MODE_108G); 4947 break; 4948 default: 4949 DPRINTF(sc, ATH_DEBUG_ANY, "%s: invalid mode %u\n", 4950 __func__, mode); 4951 return 0; 4952 } 4953 sc->sc_rates[mode] = rt; | 4952 case IEEE80211_MODE_11B: 4953 rt = ath_hal_getratetable(ah, HAL_MODE_11B); 4954 break; 4955 case IEEE80211_MODE_11G: 4956 rt = ath_hal_getratetable(ah, HAL_MODE_11G); 4957 break; 4958 case IEEE80211_MODE_TURBO_A: 4959 /* XXX until static/dynamic turbo is fixed */ 4960 rt = ath_hal_getratetable(ah, HAL_MODE_TURBO); 4961 break; 4962 case IEEE80211_MODE_TURBO_G: 4963 rt = ath_hal_getratetable(ah, HAL_MODE_108G); 4964 break; 4965 default: 4966 DPRINTF(sc, ATH_DEBUG_ANY, "%s: invalid mode %u\n", 4967 __func__, mode); 4968 return 0; 4969 } 4970 sc->sc_rates[mode] = rt; |
4954 if (rt != NULL) { 4955 rate_setup(sc, rt, &ic->ic_sup_rates[mode]); 4956 return 1; 4957 } else 4958 return 0; | 4971 return (rt != NULL); |
4959} 4960 4961static void 4962ath_setcurmode(struct ath_softc *sc, enum ieee80211_phymode mode) 4963{ 4964#define N(a) (sizeof(a)/sizeof(a[0])) 4965 /* NB: on/off times from the Atheros NDIS driver, w/ permission */ 4966 static const struct { --- 448 unchanged lines hidden (view full) --- 5415 if (!ath_hal_setrfsilent(sc->sc_ah, rfsilent)) 5416 return EINVAL; 5417 sc->sc_rfsilentpin = rfsilent & 0x1c; 5418 sc->sc_rfsilentpol = (rfsilent & 0x2) != 0; 5419 return 0; 5420} 5421 5422static int | 4972} 4973 4974static void 4975ath_setcurmode(struct ath_softc *sc, enum ieee80211_phymode mode) 4976{ 4977#define N(a) (sizeof(a)/sizeof(a[0])) 4978 /* NB: on/off times from the Atheros NDIS driver, w/ permission */ 4979 static const struct { --- 448 unchanged lines hidden (view full) --- 5428 if (!ath_hal_setrfsilent(sc->sc_ah, rfsilent)) 5429 return EINVAL; 5430 sc->sc_rfsilentpin = rfsilent & 0x1c; 5431 sc->sc_rfsilentpol = (rfsilent & 0x2) != 0; 5432 return 0; 5433} 5434 5435static int |
5436ath_sysctl_countrycode(SYSCTL_HANDLER_ARGS) 5437{ 5438 struct ath_softc *sc = arg1; 5439 u_int32_t cc = sc->sc_countrycode; 5440 struct ieee80211com *ic = &sc->sc_ic; 5441 int error; 5442 5443 error = sysctl_handle_int(oidp, &cc, 0, req); 5444 if (error || !req->newptr) 5445 return error; 5446 error = ath_getchannels(sc, sc->sc_regdomain, cc, 5447 sc->sc_outdoor, sc->sc_xchanmode); 5448 if (error != 0) 5449 return error; 5450 ieee80211_media_init(ic, ath_media_change, ieee80211_media_status); 5451 /* setcurmode? */ 5452 return 0; 5453} 5454 5455static int |
|
5423ath_sysctl_regdomain(SYSCTL_HANDLER_ARGS) 5424{ 5425 struct ath_softc *sc = arg1; | 5456ath_sysctl_regdomain(SYSCTL_HANDLER_ARGS) 5457{ 5458 struct ath_softc *sc = arg1; |
5426 u_int32_t rd; | 5459 u_int32_t rd = sc->sc_regdomain; 5460 struct ieee80211com *ic = &sc->sc_ic; |
5427 int error; 5428 | 5461 int error; 5462 |
5429 if (!ath_hal_getregdomain(sc->sc_ah, &rd)) 5430 return EINVAL; | |
5431 error = sysctl_handle_int(oidp, &rd, 0, req); 5432 if (error || !req->newptr) 5433 return error; | 5463 error = sysctl_handle_int(oidp, &rd, 0, req); 5464 if (error || !req->newptr) 5465 return error; |
5434 return !ath_hal_setregdomain(sc->sc_ah, rd) ? EINVAL : 0; | 5466 if (!ath_hal_setregdomain(sc->sc_ah, rd)) 5467 return EINVAL; 5468 error = ath_getchannels(sc, rd, sc->sc_countrycode, 5469 sc->sc_outdoor, sc->sc_xchanmode); 5470 if (error != 0) 5471 return error; 5472 ieee80211_media_init(ic, ath_media_change, ieee80211_media_status); 5473 /* setcurmode? */ 5474 return 0; |
5435} 5436 5437static int 5438ath_sysctl_tpack(SYSCTL_HANDLER_ARGS) 5439{ 5440 struct ath_softc *sc = arg1; 5441 u_int32_t tpack; 5442 int error; --- 21 unchanged lines hidden (view full) --- 5464 5465static void 5466ath_sysctlattach(struct ath_softc *sc) 5467{ 5468 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev); 5469 struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev); 5470 struct ath_hal *ah = sc->sc_ah; 5471 | 5475} 5476 5477static int 5478ath_sysctl_tpack(SYSCTL_HANDLER_ARGS) 5479{ 5480 struct ath_softc *sc = arg1; 5481 u_int32_t tpack; 5482 int error; --- 21 unchanged lines hidden (view full) --- 5504 5505static void 5506ath_sysctlattach(struct ath_softc *sc) 5507{ 5508 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev); 5509 struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev); 5510 struct ath_hal *ah = sc->sc_ah; 5511 |
5472 ath_hal_getcountrycode(sc->sc_ah, &sc->sc_countrycode); 5473 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, 5474 "countrycode", CTLFLAG_RD, &sc->sc_countrycode, 0, 5475 "EEPROM country code"); | |
5476 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, | 5512 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, |
5513 "countrycode", CTLTYPE_INT | CTLFLAG_RW, sc, 0, 5514 ath_sysctl_countrycode, "I", "country code"); 5515 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, |
|
5477 "regdomain", CTLTYPE_INT | CTLFLAG_RW, sc, 0, 5478 ath_sysctl_regdomain, "I", "EEPROM regdomain code"); 5479#ifdef ATH_DEBUG 5480 sc->sc_debug = ath_debug; 5481 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, 5482 "debug", CTLFLAG_RW, &sc->sc_debug, 0, 5483 "control debugging printfs"); 5484#endif --- 371 unchanged lines hidden --- | 5516 "regdomain", CTLTYPE_INT | CTLFLAG_RW, sc, 0, 5517 ath_sysctl_regdomain, "I", "EEPROM regdomain code"); 5518#ifdef ATH_DEBUG 5519 sc->sc_debug = ath_debug; 5520 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, 5521 "debug", CTLFLAG_RW, &sc->sc_debug, 0, 5522 "control debugging printfs"); 5523#endif --- 371 unchanged lines hidden --- |