aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2012-11-08 15:25:48 -0500
committerJohannes Berg <johannes.berg@intel.com>2012-11-26 06:42:58 -0500
commit683b6d3b31a51956ea540df00abb0b78894924c1 (patch)
tree558e0f316b56368ab259755cb4eeaeb40331853d /net/mac80211
parentfe4b31810c06cc6518fb193efb9b3c3289b55832 (diff)
cfg80211: pass a channel definition struct
Instead of passing a channel pointer and channel type to all functions and driver methods, pass a new channel definition struct. Right now, this struct contains just the control channel and channel type, but for VHT this will change. Also, add a small inline cfg80211_get_chandef_type() so that drivers don't need to use the _type field of the new structure all the time, which will change. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211')
-rw-r--r--net/mac80211/cfg.c43
-rw-r--r--net/mac80211/ibss.c21
2 files changed, 36 insertions, 28 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index ac0241e3539b..fbb2d072cb9e 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -735,14 +735,16 @@ static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
735} 735}
736 736
737static int ieee80211_set_monitor_channel(struct wiphy *wiphy, 737static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
738 struct ieee80211_channel *chan, 738 struct cfg80211_chan_def *chandef)
739 enum nl80211_channel_type channel_type)
740{ 739{
741 struct ieee80211_local *local = wiphy_priv(wiphy); 740 struct ieee80211_local *local = wiphy_priv(wiphy);
742 struct ieee80211_sub_if_data *sdata; 741 struct ieee80211_sub_if_data *sdata;
742 enum nl80211_channel_type channel_type;
743 int ret = 0; 743 int ret = 0;
744 744
745 if (local->monitor_channel == chan && 745 channel_type = cfg80211_get_chandef_type(chandef);
746
747 if (local->monitor_channel == chandef->chan &&
746 local->monitor_channel_type == channel_type) 748 local->monitor_channel_type == channel_type)
747 return 0; 749 return 0;
748 750
@@ -754,17 +756,17 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
754 if (sdata) { 756 if (sdata) {
755 ieee80211_vif_release_channel(sdata); 757 ieee80211_vif_release_channel(sdata);
756 ret = ieee80211_vif_use_channel( 758 ret = ieee80211_vif_use_channel(
757 sdata, chan, channel_type, 759 sdata, chandef->chan, channel_type,
758 IEEE80211_CHANCTX_EXCLUSIVE); 760 IEEE80211_CHANCTX_EXCLUSIVE);
759 } 761 }
760 } else if (local->open_count == local->monitors) { 762 } else if (local->open_count == local->monitors) {
761 local->_oper_channel = chan; 763 local->_oper_channel = chandef->chan;
762 local->_oper_channel_type = channel_type; 764 local->_oper_channel_type = channel_type;
763 ieee80211_hw_config(local, 0); 765 ieee80211_hw_config(local, 0);
764 } 766 }
765 767
766 if (ret == 0) { 768 if (ret == 0) {
767 local->monitor_channel = chan; 769 local->monitor_channel = chandef->chan;
768 local->monitor_channel_type = channel_type; 770 local->monitor_channel_type = channel_type;
769 } 771 }
770 mutex_unlock(&local->iflist_mtx); 772 mutex_unlock(&local->iflist_mtx);
@@ -888,9 +890,10 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
888 sdata->smps_mode = IEEE80211_SMPS_OFF; 890 sdata->smps_mode = IEEE80211_SMPS_OFF;
889 sdata->needed_rx_chains = sdata->local->rx_chains; 891 sdata->needed_rx_chains = sdata->local->rx_chains;
890 892
891 err = ieee80211_vif_use_channel(sdata, params->channel, 893 err = ieee80211_vif_use_channel(
892 params->channel_type, 894 sdata, params->chandef.chan,
893 IEEE80211_CHANCTX_SHARED); 895 cfg80211_get_chandef_type(&params->chandef),
896 IEEE80211_CHANCTX_SHARED);
894 if (err) 897 if (err)
895 return err; 898 return err;
896 899
@@ -1707,9 +1710,10 @@ static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,
1707 sdata->smps_mode = IEEE80211_SMPS_OFF; 1710 sdata->smps_mode = IEEE80211_SMPS_OFF;
1708 sdata->needed_rx_chains = sdata->local->rx_chains; 1711 sdata->needed_rx_chains = sdata->local->rx_chains;
1709 1712
1710 err = ieee80211_vif_use_channel(sdata, setup->channel, 1713 err = ieee80211_vif_use_channel(
1711 setup->channel_type, 1714 sdata, setup->chandef.chan,
1712 IEEE80211_CHANCTX_SHARED); 1715 cfg80211_get_chandef_type(&setup->chandef),
1716 IEEE80211_CHANCTX_SHARED);
1713 if (err) 1717 if (err)
1714 return err; 1718 return err;
1715 1719
@@ -3110,23 +3114,24 @@ static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
3110 return 0; 3114 return 0;
3111} 3115}
3112 3116
3113static struct ieee80211_channel * 3117static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
3114ieee80211_cfg_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev, 3118 struct wireless_dev *wdev,
3115 enum nl80211_channel_type *type) 3119 struct cfg80211_chan_def *chandef)
3116{ 3120{
3117 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); 3121 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3118 struct ieee80211_chanctx_conf *chanctx_conf; 3122 struct ieee80211_chanctx_conf *chanctx_conf;
3119 struct ieee80211_channel *chan = NULL; 3123 int ret = -ENODATA;
3120 3124
3121 rcu_read_lock(); 3125 rcu_read_lock();
3122 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); 3126 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
3123 if (chanctx_conf) { 3127 if (chanctx_conf) {
3124 *type = chanctx_conf->channel_type; 3128 chandef->chan = chanctx_conf->channel;
3125 chan = chanctx_conf->channel; 3129 chandef->_type = chanctx_conf->channel_type;
3130 ret = 0;
3126 } 3131 }
3127 rcu_read_unlock(); 3132 rcu_read_unlock();
3128 3133
3129 return chan; 3134 return ret;
3130} 3135}
3131 3136
3132#ifdef CONFIG_PM 3137#ifdef CONFIG_PM
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index 845973b67a73..bed616fd97e9 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -51,7 +51,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
51 struct cfg80211_bss *bss; 51 struct cfg80211_bss *bss;
52 u32 bss_change; 52 u32 bss_change;
53 u8 supp_rates[IEEE80211_MAX_SUPP_RATES]; 53 u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
54 enum nl80211_channel_type channel_type; 54 struct cfg80211_chan_def chandef;
55 55
56 lockdep_assert_held(&ifibss->mtx); 56 lockdep_assert_held(&ifibss->mtx);
57 57
@@ -79,12 +79,13 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
79 79
80 sdata->drop_unencrypted = capability & WLAN_CAPABILITY_PRIVACY ? 1 : 0; 80 sdata->drop_unencrypted = capability & WLAN_CAPABILITY_PRIVACY ? 1 : 0;
81 81
82 channel_type = ifibss->channel_type; 82 chandef.chan = chan;
83 if (!cfg80211_can_beacon_sec_chan(local->hw.wiphy, chan, channel_type)) 83 chandef._type = ifibss->channel_type;
84 channel_type = NL80211_CHAN_HT20; 84 if (!cfg80211_reg_can_beacon(local->hw.wiphy, &chandef))
85 chandef._type = NL80211_CHAN_HT20;
85 86
86 ieee80211_vif_release_channel(sdata); 87 ieee80211_vif_release_channel(sdata);
87 if (ieee80211_vif_use_channel(sdata, chan, channel_type, 88 if (ieee80211_vif_use_channel(sdata, chan, chandef._type,
88 ifibss->fixed_channel ? 89 ifibss->fixed_channel ?
89 IEEE80211_CHANCTX_SHARED : 90 IEEE80211_CHANCTX_SHARED :
90 IEEE80211_CHANCTX_EXCLUSIVE)) { 91 IEEE80211_CHANCTX_EXCLUSIVE)) {
@@ -158,7 +159,8 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
158 ifibss->ie, ifibss->ie_len); 159 ifibss->ie, ifibss->ie_len);
159 160
160 /* add HT capability and information IEs */ 161 /* add HT capability and information IEs */
161 if (channel_type && sband->ht_cap.ht_supported) { 162 if (chandef._type != NL80211_CHAN_NO_HT &&
163 sband->ht_cap.ht_supported) {
162 pos = skb_put(skb, 4 + 164 pos = skb_put(skb, 4 +
163 sizeof(struct ieee80211_ht_cap) + 165 sizeof(struct ieee80211_ht_cap) +
164 sizeof(struct ieee80211_ht_operation)); 166 sizeof(struct ieee80211_ht_operation));
@@ -170,7 +172,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
170 * keep them at 0 172 * keep them at 0
171 */ 173 */
172 pos = ieee80211_ie_build_ht_oper(pos, &sband->ht_cap, 174 pos = ieee80211_ie_build_ht_oper(pos, &sband->ht_cap,
173 chan, channel_type, 0); 175 chan, chandef._type, 0);
174 } 176 }
175 177
176 if (local->hw.queues >= IEEE80211_NUM_ACS) { 178 if (local->hw.queues >= IEEE80211_NUM_ACS) {
@@ -1078,8 +1080,9 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
1078 1080
1079 sdata->vif.bss_conf.beacon_int = params->beacon_interval; 1081 sdata->vif.bss_conf.beacon_int = params->beacon_interval;
1080 1082
1081 sdata->u.ibss.channel = params->channel; 1083 sdata->u.ibss.channel = params->chandef.chan;
1082 sdata->u.ibss.channel_type = params->channel_type; 1084 sdata->u.ibss.channel_type =
1085 cfg80211_get_chandef_type(&params->chandef);
1083 sdata->u.ibss.fixed_channel = params->channel_fixed; 1086 sdata->u.ibss.fixed_channel = params->channel_fixed;
1084 1087
1085 if (params->ie) { 1088 if (params->ie) {