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  * 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  *
140  * find the free timer, initialize it, and start it
141  *
142  * Return: QDF_STATUS
143  */
144 QDF_STATUS
145 wlan_serialization_find_and_start_timer(struct wlan_objmgr_psoc *psoc,
146 					struct wlan_serialization_command *cmd);
147 
148 /**
149  * wlan_serialization_find_and_update_timer() - to find and update the timer
150  * @psoc: pointer to psoc
151  * @cmd: pointer to command attributes
152  *
153  * Find the timer associated with command, and update it
154  *
155  * Return: QDF_STATUS
156  */
157 QDF_STATUS
158 wlan_serialization_find_and_update_timer(
159 		struct wlan_objmgr_psoc *psoc,
160 		struct wlan_serialization_command *cmd);
161 
162 /**
163  * wlan_serialization_find_and_stop_timer() - to find and stop the timer
164  * @psoc: pointer to psoc
165  * @cmd: pointer to actual command
166  *
167  * find the timer associated with command, stop it and destroy it
168  *
169  * Return: QDF_STATUS
170  */
171 QDF_STATUS
172 wlan_serialization_find_and_stop_timer(struct wlan_objmgr_psoc *psoc,
173 				       struct wlan_serialization_command *cmd);
174 
175 /**
176  * wlan_serialization_find_and_cancel_cmd() - to find cmd from queue and cancel
177  * @cmd: pointer to serialization command
178  * @req_type: Command cancel request type
179  * @queue_type: Bitmask for member queue type i.e active or pending or both
180  *
181  * This api will find command from active queue and pending queue and
182  * removes the command. If it is in active queue then it will notifies the
183  * requester that it is in active queue and from there it expects requester
184  * to send remove command
185  *
186  * Return: wlan_serialization_cmd_status
187  */
188 
189 enum wlan_serialization_cmd_status
190 wlan_serialization_find_and_cancel_cmd(
191 		struct wlan_serialization_command *cmd,
192 		enum wlan_serialization_cancel_type req_type,
193 		uint8_t queue_type);
194 
195 /**
196  * wlan_serialization_cmd_cancel_handler() - helper func to cancel cmd
197  * @ser_obj: private pdev ser obj
198  * @cmd: pointer to command
199  * @pdev: pointer to pdev
200  * @vdev: pointer to vdev
201  * @cmd_type: pointer to cmd_type
202  * @queue_type: If active queue or pending queue
203  *
204  * This API will decide from which queue, command needs to be cancelled
205  * and pass that queue and other parameter required to cancel the command
206  * to helper function.
207  *
208  * Return: wlan_serialization_cmd_status
209  */
210 enum wlan_serialization_cmd_status
211 wlan_serialization_cmd_cancel_handler(
212 				      struct wlan_ser_pdev_obj *ser_obj,
213 				      struct wlan_serialization_command *cmd,
214 				      struct wlan_objmgr_pdev *pdev,
215 				      struct wlan_objmgr_vdev *vdev,
216 				      enum wlan_serialization_cmd_type cmd_type,
217 				      uint8_t queue_type);
218 #endif
219