Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame^] | 2 | * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved. |
Kiet Lam | 0fb93dd | 2014-02-19 00:32:59 -0800 | [diff] [blame] | 3 | * |
| 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 20 | */ |
Kiet Lam | 0fb93dd | 2014-02-19 00:32:59 -0800 | [diff] [blame] | 21 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 22 | /* |
Kiet Lam | 0fb93dd | 2014-02-19 00:32:59 -0800 | [diff] [blame] | 23 | * 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 29 | * 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 54 | #include "limTrace.h" |
| 55 | #include "wlan_qct_wda.h" |
| 56 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 57 | tSirRetStatus |
| 58 | postPTTMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 59 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 60 | #include "vos_types.h" |
| 61 | #include "vos_packet.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 62 | |
| 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 | |
| 80 | tSirRetStatus |
| 81 | sysInitGlobals(tpAniSirGlobal pMac) |
| 82 | { |
| 83 | |
Bansidhar Gopalachari | 0a96a38 | 2013-07-24 16:55:34 +0530 | [diff] [blame] | 84 | vos_mem_set((tANI_U8 *) &pMac->sys, sizeof(pMac->sys), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 85 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 86 | pMac->sys.gSysEnableScanMode = 1; |
| 87 | pMac->sys.gSysEnableLinkMonitorMode = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 88 | schInitGlobals(pMac); |
| 89 | |
| 90 | return eSIR_SUCCESS; |
| 91 | } |
| 92 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 93 | // --------------------------------------------------------------------------- |
| 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 | */ |
| 112 | tSirRetStatus |
| 113 | sysBbtProcessMessageCore(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 Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 129 | 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 132 | |
| 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 Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 141 | MTRACE(macTrace(pMac, TRACE_CODE_RX_MGMT_DROP, NO_SESSION, dropReason);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 142 | 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 153 | else if (type == SIR_MAC_DATA_FRAME) |
| 154 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 155 | #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 Johnson | 8f7d7f9 | 2013-02-22 21:46:45 -0800 | [diff] [blame] | 161 | v_U8_t *ethTypeOffset = NULL ; |
| 162 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 163 | /* |
| 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 Johnson | 8f7d7f9 | 2013-02-22 21:46:45 -0800 | [diff] [blame] | 169 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 170 | #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 Johnson | 8f7d7f9 | 2013-02-22 21:46:45 -0800 | [diff] [blame] | 177 | ethTypeOffset = mpduHdr + WDA_GET_RX_MPDU_HEADER_LEN(pBd) |
| 178 | + RFC1042_HDR_LENGTH ; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 179 | } |
Jeff Johnson | 8f7d7f9 | 2013-02-22 21:46:45 -0800 | [diff] [blame] | 180 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 181 | ethType = GET_BE16(ethTypeOffset) ; |
| 182 | if(ETH_TYPE_89_0d == ethType) |
| 183 | { |
Jeff Johnson | 8f7d7f9 | 2013-02-22 21:46:45 -0800 | [diff] [blame] | 184 | |
| 185 | VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_ERROR, |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 186 | ("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 Johnson | 8f7d7f9 | 2013-02-22 21:46:45 -0800 | [diff] [blame] | 197 | else |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 198 | return eSIR_SUCCESS; |
| 199 | } |
| 200 | /* fall through if ethType != TDLS, which is error case */ |
Jeff Johnson | 8f7d7f9 | 2013-02-22 21:46:45 -0800 | [diff] [blame] | 201 | #endif |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame^] | 202 | #ifdef FEATURE_WLAN_ESE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 203 | 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 212 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 213 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 214 | else |
| 215 | { |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 216 | PELOG3(sysLog(pMac, LOG3, "BBT received Invalid type %d subType %d " |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 217 | "LIM state %X. BD dump is:\n", |
| 218 | type, subType, limGetSmeState(pMac)); |
Mohit Khanna | 2386376 | 2012-09-11 17:40:09 -0700 | [diff] [blame] | 219 | sirDumpBuf(pMac, SIR_SYS_MODULE_ID, LOG3, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 220 | (tANI_U8 *) pBd, WLANHAL_RX_BD_HEADER_SIZE);) |
| 221 | |
| 222 | goto fail; |
| 223 | } |
| 224 | |
| 225 | return eSIR_SUCCESS; |
| 226 | |
| 227 | fail: |
| 228 | |
| 229 | pMac->sys.gSysBbtDropped++; |
| 230 | return eSIR_FAILURE; |
| 231 | } |
| 232 | |
| 233 | |
| 234 | void 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 253 | |
| 254 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 255 | |