aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2014-01-17 20:30:55 -0500
committerDavid S. Miller <davem@davemloft.net>2014-01-17 20:30:55 -0500
commitd037c4d70fb281cd54efb03254b51c7452750491 (patch)
tree119c5bb9e513c8205efed485c2dc7b8271123326 /net
parentcf84eb0b09c0f09b4c70a648b9dfeec78be61f07 (diff)
parent7916a075571f0ccd0830cf3da293188a8b6045e3 (diff)
Merge branch 'for-davem' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next
John W. Linville says: ==================== Please pull this batch of updates for the 3.14 stream! For the mac80211 bits, Johannes says: "This time I have uAPSD fixes since I was working on that, hwsim improvements to make dynamic radios possible for the test suite, the evidently long-overdue channel_change_time removal and a few other small collected fix and improvements." For the iwlwifi bits, Emmanuel says: "Besides a few trivial patches, I have an important workaround for a HW issue that has kept me busy for a long time. Along with it, a fix that prevents an error from being printed. Eyal fixes our behavior against SISO APs and Ilan fixes an issue with multiple interface scenarios. Eliad fixes an error path in our init flow. We also have a few 'static analyzers' fix." For the NFC bits, Samuel says: "It includes: * A new NFC driver for Marvell's 8897, and a few NCI fixes and improvements needed to support this chipset. * An LLCP fix for how we were setting the default MIU on a p2p link. If there is no explicit MIU extension announced at connection time, we must use the default one and not the one announced at LLCP link establishement time. * A pn544 EEPROM config update. Some of the currently EEPROM configured values are overwriting the firmware ones while other should not be set by the driver itself. * Some NFC digital stack fixes and improvements. Asynchronous functions are better documented, RF technologies and CRC functions are set upon PSL_REQ reception, and a few minor bugs are fixed. * Minor and miscelaneous pn533, mei_phy and port100 fixes." For the ath bits, Kalle says: "Janusz added Kconfig option for DFS. The DFS code was there already, but after fixes to mac80211 we can now enable it. Bartosz added a runtime firmware feature flag to disable P2P. Our 10.1 firmware branch doesn't support P2P and ath10k can now disable that. He also added a limit for how many clients can connect to ath10k AP. Michal fixed WEP shared authentication, in case someone still uses it. And I added firmware debug log to help the firmware engineers." Along with that is a small batch of ath9k updates and a few other bits here and there. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/mac80211/cfg.c3
-rw-r--r--net/mac80211/debugfs_netdev.c61
-rw-r--r--net/mac80211/ht.c5
-rw-r--r--net/mac80211/ieee80211_i.h2
-rw-r--r--net/mac80211/main.c22
-rw-r--r--net/mac80211/mesh.c1
-rw-r--r--net/mac80211/mesh_plink.c1
-rw-r--r--net/mac80211/rx.c40
-rw-r--r--net/mac80211/sta_info.c238
-rw-r--r--net/mac80211/trace.h27
-rw-r--r--net/mac80211/tx.c2
-rw-r--r--net/mac80211/util.c41
-rw-r--r--net/mac80211/wpa.c2
-rw-r--r--net/nfc/core.c7
-rw-r--r--net/nfc/digital_core.c28
-rw-r--r--net/nfc/digital_dep.c54
-rw-r--r--net/nfc/hci/core.c7
-rw-r--r--net/nfc/llcp_commands.c6
-rw-r--r--net/nfc/llcp_core.c1
-rw-r--r--net/nfc/llcp_sock.c1
-rw-r--r--net/nfc/nci/core.c27
-rw-r--r--net/wireless/nl80211.c111
-rw-r--r--net/wireless/reg.c2
-rw-r--r--net/wireless/scan.c7
-rw-r--r--net/wireless/sme.c13
-rw-r--r--net/wireless/util.c15
-rw-r--r--net/wireless/wext-compat.c6
27 files changed, 462 insertions, 268 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 09d2e58a2ba7..f9ae9b85d4c1 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1035,6 +1035,7 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
1035 return err; 1035 return err;
1036 } 1036 }
1037 1037
1038 ieee80211_recalc_dtim(local, sdata);
1038 ieee80211_bss_info_change_notify(sdata, changed); 1039 ieee80211_bss_info_change_notify(sdata, changed);
1039 1040
1040 netif_carrier_on(dev); 1041 netif_carrier_on(dev);
@@ -3854,7 +3855,7 @@ static int ieee80211_set_qos_map(struct wiphy *wiphy,
3854 new_qos_map = NULL; 3855 new_qos_map = NULL;
3855 } 3856 }
3856 3857
3857 old_qos_map = rtnl_dereference(sdata->qos_map); 3858 old_qos_map = sdata_dereference(sdata->qos_map, sdata);
3858 rcu_assign_pointer(sdata->qos_map, new_qos_map); 3859 rcu_assign_pointer(sdata->qos_map, new_qos_map);
3859 if (old_qos_map) 3860 if (old_qos_map)
3860 kfree_rcu(old_qos_map, rcu_head); 3861 kfree_rcu(old_qos_map, rcu_head);
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c
index 04b5a14c8a05..ebf80f3abd83 100644
--- a/net/mac80211/debugfs_netdev.c
+++ b/net/mac80211/debugfs_netdev.c
@@ -133,7 +133,15 @@ static ssize_t ieee80211_if_fmt_##name( \
133 jiffies_to_msecs(sdata->field)); \ 133 jiffies_to_msecs(sdata->field)); \
134} 134}
135 135
136#define __IEEE80211_IF_FILE(name, _write) \ 136#define _IEEE80211_IF_FILE_OPS(name, _read, _write) \
137static const struct file_operations name##_ops = { \
138 .read = (_read), \
139 .write = (_write), \
140 .open = simple_open, \
141 .llseek = generic_file_llseek, \
142}
143
144#define _IEEE80211_IF_FILE_R_FN(name) \
137static ssize_t ieee80211_if_read_##name(struct file *file, \ 145static ssize_t ieee80211_if_read_##name(struct file *file, \
138 char __user *userbuf, \ 146 char __user *userbuf, \
139 size_t count, loff_t *ppos) \ 147 size_t count, loff_t *ppos) \
@@ -141,28 +149,34 @@ static ssize_t ieee80211_if_read_##name(struct file *file, \
141 return ieee80211_if_read(file->private_data, \ 149 return ieee80211_if_read(file->private_data, \
142 userbuf, count, ppos, \ 150 userbuf, count, ppos, \
143 ieee80211_if_fmt_##name); \ 151 ieee80211_if_fmt_##name); \
144} \
145static const struct file_operations name##_ops = { \
146 .read = ieee80211_if_read_##name, \
147 .write = (_write), \
148 .open = simple_open, \
149 .llseek = generic_file_llseek, \
150} 152}
151 153
152#define __IEEE80211_IF_FILE_W(name) \ 154#define _IEEE80211_IF_FILE_W_FN(name) \
153static ssize_t ieee80211_if_write_##name(struct file *file, \ 155static ssize_t ieee80211_if_write_##name(struct file *file, \
154 const char __user *userbuf, \ 156 const char __user *userbuf, \
155 size_t count, loff_t *ppos) \ 157 size_t count, loff_t *ppos) \
156{ \ 158{ \
157 return ieee80211_if_write(file->private_data, userbuf, count, \ 159 return ieee80211_if_write(file->private_data, userbuf, count, \
158 ppos, ieee80211_if_parse_##name); \ 160 ppos, ieee80211_if_parse_##name); \
159} \ 161}
160__IEEE80211_IF_FILE(name, ieee80211_if_write_##name) 162
163#define IEEE80211_IF_FILE_R(name) \
164 _IEEE80211_IF_FILE_R_FN(name) \
165 _IEEE80211_IF_FILE_OPS(name, ieee80211_if_read_##name, NULL)
166
167#define IEEE80211_IF_FILE_W(name) \
168 _IEEE80211_IF_FILE_W_FN(name) \
169 _IEEE80211_IF_FILE_OPS(name, NULL, ieee80211_if_write_##name)
161 170
171#define IEEE80211_IF_FILE_RW(name) \
172 _IEEE80211_IF_FILE_R_FN(name) \
173 _IEEE80211_IF_FILE_W_FN(name) \
174 _IEEE80211_IF_FILE_OPS(name, ieee80211_if_read_##name, \
175 ieee80211_if_write_##name)
162 176
163#define IEEE80211_IF_FILE(name, field, format) \ 177#define IEEE80211_IF_FILE(name, field, format) \
164 IEEE80211_IF_FMT_##format(name, field) \ 178 IEEE80211_IF_FMT_##format(name, field) \
165 __IEEE80211_IF_FILE(name, NULL) 179 IEEE80211_IF_FILE_R(name)
166 180
167/* common attributes */ 181/* common attributes */
168IEEE80211_IF_FILE(drop_unencrypted, drop_unencrypted, DEC); 182IEEE80211_IF_FILE(drop_unencrypted, drop_unencrypted, DEC);
@@ -199,7 +213,7 @@ ieee80211_if_fmt_hw_queues(const struct ieee80211_sub_if_data *sdata,
199 213
200 return len; 214 return len;
201} 215}
202__IEEE80211_IF_FILE(hw_queues, NULL); 216IEEE80211_IF_FILE_R(hw_queues);
203 217
204/* STA attributes */ 218/* STA attributes */
205IEEE80211_IF_FILE(bssid, u.mgd.bssid, MAC); 219IEEE80211_IF_FILE(bssid, u.mgd.bssid, MAC);
@@ -275,14 +289,7 @@ static ssize_t ieee80211_if_parse_smps(struct ieee80211_sub_if_data *sdata,
275 289
276 return -EINVAL; 290 return -EINVAL;
277} 291}
278 292IEEE80211_IF_FILE_RW(smps);
279__IEEE80211_IF_FILE_W(smps);
280
281static ssize_t ieee80211_if_fmt_tkip_mic_test(
282 const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
283{
284 return -EOPNOTSUPP;
285}
286 293
287static ssize_t ieee80211_if_parse_tkip_mic_test( 294static ssize_t ieee80211_if_parse_tkip_mic_test(
288 struct ieee80211_sub_if_data *sdata, const char *buf, int buflen) 295 struct ieee80211_sub_if_data *sdata, const char *buf, int buflen)
@@ -349,8 +356,7 @@ static ssize_t ieee80211_if_parse_tkip_mic_test(
349 356
350 return buflen; 357 return buflen;
351} 358}
352 359IEEE80211_IF_FILE_W(tkip_mic_test);
353__IEEE80211_IF_FILE_W(tkip_mic_test);
354 360
355static ssize_t ieee80211_if_fmt_uapsd_queues( 361static ssize_t ieee80211_if_fmt_uapsd_queues(
356 const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) 362 const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
@@ -378,7 +384,7 @@ static ssize_t ieee80211_if_parse_uapsd_queues(
378 384
379 return buflen; 385 return buflen;
380} 386}
381__IEEE80211_IF_FILE_W(uapsd_queues); 387IEEE80211_IF_FILE_RW(uapsd_queues);
382 388
383static ssize_t ieee80211_if_fmt_uapsd_max_sp_len( 389static ssize_t ieee80211_if_fmt_uapsd_max_sp_len(
384 const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) 390 const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
@@ -406,7 +412,7 @@ static ssize_t ieee80211_if_parse_uapsd_max_sp_len(
406 412
407 return buflen; 413 return buflen;
408} 414}
409__IEEE80211_IF_FILE_W(uapsd_max_sp_len); 415IEEE80211_IF_FILE_RW(uapsd_max_sp_len);
410 416
411/* AP attributes */ 417/* AP attributes */
412IEEE80211_IF_FILE(num_mcast_sta, u.ap.num_mcast_sta, ATOMIC); 418IEEE80211_IF_FILE(num_mcast_sta, u.ap.num_mcast_sta, ATOMIC);
@@ -419,7 +425,7 @@ static ssize_t ieee80211_if_fmt_num_buffered_multicast(
419 return scnprintf(buf, buflen, "%u\n", 425 return scnprintf(buf, buflen, "%u\n",
420 skb_queue_len(&sdata->u.ap.ps.bc_buf)); 426 skb_queue_len(&sdata->u.ap.ps.bc_buf));
421} 427}
422__IEEE80211_IF_FILE(num_buffered_multicast, NULL); 428IEEE80211_IF_FILE_R(num_buffered_multicast);
423 429
424/* IBSS attributes */ 430/* IBSS attributes */
425static ssize_t ieee80211_if_fmt_tsf( 431static ssize_t ieee80211_if_fmt_tsf(
@@ -468,9 +474,10 @@ static ssize_t ieee80211_if_parse_tsf(
468 } 474 }
469 } 475 }
470 476
477 ieee80211_recalc_dtim(local, sdata);
471 return buflen; 478 return buflen;
472} 479}
473__IEEE80211_IF_FILE_W(tsf); 480IEEE80211_IF_FILE_RW(tsf);
474 481
475 482
476/* WDS attributes */ 483/* WDS attributes */
diff --git a/net/mac80211/ht.c b/net/mac80211/ht.c
index 9a8be8f69224..fab7b91923e0 100644
--- a/net/mac80211/ht.c
+++ b/net/mac80211/ht.c
@@ -479,10 +479,9 @@ void ieee80211_request_smps(struct ieee80211_vif *vif,
479 vif->type != NL80211_IFTYPE_AP)) 479 vif->type != NL80211_IFTYPE_AP))
480 return; 480 return;
481 481
482 if (WARN_ON(smps_mode == IEEE80211_SMPS_OFF))
483 smps_mode = IEEE80211_SMPS_AUTOMATIC;
484
485 if (vif->type == NL80211_IFTYPE_STATION) { 482 if (vif->type == NL80211_IFTYPE_STATION) {
483 if (WARN_ON(smps_mode == IEEE80211_SMPS_OFF))
484 smps_mode = IEEE80211_SMPS_AUTOMATIC;
486 if (sdata->u.mgd.driver_smps_mode == smps_mode) 485 if (sdata->u.mgd.driver_smps_mode == smps_mode)
487 return; 486 return;
488 sdata->u.mgd.driver_smps_mode = smps_mode; 487 sdata->u.mgd.driver_smps_mode = smps_mode;
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 953b9e294547..3701930c6649 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1800,6 +1800,8 @@ ieee80211_cs_get(struct ieee80211_local *local, u32 cipher,
1800int ieee80211_cs_headroom(struct ieee80211_local *local, 1800int ieee80211_cs_headroom(struct ieee80211_local *local,
1801 struct cfg80211_crypto_settings *crypto, 1801 struct cfg80211_crypto_settings *crypto,
1802 enum nl80211_iftype iftype); 1802 enum nl80211_iftype iftype);
1803void ieee80211_recalc_dtim(struct ieee80211_local *local,
1804 struct ieee80211_sub_if_data *sdata);
1803 1805
1804#ifdef CONFIG_MAC80211_NOINLINE 1806#ifdef CONFIG_MAC80211_NOINLINE
1805#define debug_noinline noinline 1807#define debug_noinline noinline
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 2bd5b552b2f6..d767cfb9b45f 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -846,17 +846,6 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
846 /* TODO: consider VHT for RX chains, hopefully it's the same */ 846 /* TODO: consider VHT for RX chains, hopefully it's the same */
847 } 847 }
848 848
849 local->int_scan_req = kzalloc(sizeof(*local->int_scan_req) +
850 sizeof(void *) * channels, GFP_KERNEL);
851 if (!local->int_scan_req)
852 return -ENOMEM;
853
854 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
855 if (!local->hw.wiphy->bands[band])
856 continue;
857 local->int_scan_req->rates[band] = (u32) -1;
858 }
859
860 /* if low-level driver supports AP, we also support VLAN */ 849 /* if low-level driver supports AP, we also support VLAN */
861 if (local->hw.wiphy->interface_modes & BIT(NL80211_IFTYPE_AP)) { 850 if (local->hw.wiphy->interface_modes & BIT(NL80211_IFTYPE_AP)) {
862 hw->wiphy->interface_modes |= BIT(NL80211_IFTYPE_AP_VLAN); 851 hw->wiphy->interface_modes |= BIT(NL80211_IFTYPE_AP_VLAN);
@@ -880,6 +869,17 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
880 return -EINVAL; 869 return -EINVAL;
881 } 870 }
882 871
872 local->int_scan_req = kzalloc(sizeof(*local->int_scan_req) +
873 sizeof(void *) * channels, GFP_KERNEL);
874 if (!local->int_scan_req)
875 return -ENOMEM;
876
877 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
878 if (!local->hw.wiphy->bands[band])
879 continue;
880 local->int_scan_req->rates[band] = (u32) -1;
881 }
882
883#ifndef CONFIG_MAC80211_MESH 883#ifndef CONFIG_MAC80211_MESH
884 /* mesh depends on Kconfig, but drivers should set it if they want */ 884 /* mesh depends on Kconfig, but drivers should set it if they want */
885 local->hw.wiphy->interface_modes &= ~BIT(NL80211_IFTYPE_MESH_POINT); 885 local->hw.wiphy->interface_modes &= ~BIT(NL80211_IFTYPE_MESH_POINT);
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 5a74b249ba35..5b919cab1de0 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -807,6 +807,7 @@ int ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata)
807 return -ENOMEM; 807 return -ENOMEM;
808 } 808 }
809 809
810 ieee80211_recalc_dtim(local, sdata);
810 ieee80211_bss_info_change_notify(sdata, changed); 811 ieee80211_bss_info_change_notify(sdata, changed);
811 812
812 netif_carrier_on(sdata->dev); 813 netif_carrier_on(sdata->dev);
diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
index cf83217103f9..e8f60aa2e848 100644
--- a/net/mac80211/mesh_plink.c
+++ b/net/mac80211/mesh_plink.c
@@ -437,6 +437,7 @@ __mesh_sta_info_alloc(struct ieee80211_sub_if_data *sdata, u8 *hw_addr)
437 sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED); 437 sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
438 438
439 set_sta_flag(sta, WLAN_STA_WME); 439 set_sta_flag(sta, WLAN_STA_WME);
440 sta->sta.wme = true;
440 441
441 return sta; 442 return sta;
442} 443}
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 5a2afe9583a8..c24ca0d0f469 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -3076,8 +3076,8 @@ void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid)
3076 3076
3077/* main receive path */ 3077/* main receive path */
3078 3078
3079static int prepare_for_handlers(struct ieee80211_rx_data *rx, 3079static bool prepare_for_handlers(struct ieee80211_rx_data *rx,
3080 struct ieee80211_hdr *hdr) 3080 struct ieee80211_hdr *hdr)
3081{ 3081{
3082 struct ieee80211_sub_if_data *sdata = rx->sdata; 3082 struct ieee80211_sub_if_data *sdata = rx->sdata;
3083 struct sk_buff *skb = rx->skb; 3083 struct sk_buff *skb = rx->skb;
@@ -3088,29 +3088,29 @@ static int prepare_for_handlers(struct ieee80211_rx_data *rx,
3088 switch (sdata->vif.type) { 3088 switch (sdata->vif.type) {
3089 case NL80211_IFTYPE_STATION: 3089 case NL80211_IFTYPE_STATION:
3090 if (!bssid && !sdata->u.mgd.use_4addr) 3090 if (!bssid && !sdata->u.mgd.use_4addr)
3091 return 0; 3091 return false;
3092 if (!multicast && 3092 if (!multicast &&
3093 !ether_addr_equal(sdata->vif.addr, hdr->addr1)) { 3093 !ether_addr_equal(sdata->vif.addr, hdr->addr1)) {
3094 if (!(sdata->dev->flags & IFF_PROMISC) || 3094 if (!(sdata->dev->flags & IFF_PROMISC) ||
3095 sdata->u.mgd.use_4addr) 3095 sdata->u.mgd.use_4addr)
3096 return 0; 3096 return false;
3097 status->rx_flags &= ~IEEE80211_RX_RA_MATCH; 3097 status->rx_flags &= ~IEEE80211_RX_RA_MATCH;
3098 } 3098 }
3099 break; 3099 break;
3100 case NL80211_IFTYPE_ADHOC: 3100 case NL80211_IFTYPE_ADHOC:
3101 if (!bssid) 3101 if (!bssid)
3102 return 0; 3102 return false;
3103 if (ether_addr_equal(sdata->vif.addr, hdr->addr2) || 3103 if (ether_addr_equal(sdata->vif.addr, hdr->addr2) ||
3104 ether_addr_equal(sdata->u.ibss.bssid, hdr->addr2)) 3104 ether_addr_equal(sdata->u.ibss.bssid, hdr->addr2))
3105 return 0; 3105 return false;
3106 if (ieee80211_is_beacon(hdr->frame_control)) { 3106 if (ieee80211_is_beacon(hdr->frame_control)) {
3107 return 1; 3107 return true;
3108 } else if (!ieee80211_bssid_match(bssid, sdata->u.ibss.bssid)) { 3108 } else if (!ieee80211_bssid_match(bssid, sdata->u.ibss.bssid)) {
3109 return 0; 3109 return false;
3110 } else if (!multicast && 3110 } else if (!multicast &&
3111 !ether_addr_equal(sdata->vif.addr, hdr->addr1)) { 3111 !ether_addr_equal(sdata->vif.addr, hdr->addr1)) {
3112 if (!(sdata->dev->flags & IFF_PROMISC)) 3112 if (!(sdata->dev->flags & IFF_PROMISC))
3113 return 0; 3113 return false;
3114 status->rx_flags &= ~IEEE80211_RX_RA_MATCH; 3114 status->rx_flags &= ~IEEE80211_RX_RA_MATCH;
3115 } else if (!rx->sta) { 3115 } else if (!rx->sta) {
3116 int rate_idx; 3116 int rate_idx;
@@ -3126,7 +3126,7 @@ static int prepare_for_handlers(struct ieee80211_rx_data *rx,
3126 if (!multicast && 3126 if (!multicast &&
3127 !ether_addr_equal(sdata->vif.addr, hdr->addr1)) { 3127 !ether_addr_equal(sdata->vif.addr, hdr->addr1)) {
3128 if (!(sdata->dev->flags & IFF_PROMISC)) 3128 if (!(sdata->dev->flags & IFF_PROMISC))
3129 return 0; 3129 return false;
3130 3130
3131 status->rx_flags &= ~IEEE80211_RX_RA_MATCH; 3131 status->rx_flags &= ~IEEE80211_RX_RA_MATCH;
3132 } 3132 }
@@ -3135,7 +3135,7 @@ static int prepare_for_handlers(struct ieee80211_rx_data *rx,
3135 case NL80211_IFTYPE_AP: 3135 case NL80211_IFTYPE_AP:
3136 if (!bssid) { 3136 if (!bssid) {
3137 if (!ether_addr_equal(sdata->vif.addr, hdr->addr1)) 3137 if (!ether_addr_equal(sdata->vif.addr, hdr->addr1))
3138 return 0; 3138 return false;
3139 } else if (!ieee80211_bssid_match(bssid, sdata->vif.addr)) { 3139 } else if (!ieee80211_bssid_match(bssid, sdata->vif.addr)) {
3140 /* 3140 /*
3141 * Accept public action frames even when the 3141 * Accept public action frames even when the
@@ -3145,26 +3145,26 @@ static int prepare_for_handlers(struct ieee80211_rx_data *rx,
3145 */ 3145 */
3146 if (!multicast && 3146 if (!multicast &&
3147 !ether_addr_equal(sdata->vif.addr, hdr->addr1)) 3147 !ether_addr_equal(sdata->vif.addr, hdr->addr1))
3148 return 0; 3148 return false;
3149 if (ieee80211_is_public_action(hdr, skb->len)) 3149 if (ieee80211_is_public_action(hdr, skb->len))
3150 return 1; 3150 return true;
3151 if (!ieee80211_is_beacon(hdr->frame_control)) 3151 if (!ieee80211_is_beacon(hdr->frame_control))
3152 return 0; 3152 return false;
3153 status->rx_flags &= ~IEEE80211_RX_RA_MATCH; 3153 status->rx_flags &= ~IEEE80211_RX_RA_MATCH;
3154 } 3154 }
3155 break; 3155 break;
3156 case NL80211_IFTYPE_WDS: 3156 case NL80211_IFTYPE_WDS:
3157 if (bssid || !ieee80211_is_data(hdr->frame_control)) 3157 if (bssid || !ieee80211_is_data(hdr->frame_control))
3158 return 0; 3158 return false;
3159 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2)) 3159 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
3160 return 0; 3160 return false;
3161 break; 3161 break;
3162 case NL80211_IFTYPE_P2P_DEVICE: 3162 case NL80211_IFTYPE_P2P_DEVICE:
3163 if (!ieee80211_is_public_action(hdr, skb->len) && 3163 if (!ieee80211_is_public_action(hdr, skb->len) &&
3164 !ieee80211_is_probe_req(hdr->frame_control) && 3164 !ieee80211_is_probe_req(hdr->frame_control) &&
3165 !ieee80211_is_probe_resp(hdr->frame_control) && 3165 !ieee80211_is_probe_resp(hdr->frame_control) &&
3166 !ieee80211_is_beacon(hdr->frame_control)) 3166 !ieee80211_is_beacon(hdr->frame_control))
3167 return 0; 3167 return false;
3168 if (!ether_addr_equal(sdata->vif.addr, hdr->addr1) && 3168 if (!ether_addr_equal(sdata->vif.addr, hdr->addr1) &&
3169 !multicast) 3169 !multicast)
3170 status->rx_flags &= ~IEEE80211_RX_RA_MATCH; 3170 status->rx_flags &= ~IEEE80211_RX_RA_MATCH;
@@ -3175,7 +3175,7 @@ static int prepare_for_handlers(struct ieee80211_rx_data *rx,
3175 break; 3175 break;
3176 } 3176 }
3177 3177
3178 return 1; 3178 return true;
3179} 3179}
3180 3180
3181/* 3181/*
@@ -3191,13 +3191,11 @@ static bool ieee80211_prepare_and_rx_handle(struct ieee80211_rx_data *rx,
3191 struct ieee80211_sub_if_data *sdata = rx->sdata; 3191 struct ieee80211_sub_if_data *sdata = rx->sdata;
3192 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); 3192 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
3193 struct ieee80211_hdr *hdr = (void *)skb->data; 3193 struct ieee80211_hdr *hdr = (void *)skb->data;
3194 int prepares;
3195 3194
3196 rx->skb = skb; 3195 rx->skb = skb;
3197 status->rx_flags |= IEEE80211_RX_RA_MATCH; 3196 status->rx_flags |= IEEE80211_RX_RA_MATCH;
3198 prepares = prepare_for_handlers(rx, hdr);
3199 3197
3200 if (!prepares) 3198 if (!prepare_for_handlers(rx, hdr))
3201 return false; 3199 return false;
3202 3200
3203 if (!consume) { 3201 if (!consume) {
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 4576ba0ff221..decd30c1e290 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -300,6 +300,35 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
300 if (!sta) 300 if (!sta)
301 return NULL; 301 return NULL;
302 302
303 rcu_read_lock();
304 tx_latency = rcu_dereference(local->tx_latency);
305 /* init stations Tx latency statistics && TID bins */
306 if (tx_latency) {
307 sta->tx_lat = kzalloc(IEEE80211_NUM_TIDS *
308 sizeof(struct ieee80211_tx_latency_stat),
309 GFP_ATOMIC);
310 if (!sta->tx_lat) {
311 rcu_read_unlock();
312 goto free;
313 }
314
315 if (tx_latency->n_ranges) {
316 for (i = 0; i < IEEE80211_NUM_TIDS; i++) {
317 /* size of bins is size of the ranges +1 */
318 sta->tx_lat[i].bin_count =
319 tx_latency->n_ranges + 1;
320 sta->tx_lat[i].bins =
321 kcalloc(sta->tx_lat[i].bin_count,
322 sizeof(u32), GFP_ATOMIC);
323 if (!sta->tx_lat[i].bins) {
324 rcu_read_unlock();
325 goto free;
326 }
327 }
328 }
329 }
330 rcu_read_unlock();
331
303 spin_lock_init(&sta->lock); 332 spin_lock_init(&sta->lock);
304 INIT_WORK(&sta->drv_unblock_wk, sta_unblock); 333 INIT_WORK(&sta->drv_unblock_wk, sta_unblock);
305 INIT_WORK(&sta->ampdu_mlme.work, ieee80211_ba_session_work); 334 INIT_WORK(&sta->ampdu_mlme.work, ieee80211_ba_session_work);
@@ -324,10 +353,8 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
324 for (i = 0; i < ARRAY_SIZE(sta->chain_signal_avg); i++) 353 for (i = 0; i < ARRAY_SIZE(sta->chain_signal_avg); i++)
325 ewma_init(&sta->chain_signal_avg[i], 1024, 8); 354 ewma_init(&sta->chain_signal_avg[i], 1024, 8);
326 355
327 if (sta_prepare_rate_control(local, sta, gfp)) { 356 if (sta_prepare_rate_control(local, sta, gfp))
328 kfree(sta); 357 goto free;
329 return NULL;
330 }
331 358
332 for (i = 0; i < IEEE80211_NUM_TIDS; i++) { 359 for (i = 0; i < IEEE80211_NUM_TIDS; i++) {
333 /* 360 /*
@@ -371,34 +398,17 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
371 } 398 }
372 } 399 }
373 400
374 rcu_read_lock();
375
376 tx_latency = rcu_dereference(local->tx_latency);
377 /* init stations Tx latency statistics && TID bins */
378 if (tx_latency)
379 sta->tx_lat = kzalloc(IEEE80211_NUM_TIDS *
380 sizeof(struct ieee80211_tx_latency_stat),
381 GFP_ATOMIC);
382
383 /*
384 * if Tx latency and bins are enabled and the previous allocation
385 * succeeded
386 */
387 if (tx_latency && tx_latency->n_ranges && sta->tx_lat)
388 for (i = 0; i < IEEE80211_NUM_TIDS; i++) {
389 /* size of bins is size of the ranges +1 */
390 sta->tx_lat[i].bin_count =
391 tx_latency->n_ranges + 1;
392 sta->tx_lat[i].bins = kcalloc(sta->tx_lat[i].bin_count,
393 sizeof(u32),
394 GFP_ATOMIC);
395 }
396
397 rcu_read_unlock();
398
399 sta_dbg(sdata, "Allocated STA %pM\n", sta->sta.addr); 401 sta_dbg(sdata, "Allocated STA %pM\n", sta->sta.addr);
400
401 return sta; 402 return sta;
403
404free:
405 if (sta->tx_lat) {
406 for (i = 0; i < IEEE80211_NUM_TIDS; i++)
407 kfree(sta->tx_lat[i].bins);
408 kfree(sta->tx_lat);
409 }
410 kfree(sta);
411 return NULL;
402} 412}
403 413
404static int sta_info_insert_check(struct sta_info *sta) 414static int sta_info_insert_check(struct sta_info *sta)
@@ -1143,7 +1153,8 @@ void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta)
1143 1153
1144static void ieee80211_send_null_response(struct ieee80211_sub_if_data *sdata, 1154static void ieee80211_send_null_response(struct ieee80211_sub_if_data *sdata,
1145 struct sta_info *sta, int tid, 1155 struct sta_info *sta, int tid,
1146 enum ieee80211_frame_release_type reason) 1156 enum ieee80211_frame_release_type reason,
1157 bool call_driver)
1147{ 1158{
1148 struct ieee80211_local *local = sdata->local; 1159 struct ieee80211_local *local = sdata->local;
1149 struct ieee80211_qos_hdr *nullfunc; 1160 struct ieee80211_qos_hdr *nullfunc;
@@ -1201,7 +1212,9 @@ static void ieee80211_send_null_response(struct ieee80211_sub_if_data *sdata,
1201 IEEE80211_TX_STATUS_EOSP | 1212 IEEE80211_TX_STATUS_EOSP |
1202 IEEE80211_TX_CTL_REQ_TX_STATUS; 1213 IEEE80211_TX_CTL_REQ_TX_STATUS;
1203 1214
1204 drv_allow_buffered_frames(local, sta, BIT(tid), 1, reason, false); 1215 if (call_driver)
1216 drv_allow_buffered_frames(local, sta, BIT(tid), 1,
1217 reason, false);
1205 1218
1206 skb->dev = sdata->dev; 1219 skb->dev = sdata->dev;
1207 1220
@@ -1217,6 +1230,17 @@ static void ieee80211_send_null_response(struct ieee80211_sub_if_data *sdata,
1217 rcu_read_unlock(); 1230 rcu_read_unlock();
1218} 1231}
1219 1232
1233static int find_highest_prio_tid(unsigned long tids)
1234{
1235 /* lower 3 TIDs aren't ordered perfectly */
1236 if (tids & 0xF8)
1237 return fls(tids) - 1;
1238 /* TID 0 is BE just like TID 3 */
1239 if (tids & BIT(0))
1240 return 0;
1241 return fls(tids) - 1;
1242}
1243
1220static void 1244static void
1221ieee80211_sta_ps_deliver_response(struct sta_info *sta, 1245ieee80211_sta_ps_deliver_response(struct sta_info *sta,
1222 int n_frames, u8 ignored_acs, 1246 int n_frames, u8 ignored_acs,
@@ -1224,7 +1248,6 @@ ieee80211_sta_ps_deliver_response(struct sta_info *sta,
1224{ 1248{
1225 struct ieee80211_sub_if_data *sdata = sta->sdata; 1249 struct ieee80211_sub_if_data *sdata = sta->sdata;
1226 struct ieee80211_local *local = sdata->local; 1250 struct ieee80211_local *local = sdata->local;
1227 bool found = false;
1228 bool more_data = false; 1251 bool more_data = false;
1229 int ac; 1252 int ac;
1230 unsigned long driver_release_tids = 0; 1253 unsigned long driver_release_tids = 0;
@@ -1235,9 +1258,7 @@ ieee80211_sta_ps_deliver_response(struct sta_info *sta,
1235 1258
1236 __skb_queue_head_init(&frames); 1259 __skb_queue_head_init(&frames);
1237 1260
1238 /* 1261 /* Get response frame(s) and more data bit for the last one. */
1239 * Get response frame(s) and more data bit for it.
1240 */
1241 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { 1262 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
1242 unsigned long tids; 1263 unsigned long tids;
1243 1264
@@ -1246,43 +1267,48 @@ ieee80211_sta_ps_deliver_response(struct sta_info *sta,
1246 1267
1247 tids = ieee80211_tids_for_ac(ac); 1268 tids = ieee80211_tids_for_ac(ac);
1248 1269
1249 if (!found) { 1270 /* if we already have frames from software, then we can't also
1250 driver_release_tids = sta->driver_buffered_tids & tids; 1271 * release from hardware queues
1251 if (driver_release_tids) { 1272 */
1252 found = true; 1273 if (skb_queue_empty(&frames))
1253 } else { 1274 driver_release_tids |= sta->driver_buffered_tids & tids;
1254 struct sk_buff *skb;
1255
1256 while (n_frames > 0) {
1257 skb = skb_dequeue(&sta->tx_filtered[ac]);
1258 if (!skb) {
1259 skb = skb_dequeue(
1260 &sta->ps_tx_buf[ac]);
1261 if (skb)
1262 local->total_ps_buffered--;
1263 }
1264 if (!skb)
1265 break;
1266 n_frames--;
1267 found = true;
1268 __skb_queue_tail(&frames, skb);
1269 }
1270 }
1271 1275
1272 /* 1276 if (driver_release_tids) {
1273 * If the driver has data on more than one TID then 1277 /* If the driver has data on more than one TID then
1274 * certainly there's more data if we release just a 1278 * certainly there's more data if we release just a
1275 * single frame now (from a single TID). 1279 * single frame now (from a single TID). This will
1280 * only happen for PS-Poll.
1276 */ 1281 */
1277 if (reason == IEEE80211_FRAME_RELEASE_PSPOLL && 1282 if (reason == IEEE80211_FRAME_RELEASE_PSPOLL &&
1278 hweight16(driver_release_tids) > 1) { 1283 hweight16(driver_release_tids) > 1) {
1279 more_data = true; 1284 more_data = true;
1280 driver_release_tids = 1285 driver_release_tids =
1281 BIT(ffs(driver_release_tids) - 1); 1286 BIT(find_highest_prio_tid(
1287 driver_release_tids));
1282 break; 1288 break;
1283 } 1289 }
1290 } else {
1291 struct sk_buff *skb;
1292
1293 while (n_frames > 0) {
1294 skb = skb_dequeue(&sta->tx_filtered[ac]);
1295 if (!skb) {
1296 skb = skb_dequeue(
1297 &sta->ps_tx_buf[ac]);
1298 if (skb)
1299 local->total_ps_buffered--;
1300 }
1301 if (!skb)
1302 break;
1303 n_frames--;
1304 __skb_queue_tail(&frames, skb);
1305 }
1284 } 1306 }
1285 1307
1308 /* If we have more frames buffered on this AC, then set the
1309 * more-data bit and abort the loop since we can't send more
1310 * data from other ACs before the buffered frames from this.
1311 */
1286 if (!skb_queue_empty(&sta->tx_filtered[ac]) || 1312 if (!skb_queue_empty(&sta->tx_filtered[ac]) ||
1287 !skb_queue_empty(&sta->ps_tx_buf[ac])) { 1313 !skb_queue_empty(&sta->ps_tx_buf[ac])) {
1288 more_data = true; 1314 more_data = true;
@@ -1290,7 +1316,7 @@ ieee80211_sta_ps_deliver_response(struct sta_info *sta,
1290 } 1316 }
1291 } 1317 }
1292 1318
1293 if (!found) { 1319 if (skb_queue_empty(&frames) && !driver_release_tids) {
1294 int tid; 1320 int tid;
1295 1321
1296 /* 1322 /*
@@ -1311,15 +1337,13 @@ ieee80211_sta_ps_deliver_response(struct sta_info *sta,
1311 /* This will evaluate to 1, 3, 5 or 7. */ 1337 /* This will evaluate to 1, 3, 5 or 7. */
1312 tid = 7 - ((ffs(~ignored_acs) - 1) << 1); 1338 tid = 7 - ((ffs(~ignored_acs) - 1) << 1);
1313 1339
1314 ieee80211_send_null_response(sdata, sta, tid, reason); 1340 ieee80211_send_null_response(sdata, sta, tid, reason, true);
1315 return; 1341 } else if (!driver_release_tids) {
1316 }
1317
1318 if (!driver_release_tids) {
1319 struct sk_buff_head pending; 1342 struct sk_buff_head pending;
1320 struct sk_buff *skb; 1343 struct sk_buff *skb;
1321 int num = 0; 1344 int num = 0;
1322 u16 tids = 0; 1345 u16 tids = 0;
1346 bool need_null = false;
1323 1347
1324 skb_queue_head_init(&pending); 1348 skb_queue_head_init(&pending);
1325 1349
@@ -1353,22 +1377,57 @@ ieee80211_sta_ps_deliver_response(struct sta_info *sta,
1353 ieee80211_is_qos_nullfunc(hdr->frame_control)) 1377 ieee80211_is_qos_nullfunc(hdr->frame_control))
1354 qoshdr = ieee80211_get_qos_ctl(hdr); 1378 qoshdr = ieee80211_get_qos_ctl(hdr);
1355 1379
1356 /* end service period after last frame */ 1380 tids |= BIT(skb->priority);
1357 if (skb_queue_empty(&frames)) { 1381
1358 if (reason == IEEE80211_FRAME_RELEASE_UAPSD && 1382 __skb_queue_tail(&pending, skb);
1359 qoshdr) 1383
1360 *qoshdr |= IEEE80211_QOS_CTL_EOSP; 1384 /* end service period after last frame or add one */
1385 if (!skb_queue_empty(&frames))
1386 continue;
1361 1387
1388 if (reason != IEEE80211_FRAME_RELEASE_UAPSD) {
1389 /* for PS-Poll, there's only one frame */
1362 info->flags |= IEEE80211_TX_STATUS_EOSP | 1390 info->flags |= IEEE80211_TX_STATUS_EOSP |
1363 IEEE80211_TX_CTL_REQ_TX_STATUS; 1391 IEEE80211_TX_CTL_REQ_TX_STATUS;
1392 break;
1364 } 1393 }
1365 1394
1366 if (qoshdr) 1395 /* For uAPSD, things are a bit more complicated. If the
1367 tids |= BIT(*qoshdr & IEEE80211_QOS_CTL_TID_MASK); 1396 * last frame has a QoS header (i.e. is a QoS-data or
1368 else 1397 * QoS-nulldata frame) then just set the EOSP bit there
1369 tids |= BIT(0); 1398 * and be done.
1399 * If the frame doesn't have a QoS header (which means
1400 * it should be a bufferable MMPDU) then we can't set
1401 * the EOSP bit in the QoS header; add a QoS-nulldata
1402 * frame to the list to send it after the MMPDU.
1403 *
1404 * Note that this code is only in the mac80211-release
1405 * code path, we assume that the driver will not buffer
1406 * anything but QoS-data frames, or if it does, will
1407 * create the QoS-nulldata frame by itself if needed.
1408 *
1409 * Cf. 802.11-2012 10.2.1.10 (c).
1410 */
1411 if (qoshdr) {
1412 *qoshdr |= IEEE80211_QOS_CTL_EOSP;
1370 1413
1371 __skb_queue_tail(&pending, skb); 1414 info->flags |= IEEE80211_TX_STATUS_EOSP |
1415 IEEE80211_TX_CTL_REQ_TX_STATUS;
1416 } else {
1417 /* The standard isn't completely clear on this
1418 * as it says the more-data bit should be set
1419 * if there are more BUs. The QoS-Null frame
1420 * we're about to send isn't buffered yet, we
1421 * only create it below, but let's pretend it
1422 * was buffered just in case some clients only
1423 * expect more-data=0 when eosp=1.
1424 */
1425 hdr->frame_control |=
1426 cpu_to_le16(IEEE80211_FCTL_MOREDATA);
1427 need_null = true;
1428 num++;
1429 }
1430 break;
1372 } 1431 }
1373 1432
1374 drv_allow_buffered_frames(local, sta, tids, num, 1433 drv_allow_buffered_frames(local, sta, tids, num,
@@ -1376,17 +1435,22 @@ ieee80211_sta_ps_deliver_response(struct sta_info *sta,
1376 1435
1377 ieee80211_add_pending_skbs(local, &pending); 1436 ieee80211_add_pending_skbs(local, &pending);
1378 1437
1438 if (need_null)
1439 ieee80211_send_null_response(
1440 sdata, sta, find_highest_prio_tid(tids),
1441 reason, false);
1442
1379 sta_info_recalc_tim(sta); 1443 sta_info_recalc_tim(sta);
1380 } else { 1444 } else {
1381 /* 1445 /*
1382 * We need to release a frame that is buffered somewhere in the 1446 * We need to release a frame that is buffered somewhere in the
1383 * driver ... it'll have to handle that. 1447 * driver ... it'll have to handle that.
1384 * Note that, as per the comment above, it'll also have to see 1448 * Note that the driver also has to check the number of frames
1385 * if there is more than just one frame on the specific TID that 1449 * on the TIDs we're releasing from - if there are more than
1386 * we're releasing from, and it needs to set the more-data bit 1450 * n_frames it has to set the more-data bit (if we didn't ask
1387 * accordingly if we tell it that there's no more data. If we do 1451 * it to set it anyway due to other buffered frames); if there
1388 * tell it there's more data, then of course the more-data bit 1452 * are fewer than n_frames it has to make sure to adjust that
1389 * needs to be set anyway. 1453 * to allow the service period to end properly.
1390 */ 1454 */
1391 drv_release_buffered_frames(local, sta, driver_release_tids, 1455 drv_release_buffered_frames(local, sta, driver_release_tids,
1392 n_frames, reason, more_data); 1456 n_frames, reason, more_data);
@@ -1394,9 +1458,9 @@ ieee80211_sta_ps_deliver_response(struct sta_info *sta,
1394 /* 1458 /*
1395 * Note that we don't recalculate the TIM bit here as it would 1459 * Note that we don't recalculate the TIM bit here as it would
1396 * most likely have no effect at all unless the driver told us 1460 * most likely have no effect at all unless the driver told us
1397 * that the TID became empty before returning here from the 1461 * that the TID(s) became empty before returning here from the
1398 * release function. 1462 * release function.
1399 * Either way, however, when the driver tells us that the TID 1463 * Either way, however, when the driver tells us that the TID(s)
1400 * became empty we'll do the TIM recalculation. 1464 * became empty we'll do the TIM recalculation.
1401 */ 1465 */
1402 } 1466 }
@@ -1485,6 +1549,8 @@ void ieee80211_sta_set_buffered(struct ieee80211_sta *pubsta,
1485 if (WARN_ON(tid >= IEEE80211_NUM_TIDS)) 1549 if (WARN_ON(tid >= IEEE80211_NUM_TIDS))
1486 return; 1550 return;
1487 1551
1552 trace_api_sta_set_buffered(sta->local, pubsta, tid, buffered);
1553
1488 if (buffered) 1554 if (buffered)
1489 set_bit(tid, &sta->driver_buffered_tids); 1555 set_bit(tid, &sta->driver_buffered_tids);
1490 else 1556 else
diff --git a/net/mac80211/trace.h b/net/mac80211/trace.h
index da9366632f37..a0b0aea76525 100644
--- a/net/mac80211/trace.h
+++ b/net/mac80211/trace.h
@@ -1835,6 +1835,33 @@ TRACE_EVENT(api_eosp,
1835 ) 1835 )
1836); 1836);
1837 1837
1838TRACE_EVENT(api_sta_set_buffered,
1839 TP_PROTO(struct ieee80211_local *local,
1840 struct ieee80211_sta *sta,
1841 u8 tid, bool buffered),
1842
1843 TP_ARGS(local, sta, tid, buffered),
1844
1845 TP_STRUCT__entry(
1846 LOCAL_ENTRY
1847 STA_ENTRY
1848 __field(u8, tid)
1849 __field(bool, buffered)
1850 ),
1851
1852 TP_fast_assign(
1853 LOCAL_ASSIGN;
1854 STA_ASSIGN;
1855 __entry->tid = tid;
1856 __entry->buffered = buffered;
1857 ),
1858
1859 TP_printk(
1860 LOCAL_PR_FMT STA_PR_FMT " tid:%d buffered:%d",
1861 LOCAL_PR_ARG, STA_PR_ARG, __entry->tid, __entry->buffered
1862 )
1863);
1864
1838/* 1865/*
1839 * Tracing for internal functions 1866 * Tracing for internal functions
1840 * (which may also be called in response to driver calls) 1867 * (which may also be called in response to driver calls)
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index ef3555e16cf9..27c990bf2320 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -490,6 +490,7 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx)
490 info->control.jiffies = jiffies; 490 info->control.jiffies = jiffies;
491 info->control.vif = &tx->sdata->vif; 491 info->control.vif = &tx->sdata->vif;
492 info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; 492 info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING;
493 info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS;
493 skb_queue_tail(&sta->ps_tx_buf[ac], tx->skb); 494 skb_queue_tail(&sta->ps_tx_buf[ac], tx->skb);
494 495
495 if (!timer_pending(&local->sta_cleanup)) 496 if (!timer_pending(&local->sta_cleanup))
@@ -1076,6 +1077,7 @@ static bool ieee80211_tx_prep_agg(struct ieee80211_tx_data *tx,
1076 queued = true; 1077 queued = true;
1077 info->control.vif = &tx->sdata->vif; 1078 info->control.vif = &tx->sdata->vif;
1078 info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; 1079 info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING;
1080 info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS;
1079 __skb_queue_tail(&tid_tx->pending, skb); 1081 __skb_queue_tail(&tid_tx->pending, skb);
1080 if (skb_queue_len(&tid_tx->pending) > STA_MAX_TX_BUFFER) 1082 if (skb_queue_len(&tid_tx->pending) > STA_MAX_TX_BUFFER)
1081 purge_skb = __skb_dequeue(&tid_tx->pending); 1083 purge_skb = __skb_dequeue(&tid_tx->pending);
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index df00f1978a77..676dc0967f37 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -2734,3 +2734,44 @@ int ieee80211_parse_p2p_noa(const struct ieee80211_p2p_noa_attr *attr,
2734 return ret; 2734 return ret;
2735} 2735}
2736EXPORT_SYMBOL(ieee80211_parse_p2p_noa); 2736EXPORT_SYMBOL(ieee80211_parse_p2p_noa);
2737
2738void ieee80211_recalc_dtim(struct ieee80211_local *local,
2739 struct ieee80211_sub_if_data *sdata)
2740{
2741 u64 tsf = drv_get_tsf(local, sdata);
2742 u64 dtim_count = 0;
2743 u16 beacon_int = sdata->vif.bss_conf.beacon_int * 1024;
2744 u8 dtim_period = sdata->vif.bss_conf.dtim_period;
2745 struct ps_data *ps;
2746 u8 bcns_from_dtim;
2747
2748 if (tsf == -1ULL || !beacon_int || !dtim_period)
2749 return;
2750
2751 if (sdata->vif.type == NL80211_IFTYPE_AP ||
2752 sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {
2753 if (!sdata->bss)
2754 return;
2755
2756 ps = &sdata->bss->ps;
2757 } else if (ieee80211_vif_is_mesh(&sdata->vif)) {
2758 ps = &sdata->u.mesh.ps;
2759 } else {
2760 return;
2761 }
2762
2763 /*
2764 * actually finds last dtim_count, mac80211 will update in
2765 * __beacon_add_tim().
2766 * dtim_count = dtim_period - (tsf / bcn_int) % dtim_period
2767 */
2768 do_div(tsf, beacon_int);
2769 bcns_from_dtim = do_div(tsf, dtim_period);
2770 /* just had a DTIM */
2771 if (!bcns_from_dtim)
2772 dtim_count = 0;
2773 else
2774 dtim_count = dtim_period - bcns_from_dtim;
2775
2776 ps->dtim_count = dtim_count;
2777}
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
index 7313d379c0d3..21448d629b15 100644
--- a/net/mac80211/wpa.c
+++ b/net/mac80211/wpa.c
@@ -127,7 +127,7 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_rx_data *rx)
127 * APs with pairwise keys should never receive Michael MIC 127 * APs with pairwise keys should never receive Michael MIC
128 * errors for non-zero keyidx because these are reserved for 128 * errors for non-zero keyidx because these are reserved for
129 * group keys and only the AP is sending real multicast 129 * group keys and only the AP is sending real multicast
130 * frames in the BSS. ( 130 * frames in the BSS.
131 */ 131 */
132 return RX_DROP_UNUSABLE; 132 return RX_DROP_UNUSABLE;
133 } 133 }
diff --git a/net/nfc/core.c b/net/nfc/core.c
index b675fa4a6f19..ca1e65f4b133 100644
--- a/net/nfc/core.c
+++ b/net/nfc/core.c
@@ -133,11 +133,8 @@ int nfc_dev_up(struct nfc_dev *dev)
133 dev->dev_up = true; 133 dev->dev_up = true;
134 134
135 /* We have to enable the device before discovering SEs */ 135 /* We have to enable the device before discovering SEs */
136 if (dev->ops->discover_se) { 136 if (dev->ops->discover_se && dev->ops->discover_se(dev))
137 rc = dev->ops->discover_se(dev); 137 pr_err("SE discovery failed\n");
138 if (rc)
139 pr_warn("SE discovery failed\n");
140 }
141 138
142error: 139error:
143 device_unlock(&dev->dev); 140 device_unlock(&dev->dev);
diff --git a/net/nfc/digital_core.c b/net/nfc/digital_core.c
index 09fc95439955..c129d1571ca6 100644
--- a/net/nfc/digital_core.c
+++ b/net/nfc/digital_core.c
@@ -339,7 +339,6 @@ int digital_target_found(struct nfc_digital_dev *ddev,
339 pr_debug("rf_tech=%d, protocol=%d\n", rf_tech, protocol); 339 pr_debug("rf_tech=%d, protocol=%d\n", rf_tech, protocol);
340 340
341 ddev->curr_rf_tech = rf_tech; 341 ddev->curr_rf_tech = rf_tech;
342 ddev->curr_protocol = protocol;
343 342
344 if (DIGITAL_DRV_CAPS_IN_CRC(ddev)) { 343 if (DIGITAL_DRV_CAPS_IN_CRC(ddev)) {
345 ddev->skb_add_crc = digital_skb_add_crc_none; 344 ddev->skb_add_crc = digital_skb_add_crc_none;
@@ -541,8 +540,14 @@ static int digital_dep_link_up(struct nfc_dev *nfc_dev,
541 __u8 comm_mode, __u8 *gb, size_t gb_len) 540 __u8 comm_mode, __u8 *gb, size_t gb_len)
542{ 541{
543 struct nfc_digital_dev *ddev = nfc_get_drvdata(nfc_dev); 542 struct nfc_digital_dev *ddev = nfc_get_drvdata(nfc_dev);
543 int rc;
544
545 rc = digital_in_send_atr_req(ddev, target, comm_mode, gb, gb_len);
544 546
545 return digital_in_send_atr_req(ddev, target, comm_mode, gb, gb_len); 547 if (!rc)
548 ddev->curr_protocol = NFC_PROTO_NFC_DEP;
549
550 return rc;
546} 551}
547 552
548static int digital_dep_link_down(struct nfc_dev *nfc_dev) 553static int digital_dep_link_down(struct nfc_dev *nfc_dev)
@@ -557,6 +562,20 @@ static int digital_dep_link_down(struct nfc_dev *nfc_dev)
557static int digital_activate_target(struct nfc_dev *nfc_dev, 562static int digital_activate_target(struct nfc_dev *nfc_dev,
558 struct nfc_target *target, __u32 protocol) 563 struct nfc_target *target, __u32 protocol)
559{ 564{
565 struct nfc_digital_dev *ddev = nfc_get_drvdata(nfc_dev);
566
567 if (ddev->poll_tech_count) {
568 pr_err("Can't activate a target while polling\n");
569 return -EBUSY;
570 }
571
572 if (ddev->curr_protocol) {
573 pr_err("A target is already active\n");
574 return -EBUSY;
575 }
576
577 ddev->curr_protocol = protocol;
578
560 return 0; 579 return 0;
561} 580}
562 581
@@ -565,6 +584,11 @@ static void digital_deactivate_target(struct nfc_dev *nfc_dev,
565{ 584{
566 struct nfc_digital_dev *ddev = nfc_get_drvdata(nfc_dev); 585 struct nfc_digital_dev *ddev = nfc_get_drvdata(nfc_dev);
567 586
587 if (!ddev->curr_protocol) {
588 pr_err("No active target\n");
589 return;
590 }
591
568 ddev->curr_protocol = 0; 592 ddev->curr_protocol = 0;
569} 593}
570 594
diff --git a/net/nfc/digital_dep.c b/net/nfc/digital_dep.c
index 07bbc24fb4c7..43e450f78d0a 100644
--- a/net/nfc/digital_dep.c
+++ b/net/nfc/digital_dep.c
@@ -32,7 +32,6 @@
32#define DIGITAL_ATR_REQ_MIN_SIZE 16 32#define DIGITAL_ATR_REQ_MIN_SIZE 16
33#define DIGITAL_ATR_REQ_MAX_SIZE 64 33#define DIGITAL_ATR_REQ_MAX_SIZE 64
34 34
35#define DIGITAL_NFCID3_LEN ((u8)8)
36#define DIGITAL_LR_BITS_PAYLOAD_SIZE_254B 0x30 35#define DIGITAL_LR_BITS_PAYLOAD_SIZE_254B 0x30
37#define DIGITAL_GB_BIT 0x02 36#define DIGITAL_GB_BIT 0x02
38 37
@@ -206,10 +205,9 @@ int digital_in_send_atr_req(struct nfc_digital_dev *ddev,
206 atr_req->dir = DIGITAL_NFC_DEP_FRAME_DIR_OUT; 205 atr_req->dir = DIGITAL_NFC_DEP_FRAME_DIR_OUT;
207 atr_req->cmd = DIGITAL_CMD_ATR_REQ; 206 atr_req->cmd = DIGITAL_CMD_ATR_REQ;
208 if (target->nfcid2_len) 207 if (target->nfcid2_len)
209 memcpy(atr_req->nfcid3, target->nfcid2, 208 memcpy(atr_req->nfcid3, target->nfcid2, NFC_NFCID2_MAXSIZE);
210 max(target->nfcid2_len, DIGITAL_NFCID3_LEN));
211 else 209 else
212 get_random_bytes(atr_req->nfcid3, DIGITAL_NFCID3_LEN); 210 get_random_bytes(atr_req->nfcid3, NFC_NFCID3_MAXSIZE);
213 211
214 atr_req->did = 0; 212 atr_req->did = 0;
215 atr_req->bs = 0; 213 atr_req->bs = 0;
@@ -382,6 +380,33 @@ int digital_in_send_dep_req(struct nfc_digital_dev *ddev,
382 data_exch); 380 data_exch);
383} 381}
384 382
383static void digital_tg_set_rf_tech(struct nfc_digital_dev *ddev, u8 rf_tech)
384{
385 ddev->curr_rf_tech = rf_tech;
386
387 ddev->skb_add_crc = digital_skb_add_crc_none;
388 ddev->skb_check_crc = digital_skb_check_crc_none;
389
390 if (DIGITAL_DRV_CAPS_TG_CRC(ddev))
391 return;
392
393 switch (ddev->curr_rf_tech) {
394 case NFC_DIGITAL_RF_TECH_106A:
395 ddev->skb_add_crc = digital_skb_add_crc_a;
396 ddev->skb_check_crc = digital_skb_check_crc_a;
397 break;
398
399 case NFC_DIGITAL_RF_TECH_212F:
400 case NFC_DIGITAL_RF_TECH_424F:
401 ddev->skb_add_crc = digital_skb_add_crc_f;
402 ddev->skb_check_crc = digital_skb_check_crc_f;
403 break;
404
405 default:
406 break;
407 }
408}
409
385static void digital_tg_recv_dep_req(struct nfc_digital_dev *ddev, void *arg, 410static void digital_tg_recv_dep_req(struct nfc_digital_dev *ddev, void *arg,
386 struct sk_buff *resp) 411 struct sk_buff *resp)
387{ 412{
@@ -472,11 +497,13 @@ int digital_tg_send_dep_res(struct nfc_digital_dev *ddev, struct sk_buff *skb)
472static void digital_tg_send_psl_res_complete(struct nfc_digital_dev *ddev, 497static void digital_tg_send_psl_res_complete(struct nfc_digital_dev *ddev,
473 void *arg, struct sk_buff *resp) 498 void *arg, struct sk_buff *resp)
474{ 499{
475 u8 rf_tech = PTR_ERR(arg); 500 u8 rf_tech = (unsigned long)arg;
476 501
477 if (IS_ERR(resp)) 502 if (IS_ERR(resp))
478 return; 503 return;
479 504
505 digital_tg_set_rf_tech(ddev, rf_tech);
506
480 digital_tg_configure_hw(ddev, NFC_DIGITAL_CONFIG_RF_TECH, rf_tech); 507 digital_tg_configure_hw(ddev, NFC_DIGITAL_CONFIG_RF_TECH, rf_tech);
481 508
482 digital_tg_listen(ddev, 1500, digital_tg_recv_dep_req, NULL); 509 digital_tg_listen(ddev, 1500, digital_tg_recv_dep_req, NULL);
@@ -508,7 +535,7 @@ static int digital_tg_send_psl_res(struct nfc_digital_dev *ddev, u8 did,
508 ddev->skb_add_crc(skb); 535 ddev->skb_add_crc(skb);
509 536
510 rc = digital_tg_send_cmd(ddev, skb, 0, digital_tg_send_psl_res_complete, 537 rc = digital_tg_send_cmd(ddev, skb, 0, digital_tg_send_psl_res_complete,
511 ERR_PTR(rf_tech)); 538 (void *)(unsigned long)rf_tech);
512 539
513 if (rc) 540 if (rc)
514 kfree_skb(skb); 541 kfree_skb(skb);
@@ -661,16 +688,10 @@ void digital_tg_recv_atr_req(struct nfc_digital_dev *ddev, void *arg,
661 688
662 if (resp->data[0] == DIGITAL_NFC_DEP_NFCA_SOD_SB) { 689 if (resp->data[0] == DIGITAL_NFC_DEP_NFCA_SOD_SB) {
663 min_size = DIGITAL_ATR_REQ_MIN_SIZE + 2; 690 min_size = DIGITAL_ATR_REQ_MIN_SIZE + 2;
664 691 digital_tg_set_rf_tech(ddev, NFC_DIGITAL_RF_TECH_106A);
665 ddev->curr_rf_tech = NFC_DIGITAL_RF_TECH_106A;
666 ddev->skb_add_crc = digital_skb_add_crc_a;
667 ddev->skb_check_crc = digital_skb_check_crc_a;
668 } else { 692 } else {
669 min_size = DIGITAL_ATR_REQ_MIN_SIZE + 1; 693 min_size = DIGITAL_ATR_REQ_MIN_SIZE + 1;
670 694 digital_tg_set_rf_tech(ddev, NFC_DIGITAL_RF_TECH_212F);
671 ddev->curr_rf_tech = NFC_DIGITAL_RF_TECH_212F;
672 ddev->skb_add_crc = digital_skb_add_crc_f;
673 ddev->skb_check_crc = digital_skb_check_crc_f;
674 } 695 }
675 696
676 if (resp->len < min_size) { 697 if (resp->len < min_size) {
@@ -678,10 +699,7 @@ void digital_tg_recv_atr_req(struct nfc_digital_dev *ddev, void *arg,
678 goto exit; 699 goto exit;
679 } 700 }
680 701
681 if (DIGITAL_DRV_CAPS_TG_CRC(ddev)) { 702 ddev->curr_protocol = NFC_PROTO_NFC_DEP_MASK;
682 ddev->skb_add_crc = digital_skb_add_crc_none;
683 ddev->skb_check_crc = digital_skb_check_crc_none;
684 }
685 703
686 rc = ddev->skb_check_crc(resp); 704 rc = ddev->skb_check_crc(resp);
687 if (rc) { 705 if (rc) {
diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c
index 3b9610031baa..d45b638e77c7 100644
--- a/net/nfc/hci/core.c
+++ b/net/nfc/hci/core.c
@@ -335,11 +335,8 @@ exit:
335 kfree_skb(skb); 335 kfree_skb(skb);
336 336
337exit_noskb: 337exit_noskb:
338 if (r) { 338 if (r)
339 /* TODO: There was an error dispatching the event, 339 nfc_hci_driver_failure(hdev, r);
340 * how to propagate up to nfc core?
341 */
342 }
343} 340}
344 341
345static void nfc_hci_cmd_timeout(unsigned long data) 342static void nfc_hci_cmd_timeout(unsigned long data)
diff --git a/net/nfc/llcp_commands.c b/net/nfc/llcp_commands.c
index 693cd1aad582..bec6ed15f503 100644
--- a/net/nfc/llcp_commands.c
+++ b/net/nfc/llcp_commands.c
@@ -675,7 +675,7 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock,
675 675
676 do { 676 do {
677 remote_miu = sock->remote_miu > LLCP_MAX_MIU ? 677 remote_miu = sock->remote_miu > LLCP_MAX_MIU ?
678 local->remote_miu : sock->remote_miu; 678 LLCP_DEFAULT_MIU : sock->remote_miu;
679 679
680 frag_len = min_t(size_t, remote_miu, remaining_len); 680 frag_len = min_t(size_t, remote_miu, remaining_len);
681 681
@@ -684,8 +684,10 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock,
684 684
685 pdu = llcp_allocate_pdu(sock, LLCP_PDU_I, 685 pdu = llcp_allocate_pdu(sock, LLCP_PDU_I,
686 frag_len + LLCP_SEQUENCE_SIZE); 686 frag_len + LLCP_SEQUENCE_SIZE);
687 if (pdu == NULL) 687 if (pdu == NULL) {
688 kfree(msg_data);
688 return -ENOMEM; 689 return -ENOMEM;
690 }
689 691
690 skb_put(pdu, LLCP_SEQUENCE_SIZE); 692 skb_put(pdu, LLCP_SEQUENCE_SIZE);
691 693
diff --git a/net/nfc/llcp_core.c b/net/nfc/llcp_core.c
index 1349074e1ffc..6184bd1fba3a 100644
--- a/net/nfc/llcp_core.c
+++ b/net/nfc/llcp_core.c
@@ -943,7 +943,6 @@ static void nfc_llcp_recv_connect(struct nfc_llcp_local *local,
943 new_sock->local = nfc_llcp_local_get(local); 943 new_sock->local = nfc_llcp_local_get(local);
944 new_sock->rw = sock->rw; 944 new_sock->rw = sock->rw;
945 new_sock->miux = sock->miux; 945 new_sock->miux = sock->miux;
946 new_sock->remote_miu = local->remote_miu;
947 new_sock->nfc_protocol = sock->nfc_protocol; 946 new_sock->nfc_protocol = sock->nfc_protocol;
948 new_sock->dsap = ssap; 947 new_sock->dsap = ssap;
949 new_sock->target_idx = local->target_idx; 948 new_sock->target_idx = local->target_idx;
diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c
index 69fbc8dadba7..4a53bb58a463 100644
--- a/net/nfc/llcp_sock.c
+++ b/net/nfc/llcp_sock.c
@@ -700,7 +700,6 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr,
700 700
701 llcp_sock->dev = dev; 701 llcp_sock->dev = dev;
702 llcp_sock->local = nfc_llcp_local_get(local); 702 llcp_sock->local = nfc_llcp_local_get(local);
703 llcp_sock->remote_miu = llcp_sock->local->remote_miu;
704 llcp_sock->ssap = nfc_llcp_get_local_ssap(local); 703 llcp_sock->ssap = nfc_llcp_get_local_ssap(local);
705 if (llcp_sock->ssap == LLCP_SAP_MAX) { 704 if (llcp_sock->ssap == LLCP_SAP_MAX) {
706 ret = -ENOMEM; 705 ret = -ENOMEM;
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index f0e955e3a385..46bda010bf11 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -301,6 +301,9 @@ static int nci_open_device(struct nci_dev *ndev)
301 rc = __nci_request(ndev, nci_reset_req, 0, 301 rc = __nci_request(ndev, nci_reset_req, 0,
302 msecs_to_jiffies(NCI_RESET_TIMEOUT)); 302 msecs_to_jiffies(NCI_RESET_TIMEOUT));
303 303
304 if (ndev->ops->setup(ndev))
305 ndev->ops->setup(ndev);
306
304 if (!rc) { 307 if (!rc) {
305 rc = __nci_request(ndev, nci_init_req, 0, 308 rc = __nci_request(ndev, nci_init_req, 0,
306 msecs_to_jiffies(NCI_INIT_TIMEOUT)); 309 msecs_to_jiffies(NCI_INIT_TIMEOUT));
@@ -361,6 +364,8 @@ static int nci_close_device(struct nci_dev *ndev)
361 msecs_to_jiffies(NCI_RESET_TIMEOUT)); 364 msecs_to_jiffies(NCI_RESET_TIMEOUT));
362 clear_bit(NCI_INIT, &ndev->flags); 365 clear_bit(NCI_INIT, &ndev->flags);
363 366
367 del_timer_sync(&ndev->cmd_timer);
368
364 /* Flush cmd wq */ 369 /* Flush cmd wq */
365 flush_workqueue(ndev->cmd_wq); 370 flush_workqueue(ndev->cmd_wq);
366 371
@@ -408,12 +413,26 @@ static int nci_dev_down(struct nfc_dev *nfc_dev)
408 return nci_close_device(ndev); 413 return nci_close_device(ndev);
409} 414}
410 415
416int nci_set_config(struct nci_dev *ndev, __u8 id, size_t len, __u8 *val)
417{
418 struct nci_set_config_param param;
419
420 if (!val || !len)
421 return 0;
422
423 param.id = id;
424 param.len = len;
425 param.val = val;
426
427 return __nci_request(ndev, nci_set_config_req, (unsigned long)&param,
428 msecs_to_jiffies(NCI_SET_CONFIG_TIMEOUT));
429}
430EXPORT_SYMBOL(nci_set_config);
431
411static int nci_set_local_general_bytes(struct nfc_dev *nfc_dev) 432static int nci_set_local_general_bytes(struct nfc_dev *nfc_dev)
412{ 433{
413 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); 434 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
414 struct nci_set_config_param param; 435 struct nci_set_config_param param;
415 __u8 local_gb[NFC_MAX_GT_LEN];
416 int i;
417 436
418 param.val = nfc_get_local_general_bytes(nfc_dev, &param.len); 437 param.val = nfc_get_local_general_bytes(nfc_dev, &param.len);
419 if ((param.val == NULL) || (param.len == 0)) 438 if ((param.val == NULL) || (param.len == 0))
@@ -422,11 +441,7 @@ static int nci_set_local_general_bytes(struct nfc_dev *nfc_dev)
422 if (param.len > NFC_MAX_GT_LEN) 441 if (param.len > NFC_MAX_GT_LEN)
423 return -EINVAL; 442 return -EINVAL;
424 443
425 for (i = 0; i < param.len; i++)
426 local_gb[param.len-1-i] = param.val[i];
427
428 param.id = NCI_PN_ATR_REQ_GEN_BYTES; 444 param.id = NCI_PN_ATR_REQ_GEN_BYTES;
429 param.val = local_gb;
430 445
431 return nci_request(ndev, nci_set_config_req, (unsigned long)&param, 446 return nci_request(ndev, nci_set_config_req, (unsigned long)&param,
432 msecs_to_jiffies(NCI_SET_CONFIG_TIMEOUT)); 447 msecs_to_jiffies(NCI_SET_CONFIG_TIMEOUT));
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 4fa555e4dedc..7a742594916e 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -5257,12 +5257,7 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
5257 goto unlock; 5257 goto unlock;
5258 } 5258 }
5259 } else { 5259 } else {
5260 enum ieee80211_band band; 5260 n_channels = ieee80211_get_num_supported_channels(wiphy);
5261 n_channels = 0;
5262
5263 for (band = 0; band < IEEE80211_NUM_BANDS; band++)
5264 if (wiphy->bands[band])
5265 n_channels += wiphy->bands[band]->n_channels;
5266 } 5261 }
5267 5262
5268 if (info->attrs[NL80211_ATTR_SCAN_SSIDS]) 5263 if (info->attrs[NL80211_ATTR_SCAN_SSIDS])
@@ -5470,11 +5465,7 @@ static int nl80211_start_sched_scan(struct sk_buff *skb,
5470 if (!n_channels) 5465 if (!n_channels)
5471 return -EINVAL; 5466 return -EINVAL;
5472 } else { 5467 } else {
5473 n_channels = 0; 5468 n_channels = ieee80211_get_num_supported_channels(wiphy);
5474
5475 for (band = 0; band < IEEE80211_NUM_BANDS; band++)
5476 if (wiphy->bands[band])
5477 n_channels += wiphy->bands[band]->n_channels;
5478 } 5469 }
5479 5470
5480 if (info->attrs[NL80211_ATTR_SCAN_SSIDS]) 5471 if (info->attrs[NL80211_ATTR_SCAN_SSIDS])
@@ -6767,6 +6758,55 @@ __cfg80211_alloc_vendor_skb(struct cfg80211_registered_device *rdev,
6767 return NULL; 6758 return NULL;
6768} 6759}
6769 6760
6761struct sk_buff *__cfg80211_alloc_event_skb(struct wiphy *wiphy,
6762 enum nl80211_commands cmd,
6763 enum nl80211_attrs attr,
6764 int vendor_event_idx,
6765 int approxlen, gfp_t gfp)
6766{
6767 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
6768 const struct nl80211_vendor_cmd_info *info;
6769
6770 switch (cmd) {
6771 case NL80211_CMD_TESTMODE:
6772 if (WARN_ON(vendor_event_idx != -1))
6773 return NULL;
6774 info = NULL;
6775 break;
6776 case NL80211_CMD_VENDOR:
6777 if (WARN_ON(vendor_event_idx < 0 ||
6778 vendor_event_idx >= wiphy->n_vendor_events))
6779 return NULL;
6780 info = &wiphy->vendor_events[vendor_event_idx];
6781 break;
6782 default:
6783 WARN_ON(1);
6784 return NULL;
6785 }
6786
6787 return __cfg80211_alloc_vendor_skb(rdev, approxlen, 0, 0,
6788 cmd, attr, info, gfp);
6789}
6790EXPORT_SYMBOL(__cfg80211_alloc_event_skb);
6791
6792void __cfg80211_send_event_skb(struct sk_buff *skb, gfp_t gfp)
6793{
6794 struct cfg80211_registered_device *rdev = ((void **)skb->cb)[0];
6795 void *hdr = ((void **)skb->cb)[1];
6796 struct nlattr *data = ((void **)skb->cb)[2];
6797 enum nl80211_multicast_groups mcgrp = NL80211_MCGRP_TESTMODE;
6798
6799 nla_nest_end(skb, data);
6800 genlmsg_end(skb, hdr);
6801
6802 if (data->nla_type == NL80211_ATTR_VENDOR_DATA)
6803 mcgrp = NL80211_MCGRP_VENDOR;
6804
6805 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), skb, 0,
6806 mcgrp, gfp);
6807}
6808EXPORT_SYMBOL(__cfg80211_send_event_skb);
6809
6770#ifdef CONFIG_NL80211_TESTMODE 6810#ifdef CONFIG_NL80211_TESTMODE
6771static int nl80211_testmode_do(struct sk_buff *skb, struct genl_info *info) 6811static int nl80211_testmode_do(struct sk_buff *skb, struct genl_info *info)
6772{ 6812{
@@ -6893,55 +6933,6 @@ static int nl80211_testmode_dump(struct sk_buff *skb,
6893 rtnl_unlock(); 6933 rtnl_unlock();
6894 return err; 6934 return err;
6895} 6935}
6896
6897struct sk_buff *__cfg80211_alloc_event_skb(struct wiphy *wiphy,
6898 enum nl80211_commands cmd,
6899 enum nl80211_attrs attr,
6900 int vendor_event_idx,
6901 int approxlen, gfp_t gfp)
6902{
6903 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
6904 const struct nl80211_vendor_cmd_info *info;
6905
6906 switch (cmd) {
6907 case NL80211_CMD_TESTMODE:
6908 if (WARN_ON(vendor_event_idx != -1))
6909 return NULL;
6910 info = NULL;
6911 break;
6912 case NL80211_CMD_VENDOR:
6913 if (WARN_ON(vendor_event_idx < 0 ||
6914 vendor_event_idx >= wiphy->n_vendor_events))
6915 return NULL;
6916 info = &wiphy->vendor_events[vendor_event_idx];
6917 break;
6918 default:
6919 WARN_ON(1);
6920 return NULL;
6921 }
6922
6923 return __cfg80211_alloc_vendor_skb(rdev, approxlen, 0, 0,
6924 cmd, attr, info, gfp);
6925}
6926EXPORT_SYMBOL(__cfg80211_alloc_event_skb);
6927
6928void __cfg80211_send_event_skb(struct sk_buff *skb, gfp_t gfp)
6929{
6930 struct cfg80211_registered_device *rdev = ((void **)skb->cb)[0];
6931 void *hdr = ((void **)skb->cb)[1];
6932 struct nlattr *data = ((void **)skb->cb)[2];
6933 enum nl80211_multicast_groups mcgrp = NL80211_MCGRP_TESTMODE;
6934
6935 nla_nest_end(skb, data);
6936 genlmsg_end(skb, hdr);
6937
6938 if (data->nla_type == NL80211_ATTR_VENDOR_DATA)
6939 mcgrp = NL80211_MCGRP_VENDOR;
6940
6941 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), skb, 0,
6942 mcgrp, gfp);
6943}
6944EXPORT_SYMBOL(__cfg80211_send_event_skb);
6945#endif 6936#endif
6946 6937
6947static int nl80211_connect(struct sk_buff *skb, struct genl_info *info) 6938static int nl80211_connect(struct sk_buff *skb, struct genl_info *info)
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 7d20d844ca60..9b897fca7487 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1853,6 +1853,8 @@ int regulatory_hint(struct wiphy *wiphy, const char *alpha2)
1853 if (WARN_ON(!alpha2 || !wiphy)) 1853 if (WARN_ON(!alpha2 || !wiphy))
1854 return -EINVAL; 1854 return -EINVAL;
1855 1855
1856 wiphy->regulatory_flags &= ~REGULATORY_CUSTOM_REG;
1857
1856 request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL); 1858 request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL);
1857 if (!request) 1859 if (!request)
1858 return -ENOMEM; 1860 return -ENOMEM;
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index a32d52a04c27..b528e31da2cf 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -1089,11 +1089,8 @@ int cfg80211_wext_siwscan(struct net_device *dev,
1089 /* Determine number of channels, needed to allocate creq */ 1089 /* Determine number of channels, needed to allocate creq */
1090 if (wreq && wreq->num_channels) 1090 if (wreq && wreq->num_channels)
1091 n_channels = wreq->num_channels; 1091 n_channels = wreq->num_channels;
1092 else { 1092 else
1093 for (band = 0; band < IEEE80211_NUM_BANDS; band++) 1093 n_channels = ieee80211_get_num_supported_channels(wiphy);
1094 if (wiphy->bands[band])
1095 n_channels += wiphy->bands[band]->n_channels;
1096 }
1097 1094
1098 creq = kzalloc(sizeof(*creq) + sizeof(struct cfg80211_ssid) + 1095 creq = kzalloc(sizeof(*creq) + sizeof(struct cfg80211_ssid) +
1099 n_channels * sizeof(void *), 1096 n_channels * sizeof(void *),
diff --git a/net/wireless/sme.c b/net/wireless/sme.c
index 5d6e7bb2fc89..a63509118508 100644
--- a/net/wireless/sme.c
+++ b/net/wireless/sme.c
@@ -70,18 +70,11 @@ static int cfg80211_conn_scan(struct wireless_dev *wdev)
70 if (rdev->scan_req) 70 if (rdev->scan_req)
71 return -EBUSY; 71 return -EBUSY;
72 72
73 if (wdev->conn->params.channel) { 73 if (wdev->conn->params.channel)
74 n_channels = 1; 74 n_channels = 1;
75 } else { 75 else
76 enum ieee80211_band band; 76 n_channels = ieee80211_get_num_supported_channels(wdev->wiphy);
77 n_channels = 0;
78 77
79 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
80 if (!wdev->wiphy->bands[band])
81 continue;
82 n_channels += wdev->wiphy->bands[band]->n_channels;
83 }
84 }
85 request = kzalloc(sizeof(*request) + sizeof(request->ssids[0]) + 78 request = kzalloc(sizeof(*request) + sizeof(request->ssids[0]) +
86 sizeof(request->channels[0]) * n_channels, 79 sizeof(request->channels[0]) * n_channels,
87 GFP_KERNEL); 80 GFP_KERNEL);
diff --git a/net/wireless/util.c b/net/wireless/util.c
index 5618888853b2..d39c37104ae2 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -879,7 +879,9 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev,
879 879
880 dev->ieee80211_ptr->use_4addr = false; 880 dev->ieee80211_ptr->use_4addr = false;
881 dev->ieee80211_ptr->mesh_id_up_len = 0; 881 dev->ieee80211_ptr->mesh_id_up_len = 0;
882 wdev_lock(dev->ieee80211_ptr);
882 rdev_set_qos_map(rdev, dev, NULL); 883 rdev_set_qos_map(rdev, dev, NULL);
884 wdev_unlock(dev->ieee80211_ptr);
883 885
884 switch (otype) { 886 switch (otype) {
885 case NL80211_IFTYPE_AP: 887 case NL80211_IFTYPE_AP:
@@ -1479,6 +1481,19 @@ int ieee80211_get_ratemask(struct ieee80211_supported_band *sband,
1479 return 0; 1481 return 0;
1480} 1482}
1481 1483
1484unsigned int ieee80211_get_num_supported_channels(struct wiphy *wiphy)
1485{
1486 enum ieee80211_band band;
1487 unsigned int n_channels = 0;
1488
1489 for (band = 0; band < IEEE80211_NUM_BANDS; band++)
1490 if (wiphy->bands[band])
1491 n_channels += wiphy->bands[band]->n_channels;
1492
1493 return n_channels;
1494}
1495EXPORT_SYMBOL(ieee80211_get_num_supported_channels);
1496
1482/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ 1497/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
1483/* Ethernet-II snap header (RFC1042 for most EtherTypes) */ 1498/* Ethernet-II snap header (RFC1042 for most EtherTypes) */
1484const unsigned char rfc1042_header[] __aligned(2) = 1499const unsigned char rfc1042_header[] __aligned(2) =
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c
index e7c6e862580d..5661a54ac7ee 100644
--- a/net/wireless/wext-compat.c
+++ b/net/wireless/wext-compat.c
@@ -370,7 +370,7 @@ static int cfg80211_wext_siwretry(struct net_device *dev,
370 u8 oshort = wdev->wiphy->retry_short; 370 u8 oshort = wdev->wiphy->retry_short;
371 int err; 371 int err;
372 372
373 if (retry->disabled || 373 if (retry->disabled || retry->value < 1 || retry->value > 255 ||
374 (retry->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT) 374 (retry->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT)
375 return -EINVAL; 375 return -EINVAL;
376 376
@@ -412,9 +412,9 @@ int cfg80211_wext_giwretry(struct net_device *dev,
412 * First return short value, iwconfig will ask long value 412 * First return short value, iwconfig will ask long value
413 * later if needed 413 * later if needed
414 */ 414 */
415 retry->flags |= IW_RETRY_LIMIT; 415 retry->flags |= IW_RETRY_LIMIT | IW_RETRY_SHORT;
416 retry->value = wdev->wiphy->retry_short; 416 retry->value = wdev->wiphy->retry_short;
417 if (wdev->wiphy->retry_long != wdev->wiphy->retry_short) 417 if (wdev->wiphy->retry_long == wdev->wiphy->retry_short)
418 retry->flags |= IW_RETRY_LONG; 418 retry->flags |= IW_RETRY_LONG;
419 419
420 return 0; 420 return 0;