1 /* 2 * Copyright (c) 2017-2018 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 #define REGULATORY_CHAN_DISABLED (1<<0) 29 #define REGULATORY_CHAN_NO_IR (1<<1) 30 #define REGULATORY_CHAN_RADAR (1<<3) 31 #define REGULATORY_CHAN_NO_OFDM (1<<6) 32 #define REGULATORY_CHAN_INDOOR_ONLY (1<<9) 33 34 #define REGULATORY_CHAN_NO_HT40 (1<<4) 35 #define REGULATORY_CHAN_NO_80MHZ (1<<7) 36 #define REGULATORY_CHAN_NO_160MHZ (1<<8) 37 #define REGULATORY_CHAN_NO_20MHZ (1<<11) 38 #define REGULATORY_CHAN_NO_10MHZ (1<<12) 39 40 #define REGULATORY_PHYMODE_NO11A (1<<0) 41 #define REGULATORY_PHYMODE_NO11B (1<<1) 42 #define REGULATORY_PHYMODE_NO11G (1<<2) 43 #define REGULATORY_CHAN_NO11N (1<<3) 44 #define REGULATORY_PHYMODE_NO11AC (1<<4) 45 #define REGULATORY_PHYMODE_NO11AX (1<<5) 46 47 #define MAX_REG_RULES 10 48 #define REG_ALPHA2_LEN 2 49 50 /** 51 * enum dfs_reg - DFS region 52 * @DFS_UNINIT_REGION: un-initialized region 53 * @DFS_FCC_REGION: FCC region 54 * @DFS_ETSI_REGION: ETSI region 55 * @DFS_MKK_REGION: MKK region 56 * @DFS_CN_REGION: China region 57 * @DFS_KR_REGION: Korea region 58 * @DFS_UNDEF_REGION: Undefined region 59 */ 60 enum dfs_reg { 61 DFS_UNINIT_REGION = 0, 62 DFS_FCC_REGION = 1, 63 DFS_ETSI_REGION = 2, 64 DFS_MKK_REGION = 3, 65 DFS_CN_REGION = 4, 66 DFS_KR_REGION = 5, 67 DFS_UNDEF_REGION = 0xFFFF, 68 }; 69 70 /** 71 * struct regulatory_rule 72 * @start_freq: start frequency 73 * @end_freq: end frequency 74 * @max_bw: maximum bandwidth 75 * @reg_power: regulatory power 76 * @flags: regulatory flags 77 */ 78 struct regulatory_rule { 79 uint16_t start_freq; 80 uint16_t end_freq; 81 uint16_t max_bw; 82 uint8_t reg_power; 83 uint16_t flags; 84 }; 85 86 /** 87 * struct regdomain 88 * @ctl_val: CTL value 89 * @dfs_region: dfs region 90 * @min_bw: minimum bandwidth 91 * @num_reg_rules: number of regulatory rules 92 * @reg_rules_id: regulatory rule index 93 */ 94 struct regdomain { 95 uint8_t ctl_val; 96 enum dfs_reg dfs_region; 97 uint16_t min_bw; 98 uint8_t ant_gain; 99 uint8_t num_reg_rules; 100 uint8_t reg_rule_id[MAX_REG_RULES]; 101 }; 102 103 /** 104 * struct country_code_to_reg_domain 105 * @country_code: country code 106 * @reg_dmn_pair_id: reg domainpair id 107 * @alpha2: iso-3166 alpha2 108 * @max_bw_2g: maximum 2g bandwidth 109 * @max_bw_5g: maximum 5g bandwidth 110 * @phymode_bitmap: phymodes not supported 111 */ 112 struct country_code_to_reg_domain { 113 uint16_t country_code; 114 uint16_t reg_dmn_pair_id; 115 uint8_t alpha2[REG_ALPHA2_LEN + 1]; 116 uint16_t max_bw_2g; 117 uint16_t max_bw_5g; 118 uint16_t phymode_bitmap; 119 }; 120 121 /** 122 * struct reg_domain_pair 123 * @reg_dmn_pair_id: reg domainpiar value 124 * @dmn_id_5g: 5g reg domain value 125 * @dmn_id_2g: 2g regdomain value 126 */ 127 struct reg_domain_pair { 128 uint16_t reg_dmn_pair_id; 129 uint8_t dmn_id_5g; 130 uint8_t dmn_id_2g; 131 }; 132 133 /** 134 * enum ctl_value - CTL value 135 * @CTL_FCC: CTL FCC 136 * @CTL_MKK: CTL MKK 137 * @CTL_ETSI: CTL ETSI 138 * @CTL_KOR: CTL KOR 139 * @CTL_CHN: CTL CHINA 140 * @CTL_USER_DEF: CTL USER_DEF 141 * @CTL_NONE: CTL NONE 142 */ 143 enum ctl_value { 144 CTL_FCC = 0x10, 145 CTL_ETSI = 0x30, 146 CTL_MKK = 0x40, 147 CTL_KOR = 0x50, 148 CTL_CHN = 0x60, 149 CTL_USER_DEF = 0x70, 150 CTL_NONE = 0xff 151 }; 152 153 QDF_STATUS reg_get_num_countries(int *num_countries); 154 155 QDF_STATUS reg_get_num_reg_dmn_pairs(int *num_reg_dmn); 156 157 QDF_STATUS reg_get_default_country(uint16_t *default_country); 158 159 /** 160 * reg_etsi13_regdmn () - Checks if the reg domain is ETSI13 or not 161 * @reg_dmn: reg domain 162 * 163 * Return: true or false 164 */ 165 bool reg_etsi13_regdmn(uint8_t reg_dmn); 166 #endif 167