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_ECSA_EXPORT_H_ 16 #define _PHL_ECSA_EXPORT_H_ 17 18 #define CHANNEL_SWITCH_MODE_NORMAL 0 19 #define CHANNEL_SWITCH_MODE_STOP_TX 1 20 21 enum phl_ecsa_type{ 22 ECSA_TYPE_NONE = 0, 23 ECSA_TYPE_AP = 1, 24 ECSA_TYPE_STA = 2 25 }; 26 27 enum phl_ecsa_param_flag{ 28 ECSA_PARAM_FLAG_APPEND_BCN = BIT0, 29 ECSA_PARAM_FLAG_APPEND_PROBERSP = BIT1, 30 }; 31 32 enum phl_ecsa_start_reason{ 33 ECSA_START_MCC_24G_TO_24G = 0, 34 ECSA_START_MCC_5G_TO_5G = 1, 35 ECSA_START_MCC_24G_TO_5G = 2, 36 ECSA_START_MCC_5G_TO_24G = 3, 37 ECSA_START_CORE_TRIGGER = 4, 38 ECSA_START_UNKNOWN 39 }; 40 41 #ifdef CONFIG_PHL_ECSA_EXTEND_OPTION 42 enum phl_ecsa_extend_option{ 43 ECSA_EX_OPTION_FORCE_BW20 = BIT0, 44 }; 45 #endif 46 47 struct rtw_phl_ecsa_param{ 48 enum phl_ecsa_type ecsa_type; 49 u8 flag; 50 u8 mode; /* CHANNEL_SWITCH_MODE_NORMAL or CHANNEL_SWITCH_MODE_STOP_TX */ 51 u8 op_class; 52 u8 ch; 53 u8 count; 54 u32 delay_start_ms; 55 struct rtw_chan_def new_chan_def; 56 }; 57 58 /* 59 * priv: ops private, define by core layer 60 * update_beacon: Notify core to construct and update beacon 61 * update_chan_info: Notify core to update AP mode channel information 62 * check_ecsa_allow: Provide reason and ask core if ecsa is allowed or not, 63 * core can provide a delay time(ms) to delay start ECSA 64 * ecsa_complete: Notify core to reset csa related Information 65 * check_tx_resume_allow: Check core is allowed to resume tx paused by csa mode == 1 66 */ 67 struct rtw_phl_ecsa_ops{ 68 void *priv; 69 void (*update_beacon)(void *priv, struct rtw_wifi_role_t *role); 70 void (*update_chan_info)(void *priv, 71 struct rtw_wifi_role_t *role, 72 struct rtw_chan_def chan_def); 73 bool (*check_ecsa_allow)(void *priv, 74 struct rtw_wifi_role_t *role, 75 struct rtw_chan_def chan_def, 76 enum phl_ecsa_start_reason reason, 77 #ifdef CONFIG_PHL_ECSA_EXTEND_OPTION 78 u32 *extend_option, 79 #endif 80 u32 *delay_start_ms); 81 void (*ecsa_complete)(void *priv, struct rtw_wifi_role_t *role); 82 bool (*check_tx_resume_allow)(void *priv, struct rtw_wifi_role_t *role); 83 }; 84 85 #ifdef CONFIG_PHL_ECSA 86 enum rtw_phl_status 87 rtw_phl_ecsa_init_ops( 88 void *phl, 89 struct rtw_phl_ecsa_ops *ops 90 ); 91 92 enum rtw_phl_status 93 rtw_phl_ecsa_cmd_request( 94 void *phl, 95 struct rtw_wifi_role_t *role 96 ); 97 98 enum rtw_phl_status 99 rtw_phl_ecsa_start( 100 void *phl, 101 struct rtw_wifi_role_t *role, 102 struct rtw_phl_ecsa_param *param 103 ); 104 105 enum rtw_phl_status 106 rtw_phl_ecsa_cancel( 107 void *phl, 108 struct rtw_wifi_role_t *role 109 ); 110 111 enum rtw_phl_status 112 rtw_phl_ecsa_get_param( 113 void *phl, 114 struct rtw_phl_ecsa_param **param 115 ); 116 117 #ifdef CONFIG_PHL_ECSA_EXTEND_OPTION 118 void 119 rtw_phl_ecsa_extend_option_hdlr( 120 u32 extend_option, 121 struct rtw_phl_ecsa_param *param 122 ); 123 #endif 124 125 bool 126 rtw_phl_ecsa_check_allow( 127 void *phl, 128 struct rtw_wifi_role_t *role, 129 struct rtw_chan_def chan_def, 130 enum phl_ecsa_start_reason reason, 131 #ifdef CONFIG_PHL_ECSA_EXTEND_OPTION 132 u32 *extend_option, 133 #endif 134 u32 *delay_start_ms 135 ); 136 #else 137 #define rtw_phl_ecsa_init_ops(_phl, _ops) RTW_PHL_STATUS_SUCCESS 138 #define rtw_phl_ecsa_cmd_request(_phl, _role) RTW_PHL_STATUS_SUCCESS 139 #define rtw_phl_ecsa_start(_phl, _role, _param) RTW_PHL_STATUS_SUCCESS 140 #define rtw_phl_ecsa_cancel(_phl, _role) RTW_PHL_STATUS_SUCCESS 141 #define rtw_phl_ecsa_get_param(_phl, _param) RTW_PHL_STATUS_SUCCESS 142 #ifdef CONFIG_PHL_ECSA_EXTEND_OPTION 143 #define rtw_phl_ecsa_extend_option_hdlr(_extend_option, _param) 144 #define rtw_phl_ecsa_check_allow(_phl, _role, _chan_def, _reason, _extend_option, _delay_start_ms) false 145 #else 146 #define rtw_phl_ecsa_check_allow(_phl, _role, _chan_def, _reason, _delay_start_ms) false 147 #endif 148 #endif 149 150 #endif /*_PHL_ECSA_EXPORT_H_*/ 151