madwifi: remove stuck beacon workaround (does not work properly). add a workaround...
[openwrt-10.03/.git] / package / madwifi / patches / 306-mib_intr_workaround.patch
1 Index: madwifi-ng-r2568-20070710/ath/if_ath.c
2 ===================================================================
3 --- madwifi-ng-r2568-20070710.orig/ath/if_ath.c 2007-08-01 11:07:47.882943145 +0200
4 +++ madwifi-ng-r2568-20070710/ath/if_ath.c      2007-08-01 11:41:11.781138794 +0200
5 @@ -203,6 +203,7 @@
6  static void ath_flushrecv(struct ath_softc *);
7  static void ath_chan_change(struct ath_softc *, struct ieee80211_channel *);
8  static void ath_calibrate(unsigned long);
9 +static void ath_mib_enable(unsigned long);
10  static int ath_newstate(struct ieee80211vap *, enum ieee80211_state, int);
11  
12  static void ath_scan_start(struct ieee80211com *);
13 @@ -660,6 +661,10 @@
14         sc->sc_cal_ch.function = ath_calibrate;
15         sc->sc_cal_ch.data = (unsigned long) dev;
16  
17 +       init_timer(&sc->sc_mib_enable);
18 +       sc->sc_mib_enable.function = ath_mib_enable;
19 +       sc->sc_mib_enable.data = (unsigned long) sc;
20 +
21  #ifdef ATH_SUPERG_DYNTURBO
22         init_timer(&sc->sc_dturbo_switch_mode);
23         sc->sc_dturbo_switch_mode.function = ath_turbo_switch_mode;
24 @@ -1751,16 +1756,19 @@
25                 if (status & HAL_INT_MIB) {
26                         sc->sc_stats.ast_mib++;
27                         /*
28 -                        * Disable interrupts until we service the MIB
29 -                        * interrupt; otherwise it will continue to fire.
30 -                        */
31 -                       ath_hal_intrset(ah, 0);
32 -                       /*
33 -                        * Let the HAL handle the event.  We assume it will
34 -                        * clear whatever condition caused the interrupt.
35 +                        * When the card receives lots of PHY errors, the MIB
36 +                        * interrupt will fire at a very rapid rate. We will use
37 +                        * a timer to enforce at least 1 jiffy delay between
38 +                        * MIB interrupts. This should be unproblematic, since
39 +                        * the hardware will continue to update the counters in the
40 +                        * mean time.
41                          */
42 -                       ath_hal_mibevent(ah, &sc->sc_halstats);
43 +                       sc->sc_imask &= ~HAL_INT_MIB;
44                         ath_hal_intrset(ah, sc->sc_imask);
45 +                       mod_timer(&sc->sc_mib_enable, jiffies + 1);
46 +
47 +                       /* Let the HAL handle the event. */
48 +                       ath_hal_mibevent(ah, &sc->sc_halstats);
49                 }
50         }
51         if (needmark)
52 @@ -8029,6 +8037,19 @@
53  }
54  
55  /*
56 + * Enable MIB interrupts again, after the ISR disabled them
57 + * to slow down the rate of PHY error reporting.
58 + */
59 +static void
60 +ath_mib_enable(unsigned long arg)
61 +{
62 +       struct ath_softc *sc = (struct ath_softc *) arg;
63 +
64 +       sc->sc_imask |= HAL_INT_MIB;
65 +       ath_hal_intrset(sc->sc_ah, sc->sc_imask);
66 +}
67 +
68 +/*
69   * Periodically recalibrate the PHY to account
70   * for temperature/environment changes.
71   */
72 Index: madwifi-ng-r2568-20070710/ath/if_athvar.h
73 ===================================================================
74 --- madwifi-ng-r2568-20070710.orig/ath/if_athvar.h      2007-08-01 11:33:50.800008711 +0200
75 +++ madwifi-ng-r2568-20070710/ath/if_athvar.h   2007-08-01 11:34:33.202425088 +0200
76 @@ -687,6 +687,7 @@
77         struct ctl_table *sc_sysctls;
78  
79         u_int16_t sc_reapcount;                 /* # of tx buffers reaped after net dev stopped */
80 +       struct timer_list sc_mib_enable;
81  
82  #ifdef ATH_REVERSE_ENGINEERING
83         u_int8_t register_snapshot[MAX_REGISTER_ADDRESS];