xref: /wlan-dirver/qca-wifi-host-cmn/umac/cmn_services/serialization/inc/wlan_serialization_api.h (revision 302a1d9701784af5f4797b1a9fe07ae820b51907) !
1 /*
2  * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /**
20  * DOC: wlan_serialization_api.h
21  * This file provides prototypes of the routines needed for the
22  * external components to utilize the services provided by the
23  * serialization component.
24  */
25 
26 /* Include files */
27 #ifndef __WLAN_SERIALIZATION_API_H
28 #define __WLAN_SERIALIZATION_API_H
29 
30 #ifdef CONFIG_SERIALIZATION_V1
31 #include "qdf_status.h"
32 #include "wlan_objmgr_cmn.h"
33 
34 /* Preprocessor Definitions and Constants */
35 
36 /*
37  * struct wlan_serialization_queued_cmd_info member queue_type specifies the
38  * below values to cancel the commands in these queues. Setting both the
39  * bits will cancel the commands in both the queues.
40  */
41 #define WLAN_SERIALIZATION_ACTIVE_QUEUE  0x1
42 #define WLAN_SERIALIZATION_PENDING_QUEUE 0x2
43 
44 /**
45  * enum wlan_serialization_cb_reason - reason for calling the callback
46  * @WLAN_SERIALIZATION_REASON_ACTIVATE_CMD: activate the cmd by sending it to FW
47  * @WLAN_SERIALIZATION_REASON_CANCEL_CMD: Cancel the cmd in the pending list
48  * @WLAN_SERIALIZATION_REASON_RELEASE_MEM_CMD:cmd execution complete. Release
49  *                                           the memory allocated while
50  *                                           building the command
51  * @WLAN_SER_CB_ACTIVE_CMD_TIMEOUT: active cmd has been timeout.
52  */
53 enum wlan_serialization_cb_reason {
54 	WLAN_SER_CB_ACTIVATE_CMD,
55 	WLAN_SER_CB_CANCEL_CMD,
56 	WLAN_SER_CB_RELEASE_MEM_CMD,
57 	WLAN_SER_CB_ACTIVE_CMD_TIMEOUT,
58 };
59 
60 /**
61  * struct wlan_serialization_scan_info - Information needed for scan cmd
62  * @is_cac_in_progress: boolean to check the cac status
63  * @is_tdls_in_progress: boolean to check the tdls status
64  *
65  * This information is needed for scan command from other components
66  * to apply the rules and check whether the cmd is allowed or not
67  */
68 struct wlan_serialization_scan_info {
69 	bool is_cac_in_progress;
70 	bool is_tdls_in_progress;
71 };
72 
73 /**
74  * union wlan_serialization_rules_info - union of all rules info structures
75  * @scan_info: information needed to apply rules on scan command
76  */
77 union wlan_serialization_rules_info {
78 	struct wlan_serialization_scan_info scan_info;
79 };
80 
81 /**
82  * wlan_serialization_cmd_callback() - Callback registered by the component
83  * @wlan_cmd: Command passed by the component for serialization
84  * @reason: Reason code for which the callback is being called
85  *
86  * Reason specifies the reason for which the callback is being called. callback
87  * should return success or failure based up on overall success of callback.
88  * if callback returns failure then serialization will remove the command from
89  * active queue and proceed for next pending command.
90  *
91  * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE
92  */
93 typedef QDF_STATUS (*wlan_serialization_cmd_callback) (void *wlan_cmd,
94 				 enum wlan_serialization_cb_reason reason);
95 
96 /**
97  * wlan_serialization_comp_info_cb() - callback to fill the rules information
98  * @vdev: VDEV object for which the command has been received
99  * @comp_info: Information filled by the component
100  *
101  * This callback is registered dynamically by the component with the
102  * serialization component. Serialization component invokes the callback
103  * while applying the rules for a particular command and the component
104  * fills in the required information to apply the rules
105  *
106  * Return: None
107  */
108 typedef void (*wlan_serialization_comp_info_cb)(struct wlan_objmgr_vdev *vdev,
109 		union wlan_serialization_rules_info *comp_info);
110 
111 /**
112  * wlan_serialization_apply_rules_cb() - callback per command to apply rules
113  * @comp_info: information needed to apply the rules
114  *
115  * The rules are applied using this callback and decided whether to
116  * allow or deny the command
117  *
118  * Return: true, if rules are successful and cmd can be queued
119  *         false, if rules failed and cmd should not be queued
120  */
121 typedef bool (*wlan_serialization_apply_rules_cb)(
122 		union wlan_serialization_rules_info *comp_info,
123 		uint8_t comp_id);
124 
125 /**
126  * enum wlan_umac_cmd_id - Command Type
127  * @WLAN_SER_CMD_SCAN:     Scan command
128  */
129 enum wlan_serialization_cmd_type {
130 	/* all scan command before non-scan */
131 	WLAN_SER_CMD_SCAN,
132 	/* all non-scan command below */
133 	WLAN_SER_CMD_NONSCAN,
134 	WLAN_SER_CMD_FORCE_DISASSOC,
135 	WLAN_SER_CMD_HDD_ISSUED,
136 	WLAN_SER_CMD_LOST_LINK1,
137 	WLAN_SER_CMD_LOST_LINK2,
138 	WLAN_SER_CMD_LOST_LINK3,
139 	WLAN_SER_CMD_FORCE_DISASSOC_MIC_FAIL,
140 	WLAN_SER_CMD_HDD_ISSUE_REASSOC_SAME_AP,
141 	WLAN_SER_CMD_SME_ISSUE_REASSOC_SAME_AP,
142 	WLAN_SER_CMD_FORCE_DEAUTH,
143 	WLAN_SER_CMD_SME_ISSUE_DISASSOC_FOR_HANDOFF,
144 	WLAN_SER_CMD_SME_ISSUE_ASSOC_TO_SIMILAR_AP,
145 	WLAN_SER_CMD_SME_ISSUE_IBSS_JOIN_FAIL,
146 	WLAN_SER_CMD_FORCE_IBSS_LEAVE,
147 	WLAN_SER_CMD_STOP_BSS,
148 	WLAN_SER_CMD_SME_ISSUE_FT_REASSOC,
149 	WLAN_SER_CMD_FORCE_DISASSOC_STA,
150 	WLAN_SER_CMD_FORCE_DEAUTH_STA,
151 	WLAN_SER_CMD_PERFORM_PRE_AUTH,
152 	WLAN_SER_CMD_WM_STATUS_CHANGE,
153 	WLAN_SER_CMD_SET_KEY,
154 	WLAN_SER_CMD_NDP_INIT_REQ,
155 	WLAN_SER_CMD_NDP_RESP_REQ,
156 	WLAN_SER_CMD_NDP_DATA_END_INIT_REQ,
157 	WLAN_SER_CMD_ADDTS,
158 	WLAN_SER_CMD_DELTS,
159 	WLAN_SER_CMD_TDLS_SEND_MGMT,
160 	WLAN_SER_CMD_TDLS_ADD_PEER,
161 	WLAN_SER_CMD_TDLS_DEL_PEER,
162 	WLAN_SER_CMD_TDLS_LINK_EST,
163 	WLAN_SER_CMD_SET_HW_MODE,
164 	WLAN_SER_CMD_NSS_UPDATE,
165 	WLAN_SER_CMD_SET_DUAL_MAC_CONFIG,
166 	WLAN_SER_CMD_SET_ANTENNA_MODE,
167 	WLAN_SER_CMD_ENTER_BMPS,
168 	WLAN_SER_CMD_EXIT_BMPS,
169 	WLAN_SER_CMD_ENTER_UAPSD,
170 	WLAN_SER_CMD_EXIT_UAPSD,
171 	WLAN_SER_CMD_EXIT_WOWL,
172 	WLAN_SER_CMD_DEL_STA_SESSION,
173 	WLAN_SER_CMD_MAX
174 };
175 
176 /**
177  * enum wlan_serialization_cancel_type - Type of commands to be cancelled
178  * @WLAN_SER_CANCEL_SINGLE_SCAN: Cancel a single scan with a given ID
179  * @WLAN_SER_CANCEL_PDEV_SCANS: Cancel all the scans on a given pdev
180  * @WLAN_SER_CANCEL_VDEV_SCANS: Cancel all the scans on given vdev
181  * @WLAN_SER_CANCEL_NON_SCAN_CMD: Cancel the given non scan command
182  */
183 enum wlan_serialization_cancel_type {
184 	WLAN_SER_CANCEL_SINGLE_SCAN,
185 	WLAN_SER_CANCEL_PDEV_SCANS,
186 	WLAN_SER_CANCEL_VDEV_SCANS,
187 	WLAN_SER_CANCEL_NON_SCAN_CMD,
188 	WLAN_SER_CANCEL_MAX,
189 };
190 
191 /**
192  * enum wlan_serialization_status - Return status of cmd serialization request
193  * @WLAN_SER_CMD_PENDING: Command is put into the pending queue
194  * @WLAN_SER_CMD_ACTIVE: Command is activated and put in active queue
195  * @WLAN_SER_CMD_DENIED_RULES_FAILED: Command denied as the rules fail
196  * @WLAN_SER_CMD_DENIED_LIST_FULL: Command denied as the pending list is full
197  * @WLAN_SER_CMD_DENIED_UNSPECIFIED: Command denied due to unknown reason
198  */
199 enum wlan_serialization_status {
200 	WLAN_SER_CMD_PENDING,
201 	WLAN_SER_CMD_ACTIVE,
202 	WLAN_SER_CMD_DENIED_RULES_FAILED,
203 	WLAN_SER_CMD_DENIED_LIST_FULL,
204 	WLAN_SER_CMD_DENIED_UNSPECIFIED,
205 };
206 
207 /**
208  * enum wlan_serialization_cmd_status - Return status for a cancel request
209  * @WLAN_SER_CMD_IN_PENDING_LIST: Command cancelled from pending list
210  * @WLAN_SER_CMD_IN_ACTIVE_LIST: Command cancelled from active list
211  * @WLAN_SER_CMDS_IN_ALL_LISTS: Command cancelled from all lists
212  * @WLAN_SER_CMD_NOT_FOUND: Specified command to be cancelled
213  *                                    not found in the lists
214  */
215 enum wlan_serialization_cmd_status {
216 	WLAN_SER_CMD_IN_PENDING_LIST,
217 	WLAN_SER_CMD_IN_ACTIVE_LIST,
218 	WLAN_SER_CMDS_IN_ALL_LISTS,
219 	WLAN_SER_CMD_NOT_FOUND,
220 };
221 
222 /**
223  * struct wlan_serialization_command - Command to be serialized
224  * @wlan_serialization_cmd_type: Type of command
225  * @cmd_id: Command Identifier
226  * @cmd_cb: Command callback
227  * @source: component ID of the source of the command
228  * @is_high_priority: Normal/High Priority at which the cmd has to be queued
229  * @cmd_timeout_cb: Command timeout callback
230  * @cmd_timeout_duration: Timeout duration in milliseconds
231  * @vdev: VDEV object associated to the command
232  * @umac_cmd: Actual command that needs to be sent to WMI/firmware
233  *
234  * Note: Unnamed union has been used in this structure, so that in future if
235  * somebody wants to add pdev or psoc structure then that person can add without
236  * modifying existing code.
237  */
238 struct wlan_serialization_command {
239 	enum wlan_serialization_cmd_type cmd_type;
240 	uint32_t cmd_id;
241 	wlan_serialization_cmd_callback cmd_cb;
242 	enum wlan_umac_comp_id source;
243 	bool is_high_priority;
244 	uint16_t cmd_timeout_duration;
245 	union {
246 		struct wlan_objmgr_vdev *vdev;
247 	};
248 	void *umac_cmd;
249 };
250 
251 /**
252  * struct wlan_serialization_queued_cmd_info  - cmd that has to be cancelled
253  * @requestor: component ID of the source requesting this action
254  * @cmd_type: Command type
255  * @cmd_id: Command ID
256  * @req_type: Commands that need to be cancelled
257  * @vdev: VDEV object associated to the command
258  * @queue_type: Queues from which the command to be cancelled
259  */
260 struct wlan_serialization_queued_cmd_info {
261 	enum wlan_umac_comp_id requestor;
262 	enum wlan_serialization_cmd_type cmd_type;
263 	uint32_t cmd_id;
264 	enum wlan_serialization_cancel_type req_type;
265 	union {
266 		struct wlan_objmgr_vdev *vdev;
267 	};
268 	uint8_t queue_type;
269 };
270 
271 /**
272  * wlan_serialization_cancel_request() - Request to cancel a command
273  * @req: Request information
274  *
275  * This API is used by external components to cancel a command
276  * that is either in the pending or active queue. Based on the
277  * req_type, it is decided whether to use pdev or vdev
278  * object. For all non-scan commands, it will be pdev.
279  *
280  * Return: Status specifying the removal of a command from a certain queue
281  */
282 enum wlan_serialization_cmd_status
283 wlan_serialization_cancel_request(
284 		struct wlan_serialization_queued_cmd_info *req);
285 
286 /**
287  * wlan_serialization_remove_cmd() - Request to release a command
288  * @cmd: Command information
289  *
290  * This API is used to release a command sitting in the active
291  * queue upon successful completion of the command
292  *
293  * Return: None
294  */
295 void wlan_serialization_remove_cmd(
296 		struct wlan_serialization_queued_cmd_info *cmd);
297 
298 /**
299  * wlan_serialization_flush_cmd() - Request to flush command
300  * @cmd: Command information
301  *
302  * This API is used to flush a cmd sitting in the queue. It
303  * simply flushes the cmd from the queue and does not call
304  * any callbacks in between. If the request is for active
305  * queue, and if the active queue becomes empty upon flush,
306  * then it will pick the next pending cmd and put in the active
307  * queue before returning.
308  *
309  * Return: None
310  */
311 void wlan_serialization_flush_cmd(
312 		struct wlan_serialization_queued_cmd_info *cmd);
313 /**
314  * wlan_serialization_request() - Request to serialize a command
315  * @cmd: Command information
316  *
317  * Return: Status of the serialization request
318  */
319 enum wlan_serialization_status
320 wlan_serialization_request(struct wlan_serialization_command *cmd);
321 
322 /**
323  * wlan_serialization_register_comp_info_cb() - Register component's info
324  * 						callback
325  * @psoc: PSOC object information
326  * @comp_id: Component ID
327  * @cmd_type: Command Type
328  * @cb: Callback
329  *
330  * This is called from component during its initialization.It initializes
331  * callback handler for given comp_id/cmd_id in a 2-D array.
332  *
333  * Return: QDF Status
334  */
335 QDF_STATUS
336 wlan_serialization_register_comp_info_cb(struct wlan_objmgr_psoc *psoc,
337 		enum wlan_umac_comp_id comp_id,
338 		enum wlan_serialization_cmd_type cmd_type,
339 		wlan_serialization_comp_info_cb cb);
340 
341 /**
342  * wlan_serialization_deregister_comp_info_cb() - Deregister component's info
343  *						callback
344  * @psoc: PSOC object information
345  * @comp_id: Component ID
346  * @cmd_type: Command Type
347  *
348  * This routine is called from other component during its de-initialization.
349  *
350  * Return: QDF Status
351  */
352 QDF_STATUS
353 wlan_serialization_deregister_comp_info_cb(struct wlan_objmgr_psoc *psoc,
354 		enum wlan_umac_comp_id comp_id,
355 		enum wlan_serialization_cmd_type cmd_type);
356 
357 /**
358  * wlan_serialization_register_apply_rules_cb() - Register component's rules
359  *						callback
360  * @psoc: PSOC object information
361  * @cmd_type: Command Type
362  * @cb: Callback
363  *
364  * This is called from component during its initialization.It initializes
365  * callback handler for given cmd_type in a 1-D array.
366  *
367  * Return: QDF Status
368  */
369 QDF_STATUS
370 wlan_serialization_register_apply_rules_cb(struct wlan_objmgr_psoc *psoc,
371 		enum wlan_serialization_cmd_type cmd_type,
372 		wlan_serialization_apply_rules_cb apply_rules_cb);
373 
374 /**
375  * wlan_serialization_deregister_apply_rules_cb() - Deregister component's rules
376  *						callback
377  * @psoc: PSOC object information
378  * @cmd_type: Command Type
379  *
380  * This routine is called from other component during its de-initialization.
381  *
382  * Return: QDF Status
383  */
384 QDF_STATUS
385 wlan_serialization_deregister_apply_rules_cb(struct wlan_objmgr_psoc *psoc,
386 		enum wlan_serialization_cmd_type cmd_type);
387 
388 /**
389  * @wlan_serialization_init() - Serialization component initialization routine
390  *
391  * Return - QDF Status
392  */
393 QDF_STATUS wlan_serialization_init(void);
394 
395 /**
396  * @wlan_serialization_deinit() - Serialization component de-init routine
397  *
398  * Return - QDF Status
399  */
400 QDF_STATUS wlan_serialization_deinit(void);
401 
402 /**
403  * @wlan_serialization_psoc_open() - Serialization component open routine
404  *
405  * Return - QDF Status
406  */
407 QDF_STATUS wlan_serialization_psoc_open(struct wlan_objmgr_psoc *psoc);
408 
409 /**
410  * @wlan_serialization_psoc_close() - Serialization component close routine
411  *
412  * Return - QDF Status
413  */
414 QDF_STATUS wlan_serialization_psoc_close(struct wlan_objmgr_psoc *psoc);
415 
416 /**
417  * wlan_serialization_vdev_scan_status() - Return the status of the vdev scan
418  * @vdev: VDEV Object
419  *
420  * Return: Status of the scans for the corresponding vdev
421  */
422 enum wlan_serialization_cmd_status
423 wlan_serialization_vdev_scan_status(struct wlan_objmgr_vdev *vdev);
424 
425 /**
426  * wlan_serialization_pdev_scan_status() - Return the status of the pdev scan
427  * @pdev: PDEV Object
428  *
429  * Return: Status of the scans for the corresponding pdev
430  */
431 enum wlan_serialization_cmd_status
432 wlan_serialization_pdev_scan_status(struct wlan_objmgr_pdev *pdev);
433 
434 /**
435  * wlan_serialization_non_scan_cmd_status() - Return status of pdev non-scan cmd
436  * @pdev: PDEV Object
437  * @cmd_id: ID of the command for which the status has to be checked
438  *
439  * Return: Status of the command for the corresponding pdev
440  */
441 enum wlan_serialization_cmd_status
442 wlan_serialization_non_scan_cmd_status(struct wlan_objmgr_pdev *pdev,
443 		enum wlan_serialization_cmd_type cmd_id);
444 
445 /**
446  * wlan_serialization_is_cmd_present_in_pending_queue() - Return if the command
447  *				is already present in pending queue
448  * @cmd: pointer to serialization command to check
449  *
450  * This API will check if command is present in pending queue. If present
451  * then return true, so use know that it is duplicated command
452  *
453  * Return: true or false
454  */
455 bool wlan_serialization_is_cmd_present_in_pending_queue(
456 		struct wlan_objmgr_psoc *psoc,
457 		struct wlan_serialization_command *cmd);
458 /**
459  * wlan_serialization_is_cmd_present_in_active_queue() - Return if the command
460  *			is already present in active queue
461  * @cmd: pointer to serialization command to check
462  *
463  * This API will check if command is present in active queue. If present
464  * then return true, so use know that it is duplicated command
465  *
466  * Return: true or false
467  */
468 bool wlan_serialization_is_cmd_present_in_active_queue(
469 		struct wlan_objmgr_psoc *psoc,
470 		struct wlan_serialization_command *cmd);
471 
472 /**
473  * wlan_serialization_get_scan_cmd_using_scan_id() - Return command which
474  *					matches vdev_id and scan_id
475  * @psoc: pointer to soc
476  * @vdev_id: vdev id to pull vdev object
477  * @scan_id: scan id to match
478  * @is_scan_cmd_from_active_queue: to indicate active or pending queue
479  *
480  * This API fetches vdev/pdev object based on vdev_id, loops through scan
481  * command queue and find the command which matches scan id as well as vdev
482  * object.
483  *
484  * Return: pointer to serialization command
485  */
486 struct wlan_serialization_command*
487 wlan_serialization_get_scan_cmd_using_scan_id(
488 		struct wlan_objmgr_psoc *psoc,
489 		uint8_t vdev_id, uint16_t scan_id,
490 		uint8_t is_scan_cmd_from_active_queue);
491 /**
492  * wlan_serialization_get_active_cmd() - Return active umac command which
493  *  matches vdev and cmd type
494  * @psoc: pointer to soc
495  * @vdev_id: vdev id to pull vdev object
496  * @cmd_type: cmd type to match
497  *
498  * This API fetches vdev/pdev object based on vdev_id, loops through active
499  * command queue and find the active command which matches cmd_type as well
500  * as vdev object.
501  *
502  * Return: Pointer to umac command. NULL is returned if active command of given
503  *  type is not found.
504  */
505 void *wlan_serialization_get_active_cmd(struct wlan_objmgr_psoc *psoc,
506 				     uint8_t vdev_id,
507 				     enum wlan_serialization_cmd_type cmd_type);
508 #else /* New serialization code*/
509 #include <qdf_status.h>
510 #include <wlan_objmgr_cmn.h>
511 
512 /* Preprocessor Definitions and Constants */
513 
514 /*
515  * struct wlan_serialization_queued_cmd_info member queue_type specifies the
516  * below values to cancel the commands in these queues. Setting both the
517  * bits will cancel the commands in both the queues.
518  */
519 #define WLAN_SERIALIZATION_ACTIVE_QUEUE  0x1
520 #define WLAN_SERIALIZATION_PENDING_QUEUE 0x2
521 
522 /**
523  * enum wlan_serialization_cb_reason - reason for calling the callback
524  * @WLAN_SERIALIZATION_REASON_ACTIVATE_CMD: activate the cmd by sending it to FW
525  * @WLAN_SERIALIZATION_REASON_CANCEL_CMD: Cancel the cmd in the pending list
526  * @WLAN_SERIALIZATION_REASON_RELEASE_MEM_CMD:cmd execution complete. Release
527  *                                           the memory allocated while
528  *                                           building the command
529  * @WLAN_SER_CB_ACTIVE_CMD_TIMEOUT: active cmd has been timeout.
530  */
531 enum wlan_serialization_cb_reason {
532 	WLAN_SER_CB_ACTIVATE_CMD,
533 	WLAN_SER_CB_CANCEL_CMD,
534 	WLAN_SER_CB_RELEASE_MEM_CMD,
535 	WLAN_SER_CB_ACTIVE_CMD_TIMEOUT,
536 };
537 
538 /**
539  * struct wlan_serialization_scan_info - Information needed for scan cmd
540  * @is_cac_in_progress: boolean to check the cac status
541  * @is_tdls_in_progress: boolean to check the tdls status
542  *
543  * This information is needed for scan command from other components
544  * to apply the rules and check whether the cmd is allowed or not
545  */
546 struct wlan_serialization_scan_info {
547 	bool is_cac_in_progress;
548 	bool is_tdls_in_progress;
549 };
550 
551 /**
552  * union wlan_serialization_rules_info - union of all rules info structures
553  * @scan_info: information needed to apply rules on scan command
554  */
555 union wlan_serialization_rules_info {
556 	struct wlan_serialization_scan_info scan_info;
557 };
558 
559 /**
560  * wlan_serialization_cmd_callback() - Callback registered by the component
561  * @wlan_cmd: Command passed by the component for serialization
562  * @reason: Reason code for which the callback is being called
563  *
564  * Reason specifies the reason for which the callback is being called. callback
565  * should return success or failure based up on overall success of callback.
566  * if callback returns failure then serialization will remove the command from
567  * active queue and proceed for next pending command.
568  *
569  * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE
570  */
571 typedef QDF_STATUS (*wlan_serialization_cmd_callback)(void *wlan_cmd,
572 				 enum wlan_serialization_cb_reason reason);
573 
574 /**
575  * wlan_serialization_comp_info_cb() - callback to fill the rules information
576  * @vdev: VDEV object for which the command has been received
577  * @comp_info: Information filled by the component
578  *
579  * This callback is registered dynamically by the component with the
580  * serialization component. Serialization component invokes the callback
581  * while applying the rules for a particular command and the component
582  * fills in the required information to apply the rules
583  *
584  * Return: None
585  */
586 typedef void (*wlan_serialization_comp_info_cb)(struct wlan_objmgr_vdev *vdev,
587 		union wlan_serialization_rules_info *comp_info);
588 
589 /**
590  * wlan_serialization_apply_rules_cb() - callback per command to apply rules
591  * @comp_info: information needed to apply the rules
592  *
593  * The rules are applied using this callback and decided whether to
594  * allow or deny the command
595  *
596  * Return: true, if rules are successful and cmd can be queued
597  *         false, if rules failed and cmd should not be queued
598  */
599 typedef bool (*wlan_serialization_apply_rules_cb)(
600 		union wlan_serialization_rules_info *comp_info,
601 		uint8_t comp_id);
602 
603 /**
604  * enum wlan_umac_cmd_id - Command Type
605  * @WLAN_SER_CMD_SCAN:     Scan command
606  */
607 enum wlan_serialization_cmd_type {
608 	/* all scan command before non-scan */
609 	WLAN_SER_CMD_SCAN,
610 	/* all non-scan command below */
611 	WLAN_SER_CMD_NONSCAN,
612 	WLAN_SER_CMD_FORCE_DISASSOC,
613 	WLAN_SER_CMD_HDD_ISSUED,
614 	WLAN_SER_CMD_LOST_LINK1,
615 	WLAN_SER_CMD_LOST_LINK2,
616 	WLAN_SER_CMD_LOST_LINK3,
617 	WLAN_SER_CMD_FORCE_DISASSOC_MIC_FAIL,
618 	WLAN_SER_CMD_HDD_ISSUE_REASSOC_SAME_AP,
619 	WLAN_SER_CMD_SME_ISSUE_REASSOC_SAME_AP,
620 	WLAN_SER_CMD_FORCE_DEAUTH,
621 	WLAN_SER_CMD_SME_ISSUE_DISASSOC_FOR_HANDOFF,
622 	WLAN_SER_CMD_SME_ISSUE_ASSOC_TO_SIMILAR_AP,
623 	WLAN_SER_CMD_SME_ISSUE_IBSS_JOIN_FAIL,
624 	WLAN_SER_CMD_FORCE_IBSS_LEAVE,
625 	WLAN_SER_CMD_SME_ISSUE_FT_REASSOC,
626 	WLAN_SER_CMD_FORCE_DISASSOC_STA,
627 	WLAN_SER_CMD_FORCE_DEAUTH_STA,
628 	WLAN_SER_CMD_PERFORM_PRE_AUTH,
629 	WLAN_SER_CMD_WM_STATUS_CHANGE,
630 	WLAN_SER_CMD_SET_KEY,
631 	WLAN_SER_CMD_NDP_INIT_REQ,
632 	WLAN_SER_CMD_NDP_RESP_REQ,
633 	WLAN_SER_CMD_NDP_DATA_END_INIT_REQ,
634 	WLAN_SER_CMD_ADDTS,
635 	WLAN_SER_CMD_DELTS,
636 	WLAN_SER_CMD_TDLS_SEND_MGMT,
637 	WLAN_SER_CMD_TDLS_ADD_PEER,
638 	WLAN_SER_CMD_TDLS_DEL_PEER,
639 	WLAN_SER_CMD_TDLS_LINK_EST,
640 	WLAN_SER_CMD_SET_HW_MODE,
641 	WLAN_SER_CMD_NSS_UPDATE,
642 	WLAN_SER_CMD_SET_DUAL_MAC_CONFIG,
643 	WLAN_SER_CMD_SET_ANTENNA_MODE,
644 	WLAN_SER_CMD_ENTER_BMPS,
645 	WLAN_SER_CMD_EXIT_BMPS,
646 	WLAN_SER_CMD_ENTER_UAPSD,
647 	WLAN_SER_CMD_EXIT_UAPSD,
648 	WLAN_SER_CMD_EXIT_WOWL,
649 	WLAN_SER_CMD_DEL_STA_SESSION,
650 	WLAN_SER_CMD_VDEV_START_BSS,
651 	WLAN_SER_CMD_VDEV_STOP_BSS,
652 	WLAN_SER_CMD_VDEV_CONNECT,
653 	WLAN_SER_CMD_VDEV_DISCONNECT,
654 	WLAN_SER_CMD_VDEV_RESTART,
655 	WLAN_SER_CMD_MAX
656 };
657 
658 /**
659  * enum wlan_serialization_cancel_type - Type of commands to be cancelled
660  * @WLAN_SER_CANCEL_SINGLE_SCAN: Cancel a single scan with a given ID
661  * @WLAN_SER_CANCEL_PDEV_SCANS: Cancel all the scans on a given pdev
662  * @WLAN_SER_CANCEL_VDEV_SCANS: Cancel all the scans on given vdev
663  * @WLAN_SER_CANCEL_NON_SCAN_CMD: Cancel the given non scan command
664  */
665 enum wlan_serialization_cancel_type {
666 	WLAN_SER_CANCEL_SINGLE_SCAN,
667 	WLAN_SER_CANCEL_PDEV_SCANS,
668 	WLAN_SER_CANCEL_VDEV_SCANS,
669 	WLAN_SER_CANCEL_PDEV_NON_SCAN_CMD,
670 	WLAN_SER_CANCEL_VDEV_NON_SCAN_CMD,
671 	WLAN_SER_CANCEL_NON_SCAN_CMD,
672 	WLAN_SER_CANCEL_MAX,
673 };
674 
675 /**
676  * enum wlan_serialization_status - Return status of cmd serialization request
677  * @WLAN_SER_CMD_PENDING: Command is put into the pending queue
678  * @WLAN_SER_CMD_ACTIVE: Command is activated and put in active queue
679  * @WLAN_SER_CMD_DENIED_RULES_FAILED: Command denied as the rules fail
680  * @WLAN_SER_CMD_DENIED_LIST_FULL: Command denied as the pending list is full
681  * @WLAN_SER_CMD_DENIED_UNSPECIFIED: Command denied due to unknown reason
682  */
683 enum wlan_serialization_status {
684 	WLAN_SER_CMD_PENDING,
685 	WLAN_SER_CMD_ACTIVE,
686 	WLAN_SER_CMD_DENIED_RULES_FAILED,
687 	WLAN_SER_CMD_DENIED_LIST_FULL,
688 	WLAN_SER_CMD_DENIED_UNSPECIFIED,
689 };
690 
691 /**
692  * enum wlan_serialization_cmd_status - Return status for a cancel request
693  * @WLAN_SER_CMD_IN_PENDING_LIST: Command cancelled from pending list
694  * @WLAN_SER_CMD_IN_ACTIVE_LIST: Command cancelled from active list
695  * @WLAN_SER_CMDS_IN_ALL_LISTS: Command cancelled from all lists
696  * @WLAN_SER_CMD_NOT_FOUND: Specified command to be cancelled
697  *                                    not found in the lists
698  */
699 enum wlan_serialization_cmd_status {
700 	WLAN_SER_CMD_IN_PENDING_LIST,
701 	WLAN_SER_CMD_IN_ACTIVE_LIST,
702 	WLAN_SER_CMDS_IN_ALL_LISTS,
703 	WLAN_SER_CMD_MARKED_FOR_ACTIVATION,
704 	WLAN_SER_CMD_NOT_FOUND,
705 };
706 
707 /**
708  * struct wlan_serialization_command - Command to be serialized
709  * @wlan_serialization_cmd_type: Type of command
710  * @cmd_id: Command Identifier
711  * @cmd_cb: Command callback
712  * @source: component ID of the source of the command
713  * @is_high_priority: Normal/High Priority at which the cmd has to be queued
714  * @cmd_timeout_cb: Command timeout callback
715  * @cmd_timeout_duration: Timeout duration in milliseconds
716  * @vdev: VDEV object associated to the command
717  * @umac_cmd: Actual command that needs to be sent to WMI/firmware
718  *
719  * Note: Unnamed union has been used in this structure, so that in future if
720  * somebody wants to add pdev or psoc structure then that person can add without
721  * modifying existing code.
722  */
723 struct wlan_serialization_command {
724 	enum wlan_serialization_cmd_type cmd_type;
725 	uint32_t cmd_id;
726 	wlan_serialization_cmd_callback cmd_cb;
727 	enum wlan_umac_comp_id source;
728 	bool is_high_priority;
729 	bool is_blocking;
730 	uint16_t cmd_timeout_duration;
731 	union {
732 		struct wlan_objmgr_vdev *vdev;
733 	};
734 	void *umac_cmd;
735 };
736 
737 /**
738  * struct wlan_serialization_queued_cmd_info  - cmd that has to be cancelled
739  * @requestor: component ID of the source requesting this action
740  * @cmd_type: Command type
741  * @cmd_id: Command ID
742  * @req_type: Commands that need to be cancelled
743  * @vdev: VDEV object associated to the command
744  * @queue_type: Queues from which the command to be cancelled
745  */
746 struct wlan_serialization_queued_cmd_info {
747 	enum wlan_umac_comp_id requestor;
748 	enum wlan_serialization_cmd_type cmd_type;
749 	uint32_t cmd_id;
750 	enum wlan_serialization_cancel_type req_type;
751 	union {
752 		struct wlan_objmgr_vdev *vdev;
753 	};
754 	uint8_t queue_type;
755 };
756 
757 /**
758  * wlan_serialization_cancel_request() - Request to cancel a command
759  * @req: Request information
760  *
761  * This API is used by external components to cancel a command
762  * that is either in the pending or active queue. Based on the
763  * req_type, it is decided whether to use pdev or vdev
764  * object. For all non-scan commands, it will be pdev.
765  *
766  * Return: Status specifying the removal of a command from a certain queue
767  */
768 enum wlan_serialization_cmd_status
769 wlan_serialization_cancel_request(
770 		struct wlan_serialization_queued_cmd_info *req);
771 
772 /**
773  * wlan_serialization_remove_cmd() - Request to release a command
774  * @cmd: Command information
775  *
776  * This API is used to release a command sitting in the active
777  * queue upon successful completion of the command
778  *
779  * Return: None
780  */
781 void wlan_serialization_remove_cmd(
782 		struct wlan_serialization_queued_cmd_info *cmd);
783 
784 /**
785  * wlan_serialization_flush_cmd() - Request to flush command
786  * @cmd: Command information
787  *
788  * This API is used to flush a cmd sitting in the queue. It
789  * simply flushes the cmd from the queue and does not call
790  * any callbacks in between. If the request is for active
791  * queue, and if the active queue becomes empty upon flush,
792  * then it will pick the next pending cmd and put in the active
793  * queue before returning.
794  *
795  * Return: None
796  */
797 void wlan_serialization_flush_cmd(
798 		struct wlan_serialization_queued_cmd_info *cmd);
799 /**
800  * wlan_serialization_request() - Request to serialize a command
801  * @cmd: Command information
802  *
803  * Return: Status of the serialization request
804  */
805 enum wlan_serialization_status
806 wlan_serialization_request(struct wlan_serialization_command *cmd);
807 
808 /**
809  * wlan_serialization_register_comp_info_cb() - Register component's info cb
810  * @psoc: PSOC object information
811  * @comp_id: Component ID
812  * @cmd_type: Command Type
813  * @cb: Callback
814  *
815  * This is called from component during its initialization.It initializes
816  * callback handler for given comp_id/cmd_id in a 2-D array.
817  *
818  * Return: QDF Status
819  */
820 QDF_STATUS
821 wlan_serialization_register_comp_info_cb(
822 		struct wlan_objmgr_psoc *psoc,
823 		enum wlan_umac_comp_id comp_id,
824 		enum wlan_serialization_cmd_type cmd_type,
825 		wlan_serialization_comp_info_cb cb);
826 
827 /**
828  * wlan_serialization_deregister_comp_info_cb() - Deregister component's info
829  *						callback
830  * @psoc: PSOC object information
831  * @comp_id: Component ID
832  * @cmd_type: Command Type
833  *
834  * This routine is called from other component during its de-initialization.
835  *
836  * Return: QDF Status
837  */
838 QDF_STATUS
839 wlan_serialization_deregister_comp_info_cb(
840 		struct wlan_objmgr_psoc *psoc,
841 		enum wlan_umac_comp_id comp_id,
842 		enum wlan_serialization_cmd_type cmd_type);
843 
844 /**
845  * wlan_serialization_register_apply_rules_cb() - Register component's rules
846  *						callback
847  * @psoc: PSOC object information
848  * @cmd_type: Command Type
849  * @cb: Callback
850  *
851  * This is called from component during its initialization.It initializes
852  * callback handler for given cmd_type in a 1-D array.
853  *
854  * Return: QDF Status
855  */
856 QDF_STATUS
857 wlan_serialization_register_apply_rules_cb(
858 		struct wlan_objmgr_psoc *psoc,
859 		enum wlan_serialization_cmd_type cmd_type,
860 		wlan_serialization_apply_rules_cb apply_rules_cb);
861 
862 /**
863  * wlan_serialization_deregister_apply_rules_cb() - Deregister component's rules
864  *						callback
865  * @psoc: PSOC object information
866  * @cmd_type: Command Type
867  *
868  * This routine is called from other component during its de-initialization.
869  *
870  * Return: QDF Status
871  */
872 QDF_STATUS
873 wlan_serialization_deregister_apply_rules_cb(
874 		struct wlan_objmgr_psoc *psoc,
875 		enum wlan_serialization_cmd_type cmd_type);
876 
877 /**
878  * @wlan_serialization_init() - Serialization component initialization routine
879  *
880  * Return - QDF Status
881  */
882 QDF_STATUS wlan_serialization_init(void);
883 
884 /**
885  * @wlan_serialization_deinit() - Serialization component de-init routine
886  *
887  * Return - QDF Status
888  */
889 QDF_STATUS wlan_serialization_deinit(void);
890 
891 /**
892  * @wlan_serialization_psoc_open() - Serialization component open routine
893  *
894  * Return - QDF Status
895  */
896 QDF_STATUS wlan_serialization_psoc_open(struct wlan_objmgr_psoc *psoc);
897 
898 /**
899  * @wlan_serialization_psoc_close() - Serialization component close routine
900  *
901  * Return - QDF Status
902  */
903 QDF_STATUS wlan_serialization_psoc_close(struct wlan_objmgr_psoc *psoc);
904 
905 /**
906  * wlan_serialization_vdev_scan_status() - Return the status of the vdev scan
907  * @vdev: VDEV Object
908  *
909  * Return: Status of the scans for the corresponding vdev
910  */
911 enum wlan_serialization_cmd_status
912 wlan_serialization_vdev_scan_status(struct wlan_objmgr_vdev *vdev);
913 
914 /**
915  * wlan_serialization_pdev_scan_status() - Return the status of the pdev scan
916  * @pdev: PDEV Object
917  *
918  * Return: Status of the scans for the corresponding pdev
919  */
920 enum wlan_serialization_cmd_status
921 wlan_serialization_pdev_scan_status(struct wlan_objmgr_pdev *pdev);
922 
923 /**
924  * wlan_serialization_non_scan_cmd_status() - Return status of pdev non-scan cmd
925  * @pdev: PDEV Object
926  * @cmd_id: ID of the command for which the status has to be checked
927  *
928  * Return: Status of the command for the corresponding pdev
929  */
930 enum wlan_serialization_cmd_status
931 wlan_serialization_non_scan_cmd_status(struct wlan_objmgr_pdev *pdev,
932 				       enum wlan_serialization_cmd_type cmd_id);
933 
934 /**
935  * wlan_serialization_is_cmd_present_in_pending_queue() - Return if the command
936  *				is already present in pending queue
937  * @cmd: pointer to serialization command to check
938  *
939  * This API will check if command is present in pending queue. If present
940  * then return true, so use know that it is duplicated command
941  *
942  * Return: true or false
943  */
944 bool wlan_serialization_is_cmd_present_in_pending_queue(
945 		struct wlan_objmgr_psoc *psoc,
946 		struct wlan_serialization_command *cmd);
947 /**
948  * wlan_serialization_is_cmd_present_in_active_queue() - Return if the command
949  *			is already present in active queue
950  * @cmd: pointer to serialization command to check
951  *
952  * This API will check if command is present in active queue. If present
953  * then return true, so use know that it is duplicated command
954  *
955  * Return: true or false
956  */
957 bool wlan_serialization_is_cmd_present_in_active_queue(
958 		struct wlan_objmgr_psoc *psoc,
959 		struct wlan_serialization_command *cmd);
960 
961 /**
962  * wlan_serialization_get_scan_cmd_using_scan_id() - Return command which
963  *					matches vdev_id and scan_id
964  * @psoc: pointer to soc
965  * @vdev_id: vdev id to pull vdev object
966  * @scan_id: scan id to match
967  * @is_scan_cmd_from_active_queue: to indicate active or pending queue
968  *
969  * This API fetches vdev/pdev object based on vdev_id, loops through scan
970  * command queue and find the command which matches scan id as well as vdev
971  * object.
972  *
973  * Return: pointer to serialization command
974  */
975 struct wlan_serialization_command*
976 wlan_serialization_get_scan_cmd_using_scan_id(
977 		struct wlan_objmgr_psoc *psoc,
978 		uint8_t vdev_id, uint16_t scan_id,
979 		uint8_t is_scan_cmd_from_active_queue);
980 /**
981  * wlan_serialization_get_active_cmd() - Return active umac command which
982  *  matches vdev and cmd type
983  * @psoc: pointer to soc
984  * @vdev_id: vdev id to pull vdev object
985  * @cmd_type: cmd type to match
986  *
987  * This API fetches vdev/pdev object based on vdev_id, loops through active
988  * command queue and find the active command which matches cmd_type as well
989  * as vdev object.
990  *
991  * Return: Pointer to umac command. NULL is returned if active command of given
992  *  type is not found.
993  */
994 void *wlan_serialization_get_active_cmd(
995 		struct wlan_objmgr_psoc *psoc,
996 		uint8_t vdev_id,
997 		enum wlan_serialization_cmd_type cmd_type);
998 #endif
999 #endif
1000