aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath9k/rc.c
diff options
context:
space:
mode:
authorSujith <Sujith.Manoharan@atheros.com>2008-11-17 22:37:06 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-11-26 09:47:28 -0500
commitfe7f4a77450c1d0e463a9b1456b40c2305433e41 (patch)
treee6f3b4532b1d5bda3e9863df21e48d0adc22522d /drivers/net/wireless/ath9k/rc.c
parent5ddfac3b550250388f1222ec7d09069784a68af6 (diff)
ath9k: Remove ath_rate_softc
Move the hw rate tables to ath_softc, and access them directly. tx_triglevel_max is global, move it to ath_rate_node. Now that ath_rate_softc is gone, rate control attach becomes simpler. Signed-off-by: Sujith <Sujith.Manoharan@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath9k/rc.c')
-rw-r--r--drivers/net/wireless/ath9k/rc.c110
1 files changed, 41 insertions, 69 deletions
diff --git a/drivers/net/wireless/ath9k/rc.c b/drivers/net/wireless/ath9k/rc.c
index 0fa1b30bdcb6..59c146cdd0db 100644
--- a/drivers/net/wireless/ath9k/rc.c
+++ b/drivers/net/wireless/ath9k/rc.c
@@ -23,8 +23,6 @@
23/* FIXME: remove this include! */ 23/* FIXME: remove this include! */
24#include "../net/mac80211/rate.h" 24#include "../net/mac80211/rate.h"
25 25
26static u32 tx_triglevel_max;
27
28static struct ath_rate_table ar5416_11na_ratetable = { 26static struct ath_rate_table ar5416_11na_ratetable = {
29 42, 27 42,
30 { 28 {
@@ -436,7 +434,7 @@ static inline int8_t median(int8_t a, int8_t b, int8_t c)
436 } 434 }
437} 435}
438 436
439static void ath_rc_sort_validrates(const struct ath_rate_table *rate_table, 437static void ath_rc_sort_validrates(struct ath_rate_table *rate_table,
440 struct ath_rate_node *ath_rc_priv) 438 struct ath_rate_node *ath_rc_priv)
441{ 439{
442 u8 i, j, idx, idx_next; 440 u8 i, j, idx, idx_next;
@@ -481,7 +479,7 @@ static inline int ath_rc_isvalid_txmask(struct ath_rate_node *ath_rc_priv,
481 479
482/* Iterators for valid_txrate_mask */ 480/* Iterators for valid_txrate_mask */
483static inline int 481static inline int
484ath_rc_get_nextvalid_txrate(const struct ath_rate_table *rate_table, 482ath_rc_get_nextvalid_txrate(struct ath_rate_table *rate_table,
485 struct ath_rate_node *ath_rc_priv, 483 struct ath_rate_node *ath_rc_priv,
486 u8 cur_valid_txrate, 484 u8 cur_valid_txrate,
487 u8 *next_idx) 485 u8 *next_idx)
@@ -519,7 +517,7 @@ static int ath_rc_valid_phyrate(u32 phy, u32 capflag, int ignore_cw)
519} 517}
520 518
521static inline int 519static inline int
522ath_rc_get_nextlowervalid_txrate(const struct ath_rate_table *rate_table, 520ath_rc_get_nextlowervalid_txrate(struct ath_rate_table *rate_table,
523 struct ath_rate_node *ath_rc_priv, 521 struct ath_rate_node *ath_rc_priv,
524 u8 cur_valid_txrate, u8 *next_idx) 522 u8 cur_valid_txrate, u8 *next_idx)
525{ 523{
@@ -539,7 +537,7 @@ ath_rc_get_nextlowervalid_txrate(const struct ath_rate_table *rate_table,
539 */ 537 */
540static u8 538static u8
541ath_rc_sib_init_validrates(struct ath_rate_node *ath_rc_priv, 539ath_rc_sib_init_validrates(struct ath_rate_node *ath_rc_priv,
542 const struct ath_rate_table *rate_table, 540 struct ath_rate_table *rate_table,
543 u32 capflag) 541 u32 capflag)
544{ 542{
545 u8 i, hi = 0; 543 u8 i, hi = 0;
@@ -572,7 +570,7 @@ ath_rc_sib_init_validrates(struct ath_rate_node *ath_rc_priv,
572 */ 570 */
573static u8 571static u8
574ath_rc_sib_setvalid_rates(struct ath_rate_node *ath_rc_priv, 572ath_rc_sib_setvalid_rates(struct ath_rate_node *ath_rc_priv,
575 const struct ath_rate_table *rate_table, 573 struct ath_rate_table *rate_table,
576 struct ath_rateset *rateset, 574 struct ath_rateset *rateset,
577 u32 capflag) 575 u32 capflag)
578{ 576{
@@ -620,7 +618,7 @@ ath_rc_sib_setvalid_rates(struct ath_rate_node *ath_rc_priv,
620 618
621static u8 619static u8
622ath_rc_sib_setvalid_htrates(struct ath_rate_node *ath_rc_priv, 620ath_rc_sib_setvalid_htrates(struct ath_rate_node *ath_rc_priv,
623 const struct ath_rate_table *rate_table, 621 struct ath_rate_table *rate_table,
624 u8 *mcs_set, u32 capflag) 622 u8 *mcs_set, u32 capflag)
625{ 623{
626 u8 i, j, hi = 0; 624 u8 i, j, hi = 0;
@@ -653,50 +651,13 @@ ath_rc_sib_setvalid_htrates(struct ath_rate_node *ath_rc_priv,
653 return hi; 651 return hi;
654} 652}
655 653
656struct ath_rate_softc *ath_rate_attach(struct ath_softc *sc)
657{
658 struct ath_rate_softc *asc;
659
660 asc = kzalloc(sizeof(struct ath_rate_softc), GFP_KERNEL);
661 if (asc == NULL)
662 return NULL;
663
664 asc->hw_rate_table[ATH9K_MODE_11B] = &ar5416_11b_ratetable;
665 asc->hw_rate_table[ATH9K_MODE_11A] = &ar5416_11a_ratetable;
666 asc->hw_rate_table[ATH9K_MODE_11G] = &ar5416_11g_ratetable;
667
668 asc->hw_rate_table[ATH9K_MODE_11NA_HT20] = &ar5416_11na_ratetable;
669 asc->hw_rate_table[ATH9K_MODE_11NG_HT20] = &ar5416_11ng_ratetable;
670
671 asc->hw_rate_table[ATH9K_MODE_11NA_HT40PLUS] =
672 &ar5416_11na_ratetable;
673 asc->hw_rate_table[ATH9K_MODE_11NA_HT40MINUS] =
674 &ar5416_11na_ratetable;
675 asc->hw_rate_table[ATH9K_MODE_11NG_HT40PLUS] =
676 &ar5416_11ng_ratetable;
677 asc->hw_rate_table[ATH9K_MODE_11NG_HT40MINUS] =
678 &ar5416_11ng_ratetable;
679
680 /* Save Maximum TX Trigger Level (used for 11n) */
681 tx_triglevel_max = sc->sc_ah->ah_caps.tx_triglevel_max;
682
683 return asc;
684}
685
686void ath_rate_detach(struct ath_rate_softc *asc)
687{
688 if (asc != NULL)
689 kfree(asc);
690}
691
692u8 ath_rate_findrateix(struct ath_softc *sc, 654u8 ath_rate_findrateix(struct ath_softc *sc,
693 u8 dot11rate) 655 u8 dot11rate)
694{ 656{
695 const struct ath_rate_table *ratetable; 657 struct ath_rate_table *ratetable;
696 struct ath_rate_softc *rsc = sc->sc_rc;
697 int i; 658 int i;
698 659
699 ratetable = rsc->hw_rate_table[sc->sc_curmode]; 660 ratetable = sc->hw_rate_table[sc->sc_curmode];
700 661
701 if (WARN_ON(!ratetable)) 662 if (WARN_ON(!ratetable))
702 return 0; 663 return 0;
@@ -711,7 +672,7 @@ u8 ath_rate_findrateix(struct ath_softc *sc,
711 672
712static u8 ath_rc_ratefind_ht(struct ath_softc *sc, 673static u8 ath_rc_ratefind_ht(struct ath_softc *sc,
713 struct ath_rate_node *ath_rc_priv, 674 struct ath_rate_node *ath_rc_priv,
714 const struct ath_rate_table *rate_table, 675 struct ath_rate_table *rate_table,
715 int probe_allowed, int *is_probing, 676 int probe_allowed, int *is_probing,
716 int is_retry) 677 int is_retry)
717{ 678{
@@ -843,7 +804,7 @@ static u8 ath_rc_ratefind_ht(struct ath_softc *sc,
843 return rate; 804 return rate;
844} 805}
845 806
846static void ath_rc_rate_set_series(const struct ath_rate_table *rate_table , 807static void ath_rc_rate_set_series(struct ath_rate_table *rate_table ,
847 struct ath_rc_series *series, 808 struct ath_rc_series *series,
848 u8 tries, 809 u8 tries,
849 u8 rix, 810 u8 rix,
@@ -864,7 +825,7 @@ static void ath_rc_rate_set_series(const struct ath_rate_table *rate_table ,
864 825
865static u8 ath_rc_rate_getidx(struct ath_softc *sc, 826static u8 ath_rc_rate_getidx(struct ath_softc *sc,
866 struct ath_rate_node *ath_rc_priv, 827 struct ath_rate_node *ath_rc_priv,
867 const struct ath_rate_table *rate_table, 828 struct ath_rate_table *rate_table,
868 u8 rix, u16 stepdown, 829 u8 rix, u16 stepdown,
869 u16 min_rate) 830 u16 min_rate)
870{ 831{
@@ -898,11 +859,9 @@ static void ath_rc_ratefind(struct ath_softc *sc,
898 int is_retry) 859 int is_retry)
899{ 860{
900 u8 try_per_rate = 0, i = 0, rix, nrix; 861 u8 try_per_rate = 0, i = 0, rix, nrix;
901 struct ath_rate_softc *asc = (struct ath_rate_softc *)sc->sc_rc;
902 struct ath_rate_table *rate_table; 862 struct ath_rate_table *rate_table;
903 863
904 rate_table = 864 rate_table = sc->hw_rate_table[sc->sc_curmode];
905 (struct ath_rate_table *)asc->hw_rate_table[sc->sc_curmode];
906 rix = ath_rc_ratefind_ht(sc, ath_rc_priv, rate_table, 865 rix = ath_rc_ratefind_ht(sc, ath_rc_priv, rate_table,
907 (rcflag & ATH_RC_PROBE_ALLOWED) ? 1 : 0, 866 (rcflag & ATH_RC_PROBE_ALLOWED) ? 1 : 0,
908 is_probe, is_retry); 867 is_probe, is_retry);
@@ -1003,10 +962,7 @@ static void ath_rc_update_ht(struct ath_softc *sc,
1003 u32 now_msec = jiffies_to_msecs(jiffies); 962 u32 now_msec = jiffies_to_msecs(jiffies);
1004 int state_change = FALSE, rate, count; 963 int state_change = FALSE, rate, count;
1005 u8 last_per; 964 u8 last_per;
1006 struct ath_rate_softc *asc = (struct ath_rate_softc *)sc->sc_rc; 965 struct ath_rate_table *rate_table = sc->hw_rate_table[sc->sc_curmode];
1007 struct ath_rate_table *rate_table =
1008 (struct ath_rate_table *)asc->hw_rate_table[sc->sc_curmode];
1009
1010 static u32 nretry_to_per_lookup[10] = { 966 static u32 nretry_to_per_lookup[10] = {
1011 100 * 0 / 1, 967 100 * 0 / 1,
1012 100 * 1 / 4, 968 100 * 1 / 4,
@@ -1330,15 +1286,13 @@ static void ath_rc_update(struct ath_softc *sc,
1330 struct ath_tx_info_priv *info_priv, int final_ts_idx, 1286 struct ath_tx_info_priv *info_priv, int final_ts_idx,
1331 int xretries, int long_retry) 1287 int xretries, int long_retry)
1332{ 1288{
1333 struct ath_rate_softc *asc = (struct ath_rate_softc *)sc->sc_rc;
1334 struct ath_rate_table *rate_table; 1289 struct ath_rate_table *rate_table;
1335 struct ath_rc_series rcs[4]; 1290 struct ath_rc_series rcs[4];
1336 u8 flags; 1291 u8 flags;
1337 u32 series = 0, rix; 1292 u32 series = 0, rix;
1338 1293
1339 memcpy(rcs, info_priv->rcs, 4 * sizeof(rcs[0])); 1294 memcpy(rcs, info_priv->rcs, 4 * sizeof(rcs[0]));
1340 rate_table = (struct ath_rate_table *) 1295 rate_table = sc->hw_rate_table[sc->sc_curmode];
1341 asc->hw_rate_table[sc->sc_curmode];
1342 ASSERT(rcs[0].tries != 0); 1296 ASSERT(rcs[0].tries != 0);
1343 1297
1344 /* 1298 /*
@@ -1432,7 +1386,7 @@ static void ath_rate_tx_complete(struct ath_softc *sc,
1432 */ 1386 */
1433 if (info_priv->tx.ts_flags & 1387 if (info_priv->tx.ts_flags &
1434 (ATH9K_TX_DATA_UNDERRUN | ATH9K_TX_DELIM_UNDERRUN) && 1388 (ATH9K_TX_DATA_UNDERRUN | ATH9K_TX_DELIM_UNDERRUN) &&
1435 ((sc->sc_ah->ah_txTrigLevel) >= tx_triglevel_max)) { 1389 ((sc->sc_ah->ah_txTrigLevel) >= rc_priv->tx_triglevel_max)) {
1436 tx_status = 1; 1390 tx_status = 1;
1437 is_underrun = 1; 1391 is_underrun = 1;
1438 } 1392 }
@@ -1452,21 +1406,17 @@ static void ath_rc_init(struct ath_softc *sc,
1452 struct ieee80211_sta *sta) 1406 struct ieee80211_sta *sta)
1453{ 1407{
1454 struct ath_rate_table *rate_table = NULL; 1408 struct ath_rate_table *rate_table = NULL;
1455 struct ath_rate_softc *asc = (struct ath_rate_softc *)sc->sc_rc;
1456 struct ath_rateset *rateset = &ath_rc_priv->neg_rates; 1409 struct ath_rateset *rateset = &ath_rc_priv->neg_rates;
1457 u8 *ht_mcs = (u8 *)&ath_rc_priv->neg_ht_rates; 1410 u8 *ht_mcs = (u8 *)&ath_rc_priv->neg_ht_rates;
1458 u8 i, j, k, hi = 0, hthi = 0; 1411 u8 i, j, k, hi = 0, hthi = 0;
1459 1412
1460 rate_table = (struct ath_rate_table *) 1413 rate_table = sc->hw_rate_table[sc->sc_curmode];
1461 asc->hw_rate_table[sc->sc_curmode];
1462 1414
1463 if (sta->ht_cap.ht_supported) { 1415 if (sta->ht_cap.ht_supported) {
1464 if (sband->band == IEEE80211_BAND_2GHZ) 1416 if (sband->band == IEEE80211_BAND_2GHZ)
1465 rate_table = (struct ath_rate_table *) 1417 rate_table = sc->hw_rate_table[ATH9K_MODE_11NG_HT20];
1466 asc->hw_rate_table[ATH9K_MODE_11NG_HT20];
1467 else 1418 else
1468 rate_table = (struct ath_rate_table *) 1419 rate_table = sc->hw_rate_table[ATH9K_MODE_11NA_HT20];
1469 asc->hw_rate_table[ATH9K_MODE_11NA_HT20];
1470 1420
1471 ath_rc_priv->ht_cap = (WLAN_RC_HT_FLAG | WLAN_RC_DS_FLAG); 1421 ath_rc_priv->ht_cap = (WLAN_RC_HT_FLAG | WLAN_RC_DS_FLAG);
1472 if (sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) 1422 if (sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40)
@@ -1691,8 +1641,8 @@ static void *ath_rate_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp
1691 return NULL; 1641 return NULL;
1692 } 1642 }
1693 1643
1694 rate_priv->asc = sc->sc_rc;
1695 rate_priv->rssi_down_time = jiffies_to_msecs(jiffies); 1644 rate_priv->rssi_down_time = jiffies_to_msecs(jiffies);
1645 rate_priv->tx_triglevel_max = sc->sc_ah->ah_caps.tx_triglevel_max;
1696 1646
1697 return rate_priv; 1647 return rate_priv;
1698} 1648}
@@ -1717,6 +1667,28 @@ static struct rate_control_ops ath_rate_ops = {
1717 .free_sta = ath_rate_free_sta, 1667 .free_sta = ath_rate_free_sta,
1718}; 1668};
1719 1669
1670void ath_rate_attach(struct ath_softc *sc)
1671{
1672 sc->hw_rate_table[ATH9K_MODE_11B] =
1673 &ar5416_11b_ratetable;
1674 sc->hw_rate_table[ATH9K_MODE_11A] =
1675 &ar5416_11a_ratetable;
1676 sc->hw_rate_table[ATH9K_MODE_11G] =
1677 &ar5416_11g_ratetable;
1678 sc->hw_rate_table[ATH9K_MODE_11NA_HT20] =
1679 &ar5416_11na_ratetable;
1680 sc->hw_rate_table[ATH9K_MODE_11NG_HT20] =
1681 &ar5416_11ng_ratetable;
1682 sc->hw_rate_table[ATH9K_MODE_11NA_HT40PLUS] =
1683 &ar5416_11na_ratetable;
1684 sc->hw_rate_table[ATH9K_MODE_11NA_HT40MINUS] =
1685 &ar5416_11na_ratetable;
1686 sc->hw_rate_table[ATH9K_MODE_11NG_HT40PLUS] =
1687 &ar5416_11ng_ratetable;
1688 sc->hw_rate_table[ATH9K_MODE_11NG_HT40MINUS] =
1689 &ar5416_11ng_ratetable;
1690}
1691
1720int ath_rate_control_register(void) 1692int ath_rate_control_register(void)
1721{ 1693{
1722 return ieee80211_rate_control_register(&ath_rate_ops); 1694 return ieee80211_rate_control_register(&ath_rate_ops);