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