blob: ca614fe4ea3767096cdbe59ff999f2f6c074206b [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
2 * Copyright (c) 2011-2015 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 * This file lim ProcessMessageQueue.cc contains the code
30 * for processing LIM message Queue.
31 * Author: Chandra Modumudi
32 * Date: 02/11/02
33 * History:-
34 * Date Modified by Modification Information
35 * --------------------------------------------------------------------
36 *
37 */
38#include "cds_api.h"
39#include "wni_api.h"
40#include "wma_types.h"
41
42#include "wni_cfg.h"
43#include "cfg_api.h"
44#include "sir_common.h"
45#include "utils_api.h"
46#include "lim_types.h"
47#include "lim_utils.h"
48#include "lim_assoc_utils.h"
49#include "lim_prop_exts_utils.h"
50
51#include "lim_admit_control.h"
52#include "lim_ibss_peer_mgmt.h"
53#include "sch_api.h"
54#ifdef WLAN_FEATURE_VOWIFI_11R
55#include "lim_ft_defs.h"
56#endif
57#include "lim_session.h"
58#include "lim_send_messages.h"
59
60#if defined WLAN_FEATURE_VOWIFI
61#include "rrm_api.h"
62#endif
63
64#if defined WLAN_FEATURE_VOWIFI_11R
65#include "lim_ft.h"
66#endif
67
68#include "cdf_types.h"
69#include "cds_packet.h"
70#include "cdf_memory.h"
71
72void lim_log_session_states(tpAniSirGlobal pMac);
73static void lim_process_normal_hdd_msg(tpAniSirGlobal mac_ctx,
74 struct sSirMsgQ *msg, uint8_t rsp_reqd);
75
76/**
77 * lim_process_dual_mac_cfg_resp() - Process set dual mac config response
78 * @mac: Global MAC pointer
79 * @body: Set dual mac config response in sir_dual_mac_config_resp format
80 *
81 * Process the set dual mac config response and post the message
82 * to SME to process this further and release the active
83 * command list
84 *
85 * Return: None
86 */
87static void lim_process_dual_mac_cfg_resp(tpAniSirGlobal mac, void *body)
88{
89 struct sir_dual_mac_config_resp *resp, *param;
90 uint32_t len, fail_resp = 0;
91 tSirMsgQ msg;
92
93 resp = (struct sir_dual_mac_config_resp *)body;
94 if (!resp) {
95 lim_log(mac, LOGE, FL("Set dual mac cfg param is NULL"));
96 fail_resp = 1;
97 /* Not returning here. If possible, let us proceed
98 * and send fail response to SME
99 */
100 }
101
102 len = sizeof(*param);
103
104 param = cdf_mem_malloc(len);
105 if (!param) {
106 lim_log(mac, LOGE, FL("Fail to allocate memory"));
107 /* Memory allocation for param failed.
108 * Cannot send fail status back to SME
109 */
110 return;
111 }
112
113 if (fail_resp) {
114 lim_log(mac, LOGE, FL("Send fail status to SME"));
115 param->status = SET_HW_MODE_STATUS_ECANCELED;
116 } else {
117 param->status = resp->status;
118 /*
119 * TODO: Update this HW mode info in any UMAC params, if needed
120 */
121 }
122
123 msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
124 msg.bodyptr = param;
125 msg.bodyval = 0;
126 lim_log(mac, LOG1, FL("Send eWNI_SME_SET_DUAL_MAC_CFG_RESP to SME"));
127 lim_sys_process_mmh_msg_api(mac, &msg, ePROT);
128 return;
129}
130
131/**
132 * lim_process_set_hw_mode_resp() - Process set HW mode response
133 * @mac: Global MAC pointer
134 * @body: Set HW mode response in sir_set_hw_mode_resp format
135 *
136 * Process the set HW mode response and post the message
137 * to SME to process this further and release the active
138 * command list
139 *
140 * Return: None
141 */
142static void lim_process_set_hw_mode_resp(tpAniSirGlobal mac, void *body)
143{
144 struct sir_set_hw_mode_resp *resp, *param;
145 uint32_t len, i, fail_resp = 0;
146 tSirMsgQ msg;
147
148 resp = (struct sir_set_hw_mode_resp *)body;
149 if (!resp) {
150 lim_log(mac, LOGE, FL("Set HW mode param is NULL"));
151 fail_resp = 1;
152 /* Not returning here. If possible, let us proceed
153 * and send fail response to SME */
154 }
155
156 len = sizeof(*param);
157
158 param = cdf_mem_malloc(len);
159 if (!param) {
160 lim_log(mac, LOGE, FL("Fail to allocate memory"));
161 /* Memory allocation for param failed.
162 * Cannot send fail status back to SME
163 */
164 return;
165 }
166
167 if (fail_resp) {
168 lim_log(mac, LOGE, FL("Send fail status to SME"));
169 param->status = SET_HW_MODE_STATUS_ECANCELED;
170 param->cfgd_hw_mode_index = 0;
171 param->num_vdev_mac_entries = 0;
172 } else {
173 param->status = resp->status;
174 param->cfgd_hw_mode_index = resp->cfgd_hw_mode_index;
175 param->num_vdev_mac_entries = resp->num_vdev_mac_entries;
176
177 for (i = 0; i < resp->num_vdev_mac_entries; i++) {
178 param->vdev_mac_map[i].vdev_id =
179 resp->vdev_mac_map[i].vdev_id;
180 param->vdev_mac_map[i].mac_id =
181 resp->vdev_mac_map[i].mac_id;
182 }
183 /*
184 * TODO: Update this HW mode info in any UMAC params, if needed
185 */
186 }
187
188 msg.type = eWNI_SME_SET_HW_MODE_RESP;
189 msg.bodyptr = param;
190 msg.bodyval = 0;
191 lim_log(mac, LOGE, FL("Send eWNI_SME_SET_HW_MODE_RESP to SME"));
192 lim_sys_process_mmh_msg_api(mac, &msg, ePROT);
193 return;
194}
195
196/**
197 * lim_process_hw_mode_trans_ind() - Process set HW mode transition indication
198 * @mac: Global MAC pointer
199 * @body: Set HW mode response in sir_hw_mode_trans_ind format
200 *
201 * Process the set HW mode transition indication and post the message
202 * to SME to invoke the HDD callback
203 * command list
204 *
205 * Return: None
206 */
207static void lim_process_hw_mode_trans_ind(tpAniSirGlobal mac, void *body)
208{
209 struct sir_hw_mode_trans_ind *ind, *param;
210 uint32_t len, i;
211 tSirMsgQ msg;
212
213 ind = (struct sir_hw_mode_trans_ind *)body;
214 if (!ind) {
215 lim_log(mac, LOGE, FL("Set HW mode trans ind param is NULL"));
216 return;
217 }
218
219 len = sizeof(*param);
220
221 param = cdf_mem_malloc(len);
222 if (!param) {
223 lim_log(mac, LOGE, FL("Fail to allocate memory"));
224 return;
225 }
226
227 param->old_hw_mode_index = ind->old_hw_mode_index;
228 param->new_hw_mode_index = ind->new_hw_mode_index;
229 param->num_vdev_mac_entries = ind->num_vdev_mac_entries;
230
231 for (i = 0; i < ind->num_vdev_mac_entries; i++) {
232 param->vdev_mac_map[i].vdev_id =
233 ind->vdev_mac_map[i].vdev_id;
234 param->vdev_mac_map[i].mac_id =
235 ind->vdev_mac_map[i].mac_id;
236 }
237
238 /* TODO: Update this HW mode info in any UMAC params, if needed */
239
240 msg.type = eWNI_SME_HW_MODE_TRANS_IND;
241 msg.bodyptr = param;
242 msg.bodyval = 0;
243 lim_log(mac, LOGE, FL("Send eWNI_SME_HW_MODE_TRANS_IND to SME"));
244 lim_sys_process_mmh_msg_api(mac, &msg, ePROT);
245 return;
246}
247
248/** -------------------------------------------------------------
249 \fn def_msg_decision
250 \brief The function decides whether to defer a message or not in limProcessMessage function
251 \param tpAniSirGlobal pMac
252 \param tSirMsgQ limMsg
253 \param tSirMacTspecIE *ppInfo
254 \return none
255 -------------------------------------------------------------*/
256
257uint8_t static def_msg_decision(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
258{
259
260/* this function should not changed */
261 if (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) {
262 /* Defer processsing this message */
263 if (lim_defer_msg(pMac, limMsg) != TX_SUCCESS) {
264 CDF_TRACE(CDF_MODULE_ID_PE, LOGE,
265 FL("Unable to Defer Msg"));
266 lim_log_session_states(pMac);
267 lim_handle_defer_msg_error(pMac, limMsg);
268 }
269 return true;
270 }
271 /* When defer is requested then defer all the messages except HAL responses. */
272 if ((!lim_is_system_in_scan_state(pMac))
273 && (true != GET_LIM_PROCESS_DEFD_MESGS(pMac))
274 && !pMac->lim.gLimSystemInScanLearnMode) {
275 if ((limMsg->type != WMA_ADD_BSS_RSP)
276 && (limMsg->type != WMA_DELETE_BSS_RSP)
277 && (limMsg->type != WMA_ADD_STA_RSP)
278 && (limMsg->type != WMA_DELETE_STA_RSP)
279 && (limMsg->type != WMA_SET_BSSKEY_RSP)
280 && (limMsg->type != WMA_SET_STAKEY_RSP)
281 && (limMsg->type != WMA_SET_STA_BCASTKEY_RSP)
282 && (limMsg->type != WMA_AGGR_QOS_RSP)
283 && (limMsg->type != WMA_SET_MIMOPS_RSP)
284 && (limMsg->type != WMA_SWITCH_CHANNEL_RSP)
285 && (limMsg->type != WMA_P2P_NOA_ATTR_IND)
286 && (limMsg->type != WMA_P2P_NOA_START_IND) &&
287#ifdef FEATURE_OEM_DATA_SUPPORT
288 (limMsg->type != WMA_START_OEM_DATA_RSP) &&
289#endif
Hema Aparna Medicharla5e1f3022015-08-24 11:22:29 +0530290 (limMsg->type != WMA_ADD_TS_RSP) &&
291 /* Allow processing of RX frames while awaiting reception
292 * of ADD TS response over the air. This logic particularly
293 * handles the case when host sends ADD BA request to FW
294 * after ADD TS request is sent over the air and
295 * ADD TS response received over the air */
296 !(limMsg->type == SIR_BB_XPORT_MGMT_MSG &&
297 pMac->lim.gLimAddtsSent)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800298 PELOG1(lim_log
299 (pMac, LOG1,
300 FL
301 ("Defer the current message %s , gLimProcessDefdMsgs is false and system is not in scan/learn mode"),
302 lim_msg_str(limMsg->type));
303 )
304 /* Defer processsing this message */
305 if (lim_defer_msg(pMac, limMsg) != TX_SUCCESS) {
306 CDF_TRACE(CDF_MODULE_ID_PE, LOGE,
307 FL("Unable to Defer Msg"));
308 lim_log_session_states(pMac);
309 lim_handle_defer_msg_error(pMac, limMsg);
310
311 }
312 return true;
313 }
314 }
315 return false;
316}
317
318#ifdef FEATURE_WLAN_EXTSCAN
319static void
320__lim_pno_match_fwd_bcn_probepsp(tpAniSirGlobal pmac, uint8_t *rx_pkt_info,
321 tSirProbeRespBeacon *frame, uint32_t ie_len,
322 uint32_t msg_type)
323{
324 struct pno_match_found *result;
325 uint8_t *body;
326 tSirMsgQ mmh_msg;
327 tpSirMacMgmtHdr hdr;
328 uint32_t num_results = 1, len, i;
329
330 /* Upon receiving every matched beacon, bss info is forwarded to the
331 * the upper layer, hence num_results is set to 1 */
332 len = sizeof(*result) + (num_results * sizeof(tSirWifiScanResult)) +
333 ie_len;
334
335 result = cdf_mem_malloc(len);
336 if (NULL == result) {
337 lim_log(pmac, LOGE, FL("Memory allocation failed"));
338 return;
339 }
340 hdr = WMA_GET_RX_MAC_HEADER(rx_pkt_info);
341 body = WMA_GET_RX_MPDU_DATA(rx_pkt_info);
342 cdf_mem_zero(result, sizeof(*result) + ie_len);
343
344 /* Received frame does not have request id, hence set 0 */
345 result->request_id = 0;
346 result->more_data = 0;
347 result->num_results = num_results;
348
349 for (i = 0; i < result->num_results; i++) {
350 result->ap[i].ts = cdf_mc_timer_get_system_time();
351 result->ap[i].beaconPeriod = frame->beaconInterval;
352 result->ap[i].capability =
353 lim_get_u16((uint8_t *) &frame->capabilityInfo);
354 result->ap[i].channel = WMA_GET_RX_CH(rx_pkt_info);
Deepak Dhamdhere68929ec2015-08-05 15:16:35 -0700355 result->ap[i].rssi = WMA_GET_RX_RSSI_NORMALIZED(rx_pkt_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800356 result->ap[i].rtt = 0;
357 result->ap[i].rtt_sd = 0;
358 result->ap[i].ieLength = ie_len;
359 cdf_mem_copy((uint8_t *) &result->ap[i].ssid[0],
360 (uint8_t *) frame->ssId.ssId, frame->ssId.length);
361 result->ap[i].ssid[frame->ssId.length] = '\0';
362 cdf_mem_copy((uint8_t *) &result->ap[i].bssid,
363 (uint8_t *) hdr->bssId,
364 sizeof(tSirMacAddr));
365 /* Copy IE fields */
366 cdf_mem_copy((uint8_t *) &result->ap[i].ieData,
367 body + SIR_MAC_B_PR_SSID_OFFSET, ie_len);
368 }
369
370 mmh_msg.type = msg_type;
371 mmh_msg.bodyptr = result;
372 mmh_msg.bodyval = 0;
373 lim_sys_process_mmh_msg_api(pmac, &mmh_msg, ePROT);
374}
375
376
377static void
378__lim_ext_scan_forward_bcn_probe_rsp(tpAniSirGlobal pmac, uint8_t *rx_pkt_info,
379 tSirProbeRespBeacon *frame,
380 uint32_t ie_len,
381 uint32_t msg_type)
382{
383 tpSirWifiFullScanResultEvent result;
384 uint8_t *body;
385 tSirMsgQ mmh_msg;
386 tpSirMacMgmtHdr hdr;
387
388 result = cdf_mem_malloc(sizeof(*result) + ie_len);
389 if (NULL == result) {
390 lim_log(pmac, LOGE, FL("Memory allocation failed"));
391 return;
392 }
393 hdr = WMA_GET_RX_MAC_HEADER(rx_pkt_info);
394 body = WMA_GET_RX_MPDU_DATA(rx_pkt_info);
395 cdf_mem_zero(result, sizeof(*result) + ie_len);
396
397 /* Received frame does not have request id, hence set 0 */
398 result->requestId = 0;
399
400 result->moreData = 0;
401 result->ap.ts = cdf_mc_timer_get_system_time();
402 result->ap.beaconPeriod = frame->beaconInterval;
403 result->ap.capability =
404 lim_get_u16((uint8_t *) &frame->capabilityInfo);
405 result->ap.channel = WMA_GET_RX_CH(rx_pkt_info);
Deepak Dhamdhere68929ec2015-08-05 15:16:35 -0700406 result->ap.rssi = WMA_GET_RX_RSSI_NORMALIZED(rx_pkt_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800407 result->ap.rtt = 0;
408 result->ap.rtt_sd = 0;
409 result->ap.ieLength = ie_len;
410
411 cdf_mem_copy((uint8_t *) &result->ap.ssid[0],
412 (uint8_t *) frame->ssId.ssId, frame->ssId.length);
413 result->ap.ssid[frame->ssId.length] = '\0';
414 cdf_mem_copy((uint8_t *) &result->ap.bssid.bytes,
415 (uint8_t *) hdr->bssId,
416 CDF_MAC_ADDR_SIZE);
417 /* Copy IE fields */
418 cdf_mem_copy((uint8_t *) &result->ap.ieData,
419 body + SIR_MAC_B_PR_SSID_OFFSET, ie_len);
420
421 mmh_msg.type = msg_type;
422 mmh_msg.bodyptr = result;
423 mmh_msg.bodyval = 0;
424 lim_sys_process_mmh_msg_api(pmac, &mmh_msg, ePROT);
425}
426
427static void
428__lim_process_ext_scan_beacon_probe_rsp(tpAniSirGlobal pmac,
429 uint8_t *rx_pkt_info,
430 uint8_t sub_type)
431{
432 tSirProbeRespBeacon *frame;
433 uint8_t *body;
434 uint32_t frm_len;
435 tSirRetStatus status;
436
437 frm_len = WMA_GET_RX_PAYLOAD_LEN(rx_pkt_info);
438 if (frm_len <= SIR_MAC_B_PR_SSID_OFFSET) {
439 lim_log(pmac, LOGP,
440 FL("RX packet has invalid length %d"), frm_len);
441 return;
442 }
443
444 frame = cdf_mem_malloc(sizeof(*frame));
445 if (NULL == frame) {
446 lim_log(pmac, LOGE, FL("Memory allocation failed"));
447 return;
448 }
449
450 if (sub_type == SIR_MAC_MGMT_BEACON) {
451 lim_log(pmac, LOG2, FL("Beacon due to ExtScan/epno"));
452 status = sir_convert_beacon_frame2_struct(pmac,
453 (uint8_t *)rx_pkt_info,
454 frame);
455 } else if (sub_type == SIR_MAC_MGMT_PROBE_RSP) {
456 lim_log(pmac, LOG2, FL("Probe Rsp due to ExtScan/epno"));
457 body = WMA_GET_RX_MPDU_DATA(rx_pkt_info);
458 status = sir_convert_probe_frame2_struct(pmac, body,
459 frm_len, frame);
460 } else {
461 cdf_mem_free(frame);
462 return;
463 }
464
465 if (status != eSIR_SUCCESS) {
466 lim_log(pmac, LOGE, FL("Frame parsing failed"));
467 cdf_mem_free(frame);
468 return;
469 }
470
471 if (WMA_IS_EXTSCAN_SCAN_SRC(rx_pkt_info))
472 __lim_ext_scan_forward_bcn_probe_rsp(pmac, rx_pkt_info, frame,
473 (frm_len - SIR_MAC_B_PR_SSID_OFFSET),
474 eWNI_SME_EXTSCAN_FULL_SCAN_RESULT_IND);
475
476 if (WMA_IS_EPNO_SCAN_SRC(rx_pkt_info))
477 __lim_pno_match_fwd_bcn_probepsp(pmac, rx_pkt_info, frame,
478 (frm_len - SIR_MAC_B_PR_SSID_OFFSET),
479 eWNI_SME_EPNO_NETWORK_FOUND_IND);
480
481 cdf_mem_free(frame);
482}
483#endif
484
485/*
486 * Beacon Handling Cases:
487 * during scanning, when no session is active:
488 * handled by lim_handle_frames_in_scan_state before __lim_handle_beacon call is invoked.
489 * during scanning, when any session is active, but beacon/Pr does not belong to that session, psessionEntry will be null.
490 * handled by lim_handle_frames_in_scan_state before __lim_handle_beacon call is invoked.
491 * during scanning, when any session is active, and beacon/Pr belongs to one of the session, psessionEntry will not be null.
492 * handled by lim_handle_frames_in_scan_state before __lim_handle_beacon call is invoked.
493 * Not scanning, no session:
494 * there should not be any beacon coming, if coming, should be dropped.
495 * Not Scanning,
496 */
497static void
498__lim_handle_beacon(tpAniSirGlobal pMac, tpSirMsgQ pMsg,
499 tpPESession psessionEntry)
500{
501 /* checking for global SME state... */
502 uint8_t *pRxPacketInfo;
503 lim_get_b_dfrom_rx_packet(pMac, pMsg->bodyptr,
504 (uint32_t * *) &pRxPacketInfo);
505
506 /* This function should not be called if beacon is received in scan state. */
507 /* So not doing any checks for the global state. */
508
509 if (psessionEntry == NULL) {
510 sch_beacon_process(pMac, pRxPacketInfo, NULL);
511 } else if ((psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE) ||
512 (psessionEntry->limSmeState == eLIM_SME_NORMAL_STATE)) {
513 sch_beacon_process(pMac, pRxPacketInfo, psessionEntry);
514 } else
515 lim_process_beacon_frame(pMac, pRxPacketInfo, psessionEntry);
516
517 return;
518}
519
520/**
521 * lim_defer_msg()
522 *
523 ***FUNCTION:
524 * This function is called to defer the messages received
525 * during Learn mode
526 *
527 ***LOGIC:
528 * NA
529 *
530 ***ASSUMPTIONS:
531 * NA
532 *
533 ***NOTE:
534 * NA
535 *
536 * @param pMac - Pointer to Global MAC structure
537 * @param pMsg of type tSirMsgQ - Pointer to the message structure
538 * @return None
539 */
540
541uint32_t lim_defer_msg(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
542{
543 uint32_t retCode = TX_SUCCESS;
544
545 retCode = lim_write_deferred_msg_q(pMac, pMsg);
546
547 if (retCode == TX_SUCCESS) {
548 MTRACE(mac_trace_msg_rx
549 (pMac, NO_SESSION,
550 LIM_TRACE_MAKE_RXMSG(pMsg->type, LIM_MSG_DEFERRED));
551 )
552 } else {
553 lim_log(pMac, LOGE, FL("Dropped lim message (0x%X)"),
554 pMsg->type);
555 MTRACE(mac_trace_msg_rx
556 (pMac, NO_SESSION,
557 LIM_TRACE_MAKE_RXMSG(pMsg->type, LIM_MSG_DROPPED));
558 )
559 }
560
561 return retCode;
562} /*** end lim_defer_msg() ***/
563
564/**
565 * lim_handle_unknown_a2_index_frames() - This function handles Unknown Unicast
566 * (A2 Index) packets
567 * @mac_ctx: Pointer to the Global Mac Context.
568 * @rx_pkt_buffer: Pointer to the packet Buffer descriptor.
569 * @session_entry: Pointer to the PE Session Entry.
570 *
571 * This routine will handle public action frames.
572 *
573 * Return: None.
574 */
575static void lim_handle_unknown_a2_index_frames(tpAniSirGlobal mac_ctx,
576 void *rx_pkt_buffer, tpPESession session_entry)
577{
578#ifdef FEATURE_WLAN_TDLS
579 tpSirMacDataHdr3a mac_hdr;
580#endif
581 if (LIM_IS_P2P_DEVICE_ROLE(session_entry))
582 lim_process_action_frame_no_session(mac_ctx,
583 (uint8_t *) rx_pkt_buffer);
584#ifdef FEATURE_WLAN_TDLS
585 mac_hdr = WMA_GET_RX_MPDUHEADER3A(rx_pkt_buffer);
586
587 if (lim_is_group_addr(mac_hdr->addr2)) {
588 CDF_TRACE(CDF_MODULE_ID_PE, CDF_TRACE_LEVEL_INFO_HIGH,
589 FL("Ignoring A2 Invalid Packet received for MC/BC:"));
590 lim_print_mac_addr(mac_ctx, mac_hdr->addr2, LOG2);
591 return;
592 }
593 CDF_TRACE(CDF_MODULE_ID_PE, CDF_TRACE_LEVEL_INFO,
594 FL("type=0x%x, subtype=0x%x"),
595 mac_hdr->fc.type, mac_hdr->fc.subType);
596 /* Currently only following type and subtype are handled.
597 * If there are more combinations, then add switch-case
598 * statements.
599 */
600 if (LIM_IS_STA_ROLE(session_entry) &&
601 (mac_hdr->fc.type == SIR_MAC_MGMT_FRAME) &&
602 (mac_hdr->fc.subType == SIR_MAC_MGMT_ACTION))
603 lim_process_action_frame(mac_ctx, rx_pkt_buffer, session_entry);
604#endif
605 return;
606}
607
608/**
609 * lim_check_mgmt_registered_frames() - This function handles registered
610 * management frames.
611 *
612 * @mac_ctx: Pointer to the Global Mac Context.
613 * @buff_desc: Pointer to the packet Buffer descriptor.
614 * @session_entry: Pointer to the PE Session Entry.
615 *
616 * This function is called to process to check if received frame match with
617 * any of the registered frame from HDD. If yes pass this frame to SME.
618 *
619 * Return: True or False for Match or Mismatch respectively.
620 */
621static bool
622lim_check_mgmt_registered_frames(tpAniSirGlobal mac_ctx, uint8_t *buff_desc,
623 tpPESession session_entry)
624{
625 tSirMacFrameCtl fc;
626 tpSirMacMgmtHdr hdr;
627 uint8_t *body;
628 struct mgmt_frm_reg_info *mgmt_frame = NULL;
629 struct mgmt_frm_reg_info *next_frm = NULL;
630 uint16_t frm_type;
631 uint16_t frm_len;
632 uint8_t type, sub_type;
633 bool match = false;
634 CDF_STATUS cdf_status;
635
636 hdr = WMA_GET_RX_MAC_HEADER(buff_desc);
637 fc = hdr->fc;
638 frm_type = (fc.type << 2) | (fc.subType << 4);
639 body = WMA_GET_RX_MPDU_DATA(buff_desc);
640 frm_len = WMA_GET_RX_PAYLOAD_LEN(buff_desc);
641
642 cdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
643 cdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
644 (cdf_list_node_t **) &mgmt_frame);
645 cdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
646
647 while (mgmt_frame != NULL) {
648 type = (mgmt_frame->frameType >> 2) & 0x03;
649 sub_type = (mgmt_frame->frameType >> 4) & 0x0f;
650 if ((type == SIR_MAC_MGMT_FRAME)
651 && (fc.type == SIR_MAC_MGMT_FRAME)
652 && (sub_type == SIR_MAC_MGMT_RESERVED15)) {
653 CDF_TRACE(CDF_MODULE_ID_PE, CDF_TRACE_LEVEL_INFO_HIGH,
654 FL
655 ("rcvd frm match for SIR_MAC_MGMT_RESERVED15"));
656 match = true;
657 break;
658 }
659 if (mgmt_frame->frameType == frm_type) {
660 if (mgmt_frame->matchLen <= 0) {
661 match = true;
662 break;
663 }
664 if (mgmt_frame->matchLen <= frm_len &&
665 cdf_mem_compare(mgmt_frame->matchData, body,
666 mgmt_frame->matchLen)) {
667 /* found match! */
668 match = true;
669 break;
670 }
671 }
672
673 cdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
674 cdf_status =
675 cdf_list_peek_next(
676 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
677 (cdf_list_node_t *) mgmt_frame,
678 (cdf_list_node_t **) &next_frm);
679 cdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
680 mgmt_frame = next_frm;
681 next_frm = NULL;
682 }
683
684 if (match) {
685 CDF_TRACE(CDF_MODULE_ID_PE, CDF_TRACE_LEVEL_INFO,
686 FL("rcvd frame match with registered frame params"));
687 /* Indicate this to SME */
688 lim_send_sme_mgmt_frame_ind(mac_ctx, hdr->fc.subType,
689 (uint8_t *) hdr,
690 WMA_GET_RX_PAYLOAD_LEN(buff_desc) +
691 sizeof(tSirMacMgmtHdr), mgmt_frame->sessionId,
692 WMA_GET_RX_CH(buff_desc), session_entry, 0);
693
694 if ((type == SIR_MAC_MGMT_FRAME)
695 && (fc.type == SIR_MAC_MGMT_FRAME)
696 && (sub_type == SIR_MAC_MGMT_RESERVED15))
697 /* These packets needs to be processed by PE/SME
698 * as well as HDD.If it returns true here,
699 * the packet is forwarded to HDD only.
700 */
701 match = false;
702 }
703
704 return match;
705}
706
707/**
708 * lim_handle80211_frames()
709 *
710 ***FUNCTION:
711 * This function is called to process 802.11 frames
712 * received by LIM.
713 *
714 ***LOGIC:
715 * NA
716 *
717 ***ASSUMPTIONS:
718 * NA
719 *
720 ***NOTE:
721 * NA
722 *
723 * @param pMac - Pointer to Global MAC structure
724 * @param pMsg of type tSirMsgQ - Pointer to the message structure
725 * @return None
726 */
727
728static void
729lim_handle80211_frames(tpAniSirGlobal pMac, tpSirMsgQ limMsg, uint8_t *pDeferMsg)
730{
731 uint8_t *pRxPacketInfo = NULL;
732 tSirMacFrameCtl fc;
733 tpSirMacMgmtHdr pHdr = NULL;
734 tpPESession psessionEntry = NULL;
735 uint8_t sessionId;
736 tAniBool isFrmFt = false;
737
738 *pDeferMsg = false;
739 lim_get_b_dfrom_rx_packet(pMac, limMsg->bodyptr,
740 (uint32_t * *) &pRxPacketInfo);
741
742 pHdr = WMA_GET_RX_MAC_HEADER(pRxPacketInfo);
743 isFrmFt = WMA_GET_RX_FT_DONE(pRxPacketInfo);
744 fc = pHdr->fc;
745
746#ifdef WLAN_DUMP_MGMTFRAMES
747 lim_log(pMac, LOGE,
748 FL("ProtVersion %d, Type %d, Subtype %d rateIndex=%d"),
749 fc.protVer, fc.type, fc.subType,
750 WMA_GET_RX_MAC_RATE_IDX(pRxPacketInfo));
751 CDF_TRACE_HEX_DUMP(CDF_MODULE_ID_PE, CDF_TRACE_LEVEL_ERROR, pHdr,
752 WMA_GET_RX_MPDU_HEADER_LEN(pRxPacketInfo));
753#endif
754 if (pMac->fEnableDebugLog & 0x1) {
755 if ((fc.type == SIR_MAC_MGMT_FRAME) &&
756 (fc.subType != SIR_MAC_MGMT_PROBE_REQ) &&
757 (fc.subType != SIR_MAC_MGMT_PROBE_RSP) &&
758 (fc.subType != SIR_MAC_MGMT_BEACON)) {
759 lim_log(pMac, LOGE,
760 FL("RX MGMT - Type %hu, SubType %hu, seq num[%d]"),
761 fc.type,
762 fc.subType,
763 ((pHdr->seqControl.seqNumHi <<
764 HIGH_SEQ_NUM_OFFSET) |
765 pHdr->seqControl.seqNumLo));
766 }
767 }
768#ifdef FEATURE_WLAN_EXTSCAN
769 if (WMA_IS_EXTSCAN_SCAN_SRC(pRxPacketInfo) ||
770 WMA_IS_EPNO_SCAN_SRC(pRxPacketInfo)) {
771 if (fc.subType == SIR_MAC_MGMT_BEACON ||
772 fc.subType == SIR_MAC_MGMT_PROBE_RSP) {
773 __lim_process_ext_scan_beacon_probe_rsp(pMac,
774 pRxPacketInfo,
775 fc.subType);
776 } else {
777 lim_log(pMac, LOGE,
778 FL("Wrong frameType %d, Subtype %d for %d"),
779 fc.type, fc.subType,
780 WMA_GET_SCAN_SRC(pRxPacketInfo));
781 }
782 goto end;
783 }
784#endif
785 if (WMA_GET_OFFLOADSCANLEARN(pRxPacketInfo)) {
786 if (fc.subType == SIR_MAC_MGMT_BEACON) {
787 lim_log(pMac, LOG2, FL("Learning scan beacon"));
788 __lim_handle_beacon(pMac, limMsg, NULL);
789 } else if (fc.subType == SIR_MAC_MGMT_PROBE_RSP) {
790 lim_log(pMac, LOG2, FL("Learning scan probe rsp"));
791 lim_process_probe_rsp_frame_no_session(pMac, pRxPacketInfo);
792 } else {
793 lim_log(pMac, LOGE,
794 FL("Wrong frame Type %d, Subtype %d for LFR"),
795 fc.type, fc.subType);
796 }
797 goto end;
798 }
799 /* Added For BT-AMP Support */
800 if ((psessionEntry =
801 pe_find_session_by_bssid(pMac, pHdr->bssId,
802 &sessionId)) == NULL) {
803#ifdef WLAN_FEATURE_VOWIFI_11R
804 if (fc.subType == SIR_MAC_MGMT_AUTH) {
805#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
806 lim_log(pMac, LOG1,
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -0700807 FL("ProtVersion %d, Type %d, Subtype %d rateIndex=%d"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800808 fc.protVer, fc.type, fc.subType,
809 WMA_GET_RX_MAC_RATE_IDX(pRxPacketInfo));
810 lim_print_mac_addr(pMac, pHdr->bssId, LOG1);
811#endif
812 if (lim_process_auth_frame_no_session
813 (pMac, pRxPacketInfo,
814 limMsg->bodyptr) == eSIR_SUCCESS) {
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -0700815 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800816 }
817 }
818#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -0700819 /* Public action frame can be received from non-assoc stations*/
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800820 if ((fc.subType != SIR_MAC_MGMT_PROBE_RSP) &&
821 (fc.subType != SIR_MAC_MGMT_BEACON) &&
822 (fc.subType != SIR_MAC_MGMT_PROBE_REQ)
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -0700823 && (fc.subType != SIR_MAC_MGMT_ACTION)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800824
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -0700825 psessionEntry = pe_find_session_by_peer_sta(pMac,
826 pHdr->sa, &sessionId);
827 if (psessionEntry == NULL) {
828 lim_log(pMac, LOG3,
829 FL("session does not exist for bssId"));
830 lim_print_mac_addr(pMac, pHdr->sa, LOG3);
831 goto end;
832 } else {
833 lim_log(pMac, LOG3,
834 "SessionId:%d exists for given Bssid",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800835 psessionEntry->peSessionId);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -0700836 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800837 }
838 /* For p2p resp frames search for valid session with DA as */
839 /* BSSID will be SA and session will be present with DA only */
840 if (fc.subType == SIR_MAC_MGMT_ACTION) {
841 psessionEntry =
842 pe_find_session_by_bssid(pMac, pHdr->da, &sessionId);
843 }
844 }
845
846 /* Check if frame is registered by HDD */
847 if (lim_check_mgmt_registered_frames(pMac, pRxPacketInfo, psessionEntry)) {
848 lim_log(pMac, LOG1, FL("Received frame is passed to SME"));
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -0700849 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800850 }
851
852 if (fc.protVer != SIR_MAC_PROTOCOL_VERSION) { /* Received Frame with non-zero Protocol Version */
853 lim_log(pMac, LOGE,
854 FL("Unexpected frame with protVersion %d received"),
855 fc.protVer);
856 lim_pkt_free(pMac, TXRX_FRM_802_11_MGMT, pRxPacketInfo,
857 (void *)limMsg->bodyptr);
858#ifdef WLAN_DEBUG
859 pMac->lim.numProtErr++;
860#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -0700861 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800862 }
863
864/* Chance of crashing : to be done BT-AMP ........happens when broadcast probe req is received */
865
866#ifdef WLAN_DEBUG
867 pMac->lim.numMAC[fc.type][fc.subType]++;
868#endif
869
870 switch (fc.type) {
871 case SIR_MAC_MGMT_FRAME:
872 {
873 /* Received Management frame */
874 switch (fc.subType) {
875 case SIR_MAC_MGMT_ASSOC_REQ:
876 /* Make sure the role supports Association */
877 if (LIM_IS_BT_AMP_AP_ROLE(psessionEntry) ||
878 LIM_IS_AP_ROLE(psessionEntry))
879 lim_process_assoc_req_frame(pMac,
880 pRxPacketInfo,
881 LIM_ASSOC,
882 psessionEntry);
883 else {
884 /* Unwanted messages - Log error */
885 lim_log(pMac, LOGE,
886 FL
887 ("unexpected message received %X"),
888 limMsg->type);
889 lim_print_msg_name(pMac, LOGE,
890 limMsg->type);
891 }
892 break;
893
894 case SIR_MAC_MGMT_ASSOC_RSP:
895 lim_process_assoc_rsp_frame(pMac, pRxPacketInfo,
896 LIM_ASSOC,
897 psessionEntry);
898 break;
899
900 case SIR_MAC_MGMT_REASSOC_REQ:
901 /* Make sure the role supports Reassociation */
902 if (LIM_IS_BT_AMP_AP_ROLE(psessionEntry) ||
903 LIM_IS_AP_ROLE(psessionEntry)) {
904 lim_process_assoc_req_frame(pMac,
905 pRxPacketInfo,
906 LIM_REASSOC,
907 psessionEntry);
908 } else {
909 /* Unwanted messages - Log error */
910 lim_log(pMac, LOGE,
911 FL
912 ("unexpected message received %X"),
913 limMsg->type);
914 lim_print_msg_name(pMac, LOGE,
915 limMsg->type);
916 }
917 break;
918
919 case SIR_MAC_MGMT_REASSOC_RSP:
920 lim_process_assoc_rsp_frame(pMac, pRxPacketInfo,
921 LIM_REASSOC,
922 psessionEntry);
923 break;
924
925 case SIR_MAC_MGMT_PROBE_REQ:
926 lim_process_probe_req_frame_multiple_bss(pMac,
927 pRxPacketInfo,
928 psessionEntry);
929 break;
930
931 case SIR_MAC_MGMT_PROBE_RSP:
932 if (psessionEntry == NULL)
933 lim_process_probe_rsp_frame_no_session(pMac,
934 pRxPacketInfo);
935 else
936 lim_process_probe_rsp_frame(pMac,
937 pRxPacketInfo,
938 psessionEntry);
939 break;
940
941 case SIR_MAC_MGMT_BEACON:
942 __lim_handle_beacon(pMac, limMsg, psessionEntry);
943 break;
944
945 case SIR_MAC_MGMT_DISASSOC:
946 lim_process_disassoc_frame(pMac, pRxPacketInfo,
947 psessionEntry);
948 break;
949
950 case SIR_MAC_MGMT_AUTH:
951 lim_process_auth_frame(pMac, pRxPacketInfo,
952 psessionEntry);
953 break;
954
955 case SIR_MAC_MGMT_DEAUTH:
956 lim_process_deauth_frame(pMac, pRxPacketInfo,
957 psessionEntry);
958 break;
959
960 case SIR_MAC_MGMT_ACTION:
961 if (psessionEntry == NULL)
962 lim_process_action_frame_no_session(pMac,
963 pRxPacketInfo);
964 else {
965 if (WMA_GET_RX_UNKNOWN_UCAST
966 (pRxPacketInfo))
967 lim_handle_unknown_a2_index_frames
968 (pMac, pRxPacketInfo,
969 psessionEntry);
970 else
971 lim_process_action_frame(pMac,
972 pRxPacketInfo,
973 psessionEntry);
974 }
975 break;
976 default:
977 /* Received Management frame of 'reserved' subtype */
978 break;
979 } /* switch (fc.subType) */
980
981 }
982 break;
983 case SIR_MAC_DATA_FRAME:
984 {
985 }
986 break;
987 default:
988 /* Received frame of type 'reserved' */
989 break;
990
991 } /* switch (fc.type) */
992
993end:
994 lim_pkt_free(pMac, TXRX_FRM_802_11_MGMT, pRxPacketInfo,
995 (void *)limMsg->bodyptr);
996 return;
997} /*** end lim_handle80211_frames() ***/
998
999/**
1000 * lim_send_stop_scan_offload_req()
1001 *
1002 ***FUNCTION:
1003 * This function will be called to abort the ongoing offloaded scan
1004 * request.
1005 *
1006 *
1007 ***NOTE:
1008 *
1009 * @param pMac Pointer to Global MAC structure
1010 * @return CDF_STATUS_SUCCESS or CDF_STATUS_E_FAILURE
1011 */
1012CDF_STATUS lim_send_stop_scan_offload_req(tpAniSirGlobal pMac,
1013 uint8_t SessionId, uint32_t scan_id)
1014{
1015 tSirMsgQ msg;
1016 tSirRetStatus rc = eSIR_SUCCESS;
1017 tAbortScanParams *pAbortScanParams;
1018
1019 pAbortScanParams = cdf_mem_malloc(sizeof(tAbortScanParams));
1020 if (NULL == pAbortScanParams) {
1021 lim_log(pMac, LOGP,
1022 FL("Memory allocation failed for AbortScanParams"));
1023 return CDF_STATUS_E_NOMEM;
1024 }
1025
1026 pAbortScanParams->SessionId = SessionId;
1027 pAbortScanParams->scan_id = scan_id;
1028 msg.type = WMA_STOP_SCAN_OFFLOAD_REQ;
1029 msg.bodyptr = pAbortScanParams;
1030 msg.bodyval = 0;
1031
1032 rc = wma_post_ctrl_msg(pMac, &msg);
1033 if (rc != eSIR_SUCCESS) {
1034 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() return failure"));
1035 cdf_mem_free(pAbortScanParams);
1036 return CDF_STATUS_E_FAILURE;
1037 }
1038
1039 lim_log(pMac, LOG1, FL("Abort ongoing offload scan."));
1040 return CDF_STATUS_SUCCESS;
1041
1042}
1043
1044/**
1045 * lim_process_abort_scan_ind()
1046 *
1047 ***FUNCTION:
1048 * This function is called from HDD to abort the scan which is presently being run
1049 *
1050 *
1051 ***NOTE:
1052 *
1053 * @param pMac Pointer to Global MAC structure
1054 * @param *pMsgBuf A pointer to the SME message buffer
1055 * @return None
1056 */
1057void lim_process_abort_scan_ind(tpAniSirGlobal mac_ctx,
1058 uint8_t session_id, uint32_t scan_id)
1059{
1060#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1061 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_ABORT_IND_EVENT, NULL, 0, 0);
1062#endif
1063
1064 lim_log(mac_ctx, LOG2, FL("Processing AbortScan Ind scan_id %d"),
1065 scan_id);
1066
1067 /* send stop scan cmd to fw if scan offload is enabled. */
1068 lim_send_stop_scan_offload_req(mac_ctx, session_id, scan_id);
1069 return;
1070}
1071
1072/**
1073 * lim_message_processor() - Process messages from LIM.
1074 *
1075 * @mac_ctx: Pointer to the Global Mac Context.
1076 * @msg: Received LIM message.
1077 *
1078 * Wrapper function for lim_process_messages when handling messages received by
1079 * LIM.Could either defer messages or process them.
1080 *
1081 * Return: None.
1082 */
1083void lim_message_processor(tpAniSirGlobal mac_ctx, tpSirMsgQ msg)
1084{
1085 if (eLIM_MLM_OFFLINE_STATE == mac_ctx->lim.gLimMlmState) {
1086 pe_free_msg(mac_ctx, msg);
1087 return;
1088 }
1089
1090 if (!def_msg_decision(mac_ctx, msg)) {
1091 lim_process_messages(mac_ctx, msg);
1092 /* process deferred message queue if allowed */
1093 if ((!(mac_ctx->lim.gLimAddtsSent)) &&
1094 (!(lim_is_system_in_scan_state(mac_ctx))) &&
1095 (true == GET_LIM_PROCESS_DEFD_MESGS(mac_ctx)))
1096 lim_process_deferred_message_queue(mac_ctx);
1097 }
1098}
1099
1100#ifdef FEATURE_OEM_DATA_SUPPORT
1101
1102void lim_oem_data_rsp_handle_resume_link_rsp(tpAniSirGlobal pMac, CDF_STATUS status,
1103 uint32_t *mlmOemDataRsp)
1104{
1105 if (status != CDF_STATUS_SUCCESS) {
1106 lim_log(pMac, LOGE,
1107 FL
1108 ("OEM Data Rsp failed to get the response for resume link"));
1109 }
1110
1111 if (NULL != pMac->lim.gpLimMlmOemDataReq) {
1112 cdf_mem_free(pMac->lim.gpLimMlmOemDataReq);
1113 pMac->lim.gpLimMlmOemDataReq = NULL;
1114 }
1115 /* "Failure" status doesn't mean that Oem Data Rsp did not happen */
1116 /* and hence we need to respond to upper layers. Only Resume link is failed, but */
1117 /* we got the oem data response already. */
1118 /* Post the meessage to MLM */
1119 lim_post_sme_message(pMac, LIM_MLM_OEM_DATA_CNF,
1120 (uint32_t *) (mlmOemDataRsp));
1121
1122 return;
1123}
1124
1125void lim_process_oem_data_rsp(tpAniSirGlobal pMac, uint32_t *body)
1126{
1127 tpLimMlmOemDataRsp mlmOemDataRsp = NULL;
1128
1129 /* Process all the messages for the lim queue */
1130 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
1131
1132 mlmOemDataRsp = (tpLimMlmOemDataRsp) body;
1133
1134 PELOG1(lim_log
1135 (pMac, LOG1, FL("%s: sending oem data response msg to sme"),
1136 __func__);
1137 )
1138 lim_post_sme_message(pMac, LIM_MLM_OEM_DATA_CNF,
1139 (uint32_t *) (mlmOemDataRsp));
1140
1141 return;
1142}
1143
1144#endif
1145
1146/**
1147 * lim_process_messages() - Process messages from upper layers.
1148 *
1149 * @mac_ctx: Pointer to the Global Mac Context.
1150 * @msg: Received message.
1151 *
1152 * Return: None.
1153 */
1154void lim_process_messages(tpAniSirGlobal mac_ctx, tpSirMsgQ msg)
1155{
1156#ifdef FEATURE_AP_MCC_CH_AVOIDANCE
1157 uint8_t vdev_id = 0;
1158 tUpdateBeaconParams beacon_params;
1159#endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
1160 uint8_t i;
1161 uint8_t p2p_go_exists = 0;
1162 tpPESession session_entry = NULL;
1163 uint8_t defer_msg = false;
1164 tLinkStateParams *link_state_param;
1165 uint16_t pkt_len = 0;
1166 cds_pkt_t *body_ptr = NULL;
1167 CDF_STATUS cdf_status;
1168 tSirMsgQ new_msg;
1169 tSirSmeScanAbortReq *req_msg = NULL;
1170 uint8_t session_id;
1171 uint32_t scan_id;
1172
1173#ifdef FEATURE_WLAN_TDLS
1174 tSirTdlsInd *tdls_ind = NULL;
1175 tpDphHashNode sta_ds = NULL;
1176 tTdlsLinkEstablishParams *tdls_link_params = NULL;
1177#endif
1178 tSirMbMsgP2p *p2p_msg = NULL;
1179 if (ANI_DRIVER_TYPE(mac_ctx) == eDRIVER_TYPE_MFG) {
1180 cdf_mem_free(msg->bodyptr);
1181 msg->bodyptr = NULL;
1182 return;
1183 }
1184 if (msg == NULL) {
1185 lim_log(mac_ctx, LOGE, FL("Message pointer is Null"));
1186 CDF_ASSERT(0);
1187 return;
1188 }
1189#ifdef WLAN_DEBUG
1190 mac_ctx->lim.numTot++;
1191#endif
1192 MTRACE(mac_trace_msg_rx(mac_ctx, NO_SESSION,
1193 LIM_TRACE_MAKE_RXMSG(msg->type, LIM_MSG_PROCESSED));)
1194
1195 switch (msg->type) {
1196
1197 case SIR_LIM_UPDATE_BEACON:
1198 lim_update_beacon(mac_ctx);
1199 break;
1200 case SIR_CFG_PARAM_UPDATE_IND:
1201 if (!lim_is_system_in_scan_state(mac_ctx)) {
1202 lim_handle_cf_gparam_update(mac_ctx, msg->bodyval);
1203 break;
1204 }
1205 /* System is in DFS (Learn) mode.
1206 * Defer processsing this message
1207 */
1208 if (lim_defer_msg(mac_ctx, msg) != TX_SUCCESS) {
1209 if (!(mac_ctx->lim.deferredMsgCnt & 0xF))
1210 CDF_TRACE(CDF_MODULE_ID_PE, LOGE,
1211 FL("Unable to Defer Msg"));
1212 lim_log_session_states(mac_ctx);
1213 lim_print_msg_name(mac_ctx, LOGE, msg->type);
1214 }
1215 break;
1216#ifdef FEATURE_OEM_DATA_SUPPORT
1217 case WMA_START_OEM_DATA_RSP:
1218 lim_process_oem_data_rsp(mac_ctx, msg->bodyptr);
1219 msg->bodyptr = NULL;
1220 break;
1221#endif
1222 case WMA_SWITCH_CHANNEL_RSP:
1223 lim_process_switch_channel_rsp(mac_ctx, msg->bodyptr);
1224 msg->bodyptr = NULL;
1225 break;
1226#ifdef ANI_SIR_IBSS_PEER_CACHING
1227 case WMA_IBSS_STA_ADD:
1228 lim_ibss_sta_add(mac_ctx, msg->bodyptr);
1229 break;
1230#endif
1231 case SIR_BB_XPORT_MGMT_MSG:
1232 /* These messages are from Peer MAC entity. */
1233#ifdef WLAN_DEBUG
1234 mac_ctx->lim.numBbt++;
1235#endif
1236 /* The original msg which we were deferring have the
1237 * bodyPointer point to 'BD' instead of 'cds pkt'. If we
1238 * don't make a copy of msg, then overwrite the
1239 * msg->bodyPointer and next time when we try to
1240 * process the msg, we will try to use 'BD' as
1241 * 'cds Pkt' which will cause a crash
1242 */
1243 if (msg->bodyptr == NULL) {
1244 lim_log(mac_ctx, LOGE, FL("Message bodyptr is Null"));
1245 CDF_ASSERT(0);
1246 break;
1247 }
1248 cdf_mem_copy((uint8_t *) &new_msg,
1249 (uint8_t *) msg, sizeof(tSirMsgQ));
1250 body_ptr = (cds_pkt_t *) new_msg.bodyptr;
1251 cds_pkt_get_packet_length(body_ptr, &pkt_len);
1252
1253 cdf_status = wma_ds_peek_rx_packet_info(body_ptr,
1254 (void **) &new_msg.bodyptr, false);
1255
1256 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
1257 cds_pkt_return_packet(body_ptr);
1258 break;
1259 }
1260
1261 if (WMA_GET_ROAMCANDIDATEIND(new_msg.bodyptr))
1262 lim_log(mac_ctx, LOG1, FL("roamCandidateInd %d"),
1263 WMA_GET_ROAMCANDIDATEIND(new_msg.bodyptr));
1264
1265 if (WMA_GET_OFFLOADSCANLEARN(new_msg.bodyptr))
1266 lim_log(mac_ctx, LOG1, FL("offloadScanLearn %d"),
1267 WMA_GET_OFFLOADSCANLEARN(new_msg.bodyptr));
1268
1269 lim_handle80211_frames(mac_ctx, &new_msg, &defer_msg);
1270
1271 if (defer_msg == true) {
1272 CDF_TRACE(CDF_MODULE_ID_PE, LOG1,
1273 FL("Defer Msg type=%x"), msg->type);
1274 if (lim_defer_msg(mac_ctx, msg) != TX_SUCCESS) {
1275 CDF_TRACE(CDF_MODULE_ID_PE, LOGE,
1276 FL("Unable to Defer Msg"));
1277 lim_log_session_states(mac_ctx);
1278 cds_pkt_return_packet(body_ptr);
1279 }
1280 } else
1281 /* PE is not deferring this 802.11 frame so we need to
1282 * call cds_pkt_return. Asumption here is when Rx mgmt
1283 * frame processing is done, cds packet could be
1284 * freed here.
1285 */
1286 cds_pkt_return_packet(body_ptr);
1287 break;
1288 case eWNI_SME_SCAN_REQ:
1289 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
1290 case eWNI_SME_DISASSOC_REQ:
1291 case eWNI_SME_DEAUTH_REQ:
1292#ifdef FEATURE_OEM_DATA_SUPPORT
1293 case eWNI_SME_OEM_DATA_REQ:
1294#endif
1295#ifdef FEATURE_WLAN_TDLS
1296 case eWNI_SME_TDLS_SEND_MGMT_REQ:
1297 case eWNI_SME_TDLS_ADD_STA_REQ:
1298 case eWNI_SME_TDLS_DEL_STA_REQ:
1299 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
1300#endif
1301 case eWNI_SME_RESET_AP_CAPS_CHANGED:
1302 case eWNI_SME_SET_HW_MODE_REQ:
1303 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
1304 /* These messages are from HDD. Need to respond to HDD */
1305 lim_process_normal_hdd_msg(mac_ctx, msg, true);
1306 break;
1307
1308 case eWNI_SME_SCAN_ABORT_IND:
1309 req_msg = msg->bodyptr;
1310 if (req_msg) {
1311 session_id = req_msg->sessionId;
1312 scan_id = req_msg->scan_id;
1313 lim_process_abort_scan_ind(mac_ctx, session_id,
1314 scan_id);
1315 cdf_mem_free((void *)msg->bodyptr);
1316 msg->bodyptr = NULL;
1317 }
1318 break;
1319 case eWNI_SME_SYS_READY_IND:
1320 case eWNI_SME_JOIN_REQ:
1321 case eWNI_SME_REASSOC_REQ:
1322 case eWNI_SME_START_BSS_REQ:
1323 case eWNI_SME_STOP_BSS_REQ:
1324 case eWNI_SME_SWITCH_CHL_IND:
1325 case eWNI_SME_SETCONTEXT_REQ:
1326 case eWNI_SME_DISASSOC_CNF:
1327 case eWNI_SME_DEAUTH_CNF:
1328 case eWNI_SME_ASSOC_CNF:
1329 case eWNI_SME_ADDTS_REQ:
1330 case eWNI_SME_DELTS_REQ:
1331 case eWNI_SME_GET_ASSOC_STAS_REQ:
1332 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
1333 case eWNI_SME_UPDATE_APWPSIE_REQ:
1334 case eWNI_SME_HIDE_SSID_REQ:
1335 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
1336 case eWNI_SME_SET_APWPARSNIEs_REQ:
1337 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
1338#if defined WLAN_FEATURE_VOWIFI
1339 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
1340 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
1341#endif
1342#if defined FEATURE_WLAN_ESE
1343 case eWNI_SME_ESE_ADJACENT_AP_REPORT:
1344#endif
1345#ifdef WLAN_FEATURE_VOWIFI_11R
1346 case eWNI_SME_FT_UPDATE_KEY:
1347 case eWNI_SME_FT_PRE_AUTH_REQ:
1348 case eWNI_SME_FT_AGGR_QOS_REQ:
1349#endif
1350 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
1351 case eWNI_SME_UPDATE_NOA:
1352 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
1353 case eWNI_SME_GET_STATISTICS_REQ:
1354#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
1355 case eWNI_SME_GET_TSM_STATS_REQ:
1356#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Abhishek Singh518323d2015-10-19 17:42:01 +05301357 case eWNI_SME_EXT_CHANGE_CHANNEL:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001358 /* These messages are from HDD.No need to respond to HDD */
1359 lim_process_normal_hdd_msg(mac_ctx, msg, false);
1360 break;
1361
1362 case eWNI_PMC_SMPS_STATE_IND:
1363 if (msg->bodyptr) {
1364 cdf_mem_free(msg->bodyptr);
1365 msg->bodyptr = NULL;
1366 }
1367 break;
1368 case eWNI_SME_SEND_ACTION_FRAME_IND:
1369 lim_send_p2p_action_frame(mac_ctx, msg);
1370 cdf_mem_free(msg->bodyptr);
1371 msg->bodyptr = NULL;
1372 break;
1373 case eWNI_SME_ABORT_REMAIN_ON_CHAN_IND:
1374 p2p_msg = (tSirMbMsgP2p *) msg->bodyptr;
1375 lim_abort_remain_on_chan(mac_ctx, p2p_msg->sessionId,
1376 p2p_msg->scan_id);
1377 cdf_mem_free(msg->bodyptr);
1378 msg->bodyptr = NULL;
1379 break;
1380 case SIR_HAL_P2P_NOA_START_IND:
1381 session_entry = &mac_ctx->lim.gpSession[0];
1382 lim_log(mac_ctx, LOG1, "LIM received NOA start %x", msg->type);
1383
1384 /* Since insert NOA is done and NOA start msg received,
1385 * we should deactivate the Insert NOA timer
1386 */
1387 lim_deactivate_and_change_timer(mac_ctx,
1388 eLIM_INSERT_SINGLESHOT_NOA_TIMER);
1389
1390 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
1391 session_entry = &mac_ctx->lim.gpSession[i];
1392 if ((session_entry != NULL) && (session_entry->valid) &&
1393 (session_entry->pePersona == CDF_P2P_GO_MODE)) {
1394 /* Save P2P NOA start attribute for Go persona*/
1395 p2p_go_exists = 1;
1396 cdf_mem_copy(&session_entry->p2pGoPsNoaStartInd,
1397 msg->bodyptr, sizeof(tSirP2PNoaStart));
1398 cdf_status =
1399 session_entry->p2pGoPsNoaStartInd.status;
1400 if (cdf_status != CDF_STATUS_SUCCESS)
1401 CDF_TRACE(CDF_MODULE_ID_PE, LOGW,
1402 FL(
1403 "GO NOA start status %d by FW"),
1404 cdf_status);
1405 break;
1406 }
1407 }
1408
1409 if (p2p_go_exists == 0)
1410 CDF_TRACE(CDF_MODULE_ID_PE, LOGW,
1411 FL(
1412 "GO is removed by the time NOA start recvd"));
1413
1414 /* We received the NOA start indication. Now we can send down
1415 * the SME request which requires off-channel operation */
1416 lim_process_regd_defd_sme_req_after_noa_start(mac_ctx);
1417 cdf_mem_free(msg->bodyptr);
1418 msg->bodyptr = NULL;
1419 break;
1420#ifdef FEATURE_WLAN_TDLS
1421 case SIR_HAL_TDLS_IND:
1422 tdls_ind = (tpSirTdlsInd) msg->bodyptr;
1423 session_entry = pe_find_session_by_sta_id(mac_ctx,
1424 tdls_ind->staIdx, &session_id);
1425 if (session_entry == NULL) {
1426 lim_log(mac_ctx, LOG1,
1427 FL("No session exist for given bssId"));
1428 cdf_mem_free(msg->bodyptr);
1429 msg->bodyptr = NULL;
1430 return;
1431 }
1432 sta_ds = dph_get_hash_entry(mac_ctx, tdls_ind->assocId,
1433 &session_entry->dph.dphHashTable);
1434 if (sta_ds == NULL) {
1435 lim_log(mac_ctx, LOG1,
1436 FL("No sta_ds exist for given staId"));
1437 cdf_mem_free(msg->bodyptr);
1438 msg->bodyptr = NULL;
1439 return;
1440 }
1441
1442 if (STA_ENTRY_TDLS_PEER == sta_ds->staType) {
1443 lim_log(mac_ctx, LOGE,
1444 FL("rcvd TDLS IND from FW with RC %d "),
1445 tdls_ind->reasonCode);
1446 lim_send_sme_tdls_del_sta_ind(mac_ctx, sta_ds,
1447 session_entry, tdls_ind->reasonCode);
1448 }
1449 cdf_mem_free(msg->bodyptr);
1450 msg->bodyptr = NULL;
1451 break;
1452#endif
1453 case SIR_HAL_P2P_NOA_ATTR_IND:
1454 session_entry = &mac_ctx->lim.gpSession[0];
1455 lim_log(mac_ctx, LOG1, FL("Received message Noa_ATTR %x"),
1456 msg->type);
1457 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
1458 session_entry = &mac_ctx->lim.gpSession[i];
1459 if ((session_entry != NULL) && (session_entry->valid)
1460 && (session_entry->pePersona ==
1461 CDF_P2P_GO_MODE)) { /* Save P2P attr for Go */
1462 cdf_mem_copy(
1463 &session_entry->p2pGoPsUpdate,
1464 msg->bodyptr,
1465 sizeof(tSirP2PNoaAttr));
1466 lim_log(mac_ctx, LOG2,
1467 FL("bssId"
1468 MAC_ADDRESS_STR
1469 " ctWin=%d oppPsFlag=%d"),
1470 MAC_ADDR_ARRAY(
1471 session_entry->bssId),
1472 session_entry->p2pGoPsUpdate.ctWin,
1473 session_entry->p2pGoPsUpdate.oppPsFlag);
1474 lim_log(mac_ctx, LOG2,
1475 FL
1476 (" uNoa1IntervalCnt=%d uNoa1Duration=%d uNoa1Interval=%d uNoa1StartTime=%d"),
1477 session_entry->p2pGoPsUpdate.uNoa1IntervalCnt,
1478 session_entry->p2pGoPsUpdate.uNoa1Duration,
1479 session_entry->p2pGoPsUpdate.uNoa1Interval,
1480 session_entry->p2pGoPsUpdate.uNoa1StartTime);
1481 break;
1482 }
1483 }
1484 cdf_mem_free(msg->bodyptr);
1485 msg->bodyptr = NULL;
1486 break;
1487 case WMA_MISSED_BEACON_IND:
1488 lim_ps_offload_handle_missed_beacon_ind(mac_ctx, msg);
1489 cdf_mem_free(msg->bodyptr);
1490 msg->bodyptr = NULL;
1491 break;
1492#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1493 case WMA_ROAM_OFFLOAD_SYNCH_IND:
1494 lim_roam_offload_synch_ind(mac_ctx, msg);
1495 /* bodyPtr is freed after handling
1496 * eWNI_SME_ROAM_OFFLOAD_SYNCH_IND in sme_ProcessMsg */
1497 break;
1498#endif
1499 case SIR_LIM_ADDTS_RSP_TIMEOUT:
1500 lim_process_sme_req_messages(mac_ctx, msg);
1501 break;
1502#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001503 case WMA_TSM_STATS_RSP:
1504#ifdef FEATURE_WLAN_ESE_UPLOAD
1505 lim_send_sme_pe_ese_tsm_rsp(mac_ctx,
1506 (tAniGetTsmStatsRsp *) msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001507#endif /* FEATURE_WLAN_ESE_UPLOAD */
1508 break;
1509#endif
1510 case WMA_ADD_TS_RSP:
1511 lim_process_hal_add_ts_rsp(mac_ctx, msg);
1512 break;
1513 case SIR_LIM_DEL_TS_IND:
1514 lim_process_del_ts_ind(mac_ctx, msg);
1515 break;
1516 case SIR_LIM_BEACON_GEN_IND:
1517 if (mac_ctx->lim.gLimSystemRole != eLIM_AP_ROLE)
1518 sch_process_pre_beacon_ind(mac_ctx, msg);
1519 break;
1520 case SIR_LIM_DELETE_STA_CONTEXT_IND:
1521 lim_delete_sta_context(mac_ctx, msg);
1522 break;
1523 case SIR_LIM_PERIODIC_PROBE_REQ_TIMEOUT:
1524 case SIR_LIM_JOIN_FAIL_TIMEOUT:
1525 case SIR_LIM_PERIODIC_JOIN_PROBE_REQ_TIMEOUT:
1526 case SIR_LIM_AUTH_FAIL_TIMEOUT:
1527 case SIR_LIM_AUTH_RSP_TIMEOUT:
1528 case SIR_LIM_ASSOC_FAIL_TIMEOUT:
1529 case SIR_LIM_REASSOC_FAIL_TIMEOUT:
1530#ifdef WLAN_FEATURE_VOWIFI_11R
1531 case SIR_LIM_FT_PREAUTH_RSP_TIMEOUT:
1532#endif
1533 case SIR_LIM_REMAIN_CHN_TIMEOUT:
1534 case SIR_LIM_INSERT_SINGLESHOT_NOA_TIMEOUT:
1535 case SIR_LIM_DISASSOC_ACK_TIMEOUT:
1536 case SIR_LIM_DEAUTH_ACK_TIMEOUT:
1537 case SIR_LIM_CONVERT_ACTIVE_CHANNEL_TO_PASSIVE:
1538 /* These timeout messages are handled by MLM sub module */
1539 lim_process_mlm_req_messages(mac_ctx, msg);
1540 break;
1541 case SIR_LIM_HEART_BEAT_TIMEOUT:
1542 /** check if heart beat failed, even if one Beacon
1543 * is rcvd within the Heart Beat interval continue
1544 * normal processing
1545 */
1546 if (NULL == msg->bodyptr)
1547 lim_log(mac_ctx, LOGE,
1548 FL("Can't Process HB TO - bodyptr is Null"));
1549 else {
1550 session_entry = (tpPESession) msg->bodyptr;
1551 lim_log(mac_ctx, LOGE,
1552 FL
1553 ("SIR_LIM_HEART_BEAT_TIMEOUT, Session %d"),
1554 ((tpPESession) msg->bodyptr)->peSessionId);
1555 limResetHBPktCount(session_entry);
1556 lim_handle_heart_beat_timeout_for_session(mac_ctx,
1557 session_entry);
1558 }
1559 break;
1560 case SIR_LIM_PROBE_HB_FAILURE_TIMEOUT:
1561 lim_handle_heart_beat_failure_timeout(mac_ctx);
1562 break;
1563 case SIR_LIM_HASH_MISS_THRES_TIMEOUT:
1564 mac_ctx->lim.gLimDisassocFrameCredit = 0;
1565 break;
1566 case SIR_LIM_CNF_WAIT_TIMEOUT:
1567 /* Does not receive CNF or dummy packet */
1568 lim_handle_cnf_wait_timeout(mac_ctx, (uint16_t) msg->bodyval);
1569 break;
1570 case SIR_LIM_RETRY_INTERRUPT_MSG:
1571 /* Message from ISR upon TFP's max retry limit interrupt */
1572 break;
1573 case SIR_LIM_INV_KEY_INTERRUPT_MSG:
1574 /* Message from ISR upon SP's Invalid session key interrupt */
1575 break;
1576 case SIR_LIM_KEY_ID_INTERRUPT_MSG:
1577 /* Message from ISR upon SP's Invalid key ID interrupt */
1578 break;
1579 case SIR_LIM_REPLAY_THRES_INTERRUPT_MSG:
1580 /* Message from ISR upon SP's Replay threshold interrupt */
1581 break;
1582 case SIR_LIM_CHANNEL_SWITCH_TIMEOUT:
1583 lim_process_channel_switch_timeout(mac_ctx);
1584 break;
1585 case SIR_LIM_QUIET_TIMEOUT:
1586 lim_process_quiet_timeout(mac_ctx);
1587 break;
1588 case SIR_LIM_QUIET_BSS_TIMEOUT:
1589 lim_process_quiet_bss_timeout(mac_ctx);
1590 break;
1591 case SIR_LIM_UPDATE_OLBC_CACHEL_TIMEOUT:
1592 lim_handle_update_olbc_cache(mac_ctx);
1593 break;
1594#ifdef FEATURE_WLAN_TDLS
1595 case SIR_HAL_TDLS_SHOULD_DISCOVER:
1596 case SIR_HAL_TDLS_SHOULD_TEARDOWN:
1597 case SIR_HAL_TDLS_PEER_DISCONNECTED:
1598 CDF_TRACE(CDF_MODULE_ID_PE, CDF_TRACE_LEVEL_INFO,
1599 ("%s received tdls event: 0x%x"), __func__, msg->type);
1600 lim_send_sme_tdls_event_notify(mac_ctx, msg->type,
1601 (void *)msg->bodyptr);
1602 break;
1603#endif
1604 case WMA_ADD_BSS_RSP:
1605 lim_process_mlm_add_bss_rsp(mac_ctx, msg);
1606 break;
1607 case WMA_ADD_STA_RSP:
1608 lim_process_add_sta_rsp(mac_ctx, msg);
1609 break;
1610 case WMA_DELETE_STA_RSP:
1611 lim_process_mlm_del_sta_rsp(mac_ctx, msg);
1612 break;
1613 case WMA_DELETE_BSS_RSP:
1614 lim_handle_delete_bss_rsp(mac_ctx, msg);
1615 break;
1616 case WMA_CSA_OFFLOAD_EVENT:
1617 lim_handle_csa_offload_msg(mac_ctx, msg);
1618 break;
1619 case WMA_SET_BSSKEY_RSP:
1620 case WMA_SET_STA_BCASTKEY_RSP:
1621 lim_process_mlm_set_bss_key_rsp(mac_ctx, msg);
1622 break;
1623 case WMA_SET_STAKEY_RSP:
1624 lim_process_mlm_set_sta_key_rsp(mac_ctx, msg);
1625 break;
1626 case WMA_GET_STATISTICS_RSP:
1627 lim_send_sme_pe_statistics_rsp(mac_ctx, msg->type,
1628 (void *)msg->bodyptr);
1629 break;
1630 case WMA_SET_MIMOPS_RSP:
1631 case WMA_SET_TX_POWER_RSP:
1632 cdf_mem_free((void *)msg->bodyptr);
1633 msg->bodyptr = NULL;
1634 break;
1635 case WMA_SET_MAX_TX_POWER_RSP:
1636#if defined WLAN_FEATURE_VOWIFI
1637 rrm_set_max_tx_power_rsp(mac_ctx, msg);
1638#endif
1639 if (msg->bodyptr != NULL) {
1640 cdf_mem_free((void *)msg->bodyptr);
1641 msg->bodyptr = NULL;
1642 }
1643 break;
1644 case SIR_LIM_ADDR2_MISS_IND:
1645 lim_log(mac_ctx, LOGE,
1646 FL("Addr2 mismatch interrupt received %X"), msg->type);
1647 /* message from HAL indicating addr2 mismatch interrupt occurred
1648 * msg->bodyptr contains only pointer to 48-bit addr2 field
1649 */
1650 cdf_mem_free((void *)(msg->bodyptr));
1651 msg->bodyptr = NULL;
1652 break;
1653#ifdef WLAN_FEATURE_VOWIFI_11R
1654 case WMA_AGGR_QOS_RSP:
1655 lim_process_ft_aggr_qo_s_rsp(mac_ctx, msg);
1656 break;
1657#endif
1658 case WMA_SET_LINK_STATE_RSP:
1659 link_state_param = (tLinkStateParams *) msg->bodyptr;
1660#if defined WLAN_FEATURE_VOWIFI_11R
1661 session_entry = link_state_param->session;
1662 if (link_state_param->ft
1663#if defined WLAN_FEATURE_ROAM_OFFLOAD
1664 && !session_entry->bRoamSynchInProgress
1665#endif
1666 )
1667 lim_send_reassoc_req_with_ft_ies_mgmt_frame(mac_ctx,
1668 session_entry->pLimMlmReassocReq,
1669 session_entry);
1670#endif
1671 if (link_state_param->callback)
1672 link_state_param->callback(mac_ctx,
1673 link_state_param->callbackArg,
1674 link_state_param->status);
1675 cdf_mem_free((void *)(msg->bodyptr));
1676 msg->bodyptr = NULL;
1677 break;
1678 case eWNI_SME_SET_BCN_FILTER_REQ:
1679 session_id = (uint8_t) msg->bodyval;
1680 session_entry = &mac_ctx->lim.gpSession[session_id];
1681 if ((session_entry != NULL) &&
1682 (lim_send_beacon_filter_info(mac_ctx, session_entry) !=
1683 eSIR_SUCCESS))
1684 lim_log(mac_ctx, LOGE,
1685 FL("Failied to send Beacon Filter Info "));
1686 cdf_mem_free((void *)(msg->bodyptr));
1687 msg->bodyptr = NULL;
1688 break;
1689#ifdef FEATURE_WLAN_TDLS
1690 case WMA_SET_TDLS_LINK_ESTABLISH_REQ_RSP:
1691 tdls_link_params = (tTdlsLinkEstablishParams *) msg->bodyptr;
1692 session_entry = pe_find_session_by_sta_id(mac_ctx,
1693 tdls_link_params->staIdx, &session_id);
1694 if (session_entry == NULL) {
1695 lim_log(mac_ctx, LOGE,
1696 FL("session %u does not exist"), session_id);
1697 /* Still send the eWNI_SME_TDLS_LINK_ESTABLISH_RSP
1698 * message to SME with session id as zero and status
1699 * as FAILURE so, that message queued in SME queue
1700 * can be freed to prevent the SME cmd buffer leak
1701 */
1702 lim_send_sme_tdls_link_establish_req_rsp(mac_ctx, 0,
1703 NULL, NULL, eSIR_FAILURE);
1704 } else {
1705 lim_send_sme_tdls_link_establish_req_rsp(mac_ctx,
1706 session_entry->smeSessionId, NULL, NULL,
1707 tdls_link_params->status);
1708 }
1709 cdf_mem_free((void *)(msg->bodyptr));
1710 msg->bodyptr = NULL;
1711 break;
1712#endif
1713 case WMA_RX_SCAN_EVENT:
1714 lim_process_rx_scan_event(mac_ctx, msg->bodyptr);
1715 break;
1716 case WMA_IBSS_PEER_INACTIVITY_IND:
1717 lim_process_ibss_peer_inactivity(mac_ctx, msg->bodyptr);
1718 cdf_mem_free((void *)(msg->bodyptr));
1719 msg->bodyptr = NULL;
1720 break;
1721 case WMA_DFS_RADAR_IND:
1722 lim_send_sme_dfs_event_notify(mac_ctx, msg->type,
1723 (void *)msg->bodyptr);
1724 /* msg->bodyptr will be freed up by SME/CSR */
1725 break;
1726 case WMA_DFS_BEACON_TX_SUCCESS_IND:
1727 lim_process_beacon_tx_success_ind(mac_ctx, msg->type,
1728 (void *)msg->bodyptr);
1729 cdf_mem_free((void *)msg->bodyptr);
1730 msg->bodyptr = NULL;
1731 break;
1732 case WMA_DISASSOC_TX_COMP:
1733 lim_disassoc_tx_complete_cnf(mac_ctx, msg->bodyval);
1734 break;
1735 case WMA_DEAUTH_TX_COMP:
1736 lim_deauth_tx_complete_cnf(mac_ctx, msg->bodyval);
1737 break;
1738#ifdef FEATURE_AP_MCC_CH_AVOIDANCE
1739 case WMA_UPDATE_Q2Q_IE_IND:
1740 cdf_mem_zero(&beacon_params, sizeof(tUpdateBeaconParams));
1741 beacon_params.paramChangeBitmap = 0;
1742 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
1743 vdev_id = ((uint8_t *)msg->bodyptr)[i];
1744 session_entry = pe_find_session_by_sme_session_id(
1745 mac_ctx, vdev_id);
1746 if (session_entry == NULL)
1747 continue;
1748 session_entry->sap_advertise_avoid_ch_ie =
1749 (uint8_t)msg->bodyval;
1750 /*
1751 * if message comes for DFS channel, no need to update:
1752 * 1) We wont have MCC with DFS channels. so no need to
1753 * add Q2Q IE
1754 * 2) We cannot end up in DFS channel SCC by channel
1755 * switch from non DFS MCC scenario, so no need to
1756 * remove Q2Q IE
1757 * 3) There is however a case where device start MCC and
1758 * then user modifies hostapd.conf and does SAP
1759 * restart, in such a case, beacon params will be
1760 * reset and thus will not contain Q2Q IE, by default
1761 */
1762 if (cds_get_channel_state(
1763 session_entry->currentOperChannel)
1764 != CHANNEL_STATE_DFS) {
1765 beacon_params.bssIdx = session_entry->bssIdx;
1766 beacon_params.beaconInterval =
1767 session_entry->beaconParams.beaconInterval;
1768 beacon_params.paramChangeBitmap |=
1769 PARAM_BCN_INTERVAL_CHANGED;
1770 sch_set_fixed_beacon_fields(mac_ctx,
1771 session_entry);
1772 lim_send_beacon_params(mac_ctx, &beacon_params,
1773 session_entry);
1774 }
1775 }
1776 cdf_mem_free(msg->bodyptr);
1777 msg->bodyptr = NULL;
1778 break;
1779#endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
1780 case eWNI_SME_NSS_UPDATE_REQ:
1781 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
1782 lim_process_sme_req_messages(mac_ctx, msg);
1783 cdf_mem_free((void *)msg->bodyptr);
1784 msg->bodyptr = NULL;
1785 break;
1786 case eWNI_SME_CHANNEL_CHANGE_REQ:
1787 lim_process_sme_req_messages(mac_ctx, msg);
1788 cdf_mem_free((void *)msg->bodyptr);
1789 msg->bodyptr = NULL;
1790 break;
1791 case eWNI_SME_START_BEACON_REQ:
1792 lim_process_sme_req_messages(mac_ctx, msg);
1793 cdf_mem_free((void *)msg->bodyptr);
1794 msg->bodyptr = NULL;
1795 break;
1796 case eWNI_SME_UPDATE_ADDITIONAL_IES:
1797 lim_process_sme_req_messages(mac_ctx, msg);
1798 cdf_mem_free((void *)msg->bodyptr);
1799 msg->bodyptr = NULL;
1800 break;
1801 case eWNI_SME_MODIFY_ADDITIONAL_IES:
1802 lim_process_sme_req_messages(mac_ctx, msg);
1803 cdf_mem_free((void *)msg->bodyptr);
1804 msg->bodyptr = NULL;
1805 break;
1806#ifdef QCA_HT_2040_COEX
1807 case eWNI_SME_SET_HT_2040_MODE:
1808 lim_process_sme_req_messages(mac_ctx, msg);
1809 cdf_mem_free((void *)msg->bodyptr);
1810 msg->bodyptr = NULL;
1811 break;
1812#endif
1813 case SIR_HAL_SOC_SET_HW_MODE_RESP:
1814 lim_process_set_hw_mode_resp(mac_ctx, msg->bodyptr);
1815 cdf_mem_free((void *)msg->bodyptr);
1816 msg->bodyptr = NULL;
1817 break;
1818 case SIR_HAL_SOC_HW_MODE_TRANS_IND:
1819 lim_process_hw_mode_trans_ind(mac_ctx, msg->bodyptr);
1820 cdf_mem_free((void *)msg->bodyptr);
1821 msg->bodyptr = NULL;
1822 break;
1823 case SIR_HAL_SOC_DUAL_MAC_CFG_RESP:
1824 lim_process_dual_mac_cfg_resp(mac_ctx, msg->bodyptr);
1825 cdf_mem_free((void *)msg->bodyptr);
1826 msg->bodyptr = NULL;
1827 break;
1828 case eWNI_SME_SET_IE_REQ:
1829 lim_process_sme_req_messages(mac_ctx, msg);
1830 cdf_mem_free((void *)msg->bodyptr);
1831 msg->bodyptr = NULL;
1832 break;
1833 default:
1834 cdf_mem_free((void *)msg->bodyptr);
1835 msg->bodyptr = NULL;
1836 /* Unwanted messages */
1837 /* Log error */
1838 lim_log(mac_ctx, LOGE,
1839 FL("Discarding unexpected message received %X"),
1840 msg->type);
1841 lim_print_msg_name(mac_ctx, LOGE, msg->type);
1842 break;
1843
1844 } /* switch (msg->type) */
1845} /*** end lim_process_messages() ***/
1846
1847/**
1848 * lim_process_deferred_message_queue
1849 *
1850 ***FUNCTION:
1851 * This function is called by LIM while exiting from Learn
1852 * mode. This function fetches messages posted to the LIM
1853 * deferred message queue limDeferredMsgQ.
1854 *
1855 ***LOGIC:
1856 *
1857 ***ASSUMPTIONS:
1858 * NA
1859 *
1860 ***NOTE:
1861 * NA
1862 *
1863 * @param pMac - Pointer to Global MAC structure
1864 * @return None
1865 */
1866
1867void lim_process_deferred_message_queue(tpAniSirGlobal pMac)
1868{
1869 tSirMsgQ limMsg = { 0, 0, 0 };
1870
1871 tSirMsgQ *readMsg;
1872 uint16_t size;
1873
1874 /*
1875 ** check any deferred messages need to be processed
1876 **/
1877 size = pMac->lim.gLimDeferredMsgQ.size;
1878 if (size > 0) {
1879 while ((readMsg = lim_read_deferred_msg_q(pMac)) != NULL) {
1880 cdf_mem_copy((uint8_t *) &limMsg,
1881 (uint8_t *) readMsg, sizeof(tSirMsgQ));
1882 size--;
1883 lim_process_messages(pMac, &limMsg);
1884
1885 if ((lim_is_system_in_scan_state(pMac))
1886 || (true != GET_LIM_PROCESS_DEFD_MESGS(pMac))
Hema Aparna Medicharla5e1f3022015-08-24 11:22:29 +05301887 || (pMac->lim.gLimSystemInScanLearnMode)
1888 || pMac->lim.gLimAddtsSent)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001889 break;
1890 }
1891 }
1892} /*** end lim_process_deferred_message_queue() ***/
1893
1894/**
1895 * lim_process_normal_hdd_msg() - Process the message and defer if needed
1896 * @mac_ctx : Pointer to Global MAC structure
1897 * @msg : The message need to be processed
1898 * @rsp_reqd: whether return result to hdd
1899 *
1900 * This function checks the current lim state and decide whether the message
1901 * passed will be deferred or not.
1902 *
1903 * Return: None
1904 */
1905static void lim_process_normal_hdd_msg(tpAniSirGlobal mac_ctx, tSirMsgQ *msg,
1906 uint8_t rsp_reqd)
1907{
1908 bool defer_msg = true;
1909
1910 /* Added For BT-AMP Support */
1911 if ((mac_ctx->lim.gLimSystemRole == eLIM_AP_ROLE)
1912 || (mac_ctx->lim.gLimSystemRole == eLIM_BT_AMP_AP_ROLE)
1913 || (mac_ctx->lim.gLimSystemRole == eLIM_BT_AMP_STA_ROLE)
1914 || (mac_ctx->lim.gLimSystemRole == eLIM_UNKNOWN_ROLE)) {
1915 /*
1916 * This check is required only for the AP and in 2 cases.
1917 * 1. If we are in learn mode and we receive any of these
1918 * messages, you have to come out of scan and process the
1919 * message, hence dont defer the message here. In handler,
1920 * these message could be defered till we actually come out of
1921 * scan mode.
1922 * 2. If radar is detected, you might have to defer all of
1923 * these messages except Stop BSS request/ Switch channel
1924 * request. This decision is also made inside its handler.
1925 *
1926 * Please be careful while using the flag defer_msg. Possibly
1927 * you might end up in an infinite loop.
1928 */
1929 if ((msg->type == eWNI_SME_START_BSS_REQ) ||
1930 (msg->type == eWNI_SME_STOP_BSS_REQ) ||
1931 (msg->type == eWNI_SME_SWITCH_CHL_IND))
1932 defer_msg = false;
1933 }
1934
1935 if (((mac_ctx->lim.gLimAddtsSent) ||
1936 (lim_is_system_in_scan_state(mac_ctx))) && defer_msg) {
1937 /*
1938 * System is in DFS (Learn) mode or awaiting addts response or
1939 * if radar is detected, Defer processsing this message
1940 */
1941 if (lim_defer_msg(mac_ctx, msg) != TX_SUCCESS) {
1942#ifdef WLAN_DEBUG
1943 mac_ctx->lim.numSme++;
1944#endif
1945 lim_log_session_states(mac_ctx);
1946 /* Release body */
1947 cdf_mem_free(msg->bodyptr);
1948 msg->bodyptr = NULL;
1949 }
1950 } else {
1951 /*
1952 * These messages are from HDD.Since these requests may also be
1953 * generated internally within LIM module, need to distinquish
1954 * and send response to host
1955 */
1956 if (rsp_reqd)
1957 mac_ctx->lim.gLimRspReqd = true;
1958#ifdef WLAN_DEBUG
1959 mac_ctx->lim.numSme++;
1960#endif
1961 if (lim_process_sme_req_messages(mac_ctx, msg)) {
1962 /*
1963 * Release body. limProcessSmeReqMessage consumed the
1964 * buffer. We can free it.
1965 */
1966 cdf_mem_free(msg->bodyptr);
1967 msg->bodyptr = NULL;
1968 }
1969 }
1970}
1971
1972void
1973handle_ht_capabilityand_ht_info(struct sAniSirGlobal *pMac,
1974 tpPESession psessionEntry)
1975{
1976 tSirMacHTCapabilityInfo macHTCapabilityInfo;
1977 tSirMacHTParametersInfo macHTParametersInfo;
1978 tSirMacHTInfoField1 macHTInfoField1;
1979 tSirMacHTInfoField2 macHTInfoField2;
1980 tSirMacHTInfoField3 macHTInfoField3;
1981 uint32_t cfgValue;
1982 uint8_t *ptr;
1983
1984 if (wlan_cfg_get_int(pMac, WNI_CFG_HT_CAP_INFO, &cfgValue) !=
1985 eSIR_SUCCESS) {
1986 lim_log(pMac, LOGP,
1987 FL("Fail to retrieve WNI_CFG_HT_CAP_INFO value"));
1988 return;
1989 }
1990 ptr = (uint8_t *) &macHTCapabilityInfo;
1991 *((uint16_t *) ptr) = (uint16_t) (cfgValue & 0xffff);
1992 pMac->lim.gHTLsigTXOPProtection =
1993 (uint8_t) macHTCapabilityInfo.lsigTXOPProtection;
1994 pMac->lim.gHTMIMOPSState =
1995 (tSirMacHTMIMOPowerSaveState) macHTCapabilityInfo.mimoPowerSave;
1996 pMac->lim.gHTGreenfield = (uint8_t) macHTCapabilityInfo.greenField;
1997 pMac->lim.gHTMaxAmsduLength =
1998 (uint8_t) macHTCapabilityInfo.maximalAMSDUsize;
1999 pMac->lim.gHTShortGI20Mhz = (uint8_t) macHTCapabilityInfo.shortGI20MHz;
2000 pMac->lim.gHTShortGI40Mhz = (uint8_t) macHTCapabilityInfo.shortGI40MHz;
2001 pMac->lim.gHTPSMPSupport = (uint8_t) macHTCapabilityInfo.psmp;
2002 pMac->lim.gHTDsssCckRate40MHzSupport =
2003 (uint8_t) macHTCapabilityInfo.dsssCckMode40MHz;
2004
2005 if (wlan_cfg_get_int(pMac, WNI_CFG_HT_AMPDU_PARAMS, &cfgValue) !=
2006 eSIR_SUCCESS) {
2007 lim_log(pMac, LOGP,
2008 FL("Fail to retrieve WNI_CFG_HT_PARAM_INFO value"));
2009 return;
2010 }
2011 ptr = (uint8_t *) &macHTParametersInfo;
2012 *ptr = (uint8_t) (cfgValue & 0xff);
2013 pMac->lim.gHTAMpduDensity = (uint8_t) macHTParametersInfo.mpduDensity;
2014 pMac->lim.gHTMaxRxAMpduFactor =
2015 (uint8_t) macHTParametersInfo.maxRxAMPDUFactor;
2016
2017 /* Get HT IE Info */
2018 if (wlan_cfg_get_int(pMac, WNI_CFG_HT_INFO_FIELD1, &cfgValue) !=
2019 eSIR_SUCCESS) {
2020 lim_log(pMac, LOGP,
2021 FL("Fail to retrieve WNI_CFG_HT_INFO_FIELD1 value"));
2022 return;
2023 }
2024 ptr = (uint8_t *) &macHTInfoField1;
2025 *((uint8_t *) ptr) = (uint8_t) (cfgValue & 0xff);
2026 pMac->lim.gHTServiceIntervalGranularity =
2027 (uint8_t) macHTInfoField1.serviceIntervalGranularity;
2028 pMac->lim.gHTControlledAccessOnly =
2029 (uint8_t) macHTInfoField1.controlledAccessOnly;
2030 pMac->lim.gHTRifsMode = (uint8_t) macHTInfoField1.rifsMode;
2031
2032 if (wlan_cfg_get_int(pMac, WNI_CFG_HT_INFO_FIELD2, &cfgValue) !=
2033 eSIR_SUCCESS) {
2034 lim_log(pMac, LOGP,
2035 FL("Fail to retrieve WNI_CFG_HT_INFO_FIELD2 value"));
2036 return;
2037 }
2038 ptr = (uint8_t *) &macHTInfoField2;
2039 *((uint16_t *) ptr) = (uint16_t) (cfgValue & 0xffff);
2040 pMac->lim.gHTOperMode = (tSirMacHTOperatingMode) macHTInfoField2.opMode;
2041
2042 if (wlan_cfg_get_int(pMac, WNI_CFG_HT_INFO_FIELD3, &cfgValue) !=
2043 eSIR_SUCCESS) {
2044 lim_log(pMac, LOGP,
2045 FL("Fail to retrieve WNI_CFG_HT_INFO_FIELD3 value"));
2046 return;
2047 }
2048 ptr = (uint8_t *) &macHTInfoField3;
2049 *((uint16_t *) ptr) = (uint16_t) (cfgValue & 0xffff);
2050 pMac->lim.gHTPCOActive = (uint8_t) macHTInfoField3.pcoActive;
2051 pMac->lim.gHTPCOPhase = (uint8_t) macHTInfoField3.pcoPhase;
2052 pMac->lim.gHTSecondaryBeacon =
2053 (uint8_t) macHTInfoField3.secondaryBeacon;
2054 pMac->lim.gHTDualCTSProtection =
2055 (uint8_t) macHTInfoField3.dualCTSProtection;
2056 pMac->lim.gHTSTBCBasicMCS = (uint8_t) macHTInfoField3.basicSTBCMCS;
2057
2058 /* The lim globals for channelwidth and secondary chnl have been removed and should not be used during no session;
2059 * instead direct cfg is read and used when no session for transmission of mgmt frames (same as old);
2060 * For now, we might come here during init and join with sessionEntry = NULL; in that case just fill the globals which exist
2061 * Sessionized entries values will be filled in join or add bss req. The ones which are missed in join are filled below
2062 */
2063 if (psessionEntry != NULL) {
2064 psessionEntry->htCapability =
2065 IS_DOT11_MODE_HT(psessionEntry->dot11mode);
2066 psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport =
2067 (uint8_t) macHTInfoField3.lsigTXOPProtectionFullSupport;
2068 }
2069}
2070
2071void lim_log_session_states(tpAniSirGlobal mac_ctx)
2072{
2073#ifdef WLAN_DEBUG
2074 int i;
2075
2076 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
2077 if (mac_ctx->lim.gpSession[i].valid) {
2078 CDF_TRACE(CDF_MODULE_ID_PE, LOG1,
2079 FL("sysRole(%d) Session (%d)"),
2080 mac_ctx->lim.gLimSystemRole, i);
2081 CDF_TRACE(CDF_MODULE_ID_PE, LOG1,
2082 FL("SME: Curr %s,Prev %s,MLM: Curr %s,Prev %s"),
2083 lim_sme_state_str(
2084 mac_ctx->lim.gpSession[i].limSmeState),
2085 lim_sme_state_str(
2086 mac_ctx->lim.gpSession[i].limPrevSmeState),
2087 lim_mlm_state_str(
2088 mac_ctx->lim.gpSession[i].limMlmState),
2089 lim_mlm_state_str(
2090 mac_ctx->lim.gpSession[i].limPrevMlmState));
2091 }
2092 }
2093#endif
2094}