blob: b63cbe243815ae6e2f369e472803e6e8e894914e [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2014 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/*
Kiet Lamaa8e15a2014-02-11 23:30:06 -080023 * Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
24 * All Rights Reserved.
25 * Qualcomm Atheros Confidential and Proprietary.
Kiet Lam842dad02014-02-18 18:44:02 -080026 *
Jeff Johnson295189b2012-06-20 16:38:30 -070027 */
Kiet Lam842dad02014-02-18 18:44:02 -080028
29
Jeff Johnson295189b2012-06-20 16:38:30 -070030/**
31 * \file limSendManagementFrames.c
32 *
33 * \brief Code for preparing and sending 802.11 Management frames
34 *
Kiet Lam842dad02014-02-18 18:44:02 -080035
Jeff Johnson295189b2012-06-20 16:38:30 -070036 *
37 */
38
39#include "sirApi.h"
40#include "aniGlobal.h"
41#include "sirMacProtDef.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070042#include "cfgApi.h"
43#include "utilsApi.h"
44#include "limTypes.h"
45#include "limUtils.h"
46#include "limSecurityUtils.h"
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -070047#include "limPropExtsUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070048#include "dot11f.h"
49#include "limStaHashApi.h"
50#include "schApi.h"
51#include "limSendMessages.h"
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -080052#include "limAssocUtils.h"
53#include "limFT.h"
Chet Lanctot8cecea22014-02-11 19:09:36 -080054#ifdef WLAN_FEATURE_11W
55#include "wniCfgAp.h"
56#endif
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -080057
Jeff Johnson295189b2012-06-20 16:38:30 -070058#if defined WLAN_FEATURE_VOWIFI
59#include "rrmApi.h"
60#endif
61
Jeff Johnson295189b2012-06-20 16:38:30 -070062#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070063
64
65////////////////////////////////////////////////////////////////////////
66
Kalikinkar dhara205da782014-03-21 15:49:32 -070067tSirRetStatus limStripOffExtCapIE(tpAniSirGlobal pMac,
68 tANI_U8 *addIE,
69 tANI_U16 *addnIELen,
70 tANI_U8 *pExtractedExtCapIEBuf )
71{
72 tANI_U8* tempbuf = NULL;
73 tANI_U16 tempLen = 0;
74 int left = *addnIELen;
75 tANI_U8 *ptr = addIE;
76 tANI_U8 elem_id, elem_len;
77
78 if (NULL == addIE)
79 {
80 PELOGE(limLog(pMac, LOG1, FL("NULL addIE pointer"));)
81 return eSIR_IGNORE_IE ;
82 }
83
84 tempbuf = vos_mem_malloc(left);
85 if ( NULL == tempbuf )
86 {
87 PELOGE(limLog(pMac, LOGE,
88 FL("Unable to allocate memory to store addn IE"));)
89 return eSIR_MEM_ALLOC_FAILED;
90 }
91
92 while(left >= 2)
93 {
94 elem_id = ptr[0];
95 elem_len = ptr[1];
96 left -= 2;
97 if (elem_len > left)
98 {
99 limLog( pMac, LOGE,
100 FL("Invalid IEs eid = %d elem_len=%d left=%d"),
101 elem_id,elem_len,left);
102 vos_mem_free(tempbuf);
103 return eSIR_FAILURE;
104 }
105 if ( !(DOT11F_EID_EXTCAP == elem_id) )
106 {
107 vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2);
108 tempLen += (elem_len + 2);
109 }
110 else
111 { /*Est Cap present size is 8 + 2 byte at present*/
112 if ( NULL != pExtractedExtCapIEBuf )
113 {
114 vos_mem_set(pExtractedExtCapIEBuf,
115 DOT11F_IE_EXTCAP_MAX_LEN + 2, 0);
116 if (elem_len <= DOT11F_IE_EXTCAP_MAX_LEN )
117 {
118 vos_mem_copy (pExtractedExtCapIEBuf, &ptr[0],
119 elem_len + 2);
120 }
121 }
122 }
123 left -= elem_len;
124 ptr += (elem_len + 2);
125 }
126 vos_mem_copy (addIE, tempbuf, tempLen);
127 *addnIELen = tempLen;
128 vos_mem_free(tempbuf);
129 return eSIR_SUCCESS;
130}
131
132void limUpdateExtCapIEtoStruct(tpAniSirGlobal pMac,
133 tANI_U8 *pBuf,
134 tDot11fIEExtCap *pDst)
135{
136 tANI_U8 pOut[DOT11F_IE_EXTCAP_MAX_LEN];
137
138 if ( NULL == pBuf )
139 {
140 limLog( pMac, LOGE,
141 FL("Invalid Buffer Address"));
142 return;
143 }
144 if(NULL == pDst)
145 {
146 PELOGE(limLog(pMac, LOGE,
147 FL("NULL pDst pointer"));)
148 return ;
149 }
150
151 if ( DOT11F_EID_EXTCAP != pBuf[0] ||
152 pBuf[1] > DOT11F_IE_EXTCAP_MAX_LEN )
153 {
154 limLog( pMac, LOGE,
155 FL("Invalid IEs eid = %d elem_len=%d "),
156 pBuf[0],pBuf[1]);
157 return;
158 }
159 vos_mem_set(( tANI_U8* )&pOut[0], DOT11F_IE_EXTCAP_MAX_LEN, 0);
160 /* conversion should follow 4, 2, 2 byte order */
161 limUtilsframeshtonl(pMac, &pOut[0],*((tANI_U32*)&pBuf[2]),0);
162 limUtilsframeshtons(pMac, &pOut[4],*((tANI_U16*)&pBuf[6]),0);
163 limUtilsframeshtons(pMac, &pOut[6],*((tANI_U16*)&pBuf[8]),0);
164
165 if ( DOT11F_PARSE_SUCCESS != dot11fUnpackIeExtCap( pMac,
166 &pOut[0], DOT11F_IE_EXTCAP_MAX_LEN, pDst) )
167 {
168 limLog( pMac, LOGE,
169 FL("dot11fUnpackIeExtCap Parse Error "));
170 }
171}
172
173tSirRetStatus limStripOffExtCapIEAndUpdateStruct(tpAniSirGlobal pMac,
174 tANI_U8* addIE,
175 tANI_U16 *addnIELen,
176 tDot11fIEExtCap * pDst )
177{
178 tANI_U8 pExtractedExtCapIEBuf[DOT11F_IE_EXTCAP_MAX_LEN + 2];
179 tSirRetStatus nSirStatus;
180
181 vos_mem_set(( tANI_U8* )&pExtractedExtCapIEBuf[0],
182 DOT11F_IE_EXTCAP_MAX_LEN + 2, 0);
183 nSirStatus = limStripOffExtCapIE(pMac, addIE, addnIELen,
184 pExtractedExtCapIEBuf);
185 if ( eSIR_SUCCESS != nSirStatus )
186 {
187 limLog( pMac, LOG1, FL("Failed to strip off in"
188 "limStripOffExtCapIE status = (%d)."),
189 nSirStatus );
190 return nSirStatus;
191 }
192 /* update the extracted ExtCap to struct*/
193 limUpdateExtCapIEtoStruct(pMac, pExtractedExtCapIEBuf, pDst);
194 return nSirStatus;
195}
196
197void limMergeExtCapIEStruct(tDot11fIEExtCap *pDst,
198 tDot11fIEExtCap *pSrc)
199{
200 tANI_U8 *tempDst = (tANI_U8 *)pDst;
201 tANI_U8 *tempSrc = (tANI_U8 *)pSrc;
202 tANI_U8 structlen = sizeof(tDot11fIEExtCap);
203
204 while(tempDst && tempSrc && structlen--)
205 {
206 *tempDst |= *tempSrc;
207 tempDst++;
208 tempSrc++;
209 }
210}
Jeff Johnson295189b2012-06-20 16:38:30 -0700211
212/**
213 *
214 * \brief This function is called by various LIM modules to prepare the
215 * 802.11 frame MAC header
216 *
217 *
218 * \param pMac Pointer to Global MAC structure
219 *
220 * \param pBD Pointer to the frame buffer that needs to be populate
221 *
222 * \param type Type of the frame
223 *
224 * \param subType Subtype of the frame
225 *
226 * \return eHalStatus
227 *
228 *
229 * The pFrameBuf argument points to the beginning of the frame buffer to
230 * which - a) The 802.11 MAC header is set b) Following this MAC header
231 * will be the MGMT frame payload The payload itself is populated by the
232 * caller API
233 *
234 *
235 */
236
237tSirRetStatus limPopulateMacHeader( tpAniSirGlobal pMac,
238 tANI_U8* pBD,
239 tANI_U8 type,
240 tANI_U8 subType,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530241 tSirMacAddr peerAddr, tSirMacAddr selfMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700242{
243 tSirRetStatus statusCode = eSIR_SUCCESS;
244 tpSirMacMgmtHdr pMacHdr;
245
246 /// Prepare MAC management header
247 pMacHdr = (tpSirMacMgmtHdr) (pBD);
248
249 // Prepare FC
250 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
251 pMacHdr->fc.type = type;
252 pMacHdr->fc.subType = subType;
253
254 // Prepare Address 1
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530255 vos_mem_copy( (tANI_U8 *) pMacHdr->da,
Jeff Johnson295189b2012-06-20 16:38:30 -0700256 (tANI_U8 *) peerAddr,
257 sizeof( tSirMacAddr ));
258
259 // Prepare Address 2
Jeff Johnson295189b2012-06-20 16:38:30 -0700260 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
261
262 // Prepare Address 3
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530263 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700264 (tANI_U8 *) peerAddr,
265 sizeof( tSirMacAddr ));
266 return statusCode;
267} /*** end limPopulateMacHeader() ***/
268
269/**
270 * \brief limSendProbeReqMgmtFrame
271 *
272 *
273 * \param pMac Pointer to Global MAC structure
274 *
275 * \param pSsid SSID to be sent in Probe Request frame
276 *
277 * \param bssid BSSID to be sent in Probe Request frame
278 *
279 * \param nProbeDelay probe delay to be used before sending Probe Request
280 * frame
281 *
282 * \param nChannelNum Channel # on which the Probe Request is going out
283 *
284 * \param nAdditionalIELen if non-zero, include pAdditionalIE in the Probe Request frame
285 *
286 * \param pAdditionalIE if nAdditionalIELen is non zero, include this field in the Probe Request frame
287 *
288 * This function is called by various LIM modules to send Probe Request frame
289 * during active scan/learn phase.
290 * Probe request is sent out in the following scenarios:
291 * --heartbeat failure: session needed
292 * --join req: session needed
293 * --foreground scan: no session
294 * --background scan: no session
295 * --schBeaconProcessing: to get EDCA parameters: session needed
296 *
297 *
298 */
299tSirRetStatus
300limSendProbeReqMgmtFrame(tpAniSirGlobal pMac,
301 tSirMacSSid *pSsid,
302 tSirMacAddr bssid,
303 tANI_U8 nChannelNum,
304 tSirMacAddr SelfMacAddr,
305 tANI_U32 dot11mode,
306 tANI_U32 nAdditionalIELen,
307 tANI_U8 *pAdditionalIE)
308{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530309 tDot11fProbeRequest pr;
310 tANI_U32 nStatus, nBytes, nPayload;
311 tSirRetStatus nSirStatus;
312 tANI_U8 *pFrame;
313 void *pPacket;
314 eHalStatus halstatus;
315 tpPESession psessionEntry;
316 tANI_U8 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700317 tANI_U8 *p2pIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530318 tANI_U32 txFlag = 0;
Sandeep Puligilla60342762014-01-30 21:05:37 +0530319 tANI_U32 chanbond24G = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700320
321#ifndef GEN4_SCAN
322 return eSIR_FAILURE;
323#endif
324
325#if defined ( ANI_DVT_DEBUG )
326 return eSIR_FAILURE;
327#endif
328
Abhishek Singh4beed422014-02-03 16:47:17 +0530329 /* The probe req should not send 11ac capabilieties if band is 2.4GHz,
330 * unless enableVhtFor24GHz is enabled in INI. So if enableVhtFor24GHz
331 * is false and dot11mode is 11ac set it to 11n.
332 */
333 if ( nChannelNum <= SIR_11B_CHANNEL_END &&
334 ( FALSE == pMac->roam.configParam.enableVhtFor24GHz ) &&
335 ( WNI_CFG_DOT11_MODE_11AC == dot11mode ||
336 WNI_CFG_DOT11_MODE_11AC_ONLY == dot11mode ) )
337 dot11mode = WNI_CFG_DOT11_MODE_11N;
Jeff Johnson295189b2012-06-20 16:38:30 -0700338 /*
339 * session context may or may not be present, when probe request needs to be sent out.
340 * following cases exist:
341 * --heartbeat failure: session needed
342 * --join req: session needed
343 * --foreground scan: no session
344 * --background scan: no session
345 * --schBeaconProcessing: to get EDCA parameters: session needed
346 * If session context does not exist, some IEs will be populated from CFGs,
347 * e.g. Supported and Extended rate set IEs
348 */
349 psessionEntry = peFindSessionByBssid(pMac,bssid,&sessionId);
350
351 // The scheme here is to fill out a 'tDot11fProbeRequest' structure
352 // and then hand it off to 'dot11fPackProbeRequest' (for
353 // serialization). We start by zero-initializing the structure:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530354 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700355
356 // & delegating to assorted helpers:
357 PopulateDot11fSSID( pMac, pSsid, &pr.SSID );
358
Jeff Johnson295189b2012-06-20 16:38:30 -0700359 if( nAdditionalIELen && pAdditionalIE )
360 {
361 p2pIe = limGetP2pIEPtr(pMac, pAdditionalIE, nAdditionalIELen);
362 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700363 /* Don't include 11b rate only when device is doing P2P Search */
364 if( ( WNI_CFG_DOT11_MODE_11B != dot11mode ) &&
365 ( p2pIe != NULL ) &&
366 /* Don't include 11b rate if it is a P2P serach or probe request is sent by P2P Client */
367 ( ( ( pMac->lim.gpLimMlmScanReq != NULL ) &&
368 pMac->lim.gpLimMlmScanReq->p2pSearch ) ||
369 ( ( psessionEntry != NULL ) &&
370 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
371 )
372 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700373 {
374 /* In the below API pass channel number > 14, do that it fills only
375 * 11a rates in supported rates */
376 PopulateDot11fSuppRates( pMac, 15, &pr.SuppRates,psessionEntry);
377 }
378 else
379 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700380 PopulateDot11fSuppRates( pMac, nChannelNum,
381 &pr.SuppRates,psessionEntry);
382
383 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
384 {
385 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
386 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700387 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700388
389#if defined WLAN_FEATURE_VOWIFI
390 //Table 7-14 in IEEE Std. 802.11k-2008 says
391 //DS params "can" be present in RRM is disabled and "is" present if
392 //RRM is enabled. It should be ok even if we add it into probe req when
393 //RRM is not enabled.
394 PopulateDot11fDSParams( pMac, &pr.DSParams, nChannelNum, psessionEntry );
395 //Call RRM module to get the tx power for management used.
396 {
397 tANI_U8 txPower = (tANI_U8) rrmGetMgmtTxPower( pMac, psessionEntry );
398 PopulateDot11fWFATPC( pMac, &pr.WFATPC, txPower, 0 );
399 }
400#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700401
402 if (psessionEntry != NULL ) {
Jeff Johnsone7245742012-09-05 17:12:55 -0700403 psessionEntry->htCapability = IS_DOT11_MODE_HT(dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700404 //Include HT Capability IE
Jeff Johnsone7245742012-09-05 17:12:55 -0700405 if (psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -0700406 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700407 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700408 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700409 } else { //psessionEntry == NULL
410 if (IS_DOT11_MODE_HT(dot11mode))
Jeff Johnson295189b2012-06-20 16:38:30 -0700411 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700412 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700413 }
414 }
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800415
Sandeep Puligilla60342762014-01-30 21:05:37 +0530416 /* Get HT40 capability for 2.4GHz band */
417 wlan_cfgGetInt(pMac,WNI_CFG_CHANNEL_BONDING_24G,&chanbond24G);
418 if( (nChannelNum <= SIR_11B_CHANNEL_END) && chanbond24G != TRUE)
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800419 {
420 pr.HTCaps.supportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
421 pr.HTCaps.shortGI40MHz = 0;
422 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700423#ifdef WLAN_FEATURE_11AC
424 if (psessionEntry != NULL ) {
425 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
426 //Include HT Capability IE
427 if (psessionEntry->vhtCapability)
428 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700429 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
430 }
431 } else {
432 if (IS_DOT11_MODE_VHT(dot11mode))
433 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700434 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
435 }
436 }
437#endif
438
Jeff Johnson295189b2012-06-20 16:38:30 -0700439
440 // That's it-- now we pack it. First, how much space are we going to
441 // need?
442 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
443 if ( DOT11F_FAILED( nStatus ) )
444 {
445 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700446 "or a Probe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700447 // We'll fall back on the worst case scenario:
448 nPayload = sizeof( tDot11fProbeRequest );
449 }
450 else if ( DOT11F_WARNED( nStatus ) )
451 {
452 limLog( pMac, LOGW, FL("There were warnings while calculating"
453 "the packed size for a Probe Request ("
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700454 "0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700455 }
456
457 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAdditionalIELen;
458
459 // Ok-- try to allocate some memory:
460 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
461 ( tANI_U16 )nBytes, ( void** ) &pFrame,
462 ( void** ) &pPacket );
463 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
464 {
465 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700466 "be Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700467 return eSIR_MEM_ALLOC_FAILED;
468 }
469
470 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530471 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700472
473 // Next, we fill out the buffer descriptor:
474 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530475 SIR_MAC_MGMT_PROBE_REQ, bssid, SelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700476 if ( eSIR_SUCCESS != nSirStatus )
477 {
478 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700479 "tor for a Probe Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700480 nSirStatus );
481 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
482 ( void* ) pFrame, ( void* ) pPacket );
483 return nSirStatus; // allocated!
484 }
485
486 // That done, pack the Probe Request:
487 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
488 sizeof( tSirMacMgmtHdr ),
489 nPayload, &nPayload );
490 if ( DOT11F_FAILED( nStatus ) )
491 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700492 limLog( pMac, LOGE, FL("Failed to pack a Probe Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700493 nStatus );
494 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
495 return eSIR_FAILURE; // allocated!
496 }
497 else if ( DOT11F_WARNED( nStatus ) )
498 {
499 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800500 "robe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700501 }
502
503 // Append any AddIE if present.
504 if( nAdditionalIELen )
505 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530506 vos_mem_copy( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700507 pAdditionalIE, nAdditionalIELen );
508 nPayload += nAdditionalIELen;
509 }
510
511 /* If this probe request is sent during P2P Search State, then we need
512 * to send it at OFDM rate.
513 */
514 if( ( SIR_BAND_5_GHZ == limGetRFBand(nChannelNum))
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 || (( pMac->lim.gpLimMlmScanReq != NULL) &&
516 pMac->lim.gpLimMlmScanReq->p2pSearch )
Gopichand Nakkala67967212013-02-15 17:31:15 +0530517 /* For unicast probe req mgmt from Join function
518 we don't set above variables. So we need to add
519 one more check whether it is pePersona is P2P_CLIENT or not */
520 || ( ( psessionEntry != NULL ) &&
521 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700522 )
523 {
524 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
525 }
526
Jeff Johnson295189b2012-06-20 16:38:30 -0700527 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload,
528 HAL_TXRX_FRM_802_11_MGMT,
529 ANI_TXDIR_TODS,
530 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
531 limTxComplete, pFrame, txFlag );
532 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
533 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700534 limLog( pMac, LOGE, FL("could not send Probe Request frame!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700535 //Pkt will be freed up by the callback
536 return eSIR_FAILURE;
537 }
538
539 return eSIR_SUCCESS;
540} // End limSendProbeReqMgmtFrame.
541
Jeff Johnson295189b2012-06-20 16:38:30 -0700542tSirRetStatus limGetAddnIeForProbeResp(tpAniSirGlobal pMac,
543 tANI_U8* addIE, tANI_U16 *addnIELen,
544 tANI_U8 probeReqP2pIe)
545{
546 /* If Probe request doesn't have P2P IE, then take out P2P IE
547 from additional IE */
548 if(!probeReqP2pIe)
549 {
550 tANI_U8* tempbuf = NULL;
551 tANI_U16 tempLen = 0;
552 int left = *addnIELen;
553 v_U8_t *ptr = addIE;
554 v_U8_t elem_id, elem_len;
555
556 if(NULL == addIE)
557 {
558 PELOGE(limLog(pMac, LOGE,
559 FL(" NULL addIE pointer"));)
560 return eSIR_FAILURE;
561 }
562
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530563 tempbuf = vos_mem_malloc(left);
564 if ( NULL == tempbuf )
Jeff Johnson295189b2012-06-20 16:38:30 -0700565 {
566 PELOGE(limLog(pMac, LOGE,
567 FL("Unable to allocate memory to store addn IE"));)
568 return eSIR_MEM_ALLOC_FAILED;
569 }
570
571 while(left >= 2)
572 {
573 elem_id = ptr[0];
574 elem_len = ptr[1];
575 left -= 2;
576 if(elem_len > left)
577 {
578 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700579 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700580 elem_id,elem_len,left);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530581 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700582 return eSIR_FAILURE;
583 }
584 if ( !( (SIR_MAC_EID_VENDOR == elem_id) &&
585 (memcmp(&ptr[2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)==0) ) )
586 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530587 vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -0700588 tempLen += (elem_len + 2);
589 }
590 left -= elem_len;
591 ptr += (elem_len + 2);
592 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530593 vos_mem_copy (addIE, tempbuf, tempLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700594 *addnIELen = tempLen;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530595 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700596 }
597 return eSIR_SUCCESS;
598}
Jeff Johnson295189b2012-06-20 16:38:30 -0700599
600void
601limSendProbeRspMgmtFrame(tpAniSirGlobal pMac,
602 tSirMacAddr peerMacAddr,
603 tpAniSSID pSsid,
604 short nStaId,
605 tANI_U8 nKeepAlive,
606 tpPESession psessionEntry,
607 tANI_U8 probeReqP2pIe)
608{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700609 tDot11fProbeResponse *pFrm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530610 tSirRetStatus nSirStatus;
c_hpothubcd78652014-04-28 22:31:08 +0530611 tANI_U32 cfg, nPayload, nStatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530612 tpSirMacMgmtHdr pMacHdr;
613 tANI_U8 *pFrame;
614 void *pPacket;
615 eHalStatus halstatus;
616 tANI_U32 addnIEPresent;
617 tANI_U32 addnIE1Len=0;
618 tANI_U32 addnIE2Len=0;
619 tANI_U32 addnIE3Len=0;
620 tANI_U16 totalAddnIeLen = 0;
621 tANI_U32 wpsApEnable=0, tmp;
622 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700623 tANI_U8 *addIE = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530624 tANI_U8 *pP2pIe = NULL;
625 tANI_U8 noaLen = 0;
626 tANI_U8 total_noaLen = 0;
627 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 + SIR_P2P_IE_HEADER_LEN];
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530629 tANI_U8 noaIe[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Kalikinkar dhara205da782014-03-21 15:49:32 -0700630 tDot11fIEExtCap extractedExtCap;
631 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +0530632 tANI_U32 nBytes = 0;
633
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests
635 {
636 return; // in this case.
637 }
638
639 if(NULL == psessionEntry)
640 {
641 return;
642 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530643
644 pFrm = vos_mem_malloc(sizeof(tDot11fProbeResponse));
645 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700646 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530647 limLog(pMac, LOGE, FL("Unable to allocate memory in limSendProbeRspMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700648 return;
649 }
650
Girish Gowli0e826792014-05-17 17:56:44 +0530651 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
652
Jeff Johnson295189b2012-06-20 16:38:30 -0700653 // Fill out 'frm', after which we'll just hand the struct off to
654 // 'dot11fPackProbeResponse'.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530655 vos_mem_set(( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700656
657 // Timestamp to be updated by TFP, below.
658
659 // Beacon Interval:
Jeff Johnson295189b2012-06-20 16:38:30 -0700660 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
661 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700662 pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -0700663 }
664 else
665 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800666 nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg);
667 if (eSIR_SUCCESS != nSirStatus)
668 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700669 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d)."),
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800670 nSirStatus );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530671 vos_mem_free(pFrm);
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800672 return;
673 }
674 pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg;
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800675 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700676
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700677 PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry );
678 PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700679 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700680 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700681
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700682 PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry);
683 PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700684
Jeff Johnson295189b2012-06-20 16:38:30 -0700685
Jeff Johnson295189b2012-06-20 16:38:30 -0700686 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
687 {
688 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
689 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700690 PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700691 }
692 }
693 else
694 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800695 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700696 limLog(pMac, LOGP,"Failed to cfg get id %d", WNI_CFG_WPS_ENABLE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700697
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800698 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
Jeff Johnson295189b2012-06-20 16:38:30 -0700699
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800700 if (wpsApEnable)
701 {
702 PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes);
703 }
704
705 if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
706 {
707 PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
708 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
709 }
710
711 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
712 {
713 DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
714 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
715 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700716 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700717
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700718 PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry);
719 PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700720
Jeff Johnson295189b2012-06-20 16:38:30 -0700721
722 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700723 PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700724
725
726 // N.B. In earlier implementations, the RSN IE would be placed in
727 // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined.
728 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700729 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700730
731 //Populate HT IEs, when operating in 11n or Taurus modes.
Jeff Johnsone7245742012-09-05 17:12:55 -0700732 if ( psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -0700733 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700734 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700735 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700736 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700737#ifdef WLAN_FEATURE_11AC
738 if(psessionEntry->vhtCapability)
739 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -0800740 limLog( pMac, LOG1, FL("Populate VHT IE in Probe Response"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700741 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
742 PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation );
Jeff Johnsone7245742012-09-05 17:12:55 -0700743 // we do not support multi users yet
744 //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad );
Sandeep Puligilla60342762014-01-30 21:05:37 +0530745 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -0700746 }
747#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700748
Sandeep Puligilla60342762014-01-30 21:05:37 +0530749
Jeff Johnson295189b2012-06-20 16:38:30 -0700750 if ( psessionEntry->pLimStartBssReq )
751 {
752 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700753 &pFrm->WPA );
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700754 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
755 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -0700756 }
757
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700758 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700759
760#if defined(FEATURE_WLAN_WAPI)
761 if( psessionEntry->pLimStartBssReq )
762 {
763 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700764 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 }
766
767#endif // defined(FEATURE_WLAN_WAPI)
768
Jeff Johnson295189b2012-06-20 16:38:30 -0700769 addnIEPresent = false;
Jeff Johnson295189b2012-06-20 16:38:30 -0700770 if( pMac->lim.gpLimRemainOnChanReq )
771 {
772 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
773 }
774 //Only use CFG for non-listen mode. This CFG is not working for concurrency
775 //In listening mode, probe rsp IEs is passed in the message from SME to PE
776 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700777 {
778
779 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
780 &addnIEPresent) != eSIR_SUCCESS)
781 {
782 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530783 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700784 return;
785 }
786 }
787
788 if (addnIEPresent)
789 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530790
791 addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3);
792 if ( NULL == addIE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700793 {
794 PELOGE(limLog(pMac, LOGE,
795 FL("Unable to allocate memory to store addn IE"));)
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530796 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700797 return;
798 }
799
800 //Probe rsp IE available
801 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
802 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
803 {
804 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530805 vos_mem_free(addIE);
806 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700807 return;
808 }
809 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
810 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
811 {
812 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
813 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
814 &addnIE1Len) )
815 {
816 limLog(pMac, LOGP,
817 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530818 vos_mem_free(addIE);
819 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700820 return;
821 }
822 }
823
824 //Probe rsp IE available
825 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
826 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
827 {
828 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530829 vos_mem_free(addIE);
830 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700831 return;
832 }
833 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
834 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
835 {
836 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
837 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
838 &addnIE2Len) )
839 {
840 limLog(pMac, LOGP,
841 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530842 vos_mem_free(addIE);
843 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700844 return;
845 }
846 }
847
848 //Probe rsp IE available
849 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
850 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
851 {
852 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530853 vos_mem_free(addIE);
854 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700855 return;
856 }
857 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
858 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
859 {
860 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
861 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
862 &addIE[addnIE1Len + addnIE2Len],
863 &addnIE3Len) )
864 {
865 limLog(pMac, LOGP,
866 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530867 vos_mem_free(addIE);
868 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700869 return;
870 }
871 }
872 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
873
Jeff Johnson295189b2012-06-20 16:38:30 -0700874 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
875 {
876 limLog(pMac, LOGP,
877 FL("Unable to get final Additional IE for Probe Req"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530878 vos_mem_free(addIE);
879 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700880 return;
881 }
Kalikinkar dhara205da782014-03-21 15:49:32 -0700882
Kalikinkar dhara205da782014-03-21 15:49:32 -0700883 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
884 addIE,
885 &totalAddnIeLen,
886 &extractedExtCap );
887 if(eSIR_SUCCESS != nSirStatus )
888 {
889 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
890 limLog(pMac, LOG1,
891 FL("Unable to Stripoff ExtCap IE from Probe Rsp"));
892 }
893
Jeff Johnson295189b2012-06-20 16:38:30 -0700894 nBytes = nBytes + totalAddnIeLen;
895
896 if (probeReqP2pIe)
897 {
898 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
899 if (pP2pIe != NULL)
900 {
901 //get NoA attribute stream P2P IE
902 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
903 if (noaLen != 0)
904 {
905 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
906 &noaStream[0], noaLen);
907 nBytes = nBytes + total_noaLen;
908 }
909 }
910 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700911 }
912
c_hpothubcd78652014-04-28 22:31:08 +0530913 /*merge ExtCap IE*/
914 if (extractedExtCapFlag && extractedExtCap.present)
915 {
916 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
917 }
918
919 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
920 if ( DOT11F_FAILED( nStatus ) )
921 {
922 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
923 "or a Probe Response (0x%08x)."),
924 nStatus );
925 // We'll fall back on the worst case scenario:
926 nPayload = sizeof( tDot11fProbeResponse );
927 }
928 else if ( DOT11F_WARNED( nStatus ) )
929 {
930 limLog( pMac, LOGW, FL("There were warnings while calculating"
931 "the packed size for a Probe Response "
932 "(0x%08x)."), nStatus );
933 }
934
935 nBytes += nPayload + sizeof( tSirMacMgmtHdr );
936
Jeff Johnson295189b2012-06-20 16:38:30 -0700937 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
938 ( tANI_U16 )nBytes, ( void** ) &pFrame,
939 ( void** ) &pPacket );
940 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
941 {
942 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700943 "be Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700944 if ( addIE != NULL )
945 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530946 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700947 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530948 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700949 return;
950 }
951
952 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530953 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700954
955 // Next, we fill out the buffer descriptor:
956 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
957 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
958 if ( eSIR_SUCCESS != nSirStatus )
959 {
960 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700961 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700962 nSirStatus );
963 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
964 ( void* ) pFrame, ( void* ) pPacket );
965 if ( addIE != NULL )
966 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530967 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700968 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530969 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700970 return;
971 }
972
973 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
974
975 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
976
977 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700978 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -0700979 nPayload, &nPayload );
980 if ( DOT11F_FAILED( nStatus ) )
981 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700982 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700983 nStatus );
984 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
985 if ( addIE != NULL )
986 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530987 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700988 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530989 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 return; // allocated!
991 }
992 else if ( DOT11F_WARNED( nStatus ) )
993 {
994 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800995 "robe Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700996 }
997
998 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
999 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1000
1001 pMac->sys.probeRespond++;
1002
Jeff Johnson295189b2012-06-20 16:38:30 -07001003 if( pMac->lim.gpLimRemainOnChanReq )
1004 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301005 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -07001006 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
1007 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001008
1009 if ( addnIEPresent )
1010 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301011 vos_mem_copy(pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], totalAddnIeLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001012 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001013 if (noaLen != 0)
1014 {
Krunal Soni81b24262013-05-15 17:46:41 -07001015 if (total_noaLen > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -07001016 {
1017 limLog(pMac, LOGE,
Kaushik, Sushant96ac9d72013-12-11 19:28:10 +05301018 FL("Not able to insert NoA because of length constraint."
1019 "Total Length is :%d"),total_noaLen);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301020 vos_mem_free(addIE);
1021 vos_mem_free(pFrm);
Krunal Soni81b24262013-05-15 17:46:41 -07001022 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1023 ( void* ) pFrame, ( void* ) pPacket );
1024 return;
1025 }
1026 else
1027 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301028 vos_mem_copy( &pFrame[nBytes - (total_noaLen)],
Krunal Soni81b24262013-05-15 17:46:41 -07001029 &noaIe[0], total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 }
1031 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001032
1033 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1035 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001036 )
1037 {
1038 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1039 }
1040
1041 // Queue Probe Response frame in high priority WQ
1042 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
1043 ( tANI_U16 ) nBytes,
1044 HAL_TXRX_FRM_802_11_MGMT,
1045 ANI_TXDIR_TODS,
1046 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
1047 limTxComplete, pFrame, txFlag );
1048 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1049 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001050 limLog( pMac, LOGE, FL("Could not send Probe Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001051 //Pkt will be freed up by the callback
1052 }
1053
1054 if ( addIE != NULL )
1055 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301056 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001057 }
1058
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301059 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001060 return;
1061
1062
Jeff Johnson295189b2012-06-20 16:38:30 -07001063} // End limSendProbeRspMgmtFrame.
1064
1065void
1066limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
1067 tSirMacAddr peerMacAddr,
1068 tSirAddtsReqInfo *pAddTS,
1069 tpPESession psessionEntry)
1070{
1071 tANI_U16 i;
1072 tANI_U8 *pFrame;
1073 tSirRetStatus nSirStatus;
1074 tDot11fAddTSRequest AddTSReq;
1075 tDot11fWMMAddTSRequest WMMAddTSReq;
1076 tANI_U32 nPayload, nBytes, nStatus;
1077 tpSirMacMgmtHdr pMacHdr;
1078 void *pPacket;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001079#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001080 tANI_U32 phyMode;
1081#endif
1082 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301083 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001084
1085 if(NULL == psessionEntry)
1086 {
1087 return;
1088 }
1089
1090 if ( ! pAddTS->wmeTspecPresent )
1091 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301092 vos_mem_set(( tANI_U8* )&AddTSReq, sizeof( AddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001093
1094 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1095 AddTSReq.DialogToken.token = pAddTS->dialogToken;
1096 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1097 if ( pAddTS->lleTspecPresent )
1098 {
1099 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
1100 }
1101 else
1102 {
1103 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
1104 }
1105
1106 if ( pAddTS->lleTspecPresent )
1107 {
1108 AddTSReq.num_WMMTCLAS = 0;
1109 AddTSReq.num_TCLAS = pAddTS->numTclas;
1110 for ( i = 0; i < pAddTS->numTclas; ++i)
1111 {
1112 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1113 &AddTSReq.TCLAS[i] );
1114 }
1115 }
1116 else
1117 {
1118 AddTSReq.num_TCLAS = 0;
1119 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
1120 for ( i = 0; i < pAddTS->numTclas; ++i)
1121 {
1122 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1123 &AddTSReq.WMMTCLAS[i] );
1124 }
1125 }
1126
1127 if ( pAddTS->tclasProcPresent )
1128 {
1129 if ( pAddTS->lleTspecPresent )
1130 {
1131 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
1132 AddTSReq.TCLASSPROC.present = 1;
1133 }
1134 else
1135 {
1136 AddTSReq.WMMTCLASPROC.version = 1;
1137 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
1138 AddTSReq.WMMTCLASPROC.present = 1;
1139 }
1140 }
1141
1142 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
1143 if ( DOT11F_FAILED( nStatus ) )
1144 {
1145 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001146 "or an Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001147 nStatus );
1148 // We'll fall back on the worst case scenario:
1149 nPayload = sizeof( tDot11fAddTSRequest );
1150 }
1151 else if ( DOT11F_WARNED( nStatus ) )
1152 {
1153 limLog( pMac, LOGW, FL("There were warnings while calculating"
1154 "the packed size for an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001155 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001156 }
1157 }
1158 else
1159 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301160 vos_mem_set(( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001161
1162 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1163 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1164 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1165
1166 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1167 WMMAddTSReq.StatusCode.statusCode = 0;
1168
1169 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001170#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001171 limGetPhyMode(pMac, &phyMode, psessionEntry);
1172
1173 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1174 {
1175 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1176 }
1177 else
1178 {
1179 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1180 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001181 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.ESETrafStrmRateSet,sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07001182#endif
1183 // fillWmeTspecIE
1184
1185 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1186 if ( DOT11F_FAILED( nStatus ) )
1187 {
1188 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001189 "or a WMM Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001190 nStatus );
1191 // We'll fall back on the worst case scenario:
1192 nPayload = sizeof( tDot11fAddTSRequest );
1193 }
1194 else if ( DOT11F_WARNED( nStatus ) )
1195 {
1196 limLog( pMac, LOGW, FL("There were warnings while calculating"
1197 "the packed size for a WMM Add TS Requ"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001198 "est (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001199 }
1200 }
1201
1202 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1203
1204 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1205 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1206 ( void** ) &pPacket );
1207 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1208 {
1209 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001210 "d TS Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001211 return;
1212 }
1213
1214 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301215 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001216
1217 // Next, we fill out the buffer descriptor:
1218 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1219 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1220 if ( eSIR_SUCCESS != nSirStatus )
1221 {
1222 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001223 "tor for an Add TS Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001224 nSirStatus );
1225 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1226 ( void* ) pFrame, ( void* ) pPacket );
1227 return;
1228 }
1229
1230 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1231
1232 #if 0
1233 cfgLen = SIR_MAC_ADDR_LENGTH;
1234 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1235 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1236 {
1237 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001238 "e sending an Add TS Request.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001239 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1240 ( void* ) pFrame, ( void* ) pPacket );
1241 return;
1242 }
1243 #endif //TO SUPPORT BT-AMP
1244
1245 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1246
Chet Lanctot186b5732013-03-18 10:26:30 -07001247#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001248 limSetProtectedBit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001249#endif
1250
Jeff Johnson295189b2012-06-20 16:38:30 -07001251 // That done, pack the struct:
1252 if ( ! pAddTS->wmeTspecPresent )
1253 {
1254 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1255 pFrame + sizeof(tSirMacMgmtHdr),
1256 nPayload, &nPayload );
1257 if ( DOT11F_FAILED( nStatus ) )
1258 {
1259 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001260 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001261 nStatus );
1262 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1263 return; // allocated!
1264 }
1265 else if ( DOT11F_WARNED( nStatus ) )
1266 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001267 limLog( pMac, LOGW, FL("There were warnings while packing "
1268 "an Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001269 }
1270 }
1271 else
1272 {
1273 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1274 pFrame + sizeof(tSirMacMgmtHdr),
1275 nPayload, &nPayload );
1276 if ( DOT11F_FAILED( nStatus ) )
1277 {
1278 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001279 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001280 nStatus );
1281 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1282 return; // allocated!
1283 }
1284 else if ( DOT11F_WARNED( nStatus ) )
1285 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001286 limLog( pMac, LOGW, FL("There were warnings while packing "
1287 "a WMM Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001288 }
1289 }
1290
1291 PELOG3(limLog( pMac, LOG3, FL("Sending an Add TS Request frame to ") );
1292 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1293
1294 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001295 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1296 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001297 )
1298 {
1299 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1300 }
1301
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301302 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1303 psessionEntry->peSessionId,
1304 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001305 // Queue Addts Response frame in high priority WQ
1306 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1307 HAL_TXRX_FRM_802_11_MGMT,
1308 ANI_TXDIR_TODS,
1309 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1310 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301311 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1312 psessionEntry->peSessionId,
1313 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001314 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1315 {
1316 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001317 " (%X) ***" ), halstatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001318 //Pkt will be freed up by the callback
1319 }
1320
1321} // End limSendAddtsReqActionFrame.
1322
Jeff Johnson295189b2012-06-20 16:38:30 -07001323
1324
1325void
1326limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1327 tANI_U16 statusCode,
1328 tANI_U16 aid,
1329 tSirMacAddr peerMacAddr,
1330 tANI_U8 subType,
1331 tpDphHashNode pSta,tpPESession psessionEntry)
1332{
1333 static tDot11fAssocResponse frm;
1334 tANI_U8 *pFrame, *macAddr;
1335 tpSirMacMgmtHdr pMacHdr;
1336 tSirRetStatus nSirStatus;
1337 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1338 tHalBitVal qosMode, wmeMode;
c_hpothubcd78652014-04-28 22:31:08 +05301339 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001340 void *pPacket;
1341 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301342 tUpdateBeaconParams beaconParams;
1343 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001344 tANI_U32 addnIEPresent = false;
1345 tANI_U32 addnIELen=0;
1346 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1347 tpSirAssocReq pAssocReq = NULL;
Kalikinkar dhara205da782014-03-21 15:49:32 -07001348 tANI_U16 addStripoffIELen = 0;
1349 tDot11fIEExtCap extractedExtCap;
1350 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_FALSE;
c_hpothubcd78652014-04-28 22:31:08 +05301351 tANI_U32 nBytes = 0;
Kalikinkar dhara205da782014-03-21 15:49:32 -07001352
Chet Lanctot8cecea22014-02-11 19:09:36 -08001353#ifdef WLAN_FEATURE_11W
1354 tANI_U32 retryInterval;
1355 tANI_U32 maxRetries;
1356#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001357
1358 if(NULL == psessionEntry)
1359 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301360 limLog( pMac, LOGE, FL("psessionEntry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001361 return;
1362 }
1363
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301364 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001365
1366 limGetQosMode(psessionEntry, &qosMode);
1367 limGetWmeMode(psessionEntry, &wmeMode);
1368
1369 // An Add TS IE is added only if the AP supports it and the requesting
1370 // STA sent a traffic spec.
1371 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1372
1373 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1374
1375 frm.Status.status = statusCode;
1376
1377 frm.AID.associd = aid | LIM_AID_MASK;
1378
1379 if ( NULL == pSta )
1380 {
1381 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1382 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1383 }
1384 else
1385 {
1386 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1387 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1388 }
1389
Jeff Johnson295189b2012-06-20 16:38:30 -07001390 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1391 {
1392 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1393 {
1394 pAssocReq =
1395 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001396 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1397 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1398 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1399 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001400 }
1401 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001402
1403 if ( NULL != pSta )
1404 {
1405 if ( eHAL_SET == qosMode )
1406 {
1407 if ( pSta->lleEnabled )
1408 {
1409 lleMode = 1;
1410 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1411 {
1412 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1413
1414// FramesToDo:...
1415// if ( fAddTS )
1416// {
1417// tANI_U8 *pAf = pBody;
1418// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1419// tANI_U32 tlen;
1420// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1421// &tlen, bufLen - frameLen);
1422// } // End if on Add TS.
1423 }
1424 } // End if on .11e enabled in 'pSta'.
1425 } // End if on QOS Mode on.
1426
1427 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1428 {
1429 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1430 {
1431
Jeff Johnson295189b2012-06-20 16:38:30 -07001432 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001433
1434 if ( pSta->wsmEnabled )
1435 {
1436 PopulateDot11fWMMCaps(&frm.WMMCaps );
1437 }
1438 }
1439 }
1440
1441 if ( pSta->aniPeer )
1442 {
1443 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1444 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1445 {
1446 edcaInclude = 1;
1447 }
1448
1449 } // End if on Airgo peer.
1450
1451 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001452 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001453 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001454 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07001455 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001456 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001457
1458#ifdef WLAN_FEATURE_11AC
1459 if( pSta->mlmStaContext.vhtCapability &&
1460 psessionEntry->vhtCapability )
1461 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08001462 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Response"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001463 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
1464 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation);
Sandeep Puligilla60342762014-01-30 21:05:37 +05301465 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001466 }
1467#endif
1468
Chet Lanctot8cecea22014-02-11 19:09:36 -08001469#ifdef WLAN_FEATURE_11W
Dino Myclea7f18452014-04-24 08:55:31 +05301470 if( eSIR_MAC_TRY_AGAIN_LATER == statusCode )
1471 {
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001472 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_MAX_RETRIES,
1473 &maxRetries ) != eSIR_SUCCESS )
1474 limLog( pMac, LOGE,
1475 FL("Could not retrieve PMF SA Query maximum retries value") );
1476 else
1477 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL,
1478 &retryInterval ) != eSIR_SUCCESS)
1479 limLog( pMac, LOGE,
1480 FL("Could not retrieve PMF SA Query timer interval value") );
Dino Myclea7f18452014-04-24 08:55:31 +05301481 else
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001482 PopulateDot11fTimeoutInterval(
1483 pMac, &frm.TimeoutInterval, SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1484 (maxRetries - pSta->pmfSaQueryRetryCount) * retryInterval );
Dino Myclea7f18452014-04-24 08:55:31 +05301485 }
Chet Lanctot8cecea22014-02-11 19:09:36 -08001486#endif
Dino Myclea7f18452014-04-24 08:55:31 +05301487 } // End if on non-NULL 'pSta'.
Jeff Johnson295189b2012-06-20 16:38:30 -07001488
Chet Lanctot8cecea22014-02-11 19:09:36 -08001489 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001490
Jeff Johnson295189b2012-06-20 16:38:30 -07001491 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1492 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1493 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1494 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001495
1496 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1497 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1498
1499 beaconParams.bssIdx = psessionEntry->bssIdx;
1500
1501 //Send message to HAL about beacon parameter change.
1502 if(beaconParams.paramChangeBitmap)
1503 {
1504 schSetFixedBeaconFields(pMac,psessionEntry);
1505 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1506 }
1507
Jeff Johnson295189b2012-06-20 16:38:30 -07001508 if ( pAssocReq != NULL )
1509 {
1510 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1511 &addnIEPresent) != eSIR_SUCCESS)
1512 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301513 limLog(pMac, LOGP, FL("Unable to get "
1514 "WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001515 return;
1516 }
1517
1518 if (addnIEPresent)
1519 {
1520 //Assoc rsp IE available
1521 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1522 &addnIELen) != eSIR_SUCCESS)
1523 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301524 limLog(pMac, LOGP, FL("Unable to get "
1525 "WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001526 return;
1527 }
1528
1529 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1530 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1531 {
1532 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1533 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1534 {
Kalikinkar dhara205da782014-03-21 15:49:32 -07001535
1536 vos_mem_set(( tANI_U8* )&extractedExtCap,
1537 sizeof( tDot11fIEExtCap ), 0);
1538 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
1539 &addIE[0],
1540 &addStripoffIELen,
1541 &extractedExtCap );
1542 if(eSIR_SUCCESS != nSirStatus)
1543 {
1544 limLog(pMac, LOG1,
1545 FL("Unable to Stripoff ExtCap IE from Assoc Rsp"));
1546 }
1547 else
1548 {
1549 addnIELen = addStripoffIELen;
1550 extractedExtCapFlag = eANI_BOOLEAN_TRUE;
1551 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001552 nBytes = nBytes + addnIELen;
1553 }
1554 }
1555 }
1556 }
1557
c_hpothubcd78652014-04-28 22:31:08 +05301558 /* merge the ExtCap struct*/
1559 if (extractedExtCapFlag && extractedExtCap.present)
1560 {
1561 limMergeExtCapIEStruct(&(frm.ExtCap), &extractedExtCap);
1562 }
1563
1564 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1565 if ( DOT11F_FAILED( nStatus ) )
1566 {
1567 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
1568 "or an Association Response (0x%08x)."),
1569 nStatus );
1570 return;
1571 }
1572 else if ( DOT11F_WARNED( nStatus ) )
1573 {
1574 limLog( pMac, LOGW, FL("There were warnings while calculating "
1575 "the packed size for an Association Re"
1576 "sponse (0x%08x)."), nStatus );
1577 }
1578
1579 nBytes += sizeof( tSirMacMgmtHdr ) + nPayload;
1580
Jeff Johnson295189b2012-06-20 16:38:30 -07001581 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1582 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1583 ( void** ) &pPacket );
1584 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1585 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001586 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001587 return;
1588 }
1589
1590 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301591 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001592
1593 // Next, we fill out the buffer descriptor:
1594 nSirStatus = limPopulateMacHeader( pMac,
1595 pFrame,
1596 SIR_MAC_MGMT_FRAME,
1597 ( LIM_ASSOC == subType ) ?
1598 SIR_MAC_MGMT_ASSOC_RSP :
1599 SIR_MAC_MGMT_REASSOC_RSP,
1600 peerMacAddr,psessionEntry->selfMacAddr);
1601 if ( eSIR_SUCCESS != nSirStatus )
1602 {
1603 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001604 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001605 nSirStatus );
1606 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1607 ( void* ) pFrame, ( void* ) pPacket );
1608 return;
1609 }
1610
1611 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1612
Jeff Johnson295189b2012-06-20 16:38:30 -07001613 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1614
1615 nStatus = dot11fPackAssocResponse( pMac, &frm,
1616 pFrame + sizeof( tSirMacMgmtHdr ),
1617 nPayload, &nPayload );
1618 if ( DOT11F_FAILED( nStatus ) )
1619 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301620 limLog( pMac, LOGE, FL("Failed to pack an Association Response"
1621 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001622 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1623 ( void* ) pFrame, ( void* ) pPacket );
1624 return; // allocated!
1625 }
1626 else if ( DOT11F_WARNED( nStatus ) )
1627 {
1628 limLog( pMac, LOGW, FL("There were warnings while packing an "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001629 "Association Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001630 }
1631
1632 macAddr = pMacHdr->da;
1633
1634 if (subType == LIM_ASSOC)
1635 {
1636 PELOG1(limLog(pMac, LOG1,
1637 FL("*** Sending Assoc Resp status %d aid %d to "),
1638 statusCode, aid);)
1639 }
1640 else{
1641 PELOG1(limLog(pMac, LOG1,
1642 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1643 statusCode, aid);)
1644 }
1645 PELOG1(limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1646
1647 if ( addnIEPresent )
1648 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301649 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001650 }
1651
1652 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001653 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1654 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001655 )
1656 {
1657 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1658 }
1659
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05301660 limLog( pMac, LOG1, FL("Sending Assoc resp over WQ5 to "MAC_ADDRESS_STR
1661 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
1662 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
1663
1664 txFlag |= HAL_USE_FW_IN_TX_PATH;
1665
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301666 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1667 psessionEntry->peSessionId,
1668 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001669 /// Queue Association Response frame in high priority WQ
1670 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1671 HAL_TXRX_FRM_802_11_MGMT,
1672 ANI_TXDIR_TODS,
1673 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1674 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301675 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1676 psessionEntry->peSessionId,
1677 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001678 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1679 {
1680 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001681 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001682 nSirStatus);
1683
1684 //Pkt will be freed up by the callback
1685 }
1686
1687 // update the ANI peer station count
1688 //FIXME_PROTECTION : take care of different type of station
1689 // counter inside this function.
1690 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1691
1692} // End limSendAssocRspMgmtFrame.
1693
1694
1695
1696void
1697limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1698 tSirMacAddr peer,
1699 tANI_U16 nStatusCode,
1700 tSirAddtsReqInfo *pAddTS,
1701 tSirMacScheduleIE *pSchedule,
1702 tpPESession psessionEntry)
1703{
1704 tANI_U8 *pFrame;
1705 tpSirMacMgmtHdr pMacHdr;
1706 tDot11fAddTSResponse AddTSRsp;
1707 tDot11fWMMAddTSResponse WMMAddTSRsp;
1708 tSirRetStatus nSirStatus;
1709 tANI_U32 i, nBytes, nPayload, nStatus;
1710 void *pPacket;
1711 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301712 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001713
1714 if(NULL == psessionEntry)
1715 {
1716 return;
1717 }
1718
1719 if ( ! pAddTS->wmeTspecPresent )
1720 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301721 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001722
1723 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1724 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1725 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1726 AddTSRsp.Status.status = nStatusCode;
1727
1728 // The TsDelay information element is only filled in for a specific
1729 // status code:
1730 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1731 {
1732 if ( pAddTS->wsmTspecPresent )
1733 {
1734 AddTSRsp.WMMTSDelay.version = 1;
1735 AddTSRsp.WMMTSDelay.delay = 10;
1736 AddTSRsp.WMMTSDelay.present = 1;
1737 }
1738 else
1739 {
1740 AddTSRsp.TSDelay.delay = 10;
1741 AddTSRsp.TSDelay.present = 1;
1742 }
1743 }
1744
1745 if ( pAddTS->wsmTspecPresent )
1746 {
1747 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1748 }
1749 else
1750 {
1751 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1752 }
1753
1754 if ( pAddTS->wsmTspecPresent )
1755 {
1756 AddTSRsp.num_WMMTCLAS = 0;
1757 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1758 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1759 {
1760 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1761 &AddTSRsp.TCLAS[i] );
1762 }
1763 }
1764 else
1765 {
1766 AddTSRsp.num_TCLAS = 0;
1767 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1768 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1769 {
1770 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1771 &AddTSRsp.WMMTCLAS[i] );
1772 }
1773 }
1774
1775 if ( pAddTS->tclasProcPresent )
1776 {
1777 if ( pAddTS->wsmTspecPresent )
1778 {
1779 AddTSRsp.WMMTCLASPROC.version = 1;
1780 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1781 AddTSRsp.WMMTCLASPROC.present = 1;
1782 }
1783 else
1784 {
1785 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1786 AddTSRsp.TCLASSPROC.present = 1;
1787 }
1788 }
1789
1790 // schedule element is included only if requested in the tspec and we are
1791 // using hcca (or both edca and hcca)
1792 // 11e-D8.0 is inconsistent on whether the schedule element is included
1793 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1794 // pg 46, line 17-18 says something else. So just include it and let the
1795 // sta figure it out
1796 if ((pSchedule != NULL) &&
1797 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1798 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1799 {
1800 if ( pAddTS->wsmTspecPresent )
1801 {
1802 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1803 }
1804 else
1805 {
1806 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1807 }
1808 }
1809
1810 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1811 if ( DOT11F_FAILED( nStatus ) )
1812 {
1813 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001814 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001815 nStatus );
1816 // We'll fall back on the worst case scenario:
1817 nPayload = sizeof( tDot11fAddTSResponse );
1818 }
1819 else if ( DOT11F_WARNED( nStatus ) )
1820 {
1821 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001822 "ting the packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001823 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001824 }
1825 }
1826 else
1827 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301828 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001829
1830 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1831 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1832 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1833 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1834
1835 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1836
1837 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1838 if ( DOT11F_FAILED( nStatus ) )
1839 {
1840 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001841 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001842 nStatus );
1843 // We'll fall back on the worst case scenario:
1844 nPayload = sizeof( tDot11fWMMAddTSResponse );
1845 }
1846 else if ( DOT11F_WARNED( nStatus ) )
1847 {
1848 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001849 "ting the packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001850 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001851 }
1852 }
1853
1854 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1855
1856 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1857 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1858 {
1859 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001860 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001861 return;
1862 }
1863
1864 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301865 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001866
1867 // Next, we fill out the buffer descriptor:
1868 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1869 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1870 if ( eSIR_SUCCESS != nSirStatus )
1871 {
1872 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001873 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001874 nSirStatus );
1875 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1876 return; // allocated!
1877 }
1878
1879 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1880
1881
1882 #if 0
1883 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1884 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1885 {
1886 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001887 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001888 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1889 return; // allocated!
1890 }
1891 #endif //TO SUPPORT BT-AMP
1892 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1893
Chet Lanctot186b5732013-03-18 10:26:30 -07001894#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001895 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001896#endif
1897
Jeff Johnson295189b2012-06-20 16:38:30 -07001898 // That done, pack the struct:
1899 if ( ! pAddTS->wmeTspecPresent )
1900 {
1901 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1902 pFrame + sizeof( tSirMacMgmtHdr ),
1903 nPayload, &nPayload );
1904 if ( DOT11F_FAILED( nStatus ) )
1905 {
1906 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001907 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001908 nStatus );
1909 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1910 return;
1911 }
1912 else if ( DOT11F_WARNED( nStatus ) )
1913 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001914 limLog( pMac, LOGW, FL("There were warnings while packing "
1915 "an Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001916 }
1917 }
1918 else
1919 {
1920 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
1921 pFrame + sizeof( tSirMacMgmtHdr ),
1922 nPayload, &nPayload );
1923 if ( DOT11F_FAILED( nStatus ) )
1924 {
1925 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001926 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001927 nStatus );
1928 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1929 return;
1930 }
1931 else if ( DOT11F_WARNED( nStatus ) )
1932 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001933 limLog( pMac, LOGW, FL("There were warnings while packing "
1934 "a WMM Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001935 }
1936 }
1937
1938 PELOG1(limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
1939 nStatusCode );
1940 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
1941
1942 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001943 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1944 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001945 )
1946 {
1947 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1948 }
1949
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301950 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1951 psessionEntry->peSessionId,
1952 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001953 // Queue the frame in high priority WQ:
1954 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1955 HAL_TXRX_FRM_802_11_MGMT,
1956 ANI_TXDIR_TODS,
1957 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1958 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301959 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1960 psessionEntry->peSessionId,
1961 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001962 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1963 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001964 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001965 nSirStatus );
1966 //Pkt will be freed up by the callback
1967 }
1968
1969} // End limSendAddtsRspActionFrame.
1970
1971void
1972limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
1973 tSirMacAddr peer,
1974 tANI_U8 wmmTspecPresent,
1975 tSirMacTSInfo *pTsinfo,
1976 tSirMacTspecIE *pTspecIe,
1977 tpPESession psessionEntry)
1978{
1979 tANI_U8 *pFrame;
1980 tpSirMacMgmtHdr pMacHdr;
1981 tDot11fDelTS DelTS;
1982 tDot11fWMMDelTS WMMDelTS;
1983 tSirRetStatus nSirStatus;
1984 tANI_U32 nBytes, nPayload, nStatus;
1985 void *pPacket;
1986 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301987 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001988
1989 if(NULL == psessionEntry)
1990 {
1991 return;
1992 }
1993
1994 if ( ! wmmTspecPresent )
1995 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301996 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001997
1998 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1999 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2000 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
2001
2002 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
2003 if ( DOT11F_FAILED( nStatus ) )
2004 {
2005 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002006 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002007 nStatus );
2008 // We'll fall back on the worst case scenario:
2009 nPayload = sizeof( tDot11fDelTS );
2010 }
2011 else if ( DOT11F_WARNED( nStatus ) )
2012 {
2013 limLog( pMac, LOGW, FL("There were warnings while calcula"
2014 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002015 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002016 }
2017 }
2018 else
2019 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302020 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002021
2022 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
2023 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2024 WMMDelTS.DialogToken.token = 0;
2025 WMMDelTS.StatusCode.statusCode = 0;
2026 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
2027 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
2028 if ( DOT11F_FAILED( nStatus ) )
2029 {
2030 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002031 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002032 nStatus );
2033 // We'll fall back on the worst case scenario:
2034 nPayload = sizeof( tDot11fDelTS );
2035 }
2036 else if ( DOT11F_WARNED( nStatus ) )
2037 {
2038 limLog( pMac, LOGW, FL("There were warnings while calcula"
2039 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002040 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002041 }
2042 }
2043
2044 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
2045
2046 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
2047 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2048 {
2049 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002050 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002051 return;
2052 }
2053
2054 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302055 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002056
2057 // Next, we fill out the buffer descriptor:
2058 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2059 SIR_MAC_MGMT_ACTION, peer,
2060 psessionEntry->selfMacAddr);
2061 if ( eSIR_SUCCESS != nSirStatus )
2062 {
2063 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002064 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002065 nSirStatus );
2066 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2067 return; // allocated!
2068 }
2069
2070 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
2071
2072 #if 0
2073
2074 cfgLen = SIR_MAC_ADDR_LENGTH;
2075 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
2076 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
2077 {
2078 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002079 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002080 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2081 return; // allocated!
2082 }
2083 #endif //TO SUPPORT BT-AMP
2084 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
2085
Chet Lanctot186b5732013-03-18 10:26:30 -07002086#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002087 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07002088#endif
2089
Jeff Johnson295189b2012-06-20 16:38:30 -07002090 // That done, pack the struct:
2091 if ( !wmmTspecPresent )
2092 {
2093 nStatus = dot11fPackDelTS( pMac, &DelTS,
2094 pFrame + sizeof( tSirMacMgmtHdr ),
2095 nPayload, &nPayload );
2096 if ( DOT11F_FAILED( nStatus ) )
2097 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002098 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002099 nStatus );
2100 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2101 return; // allocated!
2102 }
2103 else if ( DOT11F_WARNED( nStatus ) )
2104 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002105 limLog( pMac, LOGW, FL("There were warnings while packing "
2106 "a Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002107 }
2108 }
2109 else
2110 {
2111 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
2112 pFrame + sizeof( tSirMacMgmtHdr ),
2113 nPayload, &nPayload );
2114 if ( DOT11F_FAILED( nStatus ) )
2115 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002116 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002117 nStatus );
2118 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2119 return; // allocated!
2120 }
2121 else if ( DOT11F_WARNED( nStatus ) )
2122 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002123 limLog( pMac, LOGW, FL("There were warnings while packing "
2124 "a WMM Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002125 }
2126 }
2127
2128 PELOG1(limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
2129 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
2130
2131 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002132 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2133 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002134 )
2135 {
2136 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2137 }
2138
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302139 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2140 psessionEntry->peSessionId,
2141 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002142 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2143 HAL_TXRX_FRM_802_11_MGMT,
2144 ANI_TXDIR_TODS,
2145 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2146 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302147 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2148 psessionEntry->peSessionId,
2149 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002150 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2151 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002152 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002153 nSirStatus );
2154 //Pkt will be freed up by the callback
2155 }
2156
2157} // End limSendDeltsReqActionFrame.
2158
2159void
2160limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
2161 tLimMlmAssocReq *pMlmAssocReq,
2162 tpPESession psessionEntry)
2163{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002164 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07002165 tANI_U16 caps;
2166 tANI_U8 *pFrame;
2167 tSirRetStatus nSirStatus;
2168 tLimMlmAssocCnf mlmAssocCnf;
c_hpothubcd78652014-04-28 22:31:08 +05302169 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07002170 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2171 void *pPacket;
2172 eHalStatus halstatus;
2173 tANI_U16 nAddIELen;
2174 tANI_U8 *pAddIE;
2175 tANI_U8 *wpsIe = NULL;
2176#if defined WLAN_FEATURE_VOWIFI
2177 tANI_U8 PowerCapsPopulated = FALSE;
2178#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302179 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302180 tpSirMacMgmtHdr pMacHdr;
Kalikinkar dhara205da782014-03-21 15:49:32 -07002181 tDot11fIEExtCap extractedExtCap;
2182 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +05302183 tANI_U32 nBytes = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002184
2185 if(NULL == psessionEntry)
2186 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302187 limLog(pMac, LOGE, FL("psessionEntry is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002188 return;
2189 }
2190
Jeff Johnson295189b2012-06-20 16:38:30 -07002191 /* check this early to avoid unncessary operation */
2192 if(NULL == psessionEntry->pLimJoinReq)
2193 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302194 limLog(pMac, LOGE, FL("psessionEntry->pLimJoinReq is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002195 return;
2196 }
2197 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
2198 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
2199
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302200 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
2201 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002202 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302203 limLog(pMac, LOGE, FL("Unable to allocate memory") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002204 return;
2205 }
2206
2207
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302208 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002209
Kalikinkar dhara205da782014-03-21 15:49:32 -07002210 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
2211 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac, pAddIE,
2212 &nAddIELen,
2213 &extractedExtCap );
2214 if(eSIR_SUCCESS != nSirStatus )
2215 {
2216 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
2217 limLog(pMac, LOG1,
2218 FL("Unable to Stripoff ExtCap IE from Assoc Req"));
2219 }
Leela Venkata Kiran Kumar Reddy Chirala2f9b5712014-05-06 00:09:42 -07002220 /* TODO:remove this code once driver provides the call back function
2221 * to supplicant for set_qos_map
2222 */
2223 else
2224 {
2225 if(extractedExtCap.interworkingService)
2226 {
2227 extractedExtCap.qosMap = 1;
2228 }
2229 }
Kalikinkar dhara205da782014-03-21 15:49:32 -07002230
Jeff Johnson295189b2012-06-20 16:38:30 -07002231 caps = pMlmAssocReq->capabilityInfo;
2232 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2233 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2234#if defined(FEATURE_WLAN_WAPI)
2235 /* CR: 262463 :
2236 According to WAPI standard:
2237 7.3.1.4 Capability Information field
2238 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2239 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2240 Reassociation management frames. */
2241 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2242 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2243#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002244 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002245
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002246 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2247 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002248 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002249 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002250
2251 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2252 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2253
2254 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2255 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2256
2257 // We prefer .11e asociations:
2258 if ( fQosEnabled ) fWmeEnabled = false;
2259
2260 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2261 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2262
2263 if ( psessionEntry->lim11hEnable &&
2264 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2265 {
2266#if defined WLAN_FEATURE_VOWIFI
2267 PowerCapsPopulated = TRUE;
2268
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002269 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002270#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002271 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002272
2273 }
2274
2275#if defined WLAN_FEATURE_VOWIFI
2276 if( pMac->rrm.rrmPEContext.rrmEnable &&
2277 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2278 {
2279 if (PowerCapsPopulated == FALSE)
2280 {
2281 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002282 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002283 }
2284 }
2285#endif
2286
2287 if ( fQosEnabled &&
2288 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002289 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002290
2291 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002292 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002293
2294#if defined WLAN_FEATURE_VOWIFI
2295 if( pMac->rrm.rrmPEContext.rrmEnable &&
2296 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2297 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002298 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002299 }
2300#endif
2301 // The join request *should* contain zero or one of the WPA and RSN
2302 // IEs. The payload send along with the request is a
2303 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2304
2305 // typedef struct sSirRSNie
2306 // {
2307 // tANI_U16 length;
2308 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2309 // } tSirRSNie, *tpSirRSNie;
2310
2311 // So, we should be able to make the following two calls harmlessly,
2312 // since they do nothing if they don't find the given IE in the
2313 // bytestream with which they're provided.
2314
2315 // The net effect of this will be to faithfully transmit whatever
2316 // security IE is in the join request.
2317
2318 // *However*, if we're associating for the purpose of WPS
2319 // enrollment, and we've been configured to indicate that by
2320 // eliding the WPA or RSN IE, we just skip this:
2321 if( nAddIELen && pAddIE )
2322 {
2323 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2324 }
2325 if ( NULL == wpsIe )
2326 {
2327 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002328 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002329 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002330 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002331#if defined(FEATURE_WLAN_WAPI)
2332 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002333 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002334#endif // defined(FEATURE_WLAN_WAPI)
2335 }
2336
2337 // include WME EDCA IE as well
2338 if ( fWmeEnabled )
2339 {
2340 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2341 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002342 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002343 }
2344
2345 if ( fWsmEnabled &&
2346 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2347 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002348 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002349 }
2350 }
2351
2352 //Populate HT IEs, when operating in 11n or Taurus modes AND
2353 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002354 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002355 pMac->lim.htCapabilityPresentInBeacon)
2356 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002357 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002358#ifdef DISABLE_GF_FOR_INTEROP
2359
2360 /*
2361 * To resolve the interop problem with Broadcom AP,
2362 * where TQ STA could not pass traffic with GF enabled,
2363 * TQ STA will do Greenfield only with TQ AP, for
2364 * everybody else it will be turned off.
2365 */
2366
2367 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2368 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302369 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP,"
2370 " Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002371 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002372 }
2373#endif
2374
2375 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002376#ifdef WLAN_FEATURE_11AC
2377 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002378 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002379 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002380 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002381 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
Jeff Johnsone7245742012-09-05 17:12:55 -07002382 }
2383#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302384 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002385
2386#if defined WLAN_FEATURE_VOWIFI_11R
2387 if (psessionEntry->pLimJoinReq->is11Rconnection)
2388 {
2389#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002390 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002391 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2392 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2393 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2394#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302395 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2396 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002397 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302398 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002399 {
2400 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302401 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002402 }
2403#endif
2404
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002405#ifdef FEATURE_WLAN_ESE
2406 /* For ESE Associations fill the ESE IEs */
2407 if (psessionEntry->isESEconnection &&
2408 psessionEntry->pLimJoinReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002409 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002410#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002411 PopulateDot11fESERadMgmtCap(&pFrm->ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002412#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002413 PopulateDot11fESEVersion(&pFrm->ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002414 }
2415#endif
2416
c_hpothubcd78652014-04-28 22:31:08 +05302417 /* merge the ExtCap struct*/
2418 if (extractedExtCapFlag && extractedExtCap.present)
2419 {
2420 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
2421 }
2422
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002423 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002424 if ( DOT11F_FAILED( nStatus ) )
2425 {
2426 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002427 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002428 nStatus );
2429 // We'll fall back on the worst case scenario:
2430 nPayload = sizeof( tDot11fAssocRequest );
2431 }
2432 else if ( DOT11F_WARNED( nStatus ) )
2433 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002434 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002435 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002436 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002437 }
2438
2439 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2440
2441 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2442 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2443 ( void** ) &pPacket );
2444 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2445 {
2446 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002447 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002448
2449 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002450 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002451
2452
2453 /* Update PE session id*/
2454 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2455
2456 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2457
2458 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2459 ( void* ) pFrame, ( void* ) pPacket );
2460
2461 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2462 ( tANI_U32* ) &mlmAssocCnf);
2463
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302464 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002465 return;
2466 }
2467
2468 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302469 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002470
2471 // Next, we fill out the buffer descriptor:
2472 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2473 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2474 if ( eSIR_SUCCESS != nSirStatus )
2475 {
2476 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002477 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002478 nSirStatus );
2479 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302480 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002481 return;
2482 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002483
Abhishek Singh57aebef2014-02-03 18:47:44 +05302484 // That done, pack the Assoc Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002485 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002486 sizeof(tSirMacMgmtHdr),
2487 nPayload, &nPayload );
2488 if ( DOT11F_FAILED( nStatus ) )
2489 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302490 limLog( pMac, LOGE, FL("Failed to pack a Assoc Request (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002491 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002492 nStatus );
2493 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2494 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302495 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002496 return;
2497 }
2498 else if ( DOT11F_WARNED( nStatus ) )
2499 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302500 limLog( pMac, LOGW, FL("There were warnings while packing a Assoc"
2501 "Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002502 }
2503
2504 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002505 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002506 nBytes );)
2507 // limPrintMacAddr( pMac, bssid, LOG1 );
2508
2509 if( psessionEntry->assocReq != NULL )
2510 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302511 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002512 psessionEntry->assocReq = NULL;
2513 }
2514
2515 if( nAddIELen )
2516 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302517 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2518 pAddIE,
2519 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002520 nPayload += nAddIELen;
2521 }
2522
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302523 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2524 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002525 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302526 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store "
2527 "assoc request"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002528 }
2529 else
2530 {
2531 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302532 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002533 psessionEntry->assocReqLen = nPayload;
2534 }
2535
2536 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002537 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2538 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002539 )
2540 {
2541 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2542 }
2543
Ganesh K08bce952012-12-13 15:04:41 -08002544 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2545 {
2546 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2547 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302548
2549 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05302550 limLog( pMac, LOG1, FL("Sending Assoc req over WQ5 to "MAC_ADDRESS_STR
2551 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
2552 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2553 txFlag |= HAL_USE_FW_IN_TX_PATH;
2554
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302555 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2556 psessionEntry->peSessionId,
2557 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05302558
2559 // enable caching
2560 WLANTL_EnableCaching(psessionEntry->staId);
2561
Jeff Johnson295189b2012-06-20 16:38:30 -07002562 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2563 HAL_TXRX_FRM_802_11_MGMT,
2564 ANI_TXDIR_TODS,
2565 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2566 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302567 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2568 psessionEntry->peSessionId,
2569 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002570 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2571 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002572 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002573 halstatus );
2574 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302575 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002576 return;
2577 }
2578
2579 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302580 vos_mem_free(pMlmAssocReq);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002581 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302582 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002583 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002584} // End limSendAssocReqMgmtFrame
2585
2586
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002587#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002588/*------------------------------------------------------------------------------------
2589 *
2590 * Send Reassoc Req with FTIEs.
2591 *
2592 *-----------------------------------------------------------------------------------
2593 */
2594void
2595limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2596 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2597{
2598 static tDot11fReAssocRequest frm;
2599 tANI_U16 caps;
2600 tANI_U8 *pFrame;
2601 tSirRetStatus nSirStatus;
2602 tANI_U32 nBytes, nPayload, nStatus;
2603 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2604 void *pPacket;
2605 eHalStatus halstatus;
2606#if defined WLAN_FEATURE_VOWIFI
2607 tANI_U8 PowerCapsPopulated = FALSE;
2608#endif
2609 tANI_U16 ft_ies_length = 0;
2610 tANI_U8 *pBody;
2611 tANI_U16 nAddIELen;
2612 tANI_U8 *pAddIE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002613#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 tANI_U8 *wpsIe = NULL;
2615#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302616 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302617 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002618
2619 if (NULL == psessionEntry)
2620 {
2621 return;
2622 }
2623
Jeff Johnson295189b2012-06-20 16:38:30 -07002624 /* check this early to avoid unncessary operation */
2625 if(NULL == psessionEntry->pLimReAssocReq)
2626 {
2627 return;
2628 }
2629 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2630 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002631 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2632 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002633
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302634 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002635
2636 caps = pMlmReassocReq->capabilityInfo;
2637 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2638 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2639#if defined(FEATURE_WLAN_WAPI)
2640 /* CR: 262463 :
2641 According to WAPI standard:
2642 7.3.1.4 Capability Information field
2643 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2644 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2645 Reassociation management frames. */
2646 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2647 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2648#endif
2649 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2650
2651 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2652
2653 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302654 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002655 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2656
2657 PopulateDot11fSSID2( pMac, &frm.SSID );
2658 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2659 &frm.SuppRates,psessionEntry);
2660
2661 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2662 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2663
2664 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2665 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2666
2667 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2668 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2669
2670 if ( psessionEntry->lim11hEnable &&
2671 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2672 {
2673#if defined WLAN_FEATURE_VOWIFI
2674 PowerCapsPopulated = TRUE;
2675
2676 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2677 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2678#endif
2679 }
2680
2681#if defined WLAN_FEATURE_VOWIFI
2682 if( pMac->rrm.rrmPEContext.rrmEnable &&
2683 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2684 {
2685 if (PowerCapsPopulated == FALSE)
2686 {
2687 PowerCapsPopulated = TRUE;
2688 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2689 }
2690 }
2691#endif
2692
2693 if ( fQosEnabled &&
2694 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2695 {
2696 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2697 }
2698
2699 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2700 &frm.ExtSuppRates, psessionEntry );
2701
2702#if defined WLAN_FEATURE_VOWIFI
2703 if( pMac->rrm.rrmPEContext.rrmEnable &&
2704 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2705 {
2706 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2707 }
2708#endif
2709
2710 // Ideally this should be enabled for 11r also. But 11r does
2711 // not follow the usual norm of using the Opaque object
2712 // for rsnie and fties. Instead we just add
2713 // the rsnie and fties at the end of the pack routine for 11r.
2714 // This should ideally! be fixed.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002715#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002716 //
2717 // The join request *should* contain zero or one of the WPA and RSN
2718 // IEs. The payload send along with the request is a
2719 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2720
2721 // typedef struct sSirRSNie
2722 // {
2723 // tANI_U16 length;
2724 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2725 // } tSirRSNie, *tpSirRSNie;
2726
2727 // So, we should be able to make the following two calls harmlessly,
2728 // since they do nothing if they don't find the given IE in the
2729 // bytestream with which they're provided.
2730
2731 // The net effect of this will be to faithfully transmit whatever
2732 // security IE is in the join request.
2733
2734 // *However*, if we're associating for the purpose of WPS
2735 // enrollment, and we've been configured to indicate that by
2736 // eliding the WPA or RSN IE, we just skip this:
2737 if (!psessionEntry->is11Rconnection)
2738 {
2739 if( nAddIELen && pAddIE )
2740 {
2741 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2742 }
2743 if ( NULL == wpsIe )
2744 {
2745 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2746 &frm.RSNOpaque );
2747 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2748 &frm.WPAOpaque );
2749 }
2750
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002751#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302752 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002753 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002754 PopulateDot11fESECckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2755 &frm.ESECckmOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002756 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002757#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002758 }
2759
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002760#ifdef FEATURE_WLAN_ESE
2761 // For ESE Associations fill the ESE IEs
2762 if (psessionEntry->isESEconnection &&
2763 psessionEntry->pLimReAssocReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002764 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002765#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002766 PopulateDot11fESERadMgmtCap(&frm.ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002767#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002768 PopulateDot11fESEVersion(&frm.ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002769 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002770#endif //FEATURE_WLAN_ESE
2771#endif //FEATURE_WLAN_ESE || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002772
2773 // include WME EDCA IE as well
2774 if ( fWmeEnabled )
2775 {
2776 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2777 {
2778 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2779 }
2780
2781 if ( fWsmEnabled &&
2782 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2783 {
2784 PopulateDot11fWMMCaps( &frm.WMMCaps );
2785 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002786#ifdef FEATURE_WLAN_ESE
2787 if (psessionEntry->isESEconnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07002788 {
2789 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2790
2791 // Populate the TSRS IE if TSPEC is included in the reassoc request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002792 if (psessionEntry->pLimReAssocReq->eseTspecInfo.numTspecs)
Jeff Johnson295189b2012-06-20 16:38:30 -07002793 {
2794 tANI_U32 phyMode;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002795 tSirMacESETSRSIE tsrsIE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002796 limGetPhyMode(pMac, &phyMode, psessionEntry);
2797
2798 tsrsIE.tsid = 0;
2799 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2800 {
2801 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2802 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302803 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002804 {
2805 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2806 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002807 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.ESETrafStrmRateSet, sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07002808 }
2809 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302810#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002811 }
2812
Jeff Johnsone7245742012-09-05 17:12:55 -07002813 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002814 pMac->lim.htCapabilityPresentInBeacon)
2815 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002816 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002817 }
2818
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002819#if defined WLAN_FEATURE_VOWIFI_11R
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +05302820 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent &&
2821 (pMac->ft.ftSmeContext.addMDIE == TRUE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002822#if defined FEATURE_WLAN_ESE
2823 && !psessionEntry->isESEconnection
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302824#endif
2825 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002826 {
2827 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2828 }
2829#endif
2830
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002831#ifdef WLAN_FEATURE_11AC
2832 if ( psessionEntry->vhtCapability &&
2833 psessionEntry->vhtCapabilityPresentInBeacon)
2834 {
2835 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
2836 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002837 }
2838#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302839 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002840
Jeff Johnson295189b2012-06-20 16:38:30 -07002841 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2842 if ( DOT11F_FAILED( nStatus ) )
2843 {
2844 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002845 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002846 nStatus );
2847 // We'll fall back on the worst case scenario:
2848 nPayload = sizeof( tDot11fReAssocRequest );
2849 }
2850 else if ( DOT11F_WARNED( nStatus ) )
2851 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002852 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002853 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002854 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002855 }
2856
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002857 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002858
2859#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002860 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002861 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2862#endif
2863
2864#if defined WLAN_FEATURE_VOWIFI_11R
2865 if (psessionEntry->is11Rconnection)
2866 {
2867 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2868 }
2869#endif
2870
2871 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2872 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2873 ( void** ) &pPacket );
2874 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2875 {
2876 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002877 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002879 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002880 goto end;
2881 }
2882
2883 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302884 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002885
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002886#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002887 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002888#endif
2889 // Next, we fill out the buffer descriptor:
2890 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2891 SIR_MAC_MGMT_REASSOC_REQ,
2892 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2893 if ( eSIR_SUCCESS != nSirStatus )
2894 {
2895 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002896 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002897 nSirStatus );
2898 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2899 goto end;
2900 }
2901
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302902 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07002903 // That done, pack the ReAssoc Request:
2904 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2905 sizeof(tSirMacMgmtHdr),
2906 nPayload, &nPayload );
2907 if ( DOT11F_FAILED( nStatus ) )
2908 {
2909 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002910 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002911 nStatus );
2912 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2913 goto end;
2914 }
2915 else if ( DOT11F_WARNED( nStatus ) )
2916 {
2917 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002918 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002919 }
2920
2921 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002922 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002923 nBytes, nPayload );)
2924 if( psessionEntry->assocReq != NULL )
2925 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302926 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002927 psessionEntry->assocReq = NULL;
2928 }
2929
2930 if( nAddIELen )
2931 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302932 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2933 pAddIE,
2934 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002935 nPayload += nAddIELen;
2936 }
2937
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302938 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2939 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002940 {
2941 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002942 }
2943 else
2944 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002945 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302946 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002947 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002948 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002949
2950 if (psessionEntry->is11Rconnection)
2951 {
2952 {
2953 int i = 0;
2954
2955 pBody = pFrame + nBytes;
2956 for (i=0; i<ft_ies_length; i++)
2957 {
2958 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2959 pBody++;
2960 }
2961 }
2962 }
2963
2964#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002965 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
2966 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002967 (tANI_U8 *)pFrame,
2968 (nBytes + ft_ies_length));)
2969#endif
2970
2971
2972 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002973 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2974 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002975 )
2976 {
2977 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2978 }
2979
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002980 if( NULL != psessionEntry->assocReq )
2981 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302982 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002983 psessionEntry->assocReq = NULL;
2984 }
2985
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302986 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
2987 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002988 {
2989 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002990 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002991 }
2992 else
2993 {
2994 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302995 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
2996 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002997 psessionEntry->assocReqLen = (ft_ies_length);
2998 }
2999
3000
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303001 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3002 psessionEntry->peSessionId,
3003 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003004 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
3005 HAL_TXRX_FRM_802_11_MGMT,
3006 ANI_TXDIR_TODS,
3007 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3008 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303009 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3010 psessionEntry->peSessionId,
3011 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003012 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3013 {
3014 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003015 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003016 nSirStatus );
3017 //Pkt will be freed up by the callback
3018 goto end;
3019 }
3020
3021end:
3022 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303023 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003024 psessionEntry->pLimMlmReassocReq = NULL;
3025
3026}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003027
3028void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
3029 tLimMlmReassocReq *pMlmReassocReq,
3030 tpPESession psessionEntry)
3031{
3032 tLimMlmReassocCnf mlmReassocCnf; // keep sme
3033 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
3034 if(NULL == pTmpMlmReassocReq)
3035 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303036 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
3037 if ( NULL == pTmpMlmReassocReq ) goto end;
3038 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
3039 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003040 }
3041
3042 // Prepare and send Reassociation request frame
3043 // start reassoc timer.
3044 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
3045 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08003046 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003047 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
3048 != TX_SUCCESS)
3049 {
3050 // Could not start reassoc failure timer.
3051 // Log error
3052 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003053 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003054 // Return Reassoc confirm with
3055 // Resources Unavailable
3056 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3057 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3058 goto end;
3059 }
3060
3061 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
3062 return;
3063
3064end:
3065 // Free up buffer allocated for reassocReq
3066 if (pMlmReassocReq != NULL)
3067 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303068 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003069 pMlmReassocReq = NULL;
3070 }
3071 if (pTmpMlmReassocReq != NULL)
3072 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303073 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003074 pTmpMlmReassocReq = NULL;
3075 }
3076 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
3077 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3078 /* Update PE sessio Id*/
3079 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
3080
3081 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3082}
3083
Jeff Johnson295189b2012-06-20 16:38:30 -07003084#endif /* WLAN_FEATURE_VOWIFI_11R */
3085
3086
3087void
3088limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
3089 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
3090{
3091 static tDot11fReAssocRequest frm;
3092 tANI_U16 caps;
3093 tANI_U8 *pFrame;
3094 tSirRetStatus nSirStatus;
3095 tANI_U32 nBytes, nPayload, nStatus;
3096 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
3097 void *pPacket;
3098 eHalStatus halstatus;
3099 tANI_U16 nAddIELen;
3100 tANI_U8 *pAddIE;
3101 tANI_U8 *wpsIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303102 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003103#if defined WLAN_FEATURE_VOWIFI
3104 tANI_U8 PowerCapsPopulated = FALSE;
3105#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303106 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003107
3108 if(NULL == psessionEntry)
3109 {
3110 return;
3111 }
3112
3113 /* check this early to avoid unncessary operation */
3114 if(NULL == psessionEntry->pLimReAssocReq)
3115 {
3116 return;
3117 }
3118 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
3119 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
3120
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303121 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003122
3123 caps = pMlmReassocReq->capabilityInfo;
3124 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
3125 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
3126#if defined(FEATURE_WLAN_WAPI)
3127 /* CR: 262463 :
3128 According to WAPI standard:
3129 7.3.1.4 Capability Information field
3130 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
3131 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
3132 Reassociation management frames. */
3133 if ( psessionEntry->encryptType == eSIR_ED_WPI)
3134 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
3135#endif
3136 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
3137
3138 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
3139
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303140 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
3141 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003142
3143 PopulateDot11fSSID2( pMac, &frm.SSID );
3144 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3145 &frm.SuppRates,psessionEntry);
3146
3147 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
3148 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
3149
3150 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
3151 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
3152
3153 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
3154 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
3155
3156
3157 if ( psessionEntry->lim11hEnable &&
3158 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
3159 {
3160#if defined WLAN_FEATURE_VOWIFI
3161 PowerCapsPopulated = TRUE;
3162 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
3163 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
3164#endif
3165 }
3166
3167#if defined WLAN_FEATURE_VOWIFI
3168 if( pMac->rrm.rrmPEContext.rrmEnable &&
3169 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
3170 {
3171 if (PowerCapsPopulated == FALSE)
3172 {
3173 PowerCapsPopulated = TRUE;
3174 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
3175 }
3176 }
3177#endif
3178
3179 if ( fQosEnabled &&
3180 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
3181 {
3182 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
3183 }
3184
3185 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3186 &frm.ExtSuppRates, psessionEntry );
3187
3188#if defined WLAN_FEATURE_VOWIFI
3189 if( pMac->rrm.rrmPEContext.rrmEnable &&
3190 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
3191 {
3192 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
3193 }
3194#endif
3195 // The join request *should* contain zero or one of the WPA and RSN
3196 // IEs. The payload send along with the request is a
3197 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
3198
3199 // typedef struct sSirRSNie
3200 // {
3201 // tANI_U16 length;
3202 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
3203 // } tSirRSNie, *tpSirRSNie;
3204
3205 // So, we should be able to make the following two calls harmlessly,
3206 // since they do nothing if they don't find the given IE in the
3207 // bytestream with which they're provided.
3208
3209 // The net effect of this will be to faithfully transmit whatever
3210 // security IE is in the join request.
3211
3212 // *However*, if we're associating for the purpose of WPS
3213 // enrollment, and we've been configured to indicate that by
3214 // eliding the WPA or RSN IE, we just skip this:
3215 if( nAddIELen && pAddIE )
3216 {
3217 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
3218 }
3219 if ( NULL == wpsIe )
3220 {
3221 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3222 &frm.RSNOpaque );
3223 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3224 &frm.WPAOpaque );
3225#if defined(FEATURE_WLAN_WAPI)
3226 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3227 &frm.WAPIOpaque );
3228#endif // defined(FEATURE_WLAN_WAPI)
3229 }
3230
3231 // include WME EDCA IE as well
3232 if ( fWmeEnabled )
3233 {
3234 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
3235 {
3236 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
3237 }
3238
3239 if ( fWsmEnabled &&
3240 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3241 {
3242 PopulateDot11fWMMCaps( &frm.WMMCaps );
3243 }
3244 }
3245
Jeff Johnsone7245742012-09-05 17:12:55 -07003246 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003247 pMac->lim.htCapabilityPresentInBeacon)
3248 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003249 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003250 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003251#ifdef WLAN_FEATURE_11AC
3252 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003253 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003254 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003255 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003256 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Sandeep Puligilla60342762014-01-30 21:05:37 +05303257 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003258 }
3259#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003260
3261 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3262 if ( DOT11F_FAILED( nStatus ) )
3263 {
3264 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003265 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003266 nStatus );
3267 // We'll fall back on the worst case scenario:
3268 nPayload = sizeof( tDot11fReAssocRequest );
3269 }
3270 else if ( DOT11F_WARNED( nStatus ) )
3271 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003272 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003273 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003274 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003275 }
3276
3277 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3278
3279 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3280 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3281 ( void** ) &pPacket );
3282 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3283 {
3284 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003285 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003286 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003287 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003288 goto end;
3289 }
3290
3291 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303292 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003293
3294 // Next, we fill out the buffer descriptor:
3295 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3296 SIR_MAC_MGMT_REASSOC_REQ,
3297 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3298 if ( eSIR_SUCCESS != nSirStatus )
3299 {
3300 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003301 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 nSirStatus );
3303 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3304 goto end;
3305 }
3306
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303307 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003308 // That done, pack the Probe Request:
3309 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3310 sizeof(tSirMacMgmtHdr),
3311 nPayload, &nPayload );
3312 if ( DOT11F_FAILED( nStatus ) )
3313 {
3314 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003315 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003316 nStatus );
3317 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3318 goto end;
3319 }
3320 else if ( DOT11F_WARNED( nStatus ) )
3321 {
3322 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003323 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003324 }
3325
3326 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003327 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003328 nBytes );)
3329
3330 if( psessionEntry->assocReq != NULL )
3331 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303332 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003333 psessionEntry->assocReq = NULL;
3334 }
3335
3336 if( nAddIELen )
3337 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303338 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3339 pAddIE,
3340 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003341 nPayload += nAddIELen;
3342 }
3343
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303344 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3345 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003346 {
3347 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003348 }
3349 else
3350 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003351 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303352 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003353 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003354 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003355
3356 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003357 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3358 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003359 )
3360 {
3361 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3362 }
3363
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003364 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003365 {
3366 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3367 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003368
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303369 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3370 psessionEntry->peSessionId,
3371 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05303372
3373 // enable caching
3374 WLANTL_EnableCaching(psessionEntry->staId);
3375
Jeff Johnson295189b2012-06-20 16:38:30 -07003376 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3377 HAL_TXRX_FRM_802_11_MGMT,
3378 ANI_TXDIR_TODS,
3379 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3380 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303381 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3382 psessionEntry->peSessionId,
3383 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003384 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3385 {
3386 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003387 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003388 nSirStatus );
3389 //Pkt will be freed up by the callback
3390 goto end;
3391 }
3392
3393end:
3394 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303395 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003396 psessionEntry->pLimMlmReassocReq = NULL;
3397
3398} // limSendReassocReqMgmtFrame
3399
3400/**
3401 * \brief Send an Authentication frame
3402 *
3403 *
3404 * \param pMac Pointer to Global MAC structure
3405 *
3406 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3407 * to be sent
3408 *
3409 * \param peerMacAddr MAC address of the peer entity to which Authentication
3410 * frame is destined
3411 *
3412 * \param wepBit Indicates whether wep bit to be set in FC while sending
3413 * Authentication frame3
3414 *
3415 *
3416 * This function is called by limProcessMlmMessages(). Authentication frame
3417 * is formatted and sent when this function is called.
3418 *
3419 *
3420 */
3421
3422void
3423limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3424 tpSirMacAuthFrameBody pAuthFrameBody,
3425 tSirMacAddr peerMacAddr,
3426 tANI_U8 wepBit,
3427 tpPESession psessionEntry
3428 )
3429{
3430 tANI_U8 *pFrame, *pBody;
3431 tANI_U32 frameLen = 0, bodyLen = 0;
3432 tpSirMacMgmtHdr pMacHdr;
3433 tANI_U16 i;
3434 void *pPacket;
3435 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303436 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003437
3438 if(NULL == psessionEntry)
3439 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303440 limLog(pMac, LOGE, FL("Error: psession Entry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003441 return;
3442 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05303443
3444 limLog(pMac, LOG1,
3445 FL("Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
3446 pAuthFrameBody->authTransactionSeqNumber,
3447 pAuthFrameBody->authStatusCode,
3448 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3449 MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003450 if (wepBit == LIM_WEP_IN_FC)
3451 {
3452 /// Auth frame3 to be sent with encrypted framebody
3453 /**
3454 * Allocate buffer for Authenticaton frame of size equal
3455 * to management frame header length plus 2 bytes each for
3456 * auth algorithm number, transaction number, status code,
3457 * 128 bytes for challenge text and 4 bytes each for
3458 * IV & ICV.
3459 */
3460
3461 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3462
3463 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3464 } // if (wepBit == LIM_WEP_IN_FC)
3465 else
3466 {
3467 switch (pAuthFrameBody->authTransactionSeqNumber)
3468 {
3469 case SIR_MAC_AUTH_FRAME_1:
3470 /**
3471 * Allocate buffer for Authenticaton frame of size
3472 * equal to management frame header length plus 2 bytes
3473 * each for auth algorithm number, transaction number
3474 * and status code.
3475 */
3476
3477 frameLen = sizeof(tSirMacMgmtHdr) +
3478 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3479 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3480
3481#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003482 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3483 {
3484 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003486 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003487 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003488 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003489 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003490 else
3491 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303492 limLog(pMac, LOG3, FL("Auth frame, Does not contain "
3493 "FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003494 frameLen += (2+SIR_MDIE_SIZE);
3495 }
3496 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003497#endif
3498 break;
3499
3500 case SIR_MAC_AUTH_FRAME_2:
3501 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3502 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3503 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3504 {
3505 /**
3506 * Allocate buffer for Authenticaton frame of size
3507 * equal to management frame header length plus
3508 * 2 bytes each for auth algorithm number,
3509 * transaction number and status code.
3510 */
3511
3512 frameLen = sizeof(tSirMacMgmtHdr) +
3513 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3514 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3515 }
3516 else
3517 {
3518 // Shared Key algorithm with challenge text
3519 // to be sent
3520 /**
3521 * Allocate buffer for Authenticaton frame of size
3522 * equal to management frame header length plus
3523 * 2 bytes each for auth algorithm number,
3524 * transaction number, status code and 128 bytes
3525 * for challenge text.
3526 */
3527
3528 frameLen = sizeof(tSirMacMgmtHdr) +
3529 sizeof(tSirMacAuthFrame);
3530 bodyLen = sizeof(tSirMacAuthFrameBody);
3531 }
3532
3533 break;
3534
3535 case SIR_MAC_AUTH_FRAME_3:
3536 /// Auth frame3 to be sent without encrypted framebody
3537 /**
3538 * Allocate buffer for Authenticaton frame of size equal
3539 * to management frame header length plus 2 bytes each
3540 * for auth algorithm number, transaction number and
3541 * status code.
3542 */
3543
3544 frameLen = sizeof(tSirMacMgmtHdr) +
3545 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3546 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3547
3548 break;
3549
3550 case SIR_MAC_AUTH_FRAME_4:
3551 /**
3552 * Allocate buffer for Authenticaton frame of size equal
3553 * to management frame header length plus 2 bytes each
3554 * for auth algorithm number, transaction number and
3555 * status code.
3556 */
3557
3558 frameLen = sizeof(tSirMacMgmtHdr) +
3559 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3560 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3561
3562 break;
3563 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3564 } // end if (wepBit == LIM_WEP_IN_FC)
3565
3566
3567 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3568
3569 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3570 {
3571 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003572 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003573
3574 return;
3575 }
3576
3577 for (i = 0; i < frameLen; i++)
3578 pFrame[i] = 0;
3579
3580 // Prepare BD
3581 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3582 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3583 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303584 limLog(pMac, LOGE, FL("call to limPopulateMacHeader failed for "
3585 "AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003586 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3587 return;
3588 }
3589
3590 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3591 pMacHdr->fc.wep = wepBit;
3592
3593 // Prepare BSSId
3594 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3595 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303596 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3597 (tANI_U8 *) psessionEntry->bssId,
3598 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003599 }
3600
3601 /// Prepare Authentication frame body
3602 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3603
3604 if (wepBit == LIM_WEP_IN_FC)
3605 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303606 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003607
3608 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303609 FL("*** Sending Auth seq# 3 status %d (%d) to"MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003610 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303611 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3612 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003613
Jeff Johnson295189b2012-06-20 16:38:30 -07003614 }
3615 else
3616 {
3617 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3618 pBody += sizeof(tANI_U16);
3619 bodyLen -= sizeof(tANI_U16);
3620
3621 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3622 pBody += sizeof(tANI_U16);
3623 bodyLen -= sizeof(tANI_U16);
3624
3625 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3626 pBody += sizeof(tANI_U16);
3627 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003628 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3629 sizeof (pAuthFrameBody->length) +
3630 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303631 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003632
3633#if defined WLAN_FEATURE_VOWIFI_11R
3634 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3635 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3636 {
3637
3638 {
3639 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003640 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3641 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003642#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowdad63eb492014-02-06 12:21:47 -08003643 PELOG2(limLog(pMac, LOG2, FL("Auth1 Frame FTIE is: "));
3644 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
Jeff Johnson295189b2012-06-20 16:38:30 -07003645 (tANI_U8 *)pBody,
3646 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003647#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003648 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3649 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003650 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3651 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003652 }
3653 }
3654 else
3655 {
3656 /* MDID attr is 54*/
3657 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003658 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003659 *pBody = SIR_MDIE_SIZE;
3660 pBody++;
3661 for(i=0;i<SIR_MDIE_SIZE;i++)
3662 {
3663 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3664 pBody++;
3665 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003666 }
3667 }
3668 }
3669#endif
3670
3671 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303672 FL("*** Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003673 pAuthFrameBody->authTransactionSeqNumber,
3674 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303675 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3676 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003677 }
3678 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3679
3680 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003681 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3682 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003683#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303684 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003685 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3686#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003687 )
3688 {
3689 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3690 }
3691
Ganesh K08bce952012-12-13 15:04:41 -08003692 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3693 {
3694 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3695 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003696
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05303697 limLog( pMac, LOG1, FL("Sending Auth Frame over WQ5 to "MAC_ADDRESS_STR
3698 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
3699 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
3700
3701 txFlag |= HAL_USE_FW_IN_TX_PATH;
3702
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303703 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3704 psessionEntry->peSessionId,
3705 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003706 /// Queue Authentication frame in high priority WQ
3707 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3708 HAL_TXRX_FRM_802_11_MGMT,
3709 ANI_TXDIR_TODS,
3710 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3711 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303712 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3713 psessionEntry->peSessionId,
3714 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003715 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3716 {
3717 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003718 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003719 halstatus);
3720
3721 //Pkt will be freed up by the callback
3722 }
3723
3724 return;
3725} /*** end limSendAuthMgmtFrame() ***/
3726
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003727eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3728{
3729 tANI_U16 aid;
3730 tpDphHashNode pStaDs;
3731 tLimMlmDeauthReq *pMlmDeauthReq;
3732 tLimMlmDeauthCnf mlmDeauthCnf;
3733 tpPESession psessionEntry;
3734
3735 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3736 if (pMlmDeauthReq)
3737 {
3738 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3739 {
3740 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3741 }
3742
3743 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3744 {
3745
3746 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003747 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003748 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3749 goto end;
3750 }
3751
3752 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3753 if (pStaDs == NULL)
3754 {
3755 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3756 goto end;
3757 }
3758
3759
3760 /// Receive path cleanup with dummy packet
3761 limCleanupRxPath(pMac, pStaDs,psessionEntry);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05303762
3763#ifdef WLAN_FEATURE_VOWIFI_11R
3764 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
3765 (
3766#ifdef FEATURE_WLAN_ESE
3767 (psessionEntry->isESEconnection ) ||
3768#endif
3769#ifdef FEATURE_WLAN_LFR
3770 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
3771#endif
3772 (psessionEntry->is11Rconnection )))
3773 {
3774 PELOGE(limLog(pMac, LOGE,
3775 FL("FT Preauth Session (%p,%d) Cleanup"
3776 " Deauth reason %d Trigger = %d"),
3777 psessionEntry, psessionEntry->peSessionId,
3778 pMlmDeauthReq->reasonCode,
3779 pMlmDeauthReq->deauthTrigger););
3780 limFTCleanup(pMac);
3781 }
3782 else
3783 {
3784 PELOGE(limLog(pMac, LOGE,
3785 FL("No FT Preauth Session Cleanup in role %d"
3786#ifdef FEATURE_WLAN_ESE
3787 " isESE %d"
3788#endif
3789#ifdef FEATURE_WLAN_LFR
3790 " isLFR %d"
3791#endif
3792 " is11r %d, Deauth reason %d Trigger = %d"),
3793 psessionEntry->limSystemRole,
3794#ifdef FEATURE_WLAN_ESE
3795 psessionEntry->isESEconnection,
3796#endif
3797#ifdef FEATURE_WLAN_LFR
3798 psessionEntry->isFastRoamIniFeatureEnabled,
3799#endif
3800 psessionEntry->is11Rconnection,
3801 pMlmDeauthReq->reasonCode,
3802 pMlmDeauthReq->deauthTrigger););
3803 }
3804#endif
3805
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003806 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303807 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003808 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3809 }
3810 return eHAL_STATUS_SUCCESS;
3811end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303812 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003813 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3814 sizeof(tSirMacAddr));
3815 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3816 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3817 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3818
3819 // Free up buffer allocated
3820 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303821 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003822
3823 limPostSmeMessage(pMac,
3824 LIM_MLM_DEAUTH_CNF,
3825 (tANI_U32 *) &mlmDeauthCnf);
3826 return eHAL_STATUS_SUCCESS;
3827}
3828
3829eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3830{
3831 tANI_U16 aid;
3832 tpDphHashNode pStaDs;
3833 tLimMlmDisassocCnf mlmDisassocCnf;
3834 tpPESession psessionEntry;
3835 tLimMlmDisassocReq *pMlmDisassocReq;
3836
3837 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3838 if (pMlmDisassocReq)
3839 {
3840 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3841 {
3842 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3843 }
3844
3845 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3846 {
3847
3848 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003849 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003850 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3851 goto end;
3852 }
3853
3854 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3855 if (pStaDs == NULL)
3856 {
3857 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3858 goto end;
3859 }
3860
3861 /// Receive path cleanup with dummy packet
3862 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3863 {
3864 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3865 goto end;
3866 }
3867
3868#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003869 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303870 (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003871#ifdef FEATURE_WLAN_ESE
3872 (psessionEntry->isESEconnection ) ||
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003873#endif
3874#ifdef FEATURE_WLAN_LFR
3875 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003876#endif
3877 (psessionEntry->is11Rconnection )) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303878 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003879 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003880 {
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303881 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003882 FL("FT Preauth Session (%p,%d) Cleanup"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003883 psessionEntry, psessionEntry->peSessionId););
3884 limFTCleanup(pMac);
3885 }
3886 else
3887 {
3888 PELOGE(limLog(pMac, LOGE,
3889 FL("No FT Preauth Session Cleanup in role %d"
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003890#ifdef FEATURE_WLAN_ESE
3891 " isESE %d"
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003892#endif
3893#ifdef FEATURE_WLAN_LFR
3894 " isLFR %d"
3895#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003896 " is11r %d reason %d"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003897 psessionEntry->limSystemRole,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003898#ifdef FEATURE_WLAN_ESE
3899 psessionEntry->isESEconnection,
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003900#endif
3901#ifdef FEATURE_WLAN_LFR
3902 psessionEntry->isFastRoamIniFeatureEnabled,
3903#endif
3904 psessionEntry->is11Rconnection,
3905 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003906 }
3907#endif
3908
3909 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303910 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003911 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3912 return eHAL_STATUS_SUCCESS;
3913 }
3914 else
3915 {
3916 return eHAL_STATUS_SUCCESS;
3917 }
3918end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303919 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003920 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3921 sizeof(tSirMacAddr));
3922 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3923 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3924
3925 /* Update PE session ID*/
3926 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3927
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003928 if(pMlmDisassocReq != NULL)
3929 {
3930 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303931 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003932 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3933 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003934
3935 limPostSmeMessage(pMac,
3936 LIM_MLM_DISASSOC_CNF,
3937 (tANI_U32 *) &mlmDisassocCnf);
3938 return eHAL_STATUS_SUCCESS;
3939}
3940
3941eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3942{
3943 return limSendDisassocCnf(pMac);
3944}
3945
3946eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3947{
3948 return limSendDeauthCnf(pMac);
3949}
3950
Jeff Johnson295189b2012-06-20 16:38:30 -07003951/**
3952 * \brief This function is called to send Disassociate frame.
3953 *
3954 *
3955 * \param pMac Pointer to Global MAC structure
3956 *
3957 * \param nReason Indicates the reason that need to be sent in
3958 * Disassociation frame
3959 *
3960 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3961 * sent
3962 *
3963 *
3964 */
3965
3966void
3967limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3968 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003969 tSirMacAddr peer,
3970 tpPESession psessionEntry,
3971 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003972{
3973 tDot11fDisassociation frm;
3974 tANI_U8 *pFrame;
3975 tSirRetStatus nSirStatus;
3976 tpSirMacMgmtHdr pMacHdr;
3977 tANI_U32 nBytes, nPayload, nStatus;
3978 void *pPacket;
3979 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303980 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003981 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003982 if(NULL == psessionEntry)
3983 {
3984 return;
3985 }
3986
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303987 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003988
3989 frm.Reason.code = nReason;
3990
3991 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
3992 if ( DOT11F_FAILED( nStatus ) )
3993 {
3994 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003995 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003996 nStatus );
3997 // We'll fall back on the worst case scenario:
3998 nPayload = sizeof( tDot11fDisassociation );
3999 }
4000 else if ( DOT11F_WARNED( nStatus ) )
4001 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004002 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004003 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004004 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004005 }
4006
4007 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4008
4009 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4010 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4011 ( void** ) &pPacket );
4012 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4013 {
4014 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004015 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004016 return;
4017 }
4018
4019 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304020 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004021
4022 // Next, we fill out the buffer descriptor:
4023 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4024 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
4025 if ( eSIR_SUCCESS != nSirStatus )
4026 {
4027 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004028 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004029 nSirStatus );
4030 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4031 ( void* ) pFrame, ( void* ) pPacket );
4032 return; // just allocated...
4033 }
4034
4035 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4036
4037 // Prepare the BSSID
4038 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4039
Chet Lanctot186b5732013-03-18 10:26:30 -07004040#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004041 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004042#endif
4043
Jeff Johnson295189b2012-06-20 16:38:30 -07004044 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
4045 sizeof(tSirMacMgmtHdr),
4046 nPayload, &nPayload );
4047 if ( DOT11F_FAILED( nStatus ) )
4048 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004049 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 nStatus );
4051 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4052 ( void* ) pFrame, ( void* ) pPacket );
4053 return; // allocated!
4054 }
4055 else if ( DOT11F_WARNED( nStatus ) )
4056 {
4057 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004058 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004059 }
4060
Abhishek Singhcd09b562013-12-24 16:02:20 +05304061 limLog( pMac, LOG1, FL("***Sessionid %d Sending Disassociation frame with "
4062 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4063 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4064 MAC_ADDR_ARRAY(pMacHdr->da),
4065 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004066
4067 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004068 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4069 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004070 )
4071 {
4072 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4073 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004074
Ganesh K08bce952012-12-13 15:04:41 -08004075 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304076 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
4077 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08004078 {
4079 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4080 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004081
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304082 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4083 {
4084 /* This frame will be sent on air by firmware,
4085 which will ensure that this frame goes out
4086 even though DEL_STA is sent immediately */
4087 /* Without this for DEL_STA command there is
4088 risk of flushing frame in BTQM queue without
4089 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304090 limLog( pMac, LOG1, FL("Sending Disassoc Frame over WQ5 to "MAC_ADDRESS_STR
4091 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4092 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304093 txFlag |= HAL_USE_FW_IN_TX_PATH;
4094 }
4095
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004096 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004097 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304098 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4099 psessionEntry->peSessionId,
4100 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004101 // Queue Disassociation frame in high priority WQ
4102 /* get the duration from the request */
4103 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4104 HAL_TXRX_FRM_802_11_MGMT,
4105 ANI_TXDIR_TODS,
4106 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4107 limTxComplete, pFrame, limDisassocTxCompleteCnf,
4108 txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304109 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4110 psessionEntry->peSessionId,
4111 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004112 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07004113
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004114 if (tx_timer_change(
4115 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
4116 != TX_SUCCESS)
4117 {
4118 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004119 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004120 return;
4121 }
4122 else if(TX_SUCCESS != tx_timer_activate(
4123 &pMac->lim.limTimers.gLimDisassocAckTimer))
4124 {
4125 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004126 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004127 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4128 return;
4129 }
4130 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004131 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004132 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304133 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4134 psessionEntry->peSessionId,
4135 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004136 // Queue Disassociation frame in high priority WQ
4137 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4138 HAL_TXRX_FRM_802_11_MGMT,
4139 ANI_TXDIR_TODS,
4140 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4141 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304142 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4143 psessionEntry->peSessionId,
4144 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004145 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4146 {
4147 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004148 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004149 nSirStatus );
4150 //Pkt will be freed up by the callback
4151 return;
4152 }
4153 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004154} // End limSendDisassocMgmtFrame.
4155
4156/**
4157 * \brief This function is called to send a Deauthenticate frame
4158 *
4159 *
4160 * \param pMac Pointer to global MAC structure
4161 *
4162 * \param nReason Indicates the reason that need to be sent in the
4163 * Deauthenticate frame
4164 *
4165 * \param peeer address of the STA to which the frame is to be sent
4166 *
4167 *
4168 */
4169
4170void
4171limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
4172 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004173 tSirMacAddr peer,
4174 tpPESession psessionEntry,
4175 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004176{
4177 tDot11fDeAuth frm;
4178 tANI_U8 *pFrame;
4179 tSirRetStatus nSirStatus;
4180 tpSirMacMgmtHdr pMacHdr;
4181 tANI_U32 nBytes, nPayload, nStatus;
4182 void *pPacket;
4183 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304184 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004185 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004186#ifdef FEATURE_WLAN_TDLS
4187 tANI_U16 aid;
4188 tpDphHashNode pStaDs;
4189#endif
4190
Jeff Johnson295189b2012-06-20 16:38:30 -07004191 if(NULL == psessionEntry)
4192 {
4193 return;
4194 }
4195
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304196 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004197
4198 frm.Reason.code = nReason;
4199
4200 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
4201 if ( DOT11F_FAILED( nStatus ) )
4202 {
4203 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004204 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004205 nStatus );
4206 // We'll fall back on the worst case scenario:
4207 nPayload = sizeof( tDot11fDeAuth );
4208 }
4209 else if ( DOT11F_WARNED( nStatus ) )
4210 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004211 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004212 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004213 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004214 }
4215
4216 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4217
4218 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4219 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4220 ( void** ) &pPacket );
4221 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4222 {
4223 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004224 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004225 return;
4226 }
4227
4228 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304229 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004230
4231 // Next, we fill out the buffer descriptor:
4232 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4233 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
4234 if ( eSIR_SUCCESS != nSirStatus )
4235 {
4236 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004237 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004238 nSirStatus );
4239 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4240 ( void* ) pFrame, ( void* ) pPacket );
4241 return; // just allocated...
4242 }
4243
4244 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4245
4246 // Prepare the BSSID
4247 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4248
Chet Lanctot186b5732013-03-18 10:26:30 -07004249#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004250 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004251#endif
4252
Jeff Johnson295189b2012-06-20 16:38:30 -07004253 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
4254 sizeof(tSirMacMgmtHdr),
4255 nPayload, &nPayload );
4256 if ( DOT11F_FAILED( nStatus ) )
4257 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004258 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004259 nStatus );
4260 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4261 ( void* ) pFrame, ( void* ) pPacket );
4262 return;
4263 }
4264 else if ( DOT11F_WARNED( nStatus ) )
4265 {
4266 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004267 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004268 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05304269 limLog( pMac, LOG1, FL("***Sessionid %d Sending Deauth frame with "
4270 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4271 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4272 MAC_ADDR_ARRAY(pMacHdr->da),
4273 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004274
4275 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004276 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4277 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004278 )
4279 {
4280 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4281 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004282
Ganesh K08bce952012-12-13 15:04:41 -08004283 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304284 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
4285 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08004286 {
4287 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4288 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004289
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304290 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4291 {
4292 /* This frame will be sent on air by firmware,
4293 which will ensure that this frame goes out
4294 even though DEL_STA is sent immediately */
4295 /* Without this for DEL_STA command there is
4296 risk of flushing frame in BTQM queue without
4297 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304298 limLog( pMac, LOG1, FL("Sending Deauth Frame over WQ5 to "MAC_ADDRESS_STR
4299 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4300 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304301 txFlag |= HAL_USE_FW_IN_TX_PATH;
4302 }
4303
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004304#ifdef FEATURE_WLAN_TDLS
4305 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
4306#endif
4307
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004308 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004309 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304310 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4311 psessionEntry->peSessionId,
4312 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004313 // Queue Disassociation frame in high priority WQ
4314 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4315 HAL_TXRX_FRM_802_11_MGMT,
4316 ANI_TXDIR_TODS,
4317 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4318 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304319 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4320 psessionEntry->peSessionId,
4321 halstatus));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304322 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004323 {
4324 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304325 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004326 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08004327 //Pkt will be freed up by the callback limTxComplete
4328
4329 /*Call limProcessDeauthAckTimeout which will send
4330 * DeauthCnf for this frame
4331 */
4332 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004333 return;
4334 }
4335
4336 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
4337
4338 if (tx_timer_change(
4339 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
4340 != TX_SUCCESS)
4341 {
4342 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004343 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004344 return;
4345 }
4346 else if(TX_SUCCESS != tx_timer_activate(
4347 &pMac->lim.limTimers.gLimDeauthAckTimer))
4348 {
4349 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004350 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004351 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4352 return;
4353 }
4354 }
4355 else
4356 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304357 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4358 psessionEntry->peSessionId,
4359 pMacHdr->fc.subType));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004360#ifdef FEATURE_WLAN_TDLS
4361 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4362 {
4363 // Queue Disassociation frame in high priority WQ
4364 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004365 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004366 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004367 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4368 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004369 }
4370 else
4371 {
4372#endif
4373 // Queue Disassociation frame in high priority WQ
4374 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4375 HAL_TXRX_FRM_802_11_MGMT,
4376 ANI_TXDIR_TODS,
4377 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4378 limTxComplete, pFrame, txFlag );
4379#ifdef FEATURE_WLAN_TDLS
4380 }
4381#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304382 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4383 psessionEntry->peSessionId,
4384 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004385 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4386 {
4387 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004388 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004389 nSirStatus );
4390 //Pkt will be freed up by the callback
4391 return;
4392 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004393 }
4394
4395} // End limSendDeauthMgmtFrame.
4396
4397
4398#ifdef ANI_SUPPORT_11H
4399/**
4400 * \brief Send a Measurement Report Action frame
4401 *
4402 *
4403 * \param pMac Pointer to the global MAC structure
4404 *
4405 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4406 *
4407 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4408 *
4409 *
4410 */
4411
4412tSirRetStatus
4413limSendMeasReportFrame(tpAniSirGlobal pMac,
4414 tpSirMacMeasReqActionFrame pMeasReqFrame,
4415 tSirMacAddr peer)
4416{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304417 tDot11fMeasurementReport frm;
4418 tANI_U8 *pFrame;
4419 tSirRetStatus nSirStatus;
4420 tpSirMacMgmtHdr pMacHdr;
4421 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4422 void *pPacket;
4423 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004424
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304425 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004426
4427 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4428 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4429 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4430
4431 switch ( pMeasReqFrame->measReqIE.measType )
4432 {
4433 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4434 nSirStatus =
4435 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4436 &frm.MeasurementReport );
4437 break;
4438 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4439 nSirStatus =
4440 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4441 &frm.MeasurementReport );
4442 break;
4443 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4444 nSirStatus =
4445 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4446 &frm.MeasurementReport );
4447 break;
4448 default:
4449 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004450 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004451 pMeasReqFrame->measReqIE.measType );
4452 return eSIR_FAILURE;
4453 }
4454
4455 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4456
4457 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4458 if ( DOT11F_FAILED( nStatus ) )
4459 {
4460 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004461 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004462 nStatus );
4463 // We'll fall back on the worst case scenario:
4464 nPayload = sizeof( tDot11fMeasurementReport );
4465 }
4466 else if ( DOT11F_WARNED( nStatus ) )
4467 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004468 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004469 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004470 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004471 }
4472
4473 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4474
4475 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4476 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4477 {
4478 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004479 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 return eSIR_FAILURE;
4481 }
4482
4483 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304484 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004485
4486 // Next, we fill out the buffer descriptor:
4487 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4488 SIR_MAC_MGMT_ACTION, peer);
4489 if ( eSIR_SUCCESS != nSirStatus )
4490 {
4491 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004492 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004493 nSirStatus );
4494 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4495 return eSIR_FAILURE; // just allocated...
4496 }
4497
4498 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4499
4500 nCfg = 6;
4501 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4502 if ( eSIR_SUCCESS != nSirStatus )
4503 {
4504 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004505 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004506 nSirStatus );
4507 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4508 return eSIR_FAILURE; // just allocated...
4509 }
4510
Chet Lanctot186b5732013-03-18 10:26:30 -07004511#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004512 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004513#endif
4514
Jeff Johnson295189b2012-06-20 16:38:30 -07004515 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4516 sizeof(tSirMacMgmtHdr),
4517 nPayload, &nPayload );
4518 if ( DOT11F_FAILED( nStatus ) )
4519 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004520 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004521 nStatus );
4522 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4523 return eSIR_FAILURE; // allocated!
4524 }
4525 else if ( DOT11F_WARNED( nStatus ) )
4526 {
4527 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004528 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004529 }
4530
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304531 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4532 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4533 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004534 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4535 HAL_TXRX_FRM_802_11_MGMT,
4536 ANI_TXDIR_TODS,
4537 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4538 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304539 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4540 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4541 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004542 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4543 {
4544 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004545 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004546 nSirStatus );
4547 //Pkt will be freed up by the callback
4548 return eSIR_FAILURE; // just allocated...
4549 }
4550
4551 return eSIR_SUCCESS;
4552
4553} // End limSendMeasReportFrame.
4554
4555
4556/**
4557 * \brief Send a TPC Request Action frame
4558 *
4559 *
4560 * \param pMac Pointer to the global MAC datastructure
4561 *
4562 * \param peer MAC address to which the frame should be sent
4563 *
4564 *
4565 */
4566
4567void
4568limSendTpcRequestFrame(tpAniSirGlobal pMac,
4569 tSirMacAddr peer)
4570{
4571 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304572 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004573 tSirRetStatus nSirStatus;
4574 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304575 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4576 void *pPacket;
4577 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004578
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304579 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004580
4581 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4582 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4583 frm.DialogToken.token = 1;
4584 frm.TPCRequest.present = 1;
4585
4586 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4587 if ( DOT11F_FAILED( nStatus ) )
4588 {
4589 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004590 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004591 nStatus );
4592 // We'll fall back on the worst case scenario:
4593 nPayload = sizeof( tDot11fTPCRequest );
4594 }
4595 else if ( DOT11F_WARNED( nStatus ) )
4596 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004597 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004598 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004599 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004600 }
4601
4602 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4603
4604 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4605 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4606 {
4607 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004608 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004609 return;
4610 }
4611
4612 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304613 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004614
4615 // Next, we fill out the buffer descriptor:
4616 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4617 SIR_MAC_MGMT_ACTION, peer);
4618 if ( eSIR_SUCCESS != nSirStatus )
4619 {
4620 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004621 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004622 nSirStatus );
4623 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4624 return; // just allocated...
4625 }
4626
4627 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4628
4629 nCfg = 6;
4630 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4631 if ( eSIR_SUCCESS != nSirStatus )
4632 {
4633 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004634 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004635 nSirStatus );
4636 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4637 return; // just allocated...
4638 }
4639
Chet Lanctot186b5732013-03-18 10:26:30 -07004640#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004641 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004642#endif
4643
Jeff Johnson295189b2012-06-20 16:38:30 -07004644 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4645 sizeof(tSirMacMgmtHdr),
4646 nPayload, &nPayload );
4647 if ( DOT11F_FAILED( nStatus ) )
4648 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004649 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004650 nStatus );
4651 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4652 return; // allocated!
4653 }
4654 else if ( DOT11F_WARNED( nStatus ) )
4655 {
4656 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004657 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004658 }
4659
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304660 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4661 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4662 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004663 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4664 HAL_TXRX_FRM_802_11_MGMT,
4665 ANI_TXDIR_TODS,
4666 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4667 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304668 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4669 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4670 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004671 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4672 {
4673 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004674 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004675 nSirStatus );
4676 //Pkt will be freed up by the callback
4677 return;
4678 }
4679
4680} // End limSendTpcRequestFrame.
4681
4682
4683/**
4684 * \brief Send a TPC Report Action frame
4685 *
4686 *
4687 * \param pMac Pointer to the global MAC datastructure
4688 *
4689 * \param pTpcReqFrame Pointer to the received TPC Request
4690 *
4691 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4692 *
4693 *
4694 */
4695
4696tSirRetStatus
4697limSendTpcReportFrame(tpAniSirGlobal pMac,
4698 tpSirMacTpcReqActionFrame pTpcReqFrame,
4699 tSirMacAddr peer)
4700{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304701 tDot11fTPCReport frm;
4702 tANI_U8 *pFrame;
4703 tSirRetStatus nSirStatus;
4704 tpSirMacMgmtHdr pMacHdr;
4705 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4706 void *pPacket;
4707 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004708
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304709 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004710
4711 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4712 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4713 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4714
4715 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4716 // "misplaced this function, need to replace:
4717 // txPower = halGetRateToPwrValue(pMac, staid,
4718 // pMac->lim.gLimCurrentChannelId, 0);
4719 frm.TPCReport.tx_power = 0;
4720 frm.TPCReport.link_margin = 0;
4721 frm.TPCReport.present = 1;
4722
4723 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4724 if ( DOT11F_FAILED( nStatus ) )
4725 {
4726 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004727 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004728 nStatus );
4729 // We'll fall back on the worst case scenario:
4730 nPayload = sizeof( tDot11fTPCReport );
4731 }
4732 else if ( DOT11F_WARNED( nStatus ) )
4733 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004734 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004735 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004736 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004737 }
4738
4739 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4740
4741 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4742 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4743 {
4744 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004745 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004746 return eSIR_FAILURE;
4747 }
4748
4749 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304750 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004751
4752 // Next, we fill out the buffer descriptor:
4753 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4754 SIR_MAC_MGMT_ACTION, peer);
4755 if ( eSIR_SUCCESS != nSirStatus )
4756 {
4757 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004758 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004759 nSirStatus );
4760 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4761 return eSIR_FAILURE; // just allocated...
4762 }
4763
4764 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4765
4766 nCfg = 6;
4767 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4768 if ( eSIR_SUCCESS != nSirStatus )
4769 {
4770 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004771 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004772 nSirStatus );
4773 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4774 return eSIR_FAILURE; // just allocated...
4775 }
4776
Chet Lanctot186b5732013-03-18 10:26:30 -07004777#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004778 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004779#endif
4780
Jeff Johnson295189b2012-06-20 16:38:30 -07004781 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4782 sizeof(tSirMacMgmtHdr),
4783 nPayload, &nPayload );
4784 if ( DOT11F_FAILED( nStatus ) )
4785 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004786 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004787 nStatus );
4788 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4789 return eSIR_FAILURE; // allocated!
4790 }
4791 else if ( DOT11F_WARNED( nStatus ) )
4792 {
4793 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004794 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004795 }
4796
4797
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304798 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4799 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4800 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004801 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4802 HAL_TXRX_FRM_802_11_MGMT,
4803 ANI_TXDIR_TODS,
4804 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4805 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304806 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4807 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4808 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004809 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4810 {
4811 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004812 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004813 nSirStatus );
4814 //Pkt will be freed up by the callback
4815 return eSIR_FAILURE; // just allocated...
4816 }
4817
4818 return eSIR_SUCCESS;
4819
4820} // End limSendTpcReportFrame.
4821#endif //ANI_SUPPORT_11H
4822
4823
Jeff Johnson295189b2012-06-20 16:38:30 -07004824/**
4825 * \brief Send a Channel Switch Announcement
4826 *
4827 *
4828 * \param pMac Pointer to the global MAC datastructure
4829 *
4830 * \param peer MAC address to which this frame will be sent
4831 *
4832 * \param nMode
4833 *
4834 * \param nNewChannel
4835 *
4836 * \param nCount
4837 *
4838 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4839 *
4840 *
4841 */
4842
4843tSirRetStatus
4844limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4845 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004846 tANI_U8 nMode,
4847 tANI_U8 nNewChannel,
4848 tANI_U8 nCount,
4849 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004850{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304851 tDot11fChannelSwitch frm;
4852 tANI_U8 *pFrame;
4853 tSirRetStatus nSirStatus;
4854 tpSirMacMgmtHdr pMacHdr;
4855 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4856 void *pPacket;
4857 eHalStatus halstatus;
4858 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004859
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304860 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004861
4862 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4863 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4864 frm.ChanSwitchAnn.switchMode = nMode;
4865 frm.ChanSwitchAnn.newChannel = nNewChannel;
4866 frm.ChanSwitchAnn.switchCount = nCount;
4867 frm.ChanSwitchAnn.present = 1;
4868
4869 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4870 if ( DOT11F_FAILED( nStatus ) )
4871 {
4872 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004873 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004874 nStatus );
4875 // We'll fall back on the worst case scenario:
4876 nPayload = sizeof( tDot11fChannelSwitch );
4877 }
4878 else if ( DOT11F_WARNED( nStatus ) )
4879 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004880 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004881 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004882 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004883 }
4884
4885 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4886
4887 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4888 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4889 {
4890 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004891 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004892 return eSIR_FAILURE;
4893 }
4894
4895 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304896 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004897
4898 // Next, we fill out the buffer descriptor:
4899 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004900 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4901 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304902 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4903 (tANI_U8 *) psessionEntry->bssId,
4904 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004905 if ( eSIR_SUCCESS != nSirStatus )
4906 {
4907 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004908 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004909 nSirStatus );
4910 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4911 return eSIR_FAILURE; // just allocated...
4912 }
4913
Jeff Johnsone7245742012-09-05 17:12:55 -07004914#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004915 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4916
4917 nCfg = 6;
4918 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4919 if ( eSIR_SUCCESS != nSirStatus )
4920 {
4921 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004922 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004923 nSirStatus );
4924 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4925 return eSIR_FAILURE; // just allocated...
4926 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004927#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004928
4929#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004930 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004931#endif
4932
Jeff Johnson295189b2012-06-20 16:38:30 -07004933 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4934 sizeof(tSirMacMgmtHdr),
4935 nPayload, &nPayload );
4936 if ( DOT11F_FAILED( nStatus ) )
4937 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004938 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004939 nStatus );
4940 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4941 return eSIR_FAILURE; // allocated!
4942 }
4943 else if ( DOT11F_WARNED( nStatus ) )
4944 {
4945 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004946 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004947 }
4948
Jeff Johnsone7245742012-09-05 17:12:55 -07004949 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004950 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4951 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004952 )
4953 {
4954 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4955 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304956
4957 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4958 psessionEntry->peSessionId,
4959 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004960 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4961 HAL_TXRX_FRM_802_11_MGMT,
4962 ANI_TXDIR_TODS,
4963 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004964 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304965 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4966 psessionEntry->peSessionId,
4967 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004968 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4969 {
4970 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004971 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004972 nSirStatus );
4973 //Pkt will be freed up by the callback
4974 return eSIR_FAILURE;
4975 }
4976
4977 return eSIR_SUCCESS;
4978
4979} // End limSendChannelSwitchMgmtFrame.
4980
Jeff Johnson295189b2012-06-20 16:38:30 -07004981
4982
Mohit Khanna4a70d262012-09-11 16:30:12 -07004983#ifdef WLAN_FEATURE_11AC
4984tSirRetStatus
4985limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
4986 tSirMacAddr peer,
4987 tANI_U8 nMode,
4988 tpPESession psessionEntry )
4989{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304990 tDot11fOperatingMode frm;
4991 tANI_U8 *pFrame;
4992 tSirRetStatus nSirStatus;
4993 tpSirMacMgmtHdr pMacHdr;
4994 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
4995 void *pPacket;
4996 eHalStatus halstatus;
4997 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07004998
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304999 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005000
5001 frm.Category.category = SIR_MAC_ACTION_VHT;
5002 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
5003 frm.OperatingMode.chanWidth = nMode;
5004 frm.OperatingMode.rxNSS = 0;
5005 frm.OperatingMode.rxNSSType = 0;
5006
5007 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
5008 if ( DOT11F_FAILED( nStatus ) )
5009 {
5010 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005011 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005012 nStatus );
5013 // We'll fall back on the worst case scenario:
5014 nPayload = sizeof( tDot11fOperatingMode);
5015 }
5016 else if ( DOT11F_WARNED( nStatus ) )
5017 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005018 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07005019 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005020 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005021 }
5022
5023 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5024
5025 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5026 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5027 {
5028 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005029 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005030 return eSIR_FAILURE;
5031 }
5032
5033 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305034 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005035
5036
5037 // Next, we fill out the buffer descriptor:
5038 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
5039 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5040 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5041 } else
5042 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5043 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
5044 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305045 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5046 (tANI_U8 *) psessionEntry->bssId,
5047 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005048 if ( eSIR_SUCCESS != nSirStatus )
5049 {
5050 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005051 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005052 nSirStatus );
5053 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5054 return eSIR_FAILURE; // just allocated...
5055 }
5056 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
5057 sizeof(tSirMacMgmtHdr),
5058 nPayload, &nPayload );
5059 if ( DOT11F_FAILED( nStatus ) )
5060 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005061 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005062 nStatus );
5063 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5064 return eSIR_FAILURE; // allocated!
5065 }
5066 else if ( DOT11F_WARNED( nStatus ) )
5067 {
5068 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005069 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005070 }
5071 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07005072 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5073 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07005074 )
5075 {
5076 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5077 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305078
5079 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5080 psessionEntry->peSessionId,
5081 pMacHdr->fc.subType));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005082 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5083 HAL_TXRX_FRM_802_11_MGMT,
5084 ANI_TXDIR_TODS,
5085 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5086 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305087 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5088 psessionEntry->peSessionId,
5089 halstatus));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005090 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5091 {
5092 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005093 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005094 nSirStatus );
5095 //Pkt will be freed up by the callback
5096 return eSIR_FAILURE;
5097 }
5098
5099 return eSIR_SUCCESS;
5100}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005101
5102/**
5103 * \brief Send a VHT Channel Switch Announcement
5104 *
5105 *
5106 * \param pMac Pointer to the global MAC datastructure
5107 *
5108 * \param peer MAC address to which this frame will be sent
5109 *
5110 * \param nChanWidth
5111 *
5112 * \param nNewChannel
5113 *
5114 *
5115 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5116 *
5117 *
5118 */
5119
5120tSirRetStatus
5121limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5122 tSirMacAddr peer,
5123 tANI_U8 nChanWidth,
5124 tANI_U8 nNewChannel,
5125 tANI_U8 ncbMode,
5126 tpPESession psessionEntry )
5127{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305128 tDot11fChannelSwitch frm;
5129 tANI_U8 *pFrame;
5130 tSirRetStatus nSirStatus;
5131 tpSirMacMgmtHdr pMacHdr;
5132 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5133 void *pPacket;
5134 eHalStatus halstatus;
5135 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005136
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305137 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005138
5139
5140 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5141 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5142 frm.ChanSwitchAnn.switchMode = 1;
5143 frm.ChanSwitchAnn.newChannel = nNewChannel;
5144 frm.ChanSwitchAnn.switchCount = 1;
5145 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
5146 frm.ExtChanSwitchAnn.present = 1;
5147 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
5148 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
5149 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
5150 frm.ChanSwitchAnn.present = 1;
5151 frm.WiderBWChanSwitchAnn.present = 1;
5152
5153 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5154 if ( DOT11F_FAILED( nStatus ) )
5155 {
5156 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005157 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005158 nStatus );
5159 // We'll fall back on the worst case scenario:
5160 nPayload = sizeof( tDot11fChannelSwitch );
5161 }
5162 else if ( DOT11F_WARNED( nStatus ) )
5163 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005164 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005165 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005166 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005167 }
5168
5169 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5170
5171 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5172 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5173 {
5174 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005175 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005176 return eSIR_FAILURE;
5177 }
5178 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305179 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005180
5181 // Next, we fill out the buffer descriptor:
5182 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5183 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5184 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305185 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5186 (tANI_U8 *) psessionEntry->bssId,
5187 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005188 if ( eSIR_SUCCESS != nSirStatus )
5189 {
5190 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005191 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005192 nSirStatus );
5193 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5194 return eSIR_FAILURE; // just allocated...
5195 }
5196 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5197 sizeof(tSirMacMgmtHdr),
5198 nPayload, &nPayload );
5199 if ( DOT11F_FAILED( nStatus ) )
5200 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005201 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005202 nStatus );
5203 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5204 return eSIR_FAILURE; // allocated!
5205 }
5206 else if ( DOT11F_WARNED( nStatus ) )
5207 {
5208 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005209 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005210 }
5211
5212 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005213 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5214 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005215 )
5216 {
5217 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5218 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305219
5220 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5221 psessionEntry->peSessionId,
5222 pMacHdr->fc.subType));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005223 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5224 HAL_TXRX_FRM_802_11_MGMT,
5225 ANI_TXDIR_TODS,
5226 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5227 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305228 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5229 psessionEntry->peSessionId,
5230 halstatus));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005231 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5232 {
5233 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005234 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005235 nSirStatus );
5236 //Pkt will be freed up by the callback
5237 return eSIR_FAILURE;
5238 }
5239
5240 return eSIR_SUCCESS;
5241
5242} // End limSendVHTChannelSwitchMgmtFrame.
5243
5244
5245
Mohit Khanna4a70d262012-09-11 16:30:12 -07005246#endif
5247
Jeff Johnson295189b2012-06-20 16:38:30 -07005248/**
5249 * \brief Send an ADDBA Req Action Frame to peer
5250 *
5251 * \sa limSendAddBAReq
5252 *
5253 * \param pMac The global tpAniSirGlobal object
5254 *
5255 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
5256 * the necessary parameters reqd by PE send the ADDBA Req Action
5257 * Frame to the peer
5258 *
5259 * \return eSIR_SUCCESS if setup completes successfully
5260 * eSIR_FAILURE is some problem is encountered
5261 */
5262tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305263 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07005264{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305265 tDot11fAddBAReq frmAddBAReq;
5266 tANI_U8 *pAddBAReqBuffer = NULL;
5267 tpSirMacMgmtHdr pMacHdr;
5268 tANI_U32 frameLen = 0, nStatus, nPayload;
5269 tSirRetStatus statusCode;
5270 eHalStatus halStatus;
5271 void *pPacket;
5272 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005273
5274 if(NULL == psessionEntry)
5275 {
5276 return eSIR_FAILURE;
5277 }
5278
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305279 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005280
5281 // Category - 3 (BA)
5282 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
5283
5284 // Action - 0 (ADDBA Req)
5285 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
5286
5287 // FIXME - Dialog Token, generalize this...
5288 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
5289
5290 // Fill the ADDBA Parameter Set
5291 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
5292 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
5293 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
5294
5295 // BA timeout
5296 // 0 - indicates no BA timeout
5297 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
5298
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305299 /* Send SSN whatever we get from FW.
5300 */
5301 frmAddBAReq.BAStartingSequenceControl.ssn = pMlmAddBAReq->baSSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07005302
5303 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
5304
5305 if( DOT11F_FAILED( nStatus ))
5306 {
5307 limLog( pMac, LOGW,
5308 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005309 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005310 nStatus );
5311
5312 // We'll fall back on the worst case scenario:
5313 nPayload = sizeof( tDot11fAddBAReq );
5314 }
5315 else if( DOT11F_WARNED( nStatus ))
5316 {
5317 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005318 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005319 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005320 nStatus );
5321 }
5322
5323 // Add the MGMT header to frame length
5324 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5325
5326 // Need to allocate a buffer for ADDBA AF
5327 if( eHAL_STATUS_SUCCESS !=
5328 (halStatus = palPktAlloc( pMac->hHdd,
5329 HAL_TXRX_FRM_802_11_MGMT,
5330 (tANI_U16) frameLen,
5331 (void **) &pAddBAReqBuffer,
5332 (void **) &pPacket )))
5333 {
5334 // Log error
5335 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005336 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005337 frameLen,
5338 halStatus );
5339
5340 statusCode = eSIR_MEM_ALLOC_FAILED;
5341 goto returnAfterError;
5342 }
5343
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305344 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005345
5346 // Copy necessary info to BD
5347 if( eSIR_SUCCESS !=
5348 (statusCode = limPopulateMacHeader( pMac,
5349 pAddBAReqBuffer,
5350 SIR_MAC_MGMT_FRAME,
5351 SIR_MAC_MGMT_ACTION,
5352 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5353 goto returnAfterError;
5354
5355 // Update A3 with the BSSID
5356 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
5357
5358 #if 0
5359 cfgLen = SIR_MAC_ADDR_LENGTH;
5360 if( eSIR_SUCCESS != cfgGetStr( pMac,
5361 WNI_CFG_BSSID,
5362 (tANI_U8 *) pMacHdr->bssId,
5363 &cfgLen ))
5364 {
5365 limLog( pMac, LOGP,
5366 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005367 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005368
5369 // FIXME - Need to convert to tSirRetStatus
5370 statusCode = eSIR_FAILURE;
5371 goto returnAfterError;
5372 }
5373 #endif//TO SUPPORT BT-AMP
5374 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5375
Chet Lanctot186b5732013-03-18 10:26:30 -07005376#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005377 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005378#endif
5379
Jeff Johnson295189b2012-06-20 16:38:30 -07005380 // Now, we're ready to "pack" the frames
5381 nStatus = dot11fPackAddBAReq( pMac,
5382 &frmAddBAReq,
5383 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5384 nPayload,
5385 &nPayload );
5386
5387 if( DOT11F_FAILED( nStatus ))
5388 {
5389 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005390 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005391 nStatus );
5392
5393 // FIXME - Need to convert to tSirRetStatus
5394 statusCode = eSIR_FAILURE;
5395 goto returnAfterError;
5396 }
5397 else if( DOT11F_WARNED( nStatus ))
5398 {
5399 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005400 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5401 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005402 }
5403
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05305404 limLog( pMac, LOG1, FL( "Sending an ADDBA REQ to "MAC_ADDRESS_STR " with"
5405 " tid = %d policy = %d buffsize = %d "
5406 " amsduSupported = %d"),
5407 MAC_ADDR_ARRAY(pMlmAddBAReq->peerMacAddr),
5408 frmAddBAReq.AddBAParameterSet.tid,
5409 frmAddBAReq.AddBAParameterSet.policy,
5410 frmAddBAReq.AddBAParameterSet.bufferSize,
5411 frmAddBAReq.AddBAParameterSet.amsduSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07005412
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305413 limLog( pMac, LOG1, FL( "ssn = %d fragNum = %d" ),
5414 frmAddBAReq.BAStartingSequenceControl.ssn,
5415 frmAddBAReq.BAStartingSequenceControl.fragNumber);
5416
Jeff Johnson295189b2012-06-20 16:38:30 -07005417 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005418 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5419 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005420 )
5421 {
5422 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5423 }
5424
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305425 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5426 psessionEntry->peSessionId,
5427 pMacHdr->fc.subType));
5428 halStatus = halTxFrame( pMac,
5429 pPacket,
5430 (tANI_U16) frameLen,
5431 HAL_TXRX_FRM_802_11_MGMT,
5432 ANI_TXDIR_TODS,
5433 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5434 limTxComplete,
5435 pAddBAReqBuffer, txFlag );
5436 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5437 psessionEntry->peSessionId,
5438 halStatus));
5439 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005440 {
5441 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005442 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005443 halStatus );
5444
5445 // FIXME - Need to convert eHalStatus to tSirRetStatus
5446 statusCode = eSIR_FAILURE;
5447 //Pkt will be freed up by the callback
5448 return statusCode;
5449 }
5450 else
5451 return eSIR_SUCCESS;
5452
5453returnAfterError:
5454
5455 // Release buffer, if allocated
5456 if( NULL != pAddBAReqBuffer )
5457 palPktFree( pMac->hHdd,
5458 HAL_TXRX_FRM_802_11_MGMT,
5459 (void *) pAddBAReqBuffer,
5460 (void *) pPacket );
5461
5462 return statusCode;
5463}
5464
5465/**
5466 * \brief Send an ADDBA Rsp Action Frame to peer
5467 *
5468 * \sa limSendAddBARsp
5469 *
5470 * \param pMac The global tpAniSirGlobal object
5471 *
5472 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5473 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5474 * Frame to the peer
5475 *
5476 * \return eSIR_SUCCESS if setup completes successfully
5477 * eSIR_FAILURE is some problem is encountered
5478 */
5479tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5480 tpLimMlmAddBARsp pMlmAddBARsp,
5481 tpPESession psessionEntry)
5482{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305483 tDot11fAddBARsp frmAddBARsp;
5484 tANI_U8 *pAddBARspBuffer = NULL;
5485 tpSirMacMgmtHdr pMacHdr;
5486 tANI_U32 frameLen = 0, nStatus, nPayload;
5487 tSirRetStatus statusCode;
5488 eHalStatus halStatus;
5489 void *pPacket;
5490 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005491
5492 if(NULL == psessionEntry)
5493 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005494 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005495 return eSIR_FAILURE;
5496 }
5497
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305498 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005499
5500 // Category - 3 (BA)
5501 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5502 // Action - 1 (ADDBA Rsp)
5503 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5504
5505 // Should be same as the one we received in the ADDBA Req
5506 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5507
5508 // ADDBA Req status
5509 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5510
5511 // Fill the ADDBA Parameter Set as provided by caller
5512 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5513 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5514 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005515
5516 if(psessionEntry->isAmsduSupportInAMPDU)
5517 {
5518 frmAddBARsp.AddBAParameterSet.amsduSupported =
5519 psessionEntry->amsduSupportedInBA;
5520 }
5521 else
5522 {
5523 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5524 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005525
5526 // BA timeout
5527 // 0 - indicates no BA timeout
5528 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5529
5530 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5531
5532 if( DOT11F_FAILED( nStatus ))
5533 {
5534 limLog( pMac, LOGW,
5535 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005536 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005537 nStatus );
5538
5539 // We'll fall back on the worst case scenario:
5540 nPayload = sizeof( tDot11fAddBARsp );
5541 }
5542 else if( DOT11F_WARNED( nStatus ))
5543 {
5544 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005545 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005546 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005547 nStatus );
5548 }
5549
5550 // Need to allocate a buffer for ADDBA AF
5551 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5552
5553 // Allocate shared memory
5554 if( eHAL_STATUS_SUCCESS !=
5555 (halStatus = palPktAlloc( pMac->hHdd,
5556 HAL_TXRX_FRM_802_11_MGMT,
5557 (tANI_U16) frameLen,
5558 (void **) &pAddBARspBuffer,
5559 (void **) &pPacket )))
5560 {
5561 // Log error
5562 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005563 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005564 frameLen,
5565 halStatus );
5566
5567 statusCode = eSIR_MEM_ALLOC_FAILED;
5568 goto returnAfterError;
5569 }
5570
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305571 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005572
5573 // Copy necessary info to BD
5574 if( eSIR_SUCCESS !=
5575 (statusCode = limPopulateMacHeader( pMac,
5576 pAddBARspBuffer,
5577 SIR_MAC_MGMT_FRAME,
5578 SIR_MAC_MGMT_ACTION,
5579 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5580 goto returnAfterError;
5581
5582 // Update A3 with the BSSID
5583
5584 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5585
5586 #if 0
5587 cfgLen = SIR_MAC_ADDR_LENGTH;
5588 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5589 WNI_CFG_BSSID,
5590 (tANI_U8 *) pMacHdr->bssId,
5591 &cfgLen ))
5592 {
5593 limLog( pMac, LOGP,
5594 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005595 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005596
5597 // FIXME - Need to convert to tSirRetStatus
5598 statusCode = eSIR_FAILURE;
5599 goto returnAfterError;
5600 }
5601 #endif // TO SUPPORT BT-AMP
5602 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5603
Chet Lanctot186b5732013-03-18 10:26:30 -07005604#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005605 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005606#endif
5607
Jeff Johnson295189b2012-06-20 16:38:30 -07005608 // Now, we're ready to "pack" the frames
5609 nStatus = dot11fPackAddBARsp( pMac,
5610 &frmAddBARsp,
5611 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5612 nPayload,
5613 &nPayload );
5614
5615 if( DOT11F_FAILED( nStatus ))
5616 {
5617 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005618 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005619 nStatus );
5620
5621 // FIXME - Need to convert to tSirRetStatus
5622 statusCode = eSIR_FAILURE;
5623 goto returnAfterError;
5624 }
5625 else if( DOT11F_WARNED( nStatus ))
5626 {
5627 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005628 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5629 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005630 }
5631
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05305632 limLog( pMac, LOG1, FL( "Sending an ADDBA RSP to "MAC_ADDRESS_STR " with"
5633 " tid = %d policy = %d buffsize = %d"
5634 " amsduSupported = %d status %d"),
5635 MAC_ADDR_ARRAY(pMlmAddBARsp->peerMacAddr),
5636 frmAddBARsp.AddBAParameterSet.tid,
5637 frmAddBARsp.AddBAParameterSet.policy,
5638 frmAddBARsp.AddBAParameterSet.bufferSize,
5639 frmAddBARsp.AddBAParameterSet.amsduSupported,
5640 frmAddBARsp.Status.status);
5641
Jeff Johnson295189b2012-06-20 16:38:30 -07005642
5643 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005644 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5645 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005646 )
5647 {
5648 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5649 }
5650
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305651 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5652 psessionEntry->peSessionId,
5653 pMacHdr->fc.subType));
5654 halStatus = halTxFrame( pMac,
5655 pPacket,
5656 (tANI_U16) frameLen,
5657 HAL_TXRX_FRM_802_11_MGMT,
5658 ANI_TXDIR_TODS,
5659 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5660 limTxComplete,
5661 pAddBARspBuffer, txFlag );
5662 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5663 psessionEntry->peSessionId,
5664 halStatus));
5665 if( eHAL_STATUS_SUCCESS != halStatus )
5666 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005667 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005668 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005669 halStatus );
5670
5671 // FIXME - HAL error codes are different from PE error
5672 // codes!! And, this routine is returning tSirRetStatus
5673 statusCode = eSIR_FAILURE;
5674 //Pkt will be freed up by the callback
5675 return statusCode;
5676 }
5677 else
5678 return eSIR_SUCCESS;
5679
5680 returnAfterError:
Jeff Johnson295189b2012-06-20 16:38:30 -07005681 // Release buffer, if allocated
5682 if( NULL != pAddBARspBuffer )
5683 palPktFree( pMac->hHdd,
5684 HAL_TXRX_FRM_802_11_MGMT,
5685 (void *) pAddBARspBuffer,
5686 (void *) pPacket );
5687
5688 return statusCode;
5689}
5690
5691/**
5692 * \brief Send a DELBA Indication Action Frame to peer
5693 *
5694 * \sa limSendDelBAInd
5695 *
5696 * \param pMac The global tpAniSirGlobal object
5697 *
5698 * \param peerMacAddr MAC Address of peer
5699 *
5700 * \param reasonCode Reason for the DELBA notification
5701 *
5702 * \param pBAParameterSet The DELBA Parameter Set.
5703 * This identifies the TID for which the BA session is
5704 * being deleted.
5705 *
5706 * \return eSIR_SUCCESS if setup completes successfully
5707 * eSIR_FAILURE is some problem is encountered
5708 */
5709tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5710 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5711{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305712 tDot11fDelBAInd frmDelBAInd;
5713 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005714 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305715 tpSirMacMgmtHdr pMacHdr;
5716 tANI_U32 frameLen = 0, nStatus, nPayload;
5717 tSirRetStatus statusCode;
5718 eHalStatus halStatus;
5719 void *pPacket;
5720 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005721
5722 if(NULL == psessionEntry)
5723 {
5724 return eSIR_FAILURE;
5725 }
5726
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305727 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005728
5729 // Category - 3 (BA)
5730 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5731 // Action - 2 (DELBA)
5732 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5733
5734 // Fill the DELBA Parameter Set as provided by caller
5735 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5736 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5737
5738 // BA Starting Sequence Number
5739 // Fragment number will always be zero
5740 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5741
5742 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5743
5744 if( DOT11F_FAILED( nStatus ))
5745 {
5746 limLog( pMac, LOGW,
5747 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005748 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005749 nStatus );
5750
5751 // We'll fall back on the worst case scenario:
5752 nPayload = sizeof( tDot11fDelBAInd );
5753 }
5754 else if( DOT11F_WARNED( nStatus ))
5755 {
5756 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005757 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005758 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005759 nStatus );
5760 }
5761
5762 // Add the MGMT header to frame length
5763 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5764
5765 // Allocate shared memory
5766 if( eHAL_STATUS_SUCCESS !=
5767 (halStatus = palPktAlloc( pMac->hHdd,
5768 HAL_TXRX_FRM_802_11_MGMT,
5769 (tANI_U16) frameLen,
5770 (void **) &pDelBAIndBuffer,
5771 (void **) &pPacket )))
5772 {
5773 // Log error
5774 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005775 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005776 frameLen,
5777 halStatus );
5778
5779 statusCode = eSIR_MEM_ALLOC_FAILED;
5780 goto returnAfterError;
5781 }
5782
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305783 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005784
5785 // Copy necessary info to BD
5786 if( eSIR_SUCCESS !=
5787 (statusCode = limPopulateMacHeader( pMac,
5788 pDelBAIndBuffer,
5789 SIR_MAC_MGMT_FRAME,
5790 SIR_MAC_MGMT_ACTION,
5791 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5792 goto returnAfterError;
5793
5794 // Update A3 with the BSSID
5795 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5796
5797 #if 0
5798 cfgLen = SIR_MAC_ADDR_LENGTH;
5799 if( eSIR_SUCCESS != cfgGetStr( pMac,
5800 WNI_CFG_BSSID,
5801 (tANI_U8 *) pMacHdr->bssId,
5802 &cfgLen ))
5803 {
5804 limLog( pMac, LOGP,
5805 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005806 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005807
5808 // FIXME - Need to convert to tSirRetStatus
5809 statusCode = eSIR_FAILURE;
5810 goto returnAfterError;
5811 }
5812 #endif //TO SUPPORT BT-AMP
5813 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5814
Chet Lanctot186b5732013-03-18 10:26:30 -07005815#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005816 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005817#endif
5818
Jeff Johnson295189b2012-06-20 16:38:30 -07005819 // Now, we're ready to "pack" the frames
5820 nStatus = dot11fPackDelBAInd( pMac,
5821 &frmDelBAInd,
5822 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5823 nPayload,
5824 &nPayload );
5825
5826 if( DOT11F_FAILED( nStatus ))
5827 {
5828 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005829 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005830 nStatus );
5831
5832 // FIXME - Need to convert to tSirRetStatus
5833 statusCode = eSIR_FAILURE;
5834 goto returnAfterError;
5835 }
5836 else if( DOT11F_WARNED( nStatus ))
5837 {
5838 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005839 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
5840 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005841 }
5842
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305843 limLog( pMac, LOG1,
5844 FL( "Sending a DELBA IND to: "MAC_ADDRESS_STR" with Tid = %d"
5845 " initiator = %d reason = %d" ),
5846 MAC_ADDR_ARRAY(pMlmDelBAReq->peerMacAddr),
5847 frmDelBAInd.DelBAParameterSet.tid,
5848 frmDelBAInd.DelBAParameterSet.initiator,
5849 frmDelBAInd.Reason.code);
5850
Jeff Johnson295189b2012-06-20 16:38:30 -07005851
5852 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005853 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5854 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005855 )
5856 {
5857 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5858 }
5859
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305860 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5861 psessionEntry->peSessionId,
5862 pMacHdr->fc.subType));
5863 halStatus = halTxFrame( pMac,
5864 pPacket,
5865 (tANI_U16) frameLen,
5866 HAL_TXRX_FRM_802_11_MGMT,
5867 ANI_TXDIR_TODS,
5868 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5869 limTxComplete,
5870 pDelBAIndBuffer, txFlag );
5871 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5872 psessionEntry->peSessionId,
5873 halStatus));
5874 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005875 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005876 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005877 statusCode = eSIR_FAILURE;
5878 //Pkt will be freed up by the callback
5879 return statusCode;
5880 }
5881 else
5882 return eSIR_SUCCESS;
5883
5884 returnAfterError:
5885
5886 // Release buffer, if allocated
5887 if( NULL != pDelBAIndBuffer )
5888 palPktFree( pMac->hHdd,
5889 HAL_TXRX_FRM_802_11_MGMT,
5890 (void *) pDelBAIndBuffer,
5891 (void *) pPacket );
5892
5893 return statusCode;
5894}
5895
5896#if defined WLAN_FEATURE_VOWIFI
5897
5898/**
5899 * \brief Send a Neighbor Report Request Action frame
5900 *
5901 *
5902 * \param pMac Pointer to the global MAC structure
5903 *
5904 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5905 *
5906 * \param peer mac address of peer station.
5907 *
5908 * \param psessionEntry address of session entry.
5909 *
5910 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5911 *
5912 *
5913 */
5914
5915tSirRetStatus
5916limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5917 tpSirMacNeighborReportReq pNeighborReq,
5918 tSirMacAddr peer,
5919 tpPESession psessionEntry
5920 )
5921{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305922 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005923 tDot11fNeighborReportRequest frm;
5924 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305925 tpSirMacMgmtHdr pMacHdr;
5926 tANI_U32 nBytes, nPayload, nStatus;
5927 void *pPacket;
5928 eHalStatus halstatus;
5929 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005930
5931 if ( psessionEntry == NULL )
5932 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005933 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 return eSIR_FAILURE;
5935 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305936 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005937
5938 frm.Category.category = SIR_MAC_ACTION_RRM;
5939 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5940 frm.DialogToken.token = pNeighborReq->dialogToken;
5941
5942
5943 if( pNeighborReq->ssid_present )
5944 {
5945 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5946 }
5947
5948 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5949 if ( DOT11F_FAILED( nStatus ) )
5950 {
5951 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005952 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005953 nStatus );
5954 // We'll fall back on the worst case scenario:
5955 nPayload = sizeof( tDot11fNeighborReportRequest );
5956 }
5957 else if ( DOT11F_WARNED( nStatus ) )
5958 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005959 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005960 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005961 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005962 }
5963
5964 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5965
5966 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5967 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5968 {
5969 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005970 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005971 return eSIR_FAILURE;
5972 }
5973
5974 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305975 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005976
5977 // Copy necessary info to BD
5978 if( eSIR_SUCCESS !=
5979 (statusCode = limPopulateMacHeader( pMac,
5980 pFrame,
5981 SIR_MAC_MGMT_FRAME,
5982 SIR_MAC_MGMT_ACTION,
5983 peer, psessionEntry->selfMacAddr)))
5984 goto returnAfterError;
5985
5986 // Update A3 with the BSSID
5987 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5988
5989 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5990
Chet Lanctot186b5732013-03-18 10:26:30 -07005991#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005992 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005993#endif
5994
Jeff Johnson295189b2012-06-20 16:38:30 -07005995 // Now, we're ready to "pack" the frames
5996 nStatus = dot11fPackNeighborReportRequest( pMac,
5997 &frm,
5998 pFrame + sizeof( tSirMacMgmtHdr ),
5999 nPayload,
6000 &nPayload );
6001
6002 if( DOT11F_FAILED( nStatus ))
6003 {
6004 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006005 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006006 nStatus );
6007
6008 // FIXME - Need to convert to tSirRetStatus
6009 statusCode = eSIR_FAILURE;
6010 goto returnAfterError;
6011 }
6012 else if( DOT11F_WARNED( nStatus ))
6013 {
6014 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006015 FL( "There were warnings while packing Neighbor Report "
6016 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006017 }
6018
6019 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006020 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006021 limPrintMacAddr( pMac, peer, LOGW );
6022
6023 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006024 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6025 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006026 )
6027 {
6028 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6029 }
6030
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306031 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6032 psessionEntry->peSessionId,
6033 pMacHdr->fc.subType));
6034 halstatus = halTxFrame( pMac,
6035 pPacket,
6036 (tANI_U16) nBytes,
6037 HAL_TXRX_FRM_802_11_MGMT,
6038 ANI_TXDIR_TODS,
6039 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6040 limTxComplete,
6041 pFrame, txFlag );
6042 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6043 psessionEntry->peSessionId,
6044 halstatus));
6045 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006046 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006047 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006048 statusCode = eSIR_FAILURE;
6049 //Pkt will be freed up by the callback
6050 return statusCode;
6051 }
6052 else
6053 return eSIR_SUCCESS;
6054
6055returnAfterError:
6056 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6057
6058 return statusCode;
6059} // End limSendNeighborReportRequestFrame.
6060
6061/**
6062 * \brief Send a Link Report Action frame
6063 *
6064 *
6065 * \param pMac Pointer to the global MAC structure
6066 *
6067 * \param pLinkReport Address of a tSirMacLinkReport
6068 *
6069 * \param peer mac address of peer station.
6070 *
6071 * \param psessionEntry address of session entry.
6072 *
6073 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6074 *
6075 *
6076 */
6077
6078tSirRetStatus
6079limSendLinkReportActionFrame(tpAniSirGlobal pMac,
6080 tpSirMacLinkReport pLinkReport,
6081 tSirMacAddr peer,
6082 tpPESession psessionEntry
6083 )
6084{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306085 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006086 tDot11fLinkMeasurementReport frm;
6087 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306088 tpSirMacMgmtHdr pMacHdr;
6089 tANI_U32 nBytes, nPayload, nStatus;
6090 void *pPacket;
6091 eHalStatus halstatus;
6092 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006093
6094
6095 if ( psessionEntry == NULL )
6096 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006097 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006098 return eSIR_FAILURE;
6099 }
6100
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306101 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006102
6103 frm.Category.category = SIR_MAC_ACTION_RRM;
6104 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
6105 frm.DialogToken.token = pLinkReport->dialogToken;
6106
6107
6108 //IEEE Std. 802.11 7.3.2.18. for the report element.
6109 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
6110 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
6111 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
6112 //such case this way than changing the frame parser.
6113 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
6114 frm.TPCEleLen.TPCLen = 2;
6115 frm.TxPower.txPower = pLinkReport->txPower;
6116 frm.LinkMargin.linkMargin = 0;
6117
6118 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
6119 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
6120 frm.RCPI.rcpi = pLinkReport->rcpi;
6121 frm.RSNI.rsni = pLinkReport->rsni;
6122
6123 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
6124 if ( DOT11F_FAILED( nStatus ) )
6125 {
6126 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006127 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006128 nStatus );
6129 // We'll fall back on the worst case scenario:
6130 nPayload = sizeof( tDot11fLinkMeasurementReport );
6131 }
6132 else if ( DOT11F_WARNED( nStatus ) )
6133 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006134 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006135 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006136 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006137 }
6138
6139 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6140
6141 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6142 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6143 {
6144 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006145 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006146 return eSIR_FAILURE;
6147 }
6148
6149 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306150 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006151
6152 // Copy necessary info to BD
6153 if( eSIR_SUCCESS !=
6154 (statusCode = limPopulateMacHeader( pMac,
6155 pFrame,
6156 SIR_MAC_MGMT_FRAME,
6157 SIR_MAC_MGMT_ACTION,
6158 peer, psessionEntry->selfMacAddr)))
6159 goto returnAfterError;
6160
6161 // Update A3 with the BSSID
6162 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6163
6164 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6165
Chet Lanctot186b5732013-03-18 10:26:30 -07006166#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006167 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006168#endif
6169
Jeff Johnson295189b2012-06-20 16:38:30 -07006170 // Now, we're ready to "pack" the frames
6171 nStatus = dot11fPackLinkMeasurementReport( pMac,
6172 &frm,
6173 pFrame + sizeof( tSirMacMgmtHdr ),
6174 nPayload,
6175 &nPayload );
6176
6177 if( DOT11F_FAILED( nStatus ))
6178 {
6179 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006180 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006181 nStatus );
6182
6183 // FIXME - Need to convert to tSirRetStatus
6184 statusCode = eSIR_FAILURE;
6185 goto returnAfterError;
6186 }
6187 else if( DOT11F_WARNED( nStatus ))
6188 {
6189 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006190 FL( "There were warnings while packing Link Report (0x%08x)." ),
6191 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006192 }
6193
6194 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006195 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006196 limPrintMacAddr( pMac, peer, LOGW );
6197
6198 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006199 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6200 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006201 )
6202 {
6203 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6204 }
6205
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306206 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6207 psessionEntry->peSessionId,
6208 pMacHdr->fc.subType));
6209 halstatus = halTxFrame( pMac,
6210 pPacket,
6211 (tANI_U16) nBytes,
6212 HAL_TXRX_FRM_802_11_MGMT,
6213 ANI_TXDIR_TODS,
6214 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6215 limTxComplete,
6216 pFrame, txFlag );
6217 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6218 psessionEntry->peSessionId,
6219 halstatus));
6220 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006221 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006222 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006223 statusCode = eSIR_FAILURE;
6224 //Pkt will be freed up by the callback
6225 return statusCode;
6226 }
6227 else
6228 return eSIR_SUCCESS;
6229
6230returnAfterError:
6231 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6232
6233 return statusCode;
6234} // End limSendLinkReportActionFrame.
6235
6236/**
6237 * \brief Send a Beacon Report Action frame
6238 *
6239 *
6240 * \param pMac Pointer to the global MAC structure
6241 *
6242 * \param dialog_token dialog token to be used in the action frame.
6243 *
6244 * \param num_report number of reports in pRRMReport.
6245 *
6246 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
6247 *
6248 * \param peer mac address of peer station.
6249 *
6250 * \param psessionEntry address of session entry.
6251 *
6252 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6253 *
6254 *
6255 */
6256
6257tSirRetStatus
6258limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
6259 tANI_U8 dialog_token,
6260 tANI_U8 num_report,
6261 tpSirMacRadioMeasureReport pRRMReport,
6262 tSirMacAddr peer,
6263 tpPESession psessionEntry
6264 )
6265{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306266 tSirRetStatus statusCode = eSIR_SUCCESS;
6267 tANI_U8 *pFrame;
6268 tpSirMacMgmtHdr pMacHdr;
6269 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006270 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306271 eHalStatus halstatus;
6272 tANI_U8 i;
6273 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006274
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006275 tDot11fRadioMeasurementReport *frm =
6276 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
6277 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006278 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006279 return eSIR_FAILURE;
6280 }
6281
Jeff Johnson295189b2012-06-20 16:38:30 -07006282 if ( psessionEntry == NULL )
6283 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006284 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006285 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006286 return eSIR_FAILURE;
6287 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306288 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006289
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006290 frm->Category.category = SIR_MAC_ACTION_RRM;
6291 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
6292 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07006293
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006294 frm->num_MeasurementReport = (num_report > RADIO_REPORTS_MAX_IN_A_FRAME ) ? RADIO_REPORTS_MAX_IN_A_FRAME : num_report;
Jeff Johnson295189b2012-06-20 16:38:30 -07006295
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006296 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006297 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006298 frm->MeasurementReport[i].type = pRRMReport[i].type;
6299 frm->MeasurementReport[i].token = pRRMReport[i].token;
6300 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006301 switch( pRRMReport[i].type )
6302 {
6303 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006304 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
6305 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6306 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
6307 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006308 break;
6309 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05306310 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6311 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006312 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006313 break;
6314 }
6315 }
6316
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006317 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07006318 if ( DOT11F_FAILED( nStatus ) )
6319 {
6320 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006321 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006322 nStatus );
6323 // We'll fall back on the worst case scenario:
6324 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006325 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006326 return eSIR_FAILURE;
6327 }
6328 else if ( DOT11F_WARNED( nStatus ) )
6329 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006330 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006331 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006332 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006333 }
6334
6335 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6336
6337 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6338 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6339 {
6340 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006341 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006342 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006343 return eSIR_FAILURE;
6344 }
6345
6346 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306347 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006348
6349 // Copy necessary info to BD
6350 if( eSIR_SUCCESS !=
6351 (statusCode = limPopulateMacHeader( pMac,
6352 pFrame,
6353 SIR_MAC_MGMT_FRAME,
6354 SIR_MAC_MGMT_ACTION,
6355 peer, psessionEntry->selfMacAddr)))
6356 goto returnAfterError;
6357
6358 // Update A3 with the BSSID
6359 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6360
6361 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6362
Chet Lanctot186b5732013-03-18 10:26:30 -07006363#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006364 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006365#endif
6366
Jeff Johnson295189b2012-06-20 16:38:30 -07006367 // Now, we're ready to "pack" the frames
6368 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006369 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07006370 pFrame + sizeof( tSirMacMgmtHdr ),
6371 nPayload,
6372 &nPayload );
6373
6374 if( DOT11F_FAILED( nStatus ))
6375 {
6376 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006377 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006378 nStatus );
6379
6380 // FIXME - Need to convert to tSirRetStatus
6381 statusCode = eSIR_FAILURE;
6382 goto returnAfterError;
6383 }
6384 else if( DOT11F_WARNED( nStatus ))
6385 {
6386 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006387 FL( "There were warnings while packing Radio "
6388 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006389 }
6390
6391 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006392 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006393 limPrintMacAddr( pMac, peer, LOGW );
6394
6395 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006396 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6397 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006398 )
6399 {
6400 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6401 }
6402
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306403 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6404 psessionEntry->peSessionId,
6405 pMacHdr->fc.subType));
6406 halstatus = halTxFrame( pMac,
6407 pPacket,
6408 (tANI_U16) nBytes,
6409 HAL_TXRX_FRM_802_11_MGMT,
6410 ANI_TXDIR_TODS,
6411 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6412 limTxComplete,
6413 pFrame, txFlag );
6414 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6415 psessionEntry->peSessionId,
6416 halstatus));
6417 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006418 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006419 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006420 statusCode = eSIR_FAILURE;
6421 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006422 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006423 return statusCode;
6424 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006425 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006426 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006427 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006428 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006429
6430returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006431 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006432 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07006433 return statusCode;
6434} // End limSendBeaconReportActionFrame.
6435
6436#endif
6437
6438#ifdef WLAN_FEATURE_11W
6439/**
Chet Lanctot8cecea22014-02-11 19:09:36 -08006440 * \brief Send SA query request action frame to peer
6441 *
6442 * \sa limSendSaQueryRequestFrame
6443 *
6444 *
6445 * \param pMac The global tpAniSirGlobal object
6446 *
6447 * \param transId Transaction identifier
6448 *
6449 * \param peer The Mac address of the station to which this action frame is addressed
6450 *
6451 * \param psessionEntry The PE session entry
6452 *
6453 * \return eSIR_SUCCESS if setup completes successfully
6454 * eSIR_FAILURE is some problem is encountered
6455 */
6456
6457tSirRetStatus limSendSaQueryRequestFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
6458 tSirMacAddr peer, tpPESession psessionEntry )
6459{
6460
6461 tDot11fSaQueryReq frm; // SA query request action frame
6462 tANI_U8 *pFrame;
6463 tSirRetStatus nSirStatus;
6464 tpSirMacMgmtHdr pMacHdr;
6465 tANI_U32 nBytes, nPayload, nStatus;
6466 void *pPacket;
6467 eHalStatus halstatus;
6468 tANI_U8 txFlag = 0;
6469
6470 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
6471 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6472 /* 11w action field is :
6473 action: 0 --> SA Query Request action frame
6474 action: 1 --> SA Query Response action frame */
6475 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
6476 /* 11w SA Query Request transId */
6477 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
6478
6479 nStatus = dot11fGetPackedSaQueryReqSize(pMac, &frm, &nPayload);
6480 if ( DOT11F_FAILED( nStatus ) )
6481 {
6482 limLog( pMac, LOGP, FL("Failed to calculate the packed size "
6483 "for an SA Query Request (0x%08x)."),
6484 nStatus );
6485 // We'll fall back on the worst case scenario:
6486 nPayload = sizeof( tDot11fSaQueryReq );
6487 }
6488 else if ( DOT11F_WARNED( nStatus ) )
6489 {
6490 limLog( pMac, LOGW, FL("There were warnings while calculating "
6491 "the packed size for an SA Query Request"
6492 " (0x%08x)."), nStatus );
6493 }
6494
6495 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6496 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6497 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6498 {
6499 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA Query Request "
6500 "action frame"), nBytes );
6501 return eSIR_FAILURE;
6502 }
6503
6504 // Paranoia:
6505 vos_mem_set( pFrame, nBytes, 0 );
6506
6507 // Copy necessary info to BD
6508 nSirStatus = limPopulateMacHeader( pMac,
6509 pFrame,
6510 SIR_MAC_MGMT_FRAME,
6511 SIR_MAC_MGMT_ACTION,
6512 peer, psessionEntry->selfMacAddr );
6513 if ( eSIR_SUCCESS != nSirStatus )
6514 goto returnAfterError;
6515
6516 // Update A3 with the BSSID
6517 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6518
6519 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6520
6521 // Since this is a SA Query Request, set the "protect" (aka WEP) bit
6522 // in the FC
6523 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
6524
6525 // Pack 11w SA Query Request frame
6526 nStatus = dot11fPackSaQueryReq( pMac,
6527 &frm,
6528 pFrame + sizeof( tSirMacMgmtHdr ),
6529 nPayload,
6530 &nPayload );
6531
6532 if ( DOT11F_FAILED( nStatus ))
6533 {
6534 limLog( pMac, LOGE,
6535 FL( "Failed to pack an SA Query Request (0x%08x)." ),
6536 nStatus );
6537 // FIXME - Need to convert to tSirRetStatus
6538 nSirStatus = eSIR_FAILURE;
6539 goto returnAfterError;
6540 }
6541 else if ( DOT11F_WARNED( nStatus ))
6542 {
6543 limLog( pMac, LOGW,
6544 FL( "There were warnings while packing SA Query Request (0x%08x)." ),
6545 nStatus);
6546 }
6547
6548 limLog( pMac, LOG1,
6549 FL( "Sending an SA Query Request to " ));
6550 limPrintMacAddr( pMac, peer, LOG1 );
6551 limPrintMacAddr( pMac, peer, LOGE );
6552 limLog( pMac, LOGE,
6553 FL( "Sending an SA Query Request from " ));
6554 limPrintMacAddr( pMac, psessionEntry->selfMacAddr, LOGE );
6555
6556 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
6557#ifdef WLAN_FEATURE_P2P
6558 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6559 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
6560#endif
6561 )
6562 {
6563 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6564 }
6565
6566 halstatus = halTxFrame( pMac,
6567 pPacket,
6568 (tANI_U16) nBytes,
6569 HAL_TXRX_FRM_802_11_MGMT,
6570 ANI_TXDIR_TODS,
6571 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6572 limTxComplete,
6573 pFrame, txFlag );
6574 if ( eHAL_STATUS_SUCCESS != halstatus )
6575 {
6576 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6577 nSirStatus = eSIR_FAILURE;
6578 //Pkt will be freed up by the callback
6579 return nSirStatus;
6580 }
6581 else {
6582 return eSIR_SUCCESS;
6583 }
6584
6585returnAfterError:
6586 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6587 return nSirStatus;
6588} // End limSendSaQueryRequestFrame
6589
6590/**
Jeff Johnson295189b2012-06-20 16:38:30 -07006591 * \brief Send SA query response action frame to peer
6592 *
6593 * \sa limSendSaQueryResponseFrame
6594 *
6595 *
6596 * \param pMac The global tpAniSirGlobal object
6597 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006598 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006599 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006600 * \param peer The Mac address of the AP to which this action frame is addressed
6601 *
6602 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07006603 *
6604 * \return eSIR_SUCCESS if setup completes successfully
6605 * eSIR_FAILURE is some problem is encountered
6606 */
6607
Chet Lanctot186b5732013-03-18 10:26:30 -07006608tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006609tSirMacAddr peer,tpPESession psessionEntry)
6610{
6611
Chet Lanctot186b5732013-03-18 10:26:30 -07006612 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006613 tANI_U8 *pFrame;
6614 tSirRetStatus nSirStatus;
6615 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07006616 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006617 void *pPacket;
6618 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306619 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006620
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306621 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07006622 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6623 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07006624 action: 0 --> SA query request action frame
6625 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07006626 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
6627 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07006628 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07006629 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006630
Chet Lanctot186b5732013-03-18 10:26:30 -07006631 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6632 if ( DOT11F_FAILED( nStatus ) )
6633 {
6634 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6635 "or a SA Query Response (0x%08x)."),
6636 nStatus );
6637 // We'll fall back on the worst case scenario:
6638 nPayload = sizeof( tDot11fSaQueryRsp );
6639 }
6640 else if ( DOT11F_WARNED( nStatus ) )
6641 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006642 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006643 "the packed size for an SA Query Response"
6644 " (0x%08x)."), nStatus );
6645 }
6646
Jeff Johnson295189b2012-06-20 16:38:30 -07006647 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6648 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6649 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6650 {
6651 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006652 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006653 return eSIR_FAILURE;
6654 }
6655
6656 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306657 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006658
Chet Lanctot186b5732013-03-18 10:26:30 -07006659 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006660 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006661 pFrame,
6662 SIR_MAC_MGMT_FRAME,
6663 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006664 peer, psessionEntry->selfMacAddr );
6665 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006666 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006667
Chet Lanctot186b5732013-03-18 10:26:30 -07006668 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006669 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6670
Chet Lanctot186b5732013-03-18 10:26:30 -07006671 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006672
Chet Lanctot186b5732013-03-18 10:26:30 -07006673 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6674 // in the FC
Chet Lanctot8cecea22014-02-11 19:09:36 -08006675 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -07006676
Chet Lanctot186b5732013-03-18 10:26:30 -07006677 // Pack 11w SA query response frame
6678 nStatus = dot11fPackSaQueryRsp( pMac,
6679 &frm,
6680 pFrame + sizeof( tSirMacMgmtHdr ),
6681 nPayload,
6682 &nPayload );
6683
6684 if ( DOT11F_FAILED( nStatus ))
6685 {
6686 limLog( pMac, LOGE,
6687 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6688 nStatus );
6689 // FIXME - Need to convert to tSirRetStatus
6690 nSirStatus = eSIR_FAILURE;
6691 goto returnAfterError;
6692 }
6693 else if ( DOT11F_WARNED( nStatus ))
6694 {
6695 limLog( pMac, LOGW,
6696 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6697 nStatus);
6698 }
6699
6700 limLog( pMac, LOG1,
6701 FL( "Sending a SA Query Response to " ));
6702 limPrintMacAddr( pMac, peer, LOGW );
6703
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006704 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006705#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006706 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6707 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006708#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006709 )
6710 {
6711 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6712 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006713
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306714 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6715 psessionEntry->peSessionId,
6716 pMacHdr->fc.subType));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006717 halstatus = halTxFrame( pMac,
6718 pPacket,
6719 (tANI_U16) nBytes,
6720 HAL_TXRX_FRM_802_11_MGMT,
6721 ANI_TXDIR_TODS,
6722 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6723 limTxComplete,
6724 pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306725 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6726 psessionEntry->peSessionId,
6727 halstatus));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006728 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006729 {
6730 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6731 nSirStatus = eSIR_FAILURE;
6732 //Pkt will be freed up by the callback
6733 return nSirStatus;
6734 }
6735 else {
6736 return eSIR_SUCCESS;
6737 }
6738
6739returnAfterError:
6740 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6741 return nSirStatus;
6742} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006743#endif