1 /* 2 * Copyright (c) 2021, The Linux Foundation. All rights reserved. 3 * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18 /** 19 * DOC: contains interface prototypes for son api 20 */ 21 #ifndef _SON_API_H_ 22 #define _SON_API_H_ 23 24 #include <qdf_types.h> 25 #include <wlan_objmgr_peer_obj.h> 26 #include <wlan_objmgr_pdev_obj.h> 27 #include <reg_services_public_struct.h> 28 #include <qdf_trace.h> 29 30 #define son_alert(format, args...) \ 31 QDF_TRACE_FATAL(QDF_MODULE_ID_SON, format, ## args) 32 33 #define son_err(format, args...) \ 34 QDF_TRACE_ERROR(QDF_MODULE_ID_SON, format, ## args) 35 36 #define son_warn(format, args...) \ 37 QDF_TRACE_WARN(QDF_MODULE_ID_SON, format, ## args) 38 39 #define son_info(format, args...) \ 40 QDF_TRACE_INFO(QDF_MODULE_ID_SON, format, ## args) 41 42 #define son_debug(format, args...) \ 43 QDF_TRACE_DEBUG(QDF_MODULE_ID_SON, format, ## args) 44 45 #define son_nofl_alert(format, args...) \ 46 QDF_TRACE_FATAL_NO_FL(QDF_MODULE_ID_SON, format, ## args) 47 48 #define son_nofl_err(format, args...) \ 49 QDF_TRACE_ERROR_NO_FL(QDF_MODULE_ID_SON, format, ## args) 50 51 #define son_nofl_warn(format, args...) \ 52 QDF_TRACE_WARN_NO_FL(QDF_MODULE_ID_SON, format, ## args) 53 54 #define son_nofl_info(format, args...) \ 55 QDF_TRACE_INFO_NO_FL(QDF_MODULE_ID_SON, format, ## args) 56 57 #define son_nofl_debug(format, args...) \ 58 QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_SON, format, ## args) 59 60 #define son_alert_rl(format, args...) \ 61 QDF_TRACE_FATAL_RL(QDF_MODULE_ID_SON, format, ## args) 62 63 #define son_err_rl(format, args...) \ 64 QDF_TRACE_ERROR_RL(QDF_MODULE_ID_SON, format, ## args) 65 66 #define son_warn_rl(format, args...) \ 67 QDF_TRACE_WARN_RL(QDF_MODULE_ID_SON, format, ## args) 68 69 #define son_info_rl(format, args...) \ 70 QDF_TRACE_INFO_RL(QDF_MODULE_ID_SON, format, ## args) 71 72 #define son_debug_rl(format, args...) \ 73 QDF_TRACE_DEBUG_RL(QDF_MODULE_ID_SON, format, ## args) 74 75 #define son_nofl_alert_rl(format, args...) \ 76 QDF_TRACE_FATAL_RL_NO_FL(QDF_MODULE_ID_SON, format, ## args) 77 78 #define son_nofl_err_rl(format, args...) \ 79 QDF_TRACE_ERROR_RL_NO_FL(QDF_MODULE_ID_SON, format, ## args) 80 81 #define son_nofl_warn_rl(format, args...) \ 82 QDF_TRACE_WARN_RL_NO_FL(QDF_MODULE_ID_SON, format, ## args) 83 84 #define son_nofl_info_rl(format, args...) \ 85 QDF_TRACE_INFO_RL_NO_FL(QDF_MODULE_ID_SON, format, ## args) 86 87 #define son_nofl_debug_rl(format, args...) \ 88 QDF_TRACE_DEBUG_RL_NO_FL(QDF_MODULE_ID_SON, format, ## args) 89 90 #define TOTAL_DWELL_TIME 200 91 92 #define CBS_DEFAULT_RESTTIME 500 /* msec */ 93 #define CBS_DEFAULT_DWELL_TIME 50 /* msec */ 94 #define CBS_DEFAULT_WAIT_TIME 1000 /* 1 sec */ 95 #define CBS_DEFAULT_DWELL_SPLIT_TIME 50 /* msec */ 96 #define CBS_DEFAULT_DWELL_REST_TIME 500 /* msec */ 97 #define CBS_DEFAULT_MIN_REST_TIME 50 /* msec */ 98 99 #define DEFAULT_BEACON_INTERVAL 100 100 101 #define CBS_DWELL_TIME_10MS 10 102 #define CBS_DWELL_TIME_25MS 25 103 #define CBS_DWELL_TIME_50MS 50 104 #define CBS_DWELL_TIME_75MS 75 105 #define MIN_SCAN_OFFSET_ARRAY_SIZE 0 106 #define MAX_SCAN_OFFSET_ARRAY_SIZE 9 107 #define SCAN_START_OFFSET_MIN 26 108 109 #define DEFAULT_SCAN_MAX_REST_TIME 500 110 111 /** 112 * enum son_cbs_state - son cbs state enumeration 113 * @CBS_INIT: init state 114 * @CBS_SCAN: scanning state 115 * @CBS_REST: rest state 116 * @CBS_RANK: rank state 117 * @CBS_WAIT: wait state 118 */ 119 enum son_cbs_state { 120 CBS_INIT, 121 CBS_SCAN, 122 CBS_REST, 123 CBS_RANK, 124 CBS_WAIT, 125 }; 126 127 /** 128 * struct son_cbs - son cbs struction 129 * @vdev: vdev 130 * @cbs_lock: cbs spin lock 131 * @cbs_timer: cbs timer 132 * @cbs_state: cbs state 133 * @cbs_scan_requestor: scan requestor 134 * @cbs_scan_id: scan id 135 * @dwell_time: dwell time configuration 136 * @rest_time: rest time configuration 137 * @wait_time: wait time configuration 138 * @scan_intvl_time: interval time configuration 139 * @scan_params: scan params 140 * @max_dwell_split_cnt: max dwell split counter 141 * @dwell_split_cnt: dwell split counter 142 * @scan_offset: scan offset array 143 * @scan_dwell_rest: scan dwell rest array 144 * @min_dwell_rest_time: nub dwell rest time 145 * @dwell_split_time: dwell split time 146 * @max_arr_size_used: max array size used 147 */ 148 struct son_cbs { 149 struct wlan_objmgr_vdev *vdev; 150 151 spinlock_t cbs_lock; 152 qdf_timer_t cbs_timer; 153 154 enum son_cbs_state cbs_state; 155 156 wlan_scan_requester cbs_scan_requestor; 157 wlan_scan_id cbs_scan_id; 158 159 uint32_t dwell_time; 160 uint32_t rest_time; 161 uint32_t wait_time; 162 int32_t scan_intvl_time; 163 164 struct scan_start_request scan_params; 165 166 uint8_t max_dwell_split_cnt; 167 int8_t dwell_split_cnt; 168 uint32_t scan_offset[10]; 169 uint32_t scan_dwell_rest[10]; 170 uint32_t min_dwell_rest_time; 171 uint32_t dwell_split_time; 172 uint8_t max_arr_size_used; 173 }; 174 175 /** 176 * typedef mlme_deliver_cb() - cb to deliver mlme event 177 * @vdev: pointer to vdev 178 * @event_len: event length 179 * @event_buf: event buffer 180 * 181 * Return: 0 if event is sent successfully 182 */ 183 typedef int (*mlme_deliver_cb)(struct wlan_objmgr_vdev *vdev, 184 uint32_t event_len, 185 const uint8_t *event_buf); 186 187 /** 188 * enum SON_MLME_DELIVER_CB_TYPE - mlme deliver cb type 189 * @SON_MLME_DELIVER_CB_TYPE_OPMODE: cb to deliver opmode 190 * @SON_MLME_DELIVER_CB_TYPE_SMPS: cb to deliver smps 191 */ 192 enum SON_MLME_DELIVER_CB_TYPE { 193 SON_MLME_DELIVER_CB_TYPE_OPMODE, 194 SON_MLME_DELIVER_CB_TYPE_SMPS, 195 }; 196 197 /** 198 * wlan_son_register_mlme_deliver_cb - register mlme deliver cb 199 * @psoc: pointer to psoc 200 * @cb: mlme deliver cb 201 * @type: mlme deliver cb type 202 * 203 * Return: QDF_STATUS 204 */ 205 QDF_STATUS 206 wlan_son_register_mlme_deliver_cb(struct wlan_objmgr_psoc *psoc, 207 mlme_deliver_cb cb, 208 enum SON_MLME_DELIVER_CB_TYPE type); 209 /** 210 * wlan_son_peer_ext_stat_enable() - sends EXT stats command to FW 211 * @pdev: pointer to pdev 212 * @mac_addr: MAC address of the target peer 213 * @vdev: Pointer to vdev 214 * @stats_count: Stats count 215 * @enable: Enable / disable ext stats 216 * 217 * Return: QDF_STATUS_SUCCESS on success else failure 218 */ 219 QDF_STATUS wlan_son_peer_ext_stat_enable(struct wlan_objmgr_pdev *pdev, 220 uint8_t *mac_addr, 221 struct wlan_objmgr_vdev *vdev, 222 uint32_t stats_count, 223 uint32_t enable); 224 225 /** 226 * wlan_son_peer_req_inst_stats() - Requests for instantaneous stats for 227 * the target mac_addr from FW via 228 * WMI_REQUEST_STATS_CMDID. 229 * @pdev: pointer to pdev 230 * @mac_addr: MAC address of the target peer 231 * @vdev: Pointer to vdev 232 * 233 * Return: QDF_STATUS_SUCCESS on success else failure 234 */ 235 QDF_STATUS wlan_son_peer_req_inst_stats(struct wlan_objmgr_pdev *pdev, 236 uint8_t *mac_addr, 237 struct wlan_objmgr_vdev *vdev); 238 239 /** 240 * wlan_son_get_chan_flag() - get chan flag 241 * @pdev: pointer to pdev 242 * @freq: qdf_freq_t 243 * @flag_160: If true, 160 channel info will be obtained; 244 * otherwise 80+80, 80 channel info will be obtained 245 * @chan_params: chan parameters 246 * 247 * Return: combination of enum qca_wlan_vendor_channel_prop_flags and 248 * enum qca_wlan_vendor_channel_prop_flags_2 249 */ 250 uint32_t wlan_son_get_chan_flag(struct wlan_objmgr_pdev *pdev, 251 qdf_freq_t freq, bool flag_160, 252 struct ch_params *chan_params); 253 254 /** 255 * wlan_son_peer_set_kickout_allow() - set the peer is allowed to kickout 256 * @vdev: pointer to vdev 257 * @peer: pointer to peer 258 * @kickout_allow: kickout_allow to set 259 * 260 * Return: QDF_STATUS_SUCCESS on Success else failure. 261 */ 262 QDF_STATUS wlan_son_peer_set_kickout_allow(struct wlan_objmgr_vdev *vdev, 263 struct wlan_objmgr_peer *peer, 264 bool kickout_allow); 265 266 /** 267 * wlan_son_cbs_init() - son cbs init 268 * 269 * Return: 0 if succeed 270 */ 271 int wlan_son_cbs_init(void); 272 273 /* wlan_son_cbs_deinit - son cbs deinit 274 * 275 * Return: 0 if succeed 276 */ 277 int wlan_son_cbs_deinit(void); 278 279 /* wlan_son_cbs_enable() - son cbs enable 280 * @vdev: pointer to vdev 281 * 282 * Return: 0 if succeed 283 */ 284 int wlan_son_cbs_enable(struct wlan_objmgr_vdev *vdev); 285 286 /* wlan_son_cbs_disable() - son cbs disable 287 * @vdev: pointer to vdev 288 * 289 * Return: 0 if succeed 290 */ 291 int wlan_son_cbs_disable(struct wlan_objmgr_vdev *vdev); 292 293 /* wlan_son_set_cbs() - son cbs set 294 * @vdev: pointer to vdev 295 * @enable: enable or disable son cbs 296 * 297 * Return: 0 if succeed 298 */ 299 int wlan_son_set_cbs(struct wlan_objmgr_vdev *vdev, 300 bool enable); 301 302 /* wlan_son_set_cbs_wait_time() - cbs wait time configure 303 * @vdev: pointer to vdev 304 * @val: wait time value 305 * 306 * Return: 0 if succeed 307 */ 308 int wlan_son_set_cbs_wait_time(struct wlan_objmgr_vdev *vdev, 309 uint32_t val); 310 311 /* wlan_son_set_cbs_dwell_split_time() - cbs dwell spilt time configure 312 * @vdev: pointer to vdev 313 * @val: dwell spilt time value 314 * 315 * Return: 0 if succeed 316 */ 317 int wlan_son_set_cbs_dwell_split_time(struct wlan_objmgr_vdev *vdev, 318 uint32_t val); 319 320 /** 321 * wlan_son_vdev_get_supported_txrx_streams() - get supported spatial streams 322 * @vdev: pointer to vdev 323 * @num_tx_streams: pointer to number of tx streams 324 * @num_rx_streams: pointer to number of rx streams 325 * 326 * Return: QDF_STATUS_SUCCESS on Success else failure. 327 */ 328 QDF_STATUS 329 wlan_son_vdev_get_supported_txrx_streams(struct wlan_objmgr_vdev *vdev, 330 uint32_t *num_tx_streams, 331 uint32_t *num_rx_streams); 332 333 #ifdef WLAN_FEATURE_SON 334 /** 335 * wlan_son_peer_is_kickout_allow() - Is peer is allowed to kickout 336 * @vdev: pointer to vdev 337 * @macaddr: mac addr of the peer 338 * 339 * Return: True if it is allowed to kickout. 340 */ 341 bool wlan_son_peer_is_kickout_allow(struct wlan_objmgr_vdev *vdev, 342 uint8_t *macaddr); 343 344 /** 345 * wlan_son_ind_assoc_req_frm() - indicate assoc req frame to son 346 * @vdev: pointer to vdev 347 * @macaddr: MAC address 348 * @is_reassoc: true if it is reassoc req 349 * @frame: frame body 350 * @frame_len: frame body length 351 * @status: assoc req frame is handled successfully 352 * 353 * Return: Void 354 */ 355 void wlan_son_ind_assoc_req_frm(struct wlan_objmgr_vdev *vdev, 356 uint8_t *macaddr, bool is_reassoc, 357 uint8_t *frame, uint16_t frame_len, 358 QDF_STATUS status); 359 360 /** 361 * wlan_son_deliver_tx_power() - notify son module of tx power 362 * @vdev: vdev 363 * @max_pwr: max power in dBm unit 364 * 365 * Return: 0 if event is sent successfully 366 */ 367 int wlan_son_deliver_tx_power(struct wlan_objmgr_vdev *vdev, 368 int32_t max_pwr); 369 370 /** 371 * wlan_son_deliver_vdev_stop() - notify son module of vdev stop 372 * @vdev: vdev 373 * 374 * Return: 0 if event is sent successfully 375 */ 376 int wlan_son_deliver_vdev_stop(struct wlan_objmgr_vdev *vdev); 377 378 /** 379 * wlan_son_deliver_inst_rssi() - notify son module of inst rssi 380 * @vdev: vdev 381 * @peer: peer device 382 * @irssi: inst rssi above the noise floor in dB unit 383 * 384 * Return: 0 if event is sent successfully 385 */ 386 int wlan_son_deliver_inst_rssi(struct wlan_objmgr_vdev *vdev, 387 struct wlan_objmgr_peer *peer, 388 uint32_t irssi); 389 390 /** 391 * wlan_son_deliver_opmode() - notify user app of opmode 392 * @vdev: vdev objmgr 393 * @bw: channel width defined in enum eSirMacHTChannelWidth 394 * @nss: supported rx nss 395 * @addr: source addr 396 * 397 * Return: 0 if event is sent successfully 398 */ 399 int wlan_son_deliver_opmode(struct wlan_objmgr_vdev *vdev, 400 uint8_t bw, 401 uint8_t nss, 402 uint8_t *addr); 403 404 /** 405 * wlan_son_deliver_smps() - notify user app of smps 406 * @vdev: vdev objmgr 407 * @is_static: is_static 408 * @addr: source addr 409 * 410 * Return: 0 if event is sent successfully 411 */ 412 int wlan_son_deliver_smps(struct wlan_objmgr_vdev *vdev, 413 uint8_t is_static, 414 uint8_t *addr); 415 416 /** 417 * wlan_son_deliver_rrm_rpt() - notify son module of rrm rpt 418 * @vdev: vdev objmgr 419 * @addr: sender addr 420 * @frm: points to measurement report 421 * @flen: frame length 422 * 423 * Return: 0 if event is sent successfully 424 */ 425 int wlan_son_deliver_rrm_rpt(struct wlan_objmgr_vdev *vdev, 426 uint8_t *addr, 427 uint8_t *frm, 428 uint32_t flen); 429 /** 430 * wlan_son_anqp_frame() - notify son module of mgmt frames 431 * @vdev: vdev 432 * @subtype: frame subtype 433 * @frame: the 802.11 frame 434 * @frame_len: frame length 435 * @action_hdr: Action header of the frame 436 * @macaddr: source mac address 437 * 438 * Return: 0 if event is sent successfully 439 */ 440 int wlan_son_anqp_frame(struct wlan_objmgr_vdev *vdev, int subtype, 441 uint8_t *frame, uint16_t frame_len, void *action_hdr, 442 uint8_t *macaddr); 443 444 /** 445 * wlan_son_get_node_tx_power() - Gets the max transmit power for peer 446 * @assoc_req_ies: assoc req ies 447 * 448 * Return: Returns the max tx power 449 */ 450 uint8_t wlan_son_get_node_tx_power(struct element_info assoc_req_ies); 451 452 /** 453 * wlan_son_get_peer_rrm_info() - Get RRM info for peer 454 * @assoc_req_ies: assoc req ies 455 * @rrmcaps: rrm capabilities 456 * @is_beacon_meas_supported: if beacon meas is supported 457 * 458 * Return: Returns QDF_STATUS_SUCCESS if succeed 459 */ 460 QDF_STATUS wlan_son_get_peer_rrm_info(struct element_info assoc_req_ies, 461 uint8_t *rrmcaps, 462 bool *is_beacon_meas_supported); 463 #else 464 wlan_son_peer_is_kickout_allow(struct wlan_objmgr_vdev * vdev,uint8_t * macaddr)465 static inline bool wlan_son_peer_is_kickout_allow(struct wlan_objmgr_vdev *vdev, 466 uint8_t *macaddr) 467 { 468 return true; 469 } 470 471 static inline wlan_son_ind_assoc_req_frm(struct wlan_objmgr_vdev * vdev,uint8_t * macaddr,bool is_reassoc,uint8_t * frame,uint16_t frame_len,QDF_STATUS status)472 void wlan_son_ind_assoc_req_frm(struct wlan_objmgr_vdev *vdev, 473 uint8_t *macaddr, bool is_reassoc, 474 uint8_t *frame, uint16_t frame_len, 475 QDF_STATUS status) 476 { 477 } 478 479 static inline wlan_son_deliver_tx_power(struct wlan_objmgr_vdev * vdev,int32_t max_pwr)480 int wlan_son_deliver_tx_power(struct wlan_objmgr_vdev *vdev, 481 int32_t max_pwr) 482 { 483 return -EINVAL; 484 } 485 486 static inline wlan_son_deliver_vdev_stop(struct wlan_objmgr_vdev * vdev)487 int wlan_son_deliver_vdev_stop(struct wlan_objmgr_vdev *vdev) 488 { 489 return -EINVAL; 490 } 491 492 static inline wlan_son_deliver_inst_rssi(struct wlan_objmgr_vdev * vdev,struct wlan_objmgr_peer * peer,uint32_t irssi)493 int wlan_son_deliver_inst_rssi(struct wlan_objmgr_vdev *vdev, 494 struct wlan_objmgr_peer *peer, 495 uint32_t irssi) 496 { 497 return -EINVAL; 498 } 499 500 static inline wlan_son_deliver_opmode(struct wlan_objmgr_vdev * vdev,uint8_t bw,uint8_t nss,uint8_t * addr)501 int wlan_son_deliver_opmode(struct wlan_objmgr_vdev *vdev, 502 uint8_t bw, 503 uint8_t nss, 504 uint8_t *addr) 505 { 506 return -EINVAL; 507 } 508 509 static inline wlan_son_deliver_smps(struct wlan_objmgr_vdev * vdev,uint8_t is_static,uint8_t * addr)510 int wlan_son_deliver_smps(struct wlan_objmgr_vdev *vdev, 511 uint8_t is_static, 512 uint8_t *addr) 513 { 514 return -EINVAL; 515 } 516 517 static inline wlan_son_deliver_rrm_rpt(struct wlan_objmgr_vdev * vdev,uint8_t * mac_addr,uint8_t * frm,uint32_t flen)518 int wlan_son_deliver_rrm_rpt(struct wlan_objmgr_vdev *vdev, 519 uint8_t *mac_addr, 520 uint8_t *frm, 521 uint32_t flen) 522 { 523 return -EINVAL; 524 } 525 526 static inline wlan_son_anqp_frame(struct wlan_objmgr_vdev * vdev,int subtype,uint8_t * frame,uint16_t frame_len,void * action_hdr,uint8_t * macaddr)527 int wlan_son_anqp_frame(struct wlan_objmgr_vdev *vdev, int subtype, 528 uint8_t *frame, uint16_t frame_len, void *action_hdr, 529 uint8_t *macaddr) 530 { 531 return -EINVAL; 532 } 533 534 static inline wlan_son_get_node_tx_power(struct element_info assoc_req_ies)535 uint8_t wlan_son_get_node_tx_power(struct element_info assoc_req_ies) 536 { 537 return 0; 538 } 539 540 static inline wlan_son_get_peer_rrm_info(struct element_info assoc_req_ies,uint8_t * rrmcaps,bool * is_beacon_meas_supported)541 QDF_STATUS wlan_son_get_peer_rrm_info(struct element_info assoc_req_ies, 542 uint8_t *rrmcaps, 543 bool *is_beacon_meas_supported) 544 { 545 return QDF_STATUS_E_INVAL; 546 } 547 #endif /*WLAN_FEATURE_SON*/ 548 #endif 549