1 From: Arik Nemtsov <arik@wizery.com>
2 Date: Wed, 8 Jul 2015 15:41:44 +0300
3 Subject: [PATCH] cfg80211: use RTNL locked reg_can_beacon for IR-relaxation
5 The RTNL is required to check for IR-relaxation conditions that allow
6 more channels to beacon. Export an RTNL locked version of reg_can_beacon
7 and use it where possible in AP/STA interface type flows, where
8 IR-relaxation may be applicable.
10 Fixes: 06f207fc5418 ("cfg80211: change GO_CONCURRENT to IR_CONCURRENT for STA")
11 Signed-off-by: Arik Nemtsov <arikx.nemtsov@intel.com>
12 Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
15 --- a/include/net/cfg80211.h
16 +++ b/include/net/cfg80211.h
17 @@ -4871,6 +4871,23 @@ bool cfg80211_reg_can_beacon(struct wiph
18 struct cfg80211_chan_def *chandef,
19 enum nl80211_iftype iftype);
22 + * cfg80211_reg_can_beacon_relax - check if beaconing is allowed with relaxation
24 + * @chandef: the channel definition
25 + * @iftype: interface type
27 + * Return: %true if there is no secondary channel or the secondary channel(s)
28 + * can be used for beaconing (i.e. is not a radar channel etc.). This version
29 + * also checks if IR-relaxation conditions apply, to allow beaconing under
30 + * more permissive conditions.
32 + * Requires the RTNL to be held.
34 +bool cfg80211_reg_can_beacon_relax(struct wiphy *wiphy,
35 + struct cfg80211_chan_def *chandef,
36 + enum nl80211_iftype iftype);
39 * cfg80211_ch_switch_notify - update wdev channel and notify userspace
40 * @dev: the device which switched channels
41 --- a/net/mac80211/tdls.c
42 +++ b/net/mac80211/tdls.c
43 @@ -69,6 +69,7 @@ ieee80211_tdls_add_subband(struct ieee80
44 struct ieee80211_channel *ch;
45 struct cfg80211_chan_def chandef;
47 + struct wiphy *wiphy = sdata->local->hw.wiphy;
49 for (i = start; i <= end; i += spacing) {
51 @@ -79,9 +80,8 @@ ieee80211_tdls_add_subband(struct ieee80
52 /* we will be active on the channel */
53 cfg80211_chandef_create(&chandef, ch,
55 - if (cfg80211_reg_can_beacon(sdata->local->hw.wiphy,
57 - sdata->wdev.iftype)) {
58 + if (cfg80211_reg_can_beacon_relax(wiphy, &chandef,
59 + sdata->wdev.iftype)) {
62 * check if the next channel is also part of
63 --- a/net/wireless/chan.c
64 +++ b/net/wireless/chan.c
65 @@ -797,23 +797,18 @@ static bool cfg80211_ir_permissive_chan(
69 -bool cfg80211_reg_can_beacon(struct wiphy *wiphy,
70 - struct cfg80211_chan_def *chandef,
71 - enum nl80211_iftype iftype)
72 +static bool _cfg80211_reg_can_beacon(struct wiphy *wiphy,
73 + struct cfg80211_chan_def *chandef,
74 + enum nl80211_iftype iftype,
78 u32 prohibited_flags = IEEE80211_CHAN_DISABLED |
81 - trace_cfg80211_reg_can_beacon(wiphy, chandef, iftype);
82 + trace_cfg80211_reg_can_beacon(wiphy, chandef, iftype, check_no_ir);
85 - * Under certain conditions suggested by some regulatory bodies a
86 - * GO/STA can IR on channels marked with IEEE80211_NO_IR. Set this flag
87 - * only if such relaxations are not enabled and the conditions are not
90 - if (!cfg80211_ir_permissive_chan(wiphy, iftype, chandef->chan))
92 prohibited_flags |= IEEE80211_CHAN_NO_IR;
94 if (cfg80211_chandef_dfs_required(wiphy, chandef, iftype) > 0 &&
95 @@ -827,8 +822,36 @@ bool cfg80211_reg_can_beacon(struct wiph
96 trace_cfg80211_return_bool(res);
100 +bool cfg80211_reg_can_beacon(struct wiphy *wiphy,
101 + struct cfg80211_chan_def *chandef,
102 + enum nl80211_iftype iftype)
104 + return _cfg80211_reg_can_beacon(wiphy, chandef, iftype, true);
106 EXPORT_SYMBOL(cfg80211_reg_can_beacon);
108 +bool cfg80211_reg_can_beacon_relax(struct wiphy *wiphy,
109 + struct cfg80211_chan_def *chandef,
110 + enum nl80211_iftype iftype)
117 + * Under certain conditions suggested by some regulatory bodies a
118 + * GO/STA can IR on channels marked with IEEE80211_NO_IR. Set this flag
119 + * only if such relaxations are not enabled and the conditions are not
122 + check_no_ir = !cfg80211_ir_permissive_chan(wiphy, iftype,
125 + return _cfg80211_reg_can_beacon(wiphy, chandef, iftype, check_no_ir);
127 +EXPORT_SYMBOL(cfg80211_reg_can_beacon_relax);
129 int cfg80211_set_monitor_channel(struct cfg80211_registered_device *rdev,
130 struct cfg80211_chan_def *chandef)
132 --- a/net/wireless/nl80211.c
133 +++ b/net/wireless/nl80211.c
134 @@ -2007,7 +2007,8 @@ static int __nl80211_set_channel(struct
136 case NL80211_IFTYPE_AP:
137 case NL80211_IFTYPE_P2P_GO:
138 - if (!cfg80211_reg_can_beacon(&rdev->wiphy, &chandef, iftype)) {
139 + if (!cfg80211_reg_can_beacon_relax(&rdev->wiphy, &chandef,
144 @@ -3408,8 +3409,8 @@ static int nl80211_start_ap(struct sk_bu
145 } else if (!nl80211_get_ap_channel(rdev, ¶ms))
148 - if (!cfg80211_reg_can_beacon(&rdev->wiphy, ¶ms.chandef,
150 + if (!cfg80211_reg_can_beacon_relax(&rdev->wiphy, ¶ms.chandef,
154 if (info->attrs[NL80211_ATTR_ACL_POLICY]) {
155 @@ -6500,8 +6501,8 @@ skip_beacons:
159 - if (!cfg80211_reg_can_beacon(&rdev->wiphy, ¶ms.chandef,
161 + if (!cfg80211_reg_can_beacon_relax(&rdev->wiphy, ¶ms.chandef,
165 err = cfg80211_chandef_dfs_required(wdev->wiphy,
166 @@ -10188,7 +10189,8 @@ static int nl80211_tdls_channel_switch(s
169 /* we will be active on the TDLS link */
170 - if (!cfg80211_reg_can_beacon(&rdev->wiphy, &chandef, wdev->iftype))
171 + if (!cfg80211_reg_can_beacon_relax(&rdev->wiphy, &chandef,
175 /* don't allow switching to DFS channels */
176 --- a/net/wireless/reg.c
177 +++ b/net/wireless/reg.c
178 @@ -1589,7 +1589,7 @@ static bool reg_wdev_chan_valid(struct w
179 case NL80211_IFTYPE_AP:
180 case NL80211_IFTYPE_P2P_GO:
181 case NL80211_IFTYPE_ADHOC:
182 - return cfg80211_reg_can_beacon(wiphy, &chandef, iftype);
183 + return cfg80211_reg_can_beacon_relax(wiphy, &chandef, iftype);
184 case NL80211_IFTYPE_STATION:
185 case NL80211_IFTYPE_P2P_CLIENT:
186 return cfg80211_chandef_usable(wiphy, &chandef,
187 --- a/net/wireless/trace.h
188 +++ b/net/wireless/trace.h
189 @@ -2358,20 +2358,23 @@ TRACE_EVENT(cfg80211_cqm_rssi_notify,
191 TRACE_EVENT(cfg80211_reg_can_beacon,
192 TP_PROTO(struct wiphy *wiphy, struct cfg80211_chan_def *chandef,
193 - enum nl80211_iftype iftype),
194 - TP_ARGS(wiphy, chandef, iftype),
195 + enum nl80211_iftype iftype, bool check_no_ir),
196 + TP_ARGS(wiphy, chandef, iftype, check_no_ir),
200 __field(enum nl80211_iftype, iftype)
201 + __field(bool, check_no_ir)
205 CHAN_DEF_ASSIGN(chandef);
206 __entry->iftype = iftype;
207 + __entry->check_no_ir = check_no_ir;
209 - TP_printk(WIPHY_PR_FMT ", " CHAN_DEF_PR_FMT ", iftype=%d",
210 - WIPHY_PR_ARG, CHAN_DEF_PR_ARG, __entry->iftype)
211 + TP_printk(WIPHY_PR_FMT ", " CHAN_DEF_PR_FMT ", iftype=%d check_no_ir=%s",
212 + WIPHY_PR_ARG, CHAN_DEF_PR_ARG, __entry->iftype,
213 + BOOL_TO_STR(__entry->check_no_ir))
216 TRACE_EVENT(cfg80211_chandef_dfs_required,