xref: /wlan-dirver/qca-wifi-host-cmn/umac/cmn_services/mgmt_txrx/dispatcher/src/wlan_mgmt_txrx_tgt_api.c (revision f28396d060cff5c6519f883cb28ae0116ce479f1)
1 /*
2  * Copyright (c) 2016-2020 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 /**
20  *  DOC:    wlan_mgmt_txrx_tgt_api.c
21  *  This file contains mgmt txrx public API definitions for
22  *  southbound interface.
23  */
24 
25 #include "wlan_mgmt_txrx_tgt_api.h"
26 #include "wlan_mgmt_txrx_utils_api.h"
27 #include "../../core/src/wlan_mgmt_txrx_main_i.h"
28 #include "wlan_objmgr_psoc_obj.h"
29 #include "wlan_objmgr_peer_obj.h"
30 #include "wlan_objmgr_pdev_obj.h"
31 
32 
33 /**
34  * mgmt_get_spec_mgmt_action_subtype() - gets spec mgmt action subtype
35  * @action_code: action code
36  *
37  * This function returns the subtype for spectrum management action
38  * category.
39  *
40  * Return: mgmt frame type
41  */
42 static enum mgmt_frame_type
43 mgmt_get_spec_mgmt_action_subtype(uint8_t action_code)
44 {
45 	enum mgmt_frame_type frm_type;
46 
47 	switch (action_code) {
48 	case ACTION_SPCT_MSR_REQ:
49 		frm_type = MGMT_ACTION_MEAS_REQUEST;
50 		break;
51 	case ACTION_SPCT_MSR_RPRT:
52 		frm_type = MGMT_ACTION_MEAS_REPORT;
53 		break;
54 	case ACTION_SPCT_TPC_REQ:
55 		frm_type = MGMT_ACTION_TPC_REQUEST;
56 		break;
57 	case ACTION_SPCT_TPC_RPRT:
58 		frm_type = MGMT_ACTION_TPC_REPORT;
59 		break;
60 	case ACTION_SPCT_CHL_SWITCH:
61 		frm_type = MGMT_ACTION_CHAN_SWITCH;
62 		break;
63 	default:
64 		frm_type = MGMT_FRM_UNSPECIFIED;
65 		break;
66 	}
67 
68 	return frm_type;
69 }
70 
71 /**
72  * mgmt_get_qos_action_subtype() - gets qos action subtype
73  * @action_code: action code
74  *
75  * This function returns the subtype for qos action
76  * category.
77  *
78  * Return: mgmt frame type
79  */
80 static enum mgmt_frame_type
81 mgmt_get_qos_action_subtype(uint8_t action_code)
82 {
83 	enum mgmt_frame_type frm_type;
84 
85 	switch (action_code) {
86 	case QOS_ADD_TS_REQ:
87 		frm_type = MGMT_ACTION_QOS_ADD_TS_REQ;
88 		break;
89 	case QOS_ADD_TS_RSP:
90 		frm_type = MGMT_ACTION_QOS_ADD_TS_RSP;
91 		break;
92 	case QOS_DEL_TS_REQ:
93 		frm_type = MGMT_ACTION_QOS_DEL_TS_REQ;
94 		break;
95 	case QOS_SCHEDULE:
96 		frm_type = MGMT_ACTION_QOS_SCHEDULE;
97 		break;
98 	case QOS_MAP_CONFIGURE:
99 		frm_type = MGMT_ACTION_QOS_MAP_CONFIGURE;
100 		break;
101 	default:
102 		frm_type = MGMT_FRM_UNSPECIFIED;
103 		break;
104 	}
105 
106 	return frm_type;
107 }
108 
109 /**
110  * mgmt_get_dls_action_subtype() - gets dls action subtype
111  * @action_code: action code
112  *
113  * This function returns the subtype for dls action
114  * category.
115  *
116  * Return: mgmt frame type
117  */
118 static enum mgmt_frame_type
119 mgmt_get_dls_action_subtype(uint8_t action_code)
120 {
121 	enum mgmt_frame_type frm_type;
122 
123 	switch (action_code) {
124 	case DLS_REQUEST:
125 		frm_type = MGMT_ACTION_DLS_REQUEST;
126 		break;
127 	case DLS_RESPONSE:
128 		frm_type = MGMT_ACTION_DLS_RESPONSE;
129 		break;
130 	case DLS_TEARDOWN:
131 		frm_type = MGMT_ACTION_DLS_TEARDOWN;
132 		break;
133 	default:
134 		frm_type = MGMT_FRM_UNSPECIFIED;
135 		break;
136 	}
137 
138 	return frm_type;
139 }
140 
141 /**
142  * mgmt_get_back_action_subtype() - gets block ack action subtype
143  * @action_code: action code
144  *
145  * This function returns the subtype for block ack action
146  * category.
147  *
148  * Return: mgmt frame type
149  */
150 static enum mgmt_frame_type
151 mgmt_get_back_action_subtype(uint8_t action_code)
152 {
153 	enum mgmt_frame_type frm_type;
154 
155 	switch (action_code) {
156 	case ADDBA_REQUEST:
157 		frm_type = MGMT_ACTION_BA_ADDBA_REQUEST;
158 		break;
159 	case ADDBA_RESPONSE:
160 		frm_type = MGMT_ACTION_BA_ADDBA_RESPONSE;
161 		break;
162 	case DELBA:
163 		frm_type = MGMT_ACTION_BA_DELBA;
164 		break;
165 	default:
166 		frm_type = MGMT_FRM_UNSPECIFIED;
167 		break;
168 	}
169 
170 	return frm_type;
171 }
172 
173 /**
174  * mgmt_get_public_action_subtype() - gets public action subtype
175  * @action_code: action code
176  *
177  * This function returns the subtype for public action
178  * category.
179  *
180  * Return: mgmt frame type
181  */
182 static enum mgmt_frame_type
183 mgmt_get_public_action_subtype(uint8_t action_code)
184 {
185 	enum mgmt_frame_type frm_type;
186 
187 	switch (action_code) {
188 	case PUB_ACTION_2040_BSS_COEXISTENCE:
189 		frm_type = MGMT_ACTION_2040_BSS_COEXISTENCE;
190 		break;
191 	case PUB_ACTION_EXT_CHANNEL_SWITCH_ID:
192 		frm_type = MGMT_ACTION_EXT_CHANNEL_SWITCH_ID;
193 		break;
194 	case PUB_ACTION_VENDOR_SPECIFIC:
195 		frm_type = MGMT_ACTION_VENDOR_SPECIFIC;
196 		break;
197 	case PUB_ACTION_TDLS_DISCRESP:
198 		frm_type = MGMT_ACTION_TDLS_DISCRESP;
199 		break;
200 	case PUB_ACTION_GAS_INITIAL_REQUEST:
201 		frm_type = MGMT_ACTION_GAS_INITIAL_REQUEST;
202 		break;
203 	case PUB_ACTION_GAS_INITIAL_RESPONSE:
204 		frm_type = MGMT_ACTION_GAS_INITIAL_RESPONSE;
205 		break;
206 	case PUB_ACTION_GAS_COMEBACK_REQUEST:
207 		frm_type = MGMT_ACTION_GAS_COMEBACK_REQUEST;
208 		break;
209 	case PUB_ACTION_GAS_COMEBACK_RESPONSE:
210 		frm_type = MGMT_ACTION_GAS_COMEBACK_RESPONSE;
211 		break;
212 	default:
213 		frm_type = MGMT_FRM_UNSPECIFIED;
214 		break;
215 	}
216 
217 	return frm_type;
218 }
219 
220 /**
221  * mgmt_get_rrm_action_subtype() - gets rrm action subtype
222  * @action_code: action code
223  *
224  * This function returns the subtype for rrm action
225  * category.
226  *
227  * Return: mgmt frame type
228  */
229 static enum mgmt_frame_type
230 mgmt_get_rrm_action_subtype(uint8_t action_code)
231 {
232 	enum mgmt_frame_type frm_type;
233 
234 	switch (action_code) {
235 	case RRM_RADIO_MEASURE_REQ:
236 		frm_type = MGMT_ACTION_RRM_RADIO_MEASURE_REQ;
237 		break;
238 	case RRM_RADIO_MEASURE_RPT:
239 		frm_type = MGMT_ACTION_RRM_RADIO_MEASURE_RPT;
240 		break;
241 	case RRM_LINK_MEASUREMENT_REQ:
242 		frm_type = MGMT_ACTION_RRM_LINK_MEASUREMENT_REQ;
243 		break;
244 	case RRM_LINK_MEASUREMENT_RPT:
245 		frm_type = MGMT_ACTION_RRM_LINK_MEASUREMENT_RPT;
246 		break;
247 	case RRM_NEIGHBOR_REQ:
248 		frm_type = MGMT_ACTION_RRM_NEIGHBOR_REQ;
249 		break;
250 	case RRM_NEIGHBOR_RPT:
251 		frm_type = MGMT_ACTION_RRM_NEIGHBOR_RPT;
252 		break;
253 	default:
254 		frm_type = MGMT_FRM_UNSPECIFIED;
255 		break;
256 	}
257 
258 	return frm_type;
259 }
260 
261 static enum mgmt_frame_type
262 mgmt_get_ft_action_subtype(uint8_t action_code)
263 {
264 	enum mgmt_frame_type frm_type;
265 
266 	switch (action_code) {
267 	case FT_FAST_BSS_TRNST_REQ:
268 		frm_type = MGMT_ACTION_FT_REQUEST;
269 		break;
270 	case FT_FAST_BSS_TRNST_RES:
271 		frm_type = MGMT_ACTION_FT_RESPONSE;
272 		break;
273 	case FT_FAST_BSS_TRNST_CONFIRM:
274 		frm_type = MGMT_ACTION_FT_CONFIRM;
275 		break;
276 	case FT_FAST_BSS_TRNST_ACK:
277 		frm_type = MGMT_ACTION_FT_ACK;
278 		break;
279 	default:
280 		frm_type = MGMT_FRM_UNSPECIFIED;
281 		break;
282 	}
283 
284 	return frm_type;
285 }
286 
287 /**
288  * mgmt_get_ht_action_subtype() - gets ht action subtype
289  * @action_code: action code
290  *
291  * This function returns the subtype for ht action
292  * category.
293  *
294  * Return: mgmt frame type
295  */
296 static enum mgmt_frame_type
297 mgmt_get_ht_action_subtype(uint8_t action_code)
298 {
299 	enum mgmt_frame_type frm_type;
300 
301 	switch (action_code) {
302 	case HT_ACTION_NOTIFY_CHANWIDTH:
303 		frm_type = MGMT_ACTION_HT_NOTIFY_CHANWIDTH;
304 		break;
305 	case HT_ACTION_SMPS:
306 		frm_type = MGMT_ACTION_HT_SMPS;
307 		break;
308 	case HT_ACTION_PSMP:
309 		frm_type = MGMT_ACTION_HT_PSMP;
310 		break;
311 	case HT_ACTION_PCO_PHASE:
312 		frm_type = MGMT_ACTION_HT_PCO_PHASE;
313 		break;
314 	case HT_ACTION_CSI:
315 		frm_type = MGMT_ACTION_HT_CSI;
316 		break;
317 	case HT_ACTION_NONCOMPRESSED_BF:
318 		frm_type = MGMT_ACTION_HT_NONCOMPRESSED_BF;
319 		break;
320 	case HT_ACTION_COMPRESSED_BF:
321 		frm_type = MGMT_ACTION_HT_COMPRESSED_BF;
322 		break;
323 	case HT_ACTION_ASEL_IDX_FEEDBACK:
324 		frm_type = MGMT_ACTION_HT_ASEL_IDX_FEEDBACK;
325 		break;
326 	default:
327 		frm_type = MGMT_FRM_UNSPECIFIED;
328 		break;
329 	}
330 
331 	return frm_type;
332 }
333 
334 /**
335  * mgmt_get_sa_query_action_subtype() - gets sa query action subtype
336  * @action_code: action code
337  *
338  * This function returns the subtype for sa query action
339  * category.
340  *
341  * Return: mgmt frame type
342  */
343 static enum mgmt_frame_type
344 mgmt_get_sa_query_action_subtype(uint8_t action_code)
345 {
346 	enum mgmt_frame_type frm_type;
347 
348 	switch (action_code) {
349 	case SA_QUERY_REQUEST:
350 		frm_type = MGMT_ACTION_SA_QUERY_REQUEST;
351 		break;
352 	case SA_QUERY_RESPONSE:
353 		frm_type = MGMT_ACTION_SA_QUERY_RESPONSE;
354 		break;
355 	default:
356 		frm_type = MGMT_FRM_UNSPECIFIED;
357 		break;
358 	}
359 
360 	return frm_type;
361 }
362 
363 /**
364  * mgmt_get_pdpa_action_subtype() - gets pdpa action subtype
365  * @action_code: action code
366  *
367  * This function returns the subtype for protected dual public
368  * action category.
369  *
370  * Return: mgmt frame type
371  */
372 static enum mgmt_frame_type
373 mgmt_get_pdpa_action_subtype(uint8_t action_code)
374 {
375 	enum mgmt_frame_type frm_type;
376 
377 	switch (action_code) {
378 	case PDPA_GAS_INIT_REQ:
379 		frm_type = MGMT_ACTION_PDPA_GAS_INIT_REQ;
380 		break;
381 	case PDPA_GAS_INIT_RSP:
382 		frm_type = MGMT_ACTION_PDPA_GAS_INIT_RSP;
383 		break;
384 	case PDPA_GAS_COMEBACK_REQ:
385 		frm_type = MGMT_ACTION_PDPA_GAS_COMEBACK_REQ;
386 		break;
387 	case PDPA_GAS_COMEBACK_RSP:
388 		frm_type = MGMT_ACTION_PDPA_GAS_COMEBACK_RSP;
389 		break;
390 	default:
391 		frm_type = MGMT_FRM_UNSPECIFIED;
392 		break;
393 	}
394 
395 	return frm_type;
396 }
397 
398 /**
399  * mgmt_get_wnm_action_subtype() - gets wnm action subtype
400  * @action_code: action code
401  *
402  * This function returns the subtype for wnm action
403  * category.
404  *
405  * Return: mgmt frame type
406  */
407 static enum mgmt_frame_type
408 mgmt_get_wnm_action_subtype(uint8_t action_code)
409 {
410 	enum mgmt_frame_type frm_type;
411 
412 	switch (action_code) {
413 	case WNM_BSS_TM_QUERY:
414 		frm_type = MGMT_ACTION_WNM_BSS_TM_QUERY;
415 		break;
416 	case WNM_BSS_TM_REQUEST:
417 		frm_type = MGMT_ACTION_WNM_BSS_TM_REQUEST;
418 		break;
419 	case WNM_BSS_TM_RESPONSE:
420 		frm_type = MGMT_ACTION_WNM_BSS_TM_RESPONSE;
421 		break;
422 	case WNM_NOTIF_REQUEST:
423 		frm_type = MGMT_ACTION_WNM_NOTIF_REQUEST;
424 		break;
425 	case WNM_NOTIF_RESPONSE:
426 		frm_type = MGMT_ACTION_WNM_NOTIF_RESPONSE;
427 		break;
428 	case WNM_FMS_REQ:
429 		frm_type = MGMT_ACTION_WNM_FMS_REQ;
430 		break;
431 	case WNM_FMS_RESP:
432 		frm_type = MGMT_ACTION_WNM_FMS_RESP;
433 		break;
434 	case WNM_TFS_REQ:
435 		frm_type = MGMT_ACTION_WNM_TFS_REQ;
436 		break;
437 	case WNM_TFS_RESP:
438 		frm_type = MGMT_ACTION_WNM_TFS_RESP;
439 		break;
440 	case WNM_TFS_NOTIFY:
441 		frm_type = MGMT_ACTION_WNM_TFS_NOTIFY;
442 		break;
443 	case WNM_SLEEP_REQ:
444 		frm_type = MGMT_ACTION_WNM_SLEEP_REQ;
445 		break;
446 	case WNM_SLEEP_RESP:
447 		frm_type = MGMT_ACTION_WNM_SLEEP_RESP;
448 		break;
449 	case WNM_TIM_REQ:
450 		frm_type = MGMT_ACTION_WNM_TFS_REQ;
451 		break;
452 	case WNM_TIM_RESP:
453 		frm_type = MGMT_ACTION_WNM_TFS_RESP;
454 		break;
455 	default:
456 		frm_type = MGMT_FRM_UNSPECIFIED;
457 		break;
458 	}
459 
460 	return frm_type;
461 }
462 
463 /**
464  * mgmt_get_wnm_action_subtype() - gets tdls action subtype
465  * @action_code: action code
466  *
467  * This function returns the subtype for tdls action
468  * category.
469  *
470  * Return: mgmt frame type
471  */
472 static enum mgmt_frame_type
473 mgmt_get_tdls_action_subtype(uint8_t action_code)
474 {
475 	enum mgmt_frame_type frm_type;
476 
477 	switch (action_code) {
478 	case TDLS_SETUP_REQUEST:
479 		frm_type = MGMT_ACTION_TDLS_SETUP_REQ;
480 		break;
481 	case TDLS_SETUP_RESPONSE:
482 		frm_type = MGMT_ACTION_TDLS_SETUP_RSP;
483 		break;
484 	case TDLS_SETUP_CONFIRM:
485 		frm_type = MGMT_ACTION_TDLS_SETUP_CNF;
486 		break;
487 	case TDLS_TEARDOWN:
488 		frm_type = MGMT_ACTION_TDLS_TEARDOWN;
489 		break;
490 	case TDLS_PEER_TRAFFIC_INDICATION:
491 		frm_type = MGMT_ACTION_TDLS_PEER_TRAFFIC_IND;
492 		break;
493 	case TDLS_CHANNEL_SWITCH_REQUEST:
494 		frm_type = MGMT_ACTION_TDLS_CH_SWITCH_REQ;
495 		break;
496 	case TDLS_CHANNEL_SWITCH_RESPONSE:
497 		frm_type = MGMT_ACTION_TDLS_CH_SWITCH_RSP;
498 		break;
499 	case TDLS_PEER_PSM_REQUEST:
500 		frm_type = MGMT_ACTION_TDLS_PEER_PSM_REQUEST;
501 		break;
502 	case TDLS_PEER_PSM_RESPONSE:
503 		frm_type = MGMT_ACTION_TDLS_PEER_PSM_RESPONSE;
504 		break;
505 	case TDLS_PEER_TRAFFIC_RESPONSE:
506 		frm_type = MGMT_ACTION_TDLS_PEER_TRAFFIC_RSP;
507 		break;
508 	case TDLS_DISCOVERY_REQUEST:
509 		frm_type = MGMT_ACTION_TDLS_DIS_REQ;
510 		break;
511 	default:
512 		frm_type = MGMT_FRM_UNSPECIFIED;
513 		break;
514 	}
515 
516 	return frm_type;
517 }
518 
519 /**
520  * mgmt_get_mesh_action_subtype() - gets mesh action subtype
521  * @action_code: action code
522  *
523  * This function returns the subtype for mesh action
524  * category.
525  *
526  * Return: mgmt frame type
527  */
528 static enum mgmt_frame_type
529 mgmt_get_mesh_action_subtype(uint8_t action_code)
530 {
531 	enum mgmt_frame_type frm_type;
532 
533 	switch (action_code) {
534 	case MESH_ACTION_LINK_METRIC_REPORT:
535 		frm_type = MGMT_ACTION_MESH_LINK_METRIC_REPORT;
536 		break;
537 	case MESH_ACTION_HWMP_PATH_SELECTION:
538 		frm_type = MGMT_ACTION_MESH_HWMP_PATH_SELECTION;
539 		break;
540 	case MESH_ACTION_GATE_ANNOUNCEMENT:
541 		frm_type = MGMT_ACTION_MESH_GATE_ANNOUNCEMENT;
542 		break;
543 	case MESH_ACTION_CONGESTION_CONTROL_NOTIFICATION:
544 		frm_type = MGMT_ACTION_MESH_CONGESTION_CONTROL_NOTIFICATION;
545 		break;
546 	case MESH_ACTION_MCCA_SETUP_REQUEST:
547 		frm_type = MGMT_ACTION_MESH_MCCA_SETUP_REQUEST;
548 		break;
549 	case MESH_ACTION_MCCA_SETUP_REPLY:
550 		frm_type = MGMT_ACTION_MESH_MCCA_SETUP_REPLY;
551 		break;
552 	case MESH_ACTION_MCCA_ADVERTISEMENT_REQUEST:
553 		frm_type = MGMT_ACTION_MESH_MCCA_ADVERTISEMENT_REQUEST;
554 		break;
555 	case MESH_ACTION_MCCA_ADVERTISEMENT:
556 		frm_type = MGMT_ACTION_MESH_MCCA_ADVERTISEMENT;
557 		break;
558 	case MESH_ACTION_MCCA_TEARDOWN:
559 		frm_type = MGMT_ACTION_MESH_MCCA_TEARDOWN;
560 		break;
561 	case MESH_ACTION_TBTT_ADJUSTMENT_REQUEST:
562 		frm_type = MGMT_ACTION_MESH_TBTT_ADJUSTMENT_REQUEST;
563 		break;
564 	case MESH_ACTION_TBTT_ADJUSTMENT_RESPONSE:
565 		frm_type = MGMT_ACTION_MESH_TBTT_ADJUSTMENT_RESPONSE;
566 		break;
567 	default:
568 		frm_type = MGMT_FRM_UNSPECIFIED;
569 		break;
570 	}
571 
572 	return frm_type;
573 }
574 
575 /**
576  * mgmt_get_self_prot_action_subtype() - gets self prot. action subtype
577  * @action_code: action code
578  *
579  * This function returns the subtype for self protected action
580  * category.
581  *
582  * Return: mgmt frame type
583  */
584 static enum mgmt_frame_type
585 mgmt_get_self_prot_action_subtype(uint8_t action_code)
586 {
587 	enum mgmt_frame_type frm_type;
588 
589 	switch (action_code) {
590 	case SP_MESH_PEERING_OPEN:
591 		frm_type = MGMT_ACTION_SP_MESH_PEERING_OPEN;
592 		break;
593 	case SP_MESH_PEERING_CONFIRM:
594 		frm_type = MGMT_ACTION_SP_MESH_PEERING_CONFIRM;
595 		break;
596 	case SP_MESH_PEERING_CLOSE:
597 		frm_type = MGMT_ACTION_SP_MESH_PEERING_CLOSE;
598 		break;
599 	case SP_MGK_INFORM:
600 		frm_type = MGMT_ACTION_SP_MGK_INFORM;
601 		break;
602 	case SP_MGK_ACK:
603 		frm_type = MGMT_ACTION_SP_MGK_ACK;
604 		break;
605 	default:
606 		frm_type = MGMT_FRM_UNSPECIFIED;
607 		break;
608 	}
609 
610 	return frm_type;
611 }
612 
613 /**
614  * mgmt_get_wmm_action_subtype() - gets wmm action subtype
615  * @action_code: action code
616  *
617  * This function returns the subtype for wmm action
618  * category.
619  *
620  * Return: mgmt frame type
621  */
622 static enum mgmt_frame_type
623 mgmt_get_wmm_action_subtype(uint8_t action_code)
624 {
625 	enum mgmt_frame_type frm_type;
626 
627 	switch (action_code) {
628 	case WMM_QOS_SETUP_REQ:
629 		frm_type = MGMT_ACTION_WMM_QOS_SETUP_REQ;
630 		break;
631 	case WMM_QOS_SETUP_RESP:
632 		frm_type = MGMT_ACTION_WMM_QOS_SETUP_RESP;
633 		break;
634 	case WMM_QOS_TEARDOWN:
635 		frm_type = MGMT_ACTION_WMM_QOS_TEARDOWN;
636 		break;
637 	default:
638 		frm_type = MGMT_FRM_UNSPECIFIED;
639 		break;
640 	}
641 
642 	return frm_type;
643 }
644 
645 /**
646  * mgmt_get_vht_action_subtype() - gets vht action subtype
647  * @action_code: action code
648  *
649  * This function returns the subtype for vht action
650  * category.
651  *
652  * Return: mgmt frame type
653  */
654 static enum mgmt_frame_type
655 mgmt_get_vht_action_subtype(uint8_t action_code)
656 {
657 	enum mgmt_frame_type frm_type;
658 
659 	switch (action_code) {
660 	case VHT_ACTION_COMPRESSED_BF:
661 		frm_type = MGMT_ACTION_VHT_COMPRESSED_BF;
662 		break;
663 	case VHT_ACTION_GID_NOTIF:
664 		frm_type = MGMT_ACTION_VHT_GID_NOTIF;
665 		break;
666 	case VHT_ACTION_OPMODE_NOTIF:
667 		frm_type = MGMT_ACTION_VHT_OPMODE_NOTIF;
668 		break;
669 	default:
670 		frm_type = MGMT_FRM_UNSPECIFIED;
671 		break;
672 	}
673 
674 	return frm_type;
675 }
676 
677 /**
678  * mgmt_get_fst_action_subtype() - gets fst action subtype
679  * @action_code: action code
680  *
681  * This function returns the subtype for fst action
682  * category.
683  *
684  * Return: mgmt frame type
685  */
686 static enum mgmt_frame_type
687 mgmt_get_fst_action_subtype(uint8_t action_code)
688 {
689 	enum mgmt_frame_type frm_type;
690 
691 	switch (action_code) {
692 	case FST_SETUP_REQ:
693 		frm_type = MGMT_ACTION_FST_SETUP_REQ;
694 		break;
695 	case FST_SETUP_RSP:
696 		frm_type = MGMT_ACTION_FST_SETUP_RSP;
697 		break;
698 	case FST_TEAR_DOWN:
699 		frm_type = MGMT_ACTION_FST_TEAR_DOWN;
700 		break;
701 	case FST_ACK_REQ:
702 		frm_type = MGMT_ACTION_FST_ACK_REQ;
703 		break;
704 	case FST_ACK_RSP:
705 		frm_type = MGMT_ACTION_FST_ACK_RSP;
706 		break;
707 	case FST_ON_CHANNEL_TUNNEL:
708 		frm_type = MGMT_ACTION_FST_ON_CHANNEL_TUNNEL;
709 		break;
710 	default:
711 		frm_type = MGMT_FRM_UNSPECIFIED;
712 		break;
713 	}
714 
715 	return frm_type;
716 }
717 
718 /**
719  * mgmt_txrx_get_action_frm_subtype() - gets action frm subtype
720  * @mpdu_data_ptr: pointer to mpdu data
721  *
722  * This function determines the action category of the frame
723  * and calls respective function to get mgmt frame type.
724  *
725  * Return: mgmt frame type
726  */
727 static enum mgmt_frame_type
728 mgmt_txrx_get_action_frm_subtype(uint8_t *mpdu_data_ptr)
729 {
730 	struct action_frm_hdr *action_hdr =
731 			(struct action_frm_hdr *)mpdu_data_ptr;
732 	enum mgmt_frame_type frm_type;
733 
734 	switch (action_hdr->action_category) {
735 	case ACTION_CATEGORY_SPECTRUM_MGMT:
736 		frm_type = mgmt_get_spec_mgmt_action_subtype(
737 						action_hdr->action_code);
738 		break;
739 	case ACTION_FAST_BSS_TRNST:
740 		frm_type = mgmt_get_ft_action_subtype(action_hdr->action_code);
741 		break;
742 	case ACTION_CATEGORY_QOS:
743 		frm_type = mgmt_get_qos_action_subtype(action_hdr->action_code);
744 		break;
745 	case ACTION_CATEGORY_DLS:
746 		frm_type = mgmt_get_dls_action_subtype(action_hdr->action_code);
747 		break;
748 	case ACTION_CATEGORY_BACK:
749 		frm_type = mgmt_get_back_action_subtype(
750 						action_hdr->action_code);
751 		break;
752 	case ACTION_CATEGORY_PUBLIC:
753 		frm_type = mgmt_get_public_action_subtype(
754 						action_hdr->action_code);
755 		break;
756 	case ACTION_CATEGORY_RRM:
757 		frm_type = mgmt_get_rrm_action_subtype(action_hdr->action_code);
758 		break;
759 	case ACTION_CATEGORY_HT:
760 		frm_type = mgmt_get_ht_action_subtype(action_hdr->action_code);
761 		break;
762 	case ACTION_CATEGORY_SA_QUERY:
763 		frm_type = mgmt_get_sa_query_action_subtype(
764 						action_hdr->action_code);
765 		break;
766 	case ACTION_CATEGORY_PROTECTED_DUAL_OF_PUBLIC_ACTION:
767 		frm_type = mgmt_get_pdpa_action_subtype(
768 						action_hdr->action_code);
769 		break;
770 	case ACTION_CATEGORY_WNM:
771 		frm_type = mgmt_get_wnm_action_subtype(action_hdr->action_code);
772 		break;
773 	case ACTION_CATEGORY_TDLS:
774 		frm_type = mgmt_get_tdls_action_subtype(
775 						action_hdr->action_code);
776 		break;
777 	case ACTION_CATEGORY_MESH_ACTION:
778 		frm_type = mgmt_get_mesh_action_subtype(
779 						action_hdr->action_code);
780 		break;
781 	case ACTION_CATEGORY_SELF_PROTECTED:
782 		frm_type = mgmt_get_self_prot_action_subtype(
783 						action_hdr->action_code);
784 		break;
785 	case ACTION_CATEGORY_WMM:
786 		frm_type = mgmt_get_wmm_action_subtype(action_hdr->action_code);
787 		break;
788 	case ACTION_CATEGORY_VHT:
789 		frm_type = mgmt_get_vht_action_subtype(action_hdr->action_code);
790 		break;
791 	case ACTION_CATEGORY_VENDOR_SPECIFIC:
792 		frm_type = MGMT_ACTION_CATEGORY_VENDOR_SPECIFIC;
793 		break;
794 	case ACTION_CATEGORY_FST:
795 		frm_type = mgmt_get_fst_action_subtype(action_hdr->action_code);
796 		break;
797 	default:
798 		frm_type = MGMT_FRM_UNSPECIFIED;
799 		break;
800 	}
801 
802 	return frm_type;
803 }
804 
805 /**
806  * mgmt_txrx_get_frm_type() - gets mgmt frm type
807  * @mgmt_subtype: mgmt subtype
808  * @mpdu_data_ptr: pointer to mpdu data
809  *
810  * This function returns mgmt frame type of the frame
811  * based on the mgmt subtype.
812  *
813  * Return: mgmt frame type
814  */
815 static enum mgmt_frame_type
816 mgmt_txrx_get_frm_type(uint8_t mgmt_subtype, uint8_t *mpdu_data_ptr)
817 {
818 	enum mgmt_frame_type frm_type;
819 
820 	switch (mgmt_subtype) {
821 	case MGMT_SUBTYPE_ASSOC_REQ:
822 		frm_type = MGMT_ASSOC_REQ;
823 		break;
824 	case MGMT_SUBTYPE_ASSOC_RESP:
825 		frm_type = MGMT_ASSOC_RESP;
826 		break;
827 	case MGMT_SUBTYPE_REASSOC_REQ:
828 		frm_type = MGMT_ASSOC_REQ;
829 		break;
830 	case MGMT_SUBTYPE_REASSOC_RESP:
831 		frm_type = MGMT_REASSOC_RESP;
832 		break;
833 	case MGMT_SUBTYPE_PROBE_REQ:
834 		frm_type = MGMT_PROBE_REQ;
835 		break;
836 	case MGMT_SUBTYPE_PROBE_RESP:
837 		frm_type = MGMT_PROBE_RESP;
838 		break;
839 	case MGMT_SUBTYPE_BEACON:
840 		frm_type = MGMT_BEACON;
841 		break;
842 	case MGMT_SUBTYPE_ATIM:
843 		frm_type = MGMT_ATIM;
844 		break;
845 	case MGMT_SUBTYPE_DISASSOC:
846 		frm_type = MGMT_DISASSOC;
847 		break;
848 	case MGMT_SUBTYPE_AUTH:
849 		frm_type = MGMT_AUTH;
850 		break;
851 	case MGMT_SUBTYPE_DEAUTH:
852 		frm_type = MGMT_DEAUTH;
853 		break;
854 	case MGMT_SUBTYPE_ACTION:
855 	case MGMT_SUBTYPE_ACTION_NO_ACK:
856 		frm_type = mgmt_txrx_get_action_frm_subtype(mpdu_data_ptr);
857 		break;
858 	default:
859 		frm_type = MGMT_FRM_UNSPECIFIED;
860 		break;
861 	}
862 
863 	return frm_type;
864 }
865 
866 /**
867  * wlan_mgmt_txrx_rx_handler_list_copy() - copies rx handler list
868  * @rx_handler: pointer to rx handler list
869  * @rx_handler_head: pointer to head of the copies list
870  * @rx_handler_tail: pointer to tail of the copies list
871  *
872  * This function copies the rx handler linked list into a local
873  * linked list.
874  *
875  * Return: QDF_STATUS_SUCCESS in case of success
876  */
877 static QDF_STATUS wlan_mgmt_txrx_rx_handler_list_copy(
878 			struct mgmt_rx_handler *rx_handler,
879 			struct mgmt_rx_handler **rx_handler_head,
880 			struct mgmt_rx_handler **rx_handler_tail)
881 {
882 	struct mgmt_rx_handler *rx_handler_node;
883 
884 	while (rx_handler) {
885 		rx_handler_node =
886 				qdf_mem_malloc_atomic(sizeof(*rx_handler_node));
887 		if (!rx_handler_node) {
888 			mgmt_txrx_err_rl("Couldn't allocate memory for rx handler node");
889 			return QDF_STATUS_E_NOMEM;
890 		}
891 
892 		rx_handler_node->comp_id = rx_handler->comp_id;
893 		rx_handler_node->rx_cb = rx_handler->rx_cb;
894 		rx_handler_node->next = NULL;
895 
896 		if (!(*rx_handler_head)) {
897 			*rx_handler_head = rx_handler_node;
898 			*rx_handler_tail = *rx_handler_head;
899 		} else {
900 			(*rx_handler_tail)->next = rx_handler_node;
901 			*rx_handler_tail = (*rx_handler_tail)->next;
902 		}
903 		rx_handler = rx_handler->next;
904 	}
905 
906 	return QDF_STATUS_SUCCESS;
907 }
908 
909 static bool
910 mgmt_rx_is_bssid_valid(struct qdf_mac_addr *mac_addr)
911 {
912 	if (qdf_is_macaddr_group(mac_addr) ||
913 	    qdf_is_macaddr_zero(mac_addr))
914 		return false;
915 
916 	return true;
917 }
918 
919 QDF_STATUS tgt_mgmt_txrx_rx_frame_handler(
920 			struct wlan_objmgr_psoc *psoc,
921 			qdf_nbuf_t buf,
922 			struct mgmt_rx_event_params *mgmt_rx_params)
923 {
924 	struct mgmt_txrx_priv_psoc_context *mgmt_txrx_psoc_ctx;
925 	struct ieee80211_frame *wh;
926 	qdf_nbuf_t copy_buf;
927 	struct wlan_objmgr_peer *peer = NULL;
928 	uint8_t mgmt_type, mgmt_subtype;
929 	uint8_t *mac_addr, *mpdu_data_ptr;
930 	enum mgmt_frame_type frm_type;
931 	struct mgmt_rx_handler *rx_handler;
932 	struct mgmt_rx_handler *rx_handler_head = NULL, *rx_handler_tail = NULL;
933 	u_int8_t *data, *ivp = NULL;
934 	uint16_t buflen;
935 	QDF_STATUS status = QDF_STATUS_SUCCESS;
936 	bool is_from_addr_valid, is_bssid_valid;
937 
938 	if (!buf) {
939 		mgmt_txrx_err("buffer passed is NULL");
940 		return QDF_STATUS_E_INVAL;
941 	}
942 
943 	if (!psoc) {
944 		mgmt_txrx_err("psoc_ctx passed is NULL");
945 		qdf_nbuf_free(buf);
946 		return QDF_STATUS_E_INVAL;
947 	}
948 
949 	data = (uint8_t *)qdf_nbuf_data(buf);
950 	wh = (struct ieee80211_frame *)data;
951 	buflen = qdf_nbuf_len(buf);
952 
953 	/**
954 	 * TO DO (calculate pdev)
955 	 * Waiting for a new parameter: pdev id to get added in rx event
956 	 */
957 
958 	mgmt_type = (wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
959 	mgmt_subtype = (wh)->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK;
960 
961 	if (mgmt_type != IEEE80211_FC0_TYPE_MGT) {
962 		mgmt_txrx_err("Rx event doesn't conatin a mgmt. packet, %d",
963 			mgmt_type);
964 		qdf_nbuf_free(buf);
965 		return QDF_STATUS_E_FAILURE;
966 	}
967 
968 	is_from_addr_valid = mgmt_rx_is_bssid_valid((struct qdf_mac_addr *)
969 							      wh->i_addr2);
970 	is_bssid_valid = mgmt_rx_is_bssid_valid((struct qdf_mac_addr *)
971 							      wh->i_addr3);
972 
973 	if (!is_from_addr_valid && !is_bssid_valid) {
974 		mgmt_txrx_debug_rl("from addr %pM bssid addr %pM both not valid, dropping them",
975 				   wh->i_addr2, wh->i_addr3);
976 		qdf_nbuf_free(buf);
977 		return QDF_STATUS_E_FAILURE;
978 	}
979 
980 	if ((mgmt_subtype == MGMT_SUBTYPE_BEACON ||
981 	     mgmt_subtype == MGMT_SUBTYPE_PROBE_RESP) &&
982 	    !(is_from_addr_valid && is_bssid_valid)) {
983 		mgmt_txrx_debug_rl("from addr %pM bssid addr %pM not valid, modifying them",
984 				   wh->i_addr2, wh->i_addr3);
985 		if (!is_from_addr_valid)
986 			qdf_mem_copy(wh->i_addr2, wh->i_addr3,
987 				     QDF_MAC_ADDR_SIZE);
988 		else
989 			qdf_mem_copy(wh->i_addr3, wh->i_addr2,
990 				     QDF_MAC_ADDR_SIZE);
991 	}
992 
993 	/* mpdu_data_ptr is pointer to action header */
994 	mpdu_data_ptr = (uint8_t *)qdf_nbuf_data(buf) +
995 			sizeof(struct ieee80211_frame);
996 	if ((wh->i_fc[1] & IEEE80211_FC1_WEP) &&
997 	    !qdf_is_macaddr_group((struct qdf_mac_addr *)wh->i_addr1) &&
998 	    !qdf_is_macaddr_broadcast((struct qdf_mac_addr *)wh->i_addr1)) {
999 
1000 		if (buflen > (sizeof(struct ieee80211_frame) +
1001 			WLAN_HDR_EXT_IV_LEN))
1002 			ivp = data + sizeof(struct ieee80211_frame);
1003 
1004 		/* Set mpdu_data_ptr based on EXT IV bit
1005 		 * if EXT IV bit set, CCMP using PMF 8 bytes of IV is present
1006 		 * else for WEP using PMF, 4 bytes of IV is present
1007 		 */
1008 		if (ivp && (ivp[WLAN_HDR_IV_LEN] & WLAN_HDR_EXT_IV_BIT)) {
1009 			if (buflen <= (sizeof(struct ieee80211_frame)
1010 					+ IEEE80211_CCMP_HEADERLEN)) {
1011 				qdf_nbuf_free(buf);
1012 				return QDF_STATUS_E_FAILURE;
1013 			}
1014 			mpdu_data_ptr += IEEE80211_CCMP_HEADERLEN;
1015 		} else {
1016 			if (buflen <= (sizeof(struct ieee80211_frame)
1017 					+ WLAN_HDR_EXT_IV_LEN)) {
1018 				qdf_nbuf_free(buf);
1019 				return QDF_STATUS_E_FAILURE;
1020 			}
1021 			mpdu_data_ptr += WLAN_HDR_EXT_IV_LEN;
1022 		}
1023 	}
1024 
1025 	frm_type = mgmt_txrx_get_frm_type(mgmt_subtype, mpdu_data_ptr);
1026 	if (frm_type == MGMT_FRM_UNSPECIFIED) {
1027 		mgmt_txrx_debug_rl("Unspecified mgmt frame type fc: %x %x",
1028 				   wh->i_fc[0], wh->i_fc[1]);
1029 		qdf_nbuf_free(buf);
1030 		return QDF_STATUS_E_FAILURE;
1031 	}
1032 
1033 	if (!(mgmt_subtype == MGMT_SUBTYPE_BEACON ||
1034 	      mgmt_subtype == MGMT_SUBTYPE_PROBE_RESP ||
1035 	      mgmt_subtype == MGMT_SUBTYPE_PROBE_REQ))
1036 		mgmt_txrx_debug("Rcvd mgmt frame subtype %x (frame type %u) from %pM, seq_num = %d, rssi = %d tsf_delta: %u",
1037 				mgmt_subtype, frm_type, wh->i_addr2,
1038 				(le16toh(*(uint16_t *)wh->i_seq) >>
1039 				WLAN_SEQ_SEQ_SHIFT), mgmt_rx_params->rssi,
1040 				mgmt_rx_params->tsf_delta);
1041 
1042 	mgmt_txrx_psoc_ctx = (struct mgmt_txrx_priv_psoc_context *)
1043 			wlan_objmgr_psoc_get_comp_private_obj(psoc,
1044 				WLAN_UMAC_COMP_MGMT_TXRX);
1045 
1046 	qdf_spin_lock_bh(&mgmt_txrx_psoc_ctx->mgmt_txrx_psoc_ctx_lock);
1047 	rx_handler = mgmt_txrx_psoc_ctx->mgmt_rx_comp_cb[frm_type];
1048 	if (rx_handler) {
1049 		status = wlan_mgmt_txrx_rx_handler_list_copy(rx_handler,
1050 				&rx_handler_head, &rx_handler_tail);
1051 		if (status != QDF_STATUS_SUCCESS) {
1052 			qdf_spin_unlock_bh(&mgmt_txrx_psoc_ctx->mgmt_txrx_psoc_ctx_lock);
1053 			qdf_nbuf_free(buf);
1054 			goto rx_handler_mem_free;
1055 		}
1056 	}
1057 
1058 	rx_handler = mgmt_txrx_psoc_ctx->mgmt_rx_comp_cb[MGMT_FRAME_TYPE_ALL];
1059 	if (rx_handler) {
1060 		status = wlan_mgmt_txrx_rx_handler_list_copy(rx_handler,
1061 				&rx_handler_head, &rx_handler_tail);
1062 		if (status != QDF_STATUS_SUCCESS) {
1063 			qdf_spin_unlock_bh(&mgmt_txrx_psoc_ctx->mgmt_txrx_psoc_ctx_lock);
1064 			qdf_nbuf_free(buf);
1065 			goto rx_handler_mem_free;
1066 		}
1067 	}
1068 
1069 	if (!rx_handler_head) {
1070 		qdf_spin_unlock_bh(&mgmt_txrx_psoc_ctx->mgmt_txrx_psoc_ctx_lock);
1071 		mgmt_txrx_debug("No rx callback registered for frm_type: %d",
1072 				frm_type);
1073 		qdf_nbuf_free(buf);
1074 		return QDF_STATUS_E_FAILURE;
1075 	}
1076 	qdf_spin_unlock_bh(&mgmt_txrx_psoc_ctx->mgmt_txrx_psoc_ctx_lock);
1077 
1078 	mac_addr = (uint8_t *)wh->i_addr2;
1079 	/*
1080 	 * peer can be NULL in following 2 scenarios:
1081 	 * 1. broadcast frame received
1082 	 * 2. operating in monitor mode
1083 	 *
1084 	 * and in both scenarios, the receiver of frame
1085 	 * is expected to do processing accordingly considerng
1086 	 * the fact that peer = NULL can be received and is a valid
1087 	 * scenario.
1088 	 */
1089 	peer = wlan_objmgr_get_peer(psoc, mgmt_rx_params->pdev_id,
1090 				    mac_addr, WLAN_MGMT_SB_ID);
1091 	if (!peer && !qdf_is_macaddr_broadcast(
1092 	    (struct qdf_mac_addr *)wh->i_addr1)) {
1093 		mac_addr = (uint8_t *)wh->i_addr1;
1094 		peer = wlan_objmgr_get_peer(psoc,
1095 					    mgmt_rx_params->pdev_id,
1096 					    mac_addr, WLAN_MGMT_SB_ID);
1097 	}
1098 
1099 	rx_handler = rx_handler_head;
1100 	while (rx_handler->next) {
1101 		copy_buf = qdf_nbuf_clone(buf);
1102 
1103 		if (!copy_buf) {
1104 			rx_handler = rx_handler->next;
1105 			continue;
1106 		}
1107 
1108 		rx_handler->rx_cb(psoc, peer, copy_buf,
1109 					mgmt_rx_params, frm_type);
1110 		rx_handler = rx_handler->next;
1111 	}
1112 	rx_handler->rx_cb(psoc, peer, buf,
1113 				mgmt_rx_params, frm_type);
1114 
1115 	if (peer)
1116 		wlan_objmgr_peer_release_ref(peer, WLAN_MGMT_SB_ID);
1117 
1118 rx_handler_mem_free:
1119 	while (rx_handler_head) {
1120 		rx_handler = rx_handler_head;
1121 		rx_handler_head = rx_handler_head->next;
1122 		qdf_mem_free(rx_handler);
1123 	}
1124 
1125 	return status;
1126 }
1127 
1128 QDF_STATUS tgt_mgmt_txrx_tx_completion_handler(
1129 			struct wlan_objmgr_pdev *pdev,
1130 			uint32_t desc_id, uint32_t status,
1131 			void *tx_compl_params)
1132 {
1133 	struct mgmt_txrx_priv_pdev_context *mgmt_txrx_pdev_ctx;
1134 	struct mgmt_txrx_desc_elem_t *mgmt_desc;
1135 	void *cb_context;
1136 	mgmt_tx_download_comp_cb tx_compl_cb;
1137 	mgmt_ota_comp_cb  ota_comp_cb;
1138 	qdf_nbuf_t nbuf;
1139 
1140 	mgmt_txrx_pdev_ctx = (struct mgmt_txrx_priv_pdev_context *)
1141 			wlan_objmgr_pdev_get_comp_private_obj(pdev,
1142 				WLAN_UMAC_COMP_MGMT_TXRX);
1143 	if (!mgmt_txrx_pdev_ctx) {
1144 		mgmt_txrx_err("Mgmt txrx context empty for pdev %pK", pdev);
1145 		return QDF_STATUS_E_NULL_VALUE;
1146 	}
1147 	if (desc_id >= MGMT_DESC_POOL_MAX) {
1148 		mgmt_txrx_err("desc_id:%u is out of bounds", desc_id);
1149 		return QDF_STATUS_E_INVAL;
1150 	}
1151 	mgmt_desc = &mgmt_txrx_pdev_ctx->mgmt_desc_pool.pool[desc_id];
1152 	if (!mgmt_desc || !mgmt_desc->in_use) {
1153 		mgmt_txrx_err("Mgmt desc empty for id %d pdev %pK ",
1154 				desc_id, pdev);
1155 		return QDF_STATUS_E_NULL_VALUE;
1156 	}
1157 	tx_compl_cb = mgmt_desc->tx_dwnld_cmpl_cb;
1158 	ota_comp_cb = mgmt_desc->tx_ota_cmpl_cb;
1159 	nbuf = mgmt_desc->nbuf;
1160 
1161 	/*
1162 	 *      TO DO
1163 	 * Make the API more generic to handle tx download completion as well
1164 	 * as OTA completion separately.
1165 	 */
1166 
1167 	/*
1168 	 * 1. If the tx frame is sent by any UMAC converged component then it
1169 	 *    passes the context as NULL while calling mgmt txrx API for
1170 	 *    sending mgmt frame. If context is NULL, peer will be passed as
1171 	 *    cb_context in completion callbacks.
1172 	 * 2. If the tx frame is sent by legacy MLME then it passes the context
1173 	 *    as its specific context (for ex- mac context in case of MCL) while
1174 	 *    calling mgmt txrx API for sending mgmt frame. This caller specific
1175 	 *    context is passed as cb_context in completion callbacks.
1176 	 */
1177 	if (mgmt_desc->context)
1178 		cb_context = mgmt_desc->context;
1179 	else
1180 		cb_context = (void *)mgmt_desc->peer;
1181 
1182 	if (!tx_compl_cb && !ota_comp_cb) {
1183 		qdf_nbuf_free(nbuf);
1184 		goto no_registered_cb;
1185 	}
1186 
1187 	if (tx_compl_cb)
1188 		tx_compl_cb(cb_context, nbuf, status);
1189 
1190 	if (ota_comp_cb)
1191 		ota_comp_cb(cb_context, nbuf, status, tx_compl_params);
1192 
1193 no_registered_cb:
1194 	/*
1195 	 * decrementing the peer ref count that was incremented while
1196 	 * accessing peer in wlan_mgmt_txrx_mgmt_frame_tx
1197 	 */
1198 	wlan_objmgr_peer_release_ref(mgmt_desc->peer, WLAN_MGMT_NB_ID);
1199 	wlan_mgmt_txrx_desc_put(mgmt_txrx_pdev_ctx, desc_id);
1200 	return QDF_STATUS_SUCCESS;
1201 }
1202 
1203 qdf_nbuf_t tgt_mgmt_txrx_get_nbuf_from_desc_id(
1204 			struct wlan_objmgr_pdev *pdev,
1205 			uint32_t desc_id)
1206 {
1207 	struct mgmt_txrx_priv_pdev_context *mgmt_txrx_pdev_ctx;
1208 	struct mgmt_txrx_desc_elem_t *mgmt_desc;
1209 	qdf_nbuf_t buf;
1210 
1211 	mgmt_txrx_pdev_ctx = (struct mgmt_txrx_priv_pdev_context *)
1212 			wlan_objmgr_pdev_get_comp_private_obj(pdev,
1213 				WLAN_UMAC_COMP_MGMT_TXRX);
1214 	if (!mgmt_txrx_pdev_ctx) {
1215 		mgmt_txrx_err("Mgmt txrx context empty for pdev %pK", pdev);
1216 		goto fail;
1217 	}
1218 	if (desc_id >= MGMT_DESC_POOL_MAX) {
1219 		mgmt_txrx_err("desc_id:%u is out of bounds", desc_id);
1220 		goto fail;
1221 	}
1222 
1223 	mgmt_desc = &mgmt_txrx_pdev_ctx->mgmt_desc_pool.pool[desc_id];
1224 	if (!mgmt_desc || !mgmt_desc->in_use) {
1225 		mgmt_txrx_err("Mgmt descriptor unavailable for id %d pdev %pK",
1226 				desc_id, pdev);
1227 		goto fail;
1228 	}
1229 	buf = mgmt_desc->nbuf;
1230 	return buf;
1231 
1232 fail:
1233 	return NULL;
1234 }
1235 
1236 struct wlan_objmgr_peer *
1237 tgt_mgmt_txrx_get_peer_from_desc_id(
1238 			struct wlan_objmgr_pdev *pdev,
1239 			uint32_t desc_id)
1240 {
1241 	struct mgmt_txrx_priv_pdev_context *mgmt_txrx_pdev_ctx;
1242 	struct mgmt_txrx_desc_elem_t *mgmt_desc;
1243 	struct wlan_objmgr_peer *peer;
1244 
1245 	mgmt_txrx_pdev_ctx = (struct mgmt_txrx_priv_pdev_context *)
1246 			wlan_objmgr_pdev_get_comp_private_obj(pdev,
1247 				WLAN_UMAC_COMP_MGMT_TXRX);
1248 	if (!mgmt_txrx_pdev_ctx) {
1249 		mgmt_txrx_err("Mgmt txrx context empty for pdev %pK", pdev);
1250 		goto fail;
1251 	}
1252 
1253 	mgmt_desc = &mgmt_txrx_pdev_ctx->mgmt_desc_pool.pool[desc_id];
1254 	if (!mgmt_desc || !mgmt_desc->in_use) {
1255 		mgmt_txrx_err("Mgmt descriptor unavailable for id %d pdev %pK",
1256 				desc_id, pdev);
1257 		goto fail;
1258 	}
1259 
1260 	peer = mgmt_desc->peer;
1261 	return peer;
1262 
1263 fail:
1264 	return NULL;
1265 }
1266 
1267 uint8_t tgt_mgmt_txrx_get_vdev_id_from_desc_id(
1268 			struct wlan_objmgr_pdev *pdev,
1269 			uint32_t desc_id)
1270 {
1271 	struct mgmt_txrx_priv_pdev_context *mgmt_txrx_pdev_ctx;
1272 	struct mgmt_txrx_desc_elem_t *mgmt_desc;
1273 	uint8_t vdev_id;
1274 
1275 	mgmt_txrx_pdev_ctx = (struct mgmt_txrx_priv_pdev_context *)
1276 			wlan_objmgr_pdev_get_comp_private_obj(pdev,
1277 				WLAN_UMAC_COMP_MGMT_TXRX);
1278 	if (!mgmt_txrx_pdev_ctx) {
1279 		mgmt_txrx_err("Mgmt txrx context empty for pdev %pK", pdev);
1280 		goto fail;
1281 	}
1282 	if (desc_id >= MGMT_DESC_POOL_MAX) {
1283 		mgmt_txrx_err("desc_id:%u is out of bounds", desc_id);
1284 		goto fail;
1285 	}
1286 
1287 	mgmt_desc = &mgmt_txrx_pdev_ctx->mgmt_desc_pool.pool[desc_id];
1288 	if (!mgmt_desc || !mgmt_desc->in_use) {
1289 		mgmt_txrx_err("Mgmt descriptor unavailable for id %d pdev %pK",
1290 				desc_id, pdev);
1291 		goto fail;
1292 	}
1293 
1294 	vdev_id = mgmt_desc->vdev_id;
1295 	return vdev_id;
1296 
1297 fail:
1298 	return WLAN_UMAC_VDEV_ID_MAX;
1299 }
1300 
1301 uint32_t tgt_mgmt_txrx_get_free_desc_pool_count(
1302 			struct wlan_objmgr_pdev *pdev)
1303 {
1304 	struct mgmt_txrx_priv_pdev_context *mgmt_txrx_pdev_ctx;
1305 	uint32_t free_desc_count = WLAN_INVALID_MGMT_DESC_COUNT;
1306 
1307 	mgmt_txrx_pdev_ctx = (struct mgmt_txrx_priv_pdev_context *)
1308 			wlan_objmgr_pdev_get_comp_private_obj(pdev,
1309 			WLAN_UMAC_COMP_MGMT_TXRX);
1310 	if (!mgmt_txrx_pdev_ctx) {
1311 		mgmt_txrx_err("Mgmt txrx context empty for pdev %pK", pdev);
1312 		goto fail;
1313 	}
1314 
1315 	free_desc_count = qdf_list_size(
1316 		&(mgmt_txrx_pdev_ctx->mgmt_desc_pool.free_list));
1317 
1318 fail:
1319 	return free_desc_count;
1320 }
1321