]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/net/wireless/ath/ath9k/rc.c
Merge tag 'v2.6.38' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[mv-sheeva.git] / drivers / net / wireless / ath / ath9k / rc.c
index 89978d71617fdaf89a70be70f28a77b199b18d98..e45147820eae4cac44cece134585cc3bcd8f7865 100644 (file)
@@ -381,25 +381,6 @@ static const struct ath_rate_table ar5416_11g_ratetable = {
 static int ath_rc_get_rateindex(const struct ath_rate_table *rate_table,
                                struct ieee80211_tx_rate *rate);
 
-static inline int8_t median(int8_t a, int8_t b, int8_t c)
-{
-       if (a >= b) {
-               if (b >= c)
-                       return b;
-               else if (a > c)
-                       return c;
-               else
-                       return a;
-       } else {
-               if (a >= c)
-                       return a;
-               else if (b >= c)
-                       return c;
-               else
-                       return b;
-       }
-}
-
 static void ath_rc_sort_validrates(const struct ath_rate_table *rate_table,
                                   struct ath_rate_priv *ath_rc_priv)
 {
@@ -419,7 +400,7 @@ static void ath_rc_sort_validrates(const struct ath_rate_table *rate_table,
        }
 }
 
-static void ath_rc_init_valid_txmask(struct ath_rate_priv *ath_rc_priv)
+static void ath_rc_init_valid_rate_idx(struct ath_rate_priv *ath_rc_priv)
 {
        u8 i;
 
@@ -427,7 +408,7 @@ static void ath_rc_init_valid_txmask(struct ath_rate_priv *ath_rc_priv)
                ath_rc_priv->valid_rate_index[i] = 0;
 }
 
-static inline void ath_rc_set_valid_txmask(struct ath_rate_priv *ath_rc_priv,
+static inline void ath_rc_set_valid_rate_idx(struct ath_rate_priv *ath_rc_priv,
                                           u8 index, int valid_tx_rate)
 {
        BUG_ON(index > ath_rc_priv->rate_table_size);
@@ -508,7 +489,7 @@ static u8 ath_rc_init_validrates(struct ath_rate_priv *ath_rc_priv,
 
                        ath_rc_priv->valid_phy_rateidx[phy][valid_rate_count] = i;
                        ath_rc_priv->valid_phy_ratecnt[phy] += 1;
-                       ath_rc_set_valid_txmask(ath_rc_priv, i, 1);
+                       ath_rc_set_valid_rate_idx(ath_rc_priv, i, 1);
                        hi = i;
                }
        }
@@ -551,7 +532,7 @@ static u8 ath_rc_setvalid_rates(struct ath_rate_priv *ath_rc_priv,
                                ath_rc_priv->valid_phy_rateidx[phy]
                                        [valid_rate_count] = j;
                                ath_rc_priv->valid_phy_ratecnt[phy] += 1;
-                               ath_rc_set_valid_txmask(ath_rc_priv, j, 1);
+                               ath_rc_set_valid_rate_idx(ath_rc_priv, j, 1);
                                hi = A_MAX(hi, j);
                        }
                }
@@ -587,7 +568,7 @@ static u8 ath_rc_setvalid_htrates(struct ath_rate_priv *ath_rc_priv,
                        ath_rc_priv->valid_phy_rateidx[phy]
                                [ath_rc_priv->valid_phy_ratecnt[phy]] = j;
                        ath_rc_priv->valid_phy_ratecnt[phy] += 1;
-                       ath_rc_set_valid_txmask(ath_rc_priv, j, 1);
+                       ath_rc_set_valid_rate_idx(ath_rc_priv, j, 1);
                        hi = A_MAX(hi, j);
                }
        }
@@ -883,7 +864,7 @@ static bool ath_rc_update_per(struct ath_softc *sc,
        bool state_change = false;
        int count, n_bad_frames;
        u8 last_per;
-       static u32 nretry_to_per_lookup[10] = {
+       static const u32 nretry_to_per_lookup[10] = {
                100 * 0 / 1,
                100 * 1 / 4,
                100 * 1 / 2,
@@ -1106,13 +1087,13 @@ static int ath_rc_get_rateindex(const struct ath_rate_table *rate_table,
                                struct ieee80211_tx_rate *rate)
 {
        int rix = 0, i = 0;
-       int mcs_rix_off[] = { 7, 15, 20, 21, 22, 23 };
+       static const int mcs_rix_off[] = { 7, 15, 20, 21, 22, 23 };
 
        if (!(rate->flags & IEEE80211_TX_RC_MCS))
                return rate->idx;
 
        while (rate->idx > mcs_rix_off[i] &&
-             i < sizeof(mcs_rix_off)/sizeof(int)) {
+              i < ARRAY_SIZE(mcs_rix_off)) {
                rix++; i++;
        }
 
@@ -1203,7 +1184,7 @@ struct ath_rate_table *ath_choose_rate_table(struct ath_softc *sc,
                        return &ar5416_11na_ratetable;
                return &ar5416_11a_ratetable;
        default:
-               ath_print(common, ATH_DBG_CONFIG, "Invalid band\n");
+               ath_dbg(common, ATH_DBG_CONFIG, "Invalid band\n");
                return NULL;
        }
 }
@@ -1229,7 +1210,7 @@ static void ath_rc_init(struct ath_softc *sc,
        }
 
        /* Determine the valid rates */
-       ath_rc_init_valid_txmask(ath_rc_priv);
+       ath_rc_init_valid_rate_idx(ath_rc_priv);
 
        for (i = 0; i < WLAN_RC_PHY_MAX; i++) {
                for (j = 0; j < MAX_TX_RATE_PHY; j++)
@@ -1278,9 +1259,9 @@ static void ath_rc_init(struct ath_softc *sc,
        ath_rc_priv->rate_max_phy = ath_rc_priv->valid_rate_index[k-4];
        ath_rc_priv->rate_table = rate_table;
 
-       ath_print(common, ATH_DBG_CONFIG,
-                 "RC Initialized with capabilities: 0x%x\n",
-                 ath_rc_priv->ht_cap);
+       ath_dbg(common, ATH_DBG_CONFIG,
+               "RC Initialized with capabilities: 0x%x\n",
+               ath_rc_priv->ht_cap);
 }
 
 static u8 ath_rc_build_ht_caps(struct ath_softc *sc, struct ieee80211_sta *sta,
@@ -1340,7 +1321,7 @@ static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband,
        struct ath_rate_priv *ath_rc_priv = priv_sta;
        struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
        struct ieee80211_hdr *hdr;
-       int final_ts_idx = 0, tx_status = 0, is_underrun = 0;
+       int final_ts_idx = 0, tx_status = 0;
        int long_retry = 0;
        __le16 fc;
        int i;
@@ -1373,32 +1354,17 @@ static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband,
                tx_info->status.ampdu_len = 1;
        }
 
-       /*
-        * If an underrun error is seen assume it as an excessive retry only
-        * if max frame trigger level has been reached (2 KB for singel stream,
-        * and 4 KB for dual stream). Adjust the long retry as if the frame was
-        * tried hw->max_rate_tries times to affect how ratectrl updates PER for
-        * the failed rate. In case of congestion on the bus penalizing these
-        * type of underruns should help hardware actually transmit new frames
-        * successfully by eventually preferring slower rates. This itself
-        * should also alleviate congestion on the bus.
-        */
-       if ((tx_info->pad[0] & ATH_TX_INFO_UNDERRUN) &&
-           (sc->sc_ah->tx_trig_level >= ath_rc_priv->tx_triglevel_max)) {
-               tx_status = 1;
-               is_underrun = 1;
-       }
-
-       if (tx_info->pad[0] & ATH_TX_INFO_XRETRY)
+       if (!(tx_info->flags & IEEE80211_TX_STAT_ACK))
                tx_status = 1;
 
        ath_rc_tx_status(sc, ath_rc_priv, tx_info, final_ts_idx, tx_status,
-                        (is_underrun) ? sc->hw->max_rate_tries : long_retry);
+                        long_retry);
 
        /* Check if aggregation has to be enabled for this tid */
        if (conf_is_ht(&sc->hw->conf) &&
            !(skb->protocol == cpu_to_be16(ETH_P_PAE))) {
-               if (ieee80211_is_data_qos(fc)) {
+               if (ieee80211_is_data_qos(fc) &&
+                   skb_get_queue_mapping(skb) != IEEE80211_AC_VO) {
                        u8 *qc, tid;
                        struct ath_node *an;
 
@@ -1407,7 +1373,7 @@ static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband,
                        an = (struct ath_node *)sta->drv_priv;
 
                        if(ath_tx_aggr_check(sc, an, tid))
-                               ieee80211_start_tx_ba_session(sta, tid);
+                               ieee80211_start_tx_ba_session(sta, tid, 0);
                }
        }
 
@@ -1444,12 +1410,12 @@ static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband,
                ath_rc_priv->neg_ht_rates.rs_nrates = j;
        }
 
-       is_cw40 = sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40;
+       is_cw40 = !!(sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40);
 
        if (is_cw40)
-               is_sgi = sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40;
+               is_sgi = !!(sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40);
        else if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_SGI_20)
-               is_sgi = sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20;
+               is_sgi = !!(sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20);
 
        /* Choose rate table first */
 
@@ -1468,10 +1434,8 @@ static void ath_rate_update(void *priv, struct ieee80211_supported_band *sband,
        struct ath_rate_priv *ath_rc_priv = priv_sta;
        const struct ath_rate_table *rate_table = NULL;
        bool oper_cw40 = false, oper_sgi;
-       bool local_cw40 = (ath_rc_priv->ht_cap & WLAN_RC_40_FLAG) ?
-               true : false;
-       bool local_sgi = (ath_rc_priv->ht_cap & WLAN_RC_SGI_FLAG) ?
-               true : false;
+       bool local_cw40 = !!(ath_rc_priv->ht_cap & WLAN_RC_40_FLAG);
+       bool local_sgi = !!(ath_rc_priv->ht_cap & WLAN_RC_SGI_FLAG);
 
        /* FIXME: Handle AP mode later when we support CWM */
 
@@ -1499,9 +1463,9 @@ static void ath_rate_update(void *priv, struct ieee80211_supported_band *sband,
                                                   oper_cw40, oper_sgi);
                        ath_rc_init(sc, priv_sta, sband, sta, rate_table);
 
-                       ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_CONFIG,
-                                 "Operating HT Bandwidth changed to: %d\n",
-                                 sc->hw->conf.channel_type);
+                       ath_dbg(ath9k_hw_common(sc->sc_ah), ATH_DBG_CONFIG,
+                               "Operating HT Bandwidth changed to: %d\n",
+                               sc->hw->conf.channel_type);
                }
        }
 }
@@ -1612,13 +1576,11 @@ static void *ath_rate_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp
 
        rate_priv = kzalloc(sizeof(struct ath_rate_priv), gfp);
        if (!rate_priv) {
-               ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_FATAL,
-                         "Unable to allocate private rc structure\n");
+               ath_err(ath9k_hw_common(sc->sc_ah),
+                       "Unable to allocate private rc structure\n");
                return NULL;
        }
 
-       rate_priv->tx_triglevel_max = sc->sc_ah->caps.tx_triglevel_max;
-
        return rate_priv;
 }