mac80211/drivers: rewrite the rate control API
[pandora-kernel.git] / drivers / net / wireless / ath9k / rc.c
index cca2fc5..6afafed 100644 (file)
@@ -1838,7 +1838,7 @@ void ath_rc_node_update(struct ieee80211_hw *hw, struct ath_rate_node *rc_priv)
        struct ath_softc *sc = hw->priv;
        u32 capflag = 0;
 
-       if (hw->conf.ht_conf.ht_supported) {
+       if (hw->conf.ht.enabled) {
                capflag |= ATH_RC_HT_FLAG | ATH_RC_DS_FLAG;
                if (sc->sc_ht_info.tx_chan_width == ATH9K_HT_MACMODE_2040)
                        capflag |= ATH_RC_CW40_FLAG;
@@ -1864,24 +1864,21 @@ static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband,
 
        hdr = (struct ieee80211_hdr *)skb->data;
        fc = hdr->frame_control;
-       tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0];
+       /* XXX: UGLY HACK!! */
+       tx_info_priv = (struct ath_tx_info_priv *)tx_info->control.vif;
 
        spin_lock_bh(&sc->node_lock);
        an = ath_node_find(sc, hdr->addr1);
        spin_unlock_bh(&sc->node_lock);
 
-       if (!an || !priv_sta || !ieee80211_is_data(fc)) {
-               if (tx_info->driver_data[0] != NULL) {
-                       kfree(tx_info->driver_data[0]);
-                       tx_info->driver_data[0] = NULL;
-               }
+       if (tx_info_priv == NULL)
                return;
-       }
-       if (tx_info->driver_data[0] != NULL) {
+
+       if (an && priv_sta && ieee80211_is_data(fc))
                ath_rate_tx_complete(sc, an, priv_sta, tx_info_priv);
-               kfree(tx_info->driver_data[0]);
-               tx_info->driver_data[0] = NULL;
-       }
+
+       kfree(tx_info_priv);
+       tx_info->control.vif = NULL;
 }
 
 static void ath_tx_aggr_resp(struct ath_softc *sc,
@@ -1910,7 +1907,7 @@ static void ath_tx_aggr_resp(struct ath_softc *sc,
         */
        si = container_of(sta, struct sta_info, sta);
        buffersize = IEEE80211_MIN_AMPDU_BUF <<
-               sband->ht_info.ampdu_factor; /* FIXME */
+               sband->ht_cap.ampdu_factor; /* FIXME */
        state = si->ampdu_mlme.tid_state_tx[tidno];
 
        if (state & HT_ADDBA_RECEIVED_MSK) {
@@ -1927,10 +1924,11 @@ static void ath_tx_aggr_resp(struct ath_softc *sc,
        }
 }
 
-static void ath_get_rate(void *priv, struct ieee80211_supported_band *sband,
-                        struct ieee80211_sta *sta, void *priv_sta,
-                        struct sk_buff *skb, struct rate_selection *sel)
+static void ath_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
+                        struct ieee80211_tx_rate_control *txrc)
 {
+       struct ieee80211_supported_band *sband = txrc->sband;
+       struct sk_buff *skb = txrc->skb;
        struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
        struct ath_softc *sc = priv;
        struct ieee80211_hw *hw = sc->hw;
@@ -1942,21 +1940,20 @@ static void ath_get_rate(void *priv, struct ieee80211_supported_band *sband,
        s8 lowest_idx;
        __le16 fc = hdr->frame_control;
        u8 *qc, tid;
-       DECLARE_MAC_BUF(mac);
 
        DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__);
 
-       /* allocate driver private area of tx_info */
-       tx_info->driver_data[0] = kzalloc(sizeof(*tx_info_priv), GFP_ATOMIC);
-       ASSERT(tx_info->driver_data[0] != NULL);
-       tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0];
+       /* allocate driver private area of tx_info, XXX: UGLY HACK! */
+       tx_info->control.vif = kzalloc(sizeof(*tx_info_priv), GFP_ATOMIC);
+       tx_info_priv = (struct ath_tx_info_priv *)tx_info->control.vif;
+       ASSERT(tx_info_priv != NULL);
 
        lowest_idx = rate_lowest_index(sband, sta);
        tx_info_priv->min_rate = (sband->bitrates[lowest_idx].bitrate * 2) / 10;
        /* lowest rate for management and multicast/broadcast frames */
        if (!ieee80211_is_data(fc) ||
            is_multicast_ether_addr(hdr->addr1) || !sta) {
-               sel->rate_idx = lowest_idx;
+               tx_info->control.rates[0].idx = lowest_idx;
                return;
        }
 
@@ -1967,8 +1964,10 @@ static void ath_get_rate(void *priv, struct ieee80211_supported_band *sband,
                          tx_info_priv->rcs,
                          &is_probe,
                          false);
+#if 0
        if (is_probe)
                sel->probe_idx = ath_rc_priv->tx_ratectrl.probe_rate;
+#endif
 
        /* Ratecontrol sometimes returns invalid rate index */
        if (tx_info_priv->rcs[0].rix != 0xff)
@@ -1976,11 +1975,11 @@ static void ath_get_rate(void *priv, struct ieee80211_supported_band *sband,
        else
                tx_info_priv->rcs[0].rix = ath_rc_priv->prev_data_rix;
 
-       sel->rate_idx = tx_info_priv->rcs[0].rix;
+       tx_info->control.rates[0].idx = tx_info_priv->rcs[0].rix;
 
        /* Check if aggregation has to be enabled for this tid */
 
-       if (hw->conf.ht_conf.ht_supported) {
+       if (hw->conf.ht.enabled) {
                if (ieee80211_is_data_qos(fc)) {
                        qc = ieee80211_get_qos_ctl(hdr);
                        tid = qc[0] & 0xf;
@@ -2003,14 +2002,14 @@ static void ath_get_rate(void *priv, struct ieee80211_supported_band *sband,
                                if (ret)
                                        DPRINTF(sc, ATH_DBG_AGGR,
                                                "%s: Unable to start tx "
-                                               "aggr for: %s\n",
+                                               "aggr for: %pM\n",
                                                __func__,
-                                               print_mac(mac, hdr->addr1));
+                                               hdr->addr1);
                                else
                                        DPRINTF(sc, ATH_DBG_AGGR,
-                                               "%s: Started tx aggr for: %s\n",
+                                               "%s: Started tx aggr for: %pM\n",
                                                __func__,
-                                               print_mac(mac, hdr->addr1));
+                                               hdr->addr1);
                        } else if (chk == AGGR_EXCHANGE_PROGRESS)
                                ath_tx_aggr_resp(sc, sband, sta, an, tid);
                }
@@ -2027,9 +2026,9 @@ static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband,
        DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__);
 
        ath_setup_rates(sc, sband, sta, ath_rc_priv);
-       if (sc->hw->conf.flags & IEEE80211_CONF_SUPPORT_HT_MODE) {
-               for (i = 0; i < MCS_SET_SIZE; i++) {
-                       if (sc->hw->conf.ht_conf.supp_mcs_set[i/8] & (1<<(i%8)))
+       if (sc->hw->conf.ht.enabled) {
+               for (i = 0; i < 77; i++) {
+                       if (sta->ht_cap.mcs.rx_mask[i/8] & (1<<(i%8)))
                                ath_rc_priv->neg_ht_rates.rs_rates[j++] = i;
                        if (j == ATH_RATE_MAX)
                                break;