blob: bacb031ed16c334cdb8faed782cc47a6fd2b01e6 [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);
355 result->ap[i].rssi = WMA_GET_RX_RSSI_DB(rx_pkt_info);
356 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);
406 result->ap.rssi = WMA_GET_RX_RSSI_DB(rx_pkt_info);
407 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,
807 FL
808 ("ProtVersion %d, Type %d, Subtype %d rateIndex=%d"),
809 fc.protVer, fc.type, fc.subType,
810 WMA_GET_RX_MAC_RATE_IDX(pRxPacketInfo));
811 lim_print_mac_addr(pMac, pHdr->bssId, LOG1);
812#endif
813 if (lim_process_auth_frame_no_session
814 (pMac, pRxPacketInfo,
815 limMsg->bodyptr) == eSIR_SUCCESS) {
816 lim_pkt_free(pMac, TXRX_FRM_802_11_MGMT,
817 pRxPacketInfo, limMsg->bodyptr);
818 return;
819 }
820 }
821#endif
822 if ((fc.subType != SIR_MAC_MGMT_PROBE_RSP) &&
823 (fc.subType != SIR_MAC_MGMT_BEACON) &&
824 (fc.subType != SIR_MAC_MGMT_PROBE_REQ)
825 && (fc.subType != SIR_MAC_MGMT_ACTION) /* Public action frame can be received from non-associated stations. */
826 ) {
827
828 if ((psessionEntry =
829 pe_find_session_by_peer_sta(pMac, pHdr->sa,
830 &sessionId)) == NULL) {
831 lim_log(pMac, LOG1,
832 FL
833 ("session does not exist for given bssId"));
834 lim_pkt_free(pMac, TXRX_FRM_802_11_MGMT,
835 pRxPacketInfo, limMsg->bodyptr);
836 return;
837 } else
838 lim_log(pMac, LOG1,
839 "SessionId:%d Session Exist for given Bssid",
840 psessionEntry->peSessionId);
841 }
842 /* For p2p resp frames search for valid session with DA as */
843 /* BSSID will be SA and session will be present with DA only */
844 if (fc.subType == SIR_MAC_MGMT_ACTION) {
845 psessionEntry =
846 pe_find_session_by_bssid(pMac, pHdr->da, &sessionId);
847 }
848 }
849
850 /* Check if frame is registered by HDD */
851 if (lim_check_mgmt_registered_frames(pMac, pRxPacketInfo, psessionEntry)) {
852 lim_log(pMac, LOG1, FL("Received frame is passed to SME"));
853 lim_pkt_free(pMac, TXRX_FRM_802_11_MGMT, pRxPacketInfo,
854 limMsg->bodyptr);
855 return;
856 }
857
858 if (fc.protVer != SIR_MAC_PROTOCOL_VERSION) { /* Received Frame with non-zero Protocol Version */
859 lim_log(pMac, LOGE,
860 FL("Unexpected frame with protVersion %d received"),
861 fc.protVer);
862 lim_pkt_free(pMac, TXRX_FRM_802_11_MGMT, pRxPacketInfo,
863 (void *)limMsg->bodyptr);
864#ifdef WLAN_DEBUG
865 pMac->lim.numProtErr++;
866#endif
867 return;
868 }
869
870/* Chance of crashing : to be done BT-AMP ........happens when broadcast probe req is received */
871
872#ifdef WLAN_DEBUG
873 pMac->lim.numMAC[fc.type][fc.subType]++;
874#endif
875
876 switch (fc.type) {
877 case SIR_MAC_MGMT_FRAME:
878 {
879 /* Received Management frame */
880 switch (fc.subType) {
881 case SIR_MAC_MGMT_ASSOC_REQ:
882 /* Make sure the role supports Association */
883 if (LIM_IS_BT_AMP_AP_ROLE(psessionEntry) ||
884 LIM_IS_AP_ROLE(psessionEntry))
885 lim_process_assoc_req_frame(pMac,
886 pRxPacketInfo,
887 LIM_ASSOC,
888 psessionEntry);
889 else {
890 /* Unwanted messages - Log error */
891 lim_log(pMac, LOGE,
892 FL
893 ("unexpected message received %X"),
894 limMsg->type);
895 lim_print_msg_name(pMac, LOGE,
896 limMsg->type);
897 }
898 break;
899
900 case SIR_MAC_MGMT_ASSOC_RSP:
901 lim_process_assoc_rsp_frame(pMac, pRxPacketInfo,
902 LIM_ASSOC,
903 psessionEntry);
904 break;
905
906 case SIR_MAC_MGMT_REASSOC_REQ:
907 /* Make sure the role supports Reassociation */
908 if (LIM_IS_BT_AMP_AP_ROLE(psessionEntry) ||
909 LIM_IS_AP_ROLE(psessionEntry)) {
910 lim_process_assoc_req_frame(pMac,
911 pRxPacketInfo,
912 LIM_REASSOC,
913 psessionEntry);
914 } else {
915 /* Unwanted messages - Log error */
916 lim_log(pMac, LOGE,
917 FL
918 ("unexpected message received %X"),
919 limMsg->type);
920 lim_print_msg_name(pMac, LOGE,
921 limMsg->type);
922 }
923 break;
924
925 case SIR_MAC_MGMT_REASSOC_RSP:
926 lim_process_assoc_rsp_frame(pMac, pRxPacketInfo,
927 LIM_REASSOC,
928 psessionEntry);
929 break;
930
931 case SIR_MAC_MGMT_PROBE_REQ:
932 lim_process_probe_req_frame_multiple_bss(pMac,
933 pRxPacketInfo,
934 psessionEntry);
935 break;
936
937 case SIR_MAC_MGMT_PROBE_RSP:
938 if (psessionEntry == NULL)
939 lim_process_probe_rsp_frame_no_session(pMac,
940 pRxPacketInfo);
941 else
942 lim_process_probe_rsp_frame(pMac,
943 pRxPacketInfo,
944 psessionEntry);
945 break;
946
947 case SIR_MAC_MGMT_BEACON:
948 __lim_handle_beacon(pMac, limMsg, psessionEntry);
949 break;
950
951 case SIR_MAC_MGMT_DISASSOC:
952 lim_process_disassoc_frame(pMac, pRxPacketInfo,
953 psessionEntry);
954 break;
955
956 case SIR_MAC_MGMT_AUTH:
957 lim_process_auth_frame(pMac, pRxPacketInfo,
958 psessionEntry);
959 break;
960
961 case SIR_MAC_MGMT_DEAUTH:
962 lim_process_deauth_frame(pMac, pRxPacketInfo,
963 psessionEntry);
964 break;
965
966 case SIR_MAC_MGMT_ACTION:
967 if (psessionEntry == NULL)
968 lim_process_action_frame_no_session(pMac,
969 pRxPacketInfo);
970 else {
971 if (WMA_GET_RX_UNKNOWN_UCAST
972 (pRxPacketInfo))
973 lim_handle_unknown_a2_index_frames
974 (pMac, pRxPacketInfo,
975 psessionEntry);
976 else
977 lim_process_action_frame(pMac,
978 pRxPacketInfo,
979 psessionEntry);
980 }
981 break;
982 default:
983 /* Received Management frame of 'reserved' subtype */
984 break;
985 } /* switch (fc.subType) */
986
987 }
988 break;
989 case SIR_MAC_DATA_FRAME:
990 {
991 }
992 break;
993 default:
994 /* Received frame of type 'reserved' */
995 break;
996
997 } /* switch (fc.type) */
998
999end:
1000 lim_pkt_free(pMac, TXRX_FRM_802_11_MGMT, pRxPacketInfo,
1001 (void *)limMsg->bodyptr);
1002 return;
1003} /*** end lim_handle80211_frames() ***/
1004
1005/**
1006 * lim_send_stop_scan_offload_req()
1007 *
1008 ***FUNCTION:
1009 * This function will be called to abort the ongoing offloaded scan
1010 * request.
1011 *
1012 *
1013 ***NOTE:
1014 *
1015 * @param pMac Pointer to Global MAC structure
1016 * @return CDF_STATUS_SUCCESS or CDF_STATUS_E_FAILURE
1017 */
1018CDF_STATUS lim_send_stop_scan_offload_req(tpAniSirGlobal pMac,
1019 uint8_t SessionId, uint32_t scan_id)
1020{
1021 tSirMsgQ msg;
1022 tSirRetStatus rc = eSIR_SUCCESS;
1023 tAbortScanParams *pAbortScanParams;
1024
1025 pAbortScanParams = cdf_mem_malloc(sizeof(tAbortScanParams));
1026 if (NULL == pAbortScanParams) {
1027 lim_log(pMac, LOGP,
1028 FL("Memory allocation failed for AbortScanParams"));
1029 return CDF_STATUS_E_NOMEM;
1030 }
1031
1032 pAbortScanParams->SessionId = SessionId;
1033 pAbortScanParams->scan_id = scan_id;
1034 msg.type = WMA_STOP_SCAN_OFFLOAD_REQ;
1035 msg.bodyptr = pAbortScanParams;
1036 msg.bodyval = 0;
1037
1038 rc = wma_post_ctrl_msg(pMac, &msg);
1039 if (rc != eSIR_SUCCESS) {
1040 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() return failure"));
1041 cdf_mem_free(pAbortScanParams);
1042 return CDF_STATUS_E_FAILURE;
1043 }
1044
1045 lim_log(pMac, LOG1, FL("Abort ongoing offload scan."));
1046 return CDF_STATUS_SUCCESS;
1047
1048}
1049
1050/**
1051 * lim_process_abort_scan_ind()
1052 *
1053 ***FUNCTION:
1054 * This function is called from HDD to abort the scan which is presently being run
1055 *
1056 *
1057 ***NOTE:
1058 *
1059 * @param pMac Pointer to Global MAC structure
1060 * @param *pMsgBuf A pointer to the SME message buffer
1061 * @return None
1062 */
1063void lim_process_abort_scan_ind(tpAniSirGlobal mac_ctx,
1064 uint8_t session_id, uint32_t scan_id)
1065{
1066#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1067 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_ABORT_IND_EVENT, NULL, 0, 0);
1068#endif
1069
1070 lim_log(mac_ctx, LOG2, FL("Processing AbortScan Ind scan_id %d"),
1071 scan_id);
1072
1073 /* send stop scan cmd to fw if scan offload is enabled. */
1074 lim_send_stop_scan_offload_req(mac_ctx, session_id, scan_id);
1075 return;
1076}
1077
1078/**
1079 * lim_message_processor() - Process messages from LIM.
1080 *
1081 * @mac_ctx: Pointer to the Global Mac Context.
1082 * @msg: Received LIM message.
1083 *
1084 * Wrapper function for lim_process_messages when handling messages received by
1085 * LIM.Could either defer messages or process them.
1086 *
1087 * Return: None.
1088 */
1089void lim_message_processor(tpAniSirGlobal mac_ctx, tpSirMsgQ msg)
1090{
1091 if (eLIM_MLM_OFFLINE_STATE == mac_ctx->lim.gLimMlmState) {
1092 pe_free_msg(mac_ctx, msg);
1093 return;
1094 }
1095
1096 if (!def_msg_decision(mac_ctx, msg)) {
1097 lim_process_messages(mac_ctx, msg);
1098 /* process deferred message queue if allowed */
1099 if ((!(mac_ctx->lim.gLimAddtsSent)) &&
1100 (!(lim_is_system_in_scan_state(mac_ctx))) &&
1101 (true == GET_LIM_PROCESS_DEFD_MESGS(mac_ctx)))
1102 lim_process_deferred_message_queue(mac_ctx);
1103 }
1104}
1105
1106#ifdef FEATURE_OEM_DATA_SUPPORT
1107
1108void lim_oem_data_rsp_handle_resume_link_rsp(tpAniSirGlobal pMac, CDF_STATUS status,
1109 uint32_t *mlmOemDataRsp)
1110{
1111 if (status != CDF_STATUS_SUCCESS) {
1112 lim_log(pMac, LOGE,
1113 FL
1114 ("OEM Data Rsp failed to get the response for resume link"));
1115 }
1116
1117 if (NULL != pMac->lim.gpLimMlmOemDataReq) {
1118 cdf_mem_free(pMac->lim.gpLimMlmOemDataReq);
1119 pMac->lim.gpLimMlmOemDataReq = NULL;
1120 }
1121 /* "Failure" status doesn't mean that Oem Data Rsp did not happen */
1122 /* and hence we need to respond to upper layers. Only Resume link is failed, but */
1123 /* we got the oem data response already. */
1124 /* Post the meessage to MLM */
1125 lim_post_sme_message(pMac, LIM_MLM_OEM_DATA_CNF,
1126 (uint32_t *) (mlmOemDataRsp));
1127
1128 return;
1129}
1130
1131void lim_process_oem_data_rsp(tpAniSirGlobal pMac, uint32_t *body)
1132{
1133 tpLimMlmOemDataRsp mlmOemDataRsp = NULL;
1134
1135 /* Process all the messages for the lim queue */
1136 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
1137
1138 mlmOemDataRsp = (tpLimMlmOemDataRsp) body;
1139
1140 PELOG1(lim_log
1141 (pMac, LOG1, FL("%s: sending oem data response msg to sme"),
1142 __func__);
1143 )
1144 lim_post_sme_message(pMac, LIM_MLM_OEM_DATA_CNF,
1145 (uint32_t *) (mlmOemDataRsp));
1146
1147 return;
1148}
1149
1150#endif
1151
1152/**
1153 * lim_process_messages() - Process messages from upper layers.
1154 *
1155 * @mac_ctx: Pointer to the Global Mac Context.
1156 * @msg: Received message.
1157 *
1158 * Return: None.
1159 */
1160void lim_process_messages(tpAniSirGlobal mac_ctx, tpSirMsgQ msg)
1161{
1162#ifdef FEATURE_AP_MCC_CH_AVOIDANCE
1163 uint8_t vdev_id = 0;
1164 tUpdateBeaconParams beacon_params;
1165#endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
1166 uint8_t i;
1167 uint8_t p2p_go_exists = 0;
1168 tpPESession session_entry = NULL;
1169 uint8_t defer_msg = false;
1170 tLinkStateParams *link_state_param;
1171 uint16_t pkt_len = 0;
1172 cds_pkt_t *body_ptr = NULL;
1173 CDF_STATUS cdf_status;
1174 tSirMsgQ new_msg;
1175 tSirSmeScanAbortReq *req_msg = NULL;
1176 uint8_t session_id;
1177 uint32_t scan_id;
1178
1179#ifdef FEATURE_WLAN_TDLS
1180 tSirTdlsInd *tdls_ind = NULL;
1181 tpDphHashNode sta_ds = NULL;
1182 tTdlsLinkEstablishParams *tdls_link_params = NULL;
1183#endif
1184 tSirMbMsgP2p *p2p_msg = NULL;
1185 if (ANI_DRIVER_TYPE(mac_ctx) == eDRIVER_TYPE_MFG) {
1186 cdf_mem_free(msg->bodyptr);
1187 msg->bodyptr = NULL;
1188 return;
1189 }
1190 if (msg == NULL) {
1191 lim_log(mac_ctx, LOGE, FL("Message pointer is Null"));
1192 CDF_ASSERT(0);
1193 return;
1194 }
1195#ifdef WLAN_DEBUG
1196 mac_ctx->lim.numTot++;
1197#endif
1198 MTRACE(mac_trace_msg_rx(mac_ctx, NO_SESSION,
1199 LIM_TRACE_MAKE_RXMSG(msg->type, LIM_MSG_PROCESSED));)
1200
1201 switch (msg->type) {
1202
1203 case SIR_LIM_UPDATE_BEACON:
1204 lim_update_beacon(mac_ctx);
1205 break;
1206 case SIR_CFG_PARAM_UPDATE_IND:
1207 if (!lim_is_system_in_scan_state(mac_ctx)) {
1208 lim_handle_cf_gparam_update(mac_ctx, msg->bodyval);
1209 break;
1210 }
1211 /* System is in DFS (Learn) mode.
1212 * Defer processsing this message
1213 */
1214 if (lim_defer_msg(mac_ctx, msg) != TX_SUCCESS) {
1215 if (!(mac_ctx->lim.deferredMsgCnt & 0xF))
1216 CDF_TRACE(CDF_MODULE_ID_PE, LOGE,
1217 FL("Unable to Defer Msg"));
1218 lim_log_session_states(mac_ctx);
1219 lim_print_msg_name(mac_ctx, LOGE, msg->type);
1220 }
1221 break;
1222#ifdef FEATURE_OEM_DATA_SUPPORT
1223 case WMA_START_OEM_DATA_RSP:
1224 lim_process_oem_data_rsp(mac_ctx, msg->bodyptr);
1225 msg->bodyptr = NULL;
1226 break;
1227#endif
1228 case WMA_SWITCH_CHANNEL_RSP:
1229 lim_process_switch_channel_rsp(mac_ctx, msg->bodyptr);
1230 msg->bodyptr = NULL;
1231 break;
1232#ifdef ANI_SIR_IBSS_PEER_CACHING
1233 case WMA_IBSS_STA_ADD:
1234 lim_ibss_sta_add(mac_ctx, msg->bodyptr);
1235 break;
1236#endif
1237 case SIR_BB_XPORT_MGMT_MSG:
1238 /* These messages are from Peer MAC entity. */
1239#ifdef WLAN_DEBUG
1240 mac_ctx->lim.numBbt++;
1241#endif
1242 /* The original msg which we were deferring have the
1243 * bodyPointer point to 'BD' instead of 'cds pkt'. If we
1244 * don't make a copy of msg, then overwrite the
1245 * msg->bodyPointer and next time when we try to
1246 * process the msg, we will try to use 'BD' as
1247 * 'cds Pkt' which will cause a crash
1248 */
1249 if (msg->bodyptr == NULL) {
1250 lim_log(mac_ctx, LOGE, FL("Message bodyptr is Null"));
1251 CDF_ASSERT(0);
1252 break;
1253 }
1254 cdf_mem_copy((uint8_t *) &new_msg,
1255 (uint8_t *) msg, sizeof(tSirMsgQ));
1256 body_ptr = (cds_pkt_t *) new_msg.bodyptr;
1257 cds_pkt_get_packet_length(body_ptr, &pkt_len);
1258
1259 cdf_status = wma_ds_peek_rx_packet_info(body_ptr,
1260 (void **) &new_msg.bodyptr, false);
1261
1262 if (!CDF_IS_STATUS_SUCCESS(cdf_status)) {
1263 cds_pkt_return_packet(body_ptr);
1264 break;
1265 }
1266
1267 if (WMA_GET_ROAMCANDIDATEIND(new_msg.bodyptr))
1268 lim_log(mac_ctx, LOG1, FL("roamCandidateInd %d"),
1269 WMA_GET_ROAMCANDIDATEIND(new_msg.bodyptr));
1270
1271 if (WMA_GET_OFFLOADSCANLEARN(new_msg.bodyptr))
1272 lim_log(mac_ctx, LOG1, FL("offloadScanLearn %d"),
1273 WMA_GET_OFFLOADSCANLEARN(new_msg.bodyptr));
1274
1275 lim_handle80211_frames(mac_ctx, &new_msg, &defer_msg);
1276
1277 if (defer_msg == true) {
1278 CDF_TRACE(CDF_MODULE_ID_PE, LOG1,
1279 FL("Defer Msg type=%x"), msg->type);
1280 if (lim_defer_msg(mac_ctx, msg) != TX_SUCCESS) {
1281 CDF_TRACE(CDF_MODULE_ID_PE, LOGE,
1282 FL("Unable to Defer Msg"));
1283 lim_log_session_states(mac_ctx);
1284 cds_pkt_return_packet(body_ptr);
1285 }
1286 } else
1287 /* PE is not deferring this 802.11 frame so we need to
1288 * call cds_pkt_return. Asumption here is when Rx mgmt
1289 * frame processing is done, cds packet could be
1290 * freed here.
1291 */
1292 cds_pkt_return_packet(body_ptr);
1293 break;
1294 case eWNI_SME_SCAN_REQ:
1295 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
1296 case eWNI_SME_DISASSOC_REQ:
1297 case eWNI_SME_DEAUTH_REQ:
1298#ifdef FEATURE_OEM_DATA_SUPPORT
1299 case eWNI_SME_OEM_DATA_REQ:
1300#endif
1301#ifdef FEATURE_WLAN_TDLS
1302 case eWNI_SME_TDLS_SEND_MGMT_REQ:
1303 case eWNI_SME_TDLS_ADD_STA_REQ:
1304 case eWNI_SME_TDLS_DEL_STA_REQ:
1305 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
1306#endif
1307 case eWNI_SME_RESET_AP_CAPS_CHANGED:
1308 case eWNI_SME_SET_HW_MODE_REQ:
1309 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
1310 /* These messages are from HDD. Need to respond to HDD */
1311 lim_process_normal_hdd_msg(mac_ctx, msg, true);
1312 break;
1313
1314 case eWNI_SME_SCAN_ABORT_IND:
1315 req_msg = msg->bodyptr;
1316 if (req_msg) {
1317 session_id = req_msg->sessionId;
1318 scan_id = req_msg->scan_id;
1319 lim_process_abort_scan_ind(mac_ctx, session_id,
1320 scan_id);
1321 cdf_mem_free((void *)msg->bodyptr);
1322 msg->bodyptr = NULL;
1323 }
1324 break;
1325 case eWNI_SME_SYS_READY_IND:
1326 case eWNI_SME_JOIN_REQ:
1327 case eWNI_SME_REASSOC_REQ:
1328 case eWNI_SME_START_BSS_REQ:
1329 case eWNI_SME_STOP_BSS_REQ:
1330 case eWNI_SME_SWITCH_CHL_IND:
1331 case eWNI_SME_SETCONTEXT_REQ:
1332 case eWNI_SME_DISASSOC_CNF:
1333 case eWNI_SME_DEAUTH_CNF:
1334 case eWNI_SME_ASSOC_CNF:
1335 case eWNI_SME_ADDTS_REQ:
1336 case eWNI_SME_DELTS_REQ:
1337 case eWNI_SME_GET_ASSOC_STAS_REQ:
1338 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
1339 case eWNI_SME_UPDATE_APWPSIE_REQ:
1340 case eWNI_SME_HIDE_SSID_REQ:
1341 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
1342 case eWNI_SME_SET_APWPARSNIEs_REQ:
1343 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
1344#if defined WLAN_FEATURE_VOWIFI
1345 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
1346 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
1347#endif
1348#if defined FEATURE_WLAN_ESE
1349 case eWNI_SME_ESE_ADJACENT_AP_REPORT:
1350#endif
1351#ifdef WLAN_FEATURE_VOWIFI_11R
1352 case eWNI_SME_FT_UPDATE_KEY:
1353 case eWNI_SME_FT_PRE_AUTH_REQ:
1354 case eWNI_SME_FT_AGGR_QOS_REQ:
1355#endif
1356 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
1357 case eWNI_SME_UPDATE_NOA:
1358 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
1359 case eWNI_SME_GET_STATISTICS_REQ:
1360#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
1361 case eWNI_SME_GET_TSM_STATS_REQ:
1362#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Abhishek Singh518323d2015-10-19 17:42:01 +05301363 case eWNI_SME_EXT_CHANGE_CHANNEL:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001364 /* These messages are from HDD.No need to respond to HDD */
1365 lim_process_normal_hdd_msg(mac_ctx, msg, false);
1366 break;
1367
1368 case eWNI_PMC_SMPS_STATE_IND:
1369 if (msg->bodyptr) {
1370 cdf_mem_free(msg->bodyptr);
1371 msg->bodyptr = NULL;
1372 }
1373 break;
1374 case eWNI_SME_SEND_ACTION_FRAME_IND:
1375 lim_send_p2p_action_frame(mac_ctx, msg);
1376 cdf_mem_free(msg->bodyptr);
1377 msg->bodyptr = NULL;
1378 break;
1379 case eWNI_SME_ABORT_REMAIN_ON_CHAN_IND:
1380 p2p_msg = (tSirMbMsgP2p *) msg->bodyptr;
1381 lim_abort_remain_on_chan(mac_ctx, p2p_msg->sessionId,
1382 p2p_msg->scan_id);
1383 cdf_mem_free(msg->bodyptr);
1384 msg->bodyptr = NULL;
1385 break;
1386 case SIR_HAL_P2P_NOA_START_IND:
1387 session_entry = &mac_ctx->lim.gpSession[0];
1388 lim_log(mac_ctx, LOG1, "LIM received NOA start %x", msg->type);
1389
1390 /* Since insert NOA is done and NOA start msg received,
1391 * we should deactivate the Insert NOA timer
1392 */
1393 lim_deactivate_and_change_timer(mac_ctx,
1394 eLIM_INSERT_SINGLESHOT_NOA_TIMER);
1395
1396 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
1397 session_entry = &mac_ctx->lim.gpSession[i];
1398 if ((session_entry != NULL) && (session_entry->valid) &&
1399 (session_entry->pePersona == CDF_P2P_GO_MODE)) {
1400 /* Save P2P NOA start attribute for Go persona*/
1401 p2p_go_exists = 1;
1402 cdf_mem_copy(&session_entry->p2pGoPsNoaStartInd,
1403 msg->bodyptr, sizeof(tSirP2PNoaStart));
1404 cdf_status =
1405 session_entry->p2pGoPsNoaStartInd.status;
1406 if (cdf_status != CDF_STATUS_SUCCESS)
1407 CDF_TRACE(CDF_MODULE_ID_PE, LOGW,
1408 FL(
1409 "GO NOA start status %d by FW"),
1410 cdf_status);
1411 break;
1412 }
1413 }
1414
1415 if (p2p_go_exists == 0)
1416 CDF_TRACE(CDF_MODULE_ID_PE, LOGW,
1417 FL(
1418 "GO is removed by the time NOA start recvd"));
1419
1420 /* We received the NOA start indication. Now we can send down
1421 * the SME request which requires off-channel operation */
1422 lim_process_regd_defd_sme_req_after_noa_start(mac_ctx);
1423 cdf_mem_free(msg->bodyptr);
1424 msg->bodyptr = NULL;
1425 break;
1426#ifdef FEATURE_WLAN_TDLS
1427 case SIR_HAL_TDLS_IND:
1428 tdls_ind = (tpSirTdlsInd) msg->bodyptr;
1429 session_entry = pe_find_session_by_sta_id(mac_ctx,
1430 tdls_ind->staIdx, &session_id);
1431 if (session_entry == NULL) {
1432 lim_log(mac_ctx, LOG1,
1433 FL("No session exist for given bssId"));
1434 cdf_mem_free(msg->bodyptr);
1435 msg->bodyptr = NULL;
1436 return;
1437 }
1438 sta_ds = dph_get_hash_entry(mac_ctx, tdls_ind->assocId,
1439 &session_entry->dph.dphHashTable);
1440 if (sta_ds == NULL) {
1441 lim_log(mac_ctx, LOG1,
1442 FL("No sta_ds exist for given staId"));
1443 cdf_mem_free(msg->bodyptr);
1444 msg->bodyptr = NULL;
1445 return;
1446 }
1447
1448 if (STA_ENTRY_TDLS_PEER == sta_ds->staType) {
1449 lim_log(mac_ctx, LOGE,
1450 FL("rcvd TDLS IND from FW with RC %d "),
1451 tdls_ind->reasonCode);
1452 lim_send_sme_tdls_del_sta_ind(mac_ctx, sta_ds,
1453 session_entry, tdls_ind->reasonCode);
1454 }
1455 cdf_mem_free(msg->bodyptr);
1456 msg->bodyptr = NULL;
1457 break;
1458#endif
1459 case SIR_HAL_P2P_NOA_ATTR_IND:
1460 session_entry = &mac_ctx->lim.gpSession[0];
1461 lim_log(mac_ctx, LOG1, FL("Received message Noa_ATTR %x"),
1462 msg->type);
1463 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
1464 session_entry = &mac_ctx->lim.gpSession[i];
1465 if ((session_entry != NULL) && (session_entry->valid)
1466 && (session_entry->pePersona ==
1467 CDF_P2P_GO_MODE)) { /* Save P2P attr for Go */
1468 cdf_mem_copy(
1469 &session_entry->p2pGoPsUpdate,
1470 msg->bodyptr,
1471 sizeof(tSirP2PNoaAttr));
1472 lim_log(mac_ctx, LOG2,
1473 FL("bssId"
1474 MAC_ADDRESS_STR
1475 " ctWin=%d oppPsFlag=%d"),
1476 MAC_ADDR_ARRAY(
1477 session_entry->bssId),
1478 session_entry->p2pGoPsUpdate.ctWin,
1479 session_entry->p2pGoPsUpdate.oppPsFlag);
1480 lim_log(mac_ctx, LOG2,
1481 FL
1482 (" uNoa1IntervalCnt=%d uNoa1Duration=%d uNoa1Interval=%d uNoa1StartTime=%d"),
1483 session_entry->p2pGoPsUpdate.uNoa1IntervalCnt,
1484 session_entry->p2pGoPsUpdate.uNoa1Duration,
1485 session_entry->p2pGoPsUpdate.uNoa1Interval,
1486 session_entry->p2pGoPsUpdate.uNoa1StartTime);
1487 break;
1488 }
1489 }
1490 cdf_mem_free(msg->bodyptr);
1491 msg->bodyptr = NULL;
1492 break;
1493 case WMA_MISSED_BEACON_IND:
1494 lim_ps_offload_handle_missed_beacon_ind(mac_ctx, msg);
1495 cdf_mem_free(msg->bodyptr);
1496 msg->bodyptr = NULL;
1497 break;
1498#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1499 case WMA_ROAM_OFFLOAD_SYNCH_IND:
1500 lim_roam_offload_synch_ind(mac_ctx, msg);
1501 /* bodyPtr is freed after handling
1502 * eWNI_SME_ROAM_OFFLOAD_SYNCH_IND in sme_ProcessMsg */
1503 break;
1504#endif
1505 case SIR_LIM_ADDTS_RSP_TIMEOUT:
1506 lim_process_sme_req_messages(mac_ctx, msg);
1507 break;
1508#ifdef FEATURE_WLAN_ESE
1509 case SIR_LIM_ESE_TSM_TIMEOUT:
1510#ifndef FEATURE_WLAN_ESE_UPLOAD
1511 limProcessTsmTimeoutHandler(mac_ctx, msg);
1512#endif /* FEATURE_WLAN_ESE_UPLOAD */
1513 break;
1514 case WMA_TSM_STATS_RSP:
1515#ifdef FEATURE_WLAN_ESE_UPLOAD
1516 lim_send_sme_pe_ese_tsm_rsp(mac_ctx,
1517 (tAniGetTsmStatsRsp *) msg->bodyptr);
1518#else
1519 limProcessHalEseTsmRsp(mac_ctx, msg);
1520#endif /* FEATURE_WLAN_ESE_UPLOAD */
1521 break;
1522#endif
1523 case WMA_ADD_TS_RSP:
1524 lim_process_hal_add_ts_rsp(mac_ctx, msg);
1525 break;
1526 case SIR_LIM_DEL_TS_IND:
1527 lim_process_del_ts_ind(mac_ctx, msg);
1528 break;
1529 case SIR_LIM_BEACON_GEN_IND:
1530 if (mac_ctx->lim.gLimSystemRole != eLIM_AP_ROLE)
1531 sch_process_pre_beacon_ind(mac_ctx, msg);
1532 break;
1533 case SIR_LIM_DELETE_STA_CONTEXT_IND:
1534 lim_delete_sta_context(mac_ctx, msg);
1535 break;
1536 case SIR_LIM_PERIODIC_PROBE_REQ_TIMEOUT:
1537 case SIR_LIM_JOIN_FAIL_TIMEOUT:
1538 case SIR_LIM_PERIODIC_JOIN_PROBE_REQ_TIMEOUT:
1539 case SIR_LIM_AUTH_FAIL_TIMEOUT:
1540 case SIR_LIM_AUTH_RSP_TIMEOUT:
1541 case SIR_LIM_ASSOC_FAIL_TIMEOUT:
1542 case SIR_LIM_REASSOC_FAIL_TIMEOUT:
1543#ifdef WLAN_FEATURE_VOWIFI_11R
1544 case SIR_LIM_FT_PREAUTH_RSP_TIMEOUT:
1545#endif
1546 case SIR_LIM_REMAIN_CHN_TIMEOUT:
1547 case SIR_LIM_INSERT_SINGLESHOT_NOA_TIMEOUT:
1548 case SIR_LIM_DISASSOC_ACK_TIMEOUT:
1549 case SIR_LIM_DEAUTH_ACK_TIMEOUT:
1550 case SIR_LIM_CONVERT_ACTIVE_CHANNEL_TO_PASSIVE:
1551 /* These timeout messages are handled by MLM sub module */
1552 lim_process_mlm_req_messages(mac_ctx, msg);
1553 break;
1554 case SIR_LIM_HEART_BEAT_TIMEOUT:
1555 /** check if heart beat failed, even if one Beacon
1556 * is rcvd within the Heart Beat interval continue
1557 * normal processing
1558 */
1559 if (NULL == msg->bodyptr)
1560 lim_log(mac_ctx, LOGE,
1561 FL("Can't Process HB TO - bodyptr is Null"));
1562 else {
1563 session_entry = (tpPESession) msg->bodyptr;
1564 lim_log(mac_ctx, LOGE,
1565 FL
1566 ("SIR_LIM_HEART_BEAT_TIMEOUT, Session %d"),
1567 ((tpPESession) msg->bodyptr)->peSessionId);
1568 limResetHBPktCount(session_entry);
1569 lim_handle_heart_beat_timeout_for_session(mac_ctx,
1570 session_entry);
1571 }
1572 break;
1573 case SIR_LIM_PROBE_HB_FAILURE_TIMEOUT:
1574 lim_handle_heart_beat_failure_timeout(mac_ctx);
1575 break;
1576 case SIR_LIM_HASH_MISS_THRES_TIMEOUT:
1577 mac_ctx->lim.gLimDisassocFrameCredit = 0;
1578 break;
1579 case SIR_LIM_CNF_WAIT_TIMEOUT:
1580 /* Does not receive CNF or dummy packet */
1581 lim_handle_cnf_wait_timeout(mac_ctx, (uint16_t) msg->bodyval);
1582 break;
1583 case SIR_LIM_RETRY_INTERRUPT_MSG:
1584 /* Message from ISR upon TFP's max retry limit interrupt */
1585 break;
1586 case SIR_LIM_INV_KEY_INTERRUPT_MSG:
1587 /* Message from ISR upon SP's Invalid session key interrupt */
1588 break;
1589 case SIR_LIM_KEY_ID_INTERRUPT_MSG:
1590 /* Message from ISR upon SP's Invalid key ID interrupt */
1591 break;
1592 case SIR_LIM_REPLAY_THRES_INTERRUPT_MSG:
1593 /* Message from ISR upon SP's Replay threshold interrupt */
1594 break;
1595 case SIR_LIM_CHANNEL_SWITCH_TIMEOUT:
1596 lim_process_channel_switch_timeout(mac_ctx);
1597 break;
1598 case SIR_LIM_QUIET_TIMEOUT:
1599 lim_process_quiet_timeout(mac_ctx);
1600 break;
1601 case SIR_LIM_QUIET_BSS_TIMEOUT:
1602 lim_process_quiet_bss_timeout(mac_ctx);
1603 break;
1604 case SIR_LIM_UPDATE_OLBC_CACHEL_TIMEOUT:
1605 lim_handle_update_olbc_cache(mac_ctx);
1606 break;
1607#ifdef FEATURE_WLAN_TDLS
1608 case SIR_HAL_TDLS_SHOULD_DISCOVER:
1609 case SIR_HAL_TDLS_SHOULD_TEARDOWN:
1610 case SIR_HAL_TDLS_PEER_DISCONNECTED:
1611 CDF_TRACE(CDF_MODULE_ID_PE, CDF_TRACE_LEVEL_INFO,
1612 ("%s received tdls event: 0x%x"), __func__, msg->type);
1613 lim_send_sme_tdls_event_notify(mac_ctx, msg->type,
1614 (void *)msg->bodyptr);
1615 break;
1616#endif
1617 case WMA_ADD_BSS_RSP:
1618 lim_process_mlm_add_bss_rsp(mac_ctx, msg);
1619 break;
1620 case WMA_ADD_STA_RSP:
1621 lim_process_add_sta_rsp(mac_ctx, msg);
1622 break;
1623 case WMA_DELETE_STA_RSP:
1624 lim_process_mlm_del_sta_rsp(mac_ctx, msg);
1625 break;
1626 case WMA_DELETE_BSS_RSP:
1627 lim_handle_delete_bss_rsp(mac_ctx, msg);
1628 break;
1629 case WMA_CSA_OFFLOAD_EVENT:
1630 lim_handle_csa_offload_msg(mac_ctx, msg);
1631 break;
1632 case WMA_SET_BSSKEY_RSP:
1633 case WMA_SET_STA_BCASTKEY_RSP:
1634 lim_process_mlm_set_bss_key_rsp(mac_ctx, msg);
1635 break;
1636 case WMA_SET_STAKEY_RSP:
1637 lim_process_mlm_set_sta_key_rsp(mac_ctx, msg);
1638 break;
1639 case WMA_GET_STATISTICS_RSP:
1640 lim_send_sme_pe_statistics_rsp(mac_ctx, msg->type,
1641 (void *)msg->bodyptr);
1642 break;
1643 case WMA_SET_MIMOPS_RSP:
1644 case WMA_SET_TX_POWER_RSP:
1645 cdf_mem_free((void *)msg->bodyptr);
1646 msg->bodyptr = NULL;
1647 break;
1648 case WMA_SET_MAX_TX_POWER_RSP:
1649#if defined WLAN_FEATURE_VOWIFI
1650 rrm_set_max_tx_power_rsp(mac_ctx, msg);
1651#endif
1652 if (msg->bodyptr != NULL) {
1653 cdf_mem_free((void *)msg->bodyptr);
1654 msg->bodyptr = NULL;
1655 }
1656 break;
1657 case SIR_LIM_ADDR2_MISS_IND:
1658 lim_log(mac_ctx, LOGE,
1659 FL("Addr2 mismatch interrupt received %X"), msg->type);
1660 /* message from HAL indicating addr2 mismatch interrupt occurred
1661 * msg->bodyptr contains only pointer to 48-bit addr2 field
1662 */
1663 cdf_mem_free((void *)(msg->bodyptr));
1664 msg->bodyptr = NULL;
1665 break;
1666#ifdef WLAN_FEATURE_VOWIFI_11R
1667 case WMA_AGGR_QOS_RSP:
1668 lim_process_ft_aggr_qo_s_rsp(mac_ctx, msg);
1669 break;
1670#endif
1671 case WMA_SET_LINK_STATE_RSP:
1672 link_state_param = (tLinkStateParams *) msg->bodyptr;
1673#if defined WLAN_FEATURE_VOWIFI_11R
1674 session_entry = link_state_param->session;
1675 if (link_state_param->ft
1676#if defined WLAN_FEATURE_ROAM_OFFLOAD
1677 && !session_entry->bRoamSynchInProgress
1678#endif
1679 )
1680 lim_send_reassoc_req_with_ft_ies_mgmt_frame(mac_ctx,
1681 session_entry->pLimMlmReassocReq,
1682 session_entry);
1683#endif
1684 if (link_state_param->callback)
1685 link_state_param->callback(mac_ctx,
1686 link_state_param->callbackArg,
1687 link_state_param->status);
1688 cdf_mem_free((void *)(msg->bodyptr));
1689 msg->bodyptr = NULL;
1690 break;
1691 case eWNI_SME_SET_BCN_FILTER_REQ:
1692 session_id = (uint8_t) msg->bodyval;
1693 session_entry = &mac_ctx->lim.gpSession[session_id];
1694 if ((session_entry != NULL) &&
1695 (lim_send_beacon_filter_info(mac_ctx, session_entry) !=
1696 eSIR_SUCCESS))
1697 lim_log(mac_ctx, LOGE,
1698 FL("Failied to send Beacon Filter Info "));
1699 cdf_mem_free((void *)(msg->bodyptr));
1700 msg->bodyptr = NULL;
1701 break;
1702#ifdef FEATURE_WLAN_TDLS
1703 case WMA_SET_TDLS_LINK_ESTABLISH_REQ_RSP:
1704 tdls_link_params = (tTdlsLinkEstablishParams *) msg->bodyptr;
1705 session_entry = pe_find_session_by_sta_id(mac_ctx,
1706 tdls_link_params->staIdx, &session_id);
1707 if (session_entry == NULL) {
1708 lim_log(mac_ctx, LOGE,
1709 FL("session %u does not exist"), session_id);
1710 /* Still send the eWNI_SME_TDLS_LINK_ESTABLISH_RSP
1711 * message to SME with session id as zero and status
1712 * as FAILURE so, that message queued in SME queue
1713 * can be freed to prevent the SME cmd buffer leak
1714 */
1715 lim_send_sme_tdls_link_establish_req_rsp(mac_ctx, 0,
1716 NULL, NULL, eSIR_FAILURE);
1717 } else {
1718 lim_send_sme_tdls_link_establish_req_rsp(mac_ctx,
1719 session_entry->smeSessionId, NULL, NULL,
1720 tdls_link_params->status);
1721 }
1722 cdf_mem_free((void *)(msg->bodyptr));
1723 msg->bodyptr = NULL;
1724 break;
1725#endif
1726 case WMA_RX_SCAN_EVENT:
1727 lim_process_rx_scan_event(mac_ctx, msg->bodyptr);
1728 break;
1729 case WMA_IBSS_PEER_INACTIVITY_IND:
1730 lim_process_ibss_peer_inactivity(mac_ctx, msg->bodyptr);
1731 cdf_mem_free((void *)(msg->bodyptr));
1732 msg->bodyptr = NULL;
1733 break;
1734 case WMA_DFS_RADAR_IND:
1735 lim_send_sme_dfs_event_notify(mac_ctx, msg->type,
1736 (void *)msg->bodyptr);
1737 /* msg->bodyptr will be freed up by SME/CSR */
1738 break;
1739 case WMA_DFS_BEACON_TX_SUCCESS_IND:
1740 lim_process_beacon_tx_success_ind(mac_ctx, msg->type,
1741 (void *)msg->bodyptr);
1742 cdf_mem_free((void *)msg->bodyptr);
1743 msg->bodyptr = NULL;
1744 break;
1745 case WMA_DISASSOC_TX_COMP:
1746 lim_disassoc_tx_complete_cnf(mac_ctx, msg->bodyval);
1747 break;
1748 case WMA_DEAUTH_TX_COMP:
1749 lim_deauth_tx_complete_cnf(mac_ctx, msg->bodyval);
1750 break;
1751#ifdef FEATURE_AP_MCC_CH_AVOIDANCE
1752 case WMA_UPDATE_Q2Q_IE_IND:
1753 cdf_mem_zero(&beacon_params, sizeof(tUpdateBeaconParams));
1754 beacon_params.paramChangeBitmap = 0;
1755 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
1756 vdev_id = ((uint8_t *)msg->bodyptr)[i];
1757 session_entry = pe_find_session_by_sme_session_id(
1758 mac_ctx, vdev_id);
1759 if (session_entry == NULL)
1760 continue;
1761 session_entry->sap_advertise_avoid_ch_ie =
1762 (uint8_t)msg->bodyval;
1763 /*
1764 * if message comes for DFS channel, no need to update:
1765 * 1) We wont have MCC with DFS channels. so no need to
1766 * add Q2Q IE
1767 * 2) We cannot end up in DFS channel SCC by channel
1768 * switch from non DFS MCC scenario, so no need to
1769 * remove Q2Q IE
1770 * 3) There is however a case where device start MCC and
1771 * then user modifies hostapd.conf and does SAP
1772 * restart, in such a case, beacon params will be
1773 * reset and thus will not contain Q2Q IE, by default
1774 */
1775 if (cds_get_channel_state(
1776 session_entry->currentOperChannel)
1777 != CHANNEL_STATE_DFS) {
1778 beacon_params.bssIdx = session_entry->bssIdx;
1779 beacon_params.beaconInterval =
1780 session_entry->beaconParams.beaconInterval;
1781 beacon_params.paramChangeBitmap |=
1782 PARAM_BCN_INTERVAL_CHANGED;
1783 sch_set_fixed_beacon_fields(mac_ctx,
1784 session_entry);
1785 lim_send_beacon_params(mac_ctx, &beacon_params,
1786 session_entry);
1787 }
1788 }
1789 cdf_mem_free(msg->bodyptr);
1790 msg->bodyptr = NULL;
1791 break;
1792#endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
1793 case eWNI_SME_NSS_UPDATE_REQ:
1794 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
1795 lim_process_sme_req_messages(mac_ctx, msg);
1796 cdf_mem_free((void *)msg->bodyptr);
1797 msg->bodyptr = NULL;
1798 break;
1799 case eWNI_SME_CHANNEL_CHANGE_REQ:
1800 lim_process_sme_req_messages(mac_ctx, msg);
1801 cdf_mem_free((void *)msg->bodyptr);
1802 msg->bodyptr = NULL;
1803 break;
1804 case eWNI_SME_START_BEACON_REQ:
1805 lim_process_sme_req_messages(mac_ctx, msg);
1806 cdf_mem_free((void *)msg->bodyptr);
1807 msg->bodyptr = NULL;
1808 break;
1809 case eWNI_SME_UPDATE_ADDITIONAL_IES:
1810 lim_process_sme_req_messages(mac_ctx, msg);
1811 cdf_mem_free((void *)msg->bodyptr);
1812 msg->bodyptr = NULL;
1813 break;
1814 case eWNI_SME_MODIFY_ADDITIONAL_IES:
1815 lim_process_sme_req_messages(mac_ctx, msg);
1816 cdf_mem_free((void *)msg->bodyptr);
1817 msg->bodyptr = NULL;
1818 break;
1819#ifdef QCA_HT_2040_COEX
1820 case eWNI_SME_SET_HT_2040_MODE:
1821 lim_process_sme_req_messages(mac_ctx, msg);
1822 cdf_mem_free((void *)msg->bodyptr);
1823 msg->bodyptr = NULL;
1824 break;
1825#endif
1826 case SIR_HAL_SOC_SET_HW_MODE_RESP:
1827 lim_process_set_hw_mode_resp(mac_ctx, msg->bodyptr);
1828 cdf_mem_free((void *)msg->bodyptr);
1829 msg->bodyptr = NULL;
1830 break;
1831 case SIR_HAL_SOC_HW_MODE_TRANS_IND:
1832 lim_process_hw_mode_trans_ind(mac_ctx, msg->bodyptr);
1833 cdf_mem_free((void *)msg->bodyptr);
1834 msg->bodyptr = NULL;
1835 break;
1836 case SIR_HAL_SOC_DUAL_MAC_CFG_RESP:
1837 lim_process_dual_mac_cfg_resp(mac_ctx, msg->bodyptr);
1838 cdf_mem_free((void *)msg->bodyptr);
1839 msg->bodyptr = NULL;
1840 break;
1841 case eWNI_SME_SET_IE_REQ:
1842 lim_process_sme_req_messages(mac_ctx, msg);
1843 cdf_mem_free((void *)msg->bodyptr);
1844 msg->bodyptr = NULL;
1845 break;
1846 default:
1847 cdf_mem_free((void *)msg->bodyptr);
1848 msg->bodyptr = NULL;
1849 /* Unwanted messages */
1850 /* Log error */
1851 lim_log(mac_ctx, LOGE,
1852 FL("Discarding unexpected message received %X"),
1853 msg->type);
1854 lim_print_msg_name(mac_ctx, LOGE, msg->type);
1855 break;
1856
1857 } /* switch (msg->type) */
1858} /*** end lim_process_messages() ***/
1859
1860/**
1861 * lim_process_deferred_message_queue
1862 *
1863 ***FUNCTION:
1864 * This function is called by LIM while exiting from Learn
1865 * mode. This function fetches messages posted to the LIM
1866 * deferred message queue limDeferredMsgQ.
1867 *
1868 ***LOGIC:
1869 *
1870 ***ASSUMPTIONS:
1871 * NA
1872 *
1873 ***NOTE:
1874 * NA
1875 *
1876 * @param pMac - Pointer to Global MAC structure
1877 * @return None
1878 */
1879
1880void lim_process_deferred_message_queue(tpAniSirGlobal pMac)
1881{
1882 tSirMsgQ limMsg = { 0, 0, 0 };
1883
1884 tSirMsgQ *readMsg;
1885 uint16_t size;
1886
1887 /*
1888 ** check any deferred messages need to be processed
1889 **/
1890 size = pMac->lim.gLimDeferredMsgQ.size;
1891 if (size > 0) {
1892 while ((readMsg = lim_read_deferred_msg_q(pMac)) != NULL) {
1893 cdf_mem_copy((uint8_t *) &limMsg,
1894 (uint8_t *) readMsg, sizeof(tSirMsgQ));
1895 size--;
1896 lim_process_messages(pMac, &limMsg);
1897
1898 if ((lim_is_system_in_scan_state(pMac))
1899 || (true != GET_LIM_PROCESS_DEFD_MESGS(pMac))
Hema Aparna Medicharla5e1f3022015-08-24 11:22:29 +05301900 || (pMac->lim.gLimSystemInScanLearnMode)
1901 || pMac->lim.gLimAddtsSent)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001902 break;
1903 }
1904 }
1905} /*** end lim_process_deferred_message_queue() ***/
1906
1907/**
1908 * lim_process_normal_hdd_msg() - Process the message and defer if needed
1909 * @mac_ctx : Pointer to Global MAC structure
1910 * @msg : The message need to be processed
1911 * @rsp_reqd: whether return result to hdd
1912 *
1913 * This function checks the current lim state and decide whether the message
1914 * passed will be deferred or not.
1915 *
1916 * Return: None
1917 */
1918static void lim_process_normal_hdd_msg(tpAniSirGlobal mac_ctx, tSirMsgQ *msg,
1919 uint8_t rsp_reqd)
1920{
1921 bool defer_msg = true;
1922
1923 /* Added For BT-AMP Support */
1924 if ((mac_ctx->lim.gLimSystemRole == eLIM_AP_ROLE)
1925 || (mac_ctx->lim.gLimSystemRole == eLIM_BT_AMP_AP_ROLE)
1926 || (mac_ctx->lim.gLimSystemRole == eLIM_BT_AMP_STA_ROLE)
1927 || (mac_ctx->lim.gLimSystemRole == eLIM_UNKNOWN_ROLE)) {
1928 /*
1929 * This check is required only for the AP and in 2 cases.
1930 * 1. If we are in learn mode and we receive any of these
1931 * messages, you have to come out of scan and process the
1932 * message, hence dont defer the message here. In handler,
1933 * these message could be defered till we actually come out of
1934 * scan mode.
1935 * 2. If radar is detected, you might have to defer all of
1936 * these messages except Stop BSS request/ Switch channel
1937 * request. This decision is also made inside its handler.
1938 *
1939 * Please be careful while using the flag defer_msg. Possibly
1940 * you might end up in an infinite loop.
1941 */
1942 if ((msg->type == eWNI_SME_START_BSS_REQ) ||
1943 (msg->type == eWNI_SME_STOP_BSS_REQ) ||
1944 (msg->type == eWNI_SME_SWITCH_CHL_IND))
1945 defer_msg = false;
1946 }
1947
1948 if (((mac_ctx->lim.gLimAddtsSent) ||
1949 (lim_is_system_in_scan_state(mac_ctx))) && defer_msg) {
1950 /*
1951 * System is in DFS (Learn) mode or awaiting addts response or
1952 * if radar is detected, Defer processsing this message
1953 */
1954 if (lim_defer_msg(mac_ctx, msg) != TX_SUCCESS) {
1955#ifdef WLAN_DEBUG
1956 mac_ctx->lim.numSme++;
1957#endif
1958 lim_log_session_states(mac_ctx);
1959 /* Release body */
1960 cdf_mem_free(msg->bodyptr);
1961 msg->bodyptr = NULL;
1962 }
1963 } else {
1964 /*
1965 * These messages are from HDD.Since these requests may also be
1966 * generated internally within LIM module, need to distinquish
1967 * and send response to host
1968 */
1969 if (rsp_reqd)
1970 mac_ctx->lim.gLimRspReqd = true;
1971#ifdef WLAN_DEBUG
1972 mac_ctx->lim.numSme++;
1973#endif
1974 if (lim_process_sme_req_messages(mac_ctx, msg)) {
1975 /*
1976 * Release body. limProcessSmeReqMessage consumed the
1977 * buffer. We can free it.
1978 */
1979 cdf_mem_free(msg->bodyptr);
1980 msg->bodyptr = NULL;
1981 }
1982 }
1983}
1984
1985void
1986handle_ht_capabilityand_ht_info(struct sAniSirGlobal *pMac,
1987 tpPESession psessionEntry)
1988{
1989 tSirMacHTCapabilityInfo macHTCapabilityInfo;
1990 tSirMacHTParametersInfo macHTParametersInfo;
1991 tSirMacHTInfoField1 macHTInfoField1;
1992 tSirMacHTInfoField2 macHTInfoField2;
1993 tSirMacHTInfoField3 macHTInfoField3;
1994 uint32_t cfgValue;
1995 uint8_t *ptr;
1996
1997 if (wlan_cfg_get_int(pMac, WNI_CFG_HT_CAP_INFO, &cfgValue) !=
1998 eSIR_SUCCESS) {
1999 lim_log(pMac, LOGP,
2000 FL("Fail to retrieve WNI_CFG_HT_CAP_INFO value"));
2001 return;
2002 }
2003 ptr = (uint8_t *) &macHTCapabilityInfo;
2004 *((uint16_t *) ptr) = (uint16_t) (cfgValue & 0xffff);
2005 pMac->lim.gHTLsigTXOPProtection =
2006 (uint8_t) macHTCapabilityInfo.lsigTXOPProtection;
2007 pMac->lim.gHTMIMOPSState =
2008 (tSirMacHTMIMOPowerSaveState) macHTCapabilityInfo.mimoPowerSave;
2009 pMac->lim.gHTGreenfield = (uint8_t) macHTCapabilityInfo.greenField;
2010 pMac->lim.gHTMaxAmsduLength =
2011 (uint8_t) macHTCapabilityInfo.maximalAMSDUsize;
2012 pMac->lim.gHTShortGI20Mhz = (uint8_t) macHTCapabilityInfo.shortGI20MHz;
2013 pMac->lim.gHTShortGI40Mhz = (uint8_t) macHTCapabilityInfo.shortGI40MHz;
2014 pMac->lim.gHTPSMPSupport = (uint8_t) macHTCapabilityInfo.psmp;
2015 pMac->lim.gHTDsssCckRate40MHzSupport =
2016 (uint8_t) macHTCapabilityInfo.dsssCckMode40MHz;
2017
2018 if (wlan_cfg_get_int(pMac, WNI_CFG_HT_AMPDU_PARAMS, &cfgValue) !=
2019 eSIR_SUCCESS) {
2020 lim_log(pMac, LOGP,
2021 FL("Fail to retrieve WNI_CFG_HT_PARAM_INFO value"));
2022 return;
2023 }
2024 ptr = (uint8_t *) &macHTParametersInfo;
2025 *ptr = (uint8_t) (cfgValue & 0xff);
2026 pMac->lim.gHTAMpduDensity = (uint8_t) macHTParametersInfo.mpduDensity;
2027 pMac->lim.gHTMaxRxAMpduFactor =
2028 (uint8_t) macHTParametersInfo.maxRxAMPDUFactor;
2029
2030 /* Get HT IE Info */
2031 if (wlan_cfg_get_int(pMac, WNI_CFG_HT_INFO_FIELD1, &cfgValue) !=
2032 eSIR_SUCCESS) {
2033 lim_log(pMac, LOGP,
2034 FL("Fail to retrieve WNI_CFG_HT_INFO_FIELD1 value"));
2035 return;
2036 }
2037 ptr = (uint8_t *) &macHTInfoField1;
2038 *((uint8_t *) ptr) = (uint8_t) (cfgValue & 0xff);
2039 pMac->lim.gHTServiceIntervalGranularity =
2040 (uint8_t) macHTInfoField1.serviceIntervalGranularity;
2041 pMac->lim.gHTControlledAccessOnly =
2042 (uint8_t) macHTInfoField1.controlledAccessOnly;
2043 pMac->lim.gHTRifsMode = (uint8_t) macHTInfoField1.rifsMode;
2044
2045 if (wlan_cfg_get_int(pMac, WNI_CFG_HT_INFO_FIELD2, &cfgValue) !=
2046 eSIR_SUCCESS) {
2047 lim_log(pMac, LOGP,
2048 FL("Fail to retrieve WNI_CFG_HT_INFO_FIELD2 value"));
2049 return;
2050 }
2051 ptr = (uint8_t *) &macHTInfoField2;
2052 *((uint16_t *) ptr) = (uint16_t) (cfgValue & 0xffff);
2053 pMac->lim.gHTOperMode = (tSirMacHTOperatingMode) macHTInfoField2.opMode;
2054
2055 if (wlan_cfg_get_int(pMac, WNI_CFG_HT_INFO_FIELD3, &cfgValue) !=
2056 eSIR_SUCCESS) {
2057 lim_log(pMac, LOGP,
2058 FL("Fail to retrieve WNI_CFG_HT_INFO_FIELD3 value"));
2059 return;
2060 }
2061 ptr = (uint8_t *) &macHTInfoField3;
2062 *((uint16_t *) ptr) = (uint16_t) (cfgValue & 0xffff);
2063 pMac->lim.gHTPCOActive = (uint8_t) macHTInfoField3.pcoActive;
2064 pMac->lim.gHTPCOPhase = (uint8_t) macHTInfoField3.pcoPhase;
2065 pMac->lim.gHTSecondaryBeacon =
2066 (uint8_t) macHTInfoField3.secondaryBeacon;
2067 pMac->lim.gHTDualCTSProtection =
2068 (uint8_t) macHTInfoField3.dualCTSProtection;
2069 pMac->lim.gHTSTBCBasicMCS = (uint8_t) macHTInfoField3.basicSTBCMCS;
2070
2071 /* The lim globals for channelwidth and secondary chnl have been removed and should not be used during no session;
2072 * instead direct cfg is read and used when no session for transmission of mgmt frames (same as old);
2073 * For now, we might come here during init and join with sessionEntry = NULL; in that case just fill the globals which exist
2074 * Sessionized entries values will be filled in join or add bss req. The ones which are missed in join are filled below
2075 */
2076 if (psessionEntry != NULL) {
2077 psessionEntry->htCapability =
2078 IS_DOT11_MODE_HT(psessionEntry->dot11mode);
2079 psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport =
2080 (uint8_t) macHTInfoField3.lsigTXOPProtectionFullSupport;
2081 }
2082}
2083
2084void lim_log_session_states(tpAniSirGlobal mac_ctx)
2085{
2086#ifdef WLAN_DEBUG
2087 int i;
2088
2089 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
2090 if (mac_ctx->lim.gpSession[i].valid) {
2091 CDF_TRACE(CDF_MODULE_ID_PE, LOG1,
2092 FL("sysRole(%d) Session (%d)"),
2093 mac_ctx->lim.gLimSystemRole, i);
2094 CDF_TRACE(CDF_MODULE_ID_PE, LOG1,
2095 FL("SME: Curr %s,Prev %s,MLM: Curr %s,Prev %s"),
2096 lim_sme_state_str(
2097 mac_ctx->lim.gpSession[i].limSmeState),
2098 lim_sme_state_str(
2099 mac_ctx->lim.gpSession[i].limPrevSmeState),
2100 lim_mlm_state_str(
2101 mac_ctx->lim.gpSession[i].limMlmState),
2102 lim_mlm_state_str(
2103 mac_ctx->lim.gpSession[i].limPrevMlmState));
2104 }
2105 }
2106#endif
2107}