| 1 | --- a/ath/if_ath.c |
| 2 | +++ b/ath/if_ath.c |
| 3 | @@ -394,7 +394,6 @@ static int rfkill = 0; |
| 4 | static int tpc = 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 | @@ -429,7 +428,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(xchanmode, "i"); |
| 17 | MODULE_PARM(rfkill, "i"); |
| 18 | #ifdef ATH_CAP_TPC |
| 19 | @@ -440,7 +438,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(xchanmode, int, 0600); |
| 25 | module_param(rfkill, int, 0600); |
| 26 | #ifdef ATH_CAP_TPC |
| 27 | @@ -825,6 +822,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 | @@ -2737,8 +2735,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 | @@ -2763,10 +2760,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 | @@ -3008,7 +3004,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 | @@ -5430,10 +5426,9 @@ ath_beacon_send(struct ath_softc *sc, in |
| 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 | @@ -9104,6 +9099,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 | @@ -9320,7 +9316,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 | @@ -9414,25 +9410,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 | @@ -9540,9 +9534,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 | @@ -9764,10 +9755,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 | @@ -9809,12 +9797,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 | @@ -832,7 +832,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 | |
| 178 | |