1 /*
2  * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2023 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  * DOC: wlan_serialization_internal_i.h
21  * This file defines the prototypes of functions which are called
22  * from serialization public API's and are internal
23  * to serialization.
24  */
25 #ifndef __WLAN_SERIALIZATION_PVT_I_H
26 #define __WLAN_SERIALIZATION_PVT_I_H
27 
28 #include <wlan_objmgr_vdev_obj.h>
29 #include <wlan_objmgr_pdev_obj.h>
30 #include <wlan_objmgr_psoc_obj.h>
31 #include <qdf_list.h>
32 #include <qdf_status.h>
33 #include "wlan_serialization_api.h"
34 #include "wlan_serialization_main_i.h"
35 #include "wlan_serialization_utils_i.h"
36 #include "wlan_serialization_non_scan_i.h"
37 
38 /**
39  * wlan_serialization_is_cmd_present_queue() - Check if same command
40  *				is already present active or pending queue
41  * @cmd: pointer to command which we need to find
42  * @is_active_queue: flag to find the command in active or pending queue
43  *
44  * This API will check the given command is already present in active or
45  * pending queue based on flag
46  * If present then return true otherwise false
47  *
48  * Return: true or false
49  */
50 bool
51 wlan_serialization_is_cmd_present_queue(
52 					struct wlan_serialization_command *cmd,
53 					uint8_t is_active_queue);
54 
55 /**
56  * wlan_serialization_is_active_cmd_allowed() - Check if the given command
57  *			can be moved to active queue
58  * @cmd: Serialization command information
59  *
60  * Return: true or false
61  */
62 bool
63 wlan_serialization_is_active_cmd_allowed(
64 		struct wlan_serialization_command *cmd);
65 
66 /**
67  * wlan_serialization_enqueue_cmd() - Enqueue the cmd to pending/active Queue
68  * @cmd: Command information
69  * @ser_reason: action for dequeue
70  *
71  * Return: Status of the serialization request
72  */
73 enum wlan_serialization_status
74 wlan_serialization_enqueue_cmd(struct wlan_serialization_command *cmd,
75 			       enum ser_queue_reason ser_reason);
76 
77 /**
78  * wlan_serialization_activate_cmd() - activate cmd in active queue
79  * @cmd_list: Command needs to be activated
80  * @ser_pdev_obj: Serialization private pdev object
81  * @ser_reason: reason the activation cb would be called
82  *
83  * Return: Status of activation of the command
84  */
85 QDF_STATUS
86 wlan_serialization_activate_cmd(
87 		struct wlan_serialization_command_list *cmd_list,
88 		struct wlan_ser_pdev_obj *ser_pdev_obj,
89 		enum ser_queue_reason ser_reason);
90 
91 /**
92  * wlan_serialization_move_pending_to_active() - Move a cmd from pending
93  *			queue to active queue
94  * @cmd_type: Type of command to be moved i.e scan or non scan
95  * @ser_pdev_obj: Serialization private pdev object
96  * @vdev: Pointer to vdev object manager
97  * @blocking_cmd_removed: If a blocking cmd is removed from active queue
98  *
99  * Return: Status of command request
100  */
101 enum wlan_serialization_status
102 wlan_serialization_move_pending_to_active(
103 		enum wlan_serialization_cmd_type cmd_type,
104 		struct wlan_ser_pdev_obj *ser_pdev_obj,
105 		struct wlan_objmgr_vdev *vdev,
106 		bool blocking_cmd_removed);
107 
108 /**
109  * wlan_serialization_dequeue_cmd() - dequeue the cmd to pending/active Queue
110  * @cmd: Command information
111  * @ser_reason: action for dequeue
112  * @active_cmd: whether command is for active queue
113  *
114  * Return: Status of the serialization request
115  */
116 enum wlan_serialization_cmd_status
117 wlan_serialization_dequeue_cmd(struct wlan_serialization_command *cmd,
118 			       enum ser_queue_reason ser_reason,
119 			       uint8_t active_cmd);
120 
121 /**
122  * wlan_serialization_find_and_start_timer() - to find and start the timer
123  * @psoc: pointer to psoc
124  * @cmd: pointer to actual command
125  * @ser_reason: serialization reason
126  *
127  * find the free timer, initialize it, and start it
128  *
129  * Return: QDF_STATUS
130  */
131 QDF_STATUS
132 wlan_serialization_find_and_start_timer(struct wlan_objmgr_psoc *psoc,
133 					struct wlan_serialization_command *cmd,
134 					enum ser_queue_reason ser_reason);
135 
136 /**
137  * wlan_serialization_find_and_update_timer() - to find and update the timer
138  * @psoc: pointer to psoc
139  * @cmd: pointer to command attributes
140  *
141  * Find the timer associated with command, and update it
142  *
143  * Return: QDF_STATUS
144  */
145 QDF_STATUS
146 wlan_serialization_find_and_update_timer(
147 		struct wlan_objmgr_psoc *psoc,
148 		struct wlan_serialization_command *cmd);
149 
150 /**
151  * wlan_serialization_find_and_stop_timer() - to find and stop the timer
152  * @psoc: pointer to psoc
153  * @cmd: pointer to actual command
154  * @ser_reason: serialization reason
155  *
156  * find the timer associated with command, stop it and destroy it
157  *
158  * Return: QDF_STATUS
159  */
160 QDF_STATUS
161 wlan_serialization_find_and_stop_timer(struct wlan_objmgr_psoc *psoc,
162 				       struct wlan_serialization_command *cmd,
163 				       enum ser_queue_reason ser_reason);
164 
165 
166 /**
167  * wlan_serialization_find_and_cancel_cmd() - to find cmd from queue and cancel
168  * @cmd: pointer to serialization command
169  * @req_type: Command cancel request type
170  * @queue_type: Bitmask for member queue type i.e active or pending or both
171  *
172  * This api will find command from active queue and pending queue and
173  * removes the command. If it is in active queue then it will notifies the
174  * requester that it is in active queue and from there it expects requester
175  * to send remove command
176  *
177  * Return: wlan_serialization_cmd_status
178  */
179 
180 enum wlan_serialization_cmd_status
181 wlan_serialization_find_and_cancel_cmd(
182 		struct wlan_serialization_command *cmd,
183 		enum wlan_serialization_cancel_type req_type,
184 		uint8_t queue_type);
185 
186 /**
187  * wlan_serialization_cmd_cancel_handler() - helper func to cancel cmd
188  * @ser_obj: private pdev ser obj
189  * @cmd: pointer to command
190  * @pdev: pointer to pdev
191  * @vdev: pointer to vdev
192  * @cmd_type: pointer to cmd_type
193  * @queue_type: If active queue or pending queue
194  * @cmd_attr: Attrbute to indicate a blocking or a non-blocking command
195  *
196  * This API will decide from which queue, command needs to be cancelled
197  * and pass that queue and other parameter required to cancel the command
198  * to helper function.
199  *
200  * Return: wlan_serialization_cmd_status
201  */
202 enum wlan_serialization_cmd_status
203 wlan_serialization_cmd_cancel_handler(
204 				      struct wlan_ser_pdev_obj *ser_obj,
205 				      struct wlan_serialization_command *cmd,
206 				      struct wlan_objmgr_pdev *pdev,
207 				      struct wlan_objmgr_vdev *vdev,
208 				      enum wlan_serialization_cmd_type cmd_type,
209 				      uint8_t queue_type,
210 				      enum wlan_ser_cmd_attr cmd_attr);
211 #endif
212