mostly revert commit r22396
[oweals/openwrt.git] / package / mac80211 / patches / 521-ath9k_no_offchannel_cal.patch
1 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
2 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
3 @@ -511,13 +511,12 @@ void ath_deinit_leds(struct ath_softc *s
4  #define SC_OP_BEACONS                BIT(1)
5  #define SC_OP_RXAGGR                 BIT(2)
6  #define SC_OP_TXAGGR                 BIT(3)
7 -#define SC_OP_FULL_RESET             BIT(4)
8  #define SC_OP_PREAMBLE_SHORT         BIT(5)
9  #define SC_OP_PROTECT_ENABLE         BIT(6)
10  #define SC_OP_RXFLUSH                BIT(7)
11  #define SC_OP_LED_ASSOCIATED         BIT(8)
12  #define SC_OP_LED_ON                 BIT(9)
13 -#define SC_OP_SCANNING               BIT(10)
14 +#define SC_OP_OFFCHANNEL             BIT(10)
15  #define SC_OP_TSF_RESET              BIT(11)
16  #define SC_OP_BT_PRIORITY_DETECTED   BIT(12)
17  #define SC_OP_BT_SCAN               BIT(13)
18 --- a/drivers/net/wireless/ath/ath9k/main.c
19 +++ b/drivers/net/wireless/ath/ath9k/main.c
20 @@ -155,6 +155,27 @@ void ath9k_ps_restore(struct ath_softc *
21         spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
22  }
23  
24 +static void ath_start_ani(struct ath_common *common)
25 +{
26 +       struct ath_hw *ah = common->ah;
27 +       unsigned long timestamp = jiffies_to_msecs(jiffies);
28 +       struct ath_softc *sc = (struct ath_softc *) common->priv;
29 +
30 +       if (!(sc->sc_flags & SC_OP_ANI_RUN))
31 +               return;
32 +
33 +       if (sc->sc_flags & SC_OP_OFFCHANNEL)
34 +               return;
35 +
36 +       common->ani.longcal_timer = timestamp;
37 +       common->ani.shortcal_timer = timestamp;
38 +       common->ani.checkani_timer = timestamp;
39 +
40 +       mod_timer(&common->ani.timer,
41 +                 jiffies +
42 +                       msecs_to_jiffies((u32)ah->config.ani_poll_interval));
43 +}
44 +
45  /*
46   * Set/change channels.  If the channel is really being changed, it's done
47   * by reseting the chip.  To accomplish this we must first cleanup any pending
48 @@ -173,6 +194,11 @@ int ath_set_channel(struct ath_softc *sc
49         if (sc->sc_flags & SC_OP_INVALID)
50                 return -EIO;
51  
52 +       del_timer_sync(&common->ani.timer);
53 +       cancel_work_sync(&sc->paprd_work);
54 +       cancel_work_sync(&sc->hw_check_work);
55 +       cancel_delayed_work_sync(&sc->tx_complete_work);
56 +
57         ath9k_ps_wakeup(sc);
58  
59         /*
60 @@ -192,7 +218,7 @@ int ath_set_channel(struct ath_softc *sc
61          * to flush data frames already in queue because of
62          * changing channel. */
63  
64 -       if (!stopped || (sc->sc_flags & SC_OP_FULL_RESET))
65 +       if (!stopped || !(sc->sc_flags & SC_OP_OFFCHANNEL))
66                 fastcc = false;
67  
68         ath_print(common, ATH_DBG_CONFIG,
69 @@ -213,8 +239,6 @@ int ath_set_channel(struct ath_softc *sc
70         }
71         spin_unlock_bh(&sc->sc_resetlock);
72  
73 -       sc->sc_flags &= ~SC_OP_FULL_RESET;
74 -
75         if (ath_startrecv(sc) != 0) {
76                 ath_print(common, ATH_DBG_FATAL,
77                           "Unable to restart recv logic\n");
78 @@ -226,6 +250,12 @@ int ath_set_channel(struct ath_softc *sc
79         ath_update_txpow(sc);
80         ath9k_hw_set_interrupts(ah, ah->imask);
81  
82 +       if (!(sc->sc_flags & SC_OP_OFFCHANNEL)) {
83 +               ath_start_ani(common);
84 +               ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0);
85 +               ath_beacon_config(sc, NULL);
86 +       }
87 +
88   ps_restore:
89         ath9k_ps_restore(sc);
90         return r;
91 @@ -440,8 +470,7 @@ set_timer:
92                 cal_interval = min(cal_interval, (u32)short_cal_interval);
93  
94         mod_timer(&common->ani.timer, jiffies + msecs_to_jiffies(cal_interval));
95 -       if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_PAPRD) &&
96 -           !(sc->sc_flags & SC_OP_SCANNING)) {
97 +       if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_PAPRD) {
98                 if (!sc->sc_ah->curchan->paprd_done)
99                         ieee80211_queue_work(sc->hw, &sc->paprd_work);
100                 else
101 @@ -449,24 +478,6 @@ set_timer:
102         }
103  }
104  
105 -static void ath_start_ani(struct ath_common *common)
106 -{
107 -       struct ath_hw *ah = common->ah;
108 -       unsigned long timestamp = jiffies_to_msecs(jiffies);
109 -       struct ath_softc *sc = (struct ath_softc *) common->priv;
110 -
111 -       if (!(sc->sc_flags & SC_OP_ANI_RUN))
112 -               return;
113 -
114 -       common->ani.longcal_timer = timestamp;
115 -       common->ani.shortcal_timer = timestamp;
116 -       common->ani.checkani_timer = timestamp;
117 -
118 -       mod_timer(&common->ani.timer,
119 -                 jiffies +
120 -                       msecs_to_jiffies((u32)ah->config.ani_poll_interval));
121 -}
122 -
123  /*
124   * Update tx/rx chainmask. For legacy association,
125   * hard code chainmask to 1x1, for 11n association, use
126 @@ -478,7 +489,7 @@ void ath_update_chainmask(struct ath_sof
127         struct ath_hw *ah = sc->sc_ah;
128         struct ath_common *common = ath9k_hw_common(ah);
129  
130 -       if ((sc->sc_flags & SC_OP_SCANNING) || is_ht ||
131 +       if ((sc->sc_flags & SC_OP_OFFCHANNEL) || is_ht ||
132             (ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE)) {
133                 common->tx_chainmask = ah->caps.tx_chainmask;
134                 common->rx_chainmask = ah->caps.rx_chainmask;
135 @@ -1580,6 +1591,10 @@ static int ath9k_config(struct ieee80211
136  
137                 aphy->chan_idx = pos;
138                 aphy->chan_is_ht = conf_is_ht(conf);
139 +               if (hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)
140 +                       sc->sc_flags |= SC_OP_OFFCHANNEL;
141 +               else
142 +                       sc->sc_flags &= ~SC_OP_OFFCHANNEL;
143  
144                 if (aphy->state == ATH_WIPHY_SCAN ||
145                     aphy->state == ATH_WIPHY_ACTIVE)
146 @@ -1991,7 +2006,6 @@ static void ath9k_sw_scan_start(struct i
147  {
148         struct ath_wiphy *aphy = hw->priv;
149         struct ath_softc *sc = aphy->sc;
150 -       struct ath_common *common = ath9k_hw_common(sc->sc_ah);
151  
152         mutex_lock(&sc->mutex);
153         if (ath9k_wiphy_scanning(sc)) {
154 @@ -2007,11 +2021,6 @@ static void ath9k_sw_scan_start(struct i
155  
156         aphy->state = ATH_WIPHY_SCAN;
157         ath9k_wiphy_pause_all_forced(sc, aphy);
158 -       sc->sc_flags |= SC_OP_SCANNING;
159 -       del_timer_sync(&common->ani.timer);
160 -       cancel_work_sync(&sc->paprd_work);
161 -       cancel_work_sync(&sc->hw_check_work);
162 -       cancel_delayed_work_sync(&sc->tx_complete_work);
163         mutex_unlock(&sc->mutex);
164  }
165  
166 @@ -2019,15 +2028,9 @@ static void ath9k_sw_scan_complete(struc
167  {
168         struct ath_wiphy *aphy = hw->priv;
169         struct ath_softc *sc = aphy->sc;
170 -       struct ath_common *common = ath9k_hw_common(sc->sc_ah);
171  
172         mutex_lock(&sc->mutex);
173         aphy->state = ATH_WIPHY_ACTIVE;
174 -       sc->sc_flags &= ~SC_OP_SCANNING;
175 -       sc->sc_flags |= SC_OP_FULL_RESET;
176 -       ath_start_ani(common);
177 -       ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0);
178 -       ath_beacon_config(sc, NULL);
179         mutex_unlock(&sc->mutex);
180  }
181  
182 --- a/drivers/net/wireless/ath/ath9k/recv.c
183 +++ b/drivers/net/wireless/ath/ath9k/recv.c
184 @@ -292,7 +292,7 @@ static void ath_edma_start_recv(struct a
185  
186         ath_opmode_init(sc);
187  
188 -       ath9k_hw_startpcureceive(sc->sc_ah, (sc->sc_flags & SC_OP_SCANNING));
189 +       ath9k_hw_startpcureceive(sc->sc_ah, (sc->sc_flags & SC_OP_OFFCHANNEL));
190  }
191  
192  static void ath_edma_stop_recv(struct ath_softc *sc)
193 @@ -498,7 +498,7 @@ int ath_startrecv(struct ath_softc *sc)
194  start_recv:
195         spin_unlock_bh(&sc->rx.rxbuflock);
196         ath_opmode_init(sc);
197 -       ath9k_hw_startpcureceive(ah, (sc->sc_flags & SC_OP_SCANNING));
198 +       ath9k_hw_startpcureceive(ah, (sc->sc_flags & SC_OP_OFFCHANNEL));
199  
200         return 0;
201  }