diff options
author | Felix Fietkau <nbd@openwrt.org> | 2009-11-15 17:09:25 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-11-18 17:09:11 -0500 |
commit | 827e69bf6734193d7a6f47f0435db7ebef1b636e (patch) | |
tree | 0e574b60dded8971a0527dbf6f2f1cbf4deb91aa /drivers/net/wireless/ath/ath9k/rc.c | |
parent | 599bf6a4d64d8399e99514e0e1ef02e97e43238f (diff) |
ath9k: get rid of tx_info_priv
This patch removes the need for separately allocated private tx info
data in ath9k and brings the driver one small step closer to using the
mac80211 rate control API properly.
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/rc.c')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/rc.c | 71 |
1 files changed, 35 insertions, 36 deletions
diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c index bb72b46567f9..ea4b9081b4d0 100644 --- a/drivers/net/wireless/ath/ath9k/rc.c +++ b/drivers/net/wireless/ath/ath9k/rc.c | |||
@@ -859,12 +859,12 @@ static void ath_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta, | |||
859 | static bool ath_rc_update_per(struct ath_softc *sc, | 859 | static bool ath_rc_update_per(struct ath_softc *sc, |
860 | const struct ath_rate_table *rate_table, | 860 | const struct ath_rate_table *rate_table, |
861 | struct ath_rate_priv *ath_rc_priv, | 861 | struct ath_rate_priv *ath_rc_priv, |
862 | struct ath_tx_info_priv *tx_info_priv, | 862 | struct ieee80211_tx_info *tx_info, |
863 | int tx_rate, int xretries, int retries, | 863 | int tx_rate, int xretries, int retries, |
864 | u32 now_msec) | 864 | u32 now_msec) |
865 | { | 865 | { |
866 | bool state_change = false; | 866 | bool state_change = false; |
867 | int count; | 867 | int count, n_bad_frames; |
868 | u8 last_per; | 868 | u8 last_per; |
869 | static u32 nretry_to_per_lookup[10] = { | 869 | static u32 nretry_to_per_lookup[10] = { |
870 | 100 * 0 / 1, | 870 | 100 * 0 / 1, |
@@ -880,6 +880,7 @@ static bool ath_rc_update_per(struct ath_softc *sc, | |||
880 | }; | 880 | }; |
881 | 881 | ||
882 | last_per = ath_rc_priv->per[tx_rate]; | 882 | last_per = ath_rc_priv->per[tx_rate]; |
883 | n_bad_frames = tx_info->status.ampdu_len - tx_info->status.ampdu_ack_len; | ||
883 | 884 | ||
884 | if (xretries) { | 885 | if (xretries) { |
885 | if (xretries == 1) { | 886 | if (xretries == 1) { |
@@ -907,7 +908,7 @@ static bool ath_rc_update_per(struct ath_softc *sc, | |||
907 | if (retries >= count) | 908 | if (retries >= count) |
908 | retries = count - 1; | 909 | retries = count - 1; |
909 | 910 | ||
910 | if (tx_info_priv->n_bad_frames) { | 911 | if (n_bad_frames) { |
911 | /* new_PER = 7/8*old_PER + 1/8*(currentPER) | 912 | /* new_PER = 7/8*old_PER + 1/8*(currentPER) |
912 | * Assuming that n_frames is not 0. The current PER | 913 | * Assuming that n_frames is not 0. The current PER |
913 | * from the retries is 100 * retries / (retries+1), | 914 | * from the retries is 100 * retries / (retries+1), |
@@ -920,14 +921,14 @@ static bool ath_rc_update_per(struct ath_softc *sc, | |||
920 | * the above PER. The expression below is a | 921 | * the above PER. The expression below is a |
921 | * simplified version of the sum of these two terms. | 922 | * simplified version of the sum of these two terms. |
922 | */ | 923 | */ |
923 | if (tx_info_priv->n_frames > 0) { | 924 | if (tx_info->status.ampdu_len > 0) { |
924 | int n_frames, n_bad_frames; | 925 | int n_frames, n_bad_tries; |
925 | u8 cur_per, new_per; | 926 | u8 cur_per, new_per; |
926 | 927 | ||
927 | n_bad_frames = retries * tx_info_priv->n_frames + | 928 | n_bad_tries = retries * tx_info->status.ampdu_len + |
928 | tx_info_priv->n_bad_frames; | 929 | n_bad_frames; |
929 | n_frames = tx_info_priv->n_frames * (retries + 1); | 930 | n_frames = tx_info->status.ampdu_len * (retries + 1); |
930 | cur_per = (100 * n_bad_frames / n_frames) >> 3; | 931 | cur_per = (100 * n_bad_tries / n_frames) >> 3; |
931 | new_per = (u8)(last_per - (last_per >> 3) + cur_per); | 932 | new_per = (u8)(last_per - (last_per >> 3) + cur_per); |
932 | ath_rc_priv->per[tx_rate] = new_per; | 933 | ath_rc_priv->per[tx_rate] = new_per; |
933 | } | 934 | } |
@@ -943,8 +944,7 @@ static bool ath_rc_update_per(struct ath_softc *sc, | |||
943 | * this was a probe. Otherwise, ignore the probe. | 944 | * this was a probe. Otherwise, ignore the probe. |
944 | */ | 945 | */ |
945 | if (ath_rc_priv->probe_rate && ath_rc_priv->probe_rate == tx_rate) { | 946 | if (ath_rc_priv->probe_rate && ath_rc_priv->probe_rate == tx_rate) { |
946 | if (retries > 0 || 2 * tx_info_priv->n_bad_frames > | 947 | if (retries > 0 || 2 * n_bad_frames > tx_info->status.ampdu_len) { |
947 | tx_info_priv->n_frames) { | ||
948 | /* | 948 | /* |
949 | * Since we probed with just a single attempt, | 949 | * Since we probed with just a single attempt, |
950 | * any retries means the probe failed. Also, | 950 | * any retries means the probe failed. Also, |
@@ -1003,7 +1003,7 @@ static bool ath_rc_update_per(struct ath_softc *sc, | |||
1003 | 1003 | ||
1004 | static void ath_rc_update_ht(struct ath_softc *sc, | 1004 | static void ath_rc_update_ht(struct ath_softc *sc, |
1005 | struct ath_rate_priv *ath_rc_priv, | 1005 | struct ath_rate_priv *ath_rc_priv, |
1006 | struct ath_tx_info_priv *tx_info_priv, | 1006 | struct ieee80211_tx_info *tx_info, |
1007 | int tx_rate, int xretries, int retries) | 1007 | int tx_rate, int xretries, int retries) |
1008 | { | 1008 | { |
1009 | u32 now_msec = jiffies_to_msecs(jiffies); | 1009 | u32 now_msec = jiffies_to_msecs(jiffies); |
@@ -1020,7 +1020,7 @@ static void ath_rc_update_ht(struct ath_softc *sc, | |||
1020 | 1020 | ||
1021 | /* Update PER first */ | 1021 | /* Update PER first */ |
1022 | state_change = ath_rc_update_per(sc, rate_table, ath_rc_priv, | 1022 | state_change = ath_rc_update_per(sc, rate_table, ath_rc_priv, |
1023 | tx_info_priv, tx_rate, xretries, | 1023 | tx_info, tx_rate, xretries, |
1024 | retries, now_msec); | 1024 | retries, now_msec); |
1025 | 1025 | ||
1026 | /* | 1026 | /* |
@@ -1098,7 +1098,6 @@ static void ath_rc_tx_status(struct ath_softc *sc, | |||
1098 | struct ieee80211_tx_info *tx_info, | 1098 | struct ieee80211_tx_info *tx_info, |
1099 | int final_ts_idx, int xretries, int long_retry) | 1099 | int final_ts_idx, int xretries, int long_retry) |
1100 | { | 1100 | { |
1101 | struct ath_tx_info_priv *tx_info_priv = ATH_TX_INFO_PRIV(tx_info); | ||
1102 | const struct ath_rate_table *rate_table; | 1101 | const struct ath_rate_table *rate_table; |
1103 | struct ieee80211_tx_rate *rates = tx_info->status.rates; | 1102 | struct ieee80211_tx_rate *rates = tx_info->status.rates; |
1104 | u8 flags; | 1103 | u8 flags; |
@@ -1124,9 +1123,8 @@ static void ath_rc_tx_status(struct ath_softc *sc, | |||
1124 | return; | 1123 | return; |
1125 | 1124 | ||
1126 | rix = ath_rc_get_rateindex(rate_table, &rates[i]); | 1125 | rix = ath_rc_get_rateindex(rate_table, &rates[i]); |
1127 | ath_rc_update_ht(sc, ath_rc_priv, | 1126 | ath_rc_update_ht(sc, ath_rc_priv, tx_info, |
1128 | tx_info_priv, rix, | 1127 | rix, xretries ? 1 : 2, |
1129 | xretries ? 1 : 2, | ||
1130 | rates[i].count); | 1128 | rates[i].count); |
1131 | } | 1129 | } |
1132 | } | 1130 | } |
@@ -1149,8 +1147,7 @@ static void ath_rc_tx_status(struct ath_softc *sc, | |||
1149 | return; | 1147 | return; |
1150 | 1148 | ||
1151 | rix = ath_rc_get_rateindex(rate_table, &rates[i]); | 1149 | rix = ath_rc_get_rateindex(rate_table, &rates[i]); |
1152 | ath_rc_update_ht(sc, ath_rc_priv, tx_info_priv, rix, | 1150 | ath_rc_update_ht(sc, ath_rc_priv, tx_info, rix, xretries, long_retry); |
1153 | xretries, long_retry); | ||
1154 | } | 1151 | } |
1155 | 1152 | ||
1156 | static const | 1153 | static const |
@@ -1301,23 +1298,30 @@ static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband, | |||
1301 | { | 1298 | { |
1302 | struct ath_softc *sc = priv; | 1299 | struct ath_softc *sc = priv; |
1303 | struct ath_rate_priv *ath_rc_priv = priv_sta; | 1300 | struct ath_rate_priv *ath_rc_priv = priv_sta; |
1304 | struct ath_tx_info_priv *tx_info_priv = NULL; | ||
1305 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); | 1301 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); |
1306 | struct ieee80211_hdr *hdr; | 1302 | struct ieee80211_hdr *hdr; |
1307 | int final_ts_idx, tx_status = 0, is_underrun = 0; | 1303 | int final_ts_idx = 0, tx_status = 0, is_underrun = 0; |
1304 | int long_retry = 0; | ||
1308 | __le16 fc; | 1305 | __le16 fc; |
1306 | int i; | ||
1309 | 1307 | ||
1310 | hdr = (struct ieee80211_hdr *)skb->data; | 1308 | hdr = (struct ieee80211_hdr *)skb->data; |
1311 | fc = hdr->frame_control; | 1309 | fc = hdr->frame_control; |
1312 | tx_info_priv = ATH_TX_INFO_PRIV(tx_info); | 1310 | for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) { |
1313 | final_ts_idx = tx_info_priv->tx.ts_rateindex; | 1311 | struct ieee80211_tx_rate *rate = &tx_info->status.rates[i]; |
1312 | if (!rate->count) | ||
1313 | break; | ||
1314 | |||
1315 | final_ts_idx = i; | ||
1316 | long_retry = rate->count - 1; | ||
1317 | } | ||
1314 | 1318 | ||
1315 | if (!priv_sta || !ieee80211_is_data(fc) || | 1319 | if (!priv_sta || !ieee80211_is_data(fc) || |
1316 | !tx_info_priv->update_rc) | 1320 | !(tx_info->pad[0] & ATH_TX_INFO_UPDATE_RC)) |
1317 | goto exit; | 1321 | return; |
1318 | 1322 | ||
1319 | if (tx_info_priv->tx.ts_status & ATH9K_TXERR_FILT) | 1323 | if (tx_info->flags & IEEE80211_TX_STAT_TX_FILTERED) |
1320 | goto exit; | 1324 | return; |
1321 | 1325 | ||
1322 | /* | 1326 | /* |
1323 | * If underrun error is seen assume it as an excessive retry only | 1327 | * If underrun error is seen assume it as an excessive retry only |
@@ -1325,20 +1329,17 @@ static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband, | |||
1325 | * Adjust the long retry as if the frame was tried hw->max_rate_tries | 1329 | * Adjust the long retry as if the frame was tried hw->max_rate_tries |
1326 | * times. This affects how ratectrl updates PER for the failed rate. | 1330 | * times. This affects how ratectrl updates PER for the failed rate. |
1327 | */ | 1331 | */ |
1328 | if (tx_info_priv->tx.ts_flags & | 1332 | if ((tx_info->pad[0] & ATH_TX_INFO_UNDERRUN) && |
1329 | (ATH9K_TX_DATA_UNDERRUN | ATH9K_TX_DELIM_UNDERRUN) && | 1333 | (sc->sc_ah->tx_trig_level >= ath_rc_priv->tx_triglevel_max)) { |
1330 | ((sc->sc_ah->tx_trig_level) >= ath_rc_priv->tx_triglevel_max)) { | ||
1331 | tx_status = 1; | 1334 | tx_status = 1; |
1332 | is_underrun = 1; | 1335 | is_underrun = 1; |
1333 | } | 1336 | } |
1334 | 1337 | ||
1335 | if ((tx_info_priv->tx.ts_status & ATH9K_TXERR_XRETRY) || | 1338 | if (tx_info->pad[0] & ATH_TX_INFO_XRETRY) |
1336 | (tx_info_priv->tx.ts_status & ATH9K_TXERR_FIFO)) | ||
1337 | tx_status = 1; | 1339 | tx_status = 1; |
1338 | 1340 | ||
1339 | ath_rc_tx_status(sc, ath_rc_priv, tx_info, final_ts_idx, tx_status, | 1341 | ath_rc_tx_status(sc, ath_rc_priv, tx_info, final_ts_idx, tx_status, |
1340 | (is_underrun) ? sc->hw->max_rate_tries : | 1342 | (is_underrun) ? sc->hw->max_rate_tries : long_retry); |
1341 | tx_info_priv->tx.ts_longretry); | ||
1342 | 1343 | ||
1343 | /* Check if aggregation has to be enabled for this tid */ | 1344 | /* Check if aggregation has to be enabled for this tid */ |
1344 | if (conf_is_ht(&sc->hw->conf) && | 1345 | if (conf_is_ht(&sc->hw->conf) && |
@@ -1357,8 +1358,6 @@ static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband, | |||
1357 | } | 1358 | } |
1358 | 1359 | ||
1359 | ath_debug_stat_rc(sc, skb); | 1360 | ath_debug_stat_rc(sc, skb); |
1360 | exit: | ||
1361 | kfree(tx_info_priv); | ||
1362 | } | 1361 | } |
1363 | 1362 | ||
1364 | static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband, | 1363 | static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband, |