1 /* 2 * Copyright (c) 2016-2019 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: This file has the DFS dispatcher API which is exposed to outside of DFS 22 * component. 23 */ 24 25 #ifndef _WLAN_DFS_TGT_API_H_ 26 #define _WLAN_DFS_TGT_API_H_ 27 28 #include <wlan_dfs_public_struct.h> 29 30 #define WLAN_DFS_RESET_TIME_S 7 31 #define WLAN_DFS_WAIT (60 + WLAN_DFS_RESET_TIME_S) /* 60 seconds */ 32 #define WLAN_DFS_WAIT_MS ((WLAN_DFS_WAIT) * 1000) /*in MS*/ 33 34 /* Command id to send test radar to firmware */ 35 #define DFS_PHYERR_OFFLOAD_TEST_SET_RADAR 0 36 37 /* Segment ID corresponding to primary segment */ 38 #define SEG_ID_PRIMARY 0 39 40 /* Segment ID corresponding to secondary segment */ 41 #define SEG_ID_SECONDARY 1 42 43 /* dfs_radar_args_for_unit_test: Radar parameters to be sent in unit test cmd. 44 * @IDX_CMD_ID: Index id pointing to command id value 45 * @IDX_PDEV_ID: Index id pointing to pdev id value 46 * @IDX_RADAR_PARAM1_ID: Index pointing to packed arguments value that includes 47 * 1). Segment ID, 48 * 2). Chirp information (is chirp or non chirp), 49 * 3). Frequency offset. 50 * 51 * The packed argument structure is: 52 * 53 * ------------------------------32 bits arg------------------------- 54 * 55 * ------------21 bits-------------|-------8 bits------|1 bit|2 bits| 56 * __________________________________________________________________ 57 *| | | | | | | | | | | | | | | 58 *|---------21 Unused bits---------|x|x|x| |x|x|x|x| |x| x | x | x | 59 *|________________________________|_|_|_|_|_|_|_|_|_|_|_____|___|___| 60 * 61 * |___________________|_____|_______| 62 * freq.offset Chirp segID 63 * 64 * @DFS_UNIT_TEST_NUM_ARGS: Number of arguments for bangradar unit test 65 * command. 66 * @DFS_MAX_NUM_UNIT_TEST_ARGS: Maximum number of arguments for unit test 67 * command in radar simulation. 68 */ 69 enum { 70 IDX_CMD_ID = 0, 71 IDX_PDEV_ID, 72 IDX_RADAR_PARAM1_ID, 73 DFS_UNIT_TEST_NUM_ARGS, 74 DFS_MAX_NUM_UNIT_TEST_ARGS = DFS_UNIT_TEST_NUM_ARGS 75 }; 76 77 #define SEG_ID_SIZE 2 78 #define IS_CHIRP_SIZE 1 79 #define MASK 0xFF 80 81 /** 82 * struct dfs_emulate_bang_radar_test_cmd - Unit test command structure to send 83 * WMI command to firmware from host 84 * and simulate bangradar event. 85 * @vdev_id: vdev id 86 * @num_args: number of arguments 87 * @args: arguments 88 */ 89 struct dfs_emulate_bang_radar_test_cmd { 90 uint32_t vdev_id; 91 uint32_t num_args; 92 uint32_t args[DFS_MAX_NUM_UNIT_TEST_ARGS]; 93 }; 94 95 extern struct dfs_to_mlme global_dfs_to_mlme; 96 97 /** 98 * tgt_dfs_set_current_channel() - Fill dfs channel structure from 99 * dfs_channel structure. 100 * @pdev: Pointer to DFS pdev object. 101 * @dfs_ch_freq: Frequency in Mhz. 102 * @dfs_ch_flags: Channel flags. 103 * @dfs_ch_flagext: Extended channel flags. 104 * @dfs_ch_ieee: IEEE channel number. 105 * @dfs_ch_vhtop_ch_freq_seg1: Channel Center frequency1. 106 * @dfs_ch_vhtop_ch_freq_seg2: Channel Center frequency2. 107 */ 108 #ifdef DFS_COMPONENT_ENABLE 109 QDF_STATUS tgt_dfs_set_current_channel(struct wlan_objmgr_pdev *pdev, 110 uint16_t dfs_ch_freq, 111 uint64_t dfs_ch_flags, 112 uint16_t dfs_ch_flagext, 113 uint8_t dfs_ch_ieee, 114 uint8_t dfs_ch_vhtop_ch_freq_seg1, 115 uint8_t dfs_ch_vhtop_ch_freq_seg2); 116 117 /** 118 * tgt_dfs_radar_enable() - Enables the radar. 119 * @pdev: Pointer to DFS pdev object. 120 * @no_cac: If no_cac is 0, it cancels the CAC. 121 * 122 * This is called each time a channel change occurs, to (potentially) enable 123 * the radar code. 124 */ 125 QDF_STATUS tgt_dfs_radar_enable(struct wlan_objmgr_pdev *pdev, 126 int no_cac, uint32_t opmode); 127 128 /** 129 * tgt_dfs_control()- Used to process ioctls related to DFS. 130 * @pdev: Pointer to DFS pdev object. 131 * @id: Command type. 132 * @indata: Input buffer. 133 * @insize: size of the input buffer. 134 * @outdata: A buffer for the results. 135 * @outsize: Size of the output buffer. 136 */ 137 QDF_STATUS tgt_dfs_control(struct wlan_objmgr_pdev *pdev, 138 u_int id, 139 void *indata, 140 uint32_t insize, 141 void *outdata, 142 uint32_t *outsize, 143 int *error); 144 145 /** 146 * tgt_dfs_get_radars() - Based on the chipset, calls init radar table functions 147 * @pdev: Pointer to DFS pdev object. 148 * 149 * Wrapper function for dfs_get_radars(). This function called from 150 * outside of DFS component. 151 */ 152 QDF_STATUS tgt_dfs_get_radars(struct wlan_objmgr_pdev *pdev); 153 154 /** 155 * tgt_dfs_process_radar_ind() - Process radar found indication. 156 * @pdev: Pointer to DFS pdev object. 157 * @radar_found: radar found info. 158 * 159 * Process radar found indication. 160 * 161 * Return QDF_STATUS. 162 */ 163 QDF_STATUS tgt_dfs_process_radar_ind(struct wlan_objmgr_pdev *pdev, 164 struct radar_found_info *radar_found); 165 #else 166 static inline QDF_STATUS tgt_dfs_set_current_channel( 167 struct wlan_objmgr_pdev *pdev, 168 uint16_t dfs_ch_freq, 169 uint64_t dfs_ch_flags, 170 uint16_t dfs_ch_flagext, 171 uint8_t dfs_ch_ieee, 172 uint8_t dfs_ch_vhtop_ch_freq_seg1, 173 uint8_t dfs_ch_vhtop_ch_freq_seg2) 174 { 175 return QDF_STATUS_SUCCESS; 176 } 177 178 static inline QDF_STATUS tgt_dfs_radar_enable(struct wlan_objmgr_pdev *pdev, 179 int no_cac, uint32_t opmode) 180 { 181 return QDF_STATUS_SUCCESS; 182 } 183 184 static inline QDF_STATUS tgt_dfs_control(struct wlan_objmgr_pdev *pdev, 185 u_int id, 186 void *indata, 187 uint32_t insize, 188 void *outdata, 189 uint32_t *outsize, 190 int *error) 191 { 192 return QDF_STATUS_SUCCESS; 193 } 194 195 static inline QDF_STATUS tgt_dfs_get_radars(struct wlan_objmgr_pdev *pdev) 196 { 197 return QDF_STATUS_SUCCESS; 198 } 199 200 static inline QDF_STATUS tgt_dfs_process_radar_ind( 201 struct wlan_objmgr_pdev *pdev, 202 struct radar_found_info *radar_found) 203 { 204 return QDF_STATUS_SUCCESS; 205 } 206 #endif 207 208 /** 209 * tgt_dfs_process_phyerr() - Process phyerr. 210 * @pdev: Pointer to DFS pdev object. 211 * @buf: Phyerr buffer. 212 * @datalen: phyerr buffer length. 213 * @r_rssi: RSSI. 214 * @r_ext_rssi: Extension channel RSSI. 215 * @r_rs_tstamp: Timestamp. 216 * @r_fulltsf: TSF64. 217 * 218 * Wrapper function for dfs_process_phyerr(). This function called from 219 * outside of DFS component. 220 */ 221 QDF_STATUS tgt_dfs_process_phyerr(struct wlan_objmgr_pdev *pdev, 222 void *buf, 223 uint16_t datalen, 224 uint8_t r_rssi, 225 uint8_t r_ext_rssi, 226 uint32_t r_rs_tstamp, 227 uint64_t r_fulltsf); 228 229 /** 230 * tgt_dfs_process_phyerr_filter_offload() - Process radar event. 231 * Wrapper function for dfs_process_phyerr_filter_offload(). This function 232 * called from outside of DFS component. 233 * @pdev: Pointer to DFS pdev object. 234 * @wlan_radar_event: pointer to radar_event_info. 235 * 236 * Return: QDF_STATUS 237 */ 238 QDF_STATUS tgt_dfs_process_phyerr_filter_offload(struct wlan_objmgr_pdev *pdev, 239 struct radar_event_info *wlan_radar_event); 240 241 /** 242 * tgt_dfs_is_phyerr_filter_offload() - Is phyerr filter offload. 243 * @psoc: Pointer to psoc object. 244 * @is_phyerr_filter_offload: Pointer to is_phyerr_filter_offload. 245 * 246 * Return: QDF_STATUS 247 */ 248 QDF_STATUS tgt_dfs_is_phyerr_filter_offload(struct wlan_objmgr_psoc *psoc, 249 bool *is_phyerr_filter_offload); 250 251 /** 252 * tgt_dfs_destroy_object() - Destroys the DFS object. 253 * @pdev: Pointer to DFS pdev object. 254 * 255 * Wrapper function for dfs_destroy_object(). This function called from 256 * outside of DFS component. 257 */ 258 QDF_STATUS tgt_dfs_destroy_object(struct wlan_objmgr_pdev *pdev); 259 260 #ifdef QCA_MCL_DFS_SUPPORT 261 /** 262 * tgt_dfs_set_tx_leakage_threshold() - set tx_leakage_threshold. 263 * @pdev: Pointer to DFS pdev object. 264 * @tx_leakage_threshold: tx leakage threshold for dfs. 265 * 266 * Return QDF_STATUS. 267 */ 268 QDF_STATUS tgt_dfs_set_tx_leakage_threshold(struct wlan_objmgr_pdev *pdev, 269 uint16_t tx_leakage_threshold); 270 #else 271 static inline QDF_STATUS tgt_dfs_set_tx_leakage_threshold 272 (struct wlan_objmgr_pdev *pdev, 273 uint16_t tx_leakage_threshold) 274 { 275 return QDF_STATUS_SUCCESS; 276 } 277 #endif 278 279 /** 280 * tgt_dfs_is_precac_timer_running() - Check whether precac timer is running. 281 * @pdev: Pointer to DFS pdev object. 282 * @is_precac_timer_running: Pointer to save precac timer value. 283 * 284 * Wrapper function for dfs_is_precac_timer_running(). This function called from 285 * outside of DFS component. 286 */ 287 QDF_STATUS tgt_dfs_is_precac_timer_running(struct wlan_objmgr_pdev *pdev, 288 bool *is_precac_timer_running); 289 290 /** 291 * utils_dfs_find_vht80_chan_for_precac() - Find VHT80 channel for precac. 292 * @pdev: Pointer to DFS pdev object. 293 * @chan_mode: Channel mode. 294 * @ch_freq_seg1: Segment1 channel freq. 295 * @cfreq1: cfreq1. 296 * @cfreq2: cfreq2. 297 * @phy_mode: Precac phymode. 298 * @dfs_set_cfreq2: Precac cfreq2 299 * @set_agile: Agile mode flag. 300 * 301 * wrapper function for dfs_find_vht80_chan_for_precacdfs_cancel_cac_timer(). 302 * This function called from outside of dfs component. 303 */ 304 QDF_STATUS tgt_dfs_find_vht80_chan_for_precac(struct wlan_objmgr_pdev *pdev, 305 uint32_t chan_mode, 306 uint8_t ch_freq_seg1, 307 uint32_t *cfreq1, 308 uint32_t *cfreq2, 309 uint32_t *phy_mode, 310 bool *dfs_set_cfreq2, 311 bool *set_agile); 312 313 /** 314 * tgt_dfs_cac_complete() - Process cac complete indication. 315 * @pdev: Pointer to DFS pdev object. 316 * @vdev_id: vdev id. 317 * 318 * Process cac complete indication from firmware. 319 * 320 * Return QDF_STATUS. 321 */ 322 QDF_STATUS tgt_dfs_cac_complete(struct wlan_objmgr_pdev *pdev, 323 uint32_t vdev_id); 324 325 /** 326 * tgt_dfs_reg_ev_handler() - Register dfs events. 327 * @psoc: Pointer to psoc. 328 * 329 * Register dfs events. 330 * 331 * Return: QDF_STATUS. 332 */ 333 QDF_STATUS tgt_dfs_reg_ev_handler(struct wlan_objmgr_psoc *psoc); 334 335 /** 336 * tgt_dfs_stop() - Clear dfs timers. 337 * @dfs: Pointer to wlan_dfs structure. 338 */ 339 QDF_STATUS tgt_dfs_stop(struct wlan_objmgr_pdev *pdev); 340 341 /** 342 * tgt_dfs_process_emulate_bang_radar_cmd() - Process to emulate dfs bangradar 343 * command. 344 * @pdev: Pointer to DFS pdev object. 345 * 346 * Process to emulate dfs bangradar command. 347 * 348 * Return: QDF_STATUS. 349 */ 350 QDF_STATUS tgt_dfs_process_emulate_bang_radar_cmd(struct wlan_objmgr_pdev *pdev, 351 struct dfs_emulate_bang_radar_test_cmd *dfs_unit_test); 352 353 #ifdef QCA_MCL_DFS_SUPPORT 354 /** 355 * tgt_dfs_set_phyerr_filter_offload() - config phyerr filter offload 356 * @pdev: Pointer to DFS pdev object. 357 * 358 * Return: QDF_STATUS 359 */ 360 QDF_STATUS tgt_dfs_set_phyerr_filter_offload(struct wlan_objmgr_pdev *pdev); 361 #else 362 static inline QDF_STATUS tgt_dfs_set_phyerr_filter_offload 363 (struct wlan_objmgr_pdev *pdev) 364 { 365 return QDF_STATUS_SUCCESS; 366 } 367 #endif 368 369 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST) 370 /** 371 * tgt_dfs_send_avg_params_to_fw() - send average radar parameters to fw. 372 * @pdev: Pointer to DFS pdev object. 373 * @params: Pointer to dfs radar average parameters. 374 * 375 * Return: QDF_STATUS 376 */ 377 QDF_STATUS 378 tgt_dfs_send_avg_params_to_fw(struct wlan_objmgr_pdev *pdev, 379 struct dfs_radar_found_params *params); 380 #endif 381 382 /** 383 * tgt_dfs_action_on_status_from_fw() - trigger the action to be taken based on 384 * host dfs status received from fw. 385 * @pdev: Pointer to pdev object. 386 * @status: Pointer to the host dfs status received from fw. 387 * 388 * Return: QDF_STATUS 389 */ 390 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST) 391 QDF_STATUS tgt_dfs_action_on_status_from_fw(struct wlan_objmgr_pdev *pdev, 392 uint32_t *status); 393 #else 394 static inline 395 QDF_STATUS tgt_dfs_action_on_status_from_fw(struct wlan_objmgr_pdev *pdev, 396 uint32_t *status) 397 { 398 return QDF_STATUS_SUCCESS; 399 } 400 #endif 401 402 /** 403 * tgt_dfs_is_radar_enabled() - checks if radar detection is enabled. 404 * @pdev: Pointer to pdev object. 405 * @ignore_dfs: Pointer to check the value. If 1, radar detection is disabled. 406 */ 407 void tgt_dfs_is_radar_enabled(struct wlan_objmgr_pdev *pdev, int *ignore_dfs); 408 409 /** 410 * tgt_dfs_reset_spoof_test() - reset the dfs spoof check variables 411 * @pdev: Pointer to pdev object. 412 * 413 * Return: QDF_STATUS 414 */ 415 #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST) 416 QDF_STATUS tgt_dfs_reset_spoof_test(struct wlan_objmgr_pdev *pdev); 417 #else 418 static inline 419 QDF_STATUS tgt_dfs_reset_spoof_test(struct wlan_objmgr_pdev *pdev) 420 { 421 return QDF_STATUS_SUCCESS; 422 } 423 #endif 424 425 /** 426 * tgt_dfs_enable_stadfs() - Enable/Disable STADFS capability. 427 * @pdev: Pointer to DFS pdev object. 428 * @val: input value. 429 */ 430 void tgt_dfs_enable_stadfs(struct wlan_objmgr_pdev *pdev, bool val); 431 432 /** 433 * tgt_dfs_is_stadfs_enabled() - Get STADFS capability 434 * @pdev: Pointer to DFS pdev object. 435 * 436 * Return: true if STADFS is enabled, else false. 437 */ 438 bool tgt_dfs_is_stadfs_enabled(struct wlan_objmgr_pdev *pdev); 439 440 /** 441 * tgt_dfs_is_pdev_5ghz() - Check if the input pdev is 5GHZ. 442 * @pdev: Pointer to DFS pdev object. 443 * 444 * Return: true if the pdev supports 5GHz, else false. 445 */ 446 bool tgt_dfs_is_pdev_5ghz(struct wlan_objmgr_pdev *pdev); 447 448 #if defined(WLAN_DFS_FULL_OFFLOAD) && defined(QCA_DFS_NOL_OFFLOAD) 449 /** 450 * tgt_dfs_send_usenol_pdev_param() - Send usenol pdev param to FW. 451 * @pdev: Pointer to pdev object. 452 * @usenol: Value of usenol 453 * 454 * Return: QDF_STATUS 455 */ 456 QDF_STATUS tgt_dfs_send_usenol_pdev_param(struct wlan_objmgr_pdev *pdev, 457 bool usenol); 458 459 /** 460 * tgt_dfs_send_subchan_marking() - Send subchannel marking pdev param to FW. 461 * @pdev: Pointer to pdev object. 462 * @subchanmark: Value of subchannel_marking. 463 * 464 * Return: QDF_STATUS 465 */ 466 QDF_STATUS tgt_dfs_send_subchan_marking(struct wlan_objmgr_pdev *pdev, 467 bool subchanmark); 468 #else 469 static inline 470 QDF_STATUS tgt_dfs_send_usenol_pdev_param(struct wlan_objmgr_pdev *pdev, 471 bool usenol) 472 { 473 return QDF_STATUS_SUCCESS; 474 } 475 476 static inline QDF_STATUS 477 tgt_dfs_send_subchan_marking(struct wlan_objmgr_pdev *pdev, bool subchanmark) 478 { 479 return QDF_STATUS_SUCCESS; 480 } 481 #endif 482 #endif /* _WLAN_DFS_TGT_API_H_ */ 483