blob: fd702310ba9b658617f2fd3c19a186a0b1fd4b39 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
Kiet Lam0fb93dd2014-02-19 00:32:59 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Jeff Johnson295189b2012-06-20 16:38:30 -070020 */
Kiet Lam0fb93dd2014-02-19 00:32:59 -080021
Jeff Johnson295189b2012-06-20 16:38:30 -070022/*
Kiet Lam0fb93dd2014-02-19 00:32:59 -080023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/*
Jeff Johnson295189b2012-06-20 16:38:30 -070029 * sysEntryFunc.cc - This file has all the system level entry functions
30 * for all the defined threads at system level.
31 * Author: V. K. Kandarpa
32 * Date: 01/16/2002
33 * History:-
34 * Date Modified by Modification Information
35 * --------------------------------------------------------------------------
36 *
37 */
38/* Standard include files */
39
40/* Application Specific include files */
41#include "sirCommon.h"
42#include "aniGlobal.h"
43
44
45#include "limApi.h"
46#include "schApi.h"
47#include "utilsApi.h"
48#include "pmmApi.h"
49
50#include "sysDebug.h"
51#include "sysDef.h"
52#include "sysEntryFunc.h"
53#include "sysStartup.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070054#include "limTrace.h"
55#include "wlan_qct_wda.h"
56
Jeff Johnson295189b2012-06-20 16:38:30 -070057tSirRetStatus
58postPTTMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070059
Jeff Johnson295189b2012-06-20 16:38:30 -070060#include "vos_types.h"
61#include "vos_packet.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070062
63// ---------------------------------------------------------------------------
64/**
65 * sysInitGlobals
66 *
67 * FUNCTION:
68 * Initializes system level global parameters
69 *
70 * LOGIC:
71 *
72 * ASSUMPTIONS:
73 *
74 * NOTE:
75 *
76 * @param tpAniSirGlobal Sirius software parameter struct pointer
77 * @return None
78 */
79
80tSirRetStatus
81sysInitGlobals(tpAniSirGlobal pMac)
82{
83
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +053084 vos_mem_set((tANI_U8 *) &pMac->sys, sizeof(pMac->sys), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070085
Jeff Johnson295189b2012-06-20 16:38:30 -070086 pMac->sys.gSysEnableScanMode = 1;
87 pMac->sys.gSysEnableLinkMonitorMode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070088 schInitGlobals(pMac);
89
90 return eSIR_SUCCESS;
91}
92
Jeff Johnson295189b2012-06-20 16:38:30 -070093// ---------------------------------------------------------------------------
94/**
95 * sysBbtProcessMessageCore
96 *
97 * FUNCTION:
98 * Process BBT messages
99 *
100 * LOGIC:
101 *
102 * ASSUMPTIONS:
103 *
104 * NOTE:
105 *
106 * @param tpAniSirGlobal A pointer to MAC params instance
107 * @param pMsg message pointer
108 * @param tANI_U32 type
109 * @param tANI_U32 sub type
110 * @return None
111 */
112tSirRetStatus
113sysBbtProcessMessageCore(tpAniSirGlobal pMac, tpSirMsgQ pMsg, tANI_U32 type,
114 tANI_U32 subType)
115{
116 tSirRetStatus ret;
117 void* pBd;
118 tMgmtFrmDropReason dropReason;
119 vos_pkt_t *pVosPkt = (vos_pkt_t *)pMsg->bodyptr;
120 VOS_STATUS vosStatus =
121 WDA_DS_PeekRxPacketInfo( pVosPkt, (v_PVOID_t *)&pBd, VOS_FALSE );
122 pMac->sys.gSysBbtReceived++;
123
124 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
125 {
126 goto fail;
127 }
128
Mohit Khanna23863762012-09-11 17:40:09 -0700129 PELOG3(sysLog(pMac, LOG3, FL("Rx Mgmt Frame Subtype: %d\n"), subType);
130 sirDumpBuf(pMac, SIR_SYS_MODULE_ID, LOG3, (tANI_U8 *)WDA_GET_RX_MAC_HEADER(pBd), WDA_GET_RX_MPDU_LEN(pBd));
131 sirDumpBuf(pMac, SIR_SYS_MODULE_ID, LOG3, WDA_GET_RX_MPDU_DATA(pBd), WDA_GET_RX_PAYLOAD_LEN(pBd));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700132
133 pMac->sys.gSysFrameCount[type][subType]++;
134
135 if(type == SIR_MAC_MGMT_FRAME)
136 {
137
138 if( (dropReason = limIsPktCandidateForDrop(pMac, pBd, subType)) != eMGMT_DROP_NO_DROP)
139 {
140 PELOG1(sysLog(pMac, LOG1, FL("Mgmt Frame %d being dropped, reason: %d\n"), subType, dropReason);)
Jeff Johnsone7245742012-09-05 17:12:55 -0700141 MTRACE(macTrace(pMac, TRACE_CODE_RX_MGMT_DROP, NO_SESSION, dropReason);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700142 goto fail;
143 }
144 //Post the message to PE Queue
145 ret = (tSirRetStatus) limPostMsgApi(pMac, pMsg);
146 if (ret != eSIR_SUCCESS)
147 {
148 PELOGE(sysLog(pMac, LOGE, FL("posting to LIM2 failed, ret %d\n"), ret);)
149 goto fail;
150 }
151 pMac->sys.gSysBbtPostedToLim++;
152 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700153 else if (type == SIR_MAC_DATA_FRAME)
154 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800155#ifdef FEATURE_WLAN_TDLS_INTERNAL
156 /*
157 * if we reached here, probably this frame can be TDLS frame.
158 */
159 v_U16_t ethType = 0 ;
160 v_U8_t *mpduHdr = NULL ;
Jeff Johnson8f7d7f92013-02-22 21:46:45 -0800161 v_U8_t *ethTypeOffset = NULL ;
162
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800163 /*
164 * Peek into payload and extract ethtype.
165 * In TDLS we can recieve TDLS frames with MAC HEADER (802.11) and also
166 * without MAC Header (Particularly TDLS action frames on direct link.
167 */
168 mpduHdr = (v_U8_t *)WDA_GET_RX_MAC_HEADER(pBd) ;
Jeff Johnson8f7d7f92013-02-22 21:46:45 -0800169
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800170#define SIR_MAC_ETH_HDR_LEN (14)
171 if(0 != WDA_GET_RX_FT_DONE(pBd))
172 {
173 ethTypeOffset = mpduHdr + SIR_MAC_ETH_HDR_LEN - sizeof(ethType) ;
174 }
175 else
176 {
Jeff Johnson8f7d7f92013-02-22 21:46:45 -0800177 ethTypeOffset = mpduHdr + WDA_GET_RX_MPDU_HEADER_LEN(pBd)
178 + RFC1042_HDR_LENGTH ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800179 }
Jeff Johnson8f7d7f92013-02-22 21:46:45 -0800180
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800181 ethType = GET_BE16(ethTypeOffset) ;
182 if(ETH_TYPE_89_0d == ethType)
183 {
Jeff Johnson8f7d7f92013-02-22 21:46:45 -0800184
185 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800186 ("TDLS Data Frame \n")) ;
187 /* Post the message to PE Queue */
188 PELOGE(sysLog(pMac, LOGE, FL("posting to TDLS frame to lim\n"));)
189
190 ret = (tSirRetStatus) limPostMsgApi(pMac, pMsg);
191 if (ret != eSIR_SUCCESS)
192 {
193 PELOGE(sysLog(pMac, LOGE, FL("posting to LIM2 failed, \
194 ret %d\n"), ret);)
195 goto fail;
196 }
Jeff Johnson8f7d7f92013-02-22 21:46:45 -0800197 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800198 return eSIR_SUCCESS;
199 }
200 /* fall through if ethType != TDLS, which is error case */
Jeff Johnson8f7d7f92013-02-22 21:46:45 -0800201#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800202#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700203 PELOGW(sysLog(pMac, LOGW, FL("IAPP Frame...\n")););
204 //Post the message to PE Queue
205 ret = (tSirRetStatus) limPostMsgApi(pMac, pMsg);
206 if (ret != eSIR_SUCCESS)
207 {
208 PELOGE(sysLog(pMac, LOGE, FL("posting to LIM2 failed, ret %d\n"), ret);)
209 goto fail;
210 }
211 pMac->sys.gSysBbtPostedToLim++;
Jeff Johnson295189b2012-06-20 16:38:30 -0700212#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800213 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700214 else
215 {
Mohit Khanna23863762012-09-11 17:40:09 -0700216 PELOG3(sysLog(pMac, LOG3, "BBT received Invalid type %d subType %d "
Jeff Johnson295189b2012-06-20 16:38:30 -0700217 "LIM state %X. BD dump is:\n",
218 type, subType, limGetSmeState(pMac));
Mohit Khanna23863762012-09-11 17:40:09 -0700219 sirDumpBuf(pMac, SIR_SYS_MODULE_ID, LOG3,
Jeff Johnson295189b2012-06-20 16:38:30 -0700220 (tANI_U8 *) pBd, WLANHAL_RX_BD_HEADER_SIZE);)
221
222 goto fail;
223 }
224
225 return eSIR_SUCCESS;
226
227fail:
228
229 pMac->sys.gSysBbtDropped++;
230 return eSIR_FAILURE;
231}
232
233
234void sysLog(tpAniSirGlobal pMac, tANI_U32 loglevel, const char *pString,...)
235{
236 // Verify against current log level
237 if ( loglevel > pMac->utils.gLogDbgLevel[LOG_INDEX_FOR_MODULE( SIR_SYS_MODULE_ID )] )
238 return;
239 else
240 {
241 va_list marker;
242
243 va_start( marker, pString ); /* Initialize variable arguments. */
244
245 logDebug(pMac, SIR_SYS_MODULE_ID, loglevel, pString, marker);
246
247 va_end( marker ); /* Reset variable arguments. */
248 }
249}
250
251
252
Jeff Johnson295189b2012-06-20 16:38:30 -0700253
254
Jeff Johnson295189b2012-06-20 16:38:30 -0700255