Blame view

include/net/regulatory.h 10.6 KB
d32365537   Johannes Berg   cfg80211: clean u...
1
2
3
4
5
  #ifndef __NET_REGULATORY_H
  #define __NET_REGULATORY_H
  /*
   * regulatory support structures
   *
dde88b736   Luis R. Rodriguez   wireless: relicen...
6
   * Copyright 2008-2009	Luis R. Rodriguez <mcgrof@qca.qualcomm.com>
230ebaa18   Haim Dreyfuss   cfg80211: read wm...
7
   * Copyright (C) 2018 Intel Corporation
d32365537   Johannes Berg   cfg80211: clean u...
8
   *
dde88b736   Luis R. Rodriguez   wireless: relicen...
9
10
11
12
13
14
15
16
17
18
19
   * Permission to use, copy, modify, and/or distribute this software for any
   * purpose with or without fee is hereby granted, provided that the above
   * copyright notice and this permission notice appear in all copies.
   *
   * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
   * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
   * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
   * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
   * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
   * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
d32365537   Johannes Berg   cfg80211: clean u...
20
   */
458f4f9e9   Johannes Berg   regulatory: use R...
21
  #include <linux/rcupdate.h>
d32365537   Johannes Berg   cfg80211: clean u...
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  
  /**
   * enum environment_cap - Environment parsed from country IE
   * @ENVIRON_ANY: indicates country IE applies to both indoor and
   *	outdoor operation.
   * @ENVIRON_INDOOR: indicates country IE applies only to indoor operation
   * @ENVIRON_OUTDOOR: indicates country IE applies only to outdoor operation
   */
  enum environment_cap {
  	ENVIRON_ANY,
  	ENVIRON_INDOOR,
  	ENVIRON_OUTDOOR,
  };
  
  /**
   * struct regulatory_request - used to keep track of regulatory requests
   *
c492db370   Johannes Berg   regulatory: use R...
39
   * @rcu_head: RCU head struct used to free the request
d32365537   Johannes Berg   cfg80211: clean u...
40
   * @wiphy_idx: this is set if this request's initiator is
a2f73b6c5   Luis R. Rodriguez   cfg80211: move re...
41
42
43
44
   *	%REGDOM_SET_BY_COUNTRY_IE or %REGDOM_SET_BY_DRIVER. This
   *	can be used by the wireless core to deal with conflicts
   *	and potentially inform users of which devices specifically
   *	cased the conflicts.
d32365537   Johannes Berg   cfg80211: clean u...
45
   * @initiator: indicates who sent this request, could be any of
dec4ca931   Randy Dunlap   net/wireless: reg...
46
   *	those set in nl80211_reg_initiator (%NL80211_REGDOM_SET_BY_*)
d32365537   Johannes Berg   cfg80211: clean u...
47
   * @alpha2: the ISO / IEC 3166 alpha2 country code of the requested
a2f73b6c5   Luis R. Rodriguez   cfg80211: move re...
48
49
50
51
   *	regulatory domain. We have a few special codes:
   *	00 - World regulatory domain
   *	99 - built by driver but a specific alpha2 cannot be determined
   *	98 - result of an intersection between two regulatory domains
09d989d17   Luis R. Rodriguez   cfg80211: add reg...
52
   *	97 - regulatory domain has not yet been configured
b68e6b3b3   Luis R. Rodriguez   cfg80211: pass DF...
53
54
55
56
   * @dfs_region: If CRDA responded with a regulatory domain that requires
   *	DFS master operation on a known DFS region (NL80211_DFS_*),
   *	dfs_region represents that region. Drivers can use this and the
   *	@alpha2 to adjust their device's DFS parameters as required.
57b5ce072   Luis R. Rodriguez   cfg80211: add cel...
57
58
59
60
   * @user_reg_hint_type: if the @initiator was of type
   *	%NL80211_REGDOM_SET_BY_USER, this classifies the type
   *	of hint passed. This could be any of the %NL80211_USER_REG_HINT_*
   *	types.
d32365537   Johannes Berg   cfg80211: clean u...
61
   * @intersect: indicates whether the wireless core should intersect
a2f73b6c5   Luis R. Rodriguez   cfg80211: move re...
62
63
   *	the requested regulatory domain with the presently set regulatory
   *	domain.
b2e253cf3   Luis R. Rodriguez   cfg80211: Fix reg...
64
65
66
67
68
69
   * @processed: indicates whether or not this requests has already been
   *	processed. When the last request is processed it means that the
   *	currently regulatory domain set on cfg80211 is updated from
   *	CRDA and can be used by other regulatory requests. When a
   *	the last request is not yet processed we must yield until it
   *	is processed before processing any new requests.
d32365537   Johannes Berg   cfg80211: clean u...
70
   * @country_ie_checksum: checksum of the last processed and accepted
a2f73b6c5   Luis R. Rodriguez   cfg80211: move re...
71
   *	country IE
d32365537   Johannes Berg   cfg80211: clean u...
72
   * @country_ie_env: lets us know if the AP is telling us we are outdoor,
a2f73b6c5   Luis R. Rodriguez   cfg80211: move re...
73
   *	indoor, or if it doesn't matter
d32365537   Johannes Berg   cfg80211: clean u...
74
75
76
   * @list: used to insert into the reg_requests_list linked list
   */
  struct regulatory_request {
c492db370   Johannes Berg   regulatory: use R...
77
  	struct rcu_head rcu_head;
d32365537   Johannes Berg   cfg80211: clean u...
78
79
  	int wiphy_idx;
  	enum nl80211_reg_initiator initiator;
57b5ce072   Luis R. Rodriguez   cfg80211: add cel...
80
  	enum nl80211_user_reg_hint_type user_reg_hint_type;
657308f73   Johannes Berg   regulatory: add N...
81
  	char alpha2[3];
4c7d3982a   Luis R. Rodriguez   cfg80211: use enu...
82
  	enum nl80211_dfs_regions dfs_region;
d32365537   Johannes Berg   cfg80211: clean u...
83
  	bool intersect;
b2e253cf3   Luis R. Rodriguez   cfg80211: Fix reg...
84
  	bool processed;
d32365537   Johannes Berg   cfg80211: clean u...
85
86
87
  	enum environment_cap country_ie_env;
  	struct list_head list;
  };
a2f73b6c5   Luis R. Rodriguez   cfg80211: move re...
88
89
90
91
92
93
94
95
96
97
  /**
   * enum ieee80211_regulatory_flags - device regulatory flags
   *
   * @REGULATORY_CUSTOM_REG: tells us the driver for this device
   *	has its own custom regulatory domain and cannot identify the
   *	ISO / IEC 3166 alpha2 it belongs to. When this is enabled
   *	we will disregard the first regulatory hint (when the
   *	initiator is %REGDOM_SET_BY_CORE). Drivers that use
   *	wiphy_apply_custom_regulatory() should have this flag set
   *	or the regulatory core will set it for the wiphy.
4f7b91404   Luis R. Rodriguez   cfg80211: make re...
98
99
100
101
   *	If you use regulatory_hint() *after* using
   *	wiphy_apply_custom_regulatory() the wireless core will
   *	clear the REGULATORY_CUSTOM_REG for your wiphy as it would be
   *	implied that the device somehow gained knowledge of its region.
a09a85a01   Luis R. Rodriguez   cfg80211: add fla...
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
   * @REGULATORY_STRICT_REG: tells us that the wiphy for this device
   *	has regulatory domain that it wishes to be considered as the
   *	superset for regulatory rules. After this device gets its regulatory
   *	domain programmed further regulatory hints shall only be considered
   *	for this device to enhance regulatory compliance, forcing the
   *	device to only possibly use subsets of the original regulatory
   *	rules. For example if channel 13 and 14 are disabled by this
   *	device's regulatory domain no user specified regulatory hint which
   *	has these channels enabled would enable them for this wiphy,
   *	the device's original regulatory domain will be trusted as the
   *	base. You can program the superset of regulatory rules for this
   *	wiphy with regulatory_hint() for cards programmed with an
   *	ISO3166-alpha2 country code. wiphys that use regulatory_hint()
   *	will have their wiphy->regd programmed once the regulatory
   *	domain is set, and all other regulatory hints will be ignored
   *	until their own regulatory domain gets programmed.
a2f73b6c5   Luis R. Rodriguez   cfg80211: move re...
118
119
120
121
   * @REGULATORY_DISABLE_BEACON_HINTS: enable this if your driver needs to
   *	ensure that passive scan flags and beaconing flags may not be lifted by
   *	cfg80211 due to regulatory beacon hints. For more information on beacon
   *	hints read the documenation for regulatory_hint_found_beacon()
a09a85a01   Luis R. Rodriguez   cfg80211: add fla...
122
123
124
125
126
127
128
   * @REGULATORY_COUNTRY_IE_FOLLOW_POWER:  for devices that have a preference
   *	that even though they may have programmed their own custom power
   *	setting prior to wiphy registration, they want to ensure their channel
   *	power settings are updated for this connection with the power settings
   *	derived from the regulatory domain. The regulatory domain used will be
   *	based on the ISO3166-alpha2 from country IE provided through
   *	regulatory_hint_country_ie()
2a901468c   Luis R. Rodriguez   cfg80211: add an ...
129
130
131
132
   * @REGULATORY_COUNTRY_IE_IGNORE: for devices that have a preference to ignore
   * 	all country IE information processed by the regulatory core. This will
   * 	override %REGULATORY_COUNTRY_IE_FOLLOW_POWER as all country IEs will
   * 	be ignored.
174e0cd28   Ilan Peer   cfg80211: Enable ...
133
134
135
136
137
   * @REGULATORY_ENABLE_RELAX_NO_IR: for devices that wish to allow the
   *      NO_IR relaxation, which enables transmissions on channels on which
   *      otherwise initiating radiation is not allowed. This will enable the
   *      relaxations enabled under the CFG80211_REG_RELAX_NO_IR configuration
   *      option
ad932f046   Arik Nemtsov   cfg80211: leave i...
138
139
140
141
142
143
144
145
146
147
148
   * @REGULATORY_IGNORE_STALE_KICKOFF: the regulatory core will _not_ make sure
   *	all interfaces on this wiphy reside on allowed channels. If this flag
   *	is not set, upon a regdomain change, the interfaces are given a grace
   *	period (currently 60 seconds) to disconnect or move to an allowed
   *	channel. Interfaces on forbidden channels are forcibly disconnected.
   *	Currently these types of interfaces are supported for enforcement:
   *	NL80211_IFTYPE_ADHOC, NL80211_IFTYPE_STATION, NL80211_IFTYPE_AP,
   *	NL80211_IFTYPE_AP_VLAN, NL80211_IFTYPE_MONITOR,
   *	NL80211_IFTYPE_P2P_CLIENT, NL80211_IFTYPE_P2P_GO,
   *	NL80211_IFTYPE_P2P_DEVICE. The flag will be set by default if a device
   *	includes any modes unsupported for enforcement checking.
b0d7aa595   Jonathan Doron   cfg80211: allow w...
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
   * @REGULATORY_WIPHY_SELF_MANAGED: for devices that employ wiphy-specific
   *	regdom management. These devices will ignore all regdom changes not
   *	originating from their own wiphy.
   *	A self-managed wiphys only employs regulatory information obtained from
   *	the FW and driver and does not use other cfg80211 sources like
   *	beacon-hints, country-code IEs and hints from other devices on the same
   *	system. Conversely, a self-managed wiphy does not share its regulatory
   *	hints with other devices in the system. If a system contains several
   *	devices, one or more of which are self-managed, there might be
   *	contradictory regulatory settings between them. Usage of flag is
   *	generally discouraged. Only use it if the FW/driver is incompatible
   *	with non-locally originated hints.
   *	This flag is incompatible with the flags: %REGULATORY_CUSTOM_REG,
   *	%REGULATORY_STRICT_REG, %REGULATORY_COUNTRY_IE_FOLLOW_POWER,
   *	%REGULATORY_COUNTRY_IE_IGNORE and %REGULATORY_DISABLE_BEACON_HINTS.
   *	Mixing any of the above flags with this flag will result in a failure
   *	to register the wiphy. This flag implies
   *	%REGULATORY_DISABLE_BEACON_HINTS and %REGULATORY_COUNTRY_IE_IGNORE.
a2f73b6c5   Luis R. Rodriguez   cfg80211: move re...
167
168
169
170
171
   */
  enum ieee80211_regulatory_flags {
  	REGULATORY_CUSTOM_REG			= BIT(0),
  	REGULATORY_STRICT_REG			= BIT(1),
  	REGULATORY_DISABLE_BEACON_HINTS		= BIT(2),
a09a85a01   Luis R. Rodriguez   cfg80211: add fla...
172
  	REGULATORY_COUNTRY_IE_FOLLOW_POWER	= BIT(3),
2a901468c   Luis R. Rodriguez   cfg80211: add an ...
173
  	REGULATORY_COUNTRY_IE_IGNORE		= BIT(4),
174e0cd28   Ilan Peer   cfg80211: Enable ...
174
  	REGULATORY_ENABLE_RELAX_NO_IR           = BIT(5),
ad932f046   Arik Nemtsov   cfg80211: leave i...
175
  	REGULATORY_IGNORE_STALE_KICKOFF         = BIT(6),
b0d7aa595   Jonathan Doron   cfg80211: allow w...
176
  	REGULATORY_WIPHY_SELF_MANAGED		= BIT(7),
a2f73b6c5   Luis R. Rodriguez   cfg80211: move re...
177
  };
d32365537   Johannes Berg   cfg80211: clean u...
178
179
180
181
182
183
184
185
186
187
  struct ieee80211_freq_range {
  	u32 start_freq_khz;
  	u32 end_freq_khz;
  	u32 max_bandwidth_khz;
  };
  
  struct ieee80211_power_rule {
  	u32 max_antenna_gain;
  	u32 max_eirp;
  };
230ebaa18   Haim Dreyfuss   cfg80211: read wm...
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
  /**
   * struct ieee80211_wmm_ac - used to store per ac wmm regulatory limitation
   *
   * The information provided in this structure is required for QoS
   * transmit queue configuration. Cf. IEEE 802.11 7.3.2.29.
   *
   * @cw_min: minimum contention window [a value of the form
   *      2^n-1 in the range 1..32767]
   * @cw_max: maximum contention window [like @cw_min]
   * @cot: maximum burst time in units of 32 usecs, 0 meaning disabled
   * @aifsn: arbitration interframe space [0..255]
   *
   */
  struct ieee80211_wmm_ac {
  	u16 cw_min;
  	u16 cw_max;
  	u16 cot;
  	u8 aifsn;
  };
  
  struct ieee80211_wmm_rule {
  	struct ieee80211_wmm_ac client[IEEE80211_NUM_ACS];
  	struct ieee80211_wmm_ac ap[IEEE80211_NUM_ACS];
  };
d32365537   Johannes Berg   cfg80211: clean u...
212
213
214
  struct ieee80211_reg_rule {
  	struct ieee80211_freq_range freq_range;
  	struct ieee80211_power_rule power_rule;
38cb87ee4   Stanislaw Gruszka   cfg80211: make wm...
215
  	struct ieee80211_wmm_rule wmm_rule;
d32365537   Johannes Berg   cfg80211: clean u...
216
  	u32 flags;
089027e57   Janusz Dziedzic   cfg80211: regulat...
217
  	u32 dfs_cac_ms;
38cb87ee4   Stanislaw Gruszka   cfg80211: make wm...
218
  	bool has_wmm;
d32365537   Johannes Berg   cfg80211: clean u...
219
220
221
  };
  
  struct ieee80211_regdomain {
458f4f9e9   Johannes Berg   regulatory: use R...
222
  	struct rcu_head rcu_head;
d32365537   Johannes Berg   cfg80211: clean u...
223
  	u32 n_reg_rules;
a5fe8e769   Eliad Peller   regulatory: add N...
224
  	char alpha2[3];
4c7d3982a   Luis R. Rodriguez   cfg80211: use enu...
225
  	enum nl80211_dfs_regions dfs_region;
d32365537   Johannes Berg   cfg80211: clean u...
226
227
  	struct ieee80211_reg_rule reg_rules[];
  };
089027e57   Janusz Dziedzic   cfg80211: regulat...
228
229
230
231
232
233
234
235
236
  #define REG_RULE_EXT(start, end, bw, gain, eirp, dfs_cac, reg_flags)	\
  {									\
  	.freq_range.start_freq_khz = MHZ_TO_KHZ(start),			\
  	.freq_range.end_freq_khz = MHZ_TO_KHZ(end),			\
  	.freq_range.max_bandwidth_khz = MHZ_TO_KHZ(bw),			\
  	.power_rule.max_antenna_gain = DBI_TO_MBI(gain),		\
  	.power_rule.max_eirp = DBM_TO_MBM(eirp),			\
  	.flags = reg_flags,						\
  	.dfs_cac_ms = dfs_cac,						\
d32365537   Johannes Berg   cfg80211: clean u...
237
  }
089027e57   Janusz Dziedzic   cfg80211: regulat...
238
239
  #define REG_RULE(start, end, bw, gain, eirp, reg_flags) \
  	REG_RULE_EXT(start, end, bw, gain, eirp, 0, reg_flags)
d32365537   Johannes Berg   cfg80211: clean u...
240
  #endif