port generic and ixp4xx kernel patches to 2.6.27 (compiles except for iptables, but...
[openwrt.git] / package / madwifi / patches / 379-invalid_rate_fix.patch
1 --- a/ath_rate/minstrel/minstrel.c
2 +++ b/ath_rate/minstrel/minstrel.c
3 @@ -111,27 +111,13 @@
4  #include <net80211/ieee80211_var.h>
5  #include <net80211/ieee80211_rate.h>
6  
7 +#include "if_ath_debug.h"
8  #include "if_athvar.h"
9  #include "if_ath_hal.h"
10  #include "ah_desc.h"
11  
12  #include "minstrel.h"
13  
14 -#ifdef AR_DEBUG
15 -#define        MINSTREL_DEBUG
16 -#endif
17 -#ifdef MINSTREL_DEBUG
18 -enum {
19 -               ATH_DEBUG_RATE          = 0x00000010    /* rate control */
20 -};
21 -#define        DPRINTF(sc, _fmt, ...) do {             \
22 -               if (sc->sc_debug & ATH_DEBUG_RATE)      \
23 -                       printk(_fmt, __VA_ARGS__);              \
24 -} while (0)
25 -#else
26 -#define        DPRINTF(sc, _fmt, ...)
27 -#endif
28 -
29  #define ONE_SECOND (1000 * 1000)  /* 1 second, or 1000 milliseconds; eternity, in other words */
30  
31  #include "release.h"
32 @@ -689,17 +675,17 @@
33                          * the node.  We know the rate is there because the
34                          * rate set is checked when the station associates. */
35                         /* NB: the rate set is assumed sorted */
36 -                       for (; (srate >= 0) && (ni->ni_rates.rs_rates[srate] & IEEE80211_RATE_VAL) != vap->iv_fixed_rate; srate--);
37 -
38 -                       KASSERT(srate >= 0,
39 -                               ("fixed rate %d not in rate set", vap->iv_fixed_rate));
40 +                       for (; (srate > 0) && (ni->ni_rates.rs_rates[srate] & IEEE80211_RATE_VAL) != vap->iv_fixed_rate; srate--);
41  
42                         sn->static_rate_ndx = srate;
43                         ni->ni_txrate = srate;
44 -                       DPRINTF(sc, "%s: %s " MAC_FMT " fixed rate %d%sMbps\n",
45 -                               dev_info, __func__, MAC_ADDR(ni->ni_macaddr),
46 -                               sn->rates[srate].rate / 2,
47 -                               (sn->rates[srate].rate % 2) ? ".5 " : " ");
48 +                       if ((ni->ni_rates.rs_rates[srate] & IEEE80211_RATE_VAL) != vap->iv_fixed_rate)
49 +                               EPRINTF(sc, "Invalid static rate, falling back to basic rate\n");
50 +                       else
51 +                               DPRINTF(sc, "%s: %s " MAC_FMT " fixed rate %d%sMbps\n",
52 +                                       dev_info, __func__, MAC_ADDR(ni->ni_macaddr),
53 +                                       sn->rates[srate].rate / 2,
54 +                                       (sn->rates[srate].rate % 2) ? ".5 " : " ");
55                         return;
56                 }
57  
58 --- a/ath_rate/amrr/amrr.c
59 +++ b/ath_rate/amrr/amrr.c
60 @@ -64,24 +64,13 @@
61  #include <net80211/ieee80211_var.h>
62  #include <net80211/ieee80211_rate.h>
63  
64 +#include "if_ath_debug.h"
65  #include "if_athvar.h"
66  #include "if_ath_hal.h"
67  #include "ah_desc.h"
68  
69  #include "amrr.h"
70  
71 -#ifdef AR_DEBUG
72 -#define        AMRR_DEBUG
73 -#endif
74 -#ifdef AMRR_DEBUG
75 -#define        DPRINTF(sc, _fmt, ...) do {                                     \
76 -       if (sc->sc_debug & 0x10)                                        \
77 -               printk(_fmt, __VA_ARGS__);                              \
78 -} while (0)
79 -#else
80 -#define        DPRINTF(sc, _fmt, ...)
81 -#endif
82 -
83  static int ath_rateinterval = 1000;            /* rate ctl interval (ms)  */
84  static int ath_rate_max_success_threshold = 10;
85  static int ath_rate_min_success_threshold = 1;
86 @@ -297,9 +286,9 @@
87                  * rate set is checked when the station associates.
88                  */
89                 srate = ni->ni_rates.rs_nrates - 1;
90 -               for (; srate >= 0 && RATE(srate) != vap->iv_fixed_rate; srate--);
91 -               KASSERT(srate >= 0,
92 -                       ("fixed rate %d not in rate set", vap->iv_fixed_rate));
93 +               for (; srate > 0 && RATE(srate) != vap->iv_fixed_rate; srate--);
94 +               if (RATE(srate) != vap->iv_fixed_rate)
95 +                       EPRINTF(sc, "Invalid static rate, falling back to basic rate\n");
96         }
97         ath_rate_update(sc, ni, srate);
98  #undef RATE
99 --- a/ath_rate/onoe/onoe.c
100 +++ b/ath_rate/onoe/onoe.c
101 @@ -60,27 +60,13 @@
102  #include <net80211/ieee80211_var.h>
103  #include <net80211/ieee80211_rate.h>
104  
105 +#include "if_ath_debug.h"
106  #include "if_athvar.h"
107  #include "if_ath_hal.h"
108  #include "ah_desc.h"
109  
110  #include "onoe.h"
111  
112 -#ifdef AR_DEBUG
113 -#define        ONOE_DEBUG
114 -#endif
115 -#ifdef ONOE_DEBUG
116 -enum {
117 -       ATH_DEBUG_RATE  = 0x00000010,   /* rate control */
118 -};
119 -#define        DPRINTF(sc, _fmt, ...) do {                             \
120 -       if (sc->sc_debug & ATH_DEBUG_RATE)                      \
121 -               printk(_fmt, __VA_ARGS__);                      \
122 -} while (0)
123 -#else
124 -#define        DPRINTF(sc, _fmt, ...)
125 -#endif
126 -
127  /*
128   * Default parameters for the rate control algorithm.  These are
129   * all tunable with sysctls.  The rate controller runs periodically
130 @@ -283,9 +269,9 @@
131                  */
132                 /* NB: the rate set is assumed sorted */
133                 srate = ni->ni_rates.rs_nrates - 1;
134 -               for (; srate >= 0 && RATE(srate) != vap->iv_fixed_rate; srate--);
135 -               KASSERT(srate >= 0,
136 -                       ("fixed rate %d not in rate set", vap->iv_fixed_rate));
137 +               for (; srate > 0 && RATE(srate) != vap->iv_fixed_rate; srate--);
138 +               if (RATE(srate) != vap->iv_fixed_rate)
139 +                       EPRINTF(sc, "Invalid static rate, falling back to basic rate\n");
140         }
141         ath_rate_update(sc, ni, srate);
142  #undef RATE
143 --- a/ath_rate/sample/sample.c
144 +++ b/ath_rate/sample/sample.c
145 @@ -62,30 +62,13 @@
146  #include <net80211/ieee80211_var.h>
147  #include <net80211/ieee80211_rate.h>
148  
149 +#include "if_ath_debug.h"
150  #include "if_athvar.h"
151  #include "if_ath_hal.h"
152  #include "ah_desc.h"
153  
154  #include "sample.h"
155  
156 -#ifdef AR_DEBUG
157 -#define SAMPLE_DEBUG
158 -#endif
159 -#ifdef SAMPLE_DEBUG
160 -enum {
161 -       ATH_DEBUG_RATE          = 0x00000010,   /* rate control */
162 -       ATH_DEBUG_ANY           = 0xffffffff
163 -};
164 -#define        DPRINTF(sc, m, fmt, ...) do {                           \
165 -       if (sc->sc_debug & (m))                                 \
166 -               printk(fmt, __VA_ARGS__);                       \
167 -} while (0)
168 -#else
169 -#define        DPRINTF(sc, m, fmt, ...) do {                           \
170 -       (void) sc;                                              \
171 -} while (0)
172 -#endif
173 -
174  /*
175   * This file is an implementation of the SampleRate algorithm
176   * in "Bit-rate Selection in Wireless Networks"
177 @@ -886,15 +869,16 @@
178                         if ((ni->ni_rates.rs_rates[x] & IEEE80211_RATE_VAL) == vap->iv_fixed_rate)
179                                 srate = x;
180  
181 -               KASSERT(((ni->ni_rates.rs_rates[srate] & IEEE80211_RATE_VAL) == vap->iv_fixed_rate),
182 -                       ("fixed rate %u not in rate set", vap->iv_fixed_rate));
183 -
184                 sn->static_rate_ndx = srate;
185                 ni->ni_txrate = srate;
186 -               DPRINTF(sc, ATH_DEBUG_RATE, "%s: %s " MAC_FMT " fixed rate %u%sMbps\n",
187 -                       dev_info, __func__, MAC_ADDR(ni->ni_macaddr),
188 -                       sn->rates[srate].rate / 2,
189 -                       (sn->rates[srate].rate % 0x1) ? ".5" : " ");
190 +
191 +               if ((ni->ni_rates.rs_rates[srate] & IEEE80211_RATE_VAL) != vap->iv_fixed_rate)
192 +                       EPRINTF(sc, "Invalid static rate, falling back to basic rate\n");
193 +               else
194 +                       DPRINTF(sc, ATH_DEBUG_RATE, "%s: %s " MAC_FMT " fixed rate %u%sMbps\n",
195 +                               dev_info, __func__, MAC_ADDR(ni->ni_macaddr),
196 +                               sn->rates[srate].rate / 2,
197 +                               (sn->rates[srate].rate % 0x1) ? ".5" : " ");
198                 return;
199         }
200