sh: convert /proc/cpu/aligmnent, /proc/cpu/kernel_alignment to seq_file
[safe/jmp/linux-2.6] / net / mac80211 / rc80211_pid_algo.c
index 96ceb7e..699d3ed 100644 (file)
@@ -169,19 +169,9 @@ static void rate_control_pid_sample(struct rc_pid_info *pinfo,
         * still a good measurement and copy it. */
        if (unlikely(spinfo->tx_num_xmit == 0))
                pf = spinfo->last_pf;
-       else {
-               /* XXX: BAD HACK!!! */
-               struct sta_info *si = container_of(sta, struct sta_info, sta);
-
+       else
                pf = spinfo->tx_num_failed * 100 / spinfo->tx_num_xmit;
 
-               if (ieee80211_vif_is_mesh(&si->sdata->vif) && pf == 100)
-                       mesh_plink_broken(si);
-               pf <<= RC_PID_ARITH_SHIFT;
-               si->fail_avg = ((pf + (spinfo->last_pf << 3)) / 9)
-                                       >> RC_PID_ARITH_SHIFT;
-       }
-
        spinfo->tx_num_xmit = 0;
        spinfo->tx_num_failed = 0;
 
@@ -256,7 +246,7 @@ static void rate_control_pid_tx_status(void *priv, struct ieee80211_supported_ba
        if (!(info->flags & IEEE80211_TX_STAT_ACK)) {
                spinfo->tx_num_failed += 2;
                spinfo->tx_num_xmit++;
-       } else if (info->status.rates[0].count) {
+       } else if (info->status.rates[0].count > 1) {
                spinfo->tx_num_failed++;
                spinfo->tx_num_xmit++;
        }
@@ -276,11 +266,9 @@ rate_control_pid_get_rate(void *priv, struct ieee80211_sta *sta,
 {
        struct sk_buff *skb = txrc->skb;
        struct ieee80211_supported_band *sband = txrc->sband;
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        struct rc_pid_sta_info *spinfo = priv_sta;
        int rateidx;
-       u16 fc;
 
        if (txrc->rts)
                info->control.rates[0].count =
@@ -289,15 +277,9 @@ rate_control_pid_get_rate(void *priv, struct ieee80211_sta *sta,
                info->control.rates[0].count =
                        txrc->hw->conf.short_frame_max_tx_count;
 
-       /* Send management frames and broadcast/multicast data using lowest
-        * rate. */
-       fc = le16_to_cpu(hdr->frame_control);
-       if (!sta || !spinfo ||
-           (fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA ||
-           is_multicast_ether_addr(hdr->addr1)) {
-               info->control.rates[0].idx = rate_lowest_index(sband, sta);
+       /* Send management frames and NO_ACK data using lowest rate. */
+       if (rate_control_send_low(sta, priv_sta, txrc))
                return;
-       }
 
        rateidx = spinfo->txrate_idx;
 
@@ -317,17 +299,44 @@ rate_control_pid_rate_init(void *priv, struct ieee80211_supported_band *sband,
                           struct ieee80211_sta *sta, void *priv_sta)
 {
        struct rc_pid_sta_info *spinfo = priv_sta;
-       struct sta_info *si;
+       struct rc_pid_info *pinfo = priv;
+       struct rc_pid_rateinfo *rinfo = pinfo->rinfo;
+       int i, j, tmp;
+       bool s;
 
        /* TODO: This routine should consider using RSSI from previous packets
         * as we need to have IEEE 802.1X auth succeed immediately after assoc..
         * Until that method is implemented, we will use the lowest supported
         * rate as a workaround. */
 
+       /* Sort the rates. This is optimized for the most common case (i.e.
+        * almost-sorted CCK+OFDM rates). Kind of bubble-sort with reversed
+        * mapping too. */
+       for (i = 0; i < sband->n_bitrates; i++) {
+               rinfo[i].index = i;
+               rinfo[i].rev_index = i;
+               if (RC_PID_FAST_START)
+                       rinfo[i].diff = 0;
+               else
+                       rinfo[i].diff = i * pinfo->norm_offset;
+       }
+       for (i = 1; i < sband->n_bitrates; i++) {
+               s = 0;
+               for (j = 0; j < sband->n_bitrates - i; j++)
+                       if (unlikely(sband->bitrates[rinfo[j].index].bitrate >
+                                    sband->bitrates[rinfo[j + 1].index].bitrate)) {
+                               tmp = rinfo[j].index;
+                               rinfo[j].index = rinfo[j + 1].index;
+                               rinfo[j + 1].index = tmp;
+                               rinfo[rinfo[j].index].rev_index = j;
+                               rinfo[rinfo[j + 1].index].rev_index = j + 1;
+                               s = 1;
+                       }
+               if (!s)
+                       break;
+       }
+
        spinfo->txrate_idx = rate_lowest_index(sband, sta);
-       /* HACK */
-       si = container_of(sta, struct sta_info, sta);
-       si->fail_avg = 0;
 }
 
 static void *rate_control_pid_alloc(struct ieee80211_hw *hw,
@@ -336,21 +345,22 @@ static void *rate_control_pid_alloc(struct ieee80211_hw *hw,
        struct rc_pid_info *pinfo;
        struct rc_pid_rateinfo *rinfo;
        struct ieee80211_supported_band *sband;
-       int i, j, tmp;
-       bool s;
+       int i, max_rates = 0;
 #ifdef CONFIG_MAC80211_DEBUGFS
        struct rc_pid_debugfs_entries *de;
 #endif
 
-       sband = hw->wiphy->bands[hw->conf.channel->band];
-
        pinfo = kmalloc(sizeof(*pinfo), GFP_ATOMIC);
        if (!pinfo)
                return NULL;
 
-       /* We can safely assume that sband won't change unless we get
-        * reinitialized. */
-       rinfo = kmalloc(sizeof(*rinfo) * sband->n_bitrates, GFP_ATOMIC);
+       for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
+               sband = hw->wiphy->bands[i];
+               if (sband && sband->n_bitrates > max_rates)
+                       max_rates = sband->n_bitrates;
+       }
+
+       rinfo = kmalloc(sizeof(*rinfo) * max_rates, GFP_ATOMIC);
        if (!rinfo) {
                kfree(pinfo);
                return NULL;
@@ -368,33 +378,6 @@ static void *rate_control_pid_alloc(struct ieee80211_hw *hw,
        pinfo->rinfo = rinfo;
        pinfo->oldrate = 0;
 
-       /* Sort the rates. This is optimized for the most common case (i.e.
-        * almost-sorted CCK+OFDM rates). Kind of bubble-sort with reversed
-        * mapping too. */
-       for (i = 0; i < sband->n_bitrates; i++) {
-               rinfo[i].index = i;
-               rinfo[i].rev_index = i;
-               if (RC_PID_FAST_START)
-                       rinfo[i].diff = 0;
-               else
-                       rinfo[i].diff = i * pinfo->norm_offset;
-       }
-       for (i = 1; i < sband->n_bitrates; i++) {
-               s = 0;
-               for (j = 0; j < sband->n_bitrates - i; j++)
-                       if (unlikely(sband->bitrates[rinfo[j].index].bitrate >
-                                    sband->bitrates[rinfo[j + 1].index].bitrate)) {
-                               tmp = rinfo[j].index;
-                               rinfo[j].index = rinfo[j + 1].index;
-                               rinfo[j + 1].index = tmp;
-                               rinfo[rinfo[j].index].rev_index = j;
-                               rinfo[rinfo[j + 1].index].rev_index = j + 1;
-                               s = 1;
-                       }
-               if (!s)
-                       break;
-       }
-
 #ifdef CONFIG_MAC80211_DEBUGFS
        de = &pinfo->dentries;
        de->target = debugfs_create_u32("target_pf", S_IRUSR | S_IWUSR,