ath9k: Revamp wireless mode usage

Use a single enum for managing modes, store supported modes by
the HW in a bitmask.
Register legacy rates with mac80211 only at init.

Signed-off-by: Sujith Manoharan <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by Sujith and committed by John W. Linville 86b89eed 3b95978d

+203 -322
+15 -33
drivers/net/wireless/ath9k/ath9k.h
··· 147 148 #define ATH9K_RXDESC_INTREQ 0x0020 149 150 enum ath9k_hw_caps { 151 ATH9K_HW_CAP_CHAN_SPREAD = BIT(0), 152 ATH9K_HW_CAP_MIC_AESCCM = BIT(1), ··· 203 204 struct ath9k_hw_capabilities { 205 u32 hw_caps; /* ATH9K_HW_CAP_* from ath9k_hw_caps */ 206 - u32 wireless_modes; 207 u16 total_queues; 208 u16 keycache_size; 209 u16 low_5ghz_chan, high_5ghz_chan; ··· 826 #endif 827 }; 828 829 - enum wireless_mode { 830 - WIRELESS_MODE_11a = 0, 831 - WIRELESS_MODE_11b = 2, 832 - WIRELESS_MODE_11g = 3, 833 - WIRELESS_MODE_11NA_HT20 = 6, 834 - WIRELESS_MODE_11NG_HT20 = 7, 835 - WIRELESS_MODE_11NA_HT40PLUS = 8, 836 - WIRELESS_MODE_11NA_HT40MINUS = 9, 837 - WIRELESS_MODE_11NG_HT40PLUS = 10, 838 - WIRELESS_MODE_11NG_HT40MINUS = 11, 839 - WIRELESS_MODE_MAX 840 - }; 841 - 842 - enum { 843 - ATH9K_MODE_SEL_11A = 0x00001, 844 - ATH9K_MODE_SEL_11B = 0x00002, 845 - ATH9K_MODE_SEL_11G = 0x00004, 846 - ATH9K_MODE_SEL_11NG_HT20 = 0x00008, 847 - ATH9K_MODE_SEL_11NA_HT20 = 0x00010, 848 - ATH9K_MODE_SEL_11NG_HT40PLUS = 0x00020, 849 - ATH9K_MODE_SEL_11NG_HT40MINUS = 0x00040, 850 - ATH9K_MODE_SEL_11NA_HT40PLUS = 0x00080, 851 - ATH9K_MODE_SEL_11NA_HT40MINUS = 0x00100, 852 - ATH9K_MODE_SEL_2GHZ = (ATH9K_MODE_SEL_11B | 853 - ATH9K_MODE_SEL_11G | 854 - ATH9K_MODE_SEL_11NG_HT20), 855 - ATH9K_MODE_SEL_5GHZ = (ATH9K_MODE_SEL_11A | 856 - ATH9K_MODE_SEL_11NA_HT20), 857 - ATH9K_MODE_SEL_ALL = 0xffffffff 858 - }; 859 - 860 struct chan_centers { 861 u16 synth_center; 862 u16 ctl_center; ··· 847 u32 maxchans, u32 *nchans, 848 u8 *regclassids, 849 u32 maxregids, u32 *nregids, 850 - u16 cc, u32 modeSelect, 851 bool enableOutdoor, 852 bool enableExtendedChannels); 853 u32 ath9k_hw_mhz2ieee(struct ath_hal *ah, u32 freq, u32 flags);
··· 147 148 #define ATH9K_RXDESC_INTREQ 0x0020 149 150 + enum wireless_mode { 151 + ATH9K_MODE_11A = 0, 152 + ATH9K_MODE_11B = 2, 153 + ATH9K_MODE_11G = 3, 154 + ATH9K_MODE_11NA_HT20 = 6, 155 + ATH9K_MODE_11NG_HT20 = 7, 156 + ATH9K_MODE_11NA_HT40PLUS = 8, 157 + ATH9K_MODE_11NA_HT40MINUS = 9, 158 + ATH9K_MODE_11NG_HT40PLUS = 10, 159 + ATH9K_MODE_11NG_HT40MINUS = 11, 160 + ATH9K_MODE_MAX 161 + }; 162 + 163 enum ath9k_hw_caps { 164 ATH9K_HW_CAP_CHAN_SPREAD = BIT(0), 165 ATH9K_HW_CAP_MIC_AESCCM = BIT(1), ··· 190 191 struct ath9k_hw_capabilities { 192 u32 hw_caps; /* ATH9K_HW_CAP_* from ath9k_hw_caps */ 193 + DECLARE_BITMAP(wireless_modes, ATH9K_MODE_MAX); /* ATH9K_MODE_* */ 194 u16 total_queues; 195 u16 keycache_size; 196 u16 low_5ghz_chan, high_5ghz_chan; ··· 813 #endif 814 }; 815 816 struct chan_centers { 817 u16 synth_center; 818 u16 ctl_center; ··· 865 u32 maxchans, u32 *nchans, 866 u8 *regclassids, 867 u32 maxregids, u32 *nregids, 868 + u16 cc, 869 bool enableOutdoor, 870 bool enableExtendedChannels); 871 u32 ath9k_hw_mhz2ieee(struct ath_hal *ah, u32 freq, u32 flags);
+1 -1
drivers/net/wireless/ath9k/beacon.c
··· 108 * Calculate rate code. 109 * XXX everything at min xmit rate 110 */ 111 - rix = sc->sc_minrateix; 112 rt = sc->sc_currates; 113 rate = rt->info[rix].rateCode; 114 if (sc->sc_flags & ATH_PREAMBLE_SHORT)
··· 108 * Calculate rate code. 109 * XXX everything at min xmit rate 110 */ 111 + rix = 0; 112 rt = sc->sc_currates; 113 rate = rt->info[rix].rateCode; 114 if (sc->sc_flags & ATH_PREAMBLE_SHORT)
+52 -94
drivers/net/wireless/ath9k/core.c
··· 64 int i; 65 66 memset(sc->sc_rixmap, 0xff, sizeof(sc->sc_rixmap)); 67 - rt = sc->sc_rates[mode]; 68 BUG_ON(!rt); 69 70 for (i = 0; i < rt->rateCount; i++) ··· 96 * 11g, otherwise at 1Mb/s. 97 * XXX select protection rate index from rate table. 98 */ 99 - sc->sc_protrix = (mode == WIRELESS_MODE_11g ? 1 : 0); 100 - /* rate index used to send mgt frames */ 101 - sc->sc_minrateix = 0; 102 } 103 104 /* 105 - * Select Rate Table 106 - * 107 - * Based on the wireless mode passed in, the rate table in the ATH object 108 - * is set to the mode specific rate table. This also calls the callback 109 - * function to set the rate in the protocol layer object. 110 - */ 111 - 112 - static int ath_rate_setup(struct ath_softc *sc, enum wireless_mode mode) 113 { 114 struct ath_hal *ah = sc->sc_ah; 115 - const struct ath9k_rate_table *rt; 116 117 - switch (mode) { 118 - case WIRELESS_MODE_11a: 119 - sc->sc_rates[mode] = 120 - ath9k_hw_getratetable(ah, ATH9K_MODE_SEL_11A); 121 break; 122 - case WIRELESS_MODE_11b: 123 - sc->sc_rates[mode] = 124 - ath9k_hw_getratetable(ah, ATH9K_MODE_SEL_11B); 125 - break; 126 - case WIRELESS_MODE_11g: 127 - sc->sc_rates[mode] = 128 - ath9k_hw_getratetable(ah, ATH9K_MODE_SEL_11G); 129 - break; 130 - case WIRELESS_MODE_11NA_HT20: 131 - sc->sc_rates[mode] = 132 - ath9k_hw_getratetable(ah, ATH9K_MODE_SEL_11NA_HT20); 133 - break; 134 - case WIRELESS_MODE_11NG_HT20: 135 - sc->sc_rates[mode] = 136 - ath9k_hw_getratetable(ah, ATH9K_MODE_SEL_11NG_HT20); 137 - break; 138 - case WIRELESS_MODE_11NA_HT40PLUS: 139 - sc->sc_rates[mode] = 140 - ath9k_hw_getratetable(ah, ATH9K_MODE_SEL_11NA_HT40PLUS); 141 - break; 142 - case WIRELESS_MODE_11NA_HT40MINUS: 143 - sc->sc_rates[mode] = 144 - ath9k_hw_getratetable(ah, 145 - ATH9K_MODE_SEL_11NA_HT40MINUS); 146 - break; 147 - case WIRELESS_MODE_11NG_HT40PLUS: 148 - sc->sc_rates[mode] = 149 - ath9k_hw_getratetable(ah, ATH9K_MODE_SEL_11NG_HT40PLUS); 150 - break; 151 - case WIRELESS_MODE_11NG_HT40MINUS: 152 - sc->sc_rates[mode] = 153 - ath9k_hw_getratetable(ah, 154 - ATH9K_MODE_SEL_11NG_HT40MINUS); 155 break; 156 default: 157 - DPRINTF(sc, ATH_DBG_FATAL, "%s: invalid mode %u\n", 158 - __func__, mode); 159 - return 0; 160 } 161 - rt = sc->sc_rates[mode]; 162 if (rt == NULL) 163 - return 0; 164 165 - /* setup rate set in 802.11 protocol layer */ 166 - ath_setup_rate(sc, mode, NORMAL_RATE, rt); 167 168 - return 1; 169 } 170 171 /* ··· 167 ATH_REGCLASSIDS_MAX, 168 &nregclass, 169 CTRY_DEFAULT, 170 - ATH9K_MODE_SEL_ALL, 171 false, 172 1)) { 173 u32 rd = ah->ah_currentRD; ··· 242 static enum wireless_mode ath_chan2mode(struct ath9k_channel *chan) 243 { 244 if (chan->chanmode == CHANNEL_A) 245 - return WIRELESS_MODE_11a; 246 else if (chan->chanmode == CHANNEL_G) 247 - return WIRELESS_MODE_11g; 248 else if (chan->chanmode == CHANNEL_B) 249 - return WIRELESS_MODE_11b; 250 else if (chan->chanmode == CHANNEL_A_HT20) 251 - return WIRELESS_MODE_11NA_HT20; 252 else if (chan->chanmode == CHANNEL_G_HT20) 253 - return WIRELESS_MODE_11NG_HT20; 254 else if (chan->chanmode == CHANNEL_A_HT40PLUS) 255 - return WIRELESS_MODE_11NA_HT40PLUS; 256 else if (chan->chanmode == CHANNEL_A_HT40MINUS) 257 - return WIRELESS_MODE_11NA_HT40MINUS; 258 else if (chan->chanmode == CHANNEL_G_HT40PLUS) 259 - return WIRELESS_MODE_11NG_HT40PLUS; 260 else if (chan->chanmode == CHANNEL_G_HT40MINUS) 261 - return WIRELESS_MODE_11NG_HT40MINUS; 262 263 /* NB: should not get here */ 264 - return WIRELESS_MODE_11b; 265 - } 266 - 267 - /* 268 - * Change Channels 269 - * 270 - * Performs the actions to change the channel in the hardware, and set up 271 - * the current operating mode for the new channel. 272 - */ 273 - 274 - static void ath_chan_change(struct ath_softc *sc, struct ath9k_channel *chan) 275 - { 276 - enum wireless_mode mode; 277 - 278 - mode = ath_chan2mode(chan); 279 - 280 - ath_rate_setup(sc, mode); 281 - ath_setcurmode(sc, mode); 282 } 283 284 /* ··· 438 * Change channels and update the h/w rate map 439 * if we're switching; e.g. 11a to 11b/g. 440 */ 441 - ath_chan_change(sc, hchan); 442 ath_update_txpow(sc); /* update tx power state */ 443 /* 444 * Re-enable interrupts. ··· 819 * vap and node data structures, which will be needed as soon 820 * as we start receiving. 821 */ 822 - ath_chan_change(sc, initial_chan); 823 824 /* XXX: we must make sure h/w is ready and clear invalid flag 825 * before turning on interrupt. */ ··· 861 * that changes the channel so update any state that 862 * might change as a result. 863 */ 864 - ath_chan_change(sc, &sc->sc_curchan); 865 866 ath_update_txpow(sc); /* update tx power state */ 867 ··· 1171 /* default to STA mode */ 1172 sc->sc_opmode = ATH9K_M_MONITOR; 1173 1174 - /* Setup rate tables for all potential media types. */ 1175 - /* 11g encompasses b,g */ 1176 1177 - ath_rate_setup(sc, WIRELESS_MODE_11a); 1178 - ath_rate_setup(sc, WIRELESS_MODE_11g); 1179 1180 /* NB: setup here so ath_rate_update is happy */ 1181 - ath_setcurmode(sc, WIRELESS_MODE_11a); 1182 1183 /* 1184 * Allocate hardware transmit queues: one queue for
··· 64 int i; 65 66 memset(sc->sc_rixmap, 0xff, sizeof(sc->sc_rixmap)); 67 + rt = ath9k_hw_getratetable(sc->sc_ah, mode); 68 BUG_ON(!rt); 69 70 for (i = 0; i < rt->rateCount; i++) ··· 96 * 11g, otherwise at 1Mb/s. 97 * XXX select protection rate index from rate table. 98 */ 99 + sc->sc_protrix = (mode == ATH9K_MODE_11G ? 1 : 0); 100 } 101 102 /* 103 + * Set up rate table (legacy rates) 104 + */ 105 + static void ath_setup_rates(struct ath_softc *sc, enum ieee80211_band band) 106 { 107 struct ath_hal *ah = sc->sc_ah; 108 + const struct ath9k_rate_table *rt = NULL; 109 + struct ieee80211_supported_band *sband; 110 + struct ieee80211_rate *rate; 111 + int i, maxrates; 112 113 + switch (band) { 114 + case IEEE80211_BAND_2GHZ: 115 + rt = ath9k_hw_getratetable(ah, ATH9K_MODE_11G); 116 break; 117 + case IEEE80211_BAND_5GHZ: 118 + rt = ath9k_hw_getratetable(ah, ATH9K_MODE_11A); 119 break; 120 default: 121 + break; 122 } 123 + 124 if (rt == NULL) 125 + return; 126 127 + sband = &sc->sbands[band]; 128 + rate = sc->rates[band]; 129 130 + if (rt->rateCount > ATH_RATE_MAX) 131 + maxrates = ATH_RATE_MAX; 132 + else 133 + maxrates = rt->rateCount; 134 + 135 + for (i = 0; i < maxrates; i++) { 136 + rate[i].bitrate = rt->info[i].rateKbps / 100; 137 + rate[i].hw_value = rt->info[i].rateCode; 138 + sband->n_bitrates++; 139 + DPRINTF(sc, ATH_DBG_CONFIG, 140 + "%s: Rate: %2dMbps, ratecode: %2d\n", 141 + __func__, 142 + rate[i].bitrate / 10, 143 + rate[i].hw_value); 144 + } 145 } 146 147 /* ··· 191 ATH_REGCLASSIDS_MAX, 192 &nregclass, 193 CTRY_DEFAULT, 194 false, 195 1)) { 196 u32 rd = ah->ah_currentRD; ··· 267 static enum wireless_mode ath_chan2mode(struct ath9k_channel *chan) 268 { 269 if (chan->chanmode == CHANNEL_A) 270 + return ATH9K_MODE_11A; 271 else if (chan->chanmode == CHANNEL_G) 272 + return ATH9K_MODE_11G; 273 else if (chan->chanmode == CHANNEL_B) 274 + return ATH9K_MODE_11B; 275 else if (chan->chanmode == CHANNEL_A_HT20) 276 + return ATH9K_MODE_11NA_HT20; 277 else if (chan->chanmode == CHANNEL_G_HT20) 278 + return ATH9K_MODE_11NG_HT20; 279 else if (chan->chanmode == CHANNEL_A_HT40PLUS) 280 + return ATH9K_MODE_11NA_HT40PLUS; 281 else if (chan->chanmode == CHANNEL_A_HT40MINUS) 282 + return ATH9K_MODE_11NA_HT40MINUS; 283 else if (chan->chanmode == CHANNEL_G_HT40PLUS) 284 + return ATH9K_MODE_11NG_HT40PLUS; 285 else if (chan->chanmode == CHANNEL_G_HT40MINUS) 286 + return ATH9K_MODE_11NG_HT40MINUS; 287 288 /* NB: should not get here */ 289 + return ATH9K_MODE_11B; 290 } 291 292 /* ··· 480 * Change channels and update the h/w rate map 481 * if we're switching; e.g. 11a to 11b/g. 482 */ 483 + ath_setcurmode(sc, ath_chan2mode(hchan)); 484 + 485 ath_update_txpow(sc); /* update tx power state */ 486 /* 487 * Re-enable interrupts. ··· 860 * vap and node data structures, which will be needed as soon 861 * as we start receiving. 862 */ 863 + ath_setcurmode(sc, ath_chan2mode(initial_chan)); 864 865 /* XXX: we must make sure h/w is ready and clear invalid flag 866 * before turning on interrupt. */ ··· 902 * that changes the channel so update any state that 903 * might change as a result. 904 */ 905 + ath_setcurmode(sc, ath_chan2mode(&sc->sc_curchan)); 906 907 ath_update_txpow(sc); /* update tx power state */ 908 ··· 1212 /* default to STA mode */ 1213 sc->sc_opmode = ATH9K_M_MONITOR; 1214 1215 + /* Setup rate tables */ 1216 1217 + ath_setup_rates(sc, IEEE80211_BAND_2GHZ); 1218 + ath_setup_rates(sc, IEEE80211_BAND_5GHZ); 1219 1220 /* NB: setup here so ath_rate_update is happy */ 1221 + ath_setcurmode(sc, ATH9K_MODE_11A); 1222 1223 /* 1224 * Allocate hardware transmit queues: one queue for
-2
drivers/net/wireless/ath9k/core.h
··· 1004 1005 /* Rate */ 1006 struct ieee80211_rate rates[IEEE80211_NUM_BANDS][ATH_RATE_MAX]; 1007 - const struct ath9k_rate_table *sc_rates[WIRELESS_MODE_MAX]; 1008 const struct ath9k_rate_table *sc_currates; 1009 u8 sc_rixmap[256]; /* IEEE to h/w rate table ix */ 1010 - u8 sc_minrateix; /* min h/w rate index */ 1011 u8 sc_protrix; /* protection rate index */ 1012 struct { 1013 u32 rateKbps; /* transfer rate in kbs */
··· 1004 1005 /* Rate */ 1006 struct ieee80211_rate rates[IEEE80211_NUM_BANDS][ATH_RATE_MAX]; 1007 const struct ath9k_rate_table *sc_currates; 1008 u8 sc_rixmap[256]; /* IEEE to h/w rate table ix */ 1009 u8 sc_protrix; /* protection rate index */ 1010 struct { 1011 u32 rateKbps; /* transfer rate in kbs */
+45 -34
drivers/net/wireless/ath9k/hw.c
··· 225 const struct ath9k_channel *chan) 226 { 227 if (IS_CHAN_CCK(chan)) 228 - return WIRELESS_MODE_11b; 229 if (IS_CHAN_G(chan)) 230 - return WIRELESS_MODE_11g; 231 - return WIRELESS_MODE_11a; 232 } 233 234 static bool ath9k_hw_wait(struct ath_hal *ah, ··· 2416 return; 2417 } else { 2418 mode = ath9k_hw_chan2wmode(ah, chan); 2419 - if (mode == WIRELESS_MODE_11g || mode == WIRELESS_MODE_11b) { 2420 if (!aniState->ofdmWeakSigDetectOff) 2421 ath9k_hw_ani_control(ah, 2422 ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION, ··· 2462 aniState->firstepLevel + 1); 2463 } else { 2464 mode = ath9k_hw_chan2wmode(ah, chan); 2465 - if (mode == WIRELESS_MODE_11g || mode == WIRELESS_MODE_11b) { 2466 if (aniState->firstepLevel > 0) 2467 ath9k_hw_ani_control(ah, 2468 ATH9K_ANI_FIRSTEP_LEVEL, ··· 2970 ah->ah_currentRD); 2971 } 2972 2973 - pCap->wireless_modes = 0; 2974 eeval = ath9k_hw_get_eeprom(ahp, EEP_OP_MODE); 2975 2976 if (eeval & AR5416_OPFLAGS_11A) { 2977 - pCap->wireless_modes |= ATH9K_MODE_SEL_11A | 2978 - ((!ah->ah_config.ht_enable 2979 - || (eeval & AR5416_OPFLAGS_N_5G_HT20)) ? 0 2980 - : (ATH9K_MODE_SEL_11NA_HT20 | 2981 - ((eeval & AR5416_OPFLAGS_N_5G_HT40) ? 0 2982 - : (ATH9K_MODE_SEL_11NA_HT40PLUS | 2983 - ATH9K_MODE_SEL_11NA_HT40MINUS)))); 2984 } 2985 - if (eeval & AR5416_OPFLAGS_11G) { 2986 - pCap->wireless_modes |= 2987 - ATH9K_MODE_SEL_11B | ATH9K_MODE_SEL_11G | 2988 - ((!ah->ah_config.ht_enable 2989 - || (eeval & AR5416_OPFLAGS_N_2G_HT20)) ? 0 2990 - : (ATH9K_MODE_SEL_11NG_HT20 | 2991 - ((eeval & AR5416_OPFLAGS_N_2G_HT40) ? 0 2992 - : (ATH9K_MODE_SEL_11NG_HT40PLUS | 2993 - ATH9K_MODE_SEL_11NG_HT40MINUS)))); 2994 2995 } 2996 pCap->tx_chainmask = ath9k_hw_get_eeprom(ahp, EEP_TX_MASK); 2997 if ((ah->ah_isPciExpress) 2998 || (eeval & AR5416_OPFLAGS_11A)) { ··· 5224 return clks / 5225 CLOCK_RATE[ath9k_hw_chan2wmode(ah, ah->ah_curchan)]; 5226 else 5227 - return clks / CLOCK_RATE[WIRELESS_MODE_11b]; 5228 } 5229 5230 static u32 ath9k_hw_mac_to_usec(struct ath_hal *ah, u32 clks) ··· 5243 return usecs * CLOCK_RATE[ath9k_hw_chan2wmode(ah, 5244 ah->ah_curchan)]; 5245 else 5246 - return usecs * CLOCK_RATE[WIRELESS_MODE_11b]; 5247 } 5248 5249 static u32 ath9k_hw_mac_to_clks(struct ath_hal *ah, u32 usecs) ··· 5935 REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, 5936 AR_GPIO_JTAG_DISABLE); 5937 5938 - if (ah->ah_caps.wireless_modes & ATH9K_MODE_SEL_11A) { 5939 if (IS_CHAN_5GHZ(chan)) 5940 ath9k_hw_set_gpio(ah, 9, 0); 5941 else ··· 8249 { 8250 struct ath9k_rate_table *rt; 8251 switch (mode) { 8252 - case ATH9K_MODE_SEL_11A: 8253 rt = &ar5416_11a_table; 8254 break; 8255 - case ATH9K_MODE_SEL_11B: 8256 rt = &ar5416_11b_table; 8257 break; 8258 - case ATH9K_MODE_SEL_11G: 8259 rt = &ar5416_11g_table; 8260 break; 8261 - case ATH9K_MODE_SEL_11NG_HT20: 8262 - case ATH9K_MODE_SEL_11NG_HT40PLUS: 8263 - case ATH9K_MODE_SEL_11NG_HT40MINUS: 8264 rt = &ar5416_11ng_table; 8265 break; 8266 - case ATH9K_MODE_SEL_11NA_HT20: 8267 - case ATH9K_MODE_SEL_11NA_HT40PLUS: 8268 - case ATH9K_MODE_SEL_11NA_HT40MINUS: 8269 rt = &ar5416_11na_table; 8270 break; 8271 default:
··· 225 const struct ath9k_channel *chan) 226 { 227 if (IS_CHAN_CCK(chan)) 228 + return ATH9K_MODE_11A; 229 if (IS_CHAN_G(chan)) 230 + return ATH9K_MODE_11G; 231 + return ATH9K_MODE_11A; 232 } 233 234 static bool ath9k_hw_wait(struct ath_hal *ah, ··· 2416 return; 2417 } else { 2418 mode = ath9k_hw_chan2wmode(ah, chan); 2419 + if (mode == ATH9K_MODE_11G || mode == ATH9K_MODE_11B) { 2420 if (!aniState->ofdmWeakSigDetectOff) 2421 ath9k_hw_ani_control(ah, 2422 ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION, ··· 2462 aniState->firstepLevel + 1); 2463 } else { 2464 mode = ath9k_hw_chan2wmode(ah, chan); 2465 + if (mode == ATH9K_MODE_11G || mode == ATH9K_MODE_11B) { 2466 if (aniState->firstepLevel > 0) 2467 ath9k_hw_ani_control(ah, 2468 ATH9K_ANI_FIRSTEP_LEVEL, ··· 2970 ah->ah_currentRD); 2971 } 2972 2973 eeval = ath9k_hw_get_eeprom(ahp, EEP_OP_MODE); 2974 + bitmap_zero(pCap->wireless_modes, ATH9K_MODE_MAX); 2975 2976 if (eeval & AR5416_OPFLAGS_11A) { 2977 + set_bit(ATH9K_MODE_11A, pCap->wireless_modes); 2978 + if (ah->ah_config.ht_enable) { 2979 + if (!(eeval & AR5416_OPFLAGS_N_5G_HT20)) 2980 + set_bit(ATH9K_MODE_11NA_HT20, 2981 + pCap->wireless_modes); 2982 + if (!(eeval & AR5416_OPFLAGS_N_5G_HT40)) { 2983 + set_bit(ATH9K_MODE_11NA_HT40PLUS, 2984 + pCap->wireless_modes); 2985 + set_bit(ATH9K_MODE_11NA_HT40MINUS, 2986 + pCap->wireless_modes); 2987 + } 2988 + } 2989 } 2990 2991 + if (eeval & AR5416_OPFLAGS_11G) { 2992 + set_bit(ATH9K_MODE_11B, pCap->wireless_modes); 2993 + set_bit(ATH9K_MODE_11G, pCap->wireless_modes); 2994 + if (ah->ah_config.ht_enable) { 2995 + if (!(eeval & AR5416_OPFLAGS_N_2G_HT20)) 2996 + set_bit(ATH9K_MODE_11NG_HT20, 2997 + pCap->wireless_modes); 2998 + if (!(eeval & AR5416_OPFLAGS_N_2G_HT40)) { 2999 + set_bit(ATH9K_MODE_11NG_HT40PLUS, 3000 + pCap->wireless_modes); 3001 + set_bit(ATH9K_MODE_11NG_HT40MINUS, 3002 + pCap->wireless_modes); 3003 + } 3004 + } 3005 } 3006 + 3007 pCap->tx_chainmask = ath9k_hw_get_eeprom(ahp, EEP_TX_MASK); 3008 if ((ah->ah_isPciExpress) 3009 || (eeval & AR5416_OPFLAGS_11A)) { ··· 5213 return clks / 5214 CLOCK_RATE[ath9k_hw_chan2wmode(ah, ah->ah_curchan)]; 5215 else 5216 + return clks / CLOCK_RATE[ATH9K_MODE_11B]; 5217 } 5218 5219 static u32 ath9k_hw_mac_to_usec(struct ath_hal *ah, u32 clks) ··· 5232 return usecs * CLOCK_RATE[ath9k_hw_chan2wmode(ah, 5233 ah->ah_curchan)]; 5234 else 5235 + return usecs * CLOCK_RATE[ATH9K_MODE_11B]; 5236 } 5237 5238 static u32 ath9k_hw_mac_to_clks(struct ath_hal *ah, u32 usecs) ··· 5924 REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, 5925 AR_GPIO_JTAG_DISABLE); 5926 5927 + if (test_bit(ATH9K_MODE_11A, ah->ah_caps.wireless_modes)) { 5928 if (IS_CHAN_5GHZ(chan)) 5929 ath9k_hw_set_gpio(ah, 9, 0); 5930 else ··· 8238 { 8239 struct ath9k_rate_table *rt; 8240 switch (mode) { 8241 + case ATH9K_MODE_11A: 8242 rt = &ar5416_11a_table; 8243 break; 8244 + case ATH9K_MODE_11B: 8245 rt = &ar5416_11b_table; 8246 break; 8247 + case ATH9K_MODE_11G: 8248 rt = &ar5416_11g_table; 8249 break; 8250 + case ATH9K_MODE_11NG_HT20: 8251 + case ATH9K_MODE_11NG_HT40PLUS: 8252 + case ATH9K_MODE_11NG_HT40MINUS: 8253 rt = &ar5416_11ng_table; 8254 break; 8255 + case ATH9K_MODE_11NA_HT20: 8256 + case ATH9K_MODE_11NA_HT40PLUS: 8257 + case ATH9K_MODE_11NA_HT40MINUS: 8258 rt = &ar5416_11na_table; 8259 break; 8260 default:
+8 -71
drivers/net/wireless/ath9k/main.c
··· 507 } 508 509 sc->sc_ah->ah_channels[pos].chanmode = 510 - (curchan->band == IEEE80211_BAND_2GHZ) ? CHANNEL_G : CHANNEL_A; 511 sc->sc_config.txpowlimit = 2 * conf->power_level; 512 513 /* set h/w channel */ ··· 1151 return sc->sc_ht_info.tx_chan_width; 1152 } 1153 1154 - void ath_setup_rate(struct ath_softc *sc, 1155 - enum wireless_mode wMode, 1156 - enum RATE_TYPE type, 1157 - const struct ath9k_rate_table *rt) 1158 - { 1159 - int i, maxrates, a = 0, b = 0; 1160 - struct ieee80211_supported_band *band_2ghz; 1161 - struct ieee80211_supported_band *band_5ghz; 1162 - struct ieee80211_rate *rates_2ghz; 1163 - struct ieee80211_rate *rates_5ghz; 1164 - 1165 - if ((wMode >= WIRELESS_MODE_MAX) || (type != NORMAL_RATE)) 1166 - return; 1167 - 1168 - band_2ghz = &sc->sbands[IEEE80211_BAND_2GHZ]; 1169 - band_5ghz = &sc->sbands[IEEE80211_BAND_5GHZ]; 1170 - rates_2ghz = sc->rates[IEEE80211_BAND_2GHZ]; 1171 - rates_5ghz = sc->rates[IEEE80211_BAND_5GHZ]; 1172 - 1173 - if (rt->rateCount > ATH_RATE_MAX) 1174 - maxrates = ATH_RATE_MAX; 1175 - else 1176 - maxrates = rt->rateCount; 1177 - 1178 - if ((band_2ghz->n_bitrates != 0) && (band_5ghz->n_bitrates != 0)) { 1179 - DPRINTF(sc, ATH_DBG_CONFIG, 1180 - "%s: Rates already setup\n", __func__); 1181 - return; 1182 - } 1183 - 1184 - for (i = 0; i < maxrates; i++) { 1185 - switch (wMode) { 1186 - case WIRELESS_MODE_11b: 1187 - case WIRELESS_MODE_11g: 1188 - rates_2ghz[a].bitrate = rt->info[i].rateKbps / 100; 1189 - rates_2ghz[a].hw_value = rt->info[i].rateCode; 1190 - a++; 1191 - band_2ghz->n_bitrates = a; 1192 - break; 1193 - case WIRELESS_MODE_11a: 1194 - rates_5ghz[b].bitrate = rt->info[i].rateKbps / 100; 1195 - rates_5ghz[b].hw_value = rt->info[i].rateCode; 1196 - b++; 1197 - band_5ghz->n_bitrates = b; 1198 - break; 1199 - default: 1200 - break; 1201 - } 1202 - } 1203 - 1204 - if (band_2ghz->n_bitrates) { 1205 - for (i = 0; i < band_2ghz->n_bitrates; i++) { 1206 - DPRINTF(sc, ATH_DBG_CONFIG, 1207 - "%s: 2GHz Rate: %2dMbps, ratecode: %2d\n", 1208 - __func__, 1209 - rates_2ghz[i].bitrate / 10, 1210 - rates_2ghz[i].hw_value); 1211 - } 1212 - } else if (band_5ghz->n_bitrates) { 1213 - for (i = 0; i < band_5ghz->n_bitrates; i++) { 1214 - DPRINTF(sc, ATH_DBG_CONFIG, 1215 - "%s: 5Ghz Rate: %2dMbps, ratecode: %2d\n", 1216 - __func__, 1217 - rates_5ghz[i].bitrate / 10, 1218 - rates_5ghz[i].hw_value); 1219 - } 1220 - } 1221 - } 1222 - 1223 static int ath_detach(struct ath_softc *sc) 1224 { 1225 struct ieee80211_hw *hw = sc->hw; ··· 1212 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = 1213 &sc->sbands[IEEE80211_BAND_2GHZ]; 1214 1215 - if (sc->sc_ah->ah_caps.wireless_modes & ATH9K_MODE_SEL_11A) { 1216 sc->sbands[IEEE80211_BAND_5GHZ].channels = 1217 sc->channels[IEEE80211_BAND_5GHZ]; 1218 sc->sbands[IEEE80211_BAND_5GHZ].bitrates =
··· 507 } 508 509 sc->sc_ah->ah_channels[pos].chanmode = 510 + (curchan->band == IEEE80211_BAND_2GHZ) ? 511 + CHANNEL_G : CHANNEL_A; 512 + 513 + if (sc->sc_curaid && hw->conf.ht_conf.ht_supported) 514 + sc->sc_ah->ah_channels[pos].chanmode = 515 + ath_get_extchanmode(sc, curchan); 516 + 517 sc->sc_config.txpowlimit = 2 * conf->power_level; 518 519 /* set h/w channel */ ··· 1145 return sc->sc_ht_info.tx_chan_width; 1146 } 1147 1148 static int ath_detach(struct ath_softc *sc) 1149 { 1150 struct ieee80211_hw *hw = sc->hw; ··· 1275 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = 1276 &sc->sbands[IEEE80211_BAND_2GHZ]; 1277 1278 + if (test_bit(ATH9K_MODE_11A, sc->sc_ah->ah_caps.wireless_modes)) { 1279 sc->sbands[IEEE80211_BAND_5GHZ].channels = 1280 sc->channels[IEEE80211_BAND_5GHZ]; 1281 sc->sbands[IEEE80211_BAND_5GHZ].bitrates =
+15 -15
drivers/net/wireless/ath9k/rc.c
··· 484 /* 485 * Attach rate tables. 486 */ 487 - sc->hw_rate_table[WIRELESS_MODE_11b] = &ar5416_11b_ratetable; 488 - sc->hw_rate_table[WIRELESS_MODE_11a] = &ar5416_11a_ratetable; 489 - sc->hw_rate_table[WIRELESS_MODE_11g] = &ar5416_11g_ratetable; 490 491 - sc->hw_rate_table[WIRELESS_MODE_11NA_HT20] = &ar5416_11na_ratetable; 492 - sc->hw_rate_table[WIRELESS_MODE_11NG_HT20] = &ar5416_11ng_ratetable; 493 - sc->hw_rate_table[WIRELESS_MODE_11NA_HT40PLUS] = 494 &ar5416_11na_ratetable; 495 - sc->hw_rate_table[WIRELESS_MODE_11NA_HT40MINUS] = 496 &ar5416_11na_ratetable; 497 - sc->hw_rate_table[WIRELESS_MODE_11NG_HT40PLUS] = 498 &ar5416_11ng_ratetable; 499 - sc->hw_rate_table[WIRELESS_MODE_11NG_HT40MINUS] = 500 &ar5416_11ng_ratetable; 501 } 502 503 static void ar5416_setquarter_ratetable(struct ath_rate_softc *sc) 504 { 505 - sc->hw_rate_table[WIRELESS_MODE_11a] = &ar5416_11a_ratetable_Quarter; 506 return; 507 } 508 509 static void ar5416_sethalf_ratetable(struct ath_rate_softc *sc) 510 { 511 - sc->hw_rate_table[WIRELESS_MODE_11a] = &ar5416_11a_ratetable_Half; 512 return; 513 } 514 515 static void ar5416_setfull_ratetable(struct ath_rate_softc *sc) 516 { 517 - sc->hw_rate_table[WIRELESS_MODE_11a] = &ar5416_11a_ratetable; 518 return; 519 } 520 ··· 1123 * So, set fourth rate in series to be same as third one for 1124 * above conditions. 1125 */ 1126 - if ((sc->sc_curmode == WIRELESS_MODE_11NG_HT20) || 1127 - (sc->sc_curmode == WIRELESS_MODE_11NG_HT40PLUS) || 1128 - (sc->sc_curmode == WIRELESS_MODE_11NG_HT40MINUS)) { 1129 u8 dot11rate = rate_table->info[rix].dot11rate; 1130 u8 phy = rate_table->info[rix].phy; 1131 if (i == 4 &&
··· 484 /* 485 * Attach rate tables. 486 */ 487 + sc->hw_rate_table[ATH9K_MODE_11B] = &ar5416_11b_ratetable; 488 + sc->hw_rate_table[ATH9K_MODE_11A] = &ar5416_11a_ratetable; 489 + sc->hw_rate_table[ATH9K_MODE_11G] = &ar5416_11g_ratetable; 490 491 + sc->hw_rate_table[ATH9K_MODE_11NA_HT20] = &ar5416_11na_ratetable; 492 + sc->hw_rate_table[ATH9K_MODE_11NG_HT20] = &ar5416_11ng_ratetable; 493 + sc->hw_rate_table[ATH9K_MODE_11NA_HT40PLUS] = 494 &ar5416_11na_ratetable; 495 + sc->hw_rate_table[ATH9K_MODE_11NA_HT40MINUS] = 496 &ar5416_11na_ratetable; 497 + sc->hw_rate_table[ATH9K_MODE_11NG_HT40PLUS] = 498 &ar5416_11ng_ratetable; 499 + sc->hw_rate_table[ATH9K_MODE_11NG_HT40MINUS] = 500 &ar5416_11ng_ratetable; 501 } 502 503 static void ar5416_setquarter_ratetable(struct ath_rate_softc *sc) 504 { 505 + sc->hw_rate_table[ATH9K_MODE_11A] = &ar5416_11a_ratetable_Quarter; 506 return; 507 } 508 509 static void ar5416_sethalf_ratetable(struct ath_rate_softc *sc) 510 { 511 + sc->hw_rate_table[ATH9K_MODE_11A] = &ar5416_11a_ratetable_Half; 512 return; 513 } 514 515 static void ar5416_setfull_ratetable(struct ath_rate_softc *sc) 516 { 517 + sc->hw_rate_table[ATH9K_MODE_11A] = &ar5416_11a_ratetable; 518 return; 519 } 520 ··· 1123 * So, set fourth rate in series to be same as third one for 1124 * above conditions. 1125 */ 1126 + if ((sc->sc_curmode == ATH9K_MODE_11NG_HT20) || 1127 + (sc->sc_curmode == ATH9K_MODE_11NG_HT40PLUS) || 1128 + (sc->sc_curmode == ATH9K_MODE_11NG_HT40MINUS)) { 1129 u8 dot11rate = rate_table->info[rix].dot11rate; 1130 u8 phy = rate_table->info[rix].phy; 1131 if (i == 4 &&
+1 -1
drivers/net/wireless/ath9k/rc.h
··· 247 /* per-device state */ 248 struct ath_rate_softc { 249 /* phy tables that contain rate control data */ 250 - const void *hw_rate_table[WIRELESS_MODE_MAX]; 251 int fixedrix; /* -1 or index of fixed rate */ 252 }; 253
··· 247 /* per-device state */ 248 struct ath_rate_softc { 249 /* phy tables that contain rate control data */ 250 + const void *hw_rate_table[ATH9K_MODE_MAX]; 251 int fixedrix; /* -1 or index of fixed rate */ 252 }; 253
+51 -56
drivers/net/wireless/ath9k/regd.c
··· 131 return false; 132 } 133 134 - static u32 135 ath9k_regd_get_wmodes_nreg(struct ath_hal *ah, 136 struct country_code_to_enum_rd *country, 137 - struct regDomain *rd5GHz) 138 { 139 - u32 modesAvail; 140 141 - modesAvail = ah->ah_caps.wireless_modes; 142 143 - if ((modesAvail & ATH9K_MODE_SEL_11G) && (!country->allow11g)) 144 - modesAvail &= ~ATH9K_MODE_SEL_11G; 145 - if ((modesAvail & ATH9K_MODE_SEL_11A) && 146 (ath9k_regd_is_chan_bm_zero(rd5GHz->chan11a))) 147 - modesAvail &= ~ATH9K_MODE_SEL_11A; 148 149 - if ((modesAvail & ATH9K_MODE_SEL_11NG_HT20) 150 && (!country->allow11ng20)) 151 - modesAvail &= ~ATH9K_MODE_SEL_11NG_HT20; 152 153 - if ((modesAvail & ATH9K_MODE_SEL_11NA_HT20) 154 && (!country->allow11na20)) 155 - modesAvail &= ~ATH9K_MODE_SEL_11NA_HT20; 156 157 - if ((modesAvail & ATH9K_MODE_SEL_11NG_HT40PLUS) && 158 (!country->allow11ng40)) 159 - modesAvail &= ~ATH9K_MODE_SEL_11NG_HT40PLUS; 160 161 - if ((modesAvail & ATH9K_MODE_SEL_11NG_HT40MINUS) && 162 (!country->allow11ng40)) 163 - modesAvail &= ~ATH9K_MODE_SEL_11NG_HT40MINUS; 164 165 - if ((modesAvail & ATH9K_MODE_SEL_11NA_HT40PLUS) && 166 (!country->allow11na40)) 167 - modesAvail &= ~ATH9K_MODE_SEL_11NA_HT40PLUS; 168 169 - if ((modesAvail & ATH9K_MODE_SEL_11NA_HT40MINUS) && 170 (!country->allow11na40)) 171 - modesAvail &= ~ATH9K_MODE_SEL_11NA_HT40MINUS; 172 - 173 - return modesAvail; 174 } 175 176 bool ath9k_regd_is_public_safety_sku(struct ath_hal *ah) ··· 544 } 545 } 546 547 - if (cm->mode & (ATH9K_MODE_SEL_11A | 548 - ATH9K_MODE_SEL_11NA_HT20 | 549 - ATH9K_MODE_SEL_11NA_HT40PLUS | 550 - ATH9K_MODE_SEL_11NA_HT40MINUS)) { 551 if (rd->flags & (ADHOC_NO_11A | DISALLOW_ADHOC_11A)) 552 privFlags |= CHANNEL_DISALLOW_ADHOC; 553 } ··· 617 u32 maxchans, 618 u32 *nchans, u8 *regclassids, 619 u32 maxregids, u32 *nregids, u16 cc, 620 - u32 modeSelect, bool enableOutdoor, 621 bool enableExtendedChannels) 622 { 623 - u32 modesAvail; 624 u16 maxChan = 7000; 625 struct country_code_to_enum_rd *country = NULL; 626 struct regDomain rd5GHz, rd2GHz; ··· 629 u8 ctl; 630 int regdmn; 631 u16 chanSep; 632 633 - DPRINTF(ah->ah_sc, ATH_DBG_REGULATORY, "%s: cc %u mode 0x%x%s%s\n", 634 - __func__, cc, modeSelect, 635 - enableOutdoor ? " Enable outdoor" : " ", 636 - enableExtendedChannels ? " Enable ecm" : ""); 637 638 if (!ath9k_regd_is_ccode_valid(ah, cc)) { 639 DPRINTF(ah->ah_sc, ATH_DBG_REGULATORY, ··· 726 } 727 728 if (country == NULL) { 729 - modesAvail = ah->ah_caps.wireless_modes; 730 } else { 731 - modesAvail = ath9k_regd_get_wmodes_nreg(ah, country, &rd5GHz); 732 if (!enableOutdoor) 733 maxChan = country->outdoorChanStart; 734 } ··· 747 struct RegDmnFreqBand *fband = NULL, *freqs; 748 int8_t low_adj = 0, hi_adj = 0; 749 750 - if ((cm->mode & modeSelect) == 0) { 751 DPRINTF(ah->ah_sc, ATH_DBG_REGULATORY, 752 - "%s: skip mode 0x%x flags 0x%x\n", 753 __func__, cm->mode, cm->flags); 754 - continue; 755 - } 756 - if ((cm->mode & modesAvail) == 0) { 757 - DPRINTF(ah->ah_sc, ATH_DBG_REGULATORY, 758 - "%s: !avail mode 0x%x (0x%x) flags 0x%x\n", 759 - __func__, modesAvail, cm->mode, 760 - cm->flags); 761 continue; 762 } 763 if (!ath9k_get_channel_edges(ah, cm->flags, &c_lo, &c_hi)) { ··· 762 } 763 764 switch (cm->mode) { 765 - case ATH9K_MODE_SEL_11A: 766 - case ATH9K_MODE_SEL_11NA_HT20: 767 - case ATH9K_MODE_SEL_11NA_HT40PLUS: 768 - case ATH9K_MODE_SEL_11NA_HT40MINUS: 769 rd = &rd5GHz; 770 channelBM = rd->chan11a; 771 freqs = &regDmn5GhzFreq[0]; 772 ctl = rd->conformanceTestLimit; 773 break; 774 - case ATH9K_MODE_SEL_11B: 775 rd = &rd2GHz; 776 channelBM = rd->chan11b; 777 freqs = &regDmn2GhzFreq[0]; 778 ctl = rd->conformanceTestLimit | CTL_11B; 779 break; 780 - case ATH9K_MODE_SEL_11G: 781 - case ATH9K_MODE_SEL_11NG_HT20: 782 - case ATH9K_MODE_SEL_11NG_HT40PLUS: 783 - case ATH9K_MODE_SEL_11NG_HT40MINUS: 784 rd = &rd2GHz; 785 channelBM = rd->chan11g; 786 freqs = &regDmn2Ghz11gFreq[0]; ··· 796 if (ath9k_regd_is_chan_bm_zero(channelBM)) 797 continue; 798 799 - if ((cm->mode == ATH9K_MODE_SEL_11NA_HT40PLUS) || 800 - (cm->mode == ATH9K_MODE_SEL_11NG_HT40PLUS)) { 801 hi_adj = -20; 802 } 803 804 - if ((cm->mode == ATH9K_MODE_SEL_11NA_HT40MINUS) || 805 - (cm->mode == ATH9K_MODE_SEL_11NG_HT40MINUS)) { 806 low_adj = 20; 807 } 808
··· 131 return false; 132 } 133 134 + static void 135 ath9k_regd_get_wmodes_nreg(struct ath_hal *ah, 136 struct country_code_to_enum_rd *country, 137 + struct regDomain *rd5GHz, 138 + unsigned long *modes_allowed) 139 { 140 + bitmap_copy(modes_allowed, ah->ah_caps.wireless_modes, ATH9K_MODE_MAX); 141 142 + if (test_bit(ATH9K_MODE_11G, ah->ah_caps.wireless_modes) && 143 + (!country->allow11g)) 144 + clear_bit(ATH9K_MODE_11G, modes_allowed); 145 146 + if (test_bit(ATH9K_MODE_11A, ah->ah_caps.wireless_modes) && 147 (ath9k_regd_is_chan_bm_zero(rd5GHz->chan11a))) 148 + clear_bit(ATH9K_MODE_11A, modes_allowed); 149 150 + if (test_bit(ATH9K_MODE_11NG_HT20, ah->ah_caps.wireless_modes) 151 && (!country->allow11ng20)) 152 + clear_bit(ATH9K_MODE_11NG_HT20, modes_allowed); 153 154 + if (test_bit(ATH9K_MODE_11NA_HT20, ah->ah_caps.wireless_modes) 155 && (!country->allow11na20)) 156 + clear_bit(ATH9K_MODE_11NA_HT20, modes_allowed); 157 158 + if (test_bit(ATH9K_MODE_11NG_HT40PLUS, ah->ah_caps.wireless_modes) && 159 (!country->allow11ng40)) 160 + clear_bit(ATH9K_MODE_11NG_HT40PLUS, modes_allowed); 161 162 + if (test_bit(ATH9K_MODE_11NG_HT40MINUS, ah->ah_caps.wireless_modes) && 163 (!country->allow11ng40)) 164 + clear_bit(ATH9K_MODE_11NG_HT40MINUS, modes_allowed); 165 166 + if (test_bit(ATH9K_MODE_11NA_HT40PLUS, ah->ah_caps.wireless_modes) && 167 (!country->allow11na40)) 168 + clear_bit(ATH9K_MODE_11NA_HT40PLUS, modes_allowed); 169 170 + if (test_bit(ATH9K_MODE_11NA_HT40MINUS, ah->ah_caps.wireless_modes) && 171 (!country->allow11na40)) 172 + clear_bit(ATH9K_MODE_11NA_HT40MINUS, modes_allowed); 173 } 174 175 bool ath9k_regd_is_public_safety_sku(struct ath_hal *ah) ··· 545 } 546 } 547 548 + if ((cm->mode == ATH9K_MODE_11A) || 549 + (cm->mode == ATH9K_MODE_11NA_HT20) || 550 + (cm->mode == ATH9K_MODE_11NA_HT40PLUS) || 551 + (cm->mode == ATH9K_MODE_11NA_HT40MINUS)) { 552 if (rd->flags & (ADHOC_NO_11A | DISALLOW_ADHOC_11A)) 553 privFlags |= CHANNEL_DISALLOW_ADHOC; 554 } ··· 618 u32 maxchans, 619 u32 *nchans, u8 *regclassids, 620 u32 maxregids, u32 *nregids, u16 cc, 621 + bool enableOutdoor, 622 bool enableExtendedChannels) 623 { 624 u16 maxChan = 7000; 625 struct country_code_to_enum_rd *country = NULL; 626 struct regDomain rd5GHz, rd2GHz; ··· 631 u8 ctl; 632 int regdmn; 633 u16 chanSep; 634 + unsigned long *modes_avail; 635 + DECLARE_BITMAP(modes_allowed, ATH9K_MODE_MAX); 636 637 + DPRINTF(ah->ah_sc, ATH_DBG_REGULATORY, "%s: cc %u %s %s\n", 638 + __func__, cc, 639 + enableOutdoor ? "Enable outdoor" : "", 640 + enableExtendedChannels ? "Enable ecm" : ""); 641 642 if (!ath9k_regd_is_ccode_valid(ah, cc)) { 643 DPRINTF(ah->ah_sc, ATH_DBG_REGULATORY, ··· 726 } 727 728 if (country == NULL) { 729 + modes_avail = ah->ah_caps.wireless_modes; 730 } else { 731 + ath9k_regd_get_wmodes_nreg(ah, country, &rd5GHz, modes_allowed); 732 + modes_avail = modes_allowed; 733 + 734 if (!enableOutdoor) 735 maxChan = country->outdoorChanStart; 736 } ··· 745 struct RegDmnFreqBand *fband = NULL, *freqs; 746 int8_t low_adj = 0, hi_adj = 0; 747 748 + if (!test_bit(cm->mode, modes_avail)) { 749 DPRINTF(ah->ah_sc, ATH_DBG_REGULATORY, 750 + "%s: !avail mode %d flags 0x%x\n", 751 __func__, cm->mode, cm->flags); 752 continue; 753 } 754 if (!ath9k_get_channel_edges(ah, cm->flags, &c_lo, &c_hi)) { ··· 767 } 768 769 switch (cm->mode) { 770 + case ATH9K_MODE_11A: 771 + case ATH9K_MODE_11NA_HT20: 772 + case ATH9K_MODE_11NA_HT40PLUS: 773 + case ATH9K_MODE_11NA_HT40MINUS: 774 rd = &rd5GHz; 775 channelBM = rd->chan11a; 776 freqs = &regDmn5GhzFreq[0]; 777 ctl = rd->conformanceTestLimit; 778 break; 779 + case ATH9K_MODE_11B: 780 rd = &rd2GHz; 781 channelBM = rd->chan11b; 782 freqs = &regDmn2GhzFreq[0]; 783 ctl = rd->conformanceTestLimit | CTL_11B; 784 break; 785 + case ATH9K_MODE_11G: 786 + case ATH9K_MODE_11NG_HT20: 787 + case ATH9K_MODE_11NG_HT40PLUS: 788 + case ATH9K_MODE_11NG_HT40MINUS: 789 rd = &rd2GHz; 790 channelBM = rd->chan11g; 791 freqs = &regDmn2Ghz11gFreq[0]; ··· 801 if (ath9k_regd_is_chan_bm_zero(channelBM)) 802 continue; 803 804 + if ((cm->mode == ATH9K_MODE_11NA_HT40PLUS) || 805 + (cm->mode == ATH9K_MODE_11NG_HT40PLUS)) { 806 hi_adj = -20; 807 } 808 809 + if ((cm->mode == ATH9K_MODE_11NA_HT40MINUS) || 810 + (cm->mode == ATH9K_MODE_11NG_HT40MINUS)) { 811 low_adj = 20; 812 } 813
+5 -5
drivers/net/wireless/ath9k/regd.h
··· 117 #define isUNII1OddChan(ch) \ 118 ((ch == 5170) || (ch == 5190) || (ch == 5210) || (ch == 5230)) 119 120 - #define IS_HT40_MODE(_mode) \ 121 - (((_mode == ATH9K_MODE_SEL_11NA_HT40PLUS || \ 122 - _mode == ATH9K_MODE_SEL_11NG_HT40PLUS || \ 123 - _mode == ATH9K_MODE_SEL_11NA_HT40MINUS || \ 124 - _mode == ATH9K_MODE_SEL_11NG_HT40MINUS) ? true : false)) 125 126 #define CHAN_FLAGS (CHANNEL_ALL|CHANNEL_HALF|CHANNEL_QUARTER) 127
··· 117 #define isUNII1OddChan(ch) \ 118 ((ch == 5170) || (ch == 5190) || (ch == 5210) || (ch == 5230)) 119 120 + #define IS_HT40_MODE(_mode) \ 121 + (((_mode == ATH9K_MODE_11NA_HT40PLUS || \ 122 + _mode == ATH9K_MODE_11NG_HT40PLUS || \ 123 + _mode == ATH9K_MODE_11NA_HT40MINUS || \ 124 + _mode == ATH9K_MODE_11NG_HT40MINUS) ? true : false)) 125 126 #define CHAN_FLAGS (CHANNEL_ALL|CHANNEL_HALF|CHANNEL_QUARTER) 127
+9 -9
drivers/net/wireless/ath9k/regd_common.h
··· 1893 }; 1894 1895 static const struct cmode modes[] = { 1896 - {ATH9K_MODE_SEL_11A, CHANNEL_A}, 1897 - {ATH9K_MODE_SEL_11B, CHANNEL_B}, 1898 - {ATH9K_MODE_SEL_11G, CHANNEL_G}, 1899 - {ATH9K_MODE_SEL_11NG_HT20, CHANNEL_G_HT20}, 1900 - {ATH9K_MODE_SEL_11NG_HT40PLUS, CHANNEL_G_HT40PLUS}, 1901 - {ATH9K_MODE_SEL_11NG_HT40MINUS, CHANNEL_G_HT40MINUS}, 1902 - {ATH9K_MODE_SEL_11NA_HT20, CHANNEL_A_HT20}, 1903 - {ATH9K_MODE_SEL_11NA_HT40PLUS, CHANNEL_A_HT40PLUS}, 1904 - {ATH9K_MODE_SEL_11NA_HT40MINUS, CHANNEL_A_HT40MINUS}, 1905 }; 1906 1907 static struct japan_bandcheck j_bandcheck[] = {
··· 1893 }; 1894 1895 static const struct cmode modes[] = { 1896 + {ATH9K_MODE_11A, CHANNEL_A}, 1897 + {ATH9K_MODE_11B, CHANNEL_B}, 1898 + {ATH9K_MODE_11G, CHANNEL_G}, 1899 + {ATH9K_MODE_11NG_HT20, CHANNEL_G_HT20}, 1900 + {ATH9K_MODE_11NG_HT40PLUS, CHANNEL_G_HT40PLUS}, 1901 + {ATH9K_MODE_11NG_HT40MINUS, CHANNEL_G_HT40MINUS}, 1902 + {ATH9K_MODE_11NA_HT20, CHANNEL_A_HT20}, 1903 + {ATH9K_MODE_11NA_HT40PLUS, CHANNEL_A_HT40PLUS}, 1904 + {ATH9K_MODE_11NA_HT40MINUS, CHANNEL_A_HT40MINUS}, 1905 }; 1906 1907 static struct japan_bandcheck j_bandcheck[] = {
+1 -1
drivers/net/wireless/ath9k/xmit.c
··· 408 if (txctl->min_rate) 409 rcs[0].rix = ath_rate_findrateix(sc, txctl->min_rate); 410 else 411 - rcs[0].rix = sc->sc_minrateix; 412 rcs[0].tries = ATH_MGT_TXMAXTRY; 413 } 414 rix = rcs[0].rix;
··· 408 if (txctl->min_rate) 409 rcs[0].rix = ath_rate_findrateix(sc, txctl->min_rate); 410 else 411 + rcs[0].rix = 0; 412 rcs[0].tries = ATH_MGT_TXMAXTRY; 413 } 414 rix = rcs[0].rix;