blob: 10c14b3ea83d3afe0278db42c93307019394a254 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lamaa8e15a2014-02-11 23:30:06 -080023 * Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
24 * All Rights Reserved.
25 * Qualcomm Atheros Confidential and Proprietary.
Kiet Lam842dad02014-02-18 18:44:02 -080026 *
Jeff Johnson295189b2012-06-20 16:38:30 -070027 */
Kiet Lam842dad02014-02-18 18:44:02 -080028
29
Jeff Johnson295189b2012-06-20 16:38:30 -070030/**
31 * \file limSendManagementFrames.c
32 *
33 * \brief Code for preparing and sending 802.11 Management frames
34 *
Kiet Lam842dad02014-02-18 18:44:02 -080035
Jeff Johnson295189b2012-06-20 16:38:30 -070036 *
37 */
38
39#include "sirApi.h"
40#include "aniGlobal.h"
41#include "sirMacProtDef.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070042#include "cfgApi.h"
43#include "utilsApi.h"
44#include "limTypes.h"
45#include "limUtils.h"
46#include "limSecurityUtils.h"
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -070047#include "limPropExtsUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070048#include "dot11f.h"
49#include "limStaHashApi.h"
50#include "schApi.h"
51#include "limSendMessages.h"
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -080052#include "limAssocUtils.h"
53#include "limFT.h"
Chet Lanctot8cecea22014-02-11 19:09:36 -080054#ifdef WLAN_FEATURE_11W
55#include "wniCfgAp.h"
56#endif
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -080057
Jeff Johnson295189b2012-06-20 16:38:30 -070058#if defined WLAN_FEATURE_VOWIFI
59#include "rrmApi.h"
60#endif
61
Jeff Johnson295189b2012-06-20 16:38:30 -070062#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070063
64
65////////////////////////////////////////////////////////////////////////
66
Kalikinkar dhara205da782014-03-21 15:49:32 -070067tSirRetStatus limStripOffExtCapIE(tpAniSirGlobal pMac,
68 tANI_U8 *addIE,
69 tANI_U16 *addnIELen,
70 tANI_U8 *pExtractedExtCapIEBuf )
71{
72 tANI_U8* tempbuf = NULL;
73 tANI_U16 tempLen = 0;
74 int left = *addnIELen;
75 tANI_U8 *ptr = addIE;
76 tANI_U8 elem_id, elem_len;
77
78 if (NULL == addIE)
79 {
80 PELOGE(limLog(pMac, LOG1, FL("NULL addIE pointer"));)
81 return eSIR_IGNORE_IE ;
82 }
83
84 tempbuf = vos_mem_malloc(left);
85 if ( NULL == tempbuf )
86 {
87 PELOGE(limLog(pMac, LOGE,
88 FL("Unable to allocate memory to store addn IE"));)
89 return eSIR_MEM_ALLOC_FAILED;
90 }
91
92 while(left >= 2)
93 {
94 elem_id = ptr[0];
95 elem_len = ptr[1];
96 left -= 2;
97 if (elem_len > left)
98 {
99 limLog( pMac, LOGE,
100 FL("Invalid IEs eid = %d elem_len=%d left=%d"),
101 elem_id,elem_len,left);
102 vos_mem_free(tempbuf);
103 return eSIR_FAILURE;
104 }
105 if ( !(DOT11F_EID_EXTCAP == elem_id) )
106 {
107 vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2);
108 tempLen += (elem_len + 2);
109 }
110 else
111 { /*Est Cap present size is 8 + 2 byte at present*/
112 if ( NULL != pExtractedExtCapIEBuf )
113 {
114 vos_mem_set(pExtractedExtCapIEBuf,
115 DOT11F_IE_EXTCAP_MAX_LEN + 2, 0);
116 if (elem_len <= DOT11F_IE_EXTCAP_MAX_LEN )
117 {
118 vos_mem_copy (pExtractedExtCapIEBuf, &ptr[0],
119 elem_len + 2);
120 }
121 }
122 }
123 left -= elem_len;
124 ptr += (elem_len + 2);
125 }
126 vos_mem_copy (addIE, tempbuf, tempLen);
127 *addnIELen = tempLen;
128 vos_mem_free(tempbuf);
129 return eSIR_SUCCESS;
130}
131
132void limUpdateExtCapIEtoStruct(tpAniSirGlobal pMac,
133 tANI_U8 *pBuf,
134 tDot11fIEExtCap *pDst)
135{
136 tANI_U8 pOut[DOT11F_IE_EXTCAP_MAX_LEN];
137
138 if ( NULL == pBuf )
139 {
140 limLog( pMac, LOGE,
141 FL("Invalid Buffer Address"));
142 return;
143 }
144 if(NULL == pDst)
145 {
146 PELOGE(limLog(pMac, LOGE,
147 FL("NULL pDst pointer"));)
148 return ;
149 }
150
151 if ( DOT11F_EID_EXTCAP != pBuf[0] ||
152 pBuf[1] > DOT11F_IE_EXTCAP_MAX_LEN )
153 {
154 limLog( pMac, LOGE,
155 FL("Invalid IEs eid = %d elem_len=%d "),
156 pBuf[0],pBuf[1]);
157 return;
158 }
159 vos_mem_set(( tANI_U8* )&pOut[0], DOT11F_IE_EXTCAP_MAX_LEN, 0);
160 /* conversion should follow 4, 2, 2 byte order */
161 limUtilsframeshtonl(pMac, &pOut[0],*((tANI_U32*)&pBuf[2]),0);
162 limUtilsframeshtons(pMac, &pOut[4],*((tANI_U16*)&pBuf[6]),0);
163 limUtilsframeshtons(pMac, &pOut[6],*((tANI_U16*)&pBuf[8]),0);
164
165 if ( DOT11F_PARSE_SUCCESS != dot11fUnpackIeExtCap( pMac,
166 &pOut[0], DOT11F_IE_EXTCAP_MAX_LEN, pDst) )
167 {
168 limLog( pMac, LOGE,
169 FL("dot11fUnpackIeExtCap Parse Error "));
170 }
171}
172
173tSirRetStatus limStripOffExtCapIEAndUpdateStruct(tpAniSirGlobal pMac,
174 tANI_U8* addIE,
175 tANI_U16 *addnIELen,
176 tDot11fIEExtCap * pDst )
177{
178 tANI_U8 pExtractedExtCapIEBuf[DOT11F_IE_EXTCAP_MAX_LEN + 2];
179 tSirRetStatus nSirStatus;
180
181 vos_mem_set(( tANI_U8* )&pExtractedExtCapIEBuf[0],
182 DOT11F_IE_EXTCAP_MAX_LEN + 2, 0);
183 nSirStatus = limStripOffExtCapIE(pMac, addIE, addnIELen,
184 pExtractedExtCapIEBuf);
185 if ( eSIR_SUCCESS != nSirStatus )
186 {
187 limLog( pMac, LOG1, FL("Failed to strip off in"
188 "limStripOffExtCapIE status = (%d)."),
189 nSirStatus );
190 return nSirStatus;
191 }
192 /* update the extracted ExtCap to struct*/
193 limUpdateExtCapIEtoStruct(pMac, pExtractedExtCapIEBuf, pDst);
194 return nSirStatus;
195}
196
197void limMergeExtCapIEStruct(tDot11fIEExtCap *pDst,
198 tDot11fIEExtCap *pSrc)
199{
200 tANI_U8 *tempDst = (tANI_U8 *)pDst;
201 tANI_U8 *tempSrc = (tANI_U8 *)pSrc;
202 tANI_U8 structlen = sizeof(tDot11fIEExtCap);
203
204 while(tempDst && tempSrc && structlen--)
205 {
206 *tempDst |= *tempSrc;
207 tempDst++;
208 tempSrc++;
209 }
210}
Jeff Johnson295189b2012-06-20 16:38:30 -0700211
212/**
213 *
214 * \brief This function is called by various LIM modules to prepare the
215 * 802.11 frame MAC header
216 *
217 *
218 * \param pMac Pointer to Global MAC structure
219 *
220 * \param pBD Pointer to the frame buffer that needs to be populate
221 *
222 * \param type Type of the frame
223 *
224 * \param subType Subtype of the frame
225 *
226 * \return eHalStatus
227 *
228 *
229 * The pFrameBuf argument points to the beginning of the frame buffer to
230 * which - a) The 802.11 MAC header is set b) Following this MAC header
231 * will be the MGMT frame payload The payload itself is populated by the
232 * caller API
233 *
234 *
235 */
236
237tSirRetStatus limPopulateMacHeader( tpAniSirGlobal pMac,
238 tANI_U8* pBD,
239 tANI_U8 type,
240 tANI_U8 subType,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530241 tSirMacAddr peerAddr, tSirMacAddr selfMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700242{
243 tSirRetStatus statusCode = eSIR_SUCCESS;
244 tpSirMacMgmtHdr pMacHdr;
245
246 /// Prepare MAC management header
247 pMacHdr = (tpSirMacMgmtHdr) (pBD);
248
249 // Prepare FC
250 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
251 pMacHdr->fc.type = type;
252 pMacHdr->fc.subType = subType;
253
254 // Prepare Address 1
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530255 vos_mem_copy( (tANI_U8 *) pMacHdr->da,
Jeff Johnson295189b2012-06-20 16:38:30 -0700256 (tANI_U8 *) peerAddr,
257 sizeof( tSirMacAddr ));
258
259 // Prepare Address 2
Jeff Johnson295189b2012-06-20 16:38:30 -0700260 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
261
262 // Prepare Address 3
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530263 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700264 (tANI_U8 *) peerAddr,
265 sizeof( tSirMacAddr ));
266 return statusCode;
267} /*** end limPopulateMacHeader() ***/
268
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700269#ifdef WLAN_FEATURE_11W
270/**
271 *
272 * \brief This function is called by various LIM modules to correctly set
273 * the Protected bit in the Frame Control Field of the 802.11 frame MAC header
274 *
275 *
276 * \param pMac Pointer to Global MAC structure
277 *
278 * \param psessionEntry Pointer to session corresponding to the connection
279 *
280 * \param peer Peer address of the STA to which the frame is to be sent
281 *
282 * \param pMacHdr Pointer to the frame MAC header
283 *
284 * \return nothing
285 *
286 *
287 */
288void
289limSetProtectedBit(tpAniSirGlobal pMac,
290 tpPESession psessionEntry,
291 tSirMacAddr peer,
292 tpSirMacMgmtHdr pMacHdr)
293{
294 tANI_U16 aid;
295 tpDphHashNode pStaDs;
296
297 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
298 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
299 {
300
301 pStaDs = dphLookupHashEntry( pMac, peer, &aid, &psessionEntry->dph.dphHashTable );
302 if( pStaDs != NULL )
303 if( pStaDs->rmfEnabled )
304 pMacHdr->fc.wep = 1;
305 }
306 else if ( psessionEntry->limRmfEnabled )
307 pMacHdr->fc.wep = 1;
308} /*** end limSetProtectedBit() ***/
309#endif
310
Jeff Johnson295189b2012-06-20 16:38:30 -0700311/**
312 * \brief limSendProbeReqMgmtFrame
313 *
314 *
315 * \param pMac Pointer to Global MAC structure
316 *
317 * \param pSsid SSID to be sent in Probe Request frame
318 *
319 * \param bssid BSSID to be sent in Probe Request frame
320 *
321 * \param nProbeDelay probe delay to be used before sending Probe Request
322 * frame
323 *
324 * \param nChannelNum Channel # on which the Probe Request is going out
325 *
326 * \param nAdditionalIELen if non-zero, include pAdditionalIE in the Probe Request frame
327 *
328 * \param pAdditionalIE if nAdditionalIELen is non zero, include this field in the Probe Request frame
329 *
330 * This function is called by various LIM modules to send Probe Request frame
331 * during active scan/learn phase.
332 * Probe request is sent out in the following scenarios:
333 * --heartbeat failure: session needed
334 * --join req: session needed
335 * --foreground scan: no session
336 * --background scan: no session
337 * --schBeaconProcessing: to get EDCA parameters: session needed
338 *
339 *
340 */
341tSirRetStatus
342limSendProbeReqMgmtFrame(tpAniSirGlobal pMac,
343 tSirMacSSid *pSsid,
344 tSirMacAddr bssid,
345 tANI_U8 nChannelNum,
346 tSirMacAddr SelfMacAddr,
347 tANI_U32 dot11mode,
348 tANI_U32 nAdditionalIELen,
349 tANI_U8 *pAdditionalIE)
350{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530351 tDot11fProbeRequest pr;
352 tANI_U32 nStatus, nBytes, nPayload;
353 tSirRetStatus nSirStatus;
354 tANI_U8 *pFrame;
355 void *pPacket;
356 eHalStatus halstatus;
357 tpPESession psessionEntry;
358 tANI_U8 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700359 tANI_U8 *p2pIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530360 tANI_U32 txFlag = 0;
Sandeep Puligilla60342762014-01-30 21:05:37 +0530361 tANI_U32 chanbond24G = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700362
363#ifndef GEN4_SCAN
364 return eSIR_FAILURE;
365#endif
366
367#if defined ( ANI_DVT_DEBUG )
368 return eSIR_FAILURE;
369#endif
370
Abhishek Singh4beed422014-02-03 16:47:17 +0530371 /* The probe req should not send 11ac capabilieties if band is 2.4GHz,
372 * unless enableVhtFor24GHz is enabled in INI. So if enableVhtFor24GHz
373 * is false and dot11mode is 11ac set it to 11n.
374 */
375 if ( nChannelNum <= SIR_11B_CHANNEL_END &&
376 ( FALSE == pMac->roam.configParam.enableVhtFor24GHz ) &&
377 ( WNI_CFG_DOT11_MODE_11AC == dot11mode ||
378 WNI_CFG_DOT11_MODE_11AC_ONLY == dot11mode ) )
379 dot11mode = WNI_CFG_DOT11_MODE_11N;
Jeff Johnson295189b2012-06-20 16:38:30 -0700380 /*
381 * session context may or may not be present, when probe request needs to be sent out.
382 * following cases exist:
383 * --heartbeat failure: session needed
384 * --join req: session needed
385 * --foreground scan: no session
386 * --background scan: no session
387 * --schBeaconProcessing: to get EDCA parameters: session needed
388 * If session context does not exist, some IEs will be populated from CFGs,
389 * e.g. Supported and Extended rate set IEs
390 */
391 psessionEntry = peFindSessionByBssid(pMac,bssid,&sessionId);
392
393 // The scheme here is to fill out a 'tDot11fProbeRequest' structure
394 // and then hand it off to 'dot11fPackProbeRequest' (for
395 // serialization). We start by zero-initializing the structure:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530396 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700397
398 // & delegating to assorted helpers:
399 PopulateDot11fSSID( pMac, pSsid, &pr.SSID );
400
Jeff Johnson295189b2012-06-20 16:38:30 -0700401 if( nAdditionalIELen && pAdditionalIE )
402 {
403 p2pIe = limGetP2pIEPtr(pMac, pAdditionalIE, nAdditionalIELen);
404 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700405 /* Don't include 11b rate only when device is doing P2P Search */
406 if( ( WNI_CFG_DOT11_MODE_11B != dot11mode ) &&
407 ( p2pIe != NULL ) &&
408 /* Don't include 11b rate if it is a P2P serach or probe request is sent by P2P Client */
409 ( ( ( pMac->lim.gpLimMlmScanReq != NULL ) &&
410 pMac->lim.gpLimMlmScanReq->p2pSearch ) ||
411 ( ( psessionEntry != NULL ) &&
412 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
413 )
414 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700415 {
416 /* In the below API pass channel number > 14, do that it fills only
417 * 11a rates in supported rates */
418 PopulateDot11fSuppRates( pMac, 15, &pr.SuppRates,psessionEntry);
419 }
420 else
421 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700422 PopulateDot11fSuppRates( pMac, nChannelNum,
423 &pr.SuppRates,psessionEntry);
424
425 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
426 {
427 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
428 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700429 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700430
431#if defined WLAN_FEATURE_VOWIFI
432 //Table 7-14 in IEEE Std. 802.11k-2008 says
433 //DS params "can" be present in RRM is disabled and "is" present if
434 //RRM is enabled. It should be ok even if we add it into probe req when
435 //RRM is not enabled.
436 PopulateDot11fDSParams( pMac, &pr.DSParams, nChannelNum, psessionEntry );
437 //Call RRM module to get the tx power for management used.
438 {
439 tANI_U8 txPower = (tANI_U8) rrmGetMgmtTxPower( pMac, psessionEntry );
440 PopulateDot11fWFATPC( pMac, &pr.WFATPC, txPower, 0 );
441 }
442#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700443
444 if (psessionEntry != NULL ) {
Jeff Johnsone7245742012-09-05 17:12:55 -0700445 psessionEntry->htCapability = IS_DOT11_MODE_HT(dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700446 //Include HT Capability IE
Jeff Johnsone7245742012-09-05 17:12:55 -0700447 if (psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -0700448 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700449 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700450 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700451 } else { //psessionEntry == NULL
452 if (IS_DOT11_MODE_HT(dot11mode))
Jeff Johnson295189b2012-06-20 16:38:30 -0700453 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700454 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700455 }
456 }
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800457
Sandeep Puligilla60342762014-01-30 21:05:37 +0530458 /* Get HT40 capability for 2.4GHz band */
459 wlan_cfgGetInt(pMac,WNI_CFG_CHANNEL_BONDING_24G,&chanbond24G);
460 if( (nChannelNum <= SIR_11B_CHANNEL_END) && chanbond24G != TRUE)
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800461 {
462 pr.HTCaps.supportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
463 pr.HTCaps.shortGI40MHz = 0;
464 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700465#ifdef WLAN_FEATURE_11AC
466 if (psessionEntry != NULL ) {
467 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
468 //Include HT Capability IE
469 if (psessionEntry->vhtCapability)
470 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700471 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
472 }
473 } else {
474 if (IS_DOT11_MODE_VHT(dot11mode))
475 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700476 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
477 }
478 }
479#endif
480
Jeff Johnson295189b2012-06-20 16:38:30 -0700481
482 // That's it-- now we pack it. First, how much space are we going to
483 // need?
484 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
485 if ( DOT11F_FAILED( nStatus ) )
486 {
487 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700488 "or a Probe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700489 // We'll fall back on the worst case scenario:
490 nPayload = sizeof( tDot11fProbeRequest );
491 }
492 else if ( DOT11F_WARNED( nStatus ) )
493 {
494 limLog( pMac, LOGW, FL("There were warnings while calculating"
495 "the packed size for a Probe Request ("
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700496 "0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700497 }
498
499 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAdditionalIELen;
500
501 // Ok-- try to allocate some memory:
502 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
503 ( tANI_U16 )nBytes, ( void** ) &pFrame,
504 ( void** ) &pPacket );
505 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
506 {
507 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700508 "be Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700509 return eSIR_MEM_ALLOC_FAILED;
510 }
511
512 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530513 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700514
515 // Next, we fill out the buffer descriptor:
516 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530517 SIR_MAC_MGMT_PROBE_REQ, bssid, SelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700518 if ( eSIR_SUCCESS != nSirStatus )
519 {
520 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700521 "tor for a Probe Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700522 nSirStatus );
523 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
524 ( void* ) pFrame, ( void* ) pPacket );
525 return nSirStatus; // allocated!
526 }
527
528 // That done, pack the Probe Request:
529 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
530 sizeof( tSirMacMgmtHdr ),
531 nPayload, &nPayload );
532 if ( DOT11F_FAILED( nStatus ) )
533 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700534 limLog( pMac, LOGE, FL("Failed to pack a Probe Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700535 nStatus );
536 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
537 return eSIR_FAILURE; // allocated!
538 }
539 else if ( DOT11F_WARNED( nStatus ) )
540 {
541 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800542 "robe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 }
544
545 // Append any AddIE if present.
546 if( nAdditionalIELen )
547 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530548 vos_mem_copy( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700549 pAdditionalIE, nAdditionalIELen );
550 nPayload += nAdditionalIELen;
551 }
552
553 /* If this probe request is sent during P2P Search State, then we need
554 * to send it at OFDM rate.
555 */
556 if( ( SIR_BAND_5_GHZ == limGetRFBand(nChannelNum))
Jeff Johnson295189b2012-06-20 16:38:30 -0700557 || (( pMac->lim.gpLimMlmScanReq != NULL) &&
558 pMac->lim.gpLimMlmScanReq->p2pSearch )
Gopichand Nakkala67967212013-02-15 17:31:15 +0530559 /* For unicast probe req mgmt from Join function
560 we don't set above variables. So we need to add
561 one more check whether it is pePersona is P2P_CLIENT or not */
562 || ( ( psessionEntry != NULL ) &&
563 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700564 )
565 {
566 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
567 }
568
Jeff Johnson295189b2012-06-20 16:38:30 -0700569 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload,
570 HAL_TXRX_FRM_802_11_MGMT,
571 ANI_TXDIR_TODS,
572 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
573 limTxComplete, pFrame, txFlag );
574 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
575 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700576 limLog( pMac, LOGE, FL("could not send Probe Request frame!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700577 //Pkt will be freed up by the callback
578 return eSIR_FAILURE;
579 }
580
581 return eSIR_SUCCESS;
582} // End limSendProbeReqMgmtFrame.
583
Jeff Johnson295189b2012-06-20 16:38:30 -0700584tSirRetStatus limGetAddnIeForProbeResp(tpAniSirGlobal pMac,
585 tANI_U8* addIE, tANI_U16 *addnIELen,
586 tANI_U8 probeReqP2pIe)
587{
588 /* If Probe request doesn't have P2P IE, then take out P2P IE
589 from additional IE */
590 if(!probeReqP2pIe)
591 {
592 tANI_U8* tempbuf = NULL;
593 tANI_U16 tempLen = 0;
594 int left = *addnIELen;
595 v_U8_t *ptr = addIE;
596 v_U8_t elem_id, elem_len;
597
598 if(NULL == addIE)
599 {
600 PELOGE(limLog(pMac, LOGE,
601 FL(" NULL addIE pointer"));)
602 return eSIR_FAILURE;
603 }
604
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530605 tempbuf = vos_mem_malloc(left);
606 if ( NULL == tempbuf )
Jeff Johnson295189b2012-06-20 16:38:30 -0700607 {
608 PELOGE(limLog(pMac, LOGE,
609 FL("Unable to allocate memory to store addn IE"));)
610 return eSIR_MEM_ALLOC_FAILED;
611 }
612
613 while(left >= 2)
614 {
615 elem_id = ptr[0];
616 elem_len = ptr[1];
617 left -= 2;
618 if(elem_len > left)
619 {
620 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700621 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700622 elem_id,elem_len,left);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530623 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700624 return eSIR_FAILURE;
625 }
626 if ( !( (SIR_MAC_EID_VENDOR == elem_id) &&
627 (memcmp(&ptr[2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)==0) ) )
628 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530629 vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -0700630 tempLen += (elem_len + 2);
631 }
632 left -= elem_len;
633 ptr += (elem_len + 2);
634 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530635 vos_mem_copy (addIE, tempbuf, tempLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 *addnIELen = tempLen;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530637 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 }
639 return eSIR_SUCCESS;
640}
Jeff Johnson295189b2012-06-20 16:38:30 -0700641
642void
643limSendProbeRspMgmtFrame(tpAniSirGlobal pMac,
644 tSirMacAddr peerMacAddr,
645 tpAniSSID pSsid,
646 short nStaId,
647 tANI_U8 nKeepAlive,
648 tpPESession psessionEntry,
649 tANI_U8 probeReqP2pIe)
650{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700651 tDot11fProbeResponse *pFrm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530652 tSirRetStatus nSirStatus;
c_hpothubcd78652014-04-28 22:31:08 +0530653 tANI_U32 cfg, nPayload, nStatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530654 tpSirMacMgmtHdr pMacHdr;
655 tANI_U8 *pFrame;
656 void *pPacket;
657 eHalStatus halstatus;
658 tANI_U32 addnIEPresent;
659 tANI_U32 addnIE1Len=0;
660 tANI_U32 addnIE2Len=0;
661 tANI_U32 addnIE3Len=0;
662 tANI_U16 totalAddnIeLen = 0;
663 tANI_U32 wpsApEnable=0, tmp;
664 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700665 tANI_U8 *addIE = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530666 tANI_U8 *pP2pIe = NULL;
667 tANI_U8 noaLen = 0;
668 tANI_U8 total_noaLen = 0;
669 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN
Jeff Johnson295189b2012-06-20 16:38:30 -0700670 + SIR_P2P_IE_HEADER_LEN];
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530671 tANI_U8 noaIe[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Kalikinkar dhara205da782014-03-21 15:49:32 -0700672 tDot11fIEExtCap extractedExtCap;
673 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +0530674 tANI_U32 nBytes = 0;
675
Jeff Johnson295189b2012-06-20 16:38:30 -0700676 if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests
677 {
678 return; // in this case.
679 }
680
681 if(NULL == psessionEntry)
682 {
683 return;
684 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530685
686 pFrm = vos_mem_malloc(sizeof(tDot11fProbeResponse));
687 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700688 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530689 limLog(pMac, LOGE, FL("Unable to allocate memory in limSendProbeRspMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700690 return;
691 }
692
Jeff Johnson295189b2012-06-20 16:38:30 -0700693 // Fill out 'frm', after which we'll just hand the struct off to
694 // 'dot11fPackProbeResponse'.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530695 vos_mem_set(( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700696
697 // Timestamp to be updated by TFP, below.
698
699 // Beacon Interval:
Jeff Johnson295189b2012-06-20 16:38:30 -0700700 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
701 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700702 pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -0700703 }
704 else
705 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800706 nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg);
707 if (eSIR_SUCCESS != nSirStatus)
708 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700709 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d)."),
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800710 nSirStatus );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530711 vos_mem_free(pFrm);
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800712 return;
713 }
714 pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg;
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800715 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700716
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700717 PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry );
718 PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700719 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700720 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700721
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700722 PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry);
723 PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700724
Jeff Johnson295189b2012-06-20 16:38:30 -0700725
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
727 {
728 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
729 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700730 PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700731 }
732 }
733 else
734 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800735 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700736 limLog(pMac, LOGP,"Failed to cfg get id %d", WNI_CFG_WPS_ENABLE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700737
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800738 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
Jeff Johnson295189b2012-06-20 16:38:30 -0700739
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800740 if (wpsApEnable)
741 {
742 PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes);
743 }
744
745 if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
746 {
747 PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
748 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
749 }
750
751 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
752 {
753 DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
754 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
755 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700756 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700757
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700758 PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry);
759 PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700760
Jeff Johnson295189b2012-06-20 16:38:30 -0700761
762 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700763 PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700764
765
766 // N.B. In earlier implementations, the RSN IE would be placed in
767 // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined.
768 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700769 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700770
771 //Populate HT IEs, when operating in 11n or Taurus modes.
Jeff Johnsone7245742012-09-05 17:12:55 -0700772 if ( psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -0700773 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700774 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700775 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700776 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700777#ifdef WLAN_FEATURE_11AC
778 if(psessionEntry->vhtCapability)
779 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -0800780 limLog( pMac, LOG1, FL("Populate VHT IE in Probe Response"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700781 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
782 PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation );
Jeff Johnsone7245742012-09-05 17:12:55 -0700783 // we do not support multi users yet
784 //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad );
Sandeep Puligilla60342762014-01-30 21:05:37 +0530785 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -0700786 }
787#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700788
Sandeep Puligilla60342762014-01-30 21:05:37 +0530789
Jeff Johnson295189b2012-06-20 16:38:30 -0700790 if ( psessionEntry->pLimStartBssReq )
791 {
792 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700793 &pFrm->WPA );
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700794 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
795 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -0700796 }
797
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700798 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700799
800#if defined(FEATURE_WLAN_WAPI)
801 if( psessionEntry->pLimStartBssReq )
802 {
803 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700804 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700805 }
806
807#endif // defined(FEATURE_WLAN_WAPI)
808
Jeff Johnson295189b2012-06-20 16:38:30 -0700809 addnIEPresent = false;
Jeff Johnson295189b2012-06-20 16:38:30 -0700810 if( pMac->lim.gpLimRemainOnChanReq )
811 {
812 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
813 }
814 //Only use CFG for non-listen mode. This CFG is not working for concurrency
815 //In listening mode, probe rsp IEs is passed in the message from SME to PE
816 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700817 {
818
819 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
820 &addnIEPresent) != eSIR_SUCCESS)
821 {
822 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530823 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700824 return;
825 }
826 }
827
828 if (addnIEPresent)
829 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530830
831 addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3);
832 if ( NULL == addIE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700833 {
834 PELOGE(limLog(pMac, LOGE,
835 FL("Unable to allocate memory to store addn IE"));)
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530836 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700837 return;
838 }
839
840 //Probe rsp IE available
841 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
842 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
843 {
844 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530845 vos_mem_free(addIE);
846 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700847 return;
848 }
849 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
850 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
851 {
852 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
853 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
854 &addnIE1Len) )
855 {
856 limLog(pMac, LOGP,
857 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530858 vos_mem_free(addIE);
859 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700860 return;
861 }
862 }
863
864 //Probe rsp IE available
865 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
866 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
867 {
868 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530869 vos_mem_free(addIE);
870 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 return;
872 }
873 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
874 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
875 {
876 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
877 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
878 &addnIE2Len) )
879 {
880 limLog(pMac, LOGP,
881 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530882 vos_mem_free(addIE);
883 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700884 return;
885 }
886 }
887
888 //Probe rsp IE available
889 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
890 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
891 {
892 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530893 vos_mem_free(addIE);
894 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 return;
896 }
897 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
898 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
899 {
900 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
901 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
902 &addIE[addnIE1Len + addnIE2Len],
903 &addnIE3Len) )
904 {
905 limLog(pMac, LOGP,
906 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530907 vos_mem_free(addIE);
908 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700909 return;
910 }
911 }
912 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
913
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
915 {
916 limLog(pMac, LOGP,
917 FL("Unable to get final Additional IE for Probe Req"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530918 vos_mem_free(addIE);
919 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700920 return;
921 }
Kalikinkar dhara205da782014-03-21 15:49:32 -0700922
923 vos_mem_set(( tANI_U8* )&extractedExtCap,
924 sizeof( tDot11fIEExtCap ), 0);
925 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
926 addIE,
927 &totalAddnIeLen,
928 &extractedExtCap );
929 if(eSIR_SUCCESS != nSirStatus )
930 {
931 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
932 limLog(pMac, LOG1,
933 FL("Unable to Stripoff ExtCap IE from Probe Rsp"));
934 }
935
Jeff Johnson295189b2012-06-20 16:38:30 -0700936 nBytes = nBytes + totalAddnIeLen;
937
938 if (probeReqP2pIe)
939 {
940 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
941 if (pP2pIe != NULL)
942 {
943 //get NoA attribute stream P2P IE
944 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
945 if (noaLen != 0)
946 {
947 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
948 &noaStream[0], noaLen);
949 nBytes = nBytes + total_noaLen;
950 }
951 }
952 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700953 }
954
c_hpothubcd78652014-04-28 22:31:08 +0530955 /*merge ExtCap IE*/
956 if (extractedExtCapFlag && extractedExtCap.present)
957 {
958 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
959 }
960
961 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
962 if ( DOT11F_FAILED( nStatus ) )
963 {
964 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
965 "or a Probe Response (0x%08x)."),
966 nStatus );
967 // We'll fall back on the worst case scenario:
968 nPayload = sizeof( tDot11fProbeResponse );
969 }
970 else if ( DOT11F_WARNED( nStatus ) )
971 {
972 limLog( pMac, LOGW, FL("There were warnings while calculating"
973 "the packed size for a Probe Response "
974 "(0x%08x)."), nStatus );
975 }
976
977 nBytes += nPayload + sizeof( tSirMacMgmtHdr );
978
Jeff Johnson295189b2012-06-20 16:38:30 -0700979 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
980 ( tANI_U16 )nBytes, ( void** ) &pFrame,
981 ( void** ) &pPacket );
982 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
983 {
984 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700985 "be Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700986 if ( addIE != NULL )
987 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530988 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700989 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530990 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700991 return;
992 }
993
994 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530995 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700996
997 // Next, we fill out the buffer descriptor:
998 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
999 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
1000 if ( eSIR_SUCCESS != nSirStatus )
1001 {
1002 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001003 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001004 nSirStatus );
1005 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1006 ( void* ) pFrame, ( void* ) pPacket );
1007 if ( addIE != NULL )
1008 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301009 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001010 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301011 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07001012 return;
1013 }
1014
1015 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1016
1017 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1018
1019 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001020 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -07001021 nPayload, &nPayload );
1022 if ( DOT11F_FAILED( nStatus ) )
1023 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001024 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001025 nStatus );
1026 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1027 if ( addIE != NULL )
1028 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301029 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301031 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07001032 return; // allocated!
1033 }
1034 else if ( DOT11F_WARNED( nStatus ) )
1035 {
1036 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001037 "robe Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001038 }
1039
1040 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
1041 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1042
1043 pMac->sys.probeRespond++;
1044
Jeff Johnson295189b2012-06-20 16:38:30 -07001045 if( pMac->lim.gpLimRemainOnChanReq )
1046 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301047 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -07001048 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
1049 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001050
1051 if ( addnIEPresent )
1052 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301053 vos_mem_copy(pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], totalAddnIeLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001054 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001055 if (noaLen != 0)
1056 {
Krunal Soni81b24262013-05-15 17:46:41 -07001057 if (total_noaLen > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -07001058 {
1059 limLog(pMac, LOGE,
Kaushik, Sushant96ac9d72013-12-11 19:28:10 +05301060 FL("Not able to insert NoA because of length constraint."
1061 "Total Length is :%d"),total_noaLen);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301062 vos_mem_free(addIE);
1063 vos_mem_free(pFrm);
Krunal Soni81b24262013-05-15 17:46:41 -07001064 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1065 ( void* ) pFrame, ( void* ) pPacket );
1066 return;
1067 }
1068 else
1069 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301070 vos_mem_copy( &pFrame[nBytes - (total_noaLen)],
Krunal Soni81b24262013-05-15 17:46:41 -07001071 &noaIe[0], total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001072 }
1073 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001074
1075 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001076 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1077 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001078 )
1079 {
1080 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1081 }
1082
1083 // Queue Probe Response frame in high priority WQ
1084 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
1085 ( tANI_U16 ) nBytes,
1086 HAL_TXRX_FRM_802_11_MGMT,
1087 ANI_TXDIR_TODS,
1088 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
1089 limTxComplete, pFrame, txFlag );
1090 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1091 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001092 limLog( pMac, LOGE, FL("Could not send Probe Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001093 //Pkt will be freed up by the callback
1094 }
1095
1096 if ( addIE != NULL )
1097 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301098 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001099 }
1100
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301101 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001102 return;
1103
1104
Jeff Johnson295189b2012-06-20 16:38:30 -07001105} // End limSendProbeRspMgmtFrame.
1106
1107void
1108limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
1109 tSirMacAddr peerMacAddr,
1110 tSirAddtsReqInfo *pAddTS,
1111 tpPESession psessionEntry)
1112{
1113 tANI_U16 i;
1114 tANI_U8 *pFrame;
1115 tSirRetStatus nSirStatus;
1116 tDot11fAddTSRequest AddTSReq;
1117 tDot11fWMMAddTSRequest WMMAddTSReq;
1118 tANI_U32 nPayload, nBytes, nStatus;
1119 tpSirMacMgmtHdr pMacHdr;
1120 void *pPacket;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001121#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001122 tANI_U32 phyMode;
1123#endif
1124 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301125 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001126
1127 if(NULL == psessionEntry)
1128 {
1129 return;
1130 }
1131
1132 if ( ! pAddTS->wmeTspecPresent )
1133 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301134 vos_mem_set(( tANI_U8* )&AddTSReq, sizeof( AddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001135
1136 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1137 AddTSReq.DialogToken.token = pAddTS->dialogToken;
1138 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1139 if ( pAddTS->lleTspecPresent )
1140 {
1141 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
1142 }
1143 else
1144 {
1145 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
1146 }
1147
1148 if ( pAddTS->lleTspecPresent )
1149 {
1150 AddTSReq.num_WMMTCLAS = 0;
1151 AddTSReq.num_TCLAS = pAddTS->numTclas;
1152 for ( i = 0; i < pAddTS->numTclas; ++i)
1153 {
1154 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1155 &AddTSReq.TCLAS[i] );
1156 }
1157 }
1158 else
1159 {
1160 AddTSReq.num_TCLAS = 0;
1161 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
1162 for ( i = 0; i < pAddTS->numTclas; ++i)
1163 {
1164 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1165 &AddTSReq.WMMTCLAS[i] );
1166 }
1167 }
1168
1169 if ( pAddTS->tclasProcPresent )
1170 {
1171 if ( pAddTS->lleTspecPresent )
1172 {
1173 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
1174 AddTSReq.TCLASSPROC.present = 1;
1175 }
1176 else
1177 {
1178 AddTSReq.WMMTCLASPROC.version = 1;
1179 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
1180 AddTSReq.WMMTCLASPROC.present = 1;
1181 }
1182 }
1183
1184 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
1185 if ( DOT11F_FAILED( nStatus ) )
1186 {
1187 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001188 "or an Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001189 nStatus );
1190 // We'll fall back on the worst case scenario:
1191 nPayload = sizeof( tDot11fAddTSRequest );
1192 }
1193 else if ( DOT11F_WARNED( nStatus ) )
1194 {
1195 limLog( pMac, LOGW, FL("There were warnings while calculating"
1196 "the packed size for an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001197 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001198 }
1199 }
1200 else
1201 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301202 vos_mem_set(( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001203
1204 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1205 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1206 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1207
1208 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1209 WMMAddTSReq.StatusCode.statusCode = 0;
1210
1211 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001212#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001213 limGetPhyMode(pMac, &phyMode, psessionEntry);
1214
1215 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1216 {
1217 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1218 }
1219 else
1220 {
1221 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1222 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001223 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.ESETrafStrmRateSet,sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07001224#endif
1225 // fillWmeTspecIE
1226
1227 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1228 if ( DOT11F_FAILED( nStatus ) )
1229 {
1230 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001231 "or a WMM Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001232 nStatus );
1233 // We'll fall back on the worst case scenario:
1234 nPayload = sizeof( tDot11fAddTSRequest );
1235 }
1236 else if ( DOT11F_WARNED( nStatus ) )
1237 {
1238 limLog( pMac, LOGW, FL("There were warnings while calculating"
1239 "the packed size for a WMM Add TS Requ"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001240 "est (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001241 }
1242 }
1243
1244 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1245
1246 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1247 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1248 ( void** ) &pPacket );
1249 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1250 {
1251 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001252 "d TS Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001253 return;
1254 }
1255
1256 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301257 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001258
1259 // Next, we fill out the buffer descriptor:
1260 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1261 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1262 if ( eSIR_SUCCESS != nSirStatus )
1263 {
1264 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001265 "tor for an Add TS Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001266 nSirStatus );
1267 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1268 ( void* ) pFrame, ( void* ) pPacket );
1269 return;
1270 }
1271
1272 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1273
1274 #if 0
1275 cfgLen = SIR_MAC_ADDR_LENGTH;
1276 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1277 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1278 {
1279 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001280 "e sending an Add TS Request.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001281 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1282 ( void* ) pFrame, ( void* ) pPacket );
1283 return;
1284 }
1285 #endif //TO SUPPORT BT-AMP
1286
1287 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1288
Chet Lanctot186b5732013-03-18 10:26:30 -07001289#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001290 limSetProtectedBit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001291#endif
1292
Jeff Johnson295189b2012-06-20 16:38:30 -07001293 // That done, pack the struct:
1294 if ( ! pAddTS->wmeTspecPresent )
1295 {
1296 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1297 pFrame + sizeof(tSirMacMgmtHdr),
1298 nPayload, &nPayload );
1299 if ( DOT11F_FAILED( nStatus ) )
1300 {
1301 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001302 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001303 nStatus );
1304 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1305 return; // allocated!
1306 }
1307 else if ( DOT11F_WARNED( nStatus ) )
1308 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001309 limLog( pMac, LOGW, FL("There were warnings while packing "
1310 "an Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001311 }
1312 }
1313 else
1314 {
1315 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1316 pFrame + sizeof(tSirMacMgmtHdr),
1317 nPayload, &nPayload );
1318 if ( DOT11F_FAILED( nStatus ) )
1319 {
1320 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001321 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001322 nStatus );
1323 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1324 return; // allocated!
1325 }
1326 else if ( DOT11F_WARNED( nStatus ) )
1327 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001328 limLog( pMac, LOGW, FL("There were warnings while packing "
1329 "a WMM Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 }
1331 }
1332
1333 PELOG3(limLog( pMac, LOG3, FL("Sending an Add TS Request frame to ") );
1334 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1335
1336 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001337 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1338 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001339 )
1340 {
1341 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1342 }
1343
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301344 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1345 psessionEntry->peSessionId,
1346 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001347 // Queue Addts Response frame in high priority WQ
1348 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1349 HAL_TXRX_FRM_802_11_MGMT,
1350 ANI_TXDIR_TODS,
1351 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1352 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301353 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1354 psessionEntry->peSessionId,
1355 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001356 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1357 {
1358 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001359 " (%X) ***" ), halstatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001360 //Pkt will be freed up by the callback
1361 }
1362
1363} // End limSendAddtsReqActionFrame.
1364
Jeff Johnson295189b2012-06-20 16:38:30 -07001365
1366
1367void
1368limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1369 tANI_U16 statusCode,
1370 tANI_U16 aid,
1371 tSirMacAddr peerMacAddr,
1372 tANI_U8 subType,
1373 tpDphHashNode pSta,tpPESession psessionEntry)
1374{
1375 static tDot11fAssocResponse frm;
1376 tANI_U8 *pFrame, *macAddr;
1377 tpSirMacMgmtHdr pMacHdr;
1378 tSirRetStatus nSirStatus;
1379 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1380 tHalBitVal qosMode, wmeMode;
c_hpothubcd78652014-04-28 22:31:08 +05301381 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001382 void *pPacket;
1383 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301384 tUpdateBeaconParams beaconParams;
1385 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001386 tANI_U32 addnIEPresent = false;
1387 tANI_U32 addnIELen=0;
1388 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1389 tpSirAssocReq pAssocReq = NULL;
Kalikinkar dhara205da782014-03-21 15:49:32 -07001390 tANI_U16 addStripoffIELen = 0;
1391 tDot11fIEExtCap extractedExtCap;
1392 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_FALSE;
c_hpothubcd78652014-04-28 22:31:08 +05301393 tANI_U32 nBytes = 0;
Kalikinkar dhara205da782014-03-21 15:49:32 -07001394
Chet Lanctot8cecea22014-02-11 19:09:36 -08001395#ifdef WLAN_FEATURE_11W
1396 tANI_U32 retryInterval;
1397 tANI_U32 maxRetries;
1398#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001399
1400 if(NULL == psessionEntry)
1401 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301402 limLog( pMac, LOGE, FL("psessionEntry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001403 return;
1404 }
1405
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301406 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001407
1408 limGetQosMode(psessionEntry, &qosMode);
1409 limGetWmeMode(psessionEntry, &wmeMode);
1410
1411 // An Add TS IE is added only if the AP supports it and the requesting
1412 // STA sent a traffic spec.
1413 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1414
1415 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1416
1417 frm.Status.status = statusCode;
1418
1419 frm.AID.associd = aid | LIM_AID_MASK;
1420
1421 if ( NULL == pSta )
1422 {
1423 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1424 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1425 }
1426 else
1427 {
1428 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1429 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1430 }
1431
Jeff Johnson295189b2012-06-20 16:38:30 -07001432 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1433 {
1434 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1435 {
1436 pAssocReq =
1437 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001438 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1439 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1440 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1441 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001442 }
1443 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001444
1445 if ( NULL != pSta )
1446 {
1447 if ( eHAL_SET == qosMode )
1448 {
1449 if ( pSta->lleEnabled )
1450 {
1451 lleMode = 1;
1452 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1453 {
1454 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1455
1456// FramesToDo:...
1457// if ( fAddTS )
1458// {
1459// tANI_U8 *pAf = pBody;
1460// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1461// tANI_U32 tlen;
1462// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1463// &tlen, bufLen - frameLen);
1464// } // End if on Add TS.
1465 }
1466 } // End if on .11e enabled in 'pSta'.
1467 } // End if on QOS Mode on.
1468
1469 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1470 {
1471 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1472 {
1473
Jeff Johnson295189b2012-06-20 16:38:30 -07001474 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001475
1476 if ( pSta->wsmEnabled )
1477 {
1478 PopulateDot11fWMMCaps(&frm.WMMCaps );
1479 }
1480 }
1481 }
1482
1483 if ( pSta->aniPeer )
1484 {
1485 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1486 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1487 {
1488 edcaInclude = 1;
1489 }
1490
1491 } // End if on Airgo peer.
1492
1493 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001494 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001495 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001496 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07001497 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001498 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001499
1500#ifdef WLAN_FEATURE_11AC
1501 if( pSta->mlmStaContext.vhtCapability &&
1502 psessionEntry->vhtCapability )
1503 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08001504 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Response"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001505 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
1506 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation);
Sandeep Puligilla60342762014-01-30 21:05:37 +05301507 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001508 }
1509#endif
1510
Chet Lanctot8cecea22014-02-11 19:09:36 -08001511#ifdef WLAN_FEATURE_11W
Dino Myclea7f18452014-04-24 08:55:31 +05301512 if( eSIR_MAC_TRY_AGAIN_LATER == statusCode )
1513 {
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001514 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_MAX_RETRIES,
1515 &maxRetries ) != eSIR_SUCCESS )
1516 limLog( pMac, LOGE,
1517 FL("Could not retrieve PMF SA Query maximum retries value") );
1518 else
1519 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL,
1520 &retryInterval ) != eSIR_SUCCESS)
1521 limLog( pMac, LOGE,
1522 FL("Could not retrieve PMF SA Query timer interval value") );
Dino Myclea7f18452014-04-24 08:55:31 +05301523 else
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001524 PopulateDot11fTimeoutInterval(
1525 pMac, &frm.TimeoutInterval, SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1526 (maxRetries - pSta->pmfSaQueryRetryCount) * retryInterval );
Dino Myclea7f18452014-04-24 08:55:31 +05301527 }
Chet Lanctot8cecea22014-02-11 19:09:36 -08001528#endif
Dino Myclea7f18452014-04-24 08:55:31 +05301529 } // End if on non-NULL 'pSta'.
Jeff Johnson295189b2012-06-20 16:38:30 -07001530
Chet Lanctot8cecea22014-02-11 19:09:36 -08001531 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001532
Jeff Johnson295189b2012-06-20 16:38:30 -07001533 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1534 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1535 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1536 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001537
1538 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1539 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1540
1541 beaconParams.bssIdx = psessionEntry->bssIdx;
1542
1543 //Send message to HAL about beacon parameter change.
1544 if(beaconParams.paramChangeBitmap)
1545 {
1546 schSetFixedBeaconFields(pMac,psessionEntry);
1547 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1548 }
1549
Jeff Johnson295189b2012-06-20 16:38:30 -07001550 if ( pAssocReq != NULL )
1551 {
1552 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1553 &addnIEPresent) != eSIR_SUCCESS)
1554 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301555 limLog(pMac, LOGP, FL("Unable to get "
1556 "WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 return;
1558 }
1559
1560 if (addnIEPresent)
1561 {
1562 //Assoc rsp IE available
1563 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1564 &addnIELen) != eSIR_SUCCESS)
1565 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301566 limLog(pMac, LOGP, FL("Unable to get "
1567 "WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001568 return;
1569 }
1570
1571 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1572 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1573 {
1574 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1575 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1576 {
Kalikinkar dhara205da782014-03-21 15:49:32 -07001577
1578 vos_mem_set(( tANI_U8* )&extractedExtCap,
1579 sizeof( tDot11fIEExtCap ), 0);
1580 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
1581 &addIE[0],
1582 &addStripoffIELen,
1583 &extractedExtCap );
1584 if(eSIR_SUCCESS != nSirStatus)
1585 {
1586 limLog(pMac, LOG1,
1587 FL("Unable to Stripoff ExtCap IE from Assoc Rsp"));
1588 }
1589 else
1590 {
1591 addnIELen = addStripoffIELen;
1592 extractedExtCapFlag = eANI_BOOLEAN_TRUE;
1593 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001594 nBytes = nBytes + addnIELen;
1595 }
1596 }
1597 }
1598 }
1599
c_hpothubcd78652014-04-28 22:31:08 +05301600 /* merge the ExtCap struct*/
1601 if (extractedExtCapFlag && extractedExtCap.present)
1602 {
1603 limMergeExtCapIEStruct(&(frm.ExtCap), &extractedExtCap);
1604 }
1605
1606 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1607 if ( DOT11F_FAILED( nStatus ) )
1608 {
1609 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
1610 "or an Association Response (0x%08x)."),
1611 nStatus );
1612 return;
1613 }
1614 else if ( DOT11F_WARNED( nStatus ) )
1615 {
1616 limLog( pMac, LOGW, FL("There were warnings while calculating "
1617 "the packed size for an Association Re"
1618 "sponse (0x%08x)."), nStatus );
1619 }
1620
1621 nBytes += sizeof( tSirMacMgmtHdr ) + nPayload;
1622
Jeff Johnson295189b2012-06-20 16:38:30 -07001623 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1624 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1625 ( void** ) &pPacket );
1626 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1627 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001628 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001629 return;
1630 }
1631
1632 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301633 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001634
1635 // Next, we fill out the buffer descriptor:
1636 nSirStatus = limPopulateMacHeader( pMac,
1637 pFrame,
1638 SIR_MAC_MGMT_FRAME,
1639 ( LIM_ASSOC == subType ) ?
1640 SIR_MAC_MGMT_ASSOC_RSP :
1641 SIR_MAC_MGMT_REASSOC_RSP,
1642 peerMacAddr,psessionEntry->selfMacAddr);
1643 if ( eSIR_SUCCESS != nSirStatus )
1644 {
1645 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001646 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001647 nSirStatus );
1648 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1649 ( void* ) pFrame, ( void* ) pPacket );
1650 return;
1651 }
1652
1653 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1654
Jeff Johnson295189b2012-06-20 16:38:30 -07001655 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1656
1657 nStatus = dot11fPackAssocResponse( pMac, &frm,
1658 pFrame + sizeof( tSirMacMgmtHdr ),
1659 nPayload, &nPayload );
1660 if ( DOT11F_FAILED( nStatus ) )
1661 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301662 limLog( pMac, LOGE, FL("Failed to pack an Association Response"
1663 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001664 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1665 ( void* ) pFrame, ( void* ) pPacket );
1666 return; // allocated!
1667 }
1668 else if ( DOT11F_WARNED( nStatus ) )
1669 {
1670 limLog( pMac, LOGW, FL("There were warnings while packing an "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001671 "Association Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001672 }
1673
1674 macAddr = pMacHdr->da;
1675
1676 if (subType == LIM_ASSOC)
1677 {
1678 PELOG1(limLog(pMac, LOG1,
1679 FL("*** Sending Assoc Resp status %d aid %d to "),
1680 statusCode, aid);)
1681 }
1682 else{
1683 PELOG1(limLog(pMac, LOG1,
1684 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1685 statusCode, aid);)
1686 }
1687 PELOG1(limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1688
1689 if ( addnIEPresent )
1690 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301691 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 }
1693
1694 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001695 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1696 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001697 )
1698 {
1699 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1700 }
1701
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05301702 limLog( pMac, LOG1, FL("Sending Assoc resp over WQ5 to "MAC_ADDRESS_STR
1703 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
1704 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
1705
1706 txFlag |= HAL_USE_FW_IN_TX_PATH;
1707
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301708 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1709 psessionEntry->peSessionId,
1710 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 /// Queue Association Response frame in high priority WQ
1712 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1713 HAL_TXRX_FRM_802_11_MGMT,
1714 ANI_TXDIR_TODS,
1715 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1716 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301717 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1718 psessionEntry->peSessionId,
1719 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001720 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1721 {
1722 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001723 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001724 nSirStatus);
1725
1726 //Pkt will be freed up by the callback
1727 }
1728
1729 // update the ANI peer station count
1730 //FIXME_PROTECTION : take care of different type of station
1731 // counter inside this function.
1732 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1733
1734} // End limSendAssocRspMgmtFrame.
1735
1736
1737
1738void
1739limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1740 tSirMacAddr peer,
1741 tANI_U16 nStatusCode,
1742 tSirAddtsReqInfo *pAddTS,
1743 tSirMacScheduleIE *pSchedule,
1744 tpPESession psessionEntry)
1745{
1746 tANI_U8 *pFrame;
1747 tpSirMacMgmtHdr pMacHdr;
1748 tDot11fAddTSResponse AddTSRsp;
1749 tDot11fWMMAddTSResponse WMMAddTSRsp;
1750 tSirRetStatus nSirStatus;
1751 tANI_U32 i, nBytes, nPayload, nStatus;
1752 void *pPacket;
1753 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301754 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001755
1756 if(NULL == psessionEntry)
1757 {
1758 return;
1759 }
1760
1761 if ( ! pAddTS->wmeTspecPresent )
1762 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301763 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001764
1765 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1766 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1767 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1768 AddTSRsp.Status.status = nStatusCode;
1769
1770 // The TsDelay information element is only filled in for a specific
1771 // status code:
1772 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1773 {
1774 if ( pAddTS->wsmTspecPresent )
1775 {
1776 AddTSRsp.WMMTSDelay.version = 1;
1777 AddTSRsp.WMMTSDelay.delay = 10;
1778 AddTSRsp.WMMTSDelay.present = 1;
1779 }
1780 else
1781 {
1782 AddTSRsp.TSDelay.delay = 10;
1783 AddTSRsp.TSDelay.present = 1;
1784 }
1785 }
1786
1787 if ( pAddTS->wsmTspecPresent )
1788 {
1789 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1790 }
1791 else
1792 {
1793 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1794 }
1795
1796 if ( pAddTS->wsmTspecPresent )
1797 {
1798 AddTSRsp.num_WMMTCLAS = 0;
1799 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1800 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1801 {
1802 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1803 &AddTSRsp.TCLAS[i] );
1804 }
1805 }
1806 else
1807 {
1808 AddTSRsp.num_TCLAS = 0;
1809 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1810 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1811 {
1812 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1813 &AddTSRsp.WMMTCLAS[i] );
1814 }
1815 }
1816
1817 if ( pAddTS->tclasProcPresent )
1818 {
1819 if ( pAddTS->wsmTspecPresent )
1820 {
1821 AddTSRsp.WMMTCLASPROC.version = 1;
1822 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1823 AddTSRsp.WMMTCLASPROC.present = 1;
1824 }
1825 else
1826 {
1827 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1828 AddTSRsp.TCLASSPROC.present = 1;
1829 }
1830 }
1831
1832 // schedule element is included only if requested in the tspec and we are
1833 // using hcca (or both edca and hcca)
1834 // 11e-D8.0 is inconsistent on whether the schedule element is included
1835 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1836 // pg 46, line 17-18 says something else. So just include it and let the
1837 // sta figure it out
1838 if ((pSchedule != NULL) &&
1839 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1840 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1841 {
1842 if ( pAddTS->wsmTspecPresent )
1843 {
1844 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1845 }
1846 else
1847 {
1848 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1849 }
1850 }
1851
1852 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1853 if ( DOT11F_FAILED( nStatus ) )
1854 {
1855 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001856 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001857 nStatus );
1858 // We'll fall back on the worst case scenario:
1859 nPayload = sizeof( tDot11fAddTSResponse );
1860 }
1861 else if ( DOT11F_WARNED( nStatus ) )
1862 {
1863 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001864 "ting the packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001865 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001866 }
1867 }
1868 else
1869 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301870 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001871
1872 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1873 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1874 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1875 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1876
1877 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1878
1879 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1880 if ( DOT11F_FAILED( nStatus ) )
1881 {
1882 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001883 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001884 nStatus );
1885 // We'll fall back on the worst case scenario:
1886 nPayload = sizeof( tDot11fWMMAddTSResponse );
1887 }
1888 else if ( DOT11F_WARNED( nStatus ) )
1889 {
1890 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001891 "ting the packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001892 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001893 }
1894 }
1895
1896 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1897
1898 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1899 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1900 {
1901 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001902 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001903 return;
1904 }
1905
1906 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301907 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001908
1909 // Next, we fill out the buffer descriptor:
1910 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1911 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1912 if ( eSIR_SUCCESS != nSirStatus )
1913 {
1914 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001915 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001916 nSirStatus );
1917 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1918 return; // allocated!
1919 }
1920
1921 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1922
1923
1924 #if 0
1925 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1926 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1927 {
1928 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001929 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001930 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1931 return; // allocated!
1932 }
1933 #endif //TO SUPPORT BT-AMP
1934 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1935
Chet Lanctot186b5732013-03-18 10:26:30 -07001936#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001937 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001938#endif
1939
Jeff Johnson295189b2012-06-20 16:38:30 -07001940 // That done, pack the struct:
1941 if ( ! pAddTS->wmeTspecPresent )
1942 {
1943 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1944 pFrame + sizeof( tSirMacMgmtHdr ),
1945 nPayload, &nPayload );
1946 if ( DOT11F_FAILED( nStatus ) )
1947 {
1948 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001949 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001950 nStatus );
1951 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1952 return;
1953 }
1954 else if ( DOT11F_WARNED( nStatus ) )
1955 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001956 limLog( pMac, LOGW, FL("There were warnings while packing "
1957 "an Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001958 }
1959 }
1960 else
1961 {
1962 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
1963 pFrame + sizeof( tSirMacMgmtHdr ),
1964 nPayload, &nPayload );
1965 if ( DOT11F_FAILED( nStatus ) )
1966 {
1967 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001968 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001969 nStatus );
1970 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1971 return;
1972 }
1973 else if ( DOT11F_WARNED( nStatus ) )
1974 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001975 limLog( pMac, LOGW, FL("There were warnings while packing "
1976 "a WMM Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001977 }
1978 }
1979
1980 PELOG1(limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
1981 nStatusCode );
1982 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
1983
1984 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001985 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1986 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001987 )
1988 {
1989 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1990 }
1991
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301992 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1993 psessionEntry->peSessionId,
1994 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001995 // Queue the frame in high priority WQ:
1996 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1997 HAL_TXRX_FRM_802_11_MGMT,
1998 ANI_TXDIR_TODS,
1999 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2000 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302001 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2002 psessionEntry->peSessionId,
2003 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002004 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2005 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002006 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002007 nSirStatus );
2008 //Pkt will be freed up by the callback
2009 }
2010
2011} // End limSendAddtsRspActionFrame.
2012
2013void
2014limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
2015 tSirMacAddr peer,
2016 tANI_U8 wmmTspecPresent,
2017 tSirMacTSInfo *pTsinfo,
2018 tSirMacTspecIE *pTspecIe,
2019 tpPESession psessionEntry)
2020{
2021 tANI_U8 *pFrame;
2022 tpSirMacMgmtHdr pMacHdr;
2023 tDot11fDelTS DelTS;
2024 tDot11fWMMDelTS WMMDelTS;
2025 tSirRetStatus nSirStatus;
2026 tANI_U32 nBytes, nPayload, nStatus;
2027 void *pPacket;
2028 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302029 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002030
2031 if(NULL == psessionEntry)
2032 {
2033 return;
2034 }
2035
2036 if ( ! wmmTspecPresent )
2037 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302038 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002039
2040 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
2041 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2042 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
2043
2044 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
2045 if ( DOT11F_FAILED( nStatus ) )
2046 {
2047 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002048 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002049 nStatus );
2050 // We'll fall back on the worst case scenario:
2051 nPayload = sizeof( tDot11fDelTS );
2052 }
2053 else if ( DOT11F_WARNED( nStatus ) )
2054 {
2055 limLog( pMac, LOGW, FL("There were warnings while calcula"
2056 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002057 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 }
2059 }
2060 else
2061 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302062 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002063
2064 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
2065 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2066 WMMDelTS.DialogToken.token = 0;
2067 WMMDelTS.StatusCode.statusCode = 0;
2068 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
2069 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
2070 if ( DOT11F_FAILED( nStatus ) )
2071 {
2072 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002073 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002074 nStatus );
2075 // We'll fall back on the worst case scenario:
2076 nPayload = sizeof( tDot11fDelTS );
2077 }
2078 else if ( DOT11F_WARNED( nStatus ) )
2079 {
2080 limLog( pMac, LOGW, FL("There were warnings while calcula"
2081 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002082 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002083 }
2084 }
2085
2086 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
2087
2088 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
2089 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2090 {
2091 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002092 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002093 return;
2094 }
2095
2096 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302097 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002098
2099 // Next, we fill out the buffer descriptor:
2100 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2101 SIR_MAC_MGMT_ACTION, peer,
2102 psessionEntry->selfMacAddr);
2103 if ( eSIR_SUCCESS != nSirStatus )
2104 {
2105 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002106 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002107 nSirStatus );
2108 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2109 return; // allocated!
2110 }
2111
2112 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
2113
2114 #if 0
2115
2116 cfgLen = SIR_MAC_ADDR_LENGTH;
2117 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
2118 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
2119 {
2120 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002121 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2123 return; // allocated!
2124 }
2125 #endif //TO SUPPORT BT-AMP
2126 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
2127
Chet Lanctot186b5732013-03-18 10:26:30 -07002128#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002129 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07002130#endif
2131
Jeff Johnson295189b2012-06-20 16:38:30 -07002132 // That done, pack the struct:
2133 if ( !wmmTspecPresent )
2134 {
2135 nStatus = dot11fPackDelTS( pMac, &DelTS,
2136 pFrame + sizeof( tSirMacMgmtHdr ),
2137 nPayload, &nPayload );
2138 if ( DOT11F_FAILED( nStatus ) )
2139 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002140 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002141 nStatus );
2142 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2143 return; // allocated!
2144 }
2145 else if ( DOT11F_WARNED( nStatus ) )
2146 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002147 limLog( pMac, LOGW, FL("There were warnings while packing "
2148 "a Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002149 }
2150 }
2151 else
2152 {
2153 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
2154 pFrame + sizeof( tSirMacMgmtHdr ),
2155 nPayload, &nPayload );
2156 if ( DOT11F_FAILED( nStatus ) )
2157 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002158 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 nStatus );
2160 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2161 return; // allocated!
2162 }
2163 else if ( DOT11F_WARNED( nStatus ) )
2164 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002165 limLog( pMac, LOGW, FL("There were warnings while packing "
2166 "a WMM Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002167 }
2168 }
2169
2170 PELOG1(limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
2171 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
2172
2173 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002174 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2175 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002176 )
2177 {
2178 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2179 }
2180
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302181 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2182 psessionEntry->peSessionId,
2183 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2185 HAL_TXRX_FRM_802_11_MGMT,
2186 ANI_TXDIR_TODS,
2187 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2188 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302189 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2190 psessionEntry->peSessionId,
2191 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002192 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2193 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002194 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002195 nSirStatus );
2196 //Pkt will be freed up by the callback
2197 }
2198
2199} // End limSendDeltsReqActionFrame.
2200
2201void
2202limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
2203 tLimMlmAssocReq *pMlmAssocReq,
2204 tpPESession psessionEntry)
2205{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002206 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07002207 tANI_U16 caps;
2208 tANI_U8 *pFrame;
2209 tSirRetStatus nSirStatus;
2210 tLimMlmAssocCnf mlmAssocCnf;
c_hpothubcd78652014-04-28 22:31:08 +05302211 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07002212 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2213 void *pPacket;
2214 eHalStatus halstatus;
2215 tANI_U16 nAddIELen;
2216 tANI_U8 *pAddIE;
2217 tANI_U8 *wpsIe = NULL;
2218#if defined WLAN_FEATURE_VOWIFI
2219 tANI_U8 PowerCapsPopulated = FALSE;
2220#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302221 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302222 tpSirMacMgmtHdr pMacHdr;
Kalikinkar dhara205da782014-03-21 15:49:32 -07002223 tDot11fIEExtCap extractedExtCap;
2224 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +05302225 tANI_U32 nBytes = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002226
2227 if(NULL == psessionEntry)
2228 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302229 limLog(pMac, LOGE, FL("psessionEntry is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002230 return;
2231 }
2232
Jeff Johnson295189b2012-06-20 16:38:30 -07002233 /* check this early to avoid unncessary operation */
2234 if(NULL == psessionEntry->pLimJoinReq)
2235 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302236 limLog(pMac, LOGE, FL("psessionEntry->pLimJoinReq is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002237 return;
2238 }
2239 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
2240 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
2241
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302242 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
2243 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002244 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302245 limLog(pMac, LOGE, FL("Unable to allocate memory") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002246 return;
2247 }
2248
2249
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302250 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002251
Kalikinkar dhara205da782014-03-21 15:49:32 -07002252 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
2253 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac, pAddIE,
2254 &nAddIELen,
2255 &extractedExtCap );
2256 if(eSIR_SUCCESS != nSirStatus )
2257 {
2258 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
2259 limLog(pMac, LOG1,
2260 FL("Unable to Stripoff ExtCap IE from Assoc Req"));
2261 }
2262
Jeff Johnson295189b2012-06-20 16:38:30 -07002263 caps = pMlmAssocReq->capabilityInfo;
2264 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2265 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2266#if defined(FEATURE_WLAN_WAPI)
2267 /* CR: 262463 :
2268 According to WAPI standard:
2269 7.3.1.4 Capability Information field
2270 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2271 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2272 Reassociation management frames. */
2273 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2274 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2275#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002276 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002277
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002278 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2279 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002281 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002282
2283 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2284 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2285
2286 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2287 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2288
2289 // We prefer .11e asociations:
2290 if ( fQosEnabled ) fWmeEnabled = false;
2291
2292 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2293 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2294
2295 if ( psessionEntry->lim11hEnable &&
2296 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2297 {
2298#if defined WLAN_FEATURE_VOWIFI
2299 PowerCapsPopulated = TRUE;
2300
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002301 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002302#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002303 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002304
2305 }
2306
2307#if defined WLAN_FEATURE_VOWIFI
2308 if( pMac->rrm.rrmPEContext.rrmEnable &&
2309 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2310 {
2311 if (PowerCapsPopulated == FALSE)
2312 {
2313 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002314 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002315 }
2316 }
2317#endif
2318
2319 if ( fQosEnabled &&
2320 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002321 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002322
2323 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002324 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002325
2326#if defined WLAN_FEATURE_VOWIFI
2327 if( pMac->rrm.rrmPEContext.rrmEnable &&
2328 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2329 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002330 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002331 }
2332#endif
2333 // The join request *should* contain zero or one of the WPA and RSN
2334 // IEs. The payload send along with the request is a
2335 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2336
2337 // typedef struct sSirRSNie
2338 // {
2339 // tANI_U16 length;
2340 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2341 // } tSirRSNie, *tpSirRSNie;
2342
2343 // So, we should be able to make the following two calls harmlessly,
2344 // since they do nothing if they don't find the given IE in the
2345 // bytestream with which they're provided.
2346
2347 // The net effect of this will be to faithfully transmit whatever
2348 // security IE is in the join request.
2349
2350 // *However*, if we're associating for the purpose of WPS
2351 // enrollment, and we've been configured to indicate that by
2352 // eliding the WPA or RSN IE, we just skip this:
2353 if( nAddIELen && pAddIE )
2354 {
2355 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2356 }
2357 if ( NULL == wpsIe )
2358 {
2359 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002360 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002361 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002362 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002363#if defined(FEATURE_WLAN_WAPI)
2364 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002365 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002366#endif // defined(FEATURE_WLAN_WAPI)
2367 }
2368
2369 // include WME EDCA IE as well
2370 if ( fWmeEnabled )
2371 {
2372 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2373 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002374 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002375 }
2376
2377 if ( fWsmEnabled &&
2378 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2379 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002380 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002381 }
2382 }
2383
2384 //Populate HT IEs, when operating in 11n or Taurus modes AND
2385 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002386 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002387 pMac->lim.htCapabilityPresentInBeacon)
2388 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002389 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002390#ifdef DISABLE_GF_FOR_INTEROP
2391
2392 /*
2393 * To resolve the interop problem with Broadcom AP,
2394 * where TQ STA could not pass traffic with GF enabled,
2395 * TQ STA will do Greenfield only with TQ AP, for
2396 * everybody else it will be turned off.
2397 */
2398
2399 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2400 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302401 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP,"
2402 " Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002403 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002404 }
2405#endif
2406
2407 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002408#ifdef WLAN_FEATURE_11AC
2409 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002410 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002411 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002412 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002413 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
Jeff Johnsone7245742012-09-05 17:12:55 -07002414 }
2415#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302416 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002417
2418#if defined WLAN_FEATURE_VOWIFI_11R
2419 if (psessionEntry->pLimJoinReq->is11Rconnection)
2420 {
2421#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002422 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002423 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2424 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2425 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2426#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302427 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2428 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002429 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302430 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002431 {
2432 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302433 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002434 }
2435#endif
2436
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002437#ifdef FEATURE_WLAN_ESE
2438 /* For ESE Associations fill the ESE IEs */
2439 if (psessionEntry->isESEconnection &&
2440 psessionEntry->pLimJoinReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002441 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002442#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002443 PopulateDot11fESERadMgmtCap(&pFrm->ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002444#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002445 PopulateDot11fESEVersion(&pFrm->ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002446 }
2447#endif
2448
c_hpothubcd78652014-04-28 22:31:08 +05302449 /* merge the ExtCap struct*/
2450 if (extractedExtCapFlag && extractedExtCap.present)
2451 {
2452 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
2453 }
2454
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002455 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002456 if ( DOT11F_FAILED( nStatus ) )
2457 {
2458 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002459 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002460 nStatus );
2461 // We'll fall back on the worst case scenario:
2462 nPayload = sizeof( tDot11fAssocRequest );
2463 }
2464 else if ( DOT11F_WARNED( nStatus ) )
2465 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002466 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002467 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002468 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002469 }
2470
2471 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2472
2473 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2474 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2475 ( void** ) &pPacket );
2476 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2477 {
2478 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002479 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002480
2481 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002482 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002483
2484
2485 /* Update PE session id*/
2486 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2487
2488 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2489
2490 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2491 ( void* ) pFrame, ( void* ) pPacket );
2492
2493 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2494 ( tANI_U32* ) &mlmAssocCnf);
2495
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302496 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002497 return;
2498 }
2499
2500 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302501 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002502
2503 // Next, we fill out the buffer descriptor:
2504 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2505 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2506 if ( eSIR_SUCCESS != nSirStatus )
2507 {
2508 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002509 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002510 nSirStatus );
2511 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302512 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002513 return;
2514 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002515
Abhishek Singh57aebef2014-02-03 18:47:44 +05302516 // That done, pack the Assoc Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002517 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002518 sizeof(tSirMacMgmtHdr),
2519 nPayload, &nPayload );
2520 if ( DOT11F_FAILED( nStatus ) )
2521 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302522 limLog( pMac, LOGE, FL("Failed to pack a Assoc Request (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002523 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002524 nStatus );
2525 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2526 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302527 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002528 return;
2529 }
2530 else if ( DOT11F_WARNED( nStatus ) )
2531 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302532 limLog( pMac, LOGW, FL("There were warnings while packing a Assoc"
2533 "Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002534 }
2535
2536 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002537 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002538 nBytes );)
2539 // limPrintMacAddr( pMac, bssid, LOG1 );
2540
2541 if( psessionEntry->assocReq != NULL )
2542 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302543 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 psessionEntry->assocReq = NULL;
2545 }
2546
2547 if( nAddIELen )
2548 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302549 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2550 pAddIE,
2551 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 nPayload += nAddIELen;
2553 }
2554
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302555 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2556 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002557 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302558 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store "
2559 "assoc request"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002560 }
2561 else
2562 {
2563 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302564 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002565 psessionEntry->assocReqLen = nPayload;
2566 }
2567
2568 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002569 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2570 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002571 )
2572 {
2573 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2574 }
2575
Ganesh K08bce952012-12-13 15:04:41 -08002576 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2577 {
2578 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2579 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302580
2581 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05302582 limLog( pMac, LOG1, FL("Sending Assoc req over WQ5 to "MAC_ADDRESS_STR
2583 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
2584 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2585 txFlag |= HAL_USE_FW_IN_TX_PATH;
2586
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302587 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2588 psessionEntry->peSessionId,
2589 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2591 HAL_TXRX_FRM_802_11_MGMT,
2592 ANI_TXDIR_TODS,
2593 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2594 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302595 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2596 psessionEntry->peSessionId,
2597 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002598 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2599 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002600 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002601 halstatus );
2602 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302603 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002604 return;
2605 }
2606
2607 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302608 vos_mem_free(pMlmAssocReq);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002609 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302610 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002611 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002612} // End limSendAssocReqMgmtFrame
2613
2614
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002615#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002616/*------------------------------------------------------------------------------------
2617 *
2618 * Send Reassoc Req with FTIEs.
2619 *
2620 *-----------------------------------------------------------------------------------
2621 */
2622void
2623limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2624 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2625{
2626 static tDot11fReAssocRequest frm;
2627 tANI_U16 caps;
2628 tANI_U8 *pFrame;
2629 tSirRetStatus nSirStatus;
2630 tANI_U32 nBytes, nPayload, nStatus;
2631 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2632 void *pPacket;
2633 eHalStatus halstatus;
2634#if defined WLAN_FEATURE_VOWIFI
2635 tANI_U8 PowerCapsPopulated = FALSE;
2636#endif
2637 tANI_U16 ft_ies_length = 0;
2638 tANI_U8 *pBody;
2639 tANI_U16 nAddIELen;
2640 tANI_U8 *pAddIE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002641#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002642 tANI_U8 *wpsIe = NULL;
2643#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302644 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302645 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002646
2647 if (NULL == psessionEntry)
2648 {
2649 return;
2650 }
2651
Jeff Johnson295189b2012-06-20 16:38:30 -07002652 /* check this early to avoid unncessary operation */
2653 if(NULL == psessionEntry->pLimReAssocReq)
2654 {
2655 return;
2656 }
2657 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2658 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002659 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2660 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002661
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302662 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002663
2664 caps = pMlmReassocReq->capabilityInfo;
2665 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2666 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2667#if defined(FEATURE_WLAN_WAPI)
2668 /* CR: 262463 :
2669 According to WAPI standard:
2670 7.3.1.4 Capability Information field
2671 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2672 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2673 Reassociation management frames. */
2674 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2675 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2676#endif
2677 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2678
2679 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2680
2681 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302682 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2684
2685 PopulateDot11fSSID2( pMac, &frm.SSID );
2686 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2687 &frm.SuppRates,psessionEntry);
2688
2689 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2690 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2691
2692 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2693 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2694
2695 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2696 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2697
2698 if ( psessionEntry->lim11hEnable &&
2699 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2700 {
2701#if defined WLAN_FEATURE_VOWIFI
2702 PowerCapsPopulated = TRUE;
2703
2704 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2705 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2706#endif
2707 }
2708
2709#if defined WLAN_FEATURE_VOWIFI
2710 if( pMac->rrm.rrmPEContext.rrmEnable &&
2711 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2712 {
2713 if (PowerCapsPopulated == FALSE)
2714 {
2715 PowerCapsPopulated = TRUE;
2716 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2717 }
2718 }
2719#endif
2720
2721 if ( fQosEnabled &&
2722 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2723 {
2724 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2725 }
2726
2727 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2728 &frm.ExtSuppRates, psessionEntry );
2729
2730#if defined WLAN_FEATURE_VOWIFI
2731 if( pMac->rrm.rrmPEContext.rrmEnable &&
2732 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2733 {
2734 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2735 }
2736#endif
2737
2738 // Ideally this should be enabled for 11r also. But 11r does
2739 // not follow the usual norm of using the Opaque object
2740 // for rsnie and fties. Instead we just add
2741 // the rsnie and fties at the end of the pack routine for 11r.
2742 // This should ideally! be fixed.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002743#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002744 //
2745 // The join request *should* contain zero or one of the WPA and RSN
2746 // IEs. The payload send along with the request is a
2747 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2748
2749 // typedef struct sSirRSNie
2750 // {
2751 // tANI_U16 length;
2752 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2753 // } tSirRSNie, *tpSirRSNie;
2754
2755 // So, we should be able to make the following two calls harmlessly,
2756 // since they do nothing if they don't find the given IE in the
2757 // bytestream with which they're provided.
2758
2759 // The net effect of this will be to faithfully transmit whatever
2760 // security IE is in the join request.
2761
2762 // *However*, if we're associating for the purpose of WPS
2763 // enrollment, and we've been configured to indicate that by
2764 // eliding the WPA or RSN IE, we just skip this:
2765 if (!psessionEntry->is11Rconnection)
2766 {
2767 if( nAddIELen && pAddIE )
2768 {
2769 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2770 }
2771 if ( NULL == wpsIe )
2772 {
2773 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2774 &frm.RSNOpaque );
2775 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2776 &frm.WPAOpaque );
2777 }
2778
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002779#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302780 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002781 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002782 PopulateDot11fESECckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2783 &frm.ESECckmOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002784 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002785#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002786 }
2787
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002788#ifdef FEATURE_WLAN_ESE
2789 // For ESE Associations fill the ESE IEs
2790 if (psessionEntry->isESEconnection &&
2791 psessionEntry->pLimReAssocReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002792 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002793#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002794 PopulateDot11fESERadMgmtCap(&frm.ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002795#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002796 PopulateDot11fESEVersion(&frm.ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002797 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002798#endif //FEATURE_WLAN_ESE
2799#endif //FEATURE_WLAN_ESE || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002800
2801 // include WME EDCA IE as well
2802 if ( fWmeEnabled )
2803 {
2804 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2805 {
2806 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2807 }
2808
2809 if ( fWsmEnabled &&
2810 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2811 {
2812 PopulateDot11fWMMCaps( &frm.WMMCaps );
2813 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002814#ifdef FEATURE_WLAN_ESE
2815 if (psessionEntry->isESEconnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07002816 {
2817 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2818
2819 // Populate the TSRS IE if TSPEC is included in the reassoc request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002820 if (psessionEntry->pLimReAssocReq->eseTspecInfo.numTspecs)
Jeff Johnson295189b2012-06-20 16:38:30 -07002821 {
2822 tANI_U32 phyMode;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002823 tSirMacESETSRSIE tsrsIE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002824 limGetPhyMode(pMac, &phyMode, psessionEntry);
2825
2826 tsrsIE.tsid = 0;
2827 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2828 {
2829 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2830 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302831 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002832 {
2833 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2834 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002835 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.ESETrafStrmRateSet, sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07002836 }
2837 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302838#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002839 }
2840
Jeff Johnsone7245742012-09-05 17:12:55 -07002841 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002842 pMac->lim.htCapabilityPresentInBeacon)
2843 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002844 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002845 }
2846
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002847#if defined WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302848 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent && (0 == pMac->ft.ftSmeContext.reassoc_ft_ies_length)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002849#if defined FEATURE_WLAN_ESE
2850 && !psessionEntry->isESEconnection
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302851#endif
2852 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002853 {
2854 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2855 }
2856#endif
2857
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002858#ifdef WLAN_FEATURE_11AC
2859 if ( psessionEntry->vhtCapability &&
2860 psessionEntry->vhtCapabilityPresentInBeacon)
2861 {
2862 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
2863 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002864 }
2865#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302866 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002867
Jeff Johnson295189b2012-06-20 16:38:30 -07002868 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2869 if ( DOT11F_FAILED( nStatus ) )
2870 {
2871 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002872 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002873 nStatus );
2874 // We'll fall back on the worst case scenario:
2875 nPayload = sizeof( tDot11fReAssocRequest );
2876 }
2877 else if ( DOT11F_WARNED( nStatus ) )
2878 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002879 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002880 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002881 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002882 }
2883
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002884 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002885
2886#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002887 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2889#endif
2890
2891#if defined WLAN_FEATURE_VOWIFI_11R
2892 if (psessionEntry->is11Rconnection)
2893 {
2894 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2895 }
2896#endif
2897
2898 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2899 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2900 ( void** ) &pPacket );
2901 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2902 {
2903 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002904 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002905 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002906 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 goto end;
2908 }
2909
2910 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302911 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002912
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002913#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002914 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002915#endif
2916 // Next, we fill out the buffer descriptor:
2917 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2918 SIR_MAC_MGMT_REASSOC_REQ,
2919 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2920 if ( eSIR_SUCCESS != nSirStatus )
2921 {
2922 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002923 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002924 nSirStatus );
2925 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2926 goto end;
2927 }
2928
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302929 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07002930 // That done, pack the ReAssoc Request:
2931 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2932 sizeof(tSirMacMgmtHdr),
2933 nPayload, &nPayload );
2934 if ( DOT11F_FAILED( nStatus ) )
2935 {
2936 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002937 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002938 nStatus );
2939 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2940 goto end;
2941 }
2942 else if ( DOT11F_WARNED( nStatus ) )
2943 {
2944 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002945 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002946 }
2947
2948 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002949 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002950 nBytes, nPayload );)
2951 if( psessionEntry->assocReq != NULL )
2952 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302953 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002954 psessionEntry->assocReq = NULL;
2955 }
2956
2957 if( nAddIELen )
2958 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302959 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2960 pAddIE,
2961 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002962 nPayload += nAddIELen;
2963 }
2964
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302965 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2966 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002967 {
2968 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002969 }
2970 else
2971 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002972 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302973 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002974 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002975 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002976
2977 if (psessionEntry->is11Rconnection)
2978 {
2979 {
2980 int i = 0;
2981
2982 pBody = pFrame + nBytes;
2983 for (i=0; i<ft_ies_length; i++)
2984 {
2985 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2986 pBody++;
2987 }
2988 }
2989 }
2990
2991#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002992 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
2993 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002994 (tANI_U8 *)pFrame,
2995 (nBytes + ft_ies_length));)
2996#endif
2997
2998
2999 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003000 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3001 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003002 )
3003 {
3004 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3005 }
3006
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003007 if( NULL != psessionEntry->assocReq )
3008 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303009 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003010 psessionEntry->assocReq = NULL;
3011 }
3012
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303013 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
3014 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003015 {
3016 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003017 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003018 }
3019 else
3020 {
3021 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303022 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
3023 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003024 psessionEntry->assocReqLen = (ft_ies_length);
3025 }
3026
3027
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303028 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3029 psessionEntry->peSessionId,
3030 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003031 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
3032 HAL_TXRX_FRM_802_11_MGMT,
3033 ANI_TXDIR_TODS,
3034 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3035 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303036 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3037 psessionEntry->peSessionId,
3038 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003039 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3040 {
3041 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003042 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003043 nSirStatus );
3044 //Pkt will be freed up by the callback
3045 goto end;
3046 }
3047
3048end:
3049 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303050 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003051 psessionEntry->pLimMlmReassocReq = NULL;
3052
3053}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003054
3055void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
3056 tLimMlmReassocReq *pMlmReassocReq,
3057 tpPESession psessionEntry)
3058{
3059 tLimMlmReassocCnf mlmReassocCnf; // keep sme
3060 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
3061 if(NULL == pTmpMlmReassocReq)
3062 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303063 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
3064 if ( NULL == pTmpMlmReassocReq ) goto end;
3065 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
3066 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003067 }
3068
3069 // Prepare and send Reassociation request frame
3070 // start reassoc timer.
3071 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
3072 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08003073 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003074 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
3075 != TX_SUCCESS)
3076 {
3077 // Could not start reassoc failure timer.
3078 // Log error
3079 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003080 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003081 // Return Reassoc confirm with
3082 // Resources Unavailable
3083 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3084 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3085 goto end;
3086 }
3087
3088 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
3089 return;
3090
3091end:
3092 // Free up buffer allocated for reassocReq
3093 if (pMlmReassocReq != NULL)
3094 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303095 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003096 pMlmReassocReq = NULL;
3097 }
3098 if (pTmpMlmReassocReq != NULL)
3099 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303100 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003101 pTmpMlmReassocReq = NULL;
3102 }
3103 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
3104 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3105 /* Update PE sessio Id*/
3106 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
3107
3108 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3109}
3110
Jeff Johnson295189b2012-06-20 16:38:30 -07003111#endif /* WLAN_FEATURE_VOWIFI_11R */
3112
3113
3114void
3115limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
3116 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
3117{
3118 static tDot11fReAssocRequest frm;
3119 tANI_U16 caps;
3120 tANI_U8 *pFrame;
3121 tSirRetStatus nSirStatus;
3122 tANI_U32 nBytes, nPayload, nStatus;
3123 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
3124 void *pPacket;
3125 eHalStatus halstatus;
3126 tANI_U16 nAddIELen;
3127 tANI_U8 *pAddIE;
3128 tANI_U8 *wpsIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303129 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003130#if defined WLAN_FEATURE_VOWIFI
3131 tANI_U8 PowerCapsPopulated = FALSE;
3132#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303133 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003134
3135 if(NULL == psessionEntry)
3136 {
3137 return;
3138 }
3139
3140 /* check this early to avoid unncessary operation */
3141 if(NULL == psessionEntry->pLimReAssocReq)
3142 {
3143 return;
3144 }
3145 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
3146 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
3147
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303148 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003149
3150 caps = pMlmReassocReq->capabilityInfo;
3151 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
3152 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
3153#if defined(FEATURE_WLAN_WAPI)
3154 /* CR: 262463 :
3155 According to WAPI standard:
3156 7.3.1.4 Capability Information field
3157 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
3158 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
3159 Reassociation management frames. */
3160 if ( psessionEntry->encryptType == eSIR_ED_WPI)
3161 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
3162#endif
3163 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
3164
3165 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
3166
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303167 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
3168 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003169
3170 PopulateDot11fSSID2( pMac, &frm.SSID );
3171 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3172 &frm.SuppRates,psessionEntry);
3173
3174 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
3175 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
3176
3177 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
3178 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
3179
3180 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
3181 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
3182
3183
3184 if ( psessionEntry->lim11hEnable &&
3185 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
3186 {
3187#if defined WLAN_FEATURE_VOWIFI
3188 PowerCapsPopulated = TRUE;
3189 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
3190 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
3191#endif
3192 }
3193
3194#if defined WLAN_FEATURE_VOWIFI
3195 if( pMac->rrm.rrmPEContext.rrmEnable &&
3196 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
3197 {
3198 if (PowerCapsPopulated == FALSE)
3199 {
3200 PowerCapsPopulated = TRUE;
3201 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
3202 }
3203 }
3204#endif
3205
3206 if ( fQosEnabled &&
3207 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
3208 {
3209 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
3210 }
3211
3212 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3213 &frm.ExtSuppRates, psessionEntry );
3214
3215#if defined WLAN_FEATURE_VOWIFI
3216 if( pMac->rrm.rrmPEContext.rrmEnable &&
3217 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
3218 {
3219 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
3220 }
3221#endif
3222 // The join request *should* contain zero or one of the WPA and RSN
3223 // IEs. The payload send along with the request is a
3224 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
3225
3226 // typedef struct sSirRSNie
3227 // {
3228 // tANI_U16 length;
3229 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
3230 // } tSirRSNie, *tpSirRSNie;
3231
3232 // So, we should be able to make the following two calls harmlessly,
3233 // since they do nothing if they don't find the given IE in the
3234 // bytestream with which they're provided.
3235
3236 // The net effect of this will be to faithfully transmit whatever
3237 // security IE is in the join request.
3238
3239 // *However*, if we're associating for the purpose of WPS
3240 // enrollment, and we've been configured to indicate that by
3241 // eliding the WPA or RSN IE, we just skip this:
3242 if( nAddIELen && pAddIE )
3243 {
3244 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
3245 }
3246 if ( NULL == wpsIe )
3247 {
3248 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3249 &frm.RSNOpaque );
3250 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3251 &frm.WPAOpaque );
3252#if defined(FEATURE_WLAN_WAPI)
3253 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3254 &frm.WAPIOpaque );
3255#endif // defined(FEATURE_WLAN_WAPI)
3256 }
3257
3258 // include WME EDCA IE as well
3259 if ( fWmeEnabled )
3260 {
3261 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
3262 {
3263 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
3264 }
3265
3266 if ( fWsmEnabled &&
3267 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3268 {
3269 PopulateDot11fWMMCaps( &frm.WMMCaps );
3270 }
3271 }
3272
Jeff Johnsone7245742012-09-05 17:12:55 -07003273 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003274 pMac->lim.htCapabilityPresentInBeacon)
3275 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003276 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003278#ifdef WLAN_FEATURE_11AC
3279 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003280 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003281 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003282 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003283 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Sandeep Puligilla60342762014-01-30 21:05:37 +05303284 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003285 }
3286#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003287
3288 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3289 if ( DOT11F_FAILED( nStatus ) )
3290 {
3291 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003292 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003293 nStatus );
3294 // We'll fall back on the worst case scenario:
3295 nPayload = sizeof( tDot11fReAssocRequest );
3296 }
3297 else if ( DOT11F_WARNED( nStatus ) )
3298 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003299 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003301 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 }
3303
3304 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3305
3306 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3307 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3308 ( void** ) &pPacket );
3309 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3310 {
3311 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003312 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003313 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003314 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003315 goto end;
3316 }
3317
3318 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303319 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003320
3321 // Next, we fill out the buffer descriptor:
3322 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3323 SIR_MAC_MGMT_REASSOC_REQ,
3324 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3325 if ( eSIR_SUCCESS != nSirStatus )
3326 {
3327 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003328 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003329 nSirStatus );
3330 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3331 goto end;
3332 }
3333
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303334 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003335 // That done, pack the Probe Request:
3336 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3337 sizeof(tSirMacMgmtHdr),
3338 nPayload, &nPayload );
3339 if ( DOT11F_FAILED( nStatus ) )
3340 {
3341 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003342 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003343 nStatus );
3344 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3345 goto end;
3346 }
3347 else if ( DOT11F_WARNED( nStatus ) )
3348 {
3349 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003350 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003351 }
3352
3353 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003354 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003355 nBytes );)
3356
3357 if( psessionEntry->assocReq != NULL )
3358 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303359 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003360 psessionEntry->assocReq = NULL;
3361 }
3362
3363 if( nAddIELen )
3364 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303365 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3366 pAddIE,
3367 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003368 nPayload += nAddIELen;
3369 }
3370
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303371 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3372 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003373 {
3374 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003375 }
3376 else
3377 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003378 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303379 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003381 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003382
3383 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003384 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3385 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003386 )
3387 {
3388 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3389 }
3390
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003391 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003392 {
3393 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3394 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003395
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303396 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3397 psessionEntry->peSessionId,
3398 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003399 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3400 HAL_TXRX_FRM_802_11_MGMT,
3401 ANI_TXDIR_TODS,
3402 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3403 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303404 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3405 psessionEntry->peSessionId,
3406 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003407 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3408 {
3409 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003410 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003411 nSirStatus );
3412 //Pkt will be freed up by the callback
3413 goto end;
3414 }
3415
3416end:
3417 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303418 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003419 psessionEntry->pLimMlmReassocReq = NULL;
3420
3421} // limSendReassocReqMgmtFrame
3422
3423/**
3424 * \brief Send an Authentication frame
3425 *
3426 *
3427 * \param pMac Pointer to Global MAC structure
3428 *
3429 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3430 * to be sent
3431 *
3432 * \param peerMacAddr MAC address of the peer entity to which Authentication
3433 * frame is destined
3434 *
3435 * \param wepBit Indicates whether wep bit to be set in FC while sending
3436 * Authentication frame3
3437 *
3438 *
3439 * This function is called by limProcessMlmMessages(). Authentication frame
3440 * is formatted and sent when this function is called.
3441 *
3442 *
3443 */
3444
3445void
3446limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3447 tpSirMacAuthFrameBody pAuthFrameBody,
3448 tSirMacAddr peerMacAddr,
3449 tANI_U8 wepBit,
3450 tpPESession psessionEntry
3451 )
3452{
3453 tANI_U8 *pFrame, *pBody;
3454 tANI_U32 frameLen = 0, bodyLen = 0;
3455 tpSirMacMgmtHdr pMacHdr;
3456 tANI_U16 i;
3457 void *pPacket;
3458 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303459 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003460
3461 if(NULL == psessionEntry)
3462 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303463 limLog(pMac, LOGE, FL("Error: psession Entry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003464 return;
3465 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05303466
3467 limLog(pMac, LOG1,
3468 FL("Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
3469 pAuthFrameBody->authTransactionSeqNumber,
3470 pAuthFrameBody->authStatusCode,
3471 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3472 MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003473 if (wepBit == LIM_WEP_IN_FC)
3474 {
3475 /// Auth frame3 to be sent with encrypted framebody
3476 /**
3477 * Allocate buffer for Authenticaton frame of size equal
3478 * to management frame header length plus 2 bytes each for
3479 * auth algorithm number, transaction number, status code,
3480 * 128 bytes for challenge text and 4 bytes each for
3481 * IV & ICV.
3482 */
3483
3484 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3485
3486 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3487 } // if (wepBit == LIM_WEP_IN_FC)
3488 else
3489 {
3490 switch (pAuthFrameBody->authTransactionSeqNumber)
3491 {
3492 case SIR_MAC_AUTH_FRAME_1:
3493 /**
3494 * Allocate buffer for Authenticaton frame of size
3495 * equal to management frame header length plus 2 bytes
3496 * each for auth algorithm number, transaction number
3497 * and status code.
3498 */
3499
3500 frameLen = sizeof(tSirMacMgmtHdr) +
3501 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3502 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3503
3504#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003505 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3506 {
3507 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003508 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003509 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003510 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003511 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003512 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003513 else
3514 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303515 limLog(pMac, LOG3, FL("Auth frame, Does not contain "
3516 "FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003517 frameLen += (2+SIR_MDIE_SIZE);
3518 }
3519 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003520#endif
3521 break;
3522
3523 case SIR_MAC_AUTH_FRAME_2:
3524 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3525 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3526 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3527 {
3528 /**
3529 * Allocate buffer for Authenticaton frame of size
3530 * equal to management frame header length plus
3531 * 2 bytes each for auth algorithm number,
3532 * transaction number and status code.
3533 */
3534
3535 frameLen = sizeof(tSirMacMgmtHdr) +
3536 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3537 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3538 }
3539 else
3540 {
3541 // Shared Key algorithm with challenge text
3542 // to be sent
3543 /**
3544 * Allocate buffer for Authenticaton frame of size
3545 * equal to management frame header length plus
3546 * 2 bytes each for auth algorithm number,
3547 * transaction number, status code and 128 bytes
3548 * for challenge text.
3549 */
3550
3551 frameLen = sizeof(tSirMacMgmtHdr) +
3552 sizeof(tSirMacAuthFrame);
3553 bodyLen = sizeof(tSirMacAuthFrameBody);
3554 }
3555
3556 break;
3557
3558 case SIR_MAC_AUTH_FRAME_3:
3559 /// Auth frame3 to be sent without encrypted framebody
3560 /**
3561 * Allocate buffer for Authenticaton frame of size equal
3562 * to management frame header length plus 2 bytes each
3563 * for auth algorithm number, transaction number and
3564 * status code.
3565 */
3566
3567 frameLen = sizeof(tSirMacMgmtHdr) +
3568 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3569 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3570
3571 break;
3572
3573 case SIR_MAC_AUTH_FRAME_4:
3574 /**
3575 * Allocate buffer for Authenticaton frame of size equal
3576 * to management frame header length plus 2 bytes each
3577 * for auth algorithm number, transaction number and
3578 * status code.
3579 */
3580
3581 frameLen = sizeof(tSirMacMgmtHdr) +
3582 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3583 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3584
3585 break;
3586 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3587 } // end if (wepBit == LIM_WEP_IN_FC)
3588
3589
3590 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3591
3592 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3593 {
3594 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003595 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003596
3597 return;
3598 }
3599
3600 for (i = 0; i < frameLen; i++)
3601 pFrame[i] = 0;
3602
3603 // Prepare BD
3604 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3605 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3606 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303607 limLog(pMac, LOGE, FL("call to limPopulateMacHeader failed for "
3608 "AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003609 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3610 return;
3611 }
3612
3613 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3614 pMacHdr->fc.wep = wepBit;
3615
3616 // Prepare BSSId
3617 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3618 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303619 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3620 (tANI_U8 *) psessionEntry->bssId,
3621 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003622 }
3623
3624 /// Prepare Authentication frame body
3625 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3626
3627 if (wepBit == LIM_WEP_IN_FC)
3628 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303629 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003630
3631 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303632 FL("*** Sending Auth seq# 3 status %d (%d) to"MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003633 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303634 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3635 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003636
Jeff Johnson295189b2012-06-20 16:38:30 -07003637 }
3638 else
3639 {
3640 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3641 pBody += sizeof(tANI_U16);
3642 bodyLen -= sizeof(tANI_U16);
3643
3644 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3645 pBody += sizeof(tANI_U16);
3646 bodyLen -= sizeof(tANI_U16);
3647
3648 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3649 pBody += sizeof(tANI_U16);
3650 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003651 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3652 sizeof (pAuthFrameBody->length) +
3653 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303654 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003655
3656#if defined WLAN_FEATURE_VOWIFI_11R
3657 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3658 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3659 {
3660
3661 {
3662 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003663 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3664 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003665#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowdad63eb492014-02-06 12:21:47 -08003666 PELOG2(limLog(pMac, LOG2, FL("Auth1 Frame FTIE is: "));
3667 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
Jeff Johnson295189b2012-06-20 16:38:30 -07003668 (tANI_U8 *)pBody,
3669 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003670#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003671 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3672 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003673 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3674 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003675 }
3676 }
3677 else
3678 {
3679 /* MDID attr is 54*/
3680 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003681 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003682 *pBody = SIR_MDIE_SIZE;
3683 pBody++;
3684 for(i=0;i<SIR_MDIE_SIZE;i++)
3685 {
3686 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3687 pBody++;
3688 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003689 }
3690 }
3691 }
3692#endif
3693
3694 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303695 FL("*** Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003696 pAuthFrameBody->authTransactionSeqNumber,
3697 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303698 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3699 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003700 }
3701 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3702
3703 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003704 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3705 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003706#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303707 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003708 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3709#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003710 )
3711 {
3712 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3713 }
3714
Ganesh K08bce952012-12-13 15:04:41 -08003715 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3716 {
3717 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3718 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003719
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05303720 limLog( pMac, LOG1, FL("Sending Auth Frame over WQ5 to "MAC_ADDRESS_STR
3721 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
3722 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
3723
3724 txFlag |= HAL_USE_FW_IN_TX_PATH;
3725
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303726 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3727 psessionEntry->peSessionId,
3728 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003729 /// Queue Authentication frame in high priority WQ
3730 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3731 HAL_TXRX_FRM_802_11_MGMT,
3732 ANI_TXDIR_TODS,
3733 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3734 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303735 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3736 psessionEntry->peSessionId,
3737 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003738 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3739 {
3740 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003741 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003742 halstatus);
3743
3744 //Pkt will be freed up by the callback
3745 }
3746
3747 return;
3748} /*** end limSendAuthMgmtFrame() ***/
3749
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003750eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3751{
3752 tANI_U16 aid;
3753 tpDphHashNode pStaDs;
3754 tLimMlmDeauthReq *pMlmDeauthReq;
3755 tLimMlmDeauthCnf mlmDeauthCnf;
3756 tpPESession psessionEntry;
3757
3758 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3759 if (pMlmDeauthReq)
3760 {
3761 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3762 {
3763 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3764 }
3765
3766 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3767 {
3768
3769 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003770 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003771 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3772 goto end;
3773 }
3774
3775 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3776 if (pStaDs == NULL)
3777 {
3778 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3779 goto end;
3780 }
3781
3782
3783 /// Receive path cleanup with dummy packet
3784 limCleanupRxPath(pMac, pStaDs,psessionEntry);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05303785
3786#ifdef WLAN_FEATURE_VOWIFI_11R
3787 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
3788 (
3789#ifdef FEATURE_WLAN_ESE
3790 (psessionEntry->isESEconnection ) ||
3791#endif
3792#ifdef FEATURE_WLAN_LFR
3793 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
3794#endif
3795 (psessionEntry->is11Rconnection )))
3796 {
3797 PELOGE(limLog(pMac, LOGE,
3798 FL("FT Preauth Session (%p,%d) Cleanup"
3799 " Deauth reason %d Trigger = %d"),
3800 psessionEntry, psessionEntry->peSessionId,
3801 pMlmDeauthReq->reasonCode,
3802 pMlmDeauthReq->deauthTrigger););
3803 limFTCleanup(pMac);
3804 }
3805 else
3806 {
3807 PELOGE(limLog(pMac, LOGE,
3808 FL("No FT Preauth Session Cleanup in role %d"
3809#ifdef FEATURE_WLAN_ESE
3810 " isESE %d"
3811#endif
3812#ifdef FEATURE_WLAN_LFR
3813 " isLFR %d"
3814#endif
3815 " is11r %d, Deauth reason %d Trigger = %d"),
3816 psessionEntry->limSystemRole,
3817#ifdef FEATURE_WLAN_ESE
3818 psessionEntry->isESEconnection,
3819#endif
3820#ifdef FEATURE_WLAN_LFR
3821 psessionEntry->isFastRoamIniFeatureEnabled,
3822#endif
3823 psessionEntry->is11Rconnection,
3824 pMlmDeauthReq->reasonCode,
3825 pMlmDeauthReq->deauthTrigger););
3826 }
3827#endif
3828
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003829 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303830 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003831 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3832 }
3833 return eHAL_STATUS_SUCCESS;
3834end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303835 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003836 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3837 sizeof(tSirMacAddr));
3838 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3839 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3840 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3841
3842 // Free up buffer allocated
3843 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303844 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003845
3846 limPostSmeMessage(pMac,
3847 LIM_MLM_DEAUTH_CNF,
3848 (tANI_U32 *) &mlmDeauthCnf);
3849 return eHAL_STATUS_SUCCESS;
3850}
3851
3852eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3853{
3854 tANI_U16 aid;
3855 tpDphHashNode pStaDs;
3856 tLimMlmDisassocCnf mlmDisassocCnf;
3857 tpPESession psessionEntry;
3858 tLimMlmDisassocReq *pMlmDisassocReq;
3859
3860 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3861 if (pMlmDisassocReq)
3862 {
3863 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3864 {
3865 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3866 }
3867
3868 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3869 {
3870
3871 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003872 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003873 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3874 goto end;
3875 }
3876
3877 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3878 if (pStaDs == NULL)
3879 {
3880 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3881 goto end;
3882 }
3883
3884 /// Receive path cleanup with dummy packet
3885 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3886 {
3887 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3888 goto end;
3889 }
3890
3891#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003892 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303893 (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003894#ifdef FEATURE_WLAN_ESE
3895 (psessionEntry->isESEconnection ) ||
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003896#endif
3897#ifdef FEATURE_WLAN_LFR
3898 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003899#endif
3900 (psessionEntry->is11Rconnection )) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303901 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003902 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003903 {
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303904 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003905 FL("FT Preauth Session (%p,%d) Cleanup"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003906 psessionEntry, psessionEntry->peSessionId););
3907 limFTCleanup(pMac);
3908 }
3909 else
3910 {
3911 PELOGE(limLog(pMac, LOGE,
3912 FL("No FT Preauth Session Cleanup in role %d"
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003913#ifdef FEATURE_WLAN_ESE
3914 " isESE %d"
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003915#endif
3916#ifdef FEATURE_WLAN_LFR
3917 " isLFR %d"
3918#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003919 " is11r %d reason %d"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003920 psessionEntry->limSystemRole,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003921#ifdef FEATURE_WLAN_ESE
3922 psessionEntry->isESEconnection,
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003923#endif
3924#ifdef FEATURE_WLAN_LFR
3925 psessionEntry->isFastRoamIniFeatureEnabled,
3926#endif
3927 psessionEntry->is11Rconnection,
3928 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003929 }
3930#endif
3931
3932 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303933 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003934 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3935 return eHAL_STATUS_SUCCESS;
3936 }
3937 else
3938 {
3939 return eHAL_STATUS_SUCCESS;
3940 }
3941end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303942 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003943 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3944 sizeof(tSirMacAddr));
3945 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3946 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3947
3948 /* Update PE session ID*/
3949 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3950
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003951 if(pMlmDisassocReq != NULL)
3952 {
3953 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303954 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003955 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3956 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003957
3958 limPostSmeMessage(pMac,
3959 LIM_MLM_DISASSOC_CNF,
3960 (tANI_U32 *) &mlmDisassocCnf);
3961 return eHAL_STATUS_SUCCESS;
3962}
3963
3964eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3965{
3966 return limSendDisassocCnf(pMac);
3967}
3968
3969eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3970{
3971 return limSendDeauthCnf(pMac);
3972}
3973
Jeff Johnson295189b2012-06-20 16:38:30 -07003974/**
3975 * \brief This function is called to send Disassociate frame.
3976 *
3977 *
3978 * \param pMac Pointer to Global MAC structure
3979 *
3980 * \param nReason Indicates the reason that need to be sent in
3981 * Disassociation frame
3982 *
3983 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3984 * sent
3985 *
3986 *
3987 */
3988
3989void
3990limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3991 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003992 tSirMacAddr peer,
3993 tpPESession psessionEntry,
3994 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003995{
3996 tDot11fDisassociation frm;
3997 tANI_U8 *pFrame;
3998 tSirRetStatus nSirStatus;
3999 tpSirMacMgmtHdr pMacHdr;
4000 tANI_U32 nBytes, nPayload, nStatus;
4001 void *pPacket;
4002 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304003 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004004 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004005 if(NULL == psessionEntry)
4006 {
4007 return;
4008 }
4009
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304010 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004011
4012 frm.Reason.code = nReason;
4013
4014 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
4015 if ( DOT11F_FAILED( nStatus ) )
4016 {
4017 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004018 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004019 nStatus );
4020 // We'll fall back on the worst case scenario:
4021 nPayload = sizeof( tDot11fDisassociation );
4022 }
4023 else if ( DOT11F_WARNED( nStatus ) )
4024 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004025 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004026 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004027 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004028 }
4029
4030 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4031
4032 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4033 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4034 ( void** ) &pPacket );
4035 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4036 {
4037 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004038 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004039 return;
4040 }
4041
4042 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304043 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004044
4045 // Next, we fill out the buffer descriptor:
4046 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4047 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
4048 if ( eSIR_SUCCESS != nSirStatus )
4049 {
4050 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004051 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004052 nSirStatus );
4053 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4054 ( void* ) pFrame, ( void* ) pPacket );
4055 return; // just allocated...
4056 }
4057
4058 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4059
4060 // Prepare the BSSID
4061 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4062
Chet Lanctot186b5732013-03-18 10:26:30 -07004063#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004064 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004065#endif
4066
Jeff Johnson295189b2012-06-20 16:38:30 -07004067 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
4068 sizeof(tSirMacMgmtHdr),
4069 nPayload, &nPayload );
4070 if ( DOT11F_FAILED( nStatus ) )
4071 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004072 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004073 nStatus );
4074 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4075 ( void* ) pFrame, ( void* ) pPacket );
4076 return; // allocated!
4077 }
4078 else if ( DOT11F_WARNED( nStatus ) )
4079 {
4080 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004081 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004082 }
4083
Abhishek Singhcd09b562013-12-24 16:02:20 +05304084 limLog( pMac, LOG1, FL("***Sessionid %d Sending Disassociation frame with "
4085 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4086 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4087 MAC_ADDR_ARRAY(pMacHdr->da),
4088 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004089
4090 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004091 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4092 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004093 )
4094 {
4095 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4096 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004097
Ganesh K08bce952012-12-13 15:04:41 -08004098 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304099 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
4100 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08004101 {
4102 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4103 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004104
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304105 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4106 {
4107 /* This frame will be sent on air by firmware,
4108 which will ensure that this frame goes out
4109 even though DEL_STA is sent immediately */
4110 /* Without this for DEL_STA command there is
4111 risk of flushing frame in BTQM queue without
4112 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304113 limLog( pMac, LOG1, FL("Sending Disassoc Frame over WQ5 to "MAC_ADDRESS_STR
4114 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4115 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304116 txFlag |= HAL_USE_FW_IN_TX_PATH;
4117 }
4118
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004119 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004120 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304121 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4122 psessionEntry->peSessionId,
4123 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004124 // Queue Disassociation frame in high priority WQ
4125 /* get the duration from the request */
4126 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4127 HAL_TXRX_FRM_802_11_MGMT,
4128 ANI_TXDIR_TODS,
4129 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4130 limTxComplete, pFrame, limDisassocTxCompleteCnf,
4131 txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304132 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4133 psessionEntry->peSessionId,
4134 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004135 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07004136
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004137 if (tx_timer_change(
4138 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
4139 != TX_SUCCESS)
4140 {
4141 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004142 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004143 return;
4144 }
4145 else if(TX_SUCCESS != tx_timer_activate(
4146 &pMac->lim.limTimers.gLimDisassocAckTimer))
4147 {
4148 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004149 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004150 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4151 return;
4152 }
4153 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004154 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004155 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304156 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4157 psessionEntry->peSessionId,
4158 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004159 // Queue Disassociation frame in high priority WQ
4160 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4161 HAL_TXRX_FRM_802_11_MGMT,
4162 ANI_TXDIR_TODS,
4163 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4164 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304165 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4166 psessionEntry->peSessionId,
4167 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004168 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4169 {
4170 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004171 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004172 nSirStatus );
4173 //Pkt will be freed up by the callback
4174 return;
4175 }
4176 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004177} // End limSendDisassocMgmtFrame.
4178
4179/**
4180 * \brief This function is called to send a Deauthenticate frame
4181 *
4182 *
4183 * \param pMac Pointer to global MAC structure
4184 *
4185 * \param nReason Indicates the reason that need to be sent in the
4186 * Deauthenticate frame
4187 *
4188 * \param peeer address of the STA to which the frame is to be sent
4189 *
4190 *
4191 */
4192
4193void
4194limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
4195 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004196 tSirMacAddr peer,
4197 tpPESession psessionEntry,
4198 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004199{
4200 tDot11fDeAuth frm;
4201 tANI_U8 *pFrame;
4202 tSirRetStatus nSirStatus;
4203 tpSirMacMgmtHdr pMacHdr;
4204 tANI_U32 nBytes, nPayload, nStatus;
4205 void *pPacket;
4206 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304207 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004208 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004209#ifdef FEATURE_WLAN_TDLS
4210 tANI_U16 aid;
4211 tpDphHashNode pStaDs;
4212#endif
4213
Jeff Johnson295189b2012-06-20 16:38:30 -07004214 if(NULL == psessionEntry)
4215 {
4216 return;
4217 }
4218
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304219 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004220
4221 frm.Reason.code = nReason;
4222
4223 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
4224 if ( DOT11F_FAILED( nStatus ) )
4225 {
4226 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004227 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004228 nStatus );
4229 // We'll fall back on the worst case scenario:
4230 nPayload = sizeof( tDot11fDeAuth );
4231 }
4232 else if ( DOT11F_WARNED( nStatus ) )
4233 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004234 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004235 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004236 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004237 }
4238
4239 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4240
4241 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4242 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4243 ( void** ) &pPacket );
4244 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4245 {
4246 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004247 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004248 return;
4249 }
4250
4251 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304252 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004253
4254 // Next, we fill out the buffer descriptor:
4255 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4256 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
4257 if ( eSIR_SUCCESS != nSirStatus )
4258 {
4259 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004260 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004261 nSirStatus );
4262 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4263 ( void* ) pFrame, ( void* ) pPacket );
4264 return; // just allocated...
4265 }
4266
4267 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4268
4269 // Prepare the BSSID
4270 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4271
Chet Lanctot186b5732013-03-18 10:26:30 -07004272#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004273 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004274#endif
4275
Jeff Johnson295189b2012-06-20 16:38:30 -07004276 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
4277 sizeof(tSirMacMgmtHdr),
4278 nPayload, &nPayload );
4279 if ( DOT11F_FAILED( nStatus ) )
4280 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004281 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004282 nStatus );
4283 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4284 ( void* ) pFrame, ( void* ) pPacket );
4285 return;
4286 }
4287 else if ( DOT11F_WARNED( nStatus ) )
4288 {
4289 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004290 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004291 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05304292 limLog( pMac, LOG1, FL("***Sessionid %d Sending Deauth frame with "
4293 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4294 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4295 MAC_ADDR_ARRAY(pMacHdr->da),
4296 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004297
4298 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004299 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4300 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004301 )
4302 {
4303 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4304 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004305
Ganesh K08bce952012-12-13 15:04:41 -08004306 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304307 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
4308 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08004309 {
4310 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4311 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004312
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304313 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4314 {
4315 /* This frame will be sent on air by firmware,
4316 which will ensure that this frame goes out
4317 even though DEL_STA is sent immediately */
4318 /* Without this for DEL_STA command there is
4319 risk of flushing frame in BTQM queue without
4320 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304321 limLog( pMac, LOG1, FL("Sending Deauth Frame over WQ5 to "MAC_ADDRESS_STR
4322 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4323 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304324 txFlag |= HAL_USE_FW_IN_TX_PATH;
4325 }
4326
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004327#ifdef FEATURE_WLAN_TDLS
4328 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
4329#endif
4330
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004331 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004332 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304333 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4334 psessionEntry->peSessionId,
4335 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004336 // Queue Disassociation frame in high priority WQ
4337 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4338 HAL_TXRX_FRM_802_11_MGMT,
4339 ANI_TXDIR_TODS,
4340 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4341 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304342 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4343 psessionEntry->peSessionId,
4344 halstatus));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304345 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004346 {
4347 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304348 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004349 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08004350 //Pkt will be freed up by the callback limTxComplete
4351
4352 /*Call limProcessDeauthAckTimeout which will send
4353 * DeauthCnf for this frame
4354 */
4355 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004356 return;
4357 }
4358
4359 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
4360
4361 if (tx_timer_change(
4362 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
4363 != TX_SUCCESS)
4364 {
4365 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004366 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004367 return;
4368 }
4369 else if(TX_SUCCESS != tx_timer_activate(
4370 &pMac->lim.limTimers.gLimDeauthAckTimer))
4371 {
4372 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004373 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004374 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4375 return;
4376 }
4377 }
4378 else
4379 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304380 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4381 psessionEntry->peSessionId,
4382 pMacHdr->fc.subType));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004383#ifdef FEATURE_WLAN_TDLS
4384 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4385 {
4386 // Queue Disassociation frame in high priority WQ
4387 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004388 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004389 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004390 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4391 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004392 }
4393 else
4394 {
4395#endif
4396 // Queue Disassociation frame in high priority WQ
4397 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4398 HAL_TXRX_FRM_802_11_MGMT,
4399 ANI_TXDIR_TODS,
4400 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4401 limTxComplete, pFrame, txFlag );
4402#ifdef FEATURE_WLAN_TDLS
4403 }
4404#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304405 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4406 psessionEntry->peSessionId,
4407 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004408 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4409 {
4410 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004411 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004412 nSirStatus );
4413 //Pkt will be freed up by the callback
4414 return;
4415 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004416 }
4417
4418} // End limSendDeauthMgmtFrame.
4419
4420
4421#ifdef ANI_SUPPORT_11H
4422/**
4423 * \brief Send a Measurement Report Action frame
4424 *
4425 *
4426 * \param pMac Pointer to the global MAC structure
4427 *
4428 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4429 *
4430 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4431 *
4432 *
4433 */
4434
4435tSirRetStatus
4436limSendMeasReportFrame(tpAniSirGlobal pMac,
4437 tpSirMacMeasReqActionFrame pMeasReqFrame,
4438 tSirMacAddr peer)
4439{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304440 tDot11fMeasurementReport frm;
4441 tANI_U8 *pFrame;
4442 tSirRetStatus nSirStatus;
4443 tpSirMacMgmtHdr pMacHdr;
4444 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4445 void *pPacket;
4446 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004447
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304448 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004449
4450 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4451 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4452 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4453
4454 switch ( pMeasReqFrame->measReqIE.measType )
4455 {
4456 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4457 nSirStatus =
4458 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4459 &frm.MeasurementReport );
4460 break;
4461 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4462 nSirStatus =
4463 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4464 &frm.MeasurementReport );
4465 break;
4466 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4467 nSirStatus =
4468 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4469 &frm.MeasurementReport );
4470 break;
4471 default:
4472 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004473 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004474 pMeasReqFrame->measReqIE.measType );
4475 return eSIR_FAILURE;
4476 }
4477
4478 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4479
4480 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4481 if ( DOT11F_FAILED( nStatus ) )
4482 {
4483 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004484 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004485 nStatus );
4486 // We'll fall back on the worst case scenario:
4487 nPayload = sizeof( tDot11fMeasurementReport );
4488 }
4489 else if ( DOT11F_WARNED( nStatus ) )
4490 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004491 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004492 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004493 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004494 }
4495
4496 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4497
4498 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4499 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4500 {
4501 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004502 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004503 return eSIR_FAILURE;
4504 }
4505
4506 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304507 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004508
4509 // Next, we fill out the buffer descriptor:
4510 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4511 SIR_MAC_MGMT_ACTION, peer);
4512 if ( eSIR_SUCCESS != nSirStatus )
4513 {
4514 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004515 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004516 nSirStatus );
4517 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4518 return eSIR_FAILURE; // just allocated...
4519 }
4520
4521 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4522
4523 nCfg = 6;
4524 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4525 if ( eSIR_SUCCESS != nSirStatus )
4526 {
4527 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004528 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004529 nSirStatus );
4530 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4531 return eSIR_FAILURE; // just allocated...
4532 }
4533
Chet Lanctot186b5732013-03-18 10:26:30 -07004534#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004535 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004536#endif
4537
Jeff Johnson295189b2012-06-20 16:38:30 -07004538 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4539 sizeof(tSirMacMgmtHdr),
4540 nPayload, &nPayload );
4541 if ( DOT11F_FAILED( nStatus ) )
4542 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004543 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004544 nStatus );
4545 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4546 return eSIR_FAILURE; // allocated!
4547 }
4548 else if ( DOT11F_WARNED( nStatus ) )
4549 {
4550 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004551 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004552 }
4553
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304554 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4555 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4556 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4558 HAL_TXRX_FRM_802_11_MGMT,
4559 ANI_TXDIR_TODS,
4560 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4561 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304562 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4563 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4564 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004565 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4566 {
4567 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004568 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004569 nSirStatus );
4570 //Pkt will be freed up by the callback
4571 return eSIR_FAILURE; // just allocated...
4572 }
4573
4574 return eSIR_SUCCESS;
4575
4576} // End limSendMeasReportFrame.
4577
4578
4579/**
4580 * \brief Send a TPC Request Action frame
4581 *
4582 *
4583 * \param pMac Pointer to the global MAC datastructure
4584 *
4585 * \param peer MAC address to which the frame should be sent
4586 *
4587 *
4588 */
4589
4590void
4591limSendTpcRequestFrame(tpAniSirGlobal pMac,
4592 tSirMacAddr peer)
4593{
4594 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304595 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004596 tSirRetStatus nSirStatus;
4597 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304598 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4599 void *pPacket;
4600 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004601
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304602 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004603
4604 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4605 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4606 frm.DialogToken.token = 1;
4607 frm.TPCRequest.present = 1;
4608
4609 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4610 if ( DOT11F_FAILED( nStatus ) )
4611 {
4612 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004613 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004614 nStatus );
4615 // We'll fall back on the worst case scenario:
4616 nPayload = sizeof( tDot11fTPCRequest );
4617 }
4618 else if ( DOT11F_WARNED( nStatus ) )
4619 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004620 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004621 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004622 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004623 }
4624
4625 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4626
4627 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4628 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4629 {
4630 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004631 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004632 return;
4633 }
4634
4635 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304636 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004637
4638 // Next, we fill out the buffer descriptor:
4639 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4640 SIR_MAC_MGMT_ACTION, peer);
4641 if ( eSIR_SUCCESS != nSirStatus )
4642 {
4643 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004644 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004645 nSirStatus );
4646 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4647 return; // just allocated...
4648 }
4649
4650 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4651
4652 nCfg = 6;
4653 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4654 if ( eSIR_SUCCESS != nSirStatus )
4655 {
4656 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004657 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004658 nSirStatus );
4659 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4660 return; // just allocated...
4661 }
4662
Chet Lanctot186b5732013-03-18 10:26:30 -07004663#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004664 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004665#endif
4666
Jeff Johnson295189b2012-06-20 16:38:30 -07004667 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4668 sizeof(tSirMacMgmtHdr),
4669 nPayload, &nPayload );
4670 if ( DOT11F_FAILED( nStatus ) )
4671 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004672 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004673 nStatus );
4674 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4675 return; // allocated!
4676 }
4677 else if ( DOT11F_WARNED( nStatus ) )
4678 {
4679 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004680 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004681 }
4682
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304683 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4684 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4685 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004686 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4687 HAL_TXRX_FRM_802_11_MGMT,
4688 ANI_TXDIR_TODS,
4689 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4690 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304691 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4692 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4693 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004694 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4695 {
4696 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004697 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004698 nSirStatus );
4699 //Pkt will be freed up by the callback
4700 return;
4701 }
4702
4703} // End limSendTpcRequestFrame.
4704
4705
4706/**
4707 * \brief Send a TPC Report Action frame
4708 *
4709 *
4710 * \param pMac Pointer to the global MAC datastructure
4711 *
4712 * \param pTpcReqFrame Pointer to the received TPC Request
4713 *
4714 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4715 *
4716 *
4717 */
4718
4719tSirRetStatus
4720limSendTpcReportFrame(tpAniSirGlobal pMac,
4721 tpSirMacTpcReqActionFrame pTpcReqFrame,
4722 tSirMacAddr peer)
4723{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304724 tDot11fTPCReport frm;
4725 tANI_U8 *pFrame;
4726 tSirRetStatus nSirStatus;
4727 tpSirMacMgmtHdr pMacHdr;
4728 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4729 void *pPacket;
4730 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004731
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304732 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004733
4734 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4735 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4736 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4737
4738 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4739 // "misplaced this function, need to replace:
4740 // txPower = halGetRateToPwrValue(pMac, staid,
4741 // pMac->lim.gLimCurrentChannelId, 0);
4742 frm.TPCReport.tx_power = 0;
4743 frm.TPCReport.link_margin = 0;
4744 frm.TPCReport.present = 1;
4745
4746 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4747 if ( DOT11F_FAILED( nStatus ) )
4748 {
4749 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004750 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004751 nStatus );
4752 // We'll fall back on the worst case scenario:
4753 nPayload = sizeof( tDot11fTPCReport );
4754 }
4755 else if ( DOT11F_WARNED( nStatus ) )
4756 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004757 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004758 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004759 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004760 }
4761
4762 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4763
4764 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4765 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4766 {
4767 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004768 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004769 return eSIR_FAILURE;
4770 }
4771
4772 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304773 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004774
4775 // Next, we fill out the buffer descriptor:
4776 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4777 SIR_MAC_MGMT_ACTION, peer);
4778 if ( eSIR_SUCCESS != nSirStatus )
4779 {
4780 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004781 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004782 nSirStatus );
4783 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4784 return eSIR_FAILURE; // just allocated...
4785 }
4786
4787 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4788
4789 nCfg = 6;
4790 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4791 if ( eSIR_SUCCESS != nSirStatus )
4792 {
4793 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004794 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004795 nSirStatus );
4796 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4797 return eSIR_FAILURE; // just allocated...
4798 }
4799
Chet Lanctot186b5732013-03-18 10:26:30 -07004800#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004801 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004802#endif
4803
Jeff Johnson295189b2012-06-20 16:38:30 -07004804 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4805 sizeof(tSirMacMgmtHdr),
4806 nPayload, &nPayload );
4807 if ( DOT11F_FAILED( nStatus ) )
4808 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004809 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004810 nStatus );
4811 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4812 return eSIR_FAILURE; // allocated!
4813 }
4814 else if ( DOT11F_WARNED( nStatus ) )
4815 {
4816 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004817 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004818 }
4819
4820
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304821 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4822 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4823 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004824 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4825 HAL_TXRX_FRM_802_11_MGMT,
4826 ANI_TXDIR_TODS,
4827 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4828 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304829 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4830 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4831 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004832 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4833 {
4834 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004835 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004836 nSirStatus );
4837 //Pkt will be freed up by the callback
4838 return eSIR_FAILURE; // just allocated...
4839 }
4840
4841 return eSIR_SUCCESS;
4842
4843} // End limSendTpcReportFrame.
4844#endif //ANI_SUPPORT_11H
4845
4846
Jeff Johnson295189b2012-06-20 16:38:30 -07004847/**
4848 * \brief Send a Channel Switch Announcement
4849 *
4850 *
4851 * \param pMac Pointer to the global MAC datastructure
4852 *
4853 * \param peer MAC address to which this frame will be sent
4854 *
4855 * \param nMode
4856 *
4857 * \param nNewChannel
4858 *
4859 * \param nCount
4860 *
4861 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4862 *
4863 *
4864 */
4865
4866tSirRetStatus
4867limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4868 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004869 tANI_U8 nMode,
4870 tANI_U8 nNewChannel,
4871 tANI_U8 nCount,
4872 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004873{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304874 tDot11fChannelSwitch frm;
4875 tANI_U8 *pFrame;
4876 tSirRetStatus nSirStatus;
4877 tpSirMacMgmtHdr pMacHdr;
4878 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4879 void *pPacket;
4880 eHalStatus halstatus;
4881 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004882
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304883 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004884
4885 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4886 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4887 frm.ChanSwitchAnn.switchMode = nMode;
4888 frm.ChanSwitchAnn.newChannel = nNewChannel;
4889 frm.ChanSwitchAnn.switchCount = nCount;
4890 frm.ChanSwitchAnn.present = 1;
4891
4892 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4893 if ( DOT11F_FAILED( nStatus ) )
4894 {
4895 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004896 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004897 nStatus );
4898 // We'll fall back on the worst case scenario:
4899 nPayload = sizeof( tDot11fChannelSwitch );
4900 }
4901 else if ( DOT11F_WARNED( nStatus ) )
4902 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004903 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004904 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004905 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004906 }
4907
4908 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4909
4910 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4911 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4912 {
4913 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004914 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004915 return eSIR_FAILURE;
4916 }
4917
4918 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304919 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004920
4921 // Next, we fill out the buffer descriptor:
4922 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004923 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4924 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304925 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4926 (tANI_U8 *) psessionEntry->bssId,
4927 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004928 if ( eSIR_SUCCESS != nSirStatus )
4929 {
4930 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004931 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004932 nSirStatus );
4933 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4934 return eSIR_FAILURE; // just allocated...
4935 }
4936
Jeff Johnsone7245742012-09-05 17:12:55 -07004937#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004938 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4939
4940 nCfg = 6;
4941 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4942 if ( eSIR_SUCCESS != nSirStatus )
4943 {
4944 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004945 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004946 nSirStatus );
4947 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4948 return eSIR_FAILURE; // just allocated...
4949 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004950#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004951
4952#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004953 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004954#endif
4955
Jeff Johnson295189b2012-06-20 16:38:30 -07004956 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4957 sizeof(tSirMacMgmtHdr),
4958 nPayload, &nPayload );
4959 if ( DOT11F_FAILED( nStatus ) )
4960 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004961 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004962 nStatus );
4963 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4964 return eSIR_FAILURE; // allocated!
4965 }
4966 else if ( DOT11F_WARNED( nStatus ) )
4967 {
4968 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004969 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004970 }
4971
Jeff Johnsone7245742012-09-05 17:12:55 -07004972 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004973 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4974 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004975 )
4976 {
4977 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4978 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304979
4980 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4981 psessionEntry->peSessionId,
4982 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004983 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4984 HAL_TXRX_FRM_802_11_MGMT,
4985 ANI_TXDIR_TODS,
4986 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004987 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304988 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4989 psessionEntry->peSessionId,
4990 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004991 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4992 {
4993 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004994 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004995 nSirStatus );
4996 //Pkt will be freed up by the callback
4997 return eSIR_FAILURE;
4998 }
4999
5000 return eSIR_SUCCESS;
5001
5002} // End limSendChannelSwitchMgmtFrame.
5003
Jeff Johnson295189b2012-06-20 16:38:30 -07005004
5005
Mohit Khanna4a70d262012-09-11 16:30:12 -07005006#ifdef WLAN_FEATURE_11AC
5007tSirRetStatus
5008limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
5009 tSirMacAddr peer,
5010 tANI_U8 nMode,
5011 tpPESession psessionEntry )
5012{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305013 tDot11fOperatingMode frm;
5014 tANI_U8 *pFrame;
5015 tSirRetStatus nSirStatus;
5016 tpSirMacMgmtHdr pMacHdr;
5017 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
5018 void *pPacket;
5019 eHalStatus halstatus;
5020 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07005021
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305022 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005023
5024 frm.Category.category = SIR_MAC_ACTION_VHT;
5025 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
5026 frm.OperatingMode.chanWidth = nMode;
5027 frm.OperatingMode.rxNSS = 0;
5028 frm.OperatingMode.rxNSSType = 0;
5029
5030 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
5031 if ( DOT11F_FAILED( nStatus ) )
5032 {
5033 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005034 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005035 nStatus );
5036 // We'll fall back on the worst case scenario:
5037 nPayload = sizeof( tDot11fOperatingMode);
5038 }
5039 else if ( DOT11F_WARNED( nStatus ) )
5040 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005041 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07005042 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005043 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005044 }
5045
5046 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5047
5048 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5049 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5050 {
5051 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005052 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005053 return eSIR_FAILURE;
5054 }
5055
5056 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305057 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005058
5059
5060 // Next, we fill out the buffer descriptor:
5061 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
5062 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5063 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5064 } else
5065 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5066 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
5067 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305068 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5069 (tANI_U8 *) psessionEntry->bssId,
5070 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005071 if ( eSIR_SUCCESS != nSirStatus )
5072 {
5073 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005074 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005075 nSirStatus );
5076 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5077 return eSIR_FAILURE; // just allocated...
5078 }
5079 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
5080 sizeof(tSirMacMgmtHdr),
5081 nPayload, &nPayload );
5082 if ( DOT11F_FAILED( nStatus ) )
5083 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005084 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005085 nStatus );
5086 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5087 return eSIR_FAILURE; // allocated!
5088 }
5089 else if ( DOT11F_WARNED( nStatus ) )
5090 {
5091 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005092 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005093 }
5094 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07005095 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5096 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07005097 )
5098 {
5099 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5100 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305101
5102 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5103 psessionEntry->peSessionId,
5104 pMacHdr->fc.subType));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005105 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5106 HAL_TXRX_FRM_802_11_MGMT,
5107 ANI_TXDIR_TODS,
5108 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5109 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305110 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5111 psessionEntry->peSessionId,
5112 halstatus));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005113 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5114 {
5115 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005116 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005117 nSirStatus );
5118 //Pkt will be freed up by the callback
5119 return eSIR_FAILURE;
5120 }
5121
5122 return eSIR_SUCCESS;
5123}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005124
5125/**
5126 * \brief Send a VHT Channel Switch Announcement
5127 *
5128 *
5129 * \param pMac Pointer to the global MAC datastructure
5130 *
5131 * \param peer MAC address to which this frame will be sent
5132 *
5133 * \param nChanWidth
5134 *
5135 * \param nNewChannel
5136 *
5137 *
5138 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5139 *
5140 *
5141 */
5142
5143tSirRetStatus
5144limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5145 tSirMacAddr peer,
5146 tANI_U8 nChanWidth,
5147 tANI_U8 nNewChannel,
5148 tANI_U8 ncbMode,
5149 tpPESession psessionEntry )
5150{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305151 tDot11fChannelSwitch frm;
5152 tANI_U8 *pFrame;
5153 tSirRetStatus nSirStatus;
5154 tpSirMacMgmtHdr pMacHdr;
5155 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5156 void *pPacket;
5157 eHalStatus halstatus;
5158 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005159
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305160 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005161
5162
5163 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5164 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5165 frm.ChanSwitchAnn.switchMode = 1;
5166 frm.ChanSwitchAnn.newChannel = nNewChannel;
5167 frm.ChanSwitchAnn.switchCount = 1;
5168 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
5169 frm.ExtChanSwitchAnn.present = 1;
5170 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
5171 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
5172 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
5173 frm.ChanSwitchAnn.present = 1;
5174 frm.WiderBWChanSwitchAnn.present = 1;
5175
5176 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5177 if ( DOT11F_FAILED( nStatus ) )
5178 {
5179 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005180 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005181 nStatus );
5182 // We'll fall back on the worst case scenario:
5183 nPayload = sizeof( tDot11fChannelSwitch );
5184 }
5185 else if ( DOT11F_WARNED( nStatus ) )
5186 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005187 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005188 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005189 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005190 }
5191
5192 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5193
5194 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5195 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5196 {
5197 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005198 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005199 return eSIR_FAILURE;
5200 }
5201 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305202 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005203
5204 // Next, we fill out the buffer descriptor:
5205 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5206 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5207 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305208 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5209 (tANI_U8 *) psessionEntry->bssId,
5210 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005211 if ( eSIR_SUCCESS != nSirStatus )
5212 {
5213 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005214 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005215 nSirStatus );
5216 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5217 return eSIR_FAILURE; // just allocated...
5218 }
5219 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5220 sizeof(tSirMacMgmtHdr),
5221 nPayload, &nPayload );
5222 if ( DOT11F_FAILED( nStatus ) )
5223 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005224 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005225 nStatus );
5226 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5227 return eSIR_FAILURE; // allocated!
5228 }
5229 else if ( DOT11F_WARNED( nStatus ) )
5230 {
5231 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005232 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005233 }
5234
5235 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005236 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5237 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005238 )
5239 {
5240 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5241 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305242
5243 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5244 psessionEntry->peSessionId,
5245 pMacHdr->fc.subType));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005246 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5247 HAL_TXRX_FRM_802_11_MGMT,
5248 ANI_TXDIR_TODS,
5249 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5250 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305251 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5252 psessionEntry->peSessionId,
5253 halstatus));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005254 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5255 {
5256 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005257 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005258 nSirStatus );
5259 //Pkt will be freed up by the callback
5260 return eSIR_FAILURE;
5261 }
5262
5263 return eSIR_SUCCESS;
5264
5265} // End limSendVHTChannelSwitchMgmtFrame.
5266
5267
5268
Mohit Khanna4a70d262012-09-11 16:30:12 -07005269#endif
5270
Jeff Johnson295189b2012-06-20 16:38:30 -07005271/**
5272 * \brief Send an ADDBA Req Action Frame to peer
5273 *
5274 * \sa limSendAddBAReq
5275 *
5276 * \param pMac The global tpAniSirGlobal object
5277 *
5278 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
5279 * the necessary parameters reqd by PE send the ADDBA Req Action
5280 * Frame to the peer
5281 *
5282 * \return eSIR_SUCCESS if setup completes successfully
5283 * eSIR_FAILURE is some problem is encountered
5284 */
5285tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305286 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07005287{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305288 tDot11fAddBAReq frmAddBAReq;
5289 tANI_U8 *pAddBAReqBuffer = NULL;
5290 tpSirMacMgmtHdr pMacHdr;
5291 tANI_U32 frameLen = 0, nStatus, nPayload;
5292 tSirRetStatus statusCode;
5293 eHalStatus halStatus;
5294 void *pPacket;
5295 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005296
5297 if(NULL == psessionEntry)
5298 {
5299 return eSIR_FAILURE;
5300 }
5301
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305302 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005303
5304 // Category - 3 (BA)
5305 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
5306
5307 // Action - 0 (ADDBA Req)
5308 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
5309
5310 // FIXME - Dialog Token, generalize this...
5311 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
5312
5313 // Fill the ADDBA Parameter Set
5314 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
5315 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
5316 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
5317
5318 // BA timeout
5319 // 0 - indicates no BA timeout
5320 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
5321
5322 // BA Starting Sequence Number
5323 // Fragment number will always be zero
5324 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
5325 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
5326 }
5327
5328 frmAddBAReq.BAStartingSequenceControl.ssn =
5329 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
5330
5331 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
5332
5333 if( DOT11F_FAILED( nStatus ))
5334 {
5335 limLog( pMac, LOGW,
5336 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005337 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005338 nStatus );
5339
5340 // We'll fall back on the worst case scenario:
5341 nPayload = sizeof( tDot11fAddBAReq );
5342 }
5343 else if( DOT11F_WARNED( nStatus ))
5344 {
5345 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005346 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005347 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005348 nStatus );
5349 }
5350
5351 // Add the MGMT header to frame length
5352 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5353
5354 // Need to allocate a buffer for ADDBA AF
5355 if( eHAL_STATUS_SUCCESS !=
5356 (halStatus = palPktAlloc( pMac->hHdd,
5357 HAL_TXRX_FRM_802_11_MGMT,
5358 (tANI_U16) frameLen,
5359 (void **) &pAddBAReqBuffer,
5360 (void **) &pPacket )))
5361 {
5362 // Log error
5363 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005364 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005365 frameLen,
5366 halStatus );
5367
5368 statusCode = eSIR_MEM_ALLOC_FAILED;
5369 goto returnAfterError;
5370 }
5371
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305372 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005373
5374 // Copy necessary info to BD
5375 if( eSIR_SUCCESS !=
5376 (statusCode = limPopulateMacHeader( pMac,
5377 pAddBAReqBuffer,
5378 SIR_MAC_MGMT_FRAME,
5379 SIR_MAC_MGMT_ACTION,
5380 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5381 goto returnAfterError;
5382
5383 // Update A3 with the BSSID
5384 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
5385
5386 #if 0
5387 cfgLen = SIR_MAC_ADDR_LENGTH;
5388 if( eSIR_SUCCESS != cfgGetStr( pMac,
5389 WNI_CFG_BSSID,
5390 (tANI_U8 *) pMacHdr->bssId,
5391 &cfgLen ))
5392 {
5393 limLog( pMac, LOGP,
5394 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005395 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005396
5397 // FIXME - Need to convert to tSirRetStatus
5398 statusCode = eSIR_FAILURE;
5399 goto returnAfterError;
5400 }
5401 #endif//TO SUPPORT BT-AMP
5402 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5403
Chet Lanctot186b5732013-03-18 10:26:30 -07005404#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005405 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005406#endif
5407
Jeff Johnson295189b2012-06-20 16:38:30 -07005408 // Now, we're ready to "pack" the frames
5409 nStatus = dot11fPackAddBAReq( pMac,
5410 &frmAddBAReq,
5411 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5412 nPayload,
5413 &nPayload );
5414
5415 if( DOT11F_FAILED( nStatus ))
5416 {
5417 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005418 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005419 nStatus );
5420
5421 // FIXME - Need to convert to tSirRetStatus
5422 statusCode = eSIR_FAILURE;
5423 goto returnAfterError;
5424 }
5425 else if( DOT11F_WARNED( nStatus ))
5426 {
5427 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005428 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5429 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 }
5431
5432 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005433 FL( "Sending an ADDBA REQ to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005434 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
5435
5436 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005437 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5438 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005439 )
5440 {
5441 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5442 }
5443
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305444 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5445 psessionEntry->peSessionId,
5446 pMacHdr->fc.subType));
5447 halStatus = halTxFrame( pMac,
5448 pPacket,
5449 (tANI_U16) frameLen,
5450 HAL_TXRX_FRM_802_11_MGMT,
5451 ANI_TXDIR_TODS,
5452 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5453 limTxComplete,
5454 pAddBAReqBuffer, txFlag );
5455 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5456 psessionEntry->peSessionId,
5457 halStatus));
5458 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005459 {
5460 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005461 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 halStatus );
5463
5464 // FIXME - Need to convert eHalStatus to tSirRetStatus
5465 statusCode = eSIR_FAILURE;
5466 //Pkt will be freed up by the callback
5467 return statusCode;
5468 }
5469 else
5470 return eSIR_SUCCESS;
5471
5472returnAfterError:
5473
5474 // Release buffer, if allocated
5475 if( NULL != pAddBAReqBuffer )
5476 palPktFree( pMac->hHdd,
5477 HAL_TXRX_FRM_802_11_MGMT,
5478 (void *) pAddBAReqBuffer,
5479 (void *) pPacket );
5480
5481 return statusCode;
5482}
5483
5484/**
5485 * \brief Send an ADDBA Rsp Action Frame to peer
5486 *
5487 * \sa limSendAddBARsp
5488 *
5489 * \param pMac The global tpAniSirGlobal object
5490 *
5491 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5492 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5493 * Frame to the peer
5494 *
5495 * \return eSIR_SUCCESS if setup completes successfully
5496 * eSIR_FAILURE is some problem is encountered
5497 */
5498tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5499 tpLimMlmAddBARsp pMlmAddBARsp,
5500 tpPESession psessionEntry)
5501{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305502 tDot11fAddBARsp frmAddBARsp;
5503 tANI_U8 *pAddBARspBuffer = NULL;
5504 tpSirMacMgmtHdr pMacHdr;
5505 tANI_U32 frameLen = 0, nStatus, nPayload;
5506 tSirRetStatus statusCode;
5507 eHalStatus halStatus;
5508 void *pPacket;
5509 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005510
5511 if(NULL == psessionEntry)
5512 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005513 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005514 return eSIR_FAILURE;
5515 }
5516
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305517 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005518
5519 // Category - 3 (BA)
5520 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5521 // Action - 1 (ADDBA Rsp)
5522 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5523
5524 // Should be same as the one we received in the ADDBA Req
5525 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5526
5527 // ADDBA Req status
5528 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5529
5530 // Fill the ADDBA Parameter Set as provided by caller
5531 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5532 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5533 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005534
5535 if(psessionEntry->isAmsduSupportInAMPDU)
5536 {
5537 frmAddBARsp.AddBAParameterSet.amsduSupported =
5538 psessionEntry->amsduSupportedInBA;
5539 }
5540 else
5541 {
5542 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5543 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005544
5545 // BA timeout
5546 // 0 - indicates no BA timeout
5547 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5548
5549 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5550
5551 if( DOT11F_FAILED( nStatus ))
5552 {
5553 limLog( pMac, LOGW,
5554 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005555 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005556 nStatus );
5557
5558 // We'll fall back on the worst case scenario:
5559 nPayload = sizeof( tDot11fAddBARsp );
5560 }
5561 else if( DOT11F_WARNED( nStatus ))
5562 {
5563 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005564 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005565 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005566 nStatus );
5567 }
5568
5569 // Need to allocate a buffer for ADDBA AF
5570 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5571
5572 // Allocate shared memory
5573 if( eHAL_STATUS_SUCCESS !=
5574 (halStatus = palPktAlloc( pMac->hHdd,
5575 HAL_TXRX_FRM_802_11_MGMT,
5576 (tANI_U16) frameLen,
5577 (void **) &pAddBARspBuffer,
5578 (void **) &pPacket )))
5579 {
5580 // Log error
5581 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005582 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005583 frameLen,
5584 halStatus );
5585
5586 statusCode = eSIR_MEM_ALLOC_FAILED;
5587 goto returnAfterError;
5588 }
5589
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305590 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005591
5592 // Copy necessary info to BD
5593 if( eSIR_SUCCESS !=
5594 (statusCode = limPopulateMacHeader( pMac,
5595 pAddBARspBuffer,
5596 SIR_MAC_MGMT_FRAME,
5597 SIR_MAC_MGMT_ACTION,
5598 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5599 goto returnAfterError;
5600
5601 // Update A3 with the BSSID
5602
5603 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5604
5605 #if 0
5606 cfgLen = SIR_MAC_ADDR_LENGTH;
5607 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5608 WNI_CFG_BSSID,
5609 (tANI_U8 *) pMacHdr->bssId,
5610 &cfgLen ))
5611 {
5612 limLog( pMac, LOGP,
5613 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005614 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005615
5616 // FIXME - Need to convert to tSirRetStatus
5617 statusCode = eSIR_FAILURE;
5618 goto returnAfterError;
5619 }
5620 #endif // TO SUPPORT BT-AMP
5621 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5622
Chet Lanctot186b5732013-03-18 10:26:30 -07005623#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005624 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005625#endif
5626
Jeff Johnson295189b2012-06-20 16:38:30 -07005627 // Now, we're ready to "pack" the frames
5628 nStatus = dot11fPackAddBARsp( pMac,
5629 &frmAddBARsp,
5630 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5631 nPayload,
5632 &nPayload );
5633
5634 if( DOT11F_FAILED( nStatus ))
5635 {
5636 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005637 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005638 nStatus );
5639
5640 // FIXME - Need to convert to tSirRetStatus
5641 statusCode = eSIR_FAILURE;
5642 goto returnAfterError;
5643 }
5644 else if( DOT11F_WARNED( nStatus ))
5645 {
5646 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005647 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5648 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005649 }
5650
5651 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005652 FL( "Sending an ADDBA RSP to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005653 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5654
5655 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005656 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5657 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 )
5659 {
5660 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5661 }
5662
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305663 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5664 psessionEntry->peSessionId,
5665 pMacHdr->fc.subType));
5666 halStatus = halTxFrame( pMac,
5667 pPacket,
5668 (tANI_U16) frameLen,
5669 HAL_TXRX_FRM_802_11_MGMT,
5670 ANI_TXDIR_TODS,
5671 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5672 limTxComplete,
5673 pAddBARspBuffer, txFlag );
5674 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5675 psessionEntry->peSessionId,
5676 halStatus));
5677 if( eHAL_STATUS_SUCCESS != halStatus )
5678 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005679 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005680 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005681 halStatus );
5682
5683 // FIXME - HAL error codes are different from PE error
5684 // codes!! And, this routine is returning tSirRetStatus
5685 statusCode = eSIR_FAILURE;
5686 //Pkt will be freed up by the callback
5687 return statusCode;
5688 }
5689 else
5690 return eSIR_SUCCESS;
5691
5692 returnAfterError:
Jeff Johnson295189b2012-06-20 16:38:30 -07005693 // Release buffer, if allocated
5694 if( NULL != pAddBARspBuffer )
5695 palPktFree( pMac->hHdd,
5696 HAL_TXRX_FRM_802_11_MGMT,
5697 (void *) pAddBARspBuffer,
5698 (void *) pPacket );
5699
5700 return statusCode;
5701}
5702
5703/**
5704 * \brief Send a DELBA Indication Action Frame to peer
5705 *
5706 * \sa limSendDelBAInd
5707 *
5708 * \param pMac The global tpAniSirGlobal object
5709 *
5710 * \param peerMacAddr MAC Address of peer
5711 *
5712 * \param reasonCode Reason for the DELBA notification
5713 *
5714 * \param pBAParameterSet The DELBA Parameter Set.
5715 * This identifies the TID for which the BA session is
5716 * being deleted.
5717 *
5718 * \return eSIR_SUCCESS if setup completes successfully
5719 * eSIR_FAILURE is some problem is encountered
5720 */
5721tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5722 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5723{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305724 tDot11fDelBAInd frmDelBAInd;
5725 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005726 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305727 tpSirMacMgmtHdr pMacHdr;
5728 tANI_U32 frameLen = 0, nStatus, nPayload;
5729 tSirRetStatus statusCode;
5730 eHalStatus halStatus;
5731 void *pPacket;
5732 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005733
5734 if(NULL == psessionEntry)
5735 {
5736 return eSIR_FAILURE;
5737 }
5738
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305739 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005740
5741 // Category - 3 (BA)
5742 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5743 // Action - 2 (DELBA)
5744 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5745
5746 // Fill the DELBA Parameter Set as provided by caller
5747 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5748 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5749
5750 // BA Starting Sequence Number
5751 // Fragment number will always be zero
5752 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5753
5754 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5755
5756 if( DOT11F_FAILED( nStatus ))
5757 {
5758 limLog( pMac, LOGW,
5759 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005760 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005761 nStatus );
5762
5763 // We'll fall back on the worst case scenario:
5764 nPayload = sizeof( tDot11fDelBAInd );
5765 }
5766 else if( DOT11F_WARNED( nStatus ))
5767 {
5768 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005769 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005770 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005771 nStatus );
5772 }
5773
5774 // Add the MGMT header to frame length
5775 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5776
5777 // Allocate shared memory
5778 if( eHAL_STATUS_SUCCESS !=
5779 (halStatus = palPktAlloc( pMac->hHdd,
5780 HAL_TXRX_FRM_802_11_MGMT,
5781 (tANI_U16) frameLen,
5782 (void **) &pDelBAIndBuffer,
5783 (void **) &pPacket )))
5784 {
5785 // Log error
5786 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005787 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005788 frameLen,
5789 halStatus );
5790
5791 statusCode = eSIR_MEM_ALLOC_FAILED;
5792 goto returnAfterError;
5793 }
5794
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305795 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005796
5797 // Copy necessary info to BD
5798 if( eSIR_SUCCESS !=
5799 (statusCode = limPopulateMacHeader( pMac,
5800 pDelBAIndBuffer,
5801 SIR_MAC_MGMT_FRAME,
5802 SIR_MAC_MGMT_ACTION,
5803 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5804 goto returnAfterError;
5805
5806 // Update A3 with the BSSID
5807 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5808
5809 #if 0
5810 cfgLen = SIR_MAC_ADDR_LENGTH;
5811 if( eSIR_SUCCESS != cfgGetStr( pMac,
5812 WNI_CFG_BSSID,
5813 (tANI_U8 *) pMacHdr->bssId,
5814 &cfgLen ))
5815 {
5816 limLog( pMac, LOGP,
5817 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005818 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005819
5820 // FIXME - Need to convert to tSirRetStatus
5821 statusCode = eSIR_FAILURE;
5822 goto returnAfterError;
5823 }
5824 #endif //TO SUPPORT BT-AMP
5825 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5826
Chet Lanctot186b5732013-03-18 10:26:30 -07005827#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005828 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005829#endif
5830
Jeff Johnson295189b2012-06-20 16:38:30 -07005831 // Now, we're ready to "pack" the frames
5832 nStatus = dot11fPackDelBAInd( pMac,
5833 &frmDelBAInd,
5834 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5835 nPayload,
5836 &nPayload );
5837
5838 if( DOT11F_FAILED( nStatus ))
5839 {
5840 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005841 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005842 nStatus );
5843
5844 // FIXME - Need to convert to tSirRetStatus
5845 statusCode = eSIR_FAILURE;
5846 goto returnAfterError;
5847 }
5848 else if( DOT11F_WARNED( nStatus ))
5849 {
5850 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005851 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
5852 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005853 }
5854
5855 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005856 FL( "Sending a DELBA IND to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005857 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5858
5859 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005860 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5861 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005862 )
5863 {
5864 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5865 }
5866
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305867 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5868 psessionEntry->peSessionId,
5869 pMacHdr->fc.subType));
5870 halStatus = halTxFrame( pMac,
5871 pPacket,
5872 (tANI_U16) frameLen,
5873 HAL_TXRX_FRM_802_11_MGMT,
5874 ANI_TXDIR_TODS,
5875 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5876 limTxComplete,
5877 pDelBAIndBuffer, txFlag );
5878 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5879 psessionEntry->peSessionId,
5880 halStatus));
5881 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005882 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005883 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005884 statusCode = eSIR_FAILURE;
5885 //Pkt will be freed up by the callback
5886 return statusCode;
5887 }
5888 else
5889 return eSIR_SUCCESS;
5890
5891 returnAfterError:
5892
5893 // Release buffer, if allocated
5894 if( NULL != pDelBAIndBuffer )
5895 palPktFree( pMac->hHdd,
5896 HAL_TXRX_FRM_802_11_MGMT,
5897 (void *) pDelBAIndBuffer,
5898 (void *) pPacket );
5899
5900 return statusCode;
5901}
5902
5903#if defined WLAN_FEATURE_VOWIFI
5904
5905/**
5906 * \brief Send a Neighbor Report Request Action frame
5907 *
5908 *
5909 * \param pMac Pointer to the global MAC structure
5910 *
5911 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5912 *
5913 * \param peer mac address of peer station.
5914 *
5915 * \param psessionEntry address of session entry.
5916 *
5917 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5918 *
5919 *
5920 */
5921
5922tSirRetStatus
5923limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5924 tpSirMacNeighborReportReq pNeighborReq,
5925 tSirMacAddr peer,
5926 tpPESession psessionEntry
5927 )
5928{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305929 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005930 tDot11fNeighborReportRequest frm;
5931 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305932 tpSirMacMgmtHdr pMacHdr;
5933 tANI_U32 nBytes, nPayload, nStatus;
5934 void *pPacket;
5935 eHalStatus halstatus;
5936 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005937
5938 if ( psessionEntry == NULL )
5939 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005940 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005941 return eSIR_FAILURE;
5942 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305943 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005944
5945 frm.Category.category = SIR_MAC_ACTION_RRM;
5946 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5947 frm.DialogToken.token = pNeighborReq->dialogToken;
5948
5949
5950 if( pNeighborReq->ssid_present )
5951 {
5952 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5953 }
5954
5955 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5956 if ( DOT11F_FAILED( nStatus ) )
5957 {
5958 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005959 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005960 nStatus );
5961 // We'll fall back on the worst case scenario:
5962 nPayload = sizeof( tDot11fNeighborReportRequest );
5963 }
5964 else if ( DOT11F_WARNED( nStatus ) )
5965 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005966 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005967 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005968 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005969 }
5970
5971 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5972
5973 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5974 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5975 {
5976 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005977 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005978 return eSIR_FAILURE;
5979 }
5980
5981 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305982 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005983
5984 // Copy necessary info to BD
5985 if( eSIR_SUCCESS !=
5986 (statusCode = limPopulateMacHeader( pMac,
5987 pFrame,
5988 SIR_MAC_MGMT_FRAME,
5989 SIR_MAC_MGMT_ACTION,
5990 peer, psessionEntry->selfMacAddr)))
5991 goto returnAfterError;
5992
5993 // Update A3 with the BSSID
5994 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5995
5996 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5997
Chet Lanctot186b5732013-03-18 10:26:30 -07005998#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005999 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006000#endif
6001
Jeff Johnson295189b2012-06-20 16:38:30 -07006002 // Now, we're ready to "pack" the frames
6003 nStatus = dot11fPackNeighborReportRequest( pMac,
6004 &frm,
6005 pFrame + sizeof( tSirMacMgmtHdr ),
6006 nPayload,
6007 &nPayload );
6008
6009 if( DOT11F_FAILED( nStatus ))
6010 {
6011 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006012 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006013 nStatus );
6014
6015 // FIXME - Need to convert to tSirRetStatus
6016 statusCode = eSIR_FAILURE;
6017 goto returnAfterError;
6018 }
6019 else if( DOT11F_WARNED( nStatus ))
6020 {
6021 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006022 FL( "There were warnings while packing Neighbor Report "
6023 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006024 }
6025
6026 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006027 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006028 limPrintMacAddr( pMac, peer, LOGW );
6029
6030 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006031 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6032 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006033 )
6034 {
6035 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6036 }
6037
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306038 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6039 psessionEntry->peSessionId,
6040 pMacHdr->fc.subType));
6041 halstatus = halTxFrame( pMac,
6042 pPacket,
6043 (tANI_U16) nBytes,
6044 HAL_TXRX_FRM_802_11_MGMT,
6045 ANI_TXDIR_TODS,
6046 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6047 limTxComplete,
6048 pFrame, txFlag );
6049 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6050 psessionEntry->peSessionId,
6051 halstatus));
6052 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006053 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006054 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006055 statusCode = eSIR_FAILURE;
6056 //Pkt will be freed up by the callback
6057 return statusCode;
6058 }
6059 else
6060 return eSIR_SUCCESS;
6061
6062returnAfterError:
6063 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6064
6065 return statusCode;
6066} // End limSendNeighborReportRequestFrame.
6067
6068/**
6069 * \brief Send a Link Report Action frame
6070 *
6071 *
6072 * \param pMac Pointer to the global MAC structure
6073 *
6074 * \param pLinkReport Address of a tSirMacLinkReport
6075 *
6076 * \param peer mac address of peer station.
6077 *
6078 * \param psessionEntry address of session entry.
6079 *
6080 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6081 *
6082 *
6083 */
6084
6085tSirRetStatus
6086limSendLinkReportActionFrame(tpAniSirGlobal pMac,
6087 tpSirMacLinkReport pLinkReport,
6088 tSirMacAddr peer,
6089 tpPESession psessionEntry
6090 )
6091{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306092 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006093 tDot11fLinkMeasurementReport frm;
6094 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306095 tpSirMacMgmtHdr pMacHdr;
6096 tANI_U32 nBytes, nPayload, nStatus;
6097 void *pPacket;
6098 eHalStatus halstatus;
6099 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006100
6101
6102 if ( psessionEntry == NULL )
6103 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006104 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006105 return eSIR_FAILURE;
6106 }
6107
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306108 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006109
6110 frm.Category.category = SIR_MAC_ACTION_RRM;
6111 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
6112 frm.DialogToken.token = pLinkReport->dialogToken;
6113
6114
6115 //IEEE Std. 802.11 7.3.2.18. for the report element.
6116 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
6117 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
6118 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
6119 //such case this way than changing the frame parser.
6120 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
6121 frm.TPCEleLen.TPCLen = 2;
6122 frm.TxPower.txPower = pLinkReport->txPower;
6123 frm.LinkMargin.linkMargin = 0;
6124
6125 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
6126 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
6127 frm.RCPI.rcpi = pLinkReport->rcpi;
6128 frm.RSNI.rsni = pLinkReport->rsni;
6129
6130 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
6131 if ( DOT11F_FAILED( nStatus ) )
6132 {
6133 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006134 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006135 nStatus );
6136 // We'll fall back on the worst case scenario:
6137 nPayload = sizeof( tDot11fLinkMeasurementReport );
6138 }
6139 else if ( DOT11F_WARNED( nStatus ) )
6140 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006141 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006142 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006143 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006144 }
6145
6146 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6147
6148 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6149 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6150 {
6151 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006152 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006153 return eSIR_FAILURE;
6154 }
6155
6156 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306157 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006158
6159 // Copy necessary info to BD
6160 if( eSIR_SUCCESS !=
6161 (statusCode = limPopulateMacHeader( pMac,
6162 pFrame,
6163 SIR_MAC_MGMT_FRAME,
6164 SIR_MAC_MGMT_ACTION,
6165 peer, psessionEntry->selfMacAddr)))
6166 goto returnAfterError;
6167
6168 // Update A3 with the BSSID
6169 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6170
6171 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6172
Chet Lanctot186b5732013-03-18 10:26:30 -07006173#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006174 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006175#endif
6176
Jeff Johnson295189b2012-06-20 16:38:30 -07006177 // Now, we're ready to "pack" the frames
6178 nStatus = dot11fPackLinkMeasurementReport( pMac,
6179 &frm,
6180 pFrame + sizeof( tSirMacMgmtHdr ),
6181 nPayload,
6182 &nPayload );
6183
6184 if( DOT11F_FAILED( nStatus ))
6185 {
6186 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006187 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006188 nStatus );
6189
6190 // FIXME - Need to convert to tSirRetStatus
6191 statusCode = eSIR_FAILURE;
6192 goto returnAfterError;
6193 }
6194 else if( DOT11F_WARNED( nStatus ))
6195 {
6196 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006197 FL( "There were warnings while packing Link Report (0x%08x)." ),
6198 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006199 }
6200
6201 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006202 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006203 limPrintMacAddr( pMac, peer, LOGW );
6204
6205 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006206 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6207 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006208 )
6209 {
6210 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6211 }
6212
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306213 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6214 psessionEntry->peSessionId,
6215 pMacHdr->fc.subType));
6216 halstatus = halTxFrame( pMac,
6217 pPacket,
6218 (tANI_U16) nBytes,
6219 HAL_TXRX_FRM_802_11_MGMT,
6220 ANI_TXDIR_TODS,
6221 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6222 limTxComplete,
6223 pFrame, txFlag );
6224 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6225 psessionEntry->peSessionId,
6226 halstatus));
6227 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006228 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006229 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006230 statusCode = eSIR_FAILURE;
6231 //Pkt will be freed up by the callback
6232 return statusCode;
6233 }
6234 else
6235 return eSIR_SUCCESS;
6236
6237returnAfterError:
6238 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6239
6240 return statusCode;
6241} // End limSendLinkReportActionFrame.
6242
6243/**
6244 * \brief Send a Beacon Report Action frame
6245 *
6246 *
6247 * \param pMac Pointer to the global MAC structure
6248 *
6249 * \param dialog_token dialog token to be used in the action frame.
6250 *
6251 * \param num_report number of reports in pRRMReport.
6252 *
6253 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
6254 *
6255 * \param peer mac address of peer station.
6256 *
6257 * \param psessionEntry address of session entry.
6258 *
6259 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6260 *
6261 *
6262 */
6263
6264tSirRetStatus
6265limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
6266 tANI_U8 dialog_token,
6267 tANI_U8 num_report,
6268 tpSirMacRadioMeasureReport pRRMReport,
6269 tSirMacAddr peer,
6270 tpPESession psessionEntry
6271 )
6272{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306273 tSirRetStatus statusCode = eSIR_SUCCESS;
6274 tANI_U8 *pFrame;
6275 tpSirMacMgmtHdr pMacHdr;
6276 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006277 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306278 eHalStatus halstatus;
6279 tANI_U8 i;
6280 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006281
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006282 tDot11fRadioMeasurementReport *frm =
6283 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
6284 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006285 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006286 return eSIR_FAILURE;
6287 }
6288
Jeff Johnson295189b2012-06-20 16:38:30 -07006289 if ( psessionEntry == NULL )
6290 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006291 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006292 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006293 return eSIR_FAILURE;
6294 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306295 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006296
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006297 frm->Category.category = SIR_MAC_ACTION_RRM;
6298 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
6299 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07006300
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006301 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 -07006302
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006303 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006304 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006305 frm->MeasurementReport[i].type = pRRMReport[i].type;
6306 frm->MeasurementReport[i].token = pRRMReport[i].token;
6307 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006308 switch( pRRMReport[i].type )
6309 {
6310 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006311 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
6312 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6313 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
6314 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006315 break;
6316 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05306317 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6318 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006319 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006320 break;
6321 }
6322 }
6323
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006324 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07006325 if ( DOT11F_FAILED( nStatus ) )
6326 {
6327 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006328 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006329 nStatus );
6330 // We'll fall back on the worst case scenario:
6331 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006332 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006333 return eSIR_FAILURE;
6334 }
6335 else if ( DOT11F_WARNED( nStatus ) )
6336 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006337 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006338 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006339 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006340 }
6341
6342 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6343
6344 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6345 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6346 {
6347 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006348 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006349 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006350 return eSIR_FAILURE;
6351 }
6352
6353 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306354 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006355
6356 // Copy necessary info to BD
6357 if( eSIR_SUCCESS !=
6358 (statusCode = limPopulateMacHeader( pMac,
6359 pFrame,
6360 SIR_MAC_MGMT_FRAME,
6361 SIR_MAC_MGMT_ACTION,
6362 peer, psessionEntry->selfMacAddr)))
6363 goto returnAfterError;
6364
6365 // Update A3 with the BSSID
6366 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6367
6368 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6369
Chet Lanctot186b5732013-03-18 10:26:30 -07006370#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006371 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006372#endif
6373
Jeff Johnson295189b2012-06-20 16:38:30 -07006374 // Now, we're ready to "pack" the frames
6375 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006376 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07006377 pFrame + sizeof( tSirMacMgmtHdr ),
6378 nPayload,
6379 &nPayload );
6380
6381 if( DOT11F_FAILED( nStatus ))
6382 {
6383 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006384 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006385 nStatus );
6386
6387 // FIXME - Need to convert to tSirRetStatus
6388 statusCode = eSIR_FAILURE;
6389 goto returnAfterError;
6390 }
6391 else if( DOT11F_WARNED( nStatus ))
6392 {
6393 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006394 FL( "There were warnings while packing Radio "
6395 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006396 }
6397
6398 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006399 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006400 limPrintMacAddr( pMac, peer, LOGW );
6401
6402 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006403 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6404 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006405 )
6406 {
6407 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6408 }
6409
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306410 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6411 psessionEntry->peSessionId,
6412 pMacHdr->fc.subType));
6413 halstatus = halTxFrame( pMac,
6414 pPacket,
6415 (tANI_U16) nBytes,
6416 HAL_TXRX_FRM_802_11_MGMT,
6417 ANI_TXDIR_TODS,
6418 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6419 limTxComplete,
6420 pFrame, txFlag );
6421 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6422 psessionEntry->peSessionId,
6423 halstatus));
6424 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006425 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006426 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006427 statusCode = eSIR_FAILURE;
6428 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006429 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006430 return statusCode;
6431 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006432 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006433 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006434 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006435 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006436
6437returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006438 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006439 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07006440 return statusCode;
6441} // End limSendBeaconReportActionFrame.
6442
6443#endif
6444
6445#ifdef WLAN_FEATURE_11W
6446/**
Chet Lanctot8cecea22014-02-11 19:09:36 -08006447 * \brief Send SA query request action frame to peer
6448 *
6449 * \sa limSendSaQueryRequestFrame
6450 *
6451 *
6452 * \param pMac The global tpAniSirGlobal object
6453 *
6454 * \param transId Transaction identifier
6455 *
6456 * \param peer The Mac address of the station to which this action frame is addressed
6457 *
6458 * \param psessionEntry The PE session entry
6459 *
6460 * \return eSIR_SUCCESS if setup completes successfully
6461 * eSIR_FAILURE is some problem is encountered
6462 */
6463
6464tSirRetStatus limSendSaQueryRequestFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
6465 tSirMacAddr peer, tpPESession psessionEntry )
6466{
6467
6468 tDot11fSaQueryReq frm; // SA query request action frame
6469 tANI_U8 *pFrame;
6470 tSirRetStatus nSirStatus;
6471 tpSirMacMgmtHdr pMacHdr;
6472 tANI_U32 nBytes, nPayload, nStatus;
6473 void *pPacket;
6474 eHalStatus halstatus;
6475 tANI_U8 txFlag = 0;
6476
6477 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
6478 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6479 /* 11w action field is :
6480 action: 0 --> SA Query Request action frame
6481 action: 1 --> SA Query Response action frame */
6482 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
6483 /* 11w SA Query Request transId */
6484 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
6485
6486 nStatus = dot11fGetPackedSaQueryReqSize(pMac, &frm, &nPayload);
6487 if ( DOT11F_FAILED( nStatus ) )
6488 {
6489 limLog( pMac, LOGP, FL("Failed to calculate the packed size "
6490 "for an SA Query Request (0x%08x)."),
6491 nStatus );
6492 // We'll fall back on the worst case scenario:
6493 nPayload = sizeof( tDot11fSaQueryReq );
6494 }
6495 else if ( DOT11F_WARNED( nStatus ) )
6496 {
6497 limLog( pMac, LOGW, FL("There were warnings while calculating "
6498 "the packed size for an SA Query Request"
6499 " (0x%08x)."), nStatus );
6500 }
6501
6502 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6503 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6504 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6505 {
6506 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA Query Request "
6507 "action frame"), nBytes );
6508 return eSIR_FAILURE;
6509 }
6510
6511 // Paranoia:
6512 vos_mem_set( pFrame, nBytes, 0 );
6513
6514 // Copy necessary info to BD
6515 nSirStatus = limPopulateMacHeader( pMac,
6516 pFrame,
6517 SIR_MAC_MGMT_FRAME,
6518 SIR_MAC_MGMT_ACTION,
6519 peer, psessionEntry->selfMacAddr );
6520 if ( eSIR_SUCCESS != nSirStatus )
6521 goto returnAfterError;
6522
6523 // Update A3 with the BSSID
6524 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6525
6526 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6527
6528 // Since this is a SA Query Request, set the "protect" (aka WEP) bit
6529 // in the FC
6530 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
6531
6532 // Pack 11w SA Query Request frame
6533 nStatus = dot11fPackSaQueryReq( pMac,
6534 &frm,
6535 pFrame + sizeof( tSirMacMgmtHdr ),
6536 nPayload,
6537 &nPayload );
6538
6539 if ( DOT11F_FAILED( nStatus ))
6540 {
6541 limLog( pMac, LOGE,
6542 FL( "Failed to pack an SA Query Request (0x%08x)." ),
6543 nStatus );
6544 // FIXME - Need to convert to tSirRetStatus
6545 nSirStatus = eSIR_FAILURE;
6546 goto returnAfterError;
6547 }
6548 else if ( DOT11F_WARNED( nStatus ))
6549 {
6550 limLog( pMac, LOGW,
6551 FL( "There were warnings while packing SA Query Request (0x%08x)." ),
6552 nStatus);
6553 }
6554
6555 limLog( pMac, LOG1,
6556 FL( "Sending an SA Query Request to " ));
6557 limPrintMacAddr( pMac, peer, LOG1 );
6558 limPrintMacAddr( pMac, peer, LOGE );
6559 limLog( pMac, LOGE,
6560 FL( "Sending an SA Query Request from " ));
6561 limPrintMacAddr( pMac, psessionEntry->selfMacAddr, LOGE );
6562
6563 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
6564#ifdef WLAN_FEATURE_P2P
6565 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6566 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
6567#endif
6568 )
6569 {
6570 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6571 }
6572
6573 halstatus = halTxFrame( pMac,
6574 pPacket,
6575 (tANI_U16) nBytes,
6576 HAL_TXRX_FRM_802_11_MGMT,
6577 ANI_TXDIR_TODS,
6578 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6579 limTxComplete,
6580 pFrame, txFlag );
6581 if ( eHAL_STATUS_SUCCESS != halstatus )
6582 {
6583 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6584 nSirStatus = eSIR_FAILURE;
6585 //Pkt will be freed up by the callback
6586 return nSirStatus;
6587 }
6588 else {
6589 return eSIR_SUCCESS;
6590 }
6591
6592returnAfterError:
6593 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6594 return nSirStatus;
6595} // End limSendSaQueryRequestFrame
6596
6597/**
Jeff Johnson295189b2012-06-20 16:38:30 -07006598 * \brief Send SA query response action frame to peer
6599 *
6600 * \sa limSendSaQueryResponseFrame
6601 *
6602 *
6603 * \param pMac The global tpAniSirGlobal object
6604 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006605 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006606 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006607 * \param peer The Mac address of the AP to which this action frame is addressed
6608 *
6609 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07006610 *
6611 * \return eSIR_SUCCESS if setup completes successfully
6612 * eSIR_FAILURE is some problem is encountered
6613 */
6614
Chet Lanctot186b5732013-03-18 10:26:30 -07006615tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006616tSirMacAddr peer,tpPESession psessionEntry)
6617{
6618
Chet Lanctot186b5732013-03-18 10:26:30 -07006619 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006620 tANI_U8 *pFrame;
6621 tSirRetStatus nSirStatus;
6622 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07006623 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006624 void *pPacket;
6625 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306626 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006627
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306628 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07006629 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6630 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07006631 action: 0 --> SA query request action frame
6632 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07006633 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
6634 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07006635 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07006636 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006637
Chet Lanctot186b5732013-03-18 10:26:30 -07006638 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6639 if ( DOT11F_FAILED( nStatus ) )
6640 {
6641 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6642 "or a SA Query Response (0x%08x)."),
6643 nStatus );
6644 // We'll fall back on the worst case scenario:
6645 nPayload = sizeof( tDot11fSaQueryRsp );
6646 }
6647 else if ( DOT11F_WARNED( nStatus ) )
6648 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006649 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006650 "the packed size for an SA Query Response"
6651 " (0x%08x)."), nStatus );
6652 }
6653
Jeff Johnson295189b2012-06-20 16:38:30 -07006654 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6655 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6656 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6657 {
6658 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006659 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006660 return eSIR_FAILURE;
6661 }
6662
6663 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306664 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006665
Chet Lanctot186b5732013-03-18 10:26:30 -07006666 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006667 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006668 pFrame,
6669 SIR_MAC_MGMT_FRAME,
6670 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006671 peer, psessionEntry->selfMacAddr );
6672 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006673 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006674
Chet Lanctot186b5732013-03-18 10:26:30 -07006675 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006676 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6677
Chet Lanctot186b5732013-03-18 10:26:30 -07006678 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006679
Chet Lanctot186b5732013-03-18 10:26:30 -07006680 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6681 // in the FC
Chet Lanctot8cecea22014-02-11 19:09:36 -08006682 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -07006683
Chet Lanctot186b5732013-03-18 10:26:30 -07006684 // Pack 11w SA query response frame
6685 nStatus = dot11fPackSaQueryRsp( pMac,
6686 &frm,
6687 pFrame + sizeof( tSirMacMgmtHdr ),
6688 nPayload,
6689 &nPayload );
6690
6691 if ( DOT11F_FAILED( nStatus ))
6692 {
6693 limLog( pMac, LOGE,
6694 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6695 nStatus );
6696 // FIXME - Need to convert to tSirRetStatus
6697 nSirStatus = eSIR_FAILURE;
6698 goto returnAfterError;
6699 }
6700 else if ( DOT11F_WARNED( nStatus ))
6701 {
6702 limLog( pMac, LOGW,
6703 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6704 nStatus);
6705 }
6706
6707 limLog( pMac, LOG1,
6708 FL( "Sending a SA Query Response to " ));
6709 limPrintMacAddr( pMac, peer, LOGW );
6710
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006711 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006712#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006713 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6714 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006715#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006716 )
6717 {
6718 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6719 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006720
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306721 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6722 psessionEntry->peSessionId,
6723 pMacHdr->fc.subType));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006724 halstatus = halTxFrame( pMac,
6725 pPacket,
6726 (tANI_U16) nBytes,
6727 HAL_TXRX_FRM_802_11_MGMT,
6728 ANI_TXDIR_TODS,
6729 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6730 limTxComplete,
6731 pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306732 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6733 psessionEntry->peSessionId,
6734 halstatus));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006735 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006736 {
6737 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6738 nSirStatus = eSIR_FAILURE;
6739 //Pkt will be freed up by the callback
6740 return nSirStatus;
6741 }
6742 else {
6743 return eSIR_SUCCESS;
6744 }
6745
6746returnAfterError:
6747 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6748 return nSirStatus;
6749} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006750#endif