Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved. |
| 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. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 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 | /* |
| 29 | * sys_entry_func.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 "sir_common.h" |
| 42 | #include "ani_global.h" |
| 43 | |
| 44 | #include "lim_api.h" |
| 45 | #include "sch_api.h" |
| 46 | #include "utils_api.h" |
| 47 | |
| 48 | #include "sys_debug.h" |
| 49 | #include "sys_def.h" |
| 50 | #include "sys_entry_func.h" |
| 51 | #include "sys_startup.h" |
| 52 | #include "lim_trace.h" |
| 53 | #include "wma_types.h" |
| 54 | |
| 55 | tSirRetStatus postPTTMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg); |
| 56 | |
| 57 | #include "cdf_types.h" |
| 58 | #include "cds_packet.h" |
| 59 | |
| 60 | #define MAX_DEAUTH_ALLOWED 5 |
| 61 | /* --------------------------------------------------------------------------- */ |
| 62 | /** |
| 63 | * sys_init_globals |
| 64 | * |
| 65 | * FUNCTION: |
| 66 | * Initializes system level global parameters |
| 67 | * |
| 68 | * LOGIC: |
| 69 | * |
| 70 | * ASSUMPTIONS: |
| 71 | * |
| 72 | * NOTE: |
| 73 | * |
| 74 | * @param tpAniSirGlobal Sirius software parameter struct pointer |
| 75 | * @return None |
| 76 | */ |
| 77 | |
| 78 | tSirRetStatus sys_init_globals(tpAniSirGlobal pMac) |
| 79 | { |
| 80 | |
| 81 | cdf_mem_set((uint8_t *) &pMac->sys, sizeof(pMac->sys), 0); |
| 82 | |
| 83 | pMac->sys.gSysEnableScanMode = 1; |
| 84 | pMac->sys.gSysEnableLinkMonitorMode = 0; |
| 85 | sch_init_globals(pMac); |
| 86 | |
| 87 | return eSIR_SUCCESS; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * sys_bbt_process_message_core() - to process BBT messages |
| 92 | * @mac_ctx: pointer to mac context |
| 93 | * @msg: message pointer |
| 94 | * @type: type of persona |
| 95 | * @subtype: subtype of persona |
| 96 | * |
| 97 | * This routine is to process some bbt messages |
| 98 | * |
| 99 | * Return: None |
| 100 | */ |
| 101 | tSirRetStatus |
| 102 | sys_bbt_process_message_core(tpAniSirGlobal mac_ctx, tpSirMsgQ msg, |
| 103 | uint32_t type, uint32_t subtype) |
| 104 | { |
| 105 | uint32_t framecount; |
| 106 | tSirRetStatus ret; |
| 107 | void *bd_ptr; |
| 108 | tMgmtFrmDropReason dropreason; |
| 109 | cds_pkt_t *vos_pkt = (cds_pkt_t *) msg->bodyptr; |
| 110 | CDF_STATUS cdf_status = |
| 111 | wma_ds_peek_rx_packet_info(vos_pkt, &bd_ptr, false); |
| 112 | uint8_t sessionid; |
| 113 | tpPESession pe_session; |
| 114 | tpSirMacMgmtHdr mac_hdr; |
| 115 | |
| 116 | mac_ctx->sys.gSysBbtReceived++; |
| 117 | |
| 118 | if (!CDF_IS_STATUS_SUCCESS(cdf_status)) |
| 119 | goto fail; |
| 120 | |
| 121 | sys_log(mac_ctx, LOG3, FL("Rx Mgmt Frame Subtype: %d\n"), subtype); |
| 122 | sir_dump_buf(mac_ctx, SIR_SYS_MODULE_ID, LOG3, |
| 123 | (uint8_t *) WMA_GET_RX_MAC_HEADER(bd_ptr), |
| 124 | WMA_GET_RX_MPDU_LEN(bd_ptr)); |
| 125 | sir_dump_buf(mac_ctx, SIR_SYS_MODULE_ID, LOG3, |
| 126 | WMA_GET_RX_MPDU_DATA(bd_ptr), |
| 127 | WMA_GET_RX_PAYLOAD_LEN(bd_ptr)); |
| 128 | |
| 129 | mac_ctx->sys.gSysFrameCount[type][subtype]++; |
| 130 | framecount = mac_ctx->sys.gSysFrameCount[type][subtype]; |
| 131 | |
| 132 | if (type == SIR_MAC_MGMT_FRAME) { |
| 133 | if (true == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running) { |
| 134 | mac_hdr = WMA_GET_RX_MAC_HEADER(bd_ptr); |
| 135 | pe_session = pe_find_session_by_bssid(mac_ctx, |
| 136 | mac_hdr->bssId, |
| 137 | &sessionid); |
| 138 | if (pe_session && |
| 139 | (pe_session->pePersona == CDF_SAP_MODE)) { |
| 140 | CDF_TRACE(CDF_MODULE_ID_SYS, |
| 141 | CDF_TRACE_LEVEL_INFO_HIGH, |
| 142 | FL("CAC timer is running, dropping the mgmt frame")); |
| 143 | goto fail; |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | /* |
| 148 | * Drop beacon frames in deferred state to avoid VOSS run out of |
| 149 | * message wrappers. |
| 150 | */ |
| 151 | if ((subtype == SIR_MAC_MGMT_BEACON) && |
| 152 | (!lim_is_system_in_scan_state(mac_ctx)) && |
| 153 | (GET_LIM_PROCESS_DEFD_MESGS(mac_ctx) != true) && |
| 154 | !mac_ctx->lim.gLimSystemInScanLearnMode) { |
| 155 | CDF_TRACE(CDF_MODULE_ID_SYS, CDF_TRACE_LEVEL_INFO_HIGH, |
| 156 | FL("dropping received beacon in deffered state")); |
| 157 | goto fail; |
| 158 | } |
| 159 | |
| 160 | dropreason = lim_is_pkt_candidate_for_drop(mac_ctx, bd_ptr, |
| 161 | subtype); |
| 162 | if (eMGMT_DROP_NO_DROP != dropreason) { |
| 163 | sys_log(mac_ctx, LOG1, |
| 164 | FL("Mgmt Frame %d being dropped, reason: %d\n"), |
| 165 | subtype, dropreason); |
| 166 | MTRACE(mac_trace(mac_ctx, |
| 167 | TRACE_CODE_RX_MGMT_DROP, NO_SESSION, |
| 168 | dropreason);) |
| 169 | goto fail; |
| 170 | } |
| 171 | |
| 172 | if (subtype == SIR_MAC_MGMT_DEAUTH) { |
| 173 | tpSirMacMgmtHdr mac_hdr = WMA_GET_RX_MAC_HEADER(bd_ptr); |
| 174 | sys_log(mac_ctx, LOGE, |
| 175 | FL("DEAUTH frame allowed: " |
| 176 | "da: " MAC_ADDRESS_STR ", " |
| 177 | "sa: " MAC_ADDRESS_STR ", " |
| 178 | "bssid: " MAC_ADDRESS_STR ", " |
| 179 | "DEAUTH count so far: %d\n"), |
| 180 | MAC_ADDR_ARRAY(mac_hdr->da), |
| 181 | MAC_ADDR_ARRAY(mac_hdr->sa), |
| 182 | MAC_ADDR_ARRAY(mac_hdr->bssId), |
| 183 | mac_ctx->sys.gSysFrameCount[type][subtype]); |
| 184 | } |
| 185 | if (subtype == SIR_MAC_MGMT_DISASSOC) { |
| 186 | tpSirMacMgmtHdr mac_hdr = WMA_GET_RX_MAC_HEADER(bd_ptr); |
| 187 | sys_log(mac_ctx, LOGE, |
| 188 | FL("DISASSOC frame allowed: " |
| 189 | "da: " MAC_ADDRESS_STR ", " |
| 190 | "sa: " MAC_ADDRESS_STR ", " |
| 191 | "bssid: " MAC_ADDRESS_STR ", " |
| 192 | "DISASSOC count so far: %d\n"), |
| 193 | MAC_ADDR_ARRAY(mac_hdr->da), |
| 194 | MAC_ADDR_ARRAY(mac_hdr->sa), |
| 195 | MAC_ADDR_ARRAY(mac_hdr->bssId), |
| 196 | mac_ctx->sys.gSysFrameCount[type][subtype]); |
| 197 | } |
| 198 | |
| 199 | /* Post the message to PE Queue */ |
| 200 | ret = (tSirRetStatus) lim_post_msg_api(mac_ctx, msg); |
| 201 | if (ret != eSIR_SUCCESS) { |
| 202 | sys_log(mac_ctx, LOGE, |
| 203 | FL("posting to LIM2 failed, ret %d\n"), ret); |
| 204 | goto fail; |
| 205 | } |
| 206 | mac_ctx->sys.gSysBbtPostedToLim++; |
| 207 | } else if (type == SIR_MAC_DATA_FRAME) { |
| 208 | #ifdef FEATURE_WLAN_ESE |
| 209 | PELOGW(sys_log(mac_ctx, LOGW, FL("IAPP Frame...\n"));); |
| 210 | /* Post the message to PE Queue */ |
| 211 | ret = (tSirRetStatus) lim_post_msg_api(mac_ctx, msg); |
| 212 | if (ret != eSIR_SUCCESS) { |
| 213 | sys_log(mac_ctx, LOGE, |
| 214 | FL("posting to LIM2 failed, ret %d\n"), ret); |
| 215 | goto fail; |
| 216 | } |
| 217 | mac_ctx->sys.gSysBbtPostedToLim++; |
| 218 | #endif |
| 219 | } else { |
| 220 | sys_log(mac_ctx, LOG3, |
| 221 | "BBT received Invalid type %d subtype %d " |
| 222 | "LIM state %X. BD dump is:\n", type, subtype, |
| 223 | lim_get_sme_state(mac_ctx)); |
| 224 | goto fail; |
| 225 | } |
| 226 | return eSIR_SUCCESS; |
| 227 | fail: |
| 228 | mac_ctx->sys.gSysBbtDropped++; |
| 229 | return eSIR_FAILURE; |
| 230 | } |
| 231 | |
| 232 | void sys_log(tpAniSirGlobal pMac, uint32_t loglevel, const char *pString, ...) |
| 233 | { |
| 234 | /* Verify against current log level */ |
| 235 | if (loglevel > |
| 236 | pMac->utils.gLogDbgLevel[LOG_INDEX_FOR_MODULE(SIR_SYS_MODULE_ID)]) |
| 237 | return; |
| 238 | else { |
| 239 | va_list marker; |
| 240 | |
| 241 | va_start(marker, pString); /* Initialize variable arguments. */ |
| 242 | |
| 243 | log_debug(pMac, SIR_SYS_MODULE_ID, loglevel, pString, marker); |
| 244 | |
| 245 | va_end(marker); /* Reset variable arguments. */ |
| 246 | } |
| 247 | } |