Commit fe7f4a77 authored by Sujith's avatar Sujith Committed by John W. Linville

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: default avatarSujith <Sujith.Manoharan@atheros.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 5ddfac3b
...@@ -1071,11 +1071,7 @@ int ath_init(u16 devid, struct ath_softc *sc) ...@@ -1071,11 +1071,7 @@ int ath_init(u16 devid, struct ath_softc *sc)
sc->sc_ani.sc_noise_floor = ATH_DEFAULT_NOISE_FLOOR; sc->sc_ani.sc_noise_floor = ATH_DEFAULT_NOISE_FLOOR;
setup_timer(&sc->sc_ani.timer, ath_ani_calibrate, (unsigned long)sc); setup_timer(&sc->sc_ani.timer, ath_ani_calibrate, (unsigned long)sc);
sc->sc_rc = ath_rate_attach(sc); ath_rate_attach(sc);
if (sc->sc_rc == NULL) {
error = -EIO;
goto bad2;
}
if (ath9k_hw_getcapability(ah, ATH9K_CAP_CIPHER, if (ath9k_hw_getcapability(ah, ATH9K_CAP_CIPHER,
ATH9K_CIPHER_TKIP, NULL)) { ATH9K_CIPHER_TKIP, NULL)) {
......
...@@ -784,7 +784,6 @@ struct ath_softc { ...@@ -784,7 +784,6 @@ struct ath_softc {
struct tasklet_struct bcon_tasklet; struct tasklet_struct bcon_tasklet;
struct ath_config sc_config; struct ath_config sc_config;
struct ath_hal *sc_ah; struct ath_hal *sc_ah;
struct ath_rate_softc *sc_rc;
void __iomem *mem; void __iomem *mem;
u8 sc_curbssid[ETH_ALEN]; u8 sc_curbssid[ETH_ALEN];
...@@ -859,6 +858,7 @@ struct ath_softc { ...@@ -859,6 +858,7 @@ struct ath_softc {
/* Rate */ /* Rate */
struct ieee80211_rate rates[IEEE80211_NUM_BANDS][ATH_RATE_MAX]; struct ieee80211_rate rates[IEEE80211_NUM_BANDS][ATH_RATE_MAX];
struct ath_rate_table *hw_rate_table[ATH9K_MODE_MAX];
const struct ath9k_rate_table *sc_currates; const struct ath9k_rate_table *sc_currates;
u8 sc_protrix; /* protection rate index */ u8 sc_protrix; /* protection rate index */
struct { struct {
......
...@@ -737,7 +737,6 @@ static void ath_detach(struct ath_softc *sc) ...@@ -737,7 +737,6 @@ static void ath_detach(struct ath_softc *sc)
ieee80211_unregister_hw(hw); ieee80211_unregister_hw(hw);
ath_rate_control_unregister(); ath_rate_control_unregister();
ath_rate_detach(sc->sc_rc);
ath_rx_cleanup(sc); ath_rx_cleanup(sc);
ath_tx_cleanup(sc); ath_tx_cleanup(sc);
......
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
/* FIXME: remove this include! */ /* FIXME: remove this include! */
#include "../net/mac80211/rate.h" #include "../net/mac80211/rate.h"
static u32 tx_triglevel_max;
static struct ath_rate_table ar5416_11na_ratetable = { static struct ath_rate_table ar5416_11na_ratetable = {
42, 42,
{ {
...@@ -436,7 +434,7 @@ static inline int8_t median(int8_t a, int8_t b, int8_t c) ...@@ -436,7 +434,7 @@ static inline int8_t median(int8_t a, int8_t b, int8_t c)
} }
} }
static void ath_rc_sort_validrates(const struct ath_rate_table *rate_table, static void ath_rc_sort_validrates(struct ath_rate_table *rate_table,
struct ath_rate_node *ath_rc_priv) struct ath_rate_node *ath_rc_priv)
{ {
u8 i, j, idx, idx_next; 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,7 +479,7 @@ static inline int ath_rc_isvalid_txmask(struct ath_rate_node *ath_rc_priv,
/* Iterators for valid_txrate_mask */ /* Iterators for valid_txrate_mask */
static inline int static inline int
ath_rc_get_nextvalid_txrate(const struct ath_rate_table *rate_table, ath_rc_get_nextvalid_txrate(struct ath_rate_table *rate_table,
struct ath_rate_node *ath_rc_priv, struct ath_rate_node *ath_rc_priv,
u8 cur_valid_txrate, u8 cur_valid_txrate,
u8 *next_idx) u8 *next_idx)
...@@ -519,7 +517,7 @@ static int ath_rc_valid_phyrate(u32 phy, u32 capflag, int ignore_cw) ...@@ -519,7 +517,7 @@ static int ath_rc_valid_phyrate(u32 phy, u32 capflag, int ignore_cw)
} }
static inline int static inline int
ath_rc_get_nextlowervalid_txrate(const struct ath_rate_table *rate_table, ath_rc_get_nextlowervalid_txrate(struct ath_rate_table *rate_table,
struct ath_rate_node *ath_rc_priv, struct ath_rate_node *ath_rc_priv,
u8 cur_valid_txrate, u8 *next_idx) u8 cur_valid_txrate, u8 *next_idx)
{ {
...@@ -539,7 +537,7 @@ ath_rc_get_nextlowervalid_txrate(const struct ath_rate_table *rate_table, ...@@ -539,7 +537,7 @@ ath_rc_get_nextlowervalid_txrate(const struct ath_rate_table *rate_table,
*/ */
static u8 static u8
ath_rc_sib_init_validrates(struct ath_rate_node *ath_rc_priv, ath_rc_sib_init_validrates(struct ath_rate_node *ath_rc_priv,
const struct ath_rate_table *rate_table, struct ath_rate_table *rate_table,
u32 capflag) u32 capflag)
{ {
u8 i, hi = 0; u8 i, hi = 0;
...@@ -572,7 +570,7 @@ ath_rc_sib_init_validrates(struct ath_rate_node *ath_rc_priv, ...@@ -572,7 +570,7 @@ ath_rc_sib_init_validrates(struct ath_rate_node *ath_rc_priv,
*/ */
static u8 static u8
ath_rc_sib_setvalid_rates(struct ath_rate_node *ath_rc_priv, ath_rc_sib_setvalid_rates(struct ath_rate_node *ath_rc_priv,
const struct ath_rate_table *rate_table, struct ath_rate_table *rate_table,
struct ath_rateset *rateset, struct ath_rateset *rateset,
u32 capflag) u32 capflag)
{ {
...@@ -620,7 +618,7 @@ ath_rc_sib_setvalid_rates(struct ath_rate_node *ath_rc_priv, ...@@ -620,7 +618,7 @@ ath_rc_sib_setvalid_rates(struct ath_rate_node *ath_rc_priv,
static u8 static u8
ath_rc_sib_setvalid_htrates(struct ath_rate_node *ath_rc_priv, ath_rc_sib_setvalid_htrates(struct ath_rate_node *ath_rc_priv,
const struct ath_rate_table *rate_table, struct ath_rate_table *rate_table,
u8 *mcs_set, u32 capflag) u8 *mcs_set, u32 capflag)
{ {
u8 i, j, hi = 0; u8 i, j, hi = 0;
...@@ -653,50 +651,13 @@ ath_rc_sib_setvalid_htrates(struct ath_rate_node *ath_rc_priv, ...@@ -653,50 +651,13 @@ ath_rc_sib_setvalid_htrates(struct ath_rate_node *ath_rc_priv,
return hi; return hi;
} }
struct ath_rate_softc *ath_rate_attach(struct ath_softc *sc)
{
struct ath_rate_softc *asc;
asc = kzalloc(sizeof(struct ath_rate_softc), GFP_KERNEL);
if (asc == NULL)
return NULL;
asc->hw_rate_table[ATH9K_MODE_11B] = &ar5416_11b_ratetable;
asc->hw_rate_table[ATH9K_MODE_11A] = &ar5416_11a_ratetable;
asc->hw_rate_table[ATH9K_MODE_11G] = &ar5416_11g_ratetable;
asc->hw_rate_table[ATH9K_MODE_11NA_HT20] = &ar5416_11na_ratetable;
asc->hw_rate_table[ATH9K_MODE_11NG_HT20] = &ar5416_11ng_ratetable;
asc->hw_rate_table[ATH9K_MODE_11NA_HT40PLUS] =
&ar5416_11na_ratetable;
asc->hw_rate_table[ATH9K_MODE_11NA_HT40MINUS] =
&ar5416_11na_ratetable;
asc->hw_rate_table[ATH9K_MODE_11NG_HT40PLUS] =
&ar5416_11ng_ratetable;
asc->hw_rate_table[ATH9K_MODE_11NG_HT40MINUS] =
&ar5416_11ng_ratetable;
/* Save Maximum TX Trigger Level (used for 11n) */
tx_triglevel_max = sc->sc_ah->ah_caps.tx_triglevel_max;
return asc;
}
void ath_rate_detach(struct ath_rate_softc *asc)
{
if (asc != NULL)
kfree(asc);
}
u8 ath_rate_findrateix(struct ath_softc *sc, u8 ath_rate_findrateix(struct ath_softc *sc,
u8 dot11rate) u8 dot11rate)
{ {
const struct ath_rate_table *ratetable; struct ath_rate_table *ratetable;
struct ath_rate_softc *rsc = sc->sc_rc;
int i; int i;
ratetable = rsc->hw_rate_table[sc->sc_curmode]; ratetable = sc->hw_rate_table[sc->sc_curmode];
if (WARN_ON(!ratetable)) if (WARN_ON(!ratetable))
return 0; return 0;
...@@ -711,7 +672,7 @@ u8 ath_rate_findrateix(struct ath_softc *sc, ...@@ -711,7 +672,7 @@ u8 ath_rate_findrateix(struct ath_softc *sc,
static u8 ath_rc_ratefind_ht(struct ath_softc *sc, static u8 ath_rc_ratefind_ht(struct ath_softc *sc,
struct ath_rate_node *ath_rc_priv, struct ath_rate_node *ath_rc_priv,
const struct ath_rate_table *rate_table, struct ath_rate_table *rate_table,
int probe_allowed, int *is_probing, int probe_allowed, int *is_probing,
int is_retry) int is_retry)
{ {
...@@ -843,7 +804,7 @@ static u8 ath_rc_ratefind_ht(struct ath_softc *sc, ...@@ -843,7 +804,7 @@ static u8 ath_rc_ratefind_ht(struct ath_softc *sc,
return rate; return rate;
} }
static void ath_rc_rate_set_series(const struct ath_rate_table *rate_table , static void ath_rc_rate_set_series(struct ath_rate_table *rate_table ,
struct ath_rc_series *series, struct ath_rc_series *series,
u8 tries, u8 tries,
u8 rix, u8 rix,
...@@ -864,7 +825,7 @@ static void ath_rc_rate_set_series(const struct ath_rate_table *rate_table , ...@@ -864,7 +825,7 @@ static void ath_rc_rate_set_series(const struct ath_rate_table *rate_table ,
static u8 ath_rc_rate_getidx(struct ath_softc *sc, static u8 ath_rc_rate_getidx(struct ath_softc *sc,
struct ath_rate_node *ath_rc_priv, struct ath_rate_node *ath_rc_priv,
const struct ath_rate_table *rate_table, struct ath_rate_table *rate_table,
u8 rix, u16 stepdown, u8 rix, u16 stepdown,
u16 min_rate) u16 min_rate)
{ {
...@@ -898,11 +859,9 @@ static void ath_rc_ratefind(struct ath_softc *sc, ...@@ -898,11 +859,9 @@ static void ath_rc_ratefind(struct ath_softc *sc,
int is_retry) int is_retry)
{ {
u8 try_per_rate = 0, i = 0, rix, nrix; u8 try_per_rate = 0, i = 0, rix, nrix;
struct ath_rate_softc *asc = (struct ath_rate_softc *)sc->sc_rc;
struct ath_rate_table *rate_table; struct ath_rate_table *rate_table;
rate_table = rate_table = sc->hw_rate_table[sc->sc_curmode];
(struct ath_rate_table *)asc->hw_rate_table[sc->sc_curmode];
rix = ath_rc_ratefind_ht(sc, ath_rc_priv, rate_table, rix = ath_rc_ratefind_ht(sc, ath_rc_priv, rate_table,
(rcflag & ATH_RC_PROBE_ALLOWED) ? 1 : 0, (rcflag & ATH_RC_PROBE_ALLOWED) ? 1 : 0,
is_probe, is_retry); is_probe, is_retry);
...@@ -1003,10 +962,7 @@ static void ath_rc_update_ht(struct ath_softc *sc, ...@@ -1003,10 +962,7 @@ static void ath_rc_update_ht(struct ath_softc *sc,
u32 now_msec = jiffies_to_msecs(jiffies); u32 now_msec = jiffies_to_msecs(jiffies);
int state_change = FALSE, rate, count; int state_change = FALSE, rate, count;
u8 last_per; u8 last_per;
struct ath_rate_softc *asc = (struct ath_rate_softc *)sc->sc_rc; struct ath_rate_table *rate_table = sc->hw_rate_table[sc->sc_curmode];
struct ath_rate_table *rate_table =
(struct ath_rate_table *)asc->hw_rate_table[sc->sc_curmode];
static u32 nretry_to_per_lookup[10] = { static u32 nretry_to_per_lookup[10] = {
100 * 0 / 1, 100 * 0 / 1,
100 * 1 / 4, 100 * 1 / 4,
...@@ -1330,15 +1286,13 @@ static void ath_rc_update(struct ath_softc *sc, ...@@ -1330,15 +1286,13 @@ static void ath_rc_update(struct ath_softc *sc,
struct ath_tx_info_priv *info_priv, int final_ts_idx, struct ath_tx_info_priv *info_priv, int final_ts_idx,
int xretries, int long_retry) int xretries, int long_retry)
{ {
struct ath_rate_softc *asc = (struct ath_rate_softc *)sc->sc_rc;
struct ath_rate_table *rate_table; struct ath_rate_table *rate_table;
struct ath_rc_series rcs[4]; struct ath_rc_series rcs[4];
u8 flags; u8 flags;
u32 series = 0, rix; u32 series = 0, rix;
memcpy(rcs, info_priv->rcs, 4 * sizeof(rcs[0])); memcpy(rcs, info_priv->rcs, 4 * sizeof(rcs[0]));
rate_table = (struct ath_rate_table *) rate_table = sc->hw_rate_table[sc->sc_curmode];
asc->hw_rate_table[sc->sc_curmode];
ASSERT(rcs[0].tries != 0); ASSERT(rcs[0].tries != 0);
/* /*
...@@ -1432,7 +1386,7 @@ static void ath_rate_tx_complete(struct ath_softc *sc, ...@@ -1432,7 +1386,7 @@ static void ath_rate_tx_complete(struct ath_softc *sc,
*/ */
if (info_priv->tx.ts_flags & if (info_priv->tx.ts_flags &
(ATH9K_TX_DATA_UNDERRUN | ATH9K_TX_DELIM_UNDERRUN) && (ATH9K_TX_DATA_UNDERRUN | ATH9K_TX_DELIM_UNDERRUN) &&
((sc->sc_ah->ah_txTrigLevel) >= tx_triglevel_max)) { ((sc->sc_ah->ah_txTrigLevel) >= rc_priv->tx_triglevel_max)) {
tx_status = 1; tx_status = 1;
is_underrun = 1; is_underrun = 1;
} }
...@@ -1452,21 +1406,17 @@ static void ath_rc_init(struct ath_softc *sc, ...@@ -1452,21 +1406,17 @@ static void ath_rc_init(struct ath_softc *sc,
struct ieee80211_sta *sta) struct ieee80211_sta *sta)
{ {
struct ath_rate_table *rate_table = NULL; struct ath_rate_table *rate_table = NULL;
struct ath_rate_softc *asc = (struct ath_rate_softc *)sc->sc_rc;
struct ath_rateset *rateset = &ath_rc_priv->neg_rates; struct ath_rateset *rateset = &ath_rc_priv->neg_rates;
u8 *ht_mcs = (u8 *)&ath_rc_priv->neg_ht_rates; u8 *ht_mcs = (u8 *)&ath_rc_priv->neg_ht_rates;
u8 i, j, k, hi = 0, hthi = 0; u8 i, j, k, hi = 0, hthi = 0;
rate_table = (struct ath_rate_table *) rate_table = sc->hw_rate_table[sc->sc_curmode];
asc->hw_rate_table[sc->sc_curmode];
if (sta->ht_cap.ht_supported) { if (sta->ht_cap.ht_supported) {
if (sband->band == IEEE80211_BAND_2GHZ) if (sband->band == IEEE80211_BAND_2GHZ)
rate_table = (struct ath_rate_table *) rate_table = sc->hw_rate_table[ATH9K_MODE_11NG_HT20];
asc->hw_rate_table[ATH9K_MODE_11NG_HT20];
else else
rate_table = (struct ath_rate_table *) rate_table = sc->hw_rate_table[ATH9K_MODE_11NA_HT20];
asc->hw_rate_table[ATH9K_MODE_11NA_HT20];
ath_rc_priv->ht_cap = (WLAN_RC_HT_FLAG | WLAN_RC_DS_FLAG); ath_rc_priv->ht_cap = (WLAN_RC_HT_FLAG | WLAN_RC_DS_FLAG);
if (sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) 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,8 +1641,8 @@ static void *ath_rate_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp
return NULL; return NULL;
} }
rate_priv->asc = sc->sc_rc;
rate_priv->rssi_down_time = jiffies_to_msecs(jiffies); rate_priv->rssi_down_time = jiffies_to_msecs(jiffies);
rate_priv->tx_triglevel_max = sc->sc_ah->ah_caps.tx_triglevel_max;
return rate_priv; return rate_priv;
} }
...@@ -1717,6 +1667,28 @@ static struct rate_control_ops ath_rate_ops = { ...@@ -1717,6 +1667,28 @@ static struct rate_control_ops ath_rate_ops = {
.free_sta = ath_rate_free_sta, .free_sta = ath_rate_free_sta,
}; };
void ath_rate_attach(struct ath_softc *sc)
{
sc->hw_rate_table[ATH9K_MODE_11B] =
&ar5416_11b_ratetable;
sc->hw_rate_table[ATH9K_MODE_11A] =
&ar5416_11a_ratetable;
sc->hw_rate_table[ATH9K_MODE_11G] =
&ar5416_11g_ratetable;
sc->hw_rate_table[ATH9K_MODE_11NA_HT20] =
&ar5416_11na_ratetable;
sc->hw_rate_table[ATH9K_MODE_11NG_HT20] =
&ar5416_11ng_ratetable;
sc->hw_rate_table[ATH9K_MODE_11NA_HT40PLUS] =
&ar5416_11na_ratetable;
sc->hw_rate_table[ATH9K_MODE_11NA_HT40MINUS] =
&ar5416_11na_ratetable;
sc->hw_rate_table[ATH9K_MODE_11NG_HT40PLUS] =
&ar5416_11ng_ratetable;
sc->hw_rate_table[ATH9K_MODE_11NG_HT40MINUS] =
&ar5416_11ng_ratetable;
}
int ath_rate_control_register(void) int ath_rate_control_register(void)
{ {
return ieee80211_rate_control_register(&ath_rate_ops); return ieee80211_rate_control_register(&ath_rate_ops);
......
...@@ -199,15 +199,6 @@ struct ath_rateset { ...@@ -199,15 +199,6 @@ struct ath_rateset {
u8 rs_rates[ATH_RATE_MAX]; u8 rs_rates[ATH_RATE_MAX];
}; };
/* per-device state */
struct ath_rate_softc {
/* phy tables that contain rate control data */
const void *hw_rate_table[ATH9K_MODE_MAX];
/* -1 or index of fixed rate */
int fixedrix;
};
/** /**
* struct ath_rate_node - Rate Control priv data * struct ath_rate_node - Rate Control priv data
* @state: RC state * @state: RC state
...@@ -261,6 +252,7 @@ struct ath_rate_node { ...@@ -261,6 +252,7 @@ struct ath_rate_node {
u32 per_down_time; u32 per_down_time;
u32 probe_interval; u32 probe_interval;
u32 prev_data_rix; u32 prev_data_rix;
u32 tx_triglevel_max;
struct ath_tx_ratectrl_state state[MAX_TX_RATE_TBL]; struct ath_tx_ratectrl_state state[MAX_TX_RATE_TBL];
struct ath_rateset neg_rates; struct ath_rateset neg_rates;
struct ath_rateset neg_ht_rates; struct ath_rateset neg_ht_rates;
...@@ -276,8 +268,7 @@ struct ath_tx_info_priv { ...@@ -276,8 +268,7 @@ struct ath_tx_info_priv {
u8 min_rate; u8 min_rate;
}; };
struct ath_rate_softc *ath_rate_attach(struct ath_softc *sch); void ath_rate_attach(struct ath_softc *sc);
void ath_rate_detach(struct ath_rate_softc *asc);
u8 ath_rate_findrateix(struct ath_softc *sc, u8 dot11_rate); u8 ath_rate_findrateix(struct ath_softc *sc, u8 dot11_rate);
int ath_rate_control_register(void); int ath_rate_control_register(void);
void ath_rate_control_unregister(void); void ath_rate_control_unregister(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment