aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJohn W. Linville <linville@tuxdriver.com>2012-10-19 15:36:53 -0400
committerJohn W. Linville <linville@tuxdriver.com>2012-10-19 15:36:53 -0400
commit3cd17638fdf13d2f7fe76465cf74106e612af5eb (patch)
treea19bff1c69430750894129c99404130f4fec689d /net
parentbc27d5f14363a1065bf9437a5bca5409492b6c06 (diff)
parentd012a605108a482392be80710ea35f1db27c4aa9 (diff)
Merge branch 'for-john' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next
Diffstat (limited to 'net')
-rw-r--r--net/mac80211/Kconfig2
-rw-r--r--net/mac80211/Makefile1
-rw-r--r--net/mac80211/cfg.c284
-rw-r--r--net/mac80211/chan.c455
-rw-r--r--net/mac80211/debugfs.h6
-rw-r--r--net/mac80211/debugfs_netdev.c10
-rw-r--r--net/mac80211/driver-ops.h65
-rw-r--r--net/mac80211/ibss.c88
-rw-r--r--net/mac80211/ieee80211_i.h171
-rw-r--r--net/mac80211/iface.c44
-rw-r--r--net/mac80211/main.c105
-rw-r--r--net/mac80211/mesh.c43
-rw-r--r--net/mac80211/mesh.h4
-rw-r--r--net/mac80211/mesh_plink.c14
-rw-r--r--net/mac80211/mesh_sync.c55
-rw-r--r--net/mac80211/mlme.c218
-rw-r--r--net/mac80211/offchannel.c9
-rw-r--r--net/mac80211/pm.c2
-rw-r--r--net/mac80211/rate.h12
-rw-r--r--net/mac80211/rx.c32
-rw-r--r--net/mac80211/scan.c29
-rw-r--r--net/mac80211/sta_info.c59
-rw-r--r--net/mac80211/status.c15
-rw-r--r--net/mac80211/trace.h112
-rw-r--r--net/mac80211/tx.c281
-rw-r--r--net/mac80211/util.c143
-rw-r--r--net/mac80211/vht.c35
-rw-r--r--net/wireless/Makefile4
-rw-r--r--net/wireless/ap.c3
-rw-r--r--net/wireless/chan.c16
-rw-r--r--net/wireless/core.c12
-rw-r--r--net/wireless/core.h6
-rw-r--r--net/wireless/ethtool.c15
-rw-r--r--net/wireless/ibss.c9
-rw-r--r--net/wireless/mesh.c11
-rw-r--r--net/wireless/mlme.c92
-rw-r--r--net/wireless/nl80211.c255
-rw-r--r--net/wireless/rdev-ops.h861
-rw-r--r--net/wireless/scan.c138
-rw-r--r--net/wireless/sme.c12
-rw-r--r--net/wireless/sysfs.c5
-rw-r--r--net/wireless/trace.c7
-rw-r--r--net/wireless/trace.h2286
-rw-r--r--net/wireless/util.c14
-rw-r--r--net/wireless/wext-compat.c48
45 files changed, 5140 insertions, 948 deletions
diff --git a/net/mac80211/Kconfig b/net/mac80211/Kconfig
index 63af25458fda..b4ecf267a34b 100644
--- a/net/mac80211/Kconfig
+++ b/net/mac80211/Kconfig
@@ -248,7 +248,7 @@ config MAC80211_MHWMP_DEBUG
248 Do not select this option. 248 Do not select this option.
249 249
250config MAC80211_MESH_SYNC_DEBUG 250config MAC80211_MESH_SYNC_DEBUG
251 bool "Verbose mesh mesh synchronization debugging" 251 bool "Verbose mesh synchronization debugging"
252 depends on MAC80211_DEBUG_MENU 252 depends on MAC80211_DEBUG_MENU
253 depends on MAC80211_MESH 253 depends on MAC80211_MESH
254 ---help--- 254 ---help---
diff --git a/net/mac80211/Makefile b/net/mac80211/Makefile
index a7dd110faafa..4911202334d9 100644
--- a/net/mac80211/Makefile
+++ b/net/mac80211/Makefile
@@ -8,6 +8,7 @@ mac80211-y := \
8 wpa.o \ 8 wpa.o \
9 scan.o offchannel.o \ 9 scan.o offchannel.o \
10 ht.o agg-tx.o agg-rx.o \ 10 ht.o agg-tx.o agg-rx.o \
11 vht.o \
11 ibss.o \ 12 ibss.o \
12 iface.o \ 13 iface.o \
13 rate.o \ 14 rate.o \
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 05f3a313db88..5eab1325a0f6 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -372,10 +372,11 @@ static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy,
372 372
373static void rate_idx_to_bitrate(struct rate_info *rate, struct sta_info *sta, int idx) 373static void rate_idx_to_bitrate(struct rate_info *rate, struct sta_info *sta, int idx)
374{ 374{
375 enum ieee80211_band band = ieee80211_get_sdata_band(sta->sdata);
376
375 if (!(rate->flags & RATE_INFO_FLAGS_MCS)) { 377 if (!(rate->flags & RATE_INFO_FLAGS_MCS)) {
376 struct ieee80211_supported_band *sband; 378 struct ieee80211_supported_band *sband;
377 sband = sta->local->hw.wiphy->bands[ 379 sband = sta->local->hw.wiphy->bands[band];
378 sta->local->oper_channel->band];
379 rate->legacy = sband->bitrates[idx].bitrate; 380 rate->legacy = sband->bitrates[idx].bitrate;
380 } else 381 } else
381 rate->mcs = idx; 382 rate->mcs = idx;
@@ -532,6 +533,8 @@ static void ieee80211_get_et_stats(struct wiphy *wiphy,
532 u64 *data) 533 u64 *data)
533{ 534{
534 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 535 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
536 struct ieee80211_chanctx_conf *chanctx_conf;
537 struct ieee80211_channel *channel;
535 struct sta_info *sta; 538 struct sta_info *sta;
536 struct ieee80211_local *local = sdata->local; 539 struct ieee80211_local *local = sdata->local;
537 struct station_info sinfo; 540 struct station_info sinfo;
@@ -607,19 +610,26 @@ static void ieee80211_get_et_stats(struct wiphy *wiphy,
607do_survey: 610do_survey:
608 i = STA_STATS_LEN - STA_STATS_SURVEY_LEN; 611 i = STA_STATS_LEN - STA_STATS_SURVEY_LEN;
609 /* Get survey stats for current channel */ 612 /* Get survey stats for current channel */
610 q = 0; 613 survey.filled = 0;
611 while (true) {
612 survey.filled = 0;
613 if (drv_get_survey(local, q, &survey) != 0) {
614 survey.filled = 0;
615 break;
616 }
617 614
618 if (survey.channel && 615 rcu_read_lock();
619 (local->oper_channel->center_freq == 616 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
620 survey.channel->center_freq)) 617 if (chanctx_conf)
621 break; 618 channel = chanctx_conf->channel;
622 q++; 619 else
620 channel = NULL;
621 rcu_read_unlock();
622
623 if (channel) {
624 q = 0;
625 do {
626 survey.filled = 0;
627 if (drv_get_survey(local, q, &survey) != 0) {
628 survey.filled = 0;
629 break;
630 }
631 q++;
632 } while (channel != survey.channel);
623 } 633 }
624 634
625 if (survey.filled) 635 if (survey.filled)
@@ -724,47 +734,42 @@ static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
724 return ret; 734 return ret;
725} 735}
726 736
727static int ieee80211_set_channel(struct wiphy *wiphy, 737static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
728 struct net_device *netdev, 738 struct ieee80211_channel *chan,
729 struct ieee80211_channel *chan, 739 enum nl80211_channel_type channel_type)
730 enum nl80211_channel_type channel_type)
731{ 740{
732 struct ieee80211_local *local = wiphy_priv(wiphy); 741 struct ieee80211_local *local = wiphy_priv(wiphy);
733 struct ieee80211_sub_if_data *sdata = NULL; 742 struct ieee80211_sub_if_data *sdata;
734 743 int ret = 0;
735 if (netdev)
736 sdata = IEEE80211_DEV_TO_SUB_IF(netdev);
737
738 switch (ieee80211_get_channel_mode(local, NULL)) {
739 case CHAN_MODE_HOPPING:
740 return -EBUSY;
741 case CHAN_MODE_FIXED:
742 if (local->oper_channel != chan ||
743 (!sdata && local->_oper_channel_type != channel_type))
744 return -EBUSY;
745 if (!sdata && local->_oper_channel_type == channel_type)
746 return 0;
747 break;
748 case CHAN_MODE_UNDEFINED:
749 break;
750 }
751
752 if (!ieee80211_set_channel_type(local, sdata, channel_type))
753 return -EBUSY;
754 744
755 local->oper_channel = chan; 745 if (local->monitor_channel == chan &&
746 local->monitor_channel_type == channel_type)
747 return 0;
756 748
757 /* auto-detects changes */ 749 mutex_lock(&local->iflist_mtx);
758 ieee80211_hw_config(local, 0); 750 if (local->use_chanctx) {
751 sdata = rcu_dereference_protected(
752 local->monitor_sdata,
753 lockdep_is_held(&local->iflist_mtx));
754 if (sdata) {
755 ieee80211_vif_release_channel(sdata);
756 ret = ieee80211_vif_use_channel(
757 sdata, chan, channel_type,
758 IEEE80211_CHANCTX_EXCLUSIVE);
759 }
760 } else if (local->open_count == local->monitors) {
761 local->_oper_channel = chan;
762 local->_oper_channel_type = channel_type;
763 ieee80211_hw_config(local, 0);
764 }
759 765
760 return 0; 766 if (ret == 0) {
761} 767 local->monitor_channel = chan;
768 local->monitor_channel_type = channel_type;
769 }
770 mutex_unlock(&local->iflist_mtx);
762 771
763static int ieee80211_set_monitor_channel(struct wiphy *wiphy, 772 return ret;
764 struct ieee80211_channel *chan,
765 enum nl80211_channel_type channel_type)
766{
767 return ieee80211_set_channel(wiphy, NULL, chan, channel_type);
768} 773}
769 774
770static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata, 775static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
@@ -879,8 +884,13 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
879 if (old) 884 if (old)
880 return -EALREADY; 885 return -EALREADY;
881 886
882 err = ieee80211_set_channel(wiphy, dev, params->channel, 887 /* TODO: make hostapd tell us what it wants */
883 params->channel_type); 888 sdata->smps_mode = IEEE80211_SMPS_OFF;
889 sdata->needed_rx_chains = sdata->local->rx_chains;
890
891 err = ieee80211_vif_use_channel(sdata, params->channel,
892 params->channel_type,
893 IEEE80211_CHANCTX_SHARED);
884 if (err) 894 if (err)
885 return err; 895 return err;
886 896
@@ -963,6 +973,8 @@ static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
963 sta_info_flush(sdata->local, sdata); 973 sta_info_flush(sdata->local, sdata);
964 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED); 974 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
965 975
976 ieee80211_vif_release_channel(sdata);
977
966 return 0; 978 return 0;
967} 979}
968 980
@@ -1019,9 +1031,10 @@ static int sta_apply_parameters(struct ieee80211_local *local,
1019 int i, j; 1031 int i, j;
1020 struct ieee80211_supported_band *sband; 1032 struct ieee80211_supported_band *sband;
1021 struct ieee80211_sub_if_data *sdata = sta->sdata; 1033 struct ieee80211_sub_if_data *sdata = sta->sdata;
1034 enum ieee80211_band band = ieee80211_get_sdata_band(sdata);
1022 u32 mask, set; 1035 u32 mask, set;
1023 1036
1024 sband = local->hw.wiphy->bands[local->oper_channel->band]; 1037 sband = local->hw.wiphy->bands[band];
1025 1038
1026 mask = params->sta_flags_mask; 1039 mask = params->sta_flags_mask;
1027 set = params->sta_flags_set; 1040 set = params->sta_flags_set;
@@ -1136,7 +1149,7 @@ static int sta_apply_parameters(struct ieee80211_local *local,
1136 rates |= BIT(j); 1149 rates |= BIT(j);
1137 } 1150 }
1138 } 1151 }
1139 sta->sta.supp_rates[local->oper_channel->band] = rates; 1152 sta->sta.supp_rates[band] = rates;
1140 } 1153 }
1141 1154
1142 if (params->ht_capa) 1155 if (params->ht_capa)
@@ -1144,6 +1157,11 @@ static int sta_apply_parameters(struct ieee80211_local *local,
1144 params->ht_capa, 1157 params->ht_capa,
1145 &sta->sta.ht_cap); 1158 &sta->sta.ht_cap);
1146 1159
1160 if (params->vht_capa)
1161 ieee80211_vht_cap_ie_to_sta_vht_cap(sdata, sband,
1162 params->vht_capa,
1163 &sta->sta.vht_cap);
1164
1147 if (ieee80211_vif_is_mesh(&sdata->vif)) { 1165 if (ieee80211_vif_is_mesh(&sdata->vif)) {
1148#ifdef CONFIG_MAC80211_MESH 1166#ifdef CONFIG_MAC80211_MESH
1149 if (sdata->u.mesh.security & IEEE80211_MESH_SEC_SECURED) 1167 if (sdata->u.mesh.security & IEEE80211_MESH_SEC_SECURED)
@@ -1664,8 +1682,13 @@ static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,
1664 if (err) 1682 if (err)
1665 return err; 1683 return err;
1666 1684
1667 err = ieee80211_set_channel(wiphy, dev, setup->channel, 1685 /* can mesh use other SMPS modes? */
1668 setup->channel_type); 1686 sdata->smps_mode = IEEE80211_SMPS_OFF;
1687 sdata->needed_rx_chains = sdata->local->rx_chains;
1688
1689 err = ieee80211_vif_use_channel(sdata, setup->channel,
1690 setup->channel_type,
1691 IEEE80211_CHANCTX_SHARED);
1669 if (err) 1692 if (err)
1670 return err; 1693 return err;
1671 1694
@@ -1679,6 +1702,7 @@ static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev)
1679 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1702 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1680 1703
1681 ieee80211_stop_mesh(sdata); 1704 ieee80211_stop_mesh(sdata);
1705 ieee80211_vif_release_channel(sdata);
1682 1706
1683 return 0; 1707 return 0;
1684} 1708}
@@ -1688,10 +1712,14 @@ static int ieee80211_change_bss(struct wiphy *wiphy,
1688 struct net_device *dev, 1712 struct net_device *dev,
1689 struct bss_parameters *params) 1713 struct bss_parameters *params)
1690{ 1714{
1691 struct ieee80211_sub_if_data *sdata; 1715 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1716 enum ieee80211_band band;
1692 u32 changed = 0; 1717 u32 changed = 0;
1693 1718
1694 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1719 if (!rtnl_dereference(sdata->u.ap.beacon))
1720 return -ENOENT;
1721
1722 band = ieee80211_get_sdata_band(sdata);
1695 1723
1696 if (params->use_cts_prot >= 0) { 1724 if (params->use_cts_prot >= 0) {
1697 sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot; 1725 sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot;
@@ -1704,7 +1732,7 @@ static int ieee80211_change_bss(struct wiphy *wiphy,
1704 } 1732 }
1705 1733
1706 if (!sdata->vif.bss_conf.use_short_slot && 1734 if (!sdata->vif.bss_conf.use_short_slot &&
1707 sdata->local->oper_channel->band == IEEE80211_BAND_5GHZ) { 1735 band == IEEE80211_BAND_5GHZ) {
1708 sdata->vif.bss_conf.use_short_slot = true; 1736 sdata->vif.bss_conf.use_short_slot = true;
1709 changed |= BSS_CHANGED_ERP_SLOT; 1737 changed |= BSS_CHANGED_ERP_SLOT;
1710 } 1738 }
@@ -1718,9 +1746,7 @@ static int ieee80211_change_bss(struct wiphy *wiphy,
1718 if (params->basic_rates) { 1746 if (params->basic_rates) {
1719 int i, j; 1747 int i, j;
1720 u32 rates = 0; 1748 u32 rates = 0;
1721 struct ieee80211_local *local = wiphy_priv(wiphy); 1749 struct ieee80211_supported_band *sband = wiphy->bands[band];
1722 struct ieee80211_supported_band *sband =
1723 wiphy->bands[local->oper_channel->band];
1724 1750
1725 for (i = 0; i < params->basic_rates_len; i++) { 1751 for (i = 0; i < params->basic_rates_len; i++) {
1726 int rate = (params->basic_rates[i] & 0x7f) * 5; 1752 int rate = (params->basic_rates[i] & 0x7f) * 5;
@@ -1829,7 +1855,16 @@ static int ieee80211_scan(struct wiphy *wiphy,
1829 * beaconing hasn't been configured yet 1855 * beaconing hasn't been configured yet
1830 */ 1856 */
1831 case NL80211_IFTYPE_AP: 1857 case NL80211_IFTYPE_AP:
1832 if (sdata->u.ap.beacon) 1858 /*
1859 * If the scan has been forced (and the driver supports
1860 * forcing), don't care about being beaconing already.
1861 * This will create problems to the attached stations (e.g. all
1862 * the frames sent while scanning on other channel will be
1863 * lost)
1864 */
1865 if (sdata->u.ap.beacon &&
1866 (!(wiphy->features & NL80211_FEATURE_AP_SCAN) ||
1867 !(req->flags & NL80211_SCAN_FLAG_AP)))
1833 return -EOPNOTSUPP; 1868 return -EOPNOTSUPP;
1834 break; 1869 break;
1835 default: 1870 default:
@@ -1872,20 +1907,6 @@ static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
1872static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev, 1907static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
1873 struct cfg80211_assoc_request *req) 1908 struct cfg80211_assoc_request *req)
1874{ 1909{
1875 struct ieee80211_local *local = wiphy_priv(wiphy);
1876 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1877
1878 switch (ieee80211_get_channel_mode(local, sdata)) {
1879 case CHAN_MODE_HOPPING:
1880 return -EBUSY;
1881 case CHAN_MODE_FIXED:
1882 if (local->oper_channel == req->bss->channel)
1883 break;
1884 return -EBUSY;
1885 case CHAN_MODE_UNDEFINED:
1886 break;
1887 }
1888
1889 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req); 1910 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
1890} 1911}
1891 1912
@@ -1904,30 +1925,12 @@ static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
1904static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, 1925static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
1905 struct cfg80211_ibss_params *params) 1926 struct cfg80211_ibss_params *params)
1906{ 1927{
1907 struct ieee80211_local *local = wiphy_priv(wiphy); 1928 return ieee80211_ibss_join(IEEE80211_DEV_TO_SUB_IF(dev), params);
1908 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1909
1910 switch (ieee80211_get_channel_mode(local, sdata)) {
1911 case CHAN_MODE_HOPPING:
1912 return -EBUSY;
1913 case CHAN_MODE_FIXED:
1914 if (!params->channel_fixed)
1915 return -EBUSY;
1916 if (local->oper_channel == params->channel)
1917 break;
1918 return -EBUSY;
1919 case CHAN_MODE_UNDEFINED:
1920 break;
1921 }
1922
1923 return ieee80211_ibss_join(sdata, params);
1924} 1929}
1925 1930
1926static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) 1931static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
1927{ 1932{
1928 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1933 return ieee80211_ibss_leave(IEEE80211_DEV_TO_SUB_IF(dev));
1929
1930 return ieee80211_ibss_leave(sdata);
1931} 1934}
1932 1935
1933static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) 1936static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
@@ -1971,9 +1974,13 @@ static int ieee80211_set_tx_power(struct wiphy *wiphy,
1971 enum nl80211_tx_power_setting type, int mbm) 1974 enum nl80211_tx_power_setting type, int mbm)
1972{ 1975{
1973 struct ieee80211_local *local = wiphy_priv(wiphy); 1976 struct ieee80211_local *local = wiphy_priv(wiphy);
1974 struct ieee80211_channel *chan = local->oper_channel; 1977 struct ieee80211_channel *chan = local->_oper_channel;
1975 u32 changes = 0; 1978 u32 changes = 0;
1976 1979
1980 /* FIXME */
1981 if (local->use_chanctx)
1982 return -EOPNOTSUPP;
1983
1977 switch (type) { 1984 switch (type) {
1978 case NL80211_TX_POWER_AUTOMATIC: 1985 case NL80211_TX_POWER_AUTOMATIC:
1979 local->user_power_level = -1; 1986 local->user_power_level = -1;
@@ -2067,13 +2074,12 @@ int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata,
2067 2074
2068 /* 2075 /*
2069 * If not associated, or current association is not an HT 2076 * If not associated, or current association is not an HT
2070 * association, there's no need to send an action frame. 2077 * association, there's no need to do anything, just store
2078 * the new value until we associate.
2071 */ 2079 */
2072 if (!sdata->u.mgd.associated || 2080 if (!sdata->u.mgd.associated ||
2073 sdata->vif.bss_conf.channel_type == NL80211_CHAN_NO_HT) { 2081 sdata->vif.bss_conf.channel_type == NL80211_CHAN_NO_HT)
2074 ieee80211_recalc_smps(sdata->local);
2075 return 0; 2082 return 0;
2076 }
2077 2083
2078 ap = sdata->u.mgd.associated->bssid; 2084 ap = sdata->u.mgd.associated->bssid;
2079 2085
@@ -2189,6 +2195,9 @@ static int ieee80211_start_roc_work(struct ieee80211_local *local,
2189 2195
2190 lockdep_assert_held(&local->mtx); 2196 lockdep_assert_held(&local->mtx);
2191 2197
2198 if (local->use_chanctx && !local->ops->remain_on_channel)
2199 return -EOPNOTSUPP;
2200
2192 roc = kzalloc(sizeof(*roc), GFP_KERNEL); 2201 roc = kzalloc(sizeof(*roc), GFP_KERNEL);
2193 if (!roc) 2202 if (!roc)
2194 return -ENOMEM; 2203 return -ENOMEM;
@@ -2515,10 +2524,20 @@ static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
2515 2524
2516 /* Check if the operating channel is the requested channel */ 2525 /* Check if the operating channel is the requested channel */
2517 if (!need_offchan) { 2526 if (!need_offchan) {
2518 need_offchan = chan != local->oper_channel; 2527 struct ieee80211_chanctx_conf *chanctx_conf;
2519 if (channel_type_valid && 2528
2520 channel_type != local->_oper_channel_type) 2529 rcu_read_lock();
2530 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
2531
2532 if (chanctx_conf) {
2533 need_offchan = chan != chanctx_conf->channel;
2534 if (channel_type_valid &&
2535 channel_type != chanctx_conf->channel_type)
2536 need_offchan = true;
2537 } else {
2521 need_offchan = true; 2538 need_offchan = true;
2539 }
2540 rcu_read_unlock();
2522 } 2541 }
2523 2542
2524 if (need_offchan && !offchan) { 2543 if (need_offchan && !offchan) {
@@ -2667,7 +2686,7 @@ static u16 ieee80211_get_tdls_sta_capab(struct ieee80211_sub_if_data *sdata)
2667 u16 capab; 2686 u16 capab;
2668 2687
2669 capab = 0; 2688 capab = 0;
2670 if (local->oper_channel->band != IEEE80211_BAND_2GHZ) 2689 if (ieee80211_get_sdata_band(sdata) != IEEE80211_BAND_2GHZ)
2671 return capab; 2690 return capab;
2672 2691
2673 if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE)) 2692 if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE))
@@ -2699,7 +2718,7 @@ ieee80211_prep_tdls_encap_data(struct wiphy *wiphy, struct net_device *dev,
2699 u16 status_code, struct sk_buff *skb) 2718 u16 status_code, struct sk_buff *skb)
2700{ 2719{
2701 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2720 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2702 struct ieee80211_local *local = sdata->local; 2721 enum ieee80211_band band = ieee80211_get_sdata_band(sdata);
2703 struct ieee80211_tdls_data *tf; 2722 struct ieee80211_tdls_data *tf;
2704 2723
2705 tf = (void *)skb_put(skb, offsetof(struct ieee80211_tdls_data, u)); 2724 tf = (void *)skb_put(skb, offsetof(struct ieee80211_tdls_data, u));
@@ -2719,10 +2738,8 @@ ieee80211_prep_tdls_encap_data(struct wiphy *wiphy, struct net_device *dev,
2719 tf->u.setup_req.capability = 2738 tf->u.setup_req.capability =
2720 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); 2739 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
2721 2740
2722 ieee80211_add_srates_ie(sdata, skb, false, 2741 ieee80211_add_srates_ie(sdata, skb, false, band);
2723 local->oper_channel->band); 2742 ieee80211_add_ext_srates_ie(sdata, skb, false, band);
2724 ieee80211_add_ext_srates_ie(sdata, skb, false,
2725 local->oper_channel->band);
2726 ieee80211_tdls_add_ext_capab(skb); 2743 ieee80211_tdls_add_ext_capab(skb);
2727 break; 2744 break;
2728 case WLAN_TDLS_SETUP_RESPONSE: 2745 case WLAN_TDLS_SETUP_RESPONSE:
@@ -2735,10 +2752,8 @@ ieee80211_prep_tdls_encap_data(struct wiphy *wiphy, struct net_device *dev,
2735 tf->u.setup_resp.capability = 2752 tf->u.setup_resp.capability =
2736 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); 2753 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
2737 2754
2738 ieee80211_add_srates_ie(sdata, skb, false, 2755 ieee80211_add_srates_ie(sdata, skb, false, band);
2739 local->oper_channel->band); 2756 ieee80211_add_ext_srates_ie(sdata, skb, false, band);
2740 ieee80211_add_ext_srates_ie(sdata, skb, false,
2741 local->oper_channel->band);
2742 ieee80211_tdls_add_ext_capab(skb); 2757 ieee80211_tdls_add_ext_capab(skb);
2743 break; 2758 break;
2744 case WLAN_TDLS_SETUP_CONFIRM: 2759 case WLAN_TDLS_SETUP_CONFIRM:
@@ -2776,7 +2791,7 @@ ieee80211_prep_tdls_direct(struct wiphy *wiphy, struct net_device *dev,
2776 u16 status_code, struct sk_buff *skb) 2791 u16 status_code, struct sk_buff *skb)
2777{ 2792{
2778 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2793 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2779 struct ieee80211_local *local = sdata->local; 2794 enum ieee80211_band band = ieee80211_get_sdata_band(sdata);
2780 struct ieee80211_mgmt *mgmt; 2795 struct ieee80211_mgmt *mgmt;
2781 2796
2782 mgmt = (void *)skb_put(skb, 24); 2797 mgmt = (void *)skb_put(skb, 24);
@@ -2799,10 +2814,8 @@ ieee80211_prep_tdls_direct(struct wiphy *wiphy, struct net_device *dev,
2799 mgmt->u.action.u.tdls_discover_resp.capability = 2814 mgmt->u.action.u.tdls_discover_resp.capability =
2800 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); 2815 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
2801 2816
2802 ieee80211_add_srates_ie(sdata, skb, false, 2817 ieee80211_add_srates_ie(sdata, skb, false, band);
2803 local->oper_channel->band); 2818 ieee80211_add_ext_srates_ie(sdata, skb, false, band);
2804 ieee80211_add_ext_srates_ie(sdata, skb, false,
2805 local->oper_channel->band);
2806 ieee80211_tdls_add_ext_capab(skb); 2819 ieee80211_tdls_add_ext_capab(skb);
2807 break; 2820 break;
2808 default: 2821 default:
@@ -2819,7 +2832,6 @@ static int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
2819{ 2832{
2820 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2833 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2821 struct ieee80211_local *local = sdata->local; 2834 struct ieee80211_local *local = sdata->local;
2822 struct ieee80211_tx_info *info;
2823 struct sk_buff *skb = NULL; 2835 struct sk_buff *skb = NULL;
2824 bool send_direct; 2836 bool send_direct;
2825 int ret; 2837 int ret;
@@ -2845,7 +2857,6 @@ static int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
2845 if (!skb) 2857 if (!skb)
2846 return -ENOMEM; 2858 return -ENOMEM;
2847 2859
2848 info = IEEE80211_SKB_CB(skb);
2849 skb_reserve(skb, local->hw.extra_tx_headroom); 2860 skb_reserve(skb, local->hw.extra_tx_headroom);
2850 2861
2851 switch (action_code) { 2862 switch (action_code) {
@@ -2982,12 +2993,19 @@ static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
2982 bool qos; 2993 bool qos;
2983 struct ieee80211_tx_info *info; 2994 struct ieee80211_tx_info *info;
2984 struct sta_info *sta; 2995 struct sta_info *sta;
2996 struct ieee80211_chanctx_conf *chanctx_conf;
2997 enum ieee80211_band band;
2985 2998
2986 rcu_read_lock(); 2999 rcu_read_lock();
3000 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
3001 if (WARN_ON(!chanctx_conf)) {
3002 rcu_read_unlock();
3003 return -EINVAL;
3004 }
3005 band = chanctx_conf->channel->band;
2987 sta = sta_info_get(sdata, peer); 3006 sta = sta_info_get(sdata, peer);
2988 if (sta) { 3007 if (sta) {
2989 qos = test_sta_flag(sta, WLAN_STA_WME); 3008 qos = test_sta_flag(sta, WLAN_STA_WME);
2990 rcu_read_unlock();
2991 } else { 3009 } else {
2992 rcu_read_unlock(); 3010 rcu_read_unlock();
2993 return -ENOLINK; 3011 return -ENOLINK;
@@ -3005,8 +3023,10 @@ static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
3005 } 3023 }
3006 3024
3007 skb = dev_alloc_skb(local->hw.extra_tx_headroom + size); 3025 skb = dev_alloc_skb(local->hw.extra_tx_headroom + size);
3008 if (!skb) 3026 if (!skb) {
3027 rcu_read_unlock();
3009 return -ENOMEM; 3028 return -ENOMEM;
3029 }
3010 3030
3011 skb->dev = dev; 3031 skb->dev = dev;
3012 3032
@@ -3031,8 +3051,9 @@ static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
3031 nullfunc->qos_ctrl = cpu_to_le16(7); 3051 nullfunc->qos_ctrl = cpu_to_le16(7);
3032 3052
3033 local_bh_disable(); 3053 local_bh_disable();
3034 ieee80211_xmit(sdata, skb); 3054 ieee80211_xmit(sdata, skb, band);
3035 local_bh_enable(); 3055 local_bh_enable();
3056 rcu_read_unlock();
3036 3057
3037 *cookie = (unsigned long) skb; 3058 *cookie = (unsigned long) skb;
3038 return 0; 3059 return 0;
@@ -3042,10 +3063,19 @@ static struct ieee80211_channel *
3042ieee80211_cfg_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev, 3063ieee80211_cfg_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev,
3043 enum nl80211_channel_type *type) 3064 enum nl80211_channel_type *type)
3044{ 3065{
3045 struct ieee80211_local *local = wiphy_priv(wiphy); 3066 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3067 struct ieee80211_chanctx_conf *chanctx_conf;
3068 struct ieee80211_channel *chan = NULL;
3069
3070 rcu_read_lock();
3071 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
3072 if (chanctx_conf) {
3073 *type = chanctx_conf->channel_type;
3074 chan = chanctx_conf->channel;
3075 }
3076 rcu_read_unlock();
3046 3077
3047 *type = local->_oper_channel_type; 3078 return chan;
3048 return local->oper_channel;
3049} 3079}
3050 3080
3051#ifdef CONFIG_PM 3081#ifdef CONFIG_PM
diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
index 0bfc914ddd15..f84b86028a9c 100644
--- a/net/mac80211/chan.c
+++ b/net/mac80211/chan.c
@@ -3,108 +3,10 @@
3 */ 3 */
4 4
5#include <linux/nl80211.h> 5#include <linux/nl80211.h>
6#include <linux/export.h>
6#include <net/cfg80211.h> 7#include <net/cfg80211.h>
7#include "ieee80211_i.h" 8#include "ieee80211_i.h"
8 9#include "driver-ops.h"
9static enum ieee80211_chan_mode
10__ieee80211_get_channel_mode(struct ieee80211_local *local,
11 struct ieee80211_sub_if_data *ignore)
12{
13 struct ieee80211_sub_if_data *sdata;
14
15 lockdep_assert_held(&local->iflist_mtx);
16
17 list_for_each_entry(sdata, &local->interfaces, list) {
18 if (sdata == ignore)
19 continue;
20
21 if (!ieee80211_sdata_running(sdata))
22 continue;
23
24 switch (sdata->vif.type) {
25 case NL80211_IFTYPE_MONITOR:
26 continue;
27 case NL80211_IFTYPE_STATION:
28 if (!sdata->u.mgd.associated)
29 continue;
30 break;
31 case NL80211_IFTYPE_ADHOC:
32 if (!sdata->u.ibss.ssid_len)
33 continue;
34 if (!sdata->u.ibss.fixed_channel)
35 return CHAN_MODE_HOPPING;
36 break;
37 case NL80211_IFTYPE_AP_VLAN:
38 /* will also have _AP interface */
39 continue;
40 case NL80211_IFTYPE_AP:
41 if (!sdata->u.ap.beacon)
42 continue;
43 break;
44 case NL80211_IFTYPE_MESH_POINT:
45 if (!sdata->wdev.mesh_id_len)
46 continue;
47 break;
48 default:
49 break;
50 }
51
52 return CHAN_MODE_FIXED;
53 }
54
55 return CHAN_MODE_UNDEFINED;
56}
57
58enum ieee80211_chan_mode
59ieee80211_get_channel_mode(struct ieee80211_local *local,
60 struct ieee80211_sub_if_data *ignore)
61{
62 enum ieee80211_chan_mode mode;
63
64 mutex_lock(&local->iflist_mtx);
65 mode = __ieee80211_get_channel_mode(local, ignore);
66 mutex_unlock(&local->iflist_mtx);
67
68 return mode;
69}
70
71static enum nl80211_channel_type
72ieee80211_get_superchan(struct ieee80211_local *local,
73 struct ieee80211_sub_if_data *sdata)
74{
75 enum nl80211_channel_type superchan = NL80211_CHAN_NO_HT;
76 struct ieee80211_sub_if_data *tmp;
77
78 mutex_lock(&local->iflist_mtx);
79 list_for_each_entry(tmp, &local->interfaces, list) {
80 if (tmp == sdata)
81 continue;
82
83 if (!ieee80211_sdata_running(tmp))
84 continue;
85
86 switch (tmp->vif.bss_conf.channel_type) {
87 case NL80211_CHAN_NO_HT:
88 case NL80211_CHAN_HT20:
89 if (superchan > tmp->vif.bss_conf.channel_type)
90 break;
91
92 superchan = tmp->vif.bss_conf.channel_type;
93 break;
94 case NL80211_CHAN_HT40PLUS:
95 WARN_ON(superchan == NL80211_CHAN_HT40MINUS);
96 superchan = NL80211_CHAN_HT40PLUS;
97 break;
98 case NL80211_CHAN_HT40MINUS:
99 WARN_ON(superchan == NL80211_CHAN_HT40PLUS);
100 superchan = NL80211_CHAN_HT40MINUS;
101 break;
102 }
103 }
104 mutex_unlock(&local->iflist_mtx);
105
106 return superchan;
107}
108 10
109static bool 11static bool
110ieee80211_channel_types_are_compatible(enum nl80211_channel_type chantype1, 12ieee80211_channel_types_are_compatible(enum nl80211_channel_type chantype1,
@@ -148,23 +50,350 @@ ieee80211_channel_types_are_compatible(enum nl80211_channel_type chantype1,
148 return true; 50 return true;
149} 51}
150 52
151bool ieee80211_set_channel_type(struct ieee80211_local *local, 53static void ieee80211_change_chantype(struct ieee80211_local *local,
152 struct ieee80211_sub_if_data *sdata, 54 struct ieee80211_chanctx *ctx,
153 enum nl80211_channel_type chantype) 55 enum nl80211_channel_type chantype)
154{ 56{
155 enum nl80211_channel_type superchan; 57 if (chantype == ctx->conf.channel_type)
156 enum nl80211_channel_type compatchan; 58 return;
157 59
158 superchan = ieee80211_get_superchan(local, sdata); 60 ctx->conf.channel_type = chantype;
159 if (!ieee80211_channel_types_are_compatible(superchan, chantype, 61 drv_change_chanctx(local, ctx, IEEE80211_CHANCTX_CHANGE_CHANNEL_TYPE);
160 &compatchan))
161 return false;
162 62
163 local->_oper_channel_type = compatchan; 63 if (!local->use_chanctx) {
64 local->_oper_channel_type = chantype;
65 ieee80211_hw_config(local, 0);
66 }
67}
164 68
165 if (sdata) 69static struct ieee80211_chanctx *
166 sdata->vif.bss_conf.channel_type = chantype; 70ieee80211_find_chanctx(struct ieee80211_local *local,
71 struct ieee80211_channel *channel,
72 enum nl80211_channel_type channel_type,
73 enum ieee80211_chanctx_mode mode)
74{
75 struct ieee80211_chanctx *ctx;
76 enum nl80211_channel_type compat_type;
167 77
168 return true; 78 lockdep_assert_held(&local->chanctx_mtx);
79
80 if (mode == IEEE80211_CHANCTX_EXCLUSIVE)
81 return NULL;
82 if (WARN_ON(!channel))
83 return NULL;
84
85 list_for_each_entry(ctx, &local->chanctx_list, list) {
86 compat_type = ctx->conf.channel_type;
87
88 if (ctx->mode == IEEE80211_CHANCTX_EXCLUSIVE)
89 continue;
90 if (ctx->conf.channel != channel)
91 continue;
92 if (!ieee80211_channel_types_are_compatible(ctx->conf.channel_type,
93 channel_type,
94 &compat_type))
95 continue;
96
97 ieee80211_change_chantype(local, ctx, compat_type);
98
99 return ctx;
100 }
101
102 return NULL;
103}
104
105static struct ieee80211_chanctx *
106ieee80211_new_chanctx(struct ieee80211_local *local,
107 struct ieee80211_channel *channel,
108 enum nl80211_channel_type channel_type,
109 enum ieee80211_chanctx_mode mode)
110{
111 struct ieee80211_chanctx *ctx;
112 int err;
113
114 lockdep_assert_held(&local->chanctx_mtx);
115
116 ctx = kzalloc(sizeof(*ctx) + local->hw.chanctx_data_size, GFP_KERNEL);
117 if (!ctx)
118 return ERR_PTR(-ENOMEM);
119
120 ctx->conf.channel = channel;
121 ctx->conf.channel_type = channel_type;
122 ctx->conf.rx_chains_static = 1;
123 ctx->conf.rx_chains_dynamic = 1;
124 ctx->mode = mode;
125
126 if (!local->use_chanctx) {
127 local->_oper_channel_type = channel_type;
128 local->_oper_channel = channel;
129 ieee80211_hw_config(local, 0);
130 } else {
131 err = drv_add_chanctx(local, ctx);
132 if (err) {
133 kfree(ctx);
134 return ERR_PTR(err);
135 }
136 }
137
138 list_add_rcu(&ctx->list, &local->chanctx_list);
139
140 return ctx;
141}
142
143static void ieee80211_free_chanctx(struct ieee80211_local *local,
144 struct ieee80211_chanctx *ctx)
145{
146 lockdep_assert_held(&local->chanctx_mtx);
147
148 WARN_ON_ONCE(ctx->refcount != 0);
149
150 if (!local->use_chanctx) {
151 local->_oper_channel_type = NL80211_CHAN_NO_HT;
152 ieee80211_hw_config(local, 0);
153 } else {
154 drv_remove_chanctx(local, ctx);
155 }
156
157 list_del_rcu(&ctx->list);
158 kfree_rcu(ctx, rcu_head);
159}
160
161static int ieee80211_assign_vif_chanctx(struct ieee80211_sub_if_data *sdata,
162 struct ieee80211_chanctx *ctx)
163{
164 struct ieee80211_local *local = sdata->local;
165 int ret;
166
167 lockdep_assert_held(&local->chanctx_mtx);
168
169 ret = drv_assign_vif_chanctx(local, sdata, ctx);
170 if (ret)
171 return ret;
172
173 rcu_assign_pointer(sdata->vif.chanctx_conf, &ctx->conf);
174 ctx->refcount++;
175
176 return 0;
177}
178
179static enum nl80211_channel_type
180ieee80211_calc_chantype(struct ieee80211_local *local,
181 struct ieee80211_chanctx *ctx)
182{
183 struct ieee80211_chanctx_conf *conf = &ctx->conf;
184 struct ieee80211_sub_if_data *sdata;
185 enum nl80211_channel_type result = NL80211_CHAN_NO_HT;
186
187 lockdep_assert_held(&local->chanctx_mtx);
188
189 rcu_read_lock();
190 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
191 if (!ieee80211_sdata_running(sdata))
192 continue;
193 if (rcu_access_pointer(sdata->vif.chanctx_conf) != conf)
194 continue;
195
196 WARN_ON_ONCE(!ieee80211_channel_types_are_compatible(
197 sdata->vif.bss_conf.channel_type,
198 result, &result));
199 }
200 rcu_read_unlock();
201
202 return result;
203}
204
205static void ieee80211_recalc_chanctx_chantype(struct ieee80211_local *local,
206 struct ieee80211_chanctx *ctx)
207{
208 enum nl80211_channel_type chantype;
209
210 lockdep_assert_held(&local->chanctx_mtx);
211
212 chantype = ieee80211_calc_chantype(local, ctx);
213 ieee80211_change_chantype(local, ctx, chantype);
214}
215
216static void ieee80211_unassign_vif_chanctx(struct ieee80211_sub_if_data *sdata,
217 struct ieee80211_chanctx *ctx)
218{
219 struct ieee80211_local *local = sdata->local;
220
221 lockdep_assert_held(&local->chanctx_mtx);
222
223 ctx->refcount--;
224 rcu_assign_pointer(sdata->vif.chanctx_conf, NULL);
225
226 drv_unassign_vif_chanctx(local, sdata, ctx);
227
228 if (ctx->refcount > 0) {
229 ieee80211_recalc_chanctx_chantype(sdata->local, ctx);
230 ieee80211_recalc_smps_chanctx(local, ctx);
231 }
232}
233
234static void __ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata)
235{
236 struct ieee80211_local *local = sdata->local;
237 struct ieee80211_chanctx_conf *conf;
238 struct ieee80211_chanctx *ctx;
239
240 lockdep_assert_held(&local->chanctx_mtx);
241
242 conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
243 lockdep_is_held(&local->chanctx_mtx));
244 if (!conf)
245 return;
246
247 ctx = container_of(conf, struct ieee80211_chanctx, conf);
248
249 ieee80211_unassign_vif_chanctx(sdata, ctx);
250 if (ctx->refcount == 0)
251 ieee80211_free_chanctx(local, ctx);
252}
253
254void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local,
255 struct ieee80211_chanctx *chanctx)
256{
257 struct ieee80211_sub_if_data *sdata;
258 u8 rx_chains_static, rx_chains_dynamic;
259
260 lockdep_assert_held(&local->chanctx_mtx);
261
262 rx_chains_static = 1;
263 rx_chains_dynamic = 1;
264
265 rcu_read_lock();
266 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
267 u8 needed_static, needed_dynamic;
268
269 if (!ieee80211_sdata_running(sdata))
270 continue;
271
272 if (rcu_access_pointer(sdata->vif.chanctx_conf) !=
273 &chanctx->conf)
274 continue;
275
276 switch (sdata->vif.type) {
277 case NL80211_IFTYPE_P2P_DEVICE:
278 continue;
279 case NL80211_IFTYPE_STATION:
280 if (!sdata->u.mgd.associated)
281 continue;
282 break;
283 case NL80211_IFTYPE_AP_VLAN:
284 continue;
285 case NL80211_IFTYPE_AP:
286 case NL80211_IFTYPE_ADHOC:
287 case NL80211_IFTYPE_WDS:
288 case NL80211_IFTYPE_MESH_POINT:
289 break;
290 default:
291 WARN_ON_ONCE(1);
292 }
293
294 switch (sdata->smps_mode) {
295 default:
296 WARN_ONCE(1, "Invalid SMPS mode %d\n",
297 sdata->smps_mode);
298 /* fall through */
299 case IEEE80211_SMPS_OFF:
300 needed_static = sdata->needed_rx_chains;
301 needed_dynamic = sdata->needed_rx_chains;
302 break;
303 case IEEE80211_SMPS_DYNAMIC:
304 needed_static = 1;
305 needed_dynamic = sdata->needed_rx_chains;
306 break;
307 case IEEE80211_SMPS_STATIC:
308 needed_static = 1;
309 needed_dynamic = 1;
310 break;
311 }
312
313 rx_chains_static = max(rx_chains_static, needed_static);
314 rx_chains_dynamic = max(rx_chains_dynamic, needed_dynamic);
315 }
316 rcu_read_unlock();
317
318 if (!local->use_chanctx) {
319 if (rx_chains_static > 1)
320 local->smps_mode = IEEE80211_SMPS_OFF;
321 else if (rx_chains_dynamic > 1)
322 local->smps_mode = IEEE80211_SMPS_DYNAMIC;
323 else
324 local->smps_mode = IEEE80211_SMPS_STATIC;
325 ieee80211_hw_config(local, 0);
326 }
327
328 if (rx_chains_static == chanctx->conf.rx_chains_static &&
329 rx_chains_dynamic == chanctx->conf.rx_chains_dynamic)
330 return;
331
332 chanctx->conf.rx_chains_static = rx_chains_static;
333 chanctx->conf.rx_chains_dynamic = rx_chains_dynamic;
334 drv_change_chanctx(local, chanctx, IEEE80211_CHANCTX_CHANGE_RX_CHAINS);
335}
336
337int ieee80211_vif_use_channel(struct ieee80211_sub_if_data *sdata,
338 struct ieee80211_channel *channel,
339 enum nl80211_channel_type channel_type,
340 enum ieee80211_chanctx_mode mode)
341{
342 struct ieee80211_local *local = sdata->local;
343 struct ieee80211_chanctx *ctx;
344 int ret;
345
346 WARN_ON(sdata->dev && netif_carrier_ok(sdata->dev));
347
348 mutex_lock(&local->chanctx_mtx);
349 __ieee80211_vif_release_channel(sdata);
350
351 ctx = ieee80211_find_chanctx(local, channel, channel_type, mode);
352 if (!ctx)
353 ctx = ieee80211_new_chanctx(local, channel, channel_type, mode);
354 if (IS_ERR(ctx)) {
355 ret = PTR_ERR(ctx);
356 goto out;
357 }
358
359 sdata->vif.bss_conf.channel_type = channel_type;
360
361 ret = ieee80211_assign_vif_chanctx(sdata, ctx);
362 if (ret) {
363 /* if assign fails refcount stays the same */
364 if (ctx->refcount == 0)
365 ieee80211_free_chanctx(local, ctx);
366 goto out;
367 }
368
369 ieee80211_recalc_smps_chanctx(local, ctx);
370 out:
371 mutex_unlock(&local->chanctx_mtx);
372 return ret;
373}
374
375void ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata)
376{
377 WARN_ON(sdata->dev && netif_carrier_ok(sdata->dev));
378
379 mutex_lock(&sdata->local->chanctx_mtx);
380 __ieee80211_vif_release_channel(sdata);
381 mutex_unlock(&sdata->local->chanctx_mtx);
382}
383
384void ieee80211_iter_chan_contexts_atomic(
385 struct ieee80211_hw *hw,
386 void (*iter)(struct ieee80211_hw *hw,
387 struct ieee80211_chanctx_conf *chanctx_conf,
388 void *data),
389 void *iter_data)
390{
391 struct ieee80211_local *local = hw_to_local(hw);
392 struct ieee80211_chanctx *ctx;
169 393
394 rcu_read_lock();
395 list_for_each_entry_rcu(ctx, &local->chanctx_list, list)
396 iter(hw, &ctx->conf, iter_data);
397 rcu_read_unlock();
170} 398}
399EXPORT_SYMBOL_GPL(ieee80211_iter_chan_contexts_atomic);
diff --git a/net/mac80211/debugfs.h b/net/mac80211/debugfs.h
index 9be4e6d71d00..214ed4ecd739 100644
--- a/net/mac80211/debugfs.h
+++ b/net/mac80211/debugfs.h
@@ -2,9 +2,9 @@
2#define __MAC80211_DEBUGFS_H 2#define __MAC80211_DEBUGFS_H
3 3
4#ifdef CONFIG_MAC80211_DEBUGFS 4#ifdef CONFIG_MAC80211_DEBUGFS
5extern void debugfs_hw_add(struct ieee80211_local *local); 5void debugfs_hw_add(struct ieee80211_local *local);
6extern int mac80211_format_buffer(char __user *userbuf, size_t count, 6int __printf(4, 5) mac80211_format_buffer(char __user *userbuf, size_t count,
7 loff_t *ppos, char *fmt, ...); 7 loff_t *ppos, char *fmt, ...);
8#else 8#else
9static inline void debugfs_hw_add(struct ieee80211_local *local) 9static inline void debugfs_hw_add(struct ieee80211_local *local)
10{ 10{
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c
index 6d5aec9418ee..3393ad5b8ab1 100644
--- a/net/mac80211/debugfs_netdev.c
+++ b/net/mac80211/debugfs_netdev.c
@@ -217,7 +217,7 @@ static ssize_t ieee80211_if_fmt_smps(const struct ieee80211_sub_if_data *sdata,
217 217
218 return snprintf(buf, buflen, "request: %s\nused: %s\n", 218 return snprintf(buf, buflen, "request: %s\nused: %s\n",
219 smps_modes[sdata->u.mgd.req_smps], 219 smps_modes[sdata->u.mgd.req_smps],
220 smps_modes[sdata->u.mgd.ap_smps]); 220 smps_modes[sdata->smps_mode]);
221} 221}
222 222
223static ssize_t ieee80211_if_parse_smps(struct ieee80211_sub_if_data *sdata, 223static ssize_t ieee80211_if_parse_smps(struct ieee80211_sub_if_data *sdata,
@@ -395,14 +395,14 @@ __IEEE80211_IF_FILE_W(uapsd_max_sp_len);
395 395
396/* AP attributes */ 396/* AP attributes */
397IEEE80211_IF_FILE(num_mcast_sta, u.ap.num_mcast_sta, ATOMIC); 397IEEE80211_IF_FILE(num_mcast_sta, u.ap.num_mcast_sta, ATOMIC);
398IEEE80211_IF_FILE(num_sta_ps, u.ap.num_sta_ps, ATOMIC); 398IEEE80211_IF_FILE(num_sta_ps, u.ap.ps.num_sta_ps, ATOMIC);
399IEEE80211_IF_FILE(dtim_count, u.ap.dtim_count, DEC); 399IEEE80211_IF_FILE(dtim_count, u.ap.ps.dtim_count, DEC);
400 400
401static ssize_t ieee80211_if_fmt_num_buffered_multicast( 401static ssize_t ieee80211_if_fmt_num_buffered_multicast(
402 const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) 402 const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
403{ 403{
404 return scnprintf(buf, buflen, "%u\n", 404 return scnprintf(buf, buflen, "%u\n",
405 skb_queue_len(&sdata->u.ap.ps_bc_buf)); 405 skb_queue_len(&sdata->u.ap.ps.bc_buf));
406} 406}
407__IEEE80211_IF_FILE(num_buffered_multicast, NULL); 407__IEEE80211_IF_FILE(num_buffered_multicast, NULL);
408 408
@@ -471,7 +471,7 @@ IEEE80211_IF_FILE(dropped_frames_congestion,
471 u.mesh.mshstats.dropped_frames_congestion, DEC); 471 u.mesh.mshstats.dropped_frames_congestion, DEC);
472IEEE80211_IF_FILE(dropped_frames_no_route, 472IEEE80211_IF_FILE(dropped_frames_no_route,
473 u.mesh.mshstats.dropped_frames_no_route, DEC); 473 u.mesh.mshstats.dropped_frames_no_route, DEC);
474IEEE80211_IF_FILE(estab_plinks, u.mesh.mshstats.estab_plinks, ATOMIC); 474IEEE80211_IF_FILE(estab_plinks, u.mesh.estab_plinks, ATOMIC);
475 475
476/* Mesh parameters */ 476/* Mesh parameters */
477IEEE80211_IF_FILE(dot11MeshMaxRetries, 477IEEE80211_IF_FILE(dot11MeshMaxRetries,
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
index da9003b20004..77407b31e1ff 100644
--- a/net/mac80211/driver-ops.h
+++ b/net/mac80211/driver-ops.h
@@ -871,4 +871,69 @@ static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
871 local->ops->mgd_prepare_tx(&local->hw, &sdata->vif); 871 local->ops->mgd_prepare_tx(&local->hw, &sdata->vif);
872 trace_drv_return_void(local); 872 trace_drv_return_void(local);
873} 873}
874
875static inline int drv_add_chanctx(struct ieee80211_local *local,
876 struct ieee80211_chanctx *ctx)
877{
878 int ret = -EOPNOTSUPP;
879
880 trace_drv_add_chanctx(local, ctx);
881 if (local->ops->add_chanctx)
882 ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
883 trace_drv_return_int(local, ret);
884
885 return ret;
886}
887
888static inline void drv_remove_chanctx(struct ieee80211_local *local,
889 struct ieee80211_chanctx *ctx)
890{
891 trace_drv_remove_chanctx(local, ctx);
892 if (local->ops->remove_chanctx)
893 local->ops->remove_chanctx(&local->hw, &ctx->conf);
894 trace_drv_return_void(local);
895}
896
897static inline void drv_change_chanctx(struct ieee80211_local *local,
898 struct ieee80211_chanctx *ctx,
899 u32 changed)
900{
901 trace_drv_change_chanctx(local, ctx, changed);
902 if (local->ops->change_chanctx)
903 local->ops->change_chanctx(&local->hw, &ctx->conf, changed);
904 trace_drv_return_void(local);
905}
906
907static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
908 struct ieee80211_sub_if_data *sdata,
909 struct ieee80211_chanctx *ctx)
910{
911 int ret = 0;
912
913 check_sdata_in_driver(sdata);
914
915 trace_drv_assign_vif_chanctx(local, sdata, ctx);
916 if (local->ops->assign_vif_chanctx)
917 ret = local->ops->assign_vif_chanctx(&local->hw,
918 &sdata->vif,
919 &ctx->conf);
920 trace_drv_return_int(local, ret);
921
922 return ret;
923}
924
925static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
926 struct ieee80211_sub_if_data *sdata,
927 struct ieee80211_chanctx *ctx)
928{
929 check_sdata_in_driver(sdata);
930
931 trace_drv_unassign_vif_chanctx(local, sdata, ctx);
932 if (local->ops->unassign_vif_chanctx)
933 local->ops->unassign_vif_chanctx(&local->hw,
934 &sdata->vif,
935 &ctx->conf);
936 trace_drv_return_void(local);
937}
938
874#endif /* __MAC80211_DRIVER_OPS */ 939#endif /* __MAC80211_DRIVER_OPS */
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index 5f3620f0bc0a..3d5332e367f8 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -26,7 +26,6 @@
26#include "rate.h" 26#include "rate.h"
27 27
28#define IEEE80211_SCAN_INTERVAL (2 * HZ) 28#define IEEE80211_SCAN_INTERVAL (2 * HZ)
29#define IEEE80211_SCAN_INTERVAL_SLOW (15 * HZ)
30#define IEEE80211_IBSS_JOIN_TIMEOUT (7 * HZ) 29#define IEEE80211_IBSS_JOIN_TIMEOUT (7 * HZ)
31 30
32#define IEEE80211_IBSS_MERGE_INTERVAL (30 * HZ) 31#define IEEE80211_IBSS_MERGE_INTERVAL (30 * HZ)
@@ -39,7 +38,8 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
39 const u8 *bssid, const int beacon_int, 38 const u8 *bssid, const int beacon_int,
40 struct ieee80211_channel *chan, 39 struct ieee80211_channel *chan,
41 const u32 basic_rates, 40 const u32 basic_rates,
42 const u16 capability, u64 tsf) 41 const u16 capability, u64 tsf,
42 bool creator)
43{ 43{
44 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 44 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
45 struct ieee80211_local *local = sdata->local; 45 struct ieee80211_local *local = sdata->local;
@@ -72,25 +72,27 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
72 /* if merging, indicate to driver that we leave the old IBSS */ 72 /* if merging, indicate to driver that we leave the old IBSS */
73 if (sdata->vif.bss_conf.ibss_joined) { 73 if (sdata->vif.bss_conf.ibss_joined) {
74 sdata->vif.bss_conf.ibss_joined = false; 74 sdata->vif.bss_conf.ibss_joined = false;
75 sdata->vif.bss_conf.ibss_creator = false;
75 netif_carrier_off(sdata->dev); 76 netif_carrier_off(sdata->dev);
76 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_IBSS); 77 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_IBSS);
77 } 78 }
78 79
79 memcpy(ifibss->bssid, bssid, ETH_ALEN);
80
81 sdata->drop_unencrypted = capability & WLAN_CAPABILITY_PRIVACY ? 1 : 0; 80 sdata->drop_unencrypted = capability & WLAN_CAPABILITY_PRIVACY ? 1 : 0;
82 81
83 local->oper_channel = chan;
84 channel_type = ifibss->channel_type; 82 channel_type = ifibss->channel_type;
85 if (!cfg80211_can_beacon_sec_chan(local->hw.wiphy, chan, channel_type)) 83 if (!cfg80211_can_beacon_sec_chan(local->hw.wiphy, chan, channel_type))
86 channel_type = NL80211_CHAN_HT20; 84 channel_type = NL80211_CHAN_HT20;
87 if (!ieee80211_set_channel_type(local, sdata, channel_type)) { 85
88 /* can only fail due to HT40+/- mismatch */ 86 ieee80211_vif_release_channel(sdata);
89 channel_type = NL80211_CHAN_HT20; 87 if (ieee80211_vif_use_channel(sdata, chan, channel_type,
90 WARN_ON(!ieee80211_set_channel_type(local, sdata, 88 ifibss->fixed_channel ?
91 NL80211_CHAN_HT20)); 89 IEEE80211_CHANCTX_SHARED :
90 IEEE80211_CHANCTX_EXCLUSIVE)) {
91 sdata_info(sdata, "Failed to join IBSS, no channel context\n");
92 return;
92 } 93 }
93 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); 94
95 memcpy(ifibss->bssid, bssid, ETH_ALEN);
94 96
95 sband = local->hw.wiphy->bands[chan->band]; 97 sband = local->hw.wiphy->bands[chan->band];
96 98
@@ -197,6 +199,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
197 bss_change |= BSS_CHANGED_HT; 199 bss_change |= BSS_CHANGED_HT;
198 bss_change |= BSS_CHANGED_IBSS; 200 bss_change |= BSS_CHANGED_IBSS;
199 sdata->vif.bss_conf.ibss_joined = true; 201 sdata->vif.bss_conf.ibss_joined = true;
202 sdata->vif.bss_conf.ibss_creator = creator;
200 ieee80211_bss_info_change_notify(sdata, bss_change); 203 ieee80211_bss_info_change_notify(sdata, bss_change);
201 204
202 ieee80211_sta_def_wmm_params(sdata, sband->n_bitrates, supp_rates); 205 ieee80211_sta_def_wmm_params(sdata, sband->n_bitrates, supp_rates);
@@ -249,7 +252,8 @@ static void ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
249 cbss->channel, 252 cbss->channel,
250 basic_rates, 253 basic_rates,
251 cbss->capability, 254 cbss->capability,
252 cbss->tsf); 255 cbss->tsf,
256 false);
253} 257}
254 258
255static struct sta_info *ieee80211_ibss_finish_sta(struct sta_info *sta, 259static struct sta_info *ieee80211_ibss_finish_sta(struct sta_info *sta,
@@ -279,7 +283,7 @@ static struct sta_info *ieee80211_ibss_finish_sta(struct sta_info *sta,
279 ibss_dbg(sdata, 283 ibss_dbg(sdata,
280 "TX Auth SA=%pM DA=%pM BSSID=%pM (auth_transaction=1)\n", 284 "TX Auth SA=%pM DA=%pM BSSID=%pM (auth_transaction=1)\n",
281 sdata->vif.addr, addr, sdata->u.ibss.bssid); 285 sdata->vif.addr, addr, sdata->u.ibss.bssid);
282 ieee80211_send_auth(sdata, 1, WLAN_AUTH_OPEN, NULL, 0, 286 ieee80211_send_auth(sdata, 1, WLAN_AUTH_OPEN, 0, NULL, 0,
283 addr, sdata->u.ibss.bssid, NULL, 0, 0); 287 addr, sdata->u.ibss.bssid, NULL, 0, 0);
284 } 288 }
285 return sta; 289 return sta;
@@ -294,7 +298,8 @@ ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
294 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 298 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
295 struct ieee80211_local *local = sdata->local; 299 struct ieee80211_local *local = sdata->local;
296 struct sta_info *sta; 300 struct sta_info *sta;
297 int band = local->oper_channel->band; 301 struct ieee80211_chanctx_conf *chanctx_conf;
302 int band;
298 303
299 /* 304 /*
300 * XXX: Consider removing the least recently used entry and 305 * XXX: Consider removing the least recently used entry and
@@ -317,6 +322,13 @@ ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
317 return NULL; 322 return NULL;
318 } 323 }
319 324
325 rcu_read_lock();
326 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
327 if (WARN_ON_ONCE(!chanctx_conf))
328 return NULL;
329 band = chanctx_conf->channel->band;
330 rcu_read_unlock();
331
320 sta = sta_info_alloc(sdata, addr, GFP_KERNEL); 332 sta = sta_info_alloc(sdata, addr, GFP_KERNEL);
321 if (!sta) { 333 if (!sta) {
322 rcu_read_lock(); 334 rcu_read_lock();
@@ -389,7 +401,7 @@ static void ieee80211_rx_mgmt_auth_ibss(struct ieee80211_sub_if_data *sdata,
389 * However, try to reply to authentication attempts if someone 401 * However, try to reply to authentication attempts if someone
390 * has actually implemented this. 402 * has actually implemented this.
391 */ 403 */
392 ieee80211_send_auth(sdata, 2, WLAN_AUTH_OPEN, NULL, 0, 404 ieee80211_send_auth(sdata, 2, WLAN_AUTH_OPEN, 0, NULL, 0,
393 mgmt->sa, sdata->u.ibss.bssid, NULL, 0, 0); 405 mgmt->sa, sdata->u.ibss.bssid, NULL, 0, 0);
394} 406}
395 407
@@ -517,7 +529,8 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
517 goto put_bss; 529 goto put_bss;
518 530
519 /* different channel */ 531 /* different channel */
520 if (cbss->channel != local->oper_channel) 532 if (sdata->u.ibss.fixed_channel &&
533 sdata->u.ibss.channel != cbss->channel)
521 goto put_bss; 534 goto put_bss;
522 535
523 /* different SSID */ 536 /* different SSID */
@@ -592,7 +605,8 @@ void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
592 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 605 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
593 struct ieee80211_local *local = sdata->local; 606 struct ieee80211_local *local = sdata->local;
594 struct sta_info *sta; 607 struct sta_info *sta;
595 int band = local->oper_channel->band; 608 struct ieee80211_chanctx_conf *chanctx_conf;
609 int band;
596 610
597 /* 611 /*
598 * XXX: Consider removing the least recently used entry and 612 * XXX: Consider removing the least recently used entry and
@@ -610,6 +624,15 @@ void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
610 if (!ether_addr_equal(bssid, sdata->u.ibss.bssid)) 624 if (!ether_addr_equal(bssid, sdata->u.ibss.bssid))
611 return; 625 return;
612 626
627 rcu_read_lock();
628 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
629 if (WARN_ON_ONCE(!chanctx_conf)) {
630 rcu_read_unlock();
631 return;
632 }
633 band = chanctx_conf->channel->band;
634 rcu_read_unlock();
635
613 sta = sta_info_alloc(sdata, addr, GFP_ATOMIC); 636 sta = sta_info_alloc(sdata, addr, GFP_ATOMIC);
614 if (!sta) 637 if (!sta)
615 return; 638 return;
@@ -715,7 +738,7 @@ static void ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata)
715 738
716 __ieee80211_sta_join_ibss(sdata, bssid, sdata->vif.bss_conf.beacon_int, 739 __ieee80211_sta_join_ibss(sdata, bssid, sdata->vif.bss_conf.beacon_int,
717 ifibss->channel, ifibss->basic_rates, 740 ifibss->channel, ifibss->basic_rates,
718 capability, 0); 741 capability, 0, true);
719} 742}
720 743
721/* 744/*
@@ -784,18 +807,8 @@ static void ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata)
784 int interval = IEEE80211_SCAN_INTERVAL; 807 int interval = IEEE80211_SCAN_INTERVAL;
785 808
786 if (time_after(jiffies, ifibss->ibss_join_req + 809 if (time_after(jiffies, ifibss->ibss_join_req +
787 IEEE80211_IBSS_JOIN_TIMEOUT)) { 810 IEEE80211_IBSS_JOIN_TIMEOUT))
788 if (!(local->oper_channel->flags & IEEE80211_CHAN_NO_IBSS)) { 811 ieee80211_sta_create_ibss(sdata);
789 ieee80211_sta_create_ibss(sdata);
790 return;
791 }
792 sdata_info(sdata, "IBSS not allowed on %d MHz\n",
793 local->oper_channel->center_freq);
794
795 /* No IBSS found - decrease scan interval and continue
796 * scanning. */
797 interval = IEEE80211_SCAN_INTERVAL_SLOW;
798 }
799 812
800 mod_timer(&ifibss->timer, 813 mod_timer(&ifibss->timer,
801 round_jiffies(jiffies + interval)); 814 round_jiffies(jiffies + interval));
@@ -1086,17 +1099,6 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
1086 sdata->u.ibss.channel_type = params->channel_type; 1099 sdata->u.ibss.channel_type = params->channel_type;
1087 sdata->u.ibss.fixed_channel = params->channel_fixed; 1100 sdata->u.ibss.fixed_channel = params->channel_fixed;
1088 1101
1089 /* fix ourselves to that channel now already */
1090 if (params->channel_fixed) {
1091 sdata->local->oper_channel = params->channel;
1092 if (!ieee80211_set_channel_type(sdata->local, sdata,
1093 params->channel_type)) {
1094 mutex_unlock(&sdata->u.ibss.mtx);
1095 kfree_skb(skb);
1096 return -EINVAL;
1097 }
1098 }
1099
1100 if (params->ie) { 1102 if (params->ie) {
1101 sdata->u.ibss.ie = kmemdup(params->ie, params->ie_len, 1103 sdata->u.ibss.ie = kmemdup(params->ie, params->ie_len,
1102 GFP_KERNEL); 1104 GFP_KERNEL);
@@ -1134,6 +1136,9 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
1134 changed |= BSS_CHANGED_HT; 1136 changed |= BSS_CHANGED_HT;
1135 ieee80211_bss_info_change_notify(sdata, changed); 1137 ieee80211_bss_info_change_notify(sdata, changed);
1136 1138
1139 sdata->smps_mode = IEEE80211_SMPS_OFF;
1140 sdata->needed_rx_chains = sdata->local->rx_chains;
1141
1137 ieee80211_queue_work(&sdata->local->hw, &sdata->work); 1142 ieee80211_queue_work(&sdata->local->hw, &sdata->work);
1138 1143
1139 return 0; 1144 return 0;
@@ -1197,6 +1202,7 @@ int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata)
1197 lockdep_is_held(&sdata->u.ibss.mtx)); 1202 lockdep_is_held(&sdata->u.ibss.mtx));
1198 RCU_INIT_POINTER(sdata->u.ibss.presp, NULL); 1203 RCU_INIT_POINTER(sdata->u.ibss.presp, NULL);
1199 sdata->vif.bss_conf.ibss_joined = false; 1204 sdata->vif.bss_conf.ibss_joined = false;
1205 sdata->vif.bss_conf.ibss_creator = false;
1200 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED | 1206 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED |
1201 BSS_CHANGED_IBSS); 1207 BSS_CHANGED_IBSS);
1202 synchronize_rcu(); 1208 synchronize_rcu();
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 8c804550465b..3026519b236a 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -280,23 +280,27 @@ struct probe_resp {
280 u8 data[0]; 280 u8 data[0];
281}; 281};
282 282
283struct ieee80211_if_ap { 283struct ps_data {
284 struct beacon_data __rcu *beacon;
285 struct probe_resp __rcu *probe_resp;
286
287 struct list_head vlans;
288
289 /* yes, this looks ugly, but guarantees that we can later use 284 /* yes, this looks ugly, but guarantees that we can later use
290 * bitmap_empty :) 285 * bitmap_empty :)
291 * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */ 286 * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */
292 u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)]; 287 u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)];
293 struct sk_buff_head ps_bc_buf; 288 struct sk_buff_head bc_buf;
294 atomic_t num_sta_ps; /* number of stations in PS mode */ 289 atomic_t num_sta_ps; /* number of stations in PS mode */
295 atomic_t num_mcast_sta; /* number of stations receiving multicast */
296 int dtim_count; 290 int dtim_count;
297 bool dtim_bc_mc; 291 bool dtim_bc_mc;
298}; 292};
299 293
294struct ieee80211_if_ap {
295 struct beacon_data __rcu *beacon;
296 struct probe_resp __rcu *probe_resp;
297
298 struct list_head vlans;
299
300 struct ps_data ps;
301 atomic_t num_mcast_sta; /* number of stations receiving multicast */
302};
303
300struct ieee80211_if_wds { 304struct ieee80211_if_wds {
301 struct sta_info *sta; 305 struct sta_info *sta;
302 u8 remote_addr[ETH_ALEN]; 306 u8 remote_addr[ETH_ALEN];
@@ -316,7 +320,6 @@ struct mesh_stats {
316 __u32 dropped_frames_ttl; /* Not transmitted since mesh_ttl == 0*/ 320 __u32 dropped_frames_ttl; /* Not transmitted since mesh_ttl == 0*/
317 __u32 dropped_frames_no_route; /* Not transmitted, no route found */ 321 __u32 dropped_frames_no_route; /* Not transmitted, no route found */
318 __u32 dropped_frames_congestion;/* Not forwarded due to congestion */ 322 __u32 dropped_frames_congestion;/* Not forwarded due to congestion */
319 atomic_t estab_plinks;
320}; 323};
321 324
322#define PREQ_Q_F_START 0x1 325#define PREQ_Q_F_START 0x1
@@ -378,8 +381,9 @@ struct ieee80211_mgd_auth_data {
378 u8 key_len, key_idx; 381 u8 key_len, key_idx;
379 bool done; 382 bool done;
380 383
381 size_t ie_len; 384 u16 sae_trans, sae_status;
382 u8 ie[]; 385 size_t data_len;
386 u8 data[];
383}; 387};
384 388
385struct ieee80211_mgd_assoc_data { 389struct ieee80211_mgd_assoc_data {
@@ -433,7 +437,6 @@ struct ieee80211_if_managed {
433 bool powersave; /* powersave requested for this iface */ 437 bool powersave; /* powersave requested for this iface */
434 bool broken_ap; /* AP is broken -- turn off powersave */ 438 bool broken_ap; /* AP is broken -- turn off powersave */
435 enum ieee80211_smps_mode req_smps, /* requested smps mode */ 439 enum ieee80211_smps_mode req_smps, /* requested smps mode */
436 ap_smps, /* smps mode AP thinks we're in */
437 driver_smps_mode; /* smps mode request */ 440 driver_smps_mode; /* smps mode request */
438 441
439 struct work_struct request_smps_work; 442 struct work_struct request_smps_work;
@@ -599,6 +602,7 @@ struct ieee80211_if_mesh {
599 int preq_queue_len; 602 int preq_queue_len;
600 struct mesh_stats mshstats; 603 struct mesh_stats mshstats;
601 struct mesh_config mshcfg; 604 struct mesh_config mshcfg;
605 atomic_t estab_plinks;
602 u32 mesh_seqnum; 606 u32 mesh_seqnum;
603 bool accepting_plinks; 607 bool accepting_plinks;
604 int num_gates; 608 int num_gates;
@@ -610,7 +614,7 @@ struct ieee80211_if_mesh {
610 IEEE80211_MESH_SEC_SECURED = 0x2, 614 IEEE80211_MESH_SEC_SECURED = 0x2,
611 } security; 615 } security;
612 /* Extensible Synchronization Framework */ 616 /* Extensible Synchronization Framework */
613 struct ieee80211_mesh_sync_ops *sync_ops; 617 const struct ieee80211_mesh_sync_ops *sync_ops;
614 s64 sync_offset_clockdrift_max; 618 s64 sync_offset_clockdrift_max;
615 spinlock_t sync_offset_lock; 619 spinlock_t sync_offset_lock;
616 bool adjusting_tbtt; 620 bool adjusting_tbtt;
@@ -658,6 +662,30 @@ enum ieee80211_sdata_state_bits {
658 SDATA_STATE_OFFCHANNEL, 662 SDATA_STATE_OFFCHANNEL,
659}; 663};
660 664
665/**
666 * enum ieee80211_chanctx_mode - channel context configuration mode
667 *
668 * @IEEE80211_CHANCTX_SHARED: channel context may be used by
669 * multiple interfaces
670 * @IEEE80211_CHANCTX_EXCLUSIVE: channel context can be used
671 * only by a single interface. This can be used for example for
672 * non-fixed channel IBSS.
673 */
674enum ieee80211_chanctx_mode {
675 IEEE80211_CHANCTX_SHARED,
676 IEEE80211_CHANCTX_EXCLUSIVE
677};
678
679struct ieee80211_chanctx {
680 struct list_head list;
681 struct rcu_head rcu_head;
682
683 enum ieee80211_chanctx_mode mode;
684 int refcount;
685
686 struct ieee80211_chanctx_conf conf;
687};
688
661struct ieee80211_sub_if_data { 689struct ieee80211_sub_if_data {
662 struct list_head list; 690 struct list_head list;
663 691
@@ -704,11 +732,17 @@ struct ieee80211_sub_if_data {
704 732
705 struct ieee80211_tx_queue_params tx_conf[IEEE80211_NUM_ACS]; 733 struct ieee80211_tx_queue_params tx_conf[IEEE80211_NUM_ACS];
706 734
735 /* used to reconfigure hardware SM PS */
736 struct work_struct recalc_smps;
737
707 struct work_struct work; 738 struct work_struct work;
708 struct sk_buff_head skb_queue; 739 struct sk_buff_head skb_queue;
709 740
710 bool arp_filter_state; 741 bool arp_filter_state;
711 742
743 u8 needed_rx_chains;
744 enum ieee80211_smps_mode smps_mode;
745
712 /* 746 /*
713 * AP this belongs to: self in AP mode and 747 * AP this belongs to: self in AP mode and
714 * corresponding AP in VLAN mode, NULL for 748 * corresponding AP in VLAN mode, NULL for
@@ -749,6 +783,21 @@ struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p)
749 return container_of(p, struct ieee80211_sub_if_data, vif); 783 return container_of(p, struct ieee80211_sub_if_data, vif);
750} 784}
751 785
786static inline enum ieee80211_band
787ieee80211_get_sdata_band(struct ieee80211_sub_if_data *sdata)
788{
789 enum ieee80211_band band = IEEE80211_BAND_2GHZ;
790 struct ieee80211_chanctx_conf *chanctx_conf;
791
792 rcu_read_lock();
793 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
794 if (!WARN_ON(!chanctx_conf))
795 band = chanctx_conf->channel->band;
796 rcu_read_unlock();
797
798 return band;
799}
800
752enum sdata_queue_type { 801enum sdata_queue_type {
753 IEEE80211_SDATA_QUEUE_TYPE_FRAME = 0, 802 IEEE80211_SDATA_QUEUE_TYPE_FRAME = 0,
754 IEEE80211_SDATA_QUEUE_AGG_START = 1, 803 IEEE80211_SDATA_QUEUE_AGG_START = 1,
@@ -821,6 +870,7 @@ enum {
821 * @SCAN_SUSPEND: Suspend the scan and go back to operating channel to 870 * @SCAN_SUSPEND: Suspend the scan and go back to operating channel to
822 * send out data 871 * send out data
823 * @SCAN_RESUME: Resume the scan and scan the next channel 872 * @SCAN_RESUME: Resume the scan and scan the next channel
873 * @SCAN_ABORT: Abort the scan and go back to operating channel
824 */ 874 */
825enum mac80211_scan_state { 875enum mac80211_scan_state {
826 SCAN_DECISION, 876 SCAN_DECISION,
@@ -828,6 +878,7 @@ enum mac80211_scan_state {
828 SCAN_SEND_PROBE, 878 SCAN_SEND_PROBE,
829 SCAN_SUSPEND, 879 SCAN_SUSPEND,
830 SCAN_RESUME, 880 SCAN_RESUME,
881 SCAN_ABORT,
831}; 882};
832 883
833struct ieee80211_local { 884struct ieee80211_local {
@@ -858,15 +909,14 @@ struct ieee80211_local {
858 909
859 bool wiphy_ciphers_allocated; 910 bool wiphy_ciphers_allocated;
860 911
912 bool use_chanctx;
913
861 /* protects the aggregated multicast list and filter calls */ 914 /* protects the aggregated multicast list and filter calls */
862 spinlock_t filter_lock; 915 spinlock_t filter_lock;
863 916
864 /* used for uploading changed mc list */ 917 /* used for uploading changed mc list */
865 struct work_struct reconfig_filter; 918 struct work_struct reconfig_filter;
866 919
867 /* used to reconfigure hardware SM PS */
868 struct work_struct recalc_smps;
869
870 /* aggregated multicast list */ 920 /* aggregated multicast list */
871 struct netdev_hw_addr_list mc_list; 921 struct netdev_hw_addr_list mc_list;
872 922
@@ -903,6 +953,9 @@ struct ieee80211_local {
903 /* wowlan is enabled -- don't reconfig on resume */ 953 /* wowlan is enabled -- don't reconfig on resume */
904 bool wowlan; 954 bool wowlan;
905 955
956 /* number of RX chains the hardware has */
957 u8 rx_chains;
958
906 int tx_headroom; /* required headroom for hardware/radiotap */ 959 int tx_headroom; /* required headroom for hardware/radiotap */
907 960
908 /* Tasklet and skb queue to process calls from IRQ mode. All frames 961 /* Tasklet and skb queue to process calls from IRQ mode. All frames
@@ -980,13 +1033,19 @@ struct ieee80211_local {
980 enum mac80211_scan_state next_scan_state; 1033 enum mac80211_scan_state next_scan_state;
981 struct delayed_work scan_work; 1034 struct delayed_work scan_work;
982 struct ieee80211_sub_if_data __rcu *scan_sdata; 1035 struct ieee80211_sub_if_data __rcu *scan_sdata;
1036 struct ieee80211_channel *csa_channel;
1037 /* For backward compatibility only -- do not use */
1038 struct ieee80211_channel *_oper_channel;
983 enum nl80211_channel_type _oper_channel_type; 1039 enum nl80211_channel_type _oper_channel_type;
984 struct ieee80211_channel *oper_channel, *csa_channel;
985 1040
986 /* Temporary remain-on-channel for off-channel operations */ 1041 /* Temporary remain-on-channel for off-channel operations */
987 struct ieee80211_channel *tmp_channel; 1042 struct ieee80211_channel *tmp_channel;
988 enum nl80211_channel_type tmp_channel_type; 1043 enum nl80211_channel_type tmp_channel_type;
989 1044
1045 /* channel contexts */
1046 struct list_head chanctx_list;
1047 struct mutex chanctx_mtx;
1048
990 /* SNMP counters */ 1049 /* SNMP counters */
991 /* dot11CountersTable */ 1050 /* dot11CountersTable */
992 u32 dot11TransmittedFragmentCount; 1051 u32 dot11TransmittedFragmentCount;
@@ -1091,6 +1150,8 @@ struct ieee80211_local {
1091 1150
1092 /* virtual monitor interface */ 1151 /* virtual monitor interface */
1093 struct ieee80211_sub_if_data __rcu *monitor_sdata; 1152 struct ieee80211_sub_if_data __rcu *monitor_sdata;
1153 struct ieee80211_channel *monitor_channel;
1154 enum nl80211_channel_type monitor_channel_type;
1094}; 1155};
1095 1156
1096static inline struct ieee80211_sub_if_data * 1157static inline struct ieee80211_sub_if_data *
@@ -1133,6 +1194,8 @@ struct ieee802_11_elems {
1133 u8 *wmm_param; 1194 u8 *wmm_param;
1134 struct ieee80211_ht_cap *ht_cap_elem; 1195 struct ieee80211_ht_cap *ht_cap_elem;
1135 struct ieee80211_ht_operation *ht_operation; 1196 struct ieee80211_ht_operation *ht_operation;
1197 struct ieee80211_vht_cap *vht_cap_elem;
1198 struct ieee80211_vht_operation *vht_operation;
1136 struct ieee80211_meshconf_ie *mesh_config; 1199 struct ieee80211_meshconf_ie *mesh_config;
1137 u8 *mesh_id; 1200 u8 *mesh_id;
1138 u8 *peering; 1201 u8 *peering;
@@ -1359,6 +1422,13 @@ void ieee80211_ba_session_work(struct work_struct *work);
1359void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid); 1422void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid);
1360void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid); 1423void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid);
1361 1424
1425u8 ieee80211_mcs_to_chains(const struct ieee80211_mcs_info *mcs);
1426
1427/* VHT */
1428void ieee80211_vht_cap_ie_to_sta_vht_cap(struct ieee80211_sub_if_data *sdata,
1429 struct ieee80211_supported_band *sband,
1430 struct ieee80211_vht_cap *vht_cap_ie,
1431 struct ieee80211_sta_vht_cap *vht_cap);
1362/* Spectrum management */ 1432/* Spectrum management */
1363void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata, 1433void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
1364 struct ieee80211_mgmt *mgmt, 1434 struct ieee80211_mgmt *mgmt,
@@ -1393,11 +1463,42 @@ void mac80211_ev_michael_mic_failure(struct ieee80211_sub_if_data *sdata, int ke
1393 gfp_t gfp); 1463 gfp_t gfp);
1394void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata, 1464void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata,
1395 bool bss_notify); 1465 bool bss_notify);
1396void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb); 1466void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
1467 enum ieee80211_band band);
1468
1469void __ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
1470 struct sk_buff *skb, int tid,
1471 enum ieee80211_band band);
1397 1472
1398void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata, 1473static inline void
1399 struct sk_buff *skb, int tid); 1474ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
1400static void inline ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata, 1475 struct sk_buff *skb, int tid,
1476 enum ieee80211_band band)
1477{
1478 rcu_read_lock();
1479 __ieee80211_tx_skb_tid_band(sdata, skb, tid, band);
1480 rcu_read_unlock();
1481}
1482
1483static inline void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata,
1484 struct sk_buff *skb, int tid)
1485{
1486 struct ieee80211_chanctx_conf *chanctx_conf;
1487
1488 rcu_read_lock();
1489 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
1490 if (WARN_ON(!chanctx_conf)) {
1491 rcu_read_unlock();
1492 kfree_skb(skb);
1493 return;
1494 }
1495
1496 __ieee80211_tx_skb_tid_band(sdata, skb, tid,
1497 chanctx_conf->channel->band);
1498 rcu_read_unlock();
1499}
1500
1501static inline void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata,
1401 struct sk_buff *skb) 1502 struct sk_buff *skb)
1402{ 1503{
1403 /* Send all internal mgmt frames on VO. Accordingly set TID to 7. */ 1504 /* Send all internal mgmt frames on VO. Accordingly set TID to 7. */
@@ -1444,7 +1545,7 @@ static inline void ieee80211_add_pending_skbs(struct ieee80211_local *local,
1444} 1545}
1445 1546
1446void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, 1547void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
1447 u16 transaction, u16 auth_alg, 1548 u16 transaction, u16 auth_alg, u16 status,
1448 u8 *extra, size_t extra_len, const u8 *bssid, 1549 u8 *extra, size_t extra_len, const u8 *bssid,
1449 const u8 *da, const u8 *key, u8 key_len, u8 key_idx); 1550 const u8 *da, const u8 *key, u8 key_len, u8 key_idx);
1450void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, 1551void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
@@ -1464,7 +1565,7 @@ void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst,
1464 const u8 *ssid, size_t ssid_len, 1565 const u8 *ssid, size_t ssid_len,
1465 const u8 *ie, size_t ie_len, 1566 const u8 *ie, size_t ie_len,
1466 u32 ratemask, bool directed, bool no_cck, 1567 u32 ratemask, bool directed, bool no_cck,
1467 struct ieee80211_channel *channel); 1568 struct ieee80211_channel *channel, bool scan);
1468 1569
1469void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata, 1570void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata,
1470 const size_t supp_rates_len, 1571 const size_t supp_rates_len,
@@ -1474,7 +1575,7 @@ u32 ieee80211_sta_get_rates(struct ieee80211_local *local,
1474 enum ieee80211_band band, u32 *basic_rates); 1575 enum ieee80211_band band, u32 *basic_rates);
1475int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata, 1576int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata,
1476 enum ieee80211_smps_mode smps_mode); 1577 enum ieee80211_smps_mode smps_mode);
1477void ieee80211_recalc_smps(struct ieee80211_local *local); 1578void ieee80211_recalc_smps(struct ieee80211_sub_if_data *sdata);
1478 1579
1479size_t ieee80211_ie_split(const u8 *ies, size_t ielen, 1580size_t ieee80211_ie_split(const u8 *ies, size_t ielen,
1480 const u8 *ids, int n_ids, size_t offset); 1581 const u8 *ids, int n_ids, size_t offset);
@@ -1495,21 +1596,19 @@ int ieee80211_add_ext_srates_ie(struct ieee80211_sub_if_data *sdata,
1495 enum ieee80211_band band); 1596 enum ieee80211_band band);
1496 1597
1497/* channel management */ 1598/* channel management */
1498enum ieee80211_chan_mode {
1499 CHAN_MODE_UNDEFINED,
1500 CHAN_MODE_HOPPING,
1501 CHAN_MODE_FIXED,
1502};
1503
1504enum ieee80211_chan_mode
1505ieee80211_get_channel_mode(struct ieee80211_local *local,
1506 struct ieee80211_sub_if_data *ignore);
1507bool ieee80211_set_channel_type(struct ieee80211_local *local,
1508 struct ieee80211_sub_if_data *sdata,
1509 enum nl80211_channel_type chantype);
1510enum nl80211_channel_type 1599enum nl80211_channel_type
1511ieee80211_ht_oper_to_channel_type(struct ieee80211_ht_operation *ht_oper); 1600ieee80211_ht_oper_to_channel_type(struct ieee80211_ht_operation *ht_oper);
1512 1601
1602int __must_check
1603ieee80211_vif_use_channel(struct ieee80211_sub_if_data *sdata,
1604 struct ieee80211_channel *channel,
1605 enum nl80211_channel_type channel_type,
1606 enum ieee80211_chanctx_mode mode);
1607void ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata);
1608
1609void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local,
1610 struct ieee80211_chanctx *chanctx);
1611
1513#ifdef CONFIG_MAC80211_NOINLINE 1612#ifdef CONFIG_MAC80211_NOINLINE
1514#define debug_noinline noinline 1613#define debug_noinline noinline
1515#else 1614#else
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 6f8a73c64fb3..c50cf6b9e28d 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -380,6 +380,15 @@ static int ieee80211_add_virtual_monitor(struct ieee80211_local *local)
380 goto out_unlock; 380 goto out_unlock;
381 } 381 }
382 382
383 ret = ieee80211_vif_use_channel(sdata, local->monitor_channel,
384 local->monitor_channel_type,
385 IEEE80211_CHANCTX_EXCLUSIVE);
386 if (ret) {
387 drv_remove_interface(local, sdata);
388 kfree(sdata);
389 goto out_unlock;
390 }
391
383 rcu_assign_pointer(local->monitor_sdata, sdata); 392 rcu_assign_pointer(local->monitor_sdata, sdata);
384 out_unlock: 393 out_unlock:
385 mutex_unlock(&local->iflist_mtx); 394 mutex_unlock(&local->iflist_mtx);
@@ -403,6 +412,8 @@ static void ieee80211_del_virtual_monitor(struct ieee80211_local *local)
403 rcu_assign_pointer(local->monitor_sdata, NULL); 412 rcu_assign_pointer(local->monitor_sdata, NULL);
404 synchronize_net(); 413 synchronize_net();
405 414
415 ieee80211_vif_release_channel(sdata);
416
406 drv_remove_interface(local, sdata); 417 drv_remove_interface(local, sdata);
407 418
408 kfree(sdata); 419 kfree(sdata);
@@ -665,7 +676,6 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
665 struct sk_buff *skb, *tmp; 676 struct sk_buff *skb, *tmp;
666 u32 hw_reconf_flags = 0; 677 u32 hw_reconf_flags = 0;
667 int i; 678 int i;
668 enum nl80211_channel_type orig_ct;
669 679
670 clear_bit(SDATA_STATE_RUNNING, &sdata->state); 680 clear_bit(SDATA_STATE_RUNNING, &sdata->state);
671 681
@@ -729,6 +739,8 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
729 del_timer_sync(&local->dynamic_ps_timer); 739 del_timer_sync(&local->dynamic_ps_timer);
730 cancel_work_sync(&local->dynamic_ps_enable_work); 740 cancel_work_sync(&local->dynamic_ps_enable_work);
731 741
742 cancel_work_sync(&sdata->recalc_smps);
743
732 /* APs need special treatment */ 744 /* APs need special treatment */
733 if (sdata->vif.type == NL80211_IFTYPE_AP) { 745 if (sdata->vif.type == NL80211_IFTYPE_AP) {
734 struct ieee80211_sub_if_data *vlan, *tmpsdata; 746 struct ieee80211_sub_if_data *vlan, *tmpsdata;
@@ -755,8 +767,8 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
755 WARN_ON(!list_empty(&sdata->u.ap.vlans)); 767 WARN_ON(!list_empty(&sdata->u.ap.vlans));
756 768
757 /* free all potentially still buffered bcast frames */ 769 /* free all potentially still buffered bcast frames */
758 local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps_bc_buf); 770 local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps.bc_buf);
759 skb_queue_purge(&sdata->u.ap.ps_bc_buf); 771 skb_queue_purge(&sdata->u.ap.ps.bc_buf);
760 } else if (sdata->vif.type == NL80211_IFTYPE_STATION) { 772 } else if (sdata->vif.type == NL80211_IFTYPE_STATION) {
761 ieee80211_mgd_stop(sdata); 773 ieee80211_mgd_stop(sdata);
762 } 774 }
@@ -837,14 +849,8 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
837 hw_reconf_flags = 0; 849 hw_reconf_flags = 0;
838 } 850 }
839 851
840 /* Re-calculate channel-type, in case there are multiple vifs
841 * on different channel types.
842 */
843 orig_ct = local->_oper_channel_type;
844 ieee80211_set_channel_type(local, NULL, NL80211_CHAN_NO_HT);
845
846 /* do after stop to avoid reconfiguring when we stop anyway */ 852 /* do after stop to avoid reconfiguring when we stop anyway */
847 if (hw_reconf_flags || (orig_ct != local->_oper_channel_type)) 853 if (hw_reconf_flags)
848 ieee80211_hw_config(local, hw_reconf_flags); 854 ieee80211_hw_config(local, hw_reconf_flags);
849 855
850 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); 856 spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
@@ -1121,6 +1127,13 @@ static void ieee80211_iface_work(struct work_struct *work)
1121 } 1127 }
1122} 1128}
1123 1129
1130static void ieee80211_recalc_smps_work(struct work_struct *work)
1131{
1132 struct ieee80211_sub_if_data *sdata =
1133 container_of(work, struct ieee80211_sub_if_data, recalc_smps);
1134
1135 ieee80211_recalc_smps(sdata);
1136}
1124 1137
1125/* 1138/*
1126 * Helper function to initialise an interface to a specific type. 1139 * Helper function to initialise an interface to a specific type.
@@ -1149,6 +1162,7 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
1149 1162
1150 skb_queue_head_init(&sdata->skb_queue); 1163 skb_queue_head_init(&sdata->skb_queue);
1151 INIT_WORK(&sdata->work, ieee80211_iface_work); 1164 INIT_WORK(&sdata->work, ieee80211_iface_work);
1165 INIT_WORK(&sdata->recalc_smps, ieee80211_recalc_smps_work);
1152 1166
1153 switch (type) { 1167 switch (type) {
1154 case NL80211_IFTYPE_P2P_GO: 1168 case NL80211_IFTYPE_P2P_GO:
@@ -1157,7 +1171,7 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
1157 sdata->vif.p2p = true; 1171 sdata->vif.p2p = true;
1158 /* fall through */ 1172 /* fall through */
1159 case NL80211_IFTYPE_AP: 1173 case NL80211_IFTYPE_AP:
1160 skb_queue_head_init(&sdata->u.ap.ps_bc_buf); 1174 skb_queue_head_init(&sdata->u.ap.ps.bc_buf);
1161 INIT_LIST_HEAD(&sdata->u.ap.vlans); 1175 INIT_LIST_HEAD(&sdata->u.ap.vlans);
1162 break; 1176 break;
1163 case NL80211_IFTYPE_P2P_CLIENT: 1177 case NL80211_IFTYPE_P2P_CLIENT:
@@ -1282,11 +1296,6 @@ int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
1282 if (type == ieee80211_vif_type_p2p(&sdata->vif)) 1296 if (type == ieee80211_vif_type_p2p(&sdata->vif))
1283 return 0; 1297 return 0;
1284 1298
1285 /* Setting ad-hoc mode on non-IBSS channel is not supported. */
1286 if (sdata->local->oper_channel->flags & IEEE80211_CHAN_NO_IBSS &&
1287 type == NL80211_IFTYPE_ADHOC)
1288 return -EOPNOTSUPP;
1289
1290 if (ieee80211_sdata_running(sdata)) { 1299 if (ieee80211_sdata_running(sdata)) {
1291 ret = ieee80211_runtime_change_iftype(sdata, type); 1300 ret = ieee80211_runtime_change_iftype(sdata, type);
1292 if (ret) 1301 if (ret)
@@ -1298,9 +1307,6 @@ int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
1298 } 1307 }
1299 1308
1300 /* reset some values that shouldn't be kept across type changes */ 1309 /* reset some values that shouldn't be kept across type changes */
1301 sdata->vif.bss_conf.basic_rates =
1302 ieee80211_mandatory_rates(sdata->local,
1303 sdata->local->oper_channel->band);
1304 sdata->drop_unencrypted = 0; 1310 sdata->drop_unencrypted = 0;
1305 if (type == NL80211_IFTYPE_STATION) 1311 if (type == NL80211_IFTYPE_STATION)
1306 sdata->u.mgd.use_4addr = false; 1312 sdata->u.mgd.use_4addr = false;
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index c80c4490351c..c42094be2f0b 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -93,23 +93,21 @@ static void ieee80211_reconfig_filter(struct work_struct *work)
93 ieee80211_configure_filter(local); 93 ieee80211_configure_filter(local);
94} 94}
95 95
96int ieee80211_hw_config(struct ieee80211_local *local, u32 changed) 96static u32 ieee80211_hw_conf_chan(struct ieee80211_local *local)
97{ 97{
98 struct ieee80211_channel *chan; 98 struct ieee80211_channel *chan;
99 int ret = 0; 99 u32 changed = 0;
100 int power; 100 int power;
101 enum nl80211_channel_type channel_type; 101 enum nl80211_channel_type channel_type;
102 u32 offchannel_flag; 102 u32 offchannel_flag;
103 103
104 might_sleep();
105
106 offchannel_flag = local->hw.conf.flags & IEEE80211_CONF_OFFCHANNEL; 104 offchannel_flag = local->hw.conf.flags & IEEE80211_CONF_OFFCHANNEL;
107 if (local->scan_channel) { 105 if (local->scan_channel) {
108 chan = local->scan_channel; 106 chan = local->scan_channel;
109 /* If scanning on oper channel, use whatever channel-type 107 /* If scanning on oper channel, use whatever channel-type
110 * is currently in use. 108 * is currently in use.
111 */ 109 */
112 if (chan == local->oper_channel) 110 if (chan == local->_oper_channel)
113 channel_type = local->_oper_channel_type; 111 channel_type = local->_oper_channel_type;
114 else 112 else
115 channel_type = NL80211_CHAN_NO_HT; 113 channel_type = NL80211_CHAN_NO_HT;
@@ -117,11 +115,11 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
117 chan = local->tmp_channel; 115 chan = local->tmp_channel;
118 channel_type = local->tmp_channel_type; 116 channel_type = local->tmp_channel_type;
119 } else { 117 } else {
120 chan = local->oper_channel; 118 chan = local->_oper_channel;
121 channel_type = local->_oper_channel_type; 119 channel_type = local->_oper_channel_type;
122 } 120 }
123 121
124 if (chan != local->oper_channel || 122 if (chan != local->_oper_channel ||
125 channel_type != local->_oper_channel_type) 123 channel_type != local->_oper_channel_type)
126 local->hw.conf.flags |= IEEE80211_CONF_OFFCHANNEL; 124 local->hw.conf.flags |= IEEE80211_CONF_OFFCHANNEL;
127 else 125 else
@@ -164,6 +162,21 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
164 local->hw.conf.power_level = power; 162 local->hw.conf.power_level = power;
165 } 163 }
166 164
165 return changed;
166}
167
168int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
169{
170 int ret = 0;
171
172 might_sleep();
173
174 if (!local->use_chanctx)
175 changed |= ieee80211_hw_conf_chan(local);
176 else
177 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
178 IEEE80211_CONF_CHANGE_POWER);
179
167 if (changed && local->open_count) { 180 if (changed && local->open_count) {
168 ret = drv_config(local, changed); 181 ret = drv_config(local, changed);
169 /* 182 /*
@@ -359,14 +372,6 @@ void ieee80211_restart_hw(struct ieee80211_hw *hw)
359} 372}
360EXPORT_SYMBOL(ieee80211_restart_hw); 373EXPORT_SYMBOL(ieee80211_restart_hw);
361 374
362static void ieee80211_recalc_smps_work(struct work_struct *work)
363{
364 struct ieee80211_local *local =
365 container_of(work, struct ieee80211_local, recalc_smps);
366
367 ieee80211_recalc_smps(local);
368}
369
370#ifdef CONFIG_INET 375#ifdef CONFIG_INET
371static int ieee80211_ifa_changed(struct notifier_block *nb, 376static int ieee80211_ifa_changed(struct notifier_block *nb,
372 unsigned long data, void *arg) 377 unsigned long data, void *arg)
@@ -540,6 +545,7 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
540 struct ieee80211_local *local; 545 struct ieee80211_local *local;
541 int priv_size, i; 546 int priv_size, i;
542 struct wiphy *wiphy; 547 struct wiphy *wiphy;
548 bool use_chanctx;
543 549
544 if (WARN_ON(!ops->tx || !ops->start || !ops->stop || !ops->config || 550 if (WARN_ON(!ops->tx || !ops->start || !ops->stop || !ops->config ||
545 !ops->add_interface || !ops->remove_interface || 551 !ops->add_interface || !ops->remove_interface ||
@@ -549,6 +555,14 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
549 if (WARN_ON(ops->sta_state && (ops->sta_add || ops->sta_remove))) 555 if (WARN_ON(ops->sta_state && (ops->sta_add || ops->sta_remove)))
550 return NULL; 556 return NULL;
551 557
558 /* check all or no channel context operations exist */
559 i = !!ops->add_chanctx + !!ops->remove_chanctx +
560 !!ops->change_chanctx + !!ops->assign_vif_chanctx +
561 !!ops->unassign_vif_chanctx;
562 if (WARN_ON(i != 0 && i != 5))
563 return NULL;
564 use_chanctx = i == 5;
565
552 /* Ensure 32-byte alignment of our private data and hw private data. 566 /* Ensure 32-byte alignment of our private data and hw private data.
553 * We use the wiphy priv data for both our ieee80211_local and for 567 * We use the wiphy priv data for both our ieee80211_local and for
554 * the driver's private data 568 * the driver's private data
@@ -584,8 +598,14 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
584 if (ops->remain_on_channel) 598 if (ops->remain_on_channel)
585 wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; 599 wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
586 600
587 wiphy->features = NL80211_FEATURE_SK_TX_STATUS | 601 wiphy->features |= NL80211_FEATURE_SK_TX_STATUS |
588 NL80211_FEATURE_HT_IBSS; 602 NL80211_FEATURE_SAE |
603 NL80211_FEATURE_HT_IBSS;
604
605 if (!ops->hw_scan)
606 wiphy->features |= NL80211_FEATURE_LOW_PRIORITY_SCAN |
607 NL80211_FEATURE_AP_SCAN;
608
589 609
590 if (!ops->set_key) 610 if (!ops->set_key)
591 wiphy->flags |= WIPHY_FLAG_IBSS_RSN; 611 wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
@@ -599,6 +619,7 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
599 local->hw.priv = (char *)local + ALIGN(sizeof(*local), NETDEV_ALIGN); 619 local->hw.priv = (char *)local + ALIGN(sizeof(*local), NETDEV_ALIGN);
600 620
601 local->ops = ops; 621 local->ops = ops;
622 local->use_chanctx = use_chanctx;
602 623
603 /* set up some defaults */ 624 /* set up some defaults */
604 local->hw.queues = 1; 625 local->hw.queues = 1;
@@ -626,6 +647,9 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
626 spin_lock_init(&local->filter_lock); 647 spin_lock_init(&local->filter_lock);
627 spin_lock_init(&local->queue_stop_reason_lock); 648 spin_lock_init(&local->queue_stop_reason_lock);
628 649
650 INIT_LIST_HEAD(&local->chanctx_list);
651 mutex_init(&local->chanctx_mtx);
652
629 /* 653 /*
630 * The rx_skb_queue is only accessed from tasklets, 654 * The rx_skb_queue is only accessed from tasklets,
631 * but other SKB queues are used from within IRQ 655 * but other SKB queues are used from within IRQ
@@ -641,7 +665,6 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
641 INIT_WORK(&local->restart_work, ieee80211_restart_work); 665 INIT_WORK(&local->restart_work, ieee80211_restart_work);
642 666
643 INIT_WORK(&local->reconfig_filter, ieee80211_reconfig_filter); 667 INIT_WORK(&local->reconfig_filter, ieee80211_reconfig_filter);
644 INIT_WORK(&local->recalc_smps, ieee80211_recalc_smps_work);
645 local->smps_mode = IEEE80211_SMPS_OFF; 668 local->smps_mode = IEEE80211_SMPS_OFF;
646 669
647 INIT_WORK(&local->dynamic_ps_enable_work, 670 INIT_WORK(&local->dynamic_ps_enable_work,
@@ -719,6 +742,25 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
719 if ((hw->flags & IEEE80211_HW_SCAN_WHILE_IDLE) && !local->ops->hw_scan) 742 if ((hw->flags & IEEE80211_HW_SCAN_WHILE_IDLE) && !local->ops->hw_scan)
720 return -EINVAL; 743 return -EINVAL;
721 744
745 if (!local->use_chanctx) {
746 for (i = 0; i < local->hw.wiphy->n_iface_combinations; i++) {
747 const struct ieee80211_iface_combination *comb;
748
749 comb = &local->hw.wiphy->iface_combinations[i];
750
751 if (comb->num_different_channels > 1)
752 return -EINVAL;
753 }
754
755 /*
756 * WDS is currently prohibited when channel contexts are used
757 * because there's no clear definition of which channel WDS
758 * type interfaces use
759 */
760 if (local->hw.wiphy->interface_modes & BIT(NL80211_IFTYPE_WDS))
761 return -EINVAL;
762 }
763
722 /* Only HW csum features are currently compatible with mac80211 */ 764 /* Only HW csum features are currently compatible with mac80211 */
723 feature_whitelist = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | 765 feature_whitelist = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
724 NETIF_F_HW_CSUM; 766 NETIF_F_HW_CSUM;
@@ -728,6 +770,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
728 if (hw->max_report_rates == 0) 770 if (hw->max_report_rates == 0)
729 hw->max_report_rates = hw->max_rates; 771 hw->max_report_rates = hw->max_rates;
730 772
773 local->rx_chains = 1;
774
731 /* 775 /*
732 * generic code guarantees at least one band, 776 * generic code guarantees at least one band,
733 * set this very early because much code assumes 777 * set this very early because much code assumes
@@ -743,18 +787,29 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
743 sband = local->hw.wiphy->bands[band]; 787 sband = local->hw.wiphy->bands[band];
744 if (!sband) 788 if (!sband)
745 continue; 789 continue;
746 if (!local->oper_channel) { 790 if (!local->use_chanctx && !local->_oper_channel) {
747 /* init channel we're on */ 791 /* init channel we're on */
748 local->hw.conf.channel = 792 local->hw.conf.channel =
749 local->oper_channel = &sband->channels[0]; 793 local->_oper_channel = &sband->channels[0];
750 local->hw.conf.channel_type = NL80211_CHAN_NO_HT; 794 local->hw.conf.channel_type = NL80211_CHAN_NO_HT;
751 } 795 }
796 if (!local->monitor_channel) {
797 local->monitor_channel = &sband->channels[0];
798 local->monitor_channel_type = NL80211_CHAN_NO_HT;
799 }
752 channels += sband->n_channels; 800 channels += sband->n_channels;
753 801
754 if (max_bitrates < sband->n_bitrates) 802 if (max_bitrates < sband->n_bitrates)
755 max_bitrates = sband->n_bitrates; 803 max_bitrates = sband->n_bitrates;
756 supp_ht = supp_ht || sband->ht_cap.ht_supported; 804 supp_ht = supp_ht || sband->ht_cap.ht_supported;
757 supp_vht = supp_vht || sband->vht_cap.vht_supported; 805 supp_vht = supp_vht || sband->vht_cap.vht_supported;
806
807 if (sband->ht_cap.ht_supported)
808 local->rx_chains =
809 max(ieee80211_mcs_to_chains(&sband->ht_cap.mcs),
810 local->rx_chains);
811
812 /* TODO: consider VHT for RX chains, hopefully it's the same */
758 } 813 }
759 814
760 local->int_scan_req = kzalloc(sizeof(*local->int_scan_req) + 815 local->int_scan_req = kzalloc(sizeof(*local->int_scan_req) +
@@ -778,19 +833,13 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
778 hw->wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR); 833 hw->wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR);
779 hw->wiphy->software_iftypes |= BIT(NL80211_IFTYPE_MONITOR); 834 hw->wiphy->software_iftypes |= BIT(NL80211_IFTYPE_MONITOR);
780 835
781 /* 836 /* mac80211 doesn't support more than one IBSS interface right now */
782 * mac80211 doesn't support more than 1 channel, and also not more
783 * than one IBSS interface
784 */
785 for (i = 0; i < hw->wiphy->n_iface_combinations; i++) { 837 for (i = 0; i < hw->wiphy->n_iface_combinations; i++) {
786 const struct ieee80211_iface_combination *c; 838 const struct ieee80211_iface_combination *c;
787 int j; 839 int j;
788 840
789 c = &hw->wiphy->iface_combinations[i]; 841 c = &hw->wiphy->iface_combinations[i];
790 842
791 if (c->num_different_channels > 1)
792 return -EINVAL;
793
794 for (j = 0; j < c->n_limits; j++) 843 for (j = 0; j < c->n_limits; j++)
795 if ((c->limits[j].types & BIT(NL80211_IFTYPE_ADHOC)) && 844 if ((c->limits[j].types & BIT(NL80211_IFTYPE_ADHOC)) &&
796 c->limits[j].max > 1) 845 c->limits[j].max > 1)
@@ -832,7 +881,7 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
832 881
833 if (supp_vht) 882 if (supp_vht)
834 local->scan_ies_len += 883 local->scan_ies_len +=
835 2 + sizeof(struct ieee80211_vht_capabilities); 884 2 + sizeof(struct ieee80211_vht_cap);
836 885
837 if (!local->ops->hw_scan) { 886 if (!local->ops->hw_scan) {
838 /* For hw_scan, driver needs to set these up. */ 887 /* For hw_scan, driver needs to set these up. */
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index ff0296c7bab8..5bed4fd5ee19 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -97,7 +97,7 @@ bool mesh_matches_local(struct ieee80211_sub_if_data *sdata,
97 (ifmsh->mesh_auth_id == ie->mesh_config->meshconf_auth))) 97 (ifmsh->mesh_auth_id == ie->mesh_config->meshconf_auth)))
98 goto mismatch; 98 goto mismatch;
99 99
100 ieee80211_sta_get_rates(local, ie, local->oper_channel->band, 100 ieee80211_sta_get_rates(local, ie, ieee80211_get_sdata_band(sdata),
101 &basic_rates); 101 &basic_rates);
102 102
103 if (sdata->vif.bss_conf.basic_rates != basic_rates) 103 if (sdata->vif.bss_conf.basic_rates != basic_rates)
@@ -264,7 +264,7 @@ mesh_add_meshconf_ie(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata)
264 /* Authentication Protocol identifier */ 264 /* Authentication Protocol identifier */
265 *pos++ = ifmsh->mesh_auth_id; 265 *pos++ = ifmsh->mesh_auth_id;
266 /* Mesh Formation Info - number of neighbors */ 266 /* Mesh Formation Info - number of neighbors */
267 neighbors = atomic_read(&ifmsh->mshstats.estab_plinks); 267 neighbors = atomic_read(&ifmsh->estab_plinks);
268 /* Number of neighbor mesh STAs or 15 whichever is smaller */ 268 /* Number of neighbor mesh STAs or 15 whichever is smaller */
269 neighbors = (neighbors > 15) ? 15 : neighbors; 269 neighbors = (neighbors > 15) ? 15 : neighbors;
270 *pos++ = neighbors << 1; 270 *pos++ = neighbors << 1;
@@ -355,12 +355,22 @@ int mesh_add_ds_params_ie(struct sk_buff *skb,
355{ 355{
356 struct ieee80211_local *local = sdata->local; 356 struct ieee80211_local *local = sdata->local;
357 struct ieee80211_supported_band *sband; 357 struct ieee80211_supported_band *sband;
358 struct ieee80211_channel *chan = local->oper_channel; 358 struct ieee80211_chanctx_conf *chanctx_conf;
359 struct ieee80211_channel *chan;
359 u8 *pos; 360 u8 *pos;
360 361
361 if (skb_tailroom(skb) < 3) 362 if (skb_tailroom(skb) < 3)
362 return -ENOMEM; 363 return -ENOMEM;
363 364
365 rcu_read_lock();
366 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
367 if (WARN_ON(!chanctx_conf)) {
368 rcu_read_unlock();
369 return -EINVAL;
370 }
371 chan = chanctx_conf->channel;
372 rcu_read_unlock();
373
364 sband = local->hw.wiphy->bands[chan->band]; 374 sband = local->hw.wiphy->bands[chan->band];
365 if (sband->band == IEEE80211_BAND_2GHZ) { 375 if (sband->band == IEEE80211_BAND_2GHZ) {
366 pos = skb_put(skb, 2 + 1); 376 pos = skb_put(skb, 2 + 1);
@@ -376,10 +386,11 @@ int mesh_add_ht_cap_ie(struct sk_buff *skb,
376 struct ieee80211_sub_if_data *sdata) 386 struct ieee80211_sub_if_data *sdata)
377{ 387{
378 struct ieee80211_local *local = sdata->local; 388 struct ieee80211_local *local = sdata->local;
389 enum ieee80211_band band = ieee80211_get_sdata_band(sdata);
379 struct ieee80211_supported_band *sband; 390 struct ieee80211_supported_band *sband;
380 u8 *pos; 391 u8 *pos;
381 392
382 sband = local->hw.wiphy->bands[local->oper_channel->band]; 393 sband = local->hw.wiphy->bands[band];
383 if (!sband->ht_cap.ht_supported || 394 if (!sband->ht_cap.ht_supported ||
384 sdata->vif.bss_conf.channel_type == NL80211_CHAN_NO_HT) 395 sdata->vif.bss_conf.channel_type == NL80211_CHAN_NO_HT)
385 return 0; 396 return 0;
@@ -397,14 +408,26 @@ int mesh_add_ht_oper_ie(struct sk_buff *skb,
397 struct ieee80211_sub_if_data *sdata) 408 struct ieee80211_sub_if_data *sdata)
398{ 409{
399 struct ieee80211_local *local = sdata->local; 410 struct ieee80211_local *local = sdata->local;
400 struct ieee80211_channel *channel = local->oper_channel; 411 struct ieee80211_chanctx_conf *chanctx_conf;
412 struct ieee80211_channel *channel;
401 enum nl80211_channel_type channel_type = 413 enum nl80211_channel_type channel_type =
402 sdata->vif.bss_conf.channel_type; 414 sdata->vif.bss_conf.channel_type;
403 struct ieee80211_supported_band *sband = 415 struct ieee80211_supported_band *sband;
404 local->hw.wiphy->bands[channel->band]; 416 struct ieee80211_sta_ht_cap *ht_cap;
405 struct ieee80211_sta_ht_cap *ht_cap = &sband->ht_cap;
406 u8 *pos; 417 u8 *pos;
407 418
419 rcu_read_lock();
420 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
421 if (WARN_ON(!chanctx_conf)) {
422 rcu_read_unlock();
423 return -EINVAL;
424 }
425 channel = chanctx_conf->channel;
426 rcu_read_unlock();
427
428 sband = local->hw.wiphy->bands[channel->band];
429 ht_cap = &sband->ht_cap;
430
408 if (!ht_cap->ht_supported || channel_type == NL80211_CHAN_NO_HT) 431 if (!ht_cap->ht_supported || channel_type == NL80211_CHAN_NO_HT)
409 return 0; 432 return 0;
410 433
@@ -610,7 +633,7 @@ void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata)
610 sdata->vif.bss_conf.beacon_int = MESH_DEFAULT_BEACON_INTERVAL; 633 sdata->vif.bss_conf.beacon_int = MESH_DEFAULT_BEACON_INTERVAL;
611 sdata->vif.bss_conf.basic_rates = 634 sdata->vif.bss_conf.basic_rates =
612 ieee80211_mandatory_rates(sdata->local, 635 ieee80211_mandatory_rates(sdata->local,
613 sdata->local->oper_channel->band); 636 ieee80211_get_sdata_band(sdata));
614 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON | 637 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON |
615 BSS_CHANGED_BEACON_ENABLED | 638 BSS_CHANGED_BEACON_ENABLED |
616 BSS_CHANGED_HT | 639 BSS_CHANGED_HT |
diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h
index 25d0f17dec71..9285f3f67e66 100644
--- a/net/mac80211/mesh.h
+++ b/net/mac80211/mesh.h
@@ -256,7 +256,7 @@ void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata);
256void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata); 256void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata);
257void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata); 257void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata);
258void ieee80211_mesh_root_setup(struct ieee80211_if_mesh *ifmsh); 258void ieee80211_mesh_root_setup(struct ieee80211_if_mesh *ifmsh);
259struct ieee80211_mesh_sync_ops *ieee80211_mesh_sync_ops_get(u8 method); 259const struct ieee80211_mesh_sync_ops *ieee80211_mesh_sync_ops_get(u8 method);
260 260
261/* Mesh paths */ 261/* Mesh paths */
262int mesh_nexthop_lookup(struct sk_buff *skb, 262int mesh_nexthop_lookup(struct sk_buff *skb,
@@ -324,7 +324,7 @@ extern int mesh_allocated;
324static inline int mesh_plink_free_count(struct ieee80211_sub_if_data *sdata) 324static inline int mesh_plink_free_count(struct ieee80211_sub_if_data *sdata)
325{ 325{
326 return sdata->u.mesh.mshcfg.dot11MeshMaxPeerLinks - 326 return sdata->u.mesh.mshcfg.dot11MeshMaxPeerLinks -
327 atomic_read(&sdata->u.mesh.mshstats.estab_plinks); 327 atomic_read(&sdata->u.mesh.estab_plinks);
328} 328}
329 329
330static inline bool mesh_plink_availables(struct ieee80211_sub_if_data *sdata) 330static inline bool mesh_plink_availables(struct ieee80211_sub_if_data *sdata)
diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
index 3ab34d816897..234fe755968b 100644
--- a/net/mac80211/mesh_plink.c
+++ b/net/mac80211/mesh_plink.c
@@ -50,14 +50,14 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
50static inline 50static inline
51u32 mesh_plink_inc_estab_count(struct ieee80211_sub_if_data *sdata) 51u32 mesh_plink_inc_estab_count(struct ieee80211_sub_if_data *sdata)
52{ 52{
53 atomic_inc(&sdata->u.mesh.mshstats.estab_plinks); 53 atomic_inc(&sdata->u.mesh.estab_plinks);
54 return mesh_accept_plinks_update(sdata); 54 return mesh_accept_plinks_update(sdata);
55} 55}
56 56
57static inline 57static inline
58u32 mesh_plink_dec_estab_count(struct ieee80211_sub_if_data *sdata) 58u32 mesh_plink_dec_estab_count(struct ieee80211_sub_if_data *sdata)
59{ 59{
60 atomic_dec(&sdata->u.mesh.mshstats.estab_plinks); 60 atomic_dec(&sdata->u.mesh.estab_plinks);
61 return mesh_accept_plinks_update(sdata); 61 return mesh_accept_plinks_update(sdata);
62} 62}
63 63
@@ -252,6 +252,8 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
252 mgmt->u.action.u.self_prot.action_code = action; 252 mgmt->u.action.u.self_prot.action_code = action;
253 253
254 if (action != WLAN_SP_MESH_PEERING_CLOSE) { 254 if (action != WLAN_SP_MESH_PEERING_CLOSE) {
255 enum ieee80211_band band = ieee80211_get_sdata_band(sdata);
256
255 /* capability info */ 257 /* capability info */
256 pos = skb_put(skb, 2); 258 pos = skb_put(skb, 2);
257 memset(pos, 0, 2); 259 memset(pos, 0, 2);
@@ -260,10 +262,8 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
260 pos = skb_put(skb, 2); 262 pos = skb_put(skb, 2);
261 memcpy(pos + 2, &plid, 2); 263 memcpy(pos + 2, &plid, 2);
262 } 264 }
263 if (ieee80211_add_srates_ie(sdata, skb, true, 265 if (ieee80211_add_srates_ie(sdata, skb, true, band) ||
264 local->oper_channel->band) || 266 ieee80211_add_ext_srates_ie(sdata, skb, true, band) ||
265 ieee80211_add_ext_srates_ie(sdata, skb, true,
266 local->oper_channel->band) ||
267 mesh_add_rsn_ie(skb, sdata) || 267 mesh_add_rsn_ie(skb, sdata) ||
268 mesh_add_meshid_ie(skb, sdata) || 268 mesh_add_meshid_ie(skb, sdata) ||
269 mesh_add_meshconf_ie(skb, sdata)) 269 mesh_add_meshconf_ie(skb, sdata))
@@ -343,7 +343,7 @@ static struct sta_info *mesh_peer_init(struct ieee80211_sub_if_data *sdata,
343 struct ieee802_11_elems *elems) 343 struct ieee802_11_elems *elems)
344{ 344{
345 struct ieee80211_local *local = sdata->local; 345 struct ieee80211_local *local = sdata->local;
346 enum ieee80211_band band = local->oper_channel->band; 346 enum ieee80211_band band = ieee80211_get_sdata_band(sdata);
347 struct ieee80211_supported_band *sband; 347 struct ieee80211_supported_band *sband;
348 u32 rates, basic_rates = 0; 348 u32 rates, basic_rates = 0;
349 struct sta_info *sta; 349 struct sta_info *sta;
diff --git a/net/mac80211/mesh_sync.c b/net/mac80211/mesh_sync.c
index a16b7b4b1e02..407c8705e10d 100644
--- a/net/mac80211/mesh_sync.c
+++ b/net/mac80211/mesh_sync.c
@@ -234,49 +234,7 @@ static void mesh_sync_offset_adjust_tbtt(struct ieee80211_sub_if_data *sdata)
234 spin_unlock_bh(&ifmsh->sync_offset_lock); 234 spin_unlock_bh(&ifmsh->sync_offset_lock);
235} 235}
236 236
237static const u8 *mesh_get_vendor_oui(struct ieee80211_sub_if_data *sdata) 237static const struct sync_method sync_methods[] = {
238{
239 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
240 u8 offset;
241
242 if (!ifmsh->ie || !ifmsh->ie_len)
243 return NULL;
244
245 offset = ieee80211_ie_split_vendor(ifmsh->ie,
246 ifmsh->ie_len, 0);
247
248 if (!offset)
249 return NULL;
250
251 return ifmsh->ie + offset + 2;
252}
253
254static void mesh_sync_vendor_rx_bcn_presp(struct ieee80211_sub_if_data *sdata,
255 u16 stype,
256 struct ieee80211_mgmt *mgmt,
257 struct ieee802_11_elems *elems,
258 struct ieee80211_rx_status *rx_status)
259{
260 const u8 *oui;
261
262 WARN_ON(sdata->u.mesh.mesh_sp_id != IEEE80211_SYNC_METHOD_VENDOR);
263 msync_dbg(sdata, "called mesh_sync_vendor_rx_bcn_presp\n");
264 oui = mesh_get_vendor_oui(sdata);
265 /* here you would implement the vendor offset tracking for this oui */
266}
267
268static void mesh_sync_vendor_adjust_tbtt(struct ieee80211_sub_if_data *sdata)
269{
270 const u8 *oui;
271
272 WARN_ON(sdata->u.mesh.mesh_sp_id != IEEE80211_SYNC_METHOD_VENDOR);
273 msync_dbg(sdata, "called mesh_sync_vendor_adjust_tbtt\n");
274 oui = mesh_get_vendor_oui(sdata);
275 /* here you would implement the vendor tsf adjustment for this oui */
276}
277
278/* global variable */
279static struct sync_method sync_methods[] = {
280 { 238 {
281 .method = IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET, 239 .method = IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET,
282 .ops = { 240 .ops = {
@@ -284,18 +242,11 @@ static struct sync_method sync_methods[] = {
284 .adjust_tbtt = &mesh_sync_offset_adjust_tbtt, 242 .adjust_tbtt = &mesh_sync_offset_adjust_tbtt,
285 } 243 }
286 }, 244 },
287 {
288 .method = IEEE80211_SYNC_METHOD_VENDOR,
289 .ops = {
290 .rx_bcn_presp = &mesh_sync_vendor_rx_bcn_presp,
291 .adjust_tbtt = &mesh_sync_vendor_adjust_tbtt,
292 }
293 },
294}; 245};
295 246
296struct ieee80211_mesh_sync_ops *ieee80211_mesh_sync_ops_get(u8 method) 247const struct ieee80211_mesh_sync_ops *ieee80211_mesh_sync_ops_get(u8 method)
297{ 248{
298 struct ieee80211_mesh_sync_ops *ops = NULL; 249 const struct ieee80211_mesh_sync_ops *ops = NULL;
299 u8 i; 250 u8 i;
300 251
301 for (i = 0 ; i < ARRAY_SIZE(sync_methods); ++i) { 252 for (i = 0 ; i < ARRAY_SIZE(sync_methods); ++i) {
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index e714ed8bb198..469d86419bc6 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -178,20 +178,30 @@ static u32 ieee80211_config_ht_tx(struct ieee80211_sub_if_data *sdata,
178{ 178{
179 struct ieee80211_local *local = sdata->local; 179 struct ieee80211_local *local = sdata->local;
180 struct ieee80211_supported_band *sband; 180 struct ieee80211_supported_band *sband;
181 struct ieee80211_chanctx_conf *chanctx_conf;
182 struct ieee80211_channel *chan;
181 struct sta_info *sta; 183 struct sta_info *sta;
182 u32 changed = 0; 184 u32 changed = 0;
183 u16 ht_opmode; 185 u16 ht_opmode;
184 bool disable_40 = false; 186 bool disable_40 = false;
185 187
186 sband = local->hw.wiphy->bands[local->oper_channel->band]; 188 rcu_read_lock();
189 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
190 if (WARN_ON(!chanctx_conf)) {
191 rcu_read_unlock();
192 return 0;
193 }
194 chan = chanctx_conf->channel;
195 rcu_read_unlock();
196 sband = local->hw.wiphy->bands[chan->band];
187 197
188 switch (sdata->vif.bss_conf.channel_type) { 198 switch (sdata->vif.bss_conf.channel_type) {
189 case NL80211_CHAN_HT40PLUS: 199 case NL80211_CHAN_HT40PLUS:
190 if (local->oper_channel->flags & IEEE80211_CHAN_NO_HT40PLUS) 200 if (chan->flags & IEEE80211_CHAN_NO_HT40PLUS)
191 disable_40 = true; 201 disable_40 = true;
192 break; 202 break;
193 case NL80211_CHAN_HT40MINUS: 203 case NL80211_CHAN_HT40MINUS:
194 if (local->oper_channel->flags & IEEE80211_CHAN_NO_HT40MINUS) 204 if (chan->flags & IEEE80211_CHAN_NO_HT40MINUS)
195 disable_40 = true; 205 disable_40 = true;
196 break; 206 break;
197 default: 207 default:
@@ -343,7 +353,7 @@ static void ieee80211_add_vht_ie(struct ieee80211_sub_if_data *sdata,
343 cap = vht_cap.cap; 353 cap = vht_cap.cap;
344 354
345 /* reserve and fill IE */ 355 /* reserve and fill IE */
346 pos = skb_put(skb, sizeof(struct ieee80211_vht_capabilities) + 2); 356 pos = skb_put(skb, sizeof(struct ieee80211_vht_cap) + 2);
347 ieee80211_ie_build_vht_cap(pos, &vht_cap, cap); 357 ieee80211_ie_build_vht_cap(pos, &vht_cap, cap);
348} 358}
349 359
@@ -359,11 +369,21 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
359 int i, count, rates_len, supp_rates_len; 369 int i, count, rates_len, supp_rates_len;
360 u16 capab; 370 u16 capab;
361 struct ieee80211_supported_band *sband; 371 struct ieee80211_supported_band *sband;
372 struct ieee80211_chanctx_conf *chanctx_conf;
373 struct ieee80211_channel *chan;
362 u32 rates = 0; 374 u32 rates = 0;
363 375
364 lockdep_assert_held(&ifmgd->mtx); 376 lockdep_assert_held(&ifmgd->mtx);
365 377
366 sband = local->hw.wiphy->bands[local->oper_channel->band]; 378 rcu_read_lock();
379 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
380 if (WARN_ON(!chanctx_conf)) {
381 rcu_read_unlock();
382 return;
383 }
384 chan = chanctx_conf->channel;
385 rcu_read_unlock();
386 sband = local->hw.wiphy->bands[chan->band];
367 387
368 if (assoc_data->supp_rates_len) { 388 if (assoc_data->supp_rates_len) {
369 /* 389 /*
@@ -392,7 +412,7 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
392 4 + /* power capability */ 412 4 + /* power capability */
393 2 + 2 * sband->n_channels + /* supported channels */ 413 2 + 2 * sband->n_channels + /* supported channels */
394 2 + sizeof(struct ieee80211_ht_cap) + /* HT */ 414 2 + sizeof(struct ieee80211_ht_cap) + /* HT */
395 2 + sizeof(struct ieee80211_vht_capabilities) + /* VHT */ 415 2 + sizeof(struct ieee80211_vht_cap) + /* VHT */
396 assoc_data->ie_len + /* extra IEs */ 416 assoc_data->ie_len + /* extra IEs */
397 9, /* WMM */ 417 9, /* WMM */
398 GFP_KERNEL); 418 GFP_KERNEL);
@@ -485,7 +505,7 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
485 *pos++ = WLAN_EID_PWR_CAPABILITY; 505 *pos++ = WLAN_EID_PWR_CAPABILITY;
486 *pos++ = 2; 506 *pos++ = 2;
487 *pos++ = 0; /* min tx power */ 507 *pos++ = 0; /* min tx power */
488 *pos++ = local->oper_channel->max_power; /* max tx power */ 508 *pos++ = chan->max_power; /* max tx power */
489 509
490 /* 2. supported channels */ 510 /* 2. supported channels */
491 /* TODO: get this in reg domain format */ 511 /* TODO: get this in reg domain format */
@@ -523,7 +543,7 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
523 543
524 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_11N)) 544 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_11N))
525 ieee80211_add_ht_ie(sdata, skb, assoc_data->ap_ht_param, 545 ieee80211_add_ht_ie(sdata, skb, assoc_data->ap_ht_param,
526 sband, local->oper_channel, ifmgd->ap_smps); 546 sband, chan, sdata->smps_mode);
527 547
528 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT)) 548 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
529 ieee80211_add_vht_ie(sdata, skb, sband); 549 ieee80211_add_vht_ie(sdata, skb, sband);
@@ -657,18 +677,18 @@ static void ieee80211_chswitch_work(struct work_struct *work)
657 if (!ifmgd->associated) 677 if (!ifmgd->associated)
658 goto out; 678 goto out;
659 679
660 sdata->local->oper_channel = sdata->local->csa_channel; 680 sdata->local->_oper_channel = sdata->local->csa_channel;
661 if (!sdata->local->ops->channel_switch) { 681 if (!sdata->local->ops->channel_switch) {
662 /* call "hw_config" only if doing sw channel switch */ 682 /* call "hw_config" only if doing sw channel switch */
663 ieee80211_hw_config(sdata->local, 683 ieee80211_hw_config(sdata->local,
664 IEEE80211_CONF_CHANGE_CHANNEL); 684 IEEE80211_CONF_CHANGE_CHANNEL);
665 } else { 685 } else {
666 /* update the device channel directly */ 686 /* update the device channel directly */
667 sdata->local->hw.conf.channel = sdata->local->oper_channel; 687 sdata->local->hw.conf.channel = sdata->local->_oper_channel;
668 } 688 }
669 689
670 /* XXX: shouldn't really modify cfg80211-owned data! */ 690 /* XXX: shouldn't really modify cfg80211-owned data! */
671 ifmgd->associated->channel = sdata->local->oper_channel; 691 ifmgd->associated->channel = sdata->local->_oper_channel;
672 692
673 /* XXX: wait for a beacon first? */ 693 /* XXX: wait for a beacon first? */
674 ieee80211_wake_queues_by_reason(&sdata->local->hw, 694 ieee80211_wake_queues_by_reason(&sdata->local->hw,
@@ -680,11 +700,8 @@ static void ieee80211_chswitch_work(struct work_struct *work)
680 700
681void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success) 701void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success)
682{ 702{
683 struct ieee80211_sub_if_data *sdata; 703 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
684 struct ieee80211_if_managed *ifmgd; 704 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
685
686 sdata = vif_to_sdata(vif);
687 ifmgd = &sdata->u.mgd;
688 705
689 trace_api_chswitch_done(sdata, success); 706 trace_api_chswitch_done(sdata, success);
690 if (!success) { 707 if (!success) {
@@ -723,6 +740,7 @@ void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
723 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 740 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
724 int new_freq = ieee80211_channel_to_frequency(sw_elem->new_ch_num, 741 int new_freq = ieee80211_channel_to_frequency(sw_elem->new_ch_num,
725 cbss->channel->band); 742 cbss->channel->band);
743 struct ieee80211_chanctx *chanctx;
726 744
727 ASSERT_MGD_MTX(ifmgd); 745 ASSERT_MGD_MTX(ifmgd);
728 746
@@ -748,10 +766,34 @@ void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
748 return; 766 return;
749 } 767 }
750 768
751 sdata->local->csa_channel = new_ch;
752
753 ifmgd->flags |= IEEE80211_STA_CSA_RECEIVED; 769 ifmgd->flags |= IEEE80211_STA_CSA_RECEIVED;
754 770
771 if (sdata->local->use_chanctx) {
772 sdata_info(sdata,
773 "not handling channel switch with channel contexts\n");
774 ieee80211_queue_work(&sdata->local->hw,
775 &ifmgd->csa_connection_drop_work);
776 }
777
778 mutex_lock(&sdata->local->chanctx_mtx);
779 if (WARN_ON(!rcu_access_pointer(sdata->vif.chanctx_conf))) {
780 mutex_unlock(&sdata->local->chanctx_mtx);
781 return;
782 }
783 chanctx = container_of(rcu_access_pointer(sdata->vif.chanctx_conf),
784 struct ieee80211_chanctx, conf);
785 if (chanctx->refcount > 1) {
786 sdata_info(sdata,
787 "channel switch with multiple interfaces on the same channel, disconnecting\n");
788 ieee80211_queue_work(&sdata->local->hw,
789 &ifmgd->csa_connection_drop_work);
790 mutex_unlock(&sdata->local->chanctx_mtx);
791 return;
792 }
793 mutex_unlock(&sdata->local->chanctx_mtx);
794
795 sdata->local->csa_channel = new_ch;
796
755 if (sw_elem->mode) 797 if (sw_elem->mode)
756 ieee80211_stop_queues_by_reason(&sdata->local->hw, 798 ieee80211_stop_queues_by_reason(&sdata->local->hw,
757 IEEE80211_QUEUE_STOP_REASON_CSA); 799 IEEE80211_QUEUE_STOP_REASON_CSA);
@@ -1280,7 +1322,7 @@ static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata,
1280 } 1322 }
1281 1323
1282 use_short_slot = !!(capab & WLAN_CAPABILITY_SHORT_SLOT_TIME); 1324 use_short_slot = !!(capab & WLAN_CAPABILITY_SHORT_SLOT_TIME);
1283 if (sdata->local->oper_channel->band == IEEE80211_BAND_5GHZ) 1325 if (ieee80211_get_sdata_band(sdata) == IEEE80211_BAND_5GHZ)
1284 use_short_slot = true; 1326 use_short_slot = true;
1285 1327
1286 if (use_protection != bss_conf->use_cts_prot) { 1328 if (use_protection != bss_conf->use_cts_prot) {
@@ -1350,7 +1392,7 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
1350 ieee80211_recalc_ps(local, -1); 1392 ieee80211_recalc_ps(local, -1);
1351 mutex_unlock(&local->iflist_mtx); 1393 mutex_unlock(&local->iflist_mtx);
1352 1394
1353 ieee80211_recalc_smps(local); 1395 ieee80211_recalc_smps(sdata);
1354 ieee80211_recalc_ps_vif(sdata); 1396 ieee80211_recalc_ps_vif(sdata);
1355 1397
1356 netif_tx_start_all_queues(sdata->dev); 1398 netif_tx_start_all_queues(sdata->dev);
@@ -1465,9 +1507,7 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
1465 changed |= BSS_CHANGED_BSSID | BSS_CHANGED_HT; 1507 changed |= BSS_CHANGED_BSSID | BSS_CHANGED_HT;
1466 ieee80211_bss_info_change_notify(sdata, changed); 1508 ieee80211_bss_info_change_notify(sdata, changed);
1467 1509
1468 /* channel(_type) changes are handled by ieee80211_hw_config */ 1510 ieee80211_vif_release_channel(sdata);
1469 WARN_ON(!ieee80211_set_channel_type(local, sdata, NL80211_CHAN_NO_HT));
1470 ieee80211_hw_config(local, 0);
1471 1511
1472 /* disassociated - set to defaults now */ 1512 /* disassociated - set to defaults now */
1473 ieee80211_set_wmm_default(sdata, false); 1513 ieee80211_set_wmm_default(sdata, false);
@@ -1589,7 +1629,7 @@ static void ieee80211_mgd_probe_ap_send(struct ieee80211_sub_if_data *sdata)
1589 1629
1590 ieee80211_send_probe_req(sdata, dst, ssid + 2, ssid_len, NULL, 1630 ieee80211_send_probe_req(sdata, dst, ssid + 2, ssid_len, NULL,
1591 0, (u32) -1, true, false, 1631 0, (u32) -1, true, false,
1592 ifmgd->associated->channel); 1632 ifmgd->associated->channel, false);
1593 } 1633 }
1594 1634
1595 ifmgd->probe_timeout = jiffies + msecs_to_jiffies(probe_wait_ms); 1635 ifmgd->probe_timeout = jiffies + msecs_to_jiffies(probe_wait_ms);
@@ -1692,8 +1732,7 @@ struct sk_buff *ieee80211_ap_probereq_get(struct ieee80211_hw *hw,
1692 ssid_len = ssid[1]; 1732 ssid_len = ssid[1];
1693 1733
1694 skb = ieee80211_build_probe_req(sdata, cbss->bssid, 1734 skb = ieee80211_build_probe_req(sdata, cbss->bssid,
1695 (u32) -1, 1735 (u32) -1, cbss->channel,
1696 sdata->local->oper_channel,
1697 ssid + 2, ssid_len, 1736 ssid + 2, ssid_len,
1698 NULL, 0, true); 1737 NULL, 0, true);
1699 1738
@@ -1804,6 +1843,7 @@ static void ieee80211_destroy_auth_data(struct ieee80211_sub_if_data *sdata,
1804 1843
1805 memset(sdata->u.mgd.bssid, 0, ETH_ALEN); 1844 memset(sdata->u.mgd.bssid, 0, ETH_ALEN);
1806 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BSSID); 1845 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BSSID);
1846 ieee80211_vif_release_channel(sdata);
1807 } 1847 }
1808 1848
1809 cfg80211_put_bss(auth_data->bss); 1849 cfg80211_put_bss(auth_data->bss);
@@ -1824,7 +1864,7 @@ static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata,
1824 return; 1864 return;
1825 auth_data->expected_transaction = 4; 1865 auth_data->expected_transaction = 4;
1826 drv_mgd_prepare_tx(sdata->local, sdata); 1866 drv_mgd_prepare_tx(sdata->local, sdata);
1827 ieee80211_send_auth(sdata, 3, auth_data->algorithm, 1867 ieee80211_send_auth(sdata, 3, auth_data->algorithm, 0,
1828 elems.challenge - 2, elems.challenge_len + 2, 1868 elems.challenge - 2, elems.challenge_len + 2,
1829 auth_data->bss->bssid, auth_data->bss->bssid, 1869 auth_data->bss->bssid, auth_data->bss->bssid,
1830 auth_data->key, auth_data->key_len, 1870 auth_data->key, auth_data->key_len,
@@ -1858,8 +1898,13 @@ ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata,
1858 status_code = le16_to_cpu(mgmt->u.auth.status_code); 1898 status_code = le16_to_cpu(mgmt->u.auth.status_code);
1859 1899
1860 if (auth_alg != ifmgd->auth_data->algorithm || 1900 if (auth_alg != ifmgd->auth_data->algorithm ||
1861 auth_transaction != ifmgd->auth_data->expected_transaction) 1901 auth_transaction != ifmgd->auth_data->expected_transaction) {
1902 sdata_info(sdata, "%pM unexpected authentication state: alg %d (expected %d) transact %d (expected %d)\n",
1903 mgmt->sa, auth_alg, ifmgd->auth_data->algorithm,
1904 auth_transaction,
1905 ifmgd->auth_data->expected_transaction);
1862 return RX_MGMT_NONE; 1906 return RX_MGMT_NONE;
1907 }
1863 1908
1864 if (status_code != WLAN_STATUS_SUCCESS) { 1909 if (status_code != WLAN_STATUS_SUCCESS) {
1865 sdata_info(sdata, "%pM denied authentication (status %d)\n", 1910 sdata_info(sdata, "%pM denied authentication (status %d)\n",
@@ -1872,6 +1917,7 @@ ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata,
1872 case WLAN_AUTH_OPEN: 1917 case WLAN_AUTH_OPEN:
1873 case WLAN_AUTH_LEAP: 1918 case WLAN_AUTH_LEAP:
1874 case WLAN_AUTH_FT: 1919 case WLAN_AUTH_FT:
1920 case WLAN_AUTH_SAE:
1875 break; 1921 break;
1876 case WLAN_AUTH_SHARED_KEY: 1922 case WLAN_AUTH_SHARED_KEY:
1877 if (ifmgd->auth_data->expected_transaction != 4) { 1923 if (ifmgd->auth_data->expected_transaction != 4) {
@@ -1891,6 +1937,15 @@ ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata,
1891 ifmgd->auth_data->timeout = jiffies + IEEE80211_AUTH_WAIT_ASSOC; 1937 ifmgd->auth_data->timeout = jiffies + IEEE80211_AUTH_WAIT_ASSOC;
1892 run_again(ifmgd, ifmgd->auth_data->timeout); 1938 run_again(ifmgd, ifmgd->auth_data->timeout);
1893 1939
1940 if (ifmgd->auth_data->algorithm == WLAN_AUTH_SAE &&
1941 ifmgd->auth_data->expected_transaction != 2) {
1942 /*
1943 * Report auth frame to user space for processing since another
1944 * round of Authentication frames is still needed.
1945 */
1946 return RX_MGMT_CFG80211_RX_AUTH;
1947 }
1948
1894 /* move station state to auth */ 1949 /* move station state to auth */
1895 mutex_lock(&sdata->local->sta_mtx); 1950 mutex_lock(&sdata->local->sta_mtx);
1896 sta = sta_info_get(sdata, bssid); 1951 sta = sta_info_get(sdata, bssid);
@@ -2030,6 +2085,7 @@ static void ieee80211_destroy_assoc_data(struct ieee80211_sub_if_data *sdata,
2030 2085
2031 memset(sdata->u.mgd.bssid, 0, ETH_ALEN); 2086 memset(sdata->u.mgd.bssid, 0, ETH_ALEN);
2032 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BSSID); 2087 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BSSID);
2088 ieee80211_vif_release_channel(sdata);
2033 } 2089 }
2034 2090
2035 kfree(assoc_data); 2091 kfree(assoc_data);
@@ -2091,7 +2147,7 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,
2091 return false; 2147 return false;
2092 } 2148 }
2093 2149
2094 sband = local->hw.wiphy->bands[local->oper_channel->band]; 2150 sband = local->hw.wiphy->bands[ieee80211_get_sdata_band(sdata)];
2095 2151
2096 if (elems.ht_cap_elem && !(ifmgd->flags & IEEE80211_STA_DISABLE_11N)) 2152 if (elems.ht_cap_elem && !(ifmgd->flags & IEEE80211_STA_DISABLE_11N))
2097 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband, 2153 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
@@ -2100,6 +2156,11 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,
2100 sta->supports_40mhz = 2156 sta->supports_40mhz =
2101 sta->sta.ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40; 2157 sta->sta.ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40;
2102 2158
2159 if (elems.vht_cap_elem && !(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
2160 ieee80211_vht_cap_ie_to_sta_vht_cap(sdata, sband,
2161 elems.vht_cap_elem,
2162 &sta->sta.vht_cap);
2163
2103 rate_control_rate_init(sta); 2164 rate_control_rate_init(sta);
2104 2165
2105 if (ifmgd->flags & IEEE80211_STA_MFP_ENABLED) 2166 if (ifmgd->flags & IEEE80211_STA_MFP_ENABLED)
@@ -2369,6 +2430,8 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
2369 size_t baselen; 2430 size_t baselen;
2370 struct ieee802_11_elems elems; 2431 struct ieee802_11_elems elems;
2371 struct ieee80211_local *local = sdata->local; 2432 struct ieee80211_local *local = sdata->local;
2433 struct ieee80211_chanctx_conf *chanctx_conf;
2434 struct ieee80211_channel *chan;
2372 u32 changed = 0; 2435 u32 changed = 0;
2373 bool erp_valid, directed_tim = false; 2436 bool erp_valid, directed_tim = false;
2374 u8 erp_value = 0; 2437 u8 erp_value = 0;
@@ -2382,8 +2445,19 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
2382 if (baselen > len) 2445 if (baselen > len)
2383 return; 2446 return;
2384 2447
2385 if (rx_status->freq != local->oper_channel->center_freq) 2448 rcu_read_lock();
2449 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
2450 if (!chanctx_conf) {
2451 rcu_read_unlock();
2386 return; 2452 return;
2453 }
2454
2455 if (rx_status->freq != chanctx_conf->channel->center_freq) {
2456 rcu_read_unlock();
2457 return;
2458 }
2459 chan = chanctx_conf->channel;
2460 rcu_read_unlock();
2387 2461
2388 if (ifmgd->assoc_data && !ifmgd->assoc_data->have_beacon && 2462 if (ifmgd->assoc_data && !ifmgd->assoc_data->have_beacon &&
2389 ether_addr_equal(mgmt->bssid, ifmgd->assoc_data->bss->bssid)) { 2463 ether_addr_equal(mgmt->bssid, ifmgd->assoc_data->bss->bssid)) {
@@ -2543,19 +2617,14 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
2543 2617
2544 2618
2545 if (elems.ht_cap_elem && elems.ht_operation && elems.wmm_param && 2619 if (elems.ht_cap_elem && elems.ht_operation && elems.wmm_param &&
2546 !(ifmgd->flags & IEEE80211_STA_DISABLE_11N)) { 2620 !(ifmgd->flags & IEEE80211_STA_DISABLE_11N))
2547 struct ieee80211_supported_band *sband;
2548
2549 sband = local->hw.wiphy->bands[local->oper_channel->band];
2550
2551 changed |= ieee80211_config_ht_tx(sdata, elems.ht_operation, 2621 changed |= ieee80211_config_ht_tx(sdata, elems.ht_operation,
2552 bssid, true); 2622 bssid, true);
2553 }
2554 2623
2555 if (elems.country_elem && elems.pwr_constr_elem && 2624 if (elems.country_elem && elems.pwr_constr_elem &&
2556 mgmt->u.probe_resp.capab_info & 2625 mgmt->u.probe_resp.capab_info &
2557 cpu_to_le16(WLAN_CAPABILITY_SPECTRUM_MGMT)) 2626 cpu_to_le16(WLAN_CAPABILITY_SPECTRUM_MGMT))
2558 ieee80211_handle_pwr_constr(sdata, local->oper_channel, 2627 ieee80211_handle_pwr_constr(sdata, chan,
2559 elems.country_elem, 2628 elems.country_elem,
2560 elems.country_elem_len, 2629 elems.country_elem_len,
2561 elems.pwr_constr_elem); 2630 elems.pwr_constr_elem);
@@ -2703,13 +2772,23 @@ static int ieee80211_probe_auth(struct ieee80211_sub_if_data *sdata)
2703 drv_mgd_prepare_tx(local, sdata); 2772 drv_mgd_prepare_tx(local, sdata);
2704 2773
2705 if (auth_data->bss->proberesp_ies) { 2774 if (auth_data->bss->proberesp_ies) {
2775 u16 trans = 1;
2776 u16 status = 0;
2777
2706 sdata_info(sdata, "send auth to %pM (try %d/%d)\n", 2778 sdata_info(sdata, "send auth to %pM (try %d/%d)\n",
2707 auth_data->bss->bssid, auth_data->tries, 2779 auth_data->bss->bssid, auth_data->tries,
2708 IEEE80211_AUTH_MAX_TRIES); 2780 IEEE80211_AUTH_MAX_TRIES);
2709 2781
2710 auth_data->expected_transaction = 2; 2782 auth_data->expected_transaction = 2;
2711 ieee80211_send_auth(sdata, 1, auth_data->algorithm, 2783
2712 auth_data->ie, auth_data->ie_len, 2784 if (auth_data->algorithm == WLAN_AUTH_SAE) {
2785 trans = auth_data->sae_trans;
2786 status = auth_data->sae_status;
2787 auth_data->expected_transaction = trans;
2788 }
2789
2790 ieee80211_send_auth(sdata, trans, auth_data->algorithm, status,
2791 auth_data->data, auth_data->data_len,
2713 auth_data->bss->bssid, 2792 auth_data->bss->bssid,
2714 auth_data->bss->bssid, NULL, 0, 0); 2793 auth_data->bss->bssid, NULL, 0, 0);
2715 } else { 2794 } else {
@@ -2728,7 +2807,7 @@ static int ieee80211_probe_auth(struct ieee80211_sub_if_data *sdata)
2728 */ 2807 */
2729 ieee80211_send_probe_req(sdata, NULL, ssidie + 2, ssidie[1], 2808 ieee80211_send_probe_req(sdata, NULL, ssidie + 2, ssidie[1],
2730 NULL, 0, (u32) -1, true, false, 2809 NULL, 0, (u32) -1, true, false,
2731 auth_data->bss->channel); 2810 auth_data->bss->channel, false);
2732 } 2811 }
2733 2812
2734 auth_data->timeout = jiffies + IEEE80211_AUTH_TIMEOUT; 2813 auth_data->timeout = jiffies + IEEE80211_AUTH_TIMEOUT;
@@ -3103,6 +3182,10 @@ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
3103 } 3182 }
3104 3183
3105 if (ht_oper) { 3184 if (ht_oper) {
3185 const u8 *ht_cap_ie;
3186 const struct ieee80211_ht_cap *ht_cap;
3187 u8 chains = 1;
3188
3106 channel_type = NL80211_CHAN_HT20; 3189 channel_type = NL80211_CHAN_HT20;
3107 3190
3108 if (sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) { 3191 if (sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) {
@@ -3116,22 +3199,25 @@ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
3116 break; 3199 break;
3117 } 3200 }
3118 } 3201 }
3119 }
3120 3202
3121 if (!ieee80211_set_channel_type(local, sdata, channel_type)) { 3203 ht_cap_ie = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY,
3122 /* can only fail due to HT40+/- mismatch */ 3204 cbss->information_elements,
3123 channel_type = NL80211_CHAN_HT20; 3205 cbss->len_information_elements);
3124 sdata_info(sdata, 3206 if (ht_cap_ie && ht_cap_ie[1] >= sizeof(*ht_cap)) {
3125 "disabling 40 MHz due to multi-vif mismatch\n"); 3207 ht_cap = (void *)(ht_cap_ie + 2);
3126 ifmgd->flags |= IEEE80211_STA_DISABLE_40MHZ; 3208 chains = ieee80211_mcs_to_chains(&ht_cap->mcs);
3127 WARN_ON(!ieee80211_set_channel_type(local, sdata, 3209 }
3128 channel_type)); 3210 sdata->needed_rx_chains = min(chains, local->rx_chains);
3211 } else {
3212 sdata->needed_rx_chains = 1;
3129 } 3213 }
3130 3214
3131 local->oper_channel = cbss->channel; 3215 /* will change later if needed */
3132 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); 3216 sdata->smps_mode = IEEE80211_SMPS_OFF;
3133 3217
3134 return 0; 3218 ieee80211_vif_release_channel(sdata);
3219 return ieee80211_vif_use_channel(sdata, cbss->channel, channel_type,
3220 IEEE80211_CHANCTX_SHARED);
3135} 3221}
3136 3222
3137static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata, 3223static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata,
@@ -3201,7 +3287,7 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata,
3201 sdata->vif.bss_conf.basic_rates = basic_rates; 3287 sdata->vif.bss_conf.basic_rates = basic_rates;
3202 3288
3203 /* cf. IEEE 802.11 9.2.12 */ 3289 /* cf. IEEE 802.11 9.2.12 */
3204 if (local->oper_channel->band == IEEE80211_BAND_2GHZ && 3290 if (cbss->channel->band == IEEE80211_BAND_2GHZ &&
3205 have_higher_than_11mbit) 3291 have_higher_than_11mbit)
3206 sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE; 3292 sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE;
3207 else 3293 else
@@ -3263,19 +3349,33 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
3263 case NL80211_AUTHTYPE_NETWORK_EAP: 3349 case NL80211_AUTHTYPE_NETWORK_EAP:
3264 auth_alg = WLAN_AUTH_LEAP; 3350 auth_alg = WLAN_AUTH_LEAP;
3265 break; 3351 break;
3352 case NL80211_AUTHTYPE_SAE:
3353 auth_alg = WLAN_AUTH_SAE;
3354 break;
3266 default: 3355 default:
3267 return -EOPNOTSUPP; 3356 return -EOPNOTSUPP;
3268 } 3357 }
3269 3358
3270 auth_data = kzalloc(sizeof(*auth_data) + req->ie_len, GFP_KERNEL); 3359 auth_data = kzalloc(sizeof(*auth_data) + req->sae_data_len +
3360 req->ie_len, GFP_KERNEL);
3271 if (!auth_data) 3361 if (!auth_data)
3272 return -ENOMEM; 3362 return -ENOMEM;
3273 3363
3274 auth_data->bss = req->bss; 3364 auth_data->bss = req->bss;
3275 3365
3366 if (req->sae_data_len >= 4) {
3367 __le16 *pos = (__le16 *) req->sae_data;
3368 auth_data->sae_trans = le16_to_cpu(pos[0]);
3369 auth_data->sae_status = le16_to_cpu(pos[1]);
3370 memcpy(auth_data->data, req->sae_data + 4,
3371 req->sae_data_len - 4);
3372 auth_data->data_len += req->sae_data_len - 4;
3373 }
3374
3276 if (req->ie && req->ie_len) { 3375 if (req->ie && req->ie_len) {
3277 memcpy(auth_data->ie, req->ie, req->ie_len); 3376 memcpy(&auth_data->data[auth_data->data_len],
3278 auth_data->ie_len = req->ie_len; 3377 req->ie, req->ie_len);
3378 auth_data->data_len += req->ie_len;
3279 } 3379 }
3280 3380
3281 if (req->key && req->key_len) { 3381 if (req->key && req->key_len) {
@@ -3442,11 +3542,11 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
3442 3542
3443 if (ifmgd->req_smps == IEEE80211_SMPS_AUTOMATIC) { 3543 if (ifmgd->req_smps == IEEE80211_SMPS_AUTOMATIC) {
3444 if (ifmgd->powersave) 3544 if (ifmgd->powersave)
3445 ifmgd->ap_smps = IEEE80211_SMPS_DYNAMIC; 3545 sdata->smps_mode = IEEE80211_SMPS_DYNAMIC;
3446 else 3546 else
3447 ifmgd->ap_smps = IEEE80211_SMPS_OFF; 3547 sdata->smps_mode = IEEE80211_SMPS_OFF;
3448 } else 3548 } else
3449 ifmgd->ap_smps = ifmgd->req_smps; 3549 sdata->smps_mode = ifmgd->req_smps;
3450 3550
3451 assoc_data->capability = req->bss->capability; 3551 assoc_data->capability = req->bss->capability;
3452 assoc_data->wmm = bss->wmm_used && 3552 assoc_data->wmm = bss->wmm_used &&
diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c
index 83608ac16780..c349f3aaf59e 100644
--- a/net/mac80211/offchannel.c
+++ b/net/mac80211/offchannel.c
@@ -107,6 +107,9 @@ void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local,
107{ 107{
108 struct ieee80211_sub_if_data *sdata; 108 struct ieee80211_sub_if_data *sdata;
109 109
110 if (WARN_ON(local->use_chanctx))
111 return;
112
110 /* 113 /*
111 * notify the AP about us leaving the channel and stop all 114 * notify the AP about us leaving the channel and stop all
112 * STA interfaces. 115 * STA interfaces.
@@ -145,6 +148,9 @@ void ieee80211_offchannel_return(struct ieee80211_local *local,
145{ 148{
146 struct ieee80211_sub_if_data *sdata; 149 struct ieee80211_sub_if_data *sdata;
147 150
151 if (WARN_ON(local->use_chanctx))
152 return;
153
148 mutex_lock(&local->iflist_mtx); 154 mutex_lock(&local->iflist_mtx);
149 list_for_each_entry(sdata, &local->interfaces, list) { 155 list_for_each_entry(sdata, &local->interfaces, list) {
150 if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) 156 if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE)
@@ -193,7 +199,8 @@ void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc)
193 199
194 if (roc->mgmt_tx_cookie) { 200 if (roc->mgmt_tx_cookie) {
195 if (!WARN_ON(!roc->frame)) { 201 if (!WARN_ON(!roc->frame)) {
196 ieee80211_tx_skb(roc->sdata, roc->frame); 202 ieee80211_tx_skb_tid_band(roc->sdata, roc->frame, 7,
203 roc->chan->band);
197 roc->frame = NULL; 204 roc->frame = NULL;
198 } 205 }
199 } else { 206 } else {
diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
index 5c572e7a1a71..9f404ac901ab 100644
--- a/net/mac80211/pm.c
+++ b/net/mac80211/pm.c
@@ -135,6 +135,8 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
135 ieee80211_bss_info_change_notify(sdata, 135 ieee80211_bss_info_change_notify(sdata,
136 BSS_CHANGED_BEACON_ENABLED); 136 BSS_CHANGED_BEACON_ENABLED);
137 137
138 /* the interface is leaving the channel and is removed */
139 ieee80211_vif_release_channel(sdata);
138 drv_remove_interface(local, sdata); 140 drv_remove_interface(local, sdata);
139 } 141 }
140 142
diff --git a/net/mac80211/rate.h b/net/mac80211/rate.h
index 10de668eb9f6..ec198ef6aa8a 100644
--- a/net/mac80211/rate.h
+++ b/net/mac80211/rate.h
@@ -52,11 +52,21 @@ static inline void rate_control_rate_init(struct sta_info *sta)
52 struct ieee80211_sta *ista = &sta->sta; 52 struct ieee80211_sta *ista = &sta->sta;
53 void *priv_sta = sta->rate_ctrl_priv; 53 void *priv_sta = sta->rate_ctrl_priv;
54 struct ieee80211_supported_band *sband; 54 struct ieee80211_supported_band *sband;
55 struct ieee80211_chanctx_conf *chanctx_conf;
55 56
56 if (!ref) 57 if (!ref)
57 return; 58 return;
58 59
59 sband = local->hw.wiphy->bands[local->oper_channel->band]; 60 rcu_read_lock();
61
62 chanctx_conf = rcu_dereference(sta->sdata->vif.chanctx_conf);
63 if (WARN_ON(!chanctx_conf)) {
64 rcu_read_unlock();
65 return;
66 }
67
68 sband = local->hw.wiphy->bands[chanctx_conf->channel->band];
69 rcu_read_unlock();
60 70
61 ref->ops->rate_init(ref->priv, sband, ista, priv_sta); 71 ref->ops->rate_init(ref->priv, sband, ista, priv_sta);
62 set_sta_flag(sta, WLAN_STA_RATE_CONTROL); 72 set_sta_flag(sta, WLAN_STA_RATE_CONTROL);
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 61c621e9273f..d07216ab5f72 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1141,12 +1141,19 @@ ieee80211_rx_h_check_more_data(struct ieee80211_rx_data *rx)
1141 return RX_CONTINUE; 1141 return RX_CONTINUE;
1142} 1142}
1143 1143
1144static void ap_sta_ps_start(struct sta_info *sta) 1144static void sta_ps_start(struct sta_info *sta)
1145{ 1145{
1146 struct ieee80211_sub_if_data *sdata = sta->sdata; 1146 struct ieee80211_sub_if_data *sdata = sta->sdata;
1147 struct ieee80211_local *local = sdata->local; 1147 struct ieee80211_local *local = sdata->local;
1148 struct ps_data *ps;
1148 1149
1149 atomic_inc(&sdata->bss->num_sta_ps); 1150 if (sta->sdata->vif.type == NL80211_IFTYPE_AP ||
1151 sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
1152 ps = &sdata->bss->ps;
1153 else
1154 return;
1155
1156 atomic_inc(&ps->num_sta_ps);
1150 set_sta_flag(sta, WLAN_STA_PS_STA); 1157 set_sta_flag(sta, WLAN_STA_PS_STA);
1151 if (!(local->hw.flags & IEEE80211_HW_AP_LINK_PS)) 1158 if (!(local->hw.flags & IEEE80211_HW_AP_LINK_PS))
1152 drv_sta_notify(local, sdata, STA_NOTIFY_SLEEP, &sta->sta); 1159 drv_sta_notify(local, sdata, STA_NOTIFY_SLEEP, &sta->sta);
@@ -1154,7 +1161,7 @@ static void ap_sta_ps_start(struct sta_info *sta)
1154 sta->sta.addr, sta->sta.aid); 1161 sta->sta.addr, sta->sta.aid);
1155} 1162}
1156 1163
1157static void ap_sta_ps_end(struct sta_info *sta) 1164static void sta_ps_end(struct sta_info *sta)
1158{ 1165{
1159 ps_dbg(sta->sdata, "STA %pM aid %d exits power save mode\n", 1166 ps_dbg(sta->sdata, "STA %pM aid %d exits power save mode\n",
1160 sta->sta.addr, sta->sta.aid); 1167 sta->sta.addr, sta->sta.aid);
@@ -1181,9 +1188,9 @@ int ieee80211_sta_ps_transition(struct ieee80211_sta *sta, bool start)
1181 return -EINVAL; 1188 return -EINVAL;
1182 1189
1183 if (start) 1190 if (start)
1184 ap_sta_ps_start(sta_inf); 1191 sta_ps_start(sta_inf);
1185 else 1192 else
1186 ap_sta_ps_end(sta_inf); 1193 sta_ps_end(sta_inf);
1187 1194
1188 return 0; 1195 return 0;
1189} 1196}
@@ -1335,10 +1342,10 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
1335 */ 1342 */
1336 if (ieee80211_is_data(hdr->frame_control) && 1343 if (ieee80211_is_data(hdr->frame_control) &&
1337 !ieee80211_has_pm(hdr->frame_control)) 1344 !ieee80211_has_pm(hdr->frame_control))
1338 ap_sta_ps_end(sta); 1345 sta_ps_end(sta);
1339 } else { 1346 } else {
1340 if (ieee80211_has_pm(hdr->frame_control)) 1347 if (ieee80211_has_pm(hdr->frame_control))
1341 ap_sta_ps_start(sta); 1348 sta_ps_start(sta);
1342 } 1349 }
1343 } 1350 }
1344 1351
@@ -1384,9 +1391,7 @@ ieee80211_reassemble_add(struct ieee80211_sub_if_data *sdata,
1384 struct sk_buff **skb) 1391 struct sk_buff **skb)
1385{ 1392{
1386 struct ieee80211_fragment_entry *entry; 1393 struct ieee80211_fragment_entry *entry;
1387 int idx;
1388 1394
1389 idx = sdata->fragment_next;
1390 entry = &sdata->fragments[sdata->fragment_next++]; 1395 entry = &sdata->fragments[sdata->fragment_next++];
1391 if (sdata->fragment_next >= IEEE80211_FRAGMENT_MAX) 1396 if (sdata->fragment_next >= IEEE80211_FRAGMENT_MAX)
1392 sdata->fragment_next = 0; 1397 sdata->fragment_next = 0;
@@ -3010,8 +3015,7 @@ void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb)
3010 3015
3011 WARN_ON_ONCE(softirq_count() == 0); 3016 WARN_ON_ONCE(softirq_count() == 0);
3012 3017
3013 if (WARN_ON(status->band < 0 || 3018 if (WARN_ON(status->band >= IEEE80211_NUM_BANDS))
3014 status->band >= IEEE80211_NUM_BANDS))
3015 goto drop; 3019 goto drop;
3016 3020
3017 sband = local->hw.wiphy->bands[status->band]; 3021 sband = local->hw.wiphy->bands[status->band];
@@ -3056,8 +3060,7 @@ void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb)
3056 * hardware error. The driver should catch hardware 3060 * hardware error. The driver should catch hardware
3057 * errors. 3061 * errors.
3058 */ 3062 */
3059 if (WARN((status->rate_idx < 0 || 3063 if (WARN(status->rate_idx > 76,
3060 status->rate_idx > 76),
3061 "Rate marked as an HT rate but passed " 3064 "Rate marked as an HT rate but passed "
3062 "status->rate_idx is not " 3065 "status->rate_idx is not "
3063 "an MCS index [0-76]: %d (0x%02x)\n", 3066 "an MCS index [0-76]: %d (0x%02x)\n",
@@ -3065,8 +3068,7 @@ void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb)
3065 status->rate_idx)) 3068 status->rate_idx))
3066 goto drop; 3069 goto drop;
3067 } else { 3070 } else {
3068 if (WARN_ON(status->rate_idx < 0 || 3071 if (WARN_ON(status->rate_idx >= sband->n_bitrates))
3069 status->rate_idx >= sband->n_bitrates))
3070 goto drop; 3072 goto drop;
3071 rate = &sband->bitrates[status->rate_idx]; 3073 rate = &sband->bitrates[status->rate_idx];
3072 } 3074 }
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index c4cdbde24fd3..13d23299e696 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -336,6 +336,10 @@ EXPORT_SYMBOL(ieee80211_scan_completed);
336 336
337static int ieee80211_start_sw_scan(struct ieee80211_local *local) 337static int ieee80211_start_sw_scan(struct ieee80211_local *local)
338{ 338{
339 /* Software scan is not supported in multi-channel cases */
340 if (local->use_chanctx)
341 return -EOPNOTSUPP;
342
339 /* 343 /*
340 * Hardware/driver doesn't support hw_scan, so use software 344 * Hardware/driver doesn't support hw_scan, so use software
341 * scanning instead. First send a nullfunc frame with power save 345 * scanning instead. First send a nullfunc frame with power save
@@ -417,7 +421,7 @@ static void ieee80211_scan_state_send_probe(struct ieee80211_local *local,
417 local->scan_req->ie, local->scan_req->ie_len, 421 local->scan_req->ie, local->scan_req->ie_len,
418 local->scan_req->rates[band], false, 422 local->scan_req->rates[band], false,
419 local->scan_req->no_cck, 423 local->scan_req->no_cck,
420 local->hw.conf.channel); 424 local->hw.conf.channel, true);
421 425
422 /* 426 /*
423 * After sending probe requests, wait for probe responses 427 * After sending probe requests, wait for probe responses
@@ -462,6 +466,7 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
462 sizeof(*local->hw_scan_req) + 466 sizeof(*local->hw_scan_req) +
463 req->n_channels * sizeof(req->channels[0]); 467 req->n_channels * sizeof(req->channels[0]);
464 local->hw_scan_req->ie = ies; 468 local->hw_scan_req->ie = ies;
469 local->hw_scan_req->flags = req->flags;
465 470
466 local->hw_scan_band = 0; 471 local->hw_scan_band = 0;
467 472
@@ -480,7 +485,7 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
480 if (local->ops->hw_scan) { 485 if (local->ops->hw_scan) {
481 __set_bit(SCAN_HW_SCANNING, &local->scanning); 486 __set_bit(SCAN_HW_SCANNING, &local->scanning);
482 } else if ((req->n_channels == 1) && 487 } else if ((req->n_channels == 1) &&
483 (req->channels[0] == local->oper_channel)) { 488 (req->channels[0] == local->_oper_channel)) {
484 /* 489 /*
485 * If we are scanning only on the operating channel 490 * If we are scanning only on the operating channel
486 * then we do not need to stop normal activities 491 * then we do not need to stop normal activities
@@ -562,6 +567,7 @@ static void ieee80211_scan_state_decision(struct ieee80211_local *local,
562 unsigned long min_beacon_int = 0; 567 unsigned long min_beacon_int = 0;
563 struct ieee80211_sub_if_data *sdata; 568 struct ieee80211_sub_if_data *sdata;
564 struct ieee80211_channel *next_chan; 569 struct ieee80211_channel *next_chan;
570 enum mac80211_scan_state next_scan_state;
565 571
566 /* 572 /*
567 * check if at least one STA interface is associated, 573 * check if at least one STA interface is associated,
@@ -620,10 +626,18 @@ static void ieee80211_scan_state_decision(struct ieee80211_local *local,
620 usecs_to_jiffies(min_beacon_int * 1024) * 626 usecs_to_jiffies(min_beacon_int * 1024) *
621 local->hw.conf.listen_interval); 627 local->hw.conf.listen_interval);
622 628
623 if (associated && (!tx_empty || bad_latency || listen_int_exceeded)) 629 if (associated && !tx_empty) {
624 local->next_scan_state = SCAN_SUSPEND; 630 if (local->scan_req->flags & NL80211_SCAN_FLAG_LOW_PRIORITY)
625 else 631 next_scan_state = SCAN_ABORT;
626 local->next_scan_state = SCAN_SET_CHANNEL; 632 else
633 next_scan_state = SCAN_SUSPEND;
634 } else if (associated && (bad_latency || listen_int_exceeded)) {
635 next_scan_state = SCAN_SUSPEND;
636 } else {
637 next_scan_state = SCAN_SET_CHANNEL;
638 }
639
640 local->next_scan_state = next_scan_state;
627 641
628 *next_delay = 0; 642 *next_delay = 0;
629} 643}
@@ -794,6 +808,9 @@ void ieee80211_scan_work(struct work_struct *work)
794 case SCAN_RESUME: 808 case SCAN_RESUME:
795 ieee80211_scan_state_resume(local, &next_delay); 809 ieee80211_scan_state_resume(local, &next_delay);
796 break; 810 break;
811 case SCAN_ABORT:
812 aborted = true;
813 goto out_complete;
797 } 814 }
798 } while (next_delay == 0); 815 } while (next_delay == 0);
799 816
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 797dd36a220d..daf55e1e0fd3 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -98,6 +98,7 @@ static void free_sta_work(struct work_struct *wk)
98 struct tid_ampdu_tx *tid_tx; 98 struct tid_ampdu_tx *tid_tx;
99 struct ieee80211_sub_if_data *sdata = sta->sdata; 99 struct ieee80211_sub_if_data *sdata = sta->sdata;
100 struct ieee80211_local *local = sdata->local; 100 struct ieee80211_local *local = sdata->local;
101 struct ps_data *ps;
101 102
102 /* 103 /*
103 * At this point, when being called as call_rcu callback, 104 * At this point, when being called as call_rcu callback,
@@ -107,11 +108,15 @@ static void free_sta_work(struct work_struct *wk)
107 */ 108 */
108 109
109 if (test_sta_flag(sta, WLAN_STA_PS_STA)) { 110 if (test_sta_flag(sta, WLAN_STA_PS_STA)) {
110 BUG_ON(!sdata->bss); 111 if (sta->sdata->vif.type == NL80211_IFTYPE_AP ||
112 sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
113 ps = &sdata->bss->ps;
114 else
115 return;
111 116
112 clear_sta_flag(sta, WLAN_STA_PS_STA); 117 clear_sta_flag(sta, WLAN_STA_PS_STA);
113 118
114 atomic_dec(&sdata->bss->num_sta_ps); 119 atomic_dec(&ps->num_sta_ps);
115 sta_info_recalc_tim(sta); 120 sta_info_recalc_tim(sta);
116 } 121 }
117 122
@@ -502,22 +507,22 @@ int sta_info_insert(struct sta_info *sta)
502 return err; 507 return err;
503} 508}
504 509
505static inline void __bss_tim_set(struct ieee80211_if_ap *bss, u16 aid) 510static inline void __bss_tim_set(u8 *tim, u16 id)
506{ 511{
507 /* 512 /*
508 * This format has been mandated by the IEEE specifications, 513 * This format has been mandated by the IEEE specifications,
509 * so this line may not be changed to use the __set_bit() format. 514 * so this line may not be changed to use the __set_bit() format.
510 */ 515 */
511 bss->tim[aid / 8] |= (1 << (aid % 8)); 516 tim[id / 8] |= (1 << (id % 8));
512} 517}
513 518
514static inline void __bss_tim_clear(struct ieee80211_if_ap *bss, u16 aid) 519static inline void __bss_tim_clear(u8 *tim, u16 id)
515{ 520{
516 /* 521 /*
517 * This format has been mandated by the IEEE specifications, 522 * This format has been mandated by the IEEE specifications,
518 * so this line may not be changed to use the __clear_bit() format. 523 * so this line may not be changed to use the __clear_bit() format.
519 */ 524 */
520 bss->tim[aid / 8] &= ~(1 << (aid % 8)); 525 tim[id / 8] &= ~(1 << (id % 8));
521} 526}
522 527
523static unsigned long ieee80211_tids_for_ac(int ac) 528static unsigned long ieee80211_tids_for_ac(int ac)
@@ -541,14 +546,23 @@ static unsigned long ieee80211_tids_for_ac(int ac)
541void sta_info_recalc_tim(struct sta_info *sta) 546void sta_info_recalc_tim(struct sta_info *sta)
542{ 547{
543 struct ieee80211_local *local = sta->local; 548 struct ieee80211_local *local = sta->local;
544 struct ieee80211_if_ap *bss = sta->sdata->bss; 549 struct ps_data *ps;
545 unsigned long flags; 550 unsigned long flags;
546 bool indicate_tim = false; 551 bool indicate_tim = false;
547 u8 ignore_for_tim = sta->sta.uapsd_queues; 552 u8 ignore_for_tim = sta->sta.uapsd_queues;
548 int ac; 553 int ac;
554 u16 id;
555
556 if (sta->sdata->vif.type == NL80211_IFTYPE_AP ||
557 sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {
558 if (WARN_ON_ONCE(!sta->sdata->bss))
559 return;
549 560
550 if (WARN_ON_ONCE(!sta->sdata->bss)) 561 ps = &sta->sdata->bss->ps;
562 id = sta->sta.aid;
563 } else {
551 return; 564 return;
565 }
552 566
553 /* No need to do anything if the driver does all */ 567 /* No need to do anything if the driver does all */
554 if (local->hw.flags & IEEE80211_HW_AP_LINK_PS) 568 if (local->hw.flags & IEEE80211_HW_AP_LINK_PS)
@@ -587,9 +601,9 @@ void sta_info_recalc_tim(struct sta_info *sta)
587 spin_lock_irqsave(&local->tim_lock, flags); 601 spin_lock_irqsave(&local->tim_lock, flags);
588 602
589 if (indicate_tim) 603 if (indicate_tim)
590 __bss_tim_set(bss, sta->sta.aid); 604 __bss_tim_set(ps->tim, id);
591 else 605 else
592 __bss_tim_clear(bss, sta->sta.aid); 606 __bss_tim_clear(ps->tim, id);
593 607
594 if (local->ops->set_tim) { 608 if (local->ops->set_tim) {
595 local->tim_in_locked_section = true; 609 local->tim_in_locked_section = true;
@@ -893,8 +907,8 @@ void ieee80211_sta_expire(struct ieee80211_sub_if_data *sdata,
893 continue; 907 continue;
894 908
895 if (time_after(jiffies, sta->last_rx + exp_time)) { 909 if (time_after(jiffies, sta->last_rx + exp_time)) {
896 ibss_dbg(sdata, "expiring inactive STA %pM\n", 910 sta_dbg(sta->sdata, "expiring inactive STA %pM\n",
897 sta->sta.addr); 911 sta->sta.addr);
898 WARN_ON(__sta_info_destroy(sta)); 912 WARN_ON(__sta_info_destroy(sta));
899 } 913 }
900 } 914 }
@@ -948,10 +962,17 @@ static void clear_sta_ps_flags(void *_sta)
948{ 962{
949 struct sta_info *sta = _sta; 963 struct sta_info *sta = _sta;
950 struct ieee80211_sub_if_data *sdata = sta->sdata; 964 struct ieee80211_sub_if_data *sdata = sta->sdata;
965 struct ps_data *ps;
966
967 if (sdata->vif.type == NL80211_IFTYPE_AP ||
968 sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
969 ps = &sdata->bss->ps;
970 else
971 return;
951 972
952 clear_sta_flag(sta, WLAN_STA_PS_DRIVER); 973 clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
953 if (test_and_clear_sta_flag(sta, WLAN_STA_PS_STA)) 974 if (test_and_clear_sta_flag(sta, WLAN_STA_PS_STA))
954 atomic_dec(&sdata->bss->num_sta_ps); 975 atomic_dec(&ps->num_sta_ps);
955} 976}
956 977
957/* powersave support code */ 978/* powersave support code */
@@ -1008,6 +1029,7 @@ static void ieee80211_send_null_response(struct ieee80211_sub_if_data *sdata,
1008 __le16 fc; 1029 __le16 fc;
1009 bool qos = test_sta_flag(sta, WLAN_STA_WME); 1030 bool qos = test_sta_flag(sta, WLAN_STA_WME);
1010 struct ieee80211_tx_info *info; 1031 struct ieee80211_tx_info *info;
1032 struct ieee80211_chanctx_conf *chanctx_conf;
1011 1033
1012 if (qos) { 1034 if (qos) {
1013 fc = cpu_to_le16(IEEE80211_FTYPE_DATA | 1035 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
@@ -1057,7 +1079,16 @@ static void ieee80211_send_null_response(struct ieee80211_sub_if_data *sdata,
1057 1079
1058 drv_allow_buffered_frames(local, sta, BIT(tid), 1, reason, false); 1080 drv_allow_buffered_frames(local, sta, BIT(tid), 1, reason, false);
1059 1081
1060 ieee80211_xmit(sdata, skb); 1082 rcu_read_lock();
1083 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
1084 if (WARN_ON(!chanctx_conf)) {
1085 rcu_read_unlock();
1086 kfree_skb(skb);
1087 return;
1088 }
1089
1090 ieee80211_xmit(sdata, skb, chanctx_conf->channel->band);
1091 rcu_read_unlock();
1061} 1092}
1062 1093
1063static void 1094static void
diff --git a/net/mac80211/status.c b/net/mac80211/status.c
index 3af0cc4130f1..21fa5c72ea14 100644
--- a/net/mac80211/status.c
+++ b/net/mac80211/status.c
@@ -189,30 +189,31 @@ static void ieee80211_frame_acked(struct sta_info *sta, struct sk_buff *skb)
189 } 189 }
190 190
191 if (ieee80211_is_action(mgmt->frame_control) && 191 if (ieee80211_is_action(mgmt->frame_control) &&
192 sdata->vif.type == NL80211_IFTYPE_STATION &&
193 mgmt->u.action.category == WLAN_CATEGORY_HT && 192 mgmt->u.action.category == WLAN_CATEGORY_HT &&
194 mgmt->u.action.u.ht_smps.action == WLAN_HT_ACTION_SMPS) { 193 mgmt->u.action.u.ht_smps.action == WLAN_HT_ACTION_SMPS &&
194 sdata->vif.type == NL80211_IFTYPE_STATION &&
195 ieee80211_sdata_running(sdata)) {
195 /* 196 /*
196 * This update looks racy, but isn't -- if we come 197 * This update looks racy, but isn't -- if we come
197 * here we've definitely got a station that we're 198 * here we've definitely got a station that we're
198 * talking to, and on a managed interface that can 199 * talking to, and on a managed interface that can
199 * only be the AP. And the only other place updating 200 * only be the AP. And the only other place updating
200 * this variable is before we're associated. 201 * this variable in managed mode is before association.
201 */ 202 */
202 switch (mgmt->u.action.u.ht_smps.smps_control) { 203 switch (mgmt->u.action.u.ht_smps.smps_control) {
203 case WLAN_HT_SMPS_CONTROL_DYNAMIC: 204 case WLAN_HT_SMPS_CONTROL_DYNAMIC:
204 sta->sdata->u.mgd.ap_smps = IEEE80211_SMPS_DYNAMIC; 205 sdata->smps_mode = IEEE80211_SMPS_DYNAMIC;
205 break; 206 break;
206 case WLAN_HT_SMPS_CONTROL_STATIC: 207 case WLAN_HT_SMPS_CONTROL_STATIC:
207 sta->sdata->u.mgd.ap_smps = IEEE80211_SMPS_STATIC; 208 sdata->smps_mode = IEEE80211_SMPS_STATIC;
208 break; 209 break;
209 case WLAN_HT_SMPS_CONTROL_DISABLED: 210 case WLAN_HT_SMPS_CONTROL_DISABLED:
210 default: /* shouldn't happen since we don't send that */ 211 default: /* shouldn't happen since we don't send that */
211 sta->sdata->u.mgd.ap_smps = IEEE80211_SMPS_OFF; 212 sdata->smps_mode = IEEE80211_SMPS_OFF;
212 break; 213 break;
213 } 214 }
214 215
215 ieee80211_queue_work(&local->hw, &local->recalc_smps); 216 ieee80211_queue_work(&local->hw, &sdata->recalc_smps);
216 } 217 }
217} 218}
218 219
diff --git a/net/mac80211/trace.h b/net/mac80211/trace.h
index 18d9c8a52e9e..629364705f7b 100644
--- a/net/mac80211/trace.h
+++ b/net/mac80211/trace.h
@@ -28,6 +28,20 @@
28#define VIF_PR_FMT " vif:%s(%d%s)" 28#define VIF_PR_FMT " vif:%s(%d%s)"
29#define VIF_PR_ARG __get_str(vif_name), __entry->vif_type, __entry->p2p ? "/p2p" : "" 29#define VIF_PR_ARG __get_str(vif_name), __entry->vif_type, __entry->p2p ? "/p2p" : ""
30 30
31#define CHANCTX_ENTRY __field(int, freq) \
32 __field(int, chantype) \
33 __field(u8, rx_chains_static) \
34 __field(u8, rx_chains_dynamic)
35#define CHANCTX_ASSIGN __entry->freq = ctx->conf.channel->center_freq; \
36 __entry->chantype = ctx->conf.channel_type; \
37 __entry->rx_chains_static = ctx->conf.rx_chains_static; \
38 __entry->rx_chains_dynamic = ctx->conf.rx_chains_dynamic
39#define CHANCTX_PR_FMT " freq:%d MHz chantype:%d chains:%d/%d"
40#define CHANCTX_PR_ARG __entry->freq, __entry->chantype, \
41 __entry->rx_chains_static, __entry->rx_chains_dynamic
42
43
44
31/* 45/*
32 * Tracing for driver callbacks. 46 * Tracing for driver callbacks.
33 */ 47 */
@@ -1256,6 +1270,104 @@ DEFINE_EVENT(local_sdata_evt, drv_mgd_prepare_tx,
1256 TP_ARGS(local, sdata) 1270 TP_ARGS(local, sdata)
1257); 1271);
1258 1272
1273DECLARE_EVENT_CLASS(local_chanctx,
1274 TP_PROTO(struct ieee80211_local *local,
1275 struct ieee80211_chanctx *ctx),
1276
1277 TP_ARGS(local, ctx),
1278
1279 TP_STRUCT__entry(
1280 LOCAL_ENTRY
1281 CHANCTX_ENTRY
1282 ),
1283
1284 TP_fast_assign(
1285 LOCAL_ASSIGN;
1286 CHANCTX_ASSIGN;
1287 ),
1288
1289 TP_printk(
1290 LOCAL_PR_FMT CHANCTX_PR_FMT,
1291 LOCAL_PR_ARG, CHANCTX_PR_ARG
1292 )
1293);
1294
1295DEFINE_EVENT(local_chanctx, drv_add_chanctx,
1296 TP_PROTO(struct ieee80211_local *local,
1297 struct ieee80211_chanctx *ctx),
1298 TP_ARGS(local, ctx)
1299);
1300
1301DEFINE_EVENT(local_chanctx, drv_remove_chanctx,
1302 TP_PROTO(struct ieee80211_local *local,
1303 struct ieee80211_chanctx *ctx),
1304 TP_ARGS(local, ctx)
1305);
1306
1307TRACE_EVENT(drv_change_chanctx,
1308 TP_PROTO(struct ieee80211_local *local,
1309 struct ieee80211_chanctx *ctx,
1310 u32 changed),
1311
1312 TP_ARGS(local, ctx, changed),
1313
1314 TP_STRUCT__entry(
1315 LOCAL_ENTRY
1316 CHANCTX_ENTRY
1317 __field(u32, changed)
1318 ),
1319
1320 TP_fast_assign(
1321 LOCAL_ASSIGN;
1322 CHANCTX_ASSIGN;
1323 __entry->changed = changed;
1324 ),
1325
1326 TP_printk(
1327 LOCAL_PR_FMT CHANCTX_PR_FMT " changed:%#x",
1328 LOCAL_PR_ARG, CHANCTX_PR_ARG, __entry->changed
1329 )
1330);
1331
1332DECLARE_EVENT_CLASS(local_sdata_chanctx,
1333 TP_PROTO(struct ieee80211_local *local,
1334 struct ieee80211_sub_if_data *sdata,
1335 struct ieee80211_chanctx *ctx),
1336
1337 TP_ARGS(local, sdata, ctx),
1338
1339 TP_STRUCT__entry(
1340 LOCAL_ENTRY
1341 VIF_ENTRY
1342 CHANCTX_ENTRY
1343 ),
1344
1345 TP_fast_assign(
1346 LOCAL_ASSIGN;
1347 VIF_ASSIGN;
1348 CHANCTX_ASSIGN;
1349 ),
1350
1351 TP_printk(
1352 LOCAL_PR_FMT VIF_PR_FMT CHANCTX_PR_FMT,
1353 LOCAL_PR_ARG, VIF_PR_ARG, CHANCTX_PR_ARG
1354 )
1355);
1356
1357DEFINE_EVENT(local_sdata_chanctx, drv_assign_vif_chanctx,
1358 TP_PROTO(struct ieee80211_local *local,
1359 struct ieee80211_sub_if_data *sdata,
1360 struct ieee80211_chanctx *ctx),
1361 TP_ARGS(local, sdata, ctx)
1362);
1363
1364DEFINE_EVENT(local_sdata_chanctx, drv_unassign_vif_chanctx,
1365 TP_PROTO(struct ieee80211_local *local,
1366 struct ieee80211_sub_if_data *sdata,
1367 struct ieee80211_chanctx *ctx),
1368 TP_ARGS(local, sdata, ctx)
1369);
1370
1259/* 1371/*
1260 * Tracing for API calls that drivers call. 1372 * Tracing for API calls that drivers call.
1261 */ 1373 */
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index c9bf83f36657..065f81cb5618 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -324,22 +324,20 @@ static void purge_old_ps_buffers(struct ieee80211_local *local)
324 struct ieee80211_sub_if_data *sdata; 324 struct ieee80211_sub_if_data *sdata;
325 struct sta_info *sta; 325 struct sta_info *sta;
326 326
327 /*
328 * virtual interfaces are protected by RCU
329 */
330 rcu_read_lock();
331
332 list_for_each_entry_rcu(sdata, &local->interfaces, list) { 327 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
333 struct ieee80211_if_ap *ap; 328 struct ps_data *ps;
334 if (sdata->vif.type != NL80211_IFTYPE_AP) 329
330 if (sdata->vif.type == NL80211_IFTYPE_AP)
331 ps = &sdata->u.ap.ps;
332 else
335 continue; 333 continue;
336 ap = &sdata->u.ap; 334
337 skb = skb_dequeue(&ap->ps_bc_buf); 335 skb = skb_dequeue(&ps->bc_buf);
338 if (skb) { 336 if (skb) {
339 purged++; 337 purged++;
340 dev_kfree_skb(skb); 338 dev_kfree_skb(skb);
341 } 339 }
342 total += skb_queue_len(&ap->ps_bc_buf); 340 total += skb_queue_len(&ps->bc_buf);
343 } 341 }
344 342
345 /* 343 /*
@@ -360,8 +358,6 @@ static void purge_old_ps_buffers(struct ieee80211_local *local)
360 } 358 }
361 } 359 }
362 360
363 rcu_read_unlock();
364
365 local->total_ps_buffered = total; 361 local->total_ps_buffered = total;
366 ps_dbg_hw(&local->hw, "PS buffers full - purged %d frames\n", purged); 362 ps_dbg_hw(&local->hw, "PS buffers full - purged %d frames\n", purged);
367} 363}
@@ -371,6 +367,7 @@ ieee80211_tx_h_multicast_ps_buf(struct ieee80211_tx_data *tx)
371{ 367{
372 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); 368 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
373 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; 369 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
370 struct ps_data *ps;
374 371
375 /* 372 /*
376 * broadcast/multicast frame 373 * broadcast/multicast frame
@@ -380,16 +377,24 @@ ieee80211_tx_h_multicast_ps_buf(struct ieee80211_tx_data *tx)
380 * This is done either by the hardware or us. 377 * This is done either by the hardware or us.
381 */ 378 */
382 379
383 /* powersaving STAs only in AP/VLAN mode */ 380 /* powersaving STAs currently only in AP/VLAN mode */
384 if (!tx->sdata->bss) 381 if (tx->sdata->vif.type == NL80211_IFTYPE_AP ||
382 tx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {
383 if (!tx->sdata->bss)
384 return TX_CONTINUE;
385
386 ps = &tx->sdata->bss->ps;
387 } else {
385 return TX_CONTINUE; 388 return TX_CONTINUE;
389 }
390
386 391
387 /* no buffering for ordered frames */ 392 /* no buffering for ordered frames */
388 if (ieee80211_has_order(hdr->frame_control)) 393 if (ieee80211_has_order(hdr->frame_control))
389 return TX_CONTINUE; 394 return TX_CONTINUE;
390 395
391 /* no stations in PS mode */ 396 /* no stations in PS mode */
392 if (!atomic_read(&tx->sdata->bss->num_sta_ps)) 397 if (!atomic_read(&ps->num_sta_ps))
393 return TX_CONTINUE; 398 return TX_CONTINUE;
394 399
395 info->flags |= IEEE80211_TX_CTL_SEND_AFTER_DTIM; 400 info->flags |= IEEE80211_TX_CTL_SEND_AFTER_DTIM;
@@ -404,14 +409,14 @@ ieee80211_tx_h_multicast_ps_buf(struct ieee80211_tx_data *tx)
404 if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) 409 if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER)
405 purge_old_ps_buffers(tx->local); 410 purge_old_ps_buffers(tx->local);
406 411
407 if (skb_queue_len(&tx->sdata->bss->ps_bc_buf) >= AP_MAX_BC_BUFFER) { 412 if (skb_queue_len(&ps->bc_buf) >= AP_MAX_BC_BUFFER) {
408 ps_dbg(tx->sdata, 413 ps_dbg(tx->sdata,
409 "BC TX buffer full - dropping the oldest frame\n"); 414 "BC TX buffer full - dropping the oldest frame\n");
410 dev_kfree_skb(skb_dequeue(&tx->sdata->bss->ps_bc_buf)); 415 dev_kfree_skb(skb_dequeue(&ps->bc_buf));
411 } else 416 } else
412 tx->local->total_ps_buffered++; 417 tx->local->total_ps_buffered++;
413 418
414 skb_queue_tail(&tx->sdata->bss->ps_bc_buf, tx->skb); 419 skb_queue_tail(&ps->bc_buf, tx->skb);
415 420
416 return TX_QUEUED; 421 return TX_QUEUED;
417} 422}
@@ -951,7 +956,6 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx)
951 fragnum = 0; 956 fragnum = 0;
952 957
953 skb_queue_walk(&tx->skbs, skb) { 958 skb_queue_walk(&tx->skbs, skb) {
954 int next_len;
955 const __le16 morefrags = cpu_to_le16(IEEE80211_FCTL_MOREFRAGS); 959 const __le16 morefrags = cpu_to_le16(IEEE80211_FCTL_MOREFRAGS);
956 960
957 hdr = (void *)skb->data; 961 hdr = (void *)skb->data;
@@ -970,7 +974,6 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx)
970 info->flags &= ~IEEE80211_TX_CTL_RATE_CTRL_PROBE; 974 info->flags &= ~IEEE80211_TX_CTL_RATE_CTRL_PROBE;
971 } else { 975 } else {
972 hdr->frame_control &= ~morefrags; 976 hdr->frame_control &= ~morefrags;
973 next_len = 0;
974 } 977 }
975 hdr->seq_ctrl |= cpu_to_le16(fragnum & IEEE80211_SCTL_FRAG); 978 hdr->seq_ctrl |= cpu_to_le16(fragnum & IEEE80211_SCTL_FRAG);
976 fragnum++; 979 fragnum++;
@@ -1372,7 +1375,8 @@ static int invoke_tx_handlers(struct ieee80211_tx_data *tx)
1372 * Returns false if the frame couldn't be transmitted but was queued instead. 1375 * Returns false if the frame couldn't be transmitted but was queued instead.
1373 */ 1376 */
1374static bool ieee80211_tx(struct ieee80211_sub_if_data *sdata, 1377static bool ieee80211_tx(struct ieee80211_sub_if_data *sdata,
1375 struct sk_buff *skb, bool txpending) 1378 struct sk_buff *skb, bool txpending,
1379 enum ieee80211_band band)
1376{ 1380{
1377 struct ieee80211_local *local = sdata->local; 1381 struct ieee80211_local *local = sdata->local;
1378 struct ieee80211_tx_data tx; 1382 struct ieee80211_tx_data tx;
@@ -1386,20 +1390,18 @@ static bool ieee80211_tx(struct ieee80211_sub_if_data *sdata,
1386 return true; 1390 return true;
1387 } 1391 }
1388 1392
1389 rcu_read_lock();
1390
1391 /* initialises tx */ 1393 /* initialises tx */
1392 led_len = skb->len; 1394 led_len = skb->len;
1393 res_prepare = ieee80211_tx_prepare(sdata, &tx, skb); 1395 res_prepare = ieee80211_tx_prepare(sdata, &tx, skb);
1394 1396
1395 if (unlikely(res_prepare == TX_DROP)) { 1397 if (unlikely(res_prepare == TX_DROP)) {
1396 ieee80211_free_txskb(&local->hw, skb); 1398 ieee80211_free_txskb(&local->hw, skb);
1397 goto out; 1399 return true;
1398 } else if (unlikely(res_prepare == TX_QUEUED)) { 1400 } else if (unlikely(res_prepare == TX_QUEUED)) {
1399 goto out; 1401 return true;
1400 } 1402 }
1401 1403
1402 info->band = local->hw.conf.channel->band; 1404 info->band = band;
1403 1405
1404 /* set up hw_queue value early */ 1406 /* set up hw_queue value early */
1405 if (!(info->flags & IEEE80211_TX_CTL_TX_OFFCHAN) || 1407 if (!(info->flags & IEEE80211_TX_CTL_TX_OFFCHAN) ||
@@ -1410,8 +1412,7 @@ static bool ieee80211_tx(struct ieee80211_sub_if_data *sdata,
1410 if (!invoke_tx_handlers(&tx)) 1412 if (!invoke_tx_handlers(&tx))
1411 result = __ieee80211_tx(local, &tx.skbs, led_len, 1413 result = __ieee80211_tx(local, &tx.skbs, led_len,
1412 tx.sta, txpending); 1414 tx.sta, txpending);
1413 out: 1415
1414 rcu_read_unlock();
1415 return result; 1416 return result;
1416} 1417}
1417 1418
@@ -1446,7 +1447,8 @@ static int ieee80211_skb_resize(struct ieee80211_sub_if_data *sdata,
1446 return 0; 1447 return 0;
1447} 1448}
1448 1449
1449void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb) 1450void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
1451 enum ieee80211_band band)
1450{ 1452{
1451 struct ieee80211_local *local = sdata->local; 1453 struct ieee80211_local *local = sdata->local;
1452 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 1454 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
@@ -1454,8 +1456,6 @@ void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
1454 int headroom; 1456 int headroom;
1455 bool may_encrypt; 1457 bool may_encrypt;
1456 1458
1457 rcu_read_lock();
1458
1459 may_encrypt = !(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT); 1459 may_encrypt = !(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT);
1460 1460
1461 headroom = local->tx_headroom; 1461 headroom = local->tx_headroom;
@@ -1466,7 +1466,6 @@ void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
1466 1466
1467 if (ieee80211_skb_resize(sdata, skb, headroom, may_encrypt)) { 1467 if (ieee80211_skb_resize(sdata, skb, headroom, may_encrypt)) {
1468 ieee80211_free_txskb(&local->hw, skb); 1468 ieee80211_free_txskb(&local->hw, skb);
1469 rcu_read_unlock();
1470 return; 1469 return;
1471 } 1470 }
1472 1471
@@ -1478,13 +1477,11 @@ void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
1478 !is_multicast_ether_addr(hdr->addr1) && 1477 !is_multicast_ether_addr(hdr->addr1) &&
1479 mesh_nexthop_resolve(skb, sdata)) { 1478 mesh_nexthop_resolve(skb, sdata)) {
1480 /* skb queued: don't free */ 1479 /* skb queued: don't free */
1481 rcu_read_unlock();
1482 return; 1480 return;
1483 } 1481 }
1484 1482
1485 ieee80211_set_qos_hdr(sdata, skb); 1483 ieee80211_set_qos_hdr(sdata, skb);
1486 ieee80211_tx(sdata, skb, false); 1484 ieee80211_tx(sdata, skb, false, band);
1487 rcu_read_unlock();
1488} 1485}
1489 1486
1490static bool ieee80211_parse_tx_radiotap(struct sk_buff *skb) 1487static bool ieee80211_parse_tx_radiotap(struct sk_buff *skb)
@@ -1574,7 +1571,8 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
1574 struct net_device *dev) 1571 struct net_device *dev)
1575{ 1572{
1576 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 1573 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1577 struct ieee80211_channel *chan = local->hw.conf.channel; 1574 struct ieee80211_chanctx_conf *chanctx_conf;
1575 struct ieee80211_channel *chan;
1578 struct ieee80211_radiotap_header *prthdr = 1576 struct ieee80211_radiotap_header *prthdr =
1579 (struct ieee80211_radiotap_header *)skb->data; 1577 (struct ieee80211_radiotap_header *)skb->data;
1580 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 1578 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
@@ -1583,26 +1581,6 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
1583 u16 len_rthdr; 1581 u16 len_rthdr;
1584 int hdrlen; 1582 int hdrlen;
1585 1583
1586 /*
1587 * Frame injection is not allowed if beaconing is not allowed
1588 * or if we need radar detection. Beaconing is usually not allowed when
1589 * the mode or operation (Adhoc, AP, Mesh) does not support DFS.
1590 * Passive scan is also used in world regulatory domains where
1591 * your country is not known and as such it should be treated as
1592 * NO TX unless the channel is explicitly allowed in which case
1593 * your current regulatory domain would not have the passive scan
1594 * flag.
1595 *
1596 * Since AP mode uses monitor interfaces to inject/TX management
1597 * frames we can make AP mode the exception to this rule once it
1598 * supports radar detection as its implementation can deal with
1599 * radar detection by itself. We can do that later by adding a
1600 * monitor flag interfaces used for AP support.
1601 */
1602 if ((chan->flags & (IEEE80211_CHAN_NO_IBSS | IEEE80211_CHAN_RADAR |
1603 IEEE80211_CHAN_PASSIVE_SCAN)))
1604 goto fail;
1605
1606 /* check for not even having the fixed radiotap header part */ 1584 /* check for not even having the fixed radiotap header part */
1607 if (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header))) 1585 if (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header)))
1608 goto fail; /* too short to be possibly valid */ 1586 goto fail; /* too short to be possibly valid */
@@ -1688,11 +1666,45 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
1688 } 1666 }
1689 } 1667 }
1690 1668
1691 ieee80211_xmit(sdata, skb); 1669 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
1670 if (!chanctx_conf) {
1671 tmp_sdata = rcu_dereference(local->monitor_sdata);
1672 if (tmp_sdata)
1673 chanctx_conf =
1674 rcu_dereference(tmp_sdata->vif.chanctx_conf);
1675 }
1676 if (!chanctx_conf)
1677 goto fail_rcu;
1678
1679 chan = chanctx_conf->channel;
1680
1681 /*
1682 * Frame injection is not allowed if beaconing is not allowed
1683 * or if we need radar detection. Beaconing is usually not allowed when
1684 * the mode or operation (Adhoc, AP, Mesh) does not support DFS.
1685 * Passive scan is also used in world regulatory domains where
1686 * your country is not known and as such it should be treated as
1687 * NO TX unless the channel is explicitly allowed in which case
1688 * your current regulatory domain would not have the passive scan
1689 * flag.
1690 *
1691 * Since AP mode uses monitor interfaces to inject/TX management
1692 * frames we can make AP mode the exception to this rule once it
1693 * supports radar detection as its implementation can deal with
1694 * radar detection by itself. We can do that later by adding a
1695 * monitor flag interfaces used for AP support.
1696 */
1697 if ((chan->flags & (IEEE80211_CHAN_NO_IBSS | IEEE80211_CHAN_RADAR |
1698 IEEE80211_CHAN_PASSIVE_SCAN)))
1699 goto fail_rcu;
1700
1701 ieee80211_xmit(sdata, skb, chan->band);
1692 rcu_read_unlock(); 1702 rcu_read_unlock();
1693 1703
1694 return NETDEV_TX_OK; 1704 return NETDEV_TX_OK;
1695 1705
1706fail_rcu:
1707 rcu_read_unlock();
1696fail: 1708fail:
1697 dev_kfree_skb(skb); 1709 dev_kfree_skb(skb);
1698 return NETDEV_TX_OK; /* meaning, we dealt with the skb */ 1710 return NETDEV_TX_OK; /* meaning, we dealt with the skb */
@@ -1734,6 +1746,9 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1734 bool multicast; 1746 bool multicast;
1735 u32 info_flags = 0; 1747 u32 info_flags = 0;
1736 u16 info_id = 0; 1748 u16 info_id = 0;
1749 struct ieee80211_chanctx_conf *chanctx_conf;
1750 struct ieee80211_sub_if_data *ap_sdata;
1751 enum ieee80211_band band;
1737 1752
1738 if (unlikely(skb->len < ETH_HLEN)) 1753 if (unlikely(skb->len < ETH_HLEN))
1739 goto fail; 1754 goto fail;
@@ -1743,9 +1758,10 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1743 ethertype = (skb->data[12] << 8) | skb->data[13]; 1758 ethertype = (skb->data[12] << 8) | skb->data[13];
1744 fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA); 1759 fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA);
1745 1760
1761 rcu_read_lock();
1762
1746 switch (sdata->vif.type) { 1763 switch (sdata->vif.type) {
1747 case NL80211_IFTYPE_AP_VLAN: 1764 case NL80211_IFTYPE_AP_VLAN:
1748 rcu_read_lock();
1749 sta = rcu_dereference(sdata->u.vlan.sta); 1765 sta = rcu_dereference(sdata->u.vlan.sta);
1750 if (sta) { 1766 if (sta) {
1751 fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS); 1767 fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS);
@@ -1758,7 +1774,12 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1758 authorized = test_sta_flag(sta, WLAN_STA_AUTHORIZED); 1774 authorized = test_sta_flag(sta, WLAN_STA_AUTHORIZED);
1759 wme_sta = test_sta_flag(sta, WLAN_STA_WME); 1775 wme_sta = test_sta_flag(sta, WLAN_STA_WME);
1760 } 1776 }
1761 rcu_read_unlock(); 1777 ap_sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
1778 u.ap);
1779 chanctx_conf = rcu_dereference(ap_sdata->vif.chanctx_conf);
1780 if (!chanctx_conf)
1781 goto fail_rcu;
1782 band = chanctx_conf->channel->band;
1762 if (sta) 1783 if (sta)
1763 break; 1784 break;
1764 /* fall through */ 1785 /* fall through */
@@ -1769,6 +1790,11 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1769 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); 1790 memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN);
1770 memcpy(hdr.addr3, skb->data + ETH_ALEN, ETH_ALEN); 1791 memcpy(hdr.addr3, skb->data + ETH_ALEN, ETH_ALEN);
1771 hdrlen = 24; 1792 hdrlen = 24;
1793 if (sdata->vif.type == NL80211_IFTYPE_AP)
1794 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
1795 if (!chanctx_conf)
1796 goto fail_rcu;
1797 band = chanctx_conf->channel->band;
1772 break; 1798 break;
1773 case NL80211_IFTYPE_WDS: 1799 case NL80211_IFTYPE_WDS:
1774 fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS); 1800 fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS);
@@ -1778,15 +1804,20 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1778 memcpy(hdr.addr3, skb->data, ETH_ALEN); 1804 memcpy(hdr.addr3, skb->data, ETH_ALEN);
1779 memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); 1805 memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN);
1780 hdrlen = 30; 1806 hdrlen = 30;
1807 /*
1808 * This is the exception! WDS style interfaces are prohibited
1809 * when channel contexts are in used so this must be valid
1810 */
1811 band = local->hw.conf.channel->band;
1781 break; 1812 break;
1782#ifdef CONFIG_MAC80211_MESH 1813#ifdef CONFIG_MAC80211_MESH
1783 case NL80211_IFTYPE_MESH_POINT: 1814 case NL80211_IFTYPE_MESH_POINT:
1784 if (!sdata->u.mesh.mshcfg.dot11MeshTTL) { 1815 if (!sdata->u.mesh.mshcfg.dot11MeshTTL) {
1785 /* Do not send frames with mesh_ttl == 0 */ 1816 /* Do not send frames with mesh_ttl == 0 */
1786 sdata->u.mesh.mshstats.dropped_frames_ttl++; 1817 sdata->u.mesh.mshstats.dropped_frames_ttl++;
1787 goto fail; 1818 goto fail_rcu;
1788 } 1819 }
1789 rcu_read_lock(); 1820
1790 if (!is_multicast_ether_addr(skb->data)) { 1821 if (!is_multicast_ether_addr(skb->data)) {
1791 mpath = mesh_path_lookup(skb->data, sdata); 1822 mpath = mesh_path_lookup(skb->data, sdata);
1792 if (!mpath) 1823 if (!mpath)
@@ -1803,7 +1834,6 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1803 !(mppath && !ether_addr_equal(mppath->mpp, skb->data))) { 1834 !(mppath && !ether_addr_equal(mppath->mpp, skb->data))) {
1804 hdrlen = ieee80211_fill_mesh_addresses(&hdr, &fc, 1835 hdrlen = ieee80211_fill_mesh_addresses(&hdr, &fc,
1805 skb->data, skb->data + ETH_ALEN); 1836 skb->data, skb->data + ETH_ALEN);
1806 rcu_read_unlock();
1807 meshhdrlen = ieee80211_new_mesh_header(&mesh_hdr, 1837 meshhdrlen = ieee80211_new_mesh_header(&mesh_hdr,
1808 sdata, NULL, NULL); 1838 sdata, NULL, NULL);
1809 } else { 1839 } else {
@@ -1819,7 +1849,6 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1819 mesh_da = mppath->mpp; 1849 mesh_da = mppath->mpp;
1820 else if (mpath) 1850 else if (mpath)
1821 mesh_da = mpath->dst; 1851 mesh_da = mpath->dst;
1822 rcu_read_unlock();
1823 1852
1824 hdrlen = ieee80211_fill_mesh_addresses(&hdr, &fc, 1853 hdrlen = ieee80211_fill_mesh_addresses(&hdr, &fc,
1825 mesh_da, sdata->vif.addr); 1854 mesh_da, sdata->vif.addr);
@@ -1839,13 +1868,16 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1839 skb->data + ETH_ALEN); 1868 skb->data + ETH_ALEN);
1840 1869
1841 } 1870 }
1871 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
1872 if (!chanctx_conf)
1873 goto fail_rcu;
1874 band = chanctx_conf->channel->band;
1842 break; 1875 break;
1843#endif 1876#endif
1844 case NL80211_IFTYPE_STATION: 1877 case NL80211_IFTYPE_STATION:
1845 if (sdata->wdev.wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS) { 1878 if (sdata->wdev.wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS) {
1846 bool tdls_peer = false; 1879 bool tdls_peer = false;
1847 1880
1848 rcu_read_lock();
1849 sta = sta_info_get(sdata, skb->data); 1881 sta = sta_info_get(sdata, skb->data);
1850 if (sta) { 1882 if (sta) {
1851 authorized = test_sta_flag(sta, 1883 authorized = test_sta_flag(sta,
@@ -1856,7 +1888,6 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1856 tdls_auth = test_sta_flag(sta, 1888 tdls_auth = test_sta_flag(sta,
1857 WLAN_STA_TDLS_PEER_AUTH); 1889 WLAN_STA_TDLS_PEER_AUTH);
1858 } 1890 }
1859 rcu_read_unlock();
1860 1891
1861 /* 1892 /*
1862 * If the TDLS link is enabled, send everything 1893 * If the TDLS link is enabled, send everything
@@ -1871,7 +1902,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1871 if (tdls_direct) { 1902 if (tdls_direct) {
1872 /* link during setup - throw out frames to peer */ 1903 /* link during setup - throw out frames to peer */
1873 if (!tdls_auth) 1904 if (!tdls_auth)
1874 goto fail; 1905 goto fail_rcu;
1875 1906
1876 /* DA SA BSSID */ 1907 /* DA SA BSSID */
1877 memcpy(hdr.addr1, skb->data, ETH_ALEN); 1908 memcpy(hdr.addr1, skb->data, ETH_ALEN);
@@ -1896,6 +1927,10 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1896 memcpy(hdr.addr3, skb->data, ETH_ALEN); 1927 memcpy(hdr.addr3, skb->data, ETH_ALEN);
1897 hdrlen = 24; 1928 hdrlen = 24;
1898 } 1929 }
1930 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
1931 if (!chanctx_conf)
1932 goto fail_rcu;
1933 band = chanctx_conf->channel->band;
1899 break; 1934 break;
1900 case NL80211_IFTYPE_ADHOC: 1935 case NL80211_IFTYPE_ADHOC:
1901 /* DA SA BSSID */ 1936 /* DA SA BSSID */
@@ -1903,9 +1938,13 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1903 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); 1938 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN);
1904 memcpy(hdr.addr3, sdata->u.ibss.bssid, ETH_ALEN); 1939 memcpy(hdr.addr3, sdata->u.ibss.bssid, ETH_ALEN);
1905 hdrlen = 24; 1940 hdrlen = 24;
1941 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
1942 if (!chanctx_conf)
1943 goto fail_rcu;
1944 band = chanctx_conf->channel->band;
1906 break; 1945 break;
1907 default: 1946 default:
1908 goto fail; 1947 goto fail_rcu;
1909 } 1948 }
1910 1949
1911 /* 1950 /*
@@ -1915,13 +1954,11 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1915 */ 1954 */
1916 multicast = is_multicast_ether_addr(hdr.addr1); 1955 multicast = is_multicast_ether_addr(hdr.addr1);
1917 if (!multicast) { 1956 if (!multicast) {
1918 rcu_read_lock();
1919 sta = sta_info_get(sdata, hdr.addr1); 1957 sta = sta_info_get(sdata, hdr.addr1);
1920 if (sta) { 1958 if (sta) {
1921 authorized = test_sta_flag(sta, WLAN_STA_AUTHORIZED); 1959 authorized = test_sta_flag(sta, WLAN_STA_AUTHORIZED);
1922 wme_sta = test_sta_flag(sta, WLAN_STA_WME); 1960 wme_sta = test_sta_flag(sta, WLAN_STA_WME);
1923 } 1961 }
1924 rcu_read_unlock();
1925 } 1962 }
1926 1963
1927 /* For mesh, the use of the QoS header is mandatory */ 1964 /* For mesh, the use of the QoS header is mandatory */
@@ -1949,7 +1986,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1949 1986
1950 I802_DEBUG_INC(local->tx_handlers_drop_unauth_port); 1987 I802_DEBUG_INC(local->tx_handlers_drop_unauth_port);
1951 1988
1952 goto fail; 1989 goto fail_rcu;
1953 } 1990 }
1954 1991
1955 if (unlikely(!multicast && skb->sk && 1992 if (unlikely(!multicast && skb->sk &&
@@ -2004,7 +2041,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
2004 kfree_skb(tmp_skb); 2041 kfree_skb(tmp_skb);
2005 2042
2006 if (!skb) 2043 if (!skb)
2007 goto fail; 2044 goto fail_rcu;
2008 } 2045 }
2009 2046
2010 hdr.frame_control = fc; 2047 hdr.frame_control = fc;
@@ -2052,7 +2089,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
2052 head_need = max_t(int, 0, head_need); 2089 head_need = max_t(int, 0, head_need);
2053 if (ieee80211_skb_resize(sdata, skb, head_need, true)) { 2090 if (ieee80211_skb_resize(sdata, skb, head_need, true)) {
2054 ieee80211_free_txskb(&local->hw, skb); 2091 ieee80211_free_txskb(&local->hw, skb);
2055 return NETDEV_TX_OK; 2092 goto fail_rcu;
2056 } 2093 }
2057 } 2094 }
2058 2095
@@ -2104,10 +2141,13 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
2104 info->flags = info_flags; 2141 info->flags = info_flags;
2105 info->ack_frame_id = info_id; 2142 info->ack_frame_id = info_id;
2106 2143
2107 ieee80211_xmit(sdata, skb); 2144 ieee80211_xmit(sdata, skb, band);
2145 rcu_read_unlock();
2108 2146
2109 return NETDEV_TX_OK; 2147 return NETDEV_TX_OK;
2110 2148
2149 fail_rcu:
2150 rcu_read_unlock();
2111 fail: 2151 fail:
2112 dev_kfree_skb(skb); 2152 dev_kfree_skb(skb);
2113 return NETDEV_TX_OK; 2153 return NETDEV_TX_OK;
@@ -2139,11 +2179,18 @@ static bool ieee80211_tx_pending_skb(struct ieee80211_local *local,
2139 struct sta_info *sta; 2179 struct sta_info *sta;
2140 struct ieee80211_hdr *hdr; 2180 struct ieee80211_hdr *hdr;
2141 bool result; 2181 bool result;
2182 struct ieee80211_chanctx_conf *chanctx_conf;
2142 2183
2143 sdata = vif_to_sdata(info->control.vif); 2184 sdata = vif_to_sdata(info->control.vif);
2144 2185
2145 if (info->flags & IEEE80211_TX_INTFL_NEED_TXPROCESSING) { 2186 if (info->flags & IEEE80211_TX_INTFL_NEED_TXPROCESSING) {
2146 result = ieee80211_tx(sdata, skb, true); 2187 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
2188 if (unlikely(!chanctx_conf)) {
2189 dev_kfree_skb(skb);
2190 return true;
2191 }
2192 result = ieee80211_tx(sdata, skb, true,
2193 chanctx_conf->channel->band);
2147 } else { 2194 } else {
2148 struct sk_buff_head skbs; 2195 struct sk_buff_head skbs;
2149 2196
@@ -2211,9 +2258,8 @@ void ieee80211_tx_pending(unsigned long data)
2211/* functions for drivers to get certain frames */ 2258/* functions for drivers to get certain frames */
2212 2259
2213static void ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata, 2260static void ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata,
2214 struct ieee80211_if_ap *bss, 2261 struct ps_data *ps,
2215 struct sk_buff *skb, 2262 struct sk_buff *skb)
2216 struct beacon_data *beacon)
2217{ 2263{
2218 u8 *pos, *tim; 2264 u8 *pos, *tim;
2219 int aid0 = 0; 2265 int aid0 = 0;
@@ -2221,27 +2267,27 @@ static void ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata,
2221 2267
2222 /* Generate bitmap for TIM only if there are any STAs in power save 2268 /* Generate bitmap for TIM only if there are any STAs in power save
2223 * mode. */ 2269 * mode. */
2224 if (atomic_read(&bss->num_sta_ps) > 0) 2270 if (atomic_read(&ps->num_sta_ps) > 0)
2225 /* in the hope that this is faster than 2271 /* in the hope that this is faster than
2226 * checking byte-for-byte */ 2272 * checking byte-for-byte */
2227 have_bits = !bitmap_empty((unsigned long*)bss->tim, 2273 have_bits = !bitmap_empty((unsigned long*)ps->tim,
2228 IEEE80211_MAX_AID+1); 2274 IEEE80211_MAX_AID+1);
2229 2275
2230 if (bss->dtim_count == 0) 2276 if (ps->dtim_count == 0)
2231 bss->dtim_count = sdata->vif.bss_conf.dtim_period - 1; 2277 ps->dtim_count = sdata->vif.bss_conf.dtim_period - 1;
2232 else 2278 else
2233 bss->dtim_count--; 2279 ps->dtim_count--;
2234 2280
2235 tim = pos = (u8 *) skb_put(skb, 6); 2281 tim = pos = (u8 *) skb_put(skb, 6);
2236 *pos++ = WLAN_EID_TIM; 2282 *pos++ = WLAN_EID_TIM;
2237 *pos++ = 4; 2283 *pos++ = 4;
2238 *pos++ = bss->dtim_count; 2284 *pos++ = ps->dtim_count;
2239 *pos++ = sdata->vif.bss_conf.dtim_period; 2285 *pos++ = sdata->vif.bss_conf.dtim_period;
2240 2286
2241 if (bss->dtim_count == 0 && !skb_queue_empty(&bss->ps_bc_buf)) 2287 if (ps->dtim_count == 0 && !skb_queue_empty(&ps->bc_buf))
2242 aid0 = 1; 2288 aid0 = 1;
2243 2289
2244 bss->dtim_bc_mc = aid0 == 1; 2290 ps->dtim_bc_mc = aid0 == 1;
2245 2291
2246 if (have_bits) { 2292 if (have_bits) {
2247 /* Find largest even number N1 so that bits numbered 1 through 2293 /* Find largest even number N1 so that bits numbered 1 through
@@ -2249,14 +2295,14 @@ static void ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata,
2249 * (N2 + 1) x 8 through 2007 are 0. */ 2295 * (N2 + 1) x 8 through 2007 are 0. */
2250 n1 = 0; 2296 n1 = 0;
2251 for (i = 0; i < IEEE80211_MAX_TIM_LEN; i++) { 2297 for (i = 0; i < IEEE80211_MAX_TIM_LEN; i++) {
2252 if (bss->tim[i]) { 2298 if (ps->tim[i]) {
2253 n1 = i & 0xfe; 2299 n1 = i & 0xfe;
2254 break; 2300 break;
2255 } 2301 }
2256 } 2302 }
2257 n2 = n1; 2303 n2 = n1;
2258 for (i = IEEE80211_MAX_TIM_LEN - 1; i >= n1; i--) { 2304 for (i = IEEE80211_MAX_TIM_LEN - 1; i >= n1; i--) {
2259 if (bss->tim[i]) { 2305 if (ps->tim[i]) {
2260 n2 = i; 2306 n2 = i;
2261 break; 2307 break;
2262 } 2308 }
@@ -2266,7 +2312,7 @@ static void ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata,
2266 *pos++ = n1 | aid0; 2312 *pos++ = n1 | aid0;
2267 /* Part Virt Bitmap */ 2313 /* Part Virt Bitmap */
2268 skb_put(skb, n2 - n1); 2314 skb_put(skb, n2 - n1);
2269 memcpy(pos, bss->tim + n1, n2 - n1 + 1); 2315 memcpy(pos, ps->tim + n1, n2 - n1 + 1);
2270 2316
2271 tim[1] = n2 - n1 + 4; 2317 tim[1] = n2 - n1 + 4;
2272 } else { 2318 } else {
@@ -2283,16 +2329,16 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
2283 struct sk_buff *skb = NULL; 2329 struct sk_buff *skb = NULL;
2284 struct ieee80211_tx_info *info; 2330 struct ieee80211_tx_info *info;
2285 struct ieee80211_sub_if_data *sdata = NULL; 2331 struct ieee80211_sub_if_data *sdata = NULL;
2286 struct ieee80211_if_ap *ap = NULL; 2332 enum ieee80211_band band;
2287 struct beacon_data *beacon;
2288 enum ieee80211_band band = local->oper_channel->band;
2289 struct ieee80211_tx_rate_control txrc; 2333 struct ieee80211_tx_rate_control txrc;
2334 struct ieee80211_chanctx_conf *chanctx_conf;
2290 2335
2291 rcu_read_lock(); 2336 rcu_read_lock();
2292 2337
2293 sdata = vif_to_sdata(vif); 2338 sdata = vif_to_sdata(vif);
2339 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
2294 2340
2295 if (!ieee80211_sdata_running(sdata)) 2341 if (!ieee80211_sdata_running(sdata) || !chanctx_conf)
2296 goto out; 2342 goto out;
2297 2343
2298 if (tim_offset) 2344 if (tim_offset)
@@ -2301,8 +2347,9 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
2301 *tim_length = 0; 2347 *tim_length = 0;
2302 2348
2303 if (sdata->vif.type == NL80211_IFTYPE_AP) { 2349 if (sdata->vif.type == NL80211_IFTYPE_AP) {
2304 ap = &sdata->u.ap; 2350 struct ieee80211_if_ap *ap = &sdata->u.ap;
2305 beacon = rcu_dereference(ap->beacon); 2351 struct beacon_data *beacon = rcu_dereference(ap->beacon);
2352
2306 if (beacon) { 2353 if (beacon) {
2307 /* 2354 /*
2308 * headroom, head length, 2355 * headroom, head length,
@@ -2326,14 +2373,12 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
2326 * of the tim bitmap in mac80211 and the driver. 2373 * of the tim bitmap in mac80211 and the driver.
2327 */ 2374 */
2328 if (local->tim_in_locked_section) { 2375 if (local->tim_in_locked_section) {
2329 ieee80211_beacon_add_tim(sdata, ap, skb, 2376 ieee80211_beacon_add_tim(sdata, &ap->ps, skb);
2330 beacon);
2331 } else { 2377 } else {
2332 unsigned long flags; 2378 unsigned long flags;
2333 2379
2334 spin_lock_irqsave(&local->tim_lock, flags); 2380 spin_lock_irqsave(&local->tim_lock, flags);
2335 ieee80211_beacon_add_tim(sdata, ap, skb, 2381 ieee80211_beacon_add_tim(sdata, &ap->ps, skb);
2336 beacon);
2337 spin_unlock_irqrestore(&local->tim_lock, flags); 2382 spin_unlock_irqrestore(&local->tim_lock, flags);
2338 } 2383 }
2339 2384
@@ -2409,6 +2454,8 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
2409 *pos++ = WLAN_EID_SSID; 2454 *pos++ = WLAN_EID_SSID;
2410 *pos++ = 0x0; 2455 *pos++ = 0x0;
2411 2456
2457 band = chanctx_conf->channel->band;
2458
2412 if (ieee80211_add_srates_ie(sdata, skb, true, band) || 2459 if (ieee80211_add_srates_ie(sdata, skb, true, band) ||
2413 mesh_add_ds_params_ie(skb, sdata) || 2460 mesh_add_ds_params_ie(skb, sdata) ||
2414 ieee80211_add_ext_srates_ie(sdata, skb, true, band) || 2461 ieee80211_add_ext_srates_ie(sdata, skb, true, band) ||
@@ -2426,6 +2473,8 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
2426 goto out; 2473 goto out;
2427 } 2474 }
2428 2475
2476 band = chanctx_conf->channel->band;
2477
2429 info = IEEE80211_SKB_CB(skb); 2478 info = IEEE80211_SKB_CB(skb);
2430 2479
2431 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; 2480 info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
@@ -2653,29 +2702,40 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw,
2653 struct sk_buff *skb = NULL; 2702 struct sk_buff *skb = NULL;
2654 struct ieee80211_tx_data tx; 2703 struct ieee80211_tx_data tx;
2655 struct ieee80211_sub_if_data *sdata; 2704 struct ieee80211_sub_if_data *sdata;
2656 struct ieee80211_if_ap *bss = NULL; 2705 struct ps_data *ps;
2657 struct beacon_data *beacon;
2658 struct ieee80211_tx_info *info; 2706 struct ieee80211_tx_info *info;
2707 struct ieee80211_chanctx_conf *chanctx_conf;
2659 2708
2660 sdata = vif_to_sdata(vif); 2709 sdata = vif_to_sdata(vif);
2661 bss = &sdata->u.ap;
2662 2710
2663 rcu_read_lock(); 2711 rcu_read_lock();
2664 beacon = rcu_dereference(bss->beacon); 2712 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
2665 2713
2666 if (sdata->vif.type != NL80211_IFTYPE_AP || !beacon || !beacon->head) 2714 if (!chanctx_conf)
2667 goto out; 2715 goto out;
2668 2716
2669 if (bss->dtim_count != 0 || !bss->dtim_bc_mc) 2717 if (sdata->vif.type == NL80211_IFTYPE_AP) {
2718 struct beacon_data *beacon =
2719 rcu_dereference(sdata->u.ap.beacon);
2720
2721 if (!beacon || !beacon->head)
2722 goto out;
2723
2724 ps = &sdata->u.ap.ps;
2725 } else {
2726 goto out;
2727 }
2728
2729 if (ps->dtim_count != 0 || !ps->dtim_bc_mc)
2670 goto out; /* send buffered bc/mc only after DTIM beacon */ 2730 goto out; /* send buffered bc/mc only after DTIM beacon */
2671 2731
2672 while (1) { 2732 while (1) {
2673 skb = skb_dequeue(&bss->ps_bc_buf); 2733 skb = skb_dequeue(&ps->bc_buf);
2674 if (!skb) 2734 if (!skb)
2675 goto out; 2735 goto out;
2676 local->total_ps_buffered--; 2736 local->total_ps_buffered--;
2677 2737
2678 if (!skb_queue_empty(&bss->ps_bc_buf) && skb->len >= 2) { 2738 if (!skb_queue_empty(&ps->bc_buf) && skb->len >= 2) {
2679 struct ieee80211_hdr *hdr = 2739 struct ieee80211_hdr *hdr =
2680 (struct ieee80211_hdr *) skb->data; 2740 (struct ieee80211_hdr *) skb->data;
2681 /* more buffered multicast/broadcast frames ==> set 2741 /* more buffered multicast/broadcast frames ==> set
@@ -2693,7 +2753,7 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw,
2693 info = IEEE80211_SKB_CB(skb); 2753 info = IEEE80211_SKB_CB(skb);
2694 2754
2695 tx.flags |= IEEE80211_TX_PS_BUFFERED; 2755 tx.flags |= IEEE80211_TX_PS_BUFFERED;
2696 info->band = local->oper_channel->band; 2756 info->band = chanctx_conf->channel->band;
2697 2757
2698 if (invoke_tx_handlers(&tx)) 2758 if (invoke_tx_handlers(&tx))
2699 skb = NULL; 2759 skb = NULL;
@@ -2704,8 +2764,9 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw,
2704} 2764}
2705EXPORT_SYMBOL(ieee80211_get_buffered_bc); 2765EXPORT_SYMBOL(ieee80211_get_buffered_bc);
2706 2766
2707void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata, 2767void __ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
2708 struct sk_buff *skb, int tid) 2768 struct sk_buff *skb, int tid,
2769 enum ieee80211_band band)
2709{ 2770{
2710 int ac = ieee802_1d_to_ac[tid & 7]; 2771 int ac = ieee802_1d_to_ac[tid & 7];
2711 2772
@@ -2722,6 +2783,6 @@ void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata,
2722 * requirements are that we do not come into tx with bhs on. 2783 * requirements are that we do not come into tx with bhs on.
2723 */ 2784 */
2724 local_bh_disable(); 2785 local_bh_disable();
2725 ieee80211_xmit(sdata, skb); 2786 ieee80211_xmit(sdata, skb, band);
2726 local_bh_enable(); 2787 local_bh_enable();
2727} 2788}
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 22ca35054dd0..51a4a2516233 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -741,6 +741,18 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len,
741 else 741 else
742 elem_parse_failed = true; 742 elem_parse_failed = true;
743 break; 743 break;
744 case WLAN_EID_VHT_CAPABILITY:
745 if (elen >= sizeof(struct ieee80211_vht_cap))
746 elems->vht_cap_elem = (void *)pos;
747 else
748 elem_parse_failed = true;
749 break;
750 case WLAN_EID_VHT_OPERATION:
751 if (elen >= sizeof(struct ieee80211_vht_operation))
752 elems->vht_operation = (void *)pos;
753 else
754 elem_parse_failed = true;
755 break;
744 case WLAN_EID_MESH_ID: 756 case WLAN_EID_MESH_ID:
745 elems->mesh_id = pos; 757 elems->mesh_id = pos;
746 elems->mesh_id_len = elen; 758 elems->mesh_id_len = elen;
@@ -832,6 +844,7 @@ void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata,
832{ 844{
833 struct ieee80211_local *local = sdata->local; 845 struct ieee80211_local *local = sdata->local;
834 struct ieee80211_tx_queue_params qparam; 846 struct ieee80211_tx_queue_params qparam;
847 struct ieee80211_chanctx_conf *chanctx_conf;
835 int ac; 848 int ac;
836 bool use_11b, enable_qos; 849 bool use_11b, enable_qos;
837 int aCWmin, aCWmax; 850 int aCWmin, aCWmax;
@@ -844,8 +857,12 @@ void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata,
844 857
845 memset(&qparam, 0, sizeof(qparam)); 858 memset(&qparam, 0, sizeof(qparam));
846 859
847 use_11b = (local->oper_channel->band == IEEE80211_BAND_2GHZ) && 860 rcu_read_lock();
861 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
862 use_11b = (chanctx_conf &&
863 chanctx_conf->channel->band == IEEE80211_BAND_2GHZ) &&
848 !(sdata->flags & IEEE80211_SDATA_OPERATING_GMODE); 864 !(sdata->flags & IEEE80211_SDATA_OPERATING_GMODE);
865 rcu_read_unlock();
849 866
850 /* 867 /*
851 * By default disable QoS in STA mode for old access points, which do 868 * By default disable QoS in STA mode for old access points, which do
@@ -924,7 +941,7 @@ void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata,
924 const size_t supp_rates_len, 941 const size_t supp_rates_len,
925 const u8 *supp_rates) 942 const u8 *supp_rates)
926{ 943{
927 struct ieee80211_local *local = sdata->local; 944 struct ieee80211_chanctx_conf *chanctx_conf;
928 int i, have_higher_than_11mbit = 0; 945 int i, have_higher_than_11mbit = 0;
929 946
930 /* cf. IEEE 802.11 9.2.12 */ 947 /* cf. IEEE 802.11 9.2.12 */
@@ -932,11 +949,16 @@ void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata,
932 if ((supp_rates[i] & 0x7f) * 5 > 110) 949 if ((supp_rates[i] & 0x7f) * 5 > 110)
933 have_higher_than_11mbit = 1; 950 have_higher_than_11mbit = 1;
934 951
935 if (local->oper_channel->band == IEEE80211_BAND_2GHZ && 952 rcu_read_lock();
953 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
954
955 if (chanctx_conf &&
956 chanctx_conf->channel->band == IEEE80211_BAND_2GHZ &&
936 have_higher_than_11mbit) 957 have_higher_than_11mbit)
937 sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE; 958 sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE;
938 else 959 else
939 sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE; 960 sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE;
961 rcu_read_unlock();
940 962
941 ieee80211_set_wmm_default(sdata, true); 963 ieee80211_set_wmm_default(sdata, true);
942} 964}
@@ -968,7 +990,7 @@ u32 ieee80211_mandatory_rates(struct ieee80211_local *local,
968} 990}
969 991
970void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, 992void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
971 u16 transaction, u16 auth_alg, 993 u16 transaction, u16 auth_alg, u16 status,
972 u8 *extra, size_t extra_len, const u8 *da, 994 u8 *extra, size_t extra_len, const u8 *da,
973 const u8 *bssid, const u8 *key, u8 key_len, u8 key_idx) 995 const u8 *bssid, const u8 *key, u8 key_len, u8 key_idx)
974{ 996{
@@ -993,7 +1015,7 @@ void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
993 memcpy(mgmt->bssid, bssid, ETH_ALEN); 1015 memcpy(mgmt->bssid, bssid, ETH_ALEN);
994 mgmt->u.auth.auth_alg = cpu_to_le16(auth_alg); 1016 mgmt->u.auth.auth_alg = cpu_to_le16(auth_alg);
995 mgmt->u.auth.auth_transaction = cpu_to_le16(transaction); 1017 mgmt->u.auth.auth_transaction = cpu_to_le16(transaction);
996 mgmt->u.auth.status_code = cpu_to_le16(0); 1018 mgmt->u.auth.status_code = cpu_to_le16(status);
997 if (extra) 1019 if (extra)
998 memcpy(skb_put(skb, extra_len), extra, extra_len); 1020 memcpy(skb_put(skb, extra_len), extra, extra_len);
999 1021
@@ -1206,7 +1228,7 @@ void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst,
1206 const u8 *ssid, size_t ssid_len, 1228 const u8 *ssid, size_t ssid_len,
1207 const u8 *ie, size_t ie_len, 1229 const u8 *ie, size_t ie_len,
1208 u32 ratemask, bool directed, bool no_cck, 1230 u32 ratemask, bool directed, bool no_cck,
1209 struct ieee80211_channel *channel) 1231 struct ieee80211_channel *channel, bool scan)
1210{ 1232{
1211 struct sk_buff *skb; 1233 struct sk_buff *skb;
1212 1234
@@ -1217,7 +1239,10 @@ void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst,
1217 if (no_cck) 1239 if (no_cck)
1218 IEEE80211_SKB_CB(skb)->flags |= 1240 IEEE80211_SKB_CB(skb)->flags |=
1219 IEEE80211_TX_CTL_NO_CCK_RATE; 1241 IEEE80211_TX_CTL_NO_CCK_RATE;
1220 ieee80211_tx_skb(sdata, skb); 1242 if (scan)
1243 ieee80211_tx_skb_tid_band(sdata, skb, 7, channel->band);
1244 else
1245 ieee80211_tx_skb(sdata, skb);
1221 } 1246 }
1222} 1247}
1223 1248
@@ -1280,6 +1305,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
1280{ 1305{
1281 struct ieee80211_hw *hw = &local->hw; 1306 struct ieee80211_hw *hw = &local->hw;
1282 struct ieee80211_sub_if_data *sdata; 1307 struct ieee80211_sub_if_data *sdata;
1308 struct ieee80211_chanctx *ctx;
1283 struct sta_info *sta; 1309 struct sta_info *sta;
1284 int res, i; 1310 int res, i;
1285 1311
@@ -1352,6 +1378,12 @@ int ieee80211_reconfig(struct ieee80211_local *local)
1352 res = drv_add_interface(local, sdata); 1378 res = drv_add_interface(local, sdata);
1353 } 1379 }
1354 1380
1381 /* add channel contexts */
1382 mutex_lock(&local->chanctx_mtx);
1383 list_for_each_entry(ctx, &local->chanctx_list, list)
1384 WARN_ON(drv_add_chanctx(local, ctx));
1385 mutex_unlock(&local->chanctx_mtx);
1386
1355 /* add STAs back */ 1387 /* add STAs back */
1356 mutex_lock(&local->sta_mtx); 1388 mutex_lock(&local->sta_mtx);
1357 list_for_each_entry(sta, &local->sta_list, list) { 1389 list_for_each_entry(sta, &local->sta_list, list) {
@@ -1392,11 +1424,22 @@ int ieee80211_reconfig(struct ieee80211_local *local)
1392 1424
1393 /* Finally also reconfigure all the BSS information */ 1425 /* Finally also reconfigure all the BSS information */
1394 list_for_each_entry(sdata, &local->interfaces, list) { 1426 list_for_each_entry(sdata, &local->interfaces, list) {
1427 struct ieee80211_chanctx_conf *ctx_conf;
1395 u32 changed; 1428 u32 changed;
1396 1429
1397 if (!ieee80211_sdata_running(sdata)) 1430 if (!ieee80211_sdata_running(sdata))
1398 continue; 1431 continue;
1399 1432
1433 mutex_lock(&local->chanctx_mtx);
1434 ctx_conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
1435 lockdep_is_held(&local->chanctx_mtx));
1436 if (ctx_conf) {
1437 ctx = container_of(ctx_conf, struct ieee80211_chanctx,
1438 conf);
1439 drv_assign_vif_chanctx(local, sdata, ctx);
1440 }
1441 mutex_unlock(&local->chanctx_mtx);
1442
1400 /* common change flags for all interface types */ 1443 /* common change flags for all interface types */
1401 changed = BSS_CHANGED_ERP_CTS_PROT | 1444 changed = BSS_CHANGED_ERP_CTS_PROT |
1402 BSS_CHANGED_ERP_PREAMBLE | 1445 BSS_CHANGED_ERP_PREAMBLE |
@@ -1587,68 +1630,24 @@ void ieee80211_resume_disconnect(struct ieee80211_vif *vif)
1587} 1630}
1588EXPORT_SYMBOL_GPL(ieee80211_resume_disconnect); 1631EXPORT_SYMBOL_GPL(ieee80211_resume_disconnect);
1589 1632
1590static int check_mgd_smps(struct ieee80211_if_managed *ifmgd, 1633void ieee80211_recalc_smps(struct ieee80211_sub_if_data *sdata)
1591 enum ieee80211_smps_mode *smps_mode)
1592{
1593 if (ifmgd->associated) {
1594 *smps_mode = ifmgd->ap_smps;
1595
1596 if (*smps_mode == IEEE80211_SMPS_AUTOMATIC) {
1597 if (ifmgd->powersave)
1598 *smps_mode = IEEE80211_SMPS_DYNAMIC;
1599 else
1600 *smps_mode = IEEE80211_SMPS_OFF;
1601 }
1602
1603 return 1;
1604 }
1605
1606 return 0;
1607}
1608
1609void ieee80211_recalc_smps(struct ieee80211_local *local)
1610{ 1634{
1611 struct ieee80211_sub_if_data *sdata; 1635 struct ieee80211_local *local = sdata->local;
1612 enum ieee80211_smps_mode smps_mode = IEEE80211_SMPS_OFF; 1636 struct ieee80211_chanctx_conf *chanctx_conf;
1613 int count = 0; 1637 struct ieee80211_chanctx *chanctx;
1614
1615 mutex_lock(&local->iflist_mtx);
1616
1617 /*
1618 * This function could be improved to handle multiple
1619 * interfaces better, but right now it makes any
1620 * non-station interfaces force SM PS to be turned
1621 * off. If there are multiple station interfaces it
1622 * could also use the best possible mode, e.g. if
1623 * one is in static and the other in dynamic then
1624 * dynamic is ok.
1625 */
1626
1627 list_for_each_entry(sdata, &local->interfaces, list) {
1628 if (!ieee80211_sdata_running(sdata))
1629 continue;
1630 if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE)
1631 continue;
1632 if (sdata->vif.type != NL80211_IFTYPE_STATION)
1633 goto set;
1634 1638
1635 count += check_mgd_smps(&sdata->u.mgd, &smps_mode); 1639 mutex_lock(&local->chanctx_mtx);
1636 1640
1637 if (count > 1) { 1641 chanctx_conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
1638 smps_mode = IEEE80211_SMPS_OFF; 1642 lockdep_is_held(&local->chanctx_mtx));
1639 break;
1640 }
1641 }
1642 1643
1643 if (smps_mode == local->smps_mode) 1644 if (WARN_ON_ONCE(!chanctx_conf))
1644 goto unlock; 1645 goto unlock;
1645 1646
1646 set: 1647 chanctx = container_of(chanctx_conf, struct ieee80211_chanctx, conf);
1647 local->smps_mode = smps_mode; 1648 ieee80211_recalc_smps_chanctx(local, chanctx);
1648 /* changed flag is auto-detected for this */
1649 ieee80211_hw_config(local, 0);
1650 unlock: 1649 unlock:
1651 mutex_unlock(&local->iflist_mtx); 1650 mutex_unlock(&local->chanctx_mtx);
1652} 1651}
1653 1652
1654static bool ieee80211_id_in_list(const u8 *ids, int n_ids, u8 id) 1653static bool ieee80211_id_in_list(const u8 *ids, int n_ids, u8 id)
@@ -1788,8 +1787,8 @@ u8 *ieee80211_ie_build_vht_cap(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap,
1788 __le32 tmp; 1787 __le32 tmp;
1789 1788
1790 *pos++ = WLAN_EID_VHT_CAPABILITY; 1789 *pos++ = WLAN_EID_VHT_CAPABILITY;
1791 *pos++ = sizeof(struct ieee80211_vht_capabilities); 1790 *pos++ = sizeof(struct ieee80211_vht_cap);
1792 memset(pos, 0, sizeof(struct ieee80211_vht_capabilities)); 1791 memset(pos, 0, sizeof(struct ieee80211_vht_cap));
1793 1792
1794 /* capability flags */ 1793 /* capability flags */
1795 tmp = cpu_to_le32(cap); 1794 tmp = cpu_to_le32(cap);
@@ -1947,3 +1946,19 @@ int ieee80211_ave_rssi(struct ieee80211_vif *vif)
1947 return ifmgd->ave_beacon_signal; 1946 return ifmgd->ave_beacon_signal;
1948} 1947}
1949EXPORT_SYMBOL_GPL(ieee80211_ave_rssi); 1948EXPORT_SYMBOL_GPL(ieee80211_ave_rssi);
1949
1950u8 ieee80211_mcs_to_chains(const struct ieee80211_mcs_info *mcs)
1951{
1952 if (!mcs)
1953 return 1;
1954
1955 /* TODO: consider rx_highest */
1956
1957 if (mcs->rx_mask[3])
1958 return 4;
1959 if (mcs->rx_mask[2])
1960 return 3;
1961 if (mcs->rx_mask[1])
1962 return 2;
1963 return 1;
1964}
diff --git a/net/mac80211/vht.c b/net/mac80211/vht.c
new file mode 100644
index 000000000000..f311388aeedf
--- /dev/null
+++ b/net/mac80211/vht.c
@@ -0,0 +1,35 @@
1/*
2 * VHT handling
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#include <linux/ieee80211.h>
10#include <linux/export.h>
11#include <net/mac80211.h>
12#include "ieee80211_i.h"
13
14
15void ieee80211_vht_cap_ie_to_sta_vht_cap(struct ieee80211_sub_if_data *sdata,
16 struct ieee80211_supported_band *sband,
17 struct ieee80211_vht_cap *vht_cap_ie,
18 struct ieee80211_sta_vht_cap *vht_cap)
19{
20 if (WARN_ON_ONCE(!vht_cap))
21 return;
22
23 memset(vht_cap, 0, sizeof(*vht_cap));
24
25 if (!vht_cap_ie || !sband->vht_cap.vht_supported)
26 return;
27
28 vht_cap->vht_supported = true;
29
30 vht_cap->cap = le32_to_cpu(vht_cap_ie->vht_cap_info);
31
32 /* Copy peer MCS info, the driver might need them. */
33 memcpy(&vht_cap->vht_mcs, &vht_cap_ie->supp_mcs,
34 sizeof(struct ieee80211_vht_mcs_info));
35}
diff --git a/net/wireless/Makefile b/net/wireless/Makefile
index 0f7e0d621ab0..a761670af31d 100644
--- a/net/wireless/Makefile
+++ b/net/wireless/Makefile
@@ -10,11 +10,13 @@ obj-$(CONFIG_WEXT_SPY) += wext-spy.o
10obj-$(CONFIG_WEXT_PRIV) += wext-priv.o 10obj-$(CONFIG_WEXT_PRIV) += wext-priv.o
11 11
12cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o scan.o nl80211.o 12cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o scan.o nl80211.o
13cfg80211-y += mlme.o ibss.o sme.o chan.o ethtool.o mesh.o ap.o 13cfg80211-y += mlme.o ibss.o sme.o chan.o ethtool.o mesh.o ap.o trace.o
14cfg80211-$(CONFIG_CFG80211_DEBUGFS) += debugfs.o 14cfg80211-$(CONFIG_CFG80211_DEBUGFS) += debugfs.o
15cfg80211-$(CONFIG_CFG80211_WEXT) += wext-compat.o wext-sme.o 15cfg80211-$(CONFIG_CFG80211_WEXT) += wext-compat.o wext-sme.o
16cfg80211-$(CONFIG_CFG80211_INTERNAL_REGDB) += regdb.o 16cfg80211-$(CONFIG_CFG80211_INTERNAL_REGDB) += regdb.o
17 17
18CFLAGS_trace.o := -I$(src)
19
18ccflags-y += -D__CHECK_ENDIAN__ 20ccflags-y += -D__CHECK_ENDIAN__
19 21
20$(obj)/regdb.c: $(src)/db.txt $(src)/genregdb.awk 22$(obj)/regdb.c: $(src)/db.txt $(src)/genregdb.awk
diff --git a/net/wireless/ap.c b/net/wireless/ap.c
index fcc60d8dbefa..e143505f05bc 100644
--- a/net/wireless/ap.c
+++ b/net/wireless/ap.c
@@ -3,6 +3,7 @@
3#include <net/cfg80211.h> 3#include <net/cfg80211.h>
4#include "nl80211.h" 4#include "nl80211.h"
5#include "core.h" 5#include "core.h"
6#include "rdev-ops.h"
6 7
7 8
8static int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev, 9static int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev,
@@ -23,7 +24,7 @@ static int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev,
23 if (!wdev->beacon_interval) 24 if (!wdev->beacon_interval)
24 return -ENOENT; 25 return -ENOENT;
25 26
26 err = rdev->ops->stop_ap(&rdev->wiphy, dev); 27 err = rdev_stop_ap(rdev, dev);
27 if (!err) { 28 if (!err) {
28 wdev->beacon_interval = 0; 29 wdev->beacon_interval = 0;
29 wdev->channel = NULL; 30 wdev->channel = NULL;
diff --git a/net/wireless/chan.c b/net/wireless/chan.c
index 2f876b9ee344..48febd2160ba 100644
--- a/net/wireless/chan.c
+++ b/net/wireless/chan.c
@@ -9,6 +9,7 @@
9#include <linux/export.h> 9#include <linux/export.h>
10#include <net/cfg80211.h> 10#include <net/cfg80211.h>
11#include "core.h" 11#include "core.h"
12#include "rdev-ops.h"
12 13
13struct ieee80211_channel * 14struct ieee80211_channel *
14rdev_freq_to_chan(struct cfg80211_registered_device *rdev, 15rdev_freq_to_chan(struct cfg80211_registered_device *rdev,
@@ -52,6 +53,8 @@ bool cfg80211_can_beacon_sec_chan(struct wiphy *wiphy,
52 struct ieee80211_channel *sec_chan; 53 struct ieee80211_channel *sec_chan;
53 int diff; 54 int diff;
54 55
56 trace_cfg80211_can_beacon_sec_chan(wiphy, chan, channel_type);
57
55 switch (channel_type) { 58 switch (channel_type) {
56 case NL80211_CHAN_HT40PLUS: 59 case NL80211_CHAN_HT40PLUS:
57 diff = 20; 60 diff = 20;
@@ -60,20 +63,25 @@ bool cfg80211_can_beacon_sec_chan(struct wiphy *wiphy,
60 diff = -20; 63 diff = -20;
61 break; 64 break;
62 default: 65 default:
66 trace_cfg80211_return_bool(true);
63 return true; 67 return true;
64 } 68 }
65 69
66 sec_chan = ieee80211_get_channel(wiphy, chan->center_freq + diff); 70 sec_chan = ieee80211_get_channel(wiphy, chan->center_freq + diff);
67 if (!sec_chan) 71 if (!sec_chan) {
72 trace_cfg80211_return_bool(false);
68 return false; 73 return false;
74 }
69 75
70 /* we'll need a DFS capability later */ 76 /* we'll need a DFS capability later */
71 if (sec_chan->flags & (IEEE80211_CHAN_DISABLED | 77 if (sec_chan->flags & (IEEE80211_CHAN_DISABLED |
72 IEEE80211_CHAN_PASSIVE_SCAN | 78 IEEE80211_CHAN_PASSIVE_SCAN |
73 IEEE80211_CHAN_NO_IBSS | 79 IEEE80211_CHAN_NO_IBSS |
74 IEEE80211_CHAN_RADAR)) 80 IEEE80211_CHAN_RADAR)) {
81 trace_cfg80211_return_bool(false);
75 return false; 82 return false;
76 83 }
84 trace_cfg80211_return_bool(true);
77 return true; 85 return true;
78} 86}
79EXPORT_SYMBOL(cfg80211_can_beacon_sec_chan); 87EXPORT_SYMBOL(cfg80211_can_beacon_sec_chan);
@@ -92,7 +100,7 @@ int cfg80211_set_monitor_channel(struct cfg80211_registered_device *rdev,
92 if (!chan) 100 if (!chan)
93 return -EINVAL; 101 return -EINVAL;
94 102
95 return rdev->ops->set_monitor_channel(&rdev->wiphy, chan, chantype); 103 return rdev_set_monitor_channel(rdev, chan, chantype);
96} 104}
97 105
98void 106void
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 443d4d7deea2..f280f48fbd43 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -26,6 +26,7 @@
26#include "debugfs.h" 26#include "debugfs.h"
27#include "wext-compat.h" 27#include "wext-compat.h"
28#include "ethtool.h" 28#include "ethtool.h"
29#include "rdev-ops.h"
29 30
30/* name for sysfs, %d is appended */ 31/* name for sysfs, %d is appended */
31#define PHY_NAME "phy" 32#define PHY_NAME "phy"
@@ -216,7 +217,7 @@ static void cfg80211_rfkill_poll(struct rfkill *rfkill, void *data)
216{ 217{
217 struct cfg80211_registered_device *rdev = data; 218 struct cfg80211_registered_device *rdev = data;
218 219
219 rdev->ops->rfkill_poll(&rdev->wiphy); 220 rdev_rfkill_poll(rdev);
220} 221}
221 222
222static int cfg80211_rfkill_set_block(void *data, bool blocked) 223static int cfg80211_rfkill_set_block(void *data, bool blocked)
@@ -370,6 +371,8 @@ struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv)
370 rdev->wiphy.rts_threshold = (u32) -1; 371 rdev->wiphy.rts_threshold = (u32) -1;
371 rdev->wiphy.coverage_class = 0; 372 rdev->wiphy.coverage_class = 0;
372 373
374 rdev->wiphy.features = NL80211_FEATURE_SCAN_FLUSH;
375
373 return &rdev->wiphy; 376 return &rdev->wiphy;
374} 377}
375EXPORT_SYMBOL(wiphy_new); 378EXPORT_SYMBOL(wiphy_new);
@@ -688,7 +691,7 @@ void wiphy_unregister(struct wiphy *wiphy)
688 flush_work(&rdev->event_work); 691 flush_work(&rdev->event_work);
689 692
690 if (rdev->wowlan && rdev->ops->set_wakeup) 693 if (rdev->wowlan && rdev->ops->set_wakeup)
691 rdev->ops->set_wakeup(&rdev->wiphy, false); 694 rdev_set_wakeup(rdev, false);
692 cfg80211_rdev_free_wowlan(rdev); 695 cfg80211_rdev_free_wowlan(rdev);
693} 696}
694EXPORT_SYMBOL(wiphy_unregister); 697EXPORT_SYMBOL(wiphy_unregister);
@@ -962,9 +965,8 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
962 if ((wdev->iftype == NL80211_IFTYPE_STATION || 965 if ((wdev->iftype == NL80211_IFTYPE_STATION ||
963 wdev->iftype == NL80211_IFTYPE_P2P_CLIENT) && 966 wdev->iftype == NL80211_IFTYPE_P2P_CLIENT) &&
964 rdev->ops->set_power_mgmt) 967 rdev->ops->set_power_mgmt)
965 if (rdev->ops->set_power_mgmt(wdev->wiphy, dev, 968 if (rdev_set_power_mgmt(rdev, dev, wdev->ps,
966 wdev->ps, 969 wdev->ps_timeout)) {
967 wdev->ps_timeout)) {
968 /* assume this means it's off */ 970 /* assume this means it's off */
969 wdev->ps = false; 971 wdev->ps = false;
970 } 972 }
diff --git a/net/wireless/core.h b/net/wireless/core.h
index a343be4a52bd..b8eb743fe7da 100644
--- a/net/wireless/core.h
+++ b/net/wireless/core.h
@@ -320,13 +320,15 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
320 const u8 *bssid, 320 const u8 *bssid,
321 const u8 *ssid, int ssid_len, 321 const u8 *ssid, int ssid_len,
322 const u8 *ie, int ie_len, 322 const u8 *ie, int ie_len,
323 const u8 *key, int key_len, int key_idx); 323 const u8 *key, int key_len, int key_idx,
324 const u8 *sae_data, int sae_data_len);
324int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, 325int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
325 struct net_device *dev, struct ieee80211_channel *chan, 326 struct net_device *dev, struct ieee80211_channel *chan,
326 enum nl80211_auth_type auth_type, const u8 *bssid, 327 enum nl80211_auth_type auth_type, const u8 *bssid,
327 const u8 *ssid, int ssid_len, 328 const u8 *ssid, int ssid_len,
328 const u8 *ie, int ie_len, 329 const u8 *ie, int ie_len,
329 const u8 *key, int key_len, int key_idx); 330 const u8 *key, int key_len, int key_idx,
331 const u8 *sae_data, int sae_data_len);
330int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, 332int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
331 struct net_device *dev, 333 struct net_device *dev,
332 struct ieee80211_channel *chan, 334 struct ieee80211_channel *chan,
diff --git a/net/wireless/ethtool.c b/net/wireless/ethtool.c
index 7eecdf40cf80..48c48ffafa1d 100644
--- a/net/wireless/ethtool.c
+++ b/net/wireless/ethtool.c
@@ -2,6 +2,7 @@
2#include <net/cfg80211.h> 2#include <net/cfg80211.h>
3#include "core.h" 3#include "core.h"
4#include "ethtool.h" 4#include "ethtool.h"
5#include "rdev-ops.h"
5 6
6static void cfg80211_get_drvinfo(struct net_device *dev, 7static void cfg80211_get_drvinfo(struct net_device *dev,
7 struct ethtool_drvinfo *info) 8 struct ethtool_drvinfo *info)
@@ -47,9 +48,8 @@ static void cfg80211_get_ringparam(struct net_device *dev,
47 memset(rp, 0, sizeof(*rp)); 48 memset(rp, 0, sizeof(*rp));
48 49
49 if (rdev->ops->get_ringparam) 50 if (rdev->ops->get_ringparam)
50 rdev->ops->get_ringparam(wdev->wiphy, 51 rdev_get_ringparam(rdev, &rp->tx_pending, &rp->tx_max_pending,
51 &rp->tx_pending, &rp->tx_max_pending, 52 &rp->rx_pending, &rp->rx_max_pending);
52 &rp->rx_pending, &rp->rx_max_pending);
53} 53}
54 54
55static int cfg80211_set_ringparam(struct net_device *dev, 55static int cfg80211_set_ringparam(struct net_device *dev,
@@ -62,8 +62,7 @@ static int cfg80211_set_ringparam(struct net_device *dev,
62 return -EINVAL; 62 return -EINVAL;
63 63
64 if (rdev->ops->set_ringparam) 64 if (rdev->ops->set_ringparam)
65 return rdev->ops->set_ringparam(wdev->wiphy, 65 return rdev_set_ringparam(rdev, rp->tx_pending, rp->rx_pending);
66 rp->tx_pending, rp->rx_pending);
67 66
68 return -ENOTSUPP; 67 return -ENOTSUPP;
69} 68}
@@ -73,7 +72,7 @@ static int cfg80211_get_sset_count(struct net_device *dev, int sset)
73 struct wireless_dev *wdev = dev->ieee80211_ptr; 72 struct wireless_dev *wdev = dev->ieee80211_ptr;
74 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); 73 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
75 if (rdev->ops->get_et_sset_count) 74 if (rdev->ops->get_et_sset_count)
76 return rdev->ops->get_et_sset_count(wdev->wiphy, dev, sset); 75 return rdev_get_et_sset_count(rdev, dev, sset);
77 return -EOPNOTSUPP; 76 return -EOPNOTSUPP;
78} 77}
79 78
@@ -83,7 +82,7 @@ static void cfg80211_get_stats(struct net_device *dev,
83 struct wireless_dev *wdev = dev->ieee80211_ptr; 82 struct wireless_dev *wdev = dev->ieee80211_ptr;
84 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); 83 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
85 if (rdev->ops->get_et_stats) 84 if (rdev->ops->get_et_stats)
86 rdev->ops->get_et_stats(wdev->wiphy, dev, stats, data); 85 rdev_get_et_stats(rdev, dev, stats, data);
87} 86}
88 87
89static void cfg80211_get_strings(struct net_device *dev, u32 sset, u8 *data) 88static void cfg80211_get_strings(struct net_device *dev, u32 sset, u8 *data)
@@ -91,7 +90,7 @@ static void cfg80211_get_strings(struct net_device *dev, u32 sset, u8 *data)
91 struct wireless_dev *wdev = dev->ieee80211_ptr; 90 struct wireless_dev *wdev = dev->ieee80211_ptr;
92 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); 91 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
93 if (rdev->ops->get_et_strings) 92 if (rdev->ops->get_et_strings)
94 rdev->ops->get_et_strings(wdev->wiphy, dev, sset, data); 93 rdev_get_et_strings(rdev, dev, sset, data);
95} 94}
96 95
97const struct ethtool_ops cfg80211_ethtool_ops = { 96const struct ethtool_ops cfg80211_ethtool_ops = {
diff --git a/net/wireless/ibss.c b/net/wireless/ibss.c
index ca5672f6ee2f..27941d5db72b 100644
--- a/net/wireless/ibss.c
+++ b/net/wireless/ibss.c
@@ -11,6 +11,7 @@
11#include <net/cfg80211.h> 11#include <net/cfg80211.h>
12#include "wext-compat.h" 12#include "wext-compat.h"
13#include "nl80211.h" 13#include "nl80211.h"
14#include "rdev-ops.h"
14 15
15 16
16void __cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid) 17void __cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid)
@@ -61,6 +62,8 @@ void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid, gfp_t gfp)
61 struct cfg80211_event *ev; 62 struct cfg80211_event *ev;
62 unsigned long flags; 63 unsigned long flags;
63 64
65 trace_cfg80211_ibss_joined(dev, bssid);
66
64 CFG80211_DEV_WARN_ON(wdev->sme_state != CFG80211_SME_CONNECTING); 67 CFG80211_DEV_WARN_ON(wdev->sme_state != CFG80211_SME_CONNECTING);
65 68
66 ev = kzalloc(sizeof(*ev), gfp); 69 ev = kzalloc(sizeof(*ev), gfp);
@@ -128,7 +131,7 @@ int __cfg80211_join_ibss(struct cfg80211_registered_device *rdev,
128 return err; 131 return err;
129 } 132 }
130 133
131 err = rdev->ops->join_ibss(&rdev->wiphy, dev, params); 134 err = rdev_join_ibss(rdev, dev, params);
132 if (err) { 135 if (err) {
133 wdev->connect_keys = NULL; 136 wdev->connect_keys = NULL;
134 wdev->sme_state = CFG80211_SME_IDLE; 137 wdev->sme_state = CFG80211_SME_IDLE;
@@ -175,7 +178,7 @@ static void __cfg80211_clear_ibss(struct net_device *dev, bool nowext)
175 */ 178 */
176 if (rdev->ops->del_key) 179 if (rdev->ops->del_key)
177 for (i = 0; i < 6; i++) 180 for (i = 0; i < 6; i++)
178 rdev->ops->del_key(wdev->wiphy, dev, i, false, NULL); 181 rdev_del_key(rdev, dev, i, false, NULL);
179 182
180 if (wdev->current_bss) { 183 if (wdev->current_bss) {
181 cfg80211_unhold_bss(wdev->current_bss); 184 cfg80211_unhold_bss(wdev->current_bss);
@@ -211,7 +214,7 @@ int __cfg80211_leave_ibss(struct cfg80211_registered_device *rdev,
211 if (!wdev->ssid_len) 214 if (!wdev->ssid_len)
212 return -ENOLINK; 215 return -ENOLINK;
213 216
214 err = rdev->ops->leave_ibss(&rdev->wiphy, dev); 217 err = rdev_leave_ibss(rdev, dev);
215 218
216 if (err) 219 if (err)
217 return err; 220 return err;
diff --git a/net/wireless/mesh.c b/net/wireless/mesh.c
index c384e77ff77a..966cfc4cd79d 100644
--- a/net/wireless/mesh.c
+++ b/net/wireless/mesh.c
@@ -3,6 +3,7 @@
3#include <net/cfg80211.h> 3#include <net/cfg80211.h>
4#include "nl80211.h" 4#include "nl80211.h"
5#include "core.h" 5#include "core.h"
6#include "rdev-ops.h"
6 7
7/* Default values, timeouts in ms */ 8/* Default values, timeouts in ms */
8#define MESH_TTL 31 9#define MESH_TTL 31
@@ -160,7 +161,7 @@ int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev,
160 if (err) 161 if (err)
161 return err; 162 return err;
162 163
163 err = rdev->ops->join_mesh(&rdev->wiphy, dev, conf, setup); 164 err = rdev_join_mesh(rdev, dev, conf, setup);
164 if (!err) { 165 if (!err) {
165 memcpy(wdev->ssid, setup->mesh_id, setup->mesh_id_len); 166 memcpy(wdev->ssid, setup->mesh_id, setup->mesh_id_len);
166 wdev->mesh_id_len = setup->mesh_id_len; 167 wdev->mesh_id_len = setup->mesh_id_len;
@@ -220,9 +221,8 @@ int cfg80211_set_mesh_freq(struct cfg80211_registered_device *rdev,
220 if (err) 221 if (err)
221 return err; 222 return err;
222 223
223 err = rdev->ops->libertas_set_mesh_channel(&rdev->wiphy, 224 err = rdev_libertas_set_mesh_channel(rdev, wdev->netdev,
224 wdev->netdev, 225 channel);
225 channel);
226 if (!err) 226 if (!err)
227 wdev->channel = channel; 227 wdev->channel = channel;
228 228
@@ -242,6 +242,7 @@ void cfg80211_notify_new_peer_candidate(struct net_device *dev,
242{ 242{
243 struct wireless_dev *wdev = dev->ieee80211_ptr; 243 struct wireless_dev *wdev = dev->ieee80211_ptr;
244 244
245 trace_cfg80211_notify_new_peer_candidate(dev, macaddr);
245 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_MESH_POINT)) 246 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_MESH_POINT))
246 return; 247 return;
247 248
@@ -267,7 +268,7 @@ static int __cfg80211_leave_mesh(struct cfg80211_registered_device *rdev,
267 if (!wdev->mesh_id_len) 268 if (!wdev->mesh_id_len)
268 return -ENOTCONN; 269 return -ENOTCONN;
269 270
270 err = rdev->ops->leave_mesh(&rdev->wiphy, dev); 271 err = rdev_leave_mesh(rdev, dev);
271 if (!err) { 272 if (!err) {
272 wdev->mesh_id_len = 0; 273 wdev->mesh_id_len = 0;
273 wdev->channel = NULL; 274 wdev->channel = NULL;
diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c
index 8016fee0752b..46aeafce08d0 100644
--- a/net/wireless/mlme.c
+++ b/net/wireless/mlme.c
@@ -15,6 +15,8 @@
15#include <net/iw_handler.h> 15#include <net/iw_handler.h>
16#include "core.h" 16#include "core.h"
17#include "nl80211.h" 17#include "nl80211.h"
18#include "rdev-ops.h"
19
18 20
19void cfg80211_send_rx_auth(struct net_device *dev, const u8 *buf, size_t len) 21void cfg80211_send_rx_auth(struct net_device *dev, const u8 *buf, size_t len)
20{ 22{
@@ -22,6 +24,7 @@ void cfg80211_send_rx_auth(struct net_device *dev, const u8 *buf, size_t len)
22 struct wiphy *wiphy = wdev->wiphy; 24 struct wiphy *wiphy = wdev->wiphy;
23 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 25 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
24 26
27 trace_cfg80211_send_rx_auth(dev);
25 wdev_lock(wdev); 28 wdev_lock(wdev);
26 29
27 nl80211_send_rx_auth(rdev, dev, buf, len, GFP_KERNEL); 30 nl80211_send_rx_auth(rdev, dev, buf, len, GFP_KERNEL);
@@ -42,6 +45,7 @@ void cfg80211_send_rx_assoc(struct net_device *dev, struct cfg80211_bss *bss,
42 u8 *ie = mgmt->u.assoc_resp.variable; 45 u8 *ie = mgmt->u.assoc_resp.variable;
43 int ieoffs = offsetof(struct ieee80211_mgmt, u.assoc_resp.variable); 46 int ieoffs = offsetof(struct ieee80211_mgmt, u.assoc_resp.variable);
44 47
48 trace_cfg80211_send_rx_assoc(dev, bss);
45 wdev_lock(wdev); 49 wdev_lock(wdev);
46 50
47 status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code); 51 status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code);
@@ -98,6 +102,7 @@ void __cfg80211_send_deauth(struct net_device *dev,
98 const u8 *bssid = mgmt->bssid; 102 const u8 *bssid = mgmt->bssid;
99 bool was_current = false; 103 bool was_current = false;
100 104
105 trace___cfg80211_send_deauth(dev);
101 ASSERT_WDEV_LOCK(wdev); 106 ASSERT_WDEV_LOCK(wdev);
102 107
103 if (wdev->current_bss && 108 if (wdev->current_bss &&
@@ -147,6 +152,7 @@ void __cfg80211_send_disassoc(struct net_device *dev,
147 u16 reason_code; 152 u16 reason_code;
148 bool from_ap; 153 bool from_ap;
149 154
155 trace___cfg80211_send_disassoc(dev);
150 ASSERT_WDEV_LOCK(wdev); 156 ASSERT_WDEV_LOCK(wdev);
151 157
152 nl80211_send_disassoc(rdev, dev, buf, len, GFP_KERNEL); 158 nl80211_send_disassoc(rdev, dev, buf, len, GFP_KERNEL);
@@ -188,6 +194,7 @@ void cfg80211_send_unprot_deauth(struct net_device *dev, const u8 *buf,
188 struct wiphy *wiphy = wdev->wiphy; 194 struct wiphy *wiphy = wdev->wiphy;
189 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 195 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
190 196
197 trace_cfg80211_send_unprot_deauth(dev);
191 nl80211_send_unprot_deauth(rdev, dev, buf, len, GFP_ATOMIC); 198 nl80211_send_unprot_deauth(rdev, dev, buf, len, GFP_ATOMIC);
192} 199}
193EXPORT_SYMBOL(cfg80211_send_unprot_deauth); 200EXPORT_SYMBOL(cfg80211_send_unprot_deauth);
@@ -199,6 +206,7 @@ void cfg80211_send_unprot_disassoc(struct net_device *dev, const u8 *buf,
199 struct wiphy *wiphy = wdev->wiphy; 206 struct wiphy *wiphy = wdev->wiphy;
200 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 207 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
201 208
209 trace_cfg80211_send_unprot_disassoc(dev);
202 nl80211_send_unprot_disassoc(rdev, dev, buf, len, GFP_ATOMIC); 210 nl80211_send_unprot_disassoc(rdev, dev, buf, len, GFP_ATOMIC);
203} 211}
204EXPORT_SYMBOL(cfg80211_send_unprot_disassoc); 212EXPORT_SYMBOL(cfg80211_send_unprot_disassoc);
@@ -209,6 +217,7 @@ void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr)
209 struct wiphy *wiphy = wdev->wiphy; 217 struct wiphy *wiphy = wdev->wiphy;
210 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 218 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
211 219
220 trace_cfg80211_send_auth_timeout(dev, addr);
212 wdev_lock(wdev); 221 wdev_lock(wdev);
213 222
214 nl80211_send_auth_timeout(rdev, dev, addr, GFP_KERNEL); 223 nl80211_send_auth_timeout(rdev, dev, addr, GFP_KERNEL);
@@ -227,6 +236,7 @@ void cfg80211_send_assoc_timeout(struct net_device *dev, const u8 *addr)
227 struct wiphy *wiphy = wdev->wiphy; 236 struct wiphy *wiphy = wdev->wiphy;
228 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 237 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
229 238
239 trace_cfg80211_send_assoc_timeout(dev, addr);
230 wdev_lock(wdev); 240 wdev_lock(wdev);
231 241
232 nl80211_send_assoc_timeout(rdev, dev, addr, GFP_KERNEL); 242 nl80211_send_assoc_timeout(rdev, dev, addr, GFP_KERNEL);
@@ -261,6 +271,7 @@ void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr,
261 } 271 }
262#endif 272#endif
263 273
274 trace_cfg80211_michael_mic_failure(dev, addr, key_type, key_id, tsc);
264 nl80211_michael_mic_failure(rdev, dev, addr, key_type, key_id, tsc, gfp); 275 nl80211_michael_mic_failure(rdev, dev, addr, key_type, key_id, tsc, gfp);
265} 276}
266EXPORT_SYMBOL(cfg80211_michael_mic_failure); 277EXPORT_SYMBOL(cfg80211_michael_mic_failure);
@@ -273,7 +284,8 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
273 const u8 *bssid, 284 const u8 *bssid,
274 const u8 *ssid, int ssid_len, 285 const u8 *ssid, int ssid_len,
275 const u8 *ie, int ie_len, 286 const u8 *ie, int ie_len,
276 const u8 *key, int key_len, int key_idx) 287 const u8 *key, int key_len, int key_idx,
288 const u8 *sae_data, int sae_data_len)
277{ 289{
278 struct wireless_dev *wdev = dev->ieee80211_ptr; 290 struct wireless_dev *wdev = dev->ieee80211_ptr;
279 struct cfg80211_auth_request req; 291 struct cfg80211_auth_request req;
@@ -293,6 +305,8 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
293 305
294 req.ie = ie; 306 req.ie = ie;
295 req.ie_len = ie_len; 307 req.ie_len = ie_len;
308 req.sae_data = sae_data;
309 req.sae_data_len = sae_data_len;
296 req.auth_type = auth_type; 310 req.auth_type = auth_type;
297 req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len, 311 req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len,
298 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); 312 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
@@ -307,7 +321,7 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
307 if (err) 321 if (err)
308 goto out; 322 goto out;
309 323
310 err = rdev->ops->auth(&rdev->wiphy, dev, &req); 324 err = rdev_auth(rdev, dev, &req);
311 325
312out: 326out:
313 cfg80211_put_bss(req.bss); 327 cfg80211_put_bss(req.bss);
@@ -319,7 +333,8 @@ int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
319 enum nl80211_auth_type auth_type, const u8 *bssid, 333 enum nl80211_auth_type auth_type, const u8 *bssid,
320 const u8 *ssid, int ssid_len, 334 const u8 *ssid, int ssid_len,
321 const u8 *ie, int ie_len, 335 const u8 *ie, int ie_len,
322 const u8 *key, int key_len, int key_idx) 336 const u8 *key, int key_len, int key_idx,
337 const u8 *sae_data, int sae_data_len)
323{ 338{
324 int err; 339 int err;
325 340
@@ -327,7 +342,8 @@ int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
327 wdev_lock(dev->ieee80211_ptr); 342 wdev_lock(dev->ieee80211_ptr);
328 err = __cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid, 343 err = __cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid,
329 ssid, ssid_len, ie, ie_len, 344 ssid, ssid_len, ie, ie_len,
330 key, key_len, key_idx); 345 key, key_len, key_idx,
346 sae_data, sae_data_len);
331 wdev_unlock(dev->ieee80211_ptr); 347 wdev_unlock(dev->ieee80211_ptr);
332 mutex_unlock(&rdev->devlist_mtx); 348 mutex_unlock(&rdev->devlist_mtx);
333 349
@@ -410,7 +426,7 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
410 if (err) 426 if (err)
411 goto out; 427 goto out;
412 428
413 err = rdev->ops->assoc(&rdev->wiphy, dev, &req); 429 err = rdev_assoc(rdev, dev, &req);
414 430
415out: 431out:
416 if (err) { 432 if (err) {
@@ -472,7 +488,7 @@ int __cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev,
472 return 0; 488 return 0;
473 } 489 }
474 490
475 return rdev->ops->deauth(&rdev->wiphy, dev, &req); 491 return rdev_deauth(rdev, dev, &req);
476} 492}
477 493
478int cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev, 494int cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev,
@@ -517,7 +533,7 @@ static int __cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev,
517 else 533 else
518 return -ENOTCONN; 534 return -ENOTCONN;
519 535
520 return rdev->ops->disassoc(&rdev->wiphy, dev, &req); 536 return rdev_disassoc(rdev, dev, &req);
521} 537}
522 538
523int cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev, 539int cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev,
@@ -558,7 +574,7 @@ void cfg80211_mlme_down(struct cfg80211_registered_device *rdev,
558 574
559 memcpy(bssid, wdev->current_bss->pub.bssid, ETH_ALEN); 575 memcpy(bssid, wdev->current_bss->pub.bssid, ETH_ALEN);
560 req.bssid = bssid; 576 req.bssid = bssid;
561 rdev->ops->deauth(&rdev->wiphy, dev, &req); 577 rdev_deauth(rdev, dev, &req);
562 578
563 if (wdev->current_bss) { 579 if (wdev->current_bss) {
564 cfg80211_unhold_bss(wdev->current_bss); 580 cfg80211_unhold_bss(wdev->current_bss);
@@ -575,6 +591,8 @@ void cfg80211_ready_on_channel(struct wireless_dev *wdev, u64 cookie,
575 struct wiphy *wiphy = wdev->wiphy; 591 struct wiphy *wiphy = wdev->wiphy;
576 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 592 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
577 593
594 trace_cfg80211_ready_on_channel(wdev, cookie, chan, channel_type,
595 duration);
578 nl80211_send_remain_on_channel(rdev, wdev, cookie, chan, channel_type, 596 nl80211_send_remain_on_channel(rdev, wdev, cookie, chan, channel_type,
579 duration, gfp); 597 duration, gfp);
580} 598}
@@ -588,6 +606,8 @@ void cfg80211_remain_on_channel_expired(struct wireless_dev *wdev, u64 cookie,
588 struct wiphy *wiphy = wdev->wiphy; 606 struct wiphy *wiphy = wdev->wiphy;
589 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 607 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
590 608
609 trace_cfg80211_ready_on_channel_expired(wdev, cookie, chan,
610 channel_type);
591 nl80211_send_remain_on_channel_cancel(rdev, wdev, cookie, chan, 611 nl80211_send_remain_on_channel_cancel(rdev, wdev, cookie, chan,
592 channel_type, gfp); 612 channel_type, gfp);
593} 613}
@@ -599,6 +619,7 @@ void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr,
599 struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; 619 struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
600 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 620 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
601 621
622 trace_cfg80211_new_sta(dev, mac_addr, sinfo);
602 nl80211_send_sta_event(rdev, dev, mac_addr, sinfo, gfp); 623 nl80211_send_sta_event(rdev, dev, mac_addr, sinfo, gfp);
603} 624}
604EXPORT_SYMBOL(cfg80211_new_sta); 625EXPORT_SYMBOL(cfg80211_new_sta);
@@ -608,6 +629,7 @@ void cfg80211_del_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp)
608 struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; 629 struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
609 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 630 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
610 631
632 trace_cfg80211_del_sta(dev, mac_addr);
611 nl80211_send_sta_del_event(rdev, dev, mac_addr, gfp); 633 nl80211_send_sta_del_event(rdev, dev, mac_addr, gfp);
612} 634}
613EXPORT_SYMBOL(cfg80211_del_sta); 635EXPORT_SYMBOL(cfg80211_del_sta);
@@ -688,7 +710,7 @@ int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_portid,
688 list_add(&nreg->list, &wdev->mgmt_registrations); 710 list_add(&nreg->list, &wdev->mgmt_registrations);
689 711
690 if (rdev->ops->mgmt_frame_register) 712 if (rdev->ops->mgmt_frame_register)
691 rdev->ops->mgmt_frame_register(wiphy, wdev, frame_type, true); 713 rdev_mgmt_frame_register(rdev, wdev, frame_type, true);
692 714
693 out: 715 out:
694 spin_unlock_bh(&wdev->mgmt_registrations_lock); 716 spin_unlock_bh(&wdev->mgmt_registrations_lock);
@@ -711,8 +733,8 @@ void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlportid)
711 if (rdev->ops->mgmt_frame_register) { 733 if (rdev->ops->mgmt_frame_register) {
712 u16 frame_type = le16_to_cpu(reg->frame_type); 734 u16 frame_type = le16_to_cpu(reg->frame_type);
713 735
714 rdev->ops->mgmt_frame_register(wiphy, wdev, 736 rdev_mgmt_frame_register(rdev, wdev,
715 frame_type, false); 737 frame_type, false);
716 } 738 }
717 739
718 list_del(&reg->list); 740 list_del(&reg->list);
@@ -838,10 +860,10 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev,
838 return -EINVAL; 860 return -EINVAL;
839 861
840 /* Transmit the Action frame as requested by user space */ 862 /* Transmit the Action frame as requested by user space */
841 return rdev->ops->mgmt_tx(&rdev->wiphy, wdev, chan, offchan, 863 return rdev_mgmt_tx(rdev, wdev, chan, offchan,
842 channel_type, channel_type_valid, 864 channel_type, channel_type_valid,
843 wait, buf, len, no_cck, dont_wait_for_ack, 865 wait, buf, len, no_cck, dont_wait_for_ack,
844 cookie); 866 cookie);
845} 867}
846 868
847bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_mbm, 869bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_mbm,
@@ -860,10 +882,13 @@ bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_mbm,
860 cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE); 882 cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE);
861 u16 stype; 883 u16 stype;
862 884
885 trace_cfg80211_rx_mgmt(wdev, freq, sig_mbm);
863 stype = (le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE) >> 4; 886 stype = (le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE) >> 4;
864 887
865 if (!(stypes->rx & BIT(stype))) 888 if (!(stypes->rx & BIT(stype))) {
889 trace_cfg80211_return_bool(false);
866 return false; 890 return false;
891 }
867 892
868 data = buf + ieee80211_hdrlen(mgmt->frame_control); 893 data = buf + ieee80211_hdrlen(mgmt->frame_control);
869 data_len = len - ieee80211_hdrlen(mgmt->frame_control); 894 data_len = len - ieee80211_hdrlen(mgmt->frame_control);
@@ -894,6 +919,7 @@ bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_mbm,
894 919
895 spin_unlock_bh(&wdev->mgmt_registrations_lock); 920 spin_unlock_bh(&wdev->mgmt_registrations_lock);
896 921
922 trace_cfg80211_return_bool(result);
897 return result; 923 return result;
898} 924}
899EXPORT_SYMBOL(cfg80211_rx_mgmt); 925EXPORT_SYMBOL(cfg80211_rx_mgmt);
@@ -904,6 +930,8 @@ void cfg80211_mgmt_tx_status(struct wireless_dev *wdev, u64 cookie,
904 struct wiphy *wiphy = wdev->wiphy; 930 struct wiphy *wiphy = wdev->wiphy;
905 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 931 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
906 932
933 trace_cfg80211_mgmt_tx_status(wdev, cookie, ack);
934
907 /* Indicate TX status of the Action frame to user space */ 935 /* Indicate TX status of the Action frame to user space */
908 nl80211_send_mgmt_tx_status(rdev, wdev, cookie, buf, len, ack, gfp); 936 nl80211_send_mgmt_tx_status(rdev, wdev, cookie, buf, len, ack, gfp);
909} 937}
@@ -917,6 +945,8 @@ void cfg80211_cqm_rssi_notify(struct net_device *dev,
917 struct wiphy *wiphy = wdev->wiphy; 945 struct wiphy *wiphy = wdev->wiphy;
918 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 946 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
919 947
948 trace_cfg80211_cqm_rssi_notify(dev, rssi_event);
949
920 /* Indicate roaming trigger event to user space */ 950 /* Indicate roaming trigger event to user space */
921 nl80211_send_cqm_rssi_notify(rdev, dev, rssi_event, gfp); 951 nl80211_send_cqm_rssi_notify(rdev, dev, rssi_event, gfp);
922} 952}
@@ -929,6 +959,8 @@ void cfg80211_cqm_pktloss_notify(struct net_device *dev,
929 struct wiphy *wiphy = wdev->wiphy; 959 struct wiphy *wiphy = wdev->wiphy;
930 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 960 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
931 961
962 trace_cfg80211_cqm_pktloss_notify(dev, peer, num_packets);
963
932 /* Indicate roaming trigger event to user space */ 964 /* Indicate roaming trigger event to user space */
933 nl80211_send_cqm_pktloss_notify(rdev, dev, peer, num_packets, gfp); 965 nl80211_send_cqm_pktloss_notify(rdev, dev, peer, num_packets, gfp);
934} 966}
@@ -954,6 +986,7 @@ void cfg80211_gtk_rekey_notify(struct net_device *dev, const u8 *bssid,
954 struct wiphy *wiphy = wdev->wiphy; 986 struct wiphy *wiphy = wdev->wiphy;
955 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 987 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
956 988
989 trace_cfg80211_gtk_rekey_notify(dev, bssid);
957 nl80211_gtk_rekey_notify(rdev, dev, bssid, replay_ctr, gfp); 990 nl80211_gtk_rekey_notify(rdev, dev, bssid, replay_ctr, gfp);
958} 991}
959EXPORT_SYMBOL(cfg80211_gtk_rekey_notify); 992EXPORT_SYMBOL(cfg80211_gtk_rekey_notify);
@@ -965,6 +998,7 @@ void cfg80211_pmksa_candidate_notify(struct net_device *dev, int index,
965 struct wiphy *wiphy = wdev->wiphy; 998 struct wiphy *wiphy = wdev->wiphy;
966 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 999 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
967 1000
1001 trace_cfg80211_pmksa_candidate_notify(dev, index, bssid, preauth);
968 nl80211_pmksa_candidate_notify(rdev, dev, index, bssid, preauth, gfp); 1002 nl80211_pmksa_candidate_notify(rdev, dev, index, bssid, preauth, gfp);
969} 1003}
970EXPORT_SYMBOL(cfg80211_pmksa_candidate_notify); 1004EXPORT_SYMBOL(cfg80211_pmksa_candidate_notify);
@@ -977,6 +1011,8 @@ void cfg80211_ch_switch_notify(struct net_device *dev, int freq,
977 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 1011 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
978 struct ieee80211_channel *chan; 1012 struct ieee80211_channel *chan;
979 1013
1014 trace_cfg80211_ch_switch_notify(dev, freq, type);
1015
980 wdev_lock(wdev); 1016 wdev_lock(wdev);
981 1017
982 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP && 1018 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP &&
@@ -999,12 +1035,18 @@ bool cfg80211_rx_spurious_frame(struct net_device *dev,
999 const u8 *addr, gfp_t gfp) 1035 const u8 *addr, gfp_t gfp)
1000{ 1036{
1001 struct wireless_dev *wdev = dev->ieee80211_ptr; 1037 struct wireless_dev *wdev = dev->ieee80211_ptr;
1038 bool ret;
1039
1040 trace_cfg80211_rx_spurious_frame(dev, addr);
1002 1041
1003 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP && 1042 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP &&
1004 wdev->iftype != NL80211_IFTYPE_P2P_GO)) 1043 wdev->iftype != NL80211_IFTYPE_P2P_GO)) {
1044 trace_cfg80211_return_bool(false);
1005 return false; 1045 return false;
1006 1046 }
1007 return nl80211_unexpected_frame(dev, addr, gfp); 1047 ret = nl80211_unexpected_frame(dev, addr, gfp);
1048 trace_cfg80211_return_bool(ret);
1049 return ret;
1008} 1050}
1009EXPORT_SYMBOL(cfg80211_rx_spurious_frame); 1051EXPORT_SYMBOL(cfg80211_rx_spurious_frame);
1010 1052
@@ -1012,12 +1054,18 @@ bool cfg80211_rx_unexpected_4addr_frame(struct net_device *dev,
1012 const u8 *addr, gfp_t gfp) 1054 const u8 *addr, gfp_t gfp)
1013{ 1055{
1014 struct wireless_dev *wdev = dev->ieee80211_ptr; 1056 struct wireless_dev *wdev = dev->ieee80211_ptr;
1057 bool ret;
1058
1059 trace_cfg80211_rx_unexpected_4addr_frame(dev, addr);
1015 1060
1016 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP && 1061 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP &&
1017 wdev->iftype != NL80211_IFTYPE_P2P_GO && 1062 wdev->iftype != NL80211_IFTYPE_P2P_GO &&
1018 wdev->iftype != NL80211_IFTYPE_AP_VLAN)) 1063 wdev->iftype != NL80211_IFTYPE_AP_VLAN)) {
1064 trace_cfg80211_return_bool(false);
1019 return false; 1065 return false;
1020 1066 }
1021 return nl80211_unexpected_4addr_frame(dev, addr, gfp); 1067 ret = nl80211_unexpected_4addr_frame(dev, addr, gfp);
1068 trace_cfg80211_return_bool(ret);
1069 return ret;
1022} 1070}
1023EXPORT_SYMBOL(cfg80211_rx_unexpected_4addr_frame); 1071EXPORT_SYMBOL(cfg80211_rx_unexpected_4addr_frame);
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 0418a6d5c1a6..5d3167d71b5f 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -22,8 +22,8 @@
22#include "core.h" 22#include "core.h"
23#include "nl80211.h" 23#include "nl80211.h"
24#include "reg.h" 24#include "reg.h"
25#include "rdev-ops.h"
25 26
26static bool nl80211_valid_auth_type(enum nl80211_auth_type auth_type);
27static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev, 27static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev,
28 struct genl_info *info, 28 struct genl_info *info,
29 struct cfg80211_crypto_settings *settings, 29 struct cfg80211_crypto_settings *settings,
@@ -355,6 +355,9 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = {
355 [NL80211_ATTR_BG_SCAN_PERIOD] = { .type = NLA_U16 }, 355 [NL80211_ATTR_BG_SCAN_PERIOD] = { .type = NLA_U16 },
356 [NL80211_ATTR_WDEV] = { .type = NLA_U64 }, 356 [NL80211_ATTR_WDEV] = { .type = NLA_U64 },
357 [NL80211_ATTR_USER_REG_HINT_TYPE] = { .type = NLA_U32 }, 357 [NL80211_ATTR_USER_REG_HINT_TYPE] = { .type = NLA_U32 },
358 [NL80211_ATTR_SAE_DATA] = { .type = NLA_BINARY, },
359 [NL80211_ATTR_VHT_CAPABILITY] = { .len = NL80211_VHT_CAPABILITY_LEN },
360 [NL80211_ATTR_SCAN_FLAGS] = { .type = NLA_U32 },
358}; 361};
359 362
360/* policy for the key attributes */ 363/* policy for the key attributes */
@@ -690,7 +693,7 @@ static int nl80211_parse_key(struct genl_info *info, struct key_parse *k)
690 693
691static struct cfg80211_cached_keys * 694static struct cfg80211_cached_keys *
692nl80211_parse_connkeys(struct cfg80211_registered_device *rdev, 695nl80211_parse_connkeys(struct cfg80211_registered_device *rdev,
693 struct nlattr *keys) 696 struct nlattr *keys, bool *no_ht)
694{ 697{
695 struct key_parse parse; 698 struct key_parse parse;
696 struct nlattr *key; 699 struct nlattr *key;
@@ -733,6 +736,12 @@ nl80211_parse_connkeys(struct cfg80211_registered_device *rdev,
733 result->params[parse.idx].key_len = parse.p.key_len; 736 result->params[parse.idx].key_len = parse.p.key_len;
734 result->params[parse.idx].key = result->data[parse.idx]; 737 result->params[parse.idx].key = result->data[parse.idx];
735 memcpy(result->data[parse.idx], parse.p.key, parse.p.key_len); 738 memcpy(result->data[parse.idx], parse.p.key, parse.p.key_len);
739
740 if (parse.p.cipher == WLAN_CIPHER_SUITE_WEP40 ||
741 parse.p.cipher == WLAN_CIPHER_SUITE_WEP104) {
742 if (no_ht)
743 *no_ht = true;
744 }
736 } 745 }
737 746
738 return result; 747 return result;
@@ -943,7 +952,7 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flag
943 dev->wiphy.available_antennas_rx) && dev->ops->get_antenna) { 952 dev->wiphy.available_antennas_rx) && dev->ops->get_antenna) {
944 u32 tx_ant = 0, rx_ant = 0; 953 u32 tx_ant = 0, rx_ant = 0;
945 int res; 954 int res;
946 res = dev->ops->get_antenna(&dev->wiphy, &tx_ant, &rx_ant); 955 res = rdev_get_antenna(dev, &tx_ant, &rx_ant);
947 if (!res) { 956 if (!res) {
948 if (nla_put_u32(msg, NL80211_ATTR_WIPHY_ANTENNA_TX, 957 if (nla_put_u32(msg, NL80211_ATTR_WIPHY_ANTENNA_TX,
949 tx_ant) || 958 tx_ant) ||
@@ -1457,7 +1466,7 @@ static int nl80211_set_wds_peer(struct sk_buff *skb, struct genl_info *info)
1457 return -EOPNOTSUPP; 1466 return -EOPNOTSUPP;
1458 1467
1459 bssid = nla_data(info->attrs[NL80211_ATTR_MAC]); 1468 bssid = nla_data(info->attrs[NL80211_ATTR_MAC]);
1460 return rdev->ops->set_wds_peer(wdev->wiphy, dev, bssid); 1469 return rdev_set_wds_peer(rdev, dev, bssid);
1461} 1470}
1462 1471
1463 1472
@@ -1562,9 +1571,8 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
1562 if (result) 1571 if (result)
1563 goto bad_res; 1572 goto bad_res;
1564 1573
1565 result = rdev->ops->set_txq_params(&rdev->wiphy, 1574 result = rdev_set_txq_params(rdev, netdev,
1566 netdev, 1575 &txq_params);
1567 &txq_params);
1568 if (result) 1576 if (result)
1569 goto bad_res; 1577 goto bad_res;
1570 } 1578 }
@@ -1599,7 +1607,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
1599 mbm = nla_get_u32(info->attrs[idx]); 1607 mbm = nla_get_u32(info->attrs[idx]);
1600 } 1608 }
1601 1609
1602 result = rdev->ops->set_tx_power(&rdev->wiphy, type, mbm); 1610 result = rdev_set_tx_power(rdev, type, mbm);
1603 if (result) 1611 if (result)
1604 goto bad_res; 1612 goto bad_res;
1605 } 1613 }
@@ -1628,7 +1636,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
1628 tx_ant = tx_ant & rdev->wiphy.available_antennas_tx; 1636 tx_ant = tx_ant & rdev->wiphy.available_antennas_tx;
1629 rx_ant = rx_ant & rdev->wiphy.available_antennas_rx; 1637 rx_ant = rx_ant & rdev->wiphy.available_antennas_rx;
1630 1638
1631 result = rdev->ops->set_antenna(&rdev->wiphy, tx_ant, rx_ant); 1639 result = rdev_set_antenna(rdev, tx_ant, rx_ant);
1632 if (result) 1640 if (result)
1633 goto bad_res; 1641 goto bad_res;
1634 } 1642 }
@@ -1713,7 +1721,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
1713 if (changed & WIPHY_PARAM_COVERAGE_CLASS) 1721 if (changed & WIPHY_PARAM_COVERAGE_CLASS)
1714 rdev->wiphy.coverage_class = coverage_class; 1722 rdev->wiphy.coverage_class = coverage_class;
1715 1723
1716 result = rdev->ops->set_wiphy_params(&rdev->wiphy, changed); 1724 result = rdev_set_wiphy_params(rdev, changed);
1717 if (result) { 1725 if (result) {
1718 rdev->wiphy.retry_short = old_retry_short; 1726 rdev->wiphy.retry_short = old_retry_short;
1719 rdev->wiphy.retry_long = old_retry_long; 1727 rdev->wiphy.retry_long = old_retry_long;
@@ -1765,8 +1773,7 @@ static int nl80211_send_iface(struct sk_buff *msg, u32 portid, u32 seq, int flag
1765 struct ieee80211_channel *chan; 1773 struct ieee80211_channel *chan;
1766 enum nl80211_channel_type channel_type; 1774 enum nl80211_channel_type channel_type;
1767 1775
1768 chan = rdev->ops->get_channel(&rdev->wiphy, wdev, 1776 chan = rdev_get_channel(rdev, wdev, &channel_type);
1769 &channel_type);
1770 if (chan && 1777 if (chan &&
1771 (nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, 1778 (nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ,
1772 chan->center_freq) || 1779 chan->center_freq) ||
@@ -2014,9 +2021,9 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info)
2014 err = parse_monitor_flags(type == NL80211_IFTYPE_MONITOR ? 2021 err = parse_monitor_flags(type == NL80211_IFTYPE_MONITOR ?
2015 info->attrs[NL80211_ATTR_MNTR_FLAGS] : NULL, 2022 info->attrs[NL80211_ATTR_MNTR_FLAGS] : NULL,
2016 &flags); 2023 &flags);
2017 wdev = rdev->ops->add_virtual_intf(&rdev->wiphy, 2024 wdev = rdev_add_virtual_intf(rdev,
2018 nla_data(info->attrs[NL80211_ATTR_IFNAME]), 2025 nla_data(info->attrs[NL80211_ATTR_IFNAME]),
2019 type, err ? NULL : &flags, &params); 2026 type, err ? NULL : &flags, &params);
2020 if (IS_ERR(wdev)) { 2027 if (IS_ERR(wdev)) {
2021 nlmsg_free(msg); 2028 nlmsg_free(msg);
2022 return PTR_ERR(wdev); 2029 return PTR_ERR(wdev);
@@ -2083,7 +2090,7 @@ static int nl80211_del_interface(struct sk_buff *skb, struct genl_info *info)
2083 if (!wdev->netdev) 2090 if (!wdev->netdev)
2084 info->user_ptr[1] = NULL; 2091 info->user_ptr[1] = NULL;
2085 2092
2086 return rdev->ops->del_virtual_intf(&rdev->wiphy, wdev); 2093 return rdev_del_virtual_intf(rdev, wdev);
2087} 2094}
2088 2095
2089static int nl80211_set_noack_map(struct sk_buff *skb, struct genl_info *info) 2096static int nl80211_set_noack_map(struct sk_buff *skb, struct genl_info *info)
@@ -2100,7 +2107,7 @@ static int nl80211_set_noack_map(struct sk_buff *skb, struct genl_info *info)
2100 2107
2101 noack_map = nla_get_u16(info->attrs[NL80211_ATTR_NOACK_MAP]); 2108 noack_map = nla_get_u16(info->attrs[NL80211_ATTR_NOACK_MAP]);
2102 2109
2103 return rdev->ops->set_noack_map(&rdev->wiphy, dev, noack_map); 2110 return rdev_set_noack_map(rdev, dev, noack_map);
2104} 2111}
2105 2112
2106struct get_key_cookie { 2113struct get_key_cookie {
@@ -2210,8 +2217,8 @@ static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info)
2210 !(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN)) 2217 !(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN))
2211 return -ENOENT; 2218 return -ENOENT;
2212 2219
2213 err = rdev->ops->get_key(&rdev->wiphy, dev, key_idx, pairwise, 2220 err = rdev_get_key(rdev, dev, key_idx, pairwise, mac_addr, &cookie,
2214 mac_addr, &cookie, get_key_callback); 2221 get_key_callback);
2215 2222
2216 if (err) 2223 if (err)
2217 goto free_msg; 2224 goto free_msg;
@@ -2259,7 +2266,7 @@ static int nl80211_set_key(struct sk_buff *skb, struct genl_info *info)
2259 if (err) 2266 if (err)
2260 goto out; 2267 goto out;
2261 2268
2262 err = rdev->ops->set_default_key(&rdev->wiphy, dev, key.idx, 2269 err = rdev_set_default_key(rdev, dev, key.idx,
2263 key.def_uni, key.def_multi); 2270 key.def_uni, key.def_multi);
2264 2271
2265 if (err) 2272 if (err)
@@ -2283,8 +2290,7 @@ static int nl80211_set_key(struct sk_buff *skb, struct genl_info *info)
2283 if (err) 2290 if (err)
2284 goto out; 2291 goto out;
2285 2292
2286 err = rdev->ops->set_default_mgmt_key(&rdev->wiphy, 2293 err = rdev_set_default_mgmt_key(rdev, dev, key.idx);
2287 dev, key.idx);
2288 if (err) 2294 if (err)
2289 goto out; 2295 goto out;
2290 2296
@@ -2340,9 +2346,9 @@ static int nl80211_new_key(struct sk_buff *skb, struct genl_info *info)
2340 wdev_lock(dev->ieee80211_ptr); 2346 wdev_lock(dev->ieee80211_ptr);
2341 err = nl80211_key_allowed(dev->ieee80211_ptr); 2347 err = nl80211_key_allowed(dev->ieee80211_ptr);
2342 if (!err) 2348 if (!err)
2343 err = rdev->ops->add_key(&rdev->wiphy, dev, key.idx, 2349 err = rdev_add_key(rdev, dev, key.idx,
2344 key.type == NL80211_KEYTYPE_PAIRWISE, 2350 key.type == NL80211_KEYTYPE_PAIRWISE,
2345 mac_addr, &key.p); 2351 mac_addr, &key.p);
2346 wdev_unlock(dev->ieee80211_ptr); 2352 wdev_unlock(dev->ieee80211_ptr);
2347 2353
2348 return err; 2354 return err;
@@ -2386,9 +2392,9 @@ static int nl80211_del_key(struct sk_buff *skb, struct genl_info *info)
2386 err = -ENOENT; 2392 err = -ENOENT;
2387 2393
2388 if (!err) 2394 if (!err)
2389 err = rdev->ops->del_key(&rdev->wiphy, dev, key.idx, 2395 err = rdev_del_key(rdev, dev, key.idx,
2390 key.type == NL80211_KEYTYPE_PAIRWISE, 2396 key.type == NL80211_KEYTYPE_PAIRWISE,
2391 mac_addr); 2397 mac_addr);
2392 2398
2393#ifdef CONFIG_CFG80211_WEXT 2399#ifdef CONFIG_CFG80211_WEXT
2394 if (!err) { 2400 if (!err) {
@@ -2490,6 +2496,30 @@ static bool nl80211_get_ap_channel(struct cfg80211_registered_device *rdev,
2490 return ret; 2496 return ret;
2491} 2497}
2492 2498
2499static bool nl80211_valid_auth_type(struct cfg80211_registered_device *rdev,
2500 enum nl80211_auth_type auth_type,
2501 enum nl80211_commands cmd)
2502{
2503 if (auth_type > NL80211_AUTHTYPE_MAX)
2504 return false;
2505
2506 switch (cmd) {
2507 case NL80211_CMD_AUTHENTICATE:
2508 if (!(rdev->wiphy.features & NL80211_FEATURE_SAE) &&
2509 auth_type == NL80211_AUTHTYPE_SAE)
2510 return false;
2511 return true;
2512 case NL80211_CMD_CONNECT:
2513 case NL80211_CMD_START_AP:
2514 /* SAE not supported yet */
2515 if (auth_type == NL80211_AUTHTYPE_SAE)
2516 return false;
2517 return true;
2518 default:
2519 return false;
2520 }
2521}
2522
2493static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info) 2523static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
2494{ 2524{
2495 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 2525 struct cfg80211_registered_device *rdev = info->user_ptr[0];
@@ -2559,7 +2589,8 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
2559 if (info->attrs[NL80211_ATTR_AUTH_TYPE]) { 2589 if (info->attrs[NL80211_ATTR_AUTH_TYPE]) {
2560 params.auth_type = nla_get_u32( 2590 params.auth_type = nla_get_u32(
2561 info->attrs[NL80211_ATTR_AUTH_TYPE]); 2591 info->attrs[NL80211_ATTR_AUTH_TYPE]);
2562 if (!nl80211_valid_auth_type(params.auth_type)) 2592 if (!nl80211_valid_auth_type(rdev, params.auth_type,
2593 NL80211_CMD_START_AP))
2563 return -EINVAL; 2594 return -EINVAL;
2564 } else 2595 } else
2565 params.auth_type = NL80211_AUTHTYPE_AUTOMATIC; 2596 params.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
@@ -2607,7 +2638,7 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
2607 if (err) 2638 if (err)
2608 return err; 2639 return err;
2609 2640
2610 err = rdev->ops->start_ap(&rdev->wiphy, dev, &params); 2641 err = rdev_start_ap(rdev, dev, &params);
2611 if (!err) { 2642 if (!err) {
2612 wdev->preset_chan = params.channel; 2643 wdev->preset_chan = params.channel;
2613 wdev->preset_chantype = params.channel_type; 2644 wdev->preset_chantype = params.channel_type;
@@ -2639,7 +2670,7 @@ static int nl80211_set_beacon(struct sk_buff *skb, struct genl_info *info)
2639 if (err) 2670 if (err)
2640 return err; 2671 return err;
2641 2672
2642 return rdev->ops->change_beacon(&rdev->wiphy, dev, &params); 2673 return rdev_change_beacon(rdev, dev, &params);
2643} 2674}
2644 2675
2645static int nl80211_stop_ap(struct sk_buff *skb, struct genl_info *info) 2676static int nl80211_stop_ap(struct sk_buff *skb, struct genl_info *info)
@@ -2923,8 +2954,8 @@ static int nl80211_dump_station(struct sk_buff *skb,
2923 2954
2924 while (1) { 2955 while (1) {
2925 memset(&sinfo, 0, sizeof(sinfo)); 2956 memset(&sinfo, 0, sizeof(sinfo));
2926 err = dev->ops->dump_station(&dev->wiphy, netdev, sta_idx, 2957 err = rdev_dump_station(dev, netdev, sta_idx,
2927 mac_addr, &sinfo); 2958 mac_addr, &sinfo);
2928 if (err == -ENOENT) 2959 if (err == -ENOENT)
2929 break; 2960 break;
2930 if (err) 2961 if (err)
@@ -2969,7 +3000,7 @@ static int nl80211_get_station(struct sk_buff *skb, struct genl_info *info)
2969 if (!rdev->ops->get_station) 3000 if (!rdev->ops->get_station)
2970 return -EOPNOTSUPP; 3001 return -EOPNOTSUPP;
2971 3002
2972 err = rdev->ops->get_station(&rdev->wiphy, dev, mac_addr, &sinfo); 3003 err = rdev_get_station(rdev, dev, mac_addr, &sinfo);
2973 if (err) 3004 if (err)
2974 return err; 3005 return err;
2975 3006
@@ -3146,7 +3177,7 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info)
3146 3177
3147 /* be aware of params.vlan when changing code here */ 3178 /* be aware of params.vlan when changing code here */
3148 3179
3149 err = rdev->ops->change_station(&rdev->wiphy, dev, mac_addr, &params); 3180 err = rdev_change_station(rdev, dev, mac_addr, &params);
3150 3181
3151 if (params.vlan) 3182 if (params.vlan)
3152 dev_put(params.vlan); 3183 dev_put(params.vlan);
@@ -3198,6 +3229,10 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
3198 params.ht_capa = 3229 params.ht_capa =
3199 nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]); 3230 nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]);
3200 3231
3232 if (info->attrs[NL80211_ATTR_VHT_CAPABILITY])
3233 params.vht_capa =
3234 nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]);
3235
3201 if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION]) 3236 if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION])
3202 params.plink_action = 3237 params.plink_action =
3203 nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]); 3238 nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]);
@@ -3275,7 +3310,7 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
3275 3310
3276 /* be aware of params.vlan when changing code here */ 3311 /* be aware of params.vlan when changing code here */
3277 3312
3278 err = rdev->ops->add_station(&rdev->wiphy, dev, mac_addr, &params); 3313 err = rdev_add_station(rdev, dev, mac_addr, &params);
3279 3314
3280 if (params.vlan) 3315 if (params.vlan)
3281 dev_put(params.vlan); 3316 dev_put(params.vlan);
@@ -3300,7 +3335,7 @@ static int nl80211_del_station(struct sk_buff *skb, struct genl_info *info)
3300 if (!rdev->ops->del_station) 3335 if (!rdev->ops->del_station)
3301 return -EOPNOTSUPP; 3336 return -EOPNOTSUPP;
3302 3337
3303 return rdev->ops->del_station(&rdev->wiphy, dev, mac_addr); 3338 return rdev_del_station(rdev, dev, mac_addr);
3304} 3339}
3305 3340
3306static int nl80211_send_mpath(struct sk_buff *msg, u32 portid, u32 seq, 3341static int nl80211_send_mpath(struct sk_buff *msg, u32 portid, u32 seq,
@@ -3382,8 +3417,8 @@ static int nl80211_dump_mpath(struct sk_buff *skb,
3382 } 3417 }
3383 3418
3384 while (1) { 3419 while (1) {
3385 err = dev->ops->dump_mpath(&dev->wiphy, netdev, path_idx, 3420 err = rdev_dump_mpath(dev, netdev, path_idx, dst, next_hop,
3386 dst, next_hop, &pinfo); 3421 &pinfo);
3387 if (err == -ENOENT) 3422 if (err == -ENOENT)
3388 break; 3423 break;
3389 if (err) 3424 if (err)
@@ -3430,7 +3465,7 @@ static int nl80211_get_mpath(struct sk_buff *skb, struct genl_info *info)
3430 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) 3465 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT)
3431 return -EOPNOTSUPP; 3466 return -EOPNOTSUPP;
3432 3467
3433 err = rdev->ops->get_mpath(&rdev->wiphy, dev, dst, next_hop, &pinfo); 3468 err = rdev_get_mpath(rdev, dev, dst, next_hop, &pinfo);
3434 if (err) 3469 if (err)
3435 return err; 3470 return err;
3436 3471
@@ -3469,7 +3504,7 @@ static int nl80211_set_mpath(struct sk_buff *skb, struct genl_info *info)
3469 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) 3504 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT)
3470 return -EOPNOTSUPP; 3505 return -EOPNOTSUPP;
3471 3506
3472 return rdev->ops->change_mpath(&rdev->wiphy, dev, dst, next_hop); 3507 return rdev_change_mpath(rdev, dev, dst, next_hop);
3473} 3508}
3474 3509
3475static int nl80211_new_mpath(struct sk_buff *skb, struct genl_info *info) 3510static int nl80211_new_mpath(struct sk_buff *skb, struct genl_info *info)
@@ -3494,7 +3529,7 @@ static int nl80211_new_mpath(struct sk_buff *skb, struct genl_info *info)
3494 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) 3529 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT)
3495 return -EOPNOTSUPP; 3530 return -EOPNOTSUPP;
3496 3531
3497 return rdev->ops->add_mpath(&rdev->wiphy, dev, dst, next_hop); 3532 return rdev_add_mpath(rdev, dev, dst, next_hop);
3498} 3533}
3499 3534
3500static int nl80211_del_mpath(struct sk_buff *skb, struct genl_info *info) 3535static int nl80211_del_mpath(struct sk_buff *skb, struct genl_info *info)
@@ -3509,7 +3544,7 @@ static int nl80211_del_mpath(struct sk_buff *skb, struct genl_info *info)
3509 if (!rdev->ops->del_mpath) 3544 if (!rdev->ops->del_mpath)
3510 return -EOPNOTSUPP; 3545 return -EOPNOTSUPP;
3511 3546
3512 return rdev->ops->del_mpath(&rdev->wiphy, dev, dst); 3547 return rdev_del_mpath(rdev, dev, dst);
3513} 3548}
3514 3549
3515static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info) 3550static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
@@ -3554,7 +3589,7 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
3554 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) 3589 dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO)
3555 return -EOPNOTSUPP; 3590 return -EOPNOTSUPP;
3556 3591
3557 return rdev->ops->change_bss(&rdev->wiphy, dev, &params); 3592 return rdev_change_bss(rdev, dev, &params);
3558} 3593}
3559 3594
3560static const struct nla_policy reg_rule_policy[NL80211_REG_RULE_ATTR_MAX + 1] = { 3595static const struct nla_policy reg_rule_policy[NL80211_REG_RULE_ATTR_MAX + 1] = {
@@ -3668,8 +3703,7 @@ static int nl80211_get_mesh_config(struct sk_buff *skb,
3668 if (!wdev->mesh_id_len) 3703 if (!wdev->mesh_id_len)
3669 memcpy(&cur_params, &default_mesh_config, sizeof(cur_params)); 3704 memcpy(&cur_params, &default_mesh_config, sizeof(cur_params));
3670 else 3705 else
3671 err = rdev->ops->get_mesh_config(&rdev->wiphy, dev, 3706 err = rdev_get_mesh_config(rdev, dev, &cur_params);
3672 &cur_params);
3673 wdev_unlock(wdev); 3707 wdev_unlock(wdev);
3674 3708
3675 if (err) 3709 if (err)
@@ -3971,8 +4005,7 @@ static int nl80211_update_mesh_config(struct sk_buff *skb,
3971 err = -ENOLINK; 4005 err = -ENOLINK;
3972 4006
3973 if (!err) 4007 if (!err)
3974 err = rdev->ops->update_mesh_config(&rdev->wiphy, dev, 4008 err = rdev_update_mesh_config(rdev, dev, mask, &cfg);
3975 mask, &cfg);
3976 4009
3977 wdev_unlock(wdev); 4010 wdev_unlock(wdev);
3978 4011
@@ -4337,14 +4370,27 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
4337 } 4370 }
4338 } 4371 }
4339 4372
4373 if (info->attrs[NL80211_ATTR_SCAN_FLAGS]) {
4374 request->flags = nla_get_u32(
4375 info->attrs[NL80211_ATTR_SCAN_FLAGS]);
4376 if (((request->flags & NL80211_SCAN_FLAG_LOW_PRIORITY) &&
4377 !(wiphy->features & NL80211_FEATURE_LOW_PRIORITY_SCAN)) ||
4378 ((request->flags & NL80211_SCAN_FLAG_FLUSH) &&
4379 !(wiphy->features & NL80211_FEATURE_SCAN_FLUSH))) {
4380 err = -EOPNOTSUPP;
4381 goto out_free;
4382 }
4383 }
4384
4340 request->no_cck = 4385 request->no_cck =
4341 nla_get_flag(info->attrs[NL80211_ATTR_TX_NO_CCK_RATE]); 4386 nla_get_flag(info->attrs[NL80211_ATTR_TX_NO_CCK_RATE]);
4342 4387
4343 request->wdev = wdev; 4388 request->wdev = wdev;
4344 request->wiphy = &rdev->wiphy; 4389 request->wiphy = &rdev->wiphy;
4390 request->scan_start = jiffies;
4345 4391
4346 rdev->scan_req = request; 4392 rdev->scan_req = request;
4347 err = rdev->ops->scan(&rdev->wiphy, request); 4393 err = rdev_scan(rdev, request);
4348 4394
4349 if (!err) { 4395 if (!err) {
4350 nl80211_send_scan_start(rdev, wdev); 4396 nl80211_send_scan_start(rdev, wdev);
@@ -4568,11 +4614,24 @@ static int nl80211_start_sched_scan(struct sk_buff *skb,
4568 request->ie_len); 4614 request->ie_len);
4569 } 4615 }
4570 4616
4617 if (info->attrs[NL80211_ATTR_SCAN_FLAGS]) {
4618 request->flags = nla_get_u32(
4619 info->attrs[NL80211_ATTR_SCAN_FLAGS]);
4620 if (((request->flags & NL80211_SCAN_FLAG_LOW_PRIORITY) &&
4621 !(wiphy->features & NL80211_FEATURE_LOW_PRIORITY_SCAN)) ||
4622 ((request->flags & NL80211_SCAN_FLAG_FLUSH) &&
4623 !(wiphy->features & NL80211_FEATURE_SCAN_FLUSH))) {
4624 err = -EOPNOTSUPP;
4625 goto out_free;
4626 }
4627 }
4628
4571 request->dev = dev; 4629 request->dev = dev;
4572 request->wiphy = &rdev->wiphy; 4630 request->wiphy = &rdev->wiphy;
4573 request->interval = interval; 4631 request->interval = interval;
4632 request->scan_start = jiffies;
4574 4633
4575 err = rdev->ops->sched_scan_start(&rdev->wiphy, dev, request); 4634 err = rdev_sched_scan_start(rdev, dev, request);
4576 if (!err) { 4635 if (!err) {
4577 rdev->sched_scan_req = request; 4636 rdev->sched_scan_req = request;
4578 nl80211_send_sched_scan(rdev, dev, 4637 nl80211_send_sched_scan(rdev, dev,
@@ -4815,8 +4874,7 @@ static int nl80211_dump_survey(struct sk_buff *skb,
4815 while (1) { 4874 while (1) {
4816 struct ieee80211_channel *chan; 4875 struct ieee80211_channel *chan;
4817 4876
4818 res = dev->ops->dump_survey(&dev->wiphy, netdev, survey_idx, 4877 res = rdev_dump_survey(dev, netdev, survey_idx, &survey);
4819 &survey);
4820 if (res == -ENOENT) 4878 if (res == -ENOENT)
4821 break; 4879 break;
4822 if (res) 4880 if (res)
@@ -4852,11 +4910,6 @@ static int nl80211_dump_survey(struct sk_buff *skb,
4852 return res; 4910 return res;
4853} 4911}
4854 4912
4855static bool nl80211_valid_auth_type(enum nl80211_auth_type auth_type)
4856{
4857 return auth_type <= NL80211_AUTHTYPE_MAX;
4858}
4859
4860static bool nl80211_valid_wpa_versions(u32 wpa_versions) 4913static bool nl80211_valid_wpa_versions(u32 wpa_versions)
4861{ 4914{
4862 return !(wpa_versions & ~(NL80211_WPA_VERSION_1 | 4915 return !(wpa_versions & ~(NL80211_WPA_VERSION_1 |
@@ -4868,8 +4921,8 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info)
4868 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 4921 struct cfg80211_registered_device *rdev = info->user_ptr[0];
4869 struct net_device *dev = info->user_ptr[1]; 4922 struct net_device *dev = info->user_ptr[1];
4870 struct ieee80211_channel *chan; 4923 struct ieee80211_channel *chan;
4871 const u8 *bssid, *ssid, *ie = NULL; 4924 const u8 *bssid, *ssid, *ie = NULL, *sae_data = NULL;
4872 int err, ssid_len, ie_len = 0; 4925 int err, ssid_len, ie_len = 0, sae_data_len = 0;
4873 enum nl80211_auth_type auth_type; 4926 enum nl80211_auth_type auth_type;
4874 struct key_parse key; 4927 struct key_parse key;
4875 bool local_state_change; 4928 bool local_state_change;
@@ -4945,9 +4998,23 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info)
4945 } 4998 }
4946 4999
4947 auth_type = nla_get_u32(info->attrs[NL80211_ATTR_AUTH_TYPE]); 5000 auth_type = nla_get_u32(info->attrs[NL80211_ATTR_AUTH_TYPE]);
4948 if (!nl80211_valid_auth_type(auth_type)) 5001 if (!nl80211_valid_auth_type(rdev, auth_type, NL80211_CMD_AUTHENTICATE))
4949 return -EINVAL; 5002 return -EINVAL;
4950 5003
5004 if (auth_type == NL80211_AUTHTYPE_SAE &&
5005 !info->attrs[NL80211_ATTR_SAE_DATA])
5006 return -EINVAL;
5007
5008 if (info->attrs[NL80211_ATTR_SAE_DATA]) {
5009 if (auth_type != NL80211_AUTHTYPE_SAE)
5010 return -EINVAL;
5011 sae_data = nla_data(info->attrs[NL80211_ATTR_SAE_DATA]);
5012 sae_data_len = nla_len(info->attrs[NL80211_ATTR_SAE_DATA]);
5013 /* need to include at least Auth Transaction and Status Code */
5014 if (sae_data_len < 4)
5015 return -EINVAL;
5016 }
5017
4951 local_state_change = !!info->attrs[NL80211_ATTR_LOCAL_STATE_CHANGE]; 5018 local_state_change = !!info->attrs[NL80211_ATTR_LOCAL_STATE_CHANGE];
4952 5019
4953 /* 5020 /*
@@ -4959,7 +5026,8 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info)
4959 5026
4960 return cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid, 5027 return cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid,
4961 ssid, ssid_len, ie, ie_len, 5028 ssid, ssid_len, ie, ie_len,
4962 key.p.key, key.p.key_len, key.idx); 5029 key.p.key, key.p.key_len, key.idx,
5030 sae_data, sae_data_len);
4963} 5031}
4964 5032
4965static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev, 5033static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev,
@@ -5339,10 +5407,18 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info)
5339 return -EINVAL; 5407 return -EINVAL;
5340 5408
5341 if (ibss.privacy && info->attrs[NL80211_ATTR_KEYS]) { 5409 if (ibss.privacy && info->attrs[NL80211_ATTR_KEYS]) {
5410 bool no_ht = false;
5411
5342 connkeys = nl80211_parse_connkeys(rdev, 5412 connkeys = nl80211_parse_connkeys(rdev,
5343 info->attrs[NL80211_ATTR_KEYS]); 5413 info->attrs[NL80211_ATTR_KEYS],
5414 &no_ht);
5344 if (IS_ERR(connkeys)) 5415 if (IS_ERR(connkeys))
5345 return PTR_ERR(connkeys); 5416 return PTR_ERR(connkeys);
5417
5418 if ((ibss.channel_type != NL80211_CHAN_NO_HT) && no_ht) {
5419 kfree(connkeys);
5420 return -EINVAL;
5421 }
5346 } 5422 }
5347 5423
5348 ibss.control_port = 5424 ibss.control_port =
@@ -5384,7 +5460,7 @@ static int nl80211_testmode_do(struct sk_buff *skb, struct genl_info *info)
5384 err = -EOPNOTSUPP; 5460 err = -EOPNOTSUPP;
5385 if (rdev->ops->testmode_cmd) { 5461 if (rdev->ops->testmode_cmd) {
5386 rdev->testmode_info = info; 5462 rdev->testmode_info = info;
5387 err = rdev->ops->testmode_cmd(&rdev->wiphy, 5463 err = rdev_testmode_cmd(rdev,
5388 nla_data(info->attrs[NL80211_ATTR_TESTDATA]), 5464 nla_data(info->attrs[NL80211_ATTR_TESTDATA]),
5389 nla_len(info->attrs[NL80211_ATTR_TESTDATA])); 5465 nla_len(info->attrs[NL80211_ATTR_TESTDATA]));
5390 rdev->testmode_info = NULL; 5466 rdev->testmode_info = NULL;
@@ -5466,8 +5542,7 @@ static int nl80211_testmode_dump(struct sk_buff *skb,
5466 genlmsg_cancel(skb, hdr); 5542 genlmsg_cancel(skb, hdr);
5467 break; 5543 break;
5468 } 5544 }
5469 err = rdev->ops->testmode_dump(&rdev->wiphy, skb, cb, 5545 err = rdev_testmode_dump(rdev, skb, cb, data, data_len);
5470 data, data_len);
5471 nla_nest_end(skb, tmdata); 5546 nla_nest_end(skb, tmdata);
5472 5547
5473 if (err == -ENOBUFS || err == -ENOENT) { 5548 if (err == -ENOBUFS || err == -ENOENT) {
@@ -5596,7 +5671,8 @@ static int nl80211_connect(struct sk_buff *skb, struct genl_info *info)
5596 if (info->attrs[NL80211_ATTR_AUTH_TYPE]) { 5671 if (info->attrs[NL80211_ATTR_AUTH_TYPE]) {
5597 connect.auth_type = 5672 connect.auth_type =
5598 nla_get_u32(info->attrs[NL80211_ATTR_AUTH_TYPE]); 5673 nla_get_u32(info->attrs[NL80211_ATTR_AUTH_TYPE]);
5599 if (!nl80211_valid_auth_type(connect.auth_type)) 5674 if (!nl80211_valid_auth_type(rdev, connect.auth_type,
5675 NL80211_CMD_CONNECT))
5600 return -EINVAL; 5676 return -EINVAL;
5601 } else 5677 } else
5602 connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC; 5678 connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
@@ -5642,7 +5718,7 @@ static int nl80211_connect(struct sk_buff *skb, struct genl_info *info)
5642 5718
5643 if (connect.privacy && info->attrs[NL80211_ATTR_KEYS]) { 5719 if (connect.privacy && info->attrs[NL80211_ATTR_KEYS]) {
5644 connkeys = nl80211_parse_connkeys(rdev, 5720 connkeys = nl80211_parse_connkeys(rdev,
5645 info->attrs[NL80211_ATTR_KEYS]); 5721 info->attrs[NL80211_ATTR_KEYS], NULL);
5646 if (IS_ERR(connkeys)) 5722 if (IS_ERR(connkeys))
5647 return PTR_ERR(connkeys); 5723 return PTR_ERR(connkeys);
5648 } 5724 }
@@ -5771,7 +5847,7 @@ static int nl80211_flush_pmksa(struct sk_buff *skb, struct genl_info *info)
5771 if (!rdev->ops->flush_pmksa) 5847 if (!rdev->ops->flush_pmksa)
5772 return -EOPNOTSUPP; 5848 return -EOPNOTSUPP;
5773 5849
5774 return rdev->ops->flush_pmksa(&rdev->wiphy, dev); 5850 return rdev_flush_pmksa(rdev, dev);
5775} 5851}
5776 5852
5777static int nl80211_tdls_mgmt(struct sk_buff *skb, struct genl_info *info) 5853static int nl80211_tdls_mgmt(struct sk_buff *skb, struct genl_info *info)
@@ -5798,10 +5874,10 @@ static int nl80211_tdls_mgmt(struct sk_buff *skb, struct genl_info *info)
5798 status_code = nla_get_u16(info->attrs[NL80211_ATTR_STATUS_CODE]); 5874 status_code = nla_get_u16(info->attrs[NL80211_ATTR_STATUS_CODE]);
5799 dialog_token = nla_get_u8(info->attrs[NL80211_ATTR_TDLS_DIALOG_TOKEN]); 5875 dialog_token = nla_get_u8(info->attrs[NL80211_ATTR_TDLS_DIALOG_TOKEN]);
5800 5876
5801 return rdev->ops->tdls_mgmt(&rdev->wiphy, dev, peer, action_code, 5877 return rdev_tdls_mgmt(rdev, dev, peer, action_code,
5802 dialog_token, status_code, 5878 dialog_token, status_code,
5803 nla_data(info->attrs[NL80211_ATTR_IE]), 5879 nla_data(info->attrs[NL80211_ATTR_IE]),
5804 nla_len(info->attrs[NL80211_ATTR_IE])); 5880 nla_len(info->attrs[NL80211_ATTR_IE]));
5805} 5881}
5806 5882
5807static int nl80211_tdls_oper(struct sk_buff *skb, struct genl_info *info) 5883static int nl80211_tdls_oper(struct sk_buff *skb, struct genl_info *info)
@@ -5822,7 +5898,7 @@ static int nl80211_tdls_oper(struct sk_buff *skb, struct genl_info *info)
5822 operation = nla_get_u8(info->attrs[NL80211_ATTR_TDLS_OPERATION]); 5898 operation = nla_get_u8(info->attrs[NL80211_ATTR_TDLS_OPERATION]);
5823 peer = nla_data(info->attrs[NL80211_ATTR_MAC]); 5899 peer = nla_data(info->attrs[NL80211_ATTR_MAC]);
5824 5900
5825 return rdev->ops->tdls_oper(&rdev->wiphy, dev, peer, operation); 5901 return rdev_tdls_oper(rdev, dev, peer, operation);
5826} 5902}
5827 5903
5828static int nl80211_remain_on_channel(struct sk_buff *skb, 5904static int nl80211_remain_on_channel(struct sk_buff *skb,
@@ -5877,8 +5953,8 @@ static int nl80211_remain_on_channel(struct sk_buff *skb,
5877 goto free_msg; 5953 goto free_msg;
5878 } 5954 }
5879 5955
5880 err = rdev->ops->remain_on_channel(&rdev->wiphy, wdev, chan, 5956 err = rdev_remain_on_channel(rdev, wdev, chan, channel_type, duration,
5881 channel_type, duration, &cookie); 5957 &cookie);
5882 5958
5883 if (err) 5959 if (err)
5884 goto free_msg; 5960 goto free_msg;
@@ -5912,7 +5988,7 @@ static int nl80211_cancel_remain_on_channel(struct sk_buff *skb,
5912 5988
5913 cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]); 5989 cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]);
5914 5990
5915 return rdev->ops->cancel_remain_on_channel(&rdev->wiphy, wdev, cookie); 5991 return rdev_cancel_remain_on_channel(rdev, wdev, cookie);
5916} 5992}
5917 5993
5918static u32 rateset_to_mask(struct ieee80211_supported_band *sband, 5994static u32 rateset_to_mask(struct ieee80211_supported_band *sband,
@@ -6055,7 +6131,7 @@ static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb,
6055 } 6131 }
6056 } 6132 }
6057 6133
6058 return rdev->ops->set_bitrate_mask(&rdev->wiphy, dev, NULL, &mask); 6134 return rdev_set_bitrate_mask(rdev, dev, NULL, &mask);
6059} 6135}
6060 6136
6061static int nl80211_register_mgmt(struct sk_buff *skb, struct genl_info *info) 6137static int nl80211_register_mgmt(struct sk_buff *skb, struct genl_info *info)
@@ -6230,7 +6306,7 @@ static int nl80211_tx_mgmt_cancel_wait(struct sk_buff *skb, struct genl_info *in
6230 6306
6231 cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]); 6307 cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]);
6232 6308
6233 return rdev->ops->mgmt_tx_cancel_wait(&rdev->wiphy, wdev, cookie); 6309 return rdev_mgmt_tx_cancel_wait(rdev, wdev, cookie);
6234} 6310}
6235 6311
6236static int nl80211_set_power_save(struct sk_buff *skb, struct genl_info *info) 6312static int nl80211_set_power_save(struct sk_buff *skb, struct genl_info *info)
@@ -6260,8 +6336,7 @@ static int nl80211_set_power_save(struct sk_buff *skb, struct genl_info *info)
6260 if (state == wdev->ps) 6336 if (state == wdev->ps)
6261 return 0; 6337 return 0;
6262 6338
6263 err = rdev->ops->set_power_mgmt(wdev->wiphy, dev, state, 6339 err = rdev_set_power_mgmt(rdev, dev, state, wdev->ps_timeout);
6264 wdev->ps_timeout);
6265 if (!err) 6340 if (!err)
6266 wdev->ps = state; 6341 wdev->ps = state;
6267 return err; 6342 return err;
@@ -6341,8 +6416,7 @@ static int nl80211_set_cqm_txe(struct genl_info *info,
6341 wdev->iftype != NL80211_IFTYPE_P2P_CLIENT) 6416 wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)
6342 return -EOPNOTSUPP; 6417 return -EOPNOTSUPP;
6343 6418
6344 return rdev->ops->set_cqm_txe_config(wdev->wiphy, dev, 6419 return rdev_set_cqm_txe_config(rdev, dev, rate, pkts, intvl);
6345 rate, pkts, intvl);
6346} 6420}
6347 6421
6348static int nl80211_set_cqm_rssi(struct genl_info *info, 6422static int nl80211_set_cqm_rssi(struct genl_info *info,
@@ -6364,8 +6438,7 @@ static int nl80211_set_cqm_rssi(struct genl_info *info,
6364 wdev->iftype != NL80211_IFTYPE_P2P_CLIENT) 6438 wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)
6365 return -EOPNOTSUPP; 6439 return -EOPNOTSUPP;
6366 6440
6367 return rdev->ops->set_cqm_rssi_config(wdev->wiphy, dev, 6441 return rdev_set_cqm_rssi_config(rdev, dev, threshold, hysteresis);
6368 threshold, hysteresis);
6369} 6442}
6370 6443
6371static int nl80211_set_cqm(struct sk_buff *skb, struct genl_info *info) 6444static int nl80211_set_cqm(struct sk_buff *skb, struct genl_info *info)
@@ -6690,7 +6763,7 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info)
6690 6763
6691 set_wakeup: 6764 set_wakeup:
6692 if (rdev->ops->set_wakeup && prev_enabled != !!rdev->wowlan) 6765 if (rdev->ops->set_wakeup && prev_enabled != !!rdev->wowlan)
6693 rdev->ops->set_wakeup(&rdev->wiphy, rdev->wowlan); 6766 rdev_set_wakeup(rdev, rdev->wowlan);
6694 6767
6695 return 0; 6768 return 0;
6696 error: 6769 error:
@@ -6746,7 +6819,7 @@ static int nl80211_set_rekey_data(struct sk_buff *skb, struct genl_info *info)
6746 goto out; 6819 goto out;
6747 } 6820 }
6748 6821
6749 err = rdev->ops->set_rekey_data(&rdev->wiphy, dev, &rekey_data); 6822 err = rdev_set_rekey_data(rdev, dev, &rekey_data);
6750 out: 6823 out:
6751 wdev_unlock(wdev); 6824 wdev_unlock(wdev);
6752 return err; 6825 return err;
@@ -6805,7 +6878,7 @@ static int nl80211_probe_client(struct sk_buff *skb,
6805 6878
6806 addr = nla_data(info->attrs[NL80211_ATTR_MAC]); 6879 addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
6807 6880
6808 err = rdev->ops->probe_client(&rdev->wiphy, dev, addr, &cookie); 6881 err = rdev_probe_client(rdev, dev, addr, &cookie);
6809 if (err) 6882 if (err)
6810 goto free_msg; 6883 goto free_msg;
6811 6884
@@ -7622,6 +7695,9 @@ static int nl80211_add_scan_req(struct sk_buff *msg,
7622 nla_put(msg, NL80211_ATTR_IE, req->ie_len, req->ie)) 7695 nla_put(msg, NL80211_ATTR_IE, req->ie_len, req->ie))
7623 goto nla_put_failure; 7696 goto nla_put_failure;
7624 7697
7698 if (req->flags)
7699 nla_put_u32(msg, NL80211_ATTR_SCAN_FLAGS, req->flags);
7700
7625 return 0; 7701 return 0;
7626 nla_put_failure: 7702 nla_put_failure:
7627 return -ENOBUFS; 7703 return -ENOBUFS;
@@ -8800,7 +8876,10 @@ void cfg80211_probe_status(struct net_device *dev, const u8 *addr,
8800 void *hdr; 8876 void *hdr;
8801 int err; 8877 int err;
8802 8878
8879 trace_cfg80211_probe_status(dev, addr, cookie, acked);
8880
8803 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); 8881 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
8882
8804 if (!msg) 8883 if (!msg)
8805 return; 8884 return;
8806 8885
@@ -8842,6 +8921,8 @@ void cfg80211_report_obss_beacon(struct wiphy *wiphy,
8842 void *hdr; 8921 void *hdr;
8843 u32 nlportid = ACCESS_ONCE(rdev->ap_beacons_nlportid); 8922 u32 nlportid = ACCESS_ONCE(rdev->ap_beacons_nlportid);
8844 8923
8924 trace_cfg80211_report_obss_beacon(wiphy, frame, len, freq, sig_dbm);
8925
8845 if (!nlportid) 8926 if (!nlportid)
8846 return; 8927 return;
8847 8928
diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h
new file mode 100644
index 000000000000..4a88a39b1319
--- /dev/null
+++ b/net/wireless/rdev-ops.h
@@ -0,0 +1,861 @@
1#ifndef __CFG80211_RDEV_OPS
2#define __CFG80211_RDEV_OPS
3
4#include <linux/rtnetlink.h>
5#include <net/cfg80211.h>
6#include "core.h"
7#include "trace.h"
8
9static inline int rdev_suspend(struct cfg80211_registered_device *rdev)
10{
11 int ret;
12 trace_rdev_suspend(&rdev->wiphy, rdev->wowlan);
13 ret = rdev->ops->suspend(&rdev->wiphy, rdev->wowlan);
14 trace_rdev_return_int(&rdev->wiphy, ret);
15 return ret;
16}
17
18static inline int rdev_resume(struct cfg80211_registered_device *rdev)
19{
20 int ret;
21 trace_rdev_resume(&rdev->wiphy);
22 ret = rdev->ops->resume(&rdev->wiphy);
23 trace_rdev_return_int(&rdev->wiphy, ret);
24 return ret;
25}
26
27static inline void rdev_set_wakeup(struct cfg80211_registered_device *rdev,
28 bool enabled)
29{
30 trace_rdev_set_wakeup(&rdev->wiphy, enabled);
31 rdev->ops->set_wakeup(&rdev->wiphy, enabled);
32 trace_rdev_return_void(&rdev->wiphy);
33}
34
35static inline struct wireless_dev
36*rdev_add_virtual_intf(struct cfg80211_registered_device *rdev, char *name,
37 enum nl80211_iftype type, u32 *flags,
38 struct vif_params *params)
39{
40 struct wireless_dev *ret;
41 trace_rdev_add_virtual_intf(&rdev->wiphy, name, type);
42 ret = rdev->ops->add_virtual_intf(&rdev->wiphy, name, type, flags,
43 params);
44 trace_rdev_return_wdev(&rdev->wiphy, ret);
45 return ret;
46}
47
48static inline int
49rdev_del_virtual_intf(struct cfg80211_registered_device *rdev,
50 struct wireless_dev *wdev)
51{
52 int ret;
53 trace_rdev_del_virtual_intf(&rdev->wiphy, wdev);
54 ret = rdev->ops->del_virtual_intf(&rdev->wiphy, wdev);
55 trace_rdev_return_int(&rdev->wiphy, ret);
56 return ret;
57}
58
59static inline int
60rdev_change_virtual_intf(struct cfg80211_registered_device *rdev,
61 struct net_device *dev, enum nl80211_iftype type,
62 u32 *flags, struct vif_params *params)
63{
64 int ret;
65 trace_rdev_change_virtual_intf(&rdev->wiphy, dev, type);
66 ret = rdev->ops->change_virtual_intf(&rdev->wiphy, dev, type, flags,
67 params);
68 trace_rdev_return_int(&rdev->wiphy, ret);
69 return ret;
70}
71
72static inline int rdev_add_key(struct cfg80211_registered_device *rdev,
73 struct net_device *netdev, u8 key_index,
74 bool pairwise, const u8 *mac_addr,
75 struct key_params *params)
76{
77 int ret;
78 trace_rdev_add_key(&rdev->wiphy, netdev, key_index, pairwise, mac_addr);
79 ret = rdev->ops->add_key(&rdev->wiphy, netdev, key_index, pairwise,
80 mac_addr, params);
81 trace_rdev_return_int(&rdev->wiphy, ret);
82 return ret;
83}
84
85static inline int
86rdev_get_key(struct cfg80211_registered_device *rdev, struct net_device *netdev,
87 u8 key_index, bool pairwise, const u8 *mac_addr, void *cookie,
88 void (*callback)(void *cookie, struct key_params*))
89{
90 int ret;
91 trace_rdev_get_key(&rdev->wiphy, netdev, key_index, pairwise, mac_addr);
92 ret = rdev->ops->get_key(&rdev->wiphy, netdev, key_index, pairwise,
93 mac_addr, cookie, callback);
94 trace_rdev_return_int(&rdev->wiphy, ret);
95 return ret;
96}
97
98static inline int rdev_del_key(struct cfg80211_registered_device *rdev,
99 struct net_device *netdev, u8 key_index,
100 bool pairwise, const u8 *mac_addr)
101{
102 int ret;
103 trace_rdev_del_key(&rdev->wiphy, netdev, key_index, pairwise, mac_addr);
104 ret = rdev->ops->del_key(&rdev->wiphy, netdev, key_index, pairwise,
105 mac_addr);
106 trace_rdev_return_int(&rdev->wiphy, ret);
107 return ret;
108}
109
110static inline int
111rdev_set_default_key(struct cfg80211_registered_device *rdev,
112 struct net_device *netdev, u8 key_index, bool unicast,
113 bool multicast)
114{
115 int ret;
116 trace_rdev_set_default_key(&rdev->wiphy, netdev, key_index,
117 unicast, multicast);
118 ret = rdev->ops->set_default_key(&rdev->wiphy, netdev, key_index,
119 unicast, multicast);
120 trace_rdev_return_int(&rdev->wiphy, ret);
121 return ret;
122}
123
124static inline int
125rdev_set_default_mgmt_key(struct cfg80211_registered_device *rdev,
126 struct net_device *netdev, u8 key_index)
127{
128 int ret;
129 trace_rdev_set_default_mgmt_key(&rdev->wiphy, netdev, key_index);
130 ret = rdev->ops->set_default_mgmt_key(&rdev->wiphy, netdev,
131 key_index);
132 trace_rdev_return_int(&rdev->wiphy, ret);
133 return ret;
134}
135
136static inline int rdev_start_ap(struct cfg80211_registered_device *rdev,
137 struct net_device *dev,
138 struct cfg80211_ap_settings *settings)
139{
140 int ret;
141 trace_rdev_start_ap(&rdev->wiphy, dev, settings);
142 ret = rdev->ops->start_ap(&rdev->wiphy, dev, settings);
143 trace_rdev_return_int(&rdev->wiphy, ret);
144 return ret;
145}
146
147static inline int rdev_change_beacon(struct cfg80211_registered_device *rdev,
148 struct net_device *dev,
149 struct cfg80211_beacon_data *info)
150{
151 int ret;
152 trace_rdev_change_beacon(&rdev->wiphy, dev, info);
153 ret = rdev->ops->change_beacon(&rdev->wiphy, dev, info);
154 trace_rdev_return_int(&rdev->wiphy, ret);
155 return ret;
156}
157
158static inline int rdev_stop_ap(struct cfg80211_registered_device *rdev,
159 struct net_device *dev)
160{
161 int ret;
162 trace_rdev_stop_ap(&rdev->wiphy, dev);
163 ret = rdev->ops->stop_ap(&rdev->wiphy, dev);
164 trace_rdev_return_int(&rdev->wiphy, ret);
165 return ret;
166}
167
168static inline int rdev_add_station(struct cfg80211_registered_device *rdev,
169 struct net_device *dev, u8 *mac,
170 struct station_parameters *params)
171{
172 int ret;
173 trace_rdev_add_station(&rdev->wiphy, dev, mac, params);
174 ret = rdev->ops->add_station(&rdev->wiphy, dev, mac, params);
175 trace_rdev_return_int(&rdev->wiphy, ret);
176 return ret;
177}
178
179static inline int rdev_del_station(struct cfg80211_registered_device *rdev,
180 struct net_device *dev, u8 *mac)
181{
182 int ret;
183 trace_rdev_del_station(&rdev->wiphy, dev, mac);
184 ret = rdev->ops->del_station(&rdev->wiphy, dev, mac);
185 trace_rdev_return_int(&rdev->wiphy, ret);
186 return ret;
187}
188
189static inline int rdev_change_station(struct cfg80211_registered_device *rdev,
190 struct net_device *dev, u8 *mac,
191 struct station_parameters *params)
192{
193 int ret;
194 trace_rdev_change_station(&rdev->wiphy, dev, mac, params);
195 ret = rdev->ops->change_station(&rdev->wiphy, dev, mac, params);
196 trace_rdev_return_int(&rdev->wiphy, ret);
197 return ret;
198}
199
200static inline int rdev_get_station(struct cfg80211_registered_device *rdev,
201 struct net_device *dev, u8 *mac,
202 struct station_info *sinfo)
203{
204 int ret;
205 trace_rdev_get_station(&rdev->wiphy, dev, mac);
206 ret = rdev->ops->get_station(&rdev->wiphy, dev, mac, sinfo);
207 trace_rdev_return_int_station_info(&rdev->wiphy, ret, sinfo);
208 return ret;
209}
210
211static inline int rdev_dump_station(struct cfg80211_registered_device *rdev,
212 struct net_device *dev, int idx, u8 *mac,
213 struct station_info *sinfo)
214{
215 int ret;
216 trace_rdev_dump_station(&rdev->wiphy, dev, idx, mac);
217 ret = rdev->ops->dump_station(&rdev->wiphy, dev, idx, mac, sinfo);
218 trace_rdev_return_int_station_info(&rdev->wiphy, ret, sinfo);
219 return ret;
220}
221
222static inline int rdev_add_mpath(struct cfg80211_registered_device *rdev,
223 struct net_device *dev, u8 *dst, u8 *next_hop)
224{
225 int ret;
226 trace_rdev_add_mpath(&rdev->wiphy, dev, dst, next_hop);
227 ret = rdev->ops->add_mpath(&rdev->wiphy, dev, dst, next_hop);
228 trace_rdev_return_int(&rdev->wiphy, ret);
229 return ret;
230}
231
232static inline int rdev_del_mpath(struct cfg80211_registered_device *rdev,
233 struct net_device *dev, u8 *dst)
234{
235 int ret;
236 trace_rdev_del_mpath(&rdev->wiphy, dev, dst);
237 ret = rdev->ops->del_mpath(&rdev->wiphy, dev, dst);
238 trace_rdev_return_int(&rdev->wiphy, ret);
239 return ret;
240}
241
242static inline int rdev_change_mpath(struct cfg80211_registered_device *rdev,
243 struct net_device *dev, u8 *dst,
244 u8 *next_hop)
245{
246 int ret;
247 trace_rdev_change_mpath(&rdev->wiphy, dev, dst, next_hop);
248 ret = rdev->ops->change_mpath(&rdev->wiphy, dev, dst, next_hop);
249 trace_rdev_return_int(&rdev->wiphy, ret);
250 return ret;
251}
252
253static inline int rdev_get_mpath(struct cfg80211_registered_device *rdev,
254 struct net_device *dev, u8 *dst, u8 *next_hop,
255 struct mpath_info *pinfo)
256{
257 int ret;
258 trace_rdev_get_mpath(&rdev->wiphy, dev, dst, next_hop);
259 ret = rdev->ops->get_mpath(&rdev->wiphy, dev, dst, next_hop, pinfo);
260 trace_rdev_return_int_mpath_info(&rdev->wiphy, ret, pinfo);
261 return ret;
262
263}
264
265static inline int rdev_dump_mpath(struct cfg80211_registered_device *rdev,
266 struct net_device *dev, int idx, u8 *dst,
267 u8 *next_hop, struct mpath_info *pinfo)
268
269{
270 int ret;
271 trace_rdev_dump_mpath(&rdev->wiphy, dev, idx, dst, next_hop);
272 ret = rdev->ops->dump_mpath(&rdev->wiphy, dev, idx, dst, next_hop,
273 pinfo);
274 trace_rdev_return_int_mpath_info(&rdev->wiphy, ret, pinfo);
275 return ret;
276}
277
278static inline int
279rdev_get_mesh_config(struct cfg80211_registered_device *rdev,
280 struct net_device *dev, struct mesh_config *conf)
281{
282 int ret;
283 trace_rdev_get_mesh_config(&rdev->wiphy, dev);
284 ret = rdev->ops->get_mesh_config(&rdev->wiphy, dev, conf);
285 trace_rdev_return_int_mesh_config(&rdev->wiphy, ret, conf);
286 return ret;
287}
288
289static inline int
290rdev_update_mesh_config(struct cfg80211_registered_device *rdev,
291 struct net_device *dev, u32 mask,
292 const struct mesh_config *nconf)
293{
294 int ret;
295 trace_rdev_update_mesh_config(&rdev->wiphy, dev, mask, nconf);
296 ret = rdev->ops->update_mesh_config(&rdev->wiphy, dev, mask, nconf);
297 trace_rdev_return_int(&rdev->wiphy, ret);
298 return ret;
299}
300
301static inline int rdev_join_mesh(struct cfg80211_registered_device *rdev,
302 struct net_device *dev,
303 const struct mesh_config *conf,
304 const struct mesh_setup *setup)
305{
306 int ret;
307 trace_rdev_join_mesh(&rdev->wiphy, dev, conf, setup);
308 ret = rdev->ops->join_mesh(&rdev->wiphy, dev, conf, setup);
309 trace_rdev_return_int(&rdev->wiphy, ret);
310 return ret;
311}
312
313
314static inline int rdev_leave_mesh(struct cfg80211_registered_device *rdev,
315 struct net_device *dev)
316{
317 int ret;
318 trace_rdev_leave_mesh(&rdev->wiphy, dev);
319 ret = rdev->ops->leave_mesh(&rdev->wiphy, dev);
320 trace_rdev_return_int(&rdev->wiphy, ret);
321 return ret;
322}
323
324static inline int rdev_change_bss(struct cfg80211_registered_device *rdev,
325 struct net_device *dev,
326 struct bss_parameters *params)
327
328{
329 int ret;
330 trace_rdev_change_bss(&rdev->wiphy, dev, params);
331 ret = rdev->ops->change_bss(&rdev->wiphy, dev, params);
332 trace_rdev_return_int(&rdev->wiphy, ret);
333 return ret;
334}
335
336static inline int rdev_set_txq_params(struct cfg80211_registered_device *rdev,
337 struct net_device *dev,
338 struct ieee80211_txq_params *params)
339
340{
341 int ret;
342 trace_rdev_set_txq_params(&rdev->wiphy, dev, params);
343 ret = rdev->ops->set_txq_params(&rdev->wiphy, dev, params);
344 trace_rdev_return_int(&rdev->wiphy, ret);
345 return ret;
346}
347
348static inline int
349rdev_libertas_set_mesh_channel(struct cfg80211_registered_device *rdev,
350 struct net_device *dev,
351 struct ieee80211_channel *chan)
352{
353 int ret;
354 trace_rdev_libertas_set_mesh_channel(&rdev->wiphy, dev, chan);
355 ret = rdev->ops->libertas_set_mesh_channel(&rdev->wiphy, dev, chan);
356 trace_rdev_return_int(&rdev->wiphy, ret);
357 return ret;
358}
359
360static inline int
361rdev_set_monitor_channel(struct cfg80211_registered_device *rdev,
362 struct ieee80211_channel *chan,
363 enum nl80211_channel_type channel_type)
364{
365 int ret;
366 trace_rdev_set_monitor_channel(&rdev->wiphy, chan, channel_type);
367 ret = rdev->ops->set_monitor_channel(&rdev->wiphy, chan, channel_type);
368 trace_rdev_return_int(&rdev->wiphy, ret);
369 return ret;
370}
371
372static inline int rdev_scan(struct cfg80211_registered_device *rdev,
373 struct cfg80211_scan_request *request)
374{
375 int ret;
376 trace_rdev_scan(&rdev->wiphy, request);
377 ret = rdev->ops->scan(&rdev->wiphy, request);
378 trace_rdev_return_int(&rdev->wiphy, ret);
379 return ret;
380}
381
382static inline int rdev_auth(struct cfg80211_registered_device *rdev,
383 struct net_device *dev,
384 struct cfg80211_auth_request *req)
385{
386 int ret;
387 trace_rdev_auth(&rdev->wiphy, dev, req);
388 ret = rdev->ops->auth(&rdev->wiphy, dev, req);
389 trace_rdev_return_int(&rdev->wiphy, ret);
390 return ret;
391}
392
393static inline int rdev_assoc(struct cfg80211_registered_device *rdev,
394 struct net_device *dev,
395 struct cfg80211_assoc_request *req)
396{
397 int ret;
398 trace_rdev_assoc(&rdev->wiphy, dev, req);
399 ret = rdev->ops->assoc(&rdev->wiphy, dev, req);
400 trace_rdev_return_int(&rdev->wiphy, ret);
401 return ret;
402}
403
404static inline int rdev_deauth(struct cfg80211_registered_device *rdev,
405 struct net_device *dev,
406 struct cfg80211_deauth_request *req)
407{
408 int ret;
409 trace_rdev_deauth(&rdev->wiphy, dev, req);
410 ret = rdev->ops->deauth(&rdev->wiphy, dev, req);
411 trace_rdev_return_int(&rdev->wiphy, ret);
412 return ret;
413}
414
415static inline int rdev_disassoc(struct cfg80211_registered_device *rdev,
416 struct net_device *dev,
417 struct cfg80211_disassoc_request *req)
418{
419 int ret;
420 trace_rdev_disassoc(&rdev->wiphy, dev, req);
421 ret = rdev->ops->disassoc(&rdev->wiphy, dev, req);
422 trace_rdev_return_int(&rdev->wiphy, ret);
423 return ret;
424}
425
426static inline int rdev_connect(struct cfg80211_registered_device *rdev,
427 struct net_device *dev,
428 struct cfg80211_connect_params *sme)
429{
430 int ret;
431 trace_rdev_connect(&rdev->wiphy, dev, sme);
432 ret = rdev->ops->connect(&rdev->wiphy, dev, sme);
433 trace_rdev_return_int(&rdev->wiphy, ret);
434 return ret;
435}
436
437static inline int rdev_disconnect(struct cfg80211_registered_device *rdev,
438 struct net_device *dev, u16 reason_code)
439{
440 int ret;
441 trace_rdev_disconnect(&rdev->wiphy, dev, reason_code);
442 ret = rdev->ops->disconnect(&rdev->wiphy, dev, reason_code);
443 trace_rdev_return_int(&rdev->wiphy, ret);
444 return ret;
445}
446
447static inline int rdev_join_ibss(struct cfg80211_registered_device *rdev,
448 struct net_device *dev,
449 struct cfg80211_ibss_params *params)
450{
451 int ret;
452 trace_rdev_join_ibss(&rdev->wiphy, dev, params);
453 ret = rdev->ops->join_ibss(&rdev->wiphy, dev, params);
454 trace_rdev_return_int(&rdev->wiphy, ret);
455 return ret;
456}
457
458static inline int rdev_leave_ibss(struct cfg80211_registered_device *rdev,
459 struct net_device *dev)
460{
461 int ret;
462 trace_rdev_leave_ibss(&rdev->wiphy, dev);
463 ret = rdev->ops->leave_ibss(&rdev->wiphy, dev);
464 trace_rdev_return_int(&rdev->wiphy, ret);
465 return ret;
466}
467
468static inline int
469rdev_set_wiphy_params(struct cfg80211_registered_device *rdev, u32 changed)
470{
471 int ret;
472 trace_rdev_set_wiphy_params(&rdev->wiphy, changed);
473 ret = rdev->ops->set_wiphy_params(&rdev->wiphy, changed);
474 trace_rdev_return_int(&rdev->wiphy, ret);
475 return ret;
476}
477
478static inline int rdev_set_tx_power(struct cfg80211_registered_device *rdev,
479 enum nl80211_tx_power_setting type, int mbm)
480{
481 int ret;
482 trace_rdev_set_tx_power(&rdev->wiphy, type, mbm);
483 ret = rdev->ops->set_tx_power(&rdev->wiphy, type, mbm);
484 trace_rdev_return_int(&rdev->wiphy, ret);
485 return ret;
486}
487
488static inline int rdev_get_tx_power(struct cfg80211_registered_device *rdev,
489 int *dbm)
490{
491 int ret;
492 trace_rdev_get_tx_power(&rdev->wiphy);
493 ret = rdev->ops->get_tx_power(&rdev->wiphy, dbm);
494 trace_rdev_return_int_int(&rdev->wiphy, ret, *dbm);
495 return ret;
496}
497
498static inline int rdev_set_wds_peer(struct cfg80211_registered_device *rdev,
499 struct net_device *dev, const u8 *addr)
500{
501 int ret;
502 trace_rdev_set_wds_peer(&rdev->wiphy, dev, addr);
503 ret = rdev->ops->set_wds_peer(&rdev->wiphy, dev, addr);
504 trace_rdev_return_int(&rdev->wiphy, ret);
505 return ret;
506}
507
508static inline void rdev_rfkill_poll(struct cfg80211_registered_device *rdev)
509{
510 trace_rdev_rfkill_poll(&rdev->wiphy);
511 rdev->ops->rfkill_poll(&rdev->wiphy);
512 trace_rdev_return_void(&rdev->wiphy);
513}
514
515
516#ifdef CONFIG_NL80211_TESTMODE
517static inline int rdev_testmode_cmd(struct cfg80211_registered_device *rdev,
518 void *data, int len)
519{
520 int ret;
521 trace_rdev_testmode_cmd(&rdev->wiphy);
522 ret = rdev->ops->testmode_cmd(&rdev->wiphy, data, len);
523 trace_rdev_return_int(&rdev->wiphy, ret);
524 return ret;
525}
526
527static inline int rdev_testmode_dump(struct cfg80211_registered_device *rdev,
528 struct sk_buff *skb,
529 struct netlink_callback *cb, void *data,
530 int len)
531{
532 int ret;
533 trace_rdev_testmode_dump(&rdev->wiphy);
534 ret = rdev->ops->testmode_dump(&rdev->wiphy, skb, cb, data, len);
535 trace_rdev_return_int(&rdev->wiphy, ret);
536 return ret;
537}
538#endif
539
540static inline int
541rdev_set_bitrate_mask(struct cfg80211_registered_device *rdev,
542 struct net_device *dev, const u8 *peer,
543 const struct cfg80211_bitrate_mask *mask)
544{
545 int ret;
546 trace_rdev_set_bitrate_mask(&rdev->wiphy, dev, peer, mask);
547 ret = rdev->ops->set_bitrate_mask(&rdev->wiphy, dev, peer, mask);
548 trace_rdev_return_int(&rdev->wiphy, ret);
549 return ret;
550}
551
552static inline int rdev_dump_survey(struct cfg80211_registered_device *rdev,
553 struct net_device *netdev, int idx,
554 struct survey_info *info)
555{
556 int ret;
557 trace_rdev_dump_survey(&rdev->wiphy, netdev, idx);
558 ret = rdev->ops->dump_survey(&rdev->wiphy, netdev, idx, info);
559 if (ret < 0)
560 trace_rdev_return_int(&rdev->wiphy, ret);
561 else
562 trace_rdev_return_int_survey_info(&rdev->wiphy, ret, info);
563 return ret;
564}
565
566static inline int rdev_set_pmksa(struct cfg80211_registered_device *rdev,
567 struct net_device *netdev,
568 struct cfg80211_pmksa *pmksa)
569{
570 int ret;
571 trace_rdev_set_pmksa(&rdev->wiphy, netdev, pmksa);
572 ret = rdev->ops->set_pmksa(&rdev->wiphy, netdev, pmksa);
573 trace_rdev_return_int(&rdev->wiphy, ret);
574 return ret;
575}
576
577static inline int rdev_del_pmksa(struct cfg80211_registered_device *rdev,
578 struct net_device *netdev,
579 struct cfg80211_pmksa *pmksa)
580{
581 int ret;
582 trace_rdev_del_pmksa(&rdev->wiphy, netdev, pmksa);
583 ret = rdev->ops->del_pmksa(&rdev->wiphy, netdev, pmksa);
584 trace_rdev_return_int(&rdev->wiphy, ret);
585 return ret;
586}
587
588static inline int rdev_flush_pmksa(struct cfg80211_registered_device *rdev,
589 struct net_device *netdev)
590{
591 int ret;
592 trace_rdev_flush_pmksa(&rdev->wiphy, netdev);
593 ret = rdev->ops->flush_pmksa(&rdev->wiphy, netdev);
594 trace_rdev_return_int(&rdev->wiphy, ret);
595 return ret;
596}
597
598static inline int
599rdev_remain_on_channel(struct cfg80211_registered_device *rdev,
600 struct wireless_dev *wdev,
601 struct ieee80211_channel *chan,
602 enum nl80211_channel_type channel_type,
603 unsigned int duration, u64 *cookie)
604{
605 int ret;
606 trace_rdev_remain_on_channel(&rdev->wiphy, wdev, chan, channel_type,
607 duration);
608 ret = rdev->ops->remain_on_channel(&rdev->wiphy, wdev, chan,
609 channel_type, duration, cookie);
610 trace_rdev_return_int_cookie(&rdev->wiphy, ret, *cookie);
611 return ret;
612}
613
614static inline int
615rdev_cancel_remain_on_channel(struct cfg80211_registered_device *rdev,
616 struct wireless_dev *wdev, u64 cookie)
617{
618 int ret;
619 trace_rdev_cancel_remain_on_channel(&rdev->wiphy, wdev, cookie);
620 ret = rdev->ops->cancel_remain_on_channel(&rdev->wiphy, wdev, cookie);
621 trace_rdev_return_int(&rdev->wiphy, ret);
622 return ret;
623}
624
625static inline int rdev_mgmt_tx(struct cfg80211_registered_device *rdev,
626 struct wireless_dev *wdev,
627 struct ieee80211_channel *chan, bool offchan,
628 enum nl80211_channel_type channel_type,
629 bool channel_type_valid, unsigned int wait,
630 const u8 *buf, size_t len, bool no_cck,
631 bool dont_wait_for_ack, u64 *cookie)
632{
633 int ret;
634 trace_rdev_mgmt_tx(&rdev->wiphy, wdev, chan, offchan, channel_type,
635 channel_type_valid, wait, no_cck, dont_wait_for_ack);
636 ret = rdev->ops->mgmt_tx(&rdev->wiphy, wdev, chan, offchan,
637 channel_type, channel_type_valid, wait, buf,
638 len, no_cck, dont_wait_for_ack, cookie);
639 trace_rdev_return_int_cookie(&rdev->wiphy, ret, *cookie);
640 return ret;
641}
642
643static inline int
644rdev_mgmt_tx_cancel_wait(struct cfg80211_registered_device *rdev,
645 struct wireless_dev *wdev, u64 cookie)
646{
647 int ret;
648 trace_rdev_mgmt_tx_cancel_wait(&rdev->wiphy, wdev, cookie);
649 ret = rdev->ops->mgmt_tx_cancel_wait(&rdev->wiphy, wdev, cookie);
650 trace_rdev_return_int(&rdev->wiphy, ret);
651 return ret;
652}
653
654static inline int rdev_set_power_mgmt(struct cfg80211_registered_device *rdev,
655 struct net_device *dev, bool enabled,
656 int timeout)
657{
658 int ret;
659 trace_rdev_set_power_mgmt(&rdev->wiphy, dev, enabled, timeout);
660 ret = rdev->ops->set_power_mgmt(&rdev->wiphy, dev, enabled, timeout);
661 trace_rdev_return_int(&rdev->wiphy, ret);
662 return ret;
663}
664
665static inline int
666rdev_set_cqm_rssi_config(struct cfg80211_registered_device *rdev,
667 struct net_device *dev, s32 rssi_thold, u32 rssi_hyst)
668{
669 int ret;
670 trace_rdev_set_cqm_rssi_config(&rdev->wiphy, dev, rssi_thold,
671 rssi_hyst);
672 ret = rdev->ops->set_cqm_rssi_config(&rdev->wiphy, dev, rssi_thold,
673 rssi_hyst);
674 trace_rdev_return_int(&rdev->wiphy, ret);
675 return ret;
676}
677
678static inline int
679rdev_set_cqm_txe_config(struct cfg80211_registered_device *rdev,
680 struct net_device *dev, u32 rate, u32 pkts, u32 intvl)
681{
682 int ret;
683 trace_rdev_set_cqm_txe_config(&rdev->wiphy, dev, rate, pkts, intvl);
684 ret = rdev->ops->set_cqm_txe_config(&rdev->wiphy, dev, rate, pkts,
685 intvl);
686 trace_rdev_return_int(&rdev->wiphy, ret);
687 return ret;
688}
689
690static inline void
691rdev_mgmt_frame_register(struct cfg80211_registered_device *rdev,
692 struct wireless_dev *wdev, u16 frame_type, bool reg)
693{
694 trace_rdev_mgmt_frame_register(&rdev->wiphy, wdev , frame_type, reg);
695 rdev->ops->mgmt_frame_register(&rdev->wiphy, wdev , frame_type, reg);
696 trace_rdev_return_void(&rdev->wiphy);
697}
698
699static inline int rdev_set_antenna(struct cfg80211_registered_device *rdev,
700 u32 tx_ant, u32 rx_ant)
701{
702 int ret;
703 trace_rdev_set_antenna(&rdev->wiphy, tx_ant, rx_ant);
704 ret = rdev->ops->set_antenna(&rdev->wiphy, tx_ant, rx_ant);
705 trace_rdev_return_int(&rdev->wiphy, ret);
706 return ret;
707}
708
709static inline int rdev_get_antenna(struct cfg80211_registered_device *rdev,
710 u32 *tx_ant, u32 *rx_ant)
711{
712 int ret;
713 trace_rdev_get_antenna(&rdev->wiphy);
714 ret = rdev->ops->get_antenna(&rdev->wiphy, tx_ant, rx_ant);
715 if (ret)
716 trace_rdev_return_int(&rdev->wiphy, ret);
717 else
718 trace_rdev_return_int_tx_rx(&rdev->wiphy, ret, *tx_ant,
719 *rx_ant);
720 return ret;
721}
722
723static inline int rdev_set_ringparam(struct cfg80211_registered_device *rdev,
724 u32 tx, u32 rx)
725{
726 int ret;
727 trace_rdev_set_ringparam(&rdev->wiphy, tx, rx);
728 ret = rdev->ops->set_ringparam(&rdev->wiphy, tx, rx);
729 trace_rdev_return_int(&rdev->wiphy, ret);
730 return ret;
731}
732
733static inline void rdev_get_ringparam(struct cfg80211_registered_device *rdev,
734 u32 *tx, u32 *tx_max, u32 *rx,
735 u32 *rx_max)
736{
737 trace_rdev_get_ringparam(&rdev->wiphy);
738 rdev->ops->get_ringparam(&rdev->wiphy, tx, tx_max, rx, rx_max);
739 trace_rdev_return_void_tx_rx(&rdev->wiphy, *tx, *tx_max, *rx, *rx_max);
740}
741
742static inline int
743rdev_sched_scan_start(struct cfg80211_registered_device *rdev,
744 struct net_device *dev,
745 struct cfg80211_sched_scan_request *request)
746{
747 int ret;
748 trace_rdev_sched_scan_start(&rdev->wiphy, dev, request);
749 ret = rdev->ops->sched_scan_start(&rdev->wiphy, dev, request);
750 trace_rdev_return_int(&rdev->wiphy, ret);
751 return ret;
752}
753
754static inline int rdev_sched_scan_stop(struct cfg80211_registered_device *rdev,
755 struct net_device *dev)
756{
757 int ret;
758 trace_rdev_sched_scan_stop(&rdev->wiphy, dev);
759 ret = rdev->ops->sched_scan_stop(&rdev->wiphy, dev);
760 trace_rdev_return_int(&rdev->wiphy, ret);
761 return ret;
762}
763
764static inline int rdev_set_rekey_data(struct cfg80211_registered_device *rdev,
765 struct net_device *dev,
766 struct cfg80211_gtk_rekey_data *data)
767{
768 int ret;
769 trace_rdev_set_rekey_data(&rdev->wiphy, dev);
770 ret = rdev->ops->set_rekey_data(&rdev->wiphy, dev, data);
771 trace_rdev_return_int(&rdev->wiphy, ret);
772 return ret;
773}
774
775static inline int rdev_tdls_mgmt(struct cfg80211_registered_device *rdev,
776 struct net_device *dev, u8 *peer,
777 u8 action_code, u8 dialog_token,
778 u16 status_code, const u8 *buf, size_t len)
779{
780 int ret;
781 trace_rdev_tdls_mgmt(&rdev->wiphy, dev, peer, action_code,
782 dialog_token, status_code, buf, len);
783 ret = rdev->ops->tdls_mgmt(&rdev->wiphy, dev, peer, action_code,
784 dialog_token, status_code, buf, len);
785 trace_rdev_return_int(&rdev->wiphy, ret);
786 return ret;
787}
788
789static inline int rdev_tdls_oper(struct cfg80211_registered_device *rdev,
790 struct net_device *dev, u8 *peer,
791 enum nl80211_tdls_operation oper)
792{
793 int ret;
794 trace_rdev_tdls_oper(&rdev->wiphy, dev, peer, oper);
795 ret = rdev->ops->tdls_oper(&rdev->wiphy, dev, peer, oper);
796 trace_rdev_return_int(&rdev->wiphy, ret);
797 return ret;
798}
799
800static inline int rdev_probe_client(struct cfg80211_registered_device *rdev,
801 struct net_device *dev, const u8 *peer,
802 u64 *cookie)
803{
804 int ret;
805 trace_rdev_probe_client(&rdev->wiphy, dev, peer);
806 ret = rdev->ops->probe_client(&rdev->wiphy, dev, peer, cookie);
807 trace_rdev_return_int_cookie(&rdev->wiphy, ret, *cookie);
808 return ret;
809}
810
811static inline int rdev_set_noack_map(struct cfg80211_registered_device *rdev,
812 struct net_device *dev, u16 noack_map)
813{
814 int ret;
815 trace_rdev_set_noack_map(&rdev->wiphy, dev, noack_map);
816 ret = rdev->ops->set_noack_map(&rdev->wiphy, dev, noack_map);
817 trace_rdev_return_int(&rdev->wiphy, ret);
818 return ret;
819}
820
821static inline int
822rdev_get_et_sset_count(struct cfg80211_registered_device *rdev,
823 struct net_device *dev, int sset)
824{
825 int ret;
826 trace_rdev_get_et_sset_count(&rdev->wiphy, dev, sset);
827 ret = rdev->ops->get_et_sset_count(&rdev->wiphy, dev, sset);
828 trace_rdev_return_int(&rdev->wiphy, ret);
829 return ret;
830}
831
832static inline void rdev_get_et_stats(struct cfg80211_registered_device *rdev,
833 struct net_device *dev,
834 struct ethtool_stats *stats, u64 *data)
835{
836 trace_rdev_get_et_stats(&rdev->wiphy, dev);
837 rdev->ops->get_et_stats(&rdev->wiphy, dev, stats, data);
838 trace_rdev_return_void(&rdev->wiphy);
839}
840
841static inline void rdev_get_et_strings(struct cfg80211_registered_device *rdev,
842 struct net_device *dev, u32 sset,
843 u8 *data)
844{
845 trace_rdev_get_et_strings(&rdev->wiphy, dev, sset);
846 rdev->ops->get_et_strings(&rdev->wiphy, dev, sset, data);
847 trace_rdev_return_void(&rdev->wiphy);
848}
849
850static inline struct ieee80211_channel
851*rdev_get_channel(struct cfg80211_registered_device *rdev,
852 struct wireless_dev *wdev, enum nl80211_channel_type *type)
853{
854 struct ieee80211_channel *ret;
855 trace_rdev_get_channel(&rdev->wiphy, wdev);
856 ret = rdev->ops->get_channel(&rdev->wiphy, wdev, type);
857 trace_rdev_return_channel(&rdev->wiphy, ret, *type);
858 return ret;
859}
860
861#endif /* __CFG80211_RDEV_OPS */
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index 9730c9862bdc..7f97a087f452 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -17,9 +17,58 @@
17#include "core.h" 17#include "core.h"
18#include "nl80211.h" 18#include "nl80211.h"
19#include "wext-compat.h" 19#include "wext-compat.h"
20#include "rdev-ops.h"
20 21
21#define IEEE80211_SCAN_RESULT_EXPIRE (30 * HZ) 22#define IEEE80211_SCAN_RESULT_EXPIRE (30 * HZ)
22 23
24static void bss_release(struct kref *ref)
25{
26 struct cfg80211_internal_bss *bss;
27
28 bss = container_of(ref, struct cfg80211_internal_bss, ref);
29 if (bss->pub.free_priv)
30 bss->pub.free_priv(&bss->pub);
31
32 if (bss->beacon_ies_allocated)
33 kfree(bss->pub.beacon_ies);
34 if (bss->proberesp_ies_allocated)
35 kfree(bss->pub.proberesp_ies);
36
37 BUG_ON(atomic_read(&bss->hold));
38
39 kfree(bss);
40}
41
42/* must hold dev->bss_lock! */
43static void __cfg80211_unlink_bss(struct cfg80211_registered_device *dev,
44 struct cfg80211_internal_bss *bss)
45{
46 list_del_init(&bss->list);
47 rb_erase(&bss->rbn, &dev->bss_tree);
48 kref_put(&bss->ref, bss_release);
49}
50
51/* must hold dev->bss_lock! */
52static void __cfg80211_bss_expire(struct cfg80211_registered_device *dev,
53 unsigned long expire_time)
54{
55 struct cfg80211_internal_bss *bss, *tmp;
56 bool expired = false;
57
58 list_for_each_entry_safe(bss, tmp, &dev->bss_list, list) {
59 if (atomic_read(&bss->hold))
60 continue;
61 if (!time_after(expire_time, bss->ts))
62 continue;
63
64 __cfg80211_unlink_bss(dev, bss);
65 expired = true;
66 }
67
68 if (expired)
69 dev->bss_generation++;
70}
71
23void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, bool leak) 72void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, bool leak)
24{ 73{
25 struct cfg80211_scan_request *request; 74 struct cfg80211_scan_request *request;
@@ -45,10 +94,17 @@ void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, bool leak)
45 if (wdev->netdev) 94 if (wdev->netdev)
46 cfg80211_sme_scan_done(wdev->netdev); 95 cfg80211_sme_scan_done(wdev->netdev);
47 96
48 if (request->aborted) 97 if (request->aborted) {
49 nl80211_send_scan_aborted(rdev, wdev); 98 nl80211_send_scan_aborted(rdev, wdev);
50 else 99 } else {
100 if (request->flags & NL80211_SCAN_FLAG_FLUSH) {
101 /* flush entries from previous scans */
102 spin_lock_bh(&rdev->bss_lock);
103 __cfg80211_bss_expire(rdev, request->scan_start);
104 spin_unlock_bh(&rdev->bss_lock);
105 }
51 nl80211_send_scan_done(rdev, wdev); 106 nl80211_send_scan_done(rdev, wdev);
107 }
52 108
53#ifdef CONFIG_CFG80211_WEXT 109#ifdef CONFIG_CFG80211_WEXT
54 if (wdev->netdev && !request->aborted) { 110 if (wdev->netdev && !request->aborted) {
@@ -89,6 +145,7 @@ void __cfg80211_scan_done(struct work_struct *wk)
89 145
90void cfg80211_scan_done(struct cfg80211_scan_request *request, bool aborted) 146void cfg80211_scan_done(struct cfg80211_scan_request *request, bool aborted)
91{ 147{
148 trace_cfg80211_scan_done(request, aborted);
92 WARN_ON(request != wiphy_to_dev(request->wiphy)->scan_req); 149 WARN_ON(request != wiphy_to_dev(request->wiphy)->scan_req);
93 150
94 request->aborted = aborted; 151 request->aborted = aborted;
@@ -99,22 +156,34 @@ EXPORT_SYMBOL(cfg80211_scan_done);
99void __cfg80211_sched_scan_results(struct work_struct *wk) 156void __cfg80211_sched_scan_results(struct work_struct *wk)
100{ 157{
101 struct cfg80211_registered_device *rdev; 158 struct cfg80211_registered_device *rdev;
159 struct cfg80211_sched_scan_request *request;
102 160
103 rdev = container_of(wk, struct cfg80211_registered_device, 161 rdev = container_of(wk, struct cfg80211_registered_device,
104 sched_scan_results_wk); 162 sched_scan_results_wk);
105 163
164 request = rdev->sched_scan_req;
165
106 mutex_lock(&rdev->sched_scan_mtx); 166 mutex_lock(&rdev->sched_scan_mtx);
107 167
108 /* we don't have sched_scan_req anymore if the scan is stopping */ 168 /* we don't have sched_scan_req anymore if the scan is stopping */
109 if (rdev->sched_scan_req) 169 if (request) {
110 nl80211_send_sched_scan_results(rdev, 170 if (request->flags & NL80211_SCAN_FLAG_FLUSH) {
111 rdev->sched_scan_req->dev); 171 /* flush entries from previous scans */
172 spin_lock_bh(&rdev->bss_lock);
173 __cfg80211_bss_expire(rdev, request->scan_start);
174 spin_unlock_bh(&rdev->bss_lock);
175 request->scan_start =
176 jiffies + msecs_to_jiffies(request->interval);
177 }
178 nl80211_send_sched_scan_results(rdev, request->dev);
179 }
112 180
113 mutex_unlock(&rdev->sched_scan_mtx); 181 mutex_unlock(&rdev->sched_scan_mtx);
114} 182}
115 183
116void cfg80211_sched_scan_results(struct wiphy *wiphy) 184void cfg80211_sched_scan_results(struct wiphy *wiphy)
117{ 185{
186 trace_cfg80211_sched_scan_results(wiphy);
118 /* ignore if we're not scanning */ 187 /* ignore if we're not scanning */
119 if (wiphy_to_dev(wiphy)->sched_scan_req) 188 if (wiphy_to_dev(wiphy)->sched_scan_req)
120 queue_work(cfg80211_wq, 189 queue_work(cfg80211_wq,
@@ -126,6 +195,8 @@ void cfg80211_sched_scan_stopped(struct wiphy *wiphy)
126{ 195{
127 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 196 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
128 197
198 trace_cfg80211_sched_scan_stopped(wiphy);
199
129 mutex_lock(&rdev->sched_scan_mtx); 200 mutex_lock(&rdev->sched_scan_mtx);
130 __cfg80211_stop_sched_scan(rdev, true); 201 __cfg80211_stop_sched_scan(rdev, true);
131 mutex_unlock(&rdev->sched_scan_mtx); 202 mutex_unlock(&rdev->sched_scan_mtx);
@@ -145,7 +216,7 @@ int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev,
145 dev = rdev->sched_scan_req->dev; 216 dev = rdev->sched_scan_req->dev;
146 217
147 if (!driver_initiated) { 218 if (!driver_initiated) {
148 int err = rdev->ops->sched_scan_stop(&rdev->wiphy, dev); 219 int err = rdev_sched_scan_stop(rdev, dev);
149 if (err) 220 if (err)
150 return err; 221 return err;
151 } 222 }
@@ -158,24 +229,6 @@ int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev,
158 return 0; 229 return 0;
159} 230}
160 231
161static void bss_release(struct kref *ref)
162{
163 struct cfg80211_internal_bss *bss;
164
165 bss = container_of(ref, struct cfg80211_internal_bss, ref);
166 if (bss->pub.free_priv)
167 bss->pub.free_priv(&bss->pub);
168
169 if (bss->beacon_ies_allocated)
170 kfree(bss->pub.beacon_ies);
171 if (bss->proberesp_ies_allocated)
172 kfree(bss->pub.proberesp_ies);
173
174 BUG_ON(atomic_read(&bss->hold));
175
176 kfree(bss);
177}
178
179/* must hold dev->bss_lock! */ 232/* must hold dev->bss_lock! */
180void cfg80211_bss_age(struct cfg80211_registered_device *dev, 233void cfg80211_bss_age(struct cfg80211_registered_device *dev,
181 unsigned long age_secs) 234 unsigned long age_secs)
@@ -188,32 +241,9 @@ void cfg80211_bss_age(struct cfg80211_registered_device *dev,
188 } 241 }
189} 242}
190 243
191/* must hold dev->bss_lock! */
192static void __cfg80211_unlink_bss(struct cfg80211_registered_device *dev,
193 struct cfg80211_internal_bss *bss)
194{
195 list_del_init(&bss->list);
196 rb_erase(&bss->rbn, &dev->bss_tree);
197 kref_put(&bss->ref, bss_release);
198}
199
200/* must hold dev->bss_lock! */
201void cfg80211_bss_expire(struct cfg80211_registered_device *dev) 244void cfg80211_bss_expire(struct cfg80211_registered_device *dev)
202{ 245{
203 struct cfg80211_internal_bss *bss, *tmp; 246 __cfg80211_bss_expire(dev, jiffies - IEEE80211_SCAN_RESULT_EXPIRE);
204 bool expired = false;
205
206 list_for_each_entry_safe(bss, tmp, &dev->bss_list, list) {
207 if (atomic_read(&bss->hold))
208 continue;
209 if (!time_after(jiffies, bss->ts + IEEE80211_SCAN_RESULT_EXPIRE))
210 continue;
211 __cfg80211_unlink_bss(dev, bss);
212 expired = true;
213 }
214
215 if (expired)
216 dev->bss_generation++;
217} 247}
218 248
219const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len) 249const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len)
@@ -459,6 +489,9 @@ struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy,
459 struct cfg80211_internal_bss *bss, *res = NULL; 489 struct cfg80211_internal_bss *bss, *res = NULL;
460 unsigned long now = jiffies; 490 unsigned long now = jiffies;
461 491
492 trace_cfg80211_get_bss(wiphy, channel, bssid, ssid, ssid_len, capa_mask,
493 capa_val);
494
462 spin_lock_bh(&dev->bss_lock); 495 spin_lock_bh(&dev->bss_lock);
463 496
464 list_for_each_entry(bss, &dev->bss_list, list) { 497 list_for_each_entry(bss, &dev->bss_list, list) {
@@ -480,6 +513,7 @@ struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy,
480 spin_unlock_bh(&dev->bss_lock); 513 spin_unlock_bh(&dev->bss_lock);
481 if (!res) 514 if (!res)
482 return NULL; 515 return NULL;
516 trace_cfg80211_return_bss(&res->pub);
483 return &res->pub; 517 return &res->pub;
484} 518}
485EXPORT_SYMBOL(cfg80211_get_bss); 519EXPORT_SYMBOL(cfg80211_get_bss);
@@ -792,6 +826,7 @@ cfg80211_inform_bss(struct wiphy *wiphy,
792 if (res->pub.capability & WLAN_CAPABILITY_ESS) 826 if (res->pub.capability & WLAN_CAPABILITY_ESS)
793 regulatory_hint_found_beacon(wiphy, channel, gfp); 827 regulatory_hint_found_beacon(wiphy, channel, gfp);
794 828
829 trace_cfg80211_return_bss(&res->pub);
795 /* cfg80211_bss_update gives us a referenced result */ 830 /* cfg80211_bss_update gives us a referenced result */
796 return &res->pub; 831 return &res->pub;
797} 832}
@@ -804,10 +839,13 @@ cfg80211_inform_bss_frame(struct wiphy *wiphy,
804 s32 signal, gfp_t gfp) 839 s32 signal, gfp_t gfp)
805{ 840{
806 struct cfg80211_internal_bss *res; 841 struct cfg80211_internal_bss *res;
842
807 size_t ielen = len - offsetof(struct ieee80211_mgmt, 843 size_t ielen = len - offsetof(struct ieee80211_mgmt,
808 u.probe_resp.variable); 844 u.probe_resp.variable);
809 size_t privsz; 845 size_t privsz;
810 846
847 trace_cfg80211_inform_bss_frame(wiphy, channel, mgmt, len, signal);
848
811 if (WARN_ON(!mgmt)) 849 if (WARN_ON(!mgmt))
812 return NULL; 850 return NULL;
813 851
@@ -861,6 +899,7 @@ cfg80211_inform_bss_frame(struct wiphy *wiphy,
861 if (res->pub.capability & WLAN_CAPABILITY_ESS) 899 if (res->pub.capability & WLAN_CAPABILITY_ESS)
862 regulatory_hint_found_beacon(wiphy, channel, gfp); 900 regulatory_hint_found_beacon(wiphy, channel, gfp);
863 901
902 trace_cfg80211_return_bss(&res->pub);
864 /* cfg80211_bss_update gives us a referenced result */ 903 /* cfg80211_bss_update gives us a referenced result */
865 return &res->pub; 904 return &res->pub;
866} 905}
@@ -962,6 +1001,7 @@ int cfg80211_wext_siwscan(struct net_device *dev,
962 creq->ssids = (void *)&creq->channels[n_channels]; 1001 creq->ssids = (void *)&creq->channels[n_channels];
963 creq->n_channels = n_channels; 1002 creq->n_channels = n_channels;
964 creq->n_ssids = 1; 1003 creq->n_ssids = 1;
1004 creq->scan_start = jiffies;
965 1005
966 /* translate "Scan on frequencies" request */ 1006 /* translate "Scan on frequencies" request */
967 i = 0; 1007 i = 0;
@@ -1026,7 +1066,7 @@ int cfg80211_wext_siwscan(struct net_device *dev,
1026 creq->rates[i] = (1 << wiphy->bands[i]->n_bitrates) - 1; 1066 creq->rates[i] = (1 << wiphy->bands[i]->n_bitrates) - 1;
1027 1067
1028 rdev->scan_req = creq; 1068 rdev->scan_req = creq;
1029 err = rdev->ops->scan(wiphy, creq); 1069 err = rdev_scan(rdev, creq);
1030 if (err) { 1070 if (err) {
1031 rdev->scan_req = NULL; 1071 rdev->scan_req = NULL;
1032 /* creq will be freed below */ 1072 /* creq will be freed below */
diff --git a/net/wireless/sme.c b/net/wireless/sme.c
index 6f39cb808302..c7490027237d 100644
--- a/net/wireless/sme.c
+++ b/net/wireless/sme.c
@@ -16,6 +16,7 @@
16#include <net/rtnetlink.h> 16#include <net/rtnetlink.h>
17#include "nl80211.h" 17#include "nl80211.h"
18#include "reg.h" 18#include "reg.h"
19#include "rdev-ops.h"
19 20
20struct cfg80211_conn { 21struct cfg80211_conn {
21 struct cfg80211_connect_params params; 22 struct cfg80211_connect_params params;
@@ -138,10 +139,11 @@ static int cfg80211_conn_scan(struct wireless_dev *wdev)
138 139
139 request->wdev = wdev; 140 request->wdev = wdev;
140 request->wiphy = &rdev->wiphy; 141 request->wiphy = &rdev->wiphy;
142 request->scan_start = jiffies;
141 143
142 rdev->scan_req = request; 144 rdev->scan_req = request;
143 145
144 err = rdev->ops->scan(wdev->wiphy, request); 146 err = rdev_scan(rdev, request);
145 if (!err) { 147 if (!err) {
146 wdev->conn->state = CFG80211_CONN_SCANNING; 148 wdev->conn->state = CFG80211_CONN_SCANNING;
147 nl80211_send_scan_start(rdev, wdev); 149 nl80211_send_scan_start(rdev, wdev);
@@ -179,7 +181,7 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev)
179 params->ssid, params->ssid_len, 181 params->ssid, params->ssid_len,
180 NULL, 0, 182 NULL, 0,
181 params->key, params->key_len, 183 params->key, params->key_len,
182 params->key_idx); 184 params->key_idx, NULL, 0);
183 case CFG80211_CONN_ASSOCIATE_NEXT: 185 case CFG80211_CONN_ASSOCIATE_NEXT:
184 BUG_ON(!rdev->ops->assoc); 186 BUG_ON(!rdev->ops->assoc);
185 wdev->conn->state = CFG80211_CONN_ASSOCIATING; 187 wdev->conn->state = CFG80211_CONN_ASSOCIATING;
@@ -716,7 +718,7 @@ void __cfg80211_disconnected(struct net_device *dev, const u8 *ie,
716 */ 718 */
717 if (rdev->ops->del_key) 719 if (rdev->ops->del_key)
718 for (i = 0; i < 6; i++) 720 for (i = 0; i < 6; i++)
719 rdev->ops->del_key(wdev->wiphy, dev, i, false, NULL); 721 rdev_del_key(rdev, dev, i, false, NULL);
720 722
721#ifdef CONFIG_CFG80211_WEXT 723#ifdef CONFIG_CFG80211_WEXT
722 memset(&wrqu, 0, sizeof(wrqu)); 724 memset(&wrqu, 0, sizeof(wrqu));
@@ -892,7 +894,7 @@ int __cfg80211_connect(struct cfg80211_registered_device *rdev,
892 } else { 894 } else {
893 wdev->sme_state = CFG80211_SME_CONNECTING; 895 wdev->sme_state = CFG80211_SME_CONNECTING;
894 wdev->connect_keys = connkeys; 896 wdev->connect_keys = connkeys;
895 err = rdev->ops->connect(&rdev->wiphy, dev, connect); 897 err = rdev_connect(rdev, dev, connect);
896 if (err) { 898 if (err) {
897 wdev->connect_keys = NULL; 899 wdev->connect_keys = NULL;
898 wdev->sme_state = CFG80211_SME_IDLE; 900 wdev->sme_state = CFG80211_SME_IDLE;
@@ -964,7 +966,7 @@ int __cfg80211_disconnect(struct cfg80211_registered_device *rdev,
964 if (err) 966 if (err)
965 return err; 967 return err;
966 } else { 968 } else {
967 err = rdev->ops->disconnect(&rdev->wiphy, dev, reason); 969 err = rdev_disconnect(rdev, dev, reason);
968 if (err) 970 if (err)
969 return err; 971 return err;
970 } 972 }
diff --git a/net/wireless/sysfs.c b/net/wireless/sysfs.c
index ff574597a854..9bf6d5e32166 100644
--- a/net/wireless/sysfs.c
+++ b/net/wireless/sysfs.c
@@ -16,6 +16,7 @@
16#include <net/cfg80211.h> 16#include <net/cfg80211.h>
17#include "sysfs.h" 17#include "sysfs.h"
18#include "core.h" 18#include "core.h"
19#include "rdev-ops.h"
19 20
20static inline struct cfg80211_registered_device *dev_to_rdev( 21static inline struct cfg80211_registered_device *dev_to_rdev(
21 struct device *dev) 22 struct device *dev)
@@ -94,7 +95,7 @@ static int wiphy_suspend(struct device *dev, pm_message_t state)
94 if (rdev->ops->suspend) { 95 if (rdev->ops->suspend) {
95 rtnl_lock(); 96 rtnl_lock();
96 if (rdev->wiphy.registered) 97 if (rdev->wiphy.registered)
97 ret = rdev->ops->suspend(&rdev->wiphy, rdev->wowlan); 98 ret = rdev_suspend(rdev);
98 rtnl_unlock(); 99 rtnl_unlock();
99 } 100 }
100 101
@@ -114,7 +115,7 @@ static int wiphy_resume(struct device *dev)
114 if (rdev->ops->resume) { 115 if (rdev->ops->resume) {
115 rtnl_lock(); 116 rtnl_lock();
116 if (rdev->wiphy.registered) 117 if (rdev->wiphy.registered)
117 ret = rdev->ops->resume(&rdev->wiphy); 118 ret = rdev_resume(rdev);
118 rtnl_unlock(); 119 rtnl_unlock();
119 } 120 }
120 121
diff --git a/net/wireless/trace.c b/net/wireless/trace.c
new file mode 100644
index 000000000000..95f997fad755
--- /dev/null
+++ b/net/wireless/trace.c
@@ -0,0 +1,7 @@
1#include <linux/module.h>
2
3#ifndef __CHECKER__
4#define CREATE_TRACE_POINTS
5#include "trace.h"
6
7#endif
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
new file mode 100644
index 000000000000..857734c4b357
--- /dev/null
+++ b/net/wireless/trace.h
@@ -0,0 +1,2286 @@
1#undef TRACE_SYSTEM
2#define TRACE_SYSTEM cfg80211
3
4#if !defined(__RDEV_OPS_TRACE) || defined(TRACE_HEADER_MULTI_READ)
5#define __RDEV_OPS_TRACE
6
7#include <linux/tracepoint.h>
8
9#include <linux/rtnetlink.h>
10#include <net/cfg80211.h>
11#include "core.h"
12
13#define MAC_ENTRY(entry_mac) __array(u8, entry_mac, ETH_ALEN)
14#define MAC_ASSIGN(entry_mac, given_mac) do { \
15 if (given_mac) \
16 memcpy(__entry->entry_mac, given_mac, ETH_ALEN); \
17 else \
18 memset(__entry->entry_mac, 0, ETH_ALEN); \
19 } while (0)
20#define MAC_PR_FMT "%pM"
21#define MAC_PR_ARG(entry_mac) (__entry->entry_mac)
22
23#define WIPHY_ENTRY MAC_ENTRY(wiphy_mac)
24#define WIPHY_ASSIGN MAC_ASSIGN(wiphy_mac, wiphy->perm_addr)
25#define WIPHY_PR_FMT "wiphy " MAC_PR_FMT
26#define WIPHY_PR_ARG MAC_PR_ARG(wiphy_mac)
27
28#define WDEV_ENTRY __field(u32, id)
29#define WDEV_ASSIGN (__entry->id) = (wdev->identifier)
30#define WDEV_PR_FMT ", wdev id: %u"
31#define WDEV_PR_ARG (__entry->id)
32
33#define NETDEV_ENTRY __array(char, name, IFNAMSIZ) \
34 MAC_ENTRY(netdev_addr) \
35 __field(int, ifindex)
36#define NETDEV_ASSIGN \
37 do { \
38 memcpy(__entry->name, netdev->name, IFNAMSIZ); \
39 MAC_ASSIGN(netdev_addr, netdev->dev_addr); \
40 (__entry->ifindex) = (netdev->ifindex); \
41 } while (0)
42#define NETDEV_PR_FMT ", netdev - name: %s, addr: " MAC_PR_FMT \
43 ", intf index: %d"
44#define NETDEV_PR_ARG (__entry->name), MAC_PR_ARG(netdev_addr), \
45 (__entry->ifindex)
46
47#define MESH_CFG_ENTRY __field(u16, dot11MeshRetryTimeout) \
48 __field(u16, dot11MeshConfirmTimeout) \
49 __field(u16, dot11MeshHoldingTimeout) \
50 __field(u16, dot11MeshMaxPeerLinks) \
51 __field(u8, dot11MeshMaxRetries) \
52 __field(u8, dot11MeshTTL) \
53 __field(u8, element_ttl) \
54 __field(bool, auto_open_plinks) \
55 __field(u32, dot11MeshNbrOffsetMaxNeighbor) \
56 __field(u8, dot11MeshHWMPmaxPREQretries) \
57 __field(u32, path_refresh_time) \
58 __field(u32, dot11MeshHWMPactivePathTimeout) \
59 __field(u16, min_discovery_timeout) \
60 __field(u16, dot11MeshHWMPpreqMinInterval) \
61 __field(u16, dot11MeshHWMPperrMinInterval) \
62 __field(u16, dot11MeshHWMPnetDiameterTraversalTime) \
63 __field(u8, dot11MeshHWMPRootMode) \
64 __field(u16, dot11MeshHWMPRannInterval) \
65 __field(bool, dot11MeshGateAnnouncementProtocol) \
66 __field(bool, dot11MeshForwarding) \
67 __field(s32, rssi_threshold) \
68 __field(u16, ht_opmode) \
69 __field(u32, dot11MeshHWMPactivePathToRootTimeout) \
70 __field(u16, dot11MeshHWMProotInterval) \
71 __field(u16, dot11MeshHWMPconfirmationInterval)
72#define MESH_CFG_ASSIGN \
73 do { \
74 __entry->dot11MeshRetryTimeout = conf->dot11MeshRetryTimeout; \
75 __entry->dot11MeshConfirmTimeout = \
76 conf->dot11MeshConfirmTimeout; \
77 __entry->dot11MeshHoldingTimeout = \
78 conf->dot11MeshHoldingTimeout; \
79 __entry->dot11MeshMaxPeerLinks = conf->dot11MeshMaxPeerLinks; \
80 __entry->dot11MeshMaxRetries = conf->dot11MeshMaxRetries; \
81 __entry->dot11MeshTTL = conf->dot11MeshTTL; \
82 __entry->element_ttl = conf->element_ttl; \
83 __entry->auto_open_plinks = conf->auto_open_plinks; \
84 __entry->dot11MeshNbrOffsetMaxNeighbor = \
85 conf->dot11MeshNbrOffsetMaxNeighbor; \
86 __entry->dot11MeshHWMPmaxPREQretries = \
87 conf->dot11MeshHWMPmaxPREQretries; \
88 __entry->path_refresh_time = conf->path_refresh_time; \
89 __entry->dot11MeshHWMPactivePathTimeout = \
90 conf->dot11MeshHWMPactivePathTimeout; \
91 __entry->min_discovery_timeout = conf->min_discovery_timeout; \
92 __entry->dot11MeshHWMPpreqMinInterval = \
93 conf->dot11MeshHWMPpreqMinInterval; \
94 __entry->dot11MeshHWMPperrMinInterval = \
95 conf->dot11MeshHWMPperrMinInterval; \
96 __entry->dot11MeshHWMPnetDiameterTraversalTime = \
97 conf->dot11MeshHWMPnetDiameterTraversalTime; \
98 __entry->dot11MeshHWMPRootMode = conf->dot11MeshHWMPRootMode; \
99 __entry->dot11MeshHWMPRannInterval = \
100 conf->dot11MeshHWMPRannInterval; \
101 __entry->dot11MeshGateAnnouncementProtocol = \
102 conf->dot11MeshGateAnnouncementProtocol; \
103 __entry->dot11MeshForwarding = conf->dot11MeshForwarding; \
104 __entry->rssi_threshold = conf->rssi_threshold; \
105 __entry->ht_opmode = conf->ht_opmode; \
106 __entry->dot11MeshHWMPactivePathToRootTimeout = \
107 conf->dot11MeshHWMPactivePathToRootTimeout; \
108 __entry->dot11MeshHWMProotInterval = \
109 conf->dot11MeshHWMProotInterval; \
110 __entry->dot11MeshHWMPconfirmationInterval = \
111 conf->dot11MeshHWMPconfirmationInterval; \
112 } while (0)
113
114#define CHAN_ENTRY __field(enum ieee80211_band, band) \
115 __field(u16, center_freq)
116#define CHAN_ASSIGN(chan) \
117 do { \
118 if (chan) { \
119 __entry->band = chan->band; \
120 __entry->center_freq = chan->center_freq; \
121 } else { \
122 __entry->band = 0; \
123 __entry->center_freq = 0; \
124 } \
125 } while (0)
126#define CHAN_PR_FMT ", band: %d, freq: %u"
127#define CHAN_PR_ARG __entry->band, __entry->center_freq
128
129#define SINFO_ENTRY __field(int, generation) \
130 __field(u32, connected_time) \
131 __field(u32, inactive_time) \
132 __field(u32, rx_bytes) \
133 __field(u32, tx_bytes) \
134 __field(u32, rx_packets) \
135 __field(u32, tx_packets) \
136 __field(u32, tx_retries) \
137 __field(u32, tx_failed) \
138 __field(u32, rx_dropped_misc) \
139 __field(u32, beacon_loss_count) \
140 __field(u16, llid) \
141 __field(u16, plid) \
142 __field(u8, plink_state)
143#define SINFO_ASSIGN \
144 do { \
145 __entry->generation = sinfo->generation; \
146 __entry->connected_time = sinfo->connected_time; \
147 __entry->inactive_time = sinfo->inactive_time; \
148 __entry->rx_bytes = sinfo->rx_bytes; \
149 __entry->tx_bytes = sinfo->tx_bytes; \
150 __entry->rx_packets = sinfo->rx_packets; \
151 __entry->tx_packets = sinfo->tx_packets; \
152 __entry->tx_retries = sinfo->tx_retries; \
153 __entry->tx_failed = sinfo->tx_failed; \
154 __entry->rx_dropped_misc = sinfo->rx_dropped_misc; \
155 __entry->beacon_loss_count = sinfo->beacon_loss_count; \
156 __entry->llid = sinfo->llid; \
157 __entry->plid = sinfo->plid; \
158 __entry->plink_state = sinfo->plink_state; \
159 } while (0)
160
161#define BOOL_TO_STR(bo) (bo) ? "true" : "false"
162
163/*************************************************************
164 * rdev->ops traces *
165 *************************************************************/
166
167TRACE_EVENT(rdev_suspend,
168 TP_PROTO(struct wiphy *wiphy, struct cfg80211_wowlan *wow),
169 TP_ARGS(wiphy, wow),
170 TP_STRUCT__entry(
171 WIPHY_ENTRY
172 __field(bool, any)
173 __field(bool, disconnect)
174 __field(bool, magic_pkt)
175 __field(bool, gtk_rekey_failure)
176 __field(bool, eap_identity_req)
177 __field(bool, four_way_handshake)
178 __field(bool, rfkill_release)
179 __field(bool, valid_wow)
180 ),
181 TP_fast_assign(
182 WIPHY_ASSIGN;
183 if (wow) {
184 __entry->any = wow->any;
185 __entry->disconnect = wow->disconnect;
186 __entry->magic_pkt = wow->magic_pkt;
187 __entry->gtk_rekey_failure = wow->gtk_rekey_failure;
188 __entry->eap_identity_req = wow->eap_identity_req;
189 __entry->four_way_handshake = wow->four_way_handshake;
190 __entry->rfkill_release = wow->rfkill_release;
191 __entry->valid_wow = true;
192 } else {
193 __entry->valid_wow = false;
194 }
195 ),
196 TP_printk(WIPHY_PR_FMT ", wow%s - any: %d, disconnect: %d, "
197 "magic pkt: %d, gtk rekey failure: %d, eap identify req: %d, "
198 "four way handshake: %d, rfkill release: %d.",
199 WIPHY_PR_ARG, __entry->valid_wow ? "" : "(Not configured!)",
200 __entry->any, __entry->disconnect, __entry->magic_pkt,
201 __entry->gtk_rekey_failure, __entry->eap_identity_req,
202 __entry->four_way_handshake, __entry->rfkill_release)
203);
204
205TRACE_EVENT(rdev_return_int,
206 TP_PROTO(struct wiphy *wiphy, int ret),
207 TP_ARGS(wiphy, ret),
208 TP_STRUCT__entry(
209 WIPHY_ENTRY
210 __field(int, ret)
211 ),
212 TP_fast_assign(
213 WIPHY_ASSIGN;
214 __entry->ret = ret;
215 ),
216 TP_printk(WIPHY_PR_FMT ", returned: %d", WIPHY_PR_ARG, __entry->ret)
217);
218
219TRACE_EVENT(rdev_scan,
220 TP_PROTO(struct wiphy *wiphy, struct cfg80211_scan_request *request),
221 TP_ARGS(wiphy, request),
222 TP_STRUCT__entry(
223 WIPHY_ENTRY
224 ),
225 TP_fast_assign(
226 WIPHY_ASSIGN;
227 ),
228 TP_printk(WIPHY_PR_FMT, WIPHY_PR_ARG)
229);
230
231DECLARE_EVENT_CLASS(wiphy_only_evt,
232 TP_PROTO(struct wiphy *wiphy),
233 TP_ARGS(wiphy),
234 TP_STRUCT__entry(
235 WIPHY_ENTRY
236 ),
237 TP_fast_assign(
238 WIPHY_ASSIGN;
239 ),
240 TP_printk(WIPHY_PR_FMT, WIPHY_PR_ARG)
241);
242
243DEFINE_EVENT(wiphy_only_evt, rdev_resume,
244 TP_PROTO(struct wiphy *wiphy),
245 TP_ARGS(wiphy)
246);
247
248DEFINE_EVENT(wiphy_only_evt, rdev_return_void,
249 TP_PROTO(struct wiphy *wiphy),
250 TP_ARGS(wiphy)
251);
252
253DEFINE_EVENT(wiphy_only_evt, rdev_get_ringparam,
254 TP_PROTO(struct wiphy *wiphy),
255 TP_ARGS(wiphy)
256);
257
258DEFINE_EVENT(wiphy_only_evt, rdev_get_antenna,
259 TP_PROTO(struct wiphy *wiphy),
260 TP_ARGS(wiphy)
261);
262
263DEFINE_EVENT(wiphy_only_evt, rdev_get_tx_power,
264 TP_PROTO(struct wiphy *wiphy),
265 TP_ARGS(wiphy)
266);
267
268DEFINE_EVENT(wiphy_only_evt, rdev_rfkill_poll,
269 TP_PROTO(struct wiphy *wiphy),
270 TP_ARGS(wiphy)
271);
272
273DECLARE_EVENT_CLASS(wiphy_enabled_evt,
274 TP_PROTO(struct wiphy *wiphy, bool enabled),
275 TP_ARGS(wiphy, enabled),
276 TP_STRUCT__entry(
277 WIPHY_ENTRY
278 __field(bool, enabled)
279 ),
280 TP_fast_assign(
281 WIPHY_ASSIGN;
282 __entry->enabled = enabled;
283 ),
284 TP_printk(WIPHY_PR_FMT ", %senabled ",
285 WIPHY_PR_ARG, __entry->enabled ? "" : "not ")
286);
287
288DEFINE_EVENT(wiphy_enabled_evt, rdev_set_wakeup,
289 TP_PROTO(struct wiphy *wiphy, bool enabled),
290 TP_ARGS(wiphy, enabled)
291);
292
293TRACE_EVENT(rdev_add_virtual_intf,
294 TP_PROTO(struct wiphy *wiphy, char *name, enum nl80211_iftype type),
295 TP_ARGS(wiphy, name, type),
296 TP_STRUCT__entry(
297 WIPHY_ENTRY
298 __string(vir_intf_name, name ? name : "<noname>")
299 __field(enum nl80211_iftype, type)
300 ),
301 TP_fast_assign(
302 WIPHY_ASSIGN;
303 __assign_str(vir_intf_name, name ? name : "<noname>");
304 __entry->type = type;
305 ),
306 TP_printk(WIPHY_PR_FMT ", virtual intf name: %s, type: %d",
307 WIPHY_PR_ARG, __get_str(vir_intf_name), __entry->type)
308);
309
310DECLARE_EVENT_CLASS(wiphy_wdev_evt,
311 TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev),
312 TP_ARGS(wiphy, wdev),
313 TP_STRUCT__entry(
314 WIPHY_ENTRY
315 WDEV_ENTRY
316 ),
317 TP_fast_assign(
318 WIPHY_ASSIGN;
319 WDEV_ASSIGN;
320 ),
321 TP_printk(WIPHY_PR_FMT WDEV_PR_FMT, WIPHY_PR_ARG, WDEV_PR_ARG)
322);
323
324DEFINE_EVENT(wiphy_wdev_evt, rdev_return_wdev,
325 TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev),
326 TP_ARGS(wiphy, wdev)
327);
328
329DEFINE_EVENT(wiphy_wdev_evt, rdev_del_virtual_intf,
330 TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev),
331 TP_ARGS(wiphy, wdev)
332);
333
334TRACE_EVENT(rdev_change_virtual_intf,
335 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
336 enum nl80211_iftype type),
337 TP_ARGS(wiphy, netdev, type),
338 TP_STRUCT__entry(
339 WIPHY_ENTRY
340 NETDEV_ENTRY
341 __field(enum nl80211_iftype, type)
342 ),
343 TP_fast_assign(
344 WIPHY_ASSIGN;
345 NETDEV_ASSIGN;
346 __entry->type = type;
347 ),
348 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", type: %d",
349 WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->type)
350);
351
352DECLARE_EVENT_CLASS(key_handle,
353 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
354 bool pairwise, const u8 *mac_addr),
355 TP_ARGS(wiphy, netdev, key_index, pairwise, mac_addr),
356 TP_STRUCT__entry(
357 WIPHY_ENTRY
358 NETDEV_ENTRY
359 MAC_ENTRY(mac_addr)
360 __field(u8, key_index)
361 __field(bool, pairwise)
362 ),
363 TP_fast_assign(
364 WIPHY_ASSIGN;
365 NETDEV_ASSIGN;
366 MAC_ASSIGN(mac_addr, mac_addr);
367 __entry->key_index = key_index;
368 __entry->pairwise = pairwise;
369 ),
370 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", key_index: %u, pairwise: %s, mac addr: " MAC_PR_FMT,
371 WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->key_index,
372 BOOL_TO_STR(__entry->pairwise), MAC_PR_ARG(mac_addr))
373);
374
375DEFINE_EVENT(key_handle, rdev_add_key,
376 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
377 bool pairwise, const u8 *mac_addr),
378 TP_ARGS(wiphy, netdev, key_index, pairwise, mac_addr)
379);
380
381DEFINE_EVENT(key_handle, rdev_get_key,
382 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
383 bool pairwise, const u8 *mac_addr),
384 TP_ARGS(wiphy, netdev, key_index, pairwise, mac_addr)
385);
386
387DEFINE_EVENT(key_handle, rdev_del_key,
388 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
389 bool pairwise, const u8 *mac_addr),
390 TP_ARGS(wiphy, netdev, key_index, pairwise, mac_addr)
391);
392
393TRACE_EVENT(rdev_set_default_key,
394 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
395 bool unicast, bool multicast),
396 TP_ARGS(wiphy, netdev, key_index, unicast, multicast),
397 TP_STRUCT__entry(
398 WIPHY_ENTRY
399 NETDEV_ENTRY
400 __field(u8, key_index)
401 __field(bool, unicast)
402 __field(bool, multicast)
403 ),
404 TP_fast_assign(
405 WIPHY_ASSIGN;
406 NETDEV_ASSIGN;
407 __entry->key_index = key_index;
408 __entry->unicast = unicast;
409 __entry->multicast = multicast;
410 ),
411 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", key index: %u, unicast: %s, multicast: %s",
412 WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->key_index,
413 BOOL_TO_STR(__entry->unicast),
414 BOOL_TO_STR(__entry->multicast))
415);
416
417TRACE_EVENT(rdev_set_default_mgmt_key,
418 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 key_index),
419 TP_ARGS(wiphy, netdev, key_index),
420 TP_STRUCT__entry(
421 WIPHY_ENTRY
422 NETDEV_ENTRY
423 __field(u8, key_index)
424 ),
425 TP_fast_assign(
426 WIPHY_ASSIGN;
427 NETDEV_ASSIGN;
428 __entry->key_index = key_index;
429 ),
430 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", key index: %u",
431 WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->key_index)
432);
433
434TRACE_EVENT(rdev_start_ap,
435 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
436 struct cfg80211_ap_settings *settings),
437 TP_ARGS(wiphy, netdev, settings),
438 TP_STRUCT__entry(
439 WIPHY_ENTRY
440 NETDEV_ENTRY
441 CHAN_ENTRY
442 __field(int, beacon_interval)
443 __field(int, dtim_period)
444 __array(char, ssid, IEEE80211_MAX_SSID_LEN + 1)
445 __field(enum nl80211_hidden_ssid, hidden_ssid)
446 __field(u32, wpa_ver)
447 __field(bool, privacy)
448 __field(enum nl80211_auth_type, auth_type)
449 __field(int, inactivity_timeout)
450 ),
451 TP_fast_assign(
452 WIPHY_ASSIGN;
453 NETDEV_ASSIGN;
454 CHAN_ASSIGN(settings->channel);
455 __entry->beacon_interval = settings->beacon_interval;
456 __entry->dtim_period = settings->dtim_period;
457 __entry->hidden_ssid = settings->hidden_ssid;
458 __entry->wpa_ver = settings->crypto.wpa_versions;
459 __entry->privacy = settings->privacy;
460 __entry->auth_type = settings->auth_type;
461 __entry->inactivity_timeout = settings->inactivity_timeout;
462 memset(__entry->ssid, 0, IEEE80211_MAX_SSID_LEN + 1);
463 memcpy(__entry->ssid, settings->ssid, settings->ssid_len);
464 ),
465 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", AP settings - ssid: %s, "
466 CHAN_PR_FMT ", beacon interval: %d, dtim period: %d, "
467 "hidden ssid: %d, wpa versions: %u, privacy: %s, "
468 "auth type: %d, inactivity timeout: %d",
469 WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->ssid, CHAN_PR_ARG,
470 __entry->beacon_interval, __entry->dtim_period,
471 __entry->hidden_ssid, __entry->wpa_ver,
472 BOOL_TO_STR(__entry->privacy), __entry->auth_type,
473 __entry->inactivity_timeout)
474);
475
476TRACE_EVENT(rdev_change_beacon,
477 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
478 struct cfg80211_beacon_data *info),
479 TP_ARGS(wiphy, netdev, info),
480 TP_STRUCT__entry(
481 WIPHY_ENTRY
482 NETDEV_ENTRY
483 __dynamic_array(u8, head, info ? info->head_len : 0)
484 __dynamic_array(u8, tail, info ? info->tail_len : 0)
485 __dynamic_array(u8, beacon_ies, info ? info->beacon_ies_len : 0)
486 __dynamic_array(u8, proberesp_ies,
487 info ? info->proberesp_ies_len : 0)
488 __dynamic_array(u8, assocresp_ies,
489 info ? info->assocresp_ies_len : 0)
490 __dynamic_array(u8, probe_resp, info ? info->probe_resp_len : 0)
491 ),
492 TP_fast_assign(
493 WIPHY_ASSIGN;
494 NETDEV_ASSIGN;
495 if (info) {
496 if (info->head)
497 memcpy(__get_dynamic_array(head), info->head,
498 info->head_len);
499 if (info->tail)
500 memcpy(__get_dynamic_array(tail), info->tail,
501 info->tail_len);
502 if (info->beacon_ies)
503 memcpy(__get_dynamic_array(beacon_ies),
504 info->beacon_ies, info->beacon_ies_len);
505 if (info->proberesp_ies)
506 memcpy(__get_dynamic_array(proberesp_ies),
507 info->proberesp_ies,
508 info->proberesp_ies_len);
509 if (info->assocresp_ies)
510 memcpy(__get_dynamic_array(assocresp_ies),
511 info->assocresp_ies,
512 info->assocresp_ies_len);
513 if (info->probe_resp)
514 memcpy(__get_dynamic_array(probe_resp),
515 info->probe_resp, info->probe_resp_len);
516 }
517 ),
518 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT, WIPHY_PR_ARG, NETDEV_PR_ARG)
519);
520
521DECLARE_EVENT_CLASS(wiphy_netdev_evt,
522 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev),
523 TP_ARGS(wiphy, netdev),
524 TP_STRUCT__entry(
525 WIPHY_ENTRY
526 NETDEV_ENTRY
527 ),
528 TP_fast_assign(
529 WIPHY_ASSIGN;
530 NETDEV_ASSIGN;
531 ),
532 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT, WIPHY_PR_ARG, NETDEV_PR_ARG)
533);
534
535DEFINE_EVENT(wiphy_netdev_evt, rdev_stop_ap,
536 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev),
537 TP_ARGS(wiphy, netdev)
538);
539
540DEFINE_EVENT(wiphy_netdev_evt, rdev_get_et_stats,
541 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev),
542 TP_ARGS(wiphy, netdev)
543);
544
545DEFINE_EVENT(wiphy_netdev_evt, rdev_sched_scan_stop,
546 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev),
547 TP_ARGS(wiphy, netdev)
548);
549
550DEFINE_EVENT(wiphy_netdev_evt, rdev_set_rekey_data,
551 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev),
552 TP_ARGS(wiphy, netdev)
553);
554
555DEFINE_EVENT(wiphy_netdev_evt, rdev_get_mesh_config,
556 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev),
557 TP_ARGS(wiphy, netdev)
558);
559
560DEFINE_EVENT(wiphy_netdev_evt, rdev_leave_mesh,
561 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev),
562 TP_ARGS(wiphy, netdev)
563);
564
565DEFINE_EVENT(wiphy_netdev_evt, rdev_leave_ibss,
566 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev),
567 TP_ARGS(wiphy, netdev)
568);
569
570DEFINE_EVENT(wiphy_netdev_evt, rdev_flush_pmksa,
571 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev),
572 TP_ARGS(wiphy, netdev)
573);
574
575DECLARE_EVENT_CLASS(station_add_change,
576 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *mac,
577 struct station_parameters *params),
578 TP_ARGS(wiphy, netdev, mac, params),
579 TP_STRUCT__entry(
580 WIPHY_ENTRY
581 NETDEV_ENTRY
582 MAC_ENTRY(sta_mac)
583 __field(u32, sta_flags_mask)
584 __field(u32, sta_flags_set)
585 __field(u32, sta_modify_mask)
586 __field(int, listen_interval)
587 __field(u16, aid)
588 __field(u8, plink_action)
589 __field(u8, plink_state)
590 __field(u8, uapsd_queues)
591 __array(u8, ht_capa, (int)sizeof(struct ieee80211_ht_cap))
592 ),
593 TP_fast_assign(
594 WIPHY_ASSIGN;
595 NETDEV_ASSIGN;
596 MAC_ASSIGN(sta_mac, mac);
597 __entry->sta_flags_mask = params->sta_flags_mask;
598 __entry->sta_flags_set = params->sta_flags_set;
599 __entry->sta_modify_mask = params->sta_modify_mask;
600 __entry->listen_interval = params->listen_interval;
601 __entry->aid = params->aid;
602 __entry->plink_action = params->plink_action;
603 __entry->plink_state = params->plink_state;
604 __entry->uapsd_queues = params->uapsd_queues;
605 memset(__entry->ht_capa, 0, sizeof(struct ieee80211_ht_cap));
606 if (params->ht_capa)
607 memcpy(__entry->ht_capa, params->ht_capa,
608 sizeof(struct ieee80211_ht_cap));
609 ),
610 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", station mac: " MAC_PR_FMT
611 ", station flags mask: %u, station flags set: %u, "
612 "station modify mask: %u, listen interval: %d, aid: %u, "
613 "plink action: %u, plink state: %u, uapsd queues: %u",
614 WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(sta_mac),
615 __entry->sta_flags_mask, __entry->sta_flags_set,
616 __entry->sta_modify_mask, __entry->listen_interval,
617 __entry->aid, __entry->plink_action, __entry->plink_state,
618 __entry->uapsd_queues)
619);
620
621DEFINE_EVENT(station_add_change, rdev_add_station,
622 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *mac,
623 struct station_parameters *params),
624 TP_ARGS(wiphy, netdev, mac, params)
625);
626
627DEFINE_EVENT(station_add_change, rdev_change_station,
628 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *mac,
629 struct station_parameters *params),
630 TP_ARGS(wiphy, netdev, mac, params)
631);
632
633DECLARE_EVENT_CLASS(wiphy_netdev_mac_evt,
634 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, const u8 *mac),
635 TP_ARGS(wiphy, netdev, mac),
636 TP_STRUCT__entry(
637 WIPHY_ENTRY
638 NETDEV_ENTRY
639 MAC_ENTRY(sta_mac)
640 ),
641 TP_fast_assign(
642 WIPHY_ASSIGN;
643 NETDEV_ASSIGN;
644 MAC_ASSIGN(sta_mac, mac);
645 ),
646 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", mac: " MAC_PR_FMT,
647 WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(sta_mac))
648);
649
650DEFINE_EVENT(wiphy_netdev_mac_evt, rdev_del_station,
651 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, const u8 *mac),
652 TP_ARGS(wiphy, netdev, mac)
653);
654
655DEFINE_EVENT(wiphy_netdev_mac_evt, rdev_get_station,
656 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, const u8 *mac),
657 TP_ARGS(wiphy, netdev, mac)
658);
659
660DEFINE_EVENT(wiphy_netdev_mac_evt, rdev_del_mpath,
661 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, const u8 *mac),
662 TP_ARGS(wiphy, netdev, mac)
663);
664
665DEFINE_EVENT(wiphy_netdev_mac_evt, rdev_set_wds_peer,
666 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, const u8 *mac),
667 TP_ARGS(wiphy, netdev, mac)
668);
669
670TRACE_EVENT(rdev_dump_station,
671 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, int idx,
672 u8 *mac),
673 TP_ARGS(wiphy, netdev, idx, mac),
674 TP_STRUCT__entry(
675 WIPHY_ENTRY
676 NETDEV_ENTRY
677 MAC_ENTRY(sta_mac)
678 __field(int, idx)
679 ),
680 TP_fast_assign(
681 WIPHY_ASSIGN;
682 NETDEV_ASSIGN;
683 MAC_ASSIGN(sta_mac, mac);
684 __entry->idx = idx;
685 ),
686 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", station mac: " MAC_PR_FMT ", idx: %d",
687 WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(sta_mac),
688 __entry->idx)
689);
690
691TRACE_EVENT(rdev_return_int_station_info,
692 TP_PROTO(struct wiphy *wiphy, int ret, struct station_info *sinfo),
693 TP_ARGS(wiphy, ret, sinfo),
694 TP_STRUCT__entry(
695 WIPHY_ENTRY
696 __field(int, ret)
697 SINFO_ENTRY
698 ),
699 TP_fast_assign(
700 WIPHY_ASSIGN;
701 __entry->ret = ret;
702 SINFO_ASSIGN;
703 ),
704 TP_printk(WIPHY_PR_FMT ", returned %d" ,
705 WIPHY_PR_ARG, __entry->ret)
706);
707
708DECLARE_EVENT_CLASS(mpath_evt,
709 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *dst,
710 u8 *next_hop),
711 TP_ARGS(wiphy, netdev, dst, next_hop),
712 TP_STRUCT__entry(
713 WIPHY_ENTRY
714 NETDEV_ENTRY
715 MAC_ENTRY(dst)
716 MAC_ENTRY(next_hop)
717 ),
718 TP_fast_assign(
719 WIPHY_ASSIGN;
720 NETDEV_ASSIGN;
721 MAC_ASSIGN(dst, dst);
722 MAC_ASSIGN(next_hop, next_hop);
723 ),
724 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", destination: " MAC_PR_FMT ", next hop: " MAC_PR_FMT,
725 WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(dst),
726 MAC_PR_ARG(next_hop))
727);
728
729DEFINE_EVENT(mpath_evt, rdev_add_mpath,
730 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *dst,
731 u8 *next_hop),
732 TP_ARGS(wiphy, netdev, dst, next_hop)
733);
734
735DEFINE_EVENT(mpath_evt, rdev_change_mpath,
736 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *dst,
737 u8 *next_hop),
738 TP_ARGS(wiphy, netdev, dst, next_hop)
739);
740
741DEFINE_EVENT(mpath_evt, rdev_get_mpath,
742 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *dst,
743 u8 *next_hop),
744 TP_ARGS(wiphy, netdev, dst, next_hop)
745);
746
747TRACE_EVENT(rdev_dump_mpath,
748 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, int idx,
749 u8 *dst, u8 *next_hop),
750 TP_ARGS(wiphy, netdev, idx, dst, next_hop),
751 TP_STRUCT__entry(
752 WIPHY_ENTRY
753 NETDEV_ENTRY
754 MAC_ENTRY(dst)
755 MAC_ENTRY(next_hop)
756 __field(int, idx)
757 ),
758 TP_fast_assign(
759 WIPHY_ASSIGN;
760 NETDEV_ASSIGN;
761 MAC_ASSIGN(dst, dst);
762 MAC_ASSIGN(next_hop, next_hop);
763 __entry->idx = idx;
764 ),
765 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", index: %d, destination: "
766 MAC_PR_FMT ", next hop: " MAC_PR_FMT,
767 WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->idx, MAC_PR_ARG(dst),
768 MAC_PR_ARG(next_hop))
769);
770
771TRACE_EVENT(rdev_return_int_mpath_info,
772 TP_PROTO(struct wiphy *wiphy, int ret, struct mpath_info *pinfo),
773 TP_ARGS(wiphy, ret, pinfo),
774 TP_STRUCT__entry(
775 WIPHY_ENTRY
776 __field(int, ret)
777 __field(int, generation)
778 __field(u32, filled)
779 __field(u32, frame_qlen)
780 __field(u32, sn)
781 __field(u32, metric)
782 __field(u32, exptime)
783 __field(u32, discovery_timeout)
784 __field(u8, discovery_retries)
785 __field(u8, flags)
786 ),
787 TP_fast_assign(
788 WIPHY_ASSIGN;
789 __entry->ret = ret;
790 __entry->generation = pinfo->generation;
791 __entry->filled = pinfo->filled;
792 __entry->frame_qlen = pinfo->frame_qlen;
793 __entry->sn = pinfo->sn;
794 __entry->metric = pinfo->metric;
795 __entry->exptime = pinfo->exptime;
796 __entry->discovery_timeout = pinfo->discovery_timeout;
797 __entry->discovery_retries = pinfo->discovery_retries;
798 __entry->flags = pinfo->flags;
799 ),
800 TP_printk(WIPHY_PR_FMT ", returned %d. mpath info - generation: %d, "
801 "filled: %u, frame qlen: %u, sn: %u, metric: %u, exptime: %u,"
802 " discovery timeout: %u, discovery retries: %u, flags: %u",
803 WIPHY_PR_ARG, __entry->ret, __entry->generation,
804 __entry->filled, __entry->frame_qlen, __entry->sn,
805 __entry->metric, __entry->exptime, __entry->discovery_timeout,
806 __entry->discovery_retries, __entry->flags)
807);
808
809TRACE_EVENT(rdev_return_int_mesh_config,
810 TP_PROTO(struct wiphy *wiphy, int ret, struct mesh_config *conf),
811 TP_ARGS(wiphy, ret, conf),
812 TP_STRUCT__entry(
813 WIPHY_ENTRY
814 MESH_CFG_ENTRY
815 __field(int, ret)
816 ),
817 TP_fast_assign(
818 WIPHY_ASSIGN;
819 MESH_CFG_ASSIGN;
820 __entry->ret = ret;
821 ),
822 TP_printk(WIPHY_PR_FMT ", returned: %d",
823 WIPHY_PR_ARG, __entry->ret)
824);
825
826TRACE_EVENT(rdev_update_mesh_config,
827 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u32 mask,
828 const struct mesh_config *conf),
829 TP_ARGS(wiphy, netdev, mask, conf),
830 TP_STRUCT__entry(
831 WIPHY_ENTRY
832 NETDEV_ENTRY
833 MESH_CFG_ENTRY
834 __field(u32, mask)
835 ),
836 TP_fast_assign(
837 WIPHY_ASSIGN;
838 NETDEV_ASSIGN;
839 MESH_CFG_ASSIGN;
840 __entry->mask = mask;
841 ),
842 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", mask: %u",
843 WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->mask)
844);
845
846TRACE_EVENT(rdev_join_mesh,
847 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
848 const struct mesh_config *conf,
849 const struct mesh_setup *setup),
850 TP_ARGS(wiphy, netdev, conf, setup),
851 TP_STRUCT__entry(
852 WIPHY_ENTRY
853 NETDEV_ENTRY
854 MESH_CFG_ENTRY
855 ),
856 TP_fast_assign(
857 WIPHY_ASSIGN;
858 NETDEV_ASSIGN;
859 MESH_CFG_ASSIGN;
860 ),
861 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT,
862 WIPHY_PR_ARG, NETDEV_PR_ARG)
863);
864
865TRACE_EVENT(rdev_change_bss,
866 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
867 struct bss_parameters *params),
868 TP_ARGS(wiphy, netdev, params),
869 TP_STRUCT__entry(
870 WIPHY_ENTRY
871 NETDEV_ENTRY
872 __field(int, use_cts_prot)
873 __field(int, use_short_preamble)
874 __field(int, use_short_slot_time)
875 __field(int, ap_isolate)
876 __field(int, ht_opmode)
877 ),
878 TP_fast_assign(
879 WIPHY_ASSIGN;
880 NETDEV_ASSIGN;
881 __entry->use_cts_prot = params->use_cts_prot;
882 __entry->use_short_preamble = params->use_short_preamble;
883 __entry->use_short_slot_time = params->use_short_slot_time;
884 __entry->ap_isolate = params->ap_isolate;
885 __entry->ht_opmode = params->ht_opmode;
886 ),
887 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", use cts prot: %d, "
888 "use short preamble: %d, use short slot time: %d, "
889 "ap isolate: %d, ht opmode: %d",
890 WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->use_cts_prot,
891 __entry->use_short_preamble, __entry->use_short_slot_time,
892 __entry->ap_isolate, __entry->ht_opmode)
893);
894
895TRACE_EVENT(rdev_set_txq_params,
896 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
897 struct ieee80211_txq_params *params),
898 TP_ARGS(wiphy, netdev, params),
899 TP_STRUCT__entry(
900 WIPHY_ENTRY
901 NETDEV_ENTRY
902 __field(enum nl80211_ac, ac)
903 __field(u16, txop)
904 __field(u16, cwmin)
905 __field(u16, cwmax)
906 __field(u8, aifs)
907 ),
908 TP_fast_assign(
909 WIPHY_ASSIGN;
910 NETDEV_ASSIGN;
911 __entry->ac = params->ac;
912 __entry->txop = params->txop;
913 __entry->cwmin = params->cwmin;
914 __entry->cwmax = params->cwmax;
915 __entry->aifs = params->aifs;
916 ),
917 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", ac: %d, txop: %u, cwmin: %u, cwmax: %u, aifs: %u",
918 WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->ac, __entry->txop,
919 __entry->cwmin, __entry->cwmax, __entry->aifs)
920);
921
922TRACE_EVENT(rdev_libertas_set_mesh_channel,
923 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
924 struct ieee80211_channel *chan),
925 TP_ARGS(wiphy, netdev, chan),
926 TP_STRUCT__entry(
927 WIPHY_ENTRY
928 NETDEV_ENTRY
929 CHAN_ENTRY
930 ),
931 TP_fast_assign(
932 WIPHY_ASSIGN;
933 NETDEV_ASSIGN;
934 CHAN_ASSIGN(chan);
935 ),
936 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT CHAN_PR_FMT, WIPHY_PR_ARG,
937 NETDEV_PR_ARG, CHAN_PR_ARG)
938);
939
940TRACE_EVENT(rdev_set_monitor_channel,
941 TP_PROTO(struct wiphy *wiphy, struct ieee80211_channel *chan,
942 enum nl80211_channel_type chan_type),
943 TP_ARGS(wiphy, chan, chan_type),
944 TP_STRUCT__entry(
945 WIPHY_ENTRY
946 CHAN_ENTRY
947 __field(enum nl80211_channel_type, chan_type)
948 ),
949 TP_fast_assign(
950 WIPHY_ASSIGN;
951 CHAN_ASSIGN(chan);
952 __entry->chan_type = chan_type;
953 ),
954 TP_printk(WIPHY_PR_FMT CHAN_PR_FMT ", channel type : %d",
955 WIPHY_PR_ARG, CHAN_PR_ARG, __entry->chan_type)
956);
957
958TRACE_EVENT(rdev_auth,
959 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
960 struct cfg80211_auth_request *req),
961 TP_ARGS(wiphy, netdev, req),
962 TP_STRUCT__entry(
963 WIPHY_ENTRY
964 NETDEV_ENTRY
965 MAC_ENTRY(bssid)
966 __field(enum nl80211_auth_type, auth_type)
967 ),
968 TP_fast_assign(
969 WIPHY_ASSIGN;
970 NETDEV_ASSIGN;
971 if (req->bss)
972 MAC_ASSIGN(bssid, req->bss->bssid);
973 else
974 memset(__entry->bssid, 0, ETH_ALEN);
975 __entry->auth_type = req->auth_type;
976 ),
977 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", auth type: %d, bssid: " MAC_PR_FMT,
978 WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->auth_type,
979 MAC_PR_ARG(bssid))
980);
981
982TRACE_EVENT(rdev_assoc,
983 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
984 struct cfg80211_assoc_request *req),
985 TP_ARGS(wiphy, netdev, req),
986 TP_STRUCT__entry(
987 WIPHY_ENTRY
988 NETDEV_ENTRY
989 MAC_ENTRY(bssid)
990 MAC_ENTRY(prev_bssid)
991 __field(bool, use_mfp)
992 __field(u32, flags)
993 ),
994 TP_fast_assign(
995 WIPHY_ASSIGN;
996 NETDEV_ASSIGN;
997 if (req->bss)
998 MAC_ASSIGN(bssid, req->bss->bssid);
999 else
1000 memset(__entry->bssid, 0, ETH_ALEN);
1001 MAC_ASSIGN(prev_bssid, req->prev_bssid);
1002 __entry->use_mfp = req->use_mfp;
1003 __entry->flags = req->flags;
1004 ),
1005 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", bssid: " MAC_PR_FMT
1006 ", previous bssid: " MAC_PR_FMT ", use mfp: %s, flags: %u",
1007 WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(bssid),
1008 MAC_PR_ARG(prev_bssid), BOOL_TO_STR(__entry->use_mfp),
1009 __entry->flags)
1010);
1011
1012TRACE_EVENT(rdev_deauth,
1013 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
1014 struct cfg80211_deauth_request *req),
1015 TP_ARGS(wiphy, netdev, req),
1016 TP_STRUCT__entry(
1017 WIPHY_ENTRY
1018 NETDEV_ENTRY
1019 MAC_ENTRY(bssid)
1020 __field(u16, reason_code)
1021 ),
1022 TP_fast_assign(
1023 WIPHY_ASSIGN;
1024 NETDEV_ASSIGN;
1025 MAC_ASSIGN(bssid, req->bssid);
1026 __entry->reason_code = req->reason_code;
1027 ),
1028 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", bssid: " MAC_PR_FMT ", reason: %u",
1029 WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(bssid),
1030 __entry->reason_code)
1031);
1032
1033TRACE_EVENT(rdev_disassoc,
1034 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
1035 struct cfg80211_disassoc_request *req),
1036 TP_ARGS(wiphy, netdev, req),
1037 TP_STRUCT__entry(
1038 WIPHY_ENTRY
1039 NETDEV_ENTRY
1040 MAC_ENTRY(bssid)
1041 __field(u16, reason_code)
1042 __field(bool, local_state_change)
1043 ),
1044 TP_fast_assign(
1045 WIPHY_ASSIGN;
1046 NETDEV_ASSIGN;
1047 if (req->bss)
1048 MAC_ASSIGN(bssid, req->bss->bssid);
1049 else
1050 memset(__entry->bssid, 0, ETH_ALEN);
1051 __entry->reason_code = req->reason_code;
1052 __entry->local_state_change = req->local_state_change;
1053 ),
1054 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", bssid: " MAC_PR_FMT
1055 ", reason: %u, local state change: %s",
1056 WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(bssid),
1057 __entry->reason_code,
1058 BOOL_TO_STR(__entry->local_state_change))
1059);
1060
1061TRACE_EVENT(rdev_mgmt_tx_cancel_wait,
1062 TP_PROTO(struct wiphy *wiphy,
1063 struct wireless_dev *wdev, u64 cookie),
1064 TP_ARGS(wiphy, wdev, cookie),
1065 TP_STRUCT__entry(
1066 WIPHY_ENTRY
1067 WDEV_ENTRY
1068 __field(u64, cookie)
1069 ),
1070 TP_fast_assign(
1071 WIPHY_ASSIGN;
1072 WDEV_ASSIGN;
1073 __entry->cookie = cookie;
1074 ),
1075 TP_printk(WIPHY_PR_FMT WDEV_PR_FMT ", cookie: %llu ",
1076 WIPHY_PR_ARG, WDEV_PR_ARG, __entry->cookie)
1077);
1078
1079TRACE_EVENT(rdev_set_power_mgmt,
1080 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
1081 bool enabled, int timeout),
1082 TP_ARGS(wiphy, netdev, enabled, timeout),
1083 TP_STRUCT__entry(
1084 WIPHY_ENTRY
1085 NETDEV_ENTRY
1086 __field(bool, enabled)
1087 __field(int, timeout)
1088 ),
1089 TP_fast_assign(
1090 WIPHY_ASSIGN;
1091 NETDEV_ASSIGN;
1092 __entry->enabled = enabled;
1093 __entry->timeout = timeout;
1094 ),
1095 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", %senabled, timeout: %d ",
1096 WIPHY_PR_ARG, NETDEV_PR_ARG,
1097 __entry->enabled ? "" : "not ", __entry->timeout)
1098);
1099
1100TRACE_EVENT(rdev_connect,
1101 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
1102 struct cfg80211_connect_params *sme),
1103 TP_ARGS(wiphy, netdev, sme),
1104 TP_STRUCT__entry(
1105 WIPHY_ENTRY
1106 NETDEV_ENTRY
1107 MAC_ENTRY(bssid)
1108 __array(char, ssid, IEEE80211_MAX_SSID_LEN + 1)
1109 __field(enum nl80211_auth_type, auth_type)
1110 __field(bool, privacy)
1111 __field(u32, wpa_versions)
1112 __field(u32, flags)
1113 ),
1114 TP_fast_assign(
1115 WIPHY_ASSIGN;
1116 NETDEV_ASSIGN;
1117 MAC_ASSIGN(bssid, sme->bssid);
1118 memset(__entry->ssid, 0, IEEE80211_MAX_SSID_LEN + 1);
1119 memcpy(__entry->ssid, sme->ssid, sme->ssid_len);
1120 __entry->auth_type = sme->auth_type;
1121 __entry->privacy = sme->privacy;
1122 __entry->wpa_versions = sme->crypto.wpa_versions;
1123 __entry->flags = sme->flags;
1124 ),
1125 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", bssid: " MAC_PR_FMT
1126 ", ssid: %s, auth type: %d, privacy: %s, wpa versions: %u, "
1127 "flags: %u",
1128 WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(bssid), __entry->ssid,
1129 __entry->auth_type, BOOL_TO_STR(__entry->privacy),
1130 __entry->wpa_versions, __entry->flags)
1131);
1132
1133TRACE_EVENT(rdev_set_cqm_rssi_config,
1134 TP_PROTO(struct wiphy *wiphy,
1135 struct net_device *netdev, s32 rssi_thold,
1136 u32 rssi_hyst),
1137 TP_ARGS(wiphy, netdev, rssi_thold, rssi_hyst),
1138 TP_STRUCT__entry(
1139 WIPHY_ENTRY
1140 NETDEV_ENTRY
1141 __field(s32, rssi_thold)
1142 __field(u32, rssi_hyst)
1143 ),
1144 TP_fast_assign(
1145 WIPHY_ASSIGN;
1146 NETDEV_ASSIGN;
1147 __entry->rssi_thold = rssi_thold;
1148 __entry->rssi_hyst = rssi_hyst;
1149 ),
1150 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT
1151 ", rssi_thold: %d, rssi_hyst: %u ",
1152 WIPHY_PR_ARG, NETDEV_PR_ARG,
1153 __entry->rssi_thold, __entry->rssi_hyst)
1154);
1155
1156TRACE_EVENT(rdev_set_cqm_txe_config,
1157 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u32 rate,
1158 u32 pkts, u32 intvl),
1159 TP_ARGS(wiphy, netdev, rate, pkts, intvl),
1160 TP_STRUCT__entry(
1161 WIPHY_ENTRY
1162 NETDEV_ENTRY
1163 __field(u32, rate)
1164 __field(u32, pkts)
1165 __field(u32, intvl)
1166 ),
1167 TP_fast_assign(
1168 WIPHY_ASSIGN;
1169 NETDEV_ASSIGN;
1170 __entry->rate = rate;
1171 __entry->pkts = pkts;
1172 __entry->intvl = intvl;
1173 ),
1174 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", rate: %u, packets: %u, interval: %u",
1175 WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->rate, __entry->pkts,
1176 __entry->intvl)
1177);
1178
1179TRACE_EVENT(rdev_disconnect,
1180 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
1181 u16 reason_code),
1182 TP_ARGS(wiphy, netdev, reason_code),
1183 TP_STRUCT__entry(
1184 WIPHY_ENTRY
1185 NETDEV_ENTRY
1186 __field(u16, reason_code)
1187 ),
1188 TP_fast_assign(
1189 WIPHY_ASSIGN;
1190 NETDEV_ASSIGN;
1191 __entry->reason_code = reason_code;
1192 ),
1193 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", reason code: %u", WIPHY_PR_ARG,
1194 NETDEV_PR_ARG, __entry->reason_code)
1195);
1196
1197TRACE_EVENT(rdev_join_ibss,
1198 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
1199 struct cfg80211_ibss_params *params),
1200 TP_ARGS(wiphy, netdev, params),
1201 TP_STRUCT__entry(
1202 WIPHY_ENTRY
1203 NETDEV_ENTRY
1204 MAC_ENTRY(bssid)
1205 __array(char, ssid, IEEE80211_MAX_SSID_LEN + 1)
1206 ),
1207 TP_fast_assign(
1208 WIPHY_ASSIGN;
1209 NETDEV_ASSIGN;
1210 MAC_ASSIGN(bssid, params->bssid);
1211 memset(__entry->ssid, 0, IEEE80211_MAX_SSID_LEN + 1);
1212 memcpy(__entry->ssid, params->ssid, params->ssid_len);
1213 ),
1214 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", bssid: " MAC_PR_FMT ", ssid: %s",
1215 WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(bssid), __entry->ssid)
1216);
1217
1218TRACE_EVENT(rdev_set_wiphy_params,
1219 TP_PROTO(struct wiphy *wiphy, u32 changed),
1220 TP_ARGS(wiphy, changed),
1221 TP_STRUCT__entry(
1222 WIPHY_ENTRY
1223 __field(u32, changed)
1224 ),
1225 TP_fast_assign(
1226 WIPHY_ASSIGN;
1227 __entry->changed = changed;
1228 ),
1229 TP_printk(WIPHY_PR_FMT ", changed: %u",
1230 WIPHY_PR_ARG, __entry->changed)
1231);
1232
1233TRACE_EVENT(rdev_set_tx_power,
1234 TP_PROTO(struct wiphy *wiphy, enum nl80211_tx_power_setting type,
1235 int mbm),
1236 TP_ARGS(wiphy, type, mbm),
1237 TP_STRUCT__entry(
1238 WIPHY_ENTRY
1239 __field(enum nl80211_tx_power_setting, type)
1240 __field(int, mbm)
1241 ),
1242 TP_fast_assign(
1243 WIPHY_ASSIGN;
1244 __entry->type = type;
1245 __entry->mbm = mbm;
1246 ),
1247 TP_printk(WIPHY_PR_FMT ", type: %d, mbm: %d",
1248 WIPHY_PR_ARG, __entry->type, __entry->mbm)
1249);
1250
1251TRACE_EVENT(rdev_return_int_int,
1252 TP_PROTO(struct wiphy *wiphy, int func_ret, int func_fill),
1253 TP_ARGS(wiphy, func_ret, func_fill),
1254 TP_STRUCT__entry(
1255 WIPHY_ENTRY
1256 __field(int, func_ret)
1257 __field(int, func_fill)
1258 ),
1259 TP_fast_assign(
1260 WIPHY_ASSIGN;
1261 __entry->func_ret = func_ret;
1262 __entry->func_fill = func_fill;
1263 ),
1264 TP_printk(WIPHY_PR_FMT ", function returns: %d, function filled: %d",
1265 WIPHY_PR_ARG, __entry->func_ret, __entry->func_fill)
1266);
1267
1268#ifdef CONFIG_NL80211_TESTMODE
1269TRACE_EVENT(rdev_testmode_cmd,
1270 TP_PROTO(struct wiphy *wiphy),
1271 TP_ARGS(wiphy),
1272 TP_STRUCT__entry(
1273 WIPHY_ENTRY
1274 ),
1275 TP_fast_assign(
1276 WIPHY_ASSIGN;
1277 ),
1278 TP_printk(WIPHY_PR_FMT, WIPHY_PR_ARG)
1279);
1280
1281TRACE_EVENT(rdev_testmode_dump,
1282 TP_PROTO(struct wiphy *wiphy),
1283 TP_ARGS(wiphy),
1284 TP_STRUCT__entry(
1285 WIPHY_ENTRY
1286 ),
1287 TP_fast_assign(
1288 WIPHY_ASSIGN;
1289 ),
1290 TP_printk(WIPHY_PR_FMT, WIPHY_PR_ARG)
1291);
1292#endif /* CONFIG_NL80211_TESTMODE */
1293
1294TRACE_EVENT(rdev_set_bitrate_mask,
1295 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
1296 const u8 *peer, const struct cfg80211_bitrate_mask *mask),
1297 TP_ARGS(wiphy, netdev, peer, mask),
1298 TP_STRUCT__entry(
1299 WIPHY_ENTRY
1300 NETDEV_ENTRY
1301 MAC_ENTRY(peer)
1302 ),
1303 TP_fast_assign(
1304 WIPHY_ASSIGN;
1305 NETDEV_ASSIGN;
1306 MAC_ASSIGN(peer, peer);
1307 ),
1308 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", peer: " MAC_PR_FMT,
1309 WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(peer))
1310);
1311
1312TRACE_EVENT(rdev_mgmt_frame_register,
1313 TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,
1314 u16 frame_type, bool reg),
1315 TP_ARGS(wiphy, wdev, frame_type, reg),
1316 TP_STRUCT__entry(
1317 WIPHY_ENTRY
1318 WDEV_ENTRY
1319 __field(u16, frame_type)
1320 __field(bool, reg)
1321 ),
1322 TP_fast_assign(
1323 WIPHY_ASSIGN;
1324 WDEV_ASSIGN;
1325 __entry->frame_type = frame_type;
1326 __entry->reg = reg;
1327 ),
1328 TP_printk(WIPHY_PR_FMT WDEV_PR_FMT ", frame_type: %u, reg: %s ",
1329 WIPHY_PR_ARG, WDEV_PR_ARG, __entry->frame_type,
1330 __entry->reg ? "true" : "false")
1331);
1332
1333TRACE_EVENT(rdev_return_int_tx_rx,
1334 TP_PROTO(struct wiphy *wiphy, int ret, u32 tx, u32 rx),
1335 TP_ARGS(wiphy, ret, tx, rx),
1336 TP_STRUCT__entry(
1337 WIPHY_ENTRY
1338 __field(int, ret)
1339 __field(u32, tx)
1340 __field(u32, rx)
1341 ),
1342 TP_fast_assign(
1343 WIPHY_ASSIGN;
1344 __entry->ret = ret;
1345 __entry->tx = tx;
1346 __entry->rx = rx;
1347 ),
1348 TP_printk(WIPHY_PR_FMT ", returned %d, tx: %u, rx: %u",
1349 WIPHY_PR_ARG, __entry->ret, __entry->tx, __entry->rx)
1350);
1351
1352TRACE_EVENT(rdev_return_void_tx_rx,
1353 TP_PROTO(struct wiphy *wiphy, u32 tx, u32 tx_max,
1354 u32 rx, u32 rx_max),
1355 TP_ARGS(wiphy, tx, tx_max, rx, rx_max),
1356 TP_STRUCT__entry(
1357 WIPHY_ENTRY
1358 __field(u32, tx)
1359 __field(u32, tx_max)
1360 __field(u32, rx)
1361 __field(u32, rx_max)
1362 ),
1363 TP_fast_assign(
1364 WIPHY_ASSIGN;
1365 __entry->tx = tx;
1366 __entry->tx_max = tx_max;
1367 __entry->rx = rx;
1368 __entry->rx_max = rx_max;
1369 ),
1370 TP_printk(WIPHY_PR_FMT ", tx: %u, tx_max: %u, rx: %u, rx_max: %u ",
1371 WIPHY_PR_ARG, __entry->tx, __entry->tx_max, __entry->rx,
1372 __entry->rx_max)
1373);
1374
1375DECLARE_EVENT_CLASS(tx_rx_evt,
1376 TP_PROTO(struct wiphy *wiphy, u32 tx, u32 rx),
1377 TP_ARGS(wiphy, rx, tx),
1378 TP_STRUCT__entry(
1379 WIPHY_ENTRY
1380 __field(u32, tx)
1381 __field(u32, rx)
1382 ),
1383 TP_fast_assign(
1384 WIPHY_ASSIGN;
1385 __entry->tx = tx;
1386 __entry->rx = rx;
1387 ),
1388 TP_printk(WIPHY_PR_FMT ", tx: %u, rx: %u ",
1389 WIPHY_PR_ARG, __entry->tx, __entry->rx)
1390);
1391
1392DEFINE_EVENT(tx_rx_evt, rdev_set_ringparam,
1393 TP_PROTO(struct wiphy *wiphy, u32 tx, u32 rx),
1394 TP_ARGS(wiphy, rx, tx)
1395);
1396
1397DEFINE_EVENT(tx_rx_evt, rdev_set_antenna,
1398 TP_PROTO(struct wiphy *wiphy, u32 tx, u32 rx),
1399 TP_ARGS(wiphy, rx, tx)
1400);
1401
1402TRACE_EVENT(rdev_sched_scan_start,
1403 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
1404 struct cfg80211_sched_scan_request *request),
1405 TP_ARGS(wiphy, netdev, request),
1406 TP_STRUCT__entry(
1407 WIPHY_ENTRY
1408 NETDEV_ENTRY
1409 ),
1410 TP_fast_assign(
1411 WIPHY_ASSIGN;
1412 NETDEV_ASSIGN;
1413 ),
1414 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT,
1415 WIPHY_PR_ARG, NETDEV_PR_ARG)
1416);
1417
1418TRACE_EVENT(rdev_tdls_mgmt,
1419 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
1420 u8 *peer, u8 action_code, u8 dialog_token,
1421 u16 status_code, const u8 *buf, size_t len),
1422 TP_ARGS(wiphy, netdev, peer, action_code, dialog_token, status_code,
1423 buf, len),
1424 TP_STRUCT__entry(
1425 WIPHY_ENTRY
1426 NETDEV_ENTRY
1427 MAC_ENTRY(peer)
1428 __field(u8, action_code)
1429 __field(u8, dialog_token)
1430 __field(u16, status_code)
1431 __dynamic_array(u8, buf, len)
1432 ),
1433 TP_fast_assign(
1434 WIPHY_ASSIGN;
1435 NETDEV_ASSIGN;
1436 MAC_ASSIGN(peer, peer);
1437 __entry->action_code = action_code;
1438 __entry->dialog_token = dialog_token;
1439 __entry->status_code = status_code;
1440 memcpy(__get_dynamic_array(buf), buf, len);
1441 ),
1442 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT MAC_PR_FMT ", action_code: %u, "
1443 "dialog_token: %u, status_code: %u, buf: %#.2x ",
1444 WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(peer),
1445 __entry->action_code, __entry->dialog_token,
1446 __entry->status_code, ((u8 *)__get_dynamic_array(buf))[0])
1447);
1448
1449TRACE_EVENT(rdev_dump_survey,
1450 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, int idx),
1451 TP_ARGS(wiphy, netdev, idx),
1452 TP_STRUCT__entry(
1453 WIPHY_ENTRY
1454 NETDEV_ENTRY
1455 __field(int, idx)
1456 ),
1457 TP_fast_assign(
1458 WIPHY_ASSIGN;
1459 NETDEV_ASSIGN;
1460 __entry->idx = idx;
1461 ),
1462 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", index: %d",
1463 WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->idx)
1464);
1465
1466TRACE_EVENT(rdev_return_int_survey_info,
1467 TP_PROTO(struct wiphy *wiphy, int ret, struct survey_info *info),
1468 TP_ARGS(wiphy, ret, info),
1469 TP_STRUCT__entry(
1470 WIPHY_ENTRY
1471 CHAN_ENTRY
1472 __field(int, ret)
1473 __field(u64, channel_time)
1474 __field(u64, channel_time_busy)
1475 __field(u64, channel_time_ext_busy)
1476 __field(u64, channel_time_rx)
1477 __field(u64, channel_time_tx)
1478 __field(u32, filled)
1479 __field(s8, noise)
1480 ),
1481 TP_fast_assign(
1482 WIPHY_ASSIGN;
1483 CHAN_ASSIGN(info->channel);
1484 __entry->ret = ret;
1485 __entry->channel_time = info->channel_time;
1486 __entry->channel_time_busy = info->channel_time_busy;
1487 __entry->channel_time_ext_busy = info->channel_time_ext_busy;
1488 __entry->channel_time_rx = info->channel_time_rx;
1489 __entry->channel_time_tx = info->channel_time_tx;
1490 __entry->filled = info->filled;
1491 __entry->noise = info->noise;
1492 ),
1493 TP_printk(WIPHY_PR_FMT ", returned: %d, " CHAN_PR_FMT
1494 ", channel time: %llu, channel time busy: %llu, "
1495 "channel time extension busy: %llu, channel time rx: %llu, "
1496 "channel time tx: %llu, filled: %u, noise: %d",
1497 WIPHY_PR_ARG, __entry->ret, CHAN_PR_ARG,
1498 __entry->channel_time, __entry->channel_time_busy,
1499 __entry->channel_time_ext_busy, __entry->channel_time_rx,
1500 __entry->channel_time_tx, __entry->filled, __entry->noise)
1501);
1502
1503TRACE_EVENT(rdev_tdls_oper,
1504 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
1505 u8 *peer, enum nl80211_tdls_operation oper),
1506 TP_ARGS(wiphy, netdev, peer, oper),
1507 TP_STRUCT__entry(
1508 WIPHY_ENTRY
1509 NETDEV_ENTRY
1510 MAC_ENTRY(peer)
1511 __field(enum nl80211_tdls_operation, oper)
1512 ),
1513 TP_fast_assign(
1514 WIPHY_ASSIGN;
1515 NETDEV_ASSIGN;
1516 MAC_ASSIGN(peer, peer);
1517 __entry->oper = oper;
1518 ),
1519 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT MAC_PR_FMT ", oper: %d",
1520 WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(peer), __entry->oper)
1521);
1522
1523DECLARE_EVENT_CLASS(rdev_pmksa,
1524 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
1525 struct cfg80211_pmksa *pmksa),
1526 TP_ARGS(wiphy, netdev, pmksa),
1527 TP_STRUCT__entry(
1528 WIPHY_ENTRY
1529 NETDEV_ENTRY
1530 MAC_ENTRY(bssid)
1531 ),
1532 TP_fast_assign(
1533 WIPHY_ASSIGN;
1534 NETDEV_ASSIGN;
1535 MAC_ASSIGN(bssid, pmksa->bssid);
1536 ),
1537 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", bssid: " MAC_PR_FMT,
1538 WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(bssid))
1539);
1540
1541TRACE_EVENT(rdev_probe_client,
1542 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
1543 const u8 *peer),
1544 TP_ARGS(wiphy, netdev, peer),
1545 TP_STRUCT__entry(
1546 WIPHY_ENTRY
1547 NETDEV_ENTRY
1548 MAC_ENTRY(peer)
1549 ),
1550 TP_fast_assign(
1551 WIPHY_ASSIGN;
1552 NETDEV_ASSIGN;
1553 MAC_ASSIGN(peer, peer);
1554 ),
1555 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT MAC_PR_FMT,
1556 WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(peer))
1557);
1558
1559DEFINE_EVENT(rdev_pmksa, rdev_set_pmksa,
1560 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
1561 struct cfg80211_pmksa *pmksa),
1562 TP_ARGS(wiphy, netdev, pmksa)
1563);
1564
1565DEFINE_EVENT(rdev_pmksa, rdev_del_pmksa,
1566 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
1567 struct cfg80211_pmksa *pmksa),
1568 TP_ARGS(wiphy, netdev, pmksa)
1569);
1570
1571TRACE_EVENT(rdev_remain_on_channel,
1572 TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,
1573 struct ieee80211_channel *chan,
1574 enum nl80211_channel_type channel_type, unsigned int duration),
1575 TP_ARGS(wiphy, wdev, chan, channel_type, duration),
1576 TP_STRUCT__entry(
1577 WIPHY_ENTRY
1578 WDEV_ENTRY
1579 CHAN_ENTRY
1580 __field(enum nl80211_channel_type, channel_type)
1581 __field(unsigned int, duration)
1582 ),
1583 TP_fast_assign(
1584 WIPHY_ASSIGN;
1585 WDEV_ASSIGN;
1586 CHAN_ASSIGN(chan);
1587 __entry->channel_type = channel_type;
1588 __entry->duration = duration;
1589 ),
1590 TP_printk(WIPHY_PR_FMT WDEV_PR_FMT CHAN_PR_FMT ", channel type: %d, duration: %u",
1591 WIPHY_PR_ARG, WDEV_PR_ARG, CHAN_PR_ARG, __entry->channel_type,
1592 __entry->duration)
1593);
1594
1595TRACE_EVENT(rdev_return_int_cookie,
1596 TP_PROTO(struct wiphy *wiphy, int ret, u64 cookie),
1597 TP_ARGS(wiphy, ret, cookie),
1598 TP_STRUCT__entry(
1599 WIPHY_ENTRY
1600 __field(int, ret)
1601 __field(u64, cookie)
1602 ),
1603 TP_fast_assign(
1604 WIPHY_ASSIGN;
1605 __entry->ret = ret;
1606 __entry->cookie = cookie;
1607 ),
1608 TP_printk(WIPHY_PR_FMT ", returned %d, cookie: %llu",
1609 WIPHY_PR_ARG, __entry->ret, __entry->cookie)
1610);
1611
1612TRACE_EVENT(rdev_cancel_remain_on_channel,
1613 TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev, u64 cookie),
1614 TP_ARGS(wiphy, wdev, cookie),
1615 TP_STRUCT__entry(
1616 WIPHY_ENTRY
1617 WDEV_ENTRY
1618 __field(u64, cookie)
1619 ),
1620 TP_fast_assign(
1621 WIPHY_ASSIGN;
1622 WDEV_ASSIGN;
1623 __entry->cookie = cookie;
1624 ),
1625 TP_printk(WIPHY_PR_FMT WDEV_PR_FMT ", cookie: %llu",
1626 WIPHY_PR_ARG, WDEV_PR_ARG, __entry->cookie)
1627);
1628
1629TRACE_EVENT(rdev_mgmt_tx,
1630 TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,
1631 struct ieee80211_channel *chan, bool offchan,
1632 enum nl80211_channel_type channel_type,
1633 bool channel_type_valid, unsigned int wait, bool no_cck,
1634 bool dont_wait_for_ack),
1635 TP_ARGS(wiphy, wdev, chan, offchan, channel_type, channel_type_valid,
1636 wait, no_cck, dont_wait_for_ack),
1637 TP_STRUCT__entry(
1638 WIPHY_ENTRY
1639 WDEV_ENTRY
1640 CHAN_ENTRY
1641 __field(bool, offchan)
1642 __field(enum nl80211_channel_type, channel_type)
1643 __field(bool, channel_type_valid)
1644 __field(unsigned int, wait)
1645 __field(bool, no_cck)
1646 __field(bool, dont_wait_for_ack)
1647 ),
1648 TP_fast_assign(
1649 WIPHY_ASSIGN;
1650 WDEV_ASSIGN;
1651 CHAN_ASSIGN(chan);
1652 __entry->offchan = offchan;
1653 __entry->channel_type = channel_type;
1654 __entry->channel_type_valid = channel_type_valid;
1655 __entry->wait = wait;
1656 __entry->no_cck = no_cck;
1657 __entry->dont_wait_for_ack = dont_wait_for_ack;
1658 ),
1659 TP_printk(WIPHY_PR_FMT WDEV_PR_FMT CHAN_PR_FMT ", offchan: %s, "
1660 "channel type: %d, channel type valid: %s, wait: %u, "
1661 "no cck: %s, dont wait for ack: %s",
1662 WIPHY_PR_ARG, WDEV_PR_ARG, CHAN_PR_ARG,
1663 BOOL_TO_STR(__entry->offchan), __entry->channel_type,
1664 BOOL_TO_STR(__entry->channel_type_valid), __entry->wait,
1665 BOOL_TO_STR(__entry->no_cck),
1666 BOOL_TO_STR(__entry->dont_wait_for_ack))
1667);
1668
1669TRACE_EVENT(rdev_set_noack_map,
1670 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
1671 u16 noack_map),
1672 TP_ARGS(wiphy, netdev, noack_map),
1673 TP_STRUCT__entry(
1674 WIPHY_ENTRY
1675 NETDEV_ENTRY
1676 __field(u16, noack_map)
1677 ),
1678 TP_fast_assign(
1679 WIPHY_ASSIGN;
1680 NETDEV_ASSIGN;
1681 __entry->noack_map = noack_map;
1682 ),
1683 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", noack_map: %u",
1684 WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->noack_map)
1685);
1686
1687TRACE_EVENT(rdev_get_et_sset_count,
1688 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, int sset),
1689 TP_ARGS(wiphy, netdev, sset),
1690 TP_STRUCT__entry(
1691 WIPHY_ENTRY
1692 NETDEV_ENTRY
1693 __field(int, sset)
1694 ),
1695 TP_fast_assign(
1696 WIPHY_ASSIGN;
1697 NETDEV_ASSIGN;
1698 __entry->sset = sset;
1699 ),
1700 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", sset: %d",
1701 WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->sset)
1702);
1703
1704TRACE_EVENT(rdev_get_et_strings,
1705 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u32 sset),
1706 TP_ARGS(wiphy, netdev, sset),
1707 TP_STRUCT__entry(
1708 WIPHY_ENTRY
1709 NETDEV_ENTRY
1710 __field(u32, sset)
1711 ),
1712 TP_fast_assign(
1713 WIPHY_ASSIGN;
1714 NETDEV_ASSIGN;
1715 __entry->sset = sset;
1716 ),
1717 TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", sset: %u",
1718 WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->sset)
1719);
1720
1721DEFINE_EVENT(wiphy_wdev_evt, rdev_get_channel,
1722 TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev),
1723 TP_ARGS(wiphy, wdev)
1724);
1725
1726TRACE_EVENT(rdev_return_channel,
1727 TP_PROTO(struct wiphy *wiphy, struct ieee80211_channel *chan,
1728 enum nl80211_channel_type type),
1729 TP_ARGS(wiphy, chan, type),
1730 TP_STRUCT__entry(
1731 WIPHY_ENTRY
1732 CHAN_ENTRY
1733 __field(enum nl80211_channel_type, type)
1734 ),
1735 TP_fast_assign(
1736 WIPHY_ASSIGN;
1737 CHAN_ASSIGN(chan);
1738 __entry->type = type;
1739 ),
1740 TP_printk(WIPHY_PR_FMT CHAN_PR_FMT ", channel type: %d",
1741 WIPHY_PR_ARG, CHAN_PR_ARG, __entry->type)
1742);
1743
1744/*************************************************************
1745 * cfg80211 exported functions traces *
1746 *************************************************************/
1747
1748TRACE_EVENT(cfg80211_return_bool,
1749 TP_PROTO(bool ret),
1750 TP_ARGS(ret),
1751 TP_STRUCT__entry(
1752 __field(bool, ret)
1753 ),
1754 TP_fast_assign(
1755 __entry->ret = ret;
1756 ),
1757 TP_printk("returned %s", BOOL_TO_STR(__entry->ret))
1758);
1759
1760DECLARE_EVENT_CLASS(cfg80211_netdev_mac_evt,
1761 TP_PROTO(struct net_device *netdev, const u8 *macaddr),
1762 TP_ARGS(netdev, macaddr),
1763 TP_STRUCT__entry(
1764 NETDEV_ENTRY
1765 MAC_ENTRY(macaddr)
1766 ),
1767 TP_fast_assign(
1768 NETDEV_ASSIGN;
1769 MAC_ASSIGN(macaddr, macaddr);
1770 ),
1771 TP_printk(NETDEV_PR_FMT ", mac: " MAC_PR_FMT,
1772 NETDEV_PR_ARG, MAC_PR_ARG(macaddr))
1773);
1774
1775DEFINE_EVENT(cfg80211_netdev_mac_evt, cfg80211_notify_new_peer_candidate,
1776 TP_PROTO(struct net_device *netdev, const u8 *macaddr),
1777 TP_ARGS(netdev, macaddr)
1778);
1779
1780DECLARE_EVENT_CLASS(netdev_evt_only,
1781 TP_PROTO(struct net_device *netdev),
1782 TP_ARGS(netdev),
1783 TP_STRUCT__entry(
1784 NETDEV_ENTRY
1785 ),
1786 TP_fast_assign(
1787 NETDEV_ASSIGN;
1788 ),
1789 TP_printk(NETDEV_PR_FMT , NETDEV_PR_ARG)
1790);
1791
1792DEFINE_EVENT(netdev_evt_only, cfg80211_send_rx_auth,
1793 TP_PROTO(struct net_device *netdev),
1794 TP_ARGS(netdev)
1795);
1796
1797TRACE_EVENT(cfg80211_send_rx_assoc,
1798 TP_PROTO(struct net_device *netdev, struct cfg80211_bss *bss),
1799 TP_ARGS(netdev, bss),
1800 TP_STRUCT__entry(
1801 NETDEV_ENTRY
1802 MAC_ENTRY(bssid)
1803 CHAN_ENTRY
1804 ),
1805 TP_fast_assign(
1806 NETDEV_ASSIGN;
1807 MAC_ASSIGN(bssid, bss->bssid);
1808 CHAN_ASSIGN(bss->channel);
1809 ),
1810 TP_printk(NETDEV_PR_FMT MAC_PR_FMT CHAN_PR_FMT,
1811 NETDEV_PR_ARG, MAC_PR_ARG(bssid), CHAN_PR_ARG)
1812);
1813
1814DEFINE_EVENT(netdev_evt_only, __cfg80211_send_deauth,
1815 TP_PROTO(struct net_device *netdev),
1816 TP_ARGS(netdev)
1817);
1818
1819DEFINE_EVENT(netdev_evt_only, __cfg80211_send_disassoc,
1820 TP_PROTO(struct net_device *netdev),
1821 TP_ARGS(netdev)
1822);
1823
1824DEFINE_EVENT(netdev_evt_only, cfg80211_send_unprot_deauth,
1825 TP_PROTO(struct net_device *netdev),
1826 TP_ARGS(netdev)
1827);
1828
1829DEFINE_EVENT(netdev_evt_only, cfg80211_send_unprot_disassoc,
1830 TP_PROTO(struct net_device *netdev),
1831 TP_ARGS(netdev)
1832);
1833
1834DECLARE_EVENT_CLASS(netdev_mac_evt,
1835 TP_PROTO(struct net_device *netdev, const u8 *mac),
1836 TP_ARGS(netdev, mac),
1837 TP_STRUCT__entry(
1838 NETDEV_ENTRY
1839 MAC_ENTRY(mac)
1840 ),
1841 TP_fast_assign(
1842 NETDEV_ASSIGN;
1843 MAC_ASSIGN(mac, mac)
1844 ),
1845 TP_printk(NETDEV_PR_FMT ", mac: " MAC_PR_FMT,
1846 NETDEV_PR_ARG, MAC_PR_ARG(mac))
1847);
1848
1849DEFINE_EVENT(netdev_mac_evt, cfg80211_send_auth_timeout,
1850 TP_PROTO(struct net_device *netdev, const u8 *mac),
1851 TP_ARGS(netdev, mac)
1852);
1853
1854DEFINE_EVENT(netdev_mac_evt, cfg80211_send_assoc_timeout,
1855 TP_PROTO(struct net_device *netdev, const u8 *mac),
1856 TP_ARGS(netdev, mac)
1857);
1858
1859TRACE_EVENT(cfg80211_michael_mic_failure,
1860 TP_PROTO(struct net_device *netdev, const u8 *addr,
1861 enum nl80211_key_type key_type, int key_id, const u8 *tsc),
1862 TP_ARGS(netdev, addr, key_type, key_id, tsc),
1863 TP_STRUCT__entry(
1864 NETDEV_ENTRY
1865 MAC_ENTRY(addr)
1866 __field(enum nl80211_key_type, key_type)
1867 __field(int, key_id)
1868 __array(u8, tsc, 6)
1869 ),
1870 TP_fast_assign(
1871 NETDEV_ASSIGN;
1872 MAC_ASSIGN(addr, addr);
1873 __entry->key_type = key_type;
1874 __entry->key_id = key_id;
1875 memcpy(__entry->tsc, tsc, 6);
1876 ),
1877 TP_printk(NETDEV_PR_FMT MAC_PR_FMT ", key type: %d, key id: %d, tsc: %pm",
1878 NETDEV_PR_ARG, MAC_PR_ARG(addr), __entry->key_type,
1879 __entry->key_id, __entry->tsc)
1880);
1881
1882TRACE_EVENT(cfg80211_ready_on_channel,
1883 TP_PROTO(struct wireless_dev *wdev, u64 cookie,
1884 struct ieee80211_channel *chan,
1885 enum nl80211_channel_type channel_type, unsigned int duration),
1886 TP_ARGS(wdev, cookie, chan, channel_type, duration),
1887 TP_STRUCT__entry(
1888 WDEV_ENTRY
1889 __field(u64, cookie)
1890 CHAN_ENTRY
1891 __field(enum nl80211_channel_type, channel_type)
1892 __field(unsigned int, duration)
1893 ),
1894 TP_fast_assign(
1895 WDEV_ASSIGN;
1896 __entry->cookie = cookie;
1897 CHAN_ASSIGN(chan);
1898 __entry->channel_type = channel_type;
1899 __entry->duration = duration;
1900 ),
1901 TP_printk(WDEV_PR_FMT ", cookie: %llu, " CHAN_PR_FMT ", channel type: %d, duration: %u",
1902 WDEV_PR_ARG, __entry->cookie, CHAN_PR_ARG,
1903 __entry->channel_type, __entry->duration)
1904);
1905
1906TRACE_EVENT(cfg80211_ready_on_channel_expired,
1907 TP_PROTO(struct wireless_dev *wdev, u64 cookie,
1908 struct ieee80211_channel *chan,
1909 enum nl80211_channel_type channel_type),
1910 TP_ARGS(wdev, cookie, chan, channel_type),
1911 TP_STRUCT__entry(
1912 WDEV_ENTRY
1913 __field(u64, cookie)
1914 CHAN_ENTRY
1915 __field(enum nl80211_channel_type, channel_type)
1916 ),
1917 TP_fast_assign(
1918 WDEV_ASSIGN;
1919 __entry->cookie = cookie;
1920 CHAN_ASSIGN(chan);
1921 __entry->channel_type = channel_type;
1922 ),
1923 TP_printk(WDEV_PR_FMT ", cookie: %llu, " CHAN_PR_FMT ", channel type: %d",
1924 WDEV_PR_ARG, __entry->cookie, CHAN_PR_ARG,
1925 __entry->channel_type)
1926);
1927
1928TRACE_EVENT(cfg80211_new_sta,
1929 TP_PROTO(struct net_device *netdev, const u8 *mac_addr,
1930 struct station_info *sinfo),
1931 TP_ARGS(netdev, mac_addr, sinfo),
1932 TP_STRUCT__entry(
1933 NETDEV_ENTRY
1934 MAC_ENTRY(mac_addr)
1935 SINFO_ENTRY
1936 ),
1937 TP_fast_assign(
1938 NETDEV_ASSIGN;
1939 MAC_ASSIGN(mac_addr, mac_addr);
1940 SINFO_ASSIGN;
1941 ),
1942 TP_printk(NETDEV_PR_FMT MAC_PR_FMT,
1943 NETDEV_PR_ARG, MAC_PR_ARG(mac_addr))
1944);
1945
1946DEFINE_EVENT(cfg80211_netdev_mac_evt, cfg80211_del_sta,
1947 TP_PROTO(struct net_device *netdev, const u8 *macaddr),
1948 TP_ARGS(netdev, macaddr)
1949);
1950
1951TRACE_EVENT(cfg80211_rx_mgmt,
1952 TP_PROTO(struct wireless_dev *wdev, int freq, int sig_mbm),
1953 TP_ARGS(wdev, freq, sig_mbm),
1954 TP_STRUCT__entry(
1955 WDEV_ENTRY
1956 __field(int, freq)
1957 __field(int, sig_mbm)
1958 ),
1959 TP_fast_assign(
1960 WDEV_ASSIGN;
1961 __entry->freq = freq;
1962 __entry->sig_mbm = sig_mbm;
1963 ),
1964 TP_printk(WDEV_PR_FMT ", freq: %d, sig mbm: %d",
1965 WDEV_PR_ARG, __entry->freq, __entry->sig_mbm)
1966);
1967
1968TRACE_EVENT(cfg80211_mgmt_tx_status,
1969 TP_PROTO(struct wireless_dev *wdev, u64 cookie, bool ack),
1970 TP_ARGS(wdev, cookie, ack),
1971 TP_STRUCT__entry(
1972 WDEV_ENTRY
1973 __field(u64, cookie)
1974 __field(bool, ack)
1975 ),
1976 TP_fast_assign(
1977 WDEV_ASSIGN;
1978 __entry->cookie = cookie;
1979 __entry->ack = ack;
1980 ),
1981 TP_printk(WDEV_PR_FMT", cookie: %llu, ack: %s",
1982 WDEV_PR_ARG, __entry->cookie, BOOL_TO_STR(__entry->ack))
1983);
1984
1985TRACE_EVENT(cfg80211_cqm_rssi_notify,
1986 TP_PROTO(struct net_device *netdev,
1987 enum nl80211_cqm_rssi_threshold_event rssi_event),
1988 TP_ARGS(netdev, rssi_event),
1989 TP_STRUCT__entry(
1990 NETDEV_ENTRY
1991 __field(enum nl80211_cqm_rssi_threshold_event, rssi_event)
1992 ),
1993 TP_fast_assign(
1994 NETDEV_ASSIGN;
1995 __entry->rssi_event = rssi_event;
1996 ),
1997 TP_printk(NETDEV_PR_FMT ", rssi event: %d",
1998 NETDEV_PR_ARG, __entry->rssi_event)
1999);
2000
2001TRACE_EVENT(cfg80211_can_beacon_sec_chan,
2002 TP_PROTO(struct wiphy *wiphy, struct ieee80211_channel *channel,
2003 enum nl80211_channel_type channel_type),
2004 TP_ARGS(wiphy, channel, channel_type),
2005 TP_STRUCT__entry(
2006 WIPHY_ENTRY
2007 CHAN_ENTRY
2008 __field(enum nl80211_channel_type, channel_type)
2009 ),
2010 TP_fast_assign(
2011 WIPHY_ASSIGN;
2012 CHAN_ASSIGN(channel);
2013 __entry->channel_type = channel_type;
2014 ),
2015 TP_printk(WIPHY_PR_FMT CHAN_PR_FMT ", channel_type: %d",
2016 WIPHY_PR_ARG, CHAN_PR_ARG, __entry->channel_type)
2017);
2018
2019TRACE_EVENT(cfg80211_ch_switch_notify,
2020 TP_PROTO(struct net_device *netdev, int freq,
2021 enum nl80211_channel_type type),
2022 TP_ARGS(netdev, freq, type),
2023 TP_STRUCT__entry(
2024 NETDEV_ENTRY
2025 __field(int, freq)
2026 __field(enum nl80211_channel_type, type)
2027 ),
2028 TP_fast_assign(
2029 NETDEV_ASSIGN;
2030 __entry->freq = freq;
2031 __entry->type = type;
2032 ),
2033 TP_printk(NETDEV_PR_FMT ", freq: %d, type: %d", NETDEV_PR_ARG,
2034 __entry->freq, __entry->type)
2035);
2036
2037DECLARE_EVENT_CLASS(cfg80211_rx_evt,
2038 TP_PROTO(struct net_device *netdev, const u8 *addr),
2039 TP_ARGS(netdev, addr),
2040 TP_STRUCT__entry(
2041 NETDEV_ENTRY
2042 MAC_ENTRY(addr)
2043 ),
2044 TP_fast_assign(
2045 NETDEV_ASSIGN;
2046 MAC_ASSIGN(addr, addr);
2047 ),
2048 TP_printk(NETDEV_PR_FMT MAC_PR_FMT, NETDEV_PR_ARG, MAC_PR_ARG(addr))
2049);
2050
2051DEFINE_EVENT(cfg80211_rx_evt, cfg80211_ibss_joined,
2052 TP_PROTO(struct net_device *netdev, const u8 *addr),
2053 TP_ARGS(netdev, addr)
2054);
2055
2056DEFINE_EVENT(cfg80211_rx_evt, cfg80211_rx_spurious_frame,
2057 TP_PROTO(struct net_device *netdev, const u8 *addr),
2058 TP_ARGS(netdev, addr)
2059);
2060
2061DEFINE_EVENT(cfg80211_rx_evt, cfg80211_rx_unexpected_4addr_frame,
2062 TP_PROTO(struct net_device *netdev, const u8 *addr),
2063 TP_ARGS(netdev, addr)
2064);
2065
2066TRACE_EVENT(cfg80211_probe_status,
2067 TP_PROTO(struct net_device *netdev, const u8 *addr, u64 cookie,
2068 bool acked),
2069 TP_ARGS(netdev, addr, cookie, acked),
2070 TP_STRUCT__entry(
2071 NETDEV_ENTRY
2072 MAC_ENTRY(addr)
2073 __field(u64, cookie)
2074 __field(bool, acked)
2075 ),
2076 TP_fast_assign(
2077 NETDEV_ASSIGN;
2078 MAC_ASSIGN(addr, addr);
2079 __entry->cookie = cookie;
2080 __entry->acked = acked;
2081 ),
2082 TP_printk(NETDEV_PR_FMT MAC_PR_FMT ", cookie: %llu, acked: %s",
2083 NETDEV_PR_ARG, MAC_PR_ARG(addr), __entry->cookie,
2084 BOOL_TO_STR(__entry->acked))
2085);
2086
2087TRACE_EVENT(cfg80211_cqm_pktloss_notify,
2088 TP_PROTO(struct net_device *netdev, const u8 *peer, u32 num_packets),
2089 TP_ARGS(netdev, peer, num_packets),
2090 TP_STRUCT__entry(
2091 NETDEV_ENTRY
2092 MAC_ENTRY(peer)
2093 __field(u32, num_packets)
2094 ),
2095 TP_fast_assign(
2096 NETDEV_ASSIGN;
2097 MAC_ASSIGN(peer, peer);
2098 __entry->num_packets = num_packets;
2099 ),
2100 TP_printk(NETDEV_PR_FMT ", peer: " MAC_PR_FMT ", num of lost packets: %u",
2101 NETDEV_PR_ARG, MAC_PR_ARG(peer), __entry->num_packets)
2102);
2103
2104DEFINE_EVENT(cfg80211_netdev_mac_evt, cfg80211_gtk_rekey_notify,
2105 TP_PROTO(struct net_device *netdev, const u8 *macaddr),
2106 TP_ARGS(netdev, macaddr)
2107);
2108
2109TRACE_EVENT(cfg80211_pmksa_candidate_notify,
2110 TP_PROTO(struct net_device *netdev, int index, const u8 *bssid,
2111 bool preauth),
2112 TP_ARGS(netdev, index, bssid, preauth),
2113 TP_STRUCT__entry(
2114 NETDEV_ENTRY
2115 __field(int, index)
2116 MAC_ENTRY(bssid)
2117 __field(bool, preauth)
2118 ),
2119 TP_fast_assign(
2120 NETDEV_ASSIGN;
2121 __entry->index = index;
2122 MAC_ASSIGN(bssid, bssid);
2123 __entry->preauth = preauth;
2124 ),
2125 TP_printk(NETDEV_PR_FMT ", index:%d, bssid: " MAC_PR_FMT ", pre auth: %s",
2126 NETDEV_PR_ARG, __entry->index, MAC_PR_ARG(bssid),
2127 BOOL_TO_STR(__entry->preauth))
2128);
2129
2130TRACE_EVENT(cfg80211_report_obss_beacon,
2131 TP_PROTO(struct wiphy *wiphy, const u8 *frame, size_t len,
2132 int freq, int sig_dbm),
2133 TP_ARGS(wiphy, frame, len, freq, sig_dbm),
2134 TP_STRUCT__entry(
2135 WIPHY_ENTRY
2136 __field(int, freq)
2137 __field(int, sig_dbm)
2138 ),
2139 TP_fast_assign(
2140 WIPHY_ASSIGN;
2141 __entry->freq = freq;
2142 __entry->sig_dbm = sig_dbm;
2143 ),
2144 TP_printk(WIPHY_PR_FMT ", freq: %d, sig_dbm: %d",
2145 WIPHY_PR_ARG, __entry->freq, __entry->sig_dbm)
2146);
2147
2148TRACE_EVENT(cfg80211_scan_done,
2149 TP_PROTO(struct cfg80211_scan_request *request, bool aborted),
2150 TP_ARGS(request, aborted),
2151 TP_STRUCT__entry(
2152 __field(u32, n_channels)
2153 __dynamic_array(u8, ie, request ? request->ie_len : 0)
2154 __array(u32, rates, IEEE80211_NUM_BANDS)
2155 __field(u32, wdev_id)
2156 MAC_ENTRY(wiphy_mac)
2157 __field(bool, no_cck)
2158 __field(bool, aborted)
2159 ),
2160 TP_fast_assign(
2161 if (request) {
2162 memcpy(__get_dynamic_array(ie), request->ie,
2163 request->ie_len);
2164 memcpy(__entry->rates, request->rates,
2165 IEEE80211_NUM_BANDS);
2166 __entry->wdev_id = request->wdev ?
2167 request->wdev->identifier : 0;
2168 if (request->wiphy)
2169 MAC_ASSIGN(wiphy_mac,
2170 request->wiphy->perm_addr);
2171 __entry->no_cck = request->no_cck;
2172 }
2173 __entry->aborted = aborted;
2174 ),
2175 TP_printk("aborted: %s", BOOL_TO_STR(__entry->aborted))
2176);
2177
2178DEFINE_EVENT(wiphy_only_evt, cfg80211_sched_scan_results,
2179 TP_PROTO(struct wiphy *wiphy),
2180 TP_ARGS(wiphy)
2181);
2182
2183DEFINE_EVENT(wiphy_only_evt, cfg80211_sched_scan_stopped,
2184 TP_PROTO(struct wiphy *wiphy),
2185 TP_ARGS(wiphy)
2186);
2187
2188TRACE_EVENT(cfg80211_get_bss,
2189 TP_PROTO(struct wiphy *wiphy, struct ieee80211_channel *channel,
2190 const u8 *bssid, const u8 *ssid, size_t ssid_len,
2191 u16 capa_mask, u16 capa_val),
2192 TP_ARGS(wiphy, channel, bssid, ssid, ssid_len, capa_mask, capa_val),
2193 TP_STRUCT__entry(
2194 WIPHY_ENTRY
2195 CHAN_ENTRY
2196 MAC_ENTRY(bssid)
2197 __dynamic_array(u8, ssid, ssid_len)
2198 __field(u16, capa_mask)
2199 __field(u16, capa_val)
2200 ),
2201 TP_fast_assign(
2202 WIPHY_ASSIGN;
2203 CHAN_ASSIGN(channel);
2204 MAC_ASSIGN(bssid, bssid);
2205 memcpy(__get_dynamic_array(ssid), ssid, ssid_len);
2206 __entry->capa_mask = capa_mask;
2207 __entry->capa_val = capa_val;
2208 ),
2209 TP_printk(WIPHY_PR_FMT CHAN_PR_FMT MAC_PR_FMT ", buf: %#.2x, "
2210 "capa_mask: %d, capa_val: %u", WIPHY_PR_ARG, CHAN_PR_ARG,
2211 MAC_PR_ARG(bssid), ((u8 *)__get_dynamic_array(ssid))[0],
2212 __entry->capa_mask, __entry->capa_val)
2213);
2214
2215TRACE_EVENT(cfg80211_inform_bss_frame,
2216 TP_PROTO(struct wiphy *wiphy, struct ieee80211_channel *channel,
2217 struct ieee80211_mgmt *mgmt, size_t len,
2218 s32 signal),
2219 TP_ARGS(wiphy, channel, mgmt, len, signal),
2220 TP_STRUCT__entry(
2221 WIPHY_ENTRY
2222 CHAN_ENTRY
2223 __dynamic_array(u8, mgmt, len)
2224 __field(s32, signal)
2225 ),
2226 TP_fast_assign(
2227 WIPHY_ASSIGN;
2228 CHAN_ASSIGN(channel);
2229 if (mgmt)
2230 memcpy(__get_dynamic_array(mgmt), mgmt, len);
2231 __entry->signal = signal;
2232 ),
2233 TP_printk(WIPHY_PR_FMT CHAN_PR_FMT "signal: %d",
2234 WIPHY_PR_ARG, CHAN_PR_ARG, __entry->signal)
2235);
2236
2237DECLARE_EVENT_CLASS(cfg80211_bss_evt,
2238 TP_PROTO(struct cfg80211_bss *pub),
2239 TP_ARGS(pub),
2240 TP_STRUCT__entry(
2241 MAC_ENTRY(bssid)
2242 CHAN_ENTRY
2243 ),
2244 TP_fast_assign(
2245 MAC_ASSIGN(bssid, pub->bssid);
2246 CHAN_ASSIGN(pub->channel);
2247 ),
2248 TP_printk(MAC_PR_FMT CHAN_PR_FMT, MAC_PR_ARG(bssid), CHAN_PR_ARG)
2249);
2250
2251DEFINE_EVENT(cfg80211_bss_evt, cfg80211_return_bss,
2252 TP_PROTO(struct cfg80211_bss *pub),
2253 TP_ARGS(pub)
2254);
2255
2256TRACE_EVENT(cfg80211_return_uint,
2257 TP_PROTO(unsigned int ret),
2258 TP_ARGS(ret),
2259 TP_STRUCT__entry(
2260 __field(unsigned int, ret)
2261 ),
2262 TP_fast_assign(
2263 __entry->ret = ret;
2264 ),
2265 TP_printk("ret: %d", __entry->ret)
2266);
2267
2268TRACE_EVENT(cfg80211_return_u32,
2269 TP_PROTO(u32 ret),
2270 TP_ARGS(ret),
2271 TP_STRUCT__entry(
2272 __field(u32, ret)
2273 ),
2274 TP_fast_assign(
2275 __entry->ret = ret;
2276 ),
2277 TP_printk("ret: %u", __entry->ret)
2278);
2279
2280#endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */
2281
2282#undef TRACE_INCLUDE_PATH
2283#define TRACE_INCLUDE_PATH .
2284#undef TRACE_INCLUDE_FILE
2285#define TRACE_INCLUDE_FILE trace
2286#include <trace/define_trace.h>
diff --git a/net/wireless/util.c b/net/wireless/util.c
index ef35f4ef2aa6..343f13c1d31d 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -11,6 +11,8 @@
11#include <net/ip.h> 11#include <net/ip.h>
12#include <net/dsfield.h> 12#include <net/dsfield.h>
13#include "core.h" 13#include "core.h"
14#include "rdev-ops.h"
15
14 16
15struct ieee80211_rate * 17struct ieee80211_rate *
16ieee80211_get_response_rate(struct ieee80211_supported_band *sband, 18ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
@@ -703,19 +705,18 @@ void cfg80211_upload_connect_keys(struct wireless_dev *wdev)
703 for (i = 0; i < 6; i++) { 705 for (i = 0; i < 6; i++) {
704 if (!wdev->connect_keys->params[i].cipher) 706 if (!wdev->connect_keys->params[i].cipher)
705 continue; 707 continue;
706 if (rdev->ops->add_key(wdev->wiphy, dev, i, false, NULL, 708 if (rdev_add_key(rdev, dev, i, false, NULL,
707 &wdev->connect_keys->params[i])) { 709 &wdev->connect_keys->params[i])) {
708 netdev_err(dev, "failed to set key %d\n", i); 710 netdev_err(dev, "failed to set key %d\n", i);
709 continue; 711 continue;
710 } 712 }
711 if (wdev->connect_keys->def == i) 713 if (wdev->connect_keys->def == i)
712 if (rdev->ops->set_default_key(wdev->wiphy, dev, 714 if (rdev_set_default_key(rdev, dev, i, true, true)) {
713 i, true, true)) {
714 netdev_err(dev, "failed to set defkey %d\n", i); 715 netdev_err(dev, "failed to set defkey %d\n", i);
715 continue; 716 continue;
716 } 717 }
717 if (wdev->connect_keys->defmgmt == i) 718 if (wdev->connect_keys->defmgmt == i)
718 if (rdev->ops->set_default_mgmt_key(wdev->wiphy, dev, i)) 719 if (rdev_set_default_mgmt_key(rdev, dev, i))
719 netdev_err(dev, "failed to set mgtdef %d\n", i); 720 netdev_err(dev, "failed to set mgtdef %d\n", i);
720 } 721 }
721 722
@@ -848,8 +849,7 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev,
848 cfg80211_process_rdev_events(rdev); 849 cfg80211_process_rdev_events(rdev);
849 } 850 }
850 851
851 err = rdev->ops->change_virtual_intf(&rdev->wiphy, dev, 852 err = rdev_change_virtual_intf(rdev, dev, ntype, flags, params);
852 ntype, flags, params);
853 853
854 WARN_ON(!err && dev->ieee80211_ptr->iftype != ntype); 854 WARN_ON(!err && dev->ieee80211_ptr->iftype != ntype);
855 855
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c
index 494379eb464f..6488d2dbc1d7 100644
--- a/net/wireless/wext-compat.c
+++ b/net/wireless/wext-compat.c
@@ -19,6 +19,7 @@
19#include <net/cfg80211-wext.h> 19#include <net/cfg80211-wext.h>
20#include "wext-compat.h" 20#include "wext-compat.h"
21#include "core.h" 21#include "core.h"
22#include "rdev-ops.h"
22 23
23int cfg80211_wext_giwname(struct net_device *dev, 24int cfg80211_wext_giwname(struct net_device *dev,
24 struct iw_request_info *info, 25 struct iw_request_info *info,
@@ -301,8 +302,7 @@ int cfg80211_wext_siwrts(struct net_device *dev,
301 else 302 else
302 wdev->wiphy->rts_threshold = rts->value; 303 wdev->wiphy->rts_threshold = rts->value;
303 304
304 err = rdev->ops->set_wiphy_params(wdev->wiphy, 305 err = rdev_set_wiphy_params(rdev, WIPHY_PARAM_RTS_THRESHOLD);
305 WIPHY_PARAM_RTS_THRESHOLD);
306 if (err) 306 if (err)
307 wdev->wiphy->rts_threshold = orts; 307 wdev->wiphy->rts_threshold = orts;
308 308
@@ -342,8 +342,7 @@ int cfg80211_wext_siwfrag(struct net_device *dev,
342 wdev->wiphy->frag_threshold = frag->value & ~0x1; 342 wdev->wiphy->frag_threshold = frag->value & ~0x1;
343 } 343 }
344 344
345 err = rdev->ops->set_wiphy_params(wdev->wiphy, 345 err = rdev_set_wiphy_params(rdev, WIPHY_PARAM_FRAG_THRESHOLD);
346 WIPHY_PARAM_FRAG_THRESHOLD);
347 if (err) 346 if (err)
348 wdev->wiphy->frag_threshold = ofrag; 347 wdev->wiphy->frag_threshold = ofrag;
349 348
@@ -396,7 +395,7 @@ static int cfg80211_wext_siwretry(struct net_device *dev,
396 if (!changed) 395 if (!changed)
397 return 0; 396 return 0;
398 397
399 err = rdev->ops->set_wiphy_params(wdev->wiphy, changed); 398 err = rdev_set_wiphy_params(rdev, changed);
400 if (err) { 399 if (err) {
401 wdev->wiphy->retry_short = oshort; 400 wdev->wiphy->retry_short = oshort;
402 wdev->wiphy->retry_long = olong; 401 wdev->wiphy->retry_long = olong;
@@ -490,8 +489,8 @@ static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev,
490 !(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN)) 489 !(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN))
491 err = -ENOENT; 490 err = -ENOENT;
492 else 491 else
493 err = rdev->ops->del_key(&rdev->wiphy, dev, idx, 492 err = rdev_del_key(rdev, dev, idx, pairwise,
494 pairwise, addr); 493 addr);
495 } 494 }
496 wdev->wext.connect.privacy = false; 495 wdev->wext.connect.privacy = false;
497 /* 496 /*
@@ -525,8 +524,7 @@ static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev,
525 524
526 err = 0; 525 err = 0;
527 if (wdev->current_bss) 526 if (wdev->current_bss)
528 err = rdev->ops->add_key(&rdev->wiphy, dev, idx, 527 err = rdev_add_key(rdev, dev, idx, pairwise, addr, params);
529 pairwise, addr, params);
530 if (err) 528 if (err)
531 return err; 529 return err;
532 530
@@ -552,8 +550,7 @@ static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev,
552 __cfg80211_leave_ibss(rdev, wdev->netdev, true); 550 __cfg80211_leave_ibss(rdev, wdev->netdev, true);
553 rejoin = true; 551 rejoin = true;
554 } 552 }
555 err = rdev->ops->set_default_key(&rdev->wiphy, dev, 553 err = rdev_set_default_key(rdev, dev, idx, true, true);
556 idx, true, true);
557 } 554 }
558 if (!err) { 555 if (!err) {
559 wdev->wext.default_key = idx; 556 wdev->wext.default_key = idx;
@@ -566,8 +563,7 @@ static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev,
566 if (params->cipher == WLAN_CIPHER_SUITE_AES_CMAC && 563 if (params->cipher == WLAN_CIPHER_SUITE_AES_CMAC &&
567 (tx_key || (!addr && wdev->wext.default_mgmt_key == -1))) { 564 (tx_key || (!addr && wdev->wext.default_mgmt_key == -1))) {
568 if (wdev->current_bss) 565 if (wdev->current_bss)
569 err = rdev->ops->set_default_mgmt_key(&rdev->wiphy, 566 err = rdev_set_default_mgmt_key(rdev, dev, idx);
570 dev, idx);
571 if (!err) 567 if (!err)
572 wdev->wext.default_mgmt_key = idx; 568 wdev->wext.default_mgmt_key = idx;
573 return err; 569 return err;
@@ -631,8 +627,8 @@ static int cfg80211_wext_siwencode(struct net_device *dev,
631 err = 0; 627 err = 0;
632 wdev_lock(wdev); 628 wdev_lock(wdev);
633 if (wdev->current_bss) 629 if (wdev->current_bss)
634 err = rdev->ops->set_default_key(&rdev->wiphy, dev, 630 err = rdev_set_default_key(rdev, dev, idx, true,
635 idx, true, true); 631 true);
636 if (!err) 632 if (!err)
637 wdev->wext.default_key = idx; 633 wdev->wext.default_key = idx;
638 wdev_unlock(wdev); 634 wdev_unlock(wdev);
@@ -839,7 +835,7 @@ static int cfg80211_wext_giwfreq(struct net_device *dev,
839 if (!rdev->ops->get_channel) 835 if (!rdev->ops->get_channel)
840 return -EINVAL; 836 return -EINVAL;
841 837
842 chan = rdev->ops->get_channel(wdev->wiphy, wdev, &channel_type); 838 chan = rdev_get_channel(rdev, wdev, &channel_type);
843 if (!chan) 839 if (!chan)
844 return -EINVAL; 840 return -EINVAL;
845 freq->m = chan->center_freq; 841 freq->m = chan->center_freq;
@@ -899,7 +895,7 @@ static int cfg80211_wext_siwtxpower(struct net_device *dev,
899 return 0; 895 return 0;
900 } 896 }
901 897
902 return rdev->ops->set_tx_power(wdev->wiphy, type, DBM_TO_MBM(dbm)); 898 return rdev_set_tx_power(rdev, type, DBM_TO_MBM(dbm));
903} 899}
904 900
905static int cfg80211_wext_giwtxpower(struct net_device *dev, 901static int cfg80211_wext_giwtxpower(struct net_device *dev,
@@ -918,7 +914,7 @@ static int cfg80211_wext_giwtxpower(struct net_device *dev,
918 if (!rdev->ops->get_tx_power) 914 if (!rdev->ops->get_tx_power)
919 return -EOPNOTSUPP; 915 return -EOPNOTSUPP;
920 916
921 err = rdev->ops->get_tx_power(wdev->wiphy, &val); 917 err = rdev_get_tx_power(rdev, &val);
922 if (err) 918 if (err)
923 return err; 919 return err;
924 920
@@ -1158,7 +1154,7 @@ static int cfg80211_wext_siwpower(struct net_device *dev,
1158 timeout = wrq->value / 1000; 1154 timeout = wrq->value / 1000;
1159 } 1155 }
1160 1156
1161 err = rdev->ops->set_power_mgmt(wdev->wiphy, dev, ps, timeout); 1157 err = rdev_set_power_mgmt(rdev, dev, ps, timeout);
1162 if (err) 1158 if (err)
1163 return err; 1159 return err;
1164 1160
@@ -1200,7 +1196,7 @@ static int cfg80211_wds_wext_siwap(struct net_device *dev,
1200 if (!rdev->ops->set_wds_peer) 1196 if (!rdev->ops->set_wds_peer)
1201 return -EOPNOTSUPP; 1197 return -EOPNOTSUPP;
1202 1198
1203 err = rdev->ops->set_wds_peer(wdev->wiphy, dev, (u8 *) &addr->sa_data); 1199 err = rdev_set_wds_peer(rdev, dev, (u8 *)&addr->sa_data);
1204 if (err) 1200 if (err)
1205 return err; 1201 return err;
1206 1202
@@ -1272,7 +1268,7 @@ static int cfg80211_wext_siwrate(struct net_device *dev,
1272 if (!match) 1268 if (!match)
1273 return -EINVAL; 1269 return -EINVAL;
1274 1270
1275 return rdev->ops->set_bitrate_mask(wdev->wiphy, dev, NULL, &mask); 1271 return rdev_set_bitrate_mask(rdev, dev, NULL, &mask);
1276} 1272}
1277 1273
1278static int cfg80211_wext_giwrate(struct net_device *dev, 1274static int cfg80211_wext_giwrate(struct net_device *dev,
@@ -1302,7 +1298,7 @@ static int cfg80211_wext_giwrate(struct net_device *dev,
1302 if (err) 1298 if (err)
1303 return err; 1299 return err;
1304 1300
1305 err = rdev->ops->get_station(&rdev->wiphy, dev, addr, &sinfo); 1301 err = rdev_get_station(rdev, dev, addr, &sinfo);
1306 if (err) 1302 if (err)
1307 return err; 1303 return err;
1308 1304
@@ -1339,7 +1335,7 @@ static struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev)
1339 memcpy(bssid, wdev->current_bss->pub.bssid, ETH_ALEN); 1335 memcpy(bssid, wdev->current_bss->pub.bssid, ETH_ALEN);
1340 wdev_unlock(wdev); 1336 wdev_unlock(wdev);
1341 1337
1342 if (rdev->ops->get_station(&rdev->wiphy, dev, bssid, &sinfo)) 1338 if (rdev_get_station(rdev, dev, bssid, &sinfo))
1343 return NULL; 1339 return NULL;
1344 1340
1345 memset(&wstats, 0, sizeof(wstats)); 1341 memset(&wstats, 0, sizeof(wstats));
@@ -1474,19 +1470,19 @@ static int cfg80211_wext_siwpmksa(struct net_device *dev,
1474 if (!rdev->ops->set_pmksa) 1470 if (!rdev->ops->set_pmksa)
1475 return -EOPNOTSUPP; 1471 return -EOPNOTSUPP;
1476 1472
1477 return rdev->ops->set_pmksa(&rdev->wiphy, dev, &cfg_pmksa); 1473 return rdev_set_pmksa(rdev, dev, &cfg_pmksa);
1478 1474
1479 case IW_PMKSA_REMOVE: 1475 case IW_PMKSA_REMOVE:
1480 if (!rdev->ops->del_pmksa) 1476 if (!rdev->ops->del_pmksa)
1481 return -EOPNOTSUPP; 1477 return -EOPNOTSUPP;
1482 1478
1483 return rdev->ops->del_pmksa(&rdev->wiphy, dev, &cfg_pmksa); 1479 return rdev_del_pmksa(rdev, dev, &cfg_pmksa);
1484 1480
1485 case IW_PMKSA_FLUSH: 1481 case IW_PMKSA_FLUSH:
1486 if (!rdev->ops->flush_pmksa) 1482 if (!rdev->ops->flush_pmksa)
1487 return -EOPNOTSUPP; 1483 return -EOPNOTSUPP;
1488 1484
1489 return rdev->ops->flush_pmksa(&rdev->wiphy, dev); 1485 return rdev_flush_pmksa(rdev, dev);
1490 1486
1491 default: 1487 default:
1492 return -EOPNOTSUPP; 1488 return -EOPNOTSUPP;