aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/wireless/ath/ath9k/rc.c65
1 files changed, 17 insertions, 48 deletions
diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c
index e034add9cd5a..2188d1ba5764 100644
--- a/drivers/net/wireless/ath/ath9k/rc.c
+++ b/drivers/net/wireless/ath/ath9k/rc.c
@@ -1185,8 +1185,6 @@ struct ath_rate_table *ath_choose_rate_table(struct ath_softc *sc,
1185 enum ieee80211_band band, 1185 enum ieee80211_band band,
1186 bool is_ht) 1186 bool is_ht)
1187{ 1187{
1188 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1189
1190 switch(band) { 1188 switch(band) {
1191 case IEEE80211_BAND_2GHZ: 1189 case IEEE80211_BAND_2GHZ:
1192 if (is_ht) 1190 if (is_ht)
@@ -1197,7 +1195,6 @@ struct ath_rate_table *ath_choose_rate_table(struct ath_softc *sc,
1197 return &ar5416_11na_ratetable; 1195 return &ar5416_11na_ratetable;
1198 return &ar5416_11a_ratetable; 1196 return &ar5416_11a_ratetable;
1199 default: 1197 default:
1200 ath_dbg(common, CONFIG, "Invalid band\n");
1201 return NULL; 1198 return NULL;
1202 } 1199 }
1203} 1200}
@@ -1278,8 +1275,7 @@ static void ath_rc_init(struct ath_softc *sc,
1278 ath_rc_priv->ht_cap); 1275 ath_rc_priv->ht_cap);
1279} 1276}
1280 1277
1281static u8 ath_rc_build_ht_caps(struct ath_softc *sc, struct ieee80211_sta *sta, 1278static u8 ath_rc_build_ht_caps(struct ath_softc *sc, struct ieee80211_sta *sta)
1282 bool is_cw40, bool is_sgi)
1283{ 1279{
1284 u8 caps = 0; 1280 u8 caps = 0;
1285 1281
@@ -1289,9 +1285,10 @@ static u8 ath_rc_build_ht_caps(struct ath_softc *sc, struct ieee80211_sta *sta,
1289 caps |= WLAN_RC_TS_FLAG | WLAN_RC_DS_FLAG; 1285 caps |= WLAN_RC_TS_FLAG | WLAN_RC_DS_FLAG;
1290 else if (sta->ht_cap.mcs.rx_mask[1]) 1286 else if (sta->ht_cap.mcs.rx_mask[1])
1291 caps |= WLAN_RC_DS_FLAG; 1287 caps |= WLAN_RC_DS_FLAG;
1292 if (is_cw40) 1288 if (sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40)
1293 caps |= WLAN_RC_40_FLAG; 1289 caps |= WLAN_RC_40_FLAG;
1294 if (is_sgi) 1290 if (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40 ||
1291 sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20)
1295 caps |= WLAN_RC_SGI_FLAG; 1292 caps |= WLAN_RC_SGI_FLAG;
1296 } 1293 }
1297 1294
@@ -1393,9 +1390,9 @@ static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband,
1393 struct ieee80211_sta *sta, void *priv_sta) 1390 struct ieee80211_sta *sta, void *priv_sta)
1394{ 1391{
1395 struct ath_softc *sc = priv; 1392 struct ath_softc *sc = priv;
1393 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1396 struct ath_rate_priv *ath_rc_priv = priv_sta; 1394 struct ath_rate_priv *ath_rc_priv = priv_sta;
1397 const struct ath_rate_table *rate_table; 1395 const struct ath_rate_table *rate_table;
1398 bool is_cw40, is_sgi = false;
1399 int i, j = 0; 1396 int i, j = 0;
1400 1397
1401 for (i = 0; i < sband->n_bitrates; i++) { 1398 for (i = 0; i < sband->n_bitrates; i++) {
@@ -1417,19 +1414,14 @@ static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband,
1417 ath_rc_priv->neg_ht_rates.rs_nrates = j; 1414 ath_rc_priv->neg_ht_rates.rs_nrates = j;
1418 } 1415 }
1419 1416
1420 is_cw40 = !!(sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40);
1421
1422 if (is_cw40)
1423 is_sgi = !!(sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40);
1424 else if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_SGI_20)
1425 is_sgi = !!(sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20);
1426
1427 /* Choose rate table first */
1428
1429 rate_table = ath_choose_rate_table(sc, sband->band, 1417 rate_table = ath_choose_rate_table(sc, sband->band,
1430 sta->ht_cap.ht_supported); 1418 sta->ht_cap.ht_supported);
1419 if (!rate_table) {
1420 ath_err(common, "No rate table chosen\n");
1421 return;
1422 }
1431 1423
1432 ath_rc_priv->ht_cap = ath_rc_build_ht_caps(sc, sta, is_cw40, is_sgi); 1424 ath_rc_priv->ht_cap = ath_rc_build_ht_caps(sc, sta);
1433 ath_rc_init(sc, priv_sta, sband, sta, rate_table); 1425 ath_rc_init(sc, priv_sta, sband, sta, rate_table);
1434} 1426}
1435 1427
@@ -1440,39 +1432,16 @@ static void ath_rate_update(void *priv, struct ieee80211_supported_band *sband,
1440 struct ath_softc *sc = priv; 1432 struct ath_softc *sc = priv;
1441 struct ath_rate_priv *ath_rc_priv = priv_sta; 1433 struct ath_rate_priv *ath_rc_priv = priv_sta;
1442 const struct ath_rate_table *rate_table = NULL; 1434 const struct ath_rate_table *rate_table = NULL;
1443 bool oper_cw40 = false, oper_sgi;
1444 bool local_cw40 = !!(ath_rc_priv->ht_cap & WLAN_RC_40_FLAG);
1445 bool local_sgi = !!(ath_rc_priv->ht_cap & WLAN_RC_SGI_FLAG);
1446
1447 /* FIXME: Handle AP mode later when we support CWM */
1448 1435
1449 if (changed & IEEE80211_RC_BW_CHANGED) { 1436 if (changed & IEEE80211_RC_BW_CHANGED) {
1450 if (sc->sc_ah->opmode != NL80211_IFTYPE_STATION) 1437 rate_table = ath_choose_rate_table(sc, sband->band,
1451 return;
1452
1453 if (sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40)
1454 oper_cw40 = true;
1455
1456 if (oper_cw40)
1457 oper_sgi = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40) ?
1458 true : false;
1459 else if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_SGI_20)
1460 oper_sgi = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20) ?
1461 true : false;
1462 else
1463 oper_sgi = false;
1464
1465 if ((local_cw40 != oper_cw40) || (local_sgi != oper_sgi)) {
1466 rate_table = ath_choose_rate_table(sc, sband->band,
1467 sta->ht_cap.ht_supported); 1438 sta->ht_cap.ht_supported);
1468 ath_rc_priv->ht_cap = ath_rc_build_ht_caps(sc, sta, 1439 ath_rc_priv->ht_cap = ath_rc_build_ht_caps(sc, sta);
1469 oper_cw40, oper_sgi); 1440 ath_rc_init(sc, priv_sta, sband, sta, rate_table);
1470 ath_rc_init(sc, priv_sta, sband, sta, rate_table);
1471 1441
1472 ath_dbg(ath9k_hw_common(sc->sc_ah), CONFIG, 1442 ath_dbg(ath9k_hw_common(sc->sc_ah), CONFIG,
1473 "Operating HT Bandwidth changed to: %d\n", 1443 "Operating HT Bandwidth changed to: %d\n",
1474 sc->hw->conf.channel_type); 1444 sc->hw->conf.channel_type);
1475 }
1476 } 1445 }
1477} 1446}
1478 1447