ath9k: add some more pending fixes
[openwrt.git] / package / mac80211 / patches / 300-pending_work.patch
1 --- a/net/mac80211/agg-rx.c
2 +++ b/net/mac80211/agg-rx.c
3 @@ -176,6 +176,8 @@ static void ieee80211_send_addba_resp(st
4 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
5 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
6 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
7 + else if (sdata->vif.type == NL80211_IFTYPE_WDS)
8 + memcpy(mgmt->bssid, da, ETH_ALEN);
9
10 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
11 IEEE80211_STYPE_ACTION);
12 --- a/net/mac80211/agg-tx.c
13 +++ b/net/mac80211/agg-tx.c
14 @@ -79,7 +79,8 @@ static void ieee80211_send_addba_request
15 memcpy(mgmt->da, da, ETH_ALEN);
16 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
17 if (sdata->vif.type == NL80211_IFTYPE_AP ||
18 - sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
19 + sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
20 + sdata->vif.type == NL80211_IFTYPE_WDS)
21 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
22 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
23 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
24 @@ -398,7 +399,8 @@ int ieee80211_start_tx_ba_session(struct
25 */
26 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
27 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
28 - sdata->vif.type != NL80211_IFTYPE_AP)
29 + sdata->vif.type != NL80211_IFTYPE_AP &&
30 + sdata->vif.type != NL80211_IFTYPE_WDS)
31 return -EINVAL;
32
33 if (test_sta_flags(sta, WLAN_STA_BLOCK_BA)) {
34 --- a/net/mac80211/debugfs_sta.c
35 +++ b/net/mac80211/debugfs_sta.c
36 @@ -59,7 +59,7 @@ static ssize_t sta_flags_read(struct fil
37 char buf[100];
38 struct sta_info *sta = file->private_data;
39 u32 staflags = get_sta_flags(sta);
40 - int res = scnprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s",
41 + int res = scnprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s",
42 staflags & WLAN_STA_AUTH ? "AUTH\n" : "",
43 staflags & WLAN_STA_ASSOC ? "ASSOC\n" : "",
44 staflags & WLAN_STA_PS_STA ? "PS (sta)\n" : "",
45 @@ -67,7 +67,6 @@ static ssize_t sta_flags_read(struct fil
46 staflags & WLAN_STA_AUTHORIZED ? "AUTHORIZED\n" : "",
47 staflags & WLAN_STA_SHORT_PREAMBLE ? "SHORT PREAMBLE\n" : "",
48 staflags & WLAN_STA_WME ? "WME\n" : "",
49 - staflags & WLAN_STA_WDS ? "WDS\n" : "",
50 staflags & WLAN_STA_MFP ? "MFP\n" : "");
51 return simple_read_from_buffer(userbuf, count, ppos, buf, res);
52 }
53 --- a/net/mac80211/iface.c
54 +++ b/net/mac80211/iface.c
55 @@ -178,7 +178,6 @@ static int ieee80211_do_open(struct net_
56 {
57 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
58 struct ieee80211_local *local = sdata->local;
59 - struct sta_info *sta;
60 u32 changed = 0;
61 int res;
62 u32 hw_reconf_flags = 0;
63 @@ -290,27 +289,6 @@ static int ieee80211_do_open(struct net_
64
65 set_bit(SDATA_STATE_RUNNING, &sdata->state);
66
67 - if (sdata->vif.type == NL80211_IFTYPE_WDS) {
68 - /* Create STA entry for the WDS peer */
69 - sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
70 - GFP_KERNEL);
71 - if (!sta) {
72 - res = -ENOMEM;
73 - goto err_del_interface;
74 - }
75 -
76 - /* no locking required since STA is not live yet */
77 - sta->flags |= WLAN_STA_AUTHORIZED;
78 -
79 - res = sta_info_insert(sta);
80 - if (res) {
81 - /* STA has been freed */
82 - goto err_del_interface;
83 - }
84 -
85 - rate_control_rate_init(sta);
86 - }
87 -
88 /*
89 * set_multicast_list will be invoked by the networking core
90 * which will check whether any increments here were done in
91 @@ -344,8 +322,7 @@ static int ieee80211_do_open(struct net_
92 netif_tx_start_all_queues(dev);
93
94 return 0;
95 - err_del_interface:
96 - drv_remove_interface(local, &sdata->vif);
97 +
98 err_stop:
99 if (!local->open_count)
100 drv_stop(local);
101 @@ -718,6 +695,70 @@ static void ieee80211_if_setup(struct ne
102 dev->destructor = free_netdev;
103 }
104
105 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
106 + struct sk_buff *skb)
107 +{
108 + struct ieee80211_local *local = sdata->local;
109 + struct ieee80211_rx_status *rx_status;
110 + struct ieee802_11_elems elems;
111 + struct ieee80211_mgmt *mgmt;
112 + struct sta_info *sta;
113 + size_t baselen;
114 + u32 rates = 0;
115 + u16 stype;
116 + bool new = false;
117 + enum ieee80211_band band = local->hw.conf.channel->band;
118 + struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
119 +
120 + rx_status = IEEE80211_SKB_RXCB(skb);
121 + mgmt = (struct ieee80211_mgmt *) skb->data;
122 + stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
123 +
124 + if (stype != IEEE80211_STYPE_BEACON)
125 + return;
126 +
127 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
128 + if (baselen > skb->len)
129 + return;
130 +
131 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
132 + skb->len - baselen, &elems);
133 +
134 + rates = ieee80211_sta_get_rates(local, &elems, band);
135 +
136 + rcu_read_lock();
137 +
138 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
139 +
140 + if (!sta) {
141 + rcu_read_unlock();
142 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
143 + GFP_KERNEL);
144 + if (!sta)
145 + return;
146 +
147 + new = true;
148 + }
149 +
150 + sta->last_rx = jiffies;
151 + sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
152 +
153 + if (elems.ht_cap_elem)
154 + ieee80211_ht_cap_ie_to_sta_ht_cap(sband,
155 + elems.ht_cap_elem, &sta->sta.ht_cap);
156 +
157 + if (elems.wmm_param)
158 + set_sta_flags(sta, WLAN_STA_WME);
159 +
160 + if (new) {
161 + sta->flags = WLAN_STA_AUTHORIZED;
162 + rate_control_rate_init(sta);
163 + sta_info_insert_rcu(sta);
164 + }
165 +
166 + rcu_read_unlock();
167 +}
168 +
169 static void ieee80211_iface_work(struct work_struct *work)
170 {
171 struct ieee80211_sub_if_data *sdata =
172 @@ -822,6 +863,9 @@ static void ieee80211_iface_work(struct
173 break;
174 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
175 break;
176 + case NL80211_IFTYPE_WDS:
177 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
178 + break;
179 default:
180 WARN(1, "frame for unexpected interface type");
181 break;
182 --- a/net/mac80211/rx.c
183 +++ b/net/mac80211/rx.c
184 @@ -2137,7 +2137,8 @@ ieee80211_rx_h_action(struct ieee80211_r
185 */
186 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
187 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
188 - sdata->vif.type != NL80211_IFTYPE_AP)
189 + sdata->vif.type != NL80211_IFTYPE_AP &&
190 + sdata->vif.type != NL80211_IFTYPE_WDS)
191 break;
192
193 /* verify action_code is present */
194 @@ -2335,13 +2336,14 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
195
196 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
197 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
198 - sdata->vif.type != NL80211_IFTYPE_STATION)
199 + sdata->vif.type != NL80211_IFTYPE_STATION &&
200 + sdata->vif.type != NL80211_IFTYPE_WDS)
201 return RX_DROP_MONITOR;
202
203 switch (stype) {
204 case cpu_to_le16(IEEE80211_STYPE_BEACON):
205 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
206 - /* process for all: mesh, mlme, ibss */
207 + /* process for all: mesh, mlme, ibss, wds */
208 break;
209 case cpu_to_le16(IEEE80211_STYPE_DEAUTH):
210 case cpu_to_le16(IEEE80211_STYPE_DISASSOC):
211 @@ -2680,10 +2682,16 @@ static int prepare_for_handlers(struct i
212 }
213 break;
214 case NL80211_IFTYPE_WDS:
215 - if (bssid || !ieee80211_is_data(hdr->frame_control))
216 - return 0;
217 if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2))
218 return 0;
219 +
220 + if (ieee80211_is_data(hdr->frame_control) ||
221 + ieee80211_is_action(hdr->frame_control)) {
222 + if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
223 + return 0;
224 + } else if (!ieee80211_is_beacon(hdr->frame_control))
225 + return 0;
226 +
227 break;
228 default:
229 /* should never get here */
230 --- a/net/mac80211/sta_info.h
231 +++ b/net/mac80211/sta_info.h
232 @@ -31,7 +31,6 @@
233 * frames.
234 * @WLAN_STA_ASSOC_AP: We're associated to that station, it is an AP.
235 * @WLAN_STA_WME: Station is a QoS-STA.
236 - * @WLAN_STA_WDS: Station is one of our WDS peers.
237 * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
238 * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
239 * frame to this station is transmitted.
240 @@ -54,7 +53,6 @@ enum ieee80211_sta_info_flags {
241 WLAN_STA_SHORT_PREAMBLE = 1<<4,
242 WLAN_STA_ASSOC_AP = 1<<5,
243 WLAN_STA_WME = 1<<6,
244 - WLAN_STA_WDS = 1<<7,
245 WLAN_STA_CLEAR_PS_FILT = 1<<9,
246 WLAN_STA_MFP = 1<<10,
247 WLAN_STA_BLOCK_BA = 1<<11,
248 --- a/drivers/net/wireless/ath/ath9k/beacon.c
249 +++ b/drivers/net/wireless/ath/ath9k/beacon.c
250 @@ -384,7 +384,9 @@ void ath_beacon_tasklet(unsigned long da
251 ath_dbg(common, ATH_DBG_BSTUCK,
252 "beacon is officially stuck\n");
253 sc->sc_flags |= SC_OP_TSF_RESET;
254 + spin_lock(&sc->sc_pcu_lock);
255 ath_reset(sc, true);
256 + spin_unlock(&sc->sc_pcu_lock);
257 }
258
259 return;
260 --- a/drivers/net/wireless/ath/ath9k/main.c
261 +++ b/drivers/net/wireless/ath/ath9k/main.c
262 @@ -617,8 +617,11 @@ void ath_hw_check(struct work_struct *wo
263 ath_dbg(common, ATH_DBG_RESET, "Possible baseband hang, "
264 "busy=%d (try %d)\n", busy, sc->hw_busy_count + 1);
265 if (busy >= 99) {
266 - if (++sc->hw_busy_count >= 3)
267 + if (++sc->hw_busy_count >= 3) {
268 + spin_lock_bh(&sc->sc_pcu_lock);
269 ath_reset(sc, true);
270 + spin_unlock_bh(&sc->sc_pcu_lock);
271 + }
272 } else if (busy >= 0)
273 sc->hw_busy_count = 0;
274
275 @@ -637,7 +640,9 @@ static void ath_hw_pll_rx_hang_check(str
276 /* Rx is hung for more than 500ms. Reset it */
277 ath_dbg(common, ATH_DBG_RESET,
278 "Possible RX hang, resetting");
279 + spin_lock_bh(&sc->sc_pcu_lock);
280 ath_reset(sc, true);
281 + spin_unlock_bh(&sc->sc_pcu_lock);
282 count = 0;
283 }
284 } else
285 @@ -674,7 +679,9 @@ void ath9k_tasklet(unsigned long data)
286
287 if ((status & ATH9K_INT_FATAL) ||
288 (status & ATH9K_INT_BB_WATCHDOG)) {
289 + spin_lock(&sc->sc_pcu_lock);
290 ath_reset(sc, true);
291 + spin_unlock(&sc->sc_pcu_lock);
292 return;
293 }
294
295 @@ -980,7 +987,6 @@ int ath_reset(struct ath_softc *sc, bool
296 del_timer_sync(&common->ani.timer);
297
298 ath9k_ps_wakeup(sc);
299 - spin_lock_bh(&sc->sc_pcu_lock);
300
301 ieee80211_stop_queues(hw);
302
303 @@ -1023,7 +1029,6 @@ int ath_reset(struct ath_softc *sc, bool
304 }
305
306 ieee80211_wake_queues(hw);
307 - spin_unlock_bh(&sc->sc_pcu_lock);
308
309 /* Start ANI */
310 if (!common->disable_ani)
311 @@ -2326,9 +2331,9 @@ static void ath9k_flush(struct ieee80211
312 ath9k_ps_wakeup(sc);
313 spin_lock_bh(&sc->sc_pcu_lock);
314 drain_txq = ath_drain_all_txq(sc, false);
315 - spin_unlock_bh(&sc->sc_pcu_lock);
316 if (!drain_txq)
317 ath_reset(sc, false);
318 + spin_unlock_bh(&sc->sc_pcu_lock);
319 ath9k_ps_restore(sc);
320 ieee80211_wake_queues(hw);
321
322 --- a/drivers/net/wireless/ath/ath9k/xmit.c
323 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
324 @@ -565,11 +565,8 @@ static void ath_tx_complete_aggr(struct
325
326 rcu_read_unlock();
327
328 - if (needreset) {
329 - spin_unlock_bh(&sc->sc_pcu_lock);
330 + if (needreset)
331 ath_reset(sc, false);
332 - spin_lock_bh(&sc->sc_pcu_lock);
333 - }
334 }
335
336 static u32 ath_lookup_rate(struct ath_softc *sc, struct ath_buf *bf,
337 @@ -2169,7 +2166,9 @@ static void ath_tx_complete_poll_work(st
338 if (needreset) {
339 ath_dbg(ath9k_hw_common(sc->sc_ah), ATH_DBG_RESET,
340 "tx hung, resetting the chip\n");
341 + spin_lock_bh(&sc->sc_pcu_lock);
342 ath_reset(sc, true);
343 + spin_unlock_bh(&sc->sc_pcu_lock);
344 }
345
346 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work,
347 --- a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
348 +++ b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
349 @@ -236,7 +236,7 @@ static void ar9003_paprd_get_gain_table(
350 memset(entry, 0, sizeof(ah->paprd_gain_table_entries));
351 memset(index, 0, sizeof(ah->paprd_gain_table_index));
352
353 - for (i = 0; i < 32; i++) {
354 + for (i = 0; i < PAPRD_GAIN_TABLE_ENTRIES; i++) {
355 entry[i] = REG_READ(ah, reg);
356 index[i] = (entry[i] >> 24) & 0xff;
357 reg += 4;
358 @@ -246,13 +246,13 @@ static void ar9003_paprd_get_gain_table(
359 static unsigned int ar9003_get_desired_gain(struct ath_hw *ah, int chain,
360 int target_power)
361 {
362 - int olpc_gain_delta = 0;
363 + int olpc_gain_delta = 0, cl_gain_mod;
364 int alpha_therm, alpha_volt;
365 int therm_cal_value, volt_cal_value;
366 int therm_value, volt_value;
367 int thermal_gain_corr, voltage_gain_corr;
368 int desired_scale, desired_gain = 0;
369 - u32 reg;
370 + u32 reg_olpc = 0, reg_cl_gain = 0;
371
372 REG_CLR_BIT(ah, AR_PHY_PAPRD_TRAINER_STAT1,
373 AR_PHY_PAPRD_TRAINER_STAT1_PAPRD_TRAIN_DONE);
374 @@ -271,15 +271,29 @@ static unsigned int ar9003_get_desired_g
375 volt_value = REG_READ_FIELD(ah, AR_PHY_BB_THERM_ADC_4,
376 AR_PHY_BB_THERM_ADC_4_LATEST_VOLT_VALUE);
377
378 - if (chain == 0)
379 - reg = AR_PHY_TPC_11_B0;
380 - else if (chain == 1)
381 - reg = AR_PHY_TPC_11_B1;
382 - else
383 - reg = AR_PHY_TPC_11_B2;
384 + switch (chain) {
385 + case 0:
386 + reg_olpc = AR_PHY_TPC_11_B0;
387 + reg_cl_gain = AR_PHY_CL_TAB_0;
388 + break;
389 + case 1:
390 + reg_olpc = AR_PHY_TPC_11_B1;
391 + reg_cl_gain = AR_PHY_CL_TAB_1;
392 + break;
393 + case 2:
394 + reg_olpc = AR_PHY_TPC_11_B2;
395 + reg_cl_gain = AR_PHY_CL_TAB_2;
396 + break;
397 + default:
398 + ath_dbg(ath9k_hw_common(ah), ATH_DBG_CALIBRATE,
399 + "Invalid chainmask: %d\n", chain);
400 + break;
401 + }
402
403 - olpc_gain_delta = REG_READ_FIELD(ah, reg,
404 + olpc_gain_delta = REG_READ_FIELD(ah, reg_olpc,
405 AR_PHY_TPC_11_OLPC_GAIN_DELTA);
406 + cl_gain_mod = REG_READ_FIELD(ah, reg_cl_gain,
407 + AR_PHY_CL_TAB_CL_GAIN_MOD);
408
409 if (olpc_gain_delta >= 128)
410 olpc_gain_delta = olpc_gain_delta - 256;
411 @@ -289,7 +303,7 @@ static unsigned int ar9003_get_desired_g
412 voltage_gain_corr = (alpha_volt * (volt_value - volt_cal_value) +
413 (128 / 2)) / 128;
414 desired_gain = target_power - olpc_gain_delta - thermal_gain_corr -
415 - voltage_gain_corr + desired_scale;
416 + voltage_gain_corr + desired_scale + cl_gain_mod;
417
418 return desired_gain;
419 }
420 @@ -727,7 +741,7 @@ int ar9003_paprd_setup_gain_table(struct
421 desired_gain = ar9003_get_desired_gain(ah, chain, train_power);
422
423 gain_index = 0;
424 - for (i = 0; i < 32; i++) {
425 + for (i = 0; i < PAPRD_GAIN_TABLE_ENTRIES; i++) {
426 if (ah->paprd_gain_table_index[i] >= desired_gain)
427 break;
428 gain_index++;
429 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h
430 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
431 @@ -1121,6 +1121,9 @@
432 #define AR_PHY_POWERTX_RATE8_POWERTXHT40_5 0x3F00
433 #define AR_PHY_POWERTX_RATE8_POWERTXHT40_5_S 8
434
435 +#define AR_PHY_CL_TAB_CL_GAIN_MOD 0x1f
436 +#define AR_PHY_CL_TAB_CL_GAIN_MOD_S 0
437 +
438 void ar9003_hw_set_chain_masks(struct ath_hw *ah, u8 rx, u8 tx);
439
440 #endif /* AR9003_PHY_H */
This page took 0.080866 seconds and 5 git commands to generate.