blob: 6357be7f89fdb84f6eb7c1ab46d7cb180b937788 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Sreelakshmi Konamki7d7f6ca2017-05-15 15:32:02 +05302 * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
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
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080028/*
Jeff Johnson295189b2012-06-20 16:38:30 -070029 *
Jeff Johnson295189b2012-06-20 16:38:30 -070030 * This file schApi.cc contains functions related to the API exposed
31 * by scheduler module
32 *
33 * Author: Sandesh Goel
34 * Date: 02/25/02
35 * History:-
36 * Date Modified by Modification Information
37 * --------------------------------------------------------------------
38 *
39 */
40#include "palTypes.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070041#include "aniGlobal.h"
Satyanarayana Dash6f438272015-03-03 18:01:06 +053042#include "wniCfg.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070043
44#include "sirMacProtDef.h"
45#include "sirMacPropExts.h"
46#include "sirCommon.h"
47
Jeff Johnson295189b2012-06-20 16:38:30 -070048
49#include "cfgApi.h"
50#include "pmmApi.h"
51
52#include "limApi.h"
53
54#include "schApi.h"
55#include "schDebug.h"
56
57#include "schSysParams.h"
58#include "limTrace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070059#include "limTypes.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070060
61#include "wlan_qct_wda.h"
62
63//--------------------------------------------------------------------
64//
65// Static Variables
66//
67//-------------------------------------------------------------------
68static tANI_U8 gSchProbeRspTemplate[SCH_MAX_PROBE_RESP_SIZE];
69static tANI_U8 gSchBeaconFrameBegin[SCH_MAX_BEACON_SIZE];
70static tANI_U8 gSchBeaconFrameEnd[SCH_MAX_BEACON_SIZE];
71
72// --------------------------------------------------------------------
73/**
74 * schGetCFPCount
75 *
76 * FUNCTION:
77 * Function used by other Sirius modules to read CFPcount
78 *
79 * LOGIC:
80 *
81 * ASSUMPTIONS:
82 *
83 * NOTE:
84 *
85 * @param None
86 * @return None
87 */
88
89tANI_U8
90schGetCFPCount(tpAniSirGlobal pMac)
91{
92 return pMac->sch.schObject.gSchCFPCount;
93}
94
95// --------------------------------------------------------------------
96/**
97 * schGetCFPDurRemaining
98 *
99 * FUNCTION:
100 * Function used by other Sirius modules to read CFPDuration remaining
101 *
102 * LOGIC:
103 *
104 * ASSUMPTIONS:
105 *
106 * NOTE:
107 *
108 * @param None
109 * @return None
110 */
111
112tANI_U16
113schGetCFPDurRemaining(tpAniSirGlobal pMac)
114{
115 return pMac->sch.schObject.gSchCFPDurRemaining;
116}
117
118
119// --------------------------------------------------------------------
120/**
121 * schInitialize
122 *
123 * FUNCTION:
124 * Initialize
125 *
126 * LOGIC:
127 *
128 * ASSUMPTIONS:
129 *
130 * NOTE:
131 *
132 * @param None
133 * @return None
134 */
135
136void
137schInitialize(tpAniSirGlobal pMac)
138{
139 pmmInitialize(pMac);
140}
141
142// --------------------------------------------------------------------
143/**
144 * schInitGlobals
145 *
146 * FUNCTION:
147 * Initialize globals
148 *
149 * LOGIC:
150 *
151 * ASSUMPTIONS:
152 *
153 * NOTE:
154 *
155 * @param None
156 * @return None
157 */
158
159void
160schInitGlobals(tpAniSirGlobal pMac)
161{
162 pMac->sch.gSchHcfEnabled = false;
163
164 pMac->sch.gSchScanRequested = false;
165 pMac->sch.gSchScanReqRcvd = false;
166
167 pMac->sch.gSchGenBeacon = 1;
168 pMac->sch.gSchBeaconsSent = 0;
169 pMac->sch.gSchBeaconsWritten = 0;
170 pMac->sch.gSchBcnParseErrorCnt = 0;
171 pMac->sch.gSchBcnIgnored = 0;
172 pMac->sch.gSchBBXportRcvCnt = 0;
173 pMac->sch.gSchUnknownRcvCnt = 0;
174 pMac->sch.gSchBcnRcvCnt = 0;
175 pMac->sch.gSchRRRcvCnt = 0;
176 pMac->sch.qosNullCnt = 0;
177 pMac->sch.numData = 0;
178 pMac->sch.numPoll = 0;
179 pMac->sch.numCorrupt = 0;
180 pMac->sch.numBogusInt = 0;
181 pMac->sch.numTxAct0 = 0;
182 pMac->sch.rrTimeout = SCH_RR_TIMEOUT;
183 pMac->sch.pollPeriod = SCH_POLL_PERIOD;
184 pMac->sch.keepAlive = 0;
185 pMac->sch.multipleSched = 1;
186 pMac->sch.maxPollTimeouts = 20;
187 pMac->sch.checkCfbFlagStuck = 0;
188
189 pMac->sch.schObject.gSchProbeRspTemplate = gSchProbeRspTemplate;
190 pMac->sch.schObject.gSchBeaconFrameBegin = gSchBeaconFrameBegin;
191 pMac->sch.schObject.gSchBeaconFrameEnd = gSchBeaconFrameEnd;
192
193}
194
195// --------------------------------------------------------------------
196/**
197 * schPostMessage
198 *
199 * FUNCTION:
200 * Post the beacon message to the scheduler message queue
201 *
202 * LOGIC:
203 *
204 * ASSUMPTIONS:
205 *
206 * NOTE:
207 *
208 * @param pMsg pointer to message
209 * @return None
210 */
211
212tSirRetStatus
213schPostMessage(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
214{
Jeff Johnson295189b2012-06-20 16:38:30 -0700215 schProcessMessage(pMac, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700216
217 return eSIR_SUCCESS;
218}
219
220
221
222
223
224// ---------------------------------------------------------------------------
225/**
226 * schSendStartScanRsp
227 *
228 * FUNCTION:
229 *
230 * LOGIC:
231 *
232 * ASSUMPTIONS:
233 *
234 * NOTE:
235 *
236 * @param None
237 * @return None
238 */
239
240void
241schSendStartScanRsp(tpAniSirGlobal pMac)
242{
243 tSirMsgQ msgQ;
244 tANI_U32 retCode;
245
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530246 schLog(pMac, LOG1, FL("Sending SIR_SCH_START_SCAN_RSP to LIM"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700247 msgQ.type = SIR_SCH_START_SCAN_RSP;
248 if ((retCode = limPostMsgApi(pMac, &msgQ)) != eSIR_SUCCESS)
249 schLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700250 FL("Posting START_SCAN_RSP to LIM failed, reason=%X"), retCode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700251}
252
253/**
254 * schSendBeaconReq
255 *
256 * FUNCTION:
257 *
258 * LOGIC:
259 * 1) SCH received SIR_SCH_BEACON_GEN_IND
260 * 2) SCH updates TIM IE and other beacon related IE's
261 * 3) SCH sends WDA_SEND_BEACON_REQ to HAL. HAL then copies the beacon
262 * template to memory
263 *
264 * ASSUMPTIONS:
265 * Memory allocation is reqd to send this message and SCH allocates memory.
266 * The assumption is that HAL will "free" this memory.
267 *
268 * NOTE:
269 *
270 * @param pMac global
271 *
272 * @param beaconPayload
273 *
274 * @param size - Length of the beacon
275 *
276 * @return eHalStatus
277 */
278tSirRetStatus schSendBeaconReq( tpAniSirGlobal pMac, tANI_U8 *beaconPayload, tANI_U16 size, tpPESession psessionEntry)
279{
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530280 tSirMsgQ msgQ;
281 tpSendbeaconParams beaconParams = NULL;
282 tSirRetStatus retCode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700283
284 schLog( pMac, LOG2,
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530285 FL( "Indicating HAL to copy the beacon template [%d bytes] to memory" ),
286 size );
Jeff Johnson295189b2012-06-20 16:38:30 -0700287
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530288 beaconParams = vos_mem_malloc(sizeof(tSendbeaconParams));
289 if ( NULL == beaconParams )
290 return eSIR_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700291
292 msgQ.type = WDA_SEND_BEACON_REQ;
293
294 // No Dialog Token reqd, as a response is not solicited
295 msgQ.reserved = 0;
296
297 // Fill in tSendbeaconParams members
298 /* Knock off all pMac global addresses */
299 // limGetBssid( pMac, beaconParams->bssId);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530300 vos_mem_copy(beaconParams->bssId, psessionEntry->bssId, sizeof(psessionEntry->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -0700301
Jeff Johnson295189b2012-06-20 16:38:30 -0700302 beaconParams->timIeOffset = pMac->sch.schObject.gSchBeaconOffsetBegin;
Gopichand Nakkala81aef732013-03-22 11:15:19 +0530303 /* p2pIeOffset should be atleast greater than timIeOffset */
304 if ((pMac->sch.schObject.p2pIeOffset != 0) &&
305 (pMac->sch.schObject.p2pIeOffset <
306 pMac->sch.schObject.gSchBeaconOffsetBegin))
307 {
308 schLog(pMac, LOGE,FL("Invalid p2pIeOffset:[%d]"),
309 pMac->sch.schObject.p2pIeOffset);
310 VOS_ASSERT( 0 );
311 return eSIR_FAILURE;
312 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700313 beaconParams->p2pIeOffset = pMac->sch.schObject.p2pIeOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -0700314#ifdef WLAN_SOFTAP_FW_BEACON_TX_PRNT_LOG
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700315 schLog(pMac, LOGE,FL("TimIeOffset:[%d]"),beaconParams->TimIeOffset );
Jeff Johnson295189b2012-06-20 16:38:30 -0700316#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700317
318 beaconParams->beacon = beaconPayload;
319 beaconParams->beaconLength = (tANI_U32) size;
320 msgQ.bodyptr = beaconParams;
321 msgQ.bodyval = 0;
322
323 // Keep a copy of recent beacon frame sent
324
325 // free previous copy of the beacon
326 if (psessionEntry->beacon )
327 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530328 vos_mem_free(psessionEntry->beacon);
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 }
330
331 psessionEntry->bcnLen = 0;
332 psessionEntry->beacon = NULL;
333
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530334 psessionEntry->beacon = vos_mem_malloc(size);
335 if ( psessionEntry->beacon != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -0700336 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530337 vos_mem_copy(psessionEntry->beacon, beaconPayload, size);
Jeff Johnson295189b2012-06-20 16:38:30 -0700338 psessionEntry->bcnLen = size;
339 }
340
Jeff Johnsone7245742012-09-05 17:12:55 -0700341 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -0700342 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
343 {
344 schLog( pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700345 FL("Posting SEND_BEACON_REQ to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700346 retCode );
347 } else
348 {
349 schLog( pMac, LOG2,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700350 FL("Successfully posted WDA_SEND_BEACON_REQ to HAL"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700351
Jeff Johnson295189b2012-06-20 16:38:30 -0700352 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE )
Sachin Ahuja825082e2014-11-25 17:34:36 +0530353 && (pMac->sch.schObject.fBeaconChanged)
354 && ((psessionEntry->proxyProbeRspEn)
355 || (IS_FEATURE_SUPPORTED_BY_FW(WPS_PRBRSP_TMPL)))
Rajeev Kumar Sirasanagandla63f85cf2016-06-29 16:52:15 +0530356 && vos_is_probe_rsp_offload_enabled()
Sachin Ahuja825082e2014-11-25 17:34:36 +0530357 )
358
Jeff Johnson295189b2012-06-20 16:38:30 -0700359 {
Sachin Ahuja825082e2014-11-25 17:34:36 +0530360 schLog(pMac, LOG1, FL("Sending probeRsp Template to HAL"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700361 if(eSIR_SUCCESS != (retCode = limSendProbeRspTemplateToHal(pMac,psessionEntry,
362 &psessionEntry->DefProbeRspIeBitmap[0])))
363 {
364 /* check whether we have to free any memory */
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700365 schLog(pMac, LOGE, FL("FAILED to send probe response template with retCode %d"), retCode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700366 }
367 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700368 }
369
370 return retCode;
371}
372
Jeff Johnson295189b2012-06-20 16:38:30 -0700373tANI_U32 limSendProbeRspTemplateToHal(tpAniSirGlobal pMac,tpPESession psessionEntry
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530374 ,tANI_U32* IeBitmap)
Jeff Johnson295189b2012-06-20 16:38:30 -0700375{
376 tSirMsgQ msgQ;
377 tANI_U8 *pFrame2Hal = pMac->sch.schObject.gSchProbeRspTemplate;
378 tpSendProbeRespParams pprobeRespParams=NULL;
379 tANI_U32 retCode = eSIR_FAILURE;
380 tANI_U32 nPayload,nBytes,nStatus;
381 tpSirMacMgmtHdr pMacHdr;
382 tANI_U32 addnIEPresent;
Sreelakshmi Konamki7d7f6ca2017-05-15 15:32:02 +0530383 tANI_U32 addnIE1Len=0;
384 tANI_U32 addnIE2Len = 0;
385 tANI_U32 addnIE3Len = 0;
386 tANI_U32 totalAddnIeLen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700387 tSirRetStatus nSirStatus;
Gopichand Nakkala77071442013-03-25 15:04:35 +0530388 tANI_U8 *addIE = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700389
390 nStatus = dot11fGetPackedProbeResponseSize( pMac, &psessionEntry->probeRespFrame, &nPayload );
391 if ( DOT11F_FAILED( nStatus ) )
392 {
393 schLog( pMac, LOGE, FL("Failed to calculate the packed size f"
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700394 "or a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700395 nStatus );
396 // We'll fall back on the worst case scenario:
397 nPayload = sizeof( tDot11fProbeResponse );
398 }
399 else if ( DOT11F_WARNED( nStatus ) )
400 {
401 schLog( pMac, LOGE, FL("There were warnings while calculating"
402 "the packed size for a Probe Response "
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700403 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700404 }
405
406 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
Gopichand Nakkala77071442013-03-25 15:04:35 +0530407
408 //Check if probe response IE is present or not
409 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG, &addnIEPresent) != eSIR_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700410 {
Gopichand Nakkala77071442013-03-25 15:04:35 +0530411 schLog(pMac, LOGE, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700412 return retCode;
413 }
414
Gopichand Nakkala77071442013-03-25 15:04:35 +0530415 if (addnIEPresent)
Jeff Johnson295189b2012-06-20 16:38:30 -0700416 {
Sreelakshmi Konamki7d7f6ca2017-05-15 15:32:02 +0530417 if (wlan_cfgGetStrLen(pMac, WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
418 &addnIE1Len) != eSIR_SUCCESS)
419 {
420 schLog(pMac, LOGE,
421 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
422 return retCode;
423 }
424
425 if (addnIE1Len == WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN)
426 {
427 if (wlan_cfgGetStrLen(pMac, WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
428 &addnIE2Len) != eSIR_SUCCESS)
429 {
430 schLog(pMac, LOGE,
431 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
432 return retCode;
433 }
434 }
435
436 if (addnIE2Len == WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN)
437 {
438 if (wlan_cfgGetStrLen(pMac, WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
439 &addnIE3Len) != eSIR_SUCCESS)
440 {
441 schLog(pMac, LOGE,
442 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
443 return retCode;
444 }
445 }
446 schLog(pMac,LOG1, FL("addnIE1Len %d, addnIE2Len %d, addnIE3Len %d"),
447 addnIE1Len, addnIE2Len, addnIE3Len);
448 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
449
450 addIE = vos_mem_malloc(totalAddnIeLen);
451 if (NULL == addIE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700452 {
Gopichand Nakkala77071442013-03-25 15:04:35 +0530453 schLog(pMac, LOGE,
454 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
455 return retCode;
456 }
457
Sreelakshmi Konamki7d7f6ca2017-05-15 15:32:02 +0530458 if (addnIE1Len && addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN &&
459 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700460 {
Gopichand Nakkala77071442013-03-25 15:04:35 +0530461 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
462 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
Sreelakshmi Konamki7d7f6ca2017-05-15 15:32:02 +0530463 &addnIE1Len))
Jeff Johnson295189b2012-06-20 16:38:30 -0700464 {
Gopichand Nakkala77071442013-03-25 15:04:35 +0530465 schLog(pMac, LOGE,
466 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530467 vos_mem_free(addIE);
Gopichand Nakkala77071442013-03-25 15:04:35 +0530468 return retCode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700469 }
470 }
Sreelakshmi Konamki7d7f6ca2017-05-15 15:32:02 +0530471
472 if (addnIE2Len && addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN &&
473 (nBytes + addnIE1Len + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
474 {
475 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
476 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
477 &addIE[addnIE1Len],
478 &addnIE2Len) )
479 {
480 schLog(pMac, LOGE,
481 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
482 vos_mem_free(addIE);
483 return retCode;
484 }
485 }
486
487 if (addnIE3Len && addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN &&
488 (nBytes + totalAddnIeLen) <= SIR_MAX_PACKET_SIZE)
489 {
490 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
491 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
492 &addIE[addnIE1Len + addnIE2Len],
493 &addnIE3Len) )
494 {
495 schLog(pMac, LOGE,
496 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
497 vos_mem_free(addIE);
498 return retCode;
499 }
500 }
501
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 }
Gopichand Nakkala77071442013-03-25 15:04:35 +0530503
504 if (addnIEPresent)
Jeff Johnson295189b2012-06-20 16:38:30 -0700505 {
Sreelakshmi Konamki7d7f6ca2017-05-15 15:32:02 +0530506 if ((nBytes + totalAddnIeLen) <= SIR_MAX_PACKET_SIZE )
507 nBytes += totalAddnIeLen;
Gopichand Nakkala77071442013-03-25 15:04:35 +0530508 else
509 addnIEPresent = false; //Dont include the IE.
Jeff Johnson295189b2012-06-20 16:38:30 -0700510 }
511
Jeff Johnson295189b2012-06-20 16:38:30 -0700512 // Paranoia:
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530513 vos_mem_set(pFrame2Hal, nBytes, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700514
515 // Next, we fill out the buffer descriptor:
516 nSirStatus = limPopulateMacHeader( pMac, pFrame2Hal, SIR_MAC_MGMT_FRAME,
517 SIR_MAC_MGMT_PROBE_RSP, psessionEntry->selfMacAddr,psessionEntry->selfMacAddr);
518
519 if ( eSIR_SUCCESS != nSirStatus )
520 {
521 schLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700522 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700523 nSirStatus );
Gopichand Nakkala77071442013-03-25 15:04:35 +0530524
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530525 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700526 return retCode;
527 }
528
529 pMacHdr = ( tpSirMacMgmtHdr ) pFrame2Hal;
Gopichand Nakkala77071442013-03-25 15:04:35 +0530530
Jeff Johnson295189b2012-06-20 16:38:30 -0700531 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
Gopichand Nakkala77071442013-03-25 15:04:35 +0530532
Jeff Johnson295189b2012-06-20 16:38:30 -0700533 // That done, pack the Probe Response:
534 nStatus = dot11fPackProbeResponse( pMac, &psessionEntry->probeRespFrame, pFrame2Hal + sizeof(tSirMacMgmtHdr),
535 nPayload, &nPayload );
536
537 if ( DOT11F_FAILED( nStatus ) )
538 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700539 schLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700540 nStatus );
Gopichand Nakkala77071442013-03-25 15:04:35 +0530541
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530542 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 return retCode; // allocated!
544 }
545 else if ( DOT11F_WARNED( nStatus ) )
546 {
547 schLog( pMac, LOGE, FL("There were warnings while packing a P"
Jeff Johnsonf9416e02013-11-03 11:00:39 -0800548 "robe Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700549 }
550
Gopichand Nakkala77071442013-03-25 15:04:35 +0530551 if (addnIEPresent)
552 {
Sreelakshmi Konamki7d7f6ca2017-05-15 15:32:02 +0530553 vos_mem_copy ( &pFrame2Hal[nBytes - totalAddnIeLen],
554 &addIE[0], totalAddnIeLen);
Gopichand Nakkala77071442013-03-25 15:04:35 +0530555 }
556
557 /* free the allocated Memory */
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530558 vos_mem_free(addIE);
Gopichand Nakkala77071442013-03-25 15:04:35 +0530559
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530560 pprobeRespParams = vos_mem_malloc(sizeof( tSendProbeRespParams ));
561 if ( NULL == pprobeRespParams )
Jeff Johnson295189b2012-06-20 16:38:30 -0700562 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700563 schLog( pMac, LOGE, FL("limSendProbeRspTemplateToHal: HAL probe response params malloc failed for bytes %d"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700564 }
565 else
566 {
567 /*
568 PELOGE(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOGE,
569 pFrame2Hal,
570 nBytes);)
571 */
572
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530573 sirCopyMacAddr( pprobeRespParams->bssId, psessionEntry->bssId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700574 pprobeRespParams->pProbeRespTemplate = pFrame2Hal;
575 pprobeRespParams->probeRespTemplateLen = nBytes;
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530576 vos_mem_copy(pprobeRespParams->ucProxyProbeReqValidIEBmap,IeBitmap,(sizeof(tANI_U32) * 8));
Gopichand Nakkala77071442013-03-25 15:04:35 +0530577 msgQ.type = WDA_UPDATE_PROBE_RSP_TEMPLATE_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -0700578 msgQ.reserved = 0;
579 msgQ.bodyptr = pprobeRespParams;
580 msgQ.bodyval = 0;
581
582 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
583 {
584 /* free the allocated Memory */
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530585 schLog( pMac,LOGE, FL("limSendProbeRspTemplateToHal: FAIL bytes %d retcode[%X]"), nBytes, retCode );
586 vos_mem_free(pprobeRespParams);
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 }
588 else
589 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700590 schLog( pMac,LOG1, FL("limSendProbeRspTemplateToHal: Probe response template msg posted to HAL of bytes %d"),nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700591 }
592 }
593
594 return retCode;
595}
Jeff Johnson295189b2012-06-20 16:38:30 -0700596