blob: 342bb8fae877533af9008e6a09d383006e66fcd9 [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 }
Leela Venkata Kiran Kumar Reddy Chirala2f9b5712014-05-06 00:09:42 -07002262 /* TODO:remove this code once driver provides the call back function
2263 * to supplicant for set_qos_map
2264 */
2265 else
2266 {
2267 if(extractedExtCap.interworkingService)
2268 {
2269 extractedExtCap.qosMap = 1;
2270 }
2271 }
Kalikinkar dhara205da782014-03-21 15:49:32 -07002272
Jeff Johnson295189b2012-06-20 16:38:30 -07002273 caps = pMlmAssocReq->capabilityInfo;
2274 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2275 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2276#if defined(FEATURE_WLAN_WAPI)
2277 /* CR: 262463 :
2278 According to WAPI standard:
2279 7.3.1.4 Capability Information field
2280 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2281 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2282 Reassociation management frames. */
2283 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2284 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2285#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002286 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002287
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002288 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2289 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002290 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002291 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002292
2293 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2294 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2295
2296 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2297 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2298
2299 // We prefer .11e asociations:
2300 if ( fQosEnabled ) fWmeEnabled = false;
2301
2302 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2303 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2304
2305 if ( psessionEntry->lim11hEnable &&
2306 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2307 {
2308#if defined WLAN_FEATURE_VOWIFI
2309 PowerCapsPopulated = TRUE;
2310
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002311 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002312#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002313 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002314
2315 }
2316
2317#if defined WLAN_FEATURE_VOWIFI
2318 if( pMac->rrm.rrmPEContext.rrmEnable &&
2319 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2320 {
2321 if (PowerCapsPopulated == FALSE)
2322 {
2323 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002324 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002325 }
2326 }
2327#endif
2328
2329 if ( fQosEnabled &&
2330 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002331 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002332
2333 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002334 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002335
2336#if defined WLAN_FEATURE_VOWIFI
2337 if( pMac->rrm.rrmPEContext.rrmEnable &&
2338 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2339 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002340 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002341 }
2342#endif
2343 // The join request *should* contain zero or one of the WPA and RSN
2344 // IEs. The payload send along with the request is a
2345 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2346
2347 // typedef struct sSirRSNie
2348 // {
2349 // tANI_U16 length;
2350 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2351 // } tSirRSNie, *tpSirRSNie;
2352
2353 // So, we should be able to make the following two calls harmlessly,
2354 // since they do nothing if they don't find the given IE in the
2355 // bytestream with which they're provided.
2356
2357 // The net effect of this will be to faithfully transmit whatever
2358 // security IE is in the join request.
2359
2360 // *However*, if we're associating for the purpose of WPS
2361 // enrollment, and we've been configured to indicate that by
2362 // eliding the WPA or RSN IE, we just skip this:
2363 if( nAddIELen && pAddIE )
2364 {
2365 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2366 }
2367 if ( NULL == wpsIe )
2368 {
2369 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002370 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002371 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002372 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002373#if defined(FEATURE_WLAN_WAPI)
2374 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002375 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002376#endif // defined(FEATURE_WLAN_WAPI)
2377 }
2378
2379 // include WME EDCA IE as well
2380 if ( fWmeEnabled )
2381 {
2382 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2383 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002384 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002385 }
2386
2387 if ( fWsmEnabled &&
2388 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2389 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002390 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002391 }
2392 }
2393
2394 //Populate HT IEs, when operating in 11n or Taurus modes AND
2395 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002396 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002397 pMac->lim.htCapabilityPresentInBeacon)
2398 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002399 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002400#ifdef DISABLE_GF_FOR_INTEROP
2401
2402 /*
2403 * To resolve the interop problem with Broadcom AP,
2404 * where TQ STA could not pass traffic with GF enabled,
2405 * TQ STA will do Greenfield only with TQ AP, for
2406 * everybody else it will be turned off.
2407 */
2408
2409 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2410 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302411 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP,"
2412 " Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002413 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002414 }
2415#endif
2416
2417 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002418#ifdef WLAN_FEATURE_11AC
2419 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002420 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002421 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002422 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002423 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
Jeff Johnsone7245742012-09-05 17:12:55 -07002424 }
2425#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302426 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002427
2428#if defined WLAN_FEATURE_VOWIFI_11R
2429 if (psessionEntry->pLimJoinReq->is11Rconnection)
2430 {
2431#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002432 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002433 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2434 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2435 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2436#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302437 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2438 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002439 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302440 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002441 {
2442 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302443 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002444 }
2445#endif
2446
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002447#ifdef FEATURE_WLAN_ESE
2448 /* For ESE Associations fill the ESE IEs */
2449 if (psessionEntry->isESEconnection &&
2450 psessionEntry->pLimJoinReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002451 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002452#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002453 PopulateDot11fESERadMgmtCap(&pFrm->ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002454#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002455 PopulateDot11fESEVersion(&pFrm->ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002456 }
2457#endif
2458
c_hpothubcd78652014-04-28 22:31:08 +05302459 /* merge the ExtCap struct*/
2460 if (extractedExtCapFlag && extractedExtCap.present)
2461 {
2462 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
2463 }
2464
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002465 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002466 if ( DOT11F_FAILED( nStatus ) )
2467 {
2468 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002469 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002470 nStatus );
2471 // We'll fall back on the worst case scenario:
2472 nPayload = sizeof( tDot11fAssocRequest );
2473 }
2474 else if ( DOT11F_WARNED( nStatus ) )
2475 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002476 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002477 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002478 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002479 }
2480
2481 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2482
2483 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2484 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2485 ( void** ) &pPacket );
2486 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2487 {
2488 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002489 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002490
2491 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002492 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002493
2494
2495 /* Update PE session id*/
2496 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2497
2498 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2499
2500 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2501 ( void* ) pFrame, ( void* ) pPacket );
2502
2503 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2504 ( tANI_U32* ) &mlmAssocCnf);
2505
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302506 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002507 return;
2508 }
2509
2510 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302511 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002512
2513 // Next, we fill out the buffer descriptor:
2514 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2515 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2516 if ( eSIR_SUCCESS != nSirStatus )
2517 {
2518 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002519 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002520 nSirStatus );
2521 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302522 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002523 return;
2524 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002525
Abhishek Singh57aebef2014-02-03 18:47:44 +05302526 // That done, pack the Assoc Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002527 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002528 sizeof(tSirMacMgmtHdr),
2529 nPayload, &nPayload );
2530 if ( DOT11F_FAILED( nStatus ) )
2531 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302532 limLog( pMac, LOGE, FL("Failed to pack a Assoc Request (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002533 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002534 nStatus );
2535 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2536 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302537 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002538 return;
2539 }
2540 else if ( DOT11F_WARNED( nStatus ) )
2541 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302542 limLog( pMac, LOGW, FL("There were warnings while packing a Assoc"
2543 "Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 }
2545
2546 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002547 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002548 nBytes );)
2549 // limPrintMacAddr( pMac, bssid, LOG1 );
2550
2551 if( psessionEntry->assocReq != NULL )
2552 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302553 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002554 psessionEntry->assocReq = NULL;
2555 }
2556
2557 if( nAddIELen )
2558 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302559 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2560 pAddIE,
2561 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002562 nPayload += nAddIELen;
2563 }
2564
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302565 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2566 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002567 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302568 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store "
2569 "assoc request"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002570 }
2571 else
2572 {
2573 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302574 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 psessionEntry->assocReqLen = nPayload;
2576 }
2577
2578 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002579 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2580 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002581 )
2582 {
2583 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2584 }
2585
Ganesh K08bce952012-12-13 15:04:41 -08002586 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2587 {
2588 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2589 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302590
2591 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05302592 limLog( pMac, LOG1, FL("Sending Assoc req over WQ5 to "MAC_ADDRESS_STR
2593 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
2594 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2595 txFlag |= HAL_USE_FW_IN_TX_PATH;
2596
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302597 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2598 psessionEntry->peSessionId,
2599 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002600 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2601 HAL_TXRX_FRM_802_11_MGMT,
2602 ANI_TXDIR_TODS,
2603 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2604 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302605 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2606 psessionEntry->peSessionId,
2607 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002608 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2609 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002610 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002611 halstatus );
2612 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302613 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 return;
2615 }
2616
2617 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302618 vos_mem_free(pMlmAssocReq);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002619 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302620 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002621 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002622} // End limSendAssocReqMgmtFrame
2623
2624
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002625#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002626/*------------------------------------------------------------------------------------
2627 *
2628 * Send Reassoc Req with FTIEs.
2629 *
2630 *-----------------------------------------------------------------------------------
2631 */
2632void
2633limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2634 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2635{
2636 static tDot11fReAssocRequest frm;
2637 tANI_U16 caps;
2638 tANI_U8 *pFrame;
2639 tSirRetStatus nSirStatus;
2640 tANI_U32 nBytes, nPayload, nStatus;
2641 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2642 void *pPacket;
2643 eHalStatus halstatus;
2644#if defined WLAN_FEATURE_VOWIFI
2645 tANI_U8 PowerCapsPopulated = FALSE;
2646#endif
2647 tANI_U16 ft_ies_length = 0;
2648 tANI_U8 *pBody;
2649 tANI_U16 nAddIELen;
2650 tANI_U8 *pAddIE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002651#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002652 tANI_U8 *wpsIe = NULL;
2653#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302654 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302655 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002656
2657 if (NULL == psessionEntry)
2658 {
2659 return;
2660 }
2661
Jeff Johnson295189b2012-06-20 16:38:30 -07002662 /* check this early to avoid unncessary operation */
2663 if(NULL == psessionEntry->pLimReAssocReq)
2664 {
2665 return;
2666 }
2667 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2668 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002669 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2670 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002671
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302672 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002673
2674 caps = pMlmReassocReq->capabilityInfo;
2675 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2676 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2677#if defined(FEATURE_WLAN_WAPI)
2678 /* CR: 262463 :
2679 According to WAPI standard:
2680 7.3.1.4 Capability Information field
2681 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2682 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2683 Reassociation management frames. */
2684 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2685 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2686#endif
2687 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2688
2689 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2690
2691 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302692 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002693 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2694
2695 PopulateDot11fSSID2( pMac, &frm.SSID );
2696 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2697 &frm.SuppRates,psessionEntry);
2698
2699 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2700 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2701
2702 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2703 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2704
2705 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2706 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2707
2708 if ( psessionEntry->lim11hEnable &&
2709 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2710 {
2711#if defined WLAN_FEATURE_VOWIFI
2712 PowerCapsPopulated = TRUE;
2713
2714 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2715 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2716#endif
2717 }
2718
2719#if defined WLAN_FEATURE_VOWIFI
2720 if( pMac->rrm.rrmPEContext.rrmEnable &&
2721 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2722 {
2723 if (PowerCapsPopulated == FALSE)
2724 {
2725 PowerCapsPopulated = TRUE;
2726 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2727 }
2728 }
2729#endif
2730
2731 if ( fQosEnabled &&
2732 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2733 {
2734 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2735 }
2736
2737 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2738 &frm.ExtSuppRates, psessionEntry );
2739
2740#if defined WLAN_FEATURE_VOWIFI
2741 if( pMac->rrm.rrmPEContext.rrmEnable &&
2742 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2743 {
2744 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2745 }
2746#endif
2747
2748 // Ideally this should be enabled for 11r also. But 11r does
2749 // not follow the usual norm of using the Opaque object
2750 // for rsnie and fties. Instead we just add
2751 // the rsnie and fties at the end of the pack routine for 11r.
2752 // This should ideally! be fixed.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002753#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002754 //
2755 // The join request *should* contain zero or one of the WPA and RSN
2756 // IEs. The payload send along with the request is a
2757 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2758
2759 // typedef struct sSirRSNie
2760 // {
2761 // tANI_U16 length;
2762 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2763 // } tSirRSNie, *tpSirRSNie;
2764
2765 // So, we should be able to make the following two calls harmlessly,
2766 // since they do nothing if they don't find the given IE in the
2767 // bytestream with which they're provided.
2768
2769 // The net effect of this will be to faithfully transmit whatever
2770 // security IE is in the join request.
2771
2772 // *However*, if we're associating for the purpose of WPS
2773 // enrollment, and we've been configured to indicate that by
2774 // eliding the WPA or RSN IE, we just skip this:
2775 if (!psessionEntry->is11Rconnection)
2776 {
2777 if( nAddIELen && pAddIE )
2778 {
2779 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2780 }
2781 if ( NULL == wpsIe )
2782 {
2783 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2784 &frm.RSNOpaque );
2785 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2786 &frm.WPAOpaque );
2787 }
2788
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002789#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302790 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002791 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002792 PopulateDot11fESECckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2793 &frm.ESECckmOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002794 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002795#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002796 }
2797
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002798#ifdef FEATURE_WLAN_ESE
2799 // For ESE Associations fill the ESE IEs
2800 if (psessionEntry->isESEconnection &&
2801 psessionEntry->pLimReAssocReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002802 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002803#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002804 PopulateDot11fESERadMgmtCap(&frm.ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002805#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002806 PopulateDot11fESEVersion(&frm.ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002807 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002808#endif //FEATURE_WLAN_ESE
2809#endif //FEATURE_WLAN_ESE || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002810
2811 // include WME EDCA IE as well
2812 if ( fWmeEnabled )
2813 {
2814 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2815 {
2816 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2817 }
2818
2819 if ( fWsmEnabled &&
2820 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2821 {
2822 PopulateDot11fWMMCaps( &frm.WMMCaps );
2823 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002824#ifdef FEATURE_WLAN_ESE
2825 if (psessionEntry->isESEconnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07002826 {
2827 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2828
2829 // Populate the TSRS IE if TSPEC is included in the reassoc request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002830 if (psessionEntry->pLimReAssocReq->eseTspecInfo.numTspecs)
Jeff Johnson295189b2012-06-20 16:38:30 -07002831 {
2832 tANI_U32 phyMode;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002833 tSirMacESETSRSIE tsrsIE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002834 limGetPhyMode(pMac, &phyMode, psessionEntry);
2835
2836 tsrsIE.tsid = 0;
2837 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2838 {
2839 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2840 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302841 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002842 {
2843 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2844 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002845 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.ESETrafStrmRateSet, sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07002846 }
2847 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302848#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002849 }
2850
Jeff Johnsone7245742012-09-05 17:12:55 -07002851 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002852 pMac->lim.htCapabilityPresentInBeacon)
2853 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002854 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002855 }
2856
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002857#if defined WLAN_FEATURE_VOWIFI_11R
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +05302858 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent &&
2859 (pMac->ft.ftSmeContext.addMDIE == TRUE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002860#if defined FEATURE_WLAN_ESE
2861 && !psessionEntry->isESEconnection
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302862#endif
2863 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002864 {
2865 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2866 }
2867#endif
2868
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002869#ifdef WLAN_FEATURE_11AC
2870 if ( psessionEntry->vhtCapability &&
2871 psessionEntry->vhtCapabilityPresentInBeacon)
2872 {
2873 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
2874 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002875 }
2876#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302877 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002878
Jeff Johnson295189b2012-06-20 16:38:30 -07002879 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2880 if ( DOT11F_FAILED( nStatus ) )
2881 {
2882 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002883 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002884 nStatus );
2885 // We'll fall back on the worst case scenario:
2886 nPayload = sizeof( tDot11fReAssocRequest );
2887 }
2888 else if ( DOT11F_WARNED( nStatus ) )
2889 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002890 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002891 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002892 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002893 }
2894
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002895 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002896
2897#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002898 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002899 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2900#endif
2901
2902#if defined WLAN_FEATURE_VOWIFI_11R
2903 if (psessionEntry->is11Rconnection)
2904 {
2905 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2906 }
2907#endif
2908
2909 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2910 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2911 ( void** ) &pPacket );
2912 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2913 {
2914 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002915 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002916 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002917 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002918 goto end;
2919 }
2920
2921 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302922 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002923
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002924#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002925 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002926#endif
2927 // Next, we fill out the buffer descriptor:
2928 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2929 SIR_MAC_MGMT_REASSOC_REQ,
2930 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2931 if ( eSIR_SUCCESS != nSirStatus )
2932 {
2933 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002934 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002935 nSirStatus );
2936 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2937 goto end;
2938 }
2939
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302940 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07002941 // That done, pack the ReAssoc Request:
2942 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2943 sizeof(tSirMacMgmtHdr),
2944 nPayload, &nPayload );
2945 if ( DOT11F_FAILED( nStatus ) )
2946 {
2947 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002948 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002949 nStatus );
2950 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2951 goto end;
2952 }
2953 else if ( DOT11F_WARNED( nStatus ) )
2954 {
2955 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002956 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002957 }
2958
2959 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002960 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002961 nBytes, nPayload );)
2962 if( psessionEntry->assocReq != NULL )
2963 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302964 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002965 psessionEntry->assocReq = NULL;
2966 }
2967
2968 if( nAddIELen )
2969 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302970 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2971 pAddIE,
2972 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002973 nPayload += nAddIELen;
2974 }
2975
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302976 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2977 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002978 {
2979 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002980 }
2981 else
2982 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002983 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302984 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002985 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002986 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002987
2988 if (psessionEntry->is11Rconnection)
2989 {
2990 {
2991 int i = 0;
2992
2993 pBody = pFrame + nBytes;
2994 for (i=0; i<ft_ies_length; i++)
2995 {
2996 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2997 pBody++;
2998 }
2999 }
3000 }
3001
3002#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003003 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
3004 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003005 (tANI_U8 *)pFrame,
3006 (nBytes + ft_ies_length));)
3007#endif
3008
3009
3010 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003011 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3012 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003013 )
3014 {
3015 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3016 }
3017
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003018 if( NULL != psessionEntry->assocReq )
3019 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303020 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003021 psessionEntry->assocReq = NULL;
3022 }
3023
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303024 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
3025 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003026 {
3027 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003028 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003029 }
3030 else
3031 {
3032 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303033 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
3034 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003035 psessionEntry->assocReqLen = (ft_ies_length);
3036 }
3037
3038
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303039 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3040 psessionEntry->peSessionId,
3041 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003042 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
3043 HAL_TXRX_FRM_802_11_MGMT,
3044 ANI_TXDIR_TODS,
3045 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3046 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303047 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3048 psessionEntry->peSessionId,
3049 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003050 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3051 {
3052 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003053 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003054 nSirStatus );
3055 //Pkt will be freed up by the callback
3056 goto end;
3057 }
3058
3059end:
3060 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303061 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003062 psessionEntry->pLimMlmReassocReq = NULL;
3063
3064}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003065
3066void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
3067 tLimMlmReassocReq *pMlmReassocReq,
3068 tpPESession psessionEntry)
3069{
3070 tLimMlmReassocCnf mlmReassocCnf; // keep sme
3071 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
3072 if(NULL == pTmpMlmReassocReq)
3073 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303074 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
3075 if ( NULL == pTmpMlmReassocReq ) goto end;
3076 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
3077 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003078 }
3079
3080 // Prepare and send Reassociation request frame
3081 // start reassoc timer.
3082 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
3083 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08003084 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003085 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
3086 != TX_SUCCESS)
3087 {
3088 // Could not start reassoc failure timer.
3089 // Log error
3090 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003091 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003092 // Return Reassoc confirm with
3093 // Resources Unavailable
3094 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3095 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3096 goto end;
3097 }
3098
3099 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
3100 return;
3101
3102end:
3103 // Free up buffer allocated for reassocReq
3104 if (pMlmReassocReq != NULL)
3105 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303106 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003107 pMlmReassocReq = NULL;
3108 }
3109 if (pTmpMlmReassocReq != NULL)
3110 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303111 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003112 pTmpMlmReassocReq = NULL;
3113 }
3114 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
3115 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3116 /* Update PE sessio Id*/
3117 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
3118
3119 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3120}
3121
Jeff Johnson295189b2012-06-20 16:38:30 -07003122#endif /* WLAN_FEATURE_VOWIFI_11R */
3123
3124
3125void
3126limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
3127 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
3128{
3129 static tDot11fReAssocRequest frm;
3130 tANI_U16 caps;
3131 tANI_U8 *pFrame;
3132 tSirRetStatus nSirStatus;
3133 tANI_U32 nBytes, nPayload, nStatus;
3134 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
3135 void *pPacket;
3136 eHalStatus halstatus;
3137 tANI_U16 nAddIELen;
3138 tANI_U8 *pAddIE;
3139 tANI_U8 *wpsIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303140 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003141#if defined WLAN_FEATURE_VOWIFI
3142 tANI_U8 PowerCapsPopulated = FALSE;
3143#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303144 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003145
3146 if(NULL == psessionEntry)
3147 {
3148 return;
3149 }
3150
3151 /* check this early to avoid unncessary operation */
3152 if(NULL == psessionEntry->pLimReAssocReq)
3153 {
3154 return;
3155 }
3156 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
3157 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
3158
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303159 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003160
3161 caps = pMlmReassocReq->capabilityInfo;
3162 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
3163 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
3164#if defined(FEATURE_WLAN_WAPI)
3165 /* CR: 262463 :
3166 According to WAPI standard:
3167 7.3.1.4 Capability Information field
3168 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
3169 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
3170 Reassociation management frames. */
3171 if ( psessionEntry->encryptType == eSIR_ED_WPI)
3172 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
3173#endif
3174 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
3175
3176 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
3177
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303178 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
3179 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003180
3181 PopulateDot11fSSID2( pMac, &frm.SSID );
3182 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3183 &frm.SuppRates,psessionEntry);
3184
3185 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
3186 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
3187
3188 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
3189 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
3190
3191 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
3192 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
3193
3194
3195 if ( psessionEntry->lim11hEnable &&
3196 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
3197 {
3198#if defined WLAN_FEATURE_VOWIFI
3199 PowerCapsPopulated = TRUE;
3200 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
3201 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
3202#endif
3203 }
3204
3205#if defined WLAN_FEATURE_VOWIFI
3206 if( pMac->rrm.rrmPEContext.rrmEnable &&
3207 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
3208 {
3209 if (PowerCapsPopulated == FALSE)
3210 {
3211 PowerCapsPopulated = TRUE;
3212 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
3213 }
3214 }
3215#endif
3216
3217 if ( fQosEnabled &&
3218 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
3219 {
3220 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
3221 }
3222
3223 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3224 &frm.ExtSuppRates, psessionEntry );
3225
3226#if defined WLAN_FEATURE_VOWIFI
3227 if( pMac->rrm.rrmPEContext.rrmEnable &&
3228 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
3229 {
3230 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
3231 }
3232#endif
3233 // The join request *should* contain zero or one of the WPA and RSN
3234 // IEs. The payload send along with the request is a
3235 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
3236
3237 // typedef struct sSirRSNie
3238 // {
3239 // tANI_U16 length;
3240 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
3241 // } tSirRSNie, *tpSirRSNie;
3242
3243 // So, we should be able to make the following two calls harmlessly,
3244 // since they do nothing if they don't find the given IE in the
3245 // bytestream with which they're provided.
3246
3247 // The net effect of this will be to faithfully transmit whatever
3248 // security IE is in the join request.
3249
3250 // *However*, if we're associating for the purpose of WPS
3251 // enrollment, and we've been configured to indicate that by
3252 // eliding the WPA or RSN IE, we just skip this:
3253 if( nAddIELen && pAddIE )
3254 {
3255 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
3256 }
3257 if ( NULL == wpsIe )
3258 {
3259 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3260 &frm.RSNOpaque );
3261 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3262 &frm.WPAOpaque );
3263#if defined(FEATURE_WLAN_WAPI)
3264 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3265 &frm.WAPIOpaque );
3266#endif // defined(FEATURE_WLAN_WAPI)
3267 }
3268
3269 // include WME EDCA IE as well
3270 if ( fWmeEnabled )
3271 {
3272 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
3273 {
3274 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
3275 }
3276
3277 if ( fWsmEnabled &&
3278 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3279 {
3280 PopulateDot11fWMMCaps( &frm.WMMCaps );
3281 }
3282 }
3283
Jeff Johnsone7245742012-09-05 17:12:55 -07003284 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003285 pMac->lim.htCapabilityPresentInBeacon)
3286 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003287 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003288 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003289#ifdef WLAN_FEATURE_11AC
3290 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003291 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003292 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003293 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003294 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Sandeep Puligilla60342762014-01-30 21:05:37 +05303295 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003296 }
3297#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003298
3299 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3300 if ( DOT11F_FAILED( nStatus ) )
3301 {
3302 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003303 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003304 nStatus );
3305 // We'll fall back on the worst case scenario:
3306 nPayload = sizeof( tDot11fReAssocRequest );
3307 }
3308 else if ( DOT11F_WARNED( nStatus ) )
3309 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003310 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003311 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003312 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003313 }
3314
3315 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3316
3317 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3318 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3319 ( void** ) &pPacket );
3320 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3321 {
3322 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003323 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003324 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003325 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003326 goto end;
3327 }
3328
3329 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303330 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003331
3332 // Next, we fill out the buffer descriptor:
3333 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3334 SIR_MAC_MGMT_REASSOC_REQ,
3335 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3336 if ( eSIR_SUCCESS != nSirStatus )
3337 {
3338 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003339 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003340 nSirStatus );
3341 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3342 goto end;
3343 }
3344
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303345 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003346 // That done, pack the Probe Request:
3347 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3348 sizeof(tSirMacMgmtHdr),
3349 nPayload, &nPayload );
3350 if ( DOT11F_FAILED( nStatus ) )
3351 {
3352 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003353 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003354 nStatus );
3355 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3356 goto end;
3357 }
3358 else if ( DOT11F_WARNED( nStatus ) )
3359 {
3360 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003361 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003362 }
3363
3364 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003365 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003366 nBytes );)
3367
3368 if( psessionEntry->assocReq != NULL )
3369 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303370 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003371 psessionEntry->assocReq = NULL;
3372 }
3373
3374 if( nAddIELen )
3375 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303376 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3377 pAddIE,
3378 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003379 nPayload += nAddIELen;
3380 }
3381
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303382 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3383 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003384 {
3385 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003386 }
3387 else
3388 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003389 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303390 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003391 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003392 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003393
3394 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003395 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3396 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003397 )
3398 {
3399 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3400 }
3401
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003402 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003403 {
3404 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3405 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003406
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303407 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3408 psessionEntry->peSessionId,
3409 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3411 HAL_TXRX_FRM_802_11_MGMT,
3412 ANI_TXDIR_TODS,
3413 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3414 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303415 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3416 psessionEntry->peSessionId,
3417 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003418 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3419 {
3420 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003421 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003422 nSirStatus );
3423 //Pkt will be freed up by the callback
3424 goto end;
3425 }
3426
3427end:
3428 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303429 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003430 psessionEntry->pLimMlmReassocReq = NULL;
3431
3432} // limSendReassocReqMgmtFrame
3433
3434/**
3435 * \brief Send an Authentication frame
3436 *
3437 *
3438 * \param pMac Pointer to Global MAC structure
3439 *
3440 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3441 * to be sent
3442 *
3443 * \param peerMacAddr MAC address of the peer entity to which Authentication
3444 * frame is destined
3445 *
3446 * \param wepBit Indicates whether wep bit to be set in FC while sending
3447 * Authentication frame3
3448 *
3449 *
3450 * This function is called by limProcessMlmMessages(). Authentication frame
3451 * is formatted and sent when this function is called.
3452 *
3453 *
3454 */
3455
3456void
3457limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3458 tpSirMacAuthFrameBody pAuthFrameBody,
3459 tSirMacAddr peerMacAddr,
3460 tANI_U8 wepBit,
3461 tpPESession psessionEntry
3462 )
3463{
3464 tANI_U8 *pFrame, *pBody;
3465 tANI_U32 frameLen = 0, bodyLen = 0;
3466 tpSirMacMgmtHdr pMacHdr;
3467 tANI_U16 i;
3468 void *pPacket;
3469 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303470 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003471
3472 if(NULL == psessionEntry)
3473 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303474 limLog(pMac, LOGE, FL("Error: psession Entry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003475 return;
3476 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05303477
3478 limLog(pMac, LOG1,
3479 FL("Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
3480 pAuthFrameBody->authTransactionSeqNumber,
3481 pAuthFrameBody->authStatusCode,
3482 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3483 MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003484 if (wepBit == LIM_WEP_IN_FC)
3485 {
3486 /// Auth frame3 to be sent with encrypted framebody
3487 /**
3488 * Allocate buffer for Authenticaton frame of size equal
3489 * to management frame header length plus 2 bytes each for
3490 * auth algorithm number, transaction number, status code,
3491 * 128 bytes for challenge text and 4 bytes each for
3492 * IV & ICV.
3493 */
3494
3495 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3496
3497 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3498 } // if (wepBit == LIM_WEP_IN_FC)
3499 else
3500 {
3501 switch (pAuthFrameBody->authTransactionSeqNumber)
3502 {
3503 case SIR_MAC_AUTH_FRAME_1:
3504 /**
3505 * Allocate buffer for Authenticaton frame of size
3506 * equal to management frame header length plus 2 bytes
3507 * each for auth algorithm number, transaction number
3508 * and status code.
3509 */
3510
3511 frameLen = sizeof(tSirMacMgmtHdr) +
3512 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3513 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3514
3515#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003516 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3517 {
3518 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003519 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003520 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003521 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003522 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003523 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003524 else
3525 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303526 limLog(pMac, LOG3, FL("Auth frame, Does not contain "
3527 "FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003528 frameLen += (2+SIR_MDIE_SIZE);
3529 }
3530 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003531#endif
3532 break;
3533
3534 case SIR_MAC_AUTH_FRAME_2:
3535 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3536 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3537 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3538 {
3539 /**
3540 * Allocate buffer for Authenticaton frame of size
3541 * equal to management frame header length plus
3542 * 2 bytes each for auth algorithm number,
3543 * transaction number and status code.
3544 */
3545
3546 frameLen = sizeof(tSirMacMgmtHdr) +
3547 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3548 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3549 }
3550 else
3551 {
3552 // Shared Key algorithm with challenge text
3553 // to be sent
3554 /**
3555 * Allocate buffer for Authenticaton frame of size
3556 * equal to management frame header length plus
3557 * 2 bytes each for auth algorithm number,
3558 * transaction number, status code and 128 bytes
3559 * for challenge text.
3560 */
3561
3562 frameLen = sizeof(tSirMacMgmtHdr) +
3563 sizeof(tSirMacAuthFrame);
3564 bodyLen = sizeof(tSirMacAuthFrameBody);
3565 }
3566
3567 break;
3568
3569 case SIR_MAC_AUTH_FRAME_3:
3570 /// Auth frame3 to be sent without encrypted framebody
3571 /**
3572 * Allocate buffer for Authenticaton frame of size equal
3573 * to management frame header length plus 2 bytes each
3574 * for auth algorithm number, transaction number and
3575 * status code.
3576 */
3577
3578 frameLen = sizeof(tSirMacMgmtHdr) +
3579 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3580 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3581
3582 break;
3583
3584 case SIR_MAC_AUTH_FRAME_4:
3585 /**
3586 * Allocate buffer for Authenticaton frame of size equal
3587 * to management frame header length plus 2 bytes each
3588 * for auth algorithm number, transaction number and
3589 * status code.
3590 */
3591
3592 frameLen = sizeof(tSirMacMgmtHdr) +
3593 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3594 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3595
3596 break;
3597 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3598 } // end if (wepBit == LIM_WEP_IN_FC)
3599
3600
3601 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3602
3603 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3604 {
3605 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003606 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003607
3608 return;
3609 }
3610
3611 for (i = 0; i < frameLen; i++)
3612 pFrame[i] = 0;
3613
3614 // Prepare BD
3615 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3616 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3617 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303618 limLog(pMac, LOGE, FL("call to limPopulateMacHeader failed for "
3619 "AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003620 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3621 return;
3622 }
3623
3624 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3625 pMacHdr->fc.wep = wepBit;
3626
3627 // Prepare BSSId
3628 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3629 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303630 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3631 (tANI_U8 *) psessionEntry->bssId,
3632 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003633 }
3634
3635 /// Prepare Authentication frame body
3636 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3637
3638 if (wepBit == LIM_WEP_IN_FC)
3639 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303640 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003641
3642 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303643 FL("*** Sending Auth seq# 3 status %d (%d) to"MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003644 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303645 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3646 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003647
Jeff Johnson295189b2012-06-20 16:38:30 -07003648 }
3649 else
3650 {
3651 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3652 pBody += sizeof(tANI_U16);
3653 bodyLen -= sizeof(tANI_U16);
3654
3655 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3656 pBody += sizeof(tANI_U16);
3657 bodyLen -= sizeof(tANI_U16);
3658
3659 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3660 pBody += sizeof(tANI_U16);
3661 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003662 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3663 sizeof (pAuthFrameBody->length) +
3664 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303665 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003666
3667#if defined WLAN_FEATURE_VOWIFI_11R
3668 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3669 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3670 {
3671
3672 {
3673 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003674 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3675 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003676#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowdad63eb492014-02-06 12:21:47 -08003677 PELOG2(limLog(pMac, LOG2, FL("Auth1 Frame FTIE is: "));
3678 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
Jeff Johnson295189b2012-06-20 16:38:30 -07003679 (tANI_U8 *)pBody,
3680 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003681#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003682 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3683 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003684 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3685 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003686 }
3687 }
3688 else
3689 {
3690 /* MDID attr is 54*/
3691 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003692 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003693 *pBody = SIR_MDIE_SIZE;
3694 pBody++;
3695 for(i=0;i<SIR_MDIE_SIZE;i++)
3696 {
3697 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3698 pBody++;
3699 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003700 }
3701 }
3702 }
3703#endif
3704
3705 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303706 FL("*** Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003707 pAuthFrameBody->authTransactionSeqNumber,
3708 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303709 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3710 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003711 }
3712 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3713
3714 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003715 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3716 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003717#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303718 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003719 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3720#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003721 )
3722 {
3723 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3724 }
3725
Ganesh K08bce952012-12-13 15:04:41 -08003726 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3727 {
3728 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3729 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003730
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05303731 limLog( pMac, LOG1, FL("Sending Auth Frame over WQ5 to "MAC_ADDRESS_STR
3732 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
3733 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
3734
3735 txFlag |= HAL_USE_FW_IN_TX_PATH;
3736
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303737 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3738 psessionEntry->peSessionId,
3739 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003740 /// Queue Authentication frame in high priority WQ
3741 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3742 HAL_TXRX_FRM_802_11_MGMT,
3743 ANI_TXDIR_TODS,
3744 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3745 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303746 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3747 psessionEntry->peSessionId,
3748 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003749 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3750 {
3751 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003752 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003753 halstatus);
3754
3755 //Pkt will be freed up by the callback
3756 }
3757
3758 return;
3759} /*** end limSendAuthMgmtFrame() ***/
3760
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003761eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3762{
3763 tANI_U16 aid;
3764 tpDphHashNode pStaDs;
3765 tLimMlmDeauthReq *pMlmDeauthReq;
3766 tLimMlmDeauthCnf mlmDeauthCnf;
3767 tpPESession psessionEntry;
3768
3769 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3770 if (pMlmDeauthReq)
3771 {
3772 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3773 {
3774 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3775 }
3776
3777 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3778 {
3779
3780 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003781 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003782 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3783 goto end;
3784 }
3785
3786 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3787 if (pStaDs == NULL)
3788 {
3789 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3790 goto end;
3791 }
3792
3793
3794 /// Receive path cleanup with dummy packet
3795 limCleanupRxPath(pMac, pStaDs,psessionEntry);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05303796
3797#ifdef WLAN_FEATURE_VOWIFI_11R
3798 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
3799 (
3800#ifdef FEATURE_WLAN_ESE
3801 (psessionEntry->isESEconnection ) ||
3802#endif
3803#ifdef FEATURE_WLAN_LFR
3804 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
3805#endif
3806 (psessionEntry->is11Rconnection )))
3807 {
3808 PELOGE(limLog(pMac, LOGE,
3809 FL("FT Preauth Session (%p,%d) Cleanup"
3810 " Deauth reason %d Trigger = %d"),
3811 psessionEntry, psessionEntry->peSessionId,
3812 pMlmDeauthReq->reasonCode,
3813 pMlmDeauthReq->deauthTrigger););
3814 limFTCleanup(pMac);
3815 }
3816 else
3817 {
3818 PELOGE(limLog(pMac, LOGE,
3819 FL("No FT Preauth Session Cleanup in role %d"
3820#ifdef FEATURE_WLAN_ESE
3821 " isESE %d"
3822#endif
3823#ifdef FEATURE_WLAN_LFR
3824 " isLFR %d"
3825#endif
3826 " is11r %d, Deauth reason %d Trigger = %d"),
3827 psessionEntry->limSystemRole,
3828#ifdef FEATURE_WLAN_ESE
3829 psessionEntry->isESEconnection,
3830#endif
3831#ifdef FEATURE_WLAN_LFR
3832 psessionEntry->isFastRoamIniFeatureEnabled,
3833#endif
3834 psessionEntry->is11Rconnection,
3835 pMlmDeauthReq->reasonCode,
3836 pMlmDeauthReq->deauthTrigger););
3837 }
3838#endif
3839
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003840 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303841 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003842 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3843 }
3844 return eHAL_STATUS_SUCCESS;
3845end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303846 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003847 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3848 sizeof(tSirMacAddr));
3849 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3850 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3851 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3852
3853 // Free up buffer allocated
3854 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303855 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003856
3857 limPostSmeMessage(pMac,
3858 LIM_MLM_DEAUTH_CNF,
3859 (tANI_U32 *) &mlmDeauthCnf);
3860 return eHAL_STATUS_SUCCESS;
3861}
3862
3863eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3864{
3865 tANI_U16 aid;
3866 tpDphHashNode pStaDs;
3867 tLimMlmDisassocCnf mlmDisassocCnf;
3868 tpPESession psessionEntry;
3869 tLimMlmDisassocReq *pMlmDisassocReq;
3870
3871 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3872 if (pMlmDisassocReq)
3873 {
3874 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3875 {
3876 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3877 }
3878
3879 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3880 {
3881
3882 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003883 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003884 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3885 goto end;
3886 }
3887
3888 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3889 if (pStaDs == NULL)
3890 {
3891 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3892 goto end;
3893 }
3894
3895 /// Receive path cleanup with dummy packet
3896 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3897 {
3898 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3899 goto end;
3900 }
3901
3902#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003903 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303904 (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003905#ifdef FEATURE_WLAN_ESE
3906 (psessionEntry->isESEconnection ) ||
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003907#endif
3908#ifdef FEATURE_WLAN_LFR
3909 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003910#endif
3911 (psessionEntry->is11Rconnection )) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303912 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003913 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003914 {
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303915 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003916 FL("FT Preauth Session (%p,%d) Cleanup"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003917 psessionEntry, psessionEntry->peSessionId););
3918 limFTCleanup(pMac);
3919 }
3920 else
3921 {
3922 PELOGE(limLog(pMac, LOGE,
3923 FL("No FT Preauth Session Cleanup in role %d"
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003924#ifdef FEATURE_WLAN_ESE
3925 " isESE %d"
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003926#endif
3927#ifdef FEATURE_WLAN_LFR
3928 " isLFR %d"
3929#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003930 " is11r %d reason %d"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003931 psessionEntry->limSystemRole,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003932#ifdef FEATURE_WLAN_ESE
3933 psessionEntry->isESEconnection,
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003934#endif
3935#ifdef FEATURE_WLAN_LFR
3936 psessionEntry->isFastRoamIniFeatureEnabled,
3937#endif
3938 psessionEntry->is11Rconnection,
3939 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003940 }
3941#endif
3942
3943 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303944 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003945 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3946 return eHAL_STATUS_SUCCESS;
3947 }
3948 else
3949 {
3950 return eHAL_STATUS_SUCCESS;
3951 }
3952end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303953 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003954 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3955 sizeof(tSirMacAddr));
3956 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3957 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3958
3959 /* Update PE session ID*/
3960 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3961
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003962 if(pMlmDisassocReq != NULL)
3963 {
3964 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303965 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003966 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3967 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003968
3969 limPostSmeMessage(pMac,
3970 LIM_MLM_DISASSOC_CNF,
3971 (tANI_U32 *) &mlmDisassocCnf);
3972 return eHAL_STATUS_SUCCESS;
3973}
3974
3975eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3976{
3977 return limSendDisassocCnf(pMac);
3978}
3979
3980eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3981{
3982 return limSendDeauthCnf(pMac);
3983}
3984
Jeff Johnson295189b2012-06-20 16:38:30 -07003985/**
3986 * \brief This function is called to send Disassociate frame.
3987 *
3988 *
3989 * \param pMac Pointer to Global MAC structure
3990 *
3991 * \param nReason Indicates the reason that need to be sent in
3992 * Disassociation frame
3993 *
3994 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3995 * sent
3996 *
3997 *
3998 */
3999
4000void
4001limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
4002 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004003 tSirMacAddr peer,
4004 tpPESession psessionEntry,
4005 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004006{
4007 tDot11fDisassociation frm;
4008 tANI_U8 *pFrame;
4009 tSirRetStatus nSirStatus;
4010 tpSirMacMgmtHdr pMacHdr;
4011 tANI_U32 nBytes, nPayload, nStatus;
4012 void *pPacket;
4013 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304014 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004015 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004016 if(NULL == psessionEntry)
4017 {
4018 return;
4019 }
4020
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304021 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004022
4023 frm.Reason.code = nReason;
4024
4025 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
4026 if ( DOT11F_FAILED( nStatus ) )
4027 {
4028 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004029 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004030 nStatus );
4031 // We'll fall back on the worst case scenario:
4032 nPayload = sizeof( tDot11fDisassociation );
4033 }
4034 else if ( DOT11F_WARNED( nStatus ) )
4035 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004036 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004037 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004038 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004039 }
4040
4041 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4042
4043 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4044 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4045 ( void** ) &pPacket );
4046 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4047 {
4048 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004049 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 return;
4051 }
4052
4053 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304054 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004055
4056 // Next, we fill out the buffer descriptor:
4057 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4058 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
4059 if ( eSIR_SUCCESS != nSirStatus )
4060 {
4061 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004062 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004063 nSirStatus );
4064 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4065 ( void* ) pFrame, ( void* ) pPacket );
4066 return; // just allocated...
4067 }
4068
4069 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4070
4071 // Prepare the BSSID
4072 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4073
Chet Lanctot186b5732013-03-18 10:26:30 -07004074#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004075 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004076#endif
4077
Jeff Johnson295189b2012-06-20 16:38:30 -07004078 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
4079 sizeof(tSirMacMgmtHdr),
4080 nPayload, &nPayload );
4081 if ( DOT11F_FAILED( nStatus ) )
4082 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004083 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004084 nStatus );
4085 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4086 ( void* ) pFrame, ( void* ) pPacket );
4087 return; // allocated!
4088 }
4089 else if ( DOT11F_WARNED( nStatus ) )
4090 {
4091 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004092 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004093 }
4094
Abhishek Singhcd09b562013-12-24 16:02:20 +05304095 limLog( pMac, LOG1, FL("***Sessionid %d Sending Disassociation frame with "
4096 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4097 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4098 MAC_ADDR_ARRAY(pMacHdr->da),
4099 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004100
4101 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004102 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4103 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004104 )
4105 {
4106 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4107 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004108
Ganesh K08bce952012-12-13 15:04:41 -08004109 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304110 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
4111 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08004112 {
4113 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4114 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004115
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304116 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4117 {
4118 /* This frame will be sent on air by firmware,
4119 which will ensure that this frame goes out
4120 even though DEL_STA is sent immediately */
4121 /* Without this for DEL_STA command there is
4122 risk of flushing frame in BTQM queue without
4123 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304124 limLog( pMac, LOG1, FL("Sending Disassoc Frame over WQ5 to "MAC_ADDRESS_STR
4125 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4126 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304127 txFlag |= HAL_USE_FW_IN_TX_PATH;
4128 }
4129
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004130 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004131 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304132 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4133 psessionEntry->peSessionId,
4134 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004135 // Queue Disassociation frame in high priority WQ
4136 /* get the duration from the request */
4137 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4138 HAL_TXRX_FRM_802_11_MGMT,
4139 ANI_TXDIR_TODS,
4140 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4141 limTxComplete, pFrame, limDisassocTxCompleteCnf,
4142 txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304143 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4144 psessionEntry->peSessionId,
4145 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004146 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07004147
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004148 if (tx_timer_change(
4149 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
4150 != TX_SUCCESS)
4151 {
4152 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004153 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004154 return;
4155 }
4156 else if(TX_SUCCESS != tx_timer_activate(
4157 &pMac->lim.limTimers.gLimDisassocAckTimer))
4158 {
4159 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004160 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004161 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4162 return;
4163 }
4164 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004165 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004166 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304167 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4168 psessionEntry->peSessionId,
4169 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004170 // Queue Disassociation frame in high priority WQ
4171 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4172 HAL_TXRX_FRM_802_11_MGMT,
4173 ANI_TXDIR_TODS,
4174 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4175 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304176 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4177 psessionEntry->peSessionId,
4178 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004179 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4180 {
4181 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004182 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004183 nSirStatus );
4184 //Pkt will be freed up by the callback
4185 return;
4186 }
4187 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004188} // End limSendDisassocMgmtFrame.
4189
4190/**
4191 * \brief This function is called to send a Deauthenticate frame
4192 *
4193 *
4194 * \param pMac Pointer to global MAC structure
4195 *
4196 * \param nReason Indicates the reason that need to be sent in the
4197 * Deauthenticate frame
4198 *
4199 * \param peeer address of the STA to which the frame is to be sent
4200 *
4201 *
4202 */
4203
4204void
4205limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
4206 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004207 tSirMacAddr peer,
4208 tpPESession psessionEntry,
4209 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004210{
4211 tDot11fDeAuth frm;
4212 tANI_U8 *pFrame;
4213 tSirRetStatus nSirStatus;
4214 tpSirMacMgmtHdr pMacHdr;
4215 tANI_U32 nBytes, nPayload, nStatus;
4216 void *pPacket;
4217 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304218 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004219 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004220#ifdef FEATURE_WLAN_TDLS
4221 tANI_U16 aid;
4222 tpDphHashNode pStaDs;
4223#endif
4224
Jeff Johnson295189b2012-06-20 16:38:30 -07004225 if(NULL == psessionEntry)
4226 {
4227 return;
4228 }
4229
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304230 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004231
4232 frm.Reason.code = nReason;
4233
4234 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
4235 if ( DOT11F_FAILED( nStatus ) )
4236 {
4237 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004238 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004239 nStatus );
4240 // We'll fall back on the worst case scenario:
4241 nPayload = sizeof( tDot11fDeAuth );
4242 }
4243 else if ( DOT11F_WARNED( nStatus ) )
4244 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004245 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004246 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004247 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004248 }
4249
4250 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4251
4252 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4253 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4254 ( void** ) &pPacket );
4255 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4256 {
4257 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004258 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004259 return;
4260 }
4261
4262 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304263 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004264
4265 // Next, we fill out the buffer descriptor:
4266 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4267 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
4268 if ( eSIR_SUCCESS != nSirStatus )
4269 {
4270 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004271 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004272 nSirStatus );
4273 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4274 ( void* ) pFrame, ( void* ) pPacket );
4275 return; // just allocated...
4276 }
4277
4278 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4279
4280 // Prepare the BSSID
4281 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4282
Chet Lanctot186b5732013-03-18 10:26:30 -07004283#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004284 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004285#endif
4286
Jeff Johnson295189b2012-06-20 16:38:30 -07004287 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
4288 sizeof(tSirMacMgmtHdr),
4289 nPayload, &nPayload );
4290 if ( DOT11F_FAILED( nStatus ) )
4291 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004292 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004293 nStatus );
4294 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4295 ( void* ) pFrame, ( void* ) pPacket );
4296 return;
4297 }
4298 else if ( DOT11F_WARNED( nStatus ) )
4299 {
4300 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004301 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004302 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05304303 limLog( pMac, LOG1, FL("***Sessionid %d Sending Deauth frame with "
4304 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4305 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4306 MAC_ADDR_ARRAY(pMacHdr->da),
4307 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004308
4309 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004310 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4311 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004312 )
4313 {
4314 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4315 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004316
Ganesh K08bce952012-12-13 15:04:41 -08004317 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304318 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
4319 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08004320 {
4321 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4322 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004323
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304324 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4325 {
4326 /* This frame will be sent on air by firmware,
4327 which will ensure that this frame goes out
4328 even though DEL_STA is sent immediately */
4329 /* Without this for DEL_STA command there is
4330 risk of flushing frame in BTQM queue without
4331 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304332 limLog( pMac, LOG1, FL("Sending Deauth Frame over WQ5 to "MAC_ADDRESS_STR
4333 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4334 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304335 txFlag |= HAL_USE_FW_IN_TX_PATH;
4336 }
4337
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004338#ifdef FEATURE_WLAN_TDLS
4339 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
4340#endif
4341
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004342 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004343 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304344 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4345 psessionEntry->peSessionId,
4346 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004347 // Queue Disassociation frame in high priority WQ
4348 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4349 HAL_TXRX_FRM_802_11_MGMT,
4350 ANI_TXDIR_TODS,
4351 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4352 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304353 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4354 psessionEntry->peSessionId,
4355 halstatus));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304356 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004357 {
4358 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304359 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004360 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08004361 //Pkt will be freed up by the callback limTxComplete
4362
4363 /*Call limProcessDeauthAckTimeout which will send
4364 * DeauthCnf for this frame
4365 */
4366 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004367 return;
4368 }
4369
4370 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
4371
4372 if (tx_timer_change(
4373 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
4374 != TX_SUCCESS)
4375 {
4376 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004377 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004378 return;
4379 }
4380 else if(TX_SUCCESS != tx_timer_activate(
4381 &pMac->lim.limTimers.gLimDeauthAckTimer))
4382 {
4383 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004384 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004385 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4386 return;
4387 }
4388 }
4389 else
4390 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304391 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4392 psessionEntry->peSessionId,
4393 pMacHdr->fc.subType));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004394#ifdef FEATURE_WLAN_TDLS
4395 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4396 {
4397 // Queue Disassociation frame in high priority WQ
4398 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004399 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004400 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004401 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4402 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004403 }
4404 else
4405 {
4406#endif
4407 // Queue Disassociation frame in high priority WQ
4408 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4409 HAL_TXRX_FRM_802_11_MGMT,
4410 ANI_TXDIR_TODS,
4411 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4412 limTxComplete, pFrame, txFlag );
4413#ifdef FEATURE_WLAN_TDLS
4414 }
4415#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304416 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4417 psessionEntry->peSessionId,
4418 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004419 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4420 {
4421 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004422 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004423 nSirStatus );
4424 //Pkt will be freed up by the callback
4425 return;
4426 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004427 }
4428
4429} // End limSendDeauthMgmtFrame.
4430
4431
4432#ifdef ANI_SUPPORT_11H
4433/**
4434 * \brief Send a Measurement Report Action frame
4435 *
4436 *
4437 * \param pMac Pointer to the global MAC structure
4438 *
4439 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4440 *
4441 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4442 *
4443 *
4444 */
4445
4446tSirRetStatus
4447limSendMeasReportFrame(tpAniSirGlobal pMac,
4448 tpSirMacMeasReqActionFrame pMeasReqFrame,
4449 tSirMacAddr peer)
4450{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304451 tDot11fMeasurementReport frm;
4452 tANI_U8 *pFrame;
4453 tSirRetStatus nSirStatus;
4454 tpSirMacMgmtHdr pMacHdr;
4455 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4456 void *pPacket;
4457 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004458
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304459 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004460
4461 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4462 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4463 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4464
4465 switch ( pMeasReqFrame->measReqIE.measType )
4466 {
4467 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4468 nSirStatus =
4469 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4470 &frm.MeasurementReport );
4471 break;
4472 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4473 nSirStatus =
4474 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4475 &frm.MeasurementReport );
4476 break;
4477 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4478 nSirStatus =
4479 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4480 &frm.MeasurementReport );
4481 break;
4482 default:
4483 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004484 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004485 pMeasReqFrame->measReqIE.measType );
4486 return eSIR_FAILURE;
4487 }
4488
4489 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4490
4491 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4492 if ( DOT11F_FAILED( nStatus ) )
4493 {
4494 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004495 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004496 nStatus );
4497 // We'll fall back on the worst case scenario:
4498 nPayload = sizeof( tDot11fMeasurementReport );
4499 }
4500 else if ( DOT11F_WARNED( nStatus ) )
4501 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004502 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004503 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004504 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004505 }
4506
4507 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4508
4509 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4510 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4511 {
4512 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004513 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004514 return eSIR_FAILURE;
4515 }
4516
4517 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304518 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004519
4520 // Next, we fill out the buffer descriptor:
4521 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4522 SIR_MAC_MGMT_ACTION, peer);
4523 if ( eSIR_SUCCESS != nSirStatus )
4524 {
4525 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004526 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004527 nSirStatus );
4528 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4529 return eSIR_FAILURE; // just allocated...
4530 }
4531
4532 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4533
4534 nCfg = 6;
4535 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4536 if ( eSIR_SUCCESS != nSirStatus )
4537 {
4538 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004539 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004540 nSirStatus );
4541 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4542 return eSIR_FAILURE; // just allocated...
4543 }
4544
Chet Lanctot186b5732013-03-18 10:26:30 -07004545#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004546 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004547#endif
4548
Jeff Johnson295189b2012-06-20 16:38:30 -07004549 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4550 sizeof(tSirMacMgmtHdr),
4551 nPayload, &nPayload );
4552 if ( DOT11F_FAILED( nStatus ) )
4553 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004554 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004555 nStatus );
4556 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4557 return eSIR_FAILURE; // allocated!
4558 }
4559 else if ( DOT11F_WARNED( nStatus ) )
4560 {
4561 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004562 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004563 }
4564
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304565 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4566 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4567 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004568 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4569 HAL_TXRX_FRM_802_11_MGMT,
4570 ANI_TXDIR_TODS,
4571 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4572 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304573 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4574 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4575 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004576 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4577 {
4578 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004579 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004580 nSirStatus );
4581 //Pkt will be freed up by the callback
4582 return eSIR_FAILURE; // just allocated...
4583 }
4584
4585 return eSIR_SUCCESS;
4586
4587} // End limSendMeasReportFrame.
4588
4589
4590/**
4591 * \brief Send a TPC Request Action frame
4592 *
4593 *
4594 * \param pMac Pointer to the global MAC datastructure
4595 *
4596 * \param peer MAC address to which the frame should be sent
4597 *
4598 *
4599 */
4600
4601void
4602limSendTpcRequestFrame(tpAniSirGlobal pMac,
4603 tSirMacAddr peer)
4604{
4605 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304606 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004607 tSirRetStatus nSirStatus;
4608 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304609 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4610 void *pPacket;
4611 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004612
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304613 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004614
4615 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4616 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4617 frm.DialogToken.token = 1;
4618 frm.TPCRequest.present = 1;
4619
4620 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4621 if ( DOT11F_FAILED( nStatus ) )
4622 {
4623 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004624 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004625 nStatus );
4626 // We'll fall back on the worst case scenario:
4627 nPayload = sizeof( tDot11fTPCRequest );
4628 }
4629 else if ( DOT11F_WARNED( nStatus ) )
4630 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004631 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004632 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004633 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 }
4635
4636 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4637
4638 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4639 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4640 {
4641 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004642 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004643 return;
4644 }
4645
4646 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304647 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004648
4649 // Next, we fill out the buffer descriptor:
4650 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4651 SIR_MAC_MGMT_ACTION, peer);
4652 if ( eSIR_SUCCESS != nSirStatus )
4653 {
4654 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004655 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004656 nSirStatus );
4657 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4658 return; // just allocated...
4659 }
4660
4661 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4662
4663 nCfg = 6;
4664 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4665 if ( eSIR_SUCCESS != nSirStatus )
4666 {
4667 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004668 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004669 nSirStatus );
4670 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4671 return; // just allocated...
4672 }
4673
Chet Lanctot186b5732013-03-18 10:26:30 -07004674#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004675 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004676#endif
4677
Jeff Johnson295189b2012-06-20 16:38:30 -07004678 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4679 sizeof(tSirMacMgmtHdr),
4680 nPayload, &nPayload );
4681 if ( DOT11F_FAILED( nStatus ) )
4682 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004683 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004684 nStatus );
4685 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4686 return; // allocated!
4687 }
4688 else if ( DOT11F_WARNED( nStatus ) )
4689 {
4690 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004691 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004692 }
4693
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304694 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4695 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4696 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004697 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4698 HAL_TXRX_FRM_802_11_MGMT,
4699 ANI_TXDIR_TODS,
4700 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4701 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304702 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4703 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4704 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004705 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4706 {
4707 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004708 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004709 nSirStatus );
4710 //Pkt will be freed up by the callback
4711 return;
4712 }
4713
4714} // End limSendTpcRequestFrame.
4715
4716
4717/**
4718 * \brief Send a TPC Report Action frame
4719 *
4720 *
4721 * \param pMac Pointer to the global MAC datastructure
4722 *
4723 * \param pTpcReqFrame Pointer to the received TPC Request
4724 *
4725 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4726 *
4727 *
4728 */
4729
4730tSirRetStatus
4731limSendTpcReportFrame(tpAniSirGlobal pMac,
4732 tpSirMacTpcReqActionFrame pTpcReqFrame,
4733 tSirMacAddr peer)
4734{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304735 tDot11fTPCReport frm;
4736 tANI_U8 *pFrame;
4737 tSirRetStatus nSirStatus;
4738 tpSirMacMgmtHdr pMacHdr;
4739 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4740 void *pPacket;
4741 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004742
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304743 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004744
4745 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4746 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4747 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4748
4749 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4750 // "misplaced this function, need to replace:
4751 // txPower = halGetRateToPwrValue(pMac, staid,
4752 // pMac->lim.gLimCurrentChannelId, 0);
4753 frm.TPCReport.tx_power = 0;
4754 frm.TPCReport.link_margin = 0;
4755 frm.TPCReport.present = 1;
4756
4757 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4758 if ( DOT11F_FAILED( nStatus ) )
4759 {
4760 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004761 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004762 nStatus );
4763 // We'll fall back on the worst case scenario:
4764 nPayload = sizeof( tDot11fTPCReport );
4765 }
4766 else if ( DOT11F_WARNED( nStatus ) )
4767 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004768 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004769 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004770 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004771 }
4772
4773 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4774
4775 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4776 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4777 {
4778 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004779 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004780 return eSIR_FAILURE;
4781 }
4782
4783 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304784 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004785
4786 // Next, we fill out the buffer descriptor:
4787 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4788 SIR_MAC_MGMT_ACTION, peer);
4789 if ( eSIR_SUCCESS != nSirStatus )
4790 {
4791 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004792 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004793 nSirStatus );
4794 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4795 return eSIR_FAILURE; // just allocated...
4796 }
4797
4798 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4799
4800 nCfg = 6;
4801 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4802 if ( eSIR_SUCCESS != nSirStatus )
4803 {
4804 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004805 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004806 nSirStatus );
4807 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4808 return eSIR_FAILURE; // just allocated...
4809 }
4810
Chet Lanctot186b5732013-03-18 10:26:30 -07004811#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004812 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004813#endif
4814
Jeff Johnson295189b2012-06-20 16:38:30 -07004815 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4816 sizeof(tSirMacMgmtHdr),
4817 nPayload, &nPayload );
4818 if ( DOT11F_FAILED( nStatus ) )
4819 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004820 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004821 nStatus );
4822 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4823 return eSIR_FAILURE; // allocated!
4824 }
4825 else if ( DOT11F_WARNED( nStatus ) )
4826 {
4827 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004828 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004829 }
4830
4831
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304832 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4833 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4834 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004835 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4836 HAL_TXRX_FRM_802_11_MGMT,
4837 ANI_TXDIR_TODS,
4838 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4839 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304840 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4841 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4842 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004843 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4844 {
4845 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004846 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004847 nSirStatus );
4848 //Pkt will be freed up by the callback
4849 return eSIR_FAILURE; // just allocated...
4850 }
4851
4852 return eSIR_SUCCESS;
4853
4854} // End limSendTpcReportFrame.
4855#endif //ANI_SUPPORT_11H
4856
4857
Jeff Johnson295189b2012-06-20 16:38:30 -07004858/**
4859 * \brief Send a Channel Switch Announcement
4860 *
4861 *
4862 * \param pMac Pointer to the global MAC datastructure
4863 *
4864 * \param peer MAC address to which this frame will be sent
4865 *
4866 * \param nMode
4867 *
4868 * \param nNewChannel
4869 *
4870 * \param nCount
4871 *
4872 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4873 *
4874 *
4875 */
4876
4877tSirRetStatus
4878limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4879 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004880 tANI_U8 nMode,
4881 tANI_U8 nNewChannel,
4882 tANI_U8 nCount,
4883 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004884{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304885 tDot11fChannelSwitch frm;
4886 tANI_U8 *pFrame;
4887 tSirRetStatus nSirStatus;
4888 tpSirMacMgmtHdr pMacHdr;
4889 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4890 void *pPacket;
4891 eHalStatus halstatus;
4892 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004893
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304894 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004895
4896 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4897 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4898 frm.ChanSwitchAnn.switchMode = nMode;
4899 frm.ChanSwitchAnn.newChannel = nNewChannel;
4900 frm.ChanSwitchAnn.switchCount = nCount;
4901 frm.ChanSwitchAnn.present = 1;
4902
4903 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4904 if ( DOT11F_FAILED( nStatus ) )
4905 {
4906 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004907 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004908 nStatus );
4909 // We'll fall back on the worst case scenario:
4910 nPayload = sizeof( tDot11fChannelSwitch );
4911 }
4912 else if ( DOT11F_WARNED( nStatus ) )
4913 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004914 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004915 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004916 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004917 }
4918
4919 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4920
4921 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4922 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4923 {
4924 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004925 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004926 return eSIR_FAILURE;
4927 }
4928
4929 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304930 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004931
4932 // Next, we fill out the buffer descriptor:
4933 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004934 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4935 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304936 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4937 (tANI_U8 *) psessionEntry->bssId,
4938 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004939 if ( eSIR_SUCCESS != nSirStatus )
4940 {
4941 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004942 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004943 nSirStatus );
4944 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4945 return eSIR_FAILURE; // just allocated...
4946 }
4947
Jeff Johnsone7245742012-09-05 17:12:55 -07004948#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004949 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4950
4951 nCfg = 6;
4952 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4953 if ( eSIR_SUCCESS != nSirStatus )
4954 {
4955 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004956 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004957 nSirStatus );
4958 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4959 return eSIR_FAILURE; // just allocated...
4960 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004961#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004962
4963#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004964 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004965#endif
4966
Jeff Johnson295189b2012-06-20 16:38:30 -07004967 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4968 sizeof(tSirMacMgmtHdr),
4969 nPayload, &nPayload );
4970 if ( DOT11F_FAILED( nStatus ) )
4971 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004972 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004973 nStatus );
4974 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4975 return eSIR_FAILURE; // allocated!
4976 }
4977 else if ( DOT11F_WARNED( nStatus ) )
4978 {
4979 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004980 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004981 }
4982
Jeff Johnsone7245742012-09-05 17:12:55 -07004983 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004984 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4985 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004986 )
4987 {
4988 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4989 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304990
4991 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4992 psessionEntry->peSessionId,
4993 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004994 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4995 HAL_TXRX_FRM_802_11_MGMT,
4996 ANI_TXDIR_TODS,
4997 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004998 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304999 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5000 psessionEntry->peSessionId,
5001 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07005002 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5003 {
5004 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005005 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005006 nSirStatus );
5007 //Pkt will be freed up by the callback
5008 return eSIR_FAILURE;
5009 }
5010
5011 return eSIR_SUCCESS;
5012
5013} // End limSendChannelSwitchMgmtFrame.
5014
Jeff Johnson295189b2012-06-20 16:38:30 -07005015
5016
Mohit Khanna4a70d262012-09-11 16:30:12 -07005017#ifdef WLAN_FEATURE_11AC
5018tSirRetStatus
5019limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
5020 tSirMacAddr peer,
5021 tANI_U8 nMode,
5022 tpPESession psessionEntry )
5023{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305024 tDot11fOperatingMode frm;
5025 tANI_U8 *pFrame;
5026 tSirRetStatus nSirStatus;
5027 tpSirMacMgmtHdr pMacHdr;
5028 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
5029 void *pPacket;
5030 eHalStatus halstatus;
5031 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07005032
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305033 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005034
5035 frm.Category.category = SIR_MAC_ACTION_VHT;
5036 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
5037 frm.OperatingMode.chanWidth = nMode;
5038 frm.OperatingMode.rxNSS = 0;
5039 frm.OperatingMode.rxNSSType = 0;
5040
5041 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
5042 if ( DOT11F_FAILED( nStatus ) )
5043 {
5044 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005045 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005046 nStatus );
5047 // We'll fall back on the worst case scenario:
5048 nPayload = sizeof( tDot11fOperatingMode);
5049 }
5050 else if ( DOT11F_WARNED( nStatus ) )
5051 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005052 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07005053 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005054 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005055 }
5056
5057 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5058
5059 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5060 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5061 {
5062 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005063 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005064 return eSIR_FAILURE;
5065 }
5066
5067 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305068 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005069
5070
5071 // Next, we fill out the buffer descriptor:
5072 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
5073 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5074 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5075 } else
5076 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5077 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
5078 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305079 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5080 (tANI_U8 *) psessionEntry->bssId,
5081 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005082 if ( eSIR_SUCCESS != nSirStatus )
5083 {
5084 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005085 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005086 nSirStatus );
5087 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5088 return eSIR_FAILURE; // just allocated...
5089 }
5090 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
5091 sizeof(tSirMacMgmtHdr),
5092 nPayload, &nPayload );
5093 if ( DOT11F_FAILED( nStatus ) )
5094 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005095 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005096 nStatus );
5097 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5098 return eSIR_FAILURE; // allocated!
5099 }
5100 else if ( DOT11F_WARNED( nStatus ) )
5101 {
5102 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005103 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005104 }
5105 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07005106 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5107 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07005108 )
5109 {
5110 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5111 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305112
5113 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5114 psessionEntry->peSessionId,
5115 pMacHdr->fc.subType));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005116 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5117 HAL_TXRX_FRM_802_11_MGMT,
5118 ANI_TXDIR_TODS,
5119 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5120 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305121 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5122 psessionEntry->peSessionId,
5123 halstatus));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005124 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5125 {
5126 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005127 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005128 nSirStatus );
5129 //Pkt will be freed up by the callback
5130 return eSIR_FAILURE;
5131 }
5132
5133 return eSIR_SUCCESS;
5134}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005135
5136/**
5137 * \brief Send a VHT Channel Switch Announcement
5138 *
5139 *
5140 * \param pMac Pointer to the global MAC datastructure
5141 *
5142 * \param peer MAC address to which this frame will be sent
5143 *
5144 * \param nChanWidth
5145 *
5146 * \param nNewChannel
5147 *
5148 *
5149 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5150 *
5151 *
5152 */
5153
5154tSirRetStatus
5155limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5156 tSirMacAddr peer,
5157 tANI_U8 nChanWidth,
5158 tANI_U8 nNewChannel,
5159 tANI_U8 ncbMode,
5160 tpPESession psessionEntry )
5161{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305162 tDot11fChannelSwitch frm;
5163 tANI_U8 *pFrame;
5164 tSirRetStatus nSirStatus;
5165 tpSirMacMgmtHdr pMacHdr;
5166 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5167 void *pPacket;
5168 eHalStatus halstatus;
5169 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005170
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305171 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005172
5173
5174 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5175 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5176 frm.ChanSwitchAnn.switchMode = 1;
5177 frm.ChanSwitchAnn.newChannel = nNewChannel;
5178 frm.ChanSwitchAnn.switchCount = 1;
5179 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
5180 frm.ExtChanSwitchAnn.present = 1;
5181 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
5182 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
5183 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
5184 frm.ChanSwitchAnn.present = 1;
5185 frm.WiderBWChanSwitchAnn.present = 1;
5186
5187 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5188 if ( DOT11F_FAILED( nStatus ) )
5189 {
5190 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005191 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005192 nStatus );
5193 // We'll fall back on the worst case scenario:
5194 nPayload = sizeof( tDot11fChannelSwitch );
5195 }
5196 else if ( DOT11F_WARNED( nStatus ) )
5197 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005198 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005199 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005200 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005201 }
5202
5203 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5204
5205 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5206 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5207 {
5208 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005209 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005210 return eSIR_FAILURE;
5211 }
5212 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305213 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005214
5215 // Next, we fill out the buffer descriptor:
5216 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5217 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5218 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305219 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5220 (tANI_U8 *) psessionEntry->bssId,
5221 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005222 if ( eSIR_SUCCESS != nSirStatus )
5223 {
5224 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005225 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005226 nSirStatus );
5227 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5228 return eSIR_FAILURE; // just allocated...
5229 }
5230 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5231 sizeof(tSirMacMgmtHdr),
5232 nPayload, &nPayload );
5233 if ( DOT11F_FAILED( nStatus ) )
5234 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005235 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005236 nStatus );
5237 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5238 return eSIR_FAILURE; // allocated!
5239 }
5240 else if ( DOT11F_WARNED( nStatus ) )
5241 {
5242 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005243 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005244 }
5245
5246 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005247 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5248 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005249 )
5250 {
5251 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5252 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305253
5254 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5255 psessionEntry->peSessionId,
5256 pMacHdr->fc.subType));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005257 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5258 HAL_TXRX_FRM_802_11_MGMT,
5259 ANI_TXDIR_TODS,
5260 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5261 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305262 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5263 psessionEntry->peSessionId,
5264 halstatus));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005265 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5266 {
5267 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005268 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005269 nSirStatus );
5270 //Pkt will be freed up by the callback
5271 return eSIR_FAILURE;
5272 }
5273
5274 return eSIR_SUCCESS;
5275
5276} // End limSendVHTChannelSwitchMgmtFrame.
5277
5278
5279
Mohit Khanna4a70d262012-09-11 16:30:12 -07005280#endif
5281
Jeff Johnson295189b2012-06-20 16:38:30 -07005282/**
5283 * \brief Send an ADDBA Req Action Frame to peer
5284 *
5285 * \sa limSendAddBAReq
5286 *
5287 * \param pMac The global tpAniSirGlobal object
5288 *
5289 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
5290 * the necessary parameters reqd by PE send the ADDBA Req Action
5291 * Frame to the peer
5292 *
5293 * \return eSIR_SUCCESS if setup completes successfully
5294 * eSIR_FAILURE is some problem is encountered
5295 */
5296tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305297 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07005298{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305299 tDot11fAddBAReq frmAddBAReq;
5300 tANI_U8 *pAddBAReqBuffer = NULL;
5301 tpSirMacMgmtHdr pMacHdr;
5302 tANI_U32 frameLen = 0, nStatus, nPayload;
5303 tSirRetStatus statusCode;
5304 eHalStatus halStatus;
5305 void *pPacket;
5306 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005307
5308 if(NULL == psessionEntry)
5309 {
5310 return eSIR_FAILURE;
5311 }
5312
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305313 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005314
5315 // Category - 3 (BA)
5316 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
5317
5318 // Action - 0 (ADDBA Req)
5319 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
5320
5321 // FIXME - Dialog Token, generalize this...
5322 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
5323
5324 // Fill the ADDBA Parameter Set
5325 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
5326 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
5327 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
5328
5329 // BA timeout
5330 // 0 - indicates no BA timeout
5331 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
5332
5333 // BA Starting Sequence Number
5334 // Fragment number will always be zero
5335 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
5336 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
5337 }
5338
5339 frmAddBAReq.BAStartingSequenceControl.ssn =
5340 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
5341
5342 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
5343
5344 if( DOT11F_FAILED( nStatus ))
5345 {
5346 limLog( pMac, LOGW,
5347 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005348 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005349 nStatus );
5350
5351 // We'll fall back on the worst case scenario:
5352 nPayload = sizeof( tDot11fAddBAReq );
5353 }
5354 else if( DOT11F_WARNED( nStatus ))
5355 {
5356 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005357 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005358 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005359 nStatus );
5360 }
5361
5362 // Add the MGMT header to frame length
5363 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5364
5365 // Need to allocate a buffer for ADDBA AF
5366 if( eHAL_STATUS_SUCCESS !=
5367 (halStatus = palPktAlloc( pMac->hHdd,
5368 HAL_TXRX_FRM_802_11_MGMT,
5369 (tANI_U16) frameLen,
5370 (void **) &pAddBAReqBuffer,
5371 (void **) &pPacket )))
5372 {
5373 // Log error
5374 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005375 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005376 frameLen,
5377 halStatus );
5378
5379 statusCode = eSIR_MEM_ALLOC_FAILED;
5380 goto returnAfterError;
5381 }
5382
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305383 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005384
5385 // Copy necessary info to BD
5386 if( eSIR_SUCCESS !=
5387 (statusCode = limPopulateMacHeader( pMac,
5388 pAddBAReqBuffer,
5389 SIR_MAC_MGMT_FRAME,
5390 SIR_MAC_MGMT_ACTION,
5391 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5392 goto returnAfterError;
5393
5394 // Update A3 with the BSSID
5395 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
5396
5397 #if 0
5398 cfgLen = SIR_MAC_ADDR_LENGTH;
5399 if( eSIR_SUCCESS != cfgGetStr( pMac,
5400 WNI_CFG_BSSID,
5401 (tANI_U8 *) pMacHdr->bssId,
5402 &cfgLen ))
5403 {
5404 limLog( pMac, LOGP,
5405 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005406 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005407
5408 // FIXME - Need to convert to tSirRetStatus
5409 statusCode = eSIR_FAILURE;
5410 goto returnAfterError;
5411 }
5412 #endif//TO SUPPORT BT-AMP
5413 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5414
Chet Lanctot186b5732013-03-18 10:26:30 -07005415#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005416 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005417#endif
5418
Jeff Johnson295189b2012-06-20 16:38:30 -07005419 // Now, we're ready to "pack" the frames
5420 nStatus = dot11fPackAddBAReq( pMac,
5421 &frmAddBAReq,
5422 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5423 nPayload,
5424 &nPayload );
5425
5426 if( DOT11F_FAILED( nStatus ))
5427 {
5428 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005429 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 nStatus );
5431
5432 // FIXME - Need to convert to tSirRetStatus
5433 statusCode = eSIR_FAILURE;
5434 goto returnAfterError;
5435 }
5436 else if( DOT11F_WARNED( nStatus ))
5437 {
5438 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005439 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5440 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005441 }
5442
5443 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005444 FL( "Sending an ADDBA REQ to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005445 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
5446
5447 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005448 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5449 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005450 )
5451 {
5452 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5453 }
5454
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305455 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5456 psessionEntry->peSessionId,
5457 pMacHdr->fc.subType));
5458 halStatus = halTxFrame( pMac,
5459 pPacket,
5460 (tANI_U16) frameLen,
5461 HAL_TXRX_FRM_802_11_MGMT,
5462 ANI_TXDIR_TODS,
5463 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5464 limTxComplete,
5465 pAddBAReqBuffer, txFlag );
5466 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5467 psessionEntry->peSessionId,
5468 halStatus));
5469 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005470 {
5471 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005472 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005473 halStatus );
5474
5475 // FIXME - Need to convert eHalStatus to tSirRetStatus
5476 statusCode = eSIR_FAILURE;
5477 //Pkt will be freed up by the callback
5478 return statusCode;
5479 }
5480 else
5481 return eSIR_SUCCESS;
5482
5483returnAfterError:
5484
5485 // Release buffer, if allocated
5486 if( NULL != pAddBAReqBuffer )
5487 palPktFree( pMac->hHdd,
5488 HAL_TXRX_FRM_802_11_MGMT,
5489 (void *) pAddBAReqBuffer,
5490 (void *) pPacket );
5491
5492 return statusCode;
5493}
5494
5495/**
5496 * \brief Send an ADDBA Rsp Action Frame to peer
5497 *
5498 * \sa limSendAddBARsp
5499 *
5500 * \param pMac The global tpAniSirGlobal object
5501 *
5502 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5503 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5504 * Frame to the peer
5505 *
5506 * \return eSIR_SUCCESS if setup completes successfully
5507 * eSIR_FAILURE is some problem is encountered
5508 */
5509tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5510 tpLimMlmAddBARsp pMlmAddBARsp,
5511 tpPESession psessionEntry)
5512{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305513 tDot11fAddBARsp frmAddBARsp;
5514 tANI_U8 *pAddBARspBuffer = NULL;
5515 tpSirMacMgmtHdr pMacHdr;
5516 tANI_U32 frameLen = 0, nStatus, nPayload;
5517 tSirRetStatus statusCode;
5518 eHalStatus halStatus;
5519 void *pPacket;
5520 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005521
5522 if(NULL == psessionEntry)
5523 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005524 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005525 return eSIR_FAILURE;
5526 }
5527
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305528 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005529
5530 // Category - 3 (BA)
5531 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5532 // Action - 1 (ADDBA Rsp)
5533 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5534
5535 // Should be same as the one we received in the ADDBA Req
5536 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5537
5538 // ADDBA Req status
5539 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5540
5541 // Fill the ADDBA Parameter Set as provided by caller
5542 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5543 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5544 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005545
5546 if(psessionEntry->isAmsduSupportInAMPDU)
5547 {
5548 frmAddBARsp.AddBAParameterSet.amsduSupported =
5549 psessionEntry->amsduSupportedInBA;
5550 }
5551 else
5552 {
5553 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5554 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005555
5556 // BA timeout
5557 // 0 - indicates no BA timeout
5558 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5559
5560 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5561
5562 if( DOT11F_FAILED( nStatus ))
5563 {
5564 limLog( pMac, LOGW,
5565 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005566 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005567 nStatus );
5568
5569 // We'll fall back on the worst case scenario:
5570 nPayload = sizeof( tDot11fAddBARsp );
5571 }
5572 else if( DOT11F_WARNED( nStatus ))
5573 {
5574 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005575 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005576 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005577 nStatus );
5578 }
5579
5580 // Need to allocate a buffer for ADDBA AF
5581 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5582
5583 // Allocate shared memory
5584 if( eHAL_STATUS_SUCCESS !=
5585 (halStatus = palPktAlloc( pMac->hHdd,
5586 HAL_TXRX_FRM_802_11_MGMT,
5587 (tANI_U16) frameLen,
5588 (void **) &pAddBARspBuffer,
5589 (void **) &pPacket )))
5590 {
5591 // Log error
5592 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005593 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005594 frameLen,
5595 halStatus );
5596
5597 statusCode = eSIR_MEM_ALLOC_FAILED;
5598 goto returnAfterError;
5599 }
5600
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305601 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005602
5603 // Copy necessary info to BD
5604 if( eSIR_SUCCESS !=
5605 (statusCode = limPopulateMacHeader( pMac,
5606 pAddBARspBuffer,
5607 SIR_MAC_MGMT_FRAME,
5608 SIR_MAC_MGMT_ACTION,
5609 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5610 goto returnAfterError;
5611
5612 // Update A3 with the BSSID
5613
5614 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5615
5616 #if 0
5617 cfgLen = SIR_MAC_ADDR_LENGTH;
5618 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5619 WNI_CFG_BSSID,
5620 (tANI_U8 *) pMacHdr->bssId,
5621 &cfgLen ))
5622 {
5623 limLog( pMac, LOGP,
5624 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005625 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005626
5627 // FIXME - Need to convert to tSirRetStatus
5628 statusCode = eSIR_FAILURE;
5629 goto returnAfterError;
5630 }
5631 #endif // TO SUPPORT BT-AMP
5632 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5633
Chet Lanctot186b5732013-03-18 10:26:30 -07005634#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005635 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005636#endif
5637
Jeff Johnson295189b2012-06-20 16:38:30 -07005638 // Now, we're ready to "pack" the frames
5639 nStatus = dot11fPackAddBARsp( pMac,
5640 &frmAddBARsp,
5641 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5642 nPayload,
5643 &nPayload );
5644
5645 if( DOT11F_FAILED( nStatus ))
5646 {
5647 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005648 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005649 nStatus );
5650
5651 // FIXME - Need to convert to tSirRetStatus
5652 statusCode = eSIR_FAILURE;
5653 goto returnAfterError;
5654 }
5655 else if( DOT11F_WARNED( nStatus ))
5656 {
5657 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005658 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5659 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005660 }
5661
5662 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005663 FL( "Sending an ADDBA RSP to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005664 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5665
5666 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005667 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5668 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005669 )
5670 {
5671 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5672 }
5673
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305674 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5675 psessionEntry->peSessionId,
5676 pMacHdr->fc.subType));
5677 halStatus = halTxFrame( pMac,
5678 pPacket,
5679 (tANI_U16) frameLen,
5680 HAL_TXRX_FRM_802_11_MGMT,
5681 ANI_TXDIR_TODS,
5682 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5683 limTxComplete,
5684 pAddBARspBuffer, txFlag );
5685 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5686 psessionEntry->peSessionId,
5687 halStatus));
5688 if( eHAL_STATUS_SUCCESS != halStatus )
5689 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005690 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005691 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005692 halStatus );
5693
5694 // FIXME - HAL error codes are different from PE error
5695 // codes!! And, this routine is returning tSirRetStatus
5696 statusCode = eSIR_FAILURE;
5697 //Pkt will be freed up by the callback
5698 return statusCode;
5699 }
5700 else
5701 return eSIR_SUCCESS;
5702
5703 returnAfterError:
Jeff Johnson295189b2012-06-20 16:38:30 -07005704 // Release buffer, if allocated
5705 if( NULL != pAddBARspBuffer )
5706 palPktFree( pMac->hHdd,
5707 HAL_TXRX_FRM_802_11_MGMT,
5708 (void *) pAddBARspBuffer,
5709 (void *) pPacket );
5710
5711 return statusCode;
5712}
5713
5714/**
5715 * \brief Send a DELBA Indication Action Frame to peer
5716 *
5717 * \sa limSendDelBAInd
5718 *
5719 * \param pMac The global tpAniSirGlobal object
5720 *
5721 * \param peerMacAddr MAC Address of peer
5722 *
5723 * \param reasonCode Reason for the DELBA notification
5724 *
5725 * \param pBAParameterSet The DELBA Parameter Set.
5726 * This identifies the TID for which the BA session is
5727 * being deleted.
5728 *
5729 * \return eSIR_SUCCESS if setup completes successfully
5730 * eSIR_FAILURE is some problem is encountered
5731 */
5732tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5733 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5734{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305735 tDot11fDelBAInd frmDelBAInd;
5736 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005737 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305738 tpSirMacMgmtHdr pMacHdr;
5739 tANI_U32 frameLen = 0, nStatus, nPayload;
5740 tSirRetStatus statusCode;
5741 eHalStatus halStatus;
5742 void *pPacket;
5743 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005744
5745 if(NULL == psessionEntry)
5746 {
5747 return eSIR_FAILURE;
5748 }
5749
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305750 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005751
5752 // Category - 3 (BA)
5753 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5754 // Action - 2 (DELBA)
5755 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5756
5757 // Fill the DELBA Parameter Set as provided by caller
5758 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5759 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5760
5761 // BA Starting Sequence Number
5762 // Fragment number will always be zero
5763 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5764
5765 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5766
5767 if( DOT11F_FAILED( nStatus ))
5768 {
5769 limLog( pMac, LOGW,
5770 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005771 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005772 nStatus );
5773
5774 // We'll fall back on the worst case scenario:
5775 nPayload = sizeof( tDot11fDelBAInd );
5776 }
5777 else if( DOT11F_WARNED( nStatus ))
5778 {
5779 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005780 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005781 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005782 nStatus );
5783 }
5784
5785 // Add the MGMT header to frame length
5786 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5787
5788 // Allocate shared memory
5789 if( eHAL_STATUS_SUCCESS !=
5790 (halStatus = palPktAlloc( pMac->hHdd,
5791 HAL_TXRX_FRM_802_11_MGMT,
5792 (tANI_U16) frameLen,
5793 (void **) &pDelBAIndBuffer,
5794 (void **) &pPacket )))
5795 {
5796 // Log error
5797 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005798 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005799 frameLen,
5800 halStatus );
5801
5802 statusCode = eSIR_MEM_ALLOC_FAILED;
5803 goto returnAfterError;
5804 }
5805
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305806 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005807
5808 // Copy necessary info to BD
5809 if( eSIR_SUCCESS !=
5810 (statusCode = limPopulateMacHeader( pMac,
5811 pDelBAIndBuffer,
5812 SIR_MAC_MGMT_FRAME,
5813 SIR_MAC_MGMT_ACTION,
5814 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5815 goto returnAfterError;
5816
5817 // Update A3 with the BSSID
5818 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5819
5820 #if 0
5821 cfgLen = SIR_MAC_ADDR_LENGTH;
5822 if( eSIR_SUCCESS != cfgGetStr( pMac,
5823 WNI_CFG_BSSID,
5824 (tANI_U8 *) pMacHdr->bssId,
5825 &cfgLen ))
5826 {
5827 limLog( pMac, LOGP,
5828 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005829 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005830
5831 // FIXME - Need to convert to tSirRetStatus
5832 statusCode = eSIR_FAILURE;
5833 goto returnAfterError;
5834 }
5835 #endif //TO SUPPORT BT-AMP
5836 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5837
Chet Lanctot186b5732013-03-18 10:26:30 -07005838#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005839 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005840#endif
5841
Jeff Johnson295189b2012-06-20 16:38:30 -07005842 // Now, we're ready to "pack" the frames
5843 nStatus = dot11fPackDelBAInd( pMac,
5844 &frmDelBAInd,
5845 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5846 nPayload,
5847 &nPayload );
5848
5849 if( DOT11F_FAILED( nStatus ))
5850 {
5851 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005852 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005853 nStatus );
5854
5855 // FIXME - Need to convert to tSirRetStatus
5856 statusCode = eSIR_FAILURE;
5857 goto returnAfterError;
5858 }
5859 else if( DOT11F_WARNED( nStatus ))
5860 {
5861 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005862 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
5863 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005864 }
5865
5866 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005867 FL( "Sending a DELBA IND to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005868 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5869
5870 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005871 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5872 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005873 )
5874 {
5875 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5876 }
5877
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305878 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5879 psessionEntry->peSessionId,
5880 pMacHdr->fc.subType));
5881 halStatus = halTxFrame( pMac,
5882 pPacket,
5883 (tANI_U16) frameLen,
5884 HAL_TXRX_FRM_802_11_MGMT,
5885 ANI_TXDIR_TODS,
5886 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5887 limTxComplete,
5888 pDelBAIndBuffer, txFlag );
5889 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5890 psessionEntry->peSessionId,
5891 halStatus));
5892 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005893 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005894 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005895 statusCode = eSIR_FAILURE;
5896 //Pkt will be freed up by the callback
5897 return statusCode;
5898 }
5899 else
5900 return eSIR_SUCCESS;
5901
5902 returnAfterError:
5903
5904 // Release buffer, if allocated
5905 if( NULL != pDelBAIndBuffer )
5906 palPktFree( pMac->hHdd,
5907 HAL_TXRX_FRM_802_11_MGMT,
5908 (void *) pDelBAIndBuffer,
5909 (void *) pPacket );
5910
5911 return statusCode;
5912}
5913
5914#if defined WLAN_FEATURE_VOWIFI
5915
5916/**
5917 * \brief Send a Neighbor Report Request Action frame
5918 *
5919 *
5920 * \param pMac Pointer to the global MAC structure
5921 *
5922 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5923 *
5924 * \param peer mac address of peer station.
5925 *
5926 * \param psessionEntry address of session entry.
5927 *
5928 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5929 *
5930 *
5931 */
5932
5933tSirRetStatus
5934limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5935 tpSirMacNeighborReportReq pNeighborReq,
5936 tSirMacAddr peer,
5937 tpPESession psessionEntry
5938 )
5939{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305940 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005941 tDot11fNeighborReportRequest frm;
5942 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305943 tpSirMacMgmtHdr pMacHdr;
5944 tANI_U32 nBytes, nPayload, nStatus;
5945 void *pPacket;
5946 eHalStatus halstatus;
5947 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005948
5949 if ( psessionEntry == NULL )
5950 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005951 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005952 return eSIR_FAILURE;
5953 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305954 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005955
5956 frm.Category.category = SIR_MAC_ACTION_RRM;
5957 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5958 frm.DialogToken.token = pNeighborReq->dialogToken;
5959
5960
5961 if( pNeighborReq->ssid_present )
5962 {
5963 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5964 }
5965
5966 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5967 if ( DOT11F_FAILED( nStatus ) )
5968 {
5969 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005970 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005971 nStatus );
5972 // We'll fall back on the worst case scenario:
5973 nPayload = sizeof( tDot11fNeighborReportRequest );
5974 }
5975 else if ( DOT11F_WARNED( nStatus ) )
5976 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005977 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005978 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005979 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 }
5981
5982 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5983
5984 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5985 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5986 {
5987 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005988 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005989 return eSIR_FAILURE;
5990 }
5991
5992 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305993 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005994
5995 // Copy necessary info to BD
5996 if( eSIR_SUCCESS !=
5997 (statusCode = limPopulateMacHeader( pMac,
5998 pFrame,
5999 SIR_MAC_MGMT_FRAME,
6000 SIR_MAC_MGMT_ACTION,
6001 peer, psessionEntry->selfMacAddr)))
6002 goto returnAfterError;
6003
6004 // Update A3 with the BSSID
6005 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6006
6007 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6008
Chet Lanctot186b5732013-03-18 10:26:30 -07006009#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006010 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006011#endif
6012
Jeff Johnson295189b2012-06-20 16:38:30 -07006013 // Now, we're ready to "pack" the frames
6014 nStatus = dot11fPackNeighborReportRequest( pMac,
6015 &frm,
6016 pFrame + sizeof( tSirMacMgmtHdr ),
6017 nPayload,
6018 &nPayload );
6019
6020 if( DOT11F_FAILED( nStatus ))
6021 {
6022 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006023 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006024 nStatus );
6025
6026 // FIXME - Need to convert to tSirRetStatus
6027 statusCode = eSIR_FAILURE;
6028 goto returnAfterError;
6029 }
6030 else if( DOT11F_WARNED( nStatus ))
6031 {
6032 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006033 FL( "There were warnings while packing Neighbor Report "
6034 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006035 }
6036
6037 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006038 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006039 limPrintMacAddr( pMac, peer, LOGW );
6040
6041 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006042 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6043 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006044 )
6045 {
6046 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6047 }
6048
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306049 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6050 psessionEntry->peSessionId,
6051 pMacHdr->fc.subType));
6052 halstatus = halTxFrame( pMac,
6053 pPacket,
6054 (tANI_U16) nBytes,
6055 HAL_TXRX_FRM_802_11_MGMT,
6056 ANI_TXDIR_TODS,
6057 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6058 limTxComplete,
6059 pFrame, txFlag );
6060 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6061 psessionEntry->peSessionId,
6062 halstatus));
6063 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006064 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006065 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006066 statusCode = eSIR_FAILURE;
6067 //Pkt will be freed up by the callback
6068 return statusCode;
6069 }
6070 else
6071 return eSIR_SUCCESS;
6072
6073returnAfterError:
6074 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6075
6076 return statusCode;
6077} // End limSendNeighborReportRequestFrame.
6078
6079/**
6080 * \brief Send a Link Report Action frame
6081 *
6082 *
6083 * \param pMac Pointer to the global MAC structure
6084 *
6085 * \param pLinkReport Address of a tSirMacLinkReport
6086 *
6087 * \param peer mac address of peer station.
6088 *
6089 * \param psessionEntry address of session entry.
6090 *
6091 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6092 *
6093 *
6094 */
6095
6096tSirRetStatus
6097limSendLinkReportActionFrame(tpAniSirGlobal pMac,
6098 tpSirMacLinkReport pLinkReport,
6099 tSirMacAddr peer,
6100 tpPESession psessionEntry
6101 )
6102{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306103 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006104 tDot11fLinkMeasurementReport frm;
6105 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306106 tpSirMacMgmtHdr pMacHdr;
6107 tANI_U32 nBytes, nPayload, nStatus;
6108 void *pPacket;
6109 eHalStatus halstatus;
6110 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006111
6112
6113 if ( psessionEntry == NULL )
6114 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006115 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006116 return eSIR_FAILURE;
6117 }
6118
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306119 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006120
6121 frm.Category.category = SIR_MAC_ACTION_RRM;
6122 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
6123 frm.DialogToken.token = pLinkReport->dialogToken;
6124
6125
6126 //IEEE Std. 802.11 7.3.2.18. for the report element.
6127 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
6128 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
6129 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
6130 //such case this way than changing the frame parser.
6131 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
6132 frm.TPCEleLen.TPCLen = 2;
6133 frm.TxPower.txPower = pLinkReport->txPower;
6134 frm.LinkMargin.linkMargin = 0;
6135
6136 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
6137 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
6138 frm.RCPI.rcpi = pLinkReport->rcpi;
6139 frm.RSNI.rsni = pLinkReport->rsni;
6140
6141 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
6142 if ( DOT11F_FAILED( nStatus ) )
6143 {
6144 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006145 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006146 nStatus );
6147 // We'll fall back on the worst case scenario:
6148 nPayload = sizeof( tDot11fLinkMeasurementReport );
6149 }
6150 else if ( DOT11F_WARNED( nStatus ) )
6151 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006152 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006153 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006154 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006155 }
6156
6157 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6158
6159 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6160 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6161 {
6162 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006163 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006164 return eSIR_FAILURE;
6165 }
6166
6167 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306168 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006169
6170 // Copy necessary info to BD
6171 if( eSIR_SUCCESS !=
6172 (statusCode = limPopulateMacHeader( pMac,
6173 pFrame,
6174 SIR_MAC_MGMT_FRAME,
6175 SIR_MAC_MGMT_ACTION,
6176 peer, psessionEntry->selfMacAddr)))
6177 goto returnAfterError;
6178
6179 // Update A3 with the BSSID
6180 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6181
6182 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6183
Chet Lanctot186b5732013-03-18 10:26:30 -07006184#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006185 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006186#endif
6187
Jeff Johnson295189b2012-06-20 16:38:30 -07006188 // Now, we're ready to "pack" the frames
6189 nStatus = dot11fPackLinkMeasurementReport( pMac,
6190 &frm,
6191 pFrame + sizeof( tSirMacMgmtHdr ),
6192 nPayload,
6193 &nPayload );
6194
6195 if( DOT11F_FAILED( nStatus ))
6196 {
6197 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006198 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006199 nStatus );
6200
6201 // FIXME - Need to convert to tSirRetStatus
6202 statusCode = eSIR_FAILURE;
6203 goto returnAfterError;
6204 }
6205 else if( DOT11F_WARNED( nStatus ))
6206 {
6207 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006208 FL( "There were warnings while packing Link Report (0x%08x)." ),
6209 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006210 }
6211
6212 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006213 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006214 limPrintMacAddr( pMac, peer, LOGW );
6215
6216 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006217 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6218 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006219 )
6220 {
6221 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6222 }
6223
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306224 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6225 psessionEntry->peSessionId,
6226 pMacHdr->fc.subType));
6227 halstatus = halTxFrame( pMac,
6228 pPacket,
6229 (tANI_U16) nBytes,
6230 HAL_TXRX_FRM_802_11_MGMT,
6231 ANI_TXDIR_TODS,
6232 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6233 limTxComplete,
6234 pFrame, txFlag );
6235 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6236 psessionEntry->peSessionId,
6237 halstatus));
6238 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006239 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006240 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006241 statusCode = eSIR_FAILURE;
6242 //Pkt will be freed up by the callback
6243 return statusCode;
6244 }
6245 else
6246 return eSIR_SUCCESS;
6247
6248returnAfterError:
6249 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6250
6251 return statusCode;
6252} // End limSendLinkReportActionFrame.
6253
6254/**
6255 * \brief Send a Beacon Report Action frame
6256 *
6257 *
6258 * \param pMac Pointer to the global MAC structure
6259 *
6260 * \param dialog_token dialog token to be used in the action frame.
6261 *
6262 * \param num_report number of reports in pRRMReport.
6263 *
6264 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
6265 *
6266 * \param peer mac address of peer station.
6267 *
6268 * \param psessionEntry address of session entry.
6269 *
6270 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6271 *
6272 *
6273 */
6274
6275tSirRetStatus
6276limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
6277 tANI_U8 dialog_token,
6278 tANI_U8 num_report,
6279 tpSirMacRadioMeasureReport pRRMReport,
6280 tSirMacAddr peer,
6281 tpPESession psessionEntry
6282 )
6283{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306284 tSirRetStatus statusCode = eSIR_SUCCESS;
6285 tANI_U8 *pFrame;
6286 tpSirMacMgmtHdr pMacHdr;
6287 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006288 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306289 eHalStatus halstatus;
6290 tANI_U8 i;
6291 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006292
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006293 tDot11fRadioMeasurementReport *frm =
6294 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
6295 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006296 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006297 return eSIR_FAILURE;
6298 }
6299
Jeff Johnson295189b2012-06-20 16:38:30 -07006300 if ( psessionEntry == NULL )
6301 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006302 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006303 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006304 return eSIR_FAILURE;
6305 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306306 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006307
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006308 frm->Category.category = SIR_MAC_ACTION_RRM;
6309 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
6310 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07006311
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006312 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 -07006313
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006314 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006315 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006316 frm->MeasurementReport[i].type = pRRMReport[i].type;
6317 frm->MeasurementReport[i].token = pRRMReport[i].token;
6318 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006319 switch( pRRMReport[i].type )
6320 {
6321 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006322 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
6323 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6324 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
6325 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006326 break;
6327 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05306328 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6329 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006330 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006331 break;
6332 }
6333 }
6334
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006335 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07006336 if ( DOT11F_FAILED( nStatus ) )
6337 {
6338 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006339 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006340 nStatus );
6341 // We'll fall back on the worst case scenario:
6342 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006343 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006344 return eSIR_FAILURE;
6345 }
6346 else if ( DOT11F_WARNED( nStatus ) )
6347 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006348 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006349 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006350 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006351 }
6352
6353 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6354
6355 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6356 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6357 {
6358 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006359 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006360 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006361 return eSIR_FAILURE;
6362 }
6363
6364 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306365 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006366
6367 // Copy necessary info to BD
6368 if( eSIR_SUCCESS !=
6369 (statusCode = limPopulateMacHeader( pMac,
6370 pFrame,
6371 SIR_MAC_MGMT_FRAME,
6372 SIR_MAC_MGMT_ACTION,
6373 peer, psessionEntry->selfMacAddr)))
6374 goto returnAfterError;
6375
6376 // Update A3 with the BSSID
6377 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6378
6379 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6380
Chet Lanctot186b5732013-03-18 10:26:30 -07006381#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006382 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006383#endif
6384
Jeff Johnson295189b2012-06-20 16:38:30 -07006385 // Now, we're ready to "pack" the frames
6386 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006387 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07006388 pFrame + sizeof( tSirMacMgmtHdr ),
6389 nPayload,
6390 &nPayload );
6391
6392 if( DOT11F_FAILED( nStatus ))
6393 {
6394 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006395 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006396 nStatus );
6397
6398 // FIXME - Need to convert to tSirRetStatus
6399 statusCode = eSIR_FAILURE;
6400 goto returnAfterError;
6401 }
6402 else if( DOT11F_WARNED( nStatus ))
6403 {
6404 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006405 FL( "There were warnings while packing Radio "
6406 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006407 }
6408
6409 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006410 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006411 limPrintMacAddr( pMac, peer, LOGW );
6412
6413 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006414 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6415 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006416 )
6417 {
6418 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6419 }
6420
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306421 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6422 psessionEntry->peSessionId,
6423 pMacHdr->fc.subType));
6424 halstatus = halTxFrame( pMac,
6425 pPacket,
6426 (tANI_U16) nBytes,
6427 HAL_TXRX_FRM_802_11_MGMT,
6428 ANI_TXDIR_TODS,
6429 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6430 limTxComplete,
6431 pFrame, txFlag );
6432 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6433 psessionEntry->peSessionId,
6434 halstatus));
6435 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006436 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006437 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006438 statusCode = eSIR_FAILURE;
6439 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006440 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006441 return statusCode;
6442 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006443 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006444 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006445 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006446 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006447
6448returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006449 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006450 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07006451 return statusCode;
6452} // End limSendBeaconReportActionFrame.
6453
6454#endif
6455
6456#ifdef WLAN_FEATURE_11W
6457/**
Chet Lanctot8cecea22014-02-11 19:09:36 -08006458 * \brief Send SA query request action frame to peer
6459 *
6460 * \sa limSendSaQueryRequestFrame
6461 *
6462 *
6463 * \param pMac The global tpAniSirGlobal object
6464 *
6465 * \param transId Transaction identifier
6466 *
6467 * \param peer The Mac address of the station to which this action frame is addressed
6468 *
6469 * \param psessionEntry The PE session entry
6470 *
6471 * \return eSIR_SUCCESS if setup completes successfully
6472 * eSIR_FAILURE is some problem is encountered
6473 */
6474
6475tSirRetStatus limSendSaQueryRequestFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
6476 tSirMacAddr peer, tpPESession psessionEntry )
6477{
6478
6479 tDot11fSaQueryReq frm; // SA query request action frame
6480 tANI_U8 *pFrame;
6481 tSirRetStatus nSirStatus;
6482 tpSirMacMgmtHdr pMacHdr;
6483 tANI_U32 nBytes, nPayload, nStatus;
6484 void *pPacket;
6485 eHalStatus halstatus;
6486 tANI_U8 txFlag = 0;
6487
6488 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
6489 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6490 /* 11w action field is :
6491 action: 0 --> SA Query Request action frame
6492 action: 1 --> SA Query Response action frame */
6493 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
6494 /* 11w SA Query Request transId */
6495 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
6496
6497 nStatus = dot11fGetPackedSaQueryReqSize(pMac, &frm, &nPayload);
6498 if ( DOT11F_FAILED( nStatus ) )
6499 {
6500 limLog( pMac, LOGP, FL("Failed to calculate the packed size "
6501 "for an SA Query Request (0x%08x)."),
6502 nStatus );
6503 // We'll fall back on the worst case scenario:
6504 nPayload = sizeof( tDot11fSaQueryReq );
6505 }
6506 else if ( DOT11F_WARNED( nStatus ) )
6507 {
6508 limLog( pMac, LOGW, FL("There were warnings while calculating "
6509 "the packed size for an SA Query Request"
6510 " (0x%08x)."), nStatus );
6511 }
6512
6513 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6514 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6515 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6516 {
6517 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA Query Request "
6518 "action frame"), nBytes );
6519 return eSIR_FAILURE;
6520 }
6521
6522 // Paranoia:
6523 vos_mem_set( pFrame, nBytes, 0 );
6524
6525 // Copy necessary info to BD
6526 nSirStatus = limPopulateMacHeader( pMac,
6527 pFrame,
6528 SIR_MAC_MGMT_FRAME,
6529 SIR_MAC_MGMT_ACTION,
6530 peer, psessionEntry->selfMacAddr );
6531 if ( eSIR_SUCCESS != nSirStatus )
6532 goto returnAfterError;
6533
6534 // Update A3 with the BSSID
6535 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6536
6537 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6538
6539 // Since this is a SA Query Request, set the "protect" (aka WEP) bit
6540 // in the FC
6541 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
6542
6543 // Pack 11w SA Query Request frame
6544 nStatus = dot11fPackSaQueryReq( pMac,
6545 &frm,
6546 pFrame + sizeof( tSirMacMgmtHdr ),
6547 nPayload,
6548 &nPayload );
6549
6550 if ( DOT11F_FAILED( nStatus ))
6551 {
6552 limLog( pMac, LOGE,
6553 FL( "Failed to pack an SA Query Request (0x%08x)." ),
6554 nStatus );
6555 // FIXME - Need to convert to tSirRetStatus
6556 nSirStatus = eSIR_FAILURE;
6557 goto returnAfterError;
6558 }
6559 else if ( DOT11F_WARNED( nStatus ))
6560 {
6561 limLog( pMac, LOGW,
6562 FL( "There were warnings while packing SA Query Request (0x%08x)." ),
6563 nStatus);
6564 }
6565
6566 limLog( pMac, LOG1,
6567 FL( "Sending an SA Query Request to " ));
6568 limPrintMacAddr( pMac, peer, LOG1 );
6569 limPrintMacAddr( pMac, peer, LOGE );
6570 limLog( pMac, LOGE,
6571 FL( "Sending an SA Query Request from " ));
6572 limPrintMacAddr( pMac, psessionEntry->selfMacAddr, LOGE );
6573
6574 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
6575#ifdef WLAN_FEATURE_P2P
6576 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6577 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
6578#endif
6579 )
6580 {
6581 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6582 }
6583
6584 halstatus = halTxFrame( pMac,
6585 pPacket,
6586 (tANI_U16) nBytes,
6587 HAL_TXRX_FRM_802_11_MGMT,
6588 ANI_TXDIR_TODS,
6589 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6590 limTxComplete,
6591 pFrame, txFlag );
6592 if ( eHAL_STATUS_SUCCESS != halstatus )
6593 {
6594 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6595 nSirStatus = eSIR_FAILURE;
6596 //Pkt will be freed up by the callback
6597 return nSirStatus;
6598 }
6599 else {
6600 return eSIR_SUCCESS;
6601 }
6602
6603returnAfterError:
6604 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6605 return nSirStatus;
6606} // End limSendSaQueryRequestFrame
6607
6608/**
Jeff Johnson295189b2012-06-20 16:38:30 -07006609 * \brief Send SA query response action frame to peer
6610 *
6611 * \sa limSendSaQueryResponseFrame
6612 *
6613 *
6614 * \param pMac The global tpAniSirGlobal object
6615 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006616 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006617 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006618 * \param peer The Mac address of the AP to which this action frame is addressed
6619 *
6620 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07006621 *
6622 * \return eSIR_SUCCESS if setup completes successfully
6623 * eSIR_FAILURE is some problem is encountered
6624 */
6625
Chet Lanctot186b5732013-03-18 10:26:30 -07006626tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006627tSirMacAddr peer,tpPESession psessionEntry)
6628{
6629
Chet Lanctot186b5732013-03-18 10:26:30 -07006630 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006631 tANI_U8 *pFrame;
6632 tSirRetStatus nSirStatus;
6633 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07006634 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006635 void *pPacket;
6636 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306637 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006638
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306639 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07006640 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6641 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07006642 action: 0 --> SA query request action frame
6643 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07006644 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
6645 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07006646 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07006647 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006648
Chet Lanctot186b5732013-03-18 10:26:30 -07006649 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6650 if ( DOT11F_FAILED( nStatus ) )
6651 {
6652 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6653 "or a SA Query Response (0x%08x)."),
6654 nStatus );
6655 // We'll fall back on the worst case scenario:
6656 nPayload = sizeof( tDot11fSaQueryRsp );
6657 }
6658 else if ( DOT11F_WARNED( nStatus ) )
6659 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006660 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006661 "the packed size for an SA Query Response"
6662 " (0x%08x)."), nStatus );
6663 }
6664
Jeff Johnson295189b2012-06-20 16:38:30 -07006665 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6666 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6667 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6668 {
6669 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006670 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006671 return eSIR_FAILURE;
6672 }
6673
6674 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306675 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006676
Chet Lanctot186b5732013-03-18 10:26:30 -07006677 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006678 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006679 pFrame,
6680 SIR_MAC_MGMT_FRAME,
6681 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006682 peer, psessionEntry->selfMacAddr );
6683 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006684 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006685
Chet Lanctot186b5732013-03-18 10:26:30 -07006686 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006687 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6688
Chet Lanctot186b5732013-03-18 10:26:30 -07006689 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006690
Chet Lanctot186b5732013-03-18 10:26:30 -07006691 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6692 // in the FC
Chet Lanctot8cecea22014-02-11 19:09:36 -08006693 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -07006694
Chet Lanctot186b5732013-03-18 10:26:30 -07006695 // Pack 11w SA query response frame
6696 nStatus = dot11fPackSaQueryRsp( pMac,
6697 &frm,
6698 pFrame + sizeof( tSirMacMgmtHdr ),
6699 nPayload,
6700 &nPayload );
6701
6702 if ( DOT11F_FAILED( nStatus ))
6703 {
6704 limLog( pMac, LOGE,
6705 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6706 nStatus );
6707 // FIXME - Need to convert to tSirRetStatus
6708 nSirStatus = eSIR_FAILURE;
6709 goto returnAfterError;
6710 }
6711 else if ( DOT11F_WARNED( nStatus ))
6712 {
6713 limLog( pMac, LOGW,
6714 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6715 nStatus);
6716 }
6717
6718 limLog( pMac, LOG1,
6719 FL( "Sending a SA Query Response to " ));
6720 limPrintMacAddr( pMac, peer, LOGW );
6721
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006722 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006723#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006724 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6725 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006726#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006727 )
6728 {
6729 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6730 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006731
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306732 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6733 psessionEntry->peSessionId,
6734 pMacHdr->fc.subType));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006735 halstatus = halTxFrame( pMac,
6736 pPacket,
6737 (tANI_U16) nBytes,
6738 HAL_TXRX_FRM_802_11_MGMT,
6739 ANI_TXDIR_TODS,
6740 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6741 limTxComplete,
6742 pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306743 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6744 psessionEntry->peSessionId,
6745 halstatus));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006746 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006747 {
6748 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6749 nSirStatus = eSIR_FAILURE;
6750 //Pkt will be freed up by the callback
6751 return nSirStatus;
6752 }
6753 else {
6754 return eSIR_SUCCESS;
6755 }
6756
6757returnAfterError:
6758 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6759 return nSirStatus;
6760} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006761#endif