blob: 4a3f3288c30320f5e279f7e463bbf47f25557ca2 [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;
653 tANI_U32 cfg, nPayload, nBytes, nStatus;
654 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;
Jeff Johnson295189b2012-06-20 16:38:30 -0700674 if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests
675 {
676 return; // in this case.
677 }
678
679 if(NULL == psessionEntry)
680 {
681 return;
682 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530683
684 pFrm = vos_mem_malloc(sizeof(tDot11fProbeResponse));
685 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700686 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530687 limLog(pMac, LOGE, FL("Unable to allocate memory in limSendProbeRspMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700688 return;
689 }
690
Jeff Johnson295189b2012-06-20 16:38:30 -0700691 // Fill out 'frm', after which we'll just hand the struct off to
692 // 'dot11fPackProbeResponse'.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530693 vos_mem_set(( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700694
695 // Timestamp to be updated by TFP, below.
696
697 // Beacon Interval:
Jeff Johnson295189b2012-06-20 16:38:30 -0700698 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
699 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700700 pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -0700701 }
702 else
703 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800704 nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg);
705 if (eSIR_SUCCESS != nSirStatus)
706 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700707 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d)."),
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800708 nSirStatus );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530709 vos_mem_free(pFrm);
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800710 return;
711 }
712 pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg;
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800713 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700714
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700715 PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry );
716 PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700717 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700718 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700719
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700720 PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry);
721 PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700722
Jeff Johnson295189b2012-06-20 16:38:30 -0700723
Jeff Johnson295189b2012-06-20 16:38:30 -0700724 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
725 {
726 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
727 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700728 PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700729 }
730 }
731 else
732 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800733 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700734 limLog(pMac, LOGP,"Failed to cfg get id %d", WNI_CFG_WPS_ENABLE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700735
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800736 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
Jeff Johnson295189b2012-06-20 16:38:30 -0700737
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800738 if (wpsApEnable)
739 {
740 PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes);
741 }
742
743 if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
744 {
745 PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
746 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
747 }
748
749 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
750 {
751 DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
752 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
753 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700754 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700755
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700756 PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry);
757 PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700758
Jeff Johnson295189b2012-06-20 16:38:30 -0700759
760 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700761 PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700762
763
764 // N.B. In earlier implementations, the RSN IE would be placed in
765 // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined.
766 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700767 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700768
769 //Populate HT IEs, when operating in 11n or Taurus modes.
Jeff Johnsone7245742012-09-05 17:12:55 -0700770 if ( psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -0700771 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700772 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700773 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700774 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700775#ifdef WLAN_FEATURE_11AC
776 if(psessionEntry->vhtCapability)
777 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -0800778 limLog( pMac, LOG1, FL("Populate VHT IE in Probe Response"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700779 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
780 PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation );
Jeff Johnsone7245742012-09-05 17:12:55 -0700781 // we do not support multi users yet
782 //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad );
Sandeep Puligilla60342762014-01-30 21:05:37 +0530783 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -0700784 }
785#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700786
Sandeep Puligilla60342762014-01-30 21:05:37 +0530787
Jeff Johnson295189b2012-06-20 16:38:30 -0700788 if ( psessionEntry->pLimStartBssReq )
789 {
790 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700791 &pFrm->WPA );
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700792 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
793 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -0700794 }
795
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700796 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700797
798#if defined(FEATURE_WLAN_WAPI)
799 if( psessionEntry->pLimStartBssReq )
800 {
801 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700802 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700803 }
804
805#endif // defined(FEATURE_WLAN_WAPI)
806
807
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700808 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -0700809 if ( DOT11F_FAILED( nStatus ) )
810 {
811 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700812 "or a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700813 nStatus );
814 // We'll fall back on the worst case scenario:
815 nPayload = sizeof( tDot11fProbeResponse );
816 }
817 else if ( DOT11F_WARNED( nStatus ) )
818 {
819 limLog( pMac, LOGW, FL("There were warnings while calculating"
820 "the packed size for a Probe Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700821 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700822 }
823
824 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
825
826 addnIEPresent = false;
827
Jeff Johnson295189b2012-06-20 16:38:30 -0700828 if( pMac->lim.gpLimRemainOnChanReq )
829 {
830 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
831 }
832 //Only use CFG for non-listen mode. This CFG is not working for concurrency
833 //In listening mode, probe rsp IEs is passed in the message from SME to PE
834 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700835 {
836
837 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
838 &addnIEPresent) != eSIR_SUCCESS)
839 {
840 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530841 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700842 return;
843 }
844 }
845
846 if (addnIEPresent)
847 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530848
849 addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3);
850 if ( NULL == addIE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700851 {
852 PELOGE(limLog(pMac, LOGE,
853 FL("Unable to allocate memory to store addn IE"));)
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530854 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700855 return;
856 }
857
858 //Probe rsp IE available
859 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
860 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
861 {
862 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530863 vos_mem_free(addIE);
864 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700865 return;
866 }
867 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
868 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
869 {
870 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
871 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
872 &addnIE1Len) )
873 {
874 limLog(pMac, LOGP,
875 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530876 vos_mem_free(addIE);
877 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700878 return;
879 }
880 }
881
882 //Probe rsp IE available
883 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
884 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
885 {
886 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530887 vos_mem_free(addIE);
888 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700889 return;
890 }
891 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
892 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
893 {
894 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
895 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
896 &addnIE2Len) )
897 {
898 limLog(pMac, LOGP,
899 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530900 vos_mem_free(addIE);
901 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700902 return;
903 }
904 }
905
906 //Probe rsp IE available
907 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
908 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
909 {
910 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530911 vos_mem_free(addIE);
912 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700913 return;
914 }
915 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
916 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
917 {
918 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
919 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
920 &addIE[addnIE1Len + addnIE2Len],
921 &addnIE3Len) )
922 {
923 limLog(pMac, LOGP,
924 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530925 vos_mem_free(addIE);
926 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700927 return;
928 }
929 }
930 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
931
Jeff Johnson295189b2012-06-20 16:38:30 -0700932 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
933 {
934 limLog(pMac, LOGP,
935 FL("Unable to get final Additional IE for Probe Req"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530936 vos_mem_free(addIE);
937 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700938 return;
939 }
Kalikinkar dhara205da782014-03-21 15:49:32 -0700940
941 vos_mem_set(( tANI_U8* )&extractedExtCap,
942 sizeof( tDot11fIEExtCap ), 0);
943 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
944 addIE,
945 &totalAddnIeLen,
946 &extractedExtCap );
947 if(eSIR_SUCCESS != nSirStatus )
948 {
949 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
950 limLog(pMac, LOG1,
951 FL("Unable to Stripoff ExtCap IE from Probe Rsp"));
952 }
953
Jeff Johnson295189b2012-06-20 16:38:30 -0700954 nBytes = nBytes + totalAddnIeLen;
955
956 if (probeReqP2pIe)
957 {
958 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
959 if (pP2pIe != NULL)
960 {
961 //get NoA attribute stream P2P IE
962 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
963 if (noaLen != 0)
964 {
965 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
966 &noaStream[0], noaLen);
967 nBytes = nBytes + total_noaLen;
968 }
969 }
970 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700971 }
972
973 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
974 ( tANI_U16 )nBytes, ( void** ) &pFrame,
975 ( void** ) &pPacket );
976 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
977 {
978 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700979 "be Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700980 if ( addIE != NULL )
981 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530982 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700983 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530984 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700985 return;
986 }
987
988 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530989 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700990
991 // Next, we fill out the buffer descriptor:
992 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
993 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
994 if ( eSIR_SUCCESS != nSirStatus )
995 {
996 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700997 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700998 nSirStatus );
999 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1000 ( void* ) pFrame, ( void* ) pPacket );
1001 if ( addIE != NULL )
1002 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301003 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001004 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301005 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07001006 return;
1007 }
1008
1009 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1010
1011 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1012
Kalikinkar dhara205da782014-03-21 15:49:32 -07001013 /*merge ExtCap IE*/
1014 if (extractedExtCapFlag)
1015 {
1016 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
1017 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001018 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001019 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -07001020 nPayload, &nPayload );
1021 if ( DOT11F_FAILED( nStatus ) )
1022 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001023 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001024 nStatus );
1025 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1026 if ( addIE != NULL )
1027 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301028 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001029 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301030 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07001031 return; // allocated!
1032 }
1033 else if ( DOT11F_WARNED( nStatus ) )
1034 {
1035 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001036 "robe Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001037 }
1038
1039 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
1040 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1041
1042 pMac->sys.probeRespond++;
1043
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 if( pMac->lim.gpLimRemainOnChanReq )
1045 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301046 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -07001047 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
1048 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001049
1050 if ( addnIEPresent )
1051 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301052 vos_mem_copy(pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], totalAddnIeLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001053 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001054 if (noaLen != 0)
1055 {
Krunal Soni81b24262013-05-15 17:46:41 -07001056 if (total_noaLen > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -07001057 {
1058 limLog(pMac, LOGE,
Kaushik, Sushant96ac9d72013-12-11 19:28:10 +05301059 FL("Not able to insert NoA because of length constraint."
1060 "Total Length is :%d"),total_noaLen);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301061 vos_mem_free(addIE);
1062 vos_mem_free(pFrm);
Krunal Soni81b24262013-05-15 17:46:41 -07001063 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1064 ( void* ) pFrame, ( void* ) pPacket );
1065 return;
1066 }
1067 else
1068 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301069 vos_mem_copy( &pFrame[nBytes - (total_noaLen)],
Krunal Soni81b24262013-05-15 17:46:41 -07001070 &noaIe[0], total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001071 }
1072 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001073
1074 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001075 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1076 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001077 )
1078 {
1079 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1080 }
1081
1082 // Queue Probe Response frame in high priority WQ
1083 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
1084 ( tANI_U16 ) nBytes,
1085 HAL_TXRX_FRM_802_11_MGMT,
1086 ANI_TXDIR_TODS,
1087 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
1088 limTxComplete, pFrame, txFlag );
1089 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1090 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001091 limLog( pMac, LOGE, FL("Could not send Probe Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001092 //Pkt will be freed up by the callback
1093 }
1094
1095 if ( addIE != NULL )
1096 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301097 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001098 }
1099
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301100 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001101 return;
1102
1103
Jeff Johnson295189b2012-06-20 16:38:30 -07001104} // End limSendProbeRspMgmtFrame.
1105
1106void
1107limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
1108 tSirMacAddr peerMacAddr,
1109 tSirAddtsReqInfo *pAddTS,
1110 tpPESession psessionEntry)
1111{
1112 tANI_U16 i;
1113 tANI_U8 *pFrame;
1114 tSirRetStatus nSirStatus;
1115 tDot11fAddTSRequest AddTSReq;
1116 tDot11fWMMAddTSRequest WMMAddTSReq;
1117 tANI_U32 nPayload, nBytes, nStatus;
1118 tpSirMacMgmtHdr pMacHdr;
1119 void *pPacket;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001120#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001121 tANI_U32 phyMode;
1122#endif
1123 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301124 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001125
1126 if(NULL == psessionEntry)
1127 {
1128 return;
1129 }
1130
1131 if ( ! pAddTS->wmeTspecPresent )
1132 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301133 vos_mem_set(( tANI_U8* )&AddTSReq, sizeof( AddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001134
1135 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1136 AddTSReq.DialogToken.token = pAddTS->dialogToken;
1137 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1138 if ( pAddTS->lleTspecPresent )
1139 {
1140 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
1141 }
1142 else
1143 {
1144 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
1145 }
1146
1147 if ( pAddTS->lleTspecPresent )
1148 {
1149 AddTSReq.num_WMMTCLAS = 0;
1150 AddTSReq.num_TCLAS = pAddTS->numTclas;
1151 for ( i = 0; i < pAddTS->numTclas; ++i)
1152 {
1153 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1154 &AddTSReq.TCLAS[i] );
1155 }
1156 }
1157 else
1158 {
1159 AddTSReq.num_TCLAS = 0;
1160 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
1161 for ( i = 0; i < pAddTS->numTclas; ++i)
1162 {
1163 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1164 &AddTSReq.WMMTCLAS[i] );
1165 }
1166 }
1167
1168 if ( pAddTS->tclasProcPresent )
1169 {
1170 if ( pAddTS->lleTspecPresent )
1171 {
1172 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
1173 AddTSReq.TCLASSPROC.present = 1;
1174 }
1175 else
1176 {
1177 AddTSReq.WMMTCLASPROC.version = 1;
1178 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
1179 AddTSReq.WMMTCLASPROC.present = 1;
1180 }
1181 }
1182
1183 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
1184 if ( DOT11F_FAILED( nStatus ) )
1185 {
1186 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001187 "or an Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001188 nStatus );
1189 // We'll fall back on the worst case scenario:
1190 nPayload = sizeof( tDot11fAddTSRequest );
1191 }
1192 else if ( DOT11F_WARNED( nStatus ) )
1193 {
1194 limLog( pMac, LOGW, FL("There were warnings while calculating"
1195 "the packed size for an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001196 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001197 }
1198 }
1199 else
1200 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301201 vos_mem_set(( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001202
1203 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1204 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1205 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1206
1207 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1208 WMMAddTSReq.StatusCode.statusCode = 0;
1209
1210 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001211#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001212 limGetPhyMode(pMac, &phyMode, psessionEntry);
1213
1214 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1215 {
1216 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1217 }
1218 else
1219 {
1220 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1221 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001222 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.ESETrafStrmRateSet,sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07001223#endif
1224 // fillWmeTspecIE
1225
1226 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1227 if ( DOT11F_FAILED( nStatus ) )
1228 {
1229 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001230 "or a WMM Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001231 nStatus );
1232 // We'll fall back on the worst case scenario:
1233 nPayload = sizeof( tDot11fAddTSRequest );
1234 }
1235 else if ( DOT11F_WARNED( nStatus ) )
1236 {
1237 limLog( pMac, LOGW, FL("There were warnings while calculating"
1238 "the packed size for a WMM Add TS Requ"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001239 "est (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001240 }
1241 }
1242
1243 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1244
1245 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1246 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1247 ( void** ) &pPacket );
1248 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1249 {
1250 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001251 "d TS Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001252 return;
1253 }
1254
1255 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301256 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001257
1258 // Next, we fill out the buffer descriptor:
1259 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1260 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1261 if ( eSIR_SUCCESS != nSirStatus )
1262 {
1263 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001264 "tor for an Add TS Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001265 nSirStatus );
1266 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1267 ( void* ) pFrame, ( void* ) pPacket );
1268 return;
1269 }
1270
1271 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1272
1273 #if 0
1274 cfgLen = SIR_MAC_ADDR_LENGTH;
1275 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1276 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1277 {
1278 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001279 "e sending an Add TS Request.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001280 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1281 ( void* ) pFrame, ( void* ) pPacket );
1282 return;
1283 }
1284 #endif //TO SUPPORT BT-AMP
1285
1286 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1287
Chet Lanctot186b5732013-03-18 10:26:30 -07001288#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001289 limSetProtectedBit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001290#endif
1291
Jeff Johnson295189b2012-06-20 16:38:30 -07001292 // That done, pack the struct:
1293 if ( ! pAddTS->wmeTspecPresent )
1294 {
1295 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1296 pFrame + sizeof(tSirMacMgmtHdr),
1297 nPayload, &nPayload );
1298 if ( DOT11F_FAILED( nStatus ) )
1299 {
1300 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001301 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001302 nStatus );
1303 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1304 return; // allocated!
1305 }
1306 else if ( DOT11F_WARNED( nStatus ) )
1307 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001308 limLog( pMac, LOGW, FL("There were warnings while packing "
1309 "an Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001310 }
1311 }
1312 else
1313 {
1314 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1315 pFrame + sizeof(tSirMacMgmtHdr),
1316 nPayload, &nPayload );
1317 if ( DOT11F_FAILED( nStatus ) )
1318 {
1319 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001320 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001321 nStatus );
1322 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1323 return; // allocated!
1324 }
1325 else if ( DOT11F_WARNED( nStatus ) )
1326 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001327 limLog( pMac, LOGW, FL("There were warnings while packing "
1328 "a WMM Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001329 }
1330 }
1331
1332 PELOG3(limLog( pMac, LOG3, FL("Sending an Add TS Request frame to ") );
1333 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1334
1335 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001336 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1337 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001338 )
1339 {
1340 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1341 }
1342
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301343 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1344 psessionEntry->peSessionId,
1345 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001346 // Queue Addts Response frame in high priority WQ
1347 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1348 HAL_TXRX_FRM_802_11_MGMT,
1349 ANI_TXDIR_TODS,
1350 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1351 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301352 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1353 psessionEntry->peSessionId,
1354 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001355 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1356 {
1357 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001358 " (%X) ***" ), halstatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001359 //Pkt will be freed up by the callback
1360 }
1361
1362} // End limSendAddtsReqActionFrame.
1363
Jeff Johnson295189b2012-06-20 16:38:30 -07001364
1365
1366void
1367limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1368 tANI_U16 statusCode,
1369 tANI_U16 aid,
1370 tSirMacAddr peerMacAddr,
1371 tANI_U8 subType,
1372 tpDphHashNode pSta,tpPESession psessionEntry)
1373{
1374 static tDot11fAssocResponse frm;
1375 tANI_U8 *pFrame, *macAddr;
1376 tpSirMacMgmtHdr pMacHdr;
1377 tSirRetStatus nSirStatus;
1378 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1379 tHalBitVal qosMode, wmeMode;
1380 tANI_U32 nPayload, nBytes, nStatus;
1381 void *pPacket;
1382 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301383 tUpdateBeaconParams beaconParams;
1384 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001385 tANI_U32 addnIEPresent = false;
1386 tANI_U32 addnIELen=0;
1387 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1388 tpSirAssocReq pAssocReq = NULL;
Kalikinkar dhara205da782014-03-21 15:49:32 -07001389 tANI_U16 addStripoffIELen = 0;
1390 tDot11fIEExtCap extractedExtCap;
1391 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_FALSE;
1392
Chet Lanctot8cecea22014-02-11 19:09:36 -08001393#ifdef WLAN_FEATURE_11W
1394 tANI_U32 retryInterval;
1395 tANI_U32 maxRetries;
1396#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001397
1398 if(NULL == psessionEntry)
1399 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301400 limLog( pMac, LOGE, FL("psessionEntry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001401 return;
1402 }
1403
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301404 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001405
1406 limGetQosMode(psessionEntry, &qosMode);
1407 limGetWmeMode(psessionEntry, &wmeMode);
1408
1409 // An Add TS IE is added only if the AP supports it and the requesting
1410 // STA sent a traffic spec.
1411 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1412
1413 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1414
1415 frm.Status.status = statusCode;
1416
1417 frm.AID.associd = aid | LIM_AID_MASK;
1418
1419 if ( NULL == pSta )
1420 {
1421 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1422 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1423 }
1424 else
1425 {
1426 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1427 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1428 }
1429
Jeff Johnson295189b2012-06-20 16:38:30 -07001430 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1431 {
1432 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1433 {
1434 pAssocReq =
1435 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001436 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1437 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1438 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1439 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001440 }
1441 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001442
1443 if ( NULL != pSta )
1444 {
1445 if ( eHAL_SET == qosMode )
1446 {
1447 if ( pSta->lleEnabled )
1448 {
1449 lleMode = 1;
1450 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1451 {
1452 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1453
1454// FramesToDo:...
1455// if ( fAddTS )
1456// {
1457// tANI_U8 *pAf = pBody;
1458// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1459// tANI_U32 tlen;
1460// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1461// &tlen, bufLen - frameLen);
1462// } // End if on Add TS.
1463 }
1464 } // End if on .11e enabled in 'pSta'.
1465 } // End if on QOS Mode on.
1466
1467 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1468 {
1469 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1470 {
1471
Jeff Johnson295189b2012-06-20 16:38:30 -07001472 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001473
1474 if ( pSta->wsmEnabled )
1475 {
1476 PopulateDot11fWMMCaps(&frm.WMMCaps );
1477 }
1478 }
1479 }
1480
1481 if ( pSta->aniPeer )
1482 {
1483 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1484 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1485 {
1486 edcaInclude = 1;
1487 }
1488
1489 } // End if on Airgo peer.
1490
1491 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001492 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001493 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001494 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07001495 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001496 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001497
1498#ifdef WLAN_FEATURE_11AC
1499 if( pSta->mlmStaContext.vhtCapability &&
1500 psessionEntry->vhtCapability )
1501 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08001502 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Response"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001503 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
1504 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation);
Sandeep Puligilla60342762014-01-30 21:05:37 +05301505 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001506 }
1507#endif
1508
Jeff Johnson295189b2012-06-20 16:38:30 -07001509 } // End if on non-NULL 'pSta'.
1510
Chet Lanctot8cecea22014-02-11 19:09:36 -08001511#ifdef WLAN_FEATURE_11W
1512 if( eSIR_MAC_TRY_AGAIN_LATER == statusCode )
1513 {
1514 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_MAX_RETRIES,
1515 &maxRetries ) != eSIR_SUCCESS )
1516 limLog( pMac, LOGE, FL("Could not retrieve PMF SA Query maximum retries value") );
1517 else
1518 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL,
1519 &retryInterval ) != eSIR_SUCCESS)
1520 limLog( pMac, LOGE, FL("Could not retrieve PMF SA Query timer interval value") );
1521 else
1522 PopulateDot11fTimeoutInterval(
1523 pMac, &frm.TimeoutInterval, SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1524 (maxRetries - pSta->pmfSaQueryRetryCount) * retryInterval );
1525 }
1526#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001527
Chet Lanctot8cecea22014-02-11 19:09:36 -08001528 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001529
Jeff Johnson295189b2012-06-20 16:38:30 -07001530 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1531 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1532 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1533 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001534
1535 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1536 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1537
1538 beaconParams.bssIdx = psessionEntry->bssIdx;
1539
1540 //Send message to HAL about beacon parameter change.
1541 if(beaconParams.paramChangeBitmap)
1542 {
1543 schSetFixedBeaconFields(pMac,psessionEntry);
1544 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1545 }
1546
1547 // Allocate a buffer for this frame:
1548 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1549 if ( DOT11F_FAILED( nStatus ) )
1550 {
1551 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001552 "or an Association Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001553 nStatus );
1554 return;
1555 }
1556 else if ( DOT11F_WARNED( nStatus ) )
1557 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001558 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07001559 "the packed size for an Association Re"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001560 "sponse (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001561 }
1562
1563 nBytes = sizeof( tSirMacMgmtHdr ) + nPayload;
1564
1565 if ( pAssocReq != NULL )
1566 {
1567 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1568 &addnIEPresent) != eSIR_SUCCESS)
1569 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301570 limLog(pMac, LOGP, FL("Unable to get "
1571 "WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001572 return;
1573 }
1574
1575 if (addnIEPresent)
1576 {
1577 //Assoc rsp IE available
1578 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1579 &addnIELen) != eSIR_SUCCESS)
1580 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301581 limLog(pMac, LOGP, FL("Unable to get "
1582 "WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001583 return;
1584 }
1585
1586 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1587 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1588 {
1589 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1590 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1591 {
Kalikinkar dhara205da782014-03-21 15:49:32 -07001592
1593 vos_mem_set(( tANI_U8* )&extractedExtCap,
1594 sizeof( tDot11fIEExtCap ), 0);
1595 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
1596 &addIE[0],
1597 &addStripoffIELen,
1598 &extractedExtCap );
1599 if(eSIR_SUCCESS != nSirStatus)
1600 {
1601 limLog(pMac, LOG1,
1602 FL("Unable to Stripoff ExtCap IE from Assoc Rsp"));
1603 }
1604 else
1605 {
1606 addnIELen = addStripoffIELen;
1607 extractedExtCapFlag = eANI_BOOLEAN_TRUE;
1608 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001609 nBytes = nBytes + addnIELen;
1610 }
1611 }
1612 }
1613 }
1614
1615 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1616 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1617 ( void** ) &pPacket );
1618 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1619 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001620 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001621 return;
1622 }
1623
1624 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301625 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001626
1627 // Next, we fill out the buffer descriptor:
1628 nSirStatus = limPopulateMacHeader( pMac,
1629 pFrame,
1630 SIR_MAC_MGMT_FRAME,
1631 ( LIM_ASSOC == subType ) ?
1632 SIR_MAC_MGMT_ASSOC_RSP :
1633 SIR_MAC_MGMT_REASSOC_RSP,
1634 peerMacAddr,psessionEntry->selfMacAddr);
1635 if ( eSIR_SUCCESS != nSirStatus )
1636 {
1637 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001638 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001639 nSirStatus );
1640 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1641 ( void* ) pFrame, ( void* ) pPacket );
1642 return;
1643 }
1644
1645 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1646
Jeff Johnson295189b2012-06-20 16:38:30 -07001647 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1648
Kalikinkar dhara205da782014-03-21 15:49:32 -07001649 /* merge the ExtCap struct*/
1650 if (extractedExtCapFlag)
1651 {
1652 limMergeExtCapIEStruct(&(frm.ExtCap), &extractedExtCap);
1653 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001654 nStatus = dot11fPackAssocResponse( pMac, &frm,
1655 pFrame + sizeof( tSirMacMgmtHdr ),
1656 nPayload, &nPayload );
1657 if ( DOT11F_FAILED( nStatus ) )
1658 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301659 limLog( pMac, LOGE, FL("Failed to pack an Association Response"
1660 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001661 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1662 ( void* ) pFrame, ( void* ) pPacket );
1663 return; // allocated!
1664 }
1665 else if ( DOT11F_WARNED( nStatus ) )
1666 {
1667 limLog( pMac, LOGW, FL("There were warnings while packing an "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001668 "Association Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001669 }
1670
1671 macAddr = pMacHdr->da;
1672
1673 if (subType == LIM_ASSOC)
1674 {
1675 PELOG1(limLog(pMac, LOG1,
1676 FL("*** Sending Assoc Resp status %d aid %d to "),
1677 statusCode, aid);)
1678 }
1679 else{
1680 PELOG1(limLog(pMac, LOG1,
1681 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1682 statusCode, aid);)
1683 }
1684 PELOG1(limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1685
1686 if ( addnIEPresent )
1687 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301688 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001689 }
1690
1691 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1693 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001694 )
1695 {
1696 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1697 }
1698
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05301699 limLog( pMac, LOG1, FL("Sending Assoc resp over WQ5 to "MAC_ADDRESS_STR
1700 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
1701 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
1702
1703 txFlag |= HAL_USE_FW_IN_TX_PATH;
1704
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301705 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1706 psessionEntry->peSessionId,
1707 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001708 /// Queue Association Response frame in high priority WQ
1709 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1710 HAL_TXRX_FRM_802_11_MGMT,
1711 ANI_TXDIR_TODS,
1712 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1713 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301714 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1715 psessionEntry->peSessionId,
1716 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001717 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1718 {
1719 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001720 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001721 nSirStatus);
1722
1723 //Pkt will be freed up by the callback
1724 }
1725
1726 // update the ANI peer station count
1727 //FIXME_PROTECTION : take care of different type of station
1728 // counter inside this function.
1729 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1730
1731} // End limSendAssocRspMgmtFrame.
1732
1733
1734
1735void
1736limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1737 tSirMacAddr peer,
1738 tANI_U16 nStatusCode,
1739 tSirAddtsReqInfo *pAddTS,
1740 tSirMacScheduleIE *pSchedule,
1741 tpPESession psessionEntry)
1742{
1743 tANI_U8 *pFrame;
1744 tpSirMacMgmtHdr pMacHdr;
1745 tDot11fAddTSResponse AddTSRsp;
1746 tDot11fWMMAddTSResponse WMMAddTSRsp;
1747 tSirRetStatus nSirStatus;
1748 tANI_U32 i, nBytes, nPayload, nStatus;
1749 void *pPacket;
1750 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301751 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001752
1753 if(NULL == psessionEntry)
1754 {
1755 return;
1756 }
1757
1758 if ( ! pAddTS->wmeTspecPresent )
1759 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301760 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001761
1762 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1763 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1764 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1765 AddTSRsp.Status.status = nStatusCode;
1766
1767 // The TsDelay information element is only filled in for a specific
1768 // status code:
1769 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1770 {
1771 if ( pAddTS->wsmTspecPresent )
1772 {
1773 AddTSRsp.WMMTSDelay.version = 1;
1774 AddTSRsp.WMMTSDelay.delay = 10;
1775 AddTSRsp.WMMTSDelay.present = 1;
1776 }
1777 else
1778 {
1779 AddTSRsp.TSDelay.delay = 10;
1780 AddTSRsp.TSDelay.present = 1;
1781 }
1782 }
1783
1784 if ( pAddTS->wsmTspecPresent )
1785 {
1786 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1787 }
1788 else
1789 {
1790 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1791 }
1792
1793 if ( pAddTS->wsmTspecPresent )
1794 {
1795 AddTSRsp.num_WMMTCLAS = 0;
1796 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1797 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1798 {
1799 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1800 &AddTSRsp.TCLAS[i] );
1801 }
1802 }
1803 else
1804 {
1805 AddTSRsp.num_TCLAS = 0;
1806 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1807 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1808 {
1809 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1810 &AddTSRsp.WMMTCLAS[i] );
1811 }
1812 }
1813
1814 if ( pAddTS->tclasProcPresent )
1815 {
1816 if ( pAddTS->wsmTspecPresent )
1817 {
1818 AddTSRsp.WMMTCLASPROC.version = 1;
1819 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1820 AddTSRsp.WMMTCLASPROC.present = 1;
1821 }
1822 else
1823 {
1824 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1825 AddTSRsp.TCLASSPROC.present = 1;
1826 }
1827 }
1828
1829 // schedule element is included only if requested in the tspec and we are
1830 // using hcca (or both edca and hcca)
1831 // 11e-D8.0 is inconsistent on whether the schedule element is included
1832 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1833 // pg 46, line 17-18 says something else. So just include it and let the
1834 // sta figure it out
1835 if ((pSchedule != NULL) &&
1836 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1837 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1838 {
1839 if ( pAddTS->wsmTspecPresent )
1840 {
1841 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1842 }
1843 else
1844 {
1845 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1846 }
1847 }
1848
1849 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1850 if ( DOT11F_FAILED( nStatus ) )
1851 {
1852 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001853 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001854 nStatus );
1855 // We'll fall back on the worst case scenario:
1856 nPayload = sizeof( tDot11fAddTSResponse );
1857 }
1858 else if ( DOT11F_WARNED( nStatus ) )
1859 {
1860 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001861 "ting the packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001862 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001863 }
1864 }
1865 else
1866 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301867 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001868
1869 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1870 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1871 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1872 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1873
1874 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1875
1876 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1877 if ( DOT11F_FAILED( nStatus ) )
1878 {
1879 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001880 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001881 nStatus );
1882 // We'll fall back on the worst case scenario:
1883 nPayload = sizeof( tDot11fWMMAddTSResponse );
1884 }
1885 else if ( DOT11F_WARNED( nStatus ) )
1886 {
1887 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001888 "ting the packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001889 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001890 }
1891 }
1892
1893 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1894
1895 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1896 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1897 {
1898 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001899 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001900 return;
1901 }
1902
1903 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301904 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001905
1906 // Next, we fill out the buffer descriptor:
1907 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1908 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1909 if ( eSIR_SUCCESS != nSirStatus )
1910 {
1911 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001912 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001913 nSirStatus );
1914 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1915 return; // allocated!
1916 }
1917
1918 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1919
1920
1921 #if 0
1922 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1923 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1924 {
1925 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001926 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001927 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1928 return; // allocated!
1929 }
1930 #endif //TO SUPPORT BT-AMP
1931 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1932
Chet Lanctot186b5732013-03-18 10:26:30 -07001933#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001934 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001935#endif
1936
Jeff Johnson295189b2012-06-20 16:38:30 -07001937 // That done, pack the struct:
1938 if ( ! pAddTS->wmeTspecPresent )
1939 {
1940 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1941 pFrame + sizeof( tSirMacMgmtHdr ),
1942 nPayload, &nPayload );
1943 if ( DOT11F_FAILED( nStatus ) )
1944 {
1945 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001946 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001947 nStatus );
1948 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1949 return;
1950 }
1951 else if ( DOT11F_WARNED( nStatus ) )
1952 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001953 limLog( pMac, LOGW, FL("There were warnings while packing "
1954 "an Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001955 }
1956 }
1957 else
1958 {
1959 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
1960 pFrame + sizeof( tSirMacMgmtHdr ),
1961 nPayload, &nPayload );
1962 if ( DOT11F_FAILED( nStatus ) )
1963 {
1964 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001965 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001966 nStatus );
1967 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1968 return;
1969 }
1970 else if ( DOT11F_WARNED( nStatus ) )
1971 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001972 limLog( pMac, LOGW, FL("There were warnings while packing "
1973 "a WMM Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001974 }
1975 }
1976
1977 PELOG1(limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
1978 nStatusCode );
1979 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
1980
1981 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001982 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1983 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001984 )
1985 {
1986 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1987 }
1988
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301989 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1990 psessionEntry->peSessionId,
1991 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001992 // Queue the frame in high priority WQ:
1993 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1994 HAL_TXRX_FRM_802_11_MGMT,
1995 ANI_TXDIR_TODS,
1996 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1997 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301998 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1999 psessionEntry->peSessionId,
2000 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002001 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2002 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002003 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002004 nSirStatus );
2005 //Pkt will be freed up by the callback
2006 }
2007
2008} // End limSendAddtsRspActionFrame.
2009
2010void
2011limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
2012 tSirMacAddr peer,
2013 tANI_U8 wmmTspecPresent,
2014 tSirMacTSInfo *pTsinfo,
2015 tSirMacTspecIE *pTspecIe,
2016 tpPESession psessionEntry)
2017{
2018 tANI_U8 *pFrame;
2019 tpSirMacMgmtHdr pMacHdr;
2020 tDot11fDelTS DelTS;
2021 tDot11fWMMDelTS WMMDelTS;
2022 tSirRetStatus nSirStatus;
2023 tANI_U32 nBytes, nPayload, nStatus;
2024 void *pPacket;
2025 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302026 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002027
2028 if(NULL == psessionEntry)
2029 {
2030 return;
2031 }
2032
2033 if ( ! wmmTspecPresent )
2034 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302035 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002036
2037 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
2038 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2039 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
2040
2041 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
2042 if ( DOT11F_FAILED( nStatus ) )
2043 {
2044 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002045 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002046 nStatus );
2047 // We'll fall back on the worst case scenario:
2048 nPayload = sizeof( tDot11fDelTS );
2049 }
2050 else if ( DOT11F_WARNED( nStatus ) )
2051 {
2052 limLog( pMac, LOGW, FL("There were warnings while calcula"
2053 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002054 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002055 }
2056 }
2057 else
2058 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302059 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002060
2061 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
2062 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2063 WMMDelTS.DialogToken.token = 0;
2064 WMMDelTS.StatusCode.statusCode = 0;
2065 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
2066 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
2067 if ( DOT11F_FAILED( nStatus ) )
2068 {
2069 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002070 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002071 nStatus );
2072 // We'll fall back on the worst case scenario:
2073 nPayload = sizeof( tDot11fDelTS );
2074 }
2075 else if ( DOT11F_WARNED( nStatus ) )
2076 {
2077 limLog( pMac, LOGW, FL("There were warnings while calcula"
2078 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002079 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002080 }
2081 }
2082
2083 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
2084
2085 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
2086 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2087 {
2088 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002089 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002090 return;
2091 }
2092
2093 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302094 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002095
2096 // Next, we fill out the buffer descriptor:
2097 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2098 SIR_MAC_MGMT_ACTION, peer,
2099 psessionEntry->selfMacAddr);
2100 if ( eSIR_SUCCESS != nSirStatus )
2101 {
2102 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002103 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002104 nSirStatus );
2105 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2106 return; // allocated!
2107 }
2108
2109 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
2110
2111 #if 0
2112
2113 cfgLen = SIR_MAC_ADDR_LENGTH;
2114 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
2115 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
2116 {
2117 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002118 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002119 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2120 return; // allocated!
2121 }
2122 #endif //TO SUPPORT BT-AMP
2123 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
2124
Chet Lanctot186b5732013-03-18 10:26:30 -07002125#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002126 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07002127#endif
2128
Jeff Johnson295189b2012-06-20 16:38:30 -07002129 // That done, pack the struct:
2130 if ( !wmmTspecPresent )
2131 {
2132 nStatus = dot11fPackDelTS( pMac, &DelTS,
2133 pFrame + sizeof( tSirMacMgmtHdr ),
2134 nPayload, &nPayload );
2135 if ( DOT11F_FAILED( nStatus ) )
2136 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002137 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002138 nStatus );
2139 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2140 return; // allocated!
2141 }
2142 else if ( DOT11F_WARNED( nStatus ) )
2143 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002144 limLog( pMac, LOGW, FL("There were warnings while packing "
2145 "a Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002146 }
2147 }
2148 else
2149 {
2150 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
2151 pFrame + sizeof( tSirMacMgmtHdr ),
2152 nPayload, &nPayload );
2153 if ( DOT11F_FAILED( nStatus ) )
2154 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002155 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002156 nStatus );
2157 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2158 return; // allocated!
2159 }
2160 else if ( DOT11F_WARNED( nStatus ) )
2161 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002162 limLog( pMac, LOGW, FL("There were warnings while packing "
2163 "a WMM Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002164 }
2165 }
2166
2167 PELOG1(limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
2168 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
2169
2170 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002171 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2172 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002173 )
2174 {
2175 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2176 }
2177
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302178 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2179 psessionEntry->peSessionId,
2180 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002181 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2182 HAL_TXRX_FRM_802_11_MGMT,
2183 ANI_TXDIR_TODS,
2184 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2185 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302186 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2187 psessionEntry->peSessionId,
2188 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002189 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2190 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002191 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002192 nSirStatus );
2193 //Pkt will be freed up by the callback
2194 }
2195
2196} // End limSendDeltsReqActionFrame.
2197
2198void
2199limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
2200 tLimMlmAssocReq *pMlmAssocReq,
2201 tpPESession psessionEntry)
2202{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002203 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07002204 tANI_U16 caps;
2205 tANI_U8 *pFrame;
2206 tSirRetStatus nSirStatus;
2207 tLimMlmAssocCnf mlmAssocCnf;
2208 tANI_U32 nBytes, nPayload, nStatus;
2209 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2210 void *pPacket;
2211 eHalStatus halstatus;
2212 tANI_U16 nAddIELen;
2213 tANI_U8 *pAddIE;
2214 tANI_U8 *wpsIe = NULL;
2215#if defined WLAN_FEATURE_VOWIFI
2216 tANI_U8 PowerCapsPopulated = FALSE;
2217#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302218 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302219 tpSirMacMgmtHdr pMacHdr;
Kalikinkar dhara205da782014-03-21 15:49:32 -07002220 tDot11fIEExtCap extractedExtCap;
2221 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002222
2223 if(NULL == psessionEntry)
2224 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302225 limLog(pMac, LOGE, FL("psessionEntry is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002226 return;
2227 }
2228
Jeff Johnson295189b2012-06-20 16:38:30 -07002229 /* check this early to avoid unncessary operation */
2230 if(NULL == psessionEntry->pLimJoinReq)
2231 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302232 limLog(pMac, LOGE, FL("psessionEntry->pLimJoinReq is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002233 return;
2234 }
2235 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
2236 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
2237
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302238 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
2239 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002240 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302241 limLog(pMac, LOGE, FL("Unable to allocate memory") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002242 return;
2243 }
2244
2245
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302246 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002247
Kalikinkar dhara205da782014-03-21 15:49:32 -07002248 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
2249 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac, pAddIE,
2250 &nAddIELen,
2251 &extractedExtCap );
2252 if(eSIR_SUCCESS != nSirStatus )
2253 {
2254 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
2255 limLog(pMac, LOG1,
2256 FL("Unable to Stripoff ExtCap IE from Assoc Req"));
2257 }
2258
Jeff Johnson295189b2012-06-20 16:38:30 -07002259 caps = pMlmAssocReq->capabilityInfo;
2260 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2261 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2262#if defined(FEATURE_WLAN_WAPI)
2263 /* CR: 262463 :
2264 According to WAPI standard:
2265 7.3.1.4 Capability Information field
2266 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2267 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2268 Reassociation management frames. */
2269 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2270 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2271#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002272 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002273
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002274 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2275 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002276 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002277 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002278
2279 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2280 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2281
2282 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2283 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2284
2285 // We prefer .11e asociations:
2286 if ( fQosEnabled ) fWmeEnabled = false;
2287
2288 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2289 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2290
2291 if ( psessionEntry->lim11hEnable &&
2292 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2293 {
2294#if defined WLAN_FEATURE_VOWIFI
2295 PowerCapsPopulated = TRUE;
2296
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002297 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002298#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002299 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002300
2301 }
2302
2303#if defined WLAN_FEATURE_VOWIFI
2304 if( pMac->rrm.rrmPEContext.rrmEnable &&
2305 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2306 {
2307 if (PowerCapsPopulated == FALSE)
2308 {
2309 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002310 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002311 }
2312 }
2313#endif
2314
2315 if ( fQosEnabled &&
2316 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002317 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002318
2319 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002320 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002321
2322#if defined WLAN_FEATURE_VOWIFI
2323 if( pMac->rrm.rrmPEContext.rrmEnable &&
2324 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2325 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002326 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002327 }
2328#endif
2329 // The join request *should* contain zero or one of the WPA and RSN
2330 // IEs. The payload send along with the request is a
2331 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2332
2333 // typedef struct sSirRSNie
2334 // {
2335 // tANI_U16 length;
2336 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2337 // } tSirRSNie, *tpSirRSNie;
2338
2339 // So, we should be able to make the following two calls harmlessly,
2340 // since they do nothing if they don't find the given IE in the
2341 // bytestream with which they're provided.
2342
2343 // The net effect of this will be to faithfully transmit whatever
2344 // security IE is in the join request.
2345
2346 // *However*, if we're associating for the purpose of WPS
2347 // enrollment, and we've been configured to indicate that by
2348 // eliding the WPA or RSN IE, we just skip this:
2349 if( nAddIELen && pAddIE )
2350 {
2351 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2352 }
2353 if ( NULL == wpsIe )
2354 {
2355 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002356 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002357 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002358 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002359#if defined(FEATURE_WLAN_WAPI)
2360 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002361 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002362#endif // defined(FEATURE_WLAN_WAPI)
2363 }
2364
2365 // include WME EDCA IE as well
2366 if ( fWmeEnabled )
2367 {
2368 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2369 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002370 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002371 }
2372
2373 if ( fWsmEnabled &&
2374 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2375 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002376 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002377 }
2378 }
2379
2380 //Populate HT IEs, when operating in 11n or Taurus modes AND
2381 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002382 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002383 pMac->lim.htCapabilityPresentInBeacon)
2384 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002385 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002386#ifdef DISABLE_GF_FOR_INTEROP
2387
2388 /*
2389 * To resolve the interop problem with Broadcom AP,
2390 * where TQ STA could not pass traffic with GF enabled,
2391 * TQ STA will do Greenfield only with TQ AP, for
2392 * everybody else it will be turned off.
2393 */
2394
2395 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2396 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302397 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP,"
2398 " Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002399 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002400 }
2401#endif
2402
2403 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002404#ifdef WLAN_FEATURE_11AC
2405 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002406 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002407 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002408 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002409 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
Jeff Johnsone7245742012-09-05 17:12:55 -07002410 }
2411#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302412 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002413
2414#if defined WLAN_FEATURE_VOWIFI_11R
2415 if (psessionEntry->pLimJoinReq->is11Rconnection)
2416 {
2417#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002418 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002419 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2420 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2421 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2422#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302423 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2424 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002425 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302426 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002427 {
2428 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302429 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002430 }
2431#endif
2432
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002433#ifdef FEATURE_WLAN_ESE
2434 /* For ESE Associations fill the ESE IEs */
2435 if (psessionEntry->isESEconnection &&
2436 psessionEntry->pLimJoinReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002437 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002438#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002439 PopulateDot11fESERadMgmtCap(&pFrm->ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002440#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002441 PopulateDot11fESEVersion(&pFrm->ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002442 }
2443#endif
2444
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002445 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002446 if ( DOT11F_FAILED( nStatus ) )
2447 {
2448 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002449 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002450 nStatus );
2451 // We'll fall back on the worst case scenario:
2452 nPayload = sizeof( tDot11fAssocRequest );
2453 }
2454 else if ( DOT11F_WARNED( nStatus ) )
2455 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002456 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002457 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002458 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002459 }
2460
2461 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2462
2463 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2464 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2465 ( void** ) &pPacket );
2466 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2467 {
2468 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002469 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002470
2471 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002472 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002473
2474
2475 /* Update PE session id*/
2476 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2477
2478 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2479
2480 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2481 ( void* ) pFrame, ( void* ) pPacket );
2482
2483 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2484 ( tANI_U32* ) &mlmAssocCnf);
2485
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302486 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002487 return;
2488 }
2489
2490 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302491 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002492
2493 // Next, we fill out the buffer descriptor:
2494 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2495 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2496 if ( eSIR_SUCCESS != nSirStatus )
2497 {
2498 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002499 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002500 nSirStatus );
2501 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302502 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002503 return;
2504 }
Kalikinkar dhara205da782014-03-21 15:49:32 -07002505 /* merge the ExtCap struct*/
2506 if (extractedExtCapFlag)
2507 {
2508 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
2509 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002510
Abhishek Singh57aebef2014-02-03 18:47:44 +05302511 // That done, pack the Assoc Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002512 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002513 sizeof(tSirMacMgmtHdr),
2514 nPayload, &nPayload );
2515 if ( DOT11F_FAILED( nStatus ) )
2516 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302517 limLog( pMac, LOGE, FL("Failed to pack a Assoc Request (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002518 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002519 nStatus );
2520 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2521 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302522 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002523 return;
2524 }
2525 else if ( DOT11F_WARNED( nStatus ) )
2526 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302527 limLog( pMac, LOGW, FL("There were warnings while packing a Assoc"
2528 "Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002529 }
2530
2531 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002532 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002533 nBytes );)
2534 // limPrintMacAddr( pMac, bssid, LOG1 );
2535
2536 if( psessionEntry->assocReq != NULL )
2537 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302538 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002539 psessionEntry->assocReq = NULL;
2540 }
2541
2542 if( nAddIELen )
2543 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302544 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2545 pAddIE,
2546 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002547 nPayload += nAddIELen;
2548 }
2549
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302550 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2551 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302553 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store "
2554 "assoc request"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002555 }
2556 else
2557 {
2558 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302559 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002560 psessionEntry->assocReqLen = nPayload;
2561 }
2562
2563 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002564 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2565 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002566 )
2567 {
2568 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2569 }
2570
Ganesh K08bce952012-12-13 15:04:41 -08002571 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2572 {
2573 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2574 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302575
2576 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05302577 limLog( pMac, LOG1, FL("Sending Assoc req over WQ5 to "MAC_ADDRESS_STR
2578 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
2579 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2580 txFlag |= HAL_USE_FW_IN_TX_PATH;
2581
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302582 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2583 psessionEntry->peSessionId,
2584 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002585 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2586 HAL_TXRX_FRM_802_11_MGMT,
2587 ANI_TXDIR_TODS,
2588 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2589 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302590 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2591 psessionEntry->peSessionId,
2592 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2594 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002595 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002596 halstatus );
2597 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302598 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002599 return;
2600 }
2601
2602 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302603 vos_mem_free(pMlmAssocReq);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002604 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302605 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002606 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002607} // End limSendAssocReqMgmtFrame
2608
2609
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002610#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002611/*------------------------------------------------------------------------------------
2612 *
2613 * Send Reassoc Req with FTIEs.
2614 *
2615 *-----------------------------------------------------------------------------------
2616 */
2617void
2618limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2619 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2620{
2621 static tDot11fReAssocRequest frm;
2622 tANI_U16 caps;
2623 tANI_U8 *pFrame;
2624 tSirRetStatus nSirStatus;
2625 tANI_U32 nBytes, nPayload, nStatus;
2626 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2627 void *pPacket;
2628 eHalStatus halstatus;
2629#if defined WLAN_FEATURE_VOWIFI
2630 tANI_U8 PowerCapsPopulated = FALSE;
2631#endif
2632 tANI_U16 ft_ies_length = 0;
2633 tANI_U8 *pBody;
2634 tANI_U16 nAddIELen;
2635 tANI_U8 *pAddIE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002636#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 tANI_U8 *wpsIe = NULL;
2638#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302639 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302640 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002641
2642 if (NULL == psessionEntry)
2643 {
2644 return;
2645 }
2646
Jeff Johnson295189b2012-06-20 16:38:30 -07002647 /* check this early to avoid unncessary operation */
2648 if(NULL == psessionEntry->pLimReAssocReq)
2649 {
2650 return;
2651 }
2652 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2653 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002654 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2655 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002656
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302657 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002658
2659 caps = pMlmReassocReq->capabilityInfo;
2660 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2661 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2662#if defined(FEATURE_WLAN_WAPI)
2663 /* CR: 262463 :
2664 According to WAPI standard:
2665 7.3.1.4 Capability Information field
2666 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2667 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2668 Reassociation management frames. */
2669 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2670 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2671#endif
2672 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2673
2674 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2675
2676 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302677 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002678 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2679
2680 PopulateDot11fSSID2( pMac, &frm.SSID );
2681 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2682 &frm.SuppRates,psessionEntry);
2683
2684 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2685 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2686
2687 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2688 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2689
2690 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2691 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2692
2693 if ( psessionEntry->lim11hEnable &&
2694 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2695 {
2696#if defined WLAN_FEATURE_VOWIFI
2697 PowerCapsPopulated = TRUE;
2698
2699 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2700 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2701#endif
2702 }
2703
2704#if defined WLAN_FEATURE_VOWIFI
2705 if( pMac->rrm.rrmPEContext.rrmEnable &&
2706 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2707 {
2708 if (PowerCapsPopulated == FALSE)
2709 {
2710 PowerCapsPopulated = TRUE;
2711 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2712 }
2713 }
2714#endif
2715
2716 if ( fQosEnabled &&
2717 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2718 {
2719 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2720 }
2721
2722 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2723 &frm.ExtSuppRates, psessionEntry );
2724
2725#if defined WLAN_FEATURE_VOWIFI
2726 if( pMac->rrm.rrmPEContext.rrmEnable &&
2727 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2728 {
2729 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2730 }
2731#endif
2732
2733 // Ideally this should be enabled for 11r also. But 11r does
2734 // not follow the usual norm of using the Opaque object
2735 // for rsnie and fties. Instead we just add
2736 // the rsnie and fties at the end of the pack routine for 11r.
2737 // This should ideally! be fixed.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002738#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002739 //
2740 // The join request *should* contain zero or one of the WPA and RSN
2741 // IEs. The payload send along with the request is a
2742 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2743
2744 // typedef struct sSirRSNie
2745 // {
2746 // tANI_U16 length;
2747 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2748 // } tSirRSNie, *tpSirRSNie;
2749
2750 // So, we should be able to make the following two calls harmlessly,
2751 // since they do nothing if they don't find the given IE in the
2752 // bytestream with which they're provided.
2753
2754 // The net effect of this will be to faithfully transmit whatever
2755 // security IE is in the join request.
2756
2757 // *However*, if we're associating for the purpose of WPS
2758 // enrollment, and we've been configured to indicate that by
2759 // eliding the WPA or RSN IE, we just skip this:
2760 if (!psessionEntry->is11Rconnection)
2761 {
2762 if( nAddIELen && pAddIE )
2763 {
2764 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2765 }
2766 if ( NULL == wpsIe )
2767 {
2768 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2769 &frm.RSNOpaque );
2770 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2771 &frm.WPAOpaque );
2772 }
2773
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002774#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302775 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002776 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002777 PopulateDot11fESECckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2778 &frm.ESECckmOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002779 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002780#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002781 }
2782
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002783#ifdef FEATURE_WLAN_ESE
2784 // For ESE Associations fill the ESE IEs
2785 if (psessionEntry->isESEconnection &&
2786 psessionEntry->pLimReAssocReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002787 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002788#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002789 PopulateDot11fESERadMgmtCap(&frm.ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002790#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002791 PopulateDot11fESEVersion(&frm.ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002792 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002793#endif //FEATURE_WLAN_ESE
2794#endif //FEATURE_WLAN_ESE || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002795
2796 // include WME EDCA IE as well
2797 if ( fWmeEnabled )
2798 {
2799 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2800 {
2801 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2802 }
2803
2804 if ( fWsmEnabled &&
2805 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2806 {
2807 PopulateDot11fWMMCaps( &frm.WMMCaps );
2808 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002809#ifdef FEATURE_WLAN_ESE
2810 if (psessionEntry->isESEconnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07002811 {
2812 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2813
2814 // Populate the TSRS IE if TSPEC is included in the reassoc request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002815 if (psessionEntry->pLimReAssocReq->eseTspecInfo.numTspecs)
Jeff Johnson295189b2012-06-20 16:38:30 -07002816 {
2817 tANI_U32 phyMode;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002818 tSirMacESETSRSIE tsrsIE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002819 limGetPhyMode(pMac, &phyMode, psessionEntry);
2820
2821 tsrsIE.tsid = 0;
2822 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2823 {
2824 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2825 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302826 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002827 {
2828 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2829 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002830 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.ESETrafStrmRateSet, sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07002831 }
2832 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302833#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002834 }
2835
Jeff Johnsone7245742012-09-05 17:12:55 -07002836 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002837 pMac->lim.htCapabilityPresentInBeacon)
2838 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002839 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002840 }
2841
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002842#if defined WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302843 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent && (0 == pMac->ft.ftSmeContext.reassoc_ft_ies_length)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002844#if defined FEATURE_WLAN_ESE
2845 && !psessionEntry->isESEconnection
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302846#endif
2847 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002848 {
2849 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2850 }
2851#endif
2852
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002853#ifdef WLAN_FEATURE_11AC
2854 if ( psessionEntry->vhtCapability &&
2855 psessionEntry->vhtCapabilityPresentInBeacon)
2856 {
2857 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
2858 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002859 }
2860#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302861 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002862
Jeff Johnson295189b2012-06-20 16:38:30 -07002863 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2864 if ( DOT11F_FAILED( nStatus ) )
2865 {
2866 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002867 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002868 nStatus );
2869 // We'll fall back on the worst case scenario:
2870 nPayload = sizeof( tDot11fReAssocRequest );
2871 }
2872 else if ( DOT11F_WARNED( nStatus ) )
2873 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002874 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002875 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002876 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002877 }
2878
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002879 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002880
2881#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002882 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002883 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2884#endif
2885
2886#if defined WLAN_FEATURE_VOWIFI_11R
2887 if (psessionEntry->is11Rconnection)
2888 {
2889 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2890 }
2891#endif
2892
2893 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2894 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2895 ( void** ) &pPacket );
2896 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2897 {
2898 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002899 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002900 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002901 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002902 goto end;
2903 }
2904
2905 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302906 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002907
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002908#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002909 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002910#endif
2911 // Next, we fill out the buffer descriptor:
2912 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2913 SIR_MAC_MGMT_REASSOC_REQ,
2914 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2915 if ( eSIR_SUCCESS != nSirStatus )
2916 {
2917 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002918 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002919 nSirStatus );
2920 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2921 goto end;
2922 }
2923
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302924 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07002925 // That done, pack the ReAssoc Request:
2926 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2927 sizeof(tSirMacMgmtHdr),
2928 nPayload, &nPayload );
2929 if ( DOT11F_FAILED( nStatus ) )
2930 {
2931 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002932 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002933 nStatus );
2934 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2935 goto end;
2936 }
2937 else if ( DOT11F_WARNED( nStatus ) )
2938 {
2939 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002940 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002941 }
2942
2943 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002944 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002945 nBytes, nPayload );)
2946 if( psessionEntry->assocReq != NULL )
2947 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302948 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002949 psessionEntry->assocReq = NULL;
2950 }
2951
2952 if( nAddIELen )
2953 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302954 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2955 pAddIE,
2956 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002957 nPayload += nAddIELen;
2958 }
2959
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302960 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2961 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002962 {
2963 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002964 }
2965 else
2966 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002967 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302968 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002969 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002970 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002971
2972 if (psessionEntry->is11Rconnection)
2973 {
2974 {
2975 int i = 0;
2976
2977 pBody = pFrame + nBytes;
2978 for (i=0; i<ft_ies_length; i++)
2979 {
2980 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2981 pBody++;
2982 }
2983 }
2984 }
2985
2986#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002987 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
2988 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002989 (tANI_U8 *)pFrame,
2990 (nBytes + ft_ies_length));)
2991#endif
2992
2993
2994 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002995 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2996 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002997 )
2998 {
2999 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3000 }
3001
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003002 if( NULL != psessionEntry->assocReq )
3003 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303004 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003005 psessionEntry->assocReq = NULL;
3006 }
3007
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303008 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
3009 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003010 {
3011 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003012 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003013 }
3014 else
3015 {
3016 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303017 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
3018 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003019 psessionEntry->assocReqLen = (ft_ies_length);
3020 }
3021
3022
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303023 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3024 psessionEntry->peSessionId,
3025 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003026 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
3027 HAL_TXRX_FRM_802_11_MGMT,
3028 ANI_TXDIR_TODS,
3029 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3030 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303031 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3032 psessionEntry->peSessionId,
3033 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003034 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3035 {
3036 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003037 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003038 nSirStatus );
3039 //Pkt will be freed up by the callback
3040 goto end;
3041 }
3042
3043end:
3044 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303045 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003046 psessionEntry->pLimMlmReassocReq = NULL;
3047
3048}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003049
3050void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
3051 tLimMlmReassocReq *pMlmReassocReq,
3052 tpPESession psessionEntry)
3053{
3054 tLimMlmReassocCnf mlmReassocCnf; // keep sme
3055 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
3056 if(NULL == pTmpMlmReassocReq)
3057 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303058 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
3059 if ( NULL == pTmpMlmReassocReq ) goto end;
3060 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
3061 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003062 }
3063
3064 // Prepare and send Reassociation request frame
3065 // start reassoc timer.
3066 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
3067 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08003068 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003069 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
3070 != TX_SUCCESS)
3071 {
3072 // Could not start reassoc failure timer.
3073 // Log error
3074 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003075 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003076 // Return Reassoc confirm with
3077 // Resources Unavailable
3078 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3079 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3080 goto end;
3081 }
3082
3083 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
3084 return;
3085
3086end:
3087 // Free up buffer allocated for reassocReq
3088 if (pMlmReassocReq != NULL)
3089 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303090 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003091 pMlmReassocReq = NULL;
3092 }
3093 if (pTmpMlmReassocReq != NULL)
3094 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303095 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003096 pTmpMlmReassocReq = NULL;
3097 }
3098 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
3099 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3100 /* Update PE sessio Id*/
3101 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
3102
3103 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3104}
3105
Jeff Johnson295189b2012-06-20 16:38:30 -07003106#endif /* WLAN_FEATURE_VOWIFI_11R */
3107
3108
3109void
3110limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
3111 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
3112{
3113 static tDot11fReAssocRequest frm;
3114 tANI_U16 caps;
3115 tANI_U8 *pFrame;
3116 tSirRetStatus nSirStatus;
3117 tANI_U32 nBytes, nPayload, nStatus;
3118 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
3119 void *pPacket;
3120 eHalStatus halstatus;
3121 tANI_U16 nAddIELen;
3122 tANI_U8 *pAddIE;
3123 tANI_U8 *wpsIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303124 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003125#if defined WLAN_FEATURE_VOWIFI
3126 tANI_U8 PowerCapsPopulated = FALSE;
3127#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303128 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003129
3130 if(NULL == psessionEntry)
3131 {
3132 return;
3133 }
3134
3135 /* check this early to avoid unncessary operation */
3136 if(NULL == psessionEntry->pLimReAssocReq)
3137 {
3138 return;
3139 }
3140 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
3141 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
3142
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303143 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003144
3145 caps = pMlmReassocReq->capabilityInfo;
3146 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
3147 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
3148#if defined(FEATURE_WLAN_WAPI)
3149 /* CR: 262463 :
3150 According to WAPI standard:
3151 7.3.1.4 Capability Information field
3152 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
3153 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
3154 Reassociation management frames. */
3155 if ( psessionEntry->encryptType == eSIR_ED_WPI)
3156 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
3157#endif
3158 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
3159
3160 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
3161
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303162 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
3163 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003164
3165 PopulateDot11fSSID2( pMac, &frm.SSID );
3166 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3167 &frm.SuppRates,psessionEntry);
3168
3169 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
3170 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
3171
3172 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
3173 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
3174
3175 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
3176 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
3177
3178
3179 if ( psessionEntry->lim11hEnable &&
3180 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
3181 {
3182#if defined WLAN_FEATURE_VOWIFI
3183 PowerCapsPopulated = TRUE;
3184 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
3185 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
3186#endif
3187 }
3188
3189#if defined WLAN_FEATURE_VOWIFI
3190 if( pMac->rrm.rrmPEContext.rrmEnable &&
3191 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
3192 {
3193 if (PowerCapsPopulated == FALSE)
3194 {
3195 PowerCapsPopulated = TRUE;
3196 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
3197 }
3198 }
3199#endif
3200
3201 if ( fQosEnabled &&
3202 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
3203 {
3204 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
3205 }
3206
3207 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3208 &frm.ExtSuppRates, psessionEntry );
3209
3210#if defined WLAN_FEATURE_VOWIFI
3211 if( pMac->rrm.rrmPEContext.rrmEnable &&
3212 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
3213 {
3214 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
3215 }
3216#endif
3217 // The join request *should* contain zero or one of the WPA and RSN
3218 // IEs. The payload send along with the request is a
3219 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
3220
3221 // typedef struct sSirRSNie
3222 // {
3223 // tANI_U16 length;
3224 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
3225 // } tSirRSNie, *tpSirRSNie;
3226
3227 // So, we should be able to make the following two calls harmlessly,
3228 // since they do nothing if they don't find the given IE in the
3229 // bytestream with which they're provided.
3230
3231 // The net effect of this will be to faithfully transmit whatever
3232 // security IE is in the join request.
3233
3234 // *However*, if we're associating for the purpose of WPS
3235 // enrollment, and we've been configured to indicate that by
3236 // eliding the WPA or RSN IE, we just skip this:
3237 if( nAddIELen && pAddIE )
3238 {
3239 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
3240 }
3241 if ( NULL == wpsIe )
3242 {
3243 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3244 &frm.RSNOpaque );
3245 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3246 &frm.WPAOpaque );
3247#if defined(FEATURE_WLAN_WAPI)
3248 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3249 &frm.WAPIOpaque );
3250#endif // defined(FEATURE_WLAN_WAPI)
3251 }
3252
3253 // include WME EDCA IE as well
3254 if ( fWmeEnabled )
3255 {
3256 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
3257 {
3258 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
3259 }
3260
3261 if ( fWsmEnabled &&
3262 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3263 {
3264 PopulateDot11fWMMCaps( &frm.WMMCaps );
3265 }
3266 }
3267
Jeff Johnsone7245742012-09-05 17:12:55 -07003268 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003269 pMac->lim.htCapabilityPresentInBeacon)
3270 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003271 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003272 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003273#ifdef WLAN_FEATURE_11AC
3274 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003275 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003276 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003277 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003278 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Sandeep Puligilla60342762014-01-30 21:05:37 +05303279 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003280 }
3281#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003282
3283 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3284 if ( DOT11F_FAILED( nStatus ) )
3285 {
3286 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003287 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003288 nStatus );
3289 // We'll fall back on the worst case scenario:
3290 nPayload = sizeof( tDot11fReAssocRequest );
3291 }
3292 else if ( DOT11F_WARNED( nStatus ) )
3293 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003294 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003295 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003296 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003297 }
3298
3299 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3300
3301 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3302 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3303 ( void** ) &pPacket );
3304 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3305 {
3306 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003307 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003308 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003309 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003310 goto end;
3311 }
3312
3313 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303314 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003315
3316 // Next, we fill out the buffer descriptor:
3317 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3318 SIR_MAC_MGMT_REASSOC_REQ,
3319 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3320 if ( eSIR_SUCCESS != nSirStatus )
3321 {
3322 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003323 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003324 nSirStatus );
3325 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3326 goto end;
3327 }
3328
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303329 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003330 // That done, pack the Probe Request:
3331 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3332 sizeof(tSirMacMgmtHdr),
3333 nPayload, &nPayload );
3334 if ( DOT11F_FAILED( nStatus ) )
3335 {
3336 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003337 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003338 nStatus );
3339 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3340 goto end;
3341 }
3342 else if ( DOT11F_WARNED( nStatus ) )
3343 {
3344 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003345 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003346 }
3347
3348 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003349 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003350 nBytes );)
3351
3352 if( psessionEntry->assocReq != NULL )
3353 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303354 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003355 psessionEntry->assocReq = NULL;
3356 }
3357
3358 if( nAddIELen )
3359 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303360 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3361 pAddIE,
3362 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003363 nPayload += nAddIELen;
3364 }
3365
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303366 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3367 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003368 {
3369 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003370 }
3371 else
3372 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003373 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303374 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003375 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003376 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003377
3378 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003379 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3380 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003381 )
3382 {
3383 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3384 }
3385
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003386 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003387 {
3388 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3389 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003390
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303391 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3392 psessionEntry->peSessionId,
3393 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003394 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3395 HAL_TXRX_FRM_802_11_MGMT,
3396 ANI_TXDIR_TODS,
3397 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3398 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303399 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3400 psessionEntry->peSessionId,
3401 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3403 {
3404 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003405 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003406 nSirStatus );
3407 //Pkt will be freed up by the callback
3408 goto end;
3409 }
3410
3411end:
3412 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303413 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003414 psessionEntry->pLimMlmReassocReq = NULL;
3415
3416} // limSendReassocReqMgmtFrame
3417
3418/**
3419 * \brief Send an Authentication frame
3420 *
3421 *
3422 * \param pMac Pointer to Global MAC structure
3423 *
3424 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3425 * to be sent
3426 *
3427 * \param peerMacAddr MAC address of the peer entity to which Authentication
3428 * frame is destined
3429 *
3430 * \param wepBit Indicates whether wep bit to be set in FC while sending
3431 * Authentication frame3
3432 *
3433 *
3434 * This function is called by limProcessMlmMessages(). Authentication frame
3435 * is formatted and sent when this function is called.
3436 *
3437 *
3438 */
3439
3440void
3441limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3442 tpSirMacAuthFrameBody pAuthFrameBody,
3443 tSirMacAddr peerMacAddr,
3444 tANI_U8 wepBit,
3445 tpPESession psessionEntry
3446 )
3447{
3448 tANI_U8 *pFrame, *pBody;
3449 tANI_U32 frameLen = 0, bodyLen = 0;
3450 tpSirMacMgmtHdr pMacHdr;
3451 tANI_U16 i;
3452 void *pPacket;
3453 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303454 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003455
3456 if(NULL == psessionEntry)
3457 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303458 limLog(pMac, LOGE, FL("Error: psession Entry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003459 return;
3460 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05303461
3462 limLog(pMac, LOG1,
3463 FL("Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
3464 pAuthFrameBody->authTransactionSeqNumber,
3465 pAuthFrameBody->authStatusCode,
3466 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3467 MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003468 if (wepBit == LIM_WEP_IN_FC)
3469 {
3470 /// Auth frame3 to be sent with encrypted framebody
3471 /**
3472 * Allocate buffer for Authenticaton frame of size equal
3473 * to management frame header length plus 2 bytes each for
3474 * auth algorithm number, transaction number, status code,
3475 * 128 bytes for challenge text and 4 bytes each for
3476 * IV & ICV.
3477 */
3478
3479 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3480
3481 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3482 } // if (wepBit == LIM_WEP_IN_FC)
3483 else
3484 {
3485 switch (pAuthFrameBody->authTransactionSeqNumber)
3486 {
3487 case SIR_MAC_AUTH_FRAME_1:
3488 /**
3489 * Allocate buffer for Authenticaton frame of size
3490 * equal to management frame header length plus 2 bytes
3491 * each for auth algorithm number, transaction number
3492 * and status code.
3493 */
3494
3495 frameLen = sizeof(tSirMacMgmtHdr) +
3496 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3497 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3498
3499#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003500 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3501 {
3502 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003503 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003504 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003505 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003506 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003507 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003508 else
3509 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303510 limLog(pMac, LOG3, FL("Auth frame, Does not contain "
3511 "FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003512 frameLen += (2+SIR_MDIE_SIZE);
3513 }
3514 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003515#endif
3516 break;
3517
3518 case SIR_MAC_AUTH_FRAME_2:
3519 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3520 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3521 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3522 {
3523 /**
3524 * Allocate buffer for Authenticaton frame of size
3525 * equal to management frame header length plus
3526 * 2 bytes each for auth algorithm number,
3527 * transaction number and status code.
3528 */
3529
3530 frameLen = sizeof(tSirMacMgmtHdr) +
3531 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3532 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3533 }
3534 else
3535 {
3536 // Shared Key algorithm with challenge text
3537 // to be sent
3538 /**
3539 * Allocate buffer for Authenticaton frame of size
3540 * equal to management frame header length plus
3541 * 2 bytes each for auth algorithm number,
3542 * transaction number, status code and 128 bytes
3543 * for challenge text.
3544 */
3545
3546 frameLen = sizeof(tSirMacMgmtHdr) +
3547 sizeof(tSirMacAuthFrame);
3548 bodyLen = sizeof(tSirMacAuthFrameBody);
3549 }
3550
3551 break;
3552
3553 case SIR_MAC_AUTH_FRAME_3:
3554 /// Auth frame3 to be sent without encrypted framebody
3555 /**
3556 * Allocate buffer for Authenticaton frame of size equal
3557 * to management frame header length plus 2 bytes each
3558 * for auth algorithm number, transaction number and
3559 * status code.
3560 */
3561
3562 frameLen = sizeof(tSirMacMgmtHdr) +
3563 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3564 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3565
3566 break;
3567
3568 case SIR_MAC_AUTH_FRAME_4:
3569 /**
3570 * Allocate buffer for Authenticaton frame of size equal
3571 * to management frame header length plus 2 bytes each
3572 * for auth algorithm number, transaction number and
3573 * status code.
3574 */
3575
3576 frameLen = sizeof(tSirMacMgmtHdr) +
3577 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3578 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3579
3580 break;
3581 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3582 } // end if (wepBit == LIM_WEP_IN_FC)
3583
3584
3585 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3586
3587 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3588 {
3589 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003590 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003591
3592 return;
3593 }
3594
3595 for (i = 0; i < frameLen; i++)
3596 pFrame[i] = 0;
3597
3598 // Prepare BD
3599 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3600 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3601 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303602 limLog(pMac, LOGE, FL("call to limPopulateMacHeader failed for "
3603 "AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003604 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3605 return;
3606 }
3607
3608 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3609 pMacHdr->fc.wep = wepBit;
3610
3611 // Prepare BSSId
3612 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3613 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303614 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3615 (tANI_U8 *) psessionEntry->bssId,
3616 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003617 }
3618
3619 /// Prepare Authentication frame body
3620 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3621
3622 if (wepBit == LIM_WEP_IN_FC)
3623 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303624 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003625
3626 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303627 FL("*** Sending Auth seq# 3 status %d (%d) to"MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003628 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303629 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3630 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003631
Jeff Johnson295189b2012-06-20 16:38:30 -07003632 }
3633 else
3634 {
3635 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3636 pBody += sizeof(tANI_U16);
3637 bodyLen -= sizeof(tANI_U16);
3638
3639 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3640 pBody += sizeof(tANI_U16);
3641 bodyLen -= sizeof(tANI_U16);
3642
3643 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3644 pBody += sizeof(tANI_U16);
3645 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003646 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3647 sizeof (pAuthFrameBody->length) +
3648 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303649 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003650
3651#if defined WLAN_FEATURE_VOWIFI_11R
3652 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3653 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3654 {
3655
3656 {
3657 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003658 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3659 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003660#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowdad63eb492014-02-06 12:21:47 -08003661 PELOG2(limLog(pMac, LOG2, FL("Auth1 Frame FTIE is: "));
3662 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
Jeff Johnson295189b2012-06-20 16:38:30 -07003663 (tANI_U8 *)pBody,
3664 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003665#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003666 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3667 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003668 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3669 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003670 }
3671 }
3672 else
3673 {
3674 /* MDID attr is 54*/
3675 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003676 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003677 *pBody = SIR_MDIE_SIZE;
3678 pBody++;
3679 for(i=0;i<SIR_MDIE_SIZE;i++)
3680 {
3681 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3682 pBody++;
3683 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003684 }
3685 }
3686 }
3687#endif
3688
3689 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303690 FL("*** Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003691 pAuthFrameBody->authTransactionSeqNumber,
3692 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303693 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3694 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003695 }
3696 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3697
3698 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003699 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3700 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003701#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303702 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003703 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3704#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003705 )
3706 {
3707 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3708 }
3709
Ganesh K08bce952012-12-13 15:04:41 -08003710 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3711 {
3712 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3713 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003714
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05303715 limLog( pMac, LOG1, FL("Sending Auth Frame over WQ5 to "MAC_ADDRESS_STR
3716 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
3717 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
3718
3719 txFlag |= HAL_USE_FW_IN_TX_PATH;
3720
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303721 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3722 psessionEntry->peSessionId,
3723 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003724 /// Queue Authentication frame in high priority WQ
3725 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3726 HAL_TXRX_FRM_802_11_MGMT,
3727 ANI_TXDIR_TODS,
3728 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3729 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303730 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3731 psessionEntry->peSessionId,
3732 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003733 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3734 {
3735 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003736 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003737 halstatus);
3738
3739 //Pkt will be freed up by the callback
3740 }
3741
3742 return;
3743} /*** end limSendAuthMgmtFrame() ***/
3744
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003745eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3746{
3747 tANI_U16 aid;
3748 tpDphHashNode pStaDs;
3749 tLimMlmDeauthReq *pMlmDeauthReq;
3750 tLimMlmDeauthCnf mlmDeauthCnf;
3751 tpPESession psessionEntry;
3752
3753 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3754 if (pMlmDeauthReq)
3755 {
3756 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3757 {
3758 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3759 }
3760
3761 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3762 {
3763
3764 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003765 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003766 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3767 goto end;
3768 }
3769
3770 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3771 if (pStaDs == NULL)
3772 {
3773 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3774 goto end;
3775 }
3776
3777
3778 /// Receive path cleanup with dummy packet
3779 limCleanupRxPath(pMac, pStaDs,psessionEntry);
3780 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303781 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003782 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3783 }
3784 return eHAL_STATUS_SUCCESS;
3785end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303786 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003787 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3788 sizeof(tSirMacAddr));
3789 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3790 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3791 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3792
3793 // Free up buffer allocated
3794 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303795 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003796
3797 limPostSmeMessage(pMac,
3798 LIM_MLM_DEAUTH_CNF,
3799 (tANI_U32 *) &mlmDeauthCnf);
3800 return eHAL_STATUS_SUCCESS;
3801}
3802
3803eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3804{
3805 tANI_U16 aid;
3806 tpDphHashNode pStaDs;
3807 tLimMlmDisassocCnf mlmDisassocCnf;
3808 tpPESession psessionEntry;
3809 tLimMlmDisassocReq *pMlmDisassocReq;
3810
3811 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3812 if (pMlmDisassocReq)
3813 {
3814 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3815 {
3816 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3817 }
3818
3819 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3820 {
3821
3822 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003823 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003824 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3825 goto end;
3826 }
3827
3828 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3829 if (pStaDs == NULL)
3830 {
3831 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3832 goto end;
3833 }
3834
3835 /// Receive path cleanup with dummy packet
3836 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3837 {
3838 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3839 goto end;
3840 }
3841
3842#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003843 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303844 (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003845#ifdef FEATURE_WLAN_ESE
3846 (psessionEntry->isESEconnection ) ||
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003847#endif
3848#ifdef FEATURE_WLAN_LFR
3849 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003850#endif
3851 (psessionEntry->is11Rconnection )) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303852 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003853 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003854 {
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303855 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003856 FL("FT Preauth Session (%p,%d) Cleanup"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003857 psessionEntry, psessionEntry->peSessionId););
3858 limFTCleanup(pMac);
3859 }
3860 else
3861 {
3862 PELOGE(limLog(pMac, LOGE,
3863 FL("No FT Preauth Session Cleanup in role %d"
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003864#ifdef FEATURE_WLAN_ESE
3865 " isESE %d"
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003866#endif
3867#ifdef FEATURE_WLAN_LFR
3868 " isLFR %d"
3869#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003870 " is11r %d reason %d"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003871 psessionEntry->limSystemRole,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003872#ifdef FEATURE_WLAN_ESE
3873 psessionEntry->isESEconnection,
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003874#endif
3875#ifdef FEATURE_WLAN_LFR
3876 psessionEntry->isFastRoamIniFeatureEnabled,
3877#endif
3878 psessionEntry->is11Rconnection,
3879 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003880 }
3881#endif
3882
3883 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303884 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003885 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3886 return eHAL_STATUS_SUCCESS;
3887 }
3888 else
3889 {
3890 return eHAL_STATUS_SUCCESS;
3891 }
3892end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303893 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003894 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3895 sizeof(tSirMacAddr));
3896 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3897 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3898
3899 /* Update PE session ID*/
3900 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3901
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003902 if(pMlmDisassocReq != NULL)
3903 {
3904 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303905 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003906 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3907 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003908
3909 limPostSmeMessage(pMac,
3910 LIM_MLM_DISASSOC_CNF,
3911 (tANI_U32 *) &mlmDisassocCnf);
3912 return eHAL_STATUS_SUCCESS;
3913}
3914
3915eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3916{
3917 return limSendDisassocCnf(pMac);
3918}
3919
3920eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3921{
3922 return limSendDeauthCnf(pMac);
3923}
3924
Jeff Johnson295189b2012-06-20 16:38:30 -07003925/**
3926 * \brief This function is called to send Disassociate frame.
3927 *
3928 *
3929 * \param pMac Pointer to Global MAC structure
3930 *
3931 * \param nReason Indicates the reason that need to be sent in
3932 * Disassociation frame
3933 *
3934 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3935 * sent
3936 *
3937 *
3938 */
3939
3940void
3941limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3942 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003943 tSirMacAddr peer,
3944 tpPESession psessionEntry,
3945 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003946{
3947 tDot11fDisassociation frm;
3948 tANI_U8 *pFrame;
3949 tSirRetStatus nSirStatus;
3950 tpSirMacMgmtHdr pMacHdr;
3951 tANI_U32 nBytes, nPayload, nStatus;
3952 void *pPacket;
3953 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303954 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003955 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003956 if(NULL == psessionEntry)
3957 {
3958 return;
3959 }
3960
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303961 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003962
3963 frm.Reason.code = nReason;
3964
3965 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
3966 if ( DOT11F_FAILED( nStatus ) )
3967 {
3968 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003969 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003970 nStatus );
3971 // We'll fall back on the worst case scenario:
3972 nPayload = sizeof( tDot11fDisassociation );
3973 }
3974 else if ( DOT11F_WARNED( nStatus ) )
3975 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003976 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003977 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003978 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 }
3980
3981 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3982
3983 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3984 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3985 ( void** ) &pPacket );
3986 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3987 {
3988 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003989 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003990 return;
3991 }
3992
3993 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303994 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003995
3996 // Next, we fill out the buffer descriptor:
3997 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3998 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
3999 if ( eSIR_SUCCESS != nSirStatus )
4000 {
4001 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004002 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004003 nSirStatus );
4004 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4005 ( void* ) pFrame, ( void* ) pPacket );
4006 return; // just allocated...
4007 }
4008
4009 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4010
4011 // Prepare the BSSID
4012 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4013
Chet Lanctot186b5732013-03-18 10:26:30 -07004014#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004015 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004016#endif
4017
Jeff Johnson295189b2012-06-20 16:38:30 -07004018 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
4019 sizeof(tSirMacMgmtHdr),
4020 nPayload, &nPayload );
4021 if ( DOT11F_FAILED( nStatus ) )
4022 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004023 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004024 nStatus );
4025 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4026 ( void* ) pFrame, ( void* ) pPacket );
4027 return; // allocated!
4028 }
4029 else if ( DOT11F_WARNED( nStatus ) )
4030 {
4031 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004032 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 }
4034
Abhishek Singhcd09b562013-12-24 16:02:20 +05304035 limLog( pMac, LOG1, FL("***Sessionid %d Sending Disassociation frame with "
4036 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4037 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4038 MAC_ADDR_ARRAY(pMacHdr->da),
4039 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004040
4041 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004042 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4043 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004044 )
4045 {
4046 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4047 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004048
Ganesh K08bce952012-12-13 15:04:41 -08004049 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304050 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
4051 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08004052 {
4053 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4054 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004055
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304056 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4057 {
4058 /* This frame will be sent on air by firmware,
4059 which will ensure that this frame goes out
4060 even though DEL_STA is sent immediately */
4061 /* Without this for DEL_STA command there is
4062 risk of flushing frame in BTQM queue without
4063 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304064 limLog( pMac, LOG1, FL("Sending Disassoc Frame over WQ5 to "MAC_ADDRESS_STR
4065 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4066 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304067 txFlag |= HAL_USE_FW_IN_TX_PATH;
4068 }
4069
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004070 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004071 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304072 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4073 psessionEntry->peSessionId,
4074 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004075 // Queue Disassociation frame in high priority WQ
4076 /* get the duration from the request */
4077 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4078 HAL_TXRX_FRM_802_11_MGMT,
4079 ANI_TXDIR_TODS,
4080 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4081 limTxComplete, pFrame, limDisassocTxCompleteCnf,
4082 txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304083 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4084 psessionEntry->peSessionId,
4085 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004086 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07004087
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004088 if (tx_timer_change(
4089 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
4090 != TX_SUCCESS)
4091 {
4092 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004093 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004094 return;
4095 }
4096 else if(TX_SUCCESS != tx_timer_activate(
4097 &pMac->lim.limTimers.gLimDisassocAckTimer))
4098 {
4099 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004100 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004101 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4102 return;
4103 }
4104 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004105 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004106 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304107 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4108 psessionEntry->peSessionId,
4109 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004110 // Queue Disassociation frame in high priority WQ
4111 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4112 HAL_TXRX_FRM_802_11_MGMT,
4113 ANI_TXDIR_TODS,
4114 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4115 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304116 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4117 psessionEntry->peSessionId,
4118 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004119 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4120 {
4121 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004122 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004123 nSirStatus );
4124 //Pkt will be freed up by the callback
4125 return;
4126 }
4127 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004128} // End limSendDisassocMgmtFrame.
4129
4130/**
4131 * \brief This function is called to send a Deauthenticate frame
4132 *
4133 *
4134 * \param pMac Pointer to global MAC structure
4135 *
4136 * \param nReason Indicates the reason that need to be sent in the
4137 * Deauthenticate frame
4138 *
4139 * \param peeer address of the STA to which the frame is to be sent
4140 *
4141 *
4142 */
4143
4144void
4145limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
4146 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004147 tSirMacAddr peer,
4148 tpPESession psessionEntry,
4149 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004150{
4151 tDot11fDeAuth frm;
4152 tANI_U8 *pFrame;
4153 tSirRetStatus nSirStatus;
4154 tpSirMacMgmtHdr pMacHdr;
4155 tANI_U32 nBytes, nPayload, nStatus;
4156 void *pPacket;
4157 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304158 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004159 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004160#ifdef FEATURE_WLAN_TDLS
4161 tANI_U16 aid;
4162 tpDphHashNode pStaDs;
4163#endif
4164
Jeff Johnson295189b2012-06-20 16:38:30 -07004165 if(NULL == psessionEntry)
4166 {
4167 return;
4168 }
4169
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304170 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004171
4172 frm.Reason.code = nReason;
4173
4174 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
4175 if ( DOT11F_FAILED( nStatus ) )
4176 {
4177 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004178 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004179 nStatus );
4180 // We'll fall back on the worst case scenario:
4181 nPayload = sizeof( tDot11fDeAuth );
4182 }
4183 else if ( DOT11F_WARNED( nStatus ) )
4184 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004185 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004186 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004187 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004188 }
4189
4190 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4191
4192 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4193 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4194 ( void** ) &pPacket );
4195 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4196 {
4197 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004198 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004199 return;
4200 }
4201
4202 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304203 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004204
4205 // Next, we fill out the buffer descriptor:
4206 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4207 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
4208 if ( eSIR_SUCCESS != nSirStatus )
4209 {
4210 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004211 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004212 nSirStatus );
4213 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4214 ( void* ) pFrame, ( void* ) pPacket );
4215 return; // just allocated...
4216 }
4217
4218 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4219
4220 // Prepare the BSSID
4221 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4222
Chet Lanctot186b5732013-03-18 10:26:30 -07004223#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004224 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004225#endif
4226
Jeff Johnson295189b2012-06-20 16:38:30 -07004227 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
4228 sizeof(tSirMacMgmtHdr),
4229 nPayload, &nPayload );
4230 if ( DOT11F_FAILED( nStatus ) )
4231 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004232 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004233 nStatus );
4234 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4235 ( void* ) pFrame, ( void* ) pPacket );
4236 return;
4237 }
4238 else if ( DOT11F_WARNED( nStatus ) )
4239 {
4240 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004241 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004242 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05304243 limLog( pMac, LOG1, FL("***Sessionid %d Sending Deauth frame with "
4244 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4245 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4246 MAC_ADDR_ARRAY(pMacHdr->da),
4247 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004248
4249 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004250 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4251 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004252 )
4253 {
4254 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4255 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004256
Ganesh K08bce952012-12-13 15:04:41 -08004257 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304258 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
4259 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08004260 {
4261 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4262 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004263
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304264 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4265 {
4266 /* This frame will be sent on air by firmware,
4267 which will ensure that this frame goes out
4268 even though DEL_STA is sent immediately */
4269 /* Without this for DEL_STA command there is
4270 risk of flushing frame in BTQM queue without
4271 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304272 limLog( pMac, LOG1, FL("Sending Deauth Frame over WQ5 to "MAC_ADDRESS_STR
4273 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4274 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304275 txFlag |= HAL_USE_FW_IN_TX_PATH;
4276 }
4277
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004278#ifdef FEATURE_WLAN_TDLS
4279 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
4280#endif
4281
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004282 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004283 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304284 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4285 psessionEntry->peSessionId,
4286 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004287 // Queue Disassociation frame in high priority WQ
4288 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4289 HAL_TXRX_FRM_802_11_MGMT,
4290 ANI_TXDIR_TODS,
4291 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4292 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304293 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4294 psessionEntry->peSessionId,
4295 halstatus));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304296 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004297 {
4298 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304299 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004300 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08004301 //Pkt will be freed up by the callback limTxComplete
4302
4303 /*Call limProcessDeauthAckTimeout which will send
4304 * DeauthCnf for this frame
4305 */
4306 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004307 return;
4308 }
4309
4310 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
4311
4312 if (tx_timer_change(
4313 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
4314 != TX_SUCCESS)
4315 {
4316 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004317 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004318 return;
4319 }
4320 else if(TX_SUCCESS != tx_timer_activate(
4321 &pMac->lim.limTimers.gLimDeauthAckTimer))
4322 {
4323 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004324 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004325 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4326 return;
4327 }
4328 }
4329 else
4330 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304331 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4332 psessionEntry->peSessionId,
4333 pMacHdr->fc.subType));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004334#ifdef FEATURE_WLAN_TDLS
4335 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4336 {
4337 // Queue Disassociation frame in high priority WQ
4338 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004339 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004340 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004341 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4342 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004343 }
4344 else
4345 {
4346#endif
4347 // Queue Disassociation frame in high priority WQ
4348 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4349 HAL_TXRX_FRM_802_11_MGMT,
4350 ANI_TXDIR_TODS,
4351 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4352 limTxComplete, pFrame, txFlag );
4353#ifdef FEATURE_WLAN_TDLS
4354 }
4355#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304356 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4357 psessionEntry->peSessionId,
4358 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004359 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4360 {
4361 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004362 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004363 nSirStatus );
4364 //Pkt will be freed up by the callback
4365 return;
4366 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004367 }
4368
4369} // End limSendDeauthMgmtFrame.
4370
4371
4372#ifdef ANI_SUPPORT_11H
4373/**
4374 * \brief Send a Measurement Report Action frame
4375 *
4376 *
4377 * \param pMac Pointer to the global MAC structure
4378 *
4379 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4380 *
4381 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4382 *
4383 *
4384 */
4385
4386tSirRetStatus
4387limSendMeasReportFrame(tpAniSirGlobal pMac,
4388 tpSirMacMeasReqActionFrame pMeasReqFrame,
4389 tSirMacAddr peer)
4390{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304391 tDot11fMeasurementReport frm;
4392 tANI_U8 *pFrame;
4393 tSirRetStatus nSirStatus;
4394 tpSirMacMgmtHdr pMacHdr;
4395 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4396 void *pPacket;
4397 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004398
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304399 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004400
4401 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4402 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4403 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4404
4405 switch ( pMeasReqFrame->measReqIE.measType )
4406 {
4407 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4408 nSirStatus =
4409 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4410 &frm.MeasurementReport );
4411 break;
4412 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4413 nSirStatus =
4414 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4415 &frm.MeasurementReport );
4416 break;
4417 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4418 nSirStatus =
4419 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4420 &frm.MeasurementReport );
4421 break;
4422 default:
4423 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004424 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004425 pMeasReqFrame->measReqIE.measType );
4426 return eSIR_FAILURE;
4427 }
4428
4429 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4430
4431 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4432 if ( DOT11F_FAILED( nStatus ) )
4433 {
4434 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004435 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004436 nStatus );
4437 // We'll fall back on the worst case scenario:
4438 nPayload = sizeof( tDot11fMeasurementReport );
4439 }
4440 else if ( DOT11F_WARNED( nStatus ) )
4441 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004442 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004443 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004444 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004445 }
4446
4447 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4448
4449 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4450 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4451 {
4452 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004453 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004454 return eSIR_FAILURE;
4455 }
4456
4457 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304458 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004459
4460 // Next, we fill out the buffer descriptor:
4461 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4462 SIR_MAC_MGMT_ACTION, peer);
4463 if ( eSIR_SUCCESS != nSirStatus )
4464 {
4465 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004466 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004467 nSirStatus );
4468 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4469 return eSIR_FAILURE; // just allocated...
4470 }
4471
4472 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4473
4474 nCfg = 6;
4475 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4476 if ( eSIR_SUCCESS != nSirStatus )
4477 {
4478 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004479 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 nSirStatus );
4481 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4482 return eSIR_FAILURE; // just allocated...
4483 }
4484
Chet Lanctot186b5732013-03-18 10:26:30 -07004485#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004486 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004487#endif
4488
Jeff Johnson295189b2012-06-20 16:38:30 -07004489 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4490 sizeof(tSirMacMgmtHdr),
4491 nPayload, &nPayload );
4492 if ( DOT11F_FAILED( nStatus ) )
4493 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004494 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004495 nStatus );
4496 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4497 return eSIR_FAILURE; // allocated!
4498 }
4499 else if ( DOT11F_WARNED( nStatus ) )
4500 {
4501 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004502 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004503 }
4504
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304505 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4506 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4507 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004508 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4509 HAL_TXRX_FRM_802_11_MGMT,
4510 ANI_TXDIR_TODS,
4511 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4512 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304513 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4514 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4515 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004516 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4517 {
4518 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004519 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004520 nSirStatus );
4521 //Pkt will be freed up by the callback
4522 return eSIR_FAILURE; // just allocated...
4523 }
4524
4525 return eSIR_SUCCESS;
4526
4527} // End limSendMeasReportFrame.
4528
4529
4530/**
4531 * \brief Send a TPC Request Action frame
4532 *
4533 *
4534 * \param pMac Pointer to the global MAC datastructure
4535 *
4536 * \param peer MAC address to which the frame should be sent
4537 *
4538 *
4539 */
4540
4541void
4542limSendTpcRequestFrame(tpAniSirGlobal pMac,
4543 tSirMacAddr peer)
4544{
4545 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304546 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004547 tSirRetStatus nSirStatus;
4548 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304549 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4550 void *pPacket;
4551 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004552
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304553 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004554
4555 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4556 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4557 frm.DialogToken.token = 1;
4558 frm.TPCRequest.present = 1;
4559
4560 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4561 if ( DOT11F_FAILED( nStatus ) )
4562 {
4563 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004564 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004565 nStatus );
4566 // We'll fall back on the worst case scenario:
4567 nPayload = sizeof( tDot11fTPCRequest );
4568 }
4569 else if ( DOT11F_WARNED( nStatus ) )
4570 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004571 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004572 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004573 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004574 }
4575
4576 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4577
4578 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4579 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4580 {
4581 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004582 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004583 return;
4584 }
4585
4586 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304587 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004588
4589 // Next, we fill out the buffer descriptor:
4590 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4591 SIR_MAC_MGMT_ACTION, peer);
4592 if ( eSIR_SUCCESS != nSirStatus )
4593 {
4594 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004595 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004596 nSirStatus );
4597 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4598 return; // just allocated...
4599 }
4600
4601 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4602
4603 nCfg = 6;
4604 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4605 if ( eSIR_SUCCESS != nSirStatus )
4606 {
4607 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004608 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004609 nSirStatus );
4610 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4611 return; // just allocated...
4612 }
4613
Chet Lanctot186b5732013-03-18 10:26:30 -07004614#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004615 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004616#endif
4617
Jeff Johnson295189b2012-06-20 16:38:30 -07004618 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4619 sizeof(tSirMacMgmtHdr),
4620 nPayload, &nPayload );
4621 if ( DOT11F_FAILED( nStatus ) )
4622 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004623 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004624 nStatus );
4625 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4626 return; // allocated!
4627 }
4628 else if ( DOT11F_WARNED( nStatus ) )
4629 {
4630 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004631 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004632 }
4633
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304634 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4635 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4636 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004637 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4638 HAL_TXRX_FRM_802_11_MGMT,
4639 ANI_TXDIR_TODS,
4640 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4641 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304642 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4643 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4644 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004645 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4646 {
4647 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004648 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004649 nSirStatus );
4650 //Pkt will be freed up by the callback
4651 return;
4652 }
4653
4654} // End limSendTpcRequestFrame.
4655
4656
4657/**
4658 * \brief Send a TPC Report Action frame
4659 *
4660 *
4661 * \param pMac Pointer to the global MAC datastructure
4662 *
4663 * \param pTpcReqFrame Pointer to the received TPC Request
4664 *
4665 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4666 *
4667 *
4668 */
4669
4670tSirRetStatus
4671limSendTpcReportFrame(tpAniSirGlobal pMac,
4672 tpSirMacTpcReqActionFrame pTpcReqFrame,
4673 tSirMacAddr peer)
4674{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304675 tDot11fTPCReport frm;
4676 tANI_U8 *pFrame;
4677 tSirRetStatus nSirStatus;
4678 tpSirMacMgmtHdr pMacHdr;
4679 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4680 void *pPacket;
4681 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004682
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304683 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004684
4685 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4686 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4687 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4688
4689 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4690 // "misplaced this function, need to replace:
4691 // txPower = halGetRateToPwrValue(pMac, staid,
4692 // pMac->lim.gLimCurrentChannelId, 0);
4693 frm.TPCReport.tx_power = 0;
4694 frm.TPCReport.link_margin = 0;
4695 frm.TPCReport.present = 1;
4696
4697 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4698 if ( DOT11F_FAILED( nStatus ) )
4699 {
4700 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004701 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004702 nStatus );
4703 // We'll fall back on the worst case scenario:
4704 nPayload = sizeof( tDot11fTPCReport );
4705 }
4706 else if ( DOT11F_WARNED( nStatus ) )
4707 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004708 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004709 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004710 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004711 }
4712
4713 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4714
4715 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4716 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4717 {
4718 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004719 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004720 return eSIR_FAILURE;
4721 }
4722
4723 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304724 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004725
4726 // Next, we fill out the buffer descriptor:
4727 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4728 SIR_MAC_MGMT_ACTION, peer);
4729 if ( eSIR_SUCCESS != nSirStatus )
4730 {
4731 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004732 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004733 nSirStatus );
4734 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4735 return eSIR_FAILURE; // just allocated...
4736 }
4737
4738 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4739
4740 nCfg = 6;
4741 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4742 if ( eSIR_SUCCESS != nSirStatus )
4743 {
4744 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004745 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004746 nSirStatus );
4747 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4748 return eSIR_FAILURE; // just allocated...
4749 }
4750
Chet Lanctot186b5732013-03-18 10:26:30 -07004751#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004752 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004753#endif
4754
Jeff Johnson295189b2012-06-20 16:38:30 -07004755 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4756 sizeof(tSirMacMgmtHdr),
4757 nPayload, &nPayload );
4758 if ( DOT11F_FAILED( nStatus ) )
4759 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004760 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004761 nStatus );
4762 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4763 return eSIR_FAILURE; // allocated!
4764 }
4765 else if ( DOT11F_WARNED( nStatus ) )
4766 {
4767 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004768 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004769 }
4770
4771
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304772 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4773 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4774 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004775 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4776 HAL_TXRX_FRM_802_11_MGMT,
4777 ANI_TXDIR_TODS,
4778 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4779 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304780 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4781 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4782 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004783 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4784 {
4785 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004786 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004787 nSirStatus );
4788 //Pkt will be freed up by the callback
4789 return eSIR_FAILURE; // just allocated...
4790 }
4791
4792 return eSIR_SUCCESS;
4793
4794} // End limSendTpcReportFrame.
4795#endif //ANI_SUPPORT_11H
4796
4797
Jeff Johnson295189b2012-06-20 16:38:30 -07004798/**
4799 * \brief Send a Channel Switch Announcement
4800 *
4801 *
4802 * \param pMac Pointer to the global MAC datastructure
4803 *
4804 * \param peer MAC address to which this frame will be sent
4805 *
4806 * \param nMode
4807 *
4808 * \param nNewChannel
4809 *
4810 * \param nCount
4811 *
4812 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4813 *
4814 *
4815 */
4816
4817tSirRetStatus
4818limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4819 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004820 tANI_U8 nMode,
4821 tANI_U8 nNewChannel,
4822 tANI_U8 nCount,
4823 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004824{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304825 tDot11fChannelSwitch frm;
4826 tANI_U8 *pFrame;
4827 tSirRetStatus nSirStatus;
4828 tpSirMacMgmtHdr pMacHdr;
4829 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4830 void *pPacket;
4831 eHalStatus halstatus;
4832 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004833
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304834 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004835
4836 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4837 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4838 frm.ChanSwitchAnn.switchMode = nMode;
4839 frm.ChanSwitchAnn.newChannel = nNewChannel;
4840 frm.ChanSwitchAnn.switchCount = nCount;
4841 frm.ChanSwitchAnn.present = 1;
4842
4843 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4844 if ( DOT11F_FAILED( nStatus ) )
4845 {
4846 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004847 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004848 nStatus );
4849 // We'll fall back on the worst case scenario:
4850 nPayload = sizeof( tDot11fChannelSwitch );
4851 }
4852 else if ( DOT11F_WARNED( nStatus ) )
4853 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004854 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004855 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004856 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004857 }
4858
4859 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4860
4861 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4862 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4863 {
4864 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004865 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004866 return eSIR_FAILURE;
4867 }
4868
4869 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304870 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004871
4872 // Next, we fill out the buffer descriptor:
4873 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004874 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4875 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304876 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4877 (tANI_U8 *) psessionEntry->bssId,
4878 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004879 if ( eSIR_SUCCESS != nSirStatus )
4880 {
4881 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004882 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004883 nSirStatus );
4884 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4885 return eSIR_FAILURE; // just allocated...
4886 }
4887
Jeff Johnsone7245742012-09-05 17:12:55 -07004888#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004889 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4890
4891 nCfg = 6;
4892 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4893 if ( eSIR_SUCCESS != nSirStatus )
4894 {
4895 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004896 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004897 nSirStatus );
4898 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4899 return eSIR_FAILURE; // just allocated...
4900 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004901#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004902
4903#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004904 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004905#endif
4906
Jeff Johnson295189b2012-06-20 16:38:30 -07004907 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4908 sizeof(tSirMacMgmtHdr),
4909 nPayload, &nPayload );
4910 if ( DOT11F_FAILED( nStatus ) )
4911 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004912 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004913 nStatus );
4914 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4915 return eSIR_FAILURE; // allocated!
4916 }
4917 else if ( DOT11F_WARNED( nStatus ) )
4918 {
4919 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004920 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004921 }
4922
Jeff Johnsone7245742012-09-05 17:12:55 -07004923 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004924 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4925 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004926 )
4927 {
4928 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4929 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304930
4931 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4932 psessionEntry->peSessionId,
4933 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004934 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4935 HAL_TXRX_FRM_802_11_MGMT,
4936 ANI_TXDIR_TODS,
4937 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004938 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304939 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4940 psessionEntry->peSessionId,
4941 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004942 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4943 {
4944 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004945 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004946 nSirStatus );
4947 //Pkt will be freed up by the callback
4948 return eSIR_FAILURE;
4949 }
4950
4951 return eSIR_SUCCESS;
4952
4953} // End limSendChannelSwitchMgmtFrame.
4954
Jeff Johnson295189b2012-06-20 16:38:30 -07004955
4956
Mohit Khanna4a70d262012-09-11 16:30:12 -07004957#ifdef WLAN_FEATURE_11AC
4958tSirRetStatus
4959limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
4960 tSirMacAddr peer,
4961 tANI_U8 nMode,
4962 tpPESession psessionEntry )
4963{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304964 tDot11fOperatingMode frm;
4965 tANI_U8 *pFrame;
4966 tSirRetStatus nSirStatus;
4967 tpSirMacMgmtHdr pMacHdr;
4968 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
4969 void *pPacket;
4970 eHalStatus halstatus;
4971 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07004972
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304973 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004974
4975 frm.Category.category = SIR_MAC_ACTION_VHT;
4976 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
4977 frm.OperatingMode.chanWidth = nMode;
4978 frm.OperatingMode.rxNSS = 0;
4979 frm.OperatingMode.rxNSSType = 0;
4980
4981 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
4982 if ( DOT11F_FAILED( nStatus ) )
4983 {
4984 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004985 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004986 nStatus );
4987 // We'll fall back on the worst case scenario:
4988 nPayload = sizeof( tDot11fOperatingMode);
4989 }
4990 else if ( DOT11F_WARNED( nStatus ) )
4991 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004992 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07004993 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004994 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004995 }
4996
4997 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4998
4999 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5000 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5001 {
5002 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005003 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005004 return eSIR_FAILURE;
5005 }
5006
5007 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305008 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005009
5010
5011 // Next, we fill out the buffer descriptor:
5012 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
5013 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5014 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5015 } else
5016 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5017 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
5018 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305019 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5020 (tANI_U8 *) psessionEntry->bssId,
5021 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005022 if ( eSIR_SUCCESS != nSirStatus )
5023 {
5024 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005025 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005026 nSirStatus );
5027 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5028 return eSIR_FAILURE; // just allocated...
5029 }
5030 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
5031 sizeof(tSirMacMgmtHdr),
5032 nPayload, &nPayload );
5033 if ( DOT11F_FAILED( nStatus ) )
5034 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005035 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005036 nStatus );
5037 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5038 return eSIR_FAILURE; // allocated!
5039 }
5040 else if ( DOT11F_WARNED( nStatus ) )
5041 {
5042 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005043 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005044 }
5045 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07005046 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5047 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07005048 )
5049 {
5050 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5051 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305052
5053 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5054 psessionEntry->peSessionId,
5055 pMacHdr->fc.subType));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005056 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5057 HAL_TXRX_FRM_802_11_MGMT,
5058 ANI_TXDIR_TODS,
5059 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5060 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305061 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5062 psessionEntry->peSessionId,
5063 halstatus));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005064 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5065 {
5066 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005067 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005068 nSirStatus );
5069 //Pkt will be freed up by the callback
5070 return eSIR_FAILURE;
5071 }
5072
5073 return eSIR_SUCCESS;
5074}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005075
5076/**
5077 * \brief Send a VHT Channel Switch Announcement
5078 *
5079 *
5080 * \param pMac Pointer to the global MAC datastructure
5081 *
5082 * \param peer MAC address to which this frame will be sent
5083 *
5084 * \param nChanWidth
5085 *
5086 * \param nNewChannel
5087 *
5088 *
5089 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5090 *
5091 *
5092 */
5093
5094tSirRetStatus
5095limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5096 tSirMacAddr peer,
5097 tANI_U8 nChanWidth,
5098 tANI_U8 nNewChannel,
5099 tANI_U8 ncbMode,
5100 tpPESession psessionEntry )
5101{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305102 tDot11fChannelSwitch frm;
5103 tANI_U8 *pFrame;
5104 tSirRetStatus nSirStatus;
5105 tpSirMacMgmtHdr pMacHdr;
5106 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5107 void *pPacket;
5108 eHalStatus halstatus;
5109 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005110
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305111 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005112
5113
5114 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5115 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5116 frm.ChanSwitchAnn.switchMode = 1;
5117 frm.ChanSwitchAnn.newChannel = nNewChannel;
5118 frm.ChanSwitchAnn.switchCount = 1;
5119 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
5120 frm.ExtChanSwitchAnn.present = 1;
5121 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
5122 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
5123 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
5124 frm.ChanSwitchAnn.present = 1;
5125 frm.WiderBWChanSwitchAnn.present = 1;
5126
5127 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5128 if ( DOT11F_FAILED( nStatus ) )
5129 {
5130 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005131 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005132 nStatus );
5133 // We'll fall back on the worst case scenario:
5134 nPayload = sizeof( tDot11fChannelSwitch );
5135 }
5136 else if ( DOT11F_WARNED( nStatus ) )
5137 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005138 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005139 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005140 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005141 }
5142
5143 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5144
5145 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5146 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5147 {
5148 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005149 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005150 return eSIR_FAILURE;
5151 }
5152 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305153 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005154
5155 // Next, we fill out the buffer descriptor:
5156 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5157 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5158 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305159 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5160 (tANI_U8 *) psessionEntry->bssId,
5161 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005162 if ( eSIR_SUCCESS != nSirStatus )
5163 {
5164 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005165 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005166 nSirStatus );
5167 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5168 return eSIR_FAILURE; // just allocated...
5169 }
5170 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5171 sizeof(tSirMacMgmtHdr),
5172 nPayload, &nPayload );
5173 if ( DOT11F_FAILED( nStatus ) )
5174 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005175 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005176 nStatus );
5177 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5178 return eSIR_FAILURE; // allocated!
5179 }
5180 else if ( DOT11F_WARNED( nStatus ) )
5181 {
5182 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005183 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005184 }
5185
5186 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005187 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5188 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005189 )
5190 {
5191 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5192 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305193
5194 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5195 psessionEntry->peSessionId,
5196 pMacHdr->fc.subType));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005197 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5198 HAL_TXRX_FRM_802_11_MGMT,
5199 ANI_TXDIR_TODS,
5200 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5201 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305202 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5203 psessionEntry->peSessionId,
5204 halstatus));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005205 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5206 {
5207 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005208 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005209 nSirStatus );
5210 //Pkt will be freed up by the callback
5211 return eSIR_FAILURE;
5212 }
5213
5214 return eSIR_SUCCESS;
5215
5216} // End limSendVHTChannelSwitchMgmtFrame.
5217
5218
5219
Mohit Khanna4a70d262012-09-11 16:30:12 -07005220#endif
5221
Jeff Johnson295189b2012-06-20 16:38:30 -07005222/**
5223 * \brief Send an ADDBA Req Action Frame to peer
5224 *
5225 * \sa limSendAddBAReq
5226 *
5227 * \param pMac The global tpAniSirGlobal object
5228 *
5229 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
5230 * the necessary parameters reqd by PE send the ADDBA Req Action
5231 * Frame to the peer
5232 *
5233 * \return eSIR_SUCCESS if setup completes successfully
5234 * eSIR_FAILURE is some problem is encountered
5235 */
5236tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305237 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07005238{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305239 tDot11fAddBAReq frmAddBAReq;
5240 tANI_U8 *pAddBAReqBuffer = NULL;
5241 tpSirMacMgmtHdr pMacHdr;
5242 tANI_U32 frameLen = 0, nStatus, nPayload;
5243 tSirRetStatus statusCode;
5244 eHalStatus halStatus;
5245 void *pPacket;
5246 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005247
5248 if(NULL == psessionEntry)
5249 {
5250 return eSIR_FAILURE;
5251 }
5252
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305253 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005254
5255 // Category - 3 (BA)
5256 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
5257
5258 // Action - 0 (ADDBA Req)
5259 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
5260
5261 // FIXME - Dialog Token, generalize this...
5262 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
5263
5264 // Fill the ADDBA Parameter Set
5265 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
5266 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
5267 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
5268
5269 // BA timeout
5270 // 0 - indicates no BA timeout
5271 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
5272
5273 // BA Starting Sequence Number
5274 // Fragment number will always be zero
5275 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
5276 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
5277 }
5278
5279 frmAddBAReq.BAStartingSequenceControl.ssn =
5280 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
5281
5282 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
5283
5284 if( DOT11F_FAILED( nStatus ))
5285 {
5286 limLog( pMac, LOGW,
5287 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005288 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005289 nStatus );
5290
5291 // We'll fall back on the worst case scenario:
5292 nPayload = sizeof( tDot11fAddBAReq );
5293 }
5294 else if( DOT11F_WARNED( nStatus ))
5295 {
5296 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005297 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005298 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005299 nStatus );
5300 }
5301
5302 // Add the MGMT header to frame length
5303 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5304
5305 // Need to allocate a buffer for ADDBA AF
5306 if( eHAL_STATUS_SUCCESS !=
5307 (halStatus = palPktAlloc( pMac->hHdd,
5308 HAL_TXRX_FRM_802_11_MGMT,
5309 (tANI_U16) frameLen,
5310 (void **) &pAddBAReqBuffer,
5311 (void **) &pPacket )))
5312 {
5313 // Log error
5314 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005315 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005316 frameLen,
5317 halStatus );
5318
5319 statusCode = eSIR_MEM_ALLOC_FAILED;
5320 goto returnAfterError;
5321 }
5322
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305323 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005324
5325 // Copy necessary info to BD
5326 if( eSIR_SUCCESS !=
5327 (statusCode = limPopulateMacHeader( pMac,
5328 pAddBAReqBuffer,
5329 SIR_MAC_MGMT_FRAME,
5330 SIR_MAC_MGMT_ACTION,
5331 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5332 goto returnAfterError;
5333
5334 // Update A3 with the BSSID
5335 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
5336
5337 #if 0
5338 cfgLen = SIR_MAC_ADDR_LENGTH;
5339 if( eSIR_SUCCESS != cfgGetStr( pMac,
5340 WNI_CFG_BSSID,
5341 (tANI_U8 *) pMacHdr->bssId,
5342 &cfgLen ))
5343 {
5344 limLog( pMac, LOGP,
5345 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005346 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005347
5348 // FIXME - Need to convert to tSirRetStatus
5349 statusCode = eSIR_FAILURE;
5350 goto returnAfterError;
5351 }
5352 #endif//TO SUPPORT BT-AMP
5353 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5354
Chet Lanctot186b5732013-03-18 10:26:30 -07005355#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005356 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005357#endif
5358
Jeff Johnson295189b2012-06-20 16:38:30 -07005359 // Now, we're ready to "pack" the frames
5360 nStatus = dot11fPackAddBAReq( pMac,
5361 &frmAddBAReq,
5362 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5363 nPayload,
5364 &nPayload );
5365
5366 if( DOT11F_FAILED( nStatus ))
5367 {
5368 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005369 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005370 nStatus );
5371
5372 // FIXME - Need to convert to tSirRetStatus
5373 statusCode = eSIR_FAILURE;
5374 goto returnAfterError;
5375 }
5376 else if( DOT11F_WARNED( nStatus ))
5377 {
5378 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005379 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5380 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005381 }
5382
5383 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005384 FL( "Sending an ADDBA REQ to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005385 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
5386
5387 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005388 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5389 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005390 )
5391 {
5392 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5393 }
5394
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305395 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5396 psessionEntry->peSessionId,
5397 pMacHdr->fc.subType));
5398 halStatus = halTxFrame( pMac,
5399 pPacket,
5400 (tANI_U16) frameLen,
5401 HAL_TXRX_FRM_802_11_MGMT,
5402 ANI_TXDIR_TODS,
5403 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5404 limTxComplete,
5405 pAddBAReqBuffer, txFlag );
5406 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5407 psessionEntry->peSessionId,
5408 halStatus));
5409 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005410 {
5411 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005412 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005413 halStatus );
5414
5415 // FIXME - Need to convert eHalStatus to tSirRetStatus
5416 statusCode = eSIR_FAILURE;
5417 //Pkt will be freed up by the callback
5418 return statusCode;
5419 }
5420 else
5421 return eSIR_SUCCESS;
5422
5423returnAfterError:
5424
5425 // Release buffer, if allocated
5426 if( NULL != pAddBAReqBuffer )
5427 palPktFree( pMac->hHdd,
5428 HAL_TXRX_FRM_802_11_MGMT,
5429 (void *) pAddBAReqBuffer,
5430 (void *) pPacket );
5431
5432 return statusCode;
5433}
5434
5435/**
5436 * \brief Send an ADDBA Rsp Action Frame to peer
5437 *
5438 * \sa limSendAddBARsp
5439 *
5440 * \param pMac The global tpAniSirGlobal object
5441 *
5442 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5443 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5444 * Frame to the peer
5445 *
5446 * \return eSIR_SUCCESS if setup completes successfully
5447 * eSIR_FAILURE is some problem is encountered
5448 */
5449tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5450 tpLimMlmAddBARsp pMlmAddBARsp,
5451 tpPESession psessionEntry)
5452{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305453 tDot11fAddBARsp frmAddBARsp;
5454 tANI_U8 *pAddBARspBuffer = NULL;
5455 tpSirMacMgmtHdr pMacHdr;
5456 tANI_U32 frameLen = 0, nStatus, nPayload;
5457 tSirRetStatus statusCode;
5458 eHalStatus halStatus;
5459 void *pPacket;
5460 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005461
5462 if(NULL == psessionEntry)
5463 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005464 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005465 return eSIR_FAILURE;
5466 }
5467
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305468 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005469
5470 // Category - 3 (BA)
5471 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5472 // Action - 1 (ADDBA Rsp)
5473 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5474
5475 // Should be same as the one we received in the ADDBA Req
5476 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5477
5478 // ADDBA Req status
5479 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5480
5481 // Fill the ADDBA Parameter Set as provided by caller
5482 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5483 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5484 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005485
5486 if(psessionEntry->isAmsduSupportInAMPDU)
5487 {
5488 frmAddBARsp.AddBAParameterSet.amsduSupported =
5489 psessionEntry->amsduSupportedInBA;
5490 }
5491 else
5492 {
5493 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5494 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005495
5496 // BA timeout
5497 // 0 - indicates no BA timeout
5498 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5499
5500 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5501
5502 if( DOT11F_FAILED( nStatus ))
5503 {
5504 limLog( pMac, LOGW,
5505 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005506 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005507 nStatus );
5508
5509 // We'll fall back on the worst case scenario:
5510 nPayload = sizeof( tDot11fAddBARsp );
5511 }
5512 else if( DOT11F_WARNED( nStatus ))
5513 {
5514 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005515 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005516 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005517 nStatus );
5518 }
5519
5520 // Need to allocate a buffer for ADDBA AF
5521 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5522
5523 // Allocate shared memory
5524 if( eHAL_STATUS_SUCCESS !=
5525 (halStatus = palPktAlloc( pMac->hHdd,
5526 HAL_TXRX_FRM_802_11_MGMT,
5527 (tANI_U16) frameLen,
5528 (void **) &pAddBARspBuffer,
5529 (void **) &pPacket )))
5530 {
5531 // Log error
5532 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005533 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005534 frameLen,
5535 halStatus );
5536
5537 statusCode = eSIR_MEM_ALLOC_FAILED;
5538 goto returnAfterError;
5539 }
5540
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305541 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005542
5543 // Copy necessary info to BD
5544 if( eSIR_SUCCESS !=
5545 (statusCode = limPopulateMacHeader( pMac,
5546 pAddBARspBuffer,
5547 SIR_MAC_MGMT_FRAME,
5548 SIR_MAC_MGMT_ACTION,
5549 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5550 goto returnAfterError;
5551
5552 // Update A3 with the BSSID
5553
5554 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5555
5556 #if 0
5557 cfgLen = SIR_MAC_ADDR_LENGTH;
5558 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5559 WNI_CFG_BSSID,
5560 (tANI_U8 *) pMacHdr->bssId,
5561 &cfgLen ))
5562 {
5563 limLog( pMac, LOGP,
5564 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005565 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005566
5567 // FIXME - Need to convert to tSirRetStatus
5568 statusCode = eSIR_FAILURE;
5569 goto returnAfterError;
5570 }
5571 #endif // TO SUPPORT BT-AMP
5572 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5573
Chet Lanctot186b5732013-03-18 10:26:30 -07005574#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005575 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005576#endif
5577
Jeff Johnson295189b2012-06-20 16:38:30 -07005578 // Now, we're ready to "pack" the frames
5579 nStatus = dot11fPackAddBARsp( pMac,
5580 &frmAddBARsp,
5581 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5582 nPayload,
5583 &nPayload );
5584
5585 if( DOT11F_FAILED( nStatus ))
5586 {
5587 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005588 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005589 nStatus );
5590
5591 // FIXME - Need to convert to tSirRetStatus
5592 statusCode = eSIR_FAILURE;
5593 goto returnAfterError;
5594 }
5595 else if( DOT11F_WARNED( nStatus ))
5596 {
5597 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005598 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5599 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005600 }
5601
5602 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005603 FL( "Sending an ADDBA RSP to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005604 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5605
5606 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005607 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5608 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005609 )
5610 {
5611 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5612 }
5613
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305614 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5615 psessionEntry->peSessionId,
5616 pMacHdr->fc.subType));
5617 halStatus = halTxFrame( pMac,
5618 pPacket,
5619 (tANI_U16) frameLen,
5620 HAL_TXRX_FRM_802_11_MGMT,
5621 ANI_TXDIR_TODS,
5622 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5623 limTxComplete,
5624 pAddBARspBuffer, txFlag );
5625 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5626 psessionEntry->peSessionId,
5627 halStatus));
5628 if( eHAL_STATUS_SUCCESS != halStatus )
5629 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005630 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005631 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005632 halStatus );
5633
5634 // FIXME - HAL error codes are different from PE error
5635 // codes!! And, this routine is returning tSirRetStatus
5636 statusCode = eSIR_FAILURE;
5637 //Pkt will be freed up by the callback
5638 return statusCode;
5639 }
5640 else
5641 return eSIR_SUCCESS;
5642
5643 returnAfterError:
Jeff Johnson295189b2012-06-20 16:38:30 -07005644 // Release buffer, if allocated
5645 if( NULL != pAddBARspBuffer )
5646 palPktFree( pMac->hHdd,
5647 HAL_TXRX_FRM_802_11_MGMT,
5648 (void *) pAddBARspBuffer,
5649 (void *) pPacket );
5650
5651 return statusCode;
5652}
5653
5654/**
5655 * \brief Send a DELBA Indication Action Frame to peer
5656 *
5657 * \sa limSendDelBAInd
5658 *
5659 * \param pMac The global tpAniSirGlobal object
5660 *
5661 * \param peerMacAddr MAC Address of peer
5662 *
5663 * \param reasonCode Reason for the DELBA notification
5664 *
5665 * \param pBAParameterSet The DELBA Parameter Set.
5666 * This identifies the TID for which the BA session is
5667 * being deleted.
5668 *
5669 * \return eSIR_SUCCESS if setup completes successfully
5670 * eSIR_FAILURE is some problem is encountered
5671 */
5672tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5673 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5674{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305675 tDot11fDelBAInd frmDelBAInd;
5676 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005677 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305678 tpSirMacMgmtHdr pMacHdr;
5679 tANI_U32 frameLen = 0, nStatus, nPayload;
5680 tSirRetStatus statusCode;
5681 eHalStatus halStatus;
5682 void *pPacket;
5683 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005684
5685 if(NULL == psessionEntry)
5686 {
5687 return eSIR_FAILURE;
5688 }
5689
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305690 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005691
5692 // Category - 3 (BA)
5693 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5694 // Action - 2 (DELBA)
5695 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5696
5697 // Fill the DELBA Parameter Set as provided by caller
5698 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5699 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5700
5701 // BA Starting Sequence Number
5702 // Fragment number will always be zero
5703 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5704
5705 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5706
5707 if( DOT11F_FAILED( nStatus ))
5708 {
5709 limLog( pMac, LOGW,
5710 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005711 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005712 nStatus );
5713
5714 // We'll fall back on the worst case scenario:
5715 nPayload = sizeof( tDot11fDelBAInd );
5716 }
5717 else if( DOT11F_WARNED( nStatus ))
5718 {
5719 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005720 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005721 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005722 nStatus );
5723 }
5724
5725 // Add the MGMT header to frame length
5726 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5727
5728 // Allocate shared memory
5729 if( eHAL_STATUS_SUCCESS !=
5730 (halStatus = palPktAlloc( pMac->hHdd,
5731 HAL_TXRX_FRM_802_11_MGMT,
5732 (tANI_U16) frameLen,
5733 (void **) &pDelBAIndBuffer,
5734 (void **) &pPacket )))
5735 {
5736 // Log error
5737 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005738 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005739 frameLen,
5740 halStatus );
5741
5742 statusCode = eSIR_MEM_ALLOC_FAILED;
5743 goto returnAfterError;
5744 }
5745
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305746 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005747
5748 // Copy necessary info to BD
5749 if( eSIR_SUCCESS !=
5750 (statusCode = limPopulateMacHeader( pMac,
5751 pDelBAIndBuffer,
5752 SIR_MAC_MGMT_FRAME,
5753 SIR_MAC_MGMT_ACTION,
5754 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5755 goto returnAfterError;
5756
5757 // Update A3 with the BSSID
5758 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5759
5760 #if 0
5761 cfgLen = SIR_MAC_ADDR_LENGTH;
5762 if( eSIR_SUCCESS != cfgGetStr( pMac,
5763 WNI_CFG_BSSID,
5764 (tANI_U8 *) pMacHdr->bssId,
5765 &cfgLen ))
5766 {
5767 limLog( pMac, LOGP,
5768 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005769 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005770
5771 // FIXME - Need to convert to tSirRetStatus
5772 statusCode = eSIR_FAILURE;
5773 goto returnAfterError;
5774 }
5775 #endif //TO SUPPORT BT-AMP
5776 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5777
Chet Lanctot186b5732013-03-18 10:26:30 -07005778#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005779 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005780#endif
5781
Jeff Johnson295189b2012-06-20 16:38:30 -07005782 // Now, we're ready to "pack" the frames
5783 nStatus = dot11fPackDelBAInd( pMac,
5784 &frmDelBAInd,
5785 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5786 nPayload,
5787 &nPayload );
5788
5789 if( DOT11F_FAILED( nStatus ))
5790 {
5791 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005792 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005793 nStatus );
5794
5795 // FIXME - Need to convert to tSirRetStatus
5796 statusCode = eSIR_FAILURE;
5797 goto returnAfterError;
5798 }
5799 else if( DOT11F_WARNED( nStatus ))
5800 {
5801 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005802 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
5803 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005804 }
5805
5806 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005807 FL( "Sending a DELBA IND to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005808 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5809
5810 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005811 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5812 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005813 )
5814 {
5815 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5816 }
5817
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305818 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5819 psessionEntry->peSessionId,
5820 pMacHdr->fc.subType));
5821 halStatus = halTxFrame( pMac,
5822 pPacket,
5823 (tANI_U16) frameLen,
5824 HAL_TXRX_FRM_802_11_MGMT,
5825 ANI_TXDIR_TODS,
5826 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5827 limTxComplete,
5828 pDelBAIndBuffer, txFlag );
5829 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5830 psessionEntry->peSessionId,
5831 halStatus));
5832 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005833 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005834 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005835 statusCode = eSIR_FAILURE;
5836 //Pkt will be freed up by the callback
5837 return statusCode;
5838 }
5839 else
5840 return eSIR_SUCCESS;
5841
5842 returnAfterError:
5843
5844 // Release buffer, if allocated
5845 if( NULL != pDelBAIndBuffer )
5846 palPktFree( pMac->hHdd,
5847 HAL_TXRX_FRM_802_11_MGMT,
5848 (void *) pDelBAIndBuffer,
5849 (void *) pPacket );
5850
5851 return statusCode;
5852}
5853
5854#if defined WLAN_FEATURE_VOWIFI
5855
5856/**
5857 * \brief Send a Neighbor Report Request Action frame
5858 *
5859 *
5860 * \param pMac Pointer to the global MAC structure
5861 *
5862 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5863 *
5864 * \param peer mac address of peer station.
5865 *
5866 * \param psessionEntry address of session entry.
5867 *
5868 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5869 *
5870 *
5871 */
5872
5873tSirRetStatus
5874limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5875 tpSirMacNeighborReportReq pNeighborReq,
5876 tSirMacAddr peer,
5877 tpPESession psessionEntry
5878 )
5879{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305880 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005881 tDot11fNeighborReportRequest frm;
5882 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305883 tpSirMacMgmtHdr pMacHdr;
5884 tANI_U32 nBytes, nPayload, nStatus;
5885 void *pPacket;
5886 eHalStatus halstatus;
5887 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005888
5889 if ( psessionEntry == NULL )
5890 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005891 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005892 return eSIR_FAILURE;
5893 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305894 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005895
5896 frm.Category.category = SIR_MAC_ACTION_RRM;
5897 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5898 frm.DialogToken.token = pNeighborReq->dialogToken;
5899
5900
5901 if( pNeighborReq->ssid_present )
5902 {
5903 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5904 }
5905
5906 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5907 if ( DOT11F_FAILED( nStatus ) )
5908 {
5909 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005910 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005911 nStatus );
5912 // We'll fall back on the worst case scenario:
5913 nPayload = sizeof( tDot11fNeighborReportRequest );
5914 }
5915 else if ( DOT11F_WARNED( nStatus ) )
5916 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005917 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005918 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005919 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005920 }
5921
5922 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5923
5924 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5925 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5926 {
5927 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005928 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005929 return eSIR_FAILURE;
5930 }
5931
5932 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305933 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005934
5935 // Copy necessary info to BD
5936 if( eSIR_SUCCESS !=
5937 (statusCode = limPopulateMacHeader( pMac,
5938 pFrame,
5939 SIR_MAC_MGMT_FRAME,
5940 SIR_MAC_MGMT_ACTION,
5941 peer, psessionEntry->selfMacAddr)))
5942 goto returnAfterError;
5943
5944 // Update A3 with the BSSID
5945 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5946
5947 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5948
Chet Lanctot186b5732013-03-18 10:26:30 -07005949#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005950 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005951#endif
5952
Jeff Johnson295189b2012-06-20 16:38:30 -07005953 // Now, we're ready to "pack" the frames
5954 nStatus = dot11fPackNeighborReportRequest( pMac,
5955 &frm,
5956 pFrame + sizeof( tSirMacMgmtHdr ),
5957 nPayload,
5958 &nPayload );
5959
5960 if( DOT11F_FAILED( nStatus ))
5961 {
5962 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005963 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005964 nStatus );
5965
5966 // FIXME - Need to convert to tSirRetStatus
5967 statusCode = eSIR_FAILURE;
5968 goto returnAfterError;
5969 }
5970 else if( DOT11F_WARNED( nStatus ))
5971 {
5972 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005973 FL( "There were warnings while packing Neighbor Report "
5974 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005975 }
5976
5977 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005978 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005979 limPrintMacAddr( pMac, peer, LOGW );
5980
5981 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005982 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5983 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005984 )
5985 {
5986 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5987 }
5988
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305989 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5990 psessionEntry->peSessionId,
5991 pMacHdr->fc.subType));
5992 halstatus = halTxFrame( pMac,
5993 pPacket,
5994 (tANI_U16) nBytes,
5995 HAL_TXRX_FRM_802_11_MGMT,
5996 ANI_TXDIR_TODS,
5997 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5998 limTxComplete,
5999 pFrame, txFlag );
6000 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6001 psessionEntry->peSessionId,
6002 halstatus));
6003 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006004 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006005 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006006 statusCode = eSIR_FAILURE;
6007 //Pkt will be freed up by the callback
6008 return statusCode;
6009 }
6010 else
6011 return eSIR_SUCCESS;
6012
6013returnAfterError:
6014 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6015
6016 return statusCode;
6017} // End limSendNeighborReportRequestFrame.
6018
6019/**
6020 * \brief Send a Link Report Action frame
6021 *
6022 *
6023 * \param pMac Pointer to the global MAC structure
6024 *
6025 * \param pLinkReport Address of a tSirMacLinkReport
6026 *
6027 * \param peer mac address of peer station.
6028 *
6029 * \param psessionEntry address of session entry.
6030 *
6031 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6032 *
6033 *
6034 */
6035
6036tSirRetStatus
6037limSendLinkReportActionFrame(tpAniSirGlobal pMac,
6038 tpSirMacLinkReport pLinkReport,
6039 tSirMacAddr peer,
6040 tpPESession psessionEntry
6041 )
6042{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306043 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006044 tDot11fLinkMeasurementReport frm;
6045 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306046 tpSirMacMgmtHdr pMacHdr;
6047 tANI_U32 nBytes, nPayload, nStatus;
6048 void *pPacket;
6049 eHalStatus halstatus;
6050 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006051
6052
6053 if ( psessionEntry == NULL )
6054 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006055 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006056 return eSIR_FAILURE;
6057 }
6058
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306059 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006060
6061 frm.Category.category = SIR_MAC_ACTION_RRM;
6062 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
6063 frm.DialogToken.token = pLinkReport->dialogToken;
6064
6065
6066 //IEEE Std. 802.11 7.3.2.18. for the report element.
6067 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
6068 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
6069 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
6070 //such case this way than changing the frame parser.
6071 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
6072 frm.TPCEleLen.TPCLen = 2;
6073 frm.TxPower.txPower = pLinkReport->txPower;
6074 frm.LinkMargin.linkMargin = 0;
6075
6076 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
6077 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
6078 frm.RCPI.rcpi = pLinkReport->rcpi;
6079 frm.RSNI.rsni = pLinkReport->rsni;
6080
6081 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
6082 if ( DOT11F_FAILED( nStatus ) )
6083 {
6084 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006085 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006086 nStatus );
6087 // We'll fall back on the worst case scenario:
6088 nPayload = sizeof( tDot11fLinkMeasurementReport );
6089 }
6090 else if ( DOT11F_WARNED( nStatus ) )
6091 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006092 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006093 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006094 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006095 }
6096
6097 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6098
6099 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6100 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6101 {
6102 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006103 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006104 return eSIR_FAILURE;
6105 }
6106
6107 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306108 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006109
6110 // Copy necessary info to BD
6111 if( eSIR_SUCCESS !=
6112 (statusCode = limPopulateMacHeader( pMac,
6113 pFrame,
6114 SIR_MAC_MGMT_FRAME,
6115 SIR_MAC_MGMT_ACTION,
6116 peer, psessionEntry->selfMacAddr)))
6117 goto returnAfterError;
6118
6119 // Update A3 with the BSSID
6120 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6121
6122 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6123
Chet Lanctot186b5732013-03-18 10:26:30 -07006124#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006125 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006126#endif
6127
Jeff Johnson295189b2012-06-20 16:38:30 -07006128 // Now, we're ready to "pack" the frames
6129 nStatus = dot11fPackLinkMeasurementReport( pMac,
6130 &frm,
6131 pFrame + sizeof( tSirMacMgmtHdr ),
6132 nPayload,
6133 &nPayload );
6134
6135 if( DOT11F_FAILED( nStatus ))
6136 {
6137 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006138 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006139 nStatus );
6140
6141 // FIXME - Need to convert to tSirRetStatus
6142 statusCode = eSIR_FAILURE;
6143 goto returnAfterError;
6144 }
6145 else if( DOT11F_WARNED( nStatus ))
6146 {
6147 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006148 FL( "There were warnings while packing Link Report (0x%08x)." ),
6149 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006150 }
6151
6152 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006153 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006154 limPrintMacAddr( pMac, peer, LOGW );
6155
6156 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006157 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6158 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006159 )
6160 {
6161 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6162 }
6163
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306164 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6165 psessionEntry->peSessionId,
6166 pMacHdr->fc.subType));
6167 halstatus = halTxFrame( pMac,
6168 pPacket,
6169 (tANI_U16) nBytes,
6170 HAL_TXRX_FRM_802_11_MGMT,
6171 ANI_TXDIR_TODS,
6172 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6173 limTxComplete,
6174 pFrame, txFlag );
6175 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6176 psessionEntry->peSessionId,
6177 halstatus));
6178 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006179 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006180 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006181 statusCode = eSIR_FAILURE;
6182 //Pkt will be freed up by the callback
6183 return statusCode;
6184 }
6185 else
6186 return eSIR_SUCCESS;
6187
6188returnAfterError:
6189 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6190
6191 return statusCode;
6192} // End limSendLinkReportActionFrame.
6193
6194/**
6195 * \brief Send a Beacon Report Action frame
6196 *
6197 *
6198 * \param pMac Pointer to the global MAC structure
6199 *
6200 * \param dialog_token dialog token to be used in the action frame.
6201 *
6202 * \param num_report number of reports in pRRMReport.
6203 *
6204 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
6205 *
6206 * \param peer mac address of peer station.
6207 *
6208 * \param psessionEntry address of session entry.
6209 *
6210 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6211 *
6212 *
6213 */
6214
6215tSirRetStatus
6216limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
6217 tANI_U8 dialog_token,
6218 tANI_U8 num_report,
6219 tpSirMacRadioMeasureReport pRRMReport,
6220 tSirMacAddr peer,
6221 tpPESession psessionEntry
6222 )
6223{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306224 tSirRetStatus statusCode = eSIR_SUCCESS;
6225 tANI_U8 *pFrame;
6226 tpSirMacMgmtHdr pMacHdr;
6227 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006228 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306229 eHalStatus halstatus;
6230 tANI_U8 i;
6231 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006232
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006233 tDot11fRadioMeasurementReport *frm =
6234 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
6235 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006236 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006237 return eSIR_FAILURE;
6238 }
6239
Jeff Johnson295189b2012-06-20 16:38:30 -07006240 if ( psessionEntry == NULL )
6241 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006242 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006243 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006244 return eSIR_FAILURE;
6245 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306246 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006247
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006248 frm->Category.category = SIR_MAC_ACTION_RRM;
6249 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
6250 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07006251
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006252 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 -07006253
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006254 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006255 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006256 frm->MeasurementReport[i].type = pRRMReport[i].type;
6257 frm->MeasurementReport[i].token = pRRMReport[i].token;
6258 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006259 switch( pRRMReport[i].type )
6260 {
6261 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006262 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
6263 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6264 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
6265 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 break;
6267 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05306268 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6269 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006270 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006271 break;
6272 }
6273 }
6274
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006275 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07006276 if ( DOT11F_FAILED( nStatus ) )
6277 {
6278 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006279 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006280 nStatus );
6281 // We'll fall back on the worst case scenario:
6282 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006283 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006284 return eSIR_FAILURE;
6285 }
6286 else if ( DOT11F_WARNED( nStatus ) )
6287 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006288 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006289 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006290 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006291 }
6292
6293 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6294
6295 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6296 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6297 {
6298 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006299 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006300 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006301 return eSIR_FAILURE;
6302 }
6303
6304 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306305 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006306
6307 // Copy necessary info to BD
6308 if( eSIR_SUCCESS !=
6309 (statusCode = limPopulateMacHeader( pMac,
6310 pFrame,
6311 SIR_MAC_MGMT_FRAME,
6312 SIR_MAC_MGMT_ACTION,
6313 peer, psessionEntry->selfMacAddr)))
6314 goto returnAfterError;
6315
6316 // Update A3 with the BSSID
6317 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6318
6319 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6320
Chet Lanctot186b5732013-03-18 10:26:30 -07006321#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006322 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006323#endif
6324
Jeff Johnson295189b2012-06-20 16:38:30 -07006325 // Now, we're ready to "pack" the frames
6326 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006327 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07006328 pFrame + sizeof( tSirMacMgmtHdr ),
6329 nPayload,
6330 &nPayload );
6331
6332 if( DOT11F_FAILED( nStatus ))
6333 {
6334 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006335 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006336 nStatus );
6337
6338 // FIXME - Need to convert to tSirRetStatus
6339 statusCode = eSIR_FAILURE;
6340 goto returnAfterError;
6341 }
6342 else if( DOT11F_WARNED( nStatus ))
6343 {
6344 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006345 FL( "There were warnings while packing Radio "
6346 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006347 }
6348
6349 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006350 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006351 limPrintMacAddr( pMac, peer, LOGW );
6352
6353 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006354 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6355 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006356 )
6357 {
6358 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6359 }
6360
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306361 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6362 psessionEntry->peSessionId,
6363 pMacHdr->fc.subType));
6364 halstatus = halTxFrame( pMac,
6365 pPacket,
6366 (tANI_U16) nBytes,
6367 HAL_TXRX_FRM_802_11_MGMT,
6368 ANI_TXDIR_TODS,
6369 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6370 limTxComplete,
6371 pFrame, txFlag );
6372 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6373 psessionEntry->peSessionId,
6374 halstatus));
6375 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006376 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006377 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006378 statusCode = eSIR_FAILURE;
6379 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006380 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006381 return statusCode;
6382 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006383 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006384 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006385 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006386 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006387
6388returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006389 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006390 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07006391 return statusCode;
6392} // End limSendBeaconReportActionFrame.
6393
6394#endif
6395
6396#ifdef WLAN_FEATURE_11W
6397/**
Chet Lanctot8cecea22014-02-11 19:09:36 -08006398 * \brief Send SA query request action frame to peer
6399 *
6400 * \sa limSendSaQueryRequestFrame
6401 *
6402 *
6403 * \param pMac The global tpAniSirGlobal object
6404 *
6405 * \param transId Transaction identifier
6406 *
6407 * \param peer The Mac address of the station to which this action frame is addressed
6408 *
6409 * \param psessionEntry The PE session entry
6410 *
6411 * \return eSIR_SUCCESS if setup completes successfully
6412 * eSIR_FAILURE is some problem is encountered
6413 */
6414
6415tSirRetStatus limSendSaQueryRequestFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
6416 tSirMacAddr peer, tpPESession psessionEntry )
6417{
6418
6419 tDot11fSaQueryReq frm; // SA query request action frame
6420 tANI_U8 *pFrame;
6421 tSirRetStatus nSirStatus;
6422 tpSirMacMgmtHdr pMacHdr;
6423 tANI_U32 nBytes, nPayload, nStatus;
6424 void *pPacket;
6425 eHalStatus halstatus;
6426 tANI_U8 txFlag = 0;
6427
6428 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
6429 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6430 /* 11w action field is :
6431 action: 0 --> SA Query Request action frame
6432 action: 1 --> SA Query Response action frame */
6433 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
6434 /* 11w SA Query Request transId */
6435 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
6436
6437 nStatus = dot11fGetPackedSaQueryReqSize(pMac, &frm, &nPayload);
6438 if ( DOT11F_FAILED( nStatus ) )
6439 {
6440 limLog( pMac, LOGP, FL("Failed to calculate the packed size "
6441 "for an SA Query Request (0x%08x)."),
6442 nStatus );
6443 // We'll fall back on the worst case scenario:
6444 nPayload = sizeof( tDot11fSaQueryReq );
6445 }
6446 else if ( DOT11F_WARNED( nStatus ) )
6447 {
6448 limLog( pMac, LOGW, FL("There were warnings while calculating "
6449 "the packed size for an SA Query Request"
6450 " (0x%08x)."), nStatus );
6451 }
6452
6453 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6454 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6455 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6456 {
6457 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA Query Request "
6458 "action frame"), nBytes );
6459 return eSIR_FAILURE;
6460 }
6461
6462 // Paranoia:
6463 vos_mem_set( pFrame, nBytes, 0 );
6464
6465 // Copy necessary info to BD
6466 nSirStatus = limPopulateMacHeader( pMac,
6467 pFrame,
6468 SIR_MAC_MGMT_FRAME,
6469 SIR_MAC_MGMT_ACTION,
6470 peer, psessionEntry->selfMacAddr );
6471 if ( eSIR_SUCCESS != nSirStatus )
6472 goto returnAfterError;
6473
6474 // Update A3 with the BSSID
6475 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6476
6477 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6478
6479 // Since this is a SA Query Request, set the "protect" (aka WEP) bit
6480 // in the FC
6481 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
6482
6483 // Pack 11w SA Query Request frame
6484 nStatus = dot11fPackSaQueryReq( pMac,
6485 &frm,
6486 pFrame + sizeof( tSirMacMgmtHdr ),
6487 nPayload,
6488 &nPayload );
6489
6490 if ( DOT11F_FAILED( nStatus ))
6491 {
6492 limLog( pMac, LOGE,
6493 FL( "Failed to pack an SA Query Request (0x%08x)." ),
6494 nStatus );
6495 // FIXME - Need to convert to tSirRetStatus
6496 nSirStatus = eSIR_FAILURE;
6497 goto returnAfterError;
6498 }
6499 else if ( DOT11F_WARNED( nStatus ))
6500 {
6501 limLog( pMac, LOGW,
6502 FL( "There were warnings while packing SA Query Request (0x%08x)." ),
6503 nStatus);
6504 }
6505
6506 limLog( pMac, LOG1,
6507 FL( "Sending an SA Query Request to " ));
6508 limPrintMacAddr( pMac, peer, LOG1 );
6509 limPrintMacAddr( pMac, peer, LOGE );
6510 limLog( pMac, LOGE,
6511 FL( "Sending an SA Query Request from " ));
6512 limPrintMacAddr( pMac, psessionEntry->selfMacAddr, LOGE );
6513
6514 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
6515#ifdef WLAN_FEATURE_P2P
6516 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6517 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
6518#endif
6519 )
6520 {
6521 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6522 }
6523
6524 halstatus = halTxFrame( pMac,
6525 pPacket,
6526 (tANI_U16) nBytes,
6527 HAL_TXRX_FRM_802_11_MGMT,
6528 ANI_TXDIR_TODS,
6529 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6530 limTxComplete,
6531 pFrame, txFlag );
6532 if ( eHAL_STATUS_SUCCESS != halstatus )
6533 {
6534 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6535 nSirStatus = eSIR_FAILURE;
6536 //Pkt will be freed up by the callback
6537 return nSirStatus;
6538 }
6539 else {
6540 return eSIR_SUCCESS;
6541 }
6542
6543returnAfterError:
6544 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6545 return nSirStatus;
6546} // End limSendSaQueryRequestFrame
6547
6548/**
Jeff Johnson295189b2012-06-20 16:38:30 -07006549 * \brief Send SA query response action frame to peer
6550 *
6551 * \sa limSendSaQueryResponseFrame
6552 *
6553 *
6554 * \param pMac The global tpAniSirGlobal object
6555 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006556 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006557 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006558 * \param peer The Mac address of the AP to which this action frame is addressed
6559 *
6560 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07006561 *
6562 * \return eSIR_SUCCESS if setup completes successfully
6563 * eSIR_FAILURE is some problem is encountered
6564 */
6565
Chet Lanctot186b5732013-03-18 10:26:30 -07006566tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006567tSirMacAddr peer,tpPESession psessionEntry)
6568{
6569
Chet Lanctot186b5732013-03-18 10:26:30 -07006570 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006571 tANI_U8 *pFrame;
6572 tSirRetStatus nSirStatus;
6573 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07006574 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006575 void *pPacket;
6576 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306577 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006578
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306579 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07006580 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6581 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07006582 action: 0 --> SA query request action frame
6583 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07006584 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
6585 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07006586 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07006587 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006588
Chet Lanctot186b5732013-03-18 10:26:30 -07006589 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6590 if ( DOT11F_FAILED( nStatus ) )
6591 {
6592 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6593 "or a SA Query Response (0x%08x)."),
6594 nStatus );
6595 // We'll fall back on the worst case scenario:
6596 nPayload = sizeof( tDot11fSaQueryRsp );
6597 }
6598 else if ( DOT11F_WARNED( nStatus ) )
6599 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006600 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006601 "the packed size for an SA Query Response"
6602 " (0x%08x)."), nStatus );
6603 }
6604
Jeff Johnson295189b2012-06-20 16:38:30 -07006605 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6606 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6607 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6608 {
6609 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006610 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 return eSIR_FAILURE;
6612 }
6613
6614 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306615 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006616
Chet Lanctot186b5732013-03-18 10:26:30 -07006617 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006618 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006619 pFrame,
6620 SIR_MAC_MGMT_FRAME,
6621 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006622 peer, psessionEntry->selfMacAddr );
6623 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006624 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006625
Chet Lanctot186b5732013-03-18 10:26:30 -07006626 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006627 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6628
Chet Lanctot186b5732013-03-18 10:26:30 -07006629 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006630
Chet Lanctot186b5732013-03-18 10:26:30 -07006631 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6632 // in the FC
Chet Lanctot8cecea22014-02-11 19:09:36 -08006633 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -07006634
Chet Lanctot186b5732013-03-18 10:26:30 -07006635 // Pack 11w SA query response frame
6636 nStatus = dot11fPackSaQueryRsp( pMac,
6637 &frm,
6638 pFrame + sizeof( tSirMacMgmtHdr ),
6639 nPayload,
6640 &nPayload );
6641
6642 if ( DOT11F_FAILED( nStatus ))
6643 {
6644 limLog( pMac, LOGE,
6645 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6646 nStatus );
6647 // FIXME - Need to convert to tSirRetStatus
6648 nSirStatus = eSIR_FAILURE;
6649 goto returnAfterError;
6650 }
6651 else if ( DOT11F_WARNED( nStatus ))
6652 {
6653 limLog( pMac, LOGW,
6654 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6655 nStatus);
6656 }
6657
6658 limLog( pMac, LOG1,
6659 FL( "Sending a SA Query Response to " ));
6660 limPrintMacAddr( pMac, peer, LOGW );
6661
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006662 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006663#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006664 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6665 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006666#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006667 )
6668 {
6669 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6670 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006671
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306672 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6673 psessionEntry->peSessionId,
6674 pMacHdr->fc.subType));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006675 halstatus = halTxFrame( pMac,
6676 pPacket,
6677 (tANI_U16) nBytes,
6678 HAL_TXRX_FRM_802_11_MGMT,
6679 ANI_TXDIR_TODS,
6680 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6681 limTxComplete,
6682 pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306683 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6684 psessionEntry->peSessionId,
6685 halstatus));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006686 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006687 {
6688 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6689 nSirStatus = eSIR_FAILURE;
6690 //Pkt will be freed up by the callback
6691 return nSirStatus;
6692 }
6693 else {
6694 return eSIR_SUCCESS;
6695 }
6696
6697returnAfterError:
6698 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6699 return nSirStatus;
6700} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006701#endif