xref: /wlan-driver/qcacld-3.0/core/sme/inc/sme_internal.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2011-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2024 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 	e_sme_command_sap_ch_width_update,
66 } eSmeCommandType;
67 
68 typedef enum eSmeState {
69 	SME_STATE_STOP,
70 	SME_STATE_START,
71 	SME_STATE_READY,
72 } eSmeState;
73 
74 #define SME_IS_START(mac)  (SME_STATE_STOP != (mac)->sme.state)
75 #define SME_IS_READY(mac)  (SME_STATE_READY == (mac)->sme.state)
76 
77 /**
78  * struct stats_ext_event - stats_ext_event payload
79  * @vdev_id: ID of the vdev for the stats
80  * @event_data_len: length of the @event_data
81  * @event_data: actual ext stats
82  */
83 struct stats_ext_event {
84 	uint32_t vdev_id;
85 	uint32_t event_data_len;
86 	uint8_t event_data[];
87 };
88 
89 /**
90  * typedef stats_ext_cb - stats ext callback
91  * @hdd_handle: Opaque handle to the HDD context
92  * @data: stats ext payload from firmware
93  */
94 typedef void (*stats_ext_cb)(hdd_handle_t hdd_handle,
95 			     struct stats_ext_event *data);
96 
97 /**
98  * typedef stats_ext2_cb - stats ext2 callback
99  * @hdd_handle: Opaque handle to the HDD context
100  * @data: stats ext2 payload from firmware
101  */
102 typedef void (*stats_ext2_cb)(hdd_handle_t hdd_handle,
103 			      struct sir_sme_rx_aggr_hole_ind *data);
104 
105 #define MAX_ACTIVE_CMD_STATS    16
106 
107 typedef struct sActiveCmdStats {
108 	eSmeCommandType command;
109 	uint32_t reason;
110 	uint32_t sessionId;
111 	uint64_t timestamp;
112 } tActiveCmdStats;
113 
114 typedef struct sSelfRecoveryStats {
115 	tActiveCmdStats activeCmdStats[MAX_ACTIVE_CMD_STATS];
116 	uint8_t cmdStatsIndx;
117 } tSelfRecoveryStats;
118 
119 typedef void (*link_layer_stats_cb)(hdd_handle_t hdd_handle,
120 				    int indication_type,
121 				    tSirLLStatsResults *results,
122 				    void *cookie);
123 
124 typedef void (*ext_scan_ind_cb)(hdd_handle_t hdd_handle,
125 				const uint16_t, void *);
126 
127 /**
128  * typedef sme_link_speed_cb - sme_get_link_speed() callback function
129  * @info: link speed information
130  * @context: user context supplied to sme_get_link_speed()
131  *
132  * This is the signature of a callback function whose addresses is
133  * passed as the asynchronous callback function to sme_get_link_speed().
134  */
135 
136 typedef void (*sme_link_speed_cb)(struct link_speed_info *info,
137 				  void *context);
138 
139 typedef void (*ocb_callback)(void *context, void *response);
140 typedef void (*sme_set_thermal_level_callback)(hdd_handle_t hdd_handle,
141 					       u_int8_t level);
142 typedef void (*p2p_lo_callback)(void *context,
143 				struct sir_p2p_lo_event *event);
144 #ifdef FEATURE_OEM_DATA_SUPPORT
145 typedef void (*sme_send_oem_data_rsp_msg)(struct oem_data_rsp *);
146 #endif
147 
148 #ifdef WLAN_SUPPORT_TWT
149 /**
150  * typedef twt_enable_cb - TWT enable callback signature.
151  * @hdd_handle: Opaque HDD handle
152  * @params: TWT enable complete event parameters.
153  */
154 typedef
155 void (*twt_enable_cb)(hdd_handle_t hdd_handle,
156 		      struct wmi_twt_enable_complete_event_param *params);
157 
158 /**
159  * typedef twt_disable_cb - TWT enable callback signature.
160  * @hdd_handle: Opaque HDD handle
161  */
162 typedef void (*twt_disable_cb)(hdd_handle_t hdd_handle);
163 
164 /**
165  * typedef twt_add_dialog_cb - TWT add dialog callback signature.
166  * @psoc: Pointer to global psoc
167  * @add_dialog_evt: pointer to event buf containing twt response parameters
168  * @renego_fail: Flag to indicate if its re-negotiation failure case
169  */
170 typedef
171 void (*twt_add_dialog_cb)(struct wlan_objmgr_psoc *psoc,
172 			  struct wma_twt_add_dialog_complete_event *add_dialog_evt,
173 			  bool renego_fail);
174 
175 /**
176  * typedef twt_del_dialog_cb - TWT delete dialog callback signature.
177  * @psoc: Pointer to global psoc
178  * @params: TWT delete dialog complete event parameters.
179  */
180 typedef void (*twt_del_dialog_cb)(
181 	struct wlan_objmgr_psoc *psoc,
182 	struct wmi_twt_del_dialog_complete_event_param *params);
183 
184 /**
185  * typedef twt_pause_dialog_cb - TWT pause dialog callback signature.
186  * @psoc: Pointer to global psoc
187  * @params: TWT pause dialog complete event parameters.
188  */
189 typedef
190 void (*twt_pause_dialog_cb)(struct wlan_objmgr_psoc *psoc,
191 			    struct wmi_twt_pause_dialog_complete_event_param *params);
192 
193 /**
194  * typedef twt_nudge_dialog_cb - TWT nudge dialog callback signature.
195  * @psoc: Pointer to global psoc
196  * @params: TWT nudge dialog complete event parameters.
197  */
198 typedef
199 void (*twt_nudge_dialog_cb)(struct wlan_objmgr_psoc *psoc,
200 		      struct wmi_twt_nudge_dialog_complete_event_param *params);
201 
202 /**
203  * typedef twt_resume_dialog_cb - TWT resume dialog callback signature.
204  * @psoc: Pointer to global psoc
205  * @params: TWT resume dialog complete event parameters.
206  */
207 typedef
208 void (*twt_resume_dialog_cb)(struct wlan_objmgr_psoc *psoc,
209 			     struct wmi_twt_resume_dialog_complete_event_param *params);
210 
211 /**
212  * typedef twt_notify_cb - TWT notify callback signature.
213  * @psoc: Pointer to global psoc
214  * @params: TWT twt notify event parameters.
215  */
216 typedef
217 void (*twt_notify_cb)(struct wlan_objmgr_psoc *psoc,
218 		      struct wmi_twt_notify_event_param *params);
219 
220 /**
221  * typedef twt_ack_comp_cb - TWT ack callback signature.
222  * @params: TWT ack complete event parameters.
223  * @context: TWT context
224  */
225 typedef
226 void (*twt_ack_comp_cb)(struct wmi_twt_ack_complete_event_param *params,
227 			void *context);
228 
229 /**
230  * struct twt_callbacks - TWT response callback pointers
231  * @twt_enable_cb: TWT enable completion callback
232  * @twt_disable_cb: TWT disable completion callback
233  * @twt_add_dialog_cb: TWT add dialog completion callback
234  * @twt_del_dialog_cb: TWT delete dialog completion callback
235  * @twt_pause_dialog_cb: TWT pause dialog completion callback
236  * @twt_resume_dialog_cb: TWT resume dialog completion callback
237  * @twt_notify_cb: TWT notify event callback
238  * @twt_nudge_dialog_cb: TWT nudge dialog completion callback
239  * @twt_ack_comp_cb: TWT ack completion callback
240  */
241 struct twt_callbacks {
242 	void (*twt_enable_cb)(hdd_handle_t hdd_handle,
243 			      struct wmi_twt_enable_complete_event_param *params);
244 	void (*twt_disable_cb)(hdd_handle_t hdd_handle);
245 	void (*twt_add_dialog_cb)(struct wlan_objmgr_psoc *psoc,
246 				  struct wma_twt_add_dialog_complete_event *add_dialog_event,
247 				  bool renego);
248 	void (*twt_del_dialog_cb)(struct wlan_objmgr_psoc *psoc,
249 				  struct wmi_twt_del_dialog_complete_event_param *params);
250 	void (*twt_pause_dialog_cb)(struct wlan_objmgr_psoc *psoc,
251 				    struct wmi_twt_pause_dialog_complete_event_param *params);
252 	void (*twt_resume_dialog_cb)(struct wlan_objmgr_psoc *psoc,
253 				     struct wmi_twt_resume_dialog_complete_event_param *params);
254 	void (*twt_notify_cb)(struct wlan_objmgr_psoc *psoc,
255 			      struct wmi_twt_notify_event_param *params);
256 	void (*twt_nudge_dialog_cb)(struct wlan_objmgr_psoc *psoc,
257 		    struct wmi_twt_nudge_dialog_complete_event_param *params);
258 	void (*twt_ack_comp_cb)(struct wmi_twt_ack_complete_event_param *params,
259 				void *context);
260 };
261 #endif
262 
263 #ifdef FEATURE_WLAN_APF
264 /**
265  * typedef apf_get_offload_cb - APF offload callback signature
266  * @context: Opaque context that the client can use to associate the
267  *    callback with the request
268  * @caps: APF offload capabilities as reported by firmware
269  */
270 struct sir_apf_get_offload;
271 typedef void (*apf_get_offload_cb)(void *context,
272 				   struct sir_apf_get_offload *caps);
273 
274 /**
275  * typedef apf_read_mem_cb - APF read memory response callback
276  * @context: Opaque context that the client can use to associate the
277  *    callback with the request
278  * @evt: APF read memory response event parameters
279  */
280 typedef void (*apf_read_mem_cb)(void *context,
281 				struct wmi_apf_read_memory_resp_event_params
282 									  *evt);
283 #endif /* FEATURE_WLAN_APF */
284 
285 /**
286  * typedef rssi_threshold_breached_cb - RSSI threshold breach callback
287  * @hdd_handle: Opaque handle to the HDD context
288  * @event: The RSSI breach event
289  */
290 typedef void (*rssi_threshold_breached_cb)(hdd_handle_t hdd_handle,
291 					   struct rssi_breach_event *event);
292 
293 /**
294  * typedef get_chain_rssi_callback - get chain rssi callback
295  * @context: Opaque context that the client can use to associate the
296  *    callback with the request
297  * @data: chain rssi result reported by firmware
298  */
299 struct chain_rssi_result;
300 typedef void (*get_chain_rssi_callback)(void *context,
301 					struct chain_rssi_result *data);
302 
303 #ifdef FEATURE_FW_STATE
304 /**
305  * typedef fw_state_callback - get firmware state callback
306  * @context: Opaque context that the client can use to associate the
307  *    callback with the request
308  */
309 typedef void (*fw_state_callback)(void *context);
310 #endif /* FEATURE_FW_STATE */
311 
312 typedef void (*tx_queue_cb)(hdd_handle_t hdd_handle, uint32_t vdev_id,
313 			    enum netif_action_type action,
314 			    enum netif_reason_type reason);
315 
316 /**
317  * typedef pwr_save_fail_cb - power save fail callback function
318  * @hdd_handle: HDD handle registered with SME
319  * @params: failure parameters
320  */
321 struct chip_pwr_save_fail_detected_params;
322 typedef void (*pwr_save_fail_cb)(hdd_handle_t hdd_handle,
323 			struct chip_pwr_save_fail_detected_params *params);
324 
325 /**
326  * typedef bt_activity_info_cb - bluetooth activity callback function
327  * @hdd_handle: HDD handle registered with SME
328  * @bt_activity: bluetooth activity information
329  */
330 typedef void (*bt_activity_info_cb)(hdd_handle_t hdd_handle,
331 				    uint32_t bt_activity);
332 
333 /**
334  * typedef rso_cmd_status_cb - RSO command status  callback function
335  * @hdd_handle: HDD handle registered with SME
336  * @rso_status: Status of the operation
337  */
338 typedef void (*rso_cmd_status_cb)(hdd_handle_t hdd_handle,
339 				  struct rso_cmd_status *rso_status);
340 
341 /**
342  * typedef lost_link_info_cb - lost link indication callback function
343  * @hdd_handle: HDD handle registered with SME
344  * @lost_link_info: Information about the lost link
345  */
346 typedef void (*lost_link_info_cb)(hdd_handle_t hdd_handle,
347 				  struct sir_lost_link_info *lost_link_info);
348 /**
349  * typedef hidden_ssid_cb - hidden ssid rsp callback fun
350  * @hdd_handle: HDD handle registered with SME
351  * @vdev_id: Vdev Id
352  */
353 typedef void (*hidden_ssid_cb)(hdd_handle_t hdd_handle,
354 				uint8_t vdev_id);
355 
356 /**
357  * typedef bcn_report_cb - recv bcn callback fun
358  * @hdd_handle: HDD handle registered with SME
359  * @beacon_report: Beacon report structure
360  */
361 typedef QDF_STATUS (*beacon_report_cb)
362 	(hdd_handle_t hdd_handle, struct wlan_beacon_report *beacon_report);
363 
364 /**
365  * beacon_pause_cb : scan start callback fun
366  * @hdd_handler: HDD handler
367  * @vdev_id: vdev id
368  * @type: scan event type
369  * @is_disconnected: Driver is in dis connected state or not
370  */
371 typedef void (*beacon_pause_cb)(hdd_handle_t hdd_handle,
372 				uint8_t vdev_id,
373 				enum scan_event_type type,
374 				bool is_disconnected);
375 
376 /**
377  * typedef sme_get_isolation_cb - get isolation callback fun
378  * @param: isolation result reported by firmware
379  * @pcontext: Opaque context that the client can use to associate the
380  *    callback with the request
381  */
382 typedef void (*sme_get_isolation_cb)(struct sir_isolation_resp *param,
383 				     void *pcontext);
384 
385 #ifdef WLAN_FEATURE_MOTION_DETECTION
386 typedef QDF_STATUS (*md_host_evt_cb)(void *hdd_ctx, struct sir_md_evt *event);
387 typedef QDF_STATUS (*md_bl_evt_cb)(void *hdd_ctx, struct sir_md_bl_evt *event);
388 #endif /* WLAN_FEATURE_MOTION_DETECTION */
389 
390 struct sme_context {
391 	eSmeState state;
392 	qdf_mutex_t sme_global_lock;
393 	uint32_t sme_cmd_count;
394 	/* following pointer contains array of pointers for tSmeCmd* */
395 	void **sme_cmd_buf_addr;
396 	tDblLinkList sme_cmd_freelist;    /* preallocated roam cmd list */
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 	QDF_STATUS (*pagefault_action_cb)(void *buf, uint32_t data);
511 
512 #ifdef MULTI_CLIENT_LL_SUPPORT
513 	void (*latency_level_event_handler_cb)
514 			(const struct latency_level_data *event_data,
515 			 uint8_t vdev_id);
516 #endif
517 
518 	sme_get_raom_scan_ch_callback roam_scan_ch_callback;
519 	void *roam_scan_ch_get_context;
520 #ifdef FEATURE_MONITOR_MODE_SUPPORT
521 	void (*monitor_mode_cb)(uint8_t vdev_id);
522 #endif
523 #if defined(CLD_PM_QOS) && defined(WLAN_FEATURE_LL_MODE)
524 	void (*beacon_latency_event_cb)(uint32_t latency_level);
525 #endif
526 	QDF_STATUS (*sme_vdev_del_cb)(mac_handle_t mac_handle,
527 				      struct wlan_objmgr_vdev *vdev);
528 };
529 
530 #endif /* #if !defined( __SMEINTERNAL_H ) */
531