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  *
69  * Return: Status of the serialization request
70  */
71 enum wlan_serialization_status
72 wlan_serialization_enqueue_cmd(struct wlan_serialization_command *cmd);
73 
74 /**
75  * wlan_serialization_activate_cmd() - activate cmd in active queue
76  * @cmd_list: Command needs to be activated
77  * @ser_pdev_obj: Serialization private pdev object
78  *
79  * Return: Status of activation of the command
80  */
81 QDF_STATUS
82 wlan_serialization_activate_cmd(
83 		struct wlan_serialization_command_list *cmd_list,
84 		struct wlan_ser_pdev_obj *ser_pdev_obj);
85 
86 /**
87  * wlan_serialization_activate_multiple_cmd() - Activate multiple cmd in
88  *			active queue
89  * @ser_pdev_obj: Serialization private pdev object
90  *
91  * Return: Status of activation of the command
92  */
93 QDF_STATUS
94 wlan_serialization_activate_multiple_cmd(
95 		struct wlan_ser_pdev_obj *ser_pdev_obj);
96 
97 /**
98  * wlan_serialization_move_pending_to_active() - Move a cmd from pending
99  *			queue to active queue
100  * @cmd_type: Type of command to be moved i.e scan or non scan
101  * @pcmd_list: Pointer to command list containing the command
102  * @ser_pdev_obj: Serialization private pdev object
103  * @vdev: Pointer to vdev object manager
104  * @blocking_cmd_removed: If a blocking cmd is removed from active queue
105  * @blocking_cmd_waiting: If a blocking cmd is waiting in pending queue
106  *
107  * Return: Status of command request
108  */
109 enum wlan_serialization_status
110 wlan_serialization_move_pending_to_active(
111 		enum wlan_serialization_cmd_type cmd_type,
112 		struct wlan_serialization_command_list **pcmd_list,
113 		struct wlan_ser_pdev_obj *ser_pdev_obj,
114 		struct wlan_objmgr_vdev *vdev,
115 		bool blocking_cmd_removed,
116 		bool blocking_cmd_waiting);
117 
118 /**
119  * wlan_serialization_dequeue_cmd() - dequeue the cmd to pending/active Queue
120  * @cmd: Command information
121  * @active_cmd: whether command is for active queue
122  *
123  * Return: Status of the serialization request
124  */
125 enum wlan_serialization_cmd_status
126 wlan_serialization_dequeue_cmd(struct wlan_serialization_command *cmd,
127 			       uint8_t active_cmd);
128 
129 /**
130  * wlan_serialization_generic_timer_cb() - timer callback when timer fire
131  * @arg: argument that timer passes to this callback
132  *
133  * All the timers in serialization module calls this callback when they fire,
134  * and this API in turn calls command specific timeout callback and remove
135  * timed-out command from active queue and move any pending command to active
136  * queue of same cmd_type.
137  *
138  * Return: none
139  */
140 void wlan_serialization_generic_timer_cb(void *arg);
141 
142 /**
143  * wlan_serialization_find_and_start_timer() - to find and start the timer
144  * @psoc: pointer to psoc
145  * @cmd: pointer to actual command
146  *
147  * find the free timer, initialize it, and start it
148  *
149  * Return: QDF_STATUS
150  */
151 QDF_STATUS
152 wlan_serialization_find_and_start_timer(struct wlan_objmgr_psoc *psoc,
153 					struct wlan_serialization_command *cmd);
154 
155 /**
156  * wlan_serialization_find_and_stop_timer() - to find and stop the timer
157  * @psoc: pointer to psoc
158  * @cmd: pointer to actual command
159  *
160  * find the timer associated with command, stop it and destroy it
161  *
162  * Return: QDF_STATUS
163  */
164 QDF_STATUS
165 wlan_serialization_find_and_stop_timer(struct wlan_objmgr_psoc *psoc,
166 				       struct wlan_serialization_command *cmd);
167 
168 /**
169  * wlan_serialization_find_and_cancel_cmd() - to find cmd from queue and cancel
170  * @cmd: pointer to serialization command
171  * @req_type: Command cancel request type
172  * @queue_type: Bitmask for member queue type i.e active or pending or both
173  *
174  * This api will find command from active queue and pending queue and
175  * removes the command. If it is in active queue then it will notifies the
176  * requester that it is in active queue and from there it expects requester
177  * to send remove command
178  *
179  * Return: wlan_serialization_cmd_status
180  */
181 
182 enum wlan_serialization_cmd_status
183 wlan_serialization_find_and_cancel_cmd(
184 		struct wlan_serialization_command *cmd,
185 		enum wlan_serialization_cancel_type req_type,
186 		uint8_t queue_type);
187 
188 /**
189  * wlan_serialization_cmd_cancel_handler() - helper func to cancel cmd
190  * @ser_obj: private pdev ser obj
191  * @cmd: pointer to command
192  * @pdev: pointer to pdev
193  * @vdev: pointer to vdev
194  * @cmd_type: pointer to cmd_type
195  * @queue_type: If active queue or pending queue
196  *
197  * This API will decide from which queue, command needs to be cancelled
198  * and pass that queue and other parameter required to cancel the command
199  * to helper function.
200  *
201  * Return: wlan_serialization_cmd_status
202  */
203 enum wlan_serialization_cmd_status
204 wlan_serialization_cmd_cancel_handler(
205 				      struct wlan_ser_pdev_obj *ser_obj,
206 				      struct wlan_serialization_command *cmd,
207 				      struct wlan_objmgr_pdev *pdev,
208 				      struct wlan_objmgr_vdev *vdev,
209 				      enum wlan_serialization_cmd_type cmd_type,
210 				      uint8_t queue_type);
211 #endif
212