xref: /wlan-driver/qcacld-3.0/core/mac/src/sys/legacy/src/system/src/sys_entry_func.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /*
21  * sys_entry_func.cc - This file has all the system level entry functions
22  *                   for all the defined threads at system level.
23  * Author:    V. K. Kandarpa
24  * Date:      01/16/2002
25  * History:-
26  * Date       Modified by            Modification Information
27  * --------------------------------------------------------------------------
28  *
29  */
30 /* Standard include files */
31 
32 /* Application Specific include files */
33 #include "sir_common.h"
34 #include "ani_global.h"
35 
36 #include "lim_api.h"
37 #include "sch_api.h"
38 #include "utils_api.h"
39 
40 #include "sys_def.h"
41 #include "sys_entry_func.h"
42 #include "sys_startup.h"
43 #include "lim_trace.h"
44 #include "wma_types.h"
45 #include "qdf_types.h"
46 #include "cds_packet.h"
47 
48 /**
49  * sys_init_globals
50  *
51  * FUNCTION:
52  *    Initializes system level global parameters
53  *
54  * LOGIC:
55  *
56  * ASSUMPTIONS:
57  *
58  * NOTE:
59  *
60  * @param struct mac_context *Sirius software parameter struct pointer
61  * @return None
62  */
63 
sys_init_globals(struct mac_context * mac)64 QDF_STATUS sys_init_globals(struct mac_context *mac)
65 {
66 
67 	qdf_mem_zero((uint8_t *) &mac->sys, sizeof(mac->sys));
68 
69 	mac->sys.gSysEnableLinkMonitorMode = 0;
70 
71 	return QDF_STATUS_SUCCESS;
72 }
73 
sys_bbt_process_message_core(struct mac_context * mac_ctx,struct scheduler_msg * msg,uint32_t type,uint32_t subtype)74 QDF_STATUS sys_bbt_process_message_core(struct mac_context *mac_ctx,
75 					struct scheduler_msg *msg,
76 					uint32_t type, uint32_t subtype)
77 {
78 	uint32_t framecount;
79 	QDF_STATUS ret;
80 	void *bd_ptr;
81 	tMgmtFrmDropReason dropreason;
82 	cds_pkt_t *vos_pkt = (cds_pkt_t *) msg->bodyptr;
83 	QDF_STATUS qdf_status = wma_ds_peek_rx_packet_info(vos_pkt, &bd_ptr);
84 
85 	mac_ctx->sys.gSysBbtReceived++;
86 
87 	if (!QDF_IS_STATUS_SUCCESS(qdf_status))
88 		goto fail;
89 
90 	mac_ctx->sys.gSysFrameCount[type][subtype]++;
91 	framecount = mac_ctx->sys.gSysFrameCount[type][subtype];
92 
93 	if (type == SIR_MAC_MGMT_FRAME) {
94 		tpSirMacMgmtHdr mac_hdr;
95 
96 		/*
97 		 * Drop beacon frames in deferred state to avoid VOSS run out of
98 		 * message wrappers.
99 		 */
100 		if ((subtype == SIR_MAC_MGMT_BEACON) &&
101 		     !GET_LIM_PROCESS_DEFD_MESGS(mac_ctx)) {
102 			pe_debug("dropping received beacon in deferred state");
103 			goto fail;
104 		}
105 
106 		dropreason = lim_is_pkt_candidate_for_drop(mac_ctx, bd_ptr,
107 				subtype);
108 		if (eMGMT_DROP_NO_DROP != dropreason) {
109 			pe_debug("Mgmt Frame %d being dropped, reason: %d\n",
110 				subtype, dropreason);
111 				MTRACE(mac_trace(mac_ctx,
112 					TRACE_CODE_RX_MGMT_DROP, NO_SESSION,
113 					dropreason));
114 			goto fail;
115 		}
116 
117 		mac_hdr = WMA_GET_RX_MAC_HEADER(bd_ptr);
118 		if (subtype == SIR_MAC_MGMT_ASSOC_REQ) {
119 			pe_debug("ASSOC REQ frame allowed: da: " QDF_MAC_ADDR_FMT ", sa: " QDF_MAC_ADDR_FMT ", bssid: " QDF_MAC_ADDR_FMT ", Assoc Req count so far: %d",
120 				 QDF_MAC_ADDR_REF(mac_hdr->da),
121 				 QDF_MAC_ADDR_REF(mac_hdr->sa),
122 				 QDF_MAC_ADDR_REF(mac_hdr->bssId),
123 				 mac_ctx->sys.gSysFrameCount[type][subtype]);
124 		}
125 		if (subtype == SIR_MAC_MGMT_DEAUTH) {
126 			pe_debug("DEAUTH frame allowed: da: " QDF_MAC_ADDR_FMT ", sa: " QDF_MAC_ADDR_FMT ", bssid: " QDF_MAC_ADDR_FMT ", DEAUTH count so far: %d",
127 				 QDF_MAC_ADDR_REF(mac_hdr->da),
128 				 QDF_MAC_ADDR_REF(mac_hdr->sa),
129 				 QDF_MAC_ADDR_REF(mac_hdr->bssId),
130 				 mac_ctx->sys.gSysFrameCount[type][subtype]);
131 		}
132 		if (subtype == SIR_MAC_MGMT_DISASSOC) {
133 			pe_debug("DISASSOC frame allowed: da: " QDF_MAC_ADDR_FMT ", sa: " QDF_MAC_ADDR_FMT ", bssid: " QDF_MAC_ADDR_FMT ", DISASSOC count so far: %d",
134 				 QDF_MAC_ADDR_REF(mac_hdr->da),
135 				 QDF_MAC_ADDR_REF(mac_hdr->sa),
136 				 QDF_MAC_ADDR_REF(mac_hdr->bssId),
137 				 mac_ctx->sys.gSysFrameCount[type][subtype]);
138 		}
139 
140 		/* Post the message to PE Queue */
141 		ret = lim_post_msg_api(mac_ctx, msg);
142 		if (ret != QDF_STATUS_SUCCESS) {
143 			pe_err("posting to LIM2 failed, ret %d\n", ret);
144 			goto fail;
145 		}
146 		mac_ctx->sys.gSysBbtPostedToLim++;
147 #ifdef FEATURE_WLAN_ESE
148 	} else if (type == SIR_MAC_DATA_FRAME) {
149 		pe_debug("IAPP Frame...");
150 		/* Post the message to PE Queue */
151 		ret = lim_post_msg_api(mac_ctx, msg);
152 		if (ret != QDF_STATUS_SUCCESS) {
153 			pe_err("posting to LIM2 failed, ret: %d", ret);
154 			goto fail;
155 		}
156 		mac_ctx->sys.gSysBbtPostedToLim++;
157 #endif
158 	} else {
159 		pe_debug("BBT received Invalid type: %d subtype: %d "
160 			"LIM state %X", type, subtype,
161 			lim_get_sme_state(mac_ctx));
162 		goto fail;
163 	}
164 	return QDF_STATUS_SUCCESS;
165 fail:
166 	mac_ctx->sys.gSysBbtDropped++;
167 	return QDF_STATUS_E_FAILURE;
168 }
169 
170