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);
10 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
11 IEEE80211_STYPE_ACTION);
12 @@ -262,7 +264,11 @@ void ieee80211_process_addba_request(str
15 #endif /* CONFIG_MAC80211_HT_DEBUG */
18 + /* delete existing Rx BA session on the same tid */
19 + ___ieee80211_stop_rx_ba_session(sta, tid, WLAN_BACK_RECIPIENT,
20 + WLAN_STATUS_UNSPECIFIED_QOS,
24 /* prepare A-MPDU MLME for Rx aggregation */
25 --- a/net/mac80211/agg-tx.c
26 +++ b/net/mac80211/agg-tx.c
27 @@ -79,7 +79,8 @@ static void ieee80211_send_addba_request
28 memcpy(mgmt->da, da, ETH_ALEN);
29 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
30 if (sdata->vif.type == NL80211_IFTYPE_AP ||
31 - sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
32 + sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
33 + sdata->vif.type == NL80211_IFTYPE_WDS)
34 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
35 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
36 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
37 @@ -398,7 +399,8 @@ int ieee80211_start_tx_ba_session(struct
39 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
40 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
41 - sdata->vif.type != NL80211_IFTYPE_AP)
42 + sdata->vif.type != NL80211_IFTYPE_AP &&
43 + sdata->vif.type != NL80211_IFTYPE_WDS)
46 if (test_sta_flags(sta, WLAN_STA_BLOCK_BA)) {
47 --- a/net/mac80211/debugfs_sta.c
48 +++ b/net/mac80211/debugfs_sta.c
49 @@ -59,7 +59,7 @@ static ssize_t sta_flags_read(struct fil
51 struct sta_info *sta = file->private_data;
52 u32 staflags = get_sta_flags(sta);
53 - int res = scnprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s",
54 + int res = scnprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s",
55 staflags & WLAN_STA_AUTH ? "AUTH\n" : "",
56 staflags & WLAN_STA_ASSOC ? "ASSOC\n" : "",
57 staflags & WLAN_STA_PS_STA ? "PS (sta)\n" : "",
58 @@ -67,7 +67,6 @@ static ssize_t sta_flags_read(struct fil
59 staflags & WLAN_STA_AUTHORIZED ? "AUTHORIZED\n" : "",
60 staflags & WLAN_STA_SHORT_PREAMBLE ? "SHORT PREAMBLE\n" : "",
61 staflags & WLAN_STA_WME ? "WME\n" : "",
62 - staflags & WLAN_STA_WDS ? "WDS\n" : "",
63 staflags & WLAN_STA_MFP ? "MFP\n" : "");
64 return simple_read_from_buffer(userbuf, count, ppos, buf, res);
66 --- a/net/mac80211/iface.c
67 +++ b/net/mac80211/iface.c
68 @@ -178,7 +178,6 @@ static int ieee80211_do_open(struct net_
70 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
71 struct ieee80211_local *local = sdata->local;
72 - struct sta_info *sta;
75 u32 hw_reconf_flags = 0;
76 @@ -290,27 +289,6 @@ static int ieee80211_do_open(struct net_
78 set_bit(SDATA_STATE_RUNNING, &sdata->state);
80 - if (sdata->vif.type == NL80211_IFTYPE_WDS) {
81 - /* Create STA entry for the WDS peer */
82 - sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
86 - goto err_del_interface;
89 - /* no locking required since STA is not live yet */
90 - sta->flags |= WLAN_STA_AUTHORIZED;
92 - res = sta_info_insert(sta);
94 - /* STA has been freed */
95 - goto err_del_interface;
98 - rate_control_rate_init(sta);
102 * set_multicast_list will be invoked by the networking core
103 * which will check whether any increments here were done in
104 @@ -344,8 +322,7 @@ static int ieee80211_do_open(struct net_
105 netif_tx_start_all_queues(dev);
109 - drv_remove_interface(local, &sdata->vif);
112 if (!local->open_count)
114 @@ -718,6 +695,70 @@ static void ieee80211_if_setup(struct ne
115 dev->destructor = free_netdev;
118 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
119 + struct sk_buff *skb)
121 + struct ieee80211_local *local = sdata->local;
122 + struct ieee80211_rx_status *rx_status;
123 + struct ieee802_11_elems elems;
124 + struct ieee80211_mgmt *mgmt;
125 + struct sta_info *sta;
130 + enum ieee80211_band band = local->hw.conf.channel->band;
131 + struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
133 + rx_status = IEEE80211_SKB_RXCB(skb);
134 + mgmt = (struct ieee80211_mgmt *) skb->data;
135 + stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
137 + if (stype != IEEE80211_STYPE_BEACON)
140 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
141 + if (baselen > skb->len)
144 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
145 + skb->len - baselen, &elems);
147 + rates = ieee80211_sta_get_rates(local, &elems, band);
151 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
155 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
163 + sta->last_rx = jiffies;
164 + sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
166 + if (elems.ht_cap_elem)
167 + ieee80211_ht_cap_ie_to_sta_ht_cap(sband,
168 + elems.ht_cap_elem, &sta->sta.ht_cap);
170 + if (elems.wmm_param)
171 + set_sta_flags(sta, WLAN_STA_WME);
174 + sta->flags = WLAN_STA_AUTHORIZED;
175 + rate_control_rate_init(sta);
176 + sta_info_insert_rcu(sta);
182 static void ieee80211_iface_work(struct work_struct *work)
184 struct ieee80211_sub_if_data *sdata =
185 @@ -822,6 +863,9 @@ static void ieee80211_iface_work(struct
187 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
189 + case NL80211_IFTYPE_WDS:
190 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
193 WARN(1, "frame for unexpected interface type");
195 --- a/net/mac80211/rx.c
196 +++ b/net/mac80211/rx.c
197 @@ -2137,7 +2137,8 @@ ieee80211_rx_h_action(struct ieee80211_r
199 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
200 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
201 - sdata->vif.type != NL80211_IFTYPE_AP)
202 + sdata->vif.type != NL80211_IFTYPE_AP &&
203 + sdata->vif.type != NL80211_IFTYPE_WDS)
206 /* verify action_code is present */
207 @@ -2335,13 +2336,14 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
209 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
210 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
211 - sdata->vif.type != NL80211_IFTYPE_STATION)
212 + sdata->vif.type != NL80211_IFTYPE_STATION &&
213 + sdata->vif.type != NL80211_IFTYPE_WDS)
214 return RX_DROP_MONITOR;
217 case cpu_to_le16(IEEE80211_STYPE_BEACON):
218 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
219 - /* process for all: mesh, mlme, ibss */
220 + /* process for all: mesh, mlme, ibss, wds */
222 case cpu_to_le16(IEEE80211_STYPE_DEAUTH):
223 case cpu_to_le16(IEEE80211_STYPE_DISASSOC):
224 @@ -2680,10 +2682,16 @@ static int prepare_for_handlers(struct i
227 case NL80211_IFTYPE_WDS:
228 - if (bssid || !ieee80211_is_data(hdr->frame_control))
230 if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2))
233 + if (ieee80211_is_data(hdr->frame_control) ||
234 + ieee80211_is_action(hdr->frame_control)) {
235 + if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
237 + } else if (!ieee80211_is_beacon(hdr->frame_control))
242 /* should never get here */
243 --- a/net/mac80211/sta_info.h
244 +++ b/net/mac80211/sta_info.h
247 * @WLAN_STA_ASSOC_AP: We're associated to that station, it is an AP.
248 * @WLAN_STA_WME: Station is a QoS-STA.
249 - * @WLAN_STA_WDS: Station is one of our WDS peers.
250 * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
251 * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
252 * frame to this station is transmitted.
253 @@ -54,7 +53,6 @@ enum ieee80211_sta_info_flags {
254 WLAN_STA_SHORT_PREAMBLE = 1<<4,
255 WLAN_STA_ASSOC_AP = 1<<5,
257 - WLAN_STA_WDS = 1<<7,
258 WLAN_STA_CLEAR_PS_FILT = 1<<9,
259 WLAN_STA_MFP = 1<<10,
260 WLAN_STA_BLOCK_BA = 1<<11,
261 --- a/drivers/net/wireless/ath/ath9k/beacon.c
262 +++ b/drivers/net/wireless/ath/ath9k/beacon.c
263 @@ -384,7 +384,9 @@ void ath_beacon_tasklet(unsigned long da
264 ath_dbg(common, ATH_DBG_BSTUCK,
265 "beacon is officially stuck\n");
266 sc->sc_flags |= SC_OP_TSF_RESET;
267 + spin_lock(&sc->sc_pcu_lock);
269 + spin_unlock(&sc->sc_pcu_lock);
273 --- a/drivers/net/wireless/ath/ath9k/main.c
274 +++ b/drivers/net/wireless/ath/ath9k/main.c
275 @@ -617,8 +617,11 @@ void ath_hw_check(struct work_struct *wo
276 ath_dbg(common, ATH_DBG_RESET, "Possible baseband hang, "
277 "busy=%d (try %d)\n", busy, sc->hw_busy_count + 1);
279 - if (++sc->hw_busy_count >= 3)
280 + if (++sc->hw_busy_count >= 3) {
281 + spin_lock_bh(&sc->sc_pcu_lock);
283 + spin_unlock_bh(&sc->sc_pcu_lock);
285 } else if (busy >= 0)
286 sc->hw_busy_count = 0;
288 @@ -637,7 +640,9 @@ static void ath_hw_pll_rx_hang_check(str
289 /* Rx is hung for more than 500ms. Reset it */
290 ath_dbg(common, ATH_DBG_RESET,
291 "Possible RX hang, resetting");
292 + spin_lock_bh(&sc->sc_pcu_lock);
294 + spin_unlock_bh(&sc->sc_pcu_lock);
298 @@ -674,7 +679,9 @@ void ath9k_tasklet(unsigned long data)
300 if ((status & ATH9K_INT_FATAL) ||
301 (status & ATH9K_INT_BB_WATCHDOG)) {
302 + spin_lock(&sc->sc_pcu_lock);
304 + spin_unlock(&sc->sc_pcu_lock);
308 @@ -980,7 +987,6 @@ int ath_reset(struct ath_softc *sc, bool
309 del_timer_sync(&common->ani.timer);
312 - spin_lock_bh(&sc->sc_pcu_lock);
314 ieee80211_stop_queues(hw);
316 @@ -1023,7 +1029,6 @@ int ath_reset(struct ath_softc *sc, bool
319 ieee80211_wake_queues(hw);
320 - spin_unlock_bh(&sc->sc_pcu_lock);
323 if (!common->disable_ani)
324 @@ -2326,9 +2331,9 @@ static void ath9k_flush(struct ieee80211
326 spin_lock_bh(&sc->sc_pcu_lock);
327 drain_txq = ath_drain_all_txq(sc, false);
328 - spin_unlock_bh(&sc->sc_pcu_lock);
330 ath_reset(sc, false);
331 + spin_unlock_bh(&sc->sc_pcu_lock);
332 ath9k_ps_restore(sc);
333 ieee80211_wake_queues(hw);
335 --- a/drivers/net/wireless/ath/ath9k/xmit.c
336 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
337 @@ -565,11 +565,8 @@ static void ath_tx_complete_aggr(struct
342 - spin_unlock_bh(&sc->sc_pcu_lock);
344 ath_reset(sc, false);
345 - spin_lock_bh(&sc->sc_pcu_lock);
349 static u32 ath_lookup_rate(struct ath_softc *sc, struct ath_buf *bf,
350 @@ -2169,7 +2166,9 @@ static void ath_tx_complete_poll_work(st
352 ath_dbg(ath9k_hw_common(sc->sc_ah), ATH_DBG_RESET,
353 "tx hung, resetting the chip\n");
354 + spin_lock_bh(&sc->sc_pcu_lock);
356 + spin_unlock_bh(&sc->sc_pcu_lock);
359 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work,
360 --- a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
361 +++ b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
362 @@ -236,7 +236,7 @@ static void ar9003_paprd_get_gain_table(
363 memset(entry, 0, sizeof(ah->paprd_gain_table_entries));
364 memset(index, 0, sizeof(ah->paprd_gain_table_index));
366 - for (i = 0; i < 32; i++) {
367 + for (i = 0; i < PAPRD_GAIN_TABLE_ENTRIES; i++) {
368 entry[i] = REG_READ(ah, reg);
369 index[i] = (entry[i] >> 24) & 0xff;
371 @@ -246,13 +246,13 @@ static void ar9003_paprd_get_gain_table(
372 static unsigned int ar9003_get_desired_gain(struct ath_hw *ah, int chain,
375 - int olpc_gain_delta = 0;
376 + int olpc_gain_delta = 0, cl_gain_mod;
377 int alpha_therm, alpha_volt;
378 int therm_cal_value, volt_cal_value;
379 int therm_value, volt_value;
380 int thermal_gain_corr, voltage_gain_corr;
381 int desired_scale, desired_gain = 0;
383 + u32 reg_olpc = 0, reg_cl_gain = 0;
385 REG_CLR_BIT(ah, AR_PHY_PAPRD_TRAINER_STAT1,
386 AR_PHY_PAPRD_TRAINER_STAT1_PAPRD_TRAIN_DONE);
387 @@ -271,15 +271,29 @@ static unsigned int ar9003_get_desired_g
388 volt_value = REG_READ_FIELD(ah, AR_PHY_BB_THERM_ADC_4,
389 AR_PHY_BB_THERM_ADC_4_LATEST_VOLT_VALUE);
392 - reg = AR_PHY_TPC_11_B0;
393 - else if (chain == 1)
394 - reg = AR_PHY_TPC_11_B1;
396 - reg = AR_PHY_TPC_11_B2;
399 + reg_olpc = AR_PHY_TPC_11_B0;
400 + reg_cl_gain = AR_PHY_CL_TAB_0;
403 + reg_olpc = AR_PHY_TPC_11_B1;
404 + reg_cl_gain = AR_PHY_CL_TAB_1;
407 + reg_olpc = AR_PHY_TPC_11_B2;
408 + reg_cl_gain = AR_PHY_CL_TAB_2;
411 + ath_dbg(ath9k_hw_common(ah), ATH_DBG_CALIBRATE,
412 + "Invalid chainmask: %d\n", chain);
416 - olpc_gain_delta = REG_READ_FIELD(ah, reg,
417 + olpc_gain_delta = REG_READ_FIELD(ah, reg_olpc,
418 AR_PHY_TPC_11_OLPC_GAIN_DELTA);
419 + cl_gain_mod = REG_READ_FIELD(ah, reg_cl_gain,
420 + AR_PHY_CL_TAB_CL_GAIN_MOD);
422 if (olpc_gain_delta >= 128)
423 olpc_gain_delta = olpc_gain_delta - 256;
424 @@ -289,7 +303,7 @@ static unsigned int ar9003_get_desired_g
425 voltage_gain_corr = (alpha_volt * (volt_value - volt_cal_value) +
427 desired_gain = target_power - olpc_gain_delta - thermal_gain_corr -
428 - voltage_gain_corr + desired_scale;
429 + voltage_gain_corr + desired_scale + cl_gain_mod;
433 @@ -727,7 +741,7 @@ int ar9003_paprd_setup_gain_table(struct
434 desired_gain = ar9003_get_desired_gain(ah, chain, train_power);
437 - for (i = 0; i < 32; i++) {
438 + for (i = 0; i < PAPRD_GAIN_TABLE_ENTRIES; i++) {
439 if (ah->paprd_gain_table_index[i] >= desired_gain)
442 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h
443 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
444 @@ -1121,6 +1121,9 @@
445 #define AR_PHY_POWERTX_RATE8_POWERTXHT40_5 0x3F00
446 #define AR_PHY_POWERTX_RATE8_POWERTXHT40_5_S 8
448 +#define AR_PHY_CL_TAB_CL_GAIN_MOD 0x1f
449 +#define AR_PHY_CL_TAB_CL_GAIN_MOD_S 0
451 void ar9003_hw_set_chain_masks(struct ath_hw *ah, u8 rx, u8 tx);
453 #endif /* AR9003_PHY_H */