integrate mklibs.py support into the build process
[openwrt.git] / package / madwifi / patches / 330-beaconcal.patch
1 --- a/ath/if_ath.c
2 +++ b/ath/if_ath.c
3 @@ -397,6 +397,7 @@ static int countrycode = -1;
4 static int maxvaps = -1;
5 static int outdoor = -1;
6 static int xchanmode = -1;
7 +static int beacon_cal = 1;
8
9 static const char *hal_status_desc[] = {
10 "No error",
11 @@ -422,6 +423,7 @@ 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(countrycode, "i");
17 MODULE_PARM(maxvaps, "i");
18 MODULE_PARM(outdoor, "i");
19 @@ -434,6 +436,7 @@ 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(countrycode, int, 0600);
25 module_param(maxvaps, int, 0600);
26 module_param(outdoor, int, 0600);
27 @@ -2600,7 +2603,8 @@ ath_stop_locked(struct net_device *dev)
28 }
29 if (!sc->sc_invalid) {
30 del_timer_sync(&sc->sc_dfs_cac_timer);
31 - del_timer_sync(&sc->sc_cal_ch);
32 + if (!sc->sc_beacon_cal)
33 + del_timer_sync(&sc->sc_cal_ch);
34 }
35 ath_draintxq(sc);
36 if (!sc->sc_invalid) {
37 @@ -2617,6 +2621,20 @@ ath_stop_locked(struct net_device *dev)
38 return 0;
39 }
40
41 +static void ath_set_beacon_cal(struct ath_softc *sc, int val)
42 +{
43 + if (sc->sc_beacon_cal == !!val)
44 + return;
45 +
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 + }
52 + sc->sc_beacon_cal = !!val && beacon_cal;
53 +}
54 +
55 /*
56 * Stop the device, grabbing the top-level lock to protect
57 * against concurrent entry through ath_init (which can happen
58 @@ -2742,6 +2760,12 @@ ath_reset(struct net_device *dev)
59 HAL_STATUS status;
60
61 /*
62 + * XXX: starting the calibration too early seems to lead to
63 + * problems with the beacons.
64 + */
65 + sc->sc_lastcal = jiffies;
66 +
67 + /*
68 * Convert to a HAL channel description with the flags
69 * constrained to reflect the current operating mode.
70 */
71 @@ -5154,6 +5178,10 @@ ath_beacon_send(struct ath_softc *sc, in
72 "Invoking ath_hal_txstart with sc_bhalq: %d\n",
73 sc->sc_bhalq);
74 ath_hal_txstart(ah, sc->sc_bhalq);
75 + if (sc->sc_beacon_cal && (jiffies > sc->sc_lastcal + (ath_calinterval * HZ))) {
76 + sc->sc_cal_ch.expires = jiffies + msecs_to_jiffies(10);
77 + add_timer(&sc->sc_cal_ch);
78 + }
79
80 sc->sc_stats.ast_be_xmit++; /* XXX per-VAP? */
81 }
82 @@ -5403,6 +5431,7 @@ ath_beacon_config(struct ath_softc *sc,
83 ath_hal_beacontimers(ah, &bs);
84 sc->sc_imask |= HAL_INT_BMISS;
85 ath_hal_intrset(ah, sc->sc_imask);
86 + ath_set_beacon_cal(sc, 0);
87 } else {
88 ath_hal_intrset(ah, 0);
89 if (reset_tsf)
90 @@ -5414,8 +5443,11 @@ ath_beacon_config(struct ath_softc *sc,
91 */
92 intval |= HAL_BEACON_ENA;
93 sc->sc_imask |= HAL_INT_SWBA;
94 + ath_set_beacon_cal(sc, 1);
95 ath_beaconq_config(sc);
96 - }
97 + } else
98 + ath_set_beacon_cal(sc, 0);
99 +
100 #ifdef ATH_SUPERG_DYNTURBO
101 ath_beacon_dturbo_config(vap, intval &
102 ~(HAL_BEACON_RESET_TSF | HAL_BEACON_ENA));
103 @@ -8879,6 +8911,9 @@ ath_chan_set(struct ath_softc *sc, struc
104 /* Enter DFS wait period */
105 mod_timer(&sc->sc_dfs_cac_timer,
106 jiffies + (sc->sc_dfs_cac_period * HZ));
107 +
108 + /* This is a good time to start a calibration */
109 + ath_set_beacon_cal(sc, 1);
110 }
111 /*
112 * re configure beacons when it is a turbo mode switch.
113 @@ -8988,8 +9023,11 @@ ath_calibrate(unsigned long arg)
114 sc->sc_curchan.channel, sc->sc_curchan.channelFlags,
115 isIQdone ? "done" : "not done");
116
117 - sc->sc_cal_ch.expires = jiffies + (ath_calinterval * HZ);
118 - add_timer(&sc->sc_cal_ch);
119 + sc->sc_lastcal = jiffies;
120 + if (!sc->sc_beacon_cal) {
121 + sc->sc_cal_ch.expires = jiffies + (ath_calinterval * HZ);
122 + add_timer(&sc->sc_cal_ch);
123 + }
124 }
125
126 static void
127 @@ -9096,7 +9134,8 @@ ath_newstate(struct ieee80211vap *vap, e
128 ieee80211_state_name[vap->iv_state],
129 ieee80211_state_name[nstate]);
130
131 - del_timer(&sc->sc_cal_ch); /* periodic calibration timer */
132 + if (!sc->sc_beacon_cal)
133 + del_timer(&sc->sc_cal_ch); /* periodic calibration timer */
134
135 ath_hal_setledstate(ah, leds[nstate]); /* set LED */
136 netif_stop_queue(dev); /* before we do anything else */
137 @@ -9321,7 +9360,8 @@ ath_newstate(struct ieee80211vap *vap, e
138 "VAP -> DFSWAIT_PENDING \n");
139 /* start calibration timer with a really small value
140 * 1/10 sec */
141 - mod_timer(&sc->sc_cal_ch, jiffies + (HZ/10));
142 + if (!sc->sc_beacon_cal)
143 + mod_timer(&sc->sc_cal_ch, jiffies + (HZ/10));
144 /* wake the receiver */
145 netif_wake_queue(dev);
146 /* don't do the other usual stuff... */
147 @@ -9364,7 +9404,7 @@ done:
148 error = avp->av_newstate(vap, nstate, arg);
149
150 /* Finally, start any timers. */
151 - if (nstate == IEEE80211_S_RUN) {
152 + if (nstate == IEEE80211_S_RUN && !sc->sc_beacon_cal) {
153 /* start periodic recalibration timer */
154 mod_timer(&sc->sc_cal_ch, jiffies + (ath_calinterval * HZ));
155 }
156 --- a/ath/if_athvar.h
157 +++ b/ath/if_athvar.h
158 @@ -778,6 +778,8 @@ struct ath_softc {
159 struct ieee80211vap **sc_bslot; /* beacon xmit slots */
160 int sc_bnext; /* next slot for beacon xmit */
161
162 + int sc_beacon_cal; /* use beacon timer for calibration */
163 + u_int64_t sc_lastcal; /* last time the calibration was performed */
164 struct timer_list sc_cal_ch; /* calibration timer */
165 HAL_NODE_STATS sc_halstats; /* station-mode rssi stats */
166
This page took 0.052046 seconds and 5 git commands to generate.