]>
Commit | Line | Data |
---|---|---|
d3236553 JB |
1 | #ifndef __NET_REGULATORY_H |
2 | #define __NET_REGULATORY_H | |
3 | /* | |
4 | * regulatory support structures | |
5 | * | |
6 | * Copyright 2008-2009 Luis R. Rodriguez <[email protected]> | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License version 2 as | |
10 | * published by the Free Software Foundation. | |
11 | */ | |
12 | ||
13 | ||
14 | /** | |
15 | * enum environment_cap - Environment parsed from country IE | |
16 | * @ENVIRON_ANY: indicates country IE applies to both indoor and | |
17 | * outdoor operation. | |
18 | * @ENVIRON_INDOOR: indicates country IE applies only to indoor operation | |
19 | * @ENVIRON_OUTDOOR: indicates country IE applies only to outdoor operation | |
20 | */ | |
21 | enum environment_cap { | |
22 | ENVIRON_ANY, | |
23 | ENVIRON_INDOOR, | |
24 | ENVIRON_OUTDOOR, | |
25 | }; | |
26 | ||
27 | /** | |
28 | * struct regulatory_request - used to keep track of regulatory requests | |
29 | * | |
30 | * @wiphy_idx: this is set if this request's initiator is | |
31 | * %REGDOM_SET_BY_COUNTRY_IE or %REGDOM_SET_BY_DRIVER. This | |
32 | * can be used by the wireless core to deal with conflicts | |
33 | * and potentially inform users of which devices specifically | |
34 | * cased the conflicts. | |
35 | * @initiator: indicates who sent this request, could be any of | |
36 | * of those set in nl80211_reg_initiator (%NL80211_REGDOM_SET_BY_*) | |
37 | * @alpha2: the ISO / IEC 3166 alpha2 country code of the requested | |
38 | * regulatory domain. We have a few special codes: | |
39 | * 00 - World regulatory domain | |
40 | * 99 - built by driver but a specific alpha2 cannot be determined | |
41 | * 98 - result of an intersection between two regulatory domains | |
42 | * @intersect: indicates whether the wireless core should intersect | |
43 | * the requested regulatory domain with the presently set regulatory | |
44 | * domain. | |
45 | * @country_ie_checksum: checksum of the last processed and accepted | |
46 | * country IE | |
47 | * @country_ie_env: lets us know if the AP is telling us we are outdoor, | |
48 | * indoor, or if it doesn't matter | |
49 | * @list: used to insert into the reg_requests_list linked list | |
50 | */ | |
51 | struct regulatory_request { | |
52 | int wiphy_idx; | |
53 | enum nl80211_reg_initiator initiator; | |
54 | char alpha2[2]; | |
55 | bool intersect; | |
56 | u32 country_ie_checksum; | |
57 | enum environment_cap country_ie_env; | |
58 | struct list_head list; | |
59 | }; | |
60 | ||
61 | struct ieee80211_freq_range { | |
62 | u32 start_freq_khz; | |
63 | u32 end_freq_khz; | |
64 | u32 max_bandwidth_khz; | |
65 | }; | |
66 | ||
67 | struct ieee80211_power_rule { | |
68 | u32 max_antenna_gain; | |
69 | u32 max_eirp; | |
70 | }; | |
71 | ||
72 | struct ieee80211_reg_rule { | |
73 | struct ieee80211_freq_range freq_range; | |
74 | struct ieee80211_power_rule power_rule; | |
75 | u32 flags; | |
76 | }; | |
77 | ||
78 | struct ieee80211_regdomain { | |
79 | u32 n_reg_rules; | |
80 | char alpha2[2]; | |
81 | struct ieee80211_reg_rule reg_rules[]; | |
82 | }; | |
83 | ||
84 | #define MHZ_TO_KHZ(freq) ((freq) * 1000) | |
85 | #define KHZ_TO_MHZ(freq) ((freq) / 1000) | |
86 | #define DBI_TO_MBI(gain) ((gain) * 100) | |
87 | #define MBI_TO_DBI(gain) ((gain) / 100) | |
88 | #define DBM_TO_MBM(gain) ((gain) * 100) | |
89 | #define MBM_TO_DBM(gain) ((gain) / 100) | |
90 | ||
91 | #define REG_RULE(start, end, bw, gain, eirp, reg_flags) \ | |
92 | { \ | |
93 | .freq_range.start_freq_khz = MHZ_TO_KHZ(start), \ | |
94 | .freq_range.end_freq_khz = MHZ_TO_KHZ(end), \ | |
95 | .freq_range.max_bandwidth_khz = MHZ_TO_KHZ(bw), \ | |
96 | .power_rule.max_antenna_gain = DBI_TO_MBI(gain),\ | |
97 | .power_rule.max_eirp = DBM_TO_MBM(eirp), \ | |
98 | .flags = reg_flags, \ | |
99 | } | |
100 | ||
101 | #endif |