1 /* 2 * Copyright (c) 2011-2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. 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 #if !defined(__SMEINTERNAL_H) 21 #define __SMEINTERNAL_H 22 23 /** 24 * \file sme_internal.h 25 * 26 * \brief prototype for SME internal structures and APIs used for SME and MAC 27 */ 28 29 /*-------------------------------------------------------------------------- 30 Include Files 31 ------------------------------------------------------------------------*/ 32 #include "qdf_status.h" 33 #include "qdf_lock.h" 34 #include "qdf_trace.h" 35 #include "qdf_mem.h" 36 #include "qdf_types.h" 37 #include "host_diag_core_event.h" 38 #include "csr_link_list.h" 39 #include "sme_power_save.h" 40 #include "wmi_unified.h" 41 #include "wmi_unified_param.h" 42 43 struct wma_twt_add_dialog_complete_event; 44 struct wmi_twt_add_dialog_complete_event_param; 45 struct wmi_twt_enable_complete_event_param; 46 /*-------------------------------------------------------------------------- 47 Type declarations 48 ------------------------------------------------------------------------*/ 49 50 /* Mask can be only have one bit set */ 51 typedef enum eSmeCommandType { 52 eSmeNoCommand = 0, 53 /* this is not a command, it is to identify this is a CSR command */ 54 eSmeCsrCommandMask = 0x10000, 55 eSmeCommandRoam, 56 eSmeCommandWmStatusChange, 57 /* QOS */ 58 eSmeQosCommandMask = 0x40000, /* To identify Qos commands */ 59 eSmeCommandAddTs, 60 eSmeCommandDelTs, 61 e_sme_command_set_hw_mode, 62 e_sme_command_nss_update, 63 e_sme_command_set_dual_mac_config, 64 e_sme_command_set_antenna_mode, 65 } eSmeCommandType; 66 67 typedef enum eSmeState { 68 SME_STATE_STOP, 69 SME_STATE_START, 70 SME_STATE_READY, 71 } eSmeState; 72 73 #define SME_IS_START(mac) (SME_STATE_STOP != (mac)->sme.state) 74 #define SME_IS_READY(mac) (SME_STATE_READY == (mac)->sme.state) 75 76 /** 77 * struct stats_ext_event - stats_ext_event payload 78 * @vdev_id: ID of the vdev for the stats 79 * @event_data_len: length of the @event_data 80 * @event_data: actual ext stats 81 */ 82 struct stats_ext_event { 83 uint32_t vdev_id; 84 uint32_t event_data_len; 85 uint8_t event_data[]; 86 }; 87 88 /** 89 * typedef stats_ext_cb - stats ext callback 90 * @hdd_handle: Opaque handle to the HDD context 91 * @data: stats ext payload from firmware 92 */ 93 typedef void (*stats_ext_cb)(hdd_handle_t hdd_handle, 94 struct stats_ext_event *data); 95 96 /** 97 * typedef stats_ext2_cb - stats ext2 callback 98 * @hdd_handle: Opaque handle to the HDD context 99 * @data: stats ext2 payload from firmware 100 */ 101 typedef void (*stats_ext2_cb)(hdd_handle_t hdd_handle, 102 struct sir_sme_rx_aggr_hole_ind *data); 103 104 #define MAX_ACTIVE_CMD_STATS 16 105 106 typedef struct sActiveCmdStats { 107 eSmeCommandType command; 108 uint32_t reason; 109 uint32_t sessionId; 110 uint64_t timestamp; 111 } tActiveCmdStats; 112 113 typedef struct sSelfRecoveryStats { 114 tActiveCmdStats activeCmdStats[MAX_ACTIVE_CMD_STATS]; 115 uint8_t cmdStatsIndx; 116 } tSelfRecoveryStats; 117 118 typedef void (*link_layer_stats_cb)(hdd_handle_t hdd_handle, 119 int indication_type, 120 tSirLLStatsResults *results, 121 void *cookie); 122 123 typedef void (*ext_scan_ind_cb)(hdd_handle_t hdd_handle, 124 const uint16_t, void *); 125 126 /** 127 * typedef sme_link_speed_cb - sme_get_link_speed() callback function 128 * @info: link speed information 129 * @context: user context supplied to sme_get_link_speed() 130 * 131 * This is the signature of a callback function whose addresses is 132 * passed as the asynchronous callback function to sme_get_link_speed(). 133 */ 134 135 typedef void (*sme_link_speed_cb)(struct link_speed_info *info, 136 void *context); 137 138 typedef void (*ocb_callback)(void *context, void *response); 139 typedef void (*sme_set_thermal_level_callback)(hdd_handle_t hdd_handle, 140 u_int8_t level); 141 typedef void (*p2p_lo_callback)(void *context, 142 struct sir_p2p_lo_event *event); 143 #ifdef FEATURE_OEM_DATA_SUPPORT 144 typedef void (*sme_send_oem_data_rsp_msg)(struct oem_data_rsp *); 145 #endif 146 147 #ifdef WLAN_SUPPORT_TWT 148 /** 149 * typedef twt_enable_cb - TWT enable callback signature. 150 * @hdd_handle: Opaque HDD handle 151 * @params: TWT enable complete event parameters. 152 */ 153 typedef 154 void (*twt_enable_cb)(hdd_handle_t hdd_handle, 155 struct wmi_twt_enable_complete_event_param *params); 156 157 /** 158 * typedef twt_disable_cb - TWT enable callback signature. 159 * @hdd_handle: Opaque HDD handle 160 */ 161 typedef void (*twt_disable_cb)(hdd_handle_t hdd_handle); 162 163 /** 164 * typedef twt_add_dialog_cb - TWT add dialog callback signature. 165 * @psoc: Pointer to global psoc 166 * @add_dialog_evt: pointer to event buf containing twt response parameters 167 * @renego_fail: Flag to indicate if its re-negotiation failure case 168 */ 169 typedef 170 void (*twt_add_dialog_cb)(struct wlan_objmgr_psoc *psoc, 171 struct wma_twt_add_dialog_complete_event *add_dialog_evt, 172 bool renego_fail); 173 174 /** 175 * typedef twt_del_dialog_cb - TWT delete dialog callback signature. 176 * @psoc: Pointer to global psoc 177 * @params: TWT delete dialog complete event parameters. 178 */ 179 typedef void (*twt_del_dialog_cb)( 180 struct wlan_objmgr_psoc *psoc, 181 struct wmi_twt_del_dialog_complete_event_param *params); 182 183 /** 184 * typedef twt_pause_dialog_cb - TWT pause dialog callback signature. 185 * @psoc: Pointer to global psoc 186 * @params: TWT pause dialog complete event parameters. 187 */ 188 typedef 189 void (*twt_pause_dialog_cb)(struct wlan_objmgr_psoc *psoc, 190 struct wmi_twt_pause_dialog_complete_event_param *params); 191 192 /** 193 * typedef twt_nudge_dialog_cb - TWT nudge dialog callback signature. 194 * @psoc: Pointer to global psoc 195 * @params: TWT nudge dialog complete event parameters. 196 */ 197 typedef 198 void (*twt_nudge_dialog_cb)(struct wlan_objmgr_psoc *psoc, 199 struct wmi_twt_nudge_dialog_complete_event_param *params); 200 201 /** 202 * typedef twt_resume_dialog_cb - TWT resume dialog callback signature. 203 * @psoc: Pointer to global psoc 204 * @params: TWT resume dialog complete event parameters. 205 */ 206 typedef 207 void (*twt_resume_dialog_cb)(struct wlan_objmgr_psoc *psoc, 208 struct wmi_twt_resume_dialog_complete_event_param *params); 209 210 /** 211 * typedef twt_notify_cb - TWT notify callback signature. 212 * @psoc: Pointer to global psoc 213 * @params: TWT twt notify event parameters. 214 */ 215 typedef 216 void (*twt_notify_cb)(struct wlan_objmgr_psoc *psoc, 217 struct wmi_twt_notify_event_param *params); 218 219 /** 220 * typedef twt_ack_comp_cb - TWT ack callback signature. 221 * @params: TWT ack complete event parameters. 222 * @context: TWT context 223 */ 224 typedef 225 void (*twt_ack_comp_cb)(struct wmi_twt_ack_complete_event_param *params, 226 void *context); 227 228 /** 229 * struct twt_callbacks - TWT response callback pointers 230 * @twt_enable_cb: TWT enable completion callback 231 * @twt_disable_cb: TWT disable completion callback 232 * @twt_add_dialog_cb: TWT add dialog completion callback 233 * @twt_del_dialog_cb: TWT delete dialog completion callback 234 * @twt_pause_dialog_cb: TWT pause dialog completion callback 235 * @twt_resume_dialog_cb: TWT resume dialog completion callback 236 * @twt_notify_cb: TWT notify event callback 237 * @twt_nudge_dialog_cb: TWT nudge dialog completion callback 238 * @twt_ack_comp_cb: TWT ack completion callback 239 */ 240 struct twt_callbacks { 241 void (*twt_enable_cb)(hdd_handle_t hdd_handle, 242 struct wmi_twt_enable_complete_event_param *params); 243 void (*twt_disable_cb)(hdd_handle_t hdd_handle); 244 void (*twt_add_dialog_cb)(struct wlan_objmgr_psoc *psoc, 245 struct wma_twt_add_dialog_complete_event *add_dialog_event, 246 bool renego); 247 void (*twt_del_dialog_cb)(struct wlan_objmgr_psoc *psoc, 248 struct wmi_twt_del_dialog_complete_event_param *params); 249 void (*twt_pause_dialog_cb)(struct wlan_objmgr_psoc *psoc, 250 struct wmi_twt_pause_dialog_complete_event_param *params); 251 void (*twt_resume_dialog_cb)(struct wlan_objmgr_psoc *psoc, 252 struct wmi_twt_resume_dialog_complete_event_param *params); 253 void (*twt_notify_cb)(struct wlan_objmgr_psoc *psoc, 254 struct wmi_twt_notify_event_param *params); 255 void (*twt_nudge_dialog_cb)(struct wlan_objmgr_psoc *psoc, 256 struct wmi_twt_nudge_dialog_complete_event_param *params); 257 void (*twt_ack_comp_cb)(struct wmi_twt_ack_complete_event_param *params, 258 void *context); 259 }; 260 #endif 261 262 #ifdef FEATURE_WLAN_APF 263 /** 264 * typedef apf_get_offload_cb - APF offload callback signature 265 * @context: Opaque context that the client can use to associate the 266 * callback with the request 267 * @caps: APF offload capabilities as reported by firmware 268 */ 269 struct sir_apf_get_offload; 270 typedef void (*apf_get_offload_cb)(void *context, 271 struct sir_apf_get_offload *caps); 272 273 /** 274 * typedef apf_read_mem_cb - APF read memory response callback 275 * @context: Opaque context that the client can use to associate the 276 * callback with the request 277 * @evt: APF read memory response event parameters 278 */ 279 typedef void (*apf_read_mem_cb)(void *context, 280 struct wmi_apf_read_memory_resp_event_params 281 *evt); 282 #endif /* FEATURE_WLAN_APF */ 283 284 /** 285 * typedef rssi_threshold_breached_cb - RSSI threshold breach callback 286 * @hdd_handle: Opaque handle to the HDD context 287 * @event: The RSSI breach event 288 */ 289 typedef void (*rssi_threshold_breached_cb)(hdd_handle_t hdd_handle, 290 struct rssi_breach_event *event); 291 292 /** 293 * typedef get_chain_rssi_callback - get chain rssi callback 294 * @context: Opaque context that the client can use to associate the 295 * callback with the request 296 * @data: chain rssi result reported by firmware 297 */ 298 struct chain_rssi_result; 299 typedef void (*get_chain_rssi_callback)(void *context, 300 struct chain_rssi_result *data); 301 302 #ifdef FEATURE_FW_STATE 303 /** 304 * typedef fw_state_callback - get firmware state callback 305 * @context: Opaque context that the client can use to associate the 306 * callback with the request 307 */ 308 typedef void (*fw_state_callback)(void *context); 309 #endif /* FEATURE_FW_STATE */ 310 311 typedef void (*tx_queue_cb)(hdd_handle_t hdd_handle, uint32_t vdev_id, 312 enum netif_action_type action, 313 enum netif_reason_type reason); 314 315 /** 316 * typedef pwr_save_fail_cb - power save fail callback function 317 * @hdd_handle: HDD handle registered with SME 318 * @params: failure parameters 319 */ 320 struct chip_pwr_save_fail_detected_params; 321 typedef void (*pwr_save_fail_cb)(hdd_handle_t hdd_handle, 322 struct chip_pwr_save_fail_detected_params *params); 323 324 /** 325 * typedef bt_activity_info_cb - bluetooth activity callback function 326 * @hdd_handle: HDD handle registered with SME 327 * @bt_activity: bluetooth activity information 328 */ 329 typedef void (*bt_activity_info_cb)(hdd_handle_t hdd_handle, 330 uint32_t bt_activity); 331 332 /** 333 * typedef rso_cmd_status_cb - RSO command status callback function 334 * @hdd_handle: HDD handle registered with SME 335 * @rso_status: Status of the operation 336 */ 337 typedef void (*rso_cmd_status_cb)(hdd_handle_t hdd_handle, 338 struct rso_cmd_status *rso_status); 339 340 /** 341 * typedef lost_link_info_cb - lost link indication callback function 342 * @hdd_handle: HDD handle registered with SME 343 * @lost_link_info: Information about the lost link 344 */ 345 typedef void (*lost_link_info_cb)(hdd_handle_t hdd_handle, 346 struct sir_lost_link_info *lost_link_info); 347 /** 348 * typedef hidden_ssid_cb - hidden ssid rsp callback fun 349 * @hdd_handle: HDD handle registered with SME 350 * @vdev_id: Vdev Id 351 */ 352 typedef void (*hidden_ssid_cb)(hdd_handle_t hdd_handle, 353 uint8_t vdev_id); 354 355 /** 356 * typedef bcn_report_cb - recv bcn callback fun 357 * @hdd_handle: HDD handle registered with SME 358 * @beacon_report: Beacon report structure 359 */ 360 typedef QDF_STATUS (*beacon_report_cb) 361 (hdd_handle_t hdd_handle, struct wlan_beacon_report *beacon_report); 362 363 /** 364 * beacon_pause_cb : scan start callback fun 365 * @hdd_handler: HDD handler 366 * @vdev_id: vdev id 367 * @type: scan event type 368 * @is_disconnected: Driver is in dis connected state or not 369 */ 370 typedef void (*beacon_pause_cb)(hdd_handle_t hdd_handle, 371 uint8_t vdev_id, 372 enum scan_event_type type, 373 bool is_disconnected); 374 375 /** 376 * typedef sme_get_isolation_cb - get isolation callback fun 377 * @param: isolation result reported by firmware 378 * @pcontext: Opaque context that the client can use to associate the 379 * callback with the request 380 */ 381 typedef void (*sme_get_isolation_cb)(struct sir_isolation_resp *param, 382 void *pcontext); 383 384 #ifdef WLAN_FEATURE_MOTION_DETECTION 385 typedef QDF_STATUS (*md_host_evt_cb)(void *hdd_ctx, struct sir_md_evt *event); 386 typedef QDF_STATUS (*md_bl_evt_cb)(void *hdd_ctx, struct sir_md_bl_evt *event); 387 #endif /* WLAN_FEATURE_MOTION_DETECTION */ 388 389 struct sme_context { 390 eSmeState state; 391 qdf_mutex_t sme_global_lock; 392 uint32_t sme_cmd_count; 393 /* following pointer contains array of pointers for tSmeCmd* */ 394 void **sme_cmd_buf_addr; 395 tDblLinkList sme_cmd_freelist; /* preallocated roam cmd list */ 396 enum QDF_OPMODE curr_device_mode; 397 void *ll_stats_context; 398 link_layer_stats_cb link_layer_stats_cb; 399 void (*link_layer_stats_ext_cb)(hdd_handle_t callback_ctx, 400 tSirLLStatsResults *rsp); 401 #ifdef WLAN_POWER_DEBUG 402 void *power_debug_stats_context; 403 void (*power_stats_resp_callback)(struct power_stats_response *rsp, 404 void *callback_context); 405 void (*sme_power_debug_stats_callback)( 406 struct mac_context *mac, 407 struct power_stats_response *response); 408 #endif 409 #ifdef WLAN_FEATURE_BEACON_RECEPTION_STATS 410 void *beacon_stats_context; 411 void (*beacon_stats_resp_callback)(struct bcn_reception_stats_rsp *rsp, 412 void *callback_context); 413 #endif 414 #ifdef FEATURE_WLAN_AUTO_SHUTDOWN 415 void (*auto_shutdown_cb)(void); 416 #endif 417 /* Maximum interfaces allowed by the host */ 418 uint8_t max_intf_count; 419 stats_ext_cb stats_ext_cb; 420 stats_ext2_cb stats_ext2_cb; 421 /* linkspeed callback */ 422 sme_link_speed_cb link_speed_cb; 423 void *link_speed_context; 424 425 sme_get_isolation_cb get_isolation_cb; 426 void *get_isolation_cb_context; 427 #ifdef FEATURE_WLAN_EXTSCAN 428 ext_scan_ind_cb ext_scan_ind_cb; 429 #endif /* FEATURE_WLAN_EXTSCAN */ 430 csr_link_status_callback link_status_callback; 431 void *link_status_context; 432 int (*get_tsf_cb)(void *pcb_cxt, struct stsf *ptsf); 433 void *get_tsf_cxt; 434 /* get temperature event context and callback */ 435 void *temperature_cb_context; 436 void (*temperature_cb)(int temperature, void *context); 437 uint8_t miracast_value; 438 struct ps_global_info ps_global_info; 439 rssi_threshold_breached_cb rssi_threshold_breached_cb; 440 sme_set_thermal_level_callback set_thermal_level_cb; 441 void *apf_get_offload_context; 442 #ifdef FEATURE_P2P_LISTEN_OFFLOAD 443 p2p_lo_callback p2p_lo_event_callback; 444 void *p2p_lo_event_context; 445 #endif 446 #ifdef FEATURE_OEM_DATA_SUPPORT 447 sme_send_oem_data_rsp_msg oem_data_rsp_callback; 448 #endif 449 lost_link_info_cb lost_link_info_cb; 450 451 bool (*set_connection_info_cb)(bool); 452 bool (*get_connection_info_cb)(uint8_t *session_id, 453 enum scan_reject_states *reason); 454 rso_cmd_status_cb rso_cmd_status_cb; 455 pwr_save_fail_cb chip_power_save_fail_cb; 456 bt_activity_info_cb bt_activity_info_cb; 457 void *get_arp_stats_context; 458 void (*get_arp_stats_cb)(void *, struct rsp_stats *, void *); 459 get_chain_rssi_callback get_chain_rssi_cb; 460 void *get_chain_rssi_context; 461 #ifdef FEATURE_FW_STATE 462 fw_state_callback fw_state_cb; 463 void *fw_state_context; 464 #endif /* FEATURE_FW_STATE */ 465 tx_queue_cb tx_queue_cb; 466 #ifdef WLAN_SUPPORT_TWT 467 twt_enable_cb twt_enable_cb; 468 twt_disable_cb twt_disable_cb; 469 twt_add_dialog_cb twt_add_dialog_cb; 470 twt_del_dialog_cb twt_del_dialog_cb; 471 twt_pause_dialog_cb twt_pause_dialog_cb; 472 twt_nudge_dialog_cb twt_nudge_dialog_cb; 473 twt_resume_dialog_cb twt_resume_dialog_cb; 474 twt_notify_cb twt_notify_cb; 475 twt_ack_comp_cb twt_ack_comp_cb; 476 void *twt_ack_context_cb; 477 #endif 478 #ifdef FEATURE_WLAN_APF 479 apf_get_offload_cb apf_get_offload_cb; 480 apf_read_mem_cb apf_read_mem_cb; 481 #endif 482 #ifdef WLAN_FEATURE_MOTION_DETECTION 483 md_host_evt_cb md_host_evt_cb; 484 md_bl_evt_cb md_bl_evt_cb; 485 void *md_ctx; 486 #endif /* WLAN_FEATURE_MOTION_DETECTION */ 487 /* hidden ssid rsp callback */ 488 hidden_ssid_cb hidden_ssid_cb; 489 #ifdef WLAN_MWS_INFO_DEBUGFS 490 void *mws_coex_info_ctx; 491 void (*mws_coex_info_state_resp_callback)(void *coex_info_data, 492 void *context, 493 wmi_mws_coex_cmd_id cmd_id); 494 #endif /* WLAN_MWS_INFO_DEBUGFS */ 495 496 #ifdef WLAN_BCN_RECV_FEATURE 497 beacon_report_cb beacon_report_cb; 498 beacon_pause_cb beacon_pause_cb; 499 #endif 500 #ifdef FEATURE_OEM_DATA 501 void (*oem_data_event_handler_cb) 502 (const struct oem_data *oem_event_data, 503 uint8_t vdev_id); 504 uint8_t oem_data_vdev_id; 505 /* async oem event callback */ 506 void (*oem_data_async_event_handler_cb) 507 (const struct oem_data *oem_event_data); 508 #endif 509 510 #ifdef MULTI_CLIENT_LL_SUPPORT 511 void (*latency_level_event_handler_cb) 512 (const struct latency_level_data *event_data, 513 uint8_t vdev_id); 514 #endif 515 516 sme_get_raom_scan_ch_callback roam_scan_ch_callback; 517 void *roam_scan_ch_get_context; 518 #ifdef FEATURE_MONITOR_MODE_SUPPORT 519 void (*monitor_mode_cb)(uint8_t vdev_id); 520 #endif 521 #if defined(CLD_PM_QOS) && defined(WLAN_FEATURE_LL_MODE) 522 void (*beacon_latency_event_cb)(uint32_t latency_level); 523 #endif 524 #ifdef WLAN_FEATURE_ROAM_OFFLOAD 525 void (*roam_rt_stats_cb)(hdd_handle_t hdd_handle, uint8_t idx, 526 struct roam_stats_event *roam_stats); 527 #endif 528 }; 529 530 #endif /* #if !defined( __SMEINTERNAL_H ) */ 531