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