1 /****************************************************************************** 2 * 3 * Copyright(c) 2007 - 2018 Realtek Corporation. 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms of version 2 of the GNU General Public License as 7 * published by the Free Software Foundation. 8 * 9 * This program is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 * more details. 13 * 14 *****************************************************************************/ 15 #ifndef __RTW_CHPLAN_H__ 16 #define __RTW_CHPLAN_H__ 17 18 #define RTW_CHPLAN_UNSPECIFIED 0xFF 19 20 u8 rtw_chplan_get_default_regd(u8 id); 21 bool rtw_chplan_is_empty(u8 id); 22 bool rtw_is_channel_plan_valid(u8 id); 23 bool rtw_regsty_is_excl_chs(struct registry_priv *regsty, u8 ch); 24 25 enum regd_src_t { 26 REGD_SRC_RTK_PRIV = 0, /* Regulatory settings from Realtek framework (Realtek defined or customized) */ 27 REGD_SRC_OS = 1, /* Regulatory settings from OS */ 28 REGD_SRC_NUM, 29 }; 30 31 #define regd_src_is_valid(src) ((src) < REGD_SRC_NUM) 32 33 extern const char *_regd_src_str[]; 34 #define regd_src_str(src) ((src) >= REGD_SRC_NUM ? _regd_src_str[REGD_SRC_NUM] : _regd_src_str[src]) 35 36 struct _RT_CHANNEL_INFO; 37 u8 init_channel_set(_adapter *adapter); 38 bool rtw_chset_is_dfs_range(struct _RT_CHANNEL_INFO *chset, u32 hi, u32 lo); 39 bool rtw_chset_is_dfs_ch(struct _RT_CHANNEL_INFO *chset, u8 ch); 40 bool rtw_chset_is_dfs_chbw(struct _RT_CHANNEL_INFO *chset, u8 ch, u8 bw, u8 offset); 41 u8 rtw_process_beacon_hint(_adapter *adapter, WLAN_BSSID_EX *bss); 42 43 #define IS_ALPHA2_NO_SPECIFIED(_alpha2) ((*((u16 *)(_alpha2))) == 0xFFFF) 44 #define IS_ALPHA2_WORLDWIDE(_alpha2) (strncmp(_alpha2, "00", 2) == 0) 45 46 #define RTW_MODULE_RTL8821AE_HMC_M2 BIT0 /* RTL8821AE(HMC + M.2) */ 47 #define RTW_MODULE_RTL8821AU BIT1 /* RTL8821AU */ 48 #define RTW_MODULE_RTL8812AENF_NGFF BIT2 /* RTL8812AENF(8812AE+8761)_NGFF */ 49 #define RTW_MODULE_RTL8812AEBT_HMC BIT3 /* RTL8812AEBT(8812AE+8761)_HMC */ 50 #define RTW_MODULE_RTL8188EE_HMC_M2 BIT4 /* RTL8188EE(HMC + M.2) */ 51 #define RTW_MODULE_RTL8723BE_HMC_M2 BIT5 /* RTL8723BE(HMC + M.2) */ 52 #define RTW_MODULE_RTL8723BS_NGFF1216 BIT6 /* RTL8723BS(NGFF1216) */ 53 #define RTW_MODULE_RTL8192EEBT_HMC_M2 BIT7 /* RTL8192EEBT(8192EE+8761AU)_(HMC + M.2) */ 54 #define RTW_MODULE_RTL8723DE_NGFF1630 BIT8 /* RTL8723DE(NGFF1630) */ 55 #define RTW_MODULE_RTL8822BE BIT9 /* RTL8822BE */ 56 #define RTW_MODULE_RTL8821CE BIT10 /* RTL8821CE */ 57 #define RTW_MODULE_RTL8822CE BIT11 /* RTL8822CE */ 58 59 enum rtw_regd { 60 RTW_REGD_NA = 0, 61 RTW_REGD_FCC = 1, 62 RTW_REGD_MKK = 2, 63 RTW_REGD_ETSI = 3, 64 RTW_REGD_IC = 4, 65 RTW_REGD_KCC = 5, 66 RTW_REGD_NCC = 6, 67 RTW_REGD_ACMA = 7, 68 RTW_REGD_CHILE = 8, 69 RTW_REGD_MEX = 9, 70 RTW_REGD_WW, 71 RTW_REGD_NUM, 72 }; 73 74 extern const char *const _regd_str[]; 75 #define regd_str(regd) (((regd) >= RTW_REGD_NUM) ? _regd_str[RTW_REGD_NA] : _regd_str[(regd)]) 76 77 enum rtw_edcca_mode { 78 RTW_EDCCA_NORMAL = 0, /* normal */ 79 RTW_EDCCA_ADAPT = 1, /* adaptivity */ 80 RTW_EDCCA_CS = 2, /* carrier sense */ 81 RTW_EDCCA_MODE_NUM, 82 RTW_EDCCA_MODE_AUTO = 0xFF, /* folllow channel plan */ 83 }; 84 85 extern const char *const _rtw_edcca_mode_str[]; 86 #define rtw_edcca_mode_str(mode) (((mode) >= RTW_EDCCA_MODE_NUM) ? _rtw_edcca_mode_str[RTW_EDCCA_NORMAL] : _rtw_edcca_mode_str[(mode)]) 87 88 enum rtw_dfs_regd { 89 RTW_DFS_REGD_NONE = 0, 90 RTW_DFS_REGD_FCC = 1, 91 RTW_DFS_REGD_MKK = 2, 92 RTW_DFS_REGD_ETSI = 3, 93 RTW_DFS_REGD_NUM, 94 RTW_DFS_REGD_AUTO = 0xFF, /* follow channel plan */ 95 }; 96 97 extern const char *_rtw_dfs_regd_str[]; 98 #define rtw_dfs_regd_str(region) (((region) >= RTW_DFS_REGD_NUM) ? _rtw_dfs_regd_str[RTW_DFS_REGD_NONE] : _rtw_dfs_regd_str[(region)]) 99 100 typedef enum _REGULATION_TXPWR_LMT { 101 TXPWR_LMT_NONE = 0, /* no limit */ 102 TXPWR_LMT_FCC = 1, 103 TXPWR_LMT_MKK = 2, 104 TXPWR_LMT_ETSI = 3, 105 TXPWR_LMT_IC = 4, 106 TXPWR_LMT_KCC = 5, 107 TXPWR_LMT_NCC = 6, 108 TXPWR_LMT_ACMA = 7, 109 TXPWR_LMT_CHILE = 8, 110 TXPWR_LMT_UKRAINE = 9, 111 TXPWR_LMT_MEXICO = 10, 112 TXPWR_LMT_CN = 11, 113 TXPWR_LMT_QATAR = 12, 114 TXPWR_LMT_WW, /* smallest of all available limit, keep last */ 115 116 TXPWR_LMT_NUM, 117 TXPWR_LMT_DEF = TXPWR_LMT_NUM, /* default (ref to domain code), used at country chplan map's override field */ 118 } REGULATION_TXPWR_LMT; 119 120 extern const char *const _txpwr_lmt_str[]; 121 #define txpwr_lmt_str(regd) (((regd) > TXPWR_LMT_WW) ? _txpwr_lmt_str[TXPWR_LMT_WW] : _txpwr_lmt_str[(regd)]) 122 123 extern const REGULATION_TXPWR_LMT _txpwr_lmt_alternate[]; 124 #define txpwr_lmt_alternate(ori) (((ori) > TXPWR_LMT_WW) ? _txpwr_lmt_alternate[TXPWR_LMT_WW] : _txpwr_lmt_alternate[(ori)]) 125 126 #define TXPWR_LMT_ALTERNATE_DEFINED(txpwr_lmt) (txpwr_lmt_alternate(txpwr_lmt) != txpwr_lmt) 127 128 extern const enum rtw_edcca_mode _rtw_regd_to_edcca_mode[RTW_REGD_NUM]; 129 #define rtw_regd_to_edcca_mode(regd) (((regd) >= RTW_REGD_NUM) ? RTW_EDCCA_NORMAL : _rtw_regd_to_edcca_mode[(regd)]) 130 131 extern const REGULATION_TXPWR_LMT _rtw_regd_to_txpwr_lmt[]; 132 #define rtw_regd_to_txpwr_lmt(regd) (((regd) >= RTW_REGD_NUM) ? TXPWR_LMT_WW : _rtw_regd_to_txpwr_lmt[(regd)]) 133 134 #define EDCCA_MODES_STR_LEN (((6 + 3 + 1) * BAND_MAX) + 1) 135 char *rtw_get_edcca_modes_str(char *buf, u8 modes[]); 136 void rtw_edcca_mode_update(struct dvobj_priv *dvobj); 137 u8 rtw_get_edcca_mode(struct dvobj_priv *dvobj, BAND_TYPE band); 138 139 #define CCHPLAN_PROTO_EN_AC BIT0 140 #define CCHPLAN_PROTO_EN_AX BIT1 141 #define CCHPLAN_PROTO_EN_ALL 0xFF 142 143 struct country_chplan { 144 char alpha2[2]; /* "00" means worldwide */ 145 u8 chplan; 146 u8 txpwr_lmt_override; 147 #if defined(CONFIG_80211AX_HE) || defined(CONFIG_80211AC_VHT) 148 u8 proto_en; 149 #endif 150 }; 151 152 #ifdef CONFIG_80211AC_VHT 153 #define COUNTRY_CHPLAN_EN_11AC(_ent) ((_ent)->proto_en & CCHPLAN_PROTO_EN_AC) 154 #else 155 #define COUNTRY_CHPLAN_EN_11AC(_ent) 0 156 #endif 157 158 #ifdef CONFIG_80211AX_HE 159 #define COUNTRY_CHPLAN_EN_11AX(_ent) ((_ent)->proto_en & CCHPLAN_PROTO_EN_AX) 160 #else 161 #define COUNTRY_CHPLAN_EN_11AX(_ent) 0 162 #endif 163 164 const struct country_chplan *rtw_get_chplan_from_country(const char *country_code); 165 166 void dump_country_chplan(void *sel, const struct country_chplan *ent, bool regd_info); 167 void dump_country_chplan_map(void *sel, bool regd_info); 168 void dump_country_list(void *sel); 169 void dump_chplan_id_list(void *sel); 170 void dump_chplan_country_list(void *sel); 171 #ifdef CONFIG_RTW_DEBUG 172 void dump_chplan_test(void *sel); 173 #endif 174 void dump_chplan_ver(void *sel); 175 176 #endif /* __RTW_CHPLAN_H__ */ 177