aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn W. Linville <linville@tuxdriver.com>2014-05-22 13:58:36 -0400
committerJohn W. Linville <linville@tuxdriver.com>2014-05-22 13:58:36 -0400
commit40a10fd740a4d5a9f3da255cf8dae48c6723d1a6 (patch)
treea65eb4adca8e37ed7335345e94e36918593f7f92
parent99abe65ff18b6bbac2e55524827b571c3eccfa86 (diff)
parent67af9811539be83dbdc0739215d29af23c870405 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next
-rw-r--r--drivers/net/wireless/ath/ath6kl/cfg80211.c7
-rw-r--r--drivers/net/wireless/ath/ath6kl/wmi.c2
-rw-r--r--drivers/net/wireless/ath/ath6kl/wmi.h2
-rw-r--r--drivers/net/wireless/ath/wil6210/cfg80211.c4
-rw-r--r--drivers/net/wireless/ath/wil6210/main.c4
-rw-r--r--drivers/net/wireless/ath/wil6210/wil6210.h2
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c6
-rw-r--r--drivers/net/wireless/libertas/cfg.c7
-rw-r--r--drivers/net/wireless/libertas/defs.h3
-rw-r--r--drivers/net/wireless/mwifiex/11n.h2
-rw-r--r--drivers/net/wireless/mwifiex/cfg80211.c19
-rw-r--r--drivers/net/wireless/mwifiex/main.h22
-rw-r--r--drivers/net/wireless/mwifiex/tdls.c44
-rw-r--r--drivers/net/wireless/mwifiex/util.c6
-rw-r--r--drivers/net/wireless/mwifiex/wmm.c10
-rw-r--r--drivers/net/wireless/mwifiex/wmm.h5
-rw-r--r--drivers/net/wireless/orinoco/hw.c4
-rw-r--r--drivers/net/wireless/orinoco/hw.h4
-rw-r--r--drivers/net/wireless/orinoco/wext.c4
-rw-r--r--drivers/net/wireless/rndis_wlan.c4
-rw-r--r--drivers/net/wireless/ti/wlcore/main.c2
-rw-r--r--drivers/net/wireless/ti/wlcore/wlcore_i.h4
-rw-r--r--drivers/staging/wlan-ng/cfg80211.c4
-rw-r--r--include/net/cfg80211.h191
-rw-r--r--include/net/mac80211.h78
-rw-r--r--include/uapi/linux/nl80211.h25
-rw-r--r--net/mac80211/Makefile3
-rw-r--r--net/mac80211/cfg.c538
-rw-r--r--net/mac80211/chan.c4
-rw-r--r--net/mac80211/driver-ops.h121
-rw-r--r--net/mac80211/ibss.c2
-rw-r--r--net/mac80211/ieee80211_i.h17
-rw-r--r--net/mac80211/iface.c7
-rw-r--r--net/mac80211/key.c7
-rw-r--r--net/mac80211/main.c2
-rw-r--r--net/mac80211/mesh.c2
-rw-r--r--net/mac80211/mesh_pathtbl.c6
-rw-r--r--net/mac80211/mesh_sync.c2
-rw-r--r--net/mac80211/mlme.c46
-rw-r--r--net/mac80211/rc80211_minstrel.c12
-rw-r--r--net/mac80211/rc80211_minstrel_ht.c22
-rw-r--r--net/mac80211/scan.c15
-rw-r--r--net/mac80211/tdls.c325
-rw-r--r--net/mac80211/trace.h32
-rw-r--r--net/mac80211/tx.c189
-rw-r--r--net/mac80211/util.c46
-rw-r--r--net/rfkill/rfkill-gpio.c19
-rw-r--r--net/wireless/ap.c4
-rw-r--r--net/wireless/chan.c5
-rw-r--r--net/wireless/core.c67
-rw-r--r--net/wireless/core.h7
-rw-r--r--net/wireless/ibss.c2
-rw-r--r--net/wireless/mesh.c4
-rw-r--r--net/wireless/nl80211.c140
-rw-r--r--net/wireless/rdev-ops.h2
-rw-r--r--net/wireless/reg.c3
-rw-r--r--net/wireless/scan.c12
-rw-r--r--net/wireless/sme.c8
-rw-r--r--net/wireless/trace.h37
-rw-r--r--net/wireless/util.c38
60 files changed, 1484 insertions, 727 deletions
diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c
index 09285084bcd3..0e26f4a34fda 100644
--- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
+++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
@@ -1759,7 +1759,7 @@ static bool is_rate_ht40(s32 rate, u8 *mcs, bool *sgi)
1759} 1759}
1760 1760
1761static int ath6kl_get_station(struct wiphy *wiphy, struct net_device *dev, 1761static int ath6kl_get_station(struct wiphy *wiphy, struct net_device *dev,
1762 u8 *mac, struct station_info *sinfo) 1762 const u8 *mac, struct station_info *sinfo)
1763{ 1763{
1764 struct ath6kl *ar = ath6kl_priv(dev); 1764 struct ath6kl *ar = ath6kl_priv(dev);
1765 struct ath6kl_vif *vif = netdev_priv(dev); 1765 struct ath6kl_vif *vif = netdev_priv(dev);
@@ -2974,7 +2974,7 @@ static int ath6kl_stop_ap(struct wiphy *wiphy, struct net_device *dev)
2974static const u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 2974static const u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
2975 2975
2976static int ath6kl_del_station(struct wiphy *wiphy, struct net_device *dev, 2976static int ath6kl_del_station(struct wiphy *wiphy, struct net_device *dev,
2977 u8 *mac) 2977 const u8 *mac)
2978{ 2978{
2979 struct ath6kl *ar = ath6kl_priv(dev); 2979 struct ath6kl *ar = ath6kl_priv(dev);
2980 struct ath6kl_vif *vif = netdev_priv(dev); 2980 struct ath6kl_vif *vif = netdev_priv(dev);
@@ -2985,7 +2985,8 @@ static int ath6kl_del_station(struct wiphy *wiphy, struct net_device *dev,
2985} 2985}
2986 2986
2987static int ath6kl_change_station(struct wiphy *wiphy, struct net_device *dev, 2987static int ath6kl_change_station(struct wiphy *wiphy, struct net_device *dev,
2988 u8 *mac, struct station_parameters *params) 2988 const u8 *mac,
2989 struct station_parameters *params)
2989{ 2990{
2990 struct ath6kl *ar = ath6kl_priv(dev); 2991 struct ath6kl *ar = ath6kl_priv(dev);
2991 struct ath6kl_vif *vif = netdev_priv(dev); 2992 struct ath6kl_vif *vif = netdev_priv(dev);
diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c
index 0c0e1e36e40f..4d7f9e4712e9 100644
--- a/drivers/net/wireless/ath/ath6kl/wmi.c
+++ b/drivers/net/wireless/ath/ath6kl/wmi.c
@@ -2320,7 +2320,7 @@ int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index,
2320 return ret; 2320 return ret;
2321} 2321}
2322 2322
2323int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 if_idx, u8 *krk) 2323int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 if_idx, const u8 *krk)
2324{ 2324{
2325 struct sk_buff *skb; 2325 struct sk_buff *skb;
2326 struct wmi_add_krk_cmd *cmd; 2326 struct wmi_add_krk_cmd *cmd;
diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h
index 1f05ecd97c91..7809afbb3e93 100644
--- a/drivers/net/wireless/ath/ath6kl/wmi.h
+++ b/drivers/net/wireless/ath/ath6kl/wmi.h
@@ -2616,7 +2616,7 @@ int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index,
2616 u8 *key_material, 2616 u8 *key_material,
2617 u8 key_op_ctrl, u8 *mac_addr, 2617 u8 key_op_ctrl, u8 *mac_addr,
2618 enum wmi_sync_flag sync_flag); 2618 enum wmi_sync_flag sync_flag);
2619int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 if_idx, u8 *krk); 2619int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 if_idx, const u8 *krk);
2620int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index); 2620int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index);
2621int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, u8 if_idx, const u8 *bssid, 2621int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, u8 if_idx, const u8 *bssid,
2622 const u8 *pmkid, bool set); 2622 const u8 *pmkid, bool set);
diff --git a/drivers/net/wireless/ath/wil6210/cfg80211.c b/drivers/net/wireless/ath/wil6210/cfg80211.c
index 4806a49cb61b..6e699d050d1e 100644
--- a/drivers/net/wireless/ath/wil6210/cfg80211.c
+++ b/drivers/net/wireless/ath/wil6210/cfg80211.c
@@ -172,7 +172,7 @@ static int wil_cid_fill_sinfo(struct wil6210_priv *wil, int cid,
172 172
173static int wil_cfg80211_get_station(struct wiphy *wiphy, 173static int wil_cfg80211_get_station(struct wiphy *wiphy,
174 struct net_device *ndev, 174 struct net_device *ndev,
175 u8 *mac, struct station_info *sinfo) 175 const u8 *mac, struct station_info *sinfo)
176{ 176{
177 struct wil6210_priv *wil = wiphy_to_wil(wiphy); 177 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
178 int rc; 178 int rc;
@@ -671,7 +671,7 @@ static int wil_cfg80211_stop_ap(struct wiphy *wiphy,
671} 671}
672 672
673static int wil_cfg80211_del_station(struct wiphy *wiphy, 673static int wil_cfg80211_del_station(struct wiphy *wiphy,
674 struct net_device *dev, u8 *mac) 674 struct net_device *dev, const u8 *mac)
675{ 675{
676 struct wil6210_priv *wil = wiphy_to_wil(wiphy); 676 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
677 677
diff --git a/drivers/net/wireless/ath/wil6210/main.c b/drivers/net/wireless/ath/wil6210/main.c
index 1b265fd19de2..670cc6de3b4c 100644
--- a/drivers/net/wireless/ath/wil6210/main.c
+++ b/drivers/net/wireless/ath/wil6210/main.c
@@ -81,7 +81,7 @@ static void wil_disconnect_cid(struct wil6210_priv *wil, int cid)
81 memset(&sta->stats, 0, sizeof(sta->stats)); 81 memset(&sta->stats, 0, sizeof(sta->stats));
82} 82}
83 83
84static void _wil6210_disconnect(struct wil6210_priv *wil, void *bssid) 84static void _wil6210_disconnect(struct wil6210_priv *wil, const u8 *bssid)
85{ 85{
86 int cid = -ENOENT; 86 int cid = -ENOENT;
87 struct net_device *ndev = wil_to_ndev(wil); 87 struct net_device *ndev = wil_to_ndev(wil);
@@ -252,7 +252,7 @@ int wil_priv_init(struct wil6210_priv *wil)
252 return 0; 252 return 0;
253} 253}
254 254
255void wil6210_disconnect(struct wil6210_priv *wil, void *bssid) 255void wil6210_disconnect(struct wil6210_priv *wil, const u8 *bssid)
256{ 256{
257 del_timer_sync(&wil->connect_timer); 257 del_timer_sync(&wil->connect_timer);
258 _wil6210_disconnect(wil, bssid); 258 _wil6210_disconnect(wil, bssid);
diff --git a/drivers/net/wireless/ath/wil6210/wil6210.h b/drivers/net/wireless/ath/wil6210/wil6210.h
index d3b8659ca32e..3427ac4a4fa1 100644
--- a/drivers/net/wireless/ath/wil6210/wil6210.h
+++ b/drivers/net/wireless/ath/wil6210/wil6210.h
@@ -508,7 +508,7 @@ void wil_wdev_free(struct wil6210_priv *wil);
508int wmi_set_mac_address(struct wil6210_priv *wil, void *addr); 508int wmi_set_mac_address(struct wil6210_priv *wil, void *addr);
509int wmi_pcp_start(struct wil6210_priv *wil, int bi, u8 wmi_nettype, u8 chan); 509int wmi_pcp_start(struct wil6210_priv *wil, int bi, u8 wmi_nettype, u8 chan);
510int wmi_pcp_stop(struct wil6210_priv *wil); 510int wmi_pcp_stop(struct wil6210_priv *wil);
511void wil6210_disconnect(struct wil6210_priv *wil, void *bssid); 511void wil6210_disconnect(struct wil6210_priv *wil, const u8 *bssid);
512 512
513int wil_rx_init(struct wil6210_priv *wil); 513int wil_rx_init(struct wil6210_priv *wil);
514void wil_rx_fini(struct wil6210_priv *wil); 514void wil_rx_fini(struct wil6210_priv *wil);
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
index 70bc2542061a..92cb29a2003f 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
@@ -2236,7 +2236,7 @@ brcmf_cfg80211_config_default_mgmt_key(struct wiphy *wiphy,
2236 2236
2237static s32 2237static s32
2238brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *ndev, 2238brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *ndev,
2239 u8 *mac, struct station_info *sinfo) 2239 const u8 *mac, struct station_info *sinfo)
2240{ 2240{
2241 struct brcmf_if *ifp = netdev_priv(ndev); 2241 struct brcmf_if *ifp = netdev_priv(ndev);
2242 struct brcmf_cfg80211_profile *profile = &ifp->vif->profile; 2242 struct brcmf_cfg80211_profile *profile = &ifp->vif->profile;
@@ -4014,7 +4014,7 @@ brcmf_cfg80211_change_beacon(struct wiphy *wiphy, struct net_device *ndev,
4014 4014
4015static int 4015static int
4016brcmf_cfg80211_del_station(struct wiphy *wiphy, struct net_device *ndev, 4016brcmf_cfg80211_del_station(struct wiphy *wiphy, struct net_device *ndev,
4017 u8 *mac) 4017 const u8 *mac)
4018{ 4018{
4019 struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); 4019 struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
4020 struct brcmf_scb_val_le scbval; 4020 struct brcmf_scb_val_le scbval;
@@ -4242,7 +4242,7 @@ static int brcmf_convert_nl80211_tdls_oper(enum nl80211_tdls_operation oper)
4242} 4242}
4243 4243
4244static int brcmf_cfg80211_tdls_oper(struct wiphy *wiphy, 4244static int brcmf_cfg80211_tdls_oper(struct wiphy *wiphy,
4245 struct net_device *ndev, u8 *peer, 4245 struct net_device *ndev, const u8 *peer,
4246 enum nl80211_tdls_operation oper) 4246 enum nl80211_tdls_operation oper)
4247{ 4247{
4248 struct brcmf_if *ifp; 4248 struct brcmf_if *ifp;
diff --git a/drivers/net/wireless/libertas/cfg.c b/drivers/net/wireless/libertas/cfg.c
index 54e344aed6e0..47a998d8f99e 100644
--- a/drivers/net/wireless/libertas/cfg.c
+++ b/drivers/net/wireless/libertas/cfg.c
@@ -1006,9 +1006,8 @@ struct cmd_key_material {
1006} __packed; 1006} __packed;
1007 1007
1008static int lbs_set_key_material(struct lbs_private *priv, 1008static int lbs_set_key_material(struct lbs_private *priv,
1009 int key_type, 1009 int key_type, int key_info,
1010 int key_info, 1010 const u8 *key, u16 key_len)
1011 u8 *key, u16 key_len)
1012{ 1011{
1013 struct cmd_key_material cmd; 1012 struct cmd_key_material cmd;
1014 int ret; 1013 int ret;
@@ -1610,7 +1609,7 @@ static int lbs_cfg_del_key(struct wiphy *wiphy, struct net_device *netdev,
1610 */ 1609 */
1611 1610
1612static int lbs_cfg_get_station(struct wiphy *wiphy, struct net_device *dev, 1611static int lbs_cfg_get_station(struct wiphy *wiphy, struct net_device *dev,
1613 u8 *mac, struct station_info *sinfo) 1612 const u8 *mac, struct station_info *sinfo)
1614{ 1613{
1615 struct lbs_private *priv = wiphy_priv(wiphy); 1614 struct lbs_private *priv = wiphy_priv(wiphy);
1616 s8 signal, noise; 1615 s8 signal, noise;
diff --git a/drivers/net/wireless/libertas/defs.h b/drivers/net/wireless/libertas/defs.h
index ab966f08024a..407784aca627 100644
--- a/drivers/net/wireless/libertas/defs.h
+++ b/drivers/net/wireless/libertas/defs.h
@@ -90,7 +90,8 @@ do { if ((lbs_debug & (grp)) == (grp)) \
90#define lbs_deb_cfg80211(fmt, args...) LBS_DEB_LL(LBS_DEB_CFG80211, " cfg80211", fmt, ##args) 90#define lbs_deb_cfg80211(fmt, args...) LBS_DEB_LL(LBS_DEB_CFG80211, " cfg80211", fmt, ##args)
91 91
92#ifdef DEBUG 92#ifdef DEBUG
93static inline void lbs_deb_hex(unsigned int grp, const char *prompt, u8 *buf, int len) 93static inline void lbs_deb_hex(unsigned int grp, const char *prompt,
94 const u8 *buf, int len)
94{ 95{
95 int i = 0; 96 int i = 0;
96 97
diff --git a/drivers/net/wireless/mwifiex/11n.h b/drivers/net/wireless/mwifiex/11n.h
index 43889d9e3b35..0b73fa08f5d4 100644
--- a/drivers/net/wireless/mwifiex/11n.h
+++ b/drivers/net/wireless/mwifiex/11n.h
@@ -200,7 +200,7 @@ static inline int mwifiex_is_sta_11n_enabled(struct mwifiex_private *priv,
200} 200}
201 201
202static inline u8 202static inline u8
203mwifiex_tdls_peer_11n_enabled(struct mwifiex_private *priv, u8 *ra) 203mwifiex_tdls_peer_11n_enabled(struct mwifiex_private *priv, const u8 *ra)
204{ 204{
205 struct mwifiex_sta_node *node = mwifiex_get_sta_entry(priv, ra); 205 struct mwifiex_sta_node *node = mwifiex_get_sta_entry(priv, ra);
206 if (node) 206 if (node)
diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
index 21ee27ab7b74..e95dec91a561 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -994,7 +994,7 @@ mwifiex_dump_station_info(struct mwifiex_private *priv,
994 */ 994 */
995static int 995static int
996mwifiex_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, 996mwifiex_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
997 u8 *mac, struct station_info *sinfo) 997 const u8 *mac, struct station_info *sinfo)
998{ 998{
999 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); 999 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
1000 1000
@@ -1270,7 +1270,7 @@ static int mwifiex_cfg80211_change_beacon(struct wiphy *wiphy,
1270 */ 1270 */
1271static int 1271static int
1272mwifiex_cfg80211_del_station(struct wiphy *wiphy, struct net_device *dev, 1272mwifiex_cfg80211_del_station(struct wiphy *wiphy, struct net_device *dev,
1273 u8 *mac) 1273 const u8 *mac)
1274{ 1274{
1275 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); 1275 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
1276 struct mwifiex_sta_node *sta_node; 1276 struct mwifiex_sta_node *sta_node;
@@ -2629,7 +2629,7 @@ static int mwifiex_cfg80211_set_coalesce(struct wiphy *wiphy,
2629 */ 2629 */
2630static int 2630static int
2631mwifiex_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, 2631mwifiex_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
2632 u8 *peer, u8 action_code, u8 dialog_token, 2632 const u8 *peer, u8 action_code, u8 dialog_token,
2633 u16 status_code, u32 peer_capability, 2633 u16 status_code, u32 peer_capability,
2634 const u8 *extra_ies, size_t extra_ies_len) 2634 const u8 *extra_ies, size_t extra_ies_len)
2635{ 2635{
@@ -2701,7 +2701,7 @@ mwifiex_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
2701 2701
2702static int 2702static int
2703mwifiex_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, 2703mwifiex_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
2704 u8 *peer, enum nl80211_tdls_operation action) 2704 const u8 *peer, enum nl80211_tdls_operation action)
2705{ 2705{
2706 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); 2706 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
2707 2707
@@ -2748,9 +2748,8 @@ mwifiex_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
2748} 2748}
2749 2749
2750static int 2750static int
2751mwifiex_cfg80211_add_station(struct wiphy *wiphy, 2751mwifiex_cfg80211_add_station(struct wiphy *wiphy, struct net_device *dev,
2752 struct net_device *dev, 2752 const u8 *mac, struct station_parameters *params)
2753 u8 *mac, struct station_parameters *params)
2754{ 2753{
2755 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); 2754 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
2756 2755
@@ -2765,9 +2764,9 @@ mwifiex_cfg80211_add_station(struct wiphy *wiphy,
2765} 2764}
2766 2765
2767static int 2766static int
2768mwifiex_cfg80211_change_station(struct wiphy *wiphy, 2767mwifiex_cfg80211_change_station(struct wiphy *wiphy, struct net_device *dev,
2769 struct net_device *dev, 2768 const u8 *mac,
2770 u8 *mac, struct station_parameters *params) 2769 struct station_parameters *params)
2771{ 2770{
2772 int ret; 2771 int ret;
2773 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); 2772 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h
index 34181192a666..3f25feb1508e 100644
--- a/drivers/net/wireless/mwifiex/main.h
+++ b/drivers/net/wireless/mwifiex/main.h
@@ -910,8 +910,6 @@ int mwifiex_handle_uap_rx_forward(struct mwifiex_private *priv,
910 struct sk_buff *skb); 910 struct sk_buff *skb);
911int mwifiex_process_sta_event(struct mwifiex_private *); 911int mwifiex_process_sta_event(struct mwifiex_private *);
912int mwifiex_process_uap_event(struct mwifiex_private *); 912int mwifiex_process_uap_event(struct mwifiex_private *);
913struct mwifiex_sta_node *
914mwifiex_get_sta_entry(struct mwifiex_private *priv, u8 *mac);
915void mwifiex_delete_all_station_list(struct mwifiex_private *priv); 913void mwifiex_delete_all_station_list(struct mwifiex_private *priv);
916void *mwifiex_process_sta_txpd(struct mwifiex_private *, struct sk_buff *skb); 914void *mwifiex_process_sta_txpd(struct mwifiex_private *, struct sk_buff *skb);
917void *mwifiex_process_uap_txpd(struct mwifiex_private *, struct sk_buff *skb); 915void *mwifiex_process_uap_txpd(struct mwifiex_private *, struct sk_buff *skb);
@@ -1220,26 +1218,26 @@ void mwifiex_dnld_txpwr_table(struct mwifiex_private *priv);
1220extern const struct ethtool_ops mwifiex_ethtool_ops; 1218extern const struct ethtool_ops mwifiex_ethtool_ops;
1221 1219
1222void mwifiex_del_all_sta_list(struct mwifiex_private *priv); 1220void mwifiex_del_all_sta_list(struct mwifiex_private *priv);
1223void mwifiex_del_sta_entry(struct mwifiex_private *priv, u8 *mac); 1221void mwifiex_del_sta_entry(struct mwifiex_private *priv, const u8 *mac);
1224void 1222void
1225mwifiex_set_sta_ht_cap(struct mwifiex_private *priv, const u8 *ies, 1223mwifiex_set_sta_ht_cap(struct mwifiex_private *priv, const u8 *ies,
1226 int ies_len, struct mwifiex_sta_node *node); 1224 int ies_len, struct mwifiex_sta_node *node);
1227struct mwifiex_sta_node * 1225struct mwifiex_sta_node *
1228mwifiex_add_sta_entry(struct mwifiex_private *priv, u8 *mac); 1226mwifiex_add_sta_entry(struct mwifiex_private *priv, const u8 *mac);
1229struct mwifiex_sta_node * 1227struct mwifiex_sta_node *
1230mwifiex_get_sta_entry(struct mwifiex_private *priv, u8 *mac); 1228mwifiex_get_sta_entry(struct mwifiex_private *priv, const u8 *mac);
1231int mwifiex_send_tdls_data_frame(struct mwifiex_private *priv, u8 *peer, 1229int mwifiex_send_tdls_data_frame(struct mwifiex_private *priv, const u8 *peer,
1232 u8 action_code, u8 dialog_token, 1230 u8 action_code, u8 dialog_token,
1233 u16 status_code, const u8 *extra_ies, 1231 u16 status_code, const u8 *extra_ies,
1234 size_t extra_ies_len); 1232 size_t extra_ies_len);
1235int mwifiex_send_tdls_action_frame(struct mwifiex_private *priv, 1233int mwifiex_send_tdls_action_frame(struct mwifiex_private *priv, const u8 *peer,
1236 u8 *peer, u8 action_code, u8 dialog_token, 1234 u8 action_code, u8 dialog_token,
1237 u16 status_code, const u8 *extra_ies, 1235 u16 status_code, const u8 *extra_ies,
1238 size_t extra_ies_len); 1236 size_t extra_ies_len);
1239void mwifiex_process_tdls_action_frame(struct mwifiex_private *priv, 1237void mwifiex_process_tdls_action_frame(struct mwifiex_private *priv,
1240 u8 *buf, int len); 1238 u8 *buf, int len);
1241int mwifiex_tdls_oper(struct mwifiex_private *priv, u8 *peer, u8 action); 1239int mwifiex_tdls_oper(struct mwifiex_private *priv, const u8 *peer, u8 action);
1242int mwifiex_get_tdls_link_status(struct mwifiex_private *priv, u8 *mac); 1240int mwifiex_get_tdls_link_status(struct mwifiex_private *priv, const u8 *mac);
1243void mwifiex_disable_all_tdls_links(struct mwifiex_private *priv); 1241void mwifiex_disable_all_tdls_links(struct mwifiex_private *priv);
1244bool mwifiex_is_bss_in_11ac_mode(struct mwifiex_private *priv); 1242bool mwifiex_is_bss_in_11ac_mode(struct mwifiex_private *priv);
1245u8 mwifiex_get_center_freq_index(struct mwifiex_private *priv, u8 band, 1243u8 mwifiex_get_center_freq_index(struct mwifiex_private *priv, u8 band,
diff --git a/drivers/net/wireless/mwifiex/tdls.c b/drivers/net/wireless/mwifiex/tdls.c
index 6bef47c2a70d..e14fbb5de49b 100644
--- a/drivers/net/wireless/mwifiex/tdls.c
+++ b/drivers/net/wireless/mwifiex/tdls.c
@@ -25,8 +25,8 @@
25#define TDLS_RESP_FIX_LEN 8 25#define TDLS_RESP_FIX_LEN 8
26#define TDLS_CONFIRM_FIX_LEN 6 26#define TDLS_CONFIRM_FIX_LEN 6
27 27
28static void 28static void mwifiex_restore_tdls_packets(struct mwifiex_private *priv,
29mwifiex_restore_tdls_packets(struct mwifiex_private *priv, u8 *mac, u8 status) 29 const u8 *mac, u8 status)
30{ 30{
31 struct mwifiex_ra_list_tbl *ra_list; 31 struct mwifiex_ra_list_tbl *ra_list;
32 struct list_head *tid_list; 32 struct list_head *tid_list;
@@ -84,7 +84,8 @@ mwifiex_restore_tdls_packets(struct mwifiex_private *priv, u8 *mac, u8 status)
84 return; 84 return;
85} 85}
86 86
87static void mwifiex_hold_tdls_packets(struct mwifiex_private *priv, u8 *mac) 87static void mwifiex_hold_tdls_packets(struct mwifiex_private *priv,
88 const u8 *mac)
88{ 89{
89 struct mwifiex_ra_list_tbl *ra_list; 90 struct mwifiex_ra_list_tbl *ra_list;
90 struct list_head *ra_list_head; 91 struct list_head *ra_list_head;
@@ -228,7 +229,7 @@ mwifiex_tdls_add_ht_oper(struct mwifiex_private *priv, u8 *mac,
228} 229}
229 230
230static int mwifiex_tdls_add_vht_oper(struct mwifiex_private *priv, 231static int mwifiex_tdls_add_vht_oper(struct mwifiex_private *priv,
231 u8 *mac, struct sk_buff *skb) 232 const u8 *mac, struct sk_buff *skb)
232{ 233{
233 struct mwifiex_bssdescriptor *bss_desc; 234 struct mwifiex_bssdescriptor *bss_desc;
234 struct ieee80211_vht_operation *vht_oper; 235 struct ieee80211_vht_operation *vht_oper;
@@ -367,8 +368,9 @@ static void mwifiex_tdls_add_qos_capab(struct sk_buff *skb)
367} 368}
368 369
369static int mwifiex_prep_tdls_encap_data(struct mwifiex_private *priv, 370static int mwifiex_prep_tdls_encap_data(struct mwifiex_private *priv,
370 u8 *peer, u8 action_code, u8 dialog_token, 371 const u8 *peer, u8 action_code,
371 u16 status_code, struct sk_buff *skb) 372 u8 dialog_token,
373 u16 status_code, struct sk_buff *skb)
372{ 374{
373 struct ieee80211_tdls_data *tf; 375 struct ieee80211_tdls_data *tf;
374 int ret; 376 int ret;
@@ -506,7 +508,8 @@ static int mwifiex_prep_tdls_encap_data(struct mwifiex_private *priv,
506} 508}
507 509
508static void 510static void
509mwifiex_tdls_add_link_ie(struct sk_buff *skb, u8 *src_addr, u8 *peer, u8 *bssid) 511mwifiex_tdls_add_link_ie(struct sk_buff *skb, const u8 *src_addr,
512 const u8 *peer, const u8 *bssid)
510{ 513{
511 struct ieee80211_tdls_lnkie *lnkid; 514 struct ieee80211_tdls_lnkie *lnkid;
512 515
@@ -520,8 +523,8 @@ mwifiex_tdls_add_link_ie(struct sk_buff *skb, u8 *src_addr, u8 *peer, u8 *bssid)
520 memcpy(lnkid->resp_sta, peer, ETH_ALEN); 523 memcpy(lnkid->resp_sta, peer, ETH_ALEN);
521} 524}
522 525
523int mwifiex_send_tdls_data_frame(struct mwifiex_private *priv, 526int mwifiex_send_tdls_data_frame(struct mwifiex_private *priv, const u8 *peer,
524 u8 *peer, u8 action_code, u8 dialog_token, 527 u8 action_code, u8 dialog_token,
525 u16 status_code, const u8 *extra_ies, 528 u16 status_code, const u8 *extra_ies,
526 size_t extra_ies_len) 529 size_t extra_ies_len)
527{ 530{
@@ -613,7 +616,8 @@ int mwifiex_send_tdls_data_frame(struct mwifiex_private *priv,
613} 616}
614 617
615static int 618static int
616mwifiex_construct_tdls_action_frame(struct mwifiex_private *priv, u8 *peer, 619mwifiex_construct_tdls_action_frame(struct mwifiex_private *priv,
620 const u8 *peer,
617 u8 action_code, u8 dialog_token, 621 u8 action_code, u8 dialog_token,
618 u16 status_code, struct sk_buff *skb) 622 u16 status_code, struct sk_buff *skb)
619{ 623{
@@ -691,10 +695,10 @@ mwifiex_construct_tdls_action_frame(struct mwifiex_private *priv, u8 *peer,
691 return 0; 695 return 0;
692} 696}
693 697
694int mwifiex_send_tdls_action_frame(struct mwifiex_private *priv, 698int mwifiex_send_tdls_action_frame(struct mwifiex_private *priv, const u8 *peer,
695 u8 *peer, u8 action_code, u8 dialog_token, 699 u8 action_code, u8 dialog_token,
696 u16 status_code, const u8 *extra_ies, 700 u16 status_code, const u8 *extra_ies,
697 size_t extra_ies_len) 701 size_t extra_ies_len)
698{ 702{
699 struct sk_buff *skb; 703 struct sk_buff *skb;
700 struct mwifiex_txinfo *tx_info; 704 struct mwifiex_txinfo *tx_info;
@@ -901,7 +905,7 @@ void mwifiex_process_tdls_action_frame(struct mwifiex_private *priv,
901} 905}
902 906
903static int 907static int
904mwifiex_tdls_process_config_link(struct mwifiex_private *priv, u8 *peer) 908mwifiex_tdls_process_config_link(struct mwifiex_private *priv, const u8 *peer)
905{ 909{
906 struct mwifiex_sta_node *sta_ptr; 910 struct mwifiex_sta_node *sta_ptr;
907 struct mwifiex_ds_tdls_oper tdls_oper; 911 struct mwifiex_ds_tdls_oper tdls_oper;
@@ -922,7 +926,7 @@ mwifiex_tdls_process_config_link(struct mwifiex_private *priv, u8 *peer)
922} 926}
923 927
924static int 928static int
925mwifiex_tdls_process_create_link(struct mwifiex_private *priv, u8 *peer) 929mwifiex_tdls_process_create_link(struct mwifiex_private *priv, const u8 *peer)
926{ 930{
927 struct mwifiex_sta_node *sta_ptr; 931 struct mwifiex_sta_node *sta_ptr;
928 struct mwifiex_ds_tdls_oper tdls_oper; 932 struct mwifiex_ds_tdls_oper tdls_oper;
@@ -949,7 +953,7 @@ mwifiex_tdls_process_create_link(struct mwifiex_private *priv, u8 *peer)
949} 953}
950 954
951static int 955static int
952mwifiex_tdls_process_disable_link(struct mwifiex_private *priv, u8 *peer) 956mwifiex_tdls_process_disable_link(struct mwifiex_private *priv, const u8 *peer)
953{ 957{
954 struct mwifiex_sta_node *sta_ptr; 958 struct mwifiex_sta_node *sta_ptr;
955 struct mwifiex_ds_tdls_oper tdls_oper; 959 struct mwifiex_ds_tdls_oper tdls_oper;
@@ -978,7 +982,7 @@ mwifiex_tdls_process_disable_link(struct mwifiex_private *priv, u8 *peer)
978} 982}
979 983
980static int 984static int
981mwifiex_tdls_process_enable_link(struct mwifiex_private *priv, u8 *peer) 985mwifiex_tdls_process_enable_link(struct mwifiex_private *priv, const u8 *peer)
982{ 986{
983 struct mwifiex_sta_node *sta_ptr; 987 struct mwifiex_sta_node *sta_ptr;
984 struct ieee80211_mcs_info mcs; 988 struct ieee80211_mcs_info mcs;
@@ -1035,7 +1039,7 @@ mwifiex_tdls_process_enable_link(struct mwifiex_private *priv, u8 *peer)
1035 return 0; 1039 return 0;
1036} 1040}
1037 1041
1038int mwifiex_tdls_oper(struct mwifiex_private *priv, u8 *peer, u8 action) 1042int mwifiex_tdls_oper(struct mwifiex_private *priv, const u8 *peer, u8 action)
1039{ 1043{
1040 switch (action) { 1044 switch (action) {
1041 case MWIFIEX_TDLS_ENABLE_LINK: 1045 case MWIFIEX_TDLS_ENABLE_LINK:
@@ -1050,7 +1054,7 @@ int mwifiex_tdls_oper(struct mwifiex_private *priv, u8 *peer, u8 action)
1050 return 0; 1054 return 0;
1051} 1055}
1052 1056
1053int mwifiex_get_tdls_link_status(struct mwifiex_private *priv, u8 *mac) 1057int mwifiex_get_tdls_link_status(struct mwifiex_private *priv, const u8 *mac)
1054{ 1058{
1055 struct mwifiex_sta_node *sta_ptr; 1059 struct mwifiex_sta_node *sta_ptr;
1056 1060
diff --git a/drivers/net/wireless/mwifiex/util.c b/drivers/net/wireless/mwifiex/util.c
index c3824e37f3f2..6da5abf52e61 100644
--- a/drivers/net/wireless/mwifiex/util.c
+++ b/drivers/net/wireless/mwifiex/util.c
@@ -259,7 +259,7 @@ int mwifiex_complete_cmd(struct mwifiex_adapter *adapter,
259 * NULL is returned if station entry is not found in associated STA list. 259 * NULL is returned if station entry is not found in associated STA list.
260 */ 260 */
261struct mwifiex_sta_node * 261struct mwifiex_sta_node *
262mwifiex_get_sta_entry(struct mwifiex_private *priv, u8 *mac) 262mwifiex_get_sta_entry(struct mwifiex_private *priv, const u8 *mac)
263{ 263{
264 struct mwifiex_sta_node *node; 264 struct mwifiex_sta_node *node;
265 265
@@ -280,7 +280,7 @@ mwifiex_get_sta_entry(struct mwifiex_private *priv, u8 *mac)
280 * If received mac address is NULL, NULL is returned. 280 * If received mac address is NULL, NULL is returned.
281 */ 281 */
282struct mwifiex_sta_node * 282struct mwifiex_sta_node *
283mwifiex_add_sta_entry(struct mwifiex_private *priv, u8 *mac) 283mwifiex_add_sta_entry(struct mwifiex_private *priv, const u8 *mac)
284{ 284{
285 struct mwifiex_sta_node *node; 285 struct mwifiex_sta_node *node;
286 unsigned long flags; 286 unsigned long flags;
@@ -332,7 +332,7 @@ mwifiex_set_sta_ht_cap(struct mwifiex_private *priv, const u8 *ies,
332} 332}
333 333
334/* This function will delete a station entry from station list */ 334/* This function will delete a station entry from station list */
335void mwifiex_del_sta_entry(struct mwifiex_private *priv, u8 *mac) 335void mwifiex_del_sta_entry(struct mwifiex_private *priv, const u8 *mac)
336{ 336{
337 struct mwifiex_sta_node *node; 337 struct mwifiex_sta_node *node;
338 unsigned long flags; 338 unsigned long flags;
diff --git a/drivers/net/wireless/mwifiex/wmm.c b/drivers/net/wireless/mwifiex/wmm.c
index 94b6c74ba727..789b86f80594 100644
--- a/drivers/net/wireless/mwifiex/wmm.c
+++ b/drivers/net/wireless/mwifiex/wmm.c
@@ -92,7 +92,7 @@ mwifiex_wmm_ac_debug_print(const struct ieee_types_wmm_ac_parameters *ac_param)
92 * The function also initializes the list with the provided RA. 92 * The function also initializes the list with the provided RA.
93 */ 93 */
94static struct mwifiex_ra_list_tbl * 94static struct mwifiex_ra_list_tbl *
95mwifiex_wmm_allocate_ralist_node(struct mwifiex_adapter *adapter, u8 *ra) 95mwifiex_wmm_allocate_ralist_node(struct mwifiex_adapter *adapter, const u8 *ra)
96{ 96{
97 struct mwifiex_ra_list_tbl *ra_list; 97 struct mwifiex_ra_list_tbl *ra_list;
98 98
@@ -139,8 +139,7 @@ static u8 mwifiex_get_random_ba_threshold(void)
139 * This function allocates and adds a RA list for all TIDs 139 * This function allocates and adds a RA list for all TIDs
140 * with the given RA. 140 * with the given RA.
141 */ 141 */
142void 142void mwifiex_ralist_add(struct mwifiex_private *priv, const u8 *ra)
143mwifiex_ralist_add(struct mwifiex_private *priv, u8 *ra)
144{ 143{
145 int i; 144 int i;
146 struct mwifiex_ra_list_tbl *ra_list; 145 struct mwifiex_ra_list_tbl *ra_list;
@@ -566,7 +565,7 @@ mwifiex_clean_txrx(struct mwifiex_private *priv)
566 */ 565 */
567static struct mwifiex_ra_list_tbl * 566static struct mwifiex_ra_list_tbl *
568mwifiex_wmm_get_ralist_node(struct mwifiex_private *priv, u8 tid, 567mwifiex_wmm_get_ralist_node(struct mwifiex_private *priv, u8 tid,
569 u8 *ra_addr) 568 const u8 *ra_addr)
570{ 569{
571 struct mwifiex_ra_list_tbl *ra_list; 570 struct mwifiex_ra_list_tbl *ra_list;
572 571
@@ -587,7 +586,8 @@ mwifiex_wmm_get_ralist_node(struct mwifiex_private *priv, u8 tid,
587 * retrieved. 586 * retrieved.
588 */ 587 */
589struct mwifiex_ra_list_tbl * 588struct mwifiex_ra_list_tbl *
590mwifiex_wmm_get_queue_raptr(struct mwifiex_private *priv, u8 tid, u8 *ra_addr) 589mwifiex_wmm_get_queue_raptr(struct mwifiex_private *priv, u8 tid,
590 const u8 *ra_addr)
591{ 591{
592 struct mwifiex_ra_list_tbl *ra_list; 592 struct mwifiex_ra_list_tbl *ra_list;
593 593
diff --git a/drivers/net/wireless/mwifiex/wmm.h b/drivers/net/wireless/mwifiex/wmm.h
index 83e42083ebff..eca56e371a57 100644
--- a/drivers/net/wireless/mwifiex/wmm.h
+++ b/drivers/net/wireless/mwifiex/wmm.h
@@ -99,7 +99,7 @@ mwifiex_wmm_is_ra_list_empty(struct list_head *ra_list_hhead)
99 99
100void mwifiex_wmm_add_buf_txqueue(struct mwifiex_private *priv, 100void mwifiex_wmm_add_buf_txqueue(struct mwifiex_private *priv,
101 struct sk_buff *skb); 101 struct sk_buff *skb);
102void mwifiex_ralist_add(struct mwifiex_private *priv, u8 *ra); 102void mwifiex_ralist_add(struct mwifiex_private *priv, const u8 *ra);
103void mwifiex_rotate_priolists(struct mwifiex_private *priv, 103void mwifiex_rotate_priolists(struct mwifiex_private *priv,
104 struct mwifiex_ra_list_tbl *ra, int tid); 104 struct mwifiex_ra_list_tbl *ra, int tid);
105 105
@@ -123,7 +123,8 @@ void mwifiex_wmm_setup_ac_downgrade(struct mwifiex_private *priv);
123int mwifiex_ret_wmm_get_status(struct mwifiex_private *priv, 123int mwifiex_ret_wmm_get_status(struct mwifiex_private *priv,
124 const struct host_cmd_ds_command *resp); 124 const struct host_cmd_ds_command *resp);
125struct mwifiex_ra_list_tbl * 125struct mwifiex_ra_list_tbl *
126mwifiex_wmm_get_queue_raptr(struct mwifiex_private *priv, u8 tid, u8 *ra_addr); 126mwifiex_wmm_get_queue_raptr(struct mwifiex_private *priv, u8 tid,
127 const u8 *ra_addr);
127u8 mwifiex_wmm_downgrade_tid(struct mwifiex_private *priv, u32 tid); 128u8 mwifiex_wmm_downgrade_tid(struct mwifiex_private *priv, u32 tid);
128 129
129#endif /* !_MWIFIEX_WMM_H_ */ 130#endif /* !_MWIFIEX_WMM_H_ */
diff --git a/drivers/net/wireless/orinoco/hw.c b/drivers/net/wireless/orinoco/hw.c
index 49300d04efdf..e27e32851f1e 100644
--- a/drivers/net/wireless/orinoco/hw.c
+++ b/drivers/net/wireless/orinoco/hw.c
@@ -988,8 +988,8 @@ int __orinoco_hw_setup_enc(struct orinoco_private *priv)
988 * tsc must be NULL or up to 8 bytes 988 * tsc must be NULL or up to 8 bytes
989 */ 989 */
990int __orinoco_hw_set_tkip_key(struct orinoco_private *priv, int key_idx, 990int __orinoco_hw_set_tkip_key(struct orinoco_private *priv, int key_idx,
991 int set_tx, u8 *key, u8 *rsc, size_t rsc_len, 991 int set_tx, const u8 *key, const u8 *rsc,
992 u8 *tsc, size_t tsc_len) 992 size_t rsc_len, const u8 *tsc, size_t tsc_len)
993{ 993{
994 struct { 994 struct {
995 __le16 idx; 995 __le16 idx;
diff --git a/drivers/net/wireless/orinoco/hw.h b/drivers/net/wireless/orinoco/hw.h
index 8f6831f4e328..466d1ede76f1 100644
--- a/drivers/net/wireless/orinoco/hw.h
+++ b/drivers/net/wireless/orinoco/hw.h
@@ -38,8 +38,8 @@ int __orinoco_hw_set_wap(struct orinoco_private *priv);
38int __orinoco_hw_setup_wepkeys(struct orinoco_private *priv); 38int __orinoco_hw_setup_wepkeys(struct orinoco_private *priv);
39int __orinoco_hw_setup_enc(struct orinoco_private *priv); 39int __orinoco_hw_setup_enc(struct orinoco_private *priv);
40int __orinoco_hw_set_tkip_key(struct orinoco_private *priv, int key_idx, 40int __orinoco_hw_set_tkip_key(struct orinoco_private *priv, int key_idx,
41 int set_tx, u8 *key, u8 *rsc, size_t rsc_len, 41 int set_tx, const u8 *key, const u8 *rsc,
42 u8 *tsc, size_t tsc_len); 42 size_t rsc_len, const u8 *tsc, size_t tsc_len);
43int orinoco_clear_tkip_key(struct orinoco_private *priv, int key_idx); 43int orinoco_clear_tkip_key(struct orinoco_private *priv, int key_idx);
44int __orinoco_hw_set_multicast_list(struct orinoco_private *priv, 44int __orinoco_hw_set_multicast_list(struct orinoco_private *priv,
45 struct net_device *dev, 45 struct net_device *dev,
diff --git a/drivers/net/wireless/orinoco/wext.c b/drivers/net/wireless/orinoco/wext.c
index b7a867b50b94..6abdaf0aa052 100644
--- a/drivers/net/wireless/orinoco/wext.c
+++ b/drivers/net/wireless/orinoco/wext.c
@@ -52,9 +52,9 @@ static int orinoco_set_key(struct orinoco_private *priv, int index,
52 priv->keys[index].seq_len = seq_len; 52 priv->keys[index].seq_len = seq_len;
53 53
54 if (key_len) 54 if (key_len)
55 memcpy(priv->keys[index].key, key, key_len); 55 memcpy((void *)priv->keys[index].key, key, key_len);
56 if (seq_len) 56 if (seq_len)
57 memcpy(priv->keys[index].seq, seq, seq_len); 57 memcpy((void *)priv->keys[index].seq, seq, seq_len);
58 58
59 switch (alg) { 59 switch (alg) {
60 case ORINOCO_ALG_TKIP: 60 case ORINOCO_ALG_TKIP:
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index 39d22a154341..d2a9a08210be 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -517,7 +517,7 @@ static int rndis_set_default_key(struct wiphy *wiphy, struct net_device *netdev,
517 u8 key_index, bool unicast, bool multicast); 517 u8 key_index, bool unicast, bool multicast);
518 518
519static int rndis_get_station(struct wiphy *wiphy, struct net_device *dev, 519static int rndis_get_station(struct wiphy *wiphy, struct net_device *dev,
520 u8 *mac, struct station_info *sinfo); 520 const u8 *mac, struct station_info *sinfo);
521 521
522static int rndis_dump_station(struct wiphy *wiphy, struct net_device *dev, 522static int rndis_dump_station(struct wiphy *wiphy, struct net_device *dev,
523 int idx, u8 *mac, struct station_info *sinfo); 523 int idx, u8 *mac, struct station_info *sinfo);
@@ -2490,7 +2490,7 @@ static void rndis_fill_station_info(struct usbnet *usbdev,
2490} 2490}
2491 2491
2492static int rndis_get_station(struct wiphy *wiphy, struct net_device *dev, 2492static int rndis_get_station(struct wiphy *wiphy, struct net_device *dev,
2493 u8 *mac, struct station_info *sinfo) 2493 const u8 *mac, struct station_info *sinfo)
2494{ 2494{
2495 struct rndis_wlan_private *priv = wiphy_priv(wiphy); 2495 struct rndis_wlan_private *priv = wiphy_priv(wiphy);
2496 struct usbnet *usbdev = priv->usbdev; 2496 struct usbnet *usbdev = priv->usbdev;
diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c
index 077eb5b9cd74..02c91d6db753 100644
--- a/drivers/net/wireless/ti/wlcore/main.c
+++ b/drivers/net/wireless/ti/wlcore/main.c
@@ -1416,7 +1416,7 @@ void wl1271_rx_filter_free(struct wl12xx_rx_filter *filter)
1416 1416
1417int wl1271_rx_filter_alloc_field(struct wl12xx_rx_filter *filter, 1417int wl1271_rx_filter_alloc_field(struct wl12xx_rx_filter *filter,
1418 u16 offset, u8 flags, 1418 u16 offset, u8 flags,
1419 u8 *pattern, u8 len) 1419 const u8 *pattern, u8 len)
1420{ 1420{
1421 struct wl12xx_rx_filter_field *field; 1421 struct wl12xx_rx_filter_field *field;
1422 1422
diff --git a/drivers/net/wireless/ti/wlcore/wlcore_i.h b/drivers/net/wireless/ti/wlcore/wlcore_i.h
index 756e890bc5ee..c2c34a84ff3d 100644
--- a/drivers/net/wireless/ti/wlcore/wlcore_i.h
+++ b/drivers/net/wireless/ti/wlcore/wlcore_i.h
@@ -512,8 +512,8 @@ int wl1271_recalc_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif);
512void wl12xx_queue_recovery_work(struct wl1271 *wl); 512void wl12xx_queue_recovery_work(struct wl1271 *wl);
513size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen); 513size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen);
514int wl1271_rx_filter_alloc_field(struct wl12xx_rx_filter *filter, 514int wl1271_rx_filter_alloc_field(struct wl12xx_rx_filter *filter,
515 u16 offset, u8 flags, 515 u16 offset, u8 flags,
516 u8 *pattern, u8 len); 516 const u8 *pattern, u8 len);
517void wl1271_rx_filter_free(struct wl12xx_rx_filter *filter); 517void wl1271_rx_filter_free(struct wl12xx_rx_filter *filter);
518struct wl12xx_rx_filter *wl1271_rx_filter_alloc(void); 518struct wl12xx_rx_filter *wl1271_rx_filter_alloc(void);
519int wl1271_rx_filter_get_fields_size(struct wl12xx_rx_filter *filter); 519int wl1271_rx_filter_get_fields_size(struct wl12xx_rx_filter *filter);
diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c
index f76f95c29617..723319ee08f3 100644
--- a/drivers/staging/wlan-ng/cfg80211.c
+++ b/drivers/staging/wlan-ng/cfg80211.c
@@ -84,7 +84,7 @@ static int prism2_domibset_uint32(wlandevice_t *wlandev, u32 did, u32 data)
84} 84}
85 85
86static int prism2_domibset_pstr32(wlandevice_t *wlandev, 86static int prism2_domibset_pstr32(wlandevice_t *wlandev,
87 u32 did, u8 len, u8 *data) 87 u32 did, u8 len, const u8 *data)
88{ 88{
89 struct p80211msg_dot11req_mibset msg; 89 struct p80211msg_dot11req_mibset msg;
90 p80211item_pstr32_t *mibitem = 90 p80211item_pstr32_t *mibitem =
@@ -298,7 +298,7 @@ static int prism2_set_default_key(struct wiphy *wiphy, struct net_device *dev,
298 298
299 299
300static int prism2_get_station(struct wiphy *wiphy, struct net_device *dev, 300static int prism2_get_station(struct wiphy *wiphy, struct net_device *dev,
301 u8 *mac, struct station_info *sinfo) 301 const u8 *mac, struct station_info *sinfo)
302{ 302{
303 wlandevice_t *wlandev = dev->ml_priv; 303 wlandevice_t *wlandev = dev->ml_priv;
304 struct p80211msg_lnxreq_commsquality quality; 304 struct p80211msg_lnxreq_commsquality quality;
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index f2c318655519..e46c437944f7 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -341,8 +341,8 @@ struct vif_params {
341 * @seq_len: length of @seq. 341 * @seq_len: length of @seq.
342 */ 342 */
343struct key_params { 343struct key_params {
344 u8 *key; 344 const u8 *key;
345 u8 *seq; 345 const u8 *seq;
346 int key_len; 346 int key_len;
347 int seq_len; 347 int seq_len;
348 u32 cipher; 348 u32 cipher;
@@ -458,7 +458,7 @@ bool cfg80211_chandef_usable(struct wiphy *wiphy,
458 */ 458 */
459int cfg80211_chandef_dfs_required(struct wiphy *wiphy, 459int cfg80211_chandef_dfs_required(struct wiphy *wiphy,
460 const struct cfg80211_chan_def *chandef, 460 const struct cfg80211_chan_def *chandef,
461 enum nl80211_iftype); 461 enum nl80211_iftype iftype);
462 462
463/** 463/**
464 * ieee80211_chandef_rate_flags - returns rate flags for a channel 464 * ieee80211_chandef_rate_flags - returns rate flags for a channel
@@ -694,8 +694,10 @@ struct cfg80211_ap_settings {
694 * 694 *
695 * @chandef: defines the channel to use after the switch 695 * @chandef: defines the channel to use after the switch
696 * @beacon_csa: beacon data while performing the switch 696 * @beacon_csa: beacon data while performing the switch
697 * @counter_offset_beacon: offset for the counter within the beacon (tail) 697 * @counter_offsets_beacon: offsets of the counters within the beacon (tail)
698 * @counter_offset_presp: offset for the counter within the probe response 698 * @counter_offsets_presp: offsets of the counters within the probe response
699 * @n_counter_offsets_beacon: number of csa counters the beacon (tail)
700 * @n_counter_offsets_presp: number of csa counters in the probe response
699 * @beacon_after: beacon data to be used on the new channel 701 * @beacon_after: beacon data to be used on the new channel
700 * @radar_required: whether radar detection is required on the new channel 702 * @radar_required: whether radar detection is required on the new channel
701 * @block_tx: whether transmissions should be blocked while changing 703 * @block_tx: whether transmissions should be blocked while changing
@@ -704,7 +706,10 @@ struct cfg80211_ap_settings {
704struct cfg80211_csa_settings { 706struct cfg80211_csa_settings {
705 struct cfg80211_chan_def chandef; 707 struct cfg80211_chan_def chandef;
706 struct cfg80211_beacon_data beacon_csa; 708 struct cfg80211_beacon_data beacon_csa;
707 u16 counter_offset_beacon, counter_offset_presp; 709 const u16 *counter_offsets_beacon;
710 const u16 *counter_offsets_presp;
711 unsigned int n_counter_offsets_beacon;
712 unsigned int n_counter_offsets_presp;
708 struct cfg80211_beacon_data beacon_after; 713 struct cfg80211_beacon_data beacon_after;
709 bool radar_required; 714 bool radar_required;
710 bool block_tx; 715 bool block_tx;
@@ -868,36 +873,38 @@ int cfg80211_check_station_change(struct wiphy *wiphy,
868 * @STATION_INFO_NONPEER_PM: @nonpeer_pm filled 873 * @STATION_INFO_NONPEER_PM: @nonpeer_pm filled
869 * @STATION_INFO_CHAIN_SIGNAL: @chain_signal filled 874 * @STATION_INFO_CHAIN_SIGNAL: @chain_signal filled
870 * @STATION_INFO_CHAIN_SIGNAL_AVG: @chain_signal_avg filled 875 * @STATION_INFO_CHAIN_SIGNAL_AVG: @chain_signal_avg filled
876 * @STATION_INFO_EXPECTED_THROUGHPUT: @expected_throughput filled
871 */ 877 */
872enum station_info_flags { 878enum station_info_flags {
873 STATION_INFO_INACTIVE_TIME = 1<<0, 879 STATION_INFO_INACTIVE_TIME = BIT(0),
874 STATION_INFO_RX_BYTES = 1<<1, 880 STATION_INFO_RX_BYTES = BIT(1),
875 STATION_INFO_TX_BYTES = 1<<2, 881 STATION_INFO_TX_BYTES = BIT(2),
876 STATION_INFO_LLID = 1<<3, 882 STATION_INFO_LLID = BIT(3),
877 STATION_INFO_PLID = 1<<4, 883 STATION_INFO_PLID = BIT(4),
878 STATION_INFO_PLINK_STATE = 1<<5, 884 STATION_INFO_PLINK_STATE = BIT(5),
879 STATION_INFO_SIGNAL = 1<<6, 885 STATION_INFO_SIGNAL = BIT(6),
880 STATION_INFO_TX_BITRATE = 1<<7, 886 STATION_INFO_TX_BITRATE = BIT(7),
881 STATION_INFO_RX_PACKETS = 1<<8, 887 STATION_INFO_RX_PACKETS = BIT(8),
882 STATION_INFO_TX_PACKETS = 1<<9, 888 STATION_INFO_TX_PACKETS = BIT(9),
883 STATION_INFO_TX_RETRIES = 1<<10, 889 STATION_INFO_TX_RETRIES = BIT(10),
884 STATION_INFO_TX_FAILED = 1<<11, 890 STATION_INFO_TX_FAILED = BIT(11),
885 STATION_INFO_RX_DROP_MISC = 1<<12, 891 STATION_INFO_RX_DROP_MISC = BIT(12),
886 STATION_INFO_SIGNAL_AVG = 1<<13, 892 STATION_INFO_SIGNAL_AVG = BIT(13),
887 STATION_INFO_RX_BITRATE = 1<<14, 893 STATION_INFO_RX_BITRATE = BIT(14),
888 STATION_INFO_BSS_PARAM = 1<<15, 894 STATION_INFO_BSS_PARAM = BIT(15),
889 STATION_INFO_CONNECTED_TIME = 1<<16, 895 STATION_INFO_CONNECTED_TIME = BIT(16),
890 STATION_INFO_ASSOC_REQ_IES = 1<<17, 896 STATION_INFO_ASSOC_REQ_IES = BIT(17),
891 STATION_INFO_STA_FLAGS = 1<<18, 897 STATION_INFO_STA_FLAGS = BIT(18),
892 STATION_INFO_BEACON_LOSS_COUNT = 1<<19, 898 STATION_INFO_BEACON_LOSS_COUNT = BIT(19),
893 STATION_INFO_T_OFFSET = 1<<20, 899 STATION_INFO_T_OFFSET = BIT(20),
894 STATION_INFO_LOCAL_PM = 1<<21, 900 STATION_INFO_LOCAL_PM = BIT(21),
895 STATION_INFO_PEER_PM = 1<<22, 901 STATION_INFO_PEER_PM = BIT(22),
896 STATION_INFO_NONPEER_PM = 1<<23, 902 STATION_INFO_NONPEER_PM = BIT(23),
897 STATION_INFO_RX_BYTES64 = 1<<24, 903 STATION_INFO_RX_BYTES64 = BIT(24),
898 STATION_INFO_TX_BYTES64 = 1<<25, 904 STATION_INFO_TX_BYTES64 = BIT(25),
899 STATION_INFO_CHAIN_SIGNAL = 1<<26, 905 STATION_INFO_CHAIN_SIGNAL = BIT(26),
900 STATION_INFO_CHAIN_SIGNAL_AVG = 1<<27, 906 STATION_INFO_CHAIN_SIGNAL_AVG = BIT(27),
907 STATION_INFO_EXPECTED_THROUGHPUT = BIT(28),
901}; 908};
902 909
903/** 910/**
@@ -1019,6 +1026,8 @@ struct sta_bss_parameters {
1019 * @local_pm: local mesh STA power save mode 1026 * @local_pm: local mesh STA power save mode
1020 * @peer_pm: peer mesh STA power save mode 1027 * @peer_pm: peer mesh STA power save mode
1021 * @nonpeer_pm: non-peer mesh STA power save mode 1028 * @nonpeer_pm: non-peer mesh STA power save mode
1029 * @expected_throughput: expected throughput in kbps (including 802.11 headers)
1030 * towards this station.
1022 */ 1031 */
1023struct station_info { 1032struct station_info {
1024 u32 filled; 1033 u32 filled;
@@ -1057,6 +1066,8 @@ struct station_info {
1057 enum nl80211_mesh_power_mode peer_pm; 1066 enum nl80211_mesh_power_mode peer_pm;
1058 enum nl80211_mesh_power_mode nonpeer_pm; 1067 enum nl80211_mesh_power_mode nonpeer_pm;
1059 1068
1069 u32 expected_throughput;
1070
1060 /* 1071 /*
1061 * Note: Add a new enum station_info_flags value for each new field and 1072 * Note: Add a new enum station_info_flags value for each new field and
1062 * use it to check which fields are initialized. 1073 * use it to check which fields are initialized.
@@ -1064,6 +1075,19 @@ struct station_info {
1064}; 1075};
1065 1076
1066/** 1077/**
1078 * cfg80211_get_station - retrieve information about a given station
1079 * @dev: the device where the station is supposed to be connected to
1080 * @mac_addr: the mac address of the station of interest
1081 * @sinfo: pointer to the structure to fill with the information
1082 *
1083 * Returns 0 on success and sinfo is filled with the available information
1084 * otherwise returns a negative error code and the content of sinfo has to be
1085 * considered undefined.
1086 */
1087int cfg80211_get_station(struct net_device *dev, const u8 *mac_addr,
1088 struct station_info *sinfo);
1089
1090/**
1067 * enum monitor_flags - monitor flags 1091 * enum monitor_flags - monitor flags
1068 * 1092 *
1069 * Monitor interface configuration flags. Note that these must be the bits 1093 * Monitor interface configuration flags. Note that these must be the bits
@@ -1164,7 +1188,7 @@ struct bss_parameters {
1164 int use_cts_prot; 1188 int use_cts_prot;
1165 int use_short_preamble; 1189 int use_short_preamble;
1166 int use_short_slot_time; 1190 int use_short_slot_time;
1167 u8 *basic_rates; 1191 const u8 *basic_rates;
1168 u8 basic_rates_len; 1192 u8 basic_rates_len;
1169 int ap_isolate; 1193 int ap_isolate;
1170 int ht_opmode; 1194 int ht_opmode;
@@ -1694,10 +1718,10 @@ struct cfg80211_disassoc_request {
1694 * @ht_capa_mask: The bits of ht_capa which are to be used. 1718 * @ht_capa_mask: The bits of ht_capa which are to be used.
1695 */ 1719 */
1696struct cfg80211_ibss_params { 1720struct cfg80211_ibss_params {
1697 u8 *ssid; 1721 const u8 *ssid;
1698 u8 *bssid; 1722 const u8 *bssid;
1699 struct cfg80211_chan_def chandef; 1723 struct cfg80211_chan_def chandef;
1700 u8 *ie; 1724 const u8 *ie;
1701 u8 ssid_len, ie_len; 1725 u8 ssid_len, ie_len;
1702 u16 beacon_interval; 1726 u16 beacon_interval;
1703 u32 basic_rates; 1727 u32 basic_rates;
@@ -1806,8 +1830,8 @@ struct cfg80211_bitrate_mask {
1806 * @pmkid: The PMK material itself. 1830 * @pmkid: The PMK material itself.
1807 */ 1831 */
1808struct cfg80211_pmksa { 1832struct cfg80211_pmksa {
1809 u8 *bssid; 1833 const u8 *bssid;
1810 u8 *pmkid; 1834 const u8 *pmkid;
1811}; 1835};
1812 1836
1813/** 1837/**
@@ -1822,7 +1846,7 @@ struct cfg80211_pmksa {
1822 * memory, free @mask only! 1846 * memory, free @mask only!
1823 */ 1847 */
1824struct cfg80211_pkt_pattern { 1848struct cfg80211_pkt_pattern {
1825 u8 *mask, *pattern; 1849 const u8 *mask, *pattern;
1826 int pattern_len; 1850 int pattern_len;
1827 int pkt_offset; 1851 int pkt_offset;
1828}; 1852};
@@ -1986,6 +2010,8 @@ struct cfg80211_update_ft_ies_params {
1986 * @len: buffer length 2010 * @len: buffer length
1987 * @no_cck: don't use cck rates for this frame 2011 * @no_cck: don't use cck rates for this frame
1988 * @dont_wait_for_ack: tells the low level not to wait for an ack 2012 * @dont_wait_for_ack: tells the low level not to wait for an ack
2013 * @n_csa_offsets: length of csa_offsets array
2014 * @csa_offsets: array of all the csa offsets in the frame
1989 */ 2015 */
1990struct cfg80211_mgmt_tx_params { 2016struct cfg80211_mgmt_tx_params {
1991 struct ieee80211_channel *chan; 2017 struct ieee80211_channel *chan;
@@ -1995,6 +2021,8 @@ struct cfg80211_mgmt_tx_params {
1995 size_t len; 2021 size_t len;
1996 bool no_cck; 2022 bool no_cck;
1997 bool dont_wait_for_ack; 2023 bool dont_wait_for_ack;
2024 int n_csa_offsets;
2025 const u16 *csa_offsets;
1998}; 2026};
1999 2027
2000/** 2028/**
@@ -2336,28 +2364,29 @@ struct cfg80211_ops {
2336 2364
2337 2365
2338 int (*add_station)(struct wiphy *wiphy, struct net_device *dev, 2366 int (*add_station)(struct wiphy *wiphy, struct net_device *dev,
2339 u8 *mac, struct station_parameters *params); 2367 const u8 *mac,
2368 struct station_parameters *params);
2340 int (*del_station)(struct wiphy *wiphy, struct net_device *dev, 2369 int (*del_station)(struct wiphy *wiphy, struct net_device *dev,
2341 u8 *mac); 2370 const u8 *mac);
2342 int (*change_station)(struct wiphy *wiphy, struct net_device *dev, 2371 int (*change_station)(struct wiphy *wiphy, struct net_device *dev,
2343 u8 *mac, struct station_parameters *params); 2372 const u8 *mac,
2373 struct station_parameters *params);
2344 int (*get_station)(struct wiphy *wiphy, struct net_device *dev, 2374 int (*get_station)(struct wiphy *wiphy, struct net_device *dev,
2345 u8 *mac, struct station_info *sinfo); 2375 const u8 *mac, struct station_info *sinfo);
2346 int (*dump_station)(struct wiphy *wiphy, struct net_device *dev, 2376 int (*dump_station)(struct wiphy *wiphy, struct net_device *dev,
2347 int idx, u8 *mac, struct station_info *sinfo); 2377 int idx, u8 *mac, struct station_info *sinfo);
2348 2378
2349 int (*add_mpath)(struct wiphy *wiphy, struct net_device *dev, 2379 int (*add_mpath)(struct wiphy *wiphy, struct net_device *dev,
2350 u8 *dst, u8 *next_hop); 2380 const u8 *dst, const u8 *next_hop);
2351 int (*del_mpath)(struct wiphy *wiphy, struct net_device *dev, 2381 int (*del_mpath)(struct wiphy *wiphy, struct net_device *dev,
2352 u8 *dst); 2382 const u8 *dst);
2353 int (*change_mpath)(struct wiphy *wiphy, struct net_device *dev, 2383 int (*change_mpath)(struct wiphy *wiphy, struct net_device *dev,
2354 u8 *dst, u8 *next_hop); 2384 const u8 *dst, const u8 *next_hop);
2355 int (*get_mpath)(struct wiphy *wiphy, struct net_device *dev, 2385 int (*get_mpath)(struct wiphy *wiphy, struct net_device *dev,
2356 u8 *dst, u8 *next_hop, 2386 u8 *dst, u8 *next_hop, struct mpath_info *pinfo);
2357 struct mpath_info *pinfo);
2358 int (*dump_mpath)(struct wiphy *wiphy, struct net_device *dev, 2387 int (*dump_mpath)(struct wiphy *wiphy, struct net_device *dev,
2359 int idx, u8 *dst, u8 *next_hop, 2388 int idx, u8 *dst, u8 *next_hop,
2360 struct mpath_info *pinfo); 2389 struct mpath_info *pinfo);
2361 int (*get_mesh_config)(struct wiphy *wiphy, 2390 int (*get_mesh_config)(struct wiphy *wiphy,
2362 struct net_device *dev, 2391 struct net_device *dev,
2363 struct mesh_config *conf); 2392 struct mesh_config *conf);
@@ -2487,11 +2516,11 @@ struct cfg80211_ops {
2487 struct cfg80211_gtk_rekey_data *data); 2516 struct cfg80211_gtk_rekey_data *data);
2488 2517
2489 int (*tdls_mgmt)(struct wiphy *wiphy, struct net_device *dev, 2518 int (*tdls_mgmt)(struct wiphy *wiphy, struct net_device *dev,
2490 u8 *peer, u8 action_code, u8 dialog_token, 2519 const u8 *peer, u8 action_code, u8 dialog_token,
2491 u16 status_code, u32 peer_capability, 2520 u16 status_code, u32 peer_capability,
2492 const u8 *buf, size_t len); 2521 const u8 *buf, size_t len);
2493 int (*tdls_oper)(struct wiphy *wiphy, struct net_device *dev, 2522 int (*tdls_oper)(struct wiphy *wiphy, struct net_device *dev,
2494 u8 *peer, enum nl80211_tdls_operation oper); 2523 const u8 *peer, enum nl80211_tdls_operation oper);
2495 2524
2496 int (*probe_client)(struct wiphy *wiphy, struct net_device *dev, 2525 int (*probe_client)(struct wiphy *wiphy, struct net_device *dev,
2497 const u8 *peer, u64 *cookie); 2526 const u8 *peer, u64 *cookie);
@@ -2638,6 +2667,7 @@ struct ieee80211_iface_limit {
2638 * between infrastructure and AP types must match. This is required 2667 * between infrastructure and AP types must match. This is required
2639 * only in special cases. 2668 * only in special cases.
2640 * @radar_detect_widths: bitmap of channel widths supported for radar detection 2669 * @radar_detect_widths: bitmap of channel widths supported for radar detection
2670 * @radar_detect_regions: bitmap of regions supported for radar detection
2641 * 2671 *
2642 * With this structure the driver can describe which interface 2672 * With this structure the driver can describe which interface
2643 * combinations it supports concurrently. 2673 * combinations it supports concurrently.
@@ -2695,6 +2725,7 @@ struct ieee80211_iface_combination {
2695 u8 n_limits; 2725 u8 n_limits;
2696 bool beacon_int_infra_match; 2726 bool beacon_int_infra_match;
2697 u8 radar_detect_widths; 2727 u8 radar_detect_widths;
2728 u8 radar_detect_regions;
2698}; 2729};
2699 2730
2700struct ieee80211_txrx_stypes { 2731struct ieee80211_txrx_stypes {
@@ -2925,6 +2956,17 @@ struct wiphy_vendor_command {
2925 * (including P2P GO) or 0 to indicate no such limit is advertised. The 2956 * (including P2P GO) or 0 to indicate no such limit is advertised. The
2926 * driver is allowed to advertise a theoretical limit that it can reach in 2957 * driver is allowed to advertise a theoretical limit that it can reach in
2927 * some cases, but may not always reach. 2958 * some cases, but may not always reach.
2959 *
2960 * @max_num_csa_counters: Number of supported csa_counters in beacons
2961 * and probe responses. This value should be set if the driver
2962 * wishes to limit the number of csa counters. Default (0) means
2963 * infinite.
2964 * @max_adj_channel_rssi_comp: max offset of between the channel on which the
2965 * frame was sent and the channel on which the frame was heard for which
2966 * the reported rssi is still valid. If a driver is able to compensate the
2967 * low rssi when a frame is heard on different channel, then it should set
2968 * this variable to the maximal offset for which it can compensate.
2969 * This value should be set in MHz.
2928 */ 2970 */
2929struct wiphy { 2971struct wiphy {
2930 /* assign these fields before you register the wiphy */ 2972 /* assign these fields before you register the wiphy */
@@ -3042,6 +3084,9 @@ struct wiphy {
3042 3084
3043 u16 max_ap_assoc_sta; 3085 u16 max_ap_assoc_sta;
3044 3086
3087 u8 max_num_csa_counters;
3088 u8 max_adj_channel_rssi_comp;
3089
3045 char priv[0] __aligned(NETDEV_ALIGN); 3090 char priv[0] __aligned(NETDEV_ALIGN);
3046}; 3091};
3047 3092
@@ -3270,7 +3315,7 @@ struct wireless_dev {
3270 struct cfg80211_ibss_params ibss; 3315 struct cfg80211_ibss_params ibss;
3271 struct cfg80211_connect_params connect; 3316 struct cfg80211_connect_params connect;
3272 struct cfg80211_cached_keys *keys; 3317 struct cfg80211_cached_keys *keys;
3273 u8 *ie; 3318 const u8 *ie;
3274 size_t ie_len; 3319 size_t ie_len;
3275 u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN]; 3320 u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN];
3276 u8 ssid[IEEE80211_MAX_SSID_LEN]; 3321 u8 ssid[IEEE80211_MAX_SSID_LEN];
@@ -3511,7 +3556,8 @@ int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr,
3511 * Return: 0 on success, or a negative error code. 3556 * Return: 0 on success, or a negative error code.
3512 */ 3557 */
3513int ieee80211_data_from_8023(struct sk_buff *skb, const u8 *addr, 3558int ieee80211_data_from_8023(struct sk_buff *skb, const u8 *addr,
3514 enum nl80211_iftype iftype, u8 *bssid, bool qos); 3559 enum nl80211_iftype iftype, const u8 *bssid,
3560 bool qos);
3515 3561
3516/** 3562/**
3517 * ieee80211_amsdu_to_8023s - decode an IEEE 802.11n A-MSDU frame 3563 * ieee80211_amsdu_to_8023s - decode an IEEE 802.11n A-MSDU frame
@@ -4312,7 +4358,7 @@ void cfg80211_roamed_bss(struct net_device *dev, struct cfg80211_bss *bss,
4312 * and not try to connect to any AP any more. 4358 * and not try to connect to any AP any more.
4313 */ 4359 */
4314void cfg80211_disconnected(struct net_device *dev, u16 reason, 4360void cfg80211_disconnected(struct net_device *dev, u16 reason,
4315 u8 *ie, size_t ie_len, gfp_t gfp); 4361 const u8 *ie, size_t ie_len, gfp_t gfp);
4316 4362
4317/** 4363/**
4318 * cfg80211_ready_on_channel - notification of remain_on_channel start 4364 * cfg80211_ready_on_channel - notification of remain_on_channel start
@@ -4768,6 +4814,35 @@ int cfg80211_iter_combinations(struct wiphy *wiphy,
4768 void *data), 4814 void *data),
4769 void *data); 4815 void *data);
4770 4816
4817/*
4818 * cfg80211_stop_iface - trigger interface disconnection
4819 *
4820 * @wiphy: the wiphy
4821 * @wdev: wireless device
4822 * @gfp: context flags
4823 *
4824 * Trigger interface to be stopped as if AP was stopped, IBSS/mesh left, STA
4825 * disconnected.
4826 *
4827 * Note: This doesn't need any locks and is asynchronous.
4828 */
4829void cfg80211_stop_iface(struct wiphy *wiphy, struct wireless_dev *wdev,
4830 gfp_t gfp);
4831
4832/**
4833 * cfg80211_shutdown_all_interfaces - shut down all interfaces for a wiphy
4834 * @wiphy: the wiphy to shut down
4835 *
4836 * This function shuts down all interfaces belonging to this wiphy by
4837 * calling dev_close() (and treating non-netdev interfaces as needed).
4838 * It shouldn't really be used unless there are some fatal device errors
4839 * that really can't be recovered in any other way.
4840 *
4841 * Callers must hold the RTNL and be able to deal with callbacks into
4842 * the driver while the function is running.
4843 */
4844void cfg80211_shutdown_all_interfaces(struct wiphy *wiphy);
4845
4771/* Logging, debugging and troubleshooting/diagnostic helpers. */ 4846/* Logging, debugging and troubleshooting/diagnostic helpers. */
4772 4847
4773/* wiphy_printk helpers, similar to dev_printk */ 4848/* wiphy_printk helpers, similar to dev_printk */
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 451c1bf00df9..2c78997bc48d 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -1113,7 +1113,9 @@ enum ieee80211_vif_flags {
1113 * @addr: address of this interface 1113 * @addr: address of this interface
1114 * @p2p: indicates whether this AP or STA interface is a p2p 1114 * @p2p: indicates whether this AP or STA interface is a p2p
1115 * interface, i.e. a GO or p2p-sta respectively 1115 * interface, i.e. a GO or p2p-sta respectively
1116 * @csa_active: marks whether a channel switch is going on 1116 * @csa_active: marks whether a channel switch is going on. Internally it is
1117 * write-protected by sdata_lock and local->mtx so holding either is fine
1118 * for read access.
1117 * @driver_flags: flags/capabilities the driver has for this interface, 1119 * @driver_flags: flags/capabilities the driver has for this interface,
1118 * these need to be set (or cleared) when the interface is added 1120 * these need to be set (or cleared) when the interface is added
1119 * or, if supported by the driver, the interface type is changed 1121 * or, if supported by the driver, the interface type is changed
@@ -1374,6 +1376,7 @@ struct ieee80211_sta_rates {
1374 * the station moves to associated state. 1376 * the station moves to associated state.
1375 * @smps_mode: current SMPS mode (off, static or dynamic) 1377 * @smps_mode: current SMPS mode (off, static or dynamic)
1376 * @rates: rate control selection table 1378 * @rates: rate control selection table
1379 * @tdls: indicates whether the STA is a TDLS peer
1377 */ 1380 */
1378struct ieee80211_sta { 1381struct ieee80211_sta {
1379 u32 supp_rates[IEEE80211_NUM_BANDS]; 1382 u32 supp_rates[IEEE80211_NUM_BANDS];
@@ -1388,6 +1391,7 @@ struct ieee80211_sta {
1388 enum ieee80211_sta_rx_bandwidth bandwidth; 1391 enum ieee80211_sta_rx_bandwidth bandwidth;
1389 enum ieee80211_smps_mode smps_mode; 1392 enum ieee80211_smps_mode smps_mode;
1390 struct ieee80211_sta_rates __rcu *rates; 1393 struct ieee80211_sta_rates __rcu *rates;
1394 bool tdls;
1391 1395
1392 /* must be last */ 1396 /* must be last */
1393 u8 drv_priv[0] __aligned(sizeof(void *)); 1397 u8 drv_priv[0] __aligned(sizeof(void *));
@@ -2765,6 +2769,10 @@ enum ieee80211_roc_type {
2765 * information in bss_conf is set up and the beacon can be retrieved. A 2769 * information in bss_conf is set up and the beacon can be retrieved. A
2766 * channel context is bound before this is called. 2770 * channel context is bound before this is called.
2767 * @leave_ibss: Leave the IBSS again. 2771 * @leave_ibss: Leave the IBSS again.
2772 *
2773 * @get_expected_throughput: extract the expected throughput towards the
2774 * specified station. The returned value is expressed in Kbps. It returns 0
2775 * if the RC algorithm does not have proper data to provide.
2768 */ 2776 */
2769struct ieee80211_ops { 2777struct ieee80211_ops {
2770 void (*tx)(struct ieee80211_hw *hw, 2778 void (*tx)(struct ieee80211_hw *hw,
@@ -2958,6 +2966,7 @@ struct ieee80211_ops {
2958 2966
2959 int (*join_ibss)(struct ieee80211_hw *hw, struct ieee80211_vif *vif); 2967 int (*join_ibss)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
2960 void (*leave_ibss)(struct ieee80211_hw *hw, struct ieee80211_vif *vif); 2968 void (*leave_ibss)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
2969 u32 (*get_expected_throughput)(struct ieee80211_sta *sta);
2961}; 2970};
2962 2971
2963/** 2972/**
@@ -3407,6 +3416,47 @@ void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
3407 */ 3416 */
3408void ieee80211_report_low_ack(struct ieee80211_sta *sta, u32 num_packets); 3417void ieee80211_report_low_ack(struct ieee80211_sta *sta, u32 num_packets);
3409 3418
3419#define IEEE80211_MAX_CSA_COUNTERS_NUM 2
3420
3421/**
3422 * struct ieee80211_mutable_offsets - mutable beacon offsets
3423 * @tim_offset: position of TIM element
3424 * @tim_length: size of TIM element
3425 * @csa_counter_offs: array of IEEE80211_MAX_CSA_COUNTERS_NUM offsets
3426 * to CSA counters. This array can contain zero values which
3427 * should be ignored.
3428 */
3429struct ieee80211_mutable_offsets {
3430 u16 tim_offset;
3431 u16 tim_length;
3432
3433 u16 csa_counter_offs[IEEE80211_MAX_CSA_COUNTERS_NUM];
3434};
3435
3436/**
3437 * ieee80211_beacon_get_template - beacon template generation function
3438 * @hw: pointer obtained from ieee80211_alloc_hw().
3439 * @vif: &struct ieee80211_vif pointer from the add_interface callback.
3440 * @offs: &struct ieee80211_mutable_offsets pointer to struct that will
3441 * receive the offsets that may be updated by the driver.
3442 *
3443 * If the driver implements beaconing modes, it must use this function to
3444 * obtain the beacon template.
3445 *
3446 * This function should be used if the beacon frames are generated by the
3447 * device, and then the driver must use the returned beacon as the template
3448 * The driver or the device are responsible to update the DTIM and, when
3449 * applicable, the CSA count.
3450 *
3451 * The driver is responsible for freeing the returned skb.
3452 *
3453 * Return: The beacon template. %NULL on error.
3454 */
3455struct sk_buff *
3456ieee80211_beacon_get_template(struct ieee80211_hw *hw,
3457 struct ieee80211_vif *vif,
3458 struct ieee80211_mutable_offsets *offs);
3459
3410/** 3460/**
3411 * ieee80211_beacon_get_tim - beacon generation function 3461 * ieee80211_beacon_get_tim - beacon generation function
3412 * @hw: pointer obtained from ieee80211_alloc_hw(). 3462 * @hw: pointer obtained from ieee80211_alloc_hw().
@@ -3418,16 +3468,12 @@ void ieee80211_report_low_ack(struct ieee80211_sta *sta, u32 num_packets);
3418 * Set to 0 if invalid (in non-AP modes). 3468 * Set to 0 if invalid (in non-AP modes).
3419 * 3469 *
3420 * If the driver implements beaconing modes, it must use this function to 3470 * If the driver implements beaconing modes, it must use this function to
3421 * obtain the beacon frame/template. 3471 * obtain the beacon frame.
3422 * 3472 *
3423 * If the beacon frames are generated by the host system (i.e., not in 3473 * If the beacon frames are generated by the host system (i.e., not in
3424 * hardware/firmware), the driver uses this function to get each beacon 3474 * hardware/firmware), the driver uses this function to get each beacon
3425 * frame from mac80211 -- it is responsible for calling this function 3475 * frame from mac80211 -- it is responsible for calling this function exactly
3426 * before the beacon is needed (e.g. based on hardware interrupt). 3476 * once before the beacon is needed (e.g. based on hardware interrupt).
3427 *
3428 * If the beacon frames are generated by the device, then the driver
3429 * must use the returned beacon as the template and change the TIM IE
3430 * according to the current DTIM parameters/TIM bitmap.
3431 * 3477 *
3432 * The driver is responsible for freeing the returned skb. 3478 * The driver is responsible for freeing the returned skb.
3433 * 3479 *
@@ -3453,6 +3499,20 @@ static inline struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
3453} 3499}
3454 3500
3455/** 3501/**
3502 * ieee80211_csa_update_counter - request mac80211 to decrement the csa counter
3503 * @vif: &struct ieee80211_vif pointer from the add_interface callback.
3504 *
3505 * The csa counter should be updated after each beacon transmission.
3506 * This function is called implicitly when
3507 * ieee80211_beacon_get/ieee80211_beacon_get_tim are called, however if the
3508 * beacon frames are generated by the device, the driver should call this
3509 * function after each beacon transmission to sync mac80211's csa counters.
3510 *
3511 * Return: new csa counter value
3512 */
3513u8 ieee80211_csa_update_counter(struct ieee80211_vif *vif);
3514
3515/**
3456 * ieee80211_csa_finish - notify mac80211 about channel switch 3516 * ieee80211_csa_finish - notify mac80211 about channel switch
3457 * @vif: &struct ieee80211_vif pointer from the add_interface callback. 3517 * @vif: &struct ieee80211_vif pointer from the add_interface callback.
3458 * 3518 *
@@ -4480,6 +4540,8 @@ struct rate_control_ops {
4480 void (*add_sta_debugfs)(void *priv, void *priv_sta, 4540 void (*add_sta_debugfs)(void *priv, void *priv_sta,
4481 struct dentry *dir); 4541 struct dentry *dir);
4482 void (*remove_sta_debugfs)(void *priv, void *priv_sta); 4542 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
4543
4544 u32 (*get_expected_throughput)(void *priv_sta);
4483}; 4545};
4484 4546
4485static inline int rate_supported(struct ieee80211_sta *sta, 4547static inline int rate_supported(struct ieee80211_sta *sta,
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 406010d4def0..fb0efa1f9066 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -503,6 +503,9 @@
503 * TX status event pertaining to the TX request. 503 * TX status event pertaining to the TX request.
504 * %NL80211_ATTR_TX_NO_CCK_RATE is used to decide whether to send the 504 * %NL80211_ATTR_TX_NO_CCK_RATE is used to decide whether to send the
505 * management frames at CCK rate or not in 2GHz band. 505 * management frames at CCK rate or not in 2GHz band.
506 * %NL80211_ATTR_CSA_C_OFFSETS_TX is an array of offsets to CSA
507 * counters which will be updated to the current value. This attribute
508 * is used during CSA period.
506 * @NL80211_CMD_FRAME_WAIT_CANCEL: When an off-channel TX was requested, this 509 * @NL80211_CMD_FRAME_WAIT_CANCEL: When an off-channel TX was requested, this
507 * command may be used with the corresponding cookie to cancel the wait 510 * command may be used with the corresponding cookie to cancel the wait
508 * time if it is known that it is no longer necessary. 511 * time if it is known that it is no longer necessary.
@@ -1525,10 +1528,10 @@ enum nl80211_commands {
1525 * operation). 1528 * operation).
1526 * @NL80211_ATTR_CSA_IES: Nested set of attributes containing the IE information 1529 * @NL80211_ATTR_CSA_IES: Nested set of attributes containing the IE information
1527 * for the time while performing a channel switch. 1530 * for the time while performing a channel switch.
1528 * @NL80211_ATTR_CSA_C_OFF_BEACON: Offset of the channel switch counter 1531 * @NL80211_ATTR_CSA_C_OFF_BEACON: An array of offsets (u16) to the channel
1529 * field in the beacons tail (%NL80211_ATTR_BEACON_TAIL). 1532 * switch counters in the beacons tail (%NL80211_ATTR_BEACON_TAIL).
1530 * @NL80211_ATTR_CSA_C_OFF_PRESP: Offset of the channel switch counter 1533 * @NL80211_ATTR_CSA_C_OFF_PRESP: An array of offsets (u16) to the channel
1531 * field in the probe response (%NL80211_ATTR_PROBE_RESP). 1534 * switch counters in the probe response (%NL80211_ATTR_PROBE_RESP).
1532 * 1535 *
1533 * @NL80211_ATTR_RXMGMT_FLAGS: flags for nl80211_send_mgmt(), u32. 1536 * @NL80211_ATTR_RXMGMT_FLAGS: flags for nl80211_send_mgmt(), u32.
1534 * As specified in the &enum nl80211_rxmgmt_flags. 1537 * As specified in the &enum nl80211_rxmgmt_flags.
@@ -1576,6 +1579,11 @@ enum nl80211_commands {
1576 * advertise values that cannot always be met. In such cases, an attempt 1579 * advertise values that cannot always be met. In such cases, an attempt
1577 * to add a new station entry with @NL80211_CMD_NEW_STATION may fail. 1580 * to add a new station entry with @NL80211_CMD_NEW_STATION may fail.
1578 * 1581 *
1582 * @NL80211_ATTR_CSA_C_OFFSETS_TX: An array of csa counter offsets (u16) which
1583 * should be updated when the frame is transmitted.
1584 * @NL80211_ATTR_MAX_CSA_COUNTERS: U8 attribute used to advertise the maximum
1585 * supported number of csa counters.
1586 *
1579 * @NL80211_ATTR_TDLS_PEER_CAPABILITY: flags for TDLS peer capabilities, u32. 1587 * @NL80211_ATTR_TDLS_PEER_CAPABILITY: flags for TDLS peer capabilities, u32.
1580 * As specified in the &enum nl80211_tdls_peer_capability. 1588 * As specified in the &enum nl80211_tdls_peer_capability.
1581 * 1589 *
@@ -1920,6 +1928,9 @@ enum nl80211_attrs {
1920 1928
1921 NL80211_ATTR_IFACE_SOCKET_OWNER, 1929 NL80211_ATTR_IFACE_SOCKET_OWNER,
1922 1930
1931 NL80211_ATTR_CSA_C_OFFSETS_TX,
1932 NL80211_ATTR_MAX_CSA_COUNTERS,
1933
1923 /* add attributes here, update the policy in nl80211.c */ 1934 /* add attributes here, update the policy in nl80211.c */
1924 1935
1925 __NL80211_ATTR_AFTER_LAST, 1936 __NL80211_ATTR_AFTER_LAST,
@@ -2188,6 +2199,8 @@ enum nl80211_sta_bss_param {
2188 * Contains a nested array of signal strength attributes (u8, dBm) 2199 * Contains a nested array of signal strength attributes (u8, dBm)
2189 * @NL80211_STA_INFO_CHAIN_SIGNAL_AVG: per-chain signal strength average 2200 * @NL80211_STA_INFO_CHAIN_SIGNAL_AVG: per-chain signal strength average
2190 * Same format as NL80211_STA_INFO_CHAIN_SIGNAL. 2201 * Same format as NL80211_STA_INFO_CHAIN_SIGNAL.
2202 * @NL80211_STA_EXPECTED_THROUGHPUT: expected throughput considering also the
2203 * 802.11 header (u32, kbps)
2191 * @__NL80211_STA_INFO_AFTER_LAST: internal 2204 * @__NL80211_STA_INFO_AFTER_LAST: internal
2192 * @NL80211_STA_INFO_MAX: highest possible station info attribute 2205 * @NL80211_STA_INFO_MAX: highest possible station info attribute
2193 */ 2206 */
@@ -2219,6 +2232,7 @@ enum nl80211_sta_info {
2219 NL80211_STA_INFO_TX_BYTES64, 2232 NL80211_STA_INFO_TX_BYTES64,
2220 NL80211_STA_INFO_CHAIN_SIGNAL, 2233 NL80211_STA_INFO_CHAIN_SIGNAL,
2221 NL80211_STA_INFO_CHAIN_SIGNAL_AVG, 2234 NL80211_STA_INFO_CHAIN_SIGNAL_AVG,
2235 NL80211_STA_INFO_EXPECTED_THROUGHPUT,
2222 2236
2223 /* keep last */ 2237 /* keep last */
2224 __NL80211_STA_INFO_AFTER_LAST, 2238 __NL80211_STA_INFO_AFTER_LAST,
@@ -3688,6 +3702,8 @@ enum nl80211_iface_limit_attrs {
3688 * different channels may be used within this group. 3702 * different channels may be used within this group.
3689 * @NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS: u32 attribute containing the bitmap 3703 * @NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS: u32 attribute containing the bitmap
3690 * of supported channel widths for radar detection. 3704 * of supported channel widths for radar detection.
3705 * @NL80211_IFACE_COMB_RADAR_DETECT_REGIONS: u32 attribute containing the bitmap
3706 * of supported regulatory regions for radar detection.
3691 * @NUM_NL80211_IFACE_COMB: number of attributes 3707 * @NUM_NL80211_IFACE_COMB: number of attributes
3692 * @MAX_NL80211_IFACE_COMB: highest attribute number 3708 * @MAX_NL80211_IFACE_COMB: highest attribute number
3693 * 3709 *
@@ -3721,6 +3737,7 @@ enum nl80211_if_combination_attrs {
3721 NL80211_IFACE_COMB_STA_AP_BI_MATCH, 3737 NL80211_IFACE_COMB_STA_AP_BI_MATCH,
3722 NL80211_IFACE_COMB_NUM_CHANNELS, 3738 NL80211_IFACE_COMB_NUM_CHANNELS,
3723 NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS, 3739 NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS,
3740 NL80211_IFACE_COMB_RADAR_DETECT_REGIONS,
3724 3741
3725 /* keep last */ 3742 /* keep last */
3726 NUM_NL80211_IFACE_COMB, 3743 NUM_NL80211_IFACE_COMB,
diff --git a/net/mac80211/Makefile b/net/mac80211/Makefile
index 9d7d840aac6d..1e46ffa69167 100644
--- a/net/mac80211/Makefile
+++ b/net/mac80211/Makefile
@@ -25,7 +25,8 @@ mac80211-y := \
25 wme.o \ 25 wme.o \
26 event.o \ 26 event.o \
27 chan.o \ 27 chan.o \
28 trace.o mlme.o 28 trace.o mlme.o \
29 tdls.o
29 30
30mac80211-$(CONFIG_MAC80211_LEDS) += led.o 31mac80211-$(CONFIG_MAC80211_LEDS) += led.o
31mac80211-$(CONFIG_MAC80211_DEBUGFS) += \ 32mac80211-$(CONFIG_MAC80211_DEBUGFS) += \
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 7b8d3cf89574..d7513a503be1 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -472,8 +472,10 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
472{ 472{
473 struct ieee80211_sub_if_data *sdata = sta->sdata; 473 struct ieee80211_sub_if_data *sdata = sta->sdata;
474 struct ieee80211_local *local = sdata->local; 474 struct ieee80211_local *local = sdata->local;
475 struct rate_control_ref *ref = local->rate_ctrl;
475 struct timespec uptime; 476 struct timespec uptime;
476 u64 packets = 0; 477 u64 packets = 0;
478 u32 thr = 0;
477 int i, ac; 479 int i, ac;
478 480
479 sinfo->generation = sdata->local->sta_generation; 481 sinfo->generation = sdata->local->sta_generation;
@@ -587,6 +589,17 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
587 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_ASSOCIATED); 589 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_ASSOCIATED);
588 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) 590 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER))
589 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_TDLS_PEER); 591 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_TDLS_PEER);
592
593 /* check if the driver has a SW RC implementation */
594 if (ref && ref->ops->get_expected_throughput)
595 thr = ref->ops->get_expected_throughput(sta->rate_ctrl_priv);
596 else
597 thr = drv_get_expected_throughput(local, &sta->sta);
598
599 if (thr != 0) {
600 sinfo->filled |= STATION_INFO_EXPECTED_THROUGHPUT;
601 sinfo->expected_throughput = thr;
602 }
590} 603}
591 604
592static const char ieee80211_gstrings_sta_stats[][ETH_GSTRING_LEN] = { 605static const char ieee80211_gstrings_sta_stats[][ETH_GSTRING_LEN] = {
@@ -777,7 +790,7 @@ static void ieee80211_get_et_strings(struct wiphy *wiphy,
777} 790}
778 791
779static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev, 792static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
780 int idx, u8 *mac, struct station_info *sinfo) 793 int idx, u8 *mac, struct station_info *sinfo)
781{ 794{
782 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 795 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
783 struct ieee80211_local *local = sdata->local; 796 struct ieee80211_local *local = sdata->local;
@@ -807,7 +820,7 @@ static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev,
807} 820}
808 821
809static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev, 822static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
810 u8 *mac, struct station_info *sinfo) 823 const u8 *mac, struct station_info *sinfo)
811{ 824{
812 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 825 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
813 struct ieee80211_local *local = sdata->local; 826 struct ieee80211_local *local = sdata->local;
@@ -1084,6 +1097,31 @@ static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev,
1084 return 0; 1097 return 0;
1085} 1098}
1086 1099
1100bool ieee80211_csa_needs_block_tx(struct ieee80211_local *local)
1101{
1102 struct ieee80211_sub_if_data *sdata;
1103
1104 lockdep_assert_held(&local->mtx);
1105
1106 rcu_read_lock();
1107 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
1108 if (!ieee80211_sdata_running(sdata))
1109 continue;
1110
1111 if (!sdata->vif.csa_active)
1112 continue;
1113
1114 if (!sdata->csa_block_tx)
1115 continue;
1116
1117 rcu_read_unlock();
1118 return true;
1119 }
1120 rcu_read_unlock();
1121
1122 return false;
1123}
1124
1087static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev) 1125static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
1088{ 1126{
1089 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1127 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
@@ -1101,7 +1139,14 @@ static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
1101 old_probe_resp = sdata_dereference(sdata->u.ap.probe_resp, sdata); 1139 old_probe_resp = sdata_dereference(sdata->u.ap.probe_resp, sdata);
1102 1140
1103 /* abort any running channel switch */ 1141 /* abort any running channel switch */
1142 mutex_lock(&local->mtx);
1104 sdata->vif.csa_active = false; 1143 sdata->vif.csa_active = false;
1144 if (!ieee80211_csa_needs_block_tx(local))
1145 ieee80211_wake_queues_by_reason(&local->hw,
1146 IEEE80211_MAX_QUEUE_MAP,
1147 IEEE80211_QUEUE_STOP_REASON_CSA);
1148 mutex_unlock(&local->mtx);
1149
1105 kfree(sdata->u.ap.next_beacon); 1150 kfree(sdata->u.ap.next_beacon);
1106 sdata->u.ap.next_beacon = NULL; 1151 sdata->u.ap.next_beacon = NULL;
1107 1152
@@ -1425,7 +1470,8 @@ static int sta_apply_parameters(struct ieee80211_local *local,
1425} 1470}
1426 1471
1427static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, 1472static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
1428 u8 *mac, struct station_parameters *params) 1473 const u8 *mac,
1474 struct station_parameters *params)
1429{ 1475{
1430 struct ieee80211_local *local = wiphy_priv(wiphy); 1476 struct ieee80211_local *local = wiphy_priv(wiphy);
1431 struct sta_info *sta; 1477 struct sta_info *sta;
@@ -1459,6 +1505,8 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
1459 if (!(params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))) { 1505 if (!(params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))) {
1460 sta_info_pre_move_state(sta, IEEE80211_STA_AUTH); 1506 sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
1461 sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC); 1507 sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
1508 } else {
1509 sta->sta.tdls = true;
1462 } 1510 }
1463 1511
1464 err = sta_apply_parameters(local, sta, params); 1512 err = sta_apply_parameters(local, sta, params);
@@ -1492,7 +1540,7 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
1492} 1540}
1493 1541
1494static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev, 1542static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
1495 u8 *mac) 1543 const u8 *mac)
1496{ 1544{
1497 struct ieee80211_sub_if_data *sdata; 1545 struct ieee80211_sub_if_data *sdata;
1498 1546
@@ -1506,7 +1554,7 @@ static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
1506} 1554}
1507 1555
1508static int ieee80211_change_station(struct wiphy *wiphy, 1556static int ieee80211_change_station(struct wiphy *wiphy,
1509 struct net_device *dev, u8 *mac, 1557 struct net_device *dev, const u8 *mac,
1510 struct station_parameters *params) 1558 struct station_parameters *params)
1511{ 1559{
1512 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1560 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
@@ -1631,7 +1679,7 @@ out_err:
1631 1679
1632#ifdef CONFIG_MAC80211_MESH 1680#ifdef CONFIG_MAC80211_MESH
1633static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev, 1681static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
1634 u8 *dst, u8 *next_hop) 1682 const u8 *dst, const u8 *next_hop)
1635{ 1683{
1636 struct ieee80211_sub_if_data *sdata; 1684 struct ieee80211_sub_if_data *sdata;
1637 struct mesh_path *mpath; 1685 struct mesh_path *mpath;
@@ -1659,7 +1707,7 @@ static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
1659} 1707}
1660 1708
1661static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev, 1709static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev,
1662 u8 *dst) 1710 const u8 *dst)
1663{ 1711{
1664 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1712 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1665 1713
@@ -1670,9 +1718,8 @@ static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev,
1670 return 0; 1718 return 0;
1671} 1719}
1672 1720
1673static int ieee80211_change_mpath(struct wiphy *wiphy, 1721static int ieee80211_change_mpath(struct wiphy *wiphy, struct net_device *dev,
1674 struct net_device *dev, 1722 const u8 *dst, const u8 *next_hop)
1675 u8 *dst, u8 *next_hop)
1676{ 1723{
1677 struct ieee80211_sub_if_data *sdata; 1724 struct ieee80211_sub_if_data *sdata;
1678 struct mesh_path *mpath; 1725 struct mesh_path *mpath;
@@ -1764,8 +1811,8 @@ static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
1764} 1811}
1765 1812
1766static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev, 1813static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
1767 int idx, u8 *dst, u8 *next_hop, 1814 int idx, u8 *dst, u8 *next_hop,
1768 struct mpath_info *pinfo) 1815 struct mpath_info *pinfo)
1769{ 1816{
1770 struct ieee80211_sub_if_data *sdata; 1817 struct ieee80211_sub_if_data *sdata;
1771 struct mesh_path *mpath; 1818 struct mesh_path *mpath;
@@ -3019,26 +3066,11 @@ void ieee80211_csa_finish(struct ieee80211_vif *vif)
3019} 3066}
3020EXPORT_SYMBOL(ieee80211_csa_finish); 3067EXPORT_SYMBOL(ieee80211_csa_finish);
3021 3068
3022static void ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata) 3069static int ieee80211_set_after_csa_beacon(struct ieee80211_sub_if_data *sdata,
3070 u32 *changed)
3023{ 3071{
3024 struct ieee80211_local *local = sdata->local; 3072 int err;
3025 int err, changed = 0;
3026
3027 sdata_assert_lock(sdata);
3028
3029 mutex_lock(&local->mtx);
3030 sdata->radar_required = sdata->csa_radar_required;
3031 err = ieee80211_vif_change_channel(sdata, &changed);
3032 mutex_unlock(&local->mtx);
3033 if (WARN_ON(err < 0))
3034 return;
3035
3036 if (!local->use_chanctx) {
3037 local->_oper_chandef = sdata->csa_chandef;
3038 ieee80211_hw_config(local, 0);
3039 }
3040 3073
3041 sdata->vif.csa_active = false;
3042 switch (sdata->vif.type) { 3074 switch (sdata->vif.type) {
3043 case NL80211_IFTYPE_AP: 3075 case NL80211_IFTYPE_AP:
3044 err = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon); 3076 err = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon);
@@ -3046,35 +3078,74 @@ static void ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
3046 sdata->u.ap.next_beacon = NULL; 3078 sdata->u.ap.next_beacon = NULL;
3047 3079
3048 if (err < 0) 3080 if (err < 0)
3049 return; 3081 return err;
3050 changed |= err; 3082 *changed |= err;
3051 break; 3083 break;
3052 case NL80211_IFTYPE_ADHOC: 3084 case NL80211_IFTYPE_ADHOC:
3053 err = ieee80211_ibss_finish_csa(sdata); 3085 err = ieee80211_ibss_finish_csa(sdata);
3054 if (err < 0) 3086 if (err < 0)
3055 return; 3087 return err;
3056 changed |= err; 3088 *changed |= err;
3057 break; 3089 break;
3058#ifdef CONFIG_MAC80211_MESH 3090#ifdef CONFIG_MAC80211_MESH
3059 case NL80211_IFTYPE_MESH_POINT: 3091 case NL80211_IFTYPE_MESH_POINT:
3060 err = ieee80211_mesh_finish_csa(sdata); 3092 err = ieee80211_mesh_finish_csa(sdata);
3061 if (err < 0) 3093 if (err < 0)
3062 return; 3094 return err;
3063 changed |= err; 3095 *changed |= err;
3064 break; 3096 break;
3065#endif 3097#endif
3066 default: 3098 default:
3067 WARN_ON(1); 3099 WARN_ON(1);
3068 return; 3100 return -EINVAL;
3101 }
3102
3103 return 0;
3104}
3105
3106static int __ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
3107{
3108 struct ieee80211_local *local = sdata->local;
3109 u32 changed = 0;
3110 int err;
3111
3112 sdata_assert_lock(sdata);
3113 lockdep_assert_held(&local->mtx);
3114
3115 sdata->radar_required = sdata->csa_radar_required;
3116 err = ieee80211_vif_change_channel(sdata, &changed);
3117 if (err < 0)
3118 return err;
3119
3120 if (!local->use_chanctx) {
3121 local->_oper_chandef = sdata->csa_chandef;
3122 ieee80211_hw_config(local, 0);
3069 } 3123 }
3070 3124
3125 sdata->vif.csa_active = false;
3126
3127 err = ieee80211_set_after_csa_beacon(sdata, &changed);
3128 if (err)
3129 return err;
3130
3071 ieee80211_bss_info_change_notify(sdata, changed); 3131 ieee80211_bss_info_change_notify(sdata, changed);
3132 cfg80211_ch_switch_notify(sdata->dev, &sdata->csa_chandef);
3072 3133
3073 ieee80211_wake_queues_by_reason(&sdata->local->hw, 3134 if (!ieee80211_csa_needs_block_tx(local))
3135 ieee80211_wake_queues_by_reason(&local->hw,
3074 IEEE80211_MAX_QUEUE_MAP, 3136 IEEE80211_MAX_QUEUE_MAP,
3075 IEEE80211_QUEUE_STOP_REASON_CSA); 3137 IEEE80211_QUEUE_STOP_REASON_CSA);
3076 3138
3077 cfg80211_ch_switch_notify(sdata->dev, &sdata->csa_chandef); 3139 return 0;
3140}
3141
3142static void ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
3143{
3144 if (__ieee80211_csa_finalize(sdata)) {
3145 sdata_info(sdata, "failed to finalize CSA, disconnecting\n");
3146 cfg80211_stop_iface(sdata->local->hw.wiphy, &sdata->wdev,
3147 GFP_KERNEL);
3148 }
3078} 3149}
3079 3150
3080void ieee80211_csa_finalize_work(struct work_struct *work) 3151void ieee80211_csa_finalize_work(struct work_struct *work)
@@ -3082,8 +3153,11 @@ void ieee80211_csa_finalize_work(struct work_struct *work)
3082 struct ieee80211_sub_if_data *sdata = 3153 struct ieee80211_sub_if_data *sdata =
3083 container_of(work, struct ieee80211_sub_if_data, 3154 container_of(work, struct ieee80211_sub_if_data,
3084 csa_finalize_work); 3155 csa_finalize_work);
3156 struct ieee80211_local *local = sdata->local;
3085 3157
3086 sdata_lock(sdata); 3158 sdata_lock(sdata);
3159 mutex_lock(&local->mtx);
3160
3087 /* AP might have been stopped while waiting for the lock. */ 3161 /* AP might have been stopped while waiting for the lock. */
3088 if (!sdata->vif.csa_active) 3162 if (!sdata->vif.csa_active)
3089 goto unlock; 3163 goto unlock;
@@ -3094,6 +3168,7 @@ void ieee80211_csa_finalize_work(struct work_struct *work)
3094 ieee80211_csa_finalize(sdata); 3168 ieee80211_csa_finalize(sdata);
3095 3169
3096unlock: 3170unlock:
3171 mutex_unlock(&local->mtx);
3097 sdata_unlock(sdata); 3172 sdata_unlock(sdata);
3098} 3173}
3099 3174
@@ -3129,9 +3204,25 @@ static int ieee80211_set_csa_beacon(struct ieee80211_sub_if_data *sdata,
3129 if (params->count <= 1) 3204 if (params->count <= 1)
3130 break; 3205 break;
3131 3206
3132 sdata->csa_counter_offset_beacon = 3207 if ((params->n_counter_offsets_beacon >
3133 params->counter_offset_beacon; 3208 IEEE80211_MAX_CSA_COUNTERS_NUM) ||
3134 sdata->csa_counter_offset_presp = params->counter_offset_presp; 3209 (params->n_counter_offsets_presp >
3210 IEEE80211_MAX_CSA_COUNTERS_NUM))
3211 return -EINVAL;
3212
3213 /* make sure we don't have garbage in other counters */
3214 memset(sdata->csa_counter_offset_beacon, 0,
3215 sizeof(sdata->csa_counter_offset_beacon));
3216 memset(sdata->csa_counter_offset_presp, 0,
3217 sizeof(sdata->csa_counter_offset_presp));
3218
3219 memcpy(sdata->csa_counter_offset_beacon,
3220 params->counter_offsets_beacon,
3221 params->n_counter_offsets_beacon * sizeof(u16));
3222 memcpy(sdata->csa_counter_offset_presp,
3223 params->counter_offsets_presp,
3224 params->n_counter_offsets_presp * sizeof(u16));
3225
3135 err = ieee80211_assign_beacon(sdata, &params->beacon_csa); 3226 err = ieee80211_assign_beacon(sdata, &params->beacon_csa);
3136 if (err < 0) { 3227 if (err < 0) {
3137 kfree(sdata->u.ap.next_beacon); 3228 kfree(sdata->u.ap.next_beacon);
@@ -3220,8 +3311,9 @@ static int ieee80211_set_csa_beacon(struct ieee80211_sub_if_data *sdata,
3220 return 0; 3311 return 0;
3221} 3312}
3222 3313
3223int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, 3314static int
3224 struct cfg80211_csa_settings *params) 3315__ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3316 struct cfg80211_csa_settings *params)
3225{ 3317{
3226 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 3318 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3227 struct ieee80211_local *local = sdata->local; 3319 struct ieee80211_local *local = sdata->local;
@@ -3230,6 +3322,7 @@ int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3230 int err, num_chanctx, changed = 0; 3322 int err, num_chanctx, changed = 0;
3231 3323
3232 sdata_assert_lock(sdata); 3324 sdata_assert_lock(sdata);
3325 lockdep_assert_held(&local->mtx);
3233 3326
3234 if (!list_empty(&local->roc_list) || local->scanning) 3327 if (!list_empty(&local->roc_list) || local->scanning)
3235 return -EBUSY; 3328 return -EBUSY;
@@ -3272,15 +3365,16 @@ int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3272 return err; 3365 return err;
3273 3366
3274 sdata->csa_radar_required = params->radar_required; 3367 sdata->csa_radar_required = params->radar_required;
3275
3276 if (params->block_tx)
3277 ieee80211_stop_queues_by_reason(&local->hw,
3278 IEEE80211_MAX_QUEUE_MAP,
3279 IEEE80211_QUEUE_STOP_REASON_CSA);
3280
3281 sdata->csa_chandef = params->chandef; 3368 sdata->csa_chandef = params->chandef;
3369 sdata->csa_block_tx = params->block_tx;
3370 sdata->csa_current_counter = params->count;
3282 sdata->vif.csa_active = true; 3371 sdata->vif.csa_active = true;
3283 3372
3373 if (sdata->csa_block_tx)
3374 ieee80211_stop_queues_by_reason(&local->hw,
3375 IEEE80211_MAX_QUEUE_MAP,
3376 IEEE80211_QUEUE_STOP_REASON_CSA);
3377
3284 if (changed) { 3378 if (changed) {
3285 ieee80211_bss_info_change_notify(sdata, changed); 3379 ieee80211_bss_info_change_notify(sdata, changed);
3286 drv_channel_switch_beacon(sdata, &params->chandef); 3380 drv_channel_switch_beacon(sdata, &params->chandef);
@@ -3292,6 +3386,20 @@ int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3292 return 0; 3386 return 0;
3293} 3387}
3294 3388
3389int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3390 struct cfg80211_csa_settings *params)
3391{
3392 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3393 struct ieee80211_local *local = sdata->local;
3394 int err;
3395
3396 mutex_lock(&local->mtx);
3397 err = __ieee80211_channel_switch(wiphy, dev, params);
3398 mutex_unlock(&local->mtx);
3399
3400 return err;
3401}
3402
3295static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, 3403static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
3296 struct cfg80211_mgmt_tx_params *params, 3404 struct cfg80211_mgmt_tx_params *params,
3297 u64 *cookie) 3405 u64 *cookie)
@@ -3304,6 +3412,7 @@ static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
3304 bool need_offchan = false; 3412 bool need_offchan = false;
3305 u32 flags; 3413 u32 flags;
3306 int ret; 3414 int ret;
3415 u8 *data;
3307 3416
3308 if (params->dont_wait_for_ack) 3417 if (params->dont_wait_for_ack)
3309 flags = IEEE80211_TX_CTL_NO_ACK; 3418 flags = IEEE80211_TX_CTL_NO_ACK;
@@ -3397,7 +3506,20 @@ static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
3397 } 3506 }
3398 skb_reserve(skb, local->hw.extra_tx_headroom); 3507 skb_reserve(skb, local->hw.extra_tx_headroom);
3399 3508
3400 memcpy(skb_put(skb, params->len), params->buf, params->len); 3509 data = skb_put(skb, params->len);
3510 memcpy(data, params->buf, params->len);
3511
3512 /* Update CSA counters */
3513 if (sdata->vif.csa_active &&
3514 (sdata->vif.type == NL80211_IFTYPE_AP ||
3515 sdata->vif.type == NL80211_IFTYPE_ADHOC) &&
3516 params->n_csa_offsets) {
3517 int i;
3518 u8 c = sdata->csa_current_counter;
3519
3520 for (i = 0; i < params->n_csa_offsets; i++)
3521 data[params->csa_offsets[i]] = c;
3522 }
3401 3523
3402 IEEE80211_SKB_CB(skb)->flags = flags; 3524 IEEE80211_SKB_CB(skb)->flags = flags;
3403 3525
@@ -3506,320 +3628,6 @@ static int ieee80211_set_rekey_data(struct wiphy *wiphy,
3506 return 0; 3628 return 0;
3507} 3629}
3508 3630
3509static void ieee80211_tdls_add_ext_capab(struct sk_buff *skb)
3510{
3511 u8 *pos = (void *)skb_put(skb, 7);
3512
3513 *pos++ = WLAN_EID_EXT_CAPABILITY;
3514 *pos++ = 5; /* len */
3515 *pos++ = 0x0;
3516 *pos++ = 0x0;
3517 *pos++ = 0x0;
3518 *pos++ = 0x0;
3519 *pos++ = WLAN_EXT_CAPA5_TDLS_ENABLED;
3520}
3521
3522static u16 ieee80211_get_tdls_sta_capab(struct ieee80211_sub_if_data *sdata)
3523{
3524 struct ieee80211_local *local = sdata->local;
3525 u16 capab;
3526
3527 capab = 0;
3528 if (ieee80211_get_sdata_band(sdata) != IEEE80211_BAND_2GHZ)
3529 return capab;
3530
3531 if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE))
3532 capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME;
3533 if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE))
3534 capab |= WLAN_CAPABILITY_SHORT_PREAMBLE;
3535
3536 return capab;
3537}
3538
3539static void ieee80211_tdls_add_link_ie(struct sk_buff *skb, u8 *src_addr,
3540 u8 *peer, u8 *bssid)
3541{
3542 struct ieee80211_tdls_lnkie *lnkid;
3543
3544 lnkid = (void *)skb_put(skb, sizeof(struct ieee80211_tdls_lnkie));
3545
3546 lnkid->ie_type = WLAN_EID_LINK_ID;
3547 lnkid->ie_len = sizeof(struct ieee80211_tdls_lnkie) - 2;
3548
3549 memcpy(lnkid->bssid, bssid, ETH_ALEN);
3550 memcpy(lnkid->init_sta, src_addr, ETH_ALEN);
3551 memcpy(lnkid->resp_sta, peer, ETH_ALEN);
3552}
3553
3554static int
3555ieee80211_prep_tdls_encap_data(struct wiphy *wiphy, struct net_device *dev,
3556 u8 *peer, u8 action_code, u8 dialog_token,
3557 u16 status_code, struct sk_buff *skb)
3558{
3559 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3560 enum ieee80211_band band = ieee80211_get_sdata_band(sdata);
3561 struct ieee80211_tdls_data *tf;
3562
3563 tf = (void *)skb_put(skb, offsetof(struct ieee80211_tdls_data, u));
3564
3565 memcpy(tf->da, peer, ETH_ALEN);
3566 memcpy(tf->sa, sdata->vif.addr, ETH_ALEN);
3567 tf->ether_type = cpu_to_be16(ETH_P_TDLS);
3568 tf->payload_type = WLAN_TDLS_SNAP_RFTYPE;
3569
3570 switch (action_code) {
3571 case WLAN_TDLS_SETUP_REQUEST:
3572 tf->category = WLAN_CATEGORY_TDLS;
3573 tf->action_code = WLAN_TDLS_SETUP_REQUEST;
3574
3575 skb_put(skb, sizeof(tf->u.setup_req));
3576 tf->u.setup_req.dialog_token = dialog_token;
3577 tf->u.setup_req.capability =
3578 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
3579
3580 ieee80211_add_srates_ie(sdata, skb, false, band);
3581 ieee80211_add_ext_srates_ie(sdata, skb, false, band);
3582 ieee80211_tdls_add_ext_capab(skb);
3583 break;
3584 case WLAN_TDLS_SETUP_RESPONSE:
3585 tf->category = WLAN_CATEGORY_TDLS;
3586 tf->action_code = WLAN_TDLS_SETUP_RESPONSE;
3587
3588 skb_put(skb, sizeof(tf->u.setup_resp));
3589 tf->u.setup_resp.status_code = cpu_to_le16(status_code);
3590 tf->u.setup_resp.dialog_token = dialog_token;
3591 tf->u.setup_resp.capability =
3592 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
3593
3594 ieee80211_add_srates_ie(sdata, skb, false, band);
3595 ieee80211_add_ext_srates_ie(sdata, skb, false, band);
3596 ieee80211_tdls_add_ext_capab(skb);
3597 break;
3598 case WLAN_TDLS_SETUP_CONFIRM:
3599 tf->category = WLAN_CATEGORY_TDLS;
3600 tf->action_code = WLAN_TDLS_SETUP_CONFIRM;
3601
3602 skb_put(skb, sizeof(tf->u.setup_cfm));
3603 tf->u.setup_cfm.status_code = cpu_to_le16(status_code);
3604 tf->u.setup_cfm.dialog_token = dialog_token;
3605 break;
3606 case WLAN_TDLS_TEARDOWN:
3607 tf->category = WLAN_CATEGORY_TDLS;
3608 tf->action_code = WLAN_TDLS_TEARDOWN;
3609
3610 skb_put(skb, sizeof(tf->u.teardown));
3611 tf->u.teardown.reason_code = cpu_to_le16(status_code);
3612 break;
3613 case WLAN_TDLS_DISCOVERY_REQUEST:
3614 tf->category = WLAN_CATEGORY_TDLS;
3615 tf->action_code = WLAN_TDLS_DISCOVERY_REQUEST;
3616
3617 skb_put(skb, sizeof(tf->u.discover_req));
3618 tf->u.discover_req.dialog_token = dialog_token;
3619 break;
3620 default:
3621 return -EINVAL;
3622 }
3623
3624 return 0;
3625}
3626
3627static int
3628ieee80211_prep_tdls_direct(struct wiphy *wiphy, struct net_device *dev,
3629 u8 *peer, u8 action_code, u8 dialog_token,
3630 u16 status_code, struct sk_buff *skb)
3631{
3632 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3633 enum ieee80211_band band = ieee80211_get_sdata_band(sdata);
3634 struct ieee80211_mgmt *mgmt;
3635
3636 mgmt = (void *)skb_put(skb, 24);
3637 memset(mgmt, 0, 24);
3638 memcpy(mgmt->da, peer, ETH_ALEN);
3639 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
3640 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
3641
3642 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
3643 IEEE80211_STYPE_ACTION);
3644
3645 switch (action_code) {
3646 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
3647 skb_put(skb, 1 + sizeof(mgmt->u.action.u.tdls_discover_resp));
3648 mgmt->u.action.category = WLAN_CATEGORY_PUBLIC;
3649 mgmt->u.action.u.tdls_discover_resp.action_code =
3650 WLAN_PUB_ACTION_TDLS_DISCOVER_RES;
3651 mgmt->u.action.u.tdls_discover_resp.dialog_token =
3652 dialog_token;
3653 mgmt->u.action.u.tdls_discover_resp.capability =
3654 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
3655
3656 ieee80211_add_srates_ie(sdata, skb, false, band);
3657 ieee80211_add_ext_srates_ie(sdata, skb, false, band);
3658 ieee80211_tdls_add_ext_capab(skb);
3659 break;
3660 default:
3661 return -EINVAL;
3662 }
3663
3664 return 0;
3665}
3666
3667static int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
3668 u8 *peer, u8 action_code, u8 dialog_token,
3669 u16 status_code, u32 peer_capability,
3670 const u8 *extra_ies, size_t extra_ies_len)
3671{
3672 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3673 struct ieee80211_local *local = sdata->local;
3674 struct sk_buff *skb = NULL;
3675 bool send_direct;
3676 int ret;
3677
3678 if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
3679 return -ENOTSUPP;
3680
3681 /* make sure we are in managed mode, and associated */
3682 if (sdata->vif.type != NL80211_IFTYPE_STATION ||
3683 !sdata->u.mgd.associated)
3684 return -EINVAL;
3685
3686 tdls_dbg(sdata, "TDLS mgmt action %d peer %pM\n",
3687 action_code, peer);
3688
3689 skb = dev_alloc_skb(local->hw.extra_tx_headroom +
3690 max(sizeof(struct ieee80211_mgmt),
3691 sizeof(struct ieee80211_tdls_data)) +
3692 50 + /* supported rates */
3693 7 + /* ext capab */
3694 extra_ies_len +
3695 sizeof(struct ieee80211_tdls_lnkie));
3696 if (!skb)
3697 return -ENOMEM;
3698
3699 skb_reserve(skb, local->hw.extra_tx_headroom);
3700
3701 switch (action_code) {
3702 case WLAN_TDLS_SETUP_REQUEST:
3703 case WLAN_TDLS_SETUP_RESPONSE:
3704 case WLAN_TDLS_SETUP_CONFIRM:
3705 case WLAN_TDLS_TEARDOWN:
3706 case WLAN_TDLS_DISCOVERY_REQUEST:
3707 ret = ieee80211_prep_tdls_encap_data(wiphy, dev, peer,
3708 action_code, dialog_token,
3709 status_code, skb);
3710 send_direct = false;
3711 break;
3712 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
3713 ret = ieee80211_prep_tdls_direct(wiphy, dev, peer, action_code,
3714 dialog_token, status_code,
3715 skb);
3716 send_direct = true;
3717 break;
3718 default:
3719 ret = -ENOTSUPP;
3720 break;
3721 }
3722
3723 if (ret < 0)
3724 goto fail;
3725
3726 if (extra_ies_len)
3727 memcpy(skb_put(skb, extra_ies_len), extra_ies, extra_ies_len);
3728
3729 /* the TDLS link IE is always added last */
3730 switch (action_code) {
3731 case WLAN_TDLS_SETUP_REQUEST:
3732 case WLAN_TDLS_SETUP_CONFIRM:
3733 case WLAN_TDLS_TEARDOWN:
3734 case WLAN_TDLS_DISCOVERY_REQUEST:
3735 /* we are the initiator */
3736 ieee80211_tdls_add_link_ie(skb, sdata->vif.addr, peer,
3737 sdata->u.mgd.bssid);
3738 break;
3739 case WLAN_TDLS_SETUP_RESPONSE:
3740 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
3741 /* we are the responder */
3742 ieee80211_tdls_add_link_ie(skb, peer, sdata->vif.addr,
3743 sdata->u.mgd.bssid);
3744 break;
3745 default:
3746 ret = -ENOTSUPP;
3747 goto fail;
3748 }
3749
3750 if (send_direct) {
3751 ieee80211_tx_skb(sdata, skb);
3752 return 0;
3753 }
3754
3755 /*
3756 * According to 802.11z: Setup req/resp are sent in AC_BK, otherwise
3757 * we should default to AC_VI.
3758 */
3759 switch (action_code) {
3760 case WLAN_TDLS_SETUP_REQUEST:
3761 case WLAN_TDLS_SETUP_RESPONSE:
3762 skb_set_queue_mapping(skb, IEEE80211_AC_BK);
3763 skb->priority = 2;
3764 break;
3765 default:
3766 skb_set_queue_mapping(skb, IEEE80211_AC_VI);
3767 skb->priority = 5;
3768 break;
3769 }
3770
3771 /* disable bottom halves when entering the Tx path */
3772 local_bh_disable();
3773 ret = ieee80211_subif_start_xmit(skb, dev);
3774 local_bh_enable();
3775
3776 return ret;
3777
3778fail:
3779 dev_kfree_skb(skb);
3780 return ret;
3781}
3782
3783static int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
3784 u8 *peer, enum nl80211_tdls_operation oper)
3785{
3786 struct sta_info *sta;
3787 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3788
3789 if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
3790 return -ENOTSUPP;
3791
3792 if (sdata->vif.type != NL80211_IFTYPE_STATION)
3793 return -EINVAL;
3794
3795 tdls_dbg(sdata, "TDLS oper %d peer %pM\n", oper, peer);
3796
3797 switch (oper) {
3798 case NL80211_TDLS_ENABLE_LINK:
3799 rcu_read_lock();
3800 sta = sta_info_get(sdata, peer);
3801 if (!sta) {
3802 rcu_read_unlock();
3803 return -ENOLINK;
3804 }
3805
3806 set_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH);
3807 rcu_read_unlock();
3808 break;
3809 case NL80211_TDLS_DISABLE_LINK:
3810 return sta_info_destroy_addr(sdata, peer);
3811 case NL80211_TDLS_TEARDOWN:
3812 case NL80211_TDLS_SETUP:
3813 case NL80211_TDLS_DISCOVERY_REQ:
3814 /* We don't support in-driver setup/teardown/discovery */
3815 return -ENOTSUPP;
3816 default:
3817 return -ENOTSUPP;
3818 }
3819
3820 return 0;
3821}
3822
3823static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev, 3631static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
3824 const u8 *peer, u64 *cookie) 3632 const u8 *peer, u64 *cookie)
3825{ 3633{
diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
index 48e6d6f010cd..a310e33972de 100644
--- a/net/mac80211/chan.c
+++ b/net/mac80211/chan.c
@@ -855,7 +855,7 @@ static void
855__ieee80211_vif_copy_chanctx_to_vlans(struct ieee80211_sub_if_data *sdata, 855__ieee80211_vif_copy_chanctx_to_vlans(struct ieee80211_sub_if_data *sdata,
856 bool clear) 856 bool clear)
857{ 857{
858 struct ieee80211_local *local = sdata->local; 858 struct ieee80211_local *local __maybe_unused = sdata->local;
859 struct ieee80211_sub_if_data *vlan; 859 struct ieee80211_sub_if_data *vlan;
860 struct ieee80211_chanctx_conf *conf; 860 struct ieee80211_chanctx_conf *conf;
861 861
@@ -871,7 +871,7 @@ __ieee80211_vif_copy_chanctx_to_vlans(struct ieee80211_sub_if_data *sdata,
871 * to a channel context that has already been freed. 871 * to a channel context that has already been freed.
872 */ 872 */
873 conf = rcu_dereference_protected(sdata->vif.chanctx_conf, 873 conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
874 lockdep_is_held(&local->chanctx_mtx)); 874 lockdep_is_held(&local->chanctx_mtx));
875 WARN_ON(!conf); 875 WARN_ON(!conf);
876 876
877 if (clear) 877 if (clear)
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
index 5331582a2c81..696ef78b1fb7 100644
--- a/net/mac80211/driver-ops.h
+++ b/net/mac80211/driver-ops.h
@@ -5,11 +5,11 @@
5#include "ieee80211_i.h" 5#include "ieee80211_i.h"
6#include "trace.h" 6#include "trace.h"
7 7
8static inline void check_sdata_in_driver(struct ieee80211_sub_if_data *sdata) 8static inline bool check_sdata_in_driver(struct ieee80211_sub_if_data *sdata)
9{ 9{
10 WARN(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER), 10 return !WARN(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER),
11 "%s: Failed check-sdata-in-driver check, flags: 0x%x\n", 11 "%s: Failed check-sdata-in-driver check, flags: 0x%x\n",
12 sdata->dev ? sdata->dev->name : sdata->name, sdata->flags); 12 sdata->dev ? sdata->dev->name : sdata->name, sdata->flags);
13} 13}
14 14
15static inline struct ieee80211_sub_if_data * 15static inline struct ieee80211_sub_if_data *
@@ -168,7 +168,8 @@ static inline int drv_change_interface(struct ieee80211_local *local,
168 168
169 might_sleep(); 169 might_sleep();
170 170
171 check_sdata_in_driver(sdata); 171 if (!check_sdata_in_driver(sdata))
172 return -EIO;
172 173
173 trace_drv_change_interface(local, sdata, type, p2p); 174 trace_drv_change_interface(local, sdata, type, p2p);
174 ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p); 175 ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p);
@@ -181,7 +182,8 @@ static inline void drv_remove_interface(struct ieee80211_local *local,
181{ 182{
182 might_sleep(); 183 might_sleep();
183 184
184 check_sdata_in_driver(sdata); 185 if (!check_sdata_in_driver(sdata))
186 return;
185 187
186 trace_drv_remove_interface(local, sdata); 188 trace_drv_remove_interface(local, sdata);
187 local->ops->remove_interface(&local->hw, &sdata->vif); 189 local->ops->remove_interface(&local->hw, &sdata->vif);
@@ -219,7 +221,8 @@ static inline void drv_bss_info_changed(struct ieee80211_local *local,
219 sdata->vif.type == NL80211_IFTYPE_MONITOR)) 221 sdata->vif.type == NL80211_IFTYPE_MONITOR))
220 return; 222 return;
221 223
222 check_sdata_in_driver(sdata); 224 if (!check_sdata_in_driver(sdata))
225 return;
223 226
224 trace_drv_bss_info_changed(local, sdata, info, changed); 227 trace_drv_bss_info_changed(local, sdata, info, changed);
225 if (local->ops->bss_info_changed) 228 if (local->ops->bss_info_changed)
@@ -278,7 +281,8 @@ static inline int drv_set_key(struct ieee80211_local *local,
278 might_sleep(); 281 might_sleep();
279 282
280 sdata = get_bss_sdata(sdata); 283 sdata = get_bss_sdata(sdata);
281 check_sdata_in_driver(sdata); 284 if (!check_sdata_in_driver(sdata))
285 return -EIO;
282 286
283 trace_drv_set_key(local, cmd, sdata, sta, key); 287 trace_drv_set_key(local, cmd, sdata, sta, key);
284 ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key); 288 ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key);
@@ -298,7 +302,8 @@ static inline void drv_update_tkip_key(struct ieee80211_local *local,
298 ista = &sta->sta; 302 ista = &sta->sta;
299 303
300 sdata = get_bss_sdata(sdata); 304 sdata = get_bss_sdata(sdata);
301 check_sdata_in_driver(sdata); 305 if (!check_sdata_in_driver(sdata))
306 return;
302 307
303 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32); 308 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
304 if (local->ops->update_tkip_key) 309 if (local->ops->update_tkip_key)
@@ -315,7 +320,8 @@ static inline int drv_hw_scan(struct ieee80211_local *local,
315 320
316 might_sleep(); 321 might_sleep();
317 322
318 check_sdata_in_driver(sdata); 323 if (!check_sdata_in_driver(sdata))
324 return -EIO;
319 325
320 trace_drv_hw_scan(local, sdata); 326 trace_drv_hw_scan(local, sdata);
321 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req); 327 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req);
@@ -328,7 +334,8 @@ static inline void drv_cancel_hw_scan(struct ieee80211_local *local,
328{ 334{
329 might_sleep(); 335 might_sleep();
330 336
331 check_sdata_in_driver(sdata); 337 if (!check_sdata_in_driver(sdata))
338 return;
332 339
333 trace_drv_cancel_hw_scan(local, sdata); 340 trace_drv_cancel_hw_scan(local, sdata);
334 local->ops->cancel_hw_scan(&local->hw, &sdata->vif); 341 local->ops->cancel_hw_scan(&local->hw, &sdata->vif);
@@ -345,7 +352,8 @@ drv_sched_scan_start(struct ieee80211_local *local,
345 352
346 might_sleep(); 353 might_sleep();
347 354
348 check_sdata_in_driver(sdata); 355 if (!check_sdata_in_driver(sdata))
356 return -EIO;
349 357
350 trace_drv_sched_scan_start(local, sdata); 358 trace_drv_sched_scan_start(local, sdata);
351 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif, 359 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif,
@@ -361,7 +369,8 @@ static inline int drv_sched_scan_stop(struct ieee80211_local *local,
361 369
362 might_sleep(); 370 might_sleep();
363 371
364 check_sdata_in_driver(sdata); 372 if (!check_sdata_in_driver(sdata))
373 return -EIO;
365 374
366 trace_drv_sched_scan_stop(local, sdata); 375 trace_drv_sched_scan_stop(local, sdata);
367 ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif); 376 ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif);
@@ -462,7 +471,8 @@ static inline void drv_sta_notify(struct ieee80211_local *local,
462 struct ieee80211_sta *sta) 471 struct ieee80211_sta *sta)
463{ 472{
464 sdata = get_bss_sdata(sdata); 473 sdata = get_bss_sdata(sdata);
465 check_sdata_in_driver(sdata); 474 if (!check_sdata_in_driver(sdata))
475 return;
466 476
467 trace_drv_sta_notify(local, sdata, cmd, sta); 477 trace_drv_sta_notify(local, sdata, cmd, sta);
468 if (local->ops->sta_notify) 478 if (local->ops->sta_notify)
@@ -479,7 +489,8 @@ static inline int drv_sta_add(struct ieee80211_local *local,
479 might_sleep(); 489 might_sleep();
480 490
481 sdata = get_bss_sdata(sdata); 491 sdata = get_bss_sdata(sdata);
482 check_sdata_in_driver(sdata); 492 if (!check_sdata_in_driver(sdata))
493 return -EIO;
483 494
484 trace_drv_sta_add(local, sdata, sta); 495 trace_drv_sta_add(local, sdata, sta);
485 if (local->ops->sta_add) 496 if (local->ops->sta_add)
@@ -497,7 +508,8 @@ static inline void drv_sta_remove(struct ieee80211_local *local,
497 might_sleep(); 508 might_sleep();
498 509
499 sdata = get_bss_sdata(sdata); 510 sdata = get_bss_sdata(sdata);
500 check_sdata_in_driver(sdata); 511 if (!check_sdata_in_driver(sdata))
512 return;
501 513
502 trace_drv_sta_remove(local, sdata, sta); 514 trace_drv_sta_remove(local, sdata, sta);
503 if (local->ops->sta_remove) 515 if (local->ops->sta_remove)
@@ -515,7 +527,8 @@ static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
515 might_sleep(); 527 might_sleep();
516 528
517 sdata = get_bss_sdata(sdata); 529 sdata = get_bss_sdata(sdata);
518 check_sdata_in_driver(sdata); 530 if (!check_sdata_in_driver(sdata))
531 return;
519 532
520 if (local->ops->sta_add_debugfs) 533 if (local->ops->sta_add_debugfs)
521 local->ops->sta_add_debugfs(&local->hw, &sdata->vif, 534 local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
@@ -545,7 +558,8 @@ static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local,
545 might_sleep(); 558 might_sleep();
546 559
547 sdata = get_bss_sdata(sdata); 560 sdata = get_bss_sdata(sdata);
548 check_sdata_in_driver(sdata); 561 if (!check_sdata_in_driver(sdata))
562 return;
549 563
550 trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta); 564 trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta);
551 if (local->ops->sta_pre_rcu_remove) 565 if (local->ops->sta_pre_rcu_remove)
@@ -566,7 +580,8 @@ int drv_sta_state(struct ieee80211_local *local,
566 might_sleep(); 580 might_sleep();
567 581
568 sdata = get_bss_sdata(sdata); 582 sdata = get_bss_sdata(sdata);
569 check_sdata_in_driver(sdata); 583 if (!check_sdata_in_driver(sdata))
584 return -EIO;
570 585
571 trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state); 586 trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state);
572 if (local->ops->sta_state) { 587 if (local->ops->sta_state) {
@@ -590,7 +605,8 @@ static inline void drv_sta_rc_update(struct ieee80211_local *local,
590 struct ieee80211_sta *sta, u32 changed) 605 struct ieee80211_sta *sta, u32 changed)
591{ 606{
592 sdata = get_bss_sdata(sdata); 607 sdata = get_bss_sdata(sdata);
593 check_sdata_in_driver(sdata); 608 if (!check_sdata_in_driver(sdata))
609 return;
594 610
595 WARN_ON(changed & IEEE80211_RC_SUPP_RATES_CHANGED && 611 WARN_ON(changed & IEEE80211_RC_SUPP_RATES_CHANGED &&
596 (sdata->vif.type != NL80211_IFTYPE_ADHOC && 612 (sdata->vif.type != NL80211_IFTYPE_ADHOC &&
@@ -612,7 +628,8 @@ static inline int drv_conf_tx(struct ieee80211_local *local,
612 628
613 might_sleep(); 629 might_sleep();
614 630
615 check_sdata_in_driver(sdata); 631 if (!check_sdata_in_driver(sdata))
632 return -EIO;
616 633
617 trace_drv_conf_tx(local, sdata, ac, params); 634 trace_drv_conf_tx(local, sdata, ac, params);
618 if (local->ops->conf_tx) 635 if (local->ops->conf_tx)
@@ -629,7 +646,8 @@ static inline u64 drv_get_tsf(struct ieee80211_local *local,
629 646
630 might_sleep(); 647 might_sleep();
631 648
632 check_sdata_in_driver(sdata); 649 if (!check_sdata_in_driver(sdata))
650 return ret;
633 651
634 trace_drv_get_tsf(local, sdata); 652 trace_drv_get_tsf(local, sdata);
635 if (local->ops->get_tsf) 653 if (local->ops->get_tsf)
@@ -644,7 +662,8 @@ static inline void drv_set_tsf(struct ieee80211_local *local,
644{ 662{
645 might_sleep(); 663 might_sleep();
646 664
647 check_sdata_in_driver(sdata); 665 if (!check_sdata_in_driver(sdata))
666 return;
648 667
649 trace_drv_set_tsf(local, sdata, tsf); 668 trace_drv_set_tsf(local, sdata, tsf);
650 if (local->ops->set_tsf) 669 if (local->ops->set_tsf)
@@ -657,7 +676,8 @@ static inline void drv_reset_tsf(struct ieee80211_local *local,
657{ 676{
658 might_sleep(); 677 might_sleep();
659 678
660 check_sdata_in_driver(sdata); 679 if (!check_sdata_in_driver(sdata))
680 return;
661 681
662 trace_drv_reset_tsf(local, sdata); 682 trace_drv_reset_tsf(local, sdata);
663 if (local->ops->reset_tsf) 683 if (local->ops->reset_tsf)
@@ -689,7 +709,8 @@ static inline int drv_ampdu_action(struct ieee80211_local *local,
689 might_sleep(); 709 might_sleep();
690 710
691 sdata = get_bss_sdata(sdata); 711 sdata = get_bss_sdata(sdata);
692 check_sdata_in_driver(sdata); 712 if (!check_sdata_in_driver(sdata))
713 return -EIO;
693 714
694 trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size); 715 trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size);
695 716
@@ -733,8 +754,8 @@ static inline void drv_flush(struct ieee80211_local *local,
733 754
734 might_sleep(); 755 might_sleep();
735 756
736 if (sdata) 757 if (sdata && !check_sdata_in_driver(sdata))
737 check_sdata_in_driver(sdata); 758 return;
738 759
739 trace_drv_flush(local, queues, drop); 760 trace_drv_flush(local, queues, drop);
740 if (local->ops->flush) 761 if (local->ops->flush)
@@ -854,7 +875,8 @@ static inline int drv_set_bitrate_mask(struct ieee80211_local *local,
854 875
855 might_sleep(); 876 might_sleep();
856 877
857 check_sdata_in_driver(sdata); 878 if (!check_sdata_in_driver(sdata))
879 return -EIO;
858 880
859 trace_drv_set_bitrate_mask(local, sdata, mask); 881 trace_drv_set_bitrate_mask(local, sdata, mask);
860 if (local->ops->set_bitrate_mask) 882 if (local->ops->set_bitrate_mask)
@@ -869,7 +891,8 @@ static inline void drv_set_rekey_data(struct ieee80211_local *local,
869 struct ieee80211_sub_if_data *sdata, 891 struct ieee80211_sub_if_data *sdata,
870 struct cfg80211_gtk_rekey_data *data) 892 struct cfg80211_gtk_rekey_data *data)
871{ 893{
872 check_sdata_in_driver(sdata); 894 if (!check_sdata_in_driver(sdata))
895 return;
873 896
874 trace_drv_set_rekey_data(local, sdata, data); 897 trace_drv_set_rekey_data(local, sdata, data);
875 if (local->ops->set_rekey_data) 898 if (local->ops->set_rekey_data)
@@ -937,7 +960,8 @@ static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
937{ 960{
938 might_sleep(); 961 might_sleep();
939 962
940 check_sdata_in_driver(sdata); 963 if (!check_sdata_in_driver(sdata))
964 return;
941 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION); 965 WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
942 966
943 trace_drv_mgd_prepare_tx(local, sdata); 967 trace_drv_mgd_prepare_tx(local, sdata);
@@ -964,6 +988,9 @@ static inline int drv_add_chanctx(struct ieee80211_local *local,
964static inline void drv_remove_chanctx(struct ieee80211_local *local, 988static inline void drv_remove_chanctx(struct ieee80211_local *local,
965 struct ieee80211_chanctx *ctx) 989 struct ieee80211_chanctx *ctx)
966{ 990{
991 if (WARN_ON(!ctx->driver_present))
992 return;
993
967 trace_drv_remove_chanctx(local, ctx); 994 trace_drv_remove_chanctx(local, ctx);
968 if (local->ops->remove_chanctx) 995 if (local->ops->remove_chanctx)
969 local->ops->remove_chanctx(&local->hw, &ctx->conf); 996 local->ops->remove_chanctx(&local->hw, &ctx->conf);
@@ -989,7 +1016,8 @@ static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
989{ 1016{
990 int ret = 0; 1017 int ret = 0;
991 1018
992 check_sdata_in_driver(sdata); 1019 if (!check_sdata_in_driver(sdata))
1020 return -EIO;
993 1021
994 trace_drv_assign_vif_chanctx(local, sdata, ctx); 1022 trace_drv_assign_vif_chanctx(local, sdata, ctx);
995 if (local->ops->assign_vif_chanctx) { 1023 if (local->ops->assign_vif_chanctx) {
@@ -1007,7 +1035,8 @@ static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
1007 struct ieee80211_sub_if_data *sdata, 1035 struct ieee80211_sub_if_data *sdata,
1008 struct ieee80211_chanctx *ctx) 1036 struct ieee80211_chanctx *ctx)
1009{ 1037{
1010 check_sdata_in_driver(sdata); 1038 if (!check_sdata_in_driver(sdata))
1039 return;
1011 1040
1012 trace_drv_unassign_vif_chanctx(local, sdata, ctx); 1041 trace_drv_unassign_vif_chanctx(local, sdata, ctx);
1013 if (local->ops->unassign_vif_chanctx) { 1042 if (local->ops->unassign_vif_chanctx) {
@@ -1024,7 +1053,8 @@ static inline int drv_start_ap(struct ieee80211_local *local,
1024{ 1053{
1025 int ret = 0; 1054 int ret = 0;
1026 1055
1027 check_sdata_in_driver(sdata); 1056 if (!check_sdata_in_driver(sdata))
1057 return -EIO;
1028 1058
1029 trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf); 1059 trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf);
1030 if (local->ops->start_ap) 1060 if (local->ops->start_ap)
@@ -1036,7 +1066,8 @@ static inline int drv_start_ap(struct ieee80211_local *local,
1036static inline void drv_stop_ap(struct ieee80211_local *local, 1066static inline void drv_stop_ap(struct ieee80211_local *local,
1037 struct ieee80211_sub_if_data *sdata) 1067 struct ieee80211_sub_if_data *sdata)
1038{ 1068{
1039 check_sdata_in_driver(sdata); 1069 if (!check_sdata_in_driver(sdata))
1070 return;
1040 1071
1041 trace_drv_stop_ap(local, sdata); 1072 trace_drv_stop_ap(local, sdata);
1042 if (local->ops->stop_ap) 1073 if (local->ops->stop_ap)
@@ -1059,7 +1090,8 @@ drv_set_default_unicast_key(struct ieee80211_local *local,
1059 struct ieee80211_sub_if_data *sdata, 1090 struct ieee80211_sub_if_data *sdata,
1060 int key_idx) 1091 int key_idx)
1061{ 1092{
1062 check_sdata_in_driver(sdata); 1093 if (!check_sdata_in_driver(sdata))
1094 return;
1063 1095
1064 WARN_ON_ONCE(key_idx < -1 || key_idx > 3); 1096 WARN_ON_ONCE(key_idx < -1 || key_idx > 3);
1065 1097
@@ -1101,7 +1133,8 @@ static inline int drv_join_ibss(struct ieee80211_local *local,
1101 int ret = 0; 1133 int ret = 0;
1102 1134
1103 might_sleep(); 1135 might_sleep();
1104 check_sdata_in_driver(sdata); 1136 if (!check_sdata_in_driver(sdata))
1137 return -EIO;
1105 1138
1106 trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf); 1139 trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf);
1107 if (local->ops->join_ibss) 1140 if (local->ops->join_ibss)
@@ -1114,7 +1147,8 @@ static inline void drv_leave_ibss(struct ieee80211_local *local,
1114 struct ieee80211_sub_if_data *sdata) 1147 struct ieee80211_sub_if_data *sdata)
1115{ 1148{
1116 might_sleep(); 1149 might_sleep();
1117 check_sdata_in_driver(sdata); 1150 if (!check_sdata_in_driver(sdata))
1151 return;
1118 1152
1119 trace_drv_leave_ibss(local, sdata); 1153 trace_drv_leave_ibss(local, sdata);
1120 if (local->ops->leave_ibss) 1154 if (local->ops->leave_ibss)
@@ -1122,4 +1156,17 @@ static inline void drv_leave_ibss(struct ieee80211_local *local,
1122 trace_drv_return_void(local); 1156 trace_drv_return_void(local);
1123} 1157}
1124 1158
1159static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
1160 struct ieee80211_sta *sta)
1161{
1162 u32 ret = 0;
1163
1164 trace_drv_get_expected_throughput(sta);
1165 if (local->ops->get_expected_throughput)
1166 ret = local->ops->get_expected_throughput(sta);
1167 trace_drv_return_u32(local, ret);
1168
1169 return ret;
1170}
1171
1125#endif /* __MAC80211_DRIVER_OPS */ 1172#endif /* __MAC80211_DRIVER_OPS */
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index ff4d4155a84d..1bbac94da58d 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -143,7 +143,7 @@ ieee80211_ibss_build_presp(struct ieee80211_sub_if_data *sdata,
143 *pos++ = csa_settings->block_tx ? 1 : 0; 143 *pos++ = csa_settings->block_tx ? 1 : 0;
144 *pos++ = ieee80211_frequency_to_channel( 144 *pos++ = ieee80211_frequency_to_channel(
145 csa_settings->chandef.chan->center_freq); 145 csa_settings->chandef.chan->center_freq);
146 sdata->csa_counter_offset_beacon = (pos - presp->head); 146 sdata->csa_counter_offset_beacon[0] = (pos - presp->head);
147 *pos++ = csa_settings->count; 147 *pos++ = csa_settings->count;
148 } 148 }
149 149
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index b455f62d357a..ed2b817d5ece 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -753,9 +753,10 @@ struct ieee80211_sub_if_data {
753 struct mac80211_qos_map __rcu *qos_map; 753 struct mac80211_qos_map __rcu *qos_map;
754 754
755 struct work_struct csa_finalize_work; 755 struct work_struct csa_finalize_work;
756 int csa_counter_offset_beacon; 756 u16 csa_counter_offset_beacon[IEEE80211_MAX_CSA_COUNTERS_NUM];
757 int csa_counter_offset_presp; 757 u16 csa_counter_offset_presp[IEEE80211_MAX_CSA_COUNTERS_NUM];
758 bool csa_radar_required; 758 bool csa_radar_required;
759 bool csa_block_tx; /* write-protected by sdata_lock and local->mtx */
759 struct cfg80211_chan_def csa_chandef; 760 struct cfg80211_chan_def csa_chandef;
760 761
761 struct list_head assigned_chanctx_list; /* protected by chanctx_mtx */ 762 struct list_head assigned_chanctx_list; /* protected by chanctx_mtx */
@@ -765,6 +766,7 @@ struct ieee80211_sub_if_data {
765 struct ieee80211_chanctx *reserved_chanctx; 766 struct ieee80211_chanctx *reserved_chanctx;
766 struct cfg80211_chan_def reserved_chandef; 767 struct cfg80211_chan_def reserved_chandef;
767 bool reserved_radar_required; 768 bool reserved_radar_required;
769 u8 csa_current_counter;
768 770
769 /* used to reconfigure hardware SM PS */ 771 /* used to reconfigure hardware SM PS */
770 struct work_struct recalc_smps; 772 struct work_struct recalc_smps;
@@ -1458,6 +1460,7 @@ __ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
1458int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata, 1460int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
1459 struct cfg80211_sched_scan_request *req); 1461 struct cfg80211_sched_scan_request *req);
1460int ieee80211_request_sched_scan_stop(struct ieee80211_sub_if_data *sdata); 1462int ieee80211_request_sched_scan_stop(struct ieee80211_sub_if_data *sdata);
1463void ieee80211_sched_scan_end(struct ieee80211_local *local);
1461void ieee80211_sched_scan_stopped_work(struct work_struct *work); 1464void ieee80211_sched_scan_stopped_work(struct work_struct *work);
1462 1465
1463/* off-channel helpers */ 1466/* off-channel helpers */
@@ -1472,6 +1475,7 @@ void ieee80211_sw_roc_work(struct work_struct *work);
1472void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc); 1475void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc);
1473 1476
1474/* channel switch handling */ 1477/* channel switch handling */
1478bool ieee80211_csa_needs_block_tx(struct ieee80211_local *local);
1475void ieee80211_csa_finalize_work(struct work_struct *work); 1479void ieee80211_csa_finalize_work(struct work_struct *work);
1476int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, 1480int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
1477 struct cfg80211_csa_settings *params); 1481 struct cfg80211_csa_settings *params);
@@ -1833,6 +1837,15 @@ int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata,
1833 u8 radar_detect); 1837 u8 radar_detect);
1834int ieee80211_max_num_channels(struct ieee80211_local *local); 1838int ieee80211_max_num_channels(struct ieee80211_local *local);
1835 1839
1840/* TDLS */
1841int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
1842 const u8 *peer, u8 action_code, u8 dialog_token,
1843 u16 status_code, u32 peer_capability,
1844 const u8 *extra_ies, size_t extra_ies_len);
1845int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
1846 const u8 *peer, enum nl80211_tdls_operation oper);
1847
1848
1836#ifdef CONFIG_MAC80211_NOINLINE 1849#ifdef CONFIG_MAC80211_NOINLINE
1837#define debug_noinline noinline 1850#define debug_noinline noinline
1838#else 1851#else
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 7fff3dcaac43..79fc98815da8 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -838,8 +838,15 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
838 838
839 cancel_work_sync(&sdata->recalc_smps); 839 cancel_work_sync(&sdata->recalc_smps);
840 sdata_lock(sdata); 840 sdata_lock(sdata);
841 mutex_lock(&local->mtx);
841 sdata->vif.csa_active = false; 842 sdata->vif.csa_active = false;
843 if (!ieee80211_csa_needs_block_tx(local))
844 ieee80211_wake_queues_by_reason(&local->hw,
845 IEEE80211_MAX_QUEUE_MAP,
846 IEEE80211_QUEUE_STOP_REASON_CSA);
847 mutex_unlock(&local->mtx);
842 sdata_unlock(sdata); 848 sdata_unlock(sdata);
849
843 cancel_work_sync(&sdata->csa_finalize_work); 850 cancel_work_sync(&sdata->csa_finalize_work);
844 851
845 cancel_delayed_work_sync(&sdata->dfs_cac_timer_work); 852 cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index 6ff65a1ebaa9..16d97f044a20 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -325,7 +325,8 @@ ieee80211_key_alloc(u32 cipher, int idx, size_t key_len,
325 struct ieee80211_key *key; 325 struct ieee80211_key *key;
326 int i, j, err; 326 int i, j, err;
327 327
328 BUG_ON(idx < 0 || idx >= NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS); 328 if (WARN_ON(idx < 0 || idx >= NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS))
329 return ERR_PTR(-EINVAL);
329 330
330 key = kzalloc(sizeof(struct ieee80211_key) + key_len, GFP_KERNEL); 331 key = kzalloc(sizeof(struct ieee80211_key) + key_len, GFP_KERNEL);
331 if (!key) 332 if (!key)
@@ -481,8 +482,8 @@ int ieee80211_key_link(struct ieee80211_key *key,
481 int idx, ret; 482 int idx, ret;
482 bool pairwise; 483 bool pairwise;
483 484
484 BUG_ON(!sdata); 485 if (WARN_ON(!sdata || !key))
485 BUG_ON(!key); 486 return -EINVAL;
486 487
487 pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE; 488 pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE;
488 idx = key->conf.keyidx; 489 idx = key->conf.keyidx;
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 27b9364cdf17..d17c26d6e369 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -956,6 +956,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
956 if (local->hw.wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS) 956 if (local->hw.wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS)
957 local->hw.wiphy->flags |= WIPHY_FLAG_TDLS_EXTERNAL_SETUP; 957 local->hw.wiphy->flags |= WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
958 958
959 local->hw.wiphy->max_num_csa_counters = IEEE80211_MAX_CSA_COUNTERS_NUM;
960
959 result = wiphy_register(local->hw.wiphy); 961 result = wiphy_register(local->hw.wiphy);
960 if (result < 0) 962 if (result < 0)
961 goto fail_wiphy_register; 963 goto fail_wiphy_register;
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index b06ddc9519ce..6495a3f0428d 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -679,7 +679,7 @@ ieee80211_mesh_build_beacon(struct ieee80211_if_mesh *ifmsh)
679 *pos++ = 0x0; 679 *pos++ = 0x0;
680 *pos++ = ieee80211_frequency_to_channel( 680 *pos++ = ieee80211_frequency_to_channel(
681 csa->settings.chandef.chan->center_freq); 681 csa->settings.chandef.chan->center_freq);
682 sdata->csa_counter_offset_beacon = hdr_len + 6; 682 sdata->csa_counter_offset_beacon[0] = hdr_len + 6;
683 *pos++ = csa->settings.count; 683 *pos++ = csa->settings.count;
684 *pos++ = WLAN_EID_CHAN_SWITCH_PARAM; 684 *pos++ = WLAN_EID_CHAN_SWITCH_PARAM;
685 *pos++ = 6; 685 *pos++ = 6;
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c
index 7d050ed6fe5a..cf032a8db9d7 100644
--- a/net/mac80211/mesh_pathtbl.c
+++ b/net/mac80211/mesh_pathtbl.c
@@ -287,8 +287,10 @@ static void mesh_path_move_to_queue(struct mesh_path *gate_mpath,
287 struct sk_buff_head failq; 287 struct sk_buff_head failq;
288 unsigned long flags; 288 unsigned long flags;
289 289
290 BUG_ON(gate_mpath == from_mpath); 290 if (WARN_ON(gate_mpath == from_mpath))
291 BUG_ON(!gate_mpath->next_hop); 291 return;
292 if (WARN_ON(!gate_mpath->next_hop))
293 return;
292 294
293 __skb_queue_head_init(&failq); 295 __skb_queue_head_init(&failq);
294 296
diff --git a/net/mac80211/mesh_sync.c b/net/mac80211/mesh_sync.c
index 2bc5dc25d5ad..09625d6205c3 100644
--- a/net/mac80211/mesh_sync.c
+++ b/net/mac80211/mesh_sync.c
@@ -171,7 +171,7 @@ static void mesh_sync_offset_adjust_tbtt(struct ieee80211_sub_if_data *sdata,
171 u8 cap; 171 u8 cap;
172 172
173 WARN_ON(ifmsh->mesh_sp_id != IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET); 173 WARN_ON(ifmsh->mesh_sp_id != IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET);
174 BUG_ON(!rcu_read_lock_held()); 174 WARN_ON(!rcu_read_lock_held());
175 cap = beacon->meshconf->meshconf_cap; 175 cap = beacon->meshconf->meshconf_cap;
176 176
177 spin_lock_bh(&ifmsh->sync_offset_lock); 177 spin_lock_bh(&ifmsh->sync_offset_lock);
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 488826f188a7..7f073ef1e0a6 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -975,16 +975,23 @@ static void ieee80211_chswitch_work(struct work_struct *work)
975 /* XXX: shouldn't really modify cfg80211-owned data! */ 975 /* XXX: shouldn't really modify cfg80211-owned data! */
976 ifmgd->associated->channel = sdata->csa_chandef.chan; 976 ifmgd->associated->channel = sdata->csa_chandef.chan;
977 977
978 ieee80211_bss_info_change_notify(sdata, changed);
979
980 mutex_lock(&local->mtx);
981 sdata->vif.csa_active = false;
978 /* XXX: wait for a beacon first? */ 982 /* XXX: wait for a beacon first? */
979 ieee80211_wake_queues_by_reason(&local->hw, 983 if (!ieee80211_csa_needs_block_tx(local))
984 ieee80211_wake_queues_by_reason(&local->hw,
980 IEEE80211_MAX_QUEUE_MAP, 985 IEEE80211_MAX_QUEUE_MAP,
981 IEEE80211_QUEUE_STOP_REASON_CSA); 986 IEEE80211_QUEUE_STOP_REASON_CSA);
987 mutex_unlock(&local->mtx);
982 988
983 ieee80211_bss_info_change_notify(sdata, changed);
984
985 out:
986 sdata->vif.csa_active = false;
987 ifmgd->flags &= ~IEEE80211_STA_CSA_RECEIVED; 989 ifmgd->flags &= ~IEEE80211_STA_CSA_RECEIVED;
990
991 ieee80211_sta_reset_beacon_monitor(sdata);
992 ieee80211_sta_reset_conn_monitor(sdata);
993
994out:
988 sdata_unlock(sdata); 995 sdata_unlock(sdata);
989} 996}
990 997
@@ -1100,12 +1107,16 @@ ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
1100 mutex_unlock(&local->chanctx_mtx); 1107 mutex_unlock(&local->chanctx_mtx);
1101 1108
1102 sdata->csa_chandef = csa_ie.chandef; 1109 sdata->csa_chandef = csa_ie.chandef;
1110
1111 mutex_lock(&local->mtx);
1103 sdata->vif.csa_active = true; 1112 sdata->vif.csa_active = true;
1113 sdata->csa_block_tx = csa_ie.mode;
1104 1114
1105 if (csa_ie.mode) 1115 if (sdata->csa_block_tx)
1106 ieee80211_stop_queues_by_reason(&local->hw, 1116 ieee80211_stop_queues_by_reason(&local->hw,
1107 IEEE80211_MAX_QUEUE_MAP, 1117 IEEE80211_MAX_QUEUE_MAP,
1108 IEEE80211_QUEUE_STOP_REASON_CSA); 1118 IEEE80211_QUEUE_STOP_REASON_CSA);
1119 mutex_unlock(&local->mtx);
1109 1120
1110 if (local->ops->channel_switch) { 1121 if (local->ops->channel_switch) {
1111 /* use driver's channel switch callback */ 1122 /* use driver's channel switch callback */
@@ -1817,6 +1828,12 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
1817 ifmgd->flags = 0; 1828 ifmgd->flags = 0;
1818 mutex_lock(&local->mtx); 1829 mutex_lock(&local->mtx);
1819 ieee80211_vif_release_channel(sdata); 1830 ieee80211_vif_release_channel(sdata);
1831
1832 sdata->vif.csa_active = false;
1833 if (!ieee80211_csa_needs_block_tx(local))
1834 ieee80211_wake_queues_by_reason(&local->hw,
1835 IEEE80211_MAX_QUEUE_MAP,
1836 IEEE80211_QUEUE_STOP_REASON_CSA);
1820 mutex_unlock(&local->mtx); 1837 mutex_unlock(&local->mtx);
1821 1838
1822 sdata->encrypt_headroom = IEEE80211_ENCRYPT_HEADROOM; 1839 sdata->encrypt_headroom = IEEE80211_ENCRYPT_HEADROOM;
@@ -2045,6 +2062,7 @@ EXPORT_SYMBOL(ieee80211_ap_probereq_get);
2045 2062
2046static void __ieee80211_disconnect(struct ieee80211_sub_if_data *sdata) 2063static void __ieee80211_disconnect(struct ieee80211_sub_if_data *sdata)
2047{ 2064{
2065 struct ieee80211_local *local = sdata->local;
2048 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 2066 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
2049 u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN]; 2067 u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN];
2050 2068
@@ -2058,10 +2076,14 @@ static void __ieee80211_disconnect(struct ieee80211_sub_if_data *sdata)
2058 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY, 2076 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY,
2059 true, frame_buf); 2077 true, frame_buf);
2060 ifmgd->flags &= ~IEEE80211_STA_CSA_RECEIVED; 2078 ifmgd->flags &= ~IEEE80211_STA_CSA_RECEIVED;
2079
2080 mutex_lock(&local->mtx);
2061 sdata->vif.csa_active = false; 2081 sdata->vif.csa_active = false;
2062 ieee80211_wake_queues_by_reason(&sdata->local->hw, 2082 if (!ieee80211_csa_needs_block_tx(local))
2083 ieee80211_wake_queues_by_reason(&local->hw,
2063 IEEE80211_MAX_QUEUE_MAP, 2084 IEEE80211_MAX_QUEUE_MAP,
2064 IEEE80211_QUEUE_STOP_REASON_CSA); 2085 IEEE80211_QUEUE_STOP_REASON_CSA);
2086 mutex_unlock(&local->mtx);
2065 2087
2066 cfg80211_tx_mlme_mgmt(sdata->dev, frame_buf, 2088 cfg80211_tx_mlme_mgmt(sdata->dev, frame_buf,
2067 IEEE80211_DEAUTH_FRAME_LEN); 2089 IEEE80211_DEAUTH_FRAME_LEN);
@@ -3546,6 +3568,9 @@ static void ieee80211_sta_bcn_mon_timer(unsigned long data)
3546 if (local->quiescing) 3568 if (local->quiescing)
3547 return; 3569 return;
3548 3570
3571 if (sdata->vif.csa_active)
3572 return;
3573
3549 sdata->u.mgd.connection_loss = false; 3574 sdata->u.mgd.connection_loss = false;
3550 ieee80211_queue_work(&sdata->local->hw, 3575 ieee80211_queue_work(&sdata->local->hw,
3551 &sdata->u.mgd.beacon_connection_loss_work); 3576 &sdata->u.mgd.beacon_connection_loss_work);
@@ -3561,6 +3586,9 @@ static void ieee80211_sta_conn_mon_timer(unsigned long data)
3561 if (local->quiescing) 3586 if (local->quiescing)
3562 return; 3587 return;
3563 3588
3589 if (sdata->vif.csa_active)
3590 return;
3591
3564 ieee80211_queue_work(&local->hw, &ifmgd->monitor_work); 3592 ieee80211_queue_work(&local->hw, &ifmgd->monitor_work);
3565} 3593}
3566 3594
diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c
index 26fd94fa0aed..1c1469c36dca 100644
--- a/net/mac80211/rc80211_minstrel.c
+++ b/net/mac80211/rc80211_minstrel.c
@@ -657,6 +657,17 @@ minstrel_free(void *priv)
657 kfree(priv); 657 kfree(priv);
658} 658}
659 659
660static u32 minstrel_get_expected_throughput(void *priv_sta)
661{
662 struct minstrel_sta_info *mi = priv_sta;
663 int idx = mi->max_tp_rate[0];
664
665 /* convert pkt per sec in kbps (1200 is the average pkt size used for
666 * computing cur_tp
667 */
668 return MINSTREL_TRUNC(mi->r[idx].cur_tp) * 1200 * 8 / 1024;
669}
670
660const struct rate_control_ops mac80211_minstrel = { 671const struct rate_control_ops mac80211_minstrel = {
661 .name = "minstrel", 672 .name = "minstrel",
662 .tx_status = minstrel_tx_status, 673 .tx_status = minstrel_tx_status,
@@ -670,6 +681,7 @@ const struct rate_control_ops mac80211_minstrel = {
670 .add_sta_debugfs = minstrel_add_sta_debugfs, 681 .add_sta_debugfs = minstrel_add_sta_debugfs,
671 .remove_sta_debugfs = minstrel_remove_sta_debugfs, 682 .remove_sta_debugfs = minstrel_remove_sta_debugfs,
672#endif 683#endif
684 .get_expected_throughput = minstrel_get_expected_throughput,
673}; 685};
674 686
675int __init 687int __init
diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c
index bccaf854a309..85c1e74b7714 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -22,7 +22,7 @@
22#define MCS_NBITS (AVG_PKT_SIZE << 3) 22#define MCS_NBITS (AVG_PKT_SIZE << 3)
23 23
24/* Number of symbols for a packet with (bps) bits per symbol */ 24/* Number of symbols for a packet with (bps) bits per symbol */
25#define MCS_NSYMS(bps) ((MCS_NBITS + (bps) - 1) / (bps)) 25#define MCS_NSYMS(bps) DIV_ROUND_UP(MCS_NBITS, (bps))
26 26
27/* Transmission time (nanoseconds) for a packet containing (syms) symbols */ 27/* Transmission time (nanoseconds) for a packet containing (syms) symbols */
28#define MCS_SYMBOL_TIME(sgi, syms) \ 28#define MCS_SYMBOL_TIME(sgi, syms) \
@@ -226,8 +226,9 @@ minstrel_ht_calc_tp(struct minstrel_ht_sta *mi, int group, int rate)
226 nsecs = 1000 * mi->overhead / MINSTREL_TRUNC(mi->avg_ampdu_len); 226 nsecs = 1000 * mi->overhead / MINSTREL_TRUNC(mi->avg_ampdu_len);
227 227
228 nsecs += minstrel_mcs_groups[group].duration[rate]; 228 nsecs += minstrel_mcs_groups[group].duration[rate];
229 tp = 1000000 * ((prob * 1000) / nsecs);
230 229
230 /* prob is scaled - see MINSTREL_FRAC above */
231 tp = 1000000 * ((prob * 1000) / nsecs);
231 mr->cur_tp = MINSTREL_TRUNC(tp); 232 mr->cur_tp = MINSTREL_TRUNC(tp);
232} 233}
233 234
@@ -1031,6 +1032,22 @@ minstrel_ht_free(void *priv)
1031 mac80211_minstrel.free(priv); 1032 mac80211_minstrel.free(priv);
1032} 1033}
1033 1034
1035static u32 minstrel_ht_get_expected_throughput(void *priv_sta)
1036{
1037 struct minstrel_ht_sta_priv *msp = priv_sta;
1038 struct minstrel_ht_sta *mi = &msp->ht;
1039 int i, j;
1040
1041 if (!msp->is_ht)
1042 return mac80211_minstrel.get_expected_throughput(priv_sta);
1043
1044 i = mi->max_tp_rate / MCS_GROUP_RATES;
1045 j = mi->max_tp_rate % MCS_GROUP_RATES;
1046
1047 /* convert cur_tp from pkt per second in kbps */
1048 return mi->groups[i].rates[j].cur_tp * AVG_PKT_SIZE * 8 / 1024;
1049}
1050
1034static const struct rate_control_ops mac80211_minstrel_ht = { 1051static const struct rate_control_ops mac80211_minstrel_ht = {
1035 .name = "minstrel_ht", 1052 .name = "minstrel_ht",
1036 .tx_status = minstrel_ht_tx_status, 1053 .tx_status = minstrel_ht_tx_status,
@@ -1045,6 +1062,7 @@ static const struct rate_control_ops mac80211_minstrel_ht = {
1045 .add_sta_debugfs = minstrel_ht_add_sta_debugfs, 1062 .add_sta_debugfs = minstrel_ht_add_sta_debugfs,
1046 .remove_sta_debugfs = minstrel_ht_remove_sta_debugfs, 1063 .remove_sta_debugfs = minstrel_ht_remove_sta_debugfs,
1047#endif 1064#endif
1065 .get_expected_throughput = minstrel_ht_get_expected_throughput,
1048}; 1066};
1049 1067
1050 1068
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 28185c8dc19a..f40661eb75b5 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -1076,12 +1076,8 @@ void ieee80211_sched_scan_results(struct ieee80211_hw *hw)
1076} 1076}
1077EXPORT_SYMBOL(ieee80211_sched_scan_results); 1077EXPORT_SYMBOL(ieee80211_sched_scan_results);
1078 1078
1079void ieee80211_sched_scan_stopped_work(struct work_struct *work) 1079void ieee80211_sched_scan_end(struct ieee80211_local *local)
1080{ 1080{
1081 struct ieee80211_local *local =
1082 container_of(work, struct ieee80211_local,
1083 sched_scan_stopped_work);
1084
1085 mutex_lock(&local->mtx); 1081 mutex_lock(&local->mtx);
1086 1082
1087 if (!rcu_access_pointer(local->sched_scan_sdata)) { 1083 if (!rcu_access_pointer(local->sched_scan_sdata)) {
@@ -1099,6 +1095,15 @@ void ieee80211_sched_scan_stopped_work(struct work_struct *work)
1099 cfg80211_sched_scan_stopped(local->hw.wiphy); 1095 cfg80211_sched_scan_stopped(local->hw.wiphy);
1100} 1096}
1101 1097
1098void ieee80211_sched_scan_stopped_work(struct work_struct *work)
1099{
1100 struct ieee80211_local *local =
1101 container_of(work, struct ieee80211_local,
1102 sched_scan_stopped_work);
1103
1104 ieee80211_sched_scan_end(local);
1105}
1106
1102void ieee80211_sched_scan_stopped(struct ieee80211_hw *hw) 1107void ieee80211_sched_scan_stopped(struct ieee80211_hw *hw)
1103{ 1108{
1104 struct ieee80211_local *local = hw_to_local(hw); 1109 struct ieee80211_local *local = hw_to_local(hw);
diff --git a/net/mac80211/tdls.c b/net/mac80211/tdls.c
new file mode 100644
index 000000000000..652813b2d3df
--- /dev/null
+++ b/net/mac80211/tdls.c
@@ -0,0 +1,325 @@
1/*
2 * mac80211 TDLS handling code
3 *
4 * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
5 * Copyright 2014, Intel Corporation
6 *
7 * This file is GPLv2 as found in COPYING.
8 */
9
10#include <linux/ieee80211.h>
11#include "ieee80211_i.h"
12
13static void ieee80211_tdls_add_ext_capab(struct sk_buff *skb)
14{
15 u8 *pos = (void *)skb_put(skb, 7);
16
17 *pos++ = WLAN_EID_EXT_CAPABILITY;
18 *pos++ = 5; /* len */
19 *pos++ = 0x0;
20 *pos++ = 0x0;
21 *pos++ = 0x0;
22 *pos++ = 0x0;
23 *pos++ = WLAN_EXT_CAPA5_TDLS_ENABLED;
24}
25
26static u16 ieee80211_get_tdls_sta_capab(struct ieee80211_sub_if_data *sdata)
27{
28 struct ieee80211_local *local = sdata->local;
29 u16 capab;
30
31 capab = 0;
32 if (ieee80211_get_sdata_band(sdata) != IEEE80211_BAND_2GHZ)
33 return capab;
34
35 if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE))
36 capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME;
37 if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE))
38 capab |= WLAN_CAPABILITY_SHORT_PREAMBLE;
39
40 return capab;
41}
42
43static void ieee80211_tdls_add_link_ie(struct sk_buff *skb, const u8 *src_addr,
44 const u8 *peer, const u8 *bssid)
45{
46 struct ieee80211_tdls_lnkie *lnkid;
47
48 lnkid = (void *)skb_put(skb, sizeof(struct ieee80211_tdls_lnkie));
49
50 lnkid->ie_type = WLAN_EID_LINK_ID;
51 lnkid->ie_len = sizeof(struct ieee80211_tdls_lnkie) - 2;
52
53 memcpy(lnkid->bssid, bssid, ETH_ALEN);
54 memcpy(lnkid->init_sta, src_addr, ETH_ALEN);
55 memcpy(lnkid->resp_sta, peer, ETH_ALEN);
56}
57
58static int
59ieee80211_prep_tdls_encap_data(struct wiphy *wiphy, struct net_device *dev,
60 const u8 *peer, u8 action_code, u8 dialog_token,
61 u16 status_code, struct sk_buff *skb)
62{
63 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
64 enum ieee80211_band band = ieee80211_get_sdata_band(sdata);
65 struct ieee80211_tdls_data *tf;
66
67 tf = (void *)skb_put(skb, offsetof(struct ieee80211_tdls_data, u));
68
69 memcpy(tf->da, peer, ETH_ALEN);
70 memcpy(tf->sa, sdata->vif.addr, ETH_ALEN);
71 tf->ether_type = cpu_to_be16(ETH_P_TDLS);
72 tf->payload_type = WLAN_TDLS_SNAP_RFTYPE;
73
74 switch (action_code) {
75 case WLAN_TDLS_SETUP_REQUEST:
76 tf->category = WLAN_CATEGORY_TDLS;
77 tf->action_code = WLAN_TDLS_SETUP_REQUEST;
78
79 skb_put(skb, sizeof(tf->u.setup_req));
80 tf->u.setup_req.dialog_token = dialog_token;
81 tf->u.setup_req.capability =
82 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
83
84 ieee80211_add_srates_ie(sdata, skb, false, band);
85 ieee80211_add_ext_srates_ie(sdata, skb, false, band);
86 ieee80211_tdls_add_ext_capab(skb);
87 break;
88 case WLAN_TDLS_SETUP_RESPONSE:
89 tf->category = WLAN_CATEGORY_TDLS;
90 tf->action_code = WLAN_TDLS_SETUP_RESPONSE;
91
92 skb_put(skb, sizeof(tf->u.setup_resp));
93 tf->u.setup_resp.status_code = cpu_to_le16(status_code);
94 tf->u.setup_resp.dialog_token = dialog_token;
95 tf->u.setup_resp.capability =
96 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
97
98 ieee80211_add_srates_ie(sdata, skb, false, band);
99 ieee80211_add_ext_srates_ie(sdata, skb, false, band);
100 ieee80211_tdls_add_ext_capab(skb);
101 break;
102 case WLAN_TDLS_SETUP_CONFIRM:
103 tf->category = WLAN_CATEGORY_TDLS;
104 tf->action_code = WLAN_TDLS_SETUP_CONFIRM;
105
106 skb_put(skb, sizeof(tf->u.setup_cfm));
107 tf->u.setup_cfm.status_code = cpu_to_le16(status_code);
108 tf->u.setup_cfm.dialog_token = dialog_token;
109 break;
110 case WLAN_TDLS_TEARDOWN:
111 tf->category = WLAN_CATEGORY_TDLS;
112 tf->action_code = WLAN_TDLS_TEARDOWN;
113
114 skb_put(skb, sizeof(tf->u.teardown));
115 tf->u.teardown.reason_code = cpu_to_le16(status_code);
116 break;
117 case WLAN_TDLS_DISCOVERY_REQUEST:
118 tf->category = WLAN_CATEGORY_TDLS;
119 tf->action_code = WLAN_TDLS_DISCOVERY_REQUEST;
120
121 skb_put(skb, sizeof(tf->u.discover_req));
122 tf->u.discover_req.dialog_token = dialog_token;
123 break;
124 default:
125 return -EINVAL;
126 }
127
128 return 0;
129}
130
131static int
132ieee80211_prep_tdls_direct(struct wiphy *wiphy, struct net_device *dev,
133 const u8 *peer, u8 action_code, u8 dialog_token,
134 u16 status_code, struct sk_buff *skb)
135{
136 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
137 enum ieee80211_band band = ieee80211_get_sdata_band(sdata);
138 struct ieee80211_mgmt *mgmt;
139
140 mgmt = (void *)skb_put(skb, 24);
141 memset(mgmt, 0, 24);
142 memcpy(mgmt->da, peer, ETH_ALEN);
143 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
144 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
145
146 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
147 IEEE80211_STYPE_ACTION);
148
149 switch (action_code) {
150 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
151 skb_put(skb, 1 + sizeof(mgmt->u.action.u.tdls_discover_resp));
152 mgmt->u.action.category = WLAN_CATEGORY_PUBLIC;
153 mgmt->u.action.u.tdls_discover_resp.action_code =
154 WLAN_PUB_ACTION_TDLS_DISCOVER_RES;
155 mgmt->u.action.u.tdls_discover_resp.dialog_token =
156 dialog_token;
157 mgmt->u.action.u.tdls_discover_resp.capability =
158 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
159
160 ieee80211_add_srates_ie(sdata, skb, false, band);
161 ieee80211_add_ext_srates_ie(sdata, skb, false, band);
162 ieee80211_tdls_add_ext_capab(skb);
163 break;
164 default:
165 return -EINVAL;
166 }
167
168 return 0;
169}
170
171int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
172 const u8 *peer, u8 action_code, u8 dialog_token,
173 u16 status_code, u32 peer_capability,
174 const u8 *extra_ies, size_t extra_ies_len)
175{
176 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
177 struct ieee80211_local *local = sdata->local;
178 struct sk_buff *skb = NULL;
179 bool send_direct;
180 int ret;
181
182 if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
183 return -ENOTSUPP;
184
185 /* make sure we are in managed mode, and associated */
186 if (sdata->vif.type != NL80211_IFTYPE_STATION ||
187 !sdata->u.mgd.associated)
188 return -EINVAL;
189
190 tdls_dbg(sdata, "TDLS mgmt action %d peer %pM\n",
191 action_code, peer);
192
193 skb = dev_alloc_skb(local->hw.extra_tx_headroom +
194 max(sizeof(struct ieee80211_mgmt),
195 sizeof(struct ieee80211_tdls_data)) +
196 50 + /* supported rates */
197 7 + /* ext capab */
198 extra_ies_len +
199 sizeof(struct ieee80211_tdls_lnkie));
200 if (!skb)
201 return -ENOMEM;
202
203 skb_reserve(skb, local->hw.extra_tx_headroom);
204
205 switch (action_code) {
206 case WLAN_TDLS_SETUP_REQUEST:
207 case WLAN_TDLS_SETUP_RESPONSE:
208 case WLAN_TDLS_SETUP_CONFIRM:
209 case WLAN_TDLS_TEARDOWN:
210 case WLAN_TDLS_DISCOVERY_REQUEST:
211 ret = ieee80211_prep_tdls_encap_data(wiphy, dev, peer,
212 action_code, dialog_token,
213 status_code, skb);
214 send_direct = false;
215 break;
216 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
217 ret = ieee80211_prep_tdls_direct(wiphy, dev, peer, action_code,
218 dialog_token, status_code,
219 skb);
220 send_direct = true;
221 break;
222 default:
223 ret = -ENOTSUPP;
224 break;
225 }
226
227 if (ret < 0)
228 goto fail;
229
230 if (extra_ies_len)
231 memcpy(skb_put(skb, extra_ies_len), extra_ies, extra_ies_len);
232
233 /* the TDLS link IE is always added last */
234 switch (action_code) {
235 case WLAN_TDLS_SETUP_REQUEST:
236 case WLAN_TDLS_SETUP_CONFIRM:
237 case WLAN_TDLS_TEARDOWN:
238 case WLAN_TDLS_DISCOVERY_REQUEST:
239 /* we are the initiator */
240 ieee80211_tdls_add_link_ie(skb, sdata->vif.addr, peer,
241 sdata->u.mgd.bssid);
242 break;
243 case WLAN_TDLS_SETUP_RESPONSE:
244 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
245 /* we are the responder */
246 ieee80211_tdls_add_link_ie(skb, peer, sdata->vif.addr,
247 sdata->u.mgd.bssid);
248 break;
249 default:
250 ret = -ENOTSUPP;
251 goto fail;
252 }
253
254 if (send_direct) {
255 ieee80211_tx_skb(sdata, skb);
256 return 0;
257 }
258
259 /*
260 * According to 802.11z: Setup req/resp are sent in AC_BK, otherwise
261 * we should default to AC_VI.
262 */
263 switch (action_code) {
264 case WLAN_TDLS_SETUP_REQUEST:
265 case WLAN_TDLS_SETUP_RESPONSE:
266 skb_set_queue_mapping(skb, IEEE80211_AC_BK);
267 skb->priority = 2;
268 break;
269 default:
270 skb_set_queue_mapping(skb, IEEE80211_AC_VI);
271 skb->priority = 5;
272 break;
273 }
274
275 /* disable bottom halves when entering the Tx path */
276 local_bh_disable();
277 ret = ieee80211_subif_start_xmit(skb, dev);
278 local_bh_enable();
279
280 return ret;
281
282fail:
283 dev_kfree_skb(skb);
284 return ret;
285}
286
287int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
288 const u8 *peer, enum nl80211_tdls_operation oper)
289{
290 struct sta_info *sta;
291 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
292
293 if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
294 return -ENOTSUPP;
295
296 if (sdata->vif.type != NL80211_IFTYPE_STATION)
297 return -EINVAL;
298
299 tdls_dbg(sdata, "TDLS oper %d peer %pM\n", oper, peer);
300
301 switch (oper) {
302 case NL80211_TDLS_ENABLE_LINK:
303 rcu_read_lock();
304 sta = sta_info_get(sdata, peer);
305 if (!sta) {
306 rcu_read_unlock();
307 return -ENOLINK;
308 }
309
310 set_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH);
311 rcu_read_unlock();
312 break;
313 case NL80211_TDLS_DISABLE_LINK:
314 return sta_info_destroy_addr(sdata, peer);
315 case NL80211_TDLS_TEARDOWN:
316 case NL80211_TDLS_SETUP:
317 case NL80211_TDLS_DISCOVERY_REQ:
318 /* We don't support in-driver setup/teardown/discovery */
319 return -ENOTSUPP;
320 default:
321 return -ENOTSUPP;
322 }
323
324 return 0;
325}
diff --git a/net/mac80211/trace.h b/net/mac80211/trace.h
index cec5b60487a4..762e4cd16386 100644
--- a/net/mac80211/trace.h
+++ b/net/mac80211/trace.h
@@ -184,6 +184,20 @@ TRACE_EVENT(drv_return_bool,
184 "true" : "false") 184 "true" : "false")
185); 185);
186 186
187TRACE_EVENT(drv_return_u32,
188 TP_PROTO(struct ieee80211_local *local, u32 ret),
189 TP_ARGS(local, ret),
190 TP_STRUCT__entry(
191 LOCAL_ENTRY
192 __field(u32, ret)
193 ),
194 TP_fast_assign(
195 LOCAL_ASSIGN;
196 __entry->ret = ret;
197 ),
198 TP_printk(LOCAL_PR_FMT " - %u", LOCAL_PR_ARG, __entry->ret)
199);
200
187TRACE_EVENT(drv_return_u64, 201TRACE_EVENT(drv_return_u64,
188 TP_PROTO(struct ieee80211_local *local, u64 ret), 202 TP_PROTO(struct ieee80211_local *local, u64 ret),
189 TP_ARGS(local, ret), 203 TP_ARGS(local, ret),
@@ -1499,6 +1513,24 @@ DEFINE_EVENT(local_sdata_evt, drv_leave_ibss,
1499 TP_ARGS(local, sdata) 1513 TP_ARGS(local, sdata)
1500); 1514);
1501 1515
1516TRACE_EVENT(drv_get_expected_throughput,
1517 TP_PROTO(struct ieee80211_sta *sta),
1518
1519 TP_ARGS(sta),
1520
1521 TP_STRUCT__entry(
1522 STA_ENTRY
1523 ),
1524
1525 TP_fast_assign(
1526 STA_ASSIGN;
1527 ),
1528
1529 TP_printk(
1530 STA_PR_FMT, STA_PR_ARG
1531 )
1532);
1533
1502/* 1534/*
1503 * Tracing for API calls that drivers call. 1535 * Tracing for API calls that drivers call.
1504 */ 1536 */
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 19d36d4117e0..5214686d9fd1 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -2328,7 +2328,8 @@ void ieee80211_tx_pending(unsigned long data)
2328/* functions for drivers to get certain frames */ 2328/* functions for drivers to get certain frames */
2329 2329
2330static void __ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata, 2330static void __ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata,
2331 struct ps_data *ps, struct sk_buff *skb) 2331 struct ps_data *ps, struct sk_buff *skb,
2332 bool is_template)
2332{ 2333{
2333 u8 *pos, *tim; 2334 u8 *pos, *tim;
2334 int aid0 = 0; 2335 int aid0 = 0;
@@ -2341,11 +2342,12 @@ static void __ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata,
2341 * checking byte-for-byte */ 2342 * checking byte-for-byte */
2342 have_bits = !bitmap_empty((unsigned long *)ps->tim, 2343 have_bits = !bitmap_empty((unsigned long *)ps->tim,
2343 IEEE80211_MAX_AID+1); 2344 IEEE80211_MAX_AID+1);
2344 2345 if (!is_template) {
2345 if (ps->dtim_count == 0) 2346 if (ps->dtim_count == 0)
2346 ps->dtim_count = sdata->vif.bss_conf.dtim_period - 1; 2347 ps->dtim_count = sdata->vif.bss_conf.dtim_period - 1;
2347 else 2348 else
2348 ps->dtim_count--; 2349 ps->dtim_count--;
2350 }
2349 2351
2350 tim = pos = (u8 *) skb_put(skb, 6); 2352 tim = pos = (u8 *) skb_put(skb, 6);
2351 *pos++ = WLAN_EID_TIM; 2353 *pos++ = WLAN_EID_TIM;
@@ -2391,7 +2393,8 @@ static void __ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata,
2391} 2393}
2392 2394
2393static int ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata, 2395static int ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata,
2394 struct ps_data *ps, struct sk_buff *skb) 2396 struct ps_data *ps, struct sk_buff *skb,
2397 bool is_template)
2395{ 2398{
2396 struct ieee80211_local *local = sdata->local; 2399 struct ieee80211_local *local = sdata->local;
2397 2400
@@ -2403,24 +2406,24 @@ static int ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata,
2403 * of the tim bitmap in mac80211 and the driver. 2406 * of the tim bitmap in mac80211 and the driver.
2404 */ 2407 */
2405 if (local->tim_in_locked_section) { 2408 if (local->tim_in_locked_section) {
2406 __ieee80211_beacon_add_tim(sdata, ps, skb); 2409 __ieee80211_beacon_add_tim(sdata, ps, skb, is_template);
2407 } else { 2410 } else {
2408 spin_lock_bh(&local->tim_lock); 2411 spin_lock_bh(&local->tim_lock);
2409 __ieee80211_beacon_add_tim(sdata, ps, skb); 2412 __ieee80211_beacon_add_tim(sdata, ps, skb, is_template);
2410 spin_unlock_bh(&local->tim_lock); 2413 spin_unlock_bh(&local->tim_lock);
2411 } 2414 }
2412 2415
2413 return 0; 2416 return 0;
2414} 2417}
2415 2418
2416static void ieee80211_update_csa(struct ieee80211_sub_if_data *sdata, 2419static void ieee80211_set_csa(struct ieee80211_sub_if_data *sdata,
2417 struct beacon_data *beacon) 2420 struct beacon_data *beacon)
2418{ 2421{
2419 struct probe_resp *resp; 2422 struct probe_resp *resp;
2420 int counter_offset_beacon = sdata->csa_counter_offset_beacon;
2421 int counter_offset_presp = sdata->csa_counter_offset_presp;
2422 u8 *beacon_data; 2423 u8 *beacon_data;
2423 size_t beacon_data_len; 2424 size_t beacon_data_len;
2425 int i;
2426 u8 count = sdata->csa_current_counter;
2424 2427
2425 switch (sdata->vif.type) { 2428 switch (sdata->vif.type) {
2426 case NL80211_IFTYPE_AP: 2429 case NL80211_IFTYPE_AP:
@@ -2438,40 +2441,57 @@ static void ieee80211_update_csa(struct ieee80211_sub_if_data *sdata,
2438 default: 2441 default:
2439 return; 2442 return;
2440 } 2443 }
2441 if (WARN_ON(counter_offset_beacon >= beacon_data_len))
2442 return;
2443 2444
2444 /* Warn if the driver did not check for/react to csa 2445 for (i = 0; i < IEEE80211_MAX_CSA_COUNTERS_NUM; ++i) {
2445 * completeness. A beacon with CSA counter set to 0 should 2446 u16 counter_offset_beacon =
2446 * never occur, because a counter of 1 means switch just 2447 sdata->csa_counter_offset_beacon[i];
2447 * before the next beacon. 2448 u16 counter_offset_presp = sdata->csa_counter_offset_presp[i];
2448 */
2449 if (WARN_ON(beacon_data[counter_offset_beacon] == 1))
2450 return;
2451 2449
2452 beacon_data[counter_offset_beacon]--; 2450 if (counter_offset_beacon) {
2451 if (WARN_ON(counter_offset_beacon >= beacon_data_len))
2452 return;
2453 2453
2454 if (sdata->vif.type == NL80211_IFTYPE_AP && counter_offset_presp) { 2454 beacon_data[counter_offset_beacon] = count;
2455 rcu_read_lock(); 2455 }
2456 resp = rcu_dereference(sdata->u.ap.probe_resp); 2456
2457 if (sdata->vif.type == NL80211_IFTYPE_AP &&
2458 counter_offset_presp) {
2459 rcu_read_lock();
2460 resp = rcu_dereference(sdata->u.ap.probe_resp);
2457 2461
2458 /* if nl80211 accepted the offset, this should not happen. */ 2462 /* If nl80211 accepted the offset, this should
2459 if (WARN_ON(!resp)) { 2463 * not happen.
2464 */
2465 if (WARN_ON(!resp)) {
2466 rcu_read_unlock();
2467 return;
2468 }
2469 resp->data[counter_offset_presp] = count;
2460 rcu_read_unlock(); 2470 rcu_read_unlock();
2461 return;
2462 } 2471 }
2463 resp->data[counter_offset_presp]--;
2464 rcu_read_unlock();
2465 } 2472 }
2466} 2473}
2467 2474
2475u8 ieee80211_csa_update_counter(struct ieee80211_vif *vif)
2476{
2477 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
2478
2479 sdata->csa_current_counter--;
2480
2481 /* the counter should never reach 0 */
2482 WARN_ON(!sdata->csa_current_counter);
2483
2484 return sdata->csa_current_counter;
2485}
2486EXPORT_SYMBOL(ieee80211_csa_update_counter);
2487
2468bool ieee80211_csa_is_complete(struct ieee80211_vif *vif) 2488bool ieee80211_csa_is_complete(struct ieee80211_vif *vif)
2469{ 2489{
2470 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); 2490 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
2471 struct beacon_data *beacon = NULL; 2491 struct beacon_data *beacon = NULL;
2472 u8 *beacon_data; 2492 u8 *beacon_data;
2473 size_t beacon_data_len; 2493 size_t beacon_data_len;
2474 int counter_beacon = sdata->csa_counter_offset_beacon; 2494 int counter_beacon = sdata->csa_counter_offset_beacon[0];
2475 int ret = false; 2495 int ret = false;
2476 2496
2477 if (!ieee80211_sdata_running(sdata)) 2497 if (!ieee80211_sdata_running(sdata))
@@ -2521,9 +2541,11 @@ bool ieee80211_csa_is_complete(struct ieee80211_vif *vif)
2521} 2541}
2522EXPORT_SYMBOL(ieee80211_csa_is_complete); 2542EXPORT_SYMBOL(ieee80211_csa_is_complete);
2523 2543
2524struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, 2544static struct sk_buff *
2525 struct ieee80211_vif *vif, 2545__ieee80211_beacon_get(struct ieee80211_hw *hw,
2526 u16 *tim_offset, u16 *tim_length) 2546 struct ieee80211_vif *vif,
2547 struct ieee80211_mutable_offsets *offs,
2548 bool is_template)
2527{ 2549{
2528 struct ieee80211_local *local = hw_to_local(hw); 2550 struct ieee80211_local *local = hw_to_local(hw);
2529 struct sk_buff *skb = NULL; 2551 struct sk_buff *skb = NULL;
@@ -2532,6 +2554,7 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
2532 enum ieee80211_band band; 2554 enum ieee80211_band band;
2533 struct ieee80211_tx_rate_control txrc; 2555 struct ieee80211_tx_rate_control txrc;
2534 struct ieee80211_chanctx_conf *chanctx_conf; 2556 struct ieee80211_chanctx_conf *chanctx_conf;
2557 int csa_off_base = 0;
2535 2558
2536 rcu_read_lock(); 2559 rcu_read_lock();
2537 2560
@@ -2541,18 +2564,20 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
2541 if (!ieee80211_sdata_running(sdata) || !chanctx_conf) 2564 if (!ieee80211_sdata_running(sdata) || !chanctx_conf)
2542 goto out; 2565 goto out;
2543 2566
2544 if (tim_offset) 2567 if (offs)
2545 *tim_offset = 0; 2568 memset(offs, 0, sizeof(*offs));
2546 if (tim_length)
2547 *tim_length = 0;
2548 2569
2549 if (sdata->vif.type == NL80211_IFTYPE_AP) { 2570 if (sdata->vif.type == NL80211_IFTYPE_AP) {
2550 struct ieee80211_if_ap *ap = &sdata->u.ap; 2571 struct ieee80211_if_ap *ap = &sdata->u.ap;
2551 struct beacon_data *beacon = rcu_dereference(ap->beacon); 2572 struct beacon_data *beacon = rcu_dereference(ap->beacon);
2552 2573
2553 if (beacon) { 2574 if (beacon) {
2554 if (sdata->vif.csa_active) 2575 if (sdata->vif.csa_active) {
2555 ieee80211_update_csa(sdata, beacon); 2576 if (!is_template)
2577 ieee80211_csa_update_counter(vif);
2578
2579 ieee80211_set_csa(sdata, beacon);
2580 }
2556 2581
2557 /* 2582 /*
2558 * headroom, head length, 2583 * headroom, head length,
@@ -2569,12 +2594,16 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
2569 memcpy(skb_put(skb, beacon->head_len), beacon->head, 2594 memcpy(skb_put(skb, beacon->head_len), beacon->head,
2570 beacon->head_len); 2595 beacon->head_len);
2571 2596
2572 ieee80211_beacon_add_tim(sdata, &ap->ps, skb); 2597 ieee80211_beacon_add_tim(sdata, &ap->ps, skb,
2598 is_template);
2573 2599
2574 if (tim_offset) 2600 if (offs) {
2575 *tim_offset = beacon->head_len; 2601 offs->tim_offset = beacon->head_len;
2576 if (tim_length) 2602 offs->tim_length = skb->len - beacon->head_len;
2577 *tim_length = skb->len - beacon->head_len; 2603
2604 /* for AP the csa offsets are from tail */
2605 csa_off_base = skb->len;
2606 }
2578 2607
2579 if (beacon->tail) 2608 if (beacon->tail)
2580 memcpy(skb_put(skb, beacon->tail_len), 2609 memcpy(skb_put(skb, beacon->tail_len),
@@ -2589,9 +2618,12 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
2589 if (!presp) 2618 if (!presp)
2590 goto out; 2619 goto out;
2591 2620
2592 if (sdata->vif.csa_active) 2621 if (sdata->vif.csa_active) {
2593 ieee80211_update_csa(sdata, presp); 2622 if (!is_template)
2623 ieee80211_csa_update_counter(vif);
2594 2624
2625 ieee80211_set_csa(sdata, presp);
2626 }
2595 2627
2596 skb = dev_alloc_skb(local->tx_headroom + presp->head_len + 2628 skb = dev_alloc_skb(local->tx_headroom + presp->head_len +
2597 local->hw.extra_beacon_tailroom); 2629 local->hw.extra_beacon_tailroom);
@@ -2611,8 +2643,17 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
2611 if (!bcn) 2643 if (!bcn)
2612 goto out; 2644 goto out;
2613 2645
2614 if (sdata->vif.csa_active) 2646 if (sdata->vif.csa_active) {
2615 ieee80211_update_csa(sdata, bcn); 2647 if (!is_template)
2648 /* TODO: For mesh csa_counter is in TU, so
2649 * decrementing it by one isn't correct, but
2650 * for now we leave it consistent with overall
2651 * mac80211's behavior.
2652 */
2653 ieee80211_csa_update_counter(vif);
2654
2655 ieee80211_set_csa(sdata, bcn);
2656 }
2616 2657
2617 if (ifmsh->sync_ops) 2658 if (ifmsh->sync_ops)
2618 ifmsh->sync_ops->adjust_tbtt(sdata, bcn); 2659 ifmsh->sync_ops->adjust_tbtt(sdata, bcn);
@@ -2626,13 +2667,33 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
2626 goto out; 2667 goto out;
2627 skb_reserve(skb, local->tx_headroom); 2668 skb_reserve(skb, local->tx_headroom);
2628 memcpy(skb_put(skb, bcn->head_len), bcn->head, bcn->head_len); 2669 memcpy(skb_put(skb, bcn->head_len), bcn->head, bcn->head_len);
2629 ieee80211_beacon_add_tim(sdata, &ifmsh->ps, skb); 2670 ieee80211_beacon_add_tim(sdata, &ifmsh->ps, skb, is_template);
2671
2672 if (offs) {
2673 offs->tim_offset = bcn->head_len;
2674 offs->tim_length = skb->len - bcn->head_len;
2675 }
2676
2630 memcpy(skb_put(skb, bcn->tail_len), bcn->tail, bcn->tail_len); 2677 memcpy(skb_put(skb, bcn->tail_len), bcn->tail, bcn->tail_len);
2631 } else { 2678 } else {
2632 WARN_ON(1); 2679 WARN_ON(1);
2633 goto out; 2680 goto out;
2634 } 2681 }
2635 2682
2683 /* CSA offsets */
2684 if (offs) {
2685 int i;
2686
2687 for (i = 0; i < IEEE80211_MAX_CSA_COUNTERS_NUM; i++) {
2688 u16 csa_off = sdata->csa_counter_offset_beacon[i];
2689
2690 if (!csa_off)
2691 continue;
2692
2693 offs->csa_counter_offs[i] = csa_off_base + csa_off;
2694 }
2695 }
2696
2636 band = chanctx_conf->def.chan->band; 2697 band = chanctx_conf->def.chan->band;
2637 2698
2638 info = IEEE80211_SKB_CB(skb); 2699 info = IEEE80211_SKB_CB(skb);
@@ -2663,6 +2724,32 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
2663 out: 2724 out:
2664 rcu_read_unlock(); 2725 rcu_read_unlock();
2665 return skb; 2726 return skb;
2727
2728}
2729
2730struct sk_buff *
2731ieee80211_beacon_get_template(struct ieee80211_hw *hw,
2732 struct ieee80211_vif *vif,
2733 struct ieee80211_mutable_offsets *offs)
2734{
2735 return __ieee80211_beacon_get(hw, vif, offs, true);
2736}
2737EXPORT_SYMBOL(ieee80211_beacon_get_template);
2738
2739struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
2740 struct ieee80211_vif *vif,
2741 u16 *tim_offset, u16 *tim_length)
2742{
2743 struct ieee80211_mutable_offsets offs = {};
2744 struct sk_buff *bcn = __ieee80211_beacon_get(hw, vif, &offs, false);
2745
2746 if (tim_offset)
2747 *tim_offset = offs.tim_offset;
2748
2749 if (tim_length)
2750 *tim_length = offs.tim_length;
2751
2752 return bcn;
2666} 2753}
2667EXPORT_SYMBOL(ieee80211_beacon_get_tim); 2754EXPORT_SYMBOL(ieee80211_beacon_get_tim);
2668 2755
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index c08bd4aca6bb..6886601afe1c 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -1457,6 +1457,44 @@ void ieee80211_stop_device(struct ieee80211_local *local)
1457 drv_stop(local); 1457 drv_stop(local);
1458} 1458}
1459 1459
1460static void ieee80211_handle_reconfig_failure(struct ieee80211_local *local)
1461{
1462 struct ieee80211_sub_if_data *sdata;
1463 struct ieee80211_chanctx *ctx;
1464
1465 /*
1466 * We get here if during resume the device can't be restarted properly.
1467 * We might also get here if this happens during HW reset, which is a
1468 * slightly different situation and we need to drop all connections in
1469 * the latter case.
1470 *
1471 * Ask cfg80211 to turn off all interfaces, this will result in more
1472 * warnings but at least we'll then get into a clean stopped state.
1473 */
1474
1475 local->resuming = false;
1476 local->suspended = false;
1477 local->started = false;
1478
1479 /* scheduled scan clearly can't be running any more, but tell
1480 * cfg80211 and clear local state
1481 */
1482 ieee80211_sched_scan_end(local);
1483
1484 list_for_each_entry(sdata, &local->interfaces, list)
1485 sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER;
1486
1487 /* Mark channel contexts as not being in the driver any more to avoid
1488 * removing them from the driver during the shutdown process...
1489 */
1490 mutex_lock(&local->chanctx_mtx);
1491 list_for_each_entry(ctx, &local->chanctx_list, list)
1492 ctx->driver_present = false;
1493 mutex_unlock(&local->chanctx_mtx);
1494
1495 cfg80211_shutdown_all_interfaces(local->hw.wiphy);
1496}
1497
1460static void ieee80211_assign_chanctx(struct ieee80211_local *local, 1498static void ieee80211_assign_chanctx(struct ieee80211_local *local,
1461 struct ieee80211_sub_if_data *sdata) 1499 struct ieee80211_sub_if_data *sdata)
1462{ 1500{
@@ -1520,9 +1558,11 @@ int ieee80211_reconfig(struct ieee80211_local *local)
1520 */ 1558 */
1521 res = drv_start(local); 1559 res = drv_start(local);
1522 if (res) { 1560 if (res) {
1523 WARN(local->suspended, "Hardware became unavailable " 1561 if (local->suspended)
1524 "upon resume. This could be a software issue " 1562 WARN(1, "Hardware became unavailable upon resume. This could be a software issue prior to suspend or a hardware issue.\n");
1525 "prior to suspend or a hardware issue.\n"); 1563 else
1564 WARN(1, "Hardware became unavailable during restart.\n");
1565 ieee80211_handle_reconfig_failure(local);
1526 return res; 1566 return res;
1527 } 1567 }
1528 1568
diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c
index 9c4a5eb91cbf..14c98e48f261 100644
--- a/net/rfkill/rfkill-gpio.c
+++ b/net/rfkill/rfkill-gpio.c
@@ -45,17 +45,14 @@ static int rfkill_gpio_set_power(void *data, bool blocked)
45{ 45{
46 struct rfkill_gpio_data *rfkill = data; 46 struct rfkill_gpio_data *rfkill = data;
47 47
48 if (blocked) { 48 if (!blocked && !IS_ERR(rfkill->clk) && !rfkill->clk_enabled)
49 gpiod_set_value(rfkill->shutdown_gpio, 0); 49 clk_enable(rfkill->clk);
50 gpiod_set_value(rfkill->reset_gpio, 0); 50
51 if (!IS_ERR(rfkill->clk) && rfkill->clk_enabled) 51 gpiod_set_value_cansleep(rfkill->shutdown_gpio, !blocked);
52 clk_disable(rfkill->clk); 52 gpiod_set_value_cansleep(rfkill->reset_gpio, !blocked);
53 } else { 53
54 if (!IS_ERR(rfkill->clk) && !rfkill->clk_enabled) 54 if (blocked && !IS_ERR(rfkill->clk) && rfkill->clk_enabled)
55 clk_enable(rfkill->clk); 55 clk_disable(rfkill->clk);
56 gpiod_set_value(rfkill->reset_gpio, 1);
57 gpiod_set_value(rfkill->shutdown_gpio, 1);
58 }
59 56
60 rfkill->clk_enabled = blocked; 57 rfkill->clk_enabled = blocked;
61 58
diff --git a/net/wireless/ap.c b/net/wireless/ap.c
index 3e02ade508d8..bdad1f951561 100644
--- a/net/wireless/ap.c
+++ b/net/wireless/ap.c
@@ -6,8 +6,8 @@
6#include "rdev-ops.h" 6#include "rdev-ops.h"
7 7
8 8
9static int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev, 9int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev,
10 struct net_device *dev, bool notify) 10 struct net_device *dev, bool notify)
11{ 11{
12 struct wireless_dev *wdev = dev->ieee80211_ptr; 12 struct wireless_dev *wdev = dev->ieee80211_ptr;
13 int err; 13 int err;
diff --git a/net/wireless/chan.c b/net/wireless/chan.c
index 84d686e2dbd0..992b34070bcb 100644
--- a/net/wireless/chan.c
+++ b/net/wireless/chan.c
@@ -370,8 +370,8 @@ int cfg80211_chandef_dfs_required(struct wiphy *wiphy,
370 case NL80211_IFTYPE_AP_VLAN: 370 case NL80211_IFTYPE_AP_VLAN:
371 case NL80211_IFTYPE_WDS: 371 case NL80211_IFTYPE_WDS:
372 case NL80211_IFTYPE_P2P_DEVICE: 372 case NL80211_IFTYPE_P2P_DEVICE:
373 case NL80211_IFTYPE_UNSPECIFIED:
374 break; 373 break;
374 case NL80211_IFTYPE_UNSPECIFIED:
375 case NUM_NL80211_IFTYPES: 375 case NUM_NL80211_IFTYPES:
376 WARN_ON(1); 376 WARN_ON(1);
377 } 377 }
@@ -796,8 +796,7 @@ bool cfg80211_reg_can_beacon(struct wiphy *wiphy,
796 !cfg80211_go_permissive_chan(rdev, chandef->chan)) 796 !cfg80211_go_permissive_chan(rdev, chandef->chan))
797 prohibited_flags |= IEEE80211_CHAN_NO_IR; 797 prohibited_flags |= IEEE80211_CHAN_NO_IR;
798 798
799 if (cfg80211_chandef_dfs_required(wiphy, chandef, 799 if (cfg80211_chandef_dfs_required(wiphy, chandef, iftype) > 0 &&
800 NL80211_IFTYPE_UNSPECIFIED) > 0 &&
801 cfg80211_chandef_dfs_available(wiphy, chandef)) { 800 cfg80211_chandef_dfs_available(wiphy, chandef)) {
802 /* We can skip IEEE80211_CHAN_NO_IR if chandef dfs available */ 801 /* We can skip IEEE80211_CHAN_NO_IR if chandef dfs available */
803 prohibited_flags = IEEE80211_CHAN_DISABLED; 802 prohibited_flags = IEEE80211_CHAN_DISABLED;
diff --git a/net/wireless/core.c b/net/wireless/core.c
index b3ff3697239a..d03d8bdb29ca 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -210,15 +210,12 @@ void cfg80211_stop_p2p_device(struct cfg80211_registered_device *rdev,
210 } 210 }
211} 211}
212 212
213static int cfg80211_rfkill_set_block(void *data, bool blocked) 213void cfg80211_shutdown_all_interfaces(struct wiphy *wiphy)
214{ 214{
215 struct cfg80211_registered_device *rdev = data; 215 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
216 struct wireless_dev *wdev; 216 struct wireless_dev *wdev;
217 217
218 if (!blocked) 218 ASSERT_RTNL();
219 return 0;
220
221 rtnl_lock();
222 219
223 list_for_each_entry(wdev, &rdev->wdev_list, list) { 220 list_for_each_entry(wdev, &rdev->wdev_list, list) {
224 if (wdev->netdev) { 221 if (wdev->netdev) {
@@ -234,7 +231,18 @@ static int cfg80211_rfkill_set_block(void *data, bool blocked)
234 break; 231 break;
235 } 232 }
236 } 233 }
234}
235EXPORT_SYMBOL_GPL(cfg80211_shutdown_all_interfaces);
237 236
237static int cfg80211_rfkill_set_block(void *data, bool blocked)
238{
239 struct cfg80211_registered_device *rdev = data;
240
241 if (!blocked)
242 return 0;
243
244 rtnl_lock();
245 cfg80211_shutdown_all_interfaces(&rdev->wiphy);
238 rtnl_unlock(); 246 rtnl_unlock();
239 247
240 return 0; 248 return 0;
@@ -394,6 +402,8 @@ struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv)
394 rdev->wiphy.rts_threshold = (u32) -1; 402 rdev->wiphy.rts_threshold = (u32) -1;
395 rdev->wiphy.coverage_class = 0; 403 rdev->wiphy.coverage_class = 0;
396 404
405 rdev->wiphy.max_num_csa_counters = 1;
406
397 return &rdev->wiphy; 407 return &rdev->wiphy;
398} 408}
399EXPORT_SYMBOL(wiphy_new); 409EXPORT_SYMBOL(wiphy_new);
@@ -690,7 +700,7 @@ void wiphy_unregister(struct wiphy *wiphy)
690 rtnl_lock(); 700 rtnl_lock();
691 rdev->wiphy.registered = false; 701 rdev->wiphy.registered = false;
692 702
693 BUG_ON(!list_empty(&rdev->wdev_list)); 703 WARN_ON(!list_empty(&rdev->wdev_list));
694 704
695 /* 705 /*
696 * First remove the hardware from everywhere, this makes 706 * First remove the hardware from everywhere, this makes
@@ -792,23 +802,23 @@ void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev,
792 rdev->num_running_monitor_ifaces += num; 802 rdev->num_running_monitor_ifaces += num;
793} 803}
794 804
795void cfg80211_leave(struct cfg80211_registered_device *rdev, 805void __cfg80211_leave(struct cfg80211_registered_device *rdev,
796 struct wireless_dev *wdev) 806 struct wireless_dev *wdev)
797{ 807{
798 struct net_device *dev = wdev->netdev; 808 struct net_device *dev = wdev->netdev;
799 809
800 ASSERT_RTNL(); 810 ASSERT_RTNL();
811 ASSERT_WDEV_LOCK(wdev);
801 812
802 switch (wdev->iftype) { 813 switch (wdev->iftype) {
803 case NL80211_IFTYPE_ADHOC: 814 case NL80211_IFTYPE_ADHOC:
804 cfg80211_leave_ibss(rdev, dev, true); 815 __cfg80211_leave_ibss(rdev, dev, true);
805 break; 816 break;
806 case NL80211_IFTYPE_P2P_CLIENT: 817 case NL80211_IFTYPE_P2P_CLIENT:
807 case NL80211_IFTYPE_STATION: 818 case NL80211_IFTYPE_STATION:
808 if (rdev->sched_scan_req && dev == rdev->sched_scan_req->dev) 819 if (rdev->sched_scan_req && dev == rdev->sched_scan_req->dev)
809 __cfg80211_stop_sched_scan(rdev, false); 820 __cfg80211_stop_sched_scan(rdev, false);
810 821
811 wdev_lock(wdev);
812#ifdef CONFIG_CFG80211_WEXT 822#ifdef CONFIG_CFG80211_WEXT
813 kfree(wdev->wext.ie); 823 kfree(wdev->wext.ie);
814 wdev->wext.ie = NULL; 824 wdev->wext.ie = NULL;
@@ -817,20 +827,49 @@ void cfg80211_leave(struct cfg80211_registered_device *rdev,
817#endif 827#endif
818 cfg80211_disconnect(rdev, dev, 828 cfg80211_disconnect(rdev, dev,
819 WLAN_REASON_DEAUTH_LEAVING, true); 829 WLAN_REASON_DEAUTH_LEAVING, true);
820 wdev_unlock(wdev);
821 break; 830 break;
822 case NL80211_IFTYPE_MESH_POINT: 831 case NL80211_IFTYPE_MESH_POINT:
823 cfg80211_leave_mesh(rdev, dev); 832 __cfg80211_leave_mesh(rdev, dev);
824 break; 833 break;
825 case NL80211_IFTYPE_AP: 834 case NL80211_IFTYPE_AP:
826 case NL80211_IFTYPE_P2P_GO: 835 case NL80211_IFTYPE_P2P_GO:
827 cfg80211_stop_ap(rdev, dev, true); 836 __cfg80211_stop_ap(rdev, dev, true);
828 break; 837 break;
829 default: 838 default:
830 break; 839 break;
831 } 840 }
832} 841}
833 842
843void cfg80211_leave(struct cfg80211_registered_device *rdev,
844 struct wireless_dev *wdev)
845{
846 wdev_lock(wdev);
847 __cfg80211_leave(rdev, wdev);
848 wdev_unlock(wdev);
849}
850
851void cfg80211_stop_iface(struct wiphy *wiphy, struct wireless_dev *wdev,
852 gfp_t gfp)
853{
854 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
855 struct cfg80211_event *ev;
856 unsigned long flags;
857
858 trace_cfg80211_stop_iface(wiphy, wdev);
859
860 ev = kzalloc(sizeof(*ev), gfp);
861 if (!ev)
862 return;
863
864 ev->type = EVENT_STOPPED;
865
866 spin_lock_irqsave(&wdev->event_lock, flags);
867 list_add_tail(&ev->list, &wdev->event_list);
868 spin_unlock_irqrestore(&wdev->event_lock, flags);
869 queue_work(cfg80211_wq, &rdev->event_work);
870}
871EXPORT_SYMBOL(cfg80211_stop_iface);
872
834static int cfg80211_netdev_notifier_call(struct notifier_block *nb, 873static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
835 unsigned long state, void *ptr) 874 unsigned long state, void *ptr)
836{ 875{
diff --git a/net/wireless/core.h b/net/wireless/core.h
index 681b8fa4355b..e9afbf10e756 100644
--- a/net/wireless/core.h
+++ b/net/wireless/core.h
@@ -185,6 +185,7 @@ enum cfg80211_event_type {
185 EVENT_ROAMED, 185 EVENT_ROAMED,
186 EVENT_DISCONNECTED, 186 EVENT_DISCONNECTED,
187 EVENT_IBSS_JOINED, 187 EVENT_IBSS_JOINED,
188 EVENT_STOPPED,
188}; 189};
189 190
190struct cfg80211_event { 191struct cfg80211_event {
@@ -281,6 +282,8 @@ int cfg80211_join_mesh(struct cfg80211_registered_device *rdev,
281 struct net_device *dev, 282 struct net_device *dev,
282 struct mesh_setup *setup, 283 struct mesh_setup *setup,
283 const struct mesh_config *conf); 284 const struct mesh_config *conf);
285int __cfg80211_leave_mesh(struct cfg80211_registered_device *rdev,
286 struct net_device *dev);
284int cfg80211_leave_mesh(struct cfg80211_registered_device *rdev, 287int cfg80211_leave_mesh(struct cfg80211_registered_device *rdev,
285 struct net_device *dev); 288 struct net_device *dev);
286int cfg80211_set_mesh_channel(struct cfg80211_registered_device *rdev, 289int cfg80211_set_mesh_channel(struct cfg80211_registered_device *rdev,
@@ -288,6 +291,8 @@ int cfg80211_set_mesh_channel(struct cfg80211_registered_device *rdev,
288 struct cfg80211_chan_def *chandef); 291 struct cfg80211_chan_def *chandef);
289 292
290/* AP */ 293/* AP */
294int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev,
295 struct net_device *dev, bool notify);
291int cfg80211_stop_ap(struct cfg80211_registered_device *rdev, 296int cfg80211_stop_ap(struct cfg80211_registered_device *rdev,
292 struct net_device *dev, bool notify); 297 struct net_device *dev, bool notify);
293 298
@@ -441,6 +446,8 @@ int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev,
441void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev, 446void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev,
442 enum nl80211_iftype iftype, int num); 447 enum nl80211_iftype iftype, int num);
443 448
449void __cfg80211_leave(struct cfg80211_registered_device *rdev,
450 struct wireless_dev *wdev);
444void cfg80211_leave(struct cfg80211_registered_device *rdev, 451void cfg80211_leave(struct cfg80211_registered_device *rdev,
445 struct wireless_dev *wdev); 452 struct wireless_dev *wdev);
446 453
diff --git a/net/wireless/ibss.c b/net/wireless/ibss.c
index 6b50588b709f..8f345da3ea5f 100644
--- a/net/wireless/ibss.c
+++ b/net/wireless/ibss.c
@@ -420,8 +420,8 @@ int cfg80211_ibss_wext_siwessid(struct net_device *dev,
420 if (len > 0 && ssid[len - 1] == '\0') 420 if (len > 0 && ssid[len - 1] == '\0')
421 len--; 421 len--;
422 422
423 memcpy(wdev->ssid, ssid, len);
423 wdev->wext.ibss.ssid = wdev->ssid; 424 wdev->wext.ibss.ssid = wdev->ssid;
424 memcpy(wdev->wext.ibss.ssid, ssid, len);
425 wdev->wext.ibss.ssid_len = len; 425 wdev->wext.ibss.ssid_len = len;
426 426
427 wdev_lock(wdev); 427 wdev_lock(wdev);
diff --git a/net/wireless/mesh.c b/net/wireless/mesh.c
index 3ddfb7cd335e..092300b30c37 100644
--- a/net/wireless/mesh.c
+++ b/net/wireless/mesh.c
@@ -238,8 +238,8 @@ int cfg80211_set_mesh_channel(struct cfg80211_registered_device *rdev,
238 return 0; 238 return 0;
239} 239}
240 240
241static int __cfg80211_leave_mesh(struct cfg80211_registered_device *rdev, 241int __cfg80211_leave_mesh(struct cfg80211_registered_device *rdev,
242 struct net_device *dev) 242 struct net_device *dev)
243{ 243{
244 struct wireless_dev *wdev = dev->ieee80211_ptr; 244 struct wireless_dev *wdev = dev->ieee80211_ptr;
245 int err; 245 int err;
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 0f1b18f209d6..62bdb1adaa4d 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -371,8 +371,8 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = {
371 [NL80211_ATTR_CH_SWITCH_COUNT] = { .type = NLA_U32 }, 371 [NL80211_ATTR_CH_SWITCH_COUNT] = { .type = NLA_U32 },
372 [NL80211_ATTR_CH_SWITCH_BLOCK_TX] = { .type = NLA_FLAG }, 372 [NL80211_ATTR_CH_SWITCH_BLOCK_TX] = { .type = NLA_FLAG },
373 [NL80211_ATTR_CSA_IES] = { .type = NLA_NESTED }, 373 [NL80211_ATTR_CSA_IES] = { .type = NLA_NESTED },
374 [NL80211_ATTR_CSA_C_OFF_BEACON] = { .type = NLA_U16 }, 374 [NL80211_ATTR_CSA_C_OFF_BEACON] = { .type = NLA_BINARY },
375 [NL80211_ATTR_CSA_C_OFF_PRESP] = { .type = NLA_U16 }, 375 [NL80211_ATTR_CSA_C_OFF_PRESP] = { .type = NLA_BINARY },
376 [NL80211_ATTR_STA_SUPPORTED_CHANNELS] = { .type = NLA_BINARY }, 376 [NL80211_ATTR_STA_SUPPORTED_CHANNELS] = { .type = NLA_BINARY },
377 [NL80211_ATTR_STA_SUPPORTED_OPER_CLASSES] = { .type = NLA_BINARY }, 377 [NL80211_ATTR_STA_SUPPORTED_OPER_CLASSES] = { .type = NLA_BINARY },
378 [NL80211_ATTR_HANDLE_DFS] = { .type = NLA_FLAG }, 378 [NL80211_ATTR_HANDLE_DFS] = { .type = NLA_FLAG },
@@ -386,6 +386,7 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = {
386 [NL80211_ATTR_WIPHY_FREQ_HINT] = { .type = NLA_U32 }, 386 [NL80211_ATTR_WIPHY_FREQ_HINT] = { .type = NLA_U32 },
387 [NL80211_ATTR_TDLS_PEER_CAPABILITY] = { .type = NLA_U32 }, 387 [NL80211_ATTR_TDLS_PEER_CAPABILITY] = { .type = NLA_U32 },
388 [NL80211_ATTR_IFACE_SOCKET_OWNER] = { .type = NLA_FLAG }, 388 [NL80211_ATTR_IFACE_SOCKET_OWNER] = { .type = NLA_FLAG },
389 [NL80211_ATTR_CSA_C_OFFSETS_TX] = { .type = NLA_BINARY },
389}; 390};
390 391
391/* policy for the key attributes */ 392/* policy for the key attributes */
@@ -970,8 +971,10 @@ static int nl80211_put_iface_combinations(struct wiphy *wiphy,
970 c->max_interfaces)) 971 c->max_interfaces))
971 goto nla_put_failure; 972 goto nla_put_failure;
972 if (large && 973 if (large &&
973 nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS, 974 (nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS,
974 c->radar_detect_widths)) 975 c->radar_detect_widths) ||
976 nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_REGIONS,
977 c->radar_detect_regions)))
975 goto nla_put_failure; 978 goto nla_put_failure;
976 979
977 nla_nest_end(msg, nl_combi); 980 nla_nest_end(msg, nl_combi);
@@ -1667,6 +1670,13 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
1667 } 1670 }
1668 nla_nest_end(msg, nested); 1671 nla_nest_end(msg, nested);
1669 } 1672 }
1673 state->split_start++;
1674 break;
1675 case 12:
1676 if (rdev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH &&
1677 nla_put_u8(msg, NL80211_ATTR_MAX_CSA_COUNTERS,
1678 rdev->wiphy.max_num_csa_counters))
1679 goto nla_put_failure;
1670 1680
1671 /* done */ 1681 /* done */
1672 state->split_start = 0; 1682 state->split_start = 0;
@@ -3640,6 +3650,10 @@ static int nl80211_send_station(struct sk_buff *msg, u32 portid, u32 seq,
3640 nla_put_u32(msg, NL80211_STA_INFO_TX_FAILED, 3650 nla_put_u32(msg, NL80211_STA_INFO_TX_FAILED,
3641 sinfo->tx_failed)) 3651 sinfo->tx_failed))
3642 goto nla_put_failure; 3652 goto nla_put_failure;
3653 if ((sinfo->filled & STATION_INFO_EXPECTED_THROUGHPUT) &&
3654 nla_put_u32(msg, NL80211_STA_INFO_EXPECTED_THROUGHPUT,
3655 sinfo->expected_throughput))
3656 goto nla_put_failure;
3643 if ((sinfo->filled & STATION_INFO_BEACON_LOSS_COUNT) && 3657 if ((sinfo->filled & STATION_INFO_BEACON_LOSS_COUNT) &&
3644 nla_put_u32(msg, NL80211_STA_INFO_BEACON_LOSS, 3658 nla_put_u32(msg, NL80211_STA_INFO_BEACON_LOSS,
3645 sinfo->beacon_loss_count)) 3659 sinfo->beacon_loss_count))
@@ -5820,7 +5834,7 @@ static int nl80211_start_radar_detection(struct sk_buff *skb,
5820 return -EBUSY; 5834 return -EBUSY;
5821 5835
5822 err = cfg80211_chandef_dfs_required(wdev->wiphy, &chandef, 5836 err = cfg80211_chandef_dfs_required(wdev->wiphy, &chandef,
5823 NL80211_IFTYPE_UNSPECIFIED); 5837 wdev->iftype);
5824 if (err < 0) 5838 if (err < 0)
5825 return err; 5839 return err;
5826 5840
@@ -5861,6 +5875,7 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
5861 u8 radar_detect_width = 0; 5875 u8 radar_detect_width = 0;
5862 int err; 5876 int err;
5863 bool need_new_beacon = false; 5877 bool need_new_beacon = false;
5878 int len, i;
5864 5879
5865 if (!rdev->ops->channel_switch || 5880 if (!rdev->ops->channel_switch ||
5866 !(rdev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH)) 5881 !(rdev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH))
@@ -5919,26 +5934,55 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
5919 if (!csa_attrs[NL80211_ATTR_CSA_C_OFF_BEACON]) 5934 if (!csa_attrs[NL80211_ATTR_CSA_C_OFF_BEACON])
5920 return -EINVAL; 5935 return -EINVAL;
5921 5936
5922 params.counter_offset_beacon = 5937 len = nla_len(csa_attrs[NL80211_ATTR_CSA_C_OFF_BEACON]);
5923 nla_get_u16(csa_attrs[NL80211_ATTR_CSA_C_OFF_BEACON]); 5938 if (!len || (len % sizeof(u16)))
5924 if (params.counter_offset_beacon >= params.beacon_csa.tail_len)
5925 return -EINVAL; 5939 return -EINVAL;
5926 5940
5927 /* sanity check - counters should be the same */ 5941 params.n_counter_offsets_beacon = len / sizeof(u16);
5928 if (params.beacon_csa.tail[params.counter_offset_beacon] != 5942 if (rdev->wiphy.max_num_csa_counters &&
5929 params.count) 5943 (params.n_counter_offsets_beacon >
5944 rdev->wiphy.max_num_csa_counters))
5930 return -EINVAL; 5945 return -EINVAL;
5931 5946
5947 params.counter_offsets_beacon =
5948 nla_data(csa_attrs[NL80211_ATTR_CSA_C_OFF_BEACON]);
5949
5950 /* sanity checks - counters should fit and be the same */
5951 for (i = 0; i < params.n_counter_offsets_beacon; i++) {
5952 u16 offset = params.counter_offsets_beacon[i];
5953
5954 if (offset >= params.beacon_csa.tail_len)
5955 return -EINVAL;
5956
5957 if (params.beacon_csa.tail[offset] != params.count)
5958 return -EINVAL;
5959 }
5960
5932 if (csa_attrs[NL80211_ATTR_CSA_C_OFF_PRESP]) { 5961 if (csa_attrs[NL80211_ATTR_CSA_C_OFF_PRESP]) {
5933 params.counter_offset_presp = 5962 len = nla_len(csa_attrs[NL80211_ATTR_CSA_C_OFF_PRESP]);
5934 nla_get_u16(csa_attrs[NL80211_ATTR_CSA_C_OFF_PRESP]); 5963 if (!len || (len % sizeof(u16)))
5935 if (params.counter_offset_presp >=
5936 params.beacon_csa.probe_resp_len)
5937 return -EINVAL; 5964 return -EINVAL;
5938 5965
5939 if (params.beacon_csa.probe_resp[params.counter_offset_presp] != 5966 params.n_counter_offsets_presp = len / sizeof(u16);
5940 params.count) 5967 if (rdev->wiphy.max_num_csa_counters &&
5968 (params.n_counter_offsets_beacon >
5969 rdev->wiphy.max_num_csa_counters))
5941 return -EINVAL; 5970 return -EINVAL;
5971
5972 params.counter_offsets_presp =
5973 nla_data(csa_attrs[NL80211_ATTR_CSA_C_OFF_PRESP]);
5974
5975 /* sanity checks - counters should fit and be the same */
5976 for (i = 0; i < params.n_counter_offsets_presp; i++) {
5977 u16 offset = params.counter_offsets_presp[i];
5978
5979 if (offset >= params.beacon_csa.probe_resp_len)
5980 return -EINVAL;
5981
5982 if (params.beacon_csa.probe_resp[offset] !=
5983 params.count)
5984 return -EINVAL;
5985 }
5942 } 5986 }
5943 5987
5944skip_beacons: 5988skip_beacons:
@@ -7784,6 +7828,27 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info)
7784 if (!chandef.chan && params.offchan) 7828 if (!chandef.chan && params.offchan)
7785 return -EINVAL; 7829 return -EINVAL;
7786 7830
7831 params.buf = nla_data(info->attrs[NL80211_ATTR_FRAME]);
7832 params.len = nla_len(info->attrs[NL80211_ATTR_FRAME]);
7833
7834 if (info->attrs[NL80211_ATTR_CSA_C_OFFSETS_TX]) {
7835 int len = nla_len(info->attrs[NL80211_ATTR_CSA_C_OFFSETS_TX]);
7836 int i;
7837
7838 if (len % sizeof(u16))
7839 return -EINVAL;
7840
7841 params.n_csa_offsets = len / sizeof(u16);
7842 params.csa_offsets =
7843 nla_data(info->attrs[NL80211_ATTR_CSA_C_OFFSETS_TX]);
7844
7845 /* check that all the offsets fit the frame */
7846 for (i = 0; i < params.n_csa_offsets; i++) {
7847 if (params.csa_offsets[i] >= params.len)
7848 return -EINVAL;
7849 }
7850 }
7851
7787 if (!params.dont_wait_for_ack) { 7852 if (!params.dont_wait_for_ack) {
7788 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); 7853 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
7789 if (!msg) 7854 if (!msg)
@@ -7797,8 +7862,6 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info)
7797 } 7862 }
7798 } 7863 }
7799 7864
7800 params.buf = nla_data(info->attrs[NL80211_ATTR_FRAME]);
7801 params.len = nla_len(info->attrs[NL80211_ATTR_FRAME]);
7802 params.chan = chandef.chan; 7865 params.chan = chandef.chan;
7803 err = cfg80211_mlme_mgmt_tx(rdev, wdev, &params, &cookie); 7866 err = cfg80211_mlme_mgmt_tx(rdev, wdev, &params, &cookie);
7804 if (err) 7867 if (err)
@@ -8495,6 +8558,8 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info)
8495 8558
8496 nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN], 8559 nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
8497 rem) { 8560 rem) {
8561 u8 *mask_pat;
8562
8498 nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat), 8563 nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat),
8499 nla_len(pat), NULL); 8564 nla_len(pat), NULL);
8500 err = -EINVAL; 8565 err = -EINVAL;
@@ -8518,19 +8583,18 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info)
8518 goto error; 8583 goto error;
8519 new_triggers.patterns[i].pkt_offset = pkt_offset; 8584 new_triggers.patterns[i].pkt_offset = pkt_offset;
8520 8585
8521 new_triggers.patterns[i].mask = 8586 mask_pat = kmalloc(mask_len + pat_len, GFP_KERNEL);
8522 kmalloc(mask_len + pat_len, GFP_KERNEL); 8587 if (!mask_pat) {
8523 if (!new_triggers.patterns[i].mask) {
8524 err = -ENOMEM; 8588 err = -ENOMEM;
8525 goto error; 8589 goto error;
8526 } 8590 }
8527 new_triggers.patterns[i].pattern = 8591 new_triggers.patterns[i].mask = mask_pat;
8528 new_triggers.patterns[i].mask + mask_len; 8592 memcpy(mask_pat, nla_data(pat_tb[NL80211_PKTPAT_MASK]),
8529 memcpy(new_triggers.patterns[i].mask,
8530 nla_data(pat_tb[NL80211_PKTPAT_MASK]),
8531 mask_len); 8593 mask_len);
8594 mask_pat += mask_len;
8595 new_triggers.patterns[i].pattern = mask_pat;
8532 new_triggers.patterns[i].pattern_len = pat_len; 8596 new_triggers.patterns[i].pattern_len = pat_len;
8533 memcpy(new_triggers.patterns[i].pattern, 8597 memcpy(mask_pat,
8534 nla_data(pat_tb[NL80211_PKTPAT_PATTERN]), 8598 nla_data(pat_tb[NL80211_PKTPAT_PATTERN]),
8535 pat_len); 8599 pat_len);
8536 i++; 8600 i++;
@@ -8722,6 +8786,8 @@ static int nl80211_parse_coalesce_rule(struct cfg80211_registered_device *rdev,
8722 8786
8723 nla_for_each_nested(pat, tb[NL80211_ATTR_COALESCE_RULE_PKT_PATTERN], 8787 nla_for_each_nested(pat, tb[NL80211_ATTR_COALESCE_RULE_PKT_PATTERN],
8724 rem) { 8788 rem) {
8789 u8 *mask_pat;
8790
8725 nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat), 8791 nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat),
8726 nla_len(pat), NULL); 8792 nla_len(pat), NULL);
8727 if (!pat_tb[NL80211_PKTPAT_MASK] || 8793 if (!pat_tb[NL80211_PKTPAT_MASK] ||
@@ -8743,17 +8809,19 @@ static int nl80211_parse_coalesce_rule(struct cfg80211_registered_device *rdev,
8743 return -EINVAL; 8809 return -EINVAL;
8744 new_rule->patterns[i].pkt_offset = pkt_offset; 8810 new_rule->patterns[i].pkt_offset = pkt_offset;
8745 8811
8746 new_rule->patterns[i].mask = 8812 mask_pat = kmalloc(mask_len + pat_len, GFP_KERNEL);
8747 kmalloc(mask_len + pat_len, GFP_KERNEL); 8813 if (!mask_pat)
8748 if (!new_rule->patterns[i].mask)
8749 return -ENOMEM; 8814 return -ENOMEM;
8750 new_rule->patterns[i].pattern = 8815
8751 new_rule->patterns[i].mask + mask_len; 8816 new_rule->patterns[i].mask = mask_pat;
8752 memcpy(new_rule->patterns[i].mask, 8817 memcpy(mask_pat, nla_data(pat_tb[NL80211_PKTPAT_MASK]),
8753 nla_data(pat_tb[NL80211_PKTPAT_MASK]), mask_len); 8818 mask_len);
8819
8820 mask_pat += mask_len;
8821 new_rule->patterns[i].pattern = mask_pat;
8754 new_rule->patterns[i].pattern_len = pat_len; 8822 new_rule->patterns[i].pattern_len = pat_len;
8755 memcpy(new_rule->patterns[i].pattern, 8823 memcpy(mask_pat, nla_data(pat_tb[NL80211_PKTPAT_PATTERN]),
8756 nla_data(pat_tb[NL80211_PKTPAT_PATTERN]), pat_len); 8824 pat_len);
8757 i++; 8825 i++;
8758 } 8826 }
8759 8827
diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h
index 00cdf73ba6c4..d95bbe348138 100644
--- a/net/wireless/rdev-ops.h
+++ b/net/wireless/rdev-ops.h
@@ -199,7 +199,7 @@ static inline int rdev_change_station(struct cfg80211_registered_device *rdev,
199} 199}
200 200
201static inline int rdev_get_station(struct cfg80211_registered_device *rdev, 201static inline int rdev_get_station(struct cfg80211_registered_device *rdev,
202 struct net_device *dev, u8 *mac, 202 struct net_device *dev, const u8 *mac,
203 struct station_info *sinfo) 203 struct station_info *sinfo)
204{ 204{
205 int ret; 205 int ret;
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index e78f532aaa5b..558b0e3a02d8 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1876,7 +1876,8 @@ static void reg_process_hint(struct regulatory_request *reg_request)
1876 case NL80211_REGDOM_SET_BY_USER: 1876 case NL80211_REGDOM_SET_BY_USER:
1877 treatment = reg_process_hint_user(reg_request); 1877 treatment = reg_process_hint_user(reg_request);
1878 if (treatment == REG_REQ_IGNORE || 1878 if (treatment == REG_REQ_IGNORE ||
1879 treatment == REG_REQ_ALREADY_SET) 1879 treatment == REG_REQ_ALREADY_SET ||
1880 treatment == REG_REQ_USER_HINT_HANDLED)
1880 return; 1881 return;
1881 queue_delayed_work(system_power_efficient_wq, 1882 queue_delayed_work(system_power_efficient_wq,
1882 &reg_timeout, msecs_to_jiffies(3142)); 1883 &reg_timeout, msecs_to_jiffies(3142));
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index e7329bb6a323..0798c62e6085 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -891,6 +891,7 @@ cfg80211_inform_bss_width(struct wiphy *wiphy,
891 struct cfg80211_bss_ies *ies; 891 struct cfg80211_bss_ies *ies;
892 struct ieee80211_channel *channel; 892 struct ieee80211_channel *channel;
893 struct cfg80211_internal_bss tmp = {}, *res; 893 struct cfg80211_internal_bss tmp = {}, *res;
894 bool signal_valid;
894 895
895 if (WARN_ON(!wiphy)) 896 if (WARN_ON(!wiphy))
896 return NULL; 897 return NULL;
@@ -927,8 +928,9 @@ cfg80211_inform_bss_width(struct wiphy *wiphy,
927 rcu_assign_pointer(tmp.pub.beacon_ies, ies); 928 rcu_assign_pointer(tmp.pub.beacon_ies, ies);
928 rcu_assign_pointer(tmp.pub.ies, ies); 929 rcu_assign_pointer(tmp.pub.ies, ies);
929 930
930 res = cfg80211_bss_update(wiphy_to_rdev(wiphy), &tmp, 931 signal_valid = abs(rx_channel->center_freq - channel->center_freq) <=
931 rx_channel == channel); 932 wiphy->max_adj_channel_rssi_comp;
933 res = cfg80211_bss_update(wiphy_to_rdev(wiphy), &tmp, signal_valid);
932 if (!res) 934 if (!res)
933 return NULL; 935 return NULL;
934 936
@@ -952,6 +954,7 @@ cfg80211_inform_bss_width_frame(struct wiphy *wiphy,
952 struct cfg80211_internal_bss tmp = {}, *res; 954 struct cfg80211_internal_bss tmp = {}, *res;
953 struct cfg80211_bss_ies *ies; 955 struct cfg80211_bss_ies *ies;
954 struct ieee80211_channel *channel; 956 struct ieee80211_channel *channel;
957 bool signal_valid;
955 size_t ielen = len - offsetof(struct ieee80211_mgmt, 958 size_t ielen = len - offsetof(struct ieee80211_mgmt,
956 u.probe_resp.variable); 959 u.probe_resp.variable);
957 960
@@ -999,8 +1002,9 @@ cfg80211_inform_bss_width_frame(struct wiphy *wiphy,
999 tmp.pub.beacon_interval = le16_to_cpu(mgmt->u.probe_resp.beacon_int); 1002 tmp.pub.beacon_interval = le16_to_cpu(mgmt->u.probe_resp.beacon_int);
1000 tmp.pub.capability = le16_to_cpu(mgmt->u.probe_resp.capab_info); 1003 tmp.pub.capability = le16_to_cpu(mgmt->u.probe_resp.capab_info);
1001 1004
1002 res = cfg80211_bss_update(wiphy_to_rdev(wiphy), &tmp, 1005 signal_valid = abs(rx_channel->center_freq - channel->center_freq) <=
1003 rx_channel == channel); 1006 wiphy->max_adj_channel_rssi_comp;
1007 res = cfg80211_bss_update(wiphy_to_rdev(wiphy), &tmp, signal_valid);
1004 if (!res) 1008 if (!res)
1005 return NULL; 1009 return NULL;
1006 1010
diff --git a/net/wireless/sme.c b/net/wireless/sme.c
index 0c0844b585d1..8bbeeb302216 100644
--- a/net/wireless/sme.c
+++ b/net/wireless/sme.c
@@ -149,7 +149,8 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev)
149 case CFG80211_CONN_SCAN_AGAIN: 149 case CFG80211_CONN_SCAN_AGAIN:
150 return cfg80211_conn_scan(wdev); 150 return cfg80211_conn_scan(wdev);
151 case CFG80211_CONN_AUTHENTICATE_NEXT: 151 case CFG80211_CONN_AUTHENTICATE_NEXT:
152 BUG_ON(!rdev->ops->auth); 152 if (WARN_ON(!rdev->ops->auth))
153 return -EOPNOTSUPP;
153 wdev->conn->state = CFG80211_CONN_AUTHENTICATING; 154 wdev->conn->state = CFG80211_CONN_AUTHENTICATING;
154 return cfg80211_mlme_auth(rdev, wdev->netdev, 155 return cfg80211_mlme_auth(rdev, wdev->netdev,
155 params->channel, params->auth_type, 156 params->channel, params->auth_type,
@@ -161,7 +162,8 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev)
161 case CFG80211_CONN_AUTH_FAILED: 162 case CFG80211_CONN_AUTH_FAILED:
162 return -ENOTCONN; 163 return -ENOTCONN;
163 case CFG80211_CONN_ASSOCIATE_NEXT: 164 case CFG80211_CONN_ASSOCIATE_NEXT:
164 BUG_ON(!rdev->ops->assoc); 165 if (WARN_ON(!rdev->ops->assoc))
166 return -EOPNOTSUPP;
165 wdev->conn->state = CFG80211_CONN_ASSOCIATING; 167 wdev->conn->state = CFG80211_CONN_ASSOCIATING;
166 if (wdev->conn->prev_bssid_valid) 168 if (wdev->conn->prev_bssid_valid)
167 req.prev_bssid = wdev->conn->prev_bssid; 169 req.prev_bssid = wdev->conn->prev_bssid;
@@ -877,7 +879,7 @@ void __cfg80211_disconnected(struct net_device *dev, const u8 *ie,
877} 879}
878 880
879void cfg80211_disconnected(struct net_device *dev, u16 reason, 881void cfg80211_disconnected(struct net_device *dev, u16 reason,
880 u8 *ie, size_t ie_len, gfp_t gfp) 882 const u8 *ie, size_t ie_len, gfp_t gfp)
881{ 883{
882 struct wireless_dev *wdev = dev->ieee80211_ptr; 884 struct wireless_dev *wdev = dev->ieee80211_ptr;
883 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); 885 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index f3c13ff4d04c..560ed77084e9 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -1876,29 +1876,33 @@ TRACE_EVENT(rdev_channel_switch,
1876 WIPHY_ENTRY 1876 WIPHY_ENTRY
1877 NETDEV_ENTRY 1877 NETDEV_ENTRY
1878 CHAN_DEF_ENTRY 1878 CHAN_DEF_ENTRY
1879 __field(u16, counter_offset_beacon)
1880 __field(u16, counter_offset_presp)
1881 __field(bool, radar_required) 1879 __field(bool, radar_required)
1882 __field(bool, block_tx) 1880 __field(bool, block_tx)
1883 __field(u8, count) 1881 __field(u8, count)
1882 __dynamic_array(u16, bcn_ofs, params->n_counter_offsets_beacon)
1883 __dynamic_array(u16, pres_ofs, params->n_counter_offsets_presp)
1884 ), 1884 ),
1885 TP_fast_assign( 1885 TP_fast_assign(
1886 WIPHY_ASSIGN; 1886 WIPHY_ASSIGN;
1887 NETDEV_ASSIGN; 1887 NETDEV_ASSIGN;
1888 CHAN_DEF_ASSIGN(&params->chandef); 1888 CHAN_DEF_ASSIGN(&params->chandef);
1889 __entry->counter_offset_beacon = params->counter_offset_beacon;
1890 __entry->counter_offset_presp = params->counter_offset_presp;
1891 __entry->radar_required = params->radar_required; 1889 __entry->radar_required = params->radar_required;
1892 __entry->block_tx = params->block_tx; 1890 __entry->block_tx = params->block_tx;
1893 __entry->count = params->count; 1891 __entry->count = params->count;
1892 memcpy(__get_dynamic_array(bcn_ofs),
1893 params->counter_offsets_beacon,
1894 params->n_counter_offsets_beacon * sizeof(u16));
1895
1896 /* probe response offsets are optional */
1897 if (params->n_counter_offsets_presp)
1898 memcpy(__get_dynamic_array(pres_ofs),
1899 params->counter_offsets_presp,
1900 params->n_counter_offsets_presp * sizeof(u16));
1894 ), 1901 ),
1895 TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", " CHAN_DEF_PR_FMT 1902 TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", " CHAN_DEF_PR_FMT
1896 ", block_tx: %d, count: %u, radar_required: %d" 1903 ", block_tx: %d, count: %u, radar_required: %d",
1897 ", counter offsets (beacon/presp): %u/%u",
1898 WIPHY_PR_ARG, NETDEV_PR_ARG, CHAN_DEF_PR_ARG, 1904 WIPHY_PR_ARG, NETDEV_PR_ARG, CHAN_DEF_PR_ARG,
1899 __entry->block_tx, __entry->count, __entry->radar_required, 1905 __entry->block_tx, __entry->count, __entry->radar_required)
1900 __entry->counter_offset_beacon,
1901 __entry->counter_offset_presp)
1902); 1906);
1903 1907
1904TRACE_EVENT(rdev_set_qos_map, 1908TRACE_EVENT(rdev_set_qos_map,
@@ -2636,6 +2640,21 @@ TRACE_EVENT(cfg80211_ft_event,
2636 WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(target_ap)) 2640 WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(target_ap))
2637); 2641);
2638 2642
2643TRACE_EVENT(cfg80211_stop_iface,
2644 TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev),
2645 TP_ARGS(wiphy, wdev),
2646 TP_STRUCT__entry(
2647 WIPHY_ENTRY
2648 WDEV_ENTRY
2649 ),
2650 TP_fast_assign(
2651 WIPHY_ASSIGN;
2652 WDEV_ASSIGN;
2653 ),
2654 TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT,
2655 WIPHY_PR_ARG, WDEV_PR_ARG)
2656);
2657
2639#endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */ 2658#endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */
2640 2659
2641#undef TRACE_INCLUDE_PATH 2660#undef TRACE_INCLUDE_PATH
diff --git a/net/wireless/util.c b/net/wireless/util.c
index 7c47fa07b276..728f1c0dc70d 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -476,7 +476,8 @@ int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr,
476EXPORT_SYMBOL(ieee80211_data_to_8023); 476EXPORT_SYMBOL(ieee80211_data_to_8023);
477 477
478int ieee80211_data_from_8023(struct sk_buff *skb, const u8 *addr, 478int ieee80211_data_from_8023(struct sk_buff *skb, const u8 *addr,
479 enum nl80211_iftype iftype, u8 *bssid, bool qos) 479 enum nl80211_iftype iftype,
480 const u8 *bssid, bool qos)
480{ 481{
481 struct ieee80211_hdr hdr; 482 struct ieee80211_hdr hdr;
482 u16 hdrlen, ethertype; 483 u16 hdrlen, ethertype;
@@ -839,6 +840,9 @@ void cfg80211_process_wdev_events(struct wireless_dev *wdev)
839 __cfg80211_ibss_joined(wdev->netdev, ev->ij.bssid, 840 __cfg80211_ibss_joined(wdev->netdev, ev->ij.bssid,
840 ev->ij.channel); 841 ev->ij.channel);
841 break; 842 break;
843 case EVENT_STOPPED:
844 __cfg80211_leave(wiphy_to_rdev(wdev->wiphy), wdev);
845 break;
842 } 846 }
843 wdev_unlock(wdev); 847 wdev_unlock(wdev);
844 848
@@ -1271,10 +1275,20 @@ int cfg80211_iter_combinations(struct wiphy *wiphy,
1271 void *data), 1275 void *data),
1272 void *data) 1276 void *data)
1273{ 1277{
1278 const struct ieee80211_regdomain *regdom;
1279 enum nl80211_dfs_regions region = 0;
1274 int i, j, iftype; 1280 int i, j, iftype;
1275 int num_interfaces = 0; 1281 int num_interfaces = 0;
1276 u32 used_iftypes = 0; 1282 u32 used_iftypes = 0;
1277 1283
1284 if (radar_detect) {
1285 rcu_read_lock();
1286 regdom = rcu_dereference(cfg80211_regdomain);
1287 if (regdom)
1288 region = regdom->dfs_region;
1289 rcu_read_unlock();
1290 }
1291
1278 for (iftype = 0; iftype < NUM_NL80211_IFTYPES; iftype++) { 1292 for (iftype = 0; iftype < NUM_NL80211_IFTYPES; iftype++) {
1279 num_interfaces += iftype_num[iftype]; 1293 num_interfaces += iftype_num[iftype];
1280 if (iftype_num[iftype] > 0 && 1294 if (iftype_num[iftype] > 0 &&
@@ -1315,6 +1329,10 @@ int cfg80211_iter_combinations(struct wiphy *wiphy,
1315 if (radar_detect != (c->radar_detect_widths & radar_detect)) 1329 if (radar_detect != (c->radar_detect_widths & radar_detect))
1316 goto cont; 1330 goto cont;
1317 1331
1332 if (radar_detect && c->radar_detect_regions &&
1333 !(c->radar_detect_regions & BIT(region)))
1334 goto cont;
1335
1318 /* Finally check that all iftypes that we're currently 1336 /* Finally check that all iftypes that we're currently
1319 * using are actually part of this combination. If they 1337 * using are actually part of this combination. If they
1320 * aren't then we can't use this combination and have 1338 * aren't then we can't use this combination and have
@@ -1528,6 +1546,24 @@ unsigned int ieee80211_get_num_supported_channels(struct wiphy *wiphy)
1528} 1546}
1529EXPORT_SYMBOL(ieee80211_get_num_supported_channels); 1547EXPORT_SYMBOL(ieee80211_get_num_supported_channels);
1530 1548
1549int cfg80211_get_station(struct net_device *dev, const u8 *mac_addr,
1550 struct station_info *sinfo)
1551{
1552 struct cfg80211_registered_device *rdev;
1553 struct wireless_dev *wdev;
1554
1555 wdev = dev->ieee80211_ptr;
1556 if (!wdev)
1557 return -EOPNOTSUPP;
1558
1559 rdev = wiphy_to_rdev(wdev->wiphy);
1560 if (!rdev->ops->get_station)
1561 return -EOPNOTSUPP;
1562
1563 return rdev_get_station(rdev, dev, mac_addr, sinfo);
1564}
1565EXPORT_SYMBOL(cfg80211_get_station);
1566
1531/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ 1567/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
1532/* Ethernet-II snap header (RFC1042 for most EtherTypes) */ 1568/* Ethernet-II snap header (RFC1042 for most EtherTypes) */
1533const unsigned char rfc1042_header[] __aligned(2) = 1569const unsigned char rfc1042_header[] __aligned(2) =