merge madwifi all changes from trunk to 8.09
[openwrt/svn-archive/archive.git] / package / madwifi / patches / 450-calibration.patch
1 --- a/ath/if_ath.c
2 +++ b/ath/if_ath.c
3 @@ -396,7 +396,6 @@ static int tpc = 1;
4 static int maxvaps = -1;
5 static int xchanmode = -1;
6 #include "ath_wprobe.c"
7 -static int beacon_cal = 1;
8
9 static const struct ath_hw_detect generic_hw_info = {
10 .vendor_name = "Unknown",
11 @@ -431,7 +430,6 @@ static struct notifier_block ath_event_b
12 };
13
14 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,52))
15 -MODULE_PARM(beacon_cal, "i");
16 MODULE_PARM(maxvaps, "i");
17 MODULE_PARM(xchanmode, "i");
18 MODULE_PARM(rfkill, "i");
19 @@ -443,7 +441,6 @@ MODULE_PARM(autocreate, "s");
20 MODULE_PARM(ratectl, "s");
21 #else
22 #include <linux/moduleparam.h>
23 -module_param(beacon_cal, int, 0600);
24 module_param(maxvaps, int, 0600);
25 module_param(xchanmode, int, 0600);
26 module_param(rfkill, int, 0600);
27 @@ -837,6 +834,7 @@ ath_attach(u_int16_t devid, struct net_d
28 error = EIO;
29 goto bad2;
30 }
31 + sc->sc_cal_interval = ath_calinterval;
32 init_timer(&sc->sc_cal_ch);
33 sc->sc_cal_ch.function = ath_calibrate;
34 sc->sc_cal_ch.data = (unsigned long) dev;
35 @@ -2765,8 +2763,7 @@ ath_stop_locked(struct net_device *dev)
36 }
37 if (!sc->sc_invalid) {
38 del_timer_sync(&sc->sc_dfs_cac_timer);
39 - if (!sc->sc_beacon_cal)
40 - del_timer_sync(&sc->sc_cal_ch);
41 + del_timer_sync(&sc->sc_cal_ch);
42 }
43 ath_draintxq(sc);
44 if (!sc->sc_invalid) {
45 @@ -2791,10 +2788,9 @@ static void ath_set_beacon_cal(struct at
46 if (val) {
47 del_timer_sync(&sc->sc_cal_ch);
48 } else {
49 - sc->sc_cal_ch.expires = jiffies + (ath_calinterval * HZ);
50 - add_timer(&sc->sc_cal_ch);
51 + mod_timer(&sc->sc_cal_ch, jiffies + (sc->sc_cal_interval * HZ));
52 }
53 - sc->sc_beacon_cal = !!val && beacon_cal;
54 + sc->sc_beacon_cal = !!val;
55 }
56
57 /*
58 @@ -3036,7 +3032,7 @@ ath_reset(struct net_device *dev)
59 * XXX: starting the calibration too early seems to lead to
60 * problems with the beacons.
61 */
62 - sc->sc_lastcal = jiffies;
63 + sc->sc_nextcal = jiffies + msecs_to_jiffies(sc->sc_cal_interval * 1000);
64
65 /*
66 * Convert to a HAL channel description with the flags
67 @@ -5477,10 +5473,9 @@ next:
68 "Invoking ath_hal_txstart with sc_bhalq: %d\n",
69 sc->sc_bhalq);
70 ath_hal_txstart(ah, sc->sc_bhalq);
71 - if (sc->sc_beacon_cal && (jiffies > sc->sc_lastcal + (ath_calinterval * HZ))) {
72 - sc->sc_cal_ch.expires = jiffies + msecs_to_jiffies(10);
73 - add_timer(&sc->sc_cal_ch);
74 - }
75 + if (sc->sc_beacon_cal && ((sc->sc_bmisscount == 3) ||
76 + (jiffies > sc->sc_nextcal)))
77 + mod_timer(&sc->sc_cal_ch, jiffies + 1);
78
79 sc->sc_stats.ast_be_xmit++; /* XXX per-VAP? */
80 }
81 @@ -9161,6 +9156,7 @@ ath_startrecv(struct ath_softc *sc)
82 dev->mtu, sc->sc_cachelsz, sc->sc_rxbufsize);
83
84 sc->sc_rxlink = NULL;
85 + ath_set_beacon_cal(sc, IEEE80211_IS_MODE_BEACON(sc->sc_ic.ic_opmode));
86 STAILQ_FOREACH(bf, &sc->sc_rxbuf, bf_list) {
87 int error = ath_rxbuf_init(sc, bf);
88 ATH_RXBUF_RESET(bf);
89 @@ -9377,7 +9373,7 @@ ath_chan_set(struct ath_softc *sc, struc
90 jiffies + (sc->sc_dfs_cac_period * HZ));
91
92 /* This is a good time to start a calibration */
93 - ath_set_beacon_cal(sc, 1);
94 + mod_timer(&sc->sc_cal_ch, jiffies + 1);
95 }
96 /*
97 * re configure beacons when it is a turbo mode switch.
98 @@ -9471,25 +9467,23 @@ ath_calibrate(unsigned long arg)
99 if (isIQdone == AH_TRUE) {
100 /* Unless user has overridden calibration interval,
101 * upgrade to less frequent calibration */
102 - if (ath_calinterval == ATH_SHORT_CALINTERVAL)
103 - ath_calinterval = ATH_LONG_CALINTERVAL;
104 + if (sc->sc_cal_interval == ATH_SHORT_CALINTERVAL)
105 + sc->sc_cal_interval = ATH_LONG_CALINTERVAL;
106 }
107 else {
108 /* Unless user has overridden calibration interval,
109 * downgrade to more frequent calibration */
110 - if (ath_calinterval == ATH_LONG_CALINTERVAL)
111 - ath_calinterval = ATH_SHORT_CALINTERVAL;
112 + if (sc->sc_cal_interval == ATH_LONG_CALINTERVAL)
113 + sc->sc_cal_interval = ATH_SHORT_CALINTERVAL;
114 }
115
116 DPRINTF(sc, ATH_DEBUG_CALIBRATE, "Channel %u/%x -- IQ %s.\n",
117 sc->sc_curchan.channel, sc->sc_curchan.channelFlags,
118 isIQdone ? "done" : "not done");
119
120 - sc->sc_lastcal = jiffies;
121 - if (!sc->sc_beacon_cal) {
122 - sc->sc_cal_ch.expires = jiffies + (ath_calinterval * HZ);
123 - add_timer(&sc->sc_cal_ch);
124 - }
125 + sc->sc_nextcal = jiffies + msecs_to_jiffies(sc->sc_cal_interval * 1000);
126 + if (!sc->sc_beacon_cal)
127 + mod_timer(&sc->sc_cal_ch, sc->sc_nextcal);
128 }
129
130 static void
131 @@ -9597,9 +9591,6 @@ ath_newstate(struct ieee80211vap *vap, e
132 ieee80211_state_name[vap->iv_state],
133 ieee80211_state_name[nstate]);
134
135 - if (!sc->sc_beacon_cal)
136 - del_timer(&sc->sc_cal_ch); /* periodic calibration timer */
137 -
138 ath_hal_setledstate(ah, leds[nstate]); /* set LED */
139 netif_stop_queue(dev); /* before we do anything else */
140
141 @@ -9821,10 +9812,7 @@ ath_newstate(struct ieee80211vap *vap, e
142 IEEE80211_IS_MODE_DFS_MASTER(vap->iv_opmode)) {
143 DPRINTF(sc, ATH_DEBUG_STATE | ATH_DEBUG_DOTH,
144 "VAP -> DFSWAIT_PENDING \n");
145 - /* start calibration timer with a really small value
146 - * 1/10 sec */
147 - if (!sc->sc_beacon_cal)
148 - mod_timer(&sc->sc_cal_ch, jiffies + (HZ/10));
149 + mod_timer(&sc->sc_cal_ch, jiffies + 1);
150 /* wake the receiver */
151 netif_wake_queue(dev);
152 /* don't do the other usual stuff... */
153 @@ -9866,12 +9854,6 @@ done:
154 /* Invoke the parent method to complete the work. */
155 error = avp->av_newstate(vap, nstate, arg);
156
157 - /* Finally, start any timers. */
158 - if (nstate == IEEE80211_S_RUN && !sc->sc_beacon_cal) {
159 - /* start periodic recalibration timer */
160 - mod_timer(&sc->sc_cal_ch, jiffies + (ath_calinterval * HZ));
161 - }
162 -
163 #ifdef ATH_SUPERG_XR
164 if (vap->iv_flags & IEEE80211_F_XR &&
165 nstate == IEEE80211_S_RUN)
166 --- a/ath/if_athvar.h
167 +++ b/ath/if_athvar.h
168 @@ -834,7 +834,8 @@ struct ath_softc {
169
170 struct ieee80211_channel *sc_last_chan;
171 int sc_beacon_cal; /* use beacon timer for calibration */
172 - u_int64_t sc_lastcal; /* last time the calibration was performed */
173 + u_int64_t sc_nextcal; /* last time the calibration was performed */
174 + int sc_cal_interval; /* current calibration interval */
175 struct timer_list sc_cal_ch; /* calibration timer */
176 HAL_NODE_STATS sc_halstats; /* station-mode rssi stats */
177