1 /****************************************************************************** 2 * 3 * Copyright(c) 2020 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 _PHL_REGULATION_H_ 16 #define _PHL_REGULATION_H_ 17 18 #define MAX_CH_NUM_GROUP 24 19 20 enum rtw_regulation_freq_group { 21 FREQ_GROUP_2GHZ = 0x0, 22 FREQ_GROUP_5GHZ_BAND1, 23 FREQ_GROUP_5GHZ_BAND2, 24 FREQ_GROUP_5GHZ_BAND3, 25 FREQ_GROUP_5GHZ_BAND4, 26 FREQ_GROUP_6GHZ_UNII5, 27 FREQ_GROUP_6GHZ_UNII6, 28 FREQ_GROUP_6GHZ_UNII7, 29 FREQ_GROUP_6GHZ_UNII8, 30 FREQ_GROUP_6GHZ_PSC, 31 FREQ_GROUP_MAX 32 }; 33 34 enum rtw_regulation_status { 35 REGULATION_SUCCESS = 0x0, 36 REGULATION_FAILURE, 37 REGULATION_DOMAIN_MISMATCH, 38 REGULATION_INVALID_2GHZ_RD, 39 REGULATION_INVALID_5GHZ_RD, 40 REGULATION_INVALID_DOMAIN 41 }; 42 43 struct rtw_regulation_chplan_group { 44 u32 cnt; 45 struct rtw_regulation_channel ch[MAX_CH_NUM_GROUP]; 46 }; 47 48 #define MAX_HISTORY_NUM 20 49 50 #define INVALID_DOMAIN_CODE 0xffff 51 #define INVALID_CHDEF 0xff 52 53 struct rtw_domain { 54 u16 code; 55 u8 reason; 56 }; 57 58 struct rtw_regulation { 59 _os_lock lock; 60 u8 init; /* regulation sw initialization */ 61 u8 invalid_cnt; 62 u8 history_cnt; 63 struct rtw_domain history[MAX_HISTORY_NUM]; 64 65 /* working regulation */ 66 bool valid; /* true if domain code successfully set */ 67 u16 capability; /* rtw_regulation_capability */ 68 struct rtw_domain domain; 69 char country[2]; 70 u8 tpo; /* tx power overwrite */ 71 u8 support_mode; 72 73 u8 ch_idx2g; /* 2ghz chdef index */ 74 u8 regulation_2g; 75 u8 ch_idx5g; /* 5ghz chdef index */ 76 u8 regulation_5g; 77 78 struct rtw_regulation_chplan_group chplan[FREQ_GROUP_MAX]; 79 80 /* 6 ghz */ 81 u8 invalid_cnt_6g; 82 u8 history_cnt_6g; 83 struct rtw_domain history_6g[MAX_HISTORY_NUM]; 84 bool valid_6g; /* true if domain code successfully set */ 85 struct rtw_domain domain_6g; 86 u8 ch_idx6g; /* 6ghz chdef index */ 87 u8 regulation_6g; 88 }; 89 90 bool rtw_phl_regulation_query_ch(void *phl, enum band_type band, u8 channel, 91 struct rtw_regulation_channel *ch); 92 93 u8 rtw_phl_get_domain_regulation_2g(u8 domain); 94 u8 rtw_phl_get_domain_regulation_5g(u8 domain); 95 96 #endif /* _PHL_REGULATION_H_ */ 97