2 * mac80211 - channel management
5 #include <linux/nl80211.h>
6 #include <net/cfg80211.h>
7 #include "ieee80211_i.h"
9 static enum ieee80211_chan_mode
10 __ieee80211_get_channel_mode(struct ieee80211_local
*local
,
11 struct ieee80211_sub_if_data
*ignore
)
13 struct ieee80211_sub_if_data
*sdata
;
15 lockdep_assert_held(&local
->iflist_mtx
);
17 list_for_each_entry(sdata
, &local
->interfaces
, list
) {
21 if (!ieee80211_sdata_running(sdata
))
24 switch (sdata
->vif
.type
) {
25 case NL80211_IFTYPE_MONITOR
:
27 case NL80211_IFTYPE_STATION
:
28 if (!sdata
->u
.mgd
.associated
)
31 case NL80211_IFTYPE_ADHOC
:
32 if (!sdata
->u
.ibss
.ssid_len
)
34 if (!sdata
->u
.ibss
.fixed_channel
)
35 return CHAN_MODE_HOPPING
;
37 case NL80211_IFTYPE_AP_VLAN
:
38 /* will also have _AP interface */
40 case NL80211_IFTYPE_AP
:
41 if (!sdata
->u
.ap
.beacon
)
48 return CHAN_MODE_FIXED
;
51 return CHAN_MODE_UNDEFINED
;
54 enum ieee80211_chan_mode
55 ieee80211_get_channel_mode(struct ieee80211_local
*local
,
56 struct ieee80211_sub_if_data
*ignore
)
58 enum ieee80211_chan_mode mode
;
60 mutex_lock(&local
->iflist_mtx
);
61 mode
= __ieee80211_get_channel_mode(local
, ignore
);
62 mutex_unlock(&local
->iflist_mtx
);
67 bool ieee80211_set_channel_type(struct ieee80211_local
*local
,
68 struct ieee80211_sub_if_data
*sdata
,
69 enum nl80211_channel_type chantype
)
71 struct ieee80211_sub_if_data
*tmp
;
72 enum nl80211_channel_type superchan
= NL80211_CHAN_NO_HT
;
75 mutex_lock(&local
->iflist_mtx
);
77 list_for_each_entry(tmp
, &local
->interfaces
, list
) {
81 if (!ieee80211_sdata_running(tmp
))
84 switch (tmp
->vif
.bss_conf
.channel_type
) {
85 case NL80211_CHAN_NO_HT
:
86 case NL80211_CHAN_HT20
:
87 if (superchan
> tmp
->vif
.bss_conf
.channel_type
)
90 superchan
= tmp
->vif
.bss_conf
.channel_type
;
92 case NL80211_CHAN_HT40PLUS
:
93 WARN_ON(superchan
== NL80211_CHAN_HT40MINUS
);
94 superchan
= NL80211_CHAN_HT40PLUS
;
96 case NL80211_CHAN_HT40MINUS
:
97 WARN_ON(superchan
== NL80211_CHAN_HT40PLUS
);
98 superchan
= NL80211_CHAN_HT40MINUS
;
104 case NL80211_CHAN_NO_HT
:
105 case NL80211_CHAN_HT20
:
107 * allow any change that doesn't go to no-HT
108 * (if it already is no-HT no change is needed)
110 if (chantype
== NL80211_CHAN_NO_HT
)
112 superchan
= chantype
;
114 case NL80211_CHAN_HT40PLUS
:
115 case NL80211_CHAN_HT40MINUS
:
116 /* allow smaller bandwidth and same */
117 if (chantype
== NL80211_CHAN_NO_HT
)
119 if (chantype
== NL80211_CHAN_HT20
)
121 if (superchan
== chantype
)
127 local
->_oper_channel_type
= superchan
;
130 sdata
->vif
.bss_conf
.channel_type
= chantype
;
134 mutex_unlock(&local
->iflist_mtx
);