blob: 92a1d658304fb37e4de77e74e8ae1cf19acc8323 [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
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700269#ifdef WLAN_FEATURE_11W
270/**
271 *
272 * \brief This function is called by various LIM modules to correctly set
273 * the Protected bit in the Frame Control Field of the 802.11 frame MAC header
274 *
275 *
276 * \param pMac Pointer to Global MAC structure
277 *
278 * \param psessionEntry Pointer to session corresponding to the connection
279 *
280 * \param peer Peer address of the STA to which the frame is to be sent
281 *
282 * \param pMacHdr Pointer to the frame MAC header
283 *
284 * \return nothing
285 *
286 *
287 */
288void
289limSetProtectedBit(tpAniSirGlobal pMac,
290 tpPESession psessionEntry,
291 tSirMacAddr peer,
292 tpSirMacMgmtHdr pMacHdr)
293{
294 tANI_U16 aid;
295 tpDphHashNode pStaDs;
296
297 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
298 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
299 {
300
301 pStaDs = dphLookupHashEntry( pMac, peer, &aid, &psessionEntry->dph.dphHashTable );
302 if( pStaDs != NULL )
303 if( pStaDs->rmfEnabled )
304 pMacHdr->fc.wep = 1;
305 }
306 else if ( psessionEntry->limRmfEnabled )
307 pMacHdr->fc.wep = 1;
308} /*** end limSetProtectedBit() ***/
309#endif
310
Jeff Johnson295189b2012-06-20 16:38:30 -0700311/**
312 * \brief limSendProbeReqMgmtFrame
313 *
314 *
315 * \param pMac Pointer to Global MAC structure
316 *
317 * \param pSsid SSID to be sent in Probe Request frame
318 *
319 * \param bssid BSSID to be sent in Probe Request frame
320 *
321 * \param nProbeDelay probe delay to be used before sending Probe Request
322 * frame
323 *
324 * \param nChannelNum Channel # on which the Probe Request is going out
325 *
326 * \param nAdditionalIELen if non-zero, include pAdditionalIE in the Probe Request frame
327 *
328 * \param pAdditionalIE if nAdditionalIELen is non zero, include this field in the Probe Request frame
329 *
330 * This function is called by various LIM modules to send Probe Request frame
331 * during active scan/learn phase.
332 * Probe request is sent out in the following scenarios:
333 * --heartbeat failure: session needed
334 * --join req: session needed
335 * --foreground scan: no session
336 * --background scan: no session
337 * --schBeaconProcessing: to get EDCA parameters: session needed
338 *
339 *
340 */
341tSirRetStatus
342limSendProbeReqMgmtFrame(tpAniSirGlobal pMac,
343 tSirMacSSid *pSsid,
344 tSirMacAddr bssid,
345 tANI_U8 nChannelNum,
346 tSirMacAddr SelfMacAddr,
347 tANI_U32 dot11mode,
348 tANI_U32 nAdditionalIELen,
349 tANI_U8 *pAdditionalIE)
350{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530351 tDot11fProbeRequest pr;
352 tANI_U32 nStatus, nBytes, nPayload;
353 tSirRetStatus nSirStatus;
354 tANI_U8 *pFrame;
355 void *pPacket;
356 eHalStatus halstatus;
357 tpPESession psessionEntry;
358 tANI_U8 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700359 tANI_U8 *p2pIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530360 tANI_U32 txFlag = 0;
Sandeep Puligilla60342762014-01-30 21:05:37 +0530361 tANI_U32 chanbond24G = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700362
363#ifndef GEN4_SCAN
364 return eSIR_FAILURE;
365#endif
366
367#if defined ( ANI_DVT_DEBUG )
368 return eSIR_FAILURE;
369#endif
370
Abhishek Singh4beed422014-02-03 16:47:17 +0530371 /* The probe req should not send 11ac capabilieties if band is 2.4GHz,
372 * unless enableVhtFor24GHz is enabled in INI. So if enableVhtFor24GHz
373 * is false and dot11mode is 11ac set it to 11n.
374 */
375 if ( nChannelNum <= SIR_11B_CHANNEL_END &&
376 ( FALSE == pMac->roam.configParam.enableVhtFor24GHz ) &&
377 ( WNI_CFG_DOT11_MODE_11AC == dot11mode ||
378 WNI_CFG_DOT11_MODE_11AC_ONLY == dot11mode ) )
379 dot11mode = WNI_CFG_DOT11_MODE_11N;
Jeff Johnson295189b2012-06-20 16:38:30 -0700380 /*
381 * session context may or may not be present, when probe request needs to be sent out.
382 * following cases exist:
383 * --heartbeat failure: session needed
384 * --join req: session needed
385 * --foreground scan: no session
386 * --background scan: no session
387 * --schBeaconProcessing: to get EDCA parameters: session needed
388 * If session context does not exist, some IEs will be populated from CFGs,
389 * e.g. Supported and Extended rate set IEs
390 */
391 psessionEntry = peFindSessionByBssid(pMac,bssid,&sessionId);
392
393 // The scheme here is to fill out a 'tDot11fProbeRequest' structure
394 // and then hand it off to 'dot11fPackProbeRequest' (for
395 // serialization). We start by zero-initializing the structure:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530396 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700397
398 // & delegating to assorted helpers:
399 PopulateDot11fSSID( pMac, pSsid, &pr.SSID );
400
Jeff Johnson295189b2012-06-20 16:38:30 -0700401 if( nAdditionalIELen && pAdditionalIE )
402 {
403 p2pIe = limGetP2pIEPtr(pMac, pAdditionalIE, nAdditionalIELen);
404 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700405 /* Don't include 11b rate only when device is doing P2P Search */
406 if( ( WNI_CFG_DOT11_MODE_11B != dot11mode ) &&
407 ( p2pIe != NULL ) &&
408 /* Don't include 11b rate if it is a P2P serach or probe request is sent by P2P Client */
409 ( ( ( pMac->lim.gpLimMlmScanReq != NULL ) &&
410 pMac->lim.gpLimMlmScanReq->p2pSearch ) ||
411 ( ( psessionEntry != NULL ) &&
412 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
413 )
414 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700415 {
416 /* In the below API pass channel number > 14, do that it fills only
417 * 11a rates in supported rates */
418 PopulateDot11fSuppRates( pMac, 15, &pr.SuppRates,psessionEntry);
419 }
420 else
421 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700422 PopulateDot11fSuppRates( pMac, nChannelNum,
423 &pr.SuppRates,psessionEntry);
424
425 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
426 {
427 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
428 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700429 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700430
431#if defined WLAN_FEATURE_VOWIFI
432 //Table 7-14 in IEEE Std. 802.11k-2008 says
433 //DS params "can" be present in RRM is disabled and "is" present if
434 //RRM is enabled. It should be ok even if we add it into probe req when
435 //RRM is not enabled.
436 PopulateDot11fDSParams( pMac, &pr.DSParams, nChannelNum, psessionEntry );
437 //Call RRM module to get the tx power for management used.
438 {
439 tANI_U8 txPower = (tANI_U8) rrmGetMgmtTxPower( pMac, psessionEntry );
440 PopulateDot11fWFATPC( pMac, &pr.WFATPC, txPower, 0 );
441 }
442#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700443
444 if (psessionEntry != NULL ) {
Jeff Johnsone7245742012-09-05 17:12:55 -0700445 psessionEntry->htCapability = IS_DOT11_MODE_HT(dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700446 //Include HT Capability IE
Jeff Johnsone7245742012-09-05 17:12:55 -0700447 if (psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -0700448 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700449 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700450 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700451 } else { //psessionEntry == NULL
452 if (IS_DOT11_MODE_HT(dot11mode))
Jeff Johnson295189b2012-06-20 16:38:30 -0700453 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700454 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700455 }
456 }
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800457
Sandeep Puligilla60342762014-01-30 21:05:37 +0530458 /* Get HT40 capability for 2.4GHz band */
459 wlan_cfgGetInt(pMac,WNI_CFG_CHANNEL_BONDING_24G,&chanbond24G);
460 if( (nChannelNum <= SIR_11B_CHANNEL_END) && chanbond24G != TRUE)
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800461 {
462 pr.HTCaps.supportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
463 pr.HTCaps.shortGI40MHz = 0;
464 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700465#ifdef WLAN_FEATURE_11AC
466 if (psessionEntry != NULL ) {
467 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
468 //Include HT Capability IE
469 if (psessionEntry->vhtCapability)
470 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700471 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
472 }
473 } else {
474 if (IS_DOT11_MODE_VHT(dot11mode))
475 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700476 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
477 }
478 }
479#endif
480
Jeff Johnson295189b2012-06-20 16:38:30 -0700481
482 // That's it-- now we pack it. First, how much space are we going to
483 // need?
484 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
485 if ( DOT11F_FAILED( nStatus ) )
486 {
487 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700488 "or a Probe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700489 // We'll fall back on the worst case scenario:
490 nPayload = sizeof( tDot11fProbeRequest );
491 }
492 else if ( DOT11F_WARNED( nStatus ) )
493 {
494 limLog( pMac, LOGW, FL("There were warnings while calculating"
495 "the packed size for a Probe Request ("
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700496 "0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700497 }
498
499 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAdditionalIELen;
500
501 // Ok-- try to allocate some memory:
502 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
503 ( tANI_U16 )nBytes, ( void** ) &pFrame,
504 ( void** ) &pPacket );
505 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
506 {
507 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700508 "be Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700509 return eSIR_MEM_ALLOC_FAILED;
510 }
511
512 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530513 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700514
515 // Next, we fill out the buffer descriptor:
516 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530517 SIR_MAC_MGMT_PROBE_REQ, bssid, SelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700518 if ( eSIR_SUCCESS != nSirStatus )
519 {
520 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700521 "tor for a Probe Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700522 nSirStatus );
523 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
524 ( void* ) pFrame, ( void* ) pPacket );
525 return nSirStatus; // allocated!
526 }
527
528 // That done, pack the Probe Request:
529 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
530 sizeof( tSirMacMgmtHdr ),
531 nPayload, &nPayload );
532 if ( DOT11F_FAILED( nStatus ) )
533 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700534 limLog( pMac, LOGE, FL("Failed to pack a Probe Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700535 nStatus );
536 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
537 return eSIR_FAILURE; // allocated!
538 }
539 else if ( DOT11F_WARNED( nStatus ) )
540 {
541 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800542 "robe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 }
544
545 // Append any AddIE if present.
546 if( nAdditionalIELen )
547 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530548 vos_mem_copy( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700549 pAdditionalIE, nAdditionalIELen );
550 nPayload += nAdditionalIELen;
551 }
552
553 /* If this probe request is sent during P2P Search State, then we need
554 * to send it at OFDM rate.
555 */
556 if( ( SIR_BAND_5_GHZ == limGetRFBand(nChannelNum))
Jeff Johnson295189b2012-06-20 16:38:30 -0700557 || (( pMac->lim.gpLimMlmScanReq != NULL) &&
558 pMac->lim.gpLimMlmScanReq->p2pSearch )
Gopichand Nakkala67967212013-02-15 17:31:15 +0530559 /* For unicast probe req mgmt from Join function
560 we don't set above variables. So we need to add
561 one more check whether it is pePersona is P2P_CLIENT or not */
562 || ( ( psessionEntry != NULL ) &&
563 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700564 )
565 {
566 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
567 }
568
Jeff Johnson295189b2012-06-20 16:38:30 -0700569 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload,
570 HAL_TXRX_FRM_802_11_MGMT,
571 ANI_TXDIR_TODS,
572 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
573 limTxComplete, pFrame, txFlag );
574 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
575 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700576 limLog( pMac, LOGE, FL("could not send Probe Request frame!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700577 //Pkt will be freed up by the callback
578 return eSIR_FAILURE;
579 }
580
581 return eSIR_SUCCESS;
582} // End limSendProbeReqMgmtFrame.
583
Jeff Johnson295189b2012-06-20 16:38:30 -0700584tSirRetStatus limGetAddnIeForProbeResp(tpAniSirGlobal pMac,
585 tANI_U8* addIE, tANI_U16 *addnIELen,
586 tANI_U8 probeReqP2pIe)
587{
588 /* If Probe request doesn't have P2P IE, then take out P2P IE
589 from additional IE */
590 if(!probeReqP2pIe)
591 {
592 tANI_U8* tempbuf = NULL;
593 tANI_U16 tempLen = 0;
594 int left = *addnIELen;
595 v_U8_t *ptr = addIE;
596 v_U8_t elem_id, elem_len;
597
598 if(NULL == addIE)
599 {
600 PELOGE(limLog(pMac, LOGE,
601 FL(" NULL addIE pointer"));)
602 return eSIR_FAILURE;
603 }
604
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530605 tempbuf = vos_mem_malloc(left);
606 if ( NULL == tempbuf )
Jeff Johnson295189b2012-06-20 16:38:30 -0700607 {
608 PELOGE(limLog(pMac, LOGE,
609 FL("Unable to allocate memory to store addn IE"));)
610 return eSIR_MEM_ALLOC_FAILED;
611 }
612
613 while(left >= 2)
614 {
615 elem_id = ptr[0];
616 elem_len = ptr[1];
617 left -= 2;
618 if(elem_len > left)
619 {
620 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700621 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700622 elem_id,elem_len,left);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530623 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700624 return eSIR_FAILURE;
625 }
626 if ( !( (SIR_MAC_EID_VENDOR == elem_id) &&
627 (memcmp(&ptr[2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)==0) ) )
628 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530629 vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -0700630 tempLen += (elem_len + 2);
631 }
632 left -= elem_len;
633 ptr += (elem_len + 2);
634 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530635 vos_mem_copy (addIE, tempbuf, tempLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 *addnIELen = tempLen;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530637 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 }
639 return eSIR_SUCCESS;
640}
Jeff Johnson295189b2012-06-20 16:38:30 -0700641
642void
643limSendProbeRspMgmtFrame(tpAniSirGlobal pMac,
644 tSirMacAddr peerMacAddr,
645 tpAniSSID pSsid,
646 short nStaId,
647 tANI_U8 nKeepAlive,
648 tpPESession psessionEntry,
649 tANI_U8 probeReqP2pIe)
650{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700651 tDot11fProbeResponse *pFrm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530652 tSirRetStatus nSirStatus;
c_hpothubcd78652014-04-28 22:31:08 +0530653 tANI_U32 cfg, nPayload, nStatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530654 tpSirMacMgmtHdr pMacHdr;
655 tANI_U8 *pFrame;
656 void *pPacket;
657 eHalStatus halstatus;
658 tANI_U32 addnIEPresent;
659 tANI_U32 addnIE1Len=0;
660 tANI_U32 addnIE2Len=0;
661 tANI_U32 addnIE3Len=0;
662 tANI_U16 totalAddnIeLen = 0;
663 tANI_U32 wpsApEnable=0, tmp;
664 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700665 tANI_U8 *addIE = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530666 tANI_U8 *pP2pIe = NULL;
667 tANI_U8 noaLen = 0;
668 tANI_U8 total_noaLen = 0;
669 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN
Jeff Johnson295189b2012-06-20 16:38:30 -0700670 + SIR_P2P_IE_HEADER_LEN];
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530671 tANI_U8 noaIe[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Kalikinkar dhara205da782014-03-21 15:49:32 -0700672 tDot11fIEExtCap extractedExtCap;
673 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +0530674 tANI_U32 nBytes = 0;
675
Jeff Johnson295189b2012-06-20 16:38:30 -0700676 if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests
677 {
678 return; // in this case.
679 }
680
681 if(NULL == psessionEntry)
682 {
683 return;
684 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530685
686 pFrm = vos_mem_malloc(sizeof(tDot11fProbeResponse));
687 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700688 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530689 limLog(pMac, LOGE, FL("Unable to allocate memory in limSendProbeRspMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700690 return;
691 }
692
Jeff Johnson295189b2012-06-20 16:38:30 -0700693 // Fill out 'frm', after which we'll just hand the struct off to
694 // 'dot11fPackProbeResponse'.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530695 vos_mem_set(( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700696
697 // Timestamp to be updated by TFP, below.
698
699 // Beacon Interval:
Jeff Johnson295189b2012-06-20 16:38:30 -0700700 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
701 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700702 pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -0700703 }
704 else
705 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800706 nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg);
707 if (eSIR_SUCCESS != nSirStatus)
708 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700709 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d)."),
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800710 nSirStatus );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530711 vos_mem_free(pFrm);
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800712 return;
713 }
714 pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg;
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800715 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700716
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700717 PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry );
718 PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700719 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700720 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700721
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700722 PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry);
723 PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700724
Jeff Johnson295189b2012-06-20 16:38:30 -0700725
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
727 {
728 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
729 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700730 PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700731 }
732 }
733 else
734 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800735 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700736 limLog(pMac, LOGP,"Failed to cfg get id %d", WNI_CFG_WPS_ENABLE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700737
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800738 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
Jeff Johnson295189b2012-06-20 16:38:30 -0700739
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800740 if (wpsApEnable)
741 {
742 PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes);
743 }
744
745 if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
746 {
747 PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
748 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
749 }
750
751 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
752 {
753 DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
754 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
755 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700756 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700757
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700758 PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry);
759 PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700760
Jeff Johnson295189b2012-06-20 16:38:30 -0700761
762 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700763 PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700764
765
766 // N.B. In earlier implementations, the RSN IE would be placed in
767 // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined.
768 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700769 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700770
771 //Populate HT IEs, when operating in 11n or Taurus modes.
Jeff Johnsone7245742012-09-05 17:12:55 -0700772 if ( psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -0700773 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700774 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700775 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700776 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700777#ifdef WLAN_FEATURE_11AC
778 if(psessionEntry->vhtCapability)
779 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -0800780 limLog( pMac, LOG1, FL("Populate VHT IE in Probe Response"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700781 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
782 PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation );
Jeff Johnsone7245742012-09-05 17:12:55 -0700783 // we do not support multi users yet
784 //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad );
Sandeep Puligilla60342762014-01-30 21:05:37 +0530785 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -0700786 }
787#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700788
Sandeep Puligilla60342762014-01-30 21:05:37 +0530789
Jeff Johnson295189b2012-06-20 16:38:30 -0700790 if ( psessionEntry->pLimStartBssReq )
791 {
792 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700793 &pFrm->WPA );
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700794 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
795 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -0700796 }
797
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700798 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700799
800#if defined(FEATURE_WLAN_WAPI)
801 if( psessionEntry->pLimStartBssReq )
802 {
803 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700804 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700805 }
806
807#endif // defined(FEATURE_WLAN_WAPI)
808
Jeff Johnson295189b2012-06-20 16:38:30 -0700809 addnIEPresent = false;
Jeff Johnson295189b2012-06-20 16:38:30 -0700810 if( pMac->lim.gpLimRemainOnChanReq )
811 {
812 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
813 }
814 //Only use CFG for non-listen mode. This CFG is not working for concurrency
815 //In listening mode, probe rsp IEs is passed in the message from SME to PE
816 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700817 {
818
819 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
820 &addnIEPresent) != eSIR_SUCCESS)
821 {
822 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530823 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700824 return;
825 }
826 }
827
828 if (addnIEPresent)
829 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530830
831 addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3);
832 if ( NULL == addIE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700833 {
834 PELOGE(limLog(pMac, LOGE,
835 FL("Unable to allocate memory to store addn IE"));)
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530836 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700837 return;
838 }
839
840 //Probe rsp IE available
841 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
842 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
843 {
844 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530845 vos_mem_free(addIE);
846 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700847 return;
848 }
849 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
850 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
851 {
852 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
853 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
854 &addnIE1Len) )
855 {
856 limLog(pMac, LOGP,
857 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530858 vos_mem_free(addIE);
859 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700860 return;
861 }
862 }
863
864 //Probe rsp IE available
865 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
866 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
867 {
868 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530869 vos_mem_free(addIE);
870 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 return;
872 }
873 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
874 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
875 {
876 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
877 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
878 &addnIE2Len) )
879 {
880 limLog(pMac, LOGP,
881 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530882 vos_mem_free(addIE);
883 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700884 return;
885 }
886 }
887
888 //Probe rsp IE available
889 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
890 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
891 {
892 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530893 vos_mem_free(addIE);
894 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 return;
896 }
897 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
898 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
899 {
900 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
901 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
902 &addIE[addnIE1Len + addnIE2Len],
903 &addnIE3Len) )
904 {
905 limLog(pMac, LOGP,
906 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530907 vos_mem_free(addIE);
908 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700909 return;
910 }
911 }
912 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
913
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
915 {
916 limLog(pMac, LOGP,
917 FL("Unable to get final Additional IE for Probe Req"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530918 vos_mem_free(addIE);
919 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700920 return;
921 }
Kalikinkar dhara205da782014-03-21 15:49:32 -0700922
923 vos_mem_set(( tANI_U8* )&extractedExtCap,
924 sizeof( tDot11fIEExtCap ), 0);
925 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
926 addIE,
927 &totalAddnIeLen,
928 &extractedExtCap );
929 if(eSIR_SUCCESS != nSirStatus )
930 {
931 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
932 limLog(pMac, LOG1,
933 FL("Unable to Stripoff ExtCap IE from Probe Rsp"));
934 }
935
Jeff Johnson295189b2012-06-20 16:38:30 -0700936 nBytes = nBytes + totalAddnIeLen;
937
938 if (probeReqP2pIe)
939 {
940 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
941 if (pP2pIe != NULL)
942 {
943 //get NoA attribute stream P2P IE
944 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
945 if (noaLen != 0)
946 {
947 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
948 &noaStream[0], noaLen);
949 nBytes = nBytes + total_noaLen;
950 }
951 }
952 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700953 }
954
c_hpothubcd78652014-04-28 22:31:08 +0530955 /*merge ExtCap IE*/
956 if (extractedExtCapFlag && extractedExtCap.present)
957 {
958 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
959 }
960
961 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
962 if ( DOT11F_FAILED( nStatus ) )
963 {
964 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
965 "or a Probe Response (0x%08x)."),
966 nStatus );
967 // We'll fall back on the worst case scenario:
968 nPayload = sizeof( tDot11fProbeResponse );
969 }
970 else if ( DOT11F_WARNED( nStatus ) )
971 {
972 limLog( pMac, LOGW, FL("There were warnings while calculating"
973 "the packed size for a Probe Response "
974 "(0x%08x)."), nStatus );
975 }
976
977 nBytes += nPayload + sizeof( tSirMacMgmtHdr );
978
Jeff Johnson295189b2012-06-20 16:38:30 -0700979 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
980 ( tANI_U16 )nBytes, ( void** ) &pFrame,
981 ( void** ) &pPacket );
982 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
983 {
984 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700985 "be Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700986 if ( addIE != NULL )
987 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530988 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700989 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530990 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700991 return;
992 }
993
994 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530995 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700996
997 // Next, we fill out the buffer descriptor:
998 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
999 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
1000 if ( eSIR_SUCCESS != nSirStatus )
1001 {
1002 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001003 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001004 nSirStatus );
1005 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1006 ( void* ) pFrame, ( void* ) pPacket );
1007 if ( addIE != NULL )
1008 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301009 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001010 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301011 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07001012 return;
1013 }
1014
1015 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1016
1017 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1018
1019 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001020 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -07001021 nPayload, &nPayload );
1022 if ( DOT11F_FAILED( nStatus ) )
1023 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001024 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001025 nStatus );
1026 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1027 if ( addIE != NULL )
1028 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301029 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301031 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07001032 return; // allocated!
1033 }
1034 else if ( DOT11F_WARNED( nStatus ) )
1035 {
1036 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001037 "robe Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001038 }
1039
1040 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
1041 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1042
1043 pMac->sys.probeRespond++;
1044
Jeff Johnson295189b2012-06-20 16:38:30 -07001045 if( pMac->lim.gpLimRemainOnChanReq )
1046 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301047 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -07001048 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
1049 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001050
1051 if ( addnIEPresent )
1052 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301053 vos_mem_copy(pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], totalAddnIeLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001054 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001055 if (noaLen != 0)
1056 {
Krunal Soni81b24262013-05-15 17:46:41 -07001057 if (total_noaLen > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -07001058 {
1059 limLog(pMac, LOGE,
Kaushik, Sushant96ac9d72013-12-11 19:28:10 +05301060 FL("Not able to insert NoA because of length constraint."
1061 "Total Length is :%d"),total_noaLen);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301062 vos_mem_free(addIE);
1063 vos_mem_free(pFrm);
Krunal Soni81b24262013-05-15 17:46:41 -07001064 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1065 ( void* ) pFrame, ( void* ) pPacket );
1066 return;
1067 }
1068 else
1069 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301070 vos_mem_copy( &pFrame[nBytes - (total_noaLen)],
Krunal Soni81b24262013-05-15 17:46:41 -07001071 &noaIe[0], total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001072 }
1073 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001074
1075 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001076 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1077 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001078 )
1079 {
1080 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1081 }
1082
1083 // Queue Probe Response frame in high priority WQ
1084 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
1085 ( tANI_U16 ) nBytes,
1086 HAL_TXRX_FRM_802_11_MGMT,
1087 ANI_TXDIR_TODS,
1088 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
1089 limTxComplete, pFrame, txFlag );
1090 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1091 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001092 limLog( pMac, LOGE, FL("Could not send Probe Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001093 //Pkt will be freed up by the callback
1094 }
1095
1096 if ( addIE != NULL )
1097 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301098 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001099 }
1100
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301101 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001102 return;
1103
1104
Jeff Johnson295189b2012-06-20 16:38:30 -07001105} // End limSendProbeRspMgmtFrame.
1106
1107void
1108limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
1109 tSirMacAddr peerMacAddr,
1110 tSirAddtsReqInfo *pAddTS,
1111 tpPESession psessionEntry)
1112{
1113 tANI_U16 i;
1114 tANI_U8 *pFrame;
1115 tSirRetStatus nSirStatus;
1116 tDot11fAddTSRequest AddTSReq;
1117 tDot11fWMMAddTSRequest WMMAddTSReq;
1118 tANI_U32 nPayload, nBytes, nStatus;
1119 tpSirMacMgmtHdr pMacHdr;
1120 void *pPacket;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001121#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001122 tANI_U32 phyMode;
1123#endif
1124 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301125 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001126
1127 if(NULL == psessionEntry)
1128 {
1129 return;
1130 }
1131
1132 if ( ! pAddTS->wmeTspecPresent )
1133 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301134 vos_mem_set(( tANI_U8* )&AddTSReq, sizeof( AddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001135
1136 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1137 AddTSReq.DialogToken.token = pAddTS->dialogToken;
1138 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1139 if ( pAddTS->lleTspecPresent )
1140 {
1141 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
1142 }
1143 else
1144 {
1145 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
1146 }
1147
1148 if ( pAddTS->lleTspecPresent )
1149 {
1150 AddTSReq.num_WMMTCLAS = 0;
1151 AddTSReq.num_TCLAS = pAddTS->numTclas;
1152 for ( i = 0; i < pAddTS->numTclas; ++i)
1153 {
1154 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1155 &AddTSReq.TCLAS[i] );
1156 }
1157 }
1158 else
1159 {
1160 AddTSReq.num_TCLAS = 0;
1161 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
1162 for ( i = 0; i < pAddTS->numTclas; ++i)
1163 {
1164 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1165 &AddTSReq.WMMTCLAS[i] );
1166 }
1167 }
1168
1169 if ( pAddTS->tclasProcPresent )
1170 {
1171 if ( pAddTS->lleTspecPresent )
1172 {
1173 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
1174 AddTSReq.TCLASSPROC.present = 1;
1175 }
1176 else
1177 {
1178 AddTSReq.WMMTCLASPROC.version = 1;
1179 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
1180 AddTSReq.WMMTCLASPROC.present = 1;
1181 }
1182 }
1183
1184 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
1185 if ( DOT11F_FAILED( nStatus ) )
1186 {
1187 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001188 "or an Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001189 nStatus );
1190 // We'll fall back on the worst case scenario:
1191 nPayload = sizeof( tDot11fAddTSRequest );
1192 }
1193 else if ( DOT11F_WARNED( nStatus ) )
1194 {
1195 limLog( pMac, LOGW, FL("There were warnings while calculating"
1196 "the packed size for an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001197 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001198 }
1199 }
1200 else
1201 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301202 vos_mem_set(( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001203
1204 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1205 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1206 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1207
1208 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1209 WMMAddTSReq.StatusCode.statusCode = 0;
1210
1211 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001212#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001213 limGetPhyMode(pMac, &phyMode, psessionEntry);
1214
1215 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1216 {
1217 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1218 }
1219 else
1220 {
1221 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1222 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001223 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.ESETrafStrmRateSet,sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07001224#endif
1225 // fillWmeTspecIE
1226
1227 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1228 if ( DOT11F_FAILED( nStatus ) )
1229 {
1230 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001231 "or a WMM Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001232 nStatus );
1233 // We'll fall back on the worst case scenario:
1234 nPayload = sizeof( tDot11fAddTSRequest );
1235 }
1236 else if ( DOT11F_WARNED( nStatus ) )
1237 {
1238 limLog( pMac, LOGW, FL("There were warnings while calculating"
1239 "the packed size for a WMM Add TS Requ"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001240 "est (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001241 }
1242 }
1243
1244 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1245
1246 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1247 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1248 ( void** ) &pPacket );
1249 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1250 {
1251 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001252 "d TS Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001253 return;
1254 }
1255
1256 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301257 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001258
1259 // Next, we fill out the buffer descriptor:
1260 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1261 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1262 if ( eSIR_SUCCESS != nSirStatus )
1263 {
1264 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001265 "tor for an Add TS Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001266 nSirStatus );
1267 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1268 ( void* ) pFrame, ( void* ) pPacket );
1269 return;
1270 }
1271
1272 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1273
1274 #if 0
1275 cfgLen = SIR_MAC_ADDR_LENGTH;
1276 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1277 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1278 {
1279 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001280 "e sending an Add TS Request.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001281 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1282 ( void* ) pFrame, ( void* ) pPacket );
1283 return;
1284 }
1285 #endif //TO SUPPORT BT-AMP
1286
1287 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1288
Chet Lanctot186b5732013-03-18 10:26:30 -07001289#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001290 limSetProtectedBit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001291#endif
1292
Jeff Johnson295189b2012-06-20 16:38:30 -07001293 // That done, pack the struct:
1294 if ( ! pAddTS->wmeTspecPresent )
1295 {
1296 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1297 pFrame + sizeof(tSirMacMgmtHdr),
1298 nPayload, &nPayload );
1299 if ( DOT11F_FAILED( nStatus ) )
1300 {
1301 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001302 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001303 nStatus );
1304 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1305 return; // allocated!
1306 }
1307 else if ( DOT11F_WARNED( nStatus ) )
1308 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001309 limLog( pMac, LOGW, FL("There were warnings while packing "
1310 "an Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001311 }
1312 }
1313 else
1314 {
1315 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1316 pFrame + sizeof(tSirMacMgmtHdr),
1317 nPayload, &nPayload );
1318 if ( DOT11F_FAILED( nStatus ) )
1319 {
1320 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001321 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001322 nStatus );
1323 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1324 return; // allocated!
1325 }
1326 else if ( DOT11F_WARNED( nStatus ) )
1327 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001328 limLog( pMac, LOGW, FL("There were warnings while packing "
1329 "a WMM Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 }
1331 }
1332
1333 PELOG3(limLog( pMac, LOG3, FL("Sending an Add TS Request frame to ") );
1334 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1335
1336 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001337 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1338 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001339 )
1340 {
1341 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1342 }
1343
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301344 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1345 psessionEntry->peSessionId,
1346 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001347 // Queue Addts Response frame in high priority WQ
1348 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1349 HAL_TXRX_FRM_802_11_MGMT,
1350 ANI_TXDIR_TODS,
1351 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1352 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301353 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1354 psessionEntry->peSessionId,
1355 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001356 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1357 {
1358 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001359 " (%X) ***" ), halstatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001360 //Pkt will be freed up by the callback
1361 }
1362
1363} // End limSendAddtsReqActionFrame.
1364
Jeff Johnson295189b2012-06-20 16:38:30 -07001365
1366
1367void
1368limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1369 tANI_U16 statusCode,
1370 tANI_U16 aid,
1371 tSirMacAddr peerMacAddr,
1372 tANI_U8 subType,
1373 tpDphHashNode pSta,tpPESession psessionEntry)
1374{
1375 static tDot11fAssocResponse frm;
1376 tANI_U8 *pFrame, *macAddr;
1377 tpSirMacMgmtHdr pMacHdr;
1378 tSirRetStatus nSirStatus;
1379 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1380 tHalBitVal qosMode, wmeMode;
c_hpothubcd78652014-04-28 22:31:08 +05301381 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001382 void *pPacket;
1383 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301384 tUpdateBeaconParams beaconParams;
1385 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001386 tANI_U32 addnIEPresent = false;
1387 tANI_U32 addnIELen=0;
1388 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1389 tpSirAssocReq pAssocReq = NULL;
Kalikinkar dhara205da782014-03-21 15:49:32 -07001390 tANI_U16 addStripoffIELen = 0;
1391 tDot11fIEExtCap extractedExtCap;
1392 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_FALSE;
c_hpothubcd78652014-04-28 22:31:08 +05301393 tANI_U32 nBytes = 0;
Kalikinkar dhara205da782014-03-21 15:49:32 -07001394
Chet Lanctot8cecea22014-02-11 19:09:36 -08001395#ifdef WLAN_FEATURE_11W
1396 tANI_U32 retryInterval;
1397 tANI_U32 maxRetries;
1398#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001399
1400 if(NULL == psessionEntry)
1401 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301402 limLog( pMac, LOGE, FL("psessionEntry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001403 return;
1404 }
1405
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301406 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001407
1408 limGetQosMode(psessionEntry, &qosMode);
1409 limGetWmeMode(psessionEntry, &wmeMode);
1410
1411 // An Add TS IE is added only if the AP supports it and the requesting
1412 // STA sent a traffic spec.
1413 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1414
1415 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1416
1417 frm.Status.status = statusCode;
1418
1419 frm.AID.associd = aid | LIM_AID_MASK;
1420
1421 if ( NULL == pSta )
1422 {
1423 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1424 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1425 }
1426 else
1427 {
1428 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1429 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1430 }
1431
Jeff Johnson295189b2012-06-20 16:38:30 -07001432 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1433 {
1434 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1435 {
1436 pAssocReq =
1437 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001438 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1439 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1440 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1441 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001442 }
1443 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001444
1445 if ( NULL != pSta )
1446 {
1447 if ( eHAL_SET == qosMode )
1448 {
1449 if ( pSta->lleEnabled )
1450 {
1451 lleMode = 1;
1452 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1453 {
1454 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1455
1456// FramesToDo:...
1457// if ( fAddTS )
1458// {
1459// tANI_U8 *pAf = pBody;
1460// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1461// tANI_U32 tlen;
1462// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1463// &tlen, bufLen - frameLen);
1464// } // End if on Add TS.
1465 }
1466 } // End if on .11e enabled in 'pSta'.
1467 } // End if on QOS Mode on.
1468
1469 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1470 {
1471 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1472 {
1473
Jeff Johnson295189b2012-06-20 16:38:30 -07001474 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001475
1476 if ( pSta->wsmEnabled )
1477 {
1478 PopulateDot11fWMMCaps(&frm.WMMCaps );
1479 }
1480 }
1481 }
1482
1483 if ( pSta->aniPeer )
1484 {
1485 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1486 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1487 {
1488 edcaInclude = 1;
1489 }
1490
1491 } // End if on Airgo peer.
1492
1493 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001494 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001495 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001496 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07001497 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001498 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001499
1500#ifdef WLAN_FEATURE_11AC
1501 if( pSta->mlmStaContext.vhtCapability &&
1502 psessionEntry->vhtCapability )
1503 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08001504 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Response"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001505 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
1506 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation);
Sandeep Puligilla60342762014-01-30 21:05:37 +05301507 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001508 }
1509#endif
1510
Chet Lanctot8cecea22014-02-11 19:09:36 -08001511#ifdef WLAN_FEATURE_11W
Dino Myclea7f18452014-04-24 08:55:31 +05301512 if( eSIR_MAC_TRY_AGAIN_LATER == statusCode )
1513 {
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001514 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_MAX_RETRIES,
1515 &maxRetries ) != eSIR_SUCCESS )
1516 limLog( pMac, LOGE,
1517 FL("Could not retrieve PMF SA Query maximum retries value") );
1518 else
1519 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL,
1520 &retryInterval ) != eSIR_SUCCESS)
1521 limLog( pMac, LOGE,
1522 FL("Could not retrieve PMF SA Query timer interval value") );
Dino Myclea7f18452014-04-24 08:55:31 +05301523 else
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001524 PopulateDot11fTimeoutInterval(
1525 pMac, &frm.TimeoutInterval, SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1526 (maxRetries - pSta->pmfSaQueryRetryCount) * retryInterval );
Dino Myclea7f18452014-04-24 08:55:31 +05301527 }
Chet Lanctot8cecea22014-02-11 19:09:36 -08001528#endif
Dino Myclea7f18452014-04-24 08:55:31 +05301529 } // End if on non-NULL 'pSta'.
Jeff Johnson295189b2012-06-20 16:38:30 -07001530
Chet Lanctot8cecea22014-02-11 19:09:36 -08001531 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001532
Jeff Johnson295189b2012-06-20 16:38:30 -07001533 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1534 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1535 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1536 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001537
1538 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1539 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1540
1541 beaconParams.bssIdx = psessionEntry->bssIdx;
1542
1543 //Send message to HAL about beacon parameter change.
1544 if(beaconParams.paramChangeBitmap)
1545 {
1546 schSetFixedBeaconFields(pMac,psessionEntry);
1547 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1548 }
1549
Jeff Johnson295189b2012-06-20 16:38:30 -07001550 if ( pAssocReq != NULL )
1551 {
1552 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1553 &addnIEPresent) != eSIR_SUCCESS)
1554 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301555 limLog(pMac, LOGP, FL("Unable to get "
1556 "WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 return;
1558 }
1559
1560 if (addnIEPresent)
1561 {
1562 //Assoc rsp IE available
1563 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1564 &addnIELen) != eSIR_SUCCESS)
1565 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301566 limLog(pMac, LOGP, FL("Unable to get "
1567 "WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001568 return;
1569 }
1570
1571 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1572 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1573 {
1574 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1575 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1576 {
Kalikinkar dhara205da782014-03-21 15:49:32 -07001577
1578 vos_mem_set(( tANI_U8* )&extractedExtCap,
1579 sizeof( tDot11fIEExtCap ), 0);
1580 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
1581 &addIE[0],
1582 &addStripoffIELen,
1583 &extractedExtCap );
1584 if(eSIR_SUCCESS != nSirStatus)
1585 {
1586 limLog(pMac, LOG1,
1587 FL("Unable to Stripoff ExtCap IE from Assoc Rsp"));
1588 }
1589 else
1590 {
1591 addnIELen = addStripoffIELen;
1592 extractedExtCapFlag = eANI_BOOLEAN_TRUE;
1593 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001594 nBytes = nBytes + addnIELen;
1595 }
1596 }
1597 }
1598 }
1599
c_hpothubcd78652014-04-28 22:31:08 +05301600 /* merge the ExtCap struct*/
1601 if (extractedExtCapFlag && extractedExtCap.present)
1602 {
1603 limMergeExtCapIEStruct(&(frm.ExtCap), &extractedExtCap);
1604 }
1605
1606 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1607 if ( DOT11F_FAILED( nStatus ) )
1608 {
1609 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
1610 "or an Association Response (0x%08x)."),
1611 nStatus );
1612 return;
1613 }
1614 else if ( DOT11F_WARNED( nStatus ) )
1615 {
1616 limLog( pMac, LOGW, FL("There were warnings while calculating "
1617 "the packed size for an Association Re"
1618 "sponse (0x%08x)."), nStatus );
1619 }
1620
1621 nBytes += sizeof( tSirMacMgmtHdr ) + nPayload;
1622
Jeff Johnson295189b2012-06-20 16:38:30 -07001623 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1624 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1625 ( void** ) &pPacket );
1626 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1627 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001628 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001629 return;
1630 }
1631
1632 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301633 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001634
1635 // Next, we fill out the buffer descriptor:
1636 nSirStatus = limPopulateMacHeader( pMac,
1637 pFrame,
1638 SIR_MAC_MGMT_FRAME,
1639 ( LIM_ASSOC == subType ) ?
1640 SIR_MAC_MGMT_ASSOC_RSP :
1641 SIR_MAC_MGMT_REASSOC_RSP,
1642 peerMacAddr,psessionEntry->selfMacAddr);
1643 if ( eSIR_SUCCESS != nSirStatus )
1644 {
1645 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001646 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001647 nSirStatus );
1648 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1649 ( void* ) pFrame, ( void* ) pPacket );
1650 return;
1651 }
1652
1653 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1654
Jeff Johnson295189b2012-06-20 16:38:30 -07001655 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1656
1657 nStatus = dot11fPackAssocResponse( pMac, &frm,
1658 pFrame + sizeof( tSirMacMgmtHdr ),
1659 nPayload, &nPayload );
1660 if ( DOT11F_FAILED( nStatus ) )
1661 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301662 limLog( pMac, LOGE, FL("Failed to pack an Association Response"
1663 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001664 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1665 ( void* ) pFrame, ( void* ) pPacket );
1666 return; // allocated!
1667 }
1668 else if ( DOT11F_WARNED( nStatus ) )
1669 {
1670 limLog( pMac, LOGW, FL("There were warnings while packing an "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001671 "Association Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001672 }
1673
1674 macAddr = pMacHdr->da;
1675
1676 if (subType == LIM_ASSOC)
1677 {
1678 PELOG1(limLog(pMac, LOG1,
1679 FL("*** Sending Assoc Resp status %d aid %d to "),
1680 statusCode, aid);)
1681 }
1682 else{
1683 PELOG1(limLog(pMac, LOG1,
1684 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1685 statusCode, aid);)
1686 }
1687 PELOG1(limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1688
1689 if ( addnIEPresent )
1690 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301691 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 }
1693
1694 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001695 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1696 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001697 )
1698 {
1699 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1700 }
1701
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05301702 limLog( pMac, LOG1, FL("Sending Assoc resp over WQ5 to "MAC_ADDRESS_STR
1703 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
1704 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
1705
1706 txFlag |= HAL_USE_FW_IN_TX_PATH;
1707
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301708 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1709 psessionEntry->peSessionId,
1710 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 /// Queue Association Response frame in high priority WQ
1712 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1713 HAL_TXRX_FRM_802_11_MGMT,
1714 ANI_TXDIR_TODS,
1715 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1716 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301717 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1718 psessionEntry->peSessionId,
1719 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001720 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1721 {
1722 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001723 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001724 nSirStatus);
1725
1726 //Pkt will be freed up by the callback
1727 }
1728
1729 // update the ANI peer station count
1730 //FIXME_PROTECTION : take care of different type of station
1731 // counter inside this function.
1732 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1733
1734} // End limSendAssocRspMgmtFrame.
1735
1736
1737
1738void
1739limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1740 tSirMacAddr peer,
1741 tANI_U16 nStatusCode,
1742 tSirAddtsReqInfo *pAddTS,
1743 tSirMacScheduleIE *pSchedule,
1744 tpPESession psessionEntry)
1745{
1746 tANI_U8 *pFrame;
1747 tpSirMacMgmtHdr pMacHdr;
1748 tDot11fAddTSResponse AddTSRsp;
1749 tDot11fWMMAddTSResponse WMMAddTSRsp;
1750 tSirRetStatus nSirStatus;
1751 tANI_U32 i, nBytes, nPayload, nStatus;
1752 void *pPacket;
1753 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301754 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001755
1756 if(NULL == psessionEntry)
1757 {
1758 return;
1759 }
1760
1761 if ( ! pAddTS->wmeTspecPresent )
1762 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301763 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001764
1765 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1766 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1767 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1768 AddTSRsp.Status.status = nStatusCode;
1769
1770 // The TsDelay information element is only filled in for a specific
1771 // status code:
1772 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1773 {
1774 if ( pAddTS->wsmTspecPresent )
1775 {
1776 AddTSRsp.WMMTSDelay.version = 1;
1777 AddTSRsp.WMMTSDelay.delay = 10;
1778 AddTSRsp.WMMTSDelay.present = 1;
1779 }
1780 else
1781 {
1782 AddTSRsp.TSDelay.delay = 10;
1783 AddTSRsp.TSDelay.present = 1;
1784 }
1785 }
1786
1787 if ( pAddTS->wsmTspecPresent )
1788 {
1789 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1790 }
1791 else
1792 {
1793 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1794 }
1795
1796 if ( pAddTS->wsmTspecPresent )
1797 {
1798 AddTSRsp.num_WMMTCLAS = 0;
1799 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1800 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1801 {
1802 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1803 &AddTSRsp.TCLAS[i] );
1804 }
1805 }
1806 else
1807 {
1808 AddTSRsp.num_TCLAS = 0;
1809 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1810 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1811 {
1812 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1813 &AddTSRsp.WMMTCLAS[i] );
1814 }
1815 }
1816
1817 if ( pAddTS->tclasProcPresent )
1818 {
1819 if ( pAddTS->wsmTspecPresent )
1820 {
1821 AddTSRsp.WMMTCLASPROC.version = 1;
1822 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1823 AddTSRsp.WMMTCLASPROC.present = 1;
1824 }
1825 else
1826 {
1827 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1828 AddTSRsp.TCLASSPROC.present = 1;
1829 }
1830 }
1831
1832 // schedule element is included only if requested in the tspec and we are
1833 // using hcca (or both edca and hcca)
1834 // 11e-D8.0 is inconsistent on whether the schedule element is included
1835 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1836 // pg 46, line 17-18 says something else. So just include it and let the
1837 // sta figure it out
1838 if ((pSchedule != NULL) &&
1839 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1840 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1841 {
1842 if ( pAddTS->wsmTspecPresent )
1843 {
1844 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1845 }
1846 else
1847 {
1848 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1849 }
1850 }
1851
1852 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1853 if ( DOT11F_FAILED( nStatus ) )
1854 {
1855 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001856 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001857 nStatus );
1858 // We'll fall back on the worst case scenario:
1859 nPayload = sizeof( tDot11fAddTSResponse );
1860 }
1861 else if ( DOT11F_WARNED( nStatus ) )
1862 {
1863 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001864 "ting the packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001865 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001866 }
1867 }
1868 else
1869 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301870 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001871
1872 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1873 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1874 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1875 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1876
1877 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1878
1879 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1880 if ( DOT11F_FAILED( nStatus ) )
1881 {
1882 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001883 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001884 nStatus );
1885 // We'll fall back on the worst case scenario:
1886 nPayload = sizeof( tDot11fWMMAddTSResponse );
1887 }
1888 else if ( DOT11F_WARNED( nStatus ) )
1889 {
1890 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001891 "ting the packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001892 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001893 }
1894 }
1895
1896 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1897
1898 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1899 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1900 {
1901 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001902 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001903 return;
1904 }
1905
1906 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301907 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001908
1909 // Next, we fill out the buffer descriptor:
1910 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1911 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1912 if ( eSIR_SUCCESS != nSirStatus )
1913 {
1914 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001915 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001916 nSirStatus );
1917 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1918 return; // allocated!
1919 }
1920
1921 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1922
1923
1924 #if 0
1925 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1926 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1927 {
1928 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001929 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001930 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1931 return; // allocated!
1932 }
1933 #endif //TO SUPPORT BT-AMP
1934 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1935
Chet Lanctot186b5732013-03-18 10:26:30 -07001936#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001937 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001938#endif
1939
Jeff Johnson295189b2012-06-20 16:38:30 -07001940 // That done, pack the struct:
1941 if ( ! pAddTS->wmeTspecPresent )
1942 {
1943 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1944 pFrame + sizeof( tSirMacMgmtHdr ),
1945 nPayload, &nPayload );
1946 if ( DOT11F_FAILED( nStatus ) )
1947 {
1948 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001949 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001950 nStatus );
1951 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1952 return;
1953 }
1954 else if ( DOT11F_WARNED( nStatus ) )
1955 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001956 limLog( pMac, LOGW, FL("There were warnings while packing "
1957 "an Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001958 }
1959 }
1960 else
1961 {
1962 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
1963 pFrame + sizeof( tSirMacMgmtHdr ),
1964 nPayload, &nPayload );
1965 if ( DOT11F_FAILED( nStatus ) )
1966 {
1967 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001968 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001969 nStatus );
1970 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1971 return;
1972 }
1973 else if ( DOT11F_WARNED( nStatus ) )
1974 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001975 limLog( pMac, LOGW, FL("There were warnings while packing "
1976 "a WMM Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001977 }
1978 }
1979
1980 PELOG1(limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
1981 nStatusCode );
1982 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
1983
1984 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001985 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1986 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001987 )
1988 {
1989 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1990 }
1991
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301992 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1993 psessionEntry->peSessionId,
1994 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001995 // Queue the frame in high priority WQ:
1996 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1997 HAL_TXRX_FRM_802_11_MGMT,
1998 ANI_TXDIR_TODS,
1999 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2000 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302001 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2002 psessionEntry->peSessionId,
2003 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002004 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2005 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002006 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002007 nSirStatus );
2008 //Pkt will be freed up by the callback
2009 }
2010
2011} // End limSendAddtsRspActionFrame.
2012
2013void
2014limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
2015 tSirMacAddr peer,
2016 tANI_U8 wmmTspecPresent,
2017 tSirMacTSInfo *pTsinfo,
2018 tSirMacTspecIE *pTspecIe,
2019 tpPESession psessionEntry)
2020{
2021 tANI_U8 *pFrame;
2022 tpSirMacMgmtHdr pMacHdr;
2023 tDot11fDelTS DelTS;
2024 tDot11fWMMDelTS WMMDelTS;
2025 tSirRetStatus nSirStatus;
2026 tANI_U32 nBytes, nPayload, nStatus;
2027 void *pPacket;
2028 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302029 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002030
2031 if(NULL == psessionEntry)
2032 {
2033 return;
2034 }
2035
2036 if ( ! wmmTspecPresent )
2037 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302038 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002039
2040 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
2041 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2042 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
2043
2044 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
2045 if ( DOT11F_FAILED( nStatus ) )
2046 {
2047 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002048 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002049 nStatus );
2050 // We'll fall back on the worst case scenario:
2051 nPayload = sizeof( tDot11fDelTS );
2052 }
2053 else if ( DOT11F_WARNED( nStatus ) )
2054 {
2055 limLog( pMac, LOGW, FL("There were warnings while calcula"
2056 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002057 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 }
2059 }
2060 else
2061 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302062 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002063
2064 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
2065 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2066 WMMDelTS.DialogToken.token = 0;
2067 WMMDelTS.StatusCode.statusCode = 0;
2068 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
2069 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
2070 if ( DOT11F_FAILED( nStatus ) )
2071 {
2072 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002073 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002074 nStatus );
2075 // We'll fall back on the worst case scenario:
2076 nPayload = sizeof( tDot11fDelTS );
2077 }
2078 else if ( DOT11F_WARNED( nStatus ) )
2079 {
2080 limLog( pMac, LOGW, FL("There were warnings while calcula"
2081 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002082 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002083 }
2084 }
2085
2086 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
2087
2088 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
2089 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2090 {
2091 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002092 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002093 return;
2094 }
2095
2096 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302097 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002098
2099 // Next, we fill out the buffer descriptor:
2100 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2101 SIR_MAC_MGMT_ACTION, peer,
2102 psessionEntry->selfMacAddr);
2103 if ( eSIR_SUCCESS != nSirStatus )
2104 {
2105 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002106 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002107 nSirStatus );
2108 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2109 return; // allocated!
2110 }
2111
2112 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
2113
2114 #if 0
2115
2116 cfgLen = SIR_MAC_ADDR_LENGTH;
2117 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
2118 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
2119 {
2120 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002121 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2123 return; // allocated!
2124 }
2125 #endif //TO SUPPORT BT-AMP
2126 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
2127
Chet Lanctot186b5732013-03-18 10:26:30 -07002128#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002129 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07002130#endif
2131
Jeff Johnson295189b2012-06-20 16:38:30 -07002132 // That done, pack the struct:
2133 if ( !wmmTspecPresent )
2134 {
2135 nStatus = dot11fPackDelTS( pMac, &DelTS,
2136 pFrame + sizeof( tSirMacMgmtHdr ),
2137 nPayload, &nPayload );
2138 if ( DOT11F_FAILED( nStatus ) )
2139 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002140 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002141 nStatus );
2142 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2143 return; // allocated!
2144 }
2145 else if ( DOT11F_WARNED( nStatus ) )
2146 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002147 limLog( pMac, LOGW, FL("There were warnings while packing "
2148 "a Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002149 }
2150 }
2151 else
2152 {
2153 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
2154 pFrame + sizeof( tSirMacMgmtHdr ),
2155 nPayload, &nPayload );
2156 if ( DOT11F_FAILED( nStatus ) )
2157 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002158 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 nStatus );
2160 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2161 return; // allocated!
2162 }
2163 else if ( DOT11F_WARNED( nStatus ) )
2164 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002165 limLog( pMac, LOGW, FL("There were warnings while packing "
2166 "a WMM Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002167 }
2168 }
2169
2170 PELOG1(limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
2171 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
2172
2173 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002174 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2175 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002176 )
2177 {
2178 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2179 }
2180
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302181 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2182 psessionEntry->peSessionId,
2183 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2185 HAL_TXRX_FRM_802_11_MGMT,
2186 ANI_TXDIR_TODS,
2187 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2188 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302189 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2190 psessionEntry->peSessionId,
2191 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002192 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2193 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002194 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002195 nSirStatus );
2196 //Pkt will be freed up by the callback
2197 }
2198
2199} // End limSendDeltsReqActionFrame.
2200
2201void
2202limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
2203 tLimMlmAssocReq *pMlmAssocReq,
2204 tpPESession psessionEntry)
2205{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002206 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07002207 tANI_U16 caps;
2208 tANI_U8 *pFrame;
2209 tSirRetStatus nSirStatus;
2210 tLimMlmAssocCnf mlmAssocCnf;
c_hpothubcd78652014-04-28 22:31:08 +05302211 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07002212 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2213 void *pPacket;
2214 eHalStatus halstatus;
2215 tANI_U16 nAddIELen;
2216 tANI_U8 *pAddIE;
2217 tANI_U8 *wpsIe = NULL;
2218#if defined WLAN_FEATURE_VOWIFI
2219 tANI_U8 PowerCapsPopulated = FALSE;
2220#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302221 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302222 tpSirMacMgmtHdr pMacHdr;
Kalikinkar dhara205da782014-03-21 15:49:32 -07002223 tDot11fIEExtCap extractedExtCap;
2224 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +05302225 tANI_U32 nBytes = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002226
2227 if(NULL == psessionEntry)
2228 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302229 limLog(pMac, LOGE, FL("psessionEntry is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002230 return;
2231 }
2232
Jeff Johnson295189b2012-06-20 16:38:30 -07002233 /* check this early to avoid unncessary operation */
2234 if(NULL == psessionEntry->pLimJoinReq)
2235 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302236 limLog(pMac, LOGE, FL("psessionEntry->pLimJoinReq is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002237 return;
2238 }
2239 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
2240 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
2241
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302242 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
2243 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002244 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302245 limLog(pMac, LOGE, FL("Unable to allocate memory") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002246 return;
2247 }
2248
2249
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302250 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002251
Kalikinkar dhara205da782014-03-21 15:49:32 -07002252 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
2253 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac, pAddIE,
2254 &nAddIELen,
2255 &extractedExtCap );
2256 if(eSIR_SUCCESS != nSirStatus )
2257 {
2258 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
2259 limLog(pMac, LOG1,
2260 FL("Unable to Stripoff ExtCap IE from Assoc Req"));
2261 }
2262
Jeff Johnson295189b2012-06-20 16:38:30 -07002263 caps = pMlmAssocReq->capabilityInfo;
2264 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2265 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2266#if defined(FEATURE_WLAN_WAPI)
2267 /* CR: 262463 :
2268 According to WAPI standard:
2269 7.3.1.4 Capability Information field
2270 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2271 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2272 Reassociation management frames. */
2273 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2274 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2275#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002276 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002277
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002278 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2279 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002281 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002282
2283 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2284 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2285
2286 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2287 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2288
2289 // We prefer .11e asociations:
2290 if ( fQosEnabled ) fWmeEnabled = false;
2291
2292 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2293 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2294
2295 if ( psessionEntry->lim11hEnable &&
2296 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2297 {
2298#if defined WLAN_FEATURE_VOWIFI
2299 PowerCapsPopulated = TRUE;
2300
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002301 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002302#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002303 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002304
2305 }
2306
2307#if defined WLAN_FEATURE_VOWIFI
2308 if( pMac->rrm.rrmPEContext.rrmEnable &&
2309 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2310 {
2311 if (PowerCapsPopulated == FALSE)
2312 {
2313 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002314 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002315 }
2316 }
2317#endif
2318
2319 if ( fQosEnabled &&
2320 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002321 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002322
2323 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002324 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002325
2326#if defined WLAN_FEATURE_VOWIFI
2327 if( pMac->rrm.rrmPEContext.rrmEnable &&
2328 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2329 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002330 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002331 }
2332#endif
2333 // The join request *should* contain zero or one of the WPA and RSN
2334 // IEs. The payload send along with the request is a
2335 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2336
2337 // typedef struct sSirRSNie
2338 // {
2339 // tANI_U16 length;
2340 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2341 // } tSirRSNie, *tpSirRSNie;
2342
2343 // So, we should be able to make the following two calls harmlessly,
2344 // since they do nothing if they don't find the given IE in the
2345 // bytestream with which they're provided.
2346
2347 // The net effect of this will be to faithfully transmit whatever
2348 // security IE is in the join request.
2349
2350 // *However*, if we're associating for the purpose of WPS
2351 // enrollment, and we've been configured to indicate that by
2352 // eliding the WPA or RSN IE, we just skip this:
2353 if( nAddIELen && pAddIE )
2354 {
2355 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2356 }
2357 if ( NULL == wpsIe )
2358 {
2359 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002360 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002361 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002362 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002363#if defined(FEATURE_WLAN_WAPI)
2364 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002365 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002366#endif // defined(FEATURE_WLAN_WAPI)
2367 }
2368
2369 // include WME EDCA IE as well
2370 if ( fWmeEnabled )
2371 {
2372 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2373 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002374 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002375 }
2376
2377 if ( fWsmEnabled &&
2378 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2379 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002380 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002381 }
2382 }
2383
2384 //Populate HT IEs, when operating in 11n or Taurus modes AND
2385 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002386 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002387 pMac->lim.htCapabilityPresentInBeacon)
2388 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002389 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002390#ifdef DISABLE_GF_FOR_INTEROP
2391
2392 /*
2393 * To resolve the interop problem with Broadcom AP,
2394 * where TQ STA could not pass traffic with GF enabled,
2395 * TQ STA will do Greenfield only with TQ AP, for
2396 * everybody else it will be turned off.
2397 */
2398
2399 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2400 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302401 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP,"
2402 " Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002403 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002404 }
2405#endif
2406
2407 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002408#ifdef WLAN_FEATURE_11AC
2409 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002410 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002411 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002412 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002413 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
Jeff Johnsone7245742012-09-05 17:12:55 -07002414 }
2415#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302416 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002417
2418#if defined WLAN_FEATURE_VOWIFI_11R
2419 if (psessionEntry->pLimJoinReq->is11Rconnection)
2420 {
2421#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002422 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002423 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2424 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2425 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2426#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302427 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2428 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002429 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302430 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002431 {
2432 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302433 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002434 }
2435#endif
2436
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002437#ifdef FEATURE_WLAN_ESE
2438 /* For ESE Associations fill the ESE IEs */
2439 if (psessionEntry->isESEconnection &&
2440 psessionEntry->pLimJoinReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002441 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002442#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002443 PopulateDot11fESERadMgmtCap(&pFrm->ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002444#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002445 PopulateDot11fESEVersion(&pFrm->ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002446 }
2447#endif
2448
c_hpothubcd78652014-04-28 22:31:08 +05302449 /* merge the ExtCap struct*/
2450 if (extractedExtCapFlag && extractedExtCap.present)
2451 {
2452 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
2453 }
2454
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002455 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002456 if ( DOT11F_FAILED( nStatus ) )
2457 {
2458 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002459 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002460 nStatus );
2461 // We'll fall back on the worst case scenario:
2462 nPayload = sizeof( tDot11fAssocRequest );
2463 }
2464 else if ( DOT11F_WARNED( nStatus ) )
2465 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002466 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002467 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002468 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002469 }
2470
2471 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2472
2473 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2474 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2475 ( void** ) &pPacket );
2476 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2477 {
2478 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002479 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002480
2481 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002482 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002483
2484
2485 /* Update PE session id*/
2486 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2487
2488 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2489
2490 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2491 ( void* ) pFrame, ( void* ) pPacket );
2492
2493 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2494 ( tANI_U32* ) &mlmAssocCnf);
2495
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302496 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002497 return;
2498 }
2499
2500 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302501 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002502
2503 // Next, we fill out the buffer descriptor:
2504 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2505 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2506 if ( eSIR_SUCCESS != nSirStatus )
2507 {
2508 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002509 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002510 nSirStatus );
2511 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302512 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002513 return;
2514 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002515
Abhishek Singh57aebef2014-02-03 18:47:44 +05302516 // That done, pack the Assoc Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002517 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002518 sizeof(tSirMacMgmtHdr),
2519 nPayload, &nPayload );
2520 if ( DOT11F_FAILED( nStatus ) )
2521 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302522 limLog( pMac, LOGE, FL("Failed to pack a Assoc Request (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002523 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002524 nStatus );
2525 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2526 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302527 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002528 return;
2529 }
2530 else if ( DOT11F_WARNED( nStatus ) )
2531 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302532 limLog( pMac, LOGW, FL("There were warnings while packing a Assoc"
2533 "Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002534 }
2535
2536 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002537 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002538 nBytes );)
2539 // limPrintMacAddr( pMac, bssid, LOG1 );
2540
2541 if( psessionEntry->assocReq != NULL )
2542 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302543 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 psessionEntry->assocReq = NULL;
2545 }
2546
2547 if( nAddIELen )
2548 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302549 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2550 pAddIE,
2551 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 nPayload += nAddIELen;
2553 }
2554
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302555 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2556 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002557 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302558 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store "
2559 "assoc request"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002560 }
2561 else
2562 {
2563 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302564 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002565 psessionEntry->assocReqLen = nPayload;
2566 }
2567
2568 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002569 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2570 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002571 )
2572 {
2573 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2574 }
2575
Ganesh K08bce952012-12-13 15:04:41 -08002576 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2577 {
2578 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2579 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302580
2581 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05302582 limLog( pMac, LOG1, FL("Sending Assoc req over WQ5 to "MAC_ADDRESS_STR
2583 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
2584 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2585 txFlag |= HAL_USE_FW_IN_TX_PATH;
2586
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302587 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2588 psessionEntry->peSessionId,
2589 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2591 HAL_TXRX_FRM_802_11_MGMT,
2592 ANI_TXDIR_TODS,
2593 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2594 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302595 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2596 psessionEntry->peSessionId,
2597 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002598 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2599 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002600 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002601 halstatus );
2602 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302603 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002604 return;
2605 }
2606
2607 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302608 vos_mem_free(pMlmAssocReq);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002609 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302610 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002611 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002612} // End limSendAssocReqMgmtFrame
2613
2614
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002615#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002616/*------------------------------------------------------------------------------------
2617 *
2618 * Send Reassoc Req with FTIEs.
2619 *
2620 *-----------------------------------------------------------------------------------
2621 */
2622void
2623limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2624 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2625{
2626 static tDot11fReAssocRequest frm;
2627 tANI_U16 caps;
2628 tANI_U8 *pFrame;
2629 tSirRetStatus nSirStatus;
2630 tANI_U32 nBytes, nPayload, nStatus;
2631 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2632 void *pPacket;
2633 eHalStatus halstatus;
2634#if defined WLAN_FEATURE_VOWIFI
2635 tANI_U8 PowerCapsPopulated = FALSE;
2636#endif
2637 tANI_U16 ft_ies_length = 0;
2638 tANI_U8 *pBody;
2639 tANI_U16 nAddIELen;
2640 tANI_U8 *pAddIE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002641#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002642 tANI_U8 *wpsIe = NULL;
2643#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302644 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302645 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002646
2647 if (NULL == psessionEntry)
2648 {
2649 return;
2650 }
2651
Jeff Johnson295189b2012-06-20 16:38:30 -07002652 /* check this early to avoid unncessary operation */
2653 if(NULL == psessionEntry->pLimReAssocReq)
2654 {
2655 return;
2656 }
2657 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2658 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002659 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2660 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002661
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302662 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002663
2664 caps = pMlmReassocReq->capabilityInfo;
2665 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2666 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2667#if defined(FEATURE_WLAN_WAPI)
2668 /* CR: 262463 :
2669 According to WAPI standard:
2670 7.3.1.4 Capability Information field
2671 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2672 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2673 Reassociation management frames. */
2674 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2675 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2676#endif
2677 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2678
2679 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2680
2681 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302682 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2684
2685 PopulateDot11fSSID2( pMac, &frm.SSID );
2686 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2687 &frm.SuppRates,psessionEntry);
2688
2689 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2690 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2691
2692 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2693 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2694
2695 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2696 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2697
2698 if ( psessionEntry->lim11hEnable &&
2699 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2700 {
2701#if defined WLAN_FEATURE_VOWIFI
2702 PowerCapsPopulated = TRUE;
2703
2704 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2705 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2706#endif
2707 }
2708
2709#if defined WLAN_FEATURE_VOWIFI
2710 if( pMac->rrm.rrmPEContext.rrmEnable &&
2711 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2712 {
2713 if (PowerCapsPopulated == FALSE)
2714 {
2715 PowerCapsPopulated = TRUE;
2716 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2717 }
2718 }
2719#endif
2720
2721 if ( fQosEnabled &&
2722 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2723 {
2724 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2725 }
2726
2727 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2728 &frm.ExtSuppRates, psessionEntry );
2729
2730#if defined WLAN_FEATURE_VOWIFI
2731 if( pMac->rrm.rrmPEContext.rrmEnable &&
2732 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2733 {
2734 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2735 }
2736#endif
2737
2738 // Ideally this should be enabled for 11r also. But 11r does
2739 // not follow the usual norm of using the Opaque object
2740 // for rsnie and fties. Instead we just add
2741 // the rsnie and fties at the end of the pack routine for 11r.
2742 // This should ideally! be fixed.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002743#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002744 //
2745 // The join request *should* contain zero or one of the WPA and RSN
2746 // IEs. The payload send along with the request is a
2747 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2748
2749 // typedef struct sSirRSNie
2750 // {
2751 // tANI_U16 length;
2752 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2753 // } tSirRSNie, *tpSirRSNie;
2754
2755 // So, we should be able to make the following two calls harmlessly,
2756 // since they do nothing if they don't find the given IE in the
2757 // bytestream with which they're provided.
2758
2759 // The net effect of this will be to faithfully transmit whatever
2760 // security IE is in the join request.
2761
2762 // *However*, if we're associating for the purpose of WPS
2763 // enrollment, and we've been configured to indicate that by
2764 // eliding the WPA or RSN IE, we just skip this:
2765 if (!psessionEntry->is11Rconnection)
2766 {
2767 if( nAddIELen && pAddIE )
2768 {
2769 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2770 }
2771 if ( NULL == wpsIe )
2772 {
2773 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2774 &frm.RSNOpaque );
2775 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2776 &frm.WPAOpaque );
2777 }
2778
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002779#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302780 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002781 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002782 PopulateDot11fESECckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2783 &frm.ESECckmOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002784 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002785#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002786 }
2787
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002788#ifdef FEATURE_WLAN_ESE
2789 // For ESE Associations fill the ESE IEs
2790 if (psessionEntry->isESEconnection &&
2791 psessionEntry->pLimReAssocReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002792 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002793#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002794 PopulateDot11fESERadMgmtCap(&frm.ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002795#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002796 PopulateDot11fESEVersion(&frm.ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002797 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002798#endif //FEATURE_WLAN_ESE
2799#endif //FEATURE_WLAN_ESE || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002800
2801 // include WME EDCA IE as well
2802 if ( fWmeEnabled )
2803 {
2804 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2805 {
2806 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2807 }
2808
2809 if ( fWsmEnabled &&
2810 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2811 {
2812 PopulateDot11fWMMCaps( &frm.WMMCaps );
2813 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002814#ifdef FEATURE_WLAN_ESE
2815 if (psessionEntry->isESEconnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07002816 {
2817 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2818
2819 // Populate the TSRS IE if TSPEC is included in the reassoc request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002820 if (psessionEntry->pLimReAssocReq->eseTspecInfo.numTspecs)
Jeff Johnson295189b2012-06-20 16:38:30 -07002821 {
2822 tANI_U32 phyMode;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002823 tSirMacESETSRSIE tsrsIE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002824 limGetPhyMode(pMac, &phyMode, psessionEntry);
2825
2826 tsrsIE.tsid = 0;
2827 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2828 {
2829 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2830 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302831 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002832 {
2833 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2834 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002835 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.ESETrafStrmRateSet, sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07002836 }
2837 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302838#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002839 }
2840
Jeff Johnsone7245742012-09-05 17:12:55 -07002841 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002842 pMac->lim.htCapabilityPresentInBeacon)
2843 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002844 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002845 }
2846
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002847#if defined WLAN_FEATURE_VOWIFI_11R
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +05302848 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent &&
2849 (pMac->ft.ftSmeContext.addMDIE == TRUE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002850#if defined FEATURE_WLAN_ESE
2851 && !psessionEntry->isESEconnection
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302852#endif
2853 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002854 {
2855 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2856 }
2857#endif
2858
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002859#ifdef WLAN_FEATURE_11AC
2860 if ( psessionEntry->vhtCapability &&
2861 psessionEntry->vhtCapabilityPresentInBeacon)
2862 {
2863 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
2864 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002865 }
2866#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302867 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002868
Jeff Johnson295189b2012-06-20 16:38:30 -07002869 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2870 if ( DOT11F_FAILED( nStatus ) )
2871 {
2872 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002873 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002874 nStatus );
2875 // We'll fall back on the worst case scenario:
2876 nPayload = sizeof( tDot11fReAssocRequest );
2877 }
2878 else if ( DOT11F_WARNED( nStatus ) )
2879 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002880 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002881 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002882 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002883 }
2884
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002885 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002886
2887#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002888 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002889 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2890#endif
2891
2892#if defined WLAN_FEATURE_VOWIFI_11R
2893 if (psessionEntry->is11Rconnection)
2894 {
2895 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2896 }
2897#endif
2898
2899 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2900 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2901 ( void** ) &pPacket );
2902 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2903 {
2904 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002905 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002906 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002907 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002908 goto end;
2909 }
2910
2911 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302912 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002913
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002914#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002915 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002916#endif
2917 // Next, we fill out the buffer descriptor:
2918 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2919 SIR_MAC_MGMT_REASSOC_REQ,
2920 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2921 if ( eSIR_SUCCESS != nSirStatus )
2922 {
2923 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002924 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002925 nSirStatus );
2926 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2927 goto end;
2928 }
2929
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302930 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07002931 // That done, pack the ReAssoc Request:
2932 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2933 sizeof(tSirMacMgmtHdr),
2934 nPayload, &nPayload );
2935 if ( DOT11F_FAILED( nStatus ) )
2936 {
2937 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002938 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002939 nStatus );
2940 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2941 goto end;
2942 }
2943 else if ( DOT11F_WARNED( nStatus ) )
2944 {
2945 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002946 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002947 }
2948
2949 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002950 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002951 nBytes, nPayload );)
2952 if( psessionEntry->assocReq != NULL )
2953 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302954 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002955 psessionEntry->assocReq = NULL;
2956 }
2957
2958 if( nAddIELen )
2959 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302960 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2961 pAddIE,
2962 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002963 nPayload += nAddIELen;
2964 }
2965
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302966 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2967 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002968 {
2969 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002970 }
2971 else
2972 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002973 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302974 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002975 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002976 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002977
2978 if (psessionEntry->is11Rconnection)
2979 {
2980 {
2981 int i = 0;
2982
2983 pBody = pFrame + nBytes;
2984 for (i=0; i<ft_ies_length; i++)
2985 {
2986 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2987 pBody++;
2988 }
2989 }
2990 }
2991
2992#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002993 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
2994 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002995 (tANI_U8 *)pFrame,
2996 (nBytes + ft_ies_length));)
2997#endif
2998
2999
3000 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003001 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3002 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003003 )
3004 {
3005 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3006 }
3007
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003008 if( NULL != psessionEntry->assocReq )
3009 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303010 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003011 psessionEntry->assocReq = NULL;
3012 }
3013
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303014 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
3015 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003016 {
3017 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003018 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003019 }
3020 else
3021 {
3022 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303023 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
3024 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003025 psessionEntry->assocReqLen = (ft_ies_length);
3026 }
3027
3028
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303029 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3030 psessionEntry->peSessionId,
3031 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003032 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
3033 HAL_TXRX_FRM_802_11_MGMT,
3034 ANI_TXDIR_TODS,
3035 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3036 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303037 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3038 psessionEntry->peSessionId,
3039 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003040 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3041 {
3042 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003043 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003044 nSirStatus );
3045 //Pkt will be freed up by the callback
3046 goto end;
3047 }
3048
3049end:
3050 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303051 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003052 psessionEntry->pLimMlmReassocReq = NULL;
3053
3054}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003055
3056void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
3057 tLimMlmReassocReq *pMlmReassocReq,
3058 tpPESession psessionEntry)
3059{
3060 tLimMlmReassocCnf mlmReassocCnf; // keep sme
3061 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
3062 if(NULL == pTmpMlmReassocReq)
3063 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303064 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
3065 if ( NULL == pTmpMlmReassocReq ) goto end;
3066 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
3067 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003068 }
3069
3070 // Prepare and send Reassociation request frame
3071 // start reassoc timer.
3072 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
3073 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08003074 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003075 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
3076 != TX_SUCCESS)
3077 {
3078 // Could not start reassoc failure timer.
3079 // Log error
3080 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003081 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003082 // Return Reassoc confirm with
3083 // Resources Unavailable
3084 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3085 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3086 goto end;
3087 }
3088
3089 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
3090 return;
3091
3092end:
3093 // Free up buffer allocated for reassocReq
3094 if (pMlmReassocReq != NULL)
3095 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303096 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003097 pMlmReassocReq = NULL;
3098 }
3099 if (pTmpMlmReassocReq != NULL)
3100 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303101 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003102 pTmpMlmReassocReq = NULL;
3103 }
3104 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
3105 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3106 /* Update PE sessio Id*/
3107 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
3108
3109 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3110}
3111
Jeff Johnson295189b2012-06-20 16:38:30 -07003112#endif /* WLAN_FEATURE_VOWIFI_11R */
3113
3114
3115void
3116limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
3117 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
3118{
3119 static tDot11fReAssocRequest frm;
3120 tANI_U16 caps;
3121 tANI_U8 *pFrame;
3122 tSirRetStatus nSirStatus;
3123 tANI_U32 nBytes, nPayload, nStatus;
3124 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
3125 void *pPacket;
3126 eHalStatus halstatus;
3127 tANI_U16 nAddIELen;
3128 tANI_U8 *pAddIE;
3129 tANI_U8 *wpsIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303130 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003131#if defined WLAN_FEATURE_VOWIFI
3132 tANI_U8 PowerCapsPopulated = FALSE;
3133#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303134 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003135
3136 if(NULL == psessionEntry)
3137 {
3138 return;
3139 }
3140
3141 /* check this early to avoid unncessary operation */
3142 if(NULL == psessionEntry->pLimReAssocReq)
3143 {
3144 return;
3145 }
3146 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
3147 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
3148
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303149 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003150
3151 caps = pMlmReassocReq->capabilityInfo;
3152 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
3153 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
3154#if defined(FEATURE_WLAN_WAPI)
3155 /* CR: 262463 :
3156 According to WAPI standard:
3157 7.3.1.4 Capability Information field
3158 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
3159 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
3160 Reassociation management frames. */
3161 if ( psessionEntry->encryptType == eSIR_ED_WPI)
3162 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
3163#endif
3164 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
3165
3166 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
3167
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303168 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
3169 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003170
3171 PopulateDot11fSSID2( pMac, &frm.SSID );
3172 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3173 &frm.SuppRates,psessionEntry);
3174
3175 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
3176 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
3177
3178 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
3179 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
3180
3181 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
3182 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
3183
3184
3185 if ( psessionEntry->lim11hEnable &&
3186 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
3187 {
3188#if defined WLAN_FEATURE_VOWIFI
3189 PowerCapsPopulated = TRUE;
3190 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
3191 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
3192#endif
3193 }
3194
3195#if defined WLAN_FEATURE_VOWIFI
3196 if( pMac->rrm.rrmPEContext.rrmEnable &&
3197 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
3198 {
3199 if (PowerCapsPopulated == FALSE)
3200 {
3201 PowerCapsPopulated = TRUE;
3202 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
3203 }
3204 }
3205#endif
3206
3207 if ( fQosEnabled &&
3208 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
3209 {
3210 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
3211 }
3212
3213 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3214 &frm.ExtSuppRates, psessionEntry );
3215
3216#if defined WLAN_FEATURE_VOWIFI
3217 if( pMac->rrm.rrmPEContext.rrmEnable &&
3218 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
3219 {
3220 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
3221 }
3222#endif
3223 // The join request *should* contain zero or one of the WPA and RSN
3224 // IEs. The payload send along with the request is a
3225 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
3226
3227 // typedef struct sSirRSNie
3228 // {
3229 // tANI_U16 length;
3230 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
3231 // } tSirRSNie, *tpSirRSNie;
3232
3233 // So, we should be able to make the following two calls harmlessly,
3234 // since they do nothing if they don't find the given IE in the
3235 // bytestream with which they're provided.
3236
3237 // The net effect of this will be to faithfully transmit whatever
3238 // security IE is in the join request.
3239
3240 // *However*, if we're associating for the purpose of WPS
3241 // enrollment, and we've been configured to indicate that by
3242 // eliding the WPA or RSN IE, we just skip this:
3243 if( nAddIELen && pAddIE )
3244 {
3245 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
3246 }
3247 if ( NULL == wpsIe )
3248 {
3249 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3250 &frm.RSNOpaque );
3251 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3252 &frm.WPAOpaque );
3253#if defined(FEATURE_WLAN_WAPI)
3254 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3255 &frm.WAPIOpaque );
3256#endif // defined(FEATURE_WLAN_WAPI)
3257 }
3258
3259 // include WME EDCA IE as well
3260 if ( fWmeEnabled )
3261 {
3262 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
3263 {
3264 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
3265 }
3266
3267 if ( fWsmEnabled &&
3268 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3269 {
3270 PopulateDot11fWMMCaps( &frm.WMMCaps );
3271 }
3272 }
3273
Jeff Johnsone7245742012-09-05 17:12:55 -07003274 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003275 pMac->lim.htCapabilityPresentInBeacon)
3276 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003277 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003278 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003279#ifdef WLAN_FEATURE_11AC
3280 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003281 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003282 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003283 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003284 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Sandeep Puligilla60342762014-01-30 21:05:37 +05303285 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003286 }
3287#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003288
3289 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3290 if ( DOT11F_FAILED( nStatus ) )
3291 {
3292 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003293 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003294 nStatus );
3295 // We'll fall back on the worst case scenario:
3296 nPayload = sizeof( tDot11fReAssocRequest );
3297 }
3298 else if ( DOT11F_WARNED( nStatus ) )
3299 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003300 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003301 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003302 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003303 }
3304
3305 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3306
3307 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3308 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3309 ( void** ) &pPacket );
3310 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3311 {
3312 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003313 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003314 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003315 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003316 goto end;
3317 }
3318
3319 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303320 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003321
3322 // Next, we fill out the buffer descriptor:
3323 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3324 SIR_MAC_MGMT_REASSOC_REQ,
3325 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3326 if ( eSIR_SUCCESS != nSirStatus )
3327 {
3328 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003329 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003330 nSirStatus );
3331 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3332 goto end;
3333 }
3334
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303335 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003336 // That done, pack the Probe Request:
3337 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3338 sizeof(tSirMacMgmtHdr),
3339 nPayload, &nPayload );
3340 if ( DOT11F_FAILED( nStatus ) )
3341 {
3342 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003343 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003344 nStatus );
3345 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3346 goto end;
3347 }
3348 else if ( DOT11F_WARNED( nStatus ) )
3349 {
3350 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003351 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003352 }
3353
3354 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003355 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003356 nBytes );)
3357
3358 if( psessionEntry->assocReq != NULL )
3359 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303360 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003361 psessionEntry->assocReq = NULL;
3362 }
3363
3364 if( nAddIELen )
3365 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303366 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3367 pAddIE,
3368 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003369 nPayload += nAddIELen;
3370 }
3371
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303372 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3373 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003374 {
3375 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003376 }
3377 else
3378 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003379 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303380 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003381 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003382 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003383
3384 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003385 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3386 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003387 )
3388 {
3389 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3390 }
3391
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003392 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003393 {
3394 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3395 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003396
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303397 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3398 psessionEntry->peSessionId,
3399 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003400 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3401 HAL_TXRX_FRM_802_11_MGMT,
3402 ANI_TXDIR_TODS,
3403 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3404 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303405 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3406 psessionEntry->peSessionId,
3407 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003408 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3409 {
3410 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003411 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003412 nSirStatus );
3413 //Pkt will be freed up by the callback
3414 goto end;
3415 }
3416
3417end:
3418 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303419 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003420 psessionEntry->pLimMlmReassocReq = NULL;
3421
3422} // limSendReassocReqMgmtFrame
3423
3424/**
3425 * \brief Send an Authentication frame
3426 *
3427 *
3428 * \param pMac Pointer to Global MAC structure
3429 *
3430 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3431 * to be sent
3432 *
3433 * \param peerMacAddr MAC address of the peer entity to which Authentication
3434 * frame is destined
3435 *
3436 * \param wepBit Indicates whether wep bit to be set in FC while sending
3437 * Authentication frame3
3438 *
3439 *
3440 * This function is called by limProcessMlmMessages(). Authentication frame
3441 * is formatted and sent when this function is called.
3442 *
3443 *
3444 */
3445
3446void
3447limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3448 tpSirMacAuthFrameBody pAuthFrameBody,
3449 tSirMacAddr peerMacAddr,
3450 tANI_U8 wepBit,
3451 tpPESession psessionEntry
3452 )
3453{
3454 tANI_U8 *pFrame, *pBody;
3455 tANI_U32 frameLen = 0, bodyLen = 0;
3456 tpSirMacMgmtHdr pMacHdr;
3457 tANI_U16 i;
3458 void *pPacket;
3459 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303460 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003461
3462 if(NULL == psessionEntry)
3463 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303464 limLog(pMac, LOGE, FL("Error: psession Entry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003465 return;
3466 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05303467
3468 limLog(pMac, LOG1,
3469 FL("Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
3470 pAuthFrameBody->authTransactionSeqNumber,
3471 pAuthFrameBody->authStatusCode,
3472 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3473 MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003474 if (wepBit == LIM_WEP_IN_FC)
3475 {
3476 /// Auth frame3 to be sent with encrypted framebody
3477 /**
3478 * Allocate buffer for Authenticaton frame of size equal
3479 * to management frame header length plus 2 bytes each for
3480 * auth algorithm number, transaction number, status code,
3481 * 128 bytes for challenge text and 4 bytes each for
3482 * IV & ICV.
3483 */
3484
3485 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3486
3487 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3488 } // if (wepBit == LIM_WEP_IN_FC)
3489 else
3490 {
3491 switch (pAuthFrameBody->authTransactionSeqNumber)
3492 {
3493 case SIR_MAC_AUTH_FRAME_1:
3494 /**
3495 * Allocate buffer for Authenticaton frame of size
3496 * equal to management frame header length plus 2 bytes
3497 * each for auth algorithm number, transaction number
3498 * and status code.
3499 */
3500
3501 frameLen = sizeof(tSirMacMgmtHdr) +
3502 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3503 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3504
3505#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003506 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3507 {
3508 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003509 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003510 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003511 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003512 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003513 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003514 else
3515 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303516 limLog(pMac, LOG3, FL("Auth frame, Does not contain "
3517 "FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003518 frameLen += (2+SIR_MDIE_SIZE);
3519 }
3520 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003521#endif
3522 break;
3523
3524 case SIR_MAC_AUTH_FRAME_2:
3525 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3526 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3527 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3528 {
3529 /**
3530 * Allocate buffer for Authenticaton frame of size
3531 * equal to management frame header length plus
3532 * 2 bytes each for auth algorithm number,
3533 * transaction number and status code.
3534 */
3535
3536 frameLen = sizeof(tSirMacMgmtHdr) +
3537 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3538 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3539 }
3540 else
3541 {
3542 // Shared Key algorithm with challenge text
3543 // to be sent
3544 /**
3545 * Allocate buffer for Authenticaton frame of size
3546 * equal to management frame header length plus
3547 * 2 bytes each for auth algorithm number,
3548 * transaction number, status code and 128 bytes
3549 * for challenge text.
3550 */
3551
3552 frameLen = sizeof(tSirMacMgmtHdr) +
3553 sizeof(tSirMacAuthFrame);
3554 bodyLen = sizeof(tSirMacAuthFrameBody);
3555 }
3556
3557 break;
3558
3559 case SIR_MAC_AUTH_FRAME_3:
3560 /// Auth frame3 to be sent without encrypted framebody
3561 /**
3562 * Allocate buffer for Authenticaton frame of size equal
3563 * to management frame header length plus 2 bytes each
3564 * for auth algorithm number, transaction number and
3565 * status code.
3566 */
3567
3568 frameLen = sizeof(tSirMacMgmtHdr) +
3569 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3570 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3571
3572 break;
3573
3574 case SIR_MAC_AUTH_FRAME_4:
3575 /**
3576 * Allocate buffer for Authenticaton frame of size equal
3577 * to management frame header length plus 2 bytes each
3578 * for auth algorithm number, transaction number and
3579 * status code.
3580 */
3581
3582 frameLen = sizeof(tSirMacMgmtHdr) +
3583 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3584 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3585
3586 break;
3587 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3588 } // end if (wepBit == LIM_WEP_IN_FC)
3589
3590
3591 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3592
3593 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3594 {
3595 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003596 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003597
3598 return;
3599 }
3600
3601 for (i = 0; i < frameLen; i++)
3602 pFrame[i] = 0;
3603
3604 // Prepare BD
3605 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3606 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3607 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303608 limLog(pMac, LOGE, FL("call to limPopulateMacHeader failed for "
3609 "AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003610 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3611 return;
3612 }
3613
3614 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3615 pMacHdr->fc.wep = wepBit;
3616
3617 // Prepare BSSId
3618 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3619 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303620 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3621 (tANI_U8 *) psessionEntry->bssId,
3622 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003623 }
3624
3625 /// Prepare Authentication frame body
3626 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3627
3628 if (wepBit == LIM_WEP_IN_FC)
3629 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303630 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003631
3632 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303633 FL("*** Sending Auth seq# 3 status %d (%d) to"MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003634 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303635 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3636 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003637
Jeff Johnson295189b2012-06-20 16:38:30 -07003638 }
3639 else
3640 {
3641 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3642 pBody += sizeof(tANI_U16);
3643 bodyLen -= sizeof(tANI_U16);
3644
3645 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3646 pBody += sizeof(tANI_U16);
3647 bodyLen -= sizeof(tANI_U16);
3648
3649 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3650 pBody += sizeof(tANI_U16);
3651 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003652 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3653 sizeof (pAuthFrameBody->length) +
3654 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303655 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003656
3657#if defined WLAN_FEATURE_VOWIFI_11R
3658 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3659 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3660 {
3661
3662 {
3663 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003664 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3665 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003666#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowdad63eb492014-02-06 12:21:47 -08003667 PELOG2(limLog(pMac, LOG2, FL("Auth1 Frame FTIE is: "));
3668 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
Jeff Johnson295189b2012-06-20 16:38:30 -07003669 (tANI_U8 *)pBody,
3670 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003671#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003672 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3673 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003674 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3675 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003676 }
3677 }
3678 else
3679 {
3680 /* MDID attr is 54*/
3681 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003682 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003683 *pBody = SIR_MDIE_SIZE;
3684 pBody++;
3685 for(i=0;i<SIR_MDIE_SIZE;i++)
3686 {
3687 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3688 pBody++;
3689 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003690 }
3691 }
3692 }
3693#endif
3694
3695 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303696 FL("*** Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003697 pAuthFrameBody->authTransactionSeqNumber,
3698 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303699 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3700 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003701 }
3702 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3703
3704 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003705 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3706 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003707#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303708 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003709 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3710#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003711 )
3712 {
3713 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3714 }
3715
Ganesh K08bce952012-12-13 15:04:41 -08003716 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3717 {
3718 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3719 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003720
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05303721 limLog( pMac, LOG1, FL("Sending Auth Frame over WQ5 to "MAC_ADDRESS_STR
3722 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
3723 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
3724
3725 txFlag |= HAL_USE_FW_IN_TX_PATH;
3726
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303727 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3728 psessionEntry->peSessionId,
3729 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003730 /// Queue Authentication frame in high priority WQ
3731 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3732 HAL_TXRX_FRM_802_11_MGMT,
3733 ANI_TXDIR_TODS,
3734 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3735 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303736 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3737 psessionEntry->peSessionId,
3738 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003739 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3740 {
3741 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003742 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003743 halstatus);
3744
3745 //Pkt will be freed up by the callback
3746 }
3747
3748 return;
3749} /*** end limSendAuthMgmtFrame() ***/
3750
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003751eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3752{
3753 tANI_U16 aid;
3754 tpDphHashNode pStaDs;
3755 tLimMlmDeauthReq *pMlmDeauthReq;
3756 tLimMlmDeauthCnf mlmDeauthCnf;
3757 tpPESession psessionEntry;
3758
3759 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3760 if (pMlmDeauthReq)
3761 {
3762 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3763 {
3764 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3765 }
3766
3767 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3768 {
3769
3770 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003771 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003772 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3773 goto end;
3774 }
3775
3776 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3777 if (pStaDs == NULL)
3778 {
3779 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3780 goto end;
3781 }
3782
3783
3784 /// Receive path cleanup with dummy packet
3785 limCleanupRxPath(pMac, pStaDs,psessionEntry);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05303786
3787#ifdef WLAN_FEATURE_VOWIFI_11R
3788 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
3789 (
3790#ifdef FEATURE_WLAN_ESE
3791 (psessionEntry->isESEconnection ) ||
3792#endif
3793#ifdef FEATURE_WLAN_LFR
3794 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
3795#endif
3796 (psessionEntry->is11Rconnection )))
3797 {
3798 PELOGE(limLog(pMac, LOGE,
3799 FL("FT Preauth Session (%p,%d) Cleanup"
3800 " Deauth reason %d Trigger = %d"),
3801 psessionEntry, psessionEntry->peSessionId,
3802 pMlmDeauthReq->reasonCode,
3803 pMlmDeauthReq->deauthTrigger););
3804 limFTCleanup(pMac);
3805 }
3806 else
3807 {
3808 PELOGE(limLog(pMac, LOGE,
3809 FL("No FT Preauth Session Cleanup in role %d"
3810#ifdef FEATURE_WLAN_ESE
3811 " isESE %d"
3812#endif
3813#ifdef FEATURE_WLAN_LFR
3814 " isLFR %d"
3815#endif
3816 " is11r %d, Deauth reason %d Trigger = %d"),
3817 psessionEntry->limSystemRole,
3818#ifdef FEATURE_WLAN_ESE
3819 psessionEntry->isESEconnection,
3820#endif
3821#ifdef FEATURE_WLAN_LFR
3822 psessionEntry->isFastRoamIniFeatureEnabled,
3823#endif
3824 psessionEntry->is11Rconnection,
3825 pMlmDeauthReq->reasonCode,
3826 pMlmDeauthReq->deauthTrigger););
3827 }
3828#endif
3829
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003830 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303831 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003832 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3833 }
3834 return eHAL_STATUS_SUCCESS;
3835end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303836 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003837 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3838 sizeof(tSirMacAddr));
3839 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3840 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3841 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3842
3843 // Free up buffer allocated
3844 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303845 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003846
3847 limPostSmeMessage(pMac,
3848 LIM_MLM_DEAUTH_CNF,
3849 (tANI_U32 *) &mlmDeauthCnf);
3850 return eHAL_STATUS_SUCCESS;
3851}
3852
3853eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3854{
3855 tANI_U16 aid;
3856 tpDphHashNode pStaDs;
3857 tLimMlmDisassocCnf mlmDisassocCnf;
3858 tpPESession psessionEntry;
3859 tLimMlmDisassocReq *pMlmDisassocReq;
3860
3861 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3862 if (pMlmDisassocReq)
3863 {
3864 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3865 {
3866 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3867 }
3868
3869 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3870 {
3871
3872 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003873 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003874 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3875 goto end;
3876 }
3877
3878 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3879 if (pStaDs == NULL)
3880 {
3881 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3882 goto end;
3883 }
3884
3885 /// Receive path cleanup with dummy packet
3886 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3887 {
3888 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3889 goto end;
3890 }
3891
3892#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003893 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303894 (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003895#ifdef FEATURE_WLAN_ESE
3896 (psessionEntry->isESEconnection ) ||
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003897#endif
3898#ifdef FEATURE_WLAN_LFR
3899 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003900#endif
3901 (psessionEntry->is11Rconnection )) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303902 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003903 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003904 {
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303905 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003906 FL("FT Preauth Session (%p,%d) Cleanup"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003907 psessionEntry, psessionEntry->peSessionId););
3908 limFTCleanup(pMac);
3909 }
3910 else
3911 {
3912 PELOGE(limLog(pMac, LOGE,
3913 FL("No FT Preauth Session Cleanup in role %d"
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003914#ifdef FEATURE_WLAN_ESE
3915 " isESE %d"
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003916#endif
3917#ifdef FEATURE_WLAN_LFR
3918 " isLFR %d"
3919#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003920 " is11r %d reason %d"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003921 psessionEntry->limSystemRole,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003922#ifdef FEATURE_WLAN_ESE
3923 psessionEntry->isESEconnection,
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003924#endif
3925#ifdef FEATURE_WLAN_LFR
3926 psessionEntry->isFastRoamIniFeatureEnabled,
3927#endif
3928 psessionEntry->is11Rconnection,
3929 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003930 }
3931#endif
3932
3933 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303934 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003935 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3936 return eHAL_STATUS_SUCCESS;
3937 }
3938 else
3939 {
3940 return eHAL_STATUS_SUCCESS;
3941 }
3942end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303943 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003944 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3945 sizeof(tSirMacAddr));
3946 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3947 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3948
3949 /* Update PE session ID*/
3950 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3951
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003952 if(pMlmDisassocReq != NULL)
3953 {
3954 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303955 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003956 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3957 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003958
3959 limPostSmeMessage(pMac,
3960 LIM_MLM_DISASSOC_CNF,
3961 (tANI_U32 *) &mlmDisassocCnf);
3962 return eHAL_STATUS_SUCCESS;
3963}
3964
3965eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3966{
3967 return limSendDisassocCnf(pMac);
3968}
3969
3970eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3971{
3972 return limSendDeauthCnf(pMac);
3973}
3974
Jeff Johnson295189b2012-06-20 16:38:30 -07003975/**
3976 * \brief This function is called to send Disassociate frame.
3977 *
3978 *
3979 * \param pMac Pointer to Global MAC structure
3980 *
3981 * \param nReason Indicates the reason that need to be sent in
3982 * Disassociation frame
3983 *
3984 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3985 * sent
3986 *
3987 *
3988 */
3989
3990void
3991limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3992 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003993 tSirMacAddr peer,
3994 tpPESession psessionEntry,
3995 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003996{
3997 tDot11fDisassociation frm;
3998 tANI_U8 *pFrame;
3999 tSirRetStatus nSirStatus;
4000 tpSirMacMgmtHdr pMacHdr;
4001 tANI_U32 nBytes, nPayload, nStatus;
4002 void *pPacket;
4003 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304004 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004005 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004006 if(NULL == psessionEntry)
4007 {
4008 return;
4009 }
4010
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304011 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004012
4013 frm.Reason.code = nReason;
4014
4015 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
4016 if ( DOT11F_FAILED( nStatus ) )
4017 {
4018 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004019 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004020 nStatus );
4021 // We'll fall back on the worst case scenario:
4022 nPayload = sizeof( tDot11fDisassociation );
4023 }
4024 else if ( DOT11F_WARNED( nStatus ) )
4025 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004026 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004027 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004028 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004029 }
4030
4031 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4032
4033 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4034 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4035 ( void** ) &pPacket );
4036 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4037 {
4038 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004039 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004040 return;
4041 }
4042
4043 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304044 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004045
4046 // Next, we fill out the buffer descriptor:
4047 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4048 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
4049 if ( eSIR_SUCCESS != nSirStatus )
4050 {
4051 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004052 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004053 nSirStatus );
4054 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4055 ( void* ) pFrame, ( void* ) pPacket );
4056 return; // just allocated...
4057 }
4058
4059 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4060
4061 // Prepare the BSSID
4062 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4063
Chet Lanctot186b5732013-03-18 10:26:30 -07004064#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004065 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004066#endif
4067
Jeff Johnson295189b2012-06-20 16:38:30 -07004068 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
4069 sizeof(tSirMacMgmtHdr),
4070 nPayload, &nPayload );
4071 if ( DOT11F_FAILED( nStatus ) )
4072 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004073 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004074 nStatus );
4075 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4076 ( void* ) pFrame, ( void* ) pPacket );
4077 return; // allocated!
4078 }
4079 else if ( DOT11F_WARNED( nStatus ) )
4080 {
4081 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004082 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004083 }
4084
Abhishek Singhcd09b562013-12-24 16:02:20 +05304085 limLog( pMac, LOG1, FL("***Sessionid %d Sending Disassociation frame with "
4086 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4087 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4088 MAC_ADDR_ARRAY(pMacHdr->da),
4089 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004090
4091 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004092 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4093 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004094 )
4095 {
4096 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4097 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004098
Ganesh K08bce952012-12-13 15:04:41 -08004099 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304100 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
4101 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08004102 {
4103 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4104 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004105
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304106 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4107 {
4108 /* This frame will be sent on air by firmware,
4109 which will ensure that this frame goes out
4110 even though DEL_STA is sent immediately */
4111 /* Without this for DEL_STA command there is
4112 risk of flushing frame in BTQM queue without
4113 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304114 limLog( pMac, LOG1, FL("Sending Disassoc Frame over WQ5 to "MAC_ADDRESS_STR
4115 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4116 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304117 txFlag |= HAL_USE_FW_IN_TX_PATH;
4118 }
4119
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004120 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004121 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304122 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4123 psessionEntry->peSessionId,
4124 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004125 // Queue Disassociation frame in high priority WQ
4126 /* get the duration from the request */
4127 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4128 HAL_TXRX_FRM_802_11_MGMT,
4129 ANI_TXDIR_TODS,
4130 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4131 limTxComplete, pFrame, limDisassocTxCompleteCnf,
4132 txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304133 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4134 psessionEntry->peSessionId,
4135 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004136 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07004137
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004138 if (tx_timer_change(
4139 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
4140 != TX_SUCCESS)
4141 {
4142 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004143 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004144 return;
4145 }
4146 else if(TX_SUCCESS != tx_timer_activate(
4147 &pMac->lim.limTimers.gLimDisassocAckTimer))
4148 {
4149 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004150 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004151 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4152 return;
4153 }
4154 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004155 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004156 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304157 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4158 psessionEntry->peSessionId,
4159 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004160 // Queue Disassociation frame in high priority WQ
4161 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4162 HAL_TXRX_FRM_802_11_MGMT,
4163 ANI_TXDIR_TODS,
4164 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4165 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304166 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4167 psessionEntry->peSessionId,
4168 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004169 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4170 {
4171 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004172 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004173 nSirStatus );
4174 //Pkt will be freed up by the callback
4175 return;
4176 }
4177 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004178} // End limSendDisassocMgmtFrame.
4179
4180/**
4181 * \brief This function is called to send a Deauthenticate frame
4182 *
4183 *
4184 * \param pMac Pointer to global MAC structure
4185 *
4186 * \param nReason Indicates the reason that need to be sent in the
4187 * Deauthenticate frame
4188 *
4189 * \param peeer address of the STA to which the frame is to be sent
4190 *
4191 *
4192 */
4193
4194void
4195limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
4196 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004197 tSirMacAddr peer,
4198 tpPESession psessionEntry,
4199 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004200{
4201 tDot11fDeAuth frm;
4202 tANI_U8 *pFrame;
4203 tSirRetStatus nSirStatus;
4204 tpSirMacMgmtHdr pMacHdr;
4205 tANI_U32 nBytes, nPayload, nStatus;
4206 void *pPacket;
4207 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304208 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004209 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004210#ifdef FEATURE_WLAN_TDLS
4211 tANI_U16 aid;
4212 tpDphHashNode pStaDs;
4213#endif
4214
Jeff Johnson295189b2012-06-20 16:38:30 -07004215 if(NULL == psessionEntry)
4216 {
4217 return;
4218 }
4219
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304220 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004221
4222 frm.Reason.code = nReason;
4223
4224 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
4225 if ( DOT11F_FAILED( nStatus ) )
4226 {
4227 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004228 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004229 nStatus );
4230 // We'll fall back on the worst case scenario:
4231 nPayload = sizeof( tDot11fDeAuth );
4232 }
4233 else if ( DOT11F_WARNED( nStatus ) )
4234 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004235 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004236 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004237 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004238 }
4239
4240 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4241
4242 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4243 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4244 ( void** ) &pPacket );
4245 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4246 {
4247 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004248 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004249 return;
4250 }
4251
4252 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304253 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004254
4255 // Next, we fill out the buffer descriptor:
4256 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4257 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
4258 if ( eSIR_SUCCESS != nSirStatus )
4259 {
4260 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004261 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004262 nSirStatus );
4263 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4264 ( void* ) pFrame, ( void* ) pPacket );
4265 return; // just allocated...
4266 }
4267
4268 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4269
4270 // Prepare the BSSID
4271 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4272
Chet Lanctot186b5732013-03-18 10:26:30 -07004273#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004274 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004275#endif
4276
Jeff Johnson295189b2012-06-20 16:38:30 -07004277 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
4278 sizeof(tSirMacMgmtHdr),
4279 nPayload, &nPayload );
4280 if ( DOT11F_FAILED( nStatus ) )
4281 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004282 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004283 nStatus );
4284 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4285 ( void* ) pFrame, ( void* ) pPacket );
4286 return;
4287 }
4288 else if ( DOT11F_WARNED( nStatus ) )
4289 {
4290 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004291 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004292 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05304293 limLog( pMac, LOG1, FL("***Sessionid %d Sending Deauth frame with "
4294 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4295 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4296 MAC_ADDR_ARRAY(pMacHdr->da),
4297 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004298
4299 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004300 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4301 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004302 )
4303 {
4304 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4305 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004306
Ganesh K08bce952012-12-13 15:04:41 -08004307 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304308 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
4309 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08004310 {
4311 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4312 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004313
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304314 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4315 {
4316 /* This frame will be sent on air by firmware,
4317 which will ensure that this frame goes out
4318 even though DEL_STA is sent immediately */
4319 /* Without this for DEL_STA command there is
4320 risk of flushing frame in BTQM queue without
4321 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304322 limLog( pMac, LOG1, FL("Sending Deauth Frame over WQ5 to "MAC_ADDRESS_STR
4323 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4324 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304325 txFlag |= HAL_USE_FW_IN_TX_PATH;
4326 }
4327
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004328#ifdef FEATURE_WLAN_TDLS
4329 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
4330#endif
4331
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004332 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004333 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304334 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4335 psessionEntry->peSessionId,
4336 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004337 // Queue Disassociation frame in high priority WQ
4338 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4339 HAL_TXRX_FRM_802_11_MGMT,
4340 ANI_TXDIR_TODS,
4341 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4342 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304343 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4344 psessionEntry->peSessionId,
4345 halstatus));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304346 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004347 {
4348 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304349 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004350 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08004351 //Pkt will be freed up by the callback limTxComplete
4352
4353 /*Call limProcessDeauthAckTimeout which will send
4354 * DeauthCnf for this frame
4355 */
4356 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004357 return;
4358 }
4359
4360 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
4361
4362 if (tx_timer_change(
4363 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
4364 != TX_SUCCESS)
4365 {
4366 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004367 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004368 return;
4369 }
4370 else if(TX_SUCCESS != tx_timer_activate(
4371 &pMac->lim.limTimers.gLimDeauthAckTimer))
4372 {
4373 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004374 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004375 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4376 return;
4377 }
4378 }
4379 else
4380 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304381 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4382 psessionEntry->peSessionId,
4383 pMacHdr->fc.subType));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004384#ifdef FEATURE_WLAN_TDLS
4385 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4386 {
4387 // Queue Disassociation frame in high priority WQ
4388 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004389 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004390 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004391 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4392 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004393 }
4394 else
4395 {
4396#endif
4397 // Queue Disassociation frame in high priority WQ
4398 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4399 HAL_TXRX_FRM_802_11_MGMT,
4400 ANI_TXDIR_TODS,
4401 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4402 limTxComplete, pFrame, txFlag );
4403#ifdef FEATURE_WLAN_TDLS
4404 }
4405#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304406 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4407 psessionEntry->peSessionId,
4408 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004409 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4410 {
4411 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004412 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004413 nSirStatus );
4414 //Pkt will be freed up by the callback
4415 return;
4416 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004417 }
4418
4419} // End limSendDeauthMgmtFrame.
4420
4421
4422#ifdef ANI_SUPPORT_11H
4423/**
4424 * \brief Send a Measurement Report Action frame
4425 *
4426 *
4427 * \param pMac Pointer to the global MAC structure
4428 *
4429 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4430 *
4431 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4432 *
4433 *
4434 */
4435
4436tSirRetStatus
4437limSendMeasReportFrame(tpAniSirGlobal pMac,
4438 tpSirMacMeasReqActionFrame pMeasReqFrame,
4439 tSirMacAddr peer)
4440{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304441 tDot11fMeasurementReport frm;
4442 tANI_U8 *pFrame;
4443 tSirRetStatus nSirStatus;
4444 tpSirMacMgmtHdr pMacHdr;
4445 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4446 void *pPacket;
4447 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004448
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304449 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004450
4451 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4452 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4453 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4454
4455 switch ( pMeasReqFrame->measReqIE.measType )
4456 {
4457 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4458 nSirStatus =
4459 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4460 &frm.MeasurementReport );
4461 break;
4462 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4463 nSirStatus =
4464 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4465 &frm.MeasurementReport );
4466 break;
4467 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4468 nSirStatus =
4469 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4470 &frm.MeasurementReport );
4471 break;
4472 default:
4473 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004474 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004475 pMeasReqFrame->measReqIE.measType );
4476 return eSIR_FAILURE;
4477 }
4478
4479 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4480
4481 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4482 if ( DOT11F_FAILED( nStatus ) )
4483 {
4484 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004485 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004486 nStatus );
4487 // We'll fall back on the worst case scenario:
4488 nPayload = sizeof( tDot11fMeasurementReport );
4489 }
4490 else if ( DOT11F_WARNED( nStatus ) )
4491 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004492 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004493 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004494 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004495 }
4496
4497 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4498
4499 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4500 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4501 {
4502 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004503 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004504 return eSIR_FAILURE;
4505 }
4506
4507 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304508 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004509
4510 // Next, we fill out the buffer descriptor:
4511 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4512 SIR_MAC_MGMT_ACTION, peer);
4513 if ( eSIR_SUCCESS != nSirStatus )
4514 {
4515 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004516 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 nSirStatus );
4518 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4519 return eSIR_FAILURE; // just allocated...
4520 }
4521
4522 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4523
4524 nCfg = 6;
4525 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4526 if ( eSIR_SUCCESS != nSirStatus )
4527 {
4528 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004529 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004530 nSirStatus );
4531 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4532 return eSIR_FAILURE; // just allocated...
4533 }
4534
Chet Lanctot186b5732013-03-18 10:26:30 -07004535#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004536 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004537#endif
4538
Jeff Johnson295189b2012-06-20 16:38:30 -07004539 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4540 sizeof(tSirMacMgmtHdr),
4541 nPayload, &nPayload );
4542 if ( DOT11F_FAILED( nStatus ) )
4543 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004544 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004545 nStatus );
4546 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4547 return eSIR_FAILURE; // allocated!
4548 }
4549 else if ( DOT11F_WARNED( nStatus ) )
4550 {
4551 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004552 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004553 }
4554
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304555 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4556 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4557 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004558 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4559 HAL_TXRX_FRM_802_11_MGMT,
4560 ANI_TXDIR_TODS,
4561 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4562 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304563 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4564 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4565 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004566 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4567 {
4568 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004569 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004570 nSirStatus );
4571 //Pkt will be freed up by the callback
4572 return eSIR_FAILURE; // just allocated...
4573 }
4574
4575 return eSIR_SUCCESS;
4576
4577} // End limSendMeasReportFrame.
4578
4579
4580/**
4581 * \brief Send a TPC Request Action frame
4582 *
4583 *
4584 * \param pMac Pointer to the global MAC datastructure
4585 *
4586 * \param peer MAC address to which the frame should be sent
4587 *
4588 *
4589 */
4590
4591void
4592limSendTpcRequestFrame(tpAniSirGlobal pMac,
4593 tSirMacAddr peer)
4594{
4595 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304596 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004597 tSirRetStatus nSirStatus;
4598 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304599 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4600 void *pPacket;
4601 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004602
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304603 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004604
4605 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4606 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4607 frm.DialogToken.token = 1;
4608 frm.TPCRequest.present = 1;
4609
4610 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4611 if ( DOT11F_FAILED( nStatus ) )
4612 {
4613 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004614 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004615 nStatus );
4616 // We'll fall back on the worst case scenario:
4617 nPayload = sizeof( tDot11fTPCRequest );
4618 }
4619 else if ( DOT11F_WARNED( nStatus ) )
4620 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004621 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004622 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004623 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004624 }
4625
4626 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4627
4628 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4629 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4630 {
4631 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004632 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004633 return;
4634 }
4635
4636 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304637 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004638
4639 // Next, we fill out the buffer descriptor:
4640 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4641 SIR_MAC_MGMT_ACTION, peer);
4642 if ( eSIR_SUCCESS != nSirStatus )
4643 {
4644 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004645 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004646 nSirStatus );
4647 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4648 return; // just allocated...
4649 }
4650
4651 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4652
4653 nCfg = 6;
4654 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4655 if ( eSIR_SUCCESS != nSirStatus )
4656 {
4657 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004658 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004659 nSirStatus );
4660 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4661 return; // just allocated...
4662 }
4663
Chet Lanctot186b5732013-03-18 10:26:30 -07004664#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004665 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004666#endif
4667
Jeff Johnson295189b2012-06-20 16:38:30 -07004668 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4669 sizeof(tSirMacMgmtHdr),
4670 nPayload, &nPayload );
4671 if ( DOT11F_FAILED( nStatus ) )
4672 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004673 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004674 nStatus );
4675 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4676 return; // allocated!
4677 }
4678 else if ( DOT11F_WARNED( nStatus ) )
4679 {
4680 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004681 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004682 }
4683
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304684 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4685 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4686 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004687 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4688 HAL_TXRX_FRM_802_11_MGMT,
4689 ANI_TXDIR_TODS,
4690 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4691 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304692 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4693 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4694 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004695 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4696 {
4697 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004698 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004699 nSirStatus );
4700 //Pkt will be freed up by the callback
4701 return;
4702 }
4703
4704} // End limSendTpcRequestFrame.
4705
4706
4707/**
4708 * \brief Send a TPC Report Action frame
4709 *
4710 *
4711 * \param pMac Pointer to the global MAC datastructure
4712 *
4713 * \param pTpcReqFrame Pointer to the received TPC Request
4714 *
4715 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4716 *
4717 *
4718 */
4719
4720tSirRetStatus
4721limSendTpcReportFrame(tpAniSirGlobal pMac,
4722 tpSirMacTpcReqActionFrame pTpcReqFrame,
4723 tSirMacAddr peer)
4724{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304725 tDot11fTPCReport frm;
4726 tANI_U8 *pFrame;
4727 tSirRetStatus nSirStatus;
4728 tpSirMacMgmtHdr pMacHdr;
4729 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4730 void *pPacket;
4731 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004732
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304733 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004734
4735 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4736 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4737 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4738
4739 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4740 // "misplaced this function, need to replace:
4741 // txPower = halGetRateToPwrValue(pMac, staid,
4742 // pMac->lim.gLimCurrentChannelId, 0);
4743 frm.TPCReport.tx_power = 0;
4744 frm.TPCReport.link_margin = 0;
4745 frm.TPCReport.present = 1;
4746
4747 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4748 if ( DOT11F_FAILED( nStatus ) )
4749 {
4750 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004751 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004752 nStatus );
4753 // We'll fall back on the worst case scenario:
4754 nPayload = sizeof( tDot11fTPCReport );
4755 }
4756 else if ( DOT11F_WARNED( nStatus ) )
4757 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004758 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004759 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004760 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004761 }
4762
4763 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4764
4765 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4766 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4767 {
4768 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004769 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004770 return eSIR_FAILURE;
4771 }
4772
4773 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304774 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004775
4776 // Next, we fill out the buffer descriptor:
4777 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4778 SIR_MAC_MGMT_ACTION, peer);
4779 if ( eSIR_SUCCESS != nSirStatus )
4780 {
4781 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004782 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004783 nSirStatus );
4784 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4785 return eSIR_FAILURE; // just allocated...
4786 }
4787
4788 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4789
4790 nCfg = 6;
4791 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4792 if ( eSIR_SUCCESS != nSirStatus )
4793 {
4794 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004795 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004796 nSirStatus );
4797 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4798 return eSIR_FAILURE; // just allocated...
4799 }
4800
Chet Lanctot186b5732013-03-18 10:26:30 -07004801#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004802 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004803#endif
4804
Jeff Johnson295189b2012-06-20 16:38:30 -07004805 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4806 sizeof(tSirMacMgmtHdr),
4807 nPayload, &nPayload );
4808 if ( DOT11F_FAILED( nStatus ) )
4809 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004810 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004811 nStatus );
4812 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4813 return eSIR_FAILURE; // allocated!
4814 }
4815 else if ( DOT11F_WARNED( nStatus ) )
4816 {
4817 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004818 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004819 }
4820
4821
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304822 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4823 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4824 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004825 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4826 HAL_TXRX_FRM_802_11_MGMT,
4827 ANI_TXDIR_TODS,
4828 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4829 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304830 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4831 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4832 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004833 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4834 {
4835 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004836 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004837 nSirStatus );
4838 //Pkt will be freed up by the callback
4839 return eSIR_FAILURE; // just allocated...
4840 }
4841
4842 return eSIR_SUCCESS;
4843
4844} // End limSendTpcReportFrame.
4845#endif //ANI_SUPPORT_11H
4846
4847
Jeff Johnson295189b2012-06-20 16:38:30 -07004848/**
4849 * \brief Send a Channel Switch Announcement
4850 *
4851 *
4852 * \param pMac Pointer to the global MAC datastructure
4853 *
4854 * \param peer MAC address to which this frame will be sent
4855 *
4856 * \param nMode
4857 *
4858 * \param nNewChannel
4859 *
4860 * \param nCount
4861 *
4862 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4863 *
4864 *
4865 */
4866
4867tSirRetStatus
4868limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4869 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004870 tANI_U8 nMode,
4871 tANI_U8 nNewChannel,
4872 tANI_U8 nCount,
4873 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004874{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304875 tDot11fChannelSwitch frm;
4876 tANI_U8 *pFrame;
4877 tSirRetStatus nSirStatus;
4878 tpSirMacMgmtHdr pMacHdr;
4879 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4880 void *pPacket;
4881 eHalStatus halstatus;
4882 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004883
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304884 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004885
4886 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4887 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4888 frm.ChanSwitchAnn.switchMode = nMode;
4889 frm.ChanSwitchAnn.newChannel = nNewChannel;
4890 frm.ChanSwitchAnn.switchCount = nCount;
4891 frm.ChanSwitchAnn.present = 1;
4892
4893 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4894 if ( DOT11F_FAILED( nStatus ) )
4895 {
4896 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004897 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004898 nStatus );
4899 // We'll fall back on the worst case scenario:
4900 nPayload = sizeof( tDot11fChannelSwitch );
4901 }
4902 else if ( DOT11F_WARNED( nStatus ) )
4903 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004904 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004905 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004906 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004907 }
4908
4909 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4910
4911 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4912 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4913 {
4914 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004915 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004916 return eSIR_FAILURE;
4917 }
4918
4919 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304920 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004921
4922 // Next, we fill out the buffer descriptor:
4923 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004924 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4925 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304926 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4927 (tANI_U8 *) psessionEntry->bssId,
4928 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004929 if ( eSIR_SUCCESS != nSirStatus )
4930 {
4931 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004932 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004933 nSirStatus );
4934 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4935 return eSIR_FAILURE; // just allocated...
4936 }
4937
Jeff Johnsone7245742012-09-05 17:12:55 -07004938#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004939 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4940
4941 nCfg = 6;
4942 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4943 if ( eSIR_SUCCESS != nSirStatus )
4944 {
4945 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004946 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004947 nSirStatus );
4948 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4949 return eSIR_FAILURE; // just allocated...
4950 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004951#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004952
4953#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004954 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004955#endif
4956
Jeff Johnson295189b2012-06-20 16:38:30 -07004957 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4958 sizeof(tSirMacMgmtHdr),
4959 nPayload, &nPayload );
4960 if ( DOT11F_FAILED( nStatus ) )
4961 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004962 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004963 nStatus );
4964 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4965 return eSIR_FAILURE; // allocated!
4966 }
4967 else if ( DOT11F_WARNED( nStatus ) )
4968 {
4969 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004970 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004971 }
4972
Jeff Johnsone7245742012-09-05 17:12:55 -07004973 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004974 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4975 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004976 )
4977 {
4978 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4979 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304980
4981 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4982 psessionEntry->peSessionId,
4983 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004984 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4985 HAL_TXRX_FRM_802_11_MGMT,
4986 ANI_TXDIR_TODS,
4987 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004988 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304989 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4990 psessionEntry->peSessionId,
4991 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004992 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4993 {
4994 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004995 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004996 nSirStatus );
4997 //Pkt will be freed up by the callback
4998 return eSIR_FAILURE;
4999 }
5000
5001 return eSIR_SUCCESS;
5002
5003} // End limSendChannelSwitchMgmtFrame.
5004
Jeff Johnson295189b2012-06-20 16:38:30 -07005005
5006
Mohit Khanna4a70d262012-09-11 16:30:12 -07005007#ifdef WLAN_FEATURE_11AC
5008tSirRetStatus
5009limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
5010 tSirMacAddr peer,
5011 tANI_U8 nMode,
5012 tpPESession psessionEntry )
5013{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305014 tDot11fOperatingMode frm;
5015 tANI_U8 *pFrame;
5016 tSirRetStatus nSirStatus;
5017 tpSirMacMgmtHdr pMacHdr;
5018 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
5019 void *pPacket;
5020 eHalStatus halstatus;
5021 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07005022
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305023 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005024
5025 frm.Category.category = SIR_MAC_ACTION_VHT;
5026 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
5027 frm.OperatingMode.chanWidth = nMode;
5028 frm.OperatingMode.rxNSS = 0;
5029 frm.OperatingMode.rxNSSType = 0;
5030
5031 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
5032 if ( DOT11F_FAILED( nStatus ) )
5033 {
5034 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005035 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005036 nStatus );
5037 // We'll fall back on the worst case scenario:
5038 nPayload = sizeof( tDot11fOperatingMode);
5039 }
5040 else if ( DOT11F_WARNED( nStatus ) )
5041 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005042 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07005043 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005044 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005045 }
5046
5047 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5048
5049 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5050 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5051 {
5052 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005053 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005054 return eSIR_FAILURE;
5055 }
5056
5057 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305058 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005059
5060
5061 // Next, we fill out the buffer descriptor:
5062 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
5063 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5064 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5065 } else
5066 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5067 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
5068 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305069 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5070 (tANI_U8 *) psessionEntry->bssId,
5071 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005072 if ( eSIR_SUCCESS != nSirStatus )
5073 {
5074 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005075 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005076 nSirStatus );
5077 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5078 return eSIR_FAILURE; // just allocated...
5079 }
5080 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
5081 sizeof(tSirMacMgmtHdr),
5082 nPayload, &nPayload );
5083 if ( DOT11F_FAILED( nStatus ) )
5084 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005085 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005086 nStatus );
5087 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5088 return eSIR_FAILURE; // allocated!
5089 }
5090 else if ( DOT11F_WARNED( nStatus ) )
5091 {
5092 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005093 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005094 }
5095 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07005096 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5097 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07005098 )
5099 {
5100 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5101 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305102
5103 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5104 psessionEntry->peSessionId,
5105 pMacHdr->fc.subType));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005106 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5107 HAL_TXRX_FRM_802_11_MGMT,
5108 ANI_TXDIR_TODS,
5109 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5110 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305111 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5112 psessionEntry->peSessionId,
5113 halstatus));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005114 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5115 {
5116 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005117 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005118 nSirStatus );
5119 //Pkt will be freed up by the callback
5120 return eSIR_FAILURE;
5121 }
5122
5123 return eSIR_SUCCESS;
5124}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005125
5126/**
5127 * \brief Send a VHT Channel Switch Announcement
5128 *
5129 *
5130 * \param pMac Pointer to the global MAC datastructure
5131 *
5132 * \param peer MAC address to which this frame will be sent
5133 *
5134 * \param nChanWidth
5135 *
5136 * \param nNewChannel
5137 *
5138 *
5139 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5140 *
5141 *
5142 */
5143
5144tSirRetStatus
5145limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5146 tSirMacAddr peer,
5147 tANI_U8 nChanWidth,
5148 tANI_U8 nNewChannel,
5149 tANI_U8 ncbMode,
5150 tpPESession psessionEntry )
5151{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305152 tDot11fChannelSwitch frm;
5153 tANI_U8 *pFrame;
5154 tSirRetStatus nSirStatus;
5155 tpSirMacMgmtHdr pMacHdr;
5156 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5157 void *pPacket;
5158 eHalStatus halstatus;
5159 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005160
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305161 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005162
5163
5164 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5165 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5166 frm.ChanSwitchAnn.switchMode = 1;
5167 frm.ChanSwitchAnn.newChannel = nNewChannel;
5168 frm.ChanSwitchAnn.switchCount = 1;
5169 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
5170 frm.ExtChanSwitchAnn.present = 1;
5171 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
5172 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
5173 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
5174 frm.ChanSwitchAnn.present = 1;
5175 frm.WiderBWChanSwitchAnn.present = 1;
5176
5177 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5178 if ( DOT11F_FAILED( nStatus ) )
5179 {
5180 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005181 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005182 nStatus );
5183 // We'll fall back on the worst case scenario:
5184 nPayload = sizeof( tDot11fChannelSwitch );
5185 }
5186 else if ( DOT11F_WARNED( nStatus ) )
5187 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005188 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005189 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005190 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005191 }
5192
5193 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5194
5195 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5196 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5197 {
5198 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005199 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005200 return eSIR_FAILURE;
5201 }
5202 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305203 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005204
5205 // Next, we fill out the buffer descriptor:
5206 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5207 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5208 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305209 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5210 (tANI_U8 *) psessionEntry->bssId,
5211 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005212 if ( eSIR_SUCCESS != nSirStatus )
5213 {
5214 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005215 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005216 nSirStatus );
5217 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5218 return eSIR_FAILURE; // just allocated...
5219 }
5220 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5221 sizeof(tSirMacMgmtHdr),
5222 nPayload, &nPayload );
5223 if ( DOT11F_FAILED( nStatus ) )
5224 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005225 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005226 nStatus );
5227 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5228 return eSIR_FAILURE; // allocated!
5229 }
5230 else if ( DOT11F_WARNED( nStatus ) )
5231 {
5232 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005233 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005234 }
5235
5236 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005237 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5238 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005239 )
5240 {
5241 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5242 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305243
5244 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5245 psessionEntry->peSessionId,
5246 pMacHdr->fc.subType));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005247 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5248 HAL_TXRX_FRM_802_11_MGMT,
5249 ANI_TXDIR_TODS,
5250 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5251 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305252 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5253 psessionEntry->peSessionId,
5254 halstatus));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005255 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5256 {
5257 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005258 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005259 nSirStatus );
5260 //Pkt will be freed up by the callback
5261 return eSIR_FAILURE;
5262 }
5263
5264 return eSIR_SUCCESS;
5265
5266} // End limSendVHTChannelSwitchMgmtFrame.
5267
5268
5269
Mohit Khanna4a70d262012-09-11 16:30:12 -07005270#endif
5271
Jeff Johnson295189b2012-06-20 16:38:30 -07005272/**
5273 * \brief Send an ADDBA Req Action Frame to peer
5274 *
5275 * \sa limSendAddBAReq
5276 *
5277 * \param pMac The global tpAniSirGlobal object
5278 *
5279 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
5280 * the necessary parameters reqd by PE send the ADDBA Req Action
5281 * Frame to the peer
5282 *
5283 * \return eSIR_SUCCESS if setup completes successfully
5284 * eSIR_FAILURE is some problem is encountered
5285 */
5286tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305287 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07005288{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305289 tDot11fAddBAReq frmAddBAReq;
5290 tANI_U8 *pAddBAReqBuffer = NULL;
5291 tpSirMacMgmtHdr pMacHdr;
5292 tANI_U32 frameLen = 0, nStatus, nPayload;
5293 tSirRetStatus statusCode;
5294 eHalStatus halStatus;
5295 void *pPacket;
5296 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005297
5298 if(NULL == psessionEntry)
5299 {
5300 return eSIR_FAILURE;
5301 }
5302
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305303 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005304
5305 // Category - 3 (BA)
5306 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
5307
5308 // Action - 0 (ADDBA Req)
5309 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
5310
5311 // FIXME - Dialog Token, generalize this...
5312 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
5313
5314 // Fill the ADDBA Parameter Set
5315 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
5316 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
5317 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
5318
5319 // BA timeout
5320 // 0 - indicates no BA timeout
5321 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
5322
5323 // BA Starting Sequence Number
5324 // Fragment number will always be zero
5325 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
5326 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
5327 }
5328
5329 frmAddBAReq.BAStartingSequenceControl.ssn =
5330 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
5331
5332 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
5333
5334 if( DOT11F_FAILED( nStatus ))
5335 {
5336 limLog( pMac, LOGW,
5337 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005338 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005339 nStatus );
5340
5341 // We'll fall back on the worst case scenario:
5342 nPayload = sizeof( tDot11fAddBAReq );
5343 }
5344 else if( DOT11F_WARNED( nStatus ))
5345 {
5346 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005347 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005348 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005349 nStatus );
5350 }
5351
5352 // Add the MGMT header to frame length
5353 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5354
5355 // Need to allocate a buffer for ADDBA AF
5356 if( eHAL_STATUS_SUCCESS !=
5357 (halStatus = palPktAlloc( pMac->hHdd,
5358 HAL_TXRX_FRM_802_11_MGMT,
5359 (tANI_U16) frameLen,
5360 (void **) &pAddBAReqBuffer,
5361 (void **) &pPacket )))
5362 {
5363 // Log error
5364 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005365 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005366 frameLen,
5367 halStatus );
5368
5369 statusCode = eSIR_MEM_ALLOC_FAILED;
5370 goto returnAfterError;
5371 }
5372
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305373 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005374
5375 // Copy necessary info to BD
5376 if( eSIR_SUCCESS !=
5377 (statusCode = limPopulateMacHeader( pMac,
5378 pAddBAReqBuffer,
5379 SIR_MAC_MGMT_FRAME,
5380 SIR_MAC_MGMT_ACTION,
5381 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5382 goto returnAfterError;
5383
5384 // Update A3 with the BSSID
5385 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
5386
5387 #if 0
5388 cfgLen = SIR_MAC_ADDR_LENGTH;
5389 if( eSIR_SUCCESS != cfgGetStr( pMac,
5390 WNI_CFG_BSSID,
5391 (tANI_U8 *) pMacHdr->bssId,
5392 &cfgLen ))
5393 {
5394 limLog( pMac, LOGP,
5395 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005396 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005397
5398 // FIXME - Need to convert to tSirRetStatus
5399 statusCode = eSIR_FAILURE;
5400 goto returnAfterError;
5401 }
5402 #endif//TO SUPPORT BT-AMP
5403 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5404
Chet Lanctot186b5732013-03-18 10:26:30 -07005405#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005406 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005407#endif
5408
Jeff Johnson295189b2012-06-20 16:38:30 -07005409 // Now, we're ready to "pack" the frames
5410 nStatus = dot11fPackAddBAReq( pMac,
5411 &frmAddBAReq,
5412 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5413 nPayload,
5414 &nPayload );
5415
5416 if( DOT11F_FAILED( nStatus ))
5417 {
5418 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005419 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005420 nStatus );
5421
5422 // FIXME - Need to convert to tSirRetStatus
5423 statusCode = eSIR_FAILURE;
5424 goto returnAfterError;
5425 }
5426 else if( DOT11F_WARNED( nStatus ))
5427 {
5428 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005429 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5430 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005431 }
5432
5433 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005434 FL( "Sending an ADDBA REQ to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005435 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
5436
5437 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005438 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5439 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005440 )
5441 {
5442 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5443 }
5444
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305445 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5446 psessionEntry->peSessionId,
5447 pMacHdr->fc.subType));
5448 halStatus = halTxFrame( pMac,
5449 pPacket,
5450 (tANI_U16) frameLen,
5451 HAL_TXRX_FRM_802_11_MGMT,
5452 ANI_TXDIR_TODS,
5453 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5454 limTxComplete,
5455 pAddBAReqBuffer, txFlag );
5456 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5457 psessionEntry->peSessionId,
5458 halStatus));
5459 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005460 {
5461 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005462 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005463 halStatus );
5464
5465 // FIXME - Need to convert eHalStatus to tSirRetStatus
5466 statusCode = eSIR_FAILURE;
5467 //Pkt will be freed up by the callback
5468 return statusCode;
5469 }
5470 else
5471 return eSIR_SUCCESS;
5472
5473returnAfterError:
5474
5475 // Release buffer, if allocated
5476 if( NULL != pAddBAReqBuffer )
5477 palPktFree( pMac->hHdd,
5478 HAL_TXRX_FRM_802_11_MGMT,
5479 (void *) pAddBAReqBuffer,
5480 (void *) pPacket );
5481
5482 return statusCode;
5483}
5484
5485/**
5486 * \brief Send an ADDBA Rsp Action Frame to peer
5487 *
5488 * \sa limSendAddBARsp
5489 *
5490 * \param pMac The global tpAniSirGlobal object
5491 *
5492 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5493 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5494 * Frame to the peer
5495 *
5496 * \return eSIR_SUCCESS if setup completes successfully
5497 * eSIR_FAILURE is some problem is encountered
5498 */
5499tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5500 tpLimMlmAddBARsp pMlmAddBARsp,
5501 tpPESession psessionEntry)
5502{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305503 tDot11fAddBARsp frmAddBARsp;
5504 tANI_U8 *pAddBARspBuffer = NULL;
5505 tpSirMacMgmtHdr pMacHdr;
5506 tANI_U32 frameLen = 0, nStatus, nPayload;
5507 tSirRetStatus statusCode;
5508 eHalStatus halStatus;
5509 void *pPacket;
5510 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005511
5512 if(NULL == psessionEntry)
5513 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005514 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005515 return eSIR_FAILURE;
5516 }
5517
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305518 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005519
5520 // Category - 3 (BA)
5521 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5522 // Action - 1 (ADDBA Rsp)
5523 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5524
5525 // Should be same as the one we received in the ADDBA Req
5526 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5527
5528 // ADDBA Req status
5529 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5530
5531 // Fill the ADDBA Parameter Set as provided by caller
5532 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5533 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5534 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005535
5536 if(psessionEntry->isAmsduSupportInAMPDU)
5537 {
5538 frmAddBARsp.AddBAParameterSet.amsduSupported =
5539 psessionEntry->amsduSupportedInBA;
5540 }
5541 else
5542 {
5543 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5544 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005545
5546 // BA timeout
5547 // 0 - indicates no BA timeout
5548 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5549
5550 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5551
5552 if( DOT11F_FAILED( nStatus ))
5553 {
5554 limLog( pMac, LOGW,
5555 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005556 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005557 nStatus );
5558
5559 // We'll fall back on the worst case scenario:
5560 nPayload = sizeof( tDot11fAddBARsp );
5561 }
5562 else if( DOT11F_WARNED( nStatus ))
5563 {
5564 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005565 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005566 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005567 nStatus );
5568 }
5569
5570 // Need to allocate a buffer for ADDBA AF
5571 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5572
5573 // Allocate shared memory
5574 if( eHAL_STATUS_SUCCESS !=
5575 (halStatus = palPktAlloc( pMac->hHdd,
5576 HAL_TXRX_FRM_802_11_MGMT,
5577 (tANI_U16) frameLen,
5578 (void **) &pAddBARspBuffer,
5579 (void **) &pPacket )))
5580 {
5581 // Log error
5582 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005583 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005584 frameLen,
5585 halStatus );
5586
5587 statusCode = eSIR_MEM_ALLOC_FAILED;
5588 goto returnAfterError;
5589 }
5590
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305591 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005592
5593 // Copy necessary info to BD
5594 if( eSIR_SUCCESS !=
5595 (statusCode = limPopulateMacHeader( pMac,
5596 pAddBARspBuffer,
5597 SIR_MAC_MGMT_FRAME,
5598 SIR_MAC_MGMT_ACTION,
5599 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5600 goto returnAfterError;
5601
5602 // Update A3 with the BSSID
5603
5604 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5605
5606 #if 0
5607 cfgLen = SIR_MAC_ADDR_LENGTH;
5608 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5609 WNI_CFG_BSSID,
5610 (tANI_U8 *) pMacHdr->bssId,
5611 &cfgLen ))
5612 {
5613 limLog( pMac, LOGP,
5614 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005615 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005616
5617 // FIXME - Need to convert to tSirRetStatus
5618 statusCode = eSIR_FAILURE;
5619 goto returnAfterError;
5620 }
5621 #endif // TO SUPPORT BT-AMP
5622 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5623
Chet Lanctot186b5732013-03-18 10:26:30 -07005624#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005625 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005626#endif
5627
Jeff Johnson295189b2012-06-20 16:38:30 -07005628 // Now, we're ready to "pack" the frames
5629 nStatus = dot11fPackAddBARsp( pMac,
5630 &frmAddBARsp,
5631 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5632 nPayload,
5633 &nPayload );
5634
5635 if( DOT11F_FAILED( nStatus ))
5636 {
5637 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005638 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005639 nStatus );
5640
5641 // FIXME - Need to convert to tSirRetStatus
5642 statusCode = eSIR_FAILURE;
5643 goto returnAfterError;
5644 }
5645 else if( DOT11F_WARNED( nStatus ))
5646 {
5647 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005648 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5649 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005650 }
5651
5652 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005653 FL( "Sending an ADDBA RSP to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005654 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5655
5656 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005657 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5658 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005659 )
5660 {
5661 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5662 }
5663
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305664 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5665 psessionEntry->peSessionId,
5666 pMacHdr->fc.subType));
5667 halStatus = halTxFrame( pMac,
5668 pPacket,
5669 (tANI_U16) frameLen,
5670 HAL_TXRX_FRM_802_11_MGMT,
5671 ANI_TXDIR_TODS,
5672 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5673 limTxComplete,
5674 pAddBARspBuffer, txFlag );
5675 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5676 psessionEntry->peSessionId,
5677 halStatus));
5678 if( eHAL_STATUS_SUCCESS != halStatus )
5679 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005680 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005681 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005682 halStatus );
5683
5684 // FIXME - HAL error codes are different from PE error
5685 // codes!! And, this routine is returning tSirRetStatus
5686 statusCode = eSIR_FAILURE;
5687 //Pkt will be freed up by the callback
5688 return statusCode;
5689 }
5690 else
5691 return eSIR_SUCCESS;
5692
5693 returnAfterError:
Jeff Johnson295189b2012-06-20 16:38:30 -07005694 // Release buffer, if allocated
5695 if( NULL != pAddBARspBuffer )
5696 palPktFree( pMac->hHdd,
5697 HAL_TXRX_FRM_802_11_MGMT,
5698 (void *) pAddBARspBuffer,
5699 (void *) pPacket );
5700
5701 return statusCode;
5702}
5703
5704/**
5705 * \brief Send a DELBA Indication Action Frame to peer
5706 *
5707 * \sa limSendDelBAInd
5708 *
5709 * \param pMac The global tpAniSirGlobal object
5710 *
5711 * \param peerMacAddr MAC Address of peer
5712 *
5713 * \param reasonCode Reason for the DELBA notification
5714 *
5715 * \param pBAParameterSet The DELBA Parameter Set.
5716 * This identifies the TID for which the BA session is
5717 * being deleted.
5718 *
5719 * \return eSIR_SUCCESS if setup completes successfully
5720 * eSIR_FAILURE is some problem is encountered
5721 */
5722tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5723 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5724{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305725 tDot11fDelBAInd frmDelBAInd;
5726 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005727 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305728 tpSirMacMgmtHdr pMacHdr;
5729 tANI_U32 frameLen = 0, nStatus, nPayload;
5730 tSirRetStatus statusCode;
5731 eHalStatus halStatus;
5732 void *pPacket;
5733 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005734
5735 if(NULL == psessionEntry)
5736 {
5737 return eSIR_FAILURE;
5738 }
5739
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305740 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005741
5742 // Category - 3 (BA)
5743 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5744 // Action - 2 (DELBA)
5745 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5746
5747 // Fill the DELBA Parameter Set as provided by caller
5748 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5749 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5750
5751 // BA Starting Sequence Number
5752 // Fragment number will always be zero
5753 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5754
5755 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5756
5757 if( DOT11F_FAILED( nStatus ))
5758 {
5759 limLog( pMac, LOGW,
5760 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005761 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005762 nStatus );
5763
5764 // We'll fall back on the worst case scenario:
5765 nPayload = sizeof( tDot11fDelBAInd );
5766 }
5767 else if( DOT11F_WARNED( nStatus ))
5768 {
5769 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005770 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005771 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005772 nStatus );
5773 }
5774
5775 // Add the MGMT header to frame length
5776 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5777
5778 // Allocate shared memory
5779 if( eHAL_STATUS_SUCCESS !=
5780 (halStatus = palPktAlloc( pMac->hHdd,
5781 HAL_TXRX_FRM_802_11_MGMT,
5782 (tANI_U16) frameLen,
5783 (void **) &pDelBAIndBuffer,
5784 (void **) &pPacket )))
5785 {
5786 // Log error
5787 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005788 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005789 frameLen,
5790 halStatus );
5791
5792 statusCode = eSIR_MEM_ALLOC_FAILED;
5793 goto returnAfterError;
5794 }
5795
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305796 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005797
5798 // Copy necessary info to BD
5799 if( eSIR_SUCCESS !=
5800 (statusCode = limPopulateMacHeader( pMac,
5801 pDelBAIndBuffer,
5802 SIR_MAC_MGMT_FRAME,
5803 SIR_MAC_MGMT_ACTION,
5804 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5805 goto returnAfterError;
5806
5807 // Update A3 with the BSSID
5808 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5809
5810 #if 0
5811 cfgLen = SIR_MAC_ADDR_LENGTH;
5812 if( eSIR_SUCCESS != cfgGetStr( pMac,
5813 WNI_CFG_BSSID,
5814 (tANI_U8 *) pMacHdr->bssId,
5815 &cfgLen ))
5816 {
5817 limLog( pMac, LOGP,
5818 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005819 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005820
5821 // FIXME - Need to convert to tSirRetStatus
5822 statusCode = eSIR_FAILURE;
5823 goto returnAfterError;
5824 }
5825 #endif //TO SUPPORT BT-AMP
5826 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5827
Chet Lanctot186b5732013-03-18 10:26:30 -07005828#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005829 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005830#endif
5831
Jeff Johnson295189b2012-06-20 16:38:30 -07005832 // Now, we're ready to "pack" the frames
5833 nStatus = dot11fPackDelBAInd( pMac,
5834 &frmDelBAInd,
5835 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5836 nPayload,
5837 &nPayload );
5838
5839 if( DOT11F_FAILED( nStatus ))
5840 {
5841 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005842 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005843 nStatus );
5844
5845 // FIXME - Need to convert to tSirRetStatus
5846 statusCode = eSIR_FAILURE;
5847 goto returnAfterError;
5848 }
5849 else if( DOT11F_WARNED( nStatus ))
5850 {
5851 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005852 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
5853 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005854 }
5855
5856 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005857 FL( "Sending a DELBA IND to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005858 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5859
5860 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005861 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5862 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005863 )
5864 {
5865 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5866 }
5867
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305868 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5869 psessionEntry->peSessionId,
5870 pMacHdr->fc.subType));
5871 halStatus = halTxFrame( pMac,
5872 pPacket,
5873 (tANI_U16) frameLen,
5874 HAL_TXRX_FRM_802_11_MGMT,
5875 ANI_TXDIR_TODS,
5876 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5877 limTxComplete,
5878 pDelBAIndBuffer, txFlag );
5879 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5880 psessionEntry->peSessionId,
5881 halStatus));
5882 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005883 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005884 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005885 statusCode = eSIR_FAILURE;
5886 //Pkt will be freed up by the callback
5887 return statusCode;
5888 }
5889 else
5890 return eSIR_SUCCESS;
5891
5892 returnAfterError:
5893
5894 // Release buffer, if allocated
5895 if( NULL != pDelBAIndBuffer )
5896 palPktFree( pMac->hHdd,
5897 HAL_TXRX_FRM_802_11_MGMT,
5898 (void *) pDelBAIndBuffer,
5899 (void *) pPacket );
5900
5901 return statusCode;
5902}
5903
5904#if defined WLAN_FEATURE_VOWIFI
5905
5906/**
5907 * \brief Send a Neighbor Report Request Action frame
5908 *
5909 *
5910 * \param pMac Pointer to the global MAC structure
5911 *
5912 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5913 *
5914 * \param peer mac address of peer station.
5915 *
5916 * \param psessionEntry address of session entry.
5917 *
5918 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5919 *
5920 *
5921 */
5922
5923tSirRetStatus
5924limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5925 tpSirMacNeighborReportReq pNeighborReq,
5926 tSirMacAddr peer,
5927 tpPESession psessionEntry
5928 )
5929{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305930 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005931 tDot11fNeighborReportRequest frm;
5932 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305933 tpSirMacMgmtHdr pMacHdr;
5934 tANI_U32 nBytes, nPayload, nStatus;
5935 void *pPacket;
5936 eHalStatus halstatus;
5937 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005938
5939 if ( psessionEntry == NULL )
5940 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005941 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005942 return eSIR_FAILURE;
5943 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305944 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005945
5946 frm.Category.category = SIR_MAC_ACTION_RRM;
5947 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5948 frm.DialogToken.token = pNeighborReq->dialogToken;
5949
5950
5951 if( pNeighborReq->ssid_present )
5952 {
5953 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5954 }
5955
5956 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5957 if ( DOT11F_FAILED( nStatus ) )
5958 {
5959 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005960 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005961 nStatus );
5962 // We'll fall back on the worst case scenario:
5963 nPayload = sizeof( tDot11fNeighborReportRequest );
5964 }
5965 else if ( DOT11F_WARNED( nStatus ) )
5966 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005967 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005968 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005969 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005970 }
5971
5972 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5973
5974 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5975 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5976 {
5977 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005978 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005979 return eSIR_FAILURE;
5980 }
5981
5982 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305983 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005984
5985 // Copy necessary info to BD
5986 if( eSIR_SUCCESS !=
5987 (statusCode = limPopulateMacHeader( pMac,
5988 pFrame,
5989 SIR_MAC_MGMT_FRAME,
5990 SIR_MAC_MGMT_ACTION,
5991 peer, psessionEntry->selfMacAddr)))
5992 goto returnAfterError;
5993
5994 // Update A3 with the BSSID
5995 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5996
5997 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5998
Chet Lanctot186b5732013-03-18 10:26:30 -07005999#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006000 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006001#endif
6002
Jeff Johnson295189b2012-06-20 16:38:30 -07006003 // Now, we're ready to "pack" the frames
6004 nStatus = dot11fPackNeighborReportRequest( pMac,
6005 &frm,
6006 pFrame + sizeof( tSirMacMgmtHdr ),
6007 nPayload,
6008 &nPayload );
6009
6010 if( DOT11F_FAILED( nStatus ))
6011 {
6012 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006013 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006014 nStatus );
6015
6016 // FIXME - Need to convert to tSirRetStatus
6017 statusCode = eSIR_FAILURE;
6018 goto returnAfterError;
6019 }
6020 else if( DOT11F_WARNED( nStatus ))
6021 {
6022 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006023 FL( "There were warnings while packing Neighbor Report "
6024 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006025 }
6026
6027 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006028 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006029 limPrintMacAddr( pMac, peer, LOGW );
6030
6031 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006032 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6033 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006034 )
6035 {
6036 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6037 }
6038
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306039 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6040 psessionEntry->peSessionId,
6041 pMacHdr->fc.subType));
6042 halstatus = halTxFrame( pMac,
6043 pPacket,
6044 (tANI_U16) nBytes,
6045 HAL_TXRX_FRM_802_11_MGMT,
6046 ANI_TXDIR_TODS,
6047 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6048 limTxComplete,
6049 pFrame, txFlag );
6050 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6051 psessionEntry->peSessionId,
6052 halstatus));
6053 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006054 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006055 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006056 statusCode = eSIR_FAILURE;
6057 //Pkt will be freed up by the callback
6058 return statusCode;
6059 }
6060 else
6061 return eSIR_SUCCESS;
6062
6063returnAfterError:
6064 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6065
6066 return statusCode;
6067} // End limSendNeighborReportRequestFrame.
6068
6069/**
6070 * \brief Send a Link Report Action frame
6071 *
6072 *
6073 * \param pMac Pointer to the global MAC structure
6074 *
6075 * \param pLinkReport Address of a tSirMacLinkReport
6076 *
6077 * \param peer mac address of peer station.
6078 *
6079 * \param psessionEntry address of session entry.
6080 *
6081 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6082 *
6083 *
6084 */
6085
6086tSirRetStatus
6087limSendLinkReportActionFrame(tpAniSirGlobal pMac,
6088 tpSirMacLinkReport pLinkReport,
6089 tSirMacAddr peer,
6090 tpPESession psessionEntry
6091 )
6092{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306093 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006094 tDot11fLinkMeasurementReport frm;
6095 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306096 tpSirMacMgmtHdr pMacHdr;
6097 tANI_U32 nBytes, nPayload, nStatus;
6098 void *pPacket;
6099 eHalStatus halstatus;
6100 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006101
6102
6103 if ( psessionEntry == NULL )
6104 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006105 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006106 return eSIR_FAILURE;
6107 }
6108
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306109 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006110
6111 frm.Category.category = SIR_MAC_ACTION_RRM;
6112 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
6113 frm.DialogToken.token = pLinkReport->dialogToken;
6114
6115
6116 //IEEE Std. 802.11 7.3.2.18. for the report element.
6117 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
6118 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
6119 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
6120 //such case this way than changing the frame parser.
6121 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
6122 frm.TPCEleLen.TPCLen = 2;
6123 frm.TxPower.txPower = pLinkReport->txPower;
6124 frm.LinkMargin.linkMargin = 0;
6125
6126 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
6127 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
6128 frm.RCPI.rcpi = pLinkReport->rcpi;
6129 frm.RSNI.rsni = pLinkReport->rsni;
6130
6131 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
6132 if ( DOT11F_FAILED( nStatus ) )
6133 {
6134 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006135 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006136 nStatus );
6137 // We'll fall back on the worst case scenario:
6138 nPayload = sizeof( tDot11fLinkMeasurementReport );
6139 }
6140 else if ( DOT11F_WARNED( nStatus ) )
6141 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006142 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006143 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006144 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006145 }
6146
6147 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6148
6149 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6150 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6151 {
6152 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006153 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006154 return eSIR_FAILURE;
6155 }
6156
6157 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306158 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006159
6160 // Copy necessary info to BD
6161 if( eSIR_SUCCESS !=
6162 (statusCode = limPopulateMacHeader( pMac,
6163 pFrame,
6164 SIR_MAC_MGMT_FRAME,
6165 SIR_MAC_MGMT_ACTION,
6166 peer, psessionEntry->selfMacAddr)))
6167 goto returnAfterError;
6168
6169 // Update A3 with the BSSID
6170 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6171
6172 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6173
Chet Lanctot186b5732013-03-18 10:26:30 -07006174#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006175 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006176#endif
6177
Jeff Johnson295189b2012-06-20 16:38:30 -07006178 // Now, we're ready to "pack" the frames
6179 nStatus = dot11fPackLinkMeasurementReport( pMac,
6180 &frm,
6181 pFrame + sizeof( tSirMacMgmtHdr ),
6182 nPayload,
6183 &nPayload );
6184
6185 if( DOT11F_FAILED( nStatus ))
6186 {
6187 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006188 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006189 nStatus );
6190
6191 // FIXME - Need to convert to tSirRetStatus
6192 statusCode = eSIR_FAILURE;
6193 goto returnAfterError;
6194 }
6195 else if( DOT11F_WARNED( nStatus ))
6196 {
6197 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006198 FL( "There were warnings while packing Link Report (0x%08x)." ),
6199 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006200 }
6201
6202 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006203 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006204 limPrintMacAddr( pMac, peer, LOGW );
6205
6206 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006207 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6208 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006209 )
6210 {
6211 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6212 }
6213
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306214 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6215 psessionEntry->peSessionId,
6216 pMacHdr->fc.subType));
6217 halstatus = halTxFrame( pMac,
6218 pPacket,
6219 (tANI_U16) nBytes,
6220 HAL_TXRX_FRM_802_11_MGMT,
6221 ANI_TXDIR_TODS,
6222 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6223 limTxComplete,
6224 pFrame, txFlag );
6225 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6226 psessionEntry->peSessionId,
6227 halstatus));
6228 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006229 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006230 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006231 statusCode = eSIR_FAILURE;
6232 //Pkt will be freed up by the callback
6233 return statusCode;
6234 }
6235 else
6236 return eSIR_SUCCESS;
6237
6238returnAfterError:
6239 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6240
6241 return statusCode;
6242} // End limSendLinkReportActionFrame.
6243
6244/**
6245 * \brief Send a Beacon Report Action frame
6246 *
6247 *
6248 * \param pMac Pointer to the global MAC structure
6249 *
6250 * \param dialog_token dialog token to be used in the action frame.
6251 *
6252 * \param num_report number of reports in pRRMReport.
6253 *
6254 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
6255 *
6256 * \param peer mac address of peer station.
6257 *
6258 * \param psessionEntry address of session entry.
6259 *
6260 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6261 *
6262 *
6263 */
6264
6265tSirRetStatus
6266limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
6267 tANI_U8 dialog_token,
6268 tANI_U8 num_report,
6269 tpSirMacRadioMeasureReport pRRMReport,
6270 tSirMacAddr peer,
6271 tpPESession psessionEntry
6272 )
6273{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306274 tSirRetStatus statusCode = eSIR_SUCCESS;
6275 tANI_U8 *pFrame;
6276 tpSirMacMgmtHdr pMacHdr;
6277 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006278 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306279 eHalStatus halstatus;
6280 tANI_U8 i;
6281 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006282
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006283 tDot11fRadioMeasurementReport *frm =
6284 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
6285 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006286 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006287 return eSIR_FAILURE;
6288 }
6289
Jeff Johnson295189b2012-06-20 16:38:30 -07006290 if ( psessionEntry == NULL )
6291 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006292 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006293 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006294 return eSIR_FAILURE;
6295 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306296 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006297
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006298 frm->Category.category = SIR_MAC_ACTION_RRM;
6299 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
6300 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07006301
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006302 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 -07006303
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006304 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006305 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006306 frm->MeasurementReport[i].type = pRRMReport[i].type;
6307 frm->MeasurementReport[i].token = pRRMReport[i].token;
6308 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006309 switch( pRRMReport[i].type )
6310 {
6311 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006312 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
6313 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6314 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
6315 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006316 break;
6317 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05306318 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6319 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006320 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006321 break;
6322 }
6323 }
6324
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006325 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07006326 if ( DOT11F_FAILED( nStatus ) )
6327 {
6328 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006329 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006330 nStatus );
6331 // We'll fall back on the worst case scenario:
6332 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006333 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006334 return eSIR_FAILURE;
6335 }
6336 else if ( DOT11F_WARNED( nStatus ) )
6337 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006338 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006339 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006340 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006341 }
6342
6343 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6344
6345 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6346 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6347 {
6348 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006349 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006350 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006351 return eSIR_FAILURE;
6352 }
6353
6354 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306355 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006356
6357 // Copy necessary info to BD
6358 if( eSIR_SUCCESS !=
6359 (statusCode = limPopulateMacHeader( pMac,
6360 pFrame,
6361 SIR_MAC_MGMT_FRAME,
6362 SIR_MAC_MGMT_ACTION,
6363 peer, psessionEntry->selfMacAddr)))
6364 goto returnAfterError;
6365
6366 // Update A3 with the BSSID
6367 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6368
6369 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6370
Chet Lanctot186b5732013-03-18 10:26:30 -07006371#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006372 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006373#endif
6374
Jeff Johnson295189b2012-06-20 16:38:30 -07006375 // Now, we're ready to "pack" the frames
6376 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006377 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07006378 pFrame + sizeof( tSirMacMgmtHdr ),
6379 nPayload,
6380 &nPayload );
6381
6382 if( DOT11F_FAILED( nStatus ))
6383 {
6384 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006385 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006386 nStatus );
6387
6388 // FIXME - Need to convert to tSirRetStatus
6389 statusCode = eSIR_FAILURE;
6390 goto returnAfterError;
6391 }
6392 else if( DOT11F_WARNED( nStatus ))
6393 {
6394 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006395 FL( "There were warnings while packing Radio "
6396 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006397 }
6398
6399 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006400 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006401 limPrintMacAddr( pMac, peer, LOGW );
6402
6403 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006404 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6405 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006406 )
6407 {
6408 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6409 }
6410
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306411 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6412 psessionEntry->peSessionId,
6413 pMacHdr->fc.subType));
6414 halstatus = halTxFrame( pMac,
6415 pPacket,
6416 (tANI_U16) nBytes,
6417 HAL_TXRX_FRM_802_11_MGMT,
6418 ANI_TXDIR_TODS,
6419 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6420 limTxComplete,
6421 pFrame, txFlag );
6422 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6423 psessionEntry->peSessionId,
6424 halstatus));
6425 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006426 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006427 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006428 statusCode = eSIR_FAILURE;
6429 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006430 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006431 return statusCode;
6432 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006433 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006434 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006435 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006436 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006437
6438returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006439 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006440 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07006441 return statusCode;
6442} // End limSendBeaconReportActionFrame.
6443
6444#endif
6445
6446#ifdef WLAN_FEATURE_11W
6447/**
Chet Lanctot8cecea22014-02-11 19:09:36 -08006448 * \brief Send SA query request action frame to peer
6449 *
6450 * \sa limSendSaQueryRequestFrame
6451 *
6452 *
6453 * \param pMac The global tpAniSirGlobal object
6454 *
6455 * \param transId Transaction identifier
6456 *
6457 * \param peer The Mac address of the station to which this action frame is addressed
6458 *
6459 * \param psessionEntry The PE session entry
6460 *
6461 * \return eSIR_SUCCESS if setup completes successfully
6462 * eSIR_FAILURE is some problem is encountered
6463 */
6464
6465tSirRetStatus limSendSaQueryRequestFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
6466 tSirMacAddr peer, tpPESession psessionEntry )
6467{
6468
6469 tDot11fSaQueryReq frm; // SA query request action frame
6470 tANI_U8 *pFrame;
6471 tSirRetStatus nSirStatus;
6472 tpSirMacMgmtHdr pMacHdr;
6473 tANI_U32 nBytes, nPayload, nStatus;
6474 void *pPacket;
6475 eHalStatus halstatus;
6476 tANI_U8 txFlag = 0;
6477
6478 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
6479 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6480 /* 11w action field is :
6481 action: 0 --> SA Query Request action frame
6482 action: 1 --> SA Query Response action frame */
6483 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
6484 /* 11w SA Query Request transId */
6485 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
6486
6487 nStatus = dot11fGetPackedSaQueryReqSize(pMac, &frm, &nPayload);
6488 if ( DOT11F_FAILED( nStatus ) )
6489 {
6490 limLog( pMac, LOGP, FL("Failed to calculate the packed size "
6491 "for an SA Query Request (0x%08x)."),
6492 nStatus );
6493 // We'll fall back on the worst case scenario:
6494 nPayload = sizeof( tDot11fSaQueryReq );
6495 }
6496 else if ( DOT11F_WARNED( nStatus ) )
6497 {
6498 limLog( pMac, LOGW, FL("There were warnings while calculating "
6499 "the packed size for an SA Query Request"
6500 " (0x%08x)."), nStatus );
6501 }
6502
6503 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6504 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6505 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6506 {
6507 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA Query Request "
6508 "action frame"), nBytes );
6509 return eSIR_FAILURE;
6510 }
6511
6512 // Paranoia:
6513 vos_mem_set( pFrame, nBytes, 0 );
6514
6515 // Copy necessary info to BD
6516 nSirStatus = limPopulateMacHeader( pMac,
6517 pFrame,
6518 SIR_MAC_MGMT_FRAME,
6519 SIR_MAC_MGMT_ACTION,
6520 peer, psessionEntry->selfMacAddr );
6521 if ( eSIR_SUCCESS != nSirStatus )
6522 goto returnAfterError;
6523
6524 // Update A3 with the BSSID
6525 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6526
6527 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6528
6529 // Since this is a SA Query Request, set the "protect" (aka WEP) bit
6530 // in the FC
6531 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
6532
6533 // Pack 11w SA Query Request frame
6534 nStatus = dot11fPackSaQueryReq( pMac,
6535 &frm,
6536 pFrame + sizeof( tSirMacMgmtHdr ),
6537 nPayload,
6538 &nPayload );
6539
6540 if ( DOT11F_FAILED( nStatus ))
6541 {
6542 limLog( pMac, LOGE,
6543 FL( "Failed to pack an SA Query Request (0x%08x)." ),
6544 nStatus );
6545 // FIXME - Need to convert to tSirRetStatus
6546 nSirStatus = eSIR_FAILURE;
6547 goto returnAfterError;
6548 }
6549 else if ( DOT11F_WARNED( nStatus ))
6550 {
6551 limLog( pMac, LOGW,
6552 FL( "There were warnings while packing SA Query Request (0x%08x)." ),
6553 nStatus);
6554 }
6555
6556 limLog( pMac, LOG1,
6557 FL( "Sending an SA Query Request to " ));
6558 limPrintMacAddr( pMac, peer, LOG1 );
6559 limPrintMacAddr( pMac, peer, LOGE );
6560 limLog( pMac, LOGE,
6561 FL( "Sending an SA Query Request from " ));
6562 limPrintMacAddr( pMac, psessionEntry->selfMacAddr, LOGE );
6563
6564 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
6565#ifdef WLAN_FEATURE_P2P
6566 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6567 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
6568#endif
6569 )
6570 {
6571 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6572 }
6573
6574 halstatus = halTxFrame( pMac,
6575 pPacket,
6576 (tANI_U16) nBytes,
6577 HAL_TXRX_FRM_802_11_MGMT,
6578 ANI_TXDIR_TODS,
6579 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6580 limTxComplete,
6581 pFrame, txFlag );
6582 if ( eHAL_STATUS_SUCCESS != halstatus )
6583 {
6584 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6585 nSirStatus = eSIR_FAILURE;
6586 //Pkt will be freed up by the callback
6587 return nSirStatus;
6588 }
6589 else {
6590 return eSIR_SUCCESS;
6591 }
6592
6593returnAfterError:
6594 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6595 return nSirStatus;
6596} // End limSendSaQueryRequestFrame
6597
6598/**
Jeff Johnson295189b2012-06-20 16:38:30 -07006599 * \brief Send SA query response action frame to peer
6600 *
6601 * \sa limSendSaQueryResponseFrame
6602 *
6603 *
6604 * \param pMac The global tpAniSirGlobal object
6605 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006606 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006607 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006608 * \param peer The Mac address of the AP to which this action frame is addressed
6609 *
6610 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 *
6612 * \return eSIR_SUCCESS if setup completes successfully
6613 * eSIR_FAILURE is some problem is encountered
6614 */
6615
Chet Lanctot186b5732013-03-18 10:26:30 -07006616tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006617tSirMacAddr peer,tpPESession psessionEntry)
6618{
6619
Chet Lanctot186b5732013-03-18 10:26:30 -07006620 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006621 tANI_U8 *pFrame;
6622 tSirRetStatus nSirStatus;
6623 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07006624 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006625 void *pPacket;
6626 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306627 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006628
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306629 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07006630 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6631 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07006632 action: 0 --> SA query request action frame
6633 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07006634 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
6635 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07006636 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07006637 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006638
Chet Lanctot186b5732013-03-18 10:26:30 -07006639 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6640 if ( DOT11F_FAILED( nStatus ) )
6641 {
6642 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6643 "or a SA Query Response (0x%08x)."),
6644 nStatus );
6645 // We'll fall back on the worst case scenario:
6646 nPayload = sizeof( tDot11fSaQueryRsp );
6647 }
6648 else if ( DOT11F_WARNED( nStatus ) )
6649 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006650 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006651 "the packed size for an SA Query Response"
6652 " (0x%08x)."), nStatus );
6653 }
6654
Jeff Johnson295189b2012-06-20 16:38:30 -07006655 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6656 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6657 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6658 {
6659 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006660 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006661 return eSIR_FAILURE;
6662 }
6663
6664 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306665 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006666
Chet Lanctot186b5732013-03-18 10:26:30 -07006667 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006668 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006669 pFrame,
6670 SIR_MAC_MGMT_FRAME,
6671 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006672 peer, psessionEntry->selfMacAddr );
6673 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006674 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006675
Chet Lanctot186b5732013-03-18 10:26:30 -07006676 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006677 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6678
Chet Lanctot186b5732013-03-18 10:26:30 -07006679 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006680
Chet Lanctot186b5732013-03-18 10:26:30 -07006681 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6682 // in the FC
Chet Lanctot8cecea22014-02-11 19:09:36 -08006683 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -07006684
Chet Lanctot186b5732013-03-18 10:26:30 -07006685 // Pack 11w SA query response frame
6686 nStatus = dot11fPackSaQueryRsp( pMac,
6687 &frm,
6688 pFrame + sizeof( tSirMacMgmtHdr ),
6689 nPayload,
6690 &nPayload );
6691
6692 if ( DOT11F_FAILED( nStatus ))
6693 {
6694 limLog( pMac, LOGE,
6695 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6696 nStatus );
6697 // FIXME - Need to convert to tSirRetStatus
6698 nSirStatus = eSIR_FAILURE;
6699 goto returnAfterError;
6700 }
6701 else if ( DOT11F_WARNED( nStatus ))
6702 {
6703 limLog( pMac, LOGW,
6704 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6705 nStatus);
6706 }
6707
6708 limLog( pMac, LOG1,
6709 FL( "Sending a SA Query Response to " ));
6710 limPrintMacAddr( pMac, peer, LOGW );
6711
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006712 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006713#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006714 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6715 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006716#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006717 )
6718 {
6719 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6720 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006721
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306722 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6723 psessionEntry->peSessionId,
6724 pMacHdr->fc.subType));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006725 halstatus = halTxFrame( pMac,
6726 pPacket,
6727 (tANI_U16) nBytes,
6728 HAL_TXRX_FRM_802_11_MGMT,
6729 ANI_TXDIR_TODS,
6730 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6731 limTxComplete,
6732 pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306733 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6734 psessionEntry->peSessionId,
6735 halstatus));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006736 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006737 {
6738 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6739 nSirStatus = eSIR_FAILURE;
6740 //Pkt will be freed up by the callback
6741 return nSirStatus;
6742 }
6743 else {
6744 return eSIR_SUCCESS;
6745 }
6746
6747returnAfterError:
6748 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6749 return nSirStatus;
6750} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006751#endif