1 /* 2 * Copyright (c) 2020, The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17 /** 18 * DOC: This file has main dcs structures definition. 19 */ 20 21 #ifndef _WLAN_DCS_H_ 22 #define _WLAN_DCS_H_ 23 24 #include <wmi_unified_param.h> 25 #include "wlan_dcs_tgt_api.h" 26 #include "wlan_dcs_ucfg_api.h" 27 28 #define dcs_debug(args ...) \ 29 QDF_TRACE_DEBUG(QDF_MODULE_ID_DCS, ## args) 30 #define dcs_info(args ...) \ 31 QDF_TRACE_INFO(QDF_MODULE_ID_DCS, ## args) 32 #define dcs_err(args ...) \ 33 QDF_TRACE_ERROR(QDF_MODULE_ID_DCS, ## args) 34 35 #define WLAN_DCS_MAX_PDEVS 3 36 37 #define DCS_TX_MAX_CU 30 38 #define MAX_DCS_TIME_RECORD 10 39 #define DCS_FREQ_CONTROL_TIME (5 * 60 * 1000) 40 41 /** 42 * enum wlan_dcs_debug_level - dcs debug trace level 43 * @DCS_DEBUG_DISABLE: disable debug trace 44 * @DCS_DEBUG_CRITICAL: critical debug trace level 45 * @DCS_DEBUG_VERBOSE: verbose debug trace level 46 */ 47 enum wlan_dcs_debug_level { 48 DCS_DEBUG_DISABLE = 0, 49 DCS_DEBUG_CRITICAL = 1, 50 DCS_DEBUG_VERBOSE = 2 51 }; 52 53 /** 54 * struct pdev_dcs_im_stats - define dcs interference mitigation 55 * stats in pdev object 56 * @prev_dcs_im_stats: previous statistics at last time 57 * @im_intfr_cnt: number of times the interference is 58 * detected within detection window 59 * @im_sample_cnt: sample counter 60 */ 61 struct pdev_dcs_im_stats { 62 struct wlan_host_dcs_im_tgt_stats prev_dcs_im_stats; 63 uint8_t im_intfr_cnt; 64 uint8_t im_samp_cnt; 65 }; 66 67 /** 68 * struct pdev_dcs_params - define dcs configuration parameter in pdev object 69 * @dcs_enable_cfg: dcs enable from ini config 70 * @dcs_enable: dcs enable from ucfg config 71 * @dcs_debug: dcs debug trace level 72 * @phy_err_penalty: phy error penalty 73 * @phy_err_threshold: phy error threshold 74 * @radar_err_threshold: radar error threshold 75 * @coch_intfr_threshold: co-channel interference threshold 76 * @user_max_cu: tx channel utilization due to AP's tx and rx 77 * @intfr_detection_threshold: interference detection threshold 78 * @intfr_detection_window: interference sampling window 79 * @tx_err_threshold: transmission failure rate threshold 80 */ 81 struct pdev_dcs_params { 82 uint8_t dcs_enable_cfg; 83 uint8_t dcs_enable; 84 enum wlan_dcs_debug_level dcs_debug; 85 uint32_t phy_err_penalty; 86 uint32_t phy_err_threshold; 87 uint32_t radar_err_threshold; 88 uint32_t coch_intfr_threshold; 89 uint32_t user_max_cu; 90 uint32_t intfr_detection_threshold; 91 uint32_t intfr_detection_window; 92 uint32_t tx_err_threshold; 93 }; 94 95 /** 96 * struct pdev_dcs_freq_ctrl_params - define dcs frequency control parameter 97 * in pdebv object 98 * @disable_threshold_per_5mins: in five minutes, if dcs happen more than 99 * threshold, then disable dcs for some time 100 * @restart_delay: when dcs happen more than threshold in five minutes, 101 * then start to disable dcs for restart_delay minutes 102 * @timestamp: record dcs happened timestamp 103 * @dcs_happened_count: dcs happened count 104 * @disable_delay_process: in dcs disable delay process or not 105 */ 106 struct pdev_dcs_freq_ctrl_params { 107 uint8_t disable_threshold_per_5mins; 108 uint32_t restart_delay; 109 unsigned long timestamp[MAX_DCS_TIME_RECORD]; 110 unsigned long dcs_happened_count; 111 bool disable_delay_process; 112 }; 113 114 /** 115 * struct pdev_dcs_timer_args - define pdev dcs timer args 116 * @psoc: psoc pointer 117 * @pdev_id: pdev id 118 */ 119 struct pdev_dcs_timer_args { 120 struct wlan_objmgr_psoc *psoc; 121 uint32_t pdev_id; 122 }; 123 124 /** 125 * struct psoc_dcs_cbk - define dcs callback in psoc oject 126 * @cbk: callback 127 * @arg: arguments 128 */ 129 struct psoc_dcs_cbk { 130 dcs_callback cbk; 131 void *arg; 132 }; 133 134 /** 135 * struct dcs_pdev_priv_obj - define dcs pdev priv 136 * @dcs_host_params: dcs host configuration parameter 137 * @dcs_im_stats: dcs im statistics 138 * @dcs_freq_ctrl_params: dcs frequency control parameter 139 * @dcs_disable_timer: dcs disable timer 140 * @dcs_timer_args: dcs disable timer args 141 */ 142 struct dcs_pdev_priv_obj { 143 struct pdev_dcs_params dcs_host_params; 144 struct pdev_dcs_im_stats dcs_im_stats; 145 struct pdev_dcs_freq_ctrl_params dcs_freq_ctrl_params; 146 qdf_timer_t dcs_disable_timer; 147 struct pdev_dcs_timer_args dcs_timer_args; 148 }; 149 150 /** 151 * struct dcs_psoc_priv_obj - define dcs psoc priv 152 * @dcs_pdev_priv: dcs pdev priv 153 * @dcs_cbk: dcs callback 154 */ 155 struct dcs_psoc_priv_obj { 156 struct dcs_pdev_priv_obj dcs_pdev_priv[WLAN_DCS_MAX_PDEVS]; 157 struct psoc_dcs_cbk dcs_cbk; 158 }; 159 160 /** 161 * wlan_dcs_get_pdev_private_obj() - get dcs pdev private object 162 * @psoc: psoc pointer 163 * @pdev_id: pdev_id 164 * 165 * API to retrieve the pdev private object from the psoc context 166 * 167 * Return: pdev private object pointer on success, NULL on error 168 */ 169 struct dcs_pdev_priv_obj * 170 wlan_dcs_get_pdev_private_obj(struct wlan_objmgr_psoc *psoc, uint32_t pdev_id); 171 172 /** 173 * wlan_dcs_attach() - Attach dcs handler 174 * @psoc: psoc pointer 175 * 176 * This function gets called to register dcs FW events handler 177 * 178 * Return: QDF_STATUS 179 */ 180 QDF_STATUS wlan_dcs_attach(struct wlan_objmgr_psoc *psoc); 181 182 /** 183 * wlan_dcs_detach() - Detach dcs handler 184 * @psoc: psoc pointer 185 * 186 * This function gets called to unregister dcs FW events handler 187 * 188 * Return: QDF_STATUS 189 */ 190 QDF_STATUS wlan_dcs_detach(struct wlan_objmgr_psoc *psoc); 191 192 /** 193 * wlan_dcs_cmd_send() - Send dcs command to target_if layer 194 * @psoc: psoc pointer 195 * @pdev_id: pdev_id 196 * @is_host_pdev_id: pdev_id is host id or not 197 * 198 * The function gets called to send dcs command to FW 199 * 200 * return: QDF_STATUS_SUCCESS for success or error code 201 */ 202 QDF_STATUS wlan_dcs_cmd_send(struct wlan_objmgr_psoc *psoc, 203 uint32_t pdev_id, 204 bool is_host_pdev_id); 205 206 /** 207 * wlan_dcs_process() - dcs process main entry 208 * @psoc: psoc pointer 209 * @event: dcs stats event pointer 210 * 211 * This function is the main entry to do dcs related operation 212 * such as algorithm handling and dcs frequency control. 213 * 214 * Return: QDF_STATUS 215 */ 216 QDF_STATUS wlan_dcs_process(struct wlan_objmgr_psoc *psoc, 217 struct dcs_stats_event *event); 218 219 /** 220 * wlan_dcs_disable_timer_fn() - dcs disable timer callback 221 * @dcs_timer_args: dcs timer argument pointer 222 * 223 * This function gets called when dcs disable timer timeout 224 * 225 * Return: None 226 */ 227 void wlan_dcs_disable_timer_fn(void *dcs_timer_args); 228 229 #endif /* _WLAN_DCS_H_ */ 230