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