aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath9k/rc.c
diff options
context:
space:
mode:
authorSujith <Sujith.Manoharan@atheros.com>2008-11-17 22:37:30 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-11-26 09:47:29 -0500
commita8efee4f4740c61fccaf73608df282c4ee24ae86 (patch)
tree62cf022a48bf59ee93c31817ce0bc251e9f95812 /drivers/net/wireless/ath9k/rc.c
parentfe7f4a77450c1d0e463a9b1456b40c2305433e41 (diff)
ath9k: Use rate_driver_data
Remove the hack using vif, and use rate_driver_data within skb->cb to hold driver specific rate information. Setup the rate series in the skb's tx control area and remove all references to ath9k specific rate series ( using struct ath_rc_series ). 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.c145
1 files changed, 61 insertions, 84 deletions
diff --git a/drivers/net/wireless/ath9k/rc.c b/drivers/net/wireless/ath9k/rc.c
index 59c146cdd0db..156b245ab9e4 100644
--- a/drivers/net/wireless/ath9k/rc.c
+++ b/drivers/net/wireless/ath9k/rc.c
@@ -805,22 +805,22 @@ static u8 ath_rc_ratefind_ht(struct ath_softc *sc,
805} 805}
806 806
807static void ath_rc_rate_set_series(struct ath_rate_table *rate_table , 807static void ath_rc_rate_set_series(struct ath_rate_table *rate_table ,
808 struct ath_rc_series *series, 808 struct ieee80211_tx_rate *rate,
809 u8 tries, 809 u8 tries,
810 u8 rix, 810 u8 rix,
811 int rtsctsenable) 811 int rtsctsenable)
812{ 812{
813 series->tries = tries; 813 rate->count = tries;
814 series->flags = (rtsctsenable ? ATH_RC_RTSCTS_FLAG : 0) | 814 rate->idx = rix;
815 (WLAN_RC_PHY_DS(rate_table->info[rix].phy) ? 815
816 ATH_RC_DS_FLAG : 0) | 816 if (rtsctsenable)
817 (WLAN_RC_PHY_40(rate_table->info[rix].phy) ? 817 rate->flags |= IEEE80211_TX_RC_USE_RTS_CTS;
818 ATH_RC_CW40_FLAG : 0) | 818 if (WLAN_RC_PHY_40(rate_table->info[rix].phy))
819 (WLAN_RC_PHY_SGI(rate_table->info[rix].phy) ? 819 rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
820 ATH_RC_SGI_FLAG : 0); 820 if (WLAN_RC_PHY_SGI(rate_table->info[rix].phy))
821 821 rate->flags |= IEEE80211_TX_RC_SHORT_GI;
822 series->rix = rate_table->info[rix].base_index; 822 if (WLAN_RC_PHY_HT(rate_table->info[rix].phy))
823 series->max_4ms_framelen = rate_table->info[rix].max_4ms_framelen; 823 rate->flags |= IEEE80211_TX_RC_MCS;
824} 824}
825 825
826static u8 ath_rc_rate_getidx(struct ath_softc *sc, 826static u8 ath_rc_rate_getidx(struct ath_softc *sc,
@@ -855,11 +855,12 @@ static u8 ath_rc_rate_getidx(struct ath_softc *sc,
855static void ath_rc_ratefind(struct ath_softc *sc, 855static void ath_rc_ratefind(struct ath_softc *sc,
856 struct ath_rate_node *ath_rc_priv, 856 struct ath_rate_node *ath_rc_priv,
857 int num_tries, int num_rates, unsigned int rcflag, 857 int num_tries, int num_rates, unsigned int rcflag,
858 struct ath_rc_series series[], int *is_probe, 858 struct ieee80211_tx_info *tx_info, int *is_probe,
859 int is_retry) 859 int is_retry)
860{ 860{
861 u8 try_per_rate = 0, i = 0, rix, nrix; 861 u8 try_per_rate = 0, i = 0, rix, nrix;
862 struct ath_rate_table *rate_table; 862 struct ath_rate_table *rate_table;
863 struct ieee80211_tx_rate *rates = tx_info->control.rates;
863 864
864 rate_table = sc->hw_rate_table[sc->sc_curmode]; 865 rate_table = sc->hw_rate_table[sc->sc_curmode];
865 rix = ath_rc_ratefind_ht(sc, ath_rc_priv, rate_table, 866 rix = ath_rc_ratefind_ht(sc, ath_rc_priv, rate_table,
@@ -871,7 +872,7 @@ static void ath_rc_ratefind(struct ath_softc *sc,
871 /* set one try for probe rates. For the 872 /* set one try for probe rates. For the
872 * probes don't enable rts */ 873 * probes don't enable rts */
873 ath_rc_rate_set_series(rate_table, 874 ath_rc_rate_set_series(rate_table,
874 &series[i++], 1, nrix, FALSE); 875 &rates[i++], 1, nrix, FALSE);
875 876
876 try_per_rate = (num_tries/num_rates); 877 try_per_rate = (num_tries/num_rates);
877 /* Get the next tried/allowed rate. No RTS for the next series 878 /* Get the next tried/allowed rate. No RTS for the next series
@@ -880,12 +881,12 @@ static void ath_rc_ratefind(struct ath_softc *sc,
880 nrix = ath_rc_rate_getidx(sc, 881 nrix = ath_rc_rate_getidx(sc,
881 ath_rc_priv, rate_table, nrix, 1, FALSE); 882 ath_rc_priv, rate_table, nrix, 1, FALSE);
882 ath_rc_rate_set_series(rate_table, 883 ath_rc_rate_set_series(rate_table,
883 &series[i++], try_per_rate, nrix, 0); 884 &rates[i++], try_per_rate, nrix, 0);
884 } else { 885 } else {
885 try_per_rate = (num_tries/num_rates); 886 try_per_rate = (num_tries/num_rates);
886 /* Set the choosen rate. No RTS for first series entry. */ 887 /* Set the choosen rate. No RTS for first series entry. */
887 ath_rc_rate_set_series(rate_table, 888 ath_rc_rate_set_series(rate_table,
888 &series[i++], try_per_rate, nrix, FALSE); 889 &rates[i++], try_per_rate, nrix, FALSE);
889 } 890 }
890 891
891 /* Fill in the other rates for multirate retry */ 892 /* Fill in the other rates for multirate retry */
@@ -902,7 +903,7 @@ static void ath_rc_ratefind(struct ath_softc *sc,
902 rate_table, nrix, 1, min_rate); 903 rate_table, nrix, 1, min_rate);
903 /* All other rates in the series have RTS enabled */ 904 /* All other rates in the series have RTS enabled */
904 ath_rc_rate_set_series(rate_table, 905 ath_rc_rate_set_series(rate_table,
905 &series[i], try_num, nrix, TRUE); 906 &rates[i], try_num, nrix, TRUE);
906 } 907 }
907 908
908 /* 909 /*
@@ -928,9 +929,8 @@ static void ath_rc_ratefind(struct ath_softc *sc,
928 if (i == 4 && 929 if (i == 4 &&
929 ((dot11rate == 2 && phy == WLAN_RC_PHY_HT_40_SS) || 930 ((dot11rate == 2 && phy == WLAN_RC_PHY_HT_40_SS) ||
930 (dot11rate == 3 && phy == WLAN_RC_PHY_HT_20_SS))) { 931 (dot11rate == 3 && phy == WLAN_RC_PHY_HT_20_SS))) {
931 series[3].rix = series[2].rix; 932 rates[3].idx = rates[2].idx;
932 series[3].flags = series[2].flags; 933 rates[3].flags = rates[2].flags;
933 series[3].max_4ms_framelen = series[2].max_4ms_framelen;
934 } 934 }
935 } 935 }
936} 936}
@@ -943,7 +943,7 @@ static void ath_rate_findrate(struct ath_softc *sc,
943 int num_tries, 943 int num_tries,
944 int num_rates, 944 int num_rates,
945 unsigned int rcflag, 945 unsigned int rcflag,
946 struct ath_rc_series series[], 946 struct ieee80211_tx_info *tx_info,
947 int *is_probe, 947 int *is_probe,
948 int is_retry) 948 int is_retry)
949{ 949{
@@ -951,7 +951,7 @@ static void ath_rate_findrate(struct ath_softc *sc,
951 return; 951 return;
952 952
953 ath_rc_ratefind(sc, ath_rc_priv, num_tries, num_rates, 953 ath_rc_ratefind(sc, ath_rc_priv, num_tries, num_rates,
954 rcflag, series, is_probe, is_retry); 954 rcflag, tx_info, is_probe, is_retry);
955} 955}
956 956
957static void ath_rc_update_ht(struct ath_softc *sc, 957static void ath_rc_update_ht(struct ath_softc *sc,
@@ -1283,17 +1283,17 @@ static void ath_rc_update_ht(struct ath_softc *sc,
1283 */ 1283 */
1284static void ath_rc_update(struct ath_softc *sc, 1284static void ath_rc_update(struct ath_softc *sc,
1285 struct ath_rate_node *ath_rc_priv, 1285 struct ath_rate_node *ath_rc_priv,
1286 struct ath_tx_info_priv *info_priv, int final_ts_idx, 1286 struct ieee80211_tx_info *tx_info, int final_ts_idx,
1287 int xretries, int long_retry) 1287 int xretries, int long_retry)
1288{ 1288{
1289 struct ath_tx_info_priv *info_priv =
1290 (struct ath_tx_info_priv *)tx_info->rate_driver_data[0];
1289 struct ath_rate_table *rate_table; 1291 struct ath_rate_table *rate_table;
1290 struct ath_rc_series rcs[4]; 1292 struct ieee80211_tx_rate *rates = tx_info->status.rates;
1291 u8 flags; 1293 u8 flags;
1292 u32 series = 0, rix; 1294 u32 series = 0, rix;
1293 1295
1294 memcpy(rcs, info_priv->rcs, 4 * sizeof(rcs[0]));
1295 rate_table = sc->hw_rate_table[sc->sc_curmode]; 1296 rate_table = sc->hw_rate_table[sc->sc_curmode];
1296 ASSERT(rcs[0].tries != 0);
1297 1297
1298 /* 1298 /*
1299 * If the first rate is not the final index, there 1299 * If the first rate is not the final index, there
@@ -1302,31 +1302,31 @@ static void ath_rc_update(struct ath_softc *sc,
1302 if (final_ts_idx != 0) { 1302 if (final_ts_idx != 0) {
1303 /* Process intermediate rates that failed.*/ 1303 /* Process intermediate rates that failed.*/
1304 for (series = 0; series < final_ts_idx ; series++) { 1304 for (series = 0; series < final_ts_idx ; series++) {
1305 if (rcs[series].tries != 0) { 1305 if (rates[series].count != 0) {
1306 flags = rcs[series].flags; 1306 flags = rates[series].flags;
1307 /* If HT40 and we have switched mode from 1307 /* If HT40 and we have switched mode from
1308 * 40 to 20 => don't update */ 1308 * 40 to 20 => don't update */
1309 if ((flags & ATH_RC_CW40_FLAG) && 1309 if ((flags & IEEE80211_TX_RC_40_MHZ_WIDTH) &&
1310 (ath_rc_priv->rc_phy_mode != 1310 (ath_rc_priv->rc_phy_mode !=
1311 (flags & ATH_RC_CW40_FLAG))) 1311 (flags & IEEE80211_TX_RC_40_MHZ_WIDTH)))
1312 return; 1312 return;
1313 if ((flags & ATH_RC_CW40_FLAG) && 1313 if ((flags & IEEE80211_TX_RC_40_MHZ_WIDTH) &&
1314 (flags & ATH_RC_SGI_FLAG)) 1314 (flags & IEEE80211_TX_RC_SHORT_GI))
1315 rix = rate_table->info[ 1315 rix = rate_table->info[
1316 rcs[series].rix].ht_index; 1316 rates[series].idx].ht_index;
1317 else if (flags & ATH_RC_SGI_FLAG) 1317 else if (flags & IEEE80211_TX_RC_SHORT_GI)
1318 rix = rate_table->info[ 1318 rix = rate_table->info[
1319 rcs[series].rix].sgi_index; 1319 rates[series].idx].sgi_index;
1320 else if (flags & ATH_RC_CW40_FLAG) 1320 else if (flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
1321 rix = rate_table->info[ 1321 rix = rate_table->info[
1322 rcs[series].rix].cw40index; 1322 rates[series].idx].cw40index;
1323 else 1323 else
1324 rix = rate_table->info[ 1324 rix = rate_table->info[
1325 rcs[series].rix].base_index; 1325 rates[series].idx].base_index;
1326 ath_rc_update_ht(sc, ath_rc_priv, 1326 ath_rc_update_ht(sc, ath_rc_priv,
1327 info_priv, rix, 1327 info_priv, rix,
1328 xretries ? 1 : 2, 1328 xretries ? 1 : 2,
1329 rcs[series].tries); 1329 rates[series].count);
1330 } 1330 }
1331 } 1331 }
1332 } else { 1332 } else {
@@ -1336,24 +1336,24 @@ static void ath_rc_update(struct ath_softc *sc,
1336 * Treating it as an excessive retry penalizes the rate 1336 * Treating it as an excessive retry penalizes the rate
1337 * inordinately. 1337 * inordinately.
1338 */ 1338 */
1339 if (rcs[0].tries == 1 && xretries == 1) 1339 if (rates[0].count == 1 && xretries == 1)
1340 xretries = 2; 1340 xretries = 2;
1341 } 1341 }
1342 1342
1343 flags = rcs[series].flags; 1343 flags = rates[series].flags;
1344 /* If HT40 and we have switched mode from 40 to 20 => don't update */ 1344 /* If HT40 and we have switched mode from 40 to 20 => don't update */
1345 if ((flags & ATH_RC_CW40_FLAG) && 1345 if ((flags & IEEE80211_TX_RC_40_MHZ_WIDTH) &&
1346 (ath_rc_priv->rc_phy_mode != (flags & ATH_RC_CW40_FLAG))) 1346 (ath_rc_priv->rc_phy_mode != (flags & IEEE80211_TX_RC_40_MHZ_WIDTH)))
1347 return; 1347 return;
1348 1348
1349 if ((flags & ATH_RC_CW40_FLAG) && (flags & ATH_RC_SGI_FLAG)) 1349 if ((flags & IEEE80211_TX_RC_40_MHZ_WIDTH) && (flags & IEEE80211_TX_RC_SHORT_GI))
1350 rix = rate_table->info[rcs[series].rix].ht_index; 1350 rix = rate_table->info[rates[series].idx].ht_index;
1351 else if (flags & ATH_RC_SGI_FLAG) 1351 else if (flags & IEEE80211_TX_RC_SHORT_GI)
1352 rix = rate_table->info[rcs[series].rix].sgi_index; 1352 rix = rate_table->info[rates[series].idx].sgi_index;
1353 else if (flags & ATH_RC_CW40_FLAG) 1353 else if (flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
1354 rix = rate_table->info[rcs[series].rix].cw40index; 1354 rix = rate_table->info[rates[series].idx].cw40index;
1355 else 1355 else
1356 rix = rate_table->info[rcs[series].rix].base_index; 1356 rix = rate_table->info[rates[series].idx].base_index;
1357 1357
1358 ath_rc_update_ht(sc, ath_rc_priv, info_priv, rix, 1358 ath_rc_update_ht(sc, ath_rc_priv, info_priv, rix,
1359 xretries, long_retry); 1359 xretries, long_retry);
@@ -1365,8 +1365,10 @@ static void ath_rc_update(struct ath_softc *sc,
1365static void ath_rate_tx_complete(struct ath_softc *sc, 1365static void ath_rate_tx_complete(struct ath_softc *sc,
1366 struct ath_node *an, 1366 struct ath_node *an,
1367 struct ath_rate_node *rc_priv, 1367 struct ath_rate_node *rc_priv,
1368 struct ath_tx_info_priv *info_priv) 1368 struct ieee80211_tx_info *tx_info)
1369{ 1369{
1370 struct ath_tx_info_priv *info_priv =
1371 (struct ath_tx_info_priv *)tx_info->rate_driver_data[0];
1370 int final_ts_idx = info_priv->tx.ts_rateindex; 1372 int final_ts_idx = info_priv->tx.ts_rateindex;
1371 int tx_status = 0, is_underrun = 0; 1373 int tx_status = 0, is_underrun = 0;
1372 1374
@@ -1395,7 +1397,7 @@ static void ath_rate_tx_complete(struct ath_softc *sc,
1395 (info_priv->tx.ts_status & ATH9K_TXERR_FIFO)) 1397 (info_priv->tx.ts_status & ATH9K_TXERR_FIFO))
1396 tx_status = 1; 1398 tx_status = 1;
1397 1399
1398 ath_rc_update(sc, rc_priv, info_priv, final_ts_idx, tx_status, 1400 ath_rc_update(sc, rc_priv, tx_info, final_ts_idx, tx_status,
1399 (is_underrun) ? ATH_11N_TXMAXTRY : 1401 (is_underrun) ? ATH_11N_TXMAXTRY :
1400 info_priv->tx.ts_longretry); 1402 info_priv->tx.ts_longretry);
1401} 1403}
@@ -1507,8 +1509,7 @@ static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband,
1507 1509
1508 hdr = (struct ieee80211_hdr *)skb->data; 1510 hdr = (struct ieee80211_hdr *)skb->data;
1509 fc = hdr->frame_control; 1511 fc = hdr->frame_control;
1510 /* XXX: UGLY HACK!! */ 1512 tx_info_priv = (struct ath_tx_info_priv *)tx_info->rate_driver_data[0];
1511 tx_info_priv = (struct ath_tx_info_priv *)tx_info->control.vif;
1512 1513
1513 an = (struct ath_node *)sta->drv_priv; 1514 an = (struct ath_node *)sta->drv_priv;
1514 1515
@@ -1516,10 +1517,9 @@ static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband,
1516 return; 1517 return;
1517 1518
1518 if (an && priv_sta && ieee80211_is_data(fc)) 1519 if (an && priv_sta && ieee80211_is_data(fc))
1519 ath_rate_tx_complete(sc, an, priv_sta, tx_info_priv); 1520 ath_rate_tx_complete(sc, an, priv_sta, tx_info);
1520 1521
1521 kfree(tx_info_priv); 1522 kfree(tx_info_priv);
1522 tx_info->control.vif = NULL;
1523} 1523}
1524 1524
1525static void ath_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta, 1525static void ath_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
@@ -1530,28 +1530,18 @@ static void ath_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
1530 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 1530 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
1531 struct ath_softc *sc = priv; 1531 struct ath_softc *sc = priv;
1532 struct ieee80211_hw *hw = sc->hw; 1532 struct ieee80211_hw *hw = sc->hw;
1533 struct ath_tx_info_priv *tx_info_priv;
1534 struct ath_rate_node *ath_rc_priv = priv_sta; 1533 struct ath_rate_node *ath_rc_priv = priv_sta;
1535 struct ath_node *an; 1534 struct ath_node *an;
1536 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 1535 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1537 int is_probe = FALSE; 1536 int is_probe = FALSE;
1538 s8 lowest_idx;
1539 __le16 fc = hdr->frame_control; 1537 __le16 fc = hdr->frame_control;
1540 u8 *qc, tid; 1538 u8 *qc, tid;
1541 1539
1542 DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__);
1543
1544 /* allocate driver private area of tx_info, XXX: UGLY HACK! */
1545 tx_info->control.vif = kzalloc(sizeof(*tx_info_priv), GFP_ATOMIC);
1546 tx_info_priv = (struct ath_tx_info_priv *)tx_info->control.vif;
1547 ASSERT(tx_info_priv != NULL);
1548
1549 lowest_idx = rate_lowest_index(sband, sta);
1550 tx_info_priv->min_rate = (sband->bitrates[lowest_idx].bitrate * 2) / 10;
1551 /* lowest rate for management and multicast/broadcast frames */ 1540 /* lowest rate for management and multicast/broadcast frames */
1552 if (!ieee80211_is_data(fc) || 1541 if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1)) {
1553 is_multicast_ether_addr(hdr->addr1) || !sta) { 1542 tx_info->control.rates[0].idx = rate_lowest_index(sband, sta);
1554 tx_info->control.rates[0].idx = lowest_idx; 1543 tx_info->control.rates[0].count =
1544 is_multicast_ether_addr(hdr->addr1) ? 1 : ATH_MGT_TXMAXTRY;
1555 return; 1545 return;
1556 } 1546 }
1557 1547
@@ -1559,24 +1549,11 @@ static void ath_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
1559 ath_rate_findrate(sc, ath_rc_priv, 1549 ath_rate_findrate(sc, ath_rc_priv,
1560 ATH_11N_TXMAXTRY, 4, 1550 ATH_11N_TXMAXTRY, 4,
1561 ATH_RC_PROBE_ALLOWED, 1551 ATH_RC_PROBE_ALLOWED,
1562 tx_info_priv->rcs, 1552 tx_info,
1563 &is_probe, 1553 &is_probe,
1564 false); 1554 false);
1565#if 0
1566 if (is_probe)
1567 sel->probe_idx = ath_rc_priv->tx_ratectrl.probe_rate;
1568#endif
1569
1570 /* Ratecontrol sometimes returns invalid rate index */
1571 if (tx_info_priv->rcs[0].rix != 0xff)
1572 ath_rc_priv->prev_data_rix = tx_info_priv->rcs[0].rix;
1573 else
1574 tx_info_priv->rcs[0].rix = ath_rc_priv->prev_data_rix;
1575
1576 tx_info->control.rates[0].idx = tx_info_priv->rcs[0].rix;
1577 1555
1578 /* Check if aggregation has to be enabled for this tid */ 1556 /* Check if aggregation has to be enabled for this tid */
1579
1580 if (hw->conf.ht.enabled) { 1557 if (hw->conf.ht.enabled) {
1581 if (ieee80211_is_data_qos(fc)) { 1558 if (ieee80211_is_data_qos(fc)) {
1582 qc = ieee80211_get_qos_ctl(hdr); 1559 qc = ieee80211_get_qos_ctl(hdr);