xref: /wlan-dirver/qca-wifi-host-cmn/umac/cmn_services/serialization/src/wlan_serialization_non_scan.c (revision bea437e2293c3d4fb1b5704fcf633aedac996962)
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_non_scan.c
20  * This file defines the functions which deals with
21  * serialization non scan commands.
22  */
23 
24 #include <wlan_objmgr_psoc_obj.h>
25 #include <wlan_objmgr_pdev_obj.h>
26 #include <wlan_objmgr_vdev_obj.h>
27 #include "wlan_serialization_main_i.h"
28 #include "wlan_serialization_utils_i.h"
29 #include "wlan_serialization_non_scan_i.h"
30 
31 bool
32 wlan_serialization_is_non_scan_pending_queue_empty(
33 		struct wlan_serialization_command *cmd)
34 {
35 	struct wlan_objmgr_vdev *vdev = NULL;
36 	struct wlan_ser_vdev_obj *ser_vdev_obj = NULL;
37 	struct wlan_serialization_vdev_queue *vdev_q;
38 	bool status = false;
39 
40 	vdev = wlan_serialization_get_vdev_from_cmd(cmd);
41 
42 	if (!vdev) {
43 		ser_err("vdev object  is invalid");
44 		goto error;
45 	}
46 
47 	ser_vdev_obj = wlan_serialization_get_vdev_obj(vdev);
48 	vdev_q = &ser_vdev_obj->vdev_q[SER_VDEV_QUEUE_COMP_NON_SCAN];
49 
50 	if (qdf_list_empty(&vdev_q->pending_list))
51 		status = true;
52 
53 error:
54 	return status;
55 }
56 
57 /**
58  * wlan_serialization_is_active_nonscan_cmd_allowed() - find if cmd allowed
59  * @pdev: pointer to pdev object
60  *
61  * This API will be called to find out if non scan cmd is allowed.
62  *
63  * Return: true or false
64  */
65 
66 bool
67 wlan_serialization_is_active_non_scan_cmd_allowed(
68 		struct wlan_serialization_command *cmd)
69 {
70 	struct wlan_serialization_pdev_queue *pdev_queue;
71 	struct wlan_ser_pdev_obj *ser_pdev_obj;
72 	uint32_t vdev_active_cmd_bitmap;
73 	bool blocking_cmd_active = 0;
74 	uint8_t blocking_cmd_waiting = 0;
75 	bool status = false;
76 	uint32_t vdev_id;
77 
78 	ser_pdev_obj = wlan_serialization_get_pdev_obj(
79 			wlan_serialization_get_pdev_from_cmd(cmd));
80 
81 	pdev_queue = wlan_serialization_get_pdev_queue_obj(ser_pdev_obj,
82 							   cmd->cmd_type);
83 
84 	vdev_active_cmd_bitmap = pdev_queue->vdev_active_cmd_bitmap;
85 	blocking_cmd_active = pdev_queue->blocking_cmd_active;
86 	blocking_cmd_waiting = pdev_queue->blocking_cmd_waiting;
87 
88 	/*
89 	 * Command is blocking
90 	 */
91 	if (cmd->is_blocking) {
92 		/*
93 		 * For blocking commands, no other
94 		 * commands from any vdev should be active
95 		 */
96 		if (vdev_active_cmd_bitmap) {
97 			status = false;
98 			pdev_queue->blocking_cmd_waiting++;
99 		} else {
100 			status = true;
101 		}
102 	} else {
103 		/*
104 		 * Command is non blocking
105 		 * For activating non blocking commands, if there any blocking
106 		 * commands, waiting or active, put it to pending queue
107 		 */
108 		if (blocking_cmd_active || blocking_cmd_waiting) {
109 			status = false;
110 		} else {
111 		/*
112 		 * For non blocking command, and no blocking commands
113 		 * waiting or active, check if a cmd for that vdev is active
114 		 * If not active, put to active else pending queue
115 		 */
116 			vdev_id = wlan_vdev_get_id(cmd->vdev);
117 			status = vdev_active_cmd_bitmap & (1 << vdev_id)
118 						? false : true;
119 		}
120 	}
121 	return status;
122 }
123 
124 enum wlan_serialization_status wlan_ser_add_non_scan_cmd(
125 		struct wlan_ser_pdev_obj *ser_pdev_obj,
126 		struct wlan_serialization_command_list *cmd_list,
127 		uint8_t is_cmd_for_active_queue)
128 {
129 	enum wlan_serialization_status pdev_status, vdev_status;
130 	enum wlan_serialization_status status = WLAN_SER_CMD_DENIED_UNSPECIFIED;
131 	struct wlan_serialization_command_list *pcmd_list;
132 	uint8_t vdev_id;
133 	struct wlan_serialization_pdev_queue *pdev_queue;
134 
135 	ser_debug("add non scan cmd: type[%d] id[%d] prio[%d] blocking[%d]",
136 		  cmd_list->cmd.cmd_type,
137 		  cmd_list->cmd.cmd_id,
138 		  cmd_list->cmd.is_high_priority,
139 		  cmd_list->cmd.is_blocking);
140 
141 	vdev_status = wlan_serialization_add_cmd_to_vdev_queue(
142 			ser_pdev_obj, cmd_list, is_cmd_for_active_queue);
143 
144 	if (vdev_status == WLAN_SER_CMD_DENIED_LIST_FULL) {
145 		ser_err_rl("List is full cannot add CMD %d cmd id %d",
146 			   cmd_list->cmd.cmd_type, cmd_list->cmd.cmd_id);
147 		status = vdev_status;
148 		goto vdev_error;
149 	}
150 
151 	if (is_cmd_for_active_queue) {
152 		if (vdev_status != WLAN_SER_CMD_ACTIVE) {
153 			ser_err("Failed to add to vdev active queue");
154 			QDF_ASSERT(0);
155 			goto vdev_error;
156 		}
157 	} else {
158 		if (vdev_status != WLAN_SER_CMD_PENDING) {
159 			ser_err("Failed to add to vdev pending queue");
160 			QDF_ASSERT(0);
161 			goto vdev_error;
162 		}
163 	}
164 
165 	pdev_status = wlan_serialization_add_cmd_to_pdev_queue(
166 			ser_pdev_obj, cmd_list, is_cmd_for_active_queue);
167 
168 	if (pdev_status == WLAN_SER_CMD_DENIED_LIST_FULL) {
169 		status = pdev_status;
170 		goto pdev_error;
171 	}
172 
173 	if (is_cmd_for_active_queue) {
174 		if (pdev_status != WLAN_SER_CMD_ACTIVE) {
175 			ser_err("Failed to add to pdev active queue");
176 			QDF_ASSERT(0);
177 			goto pdev_error;
178 		}
179 	} else {
180 		if (pdev_status != WLAN_SER_CMD_PENDING) {
181 			ser_err("Failed to add to pdev pending queue");
182 			QDF_ASSERT(0);
183 			goto pdev_error;
184 		}
185 	}
186 pdev_error:
187 	/*
188 	 * If cmd added to vdev queue, but failed while
189 	 * adding to pdev queue, remove cmd from vdev queue as well
190 	 */
191 	if (pdev_status != vdev_status) {
192 		wlan_serialization_remove_cmd_from_vdev_queue(
193 			ser_pdev_obj, &pcmd_list,
194 			&cmd_list->cmd,
195 			is_cmd_for_active_queue);
196 	} else {
197 		status = pdev_status;
198 	}
199 
200 	if (is_cmd_for_active_queue) {
201 		pdev_queue = wlan_serialization_get_pdev_queue_obj(
202 				ser_pdev_obj, cmd_list->cmd.cmd_type);
203 		vdev_id = wlan_vdev_get_id(cmd_list->cmd.vdev);
204 		pdev_queue->vdev_active_cmd_bitmap |= (1 << vdev_id);
205 
206 		if (cmd_list->cmd.is_blocking)
207 			pdev_queue->blocking_cmd_active = 1;
208 	}
209 
210 vdev_error:
211 	return status;
212 }
213 
214 enum wlan_serialization_status
215 wlan_ser_move_non_scan_pending_to_active(
216 		struct wlan_ser_pdev_obj *ser_pdev_obj,
217 		struct wlan_objmgr_vdev *vdev,
218 		bool blocking_cmd_removed)
219 {
220 	struct wlan_serialization_command_list *pending_cmd_list = NULL;
221 	struct wlan_serialization_command_list *active_cmd_list;
222 	struct wlan_serialization_command cmd_to_remove;
223 	enum wlan_serialization_status status = WLAN_SER_CMD_DENIED_UNSPECIFIED;
224 	struct wlan_serialization_pdev_queue *pdev_queue;
225 	struct wlan_serialization_vdev_queue *vdev_queue;
226 
227 	struct wlan_ser_vdev_obj *ser_vdev_obj;
228 
229 	qdf_list_t *pending_queue;
230 	qdf_list_node_t *pending_node = NULL;
231 	QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
232 	uint32_t blocking_cmd_waiting = 0;
233 	uint32_t vdev_id;
234 	uint32_t qsize;
235 	bool vdev_cmd_active = 0;
236 	bool vdev_queue_lookup = false;
237 
238 	pdev_queue = &ser_pdev_obj->pdev_q[SER_PDEV_QUEUE_COMP_NON_SCAN];
239 
240 	ser_vdev_obj = wlan_serialization_get_vdev_obj(vdev);
241 	vdev_queue = &ser_vdev_obj->vdev_q[SER_VDEV_QUEUE_COMP_NON_SCAN];
242 
243 	ser_enter();
244 
245 	if (!ser_pdev_obj) {
246 		ser_err("Can't find ser_pdev_obj");
247 		goto error;
248 	}
249 
250 	wlan_serialization_acquire_lock(&pdev_queue->pdev_queue_lock);
251 
252 	blocking_cmd_waiting = pdev_queue->blocking_cmd_waiting;
253 
254 	if (!blocking_cmd_removed && !blocking_cmd_waiting) {
255 		pending_queue = &vdev_queue->pending_list;
256 		vdev_queue_lookup = true;
257 	} else {
258 		pending_queue = &pdev_queue->pending_list;
259 	}
260 
261 	qsize =  wlan_serialization_list_size(pending_queue);
262 	if (!qsize) {
263 		wlan_serialization_release_lock(
264 			&pdev_queue->pdev_queue_lock);
265 		ser_debug("Pending Queue is empty");
266 		goto error;
267 	}
268 
269 	while (qsize--) {
270 		qdf_status = wlan_serialization_get_cmd_from_queue(
271 				pending_queue, &pending_node);
272 		if (qdf_status != QDF_STATUS_SUCCESS) {
273 			ser_err("can't peek cmd");
274 			break;
275 		}
276 
277 		if (vdev_queue_lookup) {
278 			pending_cmd_list =
279 				qdf_container_of(
280 				pending_node,
281 				struct wlan_serialization_command_list,
282 				vdev_node);
283 		} else {
284 			pending_cmd_list =
285 				qdf_container_of(
286 				pending_node,
287 				struct wlan_serialization_command_list,
288 				pdev_node);
289 		}
290 
291 		if (!pending_cmd_list) {
292 			wlan_serialization_release_lock(
293 				&pdev_queue->pdev_queue_lock);
294 			ser_debug(
295 				"non scan cmd cannot move frm pendin to actv");
296 			goto error;
297 		}
298 
299 		vdev_id = wlan_vdev_get_id(pending_cmd_list->cmd.vdev);
300 		vdev_cmd_active =
301 			pdev_queue->vdev_active_cmd_bitmap &
302 			(1 << vdev_id);
303 
304 		if (!vdev_queue_lookup) {
305 			if (pending_cmd_list->cmd.is_blocking &&
306 			    pdev_queue->vdev_active_cmd_bitmap) {
307 				break;
308 			}
309 			if (vdev_cmd_active)
310 				continue;
311 		} else {
312 			if (vdev_cmd_active)
313 				break;
314 		}
315 
316 		qdf_mem_copy(&cmd_to_remove, &pending_cmd_list->cmd,
317 			     sizeof(struct wlan_serialization_command));
318 
319 		qdf_status = wlan_ser_remove_non_scan_cmd(ser_pdev_obj,
320 							  &pending_cmd_list,
321 							  &cmd_to_remove,
322 							  false);
323 
324 		wlan_ser_update_cmd_history(
325 				pdev_queue, &pending_cmd_list->cmd,
326 				SER_PENDING_TO_ACTIVE,
327 				false, false);
328 
329 		if (QDF_STATUS_SUCCESS != qdf_status) {
330 			wlan_serialization_release_lock(
331 					&pdev_queue->pdev_queue_lock);
332 			ser_err("Can't remove cmd from pendingQ id-%d type-%d",
333 				pending_cmd_list->cmd.cmd_id,
334 				pending_cmd_list->cmd.cmd_type);
335 			QDF_ASSERT(0);
336 			status = WLAN_SER_CMD_DENIED_UNSPECIFIED;
337 			goto error;
338 		}
339 
340 		active_cmd_list = pending_cmd_list;
341 
342 		status = wlan_ser_add_non_scan_cmd(
343 				ser_pdev_obj, active_cmd_list, true);
344 
345 		if (WLAN_SER_CMD_ACTIVE != status) {
346 			wlan_serialization_release_lock(
347 					&pdev_queue->pdev_queue_lock);
348 			ser_err("Can't move cmd to activeQ id-%d type-%d",
349 				pending_cmd_list->cmd.cmd_id,
350 				pending_cmd_list->cmd.cmd_type);
351 			wlan_serialization_insert_back(
352 				&pdev_queue->cmd_pool_list,
353 				&active_cmd_list->pdev_node);
354 			status = WLAN_SER_CMD_DENIED_UNSPECIFIED;
355 			QDF_ASSERT(0);
356 			goto error;
357 		}
358 
359 		wlan_ser_update_cmd_history(
360 				pdev_queue, &active_cmd_list->cmd,
361 				SER_PENDING_TO_ACTIVE,
362 				true, true);
363 
364 		qdf_atomic_set_bit(CMD_MARKED_FOR_ACTIVATION,
365 				   &active_cmd_list->cmd_in_use);
366 
367 		if (active_cmd_list->cmd.is_blocking)
368 			pdev_queue->blocking_cmd_waiting--;
369 
370 		wlan_serialization_release_lock(&pdev_queue->pdev_queue_lock);
371 
372 		wlan_serialization_activate_cmd(active_cmd_list, ser_pdev_obj,
373 						SER_PENDING_TO_ACTIVE);
374 
375 		wlan_serialization_acquire_lock(&pdev_queue->pdev_queue_lock);
376 
377 		if (vdev_queue_lookup || pdev_queue->blocking_cmd_active)
378 			break;
379 
380 		pending_node = NULL;
381 
382 	}
383 
384 	wlan_serialization_release_lock(&pdev_queue->pdev_queue_lock);
385 error:
386 	ser_exit();
387 	return status;
388 }
389 
390 QDF_STATUS wlan_ser_remove_non_scan_cmd(
391 		struct wlan_ser_pdev_obj *ser_pdev_obj,
392 		struct wlan_serialization_command_list **pcmd_list,
393 		struct wlan_serialization_command *cmd,
394 		uint8_t is_active_cmd)
395 {
396 	QDF_STATUS pdev_status, vdev_status;
397 	QDF_STATUS status = QDF_STATUS_E_FAILURE;
398 	uint32_t vdev_id;
399 	bool blocking_cmd_removed = 0;
400 	struct wlan_serialization_pdev_queue *pdev_queue;
401 
402 	ser_debug("remove non scan cmd: type[%d] id[%d] prio[%d] blocking[%d]",
403 		  cmd->cmd_type,
404 		  cmd->cmd_id,
405 		  cmd->is_high_priority,
406 		  cmd->is_blocking);
407 
408 	vdev_status =
409 		wlan_serialization_remove_cmd_from_vdev_queue(ser_pdev_obj,
410 							      pcmd_list,
411 							      cmd,
412 							      is_active_cmd);
413 
414 	/* Here command removal can fail for 2 reasons
415 	 * 1. The cmd is not present
416 	 * 2. The command had not returned from activation
417 	 *    and will not be removed now.
418 	 *
419 	 *  In the second case, we should not flag it as error
420 	 *  since it will removed after the activation completes.
421 	 */
422 
423 	if (vdev_status != QDF_STATUS_SUCCESS) {
424 		status = vdev_status;
425 		if (vdev_status != QDF_STATUS_E_PENDING)
426 			ser_debug("Failed to remove cmd from vdev queue");
427 		goto error;
428 	}
429 
430 	pdev_status =
431 		wlan_serialization_remove_cmd_from_pdev_queue(ser_pdev_obj,
432 							      pcmd_list,
433 							      cmd,
434 							      is_active_cmd);
435 
436 	if (pdev_status != QDF_STATUS_SUCCESS) {
437 		ser_err("Failed to remove cmd from pdev active/pending queue");
438 		goto error;
439 	}
440 
441 	if (is_active_cmd) {
442 		blocking_cmd_removed = (*pcmd_list)->cmd.is_blocking;
443 		pdev_queue = wlan_serialization_get_pdev_queue_obj(
444 				ser_pdev_obj, (*pcmd_list)->cmd.cmd_type);
445 
446 		if (blocking_cmd_removed)
447 			pdev_queue->blocking_cmd_active = 0;
448 
449 		vdev_id = wlan_vdev_get_id(cmd->vdev);
450 		pdev_queue->vdev_active_cmd_bitmap &= ~(1 << vdev_id);
451 	}
452 
453 	status = QDF_STATUS_SUCCESS;
454 
455 error:
456 	return status;
457 }
458 
459 enum wlan_serialization_cmd_status
460 wlan_ser_cancel_non_scan_cmd(
461 		struct wlan_ser_pdev_obj *ser_pdev_obj,
462 		struct wlan_objmgr_pdev *pdev, struct wlan_objmgr_vdev *vdev,
463 		struct wlan_serialization_command *cmd,
464 		enum wlan_serialization_cmd_type cmd_type,
465 		uint8_t is_active_queue, enum wlan_ser_cmd_attr cmd_attr)
466 {
467 	qdf_list_t *pdev_queue;
468 	qdf_list_t *vdev_queue;
469 	struct wlan_serialization_pdev_queue *pdev_q;
470 	uint32_t qsize;
471 	uint8_t vdev_id;
472 	bool is_blocking;
473 	struct wlan_serialization_command_list *cmd_list = NULL;
474 	struct wlan_serialization_command cmd_bkup;
475 	qdf_list_node_t *nnode = NULL, *pnode = NULL;
476 	enum wlan_serialization_cmd_status status = WLAN_SER_CMD_NOT_FOUND;
477 	struct wlan_objmgr_psoc *psoc = NULL;
478 	QDF_STATUS qdf_status;
479 	QDF_STATUS pdev_status, vdev_status;
480 	struct wlan_ser_vdev_obj *ser_vdev_obj;
481 
482 	ser_enter();
483 
484 	pdev_q = wlan_serialization_get_pdev_queue_obj(ser_pdev_obj, cmd_type);
485 
486 	pdev_queue = wlan_serialization_get_list_from_pdev_queue(
487 			ser_pdev_obj, cmd_type, is_active_queue);
488 
489 	if (pdev)
490 		psoc = wlan_pdev_get_psoc(pdev);
491 	else if (vdev)
492 		psoc = wlan_vdev_get_psoc(vdev);
493 	else if (cmd && cmd->vdev)
494 		psoc = wlan_vdev_get_psoc(cmd->vdev);
495 	else
496 		ser_debug("Can't find psoc");
497 
498 	wlan_serialization_acquire_lock(&pdev_q->pdev_queue_lock);
499 
500 	qsize = wlan_serialization_list_size(pdev_queue);
501 	while (!wlan_serialization_list_empty(pdev_queue) && qsize--) {
502 		if (wlan_serialization_get_cmd_from_queue(pdev_queue, &nnode)
503 		    != QDF_STATUS_SUCCESS) {
504 			ser_err("can't read cmd from queue");
505 			status = WLAN_SER_CMD_NOT_FOUND;
506 			break;
507 		}
508 		cmd_list =
509 			qdf_container_of(nnode,
510 					 struct wlan_serialization_command_list,
511 					 pdev_node);
512 		if (cmd && !wlan_serialization_match_cmd_id_type(
513 							nnode, cmd,
514 							WLAN_SER_PDEV_NODE)) {
515 			pnode = nnode;
516 			continue;
517 		}
518 
519 		if (vdev &&
520 		    !wlan_serialization_match_cmd_vdev(nnode,
521 						      vdev,
522 						      WLAN_SER_PDEV_NODE)) {
523 			pnode = nnode;
524 			continue;
525 		}
526 
527 		if (pdev &&
528 		    !wlan_serialization_match_cmd_pdev(nnode,
529 						       pdev,
530 						       WLAN_SER_PDEV_NODE)) {
531 			pnode = nnode;
532 			continue;
533 		}
534 
535 		if (cmd_type > WLAN_SER_CMD_NONSCAN && vdev &&
536 		    (!wlan_serialization_match_cmd_type(nnode, cmd_type,
537 							WLAN_SER_PDEV_NODE) ||
538 		    !wlan_serialization_match_cmd_vdev(nnode, vdev,
539 						       WLAN_SER_PDEV_NODE))) {
540 			pnode = nnode;
541 			continue;
542 		}
543 
544 		/*
545 		 * If a non-blocking cmd is required to be cancelled, but
546 		 * the nnode cmd is a blocking cmd then continue with the
547 		 * next command in the list else proceed with cmd cancel.
548 		 */
549 		if ((cmd_attr == WLAN_SER_CMD_ATTR_NONBLOCK) &&
550 		    wlan_serialization_match_cmd_blocking(nnode,
551 							  WLAN_SER_PDEV_NODE)) {
552 			pnode = nnode;
553 			continue;
554 		}
555 
556 		/*
557 		 * active queue can't be removed directly, requester needs to
558 		 * wait for active command response and send remove request for
559 		 * active command separately
560 		 */
561 		if (is_active_queue) {
562 			if (!psoc || !cmd_list) {
563 				ser_err("psoc:0x%pK, cmd_list:0x%pK",
564 					psoc, cmd_list);
565 				status = WLAN_SER_CMD_NOT_FOUND;
566 				break;
567 			}
568 
569 			/* Cancel request received for a cmd in active
570 			 * queue which has not been activated yet, we mark
571 			 * it as CMD_ACTIVE_MARKED_FOR_CANCEL and remove
572 			 * the cmd after activation
573 			 */
574 			if (qdf_atomic_test_bit(CMD_MARKED_FOR_ACTIVATION,
575 						&cmd_list->cmd_in_use)) {
576 				qdf_atomic_set_bit(CMD_ACTIVE_MARKED_FOR_CANCEL,
577 						   &cmd_list->cmd_in_use);
578 				status = WLAN_SER_CMD_MARKED_FOR_ACTIVATION;
579 				continue;
580 			}
581 
582 			qdf_status = wlan_serialization_find_and_stop_timer(
583 							psoc, &cmd_list->cmd,
584 							SER_CANCEL);
585 			if (QDF_IS_STATUS_ERROR(qdf_status)) {
586 				ser_err("Can't find timer for active cmd");
587 				status = WLAN_SER_CMD_NOT_FOUND;
588 				/*
589 				 * This should not happen, as an active command
590 				 * should always have the timer.
591 				 */
592 				QDF_BUG(0);
593 				break;
594 			}
595 
596 			status = WLAN_SER_CMD_IN_ACTIVE_LIST;
597 		}
598 
599 		qdf_mem_copy(&cmd_bkup, &cmd_list->cmd,
600 			     sizeof(struct wlan_serialization_command));
601 
602 		pdev_status =
603 			wlan_serialization_remove_node(pdev_queue,
604 						       &cmd_list->pdev_node);
605 
606 		ser_vdev_obj = wlan_serialization_get_vdev_obj(
607 					cmd_list->cmd.vdev);
608 
609 		vdev_queue = wlan_serialization_get_list_from_vdev_queue(
610 			ser_vdev_obj, cmd_type, is_active_queue);
611 
612 		vdev_status =
613 			wlan_serialization_remove_node(vdev_queue,
614 						       &cmd_list->vdev_node);
615 
616 		if (pdev_status != QDF_STATUS_SUCCESS ||
617 		    vdev_status != QDF_STATUS_SUCCESS) {
618 			ser_err("can't remove cmd from pdev/vdev queue");
619 			status = WLAN_SER_CMD_NOT_FOUND;
620 			break;
621 		}
622 
623 		qdf_mem_zero(&cmd_list->cmd,
624 			     sizeof(struct wlan_serialization_command));
625 		cmd_list->cmd_in_use = 0;
626 		qdf_status = wlan_serialization_insert_back(
627 			&pdev_q->cmd_pool_list,
628 			&cmd_list->pdev_node);
629 
630 		if (QDF_STATUS_SUCCESS != qdf_status) {
631 			ser_err("can't remove cmd from queue");
632 			status = WLAN_SER_CMD_NOT_FOUND;
633 			break;
634 		}
635 		nnode = pnode;
636 
637 		vdev_id = wlan_vdev_get_id(cmd_bkup.vdev);
638 		is_blocking = cmd_bkup.is_blocking;
639 
640 		wlan_ser_update_cmd_history(pdev_q, &cmd_bkup,
641 					    SER_CANCEL, false, is_active_queue);
642 
643 		wlan_serialization_release_lock(&pdev_q->pdev_queue_lock);
644 		/*
645 		 * call pending cmd's callback to notify that
646 		 * it is being removed
647 		 */
648 		if (cmd_bkup.cmd_cb) {
649 			/* caller should now do necessary clean up */
650 			ser_debug("cmd cb: type[%d] id[%d]",
651 				  cmd_bkup.cmd_type,
652 				  cmd_bkup.cmd_id);
653 			ser_debug("reason: WLAN_SER_CB_CANCEL_CMD");
654 			cmd_bkup.cmd_cb(&cmd_bkup,
655 					WLAN_SER_CB_CANCEL_CMD);
656 			/* caller should release the memory */
657 			ser_debug("reason: WLAN_SER_CB_RELEASE_MEM_CMD");
658 			cmd_bkup.cmd_cb(&cmd_bkup,
659 					WLAN_SER_CB_RELEASE_MEM_CMD);
660 		}
661 
662 		wlan_serialization_acquire_lock(&pdev_q->pdev_queue_lock);
663 
664 		if (is_active_queue) {
665 			if (is_blocking)
666 				pdev_q->blocking_cmd_active = 0;
667 			pdev_q->vdev_active_cmd_bitmap &= ~(1 << vdev_id);
668 			ser_debug("pdev_q->vdev_active_cmd_bitmap %x after reseting for vdev %d",
669 				  pdev_q->vdev_active_cmd_bitmap,
670 				  vdev_id);
671 		} else {
672 			if (is_blocking)
673 				pdev_q->blocking_cmd_waiting--;
674 
675 			status = WLAN_SER_CMD_IN_PENDING_LIST;
676 		}
677 
678 
679 		if (!vdev && !pdev)
680 			break;
681 	}
682 
683 	wlan_serialization_release_lock(&pdev_q->pdev_queue_lock);
684 
685 	ser_exit();
686 	return status;
687 }
688