2 * mac80211 - channel management
5 #include <linux/nl80211.h>
6 #include "ieee80211_i.h"
8 static enum ieee80211_chan_mode
9 __ieee80211_get_channel_mode(struct ieee80211_local
*local
,
10 struct ieee80211_sub_if_data
*ignore
)
12 struct ieee80211_sub_if_data
*sdata
;
14 lockdep_assert_held(&local
->iflist_mtx
);
16 list_for_each_entry(sdata
, &local
->interfaces
, list
) {
20 if (!ieee80211_sdata_running(sdata
))
23 switch (sdata
->vif
.type
) {
24 case NL80211_IFTYPE_MONITOR
:
26 case NL80211_IFTYPE_STATION
:
27 if (!sdata
->u
.mgd
.associated
)
30 case NL80211_IFTYPE_ADHOC
:
31 if (!sdata
->u
.ibss
.ssid_len
)
33 if (!sdata
->u
.ibss
.fixed_channel
)
34 return CHAN_MODE_HOPPING
;
36 case NL80211_IFTYPE_AP_VLAN
:
37 /* will also have _AP interface */
39 case NL80211_IFTYPE_AP
:
40 if (!sdata
->u
.ap
.beacon
)
47 return CHAN_MODE_FIXED
;
50 return CHAN_MODE_UNDEFINED
;
53 enum ieee80211_chan_mode
54 ieee80211_get_channel_mode(struct ieee80211_local
*local
,
55 struct ieee80211_sub_if_data
*ignore
)
57 enum ieee80211_chan_mode mode
;
59 mutex_lock(&local
->iflist_mtx
);
60 mode
= __ieee80211_get_channel_mode(local
, ignore
);
61 mutex_unlock(&local
->iflist_mtx
);
66 bool ieee80211_set_channel_type(struct ieee80211_local
*local
,
67 struct ieee80211_sub_if_data
*sdata
,
68 enum nl80211_channel_type chantype
)
70 struct ieee80211_sub_if_data
*tmp
;
71 enum nl80211_channel_type superchan
= NL80211_CHAN_NO_HT
;
74 mutex_lock(&local
->iflist_mtx
);
76 list_for_each_entry(tmp
, &local
->interfaces
, list
) {
80 if (!ieee80211_sdata_running(tmp
))
83 switch (tmp
->vif
.bss_conf
.channel_type
) {
84 case NL80211_CHAN_NO_HT
:
85 case NL80211_CHAN_HT20
:
86 if (superchan
> tmp
->vif
.bss_conf
.channel_type
)
89 superchan
= tmp
->vif
.bss_conf
.channel_type
;
91 case NL80211_CHAN_HT40PLUS
:
92 WARN_ON(superchan
== NL80211_CHAN_HT40MINUS
);
93 superchan
= NL80211_CHAN_HT40PLUS
;
95 case NL80211_CHAN_HT40MINUS
:
96 WARN_ON(superchan
== NL80211_CHAN_HT40PLUS
);
97 superchan
= NL80211_CHAN_HT40MINUS
;
103 case NL80211_CHAN_NO_HT
:
104 case NL80211_CHAN_HT20
:
106 * allow any change that doesn't go to no-HT
107 * (if it already is no-HT no change is needed)
109 if (chantype
== NL80211_CHAN_NO_HT
)
111 superchan
= chantype
;
113 case NL80211_CHAN_HT40PLUS
:
114 case NL80211_CHAN_HT40MINUS
:
115 /* allow smaller bandwidth and same */
116 if (chantype
== NL80211_CHAN_NO_HT
)
118 if (chantype
== NL80211_CHAN_HT20
)
120 if (superchan
== chantype
)
126 local
->_oper_channel_type
= superchan
;
129 sdata
->vif
.bss_conf
.channel_type
= chantype
;
133 mutex_unlock(&local
->iflist_mtx
);