1 /* 2 * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved. 3 * 4 * 5 * Permission to use, copy, modify, and/or distribute this software for 6 * any purpose with or without fee is hereby granted, provided that the 7 * above copyright notice and this permission notice appear in all 8 * copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 /** 21 * DOC: reg_db.h 22 * This file contains regulatory component data structures 23 */ 24 25 #ifndef __REG_DB_H 26 #define __REG_DB_H 27 28 /* 29 * If COMPILE_REGDB_6G and CONFIG_BAND_6GHZ are defined, then 30 * reg_6ghz_super_dmn_id and max_bw_6g are part of the 31 * country_code_to_reg_domain table for a country 32 * entry. If COMPILE_REGDB_6G and CONFIG_BAND_6GHZ are not defined, then they 33 * are absent. 34 * 35 * COMPILE_REGDB_6G is not defined for the Partial offload platform. 36 * 37 * CE:- country entry 38 */ 39 #if defined(CONFIG_BAND_6GHZ) && defined(COMPILE_REGDB_6G) 40 #define CE(country_code, reg_dmn_pair_id, reg_6ghz_super_dmn_id, \ 41 alpha2, max_bw_2g, max_bw_5g, max_bw_6g, phymode_bitmap) \ 42 {CTRY_ ## country_code, reg_dmn_pair_id, reg_6ghz_super_dmn_id, \ 43 #alpha2, max_bw_2g, max_bw_5g, max_bw_6g, phymode_bitmap} 44 #else 45 #define CE(country_code, reg_dmn_pair_id, reg_6ghz_super_dmn_id, alpha2, \ 46 max_bw_2g, max_bw_5g, max_bw_6g, phymode_bitmap) \ 47 {CTRY_ ## country_code, reg_dmn_pair_id, #alpha2, max_bw_2g, \ 48 max_bw_5g, phymode_bitmap} 49 #endif 50 51 /* Alpha2 code for world reg domain */ 52 #define REG_WORLD_ALPHA2 "00" 53 54 /** 55 * struct regulatory_rule 56 * @start_freq: start frequency 57 * @end_freq: end frequency 58 * @max_bw: maximum bandwidth 59 * @reg_power: regulatory power 60 * @flags: regulatory flags 61 */ 62 struct regulatory_rule { 63 uint16_t start_freq; 64 uint16_t end_freq; 65 uint16_t max_bw; 66 uint8_t reg_power; 67 uint16_t flags; 68 }; 69 70 #if defined(CONFIG_BAND_6GHZ) && defined(COMPILE_REGDB_6G) 71 /** 72 * struct regulatory_rule_ext 73 * @start_freq: start frequency in MHz 74 * @end_freq: end frequency in MHz 75 * @max_bw: maximum bandwidth in MHz 76 * @eirp_power: EIRP power in dBm 77 * @psd_power: Max PSD power in dBm per MHz 78 * @flags: regulatory flags 79 */ 80 struct regulatory_rule_ext { 81 uint16_t start_freq; 82 uint16_t end_freq; 83 uint16_t max_bw; 84 uint8_t eirp_power; 85 int8_t psd_power; 86 uint16_t flags; 87 }; 88 #endif 89 90 /** 91 * struct regdomain 92 * @ctl_val: CTL value 93 * @dfs_region: dfs region 94 * @min_bw: minimum bandwidth 95 * @max_bw: maximum bandwidth 96 * @num_reg_rules: number of regulatory rules 97 * @reg_rules_id: regulatory rule index 98 */ 99 struct regdomain { 100 uint8_t ctl_val; 101 enum dfs_reg dfs_region; 102 uint16_t min_bw; 103 uint16_t max_bw; 104 uint8_t ant_gain; 105 uint8_t num_reg_rules; 106 uint8_t reg_rule_id[MAX_REG_RULES]; 107 }; 108 109 #if defined(CONFIG_BAND_6GHZ) && defined(COMPILE_REGDB_6G) 110 #define REG_MAX_PSD (0x7F) /* 127=63.5 dBm/MHz */ 111 112 /** 113 * struct sub_6g_regdomain 114 * @min_bw: Minimum bandwidth in MHz 115 * @max_bw: Maximum bandwidth in MHz 116 * @num_reg_rules: number of regulatory rules 117 * @reg_rules_id: regulatory rule index 118 */ 119 struct sub_6g_regdomain { 120 uint16_t min_bw; 121 uint16_t max_bw; 122 uint8_t num_reg_rules; 123 uint8_t sixg_reg_rule_id[MAX_REG_RULES]; 124 }; 125 #endif 126 127 /** 128 * struct country_code_to_reg_domain 129 * @country_code: country code 130 * @reg_dmn_pair_id: reg domainpair id 131 * @reg_6ghz_super_dmn_id: 6GHz super domain id 132 * @alpha2: iso-3166 alpha2 133 * @max_bw_2g: maximum 2g bandwidth in MHz 134 * @max_bw_5g: maximum 5g bandwidth in MHz 135 * @max_bw_6g: maximum 6g bandwidth in MHz 136 * @phymode_bitmap: phymodes not supported 137 */ 138 struct country_code_to_reg_domain { 139 uint16_t country_code; 140 uint16_t reg_dmn_pair_id; 141 #if defined(CONFIG_BAND_6GHZ) && defined(COMPILE_REGDB_6G) 142 uint16_t reg_6ghz_super_dmn_id; 143 #endif 144 uint8_t alpha2[REG_ALPHA2_LEN + 1]; 145 uint16_t max_bw_2g; 146 uint16_t max_bw_5g; 147 #if defined(CONFIG_BAND_6GHZ) && defined(COMPILE_REGDB_6G) 148 uint16_t max_bw_6g; 149 #endif 150 uint16_t phymode_bitmap; 151 }; 152 153 /** 154 * struct reg_domain_pair 155 * @reg_dmn_pair_id: reg domainpiar value 156 * @dmn_id_5g: 5g reg domain value 157 * @dmn_id_2g: 2g regdomain value 158 */ 159 struct reg_domain_pair { 160 uint16_t reg_dmn_pair_id; 161 uint8_t dmn_id_5g; 162 uint8_t dmn_id_2g; 163 }; 164 165 #if defined(CONFIG_BAND_6GHZ) 166 /** 167 * enum reg_super_domain_6g - 6G Super Domain enumeration 168 * @FCC1_6G_01: Super domain FCC1_6G_01 for US 169 * @ETSI1_6G_02: Super domain ETSI1_6G_02 for EU 170 * @ETSI2_6G_03: Super domain ETSI2_6G_03 for UK 171 * @APL1_6G_04: Super domain APL1_6G_04 for Korea 172 * @FCC1_6G_05: Super domain FCC1_6G_05 for Chile 173 * @APL2_6G_06: Super domain APL2_6G_06 for Guatemala 174 */ 175 enum reg_super_domain_6g { 176 FCC1_6G_01 = 0x01, 177 ETSI1_6G_02 = 0x02, 178 ETSI2_6G_03 = 0x03, 179 APL1_6G_04 = 0x04, 180 FCC1_6G_05 = 0x05, 181 APL2_6G_06 = 0x06, 182 }; 183 184 #if defined(COMPILE_REGDB_6G) 185 /** 186 * struct sixghz_super_to_subdomains 187 * @reg_6ghz_super_dmn_id: 6G super domain id. 188 * @reg_domain_6g_id_ap_lpi: 6G domain id for LPI AP. 189 * @reg_domain_6g_id_ap_sp: 6G domain id for SP AP. 190 * @reg_domain_6g_id_ap_vlp: 6G domain id for VLP AP. 191 * @reg_domain_6g_id_client_lpi: 6G domain id for clients of the LPI AP. 192 * @reg_domain_6g_id_client_sp: 6G domain id for clients of the SP AP. 193 * @reg_domain_6g_id_client_vlp: 6G domain id for clients of the VLP AP. 194 */ 195 struct sixghz_super_to_subdomains { 196 uint16_t reg_6ghz_super_dmn_id; 197 uint8_t reg_domain_6g_id_ap_lpi; 198 uint8_t reg_domain_6g_id_ap_sp; 199 uint8_t reg_domain_6g_id_ap_vlp; 200 uint8_t reg_domain_6g_id_client_lpi[REG_MAX_CLIENT_TYPE]; 201 uint8_t reg_domain_6g_id_client_sp[REG_MAX_CLIENT_TYPE]; 202 uint8_t reg_domain_6g_id_client_vlp[REG_MAX_CLIENT_TYPE]; 203 }; 204 #endif 205 #endif 206 207 QDF_STATUS reg_get_num_countries(int *num_countries); 208 209 QDF_STATUS reg_get_num_reg_dmn_pairs(int *num_reg_dmn); 210 211 QDF_STATUS reg_get_default_country(uint16_t *default_country); 212 213 /** 214 * reg_etsi13_regdmn () - Checks if the reg domain is ETSI13 or not 215 * @reg_dmn: reg domain 216 * 217 * Return: true or false 218 */ 219 bool reg_etsi13_regdmn(uint8_t reg_dmn); 220 221 /** 222 * reg_fcc_regdmn () - Checks if the reg domain is FCC3/FCC8/FCC15/FCC16 or not 223 * @reg_dmn: reg domain 224 * 225 * Return: true or false 226 */ 227 bool reg_fcc_regdmn(uint8_t reg_dmn); 228 229 /** 230 * reg_en302_502_regdmn() - Check if the reg domain is en302_502 applicable. 231 * @reg_dmn: Regulatory domain pair ID. 232 * 233 * Return: True if EN302_502 applicable, else false. 234 */ 235 bool reg_en302_502_regdmn(uint16_t reg_dmn); 236 #endif 237