add preliminary 2.6.32 support
[openwrt.git] / package / madwifi / patches / 452-minstrel_no_timer.patch
1 --- a/ath_rate/minstrel/minstrel.c
2 +++ b/ath_rate/minstrel/minstrel.c
3 @@ -119,6 +119,7 @@
4  #include "minstrel.h"
5  
6  #define ONE_SECOND (1000 * 1000)  /* 1 second, or 1000 milliseconds; eternity, in other words */
7 +#define TIMER_INTERVAL 100 /* msecs */
8  
9  #include "release.h"
10  
11 @@ -128,9 +129,6 @@ static char *dev_info = "ath_rate_minstr
12  #define STALE_FAILURE_TIMEOUT_MS 10000
13  #define ENABLE_MRR 1
14  
15 -static int ath_timer_interval = (1000 / 10); /* every 1/10 second, timer runs */
16 -static void ath_timer_function(unsigned long data);
17 -
18  /* 10% of the time, send a packet at something other than the optimal rate, which fills
19   * the statistics tables nicely. This percentage is applied to the first packet of the
20   * multi rate retry chain. */
21 @@ -142,7 +140,7 @@ static void ath_rate_ctl_reset(struct at
22  /* Calculate the throughput and probability of success for each node
23   * we are talking on, based on the statistics collected during the
24   * last timer period. */
25 -static void ath_rate_statistics(void *arg, struct ieee80211_node *ni);
26 +static void ath_rate_statistics(struct ieee80211_node *ni);
27  
28  
29  #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,52))
30 @@ -204,6 +202,11 @@ ath_rate_findrate(struct ath_softc *sc, 
31                 unsigned int ndx, offset;
32                 int mrr;
33  
34 +
35 +               if (sn->last_update + msecs_to_jiffies(TIMER_INTERVAL) < jiffies) {
36 +                       ath_rate_statistics(&an->an_node);
37 +                       sn->last_update = jiffies;
38 +               }
39                 if (sn->num_rates <= 0) {
40                             printk(KERN_WARNING "%s: no rates for " MAC_FMT "?\n",
41                                    dev_info,
42 @@ -640,54 +643,11 @@ ath_rate_newstate(struct ieee80211vap *v
43                 }
44  }
45  
46 -static void
47 -ath_timer_function(unsigned long data)
48 -{
49 -               struct minstrel_softc *ssc = (struct minstrel_softc *) data;
50 -               struct ath_softc *sc = ssc->sc;
51 -               struct ieee80211com *ic;
52 -               struct net_device *dev = ssc->sc_dev;
53 -               struct timer_list *timer;
54 -               unsigned int interval = ath_timer_interval;
55 -
56 -               if (dev == NULL)
57 -                       DPRINTF(sc, ATH_DEBUG_RATE, "%s: 'dev' is null in this timer \n", __func__);
58 -
59 -               if (sc == NULL)
60 -                       DPRINTF(sc, ATH_DEBUG_RATE, "%s: 'sc' is null in this timer\n", __func__);
61 -
62 -               ic = &sc->sc_ic;
63 -
64 -               if (ssc->close_timer_now)
65 -                       return;
66 -
67 -               if (dev->flags & IFF_RUNNING) {
68 -                       sc->sc_stats.ast_rate_calls++;
69 -
70 -                       if (ic->ic_opmode == IEEE80211_M_STA) {
71 -                               struct ieee80211vap *tmpvap;
72 -                               TAILQ_FOREACH(tmpvap, &ic->ic_vaps, iv_next) {
73 -                                       ath_rate_statistics(sc, tmpvap->iv_bss);/* NB: no reference */
74 -                               }
75 -                       } else
76 -                                   ieee80211_iterate_nodes(&ic->ic_sta, ath_rate_statistics, sc);
77 -               }
78 -
79 -               if (ic->ic_opmode == IEEE80211_M_STA)
80 -                       interval = ath_timer_interval >> 1;
81 -
82 -               timer  = &(ssc->timer);
83 -               if (timer == NULL)
84 -                       DPRINTF(sc, ATH_DEBUG_RATE, "%s: timer is null - leave it\n", __func__);
85 -
86 -               timer->expires = jiffies + ((HZ * interval) / 1000);
87 -               add_timer(timer);
88 -}
89  
90  static void
91 -ath_rate_statistics(void *arg, struct ieee80211_node *ni)
92 +ath_rate_statistics(struct ieee80211_node *ni)
93  {
94 -               struct ath_node *an = (struct ath_node *) ni;
95 +               struct ath_node *an = ATH_NODE(ni);
96                 struct ieee80211_rateset *rs = &ni->ni_rates;
97                 struct minstrel_node *rn = ATH_NODE_MINSTREL(an);
98                 unsigned int i;
99 @@ -786,15 +746,8 @@ ath_rate_attach(struct ath_softc *sc)
100                 osc->arc.arc_space = sizeof(struct minstrel_node);
101                 osc->arc.arc_vap_space = 0;
102  
103 -               osc->close_timer_now = 0;
104 -               init_timer(&osc->timer);
105         osc->sc          = sc;
106                 osc->sc_dev      = sc->sc_dev;
107 -               osc->timer.function = ath_timer_function;
108 -               osc->timer.data = (unsigned long)osc;
109 -
110 -               osc->timer.expires = jiffies + HZ;
111 -               add_timer(&osc->timer);
112  
113                 return &osc->arc;
114  }
115 @@ -803,8 +756,6 @@ static void
116  ath_rate_detach(struct ath_ratectrl *arc)
117  {
118         struct minstrel_softc *osc = (struct minstrel_softc *) arc;
119 -               osc->close_timer_now = 1;
120 -               del_timer(&osc->timer);
121                 kfree(osc);
122                 _MOD_DEC_USE(THIS_MODULE);
123  }
124 --- a/ath_rate/minstrel/minstrel.h
125 +++ b/ath_rate/minstrel/minstrel.h
126 @@ -167,6 +167,8 @@ struct minstrel_node {
127                packet, or a packet at an optimal rate.*/
128         int random_n;
129         int a, b;          /**Coefficients of the random thing */
130 +
131 +       unsigned long last_update;
132  };
133  
134