aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath9k/main.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-10-09 06:13:49 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-10-31 19:00:06 -0400
commitd9fe60dea7779d412b34679f1177c5ca1940ea8d (patch)
treea51e16b013f7c1d16ded502cb32c03872bcbfcaa /drivers/net/wireless/ath9k/main.c
parent40333e4fb476014cdd939d27e20eb54573172b32 (diff)
802.11: clean up/fix HT support
This patch cleans up a number of things: * the unusable definition of the HT capabilities/HT information information elements * variable names that are hard to understand * mac80211: move ieee80211_handle_ht to ht.c and remove the unused enable_ht parameter * mac80211: fix bug with MCS rate 32 in ieee80211_handle_ht * mac80211: fix bug with casting the result of ieee80211_bss_get_ie to an information element _contents_ rather than the whole element, add size checking (another out-of-bounds access bug fixed!) * mac80211: remove some unused return values in favour of BUG_ON checking * a few minor other things Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath9k/main.c')
-rw-r--r--drivers/net/wireless/ath9k/main.c57
1 files changed, 27 insertions, 30 deletions
diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index 186d75acb32..5e087c92a6d 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -61,24 +61,24 @@ static u32 ath_get_extchanmode(struct ath_softc *sc,
61 61
62 switch (chan->band) { 62 switch (chan->band) {
63 case IEEE80211_BAND_2GHZ: 63 case IEEE80211_BAND_2GHZ:
64 if ((ext_chan_offset == IEEE80211_HT_IE_CHA_SEC_NONE) && 64 if ((ext_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_NONE) &&
65 (tx_chan_width == ATH9K_HT_MACMODE_20)) 65 (tx_chan_width == ATH9K_HT_MACMODE_20))
66 chanmode = CHANNEL_G_HT20; 66 chanmode = CHANNEL_G_HT20;
67 if ((ext_chan_offset == IEEE80211_HT_IE_CHA_SEC_ABOVE) && 67 if ((ext_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_ABOVE) &&
68 (tx_chan_width == ATH9K_HT_MACMODE_2040)) 68 (tx_chan_width == ATH9K_HT_MACMODE_2040))
69 chanmode = CHANNEL_G_HT40PLUS; 69 chanmode = CHANNEL_G_HT40PLUS;
70 if ((ext_chan_offset == IEEE80211_HT_IE_CHA_SEC_BELOW) && 70 if ((ext_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_BELOW) &&
71 (tx_chan_width == ATH9K_HT_MACMODE_2040)) 71 (tx_chan_width == ATH9K_HT_MACMODE_2040))
72 chanmode = CHANNEL_G_HT40MINUS; 72 chanmode = CHANNEL_G_HT40MINUS;
73 break; 73 break;
74 case IEEE80211_BAND_5GHZ: 74 case IEEE80211_BAND_5GHZ:
75 if ((ext_chan_offset == IEEE80211_HT_IE_CHA_SEC_NONE) && 75 if ((ext_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_NONE) &&
76 (tx_chan_width == ATH9K_HT_MACMODE_20)) 76 (tx_chan_width == ATH9K_HT_MACMODE_20))
77 chanmode = CHANNEL_A_HT20; 77 chanmode = CHANNEL_A_HT20;
78 if ((ext_chan_offset == IEEE80211_HT_IE_CHA_SEC_ABOVE) && 78 if ((ext_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_ABOVE) &&
79 (tx_chan_width == ATH9K_HT_MACMODE_2040)) 79 (tx_chan_width == ATH9K_HT_MACMODE_2040))
80 chanmode = CHANNEL_A_HT40PLUS; 80 chanmode = CHANNEL_A_HT40PLUS;
81 if ((ext_chan_offset == IEEE80211_HT_IE_CHA_SEC_BELOW) && 81 if ((ext_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_BELOW) &&
82 (tx_chan_width == ATH9K_HT_MACMODE_2040)) 82 (tx_chan_width == ATH9K_HT_MACMODE_2040))
83 chanmode = CHANNEL_A_HT40MINUS; 83 chanmode = CHANNEL_A_HT40MINUS;
84 break; 84 break;
@@ -215,24 +215,24 @@ static void ath_key_delete(struct ath_softc *sc, struct ieee80211_key_conf *key)
215 ath_key_reset(sc, key->keyidx, freeslot); 215 ath_key_reset(sc, key->keyidx, freeslot);
216} 216}
217 217
218static void setup_ht_cap(struct ieee80211_ht_info *ht_info) 218static void setup_ht_cap(struct ieee80211_sta_ht_cap *ht_info)
219{ 219{
220#define ATH9K_HT_CAP_MAXRXAMPDU_65536 0x3 /* 2 ^ 16 */ 220#define ATH9K_HT_CAP_MAXRXAMPDU_65536 0x3 /* 2 ^ 16 */
221#define ATH9K_HT_CAP_MPDUDENSITY_8 0x6 /* 8 usec */ 221#define ATH9K_HT_CAP_MPDUDENSITY_8 0x6 /* 8 usec */
222 222
223 ht_info->ht_supported = 1; 223 ht_info->ht_supported = true;
224 ht_info->cap = (u16)IEEE80211_HT_CAP_SUP_WIDTH 224 ht_info->cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
225 |(u16)IEEE80211_HT_CAP_SM_PS 225 IEEE80211_HT_CAP_SM_PS |
226 |(u16)IEEE80211_HT_CAP_SGI_40 226 IEEE80211_HT_CAP_SGI_40 |
227 |(u16)IEEE80211_HT_CAP_DSSSCCK40; 227 IEEE80211_HT_CAP_DSSSCCK40;
228 228
229 ht_info->ampdu_factor = ATH9K_HT_CAP_MAXRXAMPDU_65536; 229 ht_info->ampdu_factor = ATH9K_HT_CAP_MAXRXAMPDU_65536;
230 ht_info->ampdu_density = ATH9K_HT_CAP_MPDUDENSITY_8; 230 ht_info->ampdu_density = ATH9K_HT_CAP_MPDUDENSITY_8;
231 /* setup supported mcs set */ 231 /* set up supported mcs set */
232 memset(ht_info->supp_mcs_set, 0, 16); 232 memset(&ht_info->mcs, 0, sizeof(ht_info->mcs));
233 ht_info->supp_mcs_set[0] = 0xff; 233 ht_info->mcs.rx_mask[0] = 0xff;
234 ht_info->supp_mcs_set[1] = 0xff; 234 ht_info->mcs.rx_mask[1] = 0xff;
235 ht_info->supp_mcs_set[12] = IEEE80211_HT_CAP_MCS_TX_DEFINED; 235 ht_info->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED;
236} 236}
237 237
238static int ath_rate2idx(struct ath_softc *sc, int rate) 238static int ath_rate2idx(struct ath_softc *sc, int rate)
@@ -328,31 +328,28 @@ static u8 parse_mpdudensity(u8 mpdudensity)
328static void ath9k_ht_conf(struct ath_softc *sc, 328static void ath9k_ht_conf(struct ath_softc *sc,
329 struct ieee80211_bss_conf *bss_conf) 329 struct ieee80211_bss_conf *bss_conf)
330{ 330{
331#define IEEE80211_HT_CAP_40MHZ_INTOLERANT BIT(14)
332 struct ath_ht_info *ht_info = &sc->sc_ht_info; 331 struct ath_ht_info *ht_info = &sc->sc_ht_info;
333 332
334 if (bss_conf->assoc_ht) { 333 if (bss_conf->assoc_ht) {
335 ht_info->ext_chan_offset = 334 ht_info->ext_chan_offset =
336 bss_conf->ht_bss_conf->bss_cap & 335 bss_conf->ht_bss_conf->bss_cap &
337 IEEE80211_HT_IE_CHA_SEC_OFFSET; 336 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
338 337
339 if (!(bss_conf->ht_conf->cap & 338 if (!(bss_conf->ht_cap->cap &
340 IEEE80211_HT_CAP_40MHZ_INTOLERANT) && 339 IEEE80211_HT_CAP_40MHZ_INTOLERANT) &&
341 (bss_conf->ht_bss_conf->bss_cap & 340 (bss_conf->ht_bss_conf->bss_cap &
342 IEEE80211_HT_IE_CHA_WIDTH)) 341 IEEE80211_HT_PARAM_CHAN_WIDTH_ANY))
343 ht_info->tx_chan_width = ATH9K_HT_MACMODE_2040; 342 ht_info->tx_chan_width = ATH9K_HT_MACMODE_2040;
344 else 343 else
345 ht_info->tx_chan_width = ATH9K_HT_MACMODE_20; 344 ht_info->tx_chan_width = ATH9K_HT_MACMODE_20;
346 345
347 ath9k_hw_set11nmac2040(sc->sc_ah, ht_info->tx_chan_width); 346 ath9k_hw_set11nmac2040(sc->sc_ah, ht_info->tx_chan_width);
348 ht_info->maxampdu = 1 << (IEEE80211_HTCAP_MAXRXAMPDU_FACTOR + 347 ht_info->maxampdu = 1 << (IEEE80211_HTCAP_MAXRXAMPDU_FACTOR +
349 bss_conf->ht_conf->ampdu_factor); 348 bss_conf->ht_cap->ampdu_factor);
350 ht_info->mpdudensity = 349 ht_info->mpdudensity =
351 parse_mpdudensity(bss_conf->ht_conf->ampdu_density); 350 parse_mpdudensity(bss_conf->ht_cap->ampdu_density);
352 351
353 } 352 }
354
355#undef IEEE80211_HT_CAP_40MHZ_INTOLERANT
356} 353}
357 354
358static void ath9k_bss_assoc_info(struct ath_softc *sc, 355static void ath9k_bss_assoc_info(struct ath_softc *sc,
@@ -411,7 +408,7 @@ static void ath9k_bss_assoc_info(struct ath_softc *sc,
411 return; 408 return;
412 } 409 }
413 410
414 if (hw->conf.ht_conf.ht_supported) 411 if (hw->conf.ht_cap.ht_supported)
415 sc->sc_ah->ah_channels[pos].chanmode = 412 sc->sc_ah->ah_channels[pos].chanmode =
416 ath_get_extchanmode(sc, curchan); 413 ath_get_extchanmode(sc, curchan);
417 else 414 else
@@ -534,7 +531,7 @@ int _ath_rx_indicate(struct ath_softc *sc,
534 531
535 if (an) { 532 if (an) {
536 ath_rx_input(sc, an, 533 ath_rx_input(sc, an,
537 hw->conf.ht_conf.ht_supported, 534 hw->conf.ht_cap.ht_supported,
538 skb, status, &st); 535 skb, status, &st);
539 } 536 }
540 if (!an || (st != ATH_RX_CONSUMED)) 537 if (!an || (st != ATH_RX_CONSUMED))
@@ -943,7 +940,7 @@ static int ath_attach(u16 devid,
943 940
944 if (sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_HT) 941 if (sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_HT)
945 /* Setup HT capabilities for 2.4Ghz*/ 942 /* Setup HT capabilities for 2.4Ghz*/
946 setup_ht_cap(&sc->sbands[IEEE80211_BAND_2GHZ].ht_info); 943 setup_ht_cap(&sc->sbands[IEEE80211_BAND_2GHZ].ht_cap);
947 944
948 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = 945 hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
949 &sc->sbands[IEEE80211_BAND_2GHZ]; 946 &sc->sbands[IEEE80211_BAND_2GHZ];
@@ -958,7 +955,7 @@ static int ath_attach(u16 devid,
958 955
959 if (sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_HT) 956 if (sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_HT)
960 /* Setup HT capabilities for 5Ghz*/ 957 /* Setup HT capabilities for 5Ghz*/
961 setup_ht_cap(&sc->sbands[IEEE80211_BAND_5GHZ].ht_info); 958 setup_ht_cap(&sc->sbands[IEEE80211_BAND_5GHZ].ht_cap);
962 959
963 hw->wiphy->bands[IEEE80211_BAND_5GHZ] = 960 hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
964 &sc->sbands[IEEE80211_BAND_5GHZ]; 961 &sc->sbands[IEEE80211_BAND_5GHZ];
@@ -1254,7 +1251,7 @@ static int ath9k_config(struct ieee80211_hw *hw,
1254 (curchan->band == IEEE80211_BAND_2GHZ) ? 1251 (curchan->band == IEEE80211_BAND_2GHZ) ?
1255 CHANNEL_G : CHANNEL_A; 1252 CHANNEL_G : CHANNEL_A;
1256 1253
1257 if (sc->sc_curaid && hw->conf.ht_conf.ht_supported) 1254 if (sc->sc_curaid && hw->conf.ht_cap.ht_supported)
1258 sc->sc_ah->ah_channels[pos].chanmode = 1255 sc->sc_ah->ah_channels[pos].chanmode =
1259 ath_get_extchanmode(sc, curchan); 1256 ath_get_extchanmode(sc, curchan);
1260 1257