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