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