aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSujith <Sujith.Manoharan@atheros.com>2010-05-17 02:31:16 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-06-02 16:13:15 -0400
commit0d425a7d7bc7bc834fe04e15e88b61bc34331a98 (patch)
tree3b4722ea7ad80ad9ef873026604255bb9d0ea482
parent01574c4b46d08e62d509118ad209983c00ade898 (diff)
ath9k_htc: Cleanup rate initialization
This patch removes a large chunk of code dealing with rate management within the driver and simplifying things by removing the hacky method of calculating HT changes. A subsequent patch would fix this by just using BSS_CHANGED_HT from mac80211. Signed-off-by: Sujith <Sujith.Manoharan@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/ath/ath9k/htc.h2
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_main.c113
2 files changed, 32 insertions, 83 deletions
diff --git a/drivers/net/wireless/ath/ath9k/htc.h b/drivers/net/wireless/ath/ath9k/htc.h
index 2207299547f8..bf2bd4211c87 100644
--- a/drivers/net/wireless/ath/ath9k/htc.h
+++ b/drivers/net/wireless/ath/ath9k/htc.h
@@ -401,8 +401,6 @@ struct ath9k_htc_priv {
401#ifdef CONFIG_ATH9K_HTC_DEBUGFS 401#ifdef CONFIG_ATH9K_HTC_DEBUGFS
402 struct ath9k_debug debug; 402 struct ath9k_debug debug;
403#endif 403#endif
404 struct ath9k_htc_target_rate tgt_rate;
405
406 struct mutex mutex; 404 struct mutex mutex;
407}; 405};
408 406
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
index cf1112be2a9a..fe5debf0b7d7 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
@@ -334,40 +334,35 @@ static int ath9k_htc_update_cap_target(struct ath9k_htc_priv *priv)
334 return ret; 334 return ret;
335} 335}
336 336
337static int ath9k_htc_init_rate(struct ath9k_htc_priv *priv, 337static void ath9k_htc_setup_rate(struct ath9k_htc_priv *priv,
338 struct ieee80211_vif *vif, 338 struct ieee80211_sta *sta,
339 struct ieee80211_sta *sta) 339 struct ath9k_htc_target_rate *trate)
340{ 340{
341 struct ath_common *common = ath9k_hw_common(priv->ah);
342 struct ath9k_htc_sta *ista = (struct ath9k_htc_sta *) sta->drv_priv; 341 struct ath9k_htc_sta *ista = (struct ath9k_htc_sta *) sta->drv_priv;
343 struct ieee80211_supported_band *sband; 342 struct ieee80211_supported_band *sband;
344 struct ath9k_htc_target_rate trate;
345 u32 caps = 0; 343 u32 caps = 0;
346 u8 cmd_rsp; 344 int i, j;
347 int i, j, ret;
348
349 memset(&trate, 0, sizeof(trate));
350 345
351 /* Only 2GHz is supported */ 346 /* Only 2GHz is supported */
352 sband = priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ]; 347 sband = priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ];
353 348
354 for (i = 0, j = 0; i < sband->n_bitrates; i++) { 349 for (i = 0, j = 0; i < sband->n_bitrates; i++) {
355 if (sta->supp_rates[sband->band] & BIT(i)) { 350 if (sta->supp_rates[sband->band] & BIT(i)) {
356 priv->tgt_rate.rates.legacy_rates.rs_rates[j] 351 trate->rates.legacy_rates.rs_rates[j]
357 = (sband->bitrates[i].bitrate * 2) / 10; 352 = (sband->bitrates[i].bitrate * 2) / 10;
358 j++; 353 j++;
359 } 354 }
360 } 355 }
361 priv->tgt_rate.rates.legacy_rates.rs_nrates = j; 356 trate->rates.legacy_rates.rs_nrates = j;
362 357
363 if (sta->ht_cap.ht_supported) { 358 if (sta->ht_cap.ht_supported) {
364 for (i = 0, j = 0; i < 77; i++) { 359 for (i = 0, j = 0; i < 77; i++) {
365 if (sta->ht_cap.mcs.rx_mask[i/8] & (1<<(i%8))) 360 if (sta->ht_cap.mcs.rx_mask[i/8] & (1<<(i%8)))
366 priv->tgt_rate.rates.ht_rates.rs_rates[j++] = i; 361 trate->rates.ht_rates.rs_rates[j++] = i;
367 if (j == ATH_HTC_RATE_MAX) 362 if (j == ATH_HTC_RATE_MAX)
368 break; 363 break;
369 } 364 }
370 priv->tgt_rate.rates.ht_rates.rs_nrates = j; 365 trate->rates.ht_rates.rs_nrates = j;
371 366
372 caps = WLAN_RC_HT_FLAG; 367 caps = WLAN_RC_HT_FLAG;
373 if (sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) 368 if (sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40)
@@ -377,81 +372,41 @@ static int ath9k_htc_init_rate(struct ath9k_htc_priv *priv,
377 372
378 } 373 }
379 374
380 priv->tgt_rate.sta_index = ista->index; 375 trate->sta_index = ista->index;
381 priv->tgt_rate.isnew = 1; 376 trate->isnew = 1;
382 trate = priv->tgt_rate; 377 trate->capflags = cpu_to_be32(caps);
383 priv->tgt_rate.capflags = cpu_to_be32(caps); 378}
384 trate.capflags = cpu_to_be32(caps); 379
380static int ath9k_htc_send_rate_cmd(struct ath9k_htc_priv *priv,
381 struct ath9k_htc_target_rate *trate)
382{
383 struct ath_common *common = ath9k_hw_common(priv->ah);
384 int ret;
385 u8 cmd_rsp;
385 386
386 WMI_CMD_BUF(WMI_RC_RATE_UPDATE_CMDID, &trate); 387 WMI_CMD_BUF(WMI_RC_RATE_UPDATE_CMDID, trate);
387 if (ret) { 388 if (ret) {
388 ath_print(common, ATH_DBG_FATAL, 389 ath_print(common, ATH_DBG_FATAL,
389 "Unable to initialize Rate information on target\n"); 390 "Unable to initialize Rate information on target\n");
390 return ret;
391 } 391 }
392 392
393 ath_print(common, ATH_DBG_CONFIG, 393 return ret;
394 "Updated target STA: %pM (caps: 0x%x)\n", sta->addr, caps);
395 return 0;
396}
397
398static bool check_rc_update(struct ieee80211_hw *hw, bool *cw40)
399{
400 struct ath9k_htc_priv *priv = hw->priv;
401 struct ieee80211_conf *conf = &hw->conf;
402
403 if (!conf_is_ht(conf))
404 return false;
405
406 if (!(priv->op_flags & OP_ASSOCIATED) ||
407 (priv->op_flags & OP_SCANNING))
408 return false;
409
410 if (conf_is_ht40(conf)) {
411 if (priv->ah->curchan->chanmode &
412 (CHANNEL_HT40PLUS | CHANNEL_HT40MINUS)) {
413 return false;
414 } else {
415 *cw40 = true;
416 return true;
417 }
418 } else { /* ht20 */
419 if (priv->ah->curchan->chanmode & CHANNEL_HT20)
420 return false;
421 else
422 return true;
423 }
424} 394}
425 395
426static void ath9k_htc_rc_update(struct ath9k_htc_priv *priv, bool is_cw40) 396static void ath9k_htc_init_rate(struct ath9k_htc_priv *priv,
397 struct ieee80211_sta *sta)
427{ 398{
428 struct ath9k_htc_target_rate trate;
429 struct ath_common *common = ath9k_hw_common(priv->ah); 399 struct ath_common *common = ath9k_hw_common(priv->ah);
400 struct ath9k_htc_target_rate trate;
430 int ret; 401 int ret;
431 u32 caps = be32_to_cpu(priv->tgt_rate.capflags);
432 u8 cmd_rsp;
433
434 memset(&trate, 0, sizeof(trate));
435
436 trate = priv->tgt_rate;
437 402
438 if (is_cw40) 403 memset(&trate, 0, sizeof(struct ath9k_htc_target_rate));
439 caps |= WLAN_RC_40_FLAG; 404 ath9k_htc_setup_rate(priv, sta, &trate);
440 else 405 ret = ath9k_htc_send_rate_cmd(priv, &trate);
441 caps &= ~WLAN_RC_40_FLAG; 406 if (!ret)
442 407 ath_print(common, ATH_DBG_CONFIG,
443 priv->tgt_rate.capflags = cpu_to_be32(caps); 408 "Updated target sta: %pM, rate caps: 0x%X\n",
444 trate.capflags = cpu_to_be32(caps); 409 sta->addr, be32_to_cpu(trate.capflags));
445
446 WMI_CMD_BUF(WMI_RC_RATE_UPDATE_CMDID, &trate);
447 if (ret) {
448 ath_print(common, ATH_DBG_FATAL,
449 "Unable to update Rate information on target\n");
450 return;
451 }
452
453 ath_print(common, ATH_DBG_CONFIG, "Rate control updated with "
454 "caps:0x%x on target\n", priv->tgt_rate.capflags);
455} 410}
456 411
457static int ath9k_htc_aggr_oper(struct ath9k_htc_priv *priv, 412static int ath9k_htc_aggr_oper(struct ath9k_htc_priv *priv,
@@ -1372,14 +1327,10 @@ static int ath9k_htc_config(struct ieee80211_hw *hw, u32 changed)
1372 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { 1327 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
1373 struct ieee80211_channel *curchan = hw->conf.channel; 1328 struct ieee80211_channel *curchan = hw->conf.channel;
1374 int pos = curchan->hw_value; 1329 int pos = curchan->hw_value;
1375 bool is_cw40 = false;
1376 1330
1377 ath_print(common, ATH_DBG_CONFIG, "Set channel: %d MHz\n", 1331 ath_print(common, ATH_DBG_CONFIG, "Set channel: %d MHz\n",
1378 curchan->center_freq); 1332 curchan->center_freq);
1379 1333
1380 if (check_rc_update(hw, &is_cw40))
1381 ath9k_htc_rc_update(priv, is_cw40);
1382
1383 ath9k_cmn_update_ichannel(hw, &priv->ah->channels[pos]); 1334 ath9k_cmn_update_ichannel(hw, &priv->ah->channels[pos]);
1384 1335
1385 if (ath9k_htc_set_channel(priv, hw, &priv->ah->channels[pos]) < 0) { 1336 if (ath9k_htc_set_channel(priv, hw, &priv->ah->channels[pos]) < 0) {
@@ -1471,7 +1422,7 @@ static void ath9k_htc_sta_notify(struct ieee80211_hw *hw,
1471 case STA_NOTIFY_ADD: 1422 case STA_NOTIFY_ADD:
1472 ret = ath9k_htc_add_station(priv, vif, sta); 1423 ret = ath9k_htc_add_station(priv, vif, sta);
1473 if (!ret) 1424 if (!ret)
1474 ath9k_htc_init_rate(priv, vif, sta); 1425 ath9k_htc_init_rate(priv, sta);
1475 break; 1426 break;
1476 case STA_NOTIFY_REMOVE: 1427 case STA_NOTIFY_REMOVE:
1477 ath9k_htc_remove_station(priv, vif, sta); 1428 ath9k_htc_remove_station(priv, vif, sta);