blob: b136cf502c9580bc427e83d46bc7b5a355413674 [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);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05303780
3781#ifdef WLAN_FEATURE_VOWIFI_11R
3782 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
3783 (
3784#ifdef FEATURE_WLAN_ESE
3785 (psessionEntry->isESEconnection ) ||
3786#endif
3787#ifdef FEATURE_WLAN_LFR
3788 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
3789#endif
3790 (psessionEntry->is11Rconnection )))
3791 {
3792 PELOGE(limLog(pMac, LOGE,
3793 FL("FT Preauth Session (%p,%d) Cleanup"
3794 " Deauth reason %d Trigger = %d"),
3795 psessionEntry, psessionEntry->peSessionId,
3796 pMlmDeauthReq->reasonCode,
3797 pMlmDeauthReq->deauthTrigger););
3798 limFTCleanup(pMac);
3799 }
3800 else
3801 {
3802 PELOGE(limLog(pMac, LOGE,
3803 FL("No FT Preauth Session Cleanup in role %d"
3804#ifdef FEATURE_WLAN_ESE
3805 " isESE %d"
3806#endif
3807#ifdef FEATURE_WLAN_LFR
3808 " isLFR %d"
3809#endif
3810 " is11r %d, Deauth reason %d Trigger = %d"),
3811 psessionEntry->limSystemRole,
3812#ifdef FEATURE_WLAN_ESE
3813 psessionEntry->isESEconnection,
3814#endif
3815#ifdef FEATURE_WLAN_LFR
3816 psessionEntry->isFastRoamIniFeatureEnabled,
3817#endif
3818 psessionEntry->is11Rconnection,
3819 pMlmDeauthReq->reasonCode,
3820 pMlmDeauthReq->deauthTrigger););
3821 }
3822#endif
3823
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003824 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303825 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003826 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3827 }
3828 return eHAL_STATUS_SUCCESS;
3829end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303830 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003831 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3832 sizeof(tSirMacAddr));
3833 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3834 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3835 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3836
3837 // Free up buffer allocated
3838 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303839 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003840
3841 limPostSmeMessage(pMac,
3842 LIM_MLM_DEAUTH_CNF,
3843 (tANI_U32 *) &mlmDeauthCnf);
3844 return eHAL_STATUS_SUCCESS;
3845}
3846
3847eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3848{
3849 tANI_U16 aid;
3850 tpDphHashNode pStaDs;
3851 tLimMlmDisassocCnf mlmDisassocCnf;
3852 tpPESession psessionEntry;
3853 tLimMlmDisassocReq *pMlmDisassocReq;
3854
3855 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3856 if (pMlmDisassocReq)
3857 {
3858 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3859 {
3860 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3861 }
3862
3863 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3864 {
3865
3866 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003867 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003868 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3869 goto end;
3870 }
3871
3872 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3873 if (pStaDs == NULL)
3874 {
3875 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3876 goto end;
3877 }
3878
3879 /// Receive path cleanup with dummy packet
3880 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3881 {
3882 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3883 goto end;
3884 }
3885
3886#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003887 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303888 (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003889#ifdef FEATURE_WLAN_ESE
3890 (psessionEntry->isESEconnection ) ||
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003891#endif
3892#ifdef FEATURE_WLAN_LFR
3893 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003894#endif
3895 (psessionEntry->is11Rconnection )) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303896 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003897 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003898 {
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303899 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003900 FL("FT Preauth Session (%p,%d) Cleanup"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003901 psessionEntry, psessionEntry->peSessionId););
3902 limFTCleanup(pMac);
3903 }
3904 else
3905 {
3906 PELOGE(limLog(pMac, LOGE,
3907 FL("No FT Preauth Session Cleanup in role %d"
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003908#ifdef FEATURE_WLAN_ESE
3909 " isESE %d"
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003910#endif
3911#ifdef FEATURE_WLAN_LFR
3912 " isLFR %d"
3913#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003914 " is11r %d reason %d"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003915 psessionEntry->limSystemRole,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003916#ifdef FEATURE_WLAN_ESE
3917 psessionEntry->isESEconnection,
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003918#endif
3919#ifdef FEATURE_WLAN_LFR
3920 psessionEntry->isFastRoamIniFeatureEnabled,
3921#endif
3922 psessionEntry->is11Rconnection,
3923 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003924 }
3925#endif
3926
3927 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303928 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003929 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3930 return eHAL_STATUS_SUCCESS;
3931 }
3932 else
3933 {
3934 return eHAL_STATUS_SUCCESS;
3935 }
3936end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303937 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003938 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3939 sizeof(tSirMacAddr));
3940 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3941 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3942
3943 /* Update PE session ID*/
3944 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3945
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003946 if(pMlmDisassocReq != NULL)
3947 {
3948 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303949 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003950 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3951 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003952
3953 limPostSmeMessage(pMac,
3954 LIM_MLM_DISASSOC_CNF,
3955 (tANI_U32 *) &mlmDisassocCnf);
3956 return eHAL_STATUS_SUCCESS;
3957}
3958
3959eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3960{
3961 return limSendDisassocCnf(pMac);
3962}
3963
3964eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3965{
3966 return limSendDeauthCnf(pMac);
3967}
3968
Jeff Johnson295189b2012-06-20 16:38:30 -07003969/**
3970 * \brief This function is called to send Disassociate frame.
3971 *
3972 *
3973 * \param pMac Pointer to Global MAC structure
3974 *
3975 * \param nReason Indicates the reason that need to be sent in
3976 * Disassociation frame
3977 *
3978 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3979 * sent
3980 *
3981 *
3982 */
3983
3984void
3985limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3986 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003987 tSirMacAddr peer,
3988 tpPESession psessionEntry,
3989 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003990{
3991 tDot11fDisassociation frm;
3992 tANI_U8 *pFrame;
3993 tSirRetStatus nSirStatus;
3994 tpSirMacMgmtHdr pMacHdr;
3995 tANI_U32 nBytes, nPayload, nStatus;
3996 void *pPacket;
3997 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303998 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003999 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004000 if(NULL == psessionEntry)
4001 {
4002 return;
4003 }
4004
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304005 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004006
4007 frm.Reason.code = nReason;
4008
4009 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
4010 if ( DOT11F_FAILED( nStatus ) )
4011 {
4012 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004013 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004014 nStatus );
4015 // We'll fall back on the worst case scenario:
4016 nPayload = sizeof( tDot11fDisassociation );
4017 }
4018 else if ( DOT11F_WARNED( nStatus ) )
4019 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004020 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004021 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004022 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004023 }
4024
4025 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4026
4027 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4028 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4029 ( void** ) &pPacket );
4030 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4031 {
4032 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004033 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004034 return;
4035 }
4036
4037 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304038 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004039
4040 // Next, we fill out the buffer descriptor:
4041 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4042 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
4043 if ( eSIR_SUCCESS != nSirStatus )
4044 {
4045 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004046 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004047 nSirStatus );
4048 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4049 ( void* ) pFrame, ( void* ) pPacket );
4050 return; // just allocated...
4051 }
4052
4053 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4054
4055 // Prepare the BSSID
4056 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4057
Chet Lanctot186b5732013-03-18 10:26:30 -07004058#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004059 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004060#endif
4061
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
4063 sizeof(tSirMacMgmtHdr),
4064 nPayload, &nPayload );
4065 if ( DOT11F_FAILED( nStatus ) )
4066 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004067 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004068 nStatus );
4069 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4070 ( void* ) pFrame, ( void* ) pPacket );
4071 return; // allocated!
4072 }
4073 else if ( DOT11F_WARNED( nStatus ) )
4074 {
4075 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004076 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004077 }
4078
Abhishek Singhcd09b562013-12-24 16:02:20 +05304079 limLog( pMac, LOG1, FL("***Sessionid %d Sending Disassociation frame with "
4080 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4081 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4082 MAC_ADDR_ARRAY(pMacHdr->da),
4083 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004084
4085 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004086 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4087 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004088 )
4089 {
4090 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4091 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004092
Ganesh K08bce952012-12-13 15:04:41 -08004093 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304094 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
4095 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08004096 {
4097 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4098 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004099
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304100 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4101 {
4102 /* This frame will be sent on air by firmware,
4103 which will ensure that this frame goes out
4104 even though DEL_STA is sent immediately */
4105 /* Without this for DEL_STA command there is
4106 risk of flushing frame in BTQM queue without
4107 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304108 limLog( pMac, LOG1, FL("Sending Disassoc Frame over WQ5 to "MAC_ADDRESS_STR
4109 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4110 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304111 txFlag |= HAL_USE_FW_IN_TX_PATH;
4112 }
4113
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004114 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304116 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4117 psessionEntry->peSessionId,
4118 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004119 // Queue Disassociation frame in high priority WQ
4120 /* get the duration from the request */
4121 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4122 HAL_TXRX_FRM_802_11_MGMT,
4123 ANI_TXDIR_TODS,
4124 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4125 limTxComplete, pFrame, limDisassocTxCompleteCnf,
4126 txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304127 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4128 psessionEntry->peSessionId,
4129 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004130 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07004131
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004132 if (tx_timer_change(
4133 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
4134 != TX_SUCCESS)
4135 {
4136 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004137 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004138 return;
4139 }
4140 else if(TX_SUCCESS != tx_timer_activate(
4141 &pMac->lim.limTimers.gLimDisassocAckTimer))
4142 {
4143 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004144 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004145 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4146 return;
4147 }
4148 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004149 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004150 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304151 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4152 psessionEntry->peSessionId,
4153 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004154 // Queue Disassociation frame in high priority WQ
4155 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4156 HAL_TXRX_FRM_802_11_MGMT,
4157 ANI_TXDIR_TODS,
4158 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4159 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304160 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4161 psessionEntry->peSessionId,
4162 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004163 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4164 {
4165 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004166 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004167 nSirStatus );
4168 //Pkt will be freed up by the callback
4169 return;
4170 }
4171 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004172} // End limSendDisassocMgmtFrame.
4173
4174/**
4175 * \brief This function is called to send a Deauthenticate frame
4176 *
4177 *
4178 * \param pMac Pointer to global MAC structure
4179 *
4180 * \param nReason Indicates the reason that need to be sent in the
4181 * Deauthenticate frame
4182 *
4183 * \param peeer address of the STA to which the frame is to be sent
4184 *
4185 *
4186 */
4187
4188void
4189limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
4190 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004191 tSirMacAddr peer,
4192 tpPESession psessionEntry,
4193 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004194{
4195 tDot11fDeAuth frm;
4196 tANI_U8 *pFrame;
4197 tSirRetStatus nSirStatus;
4198 tpSirMacMgmtHdr pMacHdr;
4199 tANI_U32 nBytes, nPayload, nStatus;
4200 void *pPacket;
4201 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304202 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004203 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004204#ifdef FEATURE_WLAN_TDLS
4205 tANI_U16 aid;
4206 tpDphHashNode pStaDs;
4207#endif
4208
Jeff Johnson295189b2012-06-20 16:38:30 -07004209 if(NULL == psessionEntry)
4210 {
4211 return;
4212 }
4213
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304214 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004215
4216 frm.Reason.code = nReason;
4217
4218 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
4219 if ( DOT11F_FAILED( nStatus ) )
4220 {
4221 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004222 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004223 nStatus );
4224 // We'll fall back on the worst case scenario:
4225 nPayload = sizeof( tDot11fDeAuth );
4226 }
4227 else if ( DOT11F_WARNED( nStatus ) )
4228 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004229 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004230 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004231 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004232 }
4233
4234 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4235
4236 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4237 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4238 ( void** ) &pPacket );
4239 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4240 {
4241 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004242 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004243 return;
4244 }
4245
4246 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304247 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004248
4249 // Next, we fill out the buffer descriptor:
4250 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4251 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
4252 if ( eSIR_SUCCESS != nSirStatus )
4253 {
4254 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004255 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004256 nSirStatus );
4257 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4258 ( void* ) pFrame, ( void* ) pPacket );
4259 return; // just allocated...
4260 }
4261
4262 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4263
4264 // Prepare the BSSID
4265 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4266
Chet Lanctot186b5732013-03-18 10:26:30 -07004267#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004268 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004269#endif
4270
Jeff Johnson295189b2012-06-20 16:38:30 -07004271 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
4272 sizeof(tSirMacMgmtHdr),
4273 nPayload, &nPayload );
4274 if ( DOT11F_FAILED( nStatus ) )
4275 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004276 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004277 nStatus );
4278 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4279 ( void* ) pFrame, ( void* ) pPacket );
4280 return;
4281 }
4282 else if ( DOT11F_WARNED( nStatus ) )
4283 {
4284 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004285 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004286 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05304287 limLog( pMac, LOG1, FL("***Sessionid %d Sending Deauth frame with "
4288 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4289 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4290 MAC_ADDR_ARRAY(pMacHdr->da),
4291 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004292
4293 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004294 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4295 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 )
4297 {
4298 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4299 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004300
Ganesh K08bce952012-12-13 15:04:41 -08004301 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304302 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
4303 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08004304 {
4305 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4306 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004307
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304308 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4309 {
4310 /* This frame will be sent on air by firmware,
4311 which will ensure that this frame goes out
4312 even though DEL_STA is sent immediately */
4313 /* Without this for DEL_STA command there is
4314 risk of flushing frame in BTQM queue without
4315 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304316 limLog( pMac, LOG1, FL("Sending Deauth Frame over WQ5 to "MAC_ADDRESS_STR
4317 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4318 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304319 txFlag |= HAL_USE_FW_IN_TX_PATH;
4320 }
4321
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004322#ifdef FEATURE_WLAN_TDLS
4323 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
4324#endif
4325
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004326 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004327 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304328 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4329 psessionEntry->peSessionId,
4330 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004331 // Queue Disassociation frame in high priority WQ
4332 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4333 HAL_TXRX_FRM_802_11_MGMT,
4334 ANI_TXDIR_TODS,
4335 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4336 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304337 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4338 psessionEntry->peSessionId,
4339 halstatus));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304340 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004341 {
4342 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304343 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004344 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08004345 //Pkt will be freed up by the callback limTxComplete
4346
4347 /*Call limProcessDeauthAckTimeout which will send
4348 * DeauthCnf for this frame
4349 */
4350 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004351 return;
4352 }
4353
4354 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
4355
4356 if (tx_timer_change(
4357 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
4358 != TX_SUCCESS)
4359 {
4360 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004361 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004362 return;
4363 }
4364 else if(TX_SUCCESS != tx_timer_activate(
4365 &pMac->lim.limTimers.gLimDeauthAckTimer))
4366 {
4367 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004368 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004369 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4370 return;
4371 }
4372 }
4373 else
4374 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304375 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4376 psessionEntry->peSessionId,
4377 pMacHdr->fc.subType));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004378#ifdef FEATURE_WLAN_TDLS
4379 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4380 {
4381 // Queue Disassociation frame in high priority WQ
4382 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004383 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004384 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004385 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4386 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004387 }
4388 else
4389 {
4390#endif
4391 // Queue Disassociation frame in high priority WQ
4392 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4393 HAL_TXRX_FRM_802_11_MGMT,
4394 ANI_TXDIR_TODS,
4395 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4396 limTxComplete, pFrame, txFlag );
4397#ifdef FEATURE_WLAN_TDLS
4398 }
4399#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304400 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4401 psessionEntry->peSessionId,
4402 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004403 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4404 {
4405 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004406 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004407 nSirStatus );
4408 //Pkt will be freed up by the callback
4409 return;
4410 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004411 }
4412
4413} // End limSendDeauthMgmtFrame.
4414
4415
4416#ifdef ANI_SUPPORT_11H
4417/**
4418 * \brief Send a Measurement Report Action frame
4419 *
4420 *
4421 * \param pMac Pointer to the global MAC structure
4422 *
4423 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4424 *
4425 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4426 *
4427 *
4428 */
4429
4430tSirRetStatus
4431limSendMeasReportFrame(tpAniSirGlobal pMac,
4432 tpSirMacMeasReqActionFrame pMeasReqFrame,
4433 tSirMacAddr peer)
4434{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304435 tDot11fMeasurementReport frm;
4436 tANI_U8 *pFrame;
4437 tSirRetStatus nSirStatus;
4438 tpSirMacMgmtHdr pMacHdr;
4439 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4440 void *pPacket;
4441 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004442
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304443 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004444
4445 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4446 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4447 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4448
4449 switch ( pMeasReqFrame->measReqIE.measType )
4450 {
4451 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4452 nSirStatus =
4453 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4454 &frm.MeasurementReport );
4455 break;
4456 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4457 nSirStatus =
4458 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4459 &frm.MeasurementReport );
4460 break;
4461 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4462 nSirStatus =
4463 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4464 &frm.MeasurementReport );
4465 break;
4466 default:
4467 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004468 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004469 pMeasReqFrame->measReqIE.measType );
4470 return eSIR_FAILURE;
4471 }
4472
4473 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4474
4475 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4476 if ( DOT11F_FAILED( nStatus ) )
4477 {
4478 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004479 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 nStatus );
4481 // We'll fall back on the worst case scenario:
4482 nPayload = sizeof( tDot11fMeasurementReport );
4483 }
4484 else if ( DOT11F_WARNED( nStatus ) )
4485 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004486 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004487 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004488 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004489 }
4490
4491 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4492
4493 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4494 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4495 {
4496 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004497 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004498 return eSIR_FAILURE;
4499 }
4500
4501 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304502 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004503
4504 // Next, we fill out the buffer descriptor:
4505 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4506 SIR_MAC_MGMT_ACTION, peer);
4507 if ( eSIR_SUCCESS != nSirStatus )
4508 {
4509 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004510 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004511 nSirStatus );
4512 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4513 return eSIR_FAILURE; // just allocated...
4514 }
4515
4516 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4517
4518 nCfg = 6;
4519 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4520 if ( eSIR_SUCCESS != nSirStatus )
4521 {
4522 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004523 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004524 nSirStatus );
4525 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4526 return eSIR_FAILURE; // just allocated...
4527 }
4528
Chet Lanctot186b5732013-03-18 10:26:30 -07004529#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004530 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004531#endif
4532
Jeff Johnson295189b2012-06-20 16:38:30 -07004533 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4534 sizeof(tSirMacMgmtHdr),
4535 nPayload, &nPayload );
4536 if ( DOT11F_FAILED( nStatus ) )
4537 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004538 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004539 nStatus );
4540 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4541 return eSIR_FAILURE; // allocated!
4542 }
4543 else if ( DOT11F_WARNED( nStatus ) )
4544 {
4545 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004546 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004547 }
4548
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304549 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4550 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4551 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004552 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4553 HAL_TXRX_FRM_802_11_MGMT,
4554 ANI_TXDIR_TODS,
4555 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4556 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304557 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4558 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4559 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4561 {
4562 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004563 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004564 nSirStatus );
4565 //Pkt will be freed up by the callback
4566 return eSIR_FAILURE; // just allocated...
4567 }
4568
4569 return eSIR_SUCCESS;
4570
4571} // End limSendMeasReportFrame.
4572
4573
4574/**
4575 * \brief Send a TPC Request Action frame
4576 *
4577 *
4578 * \param pMac Pointer to the global MAC datastructure
4579 *
4580 * \param peer MAC address to which the frame should be sent
4581 *
4582 *
4583 */
4584
4585void
4586limSendTpcRequestFrame(tpAniSirGlobal pMac,
4587 tSirMacAddr peer)
4588{
4589 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304590 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004591 tSirRetStatus nSirStatus;
4592 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304593 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4594 void *pPacket;
4595 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004596
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304597 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004598
4599 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4600 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4601 frm.DialogToken.token = 1;
4602 frm.TPCRequest.present = 1;
4603
4604 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4605 if ( DOT11F_FAILED( nStatus ) )
4606 {
4607 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004608 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004609 nStatus );
4610 // We'll fall back on the worst case scenario:
4611 nPayload = sizeof( tDot11fTPCRequest );
4612 }
4613 else if ( DOT11F_WARNED( nStatus ) )
4614 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004615 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004616 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004617 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004618 }
4619
4620 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4621
4622 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4623 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4624 {
4625 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004626 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004627 return;
4628 }
4629
4630 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304631 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004632
4633 // Next, we fill out the buffer descriptor:
4634 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4635 SIR_MAC_MGMT_ACTION, peer);
4636 if ( eSIR_SUCCESS != nSirStatus )
4637 {
4638 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004639 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004640 nSirStatus );
4641 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4642 return; // just allocated...
4643 }
4644
4645 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4646
4647 nCfg = 6;
4648 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4649 if ( eSIR_SUCCESS != nSirStatus )
4650 {
4651 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004652 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004653 nSirStatus );
4654 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4655 return; // just allocated...
4656 }
4657
Chet Lanctot186b5732013-03-18 10:26:30 -07004658#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004659 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004660#endif
4661
Jeff Johnson295189b2012-06-20 16:38:30 -07004662 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4663 sizeof(tSirMacMgmtHdr),
4664 nPayload, &nPayload );
4665 if ( DOT11F_FAILED( nStatus ) )
4666 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004667 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004668 nStatus );
4669 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4670 return; // allocated!
4671 }
4672 else if ( DOT11F_WARNED( nStatus ) )
4673 {
4674 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004675 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004676 }
4677
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304678 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4679 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4680 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004681 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4682 HAL_TXRX_FRM_802_11_MGMT,
4683 ANI_TXDIR_TODS,
4684 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4685 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304686 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4687 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4688 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004689 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4690 {
4691 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004692 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004693 nSirStatus );
4694 //Pkt will be freed up by the callback
4695 return;
4696 }
4697
4698} // End limSendTpcRequestFrame.
4699
4700
4701/**
4702 * \brief Send a TPC Report Action frame
4703 *
4704 *
4705 * \param pMac Pointer to the global MAC datastructure
4706 *
4707 * \param pTpcReqFrame Pointer to the received TPC Request
4708 *
4709 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4710 *
4711 *
4712 */
4713
4714tSirRetStatus
4715limSendTpcReportFrame(tpAniSirGlobal pMac,
4716 tpSirMacTpcReqActionFrame pTpcReqFrame,
4717 tSirMacAddr peer)
4718{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304719 tDot11fTPCReport frm;
4720 tANI_U8 *pFrame;
4721 tSirRetStatus nSirStatus;
4722 tpSirMacMgmtHdr pMacHdr;
4723 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4724 void *pPacket;
4725 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004726
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304727 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004728
4729 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4730 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4731 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4732
4733 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4734 // "misplaced this function, need to replace:
4735 // txPower = halGetRateToPwrValue(pMac, staid,
4736 // pMac->lim.gLimCurrentChannelId, 0);
4737 frm.TPCReport.tx_power = 0;
4738 frm.TPCReport.link_margin = 0;
4739 frm.TPCReport.present = 1;
4740
4741 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4742 if ( DOT11F_FAILED( nStatus ) )
4743 {
4744 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004745 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004746 nStatus );
4747 // We'll fall back on the worst case scenario:
4748 nPayload = sizeof( tDot11fTPCReport );
4749 }
4750 else if ( DOT11F_WARNED( nStatus ) )
4751 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004752 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004753 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004754 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004755 }
4756
4757 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4758
4759 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4760 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4761 {
4762 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004763 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004764 return eSIR_FAILURE;
4765 }
4766
4767 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304768 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004769
4770 // Next, we fill out the buffer descriptor:
4771 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4772 SIR_MAC_MGMT_ACTION, peer);
4773 if ( eSIR_SUCCESS != nSirStatus )
4774 {
4775 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004776 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004777 nSirStatus );
4778 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4779 return eSIR_FAILURE; // just allocated...
4780 }
4781
4782 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4783
4784 nCfg = 6;
4785 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4786 if ( eSIR_SUCCESS != nSirStatus )
4787 {
4788 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004789 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004790 nSirStatus );
4791 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4792 return eSIR_FAILURE; // just allocated...
4793 }
4794
Chet Lanctot186b5732013-03-18 10:26:30 -07004795#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004796 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004797#endif
4798
Jeff Johnson295189b2012-06-20 16:38:30 -07004799 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4800 sizeof(tSirMacMgmtHdr),
4801 nPayload, &nPayload );
4802 if ( DOT11F_FAILED( nStatus ) )
4803 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004804 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004805 nStatus );
4806 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4807 return eSIR_FAILURE; // allocated!
4808 }
4809 else if ( DOT11F_WARNED( nStatus ) )
4810 {
4811 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004812 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004813 }
4814
4815
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304816 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4817 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4818 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004819 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4820 HAL_TXRX_FRM_802_11_MGMT,
4821 ANI_TXDIR_TODS,
4822 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4823 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304824 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4825 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4826 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004827 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4828 {
4829 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004830 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004831 nSirStatus );
4832 //Pkt will be freed up by the callback
4833 return eSIR_FAILURE; // just allocated...
4834 }
4835
4836 return eSIR_SUCCESS;
4837
4838} // End limSendTpcReportFrame.
4839#endif //ANI_SUPPORT_11H
4840
4841
Jeff Johnson295189b2012-06-20 16:38:30 -07004842/**
4843 * \brief Send a Channel Switch Announcement
4844 *
4845 *
4846 * \param pMac Pointer to the global MAC datastructure
4847 *
4848 * \param peer MAC address to which this frame will be sent
4849 *
4850 * \param nMode
4851 *
4852 * \param nNewChannel
4853 *
4854 * \param nCount
4855 *
4856 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4857 *
4858 *
4859 */
4860
4861tSirRetStatus
4862limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4863 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004864 tANI_U8 nMode,
4865 tANI_U8 nNewChannel,
4866 tANI_U8 nCount,
4867 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004868{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304869 tDot11fChannelSwitch frm;
4870 tANI_U8 *pFrame;
4871 tSirRetStatus nSirStatus;
4872 tpSirMacMgmtHdr pMacHdr;
4873 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4874 void *pPacket;
4875 eHalStatus halstatus;
4876 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004877
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304878 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004879
4880 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4881 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4882 frm.ChanSwitchAnn.switchMode = nMode;
4883 frm.ChanSwitchAnn.newChannel = nNewChannel;
4884 frm.ChanSwitchAnn.switchCount = nCount;
4885 frm.ChanSwitchAnn.present = 1;
4886
4887 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4888 if ( DOT11F_FAILED( nStatus ) )
4889 {
4890 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004891 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004892 nStatus );
4893 // We'll fall back on the worst case scenario:
4894 nPayload = sizeof( tDot11fChannelSwitch );
4895 }
4896 else if ( DOT11F_WARNED( nStatus ) )
4897 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004898 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004899 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004900 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004901 }
4902
4903 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4904
4905 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4906 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4907 {
4908 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004909 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004910 return eSIR_FAILURE;
4911 }
4912
4913 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304914 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004915
4916 // Next, we fill out the buffer descriptor:
4917 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004918 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4919 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304920 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4921 (tANI_U8 *) psessionEntry->bssId,
4922 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004923 if ( eSIR_SUCCESS != nSirStatus )
4924 {
4925 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004926 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004927 nSirStatus );
4928 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4929 return eSIR_FAILURE; // just allocated...
4930 }
4931
Jeff Johnsone7245742012-09-05 17:12:55 -07004932#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004933 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4934
4935 nCfg = 6;
4936 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4937 if ( eSIR_SUCCESS != nSirStatus )
4938 {
4939 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004940 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004941 nSirStatus );
4942 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4943 return eSIR_FAILURE; // just allocated...
4944 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004945#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004946
4947#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004948 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004949#endif
4950
Jeff Johnson295189b2012-06-20 16:38:30 -07004951 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4952 sizeof(tSirMacMgmtHdr),
4953 nPayload, &nPayload );
4954 if ( DOT11F_FAILED( nStatus ) )
4955 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004956 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004957 nStatus );
4958 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4959 return eSIR_FAILURE; // allocated!
4960 }
4961 else if ( DOT11F_WARNED( nStatus ) )
4962 {
4963 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004964 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004965 }
4966
Jeff Johnsone7245742012-09-05 17:12:55 -07004967 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004968 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4969 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004970 )
4971 {
4972 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4973 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304974
4975 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4976 psessionEntry->peSessionId,
4977 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004978 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4979 HAL_TXRX_FRM_802_11_MGMT,
4980 ANI_TXDIR_TODS,
4981 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004982 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304983 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4984 psessionEntry->peSessionId,
4985 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004986 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4987 {
4988 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004989 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004990 nSirStatus );
4991 //Pkt will be freed up by the callback
4992 return eSIR_FAILURE;
4993 }
4994
4995 return eSIR_SUCCESS;
4996
4997} // End limSendChannelSwitchMgmtFrame.
4998
Jeff Johnson295189b2012-06-20 16:38:30 -07004999
5000
Mohit Khanna4a70d262012-09-11 16:30:12 -07005001#ifdef WLAN_FEATURE_11AC
5002tSirRetStatus
5003limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
5004 tSirMacAddr peer,
5005 tANI_U8 nMode,
5006 tpPESession psessionEntry )
5007{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305008 tDot11fOperatingMode frm;
5009 tANI_U8 *pFrame;
5010 tSirRetStatus nSirStatus;
5011 tpSirMacMgmtHdr pMacHdr;
5012 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
5013 void *pPacket;
5014 eHalStatus halstatus;
5015 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07005016
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305017 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005018
5019 frm.Category.category = SIR_MAC_ACTION_VHT;
5020 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
5021 frm.OperatingMode.chanWidth = nMode;
5022 frm.OperatingMode.rxNSS = 0;
5023 frm.OperatingMode.rxNSSType = 0;
5024
5025 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
5026 if ( DOT11F_FAILED( nStatus ) )
5027 {
5028 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005029 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005030 nStatus );
5031 // We'll fall back on the worst case scenario:
5032 nPayload = sizeof( tDot11fOperatingMode);
5033 }
5034 else if ( DOT11F_WARNED( nStatus ) )
5035 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005036 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07005037 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005038 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005039 }
5040
5041 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5042
5043 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5044 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5045 {
5046 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005047 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005048 return eSIR_FAILURE;
5049 }
5050
5051 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305052 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005053
5054
5055 // Next, we fill out the buffer descriptor:
5056 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
5057 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5058 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5059 } else
5060 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5061 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
5062 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305063 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5064 (tANI_U8 *) psessionEntry->bssId,
5065 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005066 if ( eSIR_SUCCESS != nSirStatus )
5067 {
5068 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005069 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005070 nSirStatus );
5071 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5072 return eSIR_FAILURE; // just allocated...
5073 }
5074 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
5075 sizeof(tSirMacMgmtHdr),
5076 nPayload, &nPayload );
5077 if ( DOT11F_FAILED( nStatus ) )
5078 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005079 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005080 nStatus );
5081 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5082 return eSIR_FAILURE; // allocated!
5083 }
5084 else if ( DOT11F_WARNED( nStatus ) )
5085 {
5086 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005087 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005088 }
5089 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07005090 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5091 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07005092 )
5093 {
5094 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5095 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305096
5097 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5098 psessionEntry->peSessionId,
5099 pMacHdr->fc.subType));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005100 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5101 HAL_TXRX_FRM_802_11_MGMT,
5102 ANI_TXDIR_TODS,
5103 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5104 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305105 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5106 psessionEntry->peSessionId,
5107 halstatus));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005108 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5109 {
5110 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005111 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005112 nSirStatus );
5113 //Pkt will be freed up by the callback
5114 return eSIR_FAILURE;
5115 }
5116
5117 return eSIR_SUCCESS;
5118}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005119
5120/**
5121 * \brief Send a VHT Channel Switch Announcement
5122 *
5123 *
5124 * \param pMac Pointer to the global MAC datastructure
5125 *
5126 * \param peer MAC address to which this frame will be sent
5127 *
5128 * \param nChanWidth
5129 *
5130 * \param nNewChannel
5131 *
5132 *
5133 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5134 *
5135 *
5136 */
5137
5138tSirRetStatus
5139limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5140 tSirMacAddr peer,
5141 tANI_U8 nChanWidth,
5142 tANI_U8 nNewChannel,
5143 tANI_U8 ncbMode,
5144 tpPESession psessionEntry )
5145{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305146 tDot11fChannelSwitch frm;
5147 tANI_U8 *pFrame;
5148 tSirRetStatus nSirStatus;
5149 tpSirMacMgmtHdr pMacHdr;
5150 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5151 void *pPacket;
5152 eHalStatus halstatus;
5153 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005154
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305155 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005156
5157
5158 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5159 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5160 frm.ChanSwitchAnn.switchMode = 1;
5161 frm.ChanSwitchAnn.newChannel = nNewChannel;
5162 frm.ChanSwitchAnn.switchCount = 1;
5163 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
5164 frm.ExtChanSwitchAnn.present = 1;
5165 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
5166 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
5167 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
5168 frm.ChanSwitchAnn.present = 1;
5169 frm.WiderBWChanSwitchAnn.present = 1;
5170
5171 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5172 if ( DOT11F_FAILED( nStatus ) )
5173 {
5174 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005175 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005176 nStatus );
5177 // We'll fall back on the worst case scenario:
5178 nPayload = sizeof( tDot11fChannelSwitch );
5179 }
5180 else if ( DOT11F_WARNED( nStatus ) )
5181 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005182 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005183 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005184 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005185 }
5186
5187 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5188
5189 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5190 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5191 {
5192 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005193 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005194 return eSIR_FAILURE;
5195 }
5196 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305197 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005198
5199 // Next, we fill out the buffer descriptor:
5200 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5201 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5202 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305203 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5204 (tANI_U8 *) psessionEntry->bssId,
5205 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005206 if ( eSIR_SUCCESS != nSirStatus )
5207 {
5208 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005209 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005210 nSirStatus );
5211 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5212 return eSIR_FAILURE; // just allocated...
5213 }
5214 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5215 sizeof(tSirMacMgmtHdr),
5216 nPayload, &nPayload );
5217 if ( DOT11F_FAILED( nStatus ) )
5218 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005219 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005220 nStatus );
5221 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5222 return eSIR_FAILURE; // allocated!
5223 }
5224 else if ( DOT11F_WARNED( nStatus ) )
5225 {
5226 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005227 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005228 }
5229
5230 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005231 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5232 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005233 )
5234 {
5235 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5236 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305237
5238 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5239 psessionEntry->peSessionId,
5240 pMacHdr->fc.subType));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005241 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5242 HAL_TXRX_FRM_802_11_MGMT,
5243 ANI_TXDIR_TODS,
5244 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5245 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305246 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5247 psessionEntry->peSessionId,
5248 halstatus));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005249 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5250 {
5251 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005252 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005253 nSirStatus );
5254 //Pkt will be freed up by the callback
5255 return eSIR_FAILURE;
5256 }
5257
5258 return eSIR_SUCCESS;
5259
5260} // End limSendVHTChannelSwitchMgmtFrame.
5261
5262
5263
Mohit Khanna4a70d262012-09-11 16:30:12 -07005264#endif
5265
Jeff Johnson295189b2012-06-20 16:38:30 -07005266/**
5267 * \brief Send an ADDBA Req Action Frame to peer
5268 *
5269 * \sa limSendAddBAReq
5270 *
5271 * \param pMac The global tpAniSirGlobal object
5272 *
5273 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
5274 * the necessary parameters reqd by PE send the ADDBA Req Action
5275 * Frame to the peer
5276 *
5277 * \return eSIR_SUCCESS if setup completes successfully
5278 * eSIR_FAILURE is some problem is encountered
5279 */
5280tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305281 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07005282{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305283 tDot11fAddBAReq frmAddBAReq;
5284 tANI_U8 *pAddBAReqBuffer = NULL;
5285 tpSirMacMgmtHdr pMacHdr;
5286 tANI_U32 frameLen = 0, nStatus, nPayload;
5287 tSirRetStatus statusCode;
5288 eHalStatus halStatus;
5289 void *pPacket;
5290 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005291
5292 if(NULL == psessionEntry)
5293 {
5294 return eSIR_FAILURE;
5295 }
5296
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305297 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005298
5299 // Category - 3 (BA)
5300 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
5301
5302 // Action - 0 (ADDBA Req)
5303 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
5304
5305 // FIXME - Dialog Token, generalize this...
5306 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
5307
5308 // Fill the ADDBA Parameter Set
5309 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
5310 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
5311 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
5312
5313 // BA timeout
5314 // 0 - indicates no BA timeout
5315 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
5316
5317 // BA Starting Sequence Number
5318 // Fragment number will always be zero
5319 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
5320 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
5321 }
5322
5323 frmAddBAReq.BAStartingSequenceControl.ssn =
5324 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
5325
5326 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
5327
5328 if( DOT11F_FAILED( nStatus ))
5329 {
5330 limLog( pMac, LOGW,
5331 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005332 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005333 nStatus );
5334
5335 // We'll fall back on the worst case scenario:
5336 nPayload = sizeof( tDot11fAddBAReq );
5337 }
5338 else if( DOT11F_WARNED( nStatus ))
5339 {
5340 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005341 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005342 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005343 nStatus );
5344 }
5345
5346 // Add the MGMT header to frame length
5347 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5348
5349 // Need to allocate a buffer for ADDBA AF
5350 if( eHAL_STATUS_SUCCESS !=
5351 (halStatus = palPktAlloc( pMac->hHdd,
5352 HAL_TXRX_FRM_802_11_MGMT,
5353 (tANI_U16) frameLen,
5354 (void **) &pAddBAReqBuffer,
5355 (void **) &pPacket )))
5356 {
5357 // Log error
5358 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005359 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005360 frameLen,
5361 halStatus );
5362
5363 statusCode = eSIR_MEM_ALLOC_FAILED;
5364 goto returnAfterError;
5365 }
5366
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305367 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005368
5369 // Copy necessary info to BD
5370 if( eSIR_SUCCESS !=
5371 (statusCode = limPopulateMacHeader( pMac,
5372 pAddBAReqBuffer,
5373 SIR_MAC_MGMT_FRAME,
5374 SIR_MAC_MGMT_ACTION,
5375 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5376 goto returnAfterError;
5377
5378 // Update A3 with the BSSID
5379 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
5380
5381 #if 0
5382 cfgLen = SIR_MAC_ADDR_LENGTH;
5383 if( eSIR_SUCCESS != cfgGetStr( pMac,
5384 WNI_CFG_BSSID,
5385 (tANI_U8 *) pMacHdr->bssId,
5386 &cfgLen ))
5387 {
5388 limLog( pMac, LOGP,
5389 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005390 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005391
5392 // FIXME - Need to convert to tSirRetStatus
5393 statusCode = eSIR_FAILURE;
5394 goto returnAfterError;
5395 }
5396 #endif//TO SUPPORT BT-AMP
5397 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5398
Chet Lanctot186b5732013-03-18 10:26:30 -07005399#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005400 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005401#endif
5402
Jeff Johnson295189b2012-06-20 16:38:30 -07005403 // Now, we're ready to "pack" the frames
5404 nStatus = dot11fPackAddBAReq( pMac,
5405 &frmAddBAReq,
5406 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5407 nPayload,
5408 &nPayload );
5409
5410 if( DOT11F_FAILED( nStatus ))
5411 {
5412 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005413 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005414 nStatus );
5415
5416 // FIXME - Need to convert to tSirRetStatus
5417 statusCode = eSIR_FAILURE;
5418 goto returnAfterError;
5419 }
5420 else if( DOT11F_WARNED( nStatus ))
5421 {
5422 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005423 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5424 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005425 }
5426
5427 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005428 FL( "Sending an ADDBA REQ to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005429 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
5430
5431 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005432 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5433 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005434 )
5435 {
5436 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5437 }
5438
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305439 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5440 psessionEntry->peSessionId,
5441 pMacHdr->fc.subType));
5442 halStatus = halTxFrame( pMac,
5443 pPacket,
5444 (tANI_U16) frameLen,
5445 HAL_TXRX_FRM_802_11_MGMT,
5446 ANI_TXDIR_TODS,
5447 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5448 limTxComplete,
5449 pAddBAReqBuffer, txFlag );
5450 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5451 psessionEntry->peSessionId,
5452 halStatus));
5453 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005454 {
5455 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005456 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005457 halStatus );
5458
5459 // FIXME - Need to convert eHalStatus to tSirRetStatus
5460 statusCode = eSIR_FAILURE;
5461 //Pkt will be freed up by the callback
5462 return statusCode;
5463 }
5464 else
5465 return eSIR_SUCCESS;
5466
5467returnAfterError:
5468
5469 // Release buffer, if allocated
5470 if( NULL != pAddBAReqBuffer )
5471 palPktFree( pMac->hHdd,
5472 HAL_TXRX_FRM_802_11_MGMT,
5473 (void *) pAddBAReqBuffer,
5474 (void *) pPacket );
5475
5476 return statusCode;
5477}
5478
5479/**
5480 * \brief Send an ADDBA Rsp Action Frame to peer
5481 *
5482 * \sa limSendAddBARsp
5483 *
5484 * \param pMac The global tpAniSirGlobal object
5485 *
5486 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5487 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5488 * Frame to the peer
5489 *
5490 * \return eSIR_SUCCESS if setup completes successfully
5491 * eSIR_FAILURE is some problem is encountered
5492 */
5493tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5494 tpLimMlmAddBARsp pMlmAddBARsp,
5495 tpPESession psessionEntry)
5496{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305497 tDot11fAddBARsp frmAddBARsp;
5498 tANI_U8 *pAddBARspBuffer = NULL;
5499 tpSirMacMgmtHdr pMacHdr;
5500 tANI_U32 frameLen = 0, nStatus, nPayload;
5501 tSirRetStatus statusCode;
5502 eHalStatus halStatus;
5503 void *pPacket;
5504 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005505
5506 if(NULL == psessionEntry)
5507 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005508 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 return eSIR_FAILURE;
5510 }
5511
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305512 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005513
5514 // Category - 3 (BA)
5515 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5516 // Action - 1 (ADDBA Rsp)
5517 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5518
5519 // Should be same as the one we received in the ADDBA Req
5520 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5521
5522 // ADDBA Req status
5523 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5524
5525 // Fill the ADDBA Parameter Set as provided by caller
5526 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5527 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5528 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005529
5530 if(psessionEntry->isAmsduSupportInAMPDU)
5531 {
5532 frmAddBARsp.AddBAParameterSet.amsduSupported =
5533 psessionEntry->amsduSupportedInBA;
5534 }
5535 else
5536 {
5537 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5538 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005539
5540 // BA timeout
5541 // 0 - indicates no BA timeout
5542 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5543
5544 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5545
5546 if( DOT11F_FAILED( nStatus ))
5547 {
5548 limLog( pMac, LOGW,
5549 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005550 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005551 nStatus );
5552
5553 // We'll fall back on the worst case scenario:
5554 nPayload = sizeof( tDot11fAddBARsp );
5555 }
5556 else if( DOT11F_WARNED( nStatus ))
5557 {
5558 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005559 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005560 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005561 nStatus );
5562 }
5563
5564 // Need to allocate a buffer for ADDBA AF
5565 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5566
5567 // Allocate shared memory
5568 if( eHAL_STATUS_SUCCESS !=
5569 (halStatus = palPktAlloc( pMac->hHdd,
5570 HAL_TXRX_FRM_802_11_MGMT,
5571 (tANI_U16) frameLen,
5572 (void **) &pAddBARspBuffer,
5573 (void **) &pPacket )))
5574 {
5575 // Log error
5576 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005577 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005578 frameLen,
5579 halStatus );
5580
5581 statusCode = eSIR_MEM_ALLOC_FAILED;
5582 goto returnAfterError;
5583 }
5584
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305585 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005586
5587 // Copy necessary info to BD
5588 if( eSIR_SUCCESS !=
5589 (statusCode = limPopulateMacHeader( pMac,
5590 pAddBARspBuffer,
5591 SIR_MAC_MGMT_FRAME,
5592 SIR_MAC_MGMT_ACTION,
5593 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5594 goto returnAfterError;
5595
5596 // Update A3 with the BSSID
5597
5598 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5599
5600 #if 0
5601 cfgLen = SIR_MAC_ADDR_LENGTH;
5602 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5603 WNI_CFG_BSSID,
5604 (tANI_U8 *) pMacHdr->bssId,
5605 &cfgLen ))
5606 {
5607 limLog( pMac, LOGP,
5608 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005609 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005610
5611 // FIXME - Need to convert to tSirRetStatus
5612 statusCode = eSIR_FAILURE;
5613 goto returnAfterError;
5614 }
5615 #endif // TO SUPPORT BT-AMP
5616 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5617
Chet Lanctot186b5732013-03-18 10:26:30 -07005618#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005619 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005620#endif
5621
Jeff Johnson295189b2012-06-20 16:38:30 -07005622 // Now, we're ready to "pack" the frames
5623 nStatus = dot11fPackAddBARsp( pMac,
5624 &frmAddBARsp,
5625 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5626 nPayload,
5627 &nPayload );
5628
5629 if( DOT11F_FAILED( nStatus ))
5630 {
5631 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005632 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005633 nStatus );
5634
5635 // FIXME - Need to convert to tSirRetStatus
5636 statusCode = eSIR_FAILURE;
5637 goto returnAfterError;
5638 }
5639 else if( DOT11F_WARNED( nStatus ))
5640 {
5641 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005642 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5643 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005644 }
5645
5646 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005647 FL( "Sending an ADDBA RSP to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005648 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5649
5650 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005651 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5652 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005653 )
5654 {
5655 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5656 }
5657
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305658 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5659 psessionEntry->peSessionId,
5660 pMacHdr->fc.subType));
5661 halStatus = halTxFrame( pMac,
5662 pPacket,
5663 (tANI_U16) frameLen,
5664 HAL_TXRX_FRM_802_11_MGMT,
5665 ANI_TXDIR_TODS,
5666 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5667 limTxComplete,
5668 pAddBARspBuffer, txFlag );
5669 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5670 psessionEntry->peSessionId,
5671 halStatus));
5672 if( eHAL_STATUS_SUCCESS != halStatus )
5673 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005674 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005675 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005676 halStatus );
5677
5678 // FIXME - HAL error codes are different from PE error
5679 // codes!! And, this routine is returning tSirRetStatus
5680 statusCode = eSIR_FAILURE;
5681 //Pkt will be freed up by the callback
5682 return statusCode;
5683 }
5684 else
5685 return eSIR_SUCCESS;
5686
5687 returnAfterError:
Jeff Johnson295189b2012-06-20 16:38:30 -07005688 // Release buffer, if allocated
5689 if( NULL != pAddBARspBuffer )
5690 palPktFree( pMac->hHdd,
5691 HAL_TXRX_FRM_802_11_MGMT,
5692 (void *) pAddBARspBuffer,
5693 (void *) pPacket );
5694
5695 return statusCode;
5696}
5697
5698/**
5699 * \brief Send a DELBA Indication Action Frame to peer
5700 *
5701 * \sa limSendDelBAInd
5702 *
5703 * \param pMac The global tpAniSirGlobal object
5704 *
5705 * \param peerMacAddr MAC Address of peer
5706 *
5707 * \param reasonCode Reason for the DELBA notification
5708 *
5709 * \param pBAParameterSet The DELBA Parameter Set.
5710 * This identifies the TID for which the BA session is
5711 * being deleted.
5712 *
5713 * \return eSIR_SUCCESS if setup completes successfully
5714 * eSIR_FAILURE is some problem is encountered
5715 */
5716tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5717 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5718{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305719 tDot11fDelBAInd frmDelBAInd;
5720 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005721 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305722 tpSirMacMgmtHdr pMacHdr;
5723 tANI_U32 frameLen = 0, nStatus, nPayload;
5724 tSirRetStatus statusCode;
5725 eHalStatus halStatus;
5726 void *pPacket;
5727 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005728
5729 if(NULL == psessionEntry)
5730 {
5731 return eSIR_FAILURE;
5732 }
5733
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305734 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005735
5736 // Category - 3 (BA)
5737 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5738 // Action - 2 (DELBA)
5739 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5740
5741 // Fill the DELBA Parameter Set as provided by caller
5742 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5743 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5744
5745 // BA Starting Sequence Number
5746 // Fragment number will always be zero
5747 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5748
5749 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5750
5751 if( DOT11F_FAILED( nStatus ))
5752 {
5753 limLog( pMac, LOGW,
5754 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005755 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005756 nStatus );
5757
5758 // We'll fall back on the worst case scenario:
5759 nPayload = sizeof( tDot11fDelBAInd );
5760 }
5761 else if( DOT11F_WARNED( nStatus ))
5762 {
5763 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005764 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005765 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005766 nStatus );
5767 }
5768
5769 // Add the MGMT header to frame length
5770 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5771
5772 // Allocate shared memory
5773 if( eHAL_STATUS_SUCCESS !=
5774 (halStatus = palPktAlloc( pMac->hHdd,
5775 HAL_TXRX_FRM_802_11_MGMT,
5776 (tANI_U16) frameLen,
5777 (void **) &pDelBAIndBuffer,
5778 (void **) &pPacket )))
5779 {
5780 // Log error
5781 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005782 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005783 frameLen,
5784 halStatus );
5785
5786 statusCode = eSIR_MEM_ALLOC_FAILED;
5787 goto returnAfterError;
5788 }
5789
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305790 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005791
5792 // Copy necessary info to BD
5793 if( eSIR_SUCCESS !=
5794 (statusCode = limPopulateMacHeader( pMac,
5795 pDelBAIndBuffer,
5796 SIR_MAC_MGMT_FRAME,
5797 SIR_MAC_MGMT_ACTION,
5798 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5799 goto returnAfterError;
5800
5801 // Update A3 with the BSSID
5802 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5803
5804 #if 0
5805 cfgLen = SIR_MAC_ADDR_LENGTH;
5806 if( eSIR_SUCCESS != cfgGetStr( pMac,
5807 WNI_CFG_BSSID,
5808 (tANI_U8 *) pMacHdr->bssId,
5809 &cfgLen ))
5810 {
5811 limLog( pMac, LOGP,
5812 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005813 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005814
5815 // FIXME - Need to convert to tSirRetStatus
5816 statusCode = eSIR_FAILURE;
5817 goto returnAfterError;
5818 }
5819 #endif //TO SUPPORT BT-AMP
5820 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5821
Chet Lanctot186b5732013-03-18 10:26:30 -07005822#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005823 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005824#endif
5825
Jeff Johnson295189b2012-06-20 16:38:30 -07005826 // Now, we're ready to "pack" the frames
5827 nStatus = dot11fPackDelBAInd( pMac,
5828 &frmDelBAInd,
5829 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5830 nPayload,
5831 &nPayload );
5832
5833 if( DOT11F_FAILED( nStatus ))
5834 {
5835 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005836 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005837 nStatus );
5838
5839 // FIXME - Need to convert to tSirRetStatus
5840 statusCode = eSIR_FAILURE;
5841 goto returnAfterError;
5842 }
5843 else if( DOT11F_WARNED( nStatus ))
5844 {
5845 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005846 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
5847 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005848 }
5849
5850 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005851 FL( "Sending a DELBA IND to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005852 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5853
5854 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005855 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5856 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005857 )
5858 {
5859 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5860 }
5861
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305862 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5863 psessionEntry->peSessionId,
5864 pMacHdr->fc.subType));
5865 halStatus = halTxFrame( pMac,
5866 pPacket,
5867 (tANI_U16) frameLen,
5868 HAL_TXRX_FRM_802_11_MGMT,
5869 ANI_TXDIR_TODS,
5870 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5871 limTxComplete,
5872 pDelBAIndBuffer, txFlag );
5873 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5874 psessionEntry->peSessionId,
5875 halStatus));
5876 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005877 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005878 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005879 statusCode = eSIR_FAILURE;
5880 //Pkt will be freed up by the callback
5881 return statusCode;
5882 }
5883 else
5884 return eSIR_SUCCESS;
5885
5886 returnAfterError:
5887
5888 // Release buffer, if allocated
5889 if( NULL != pDelBAIndBuffer )
5890 palPktFree( pMac->hHdd,
5891 HAL_TXRX_FRM_802_11_MGMT,
5892 (void *) pDelBAIndBuffer,
5893 (void *) pPacket );
5894
5895 return statusCode;
5896}
5897
5898#if defined WLAN_FEATURE_VOWIFI
5899
5900/**
5901 * \brief Send a Neighbor Report Request Action frame
5902 *
5903 *
5904 * \param pMac Pointer to the global MAC structure
5905 *
5906 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5907 *
5908 * \param peer mac address of peer station.
5909 *
5910 * \param psessionEntry address of session entry.
5911 *
5912 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5913 *
5914 *
5915 */
5916
5917tSirRetStatus
5918limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5919 tpSirMacNeighborReportReq pNeighborReq,
5920 tSirMacAddr peer,
5921 tpPESession psessionEntry
5922 )
5923{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305924 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005925 tDot11fNeighborReportRequest frm;
5926 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305927 tpSirMacMgmtHdr pMacHdr;
5928 tANI_U32 nBytes, nPayload, nStatus;
5929 void *pPacket;
5930 eHalStatus halstatus;
5931 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005932
5933 if ( psessionEntry == NULL )
5934 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005935 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005936 return eSIR_FAILURE;
5937 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305938 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005939
5940 frm.Category.category = SIR_MAC_ACTION_RRM;
5941 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5942 frm.DialogToken.token = pNeighborReq->dialogToken;
5943
5944
5945 if( pNeighborReq->ssid_present )
5946 {
5947 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5948 }
5949
5950 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5951 if ( DOT11F_FAILED( nStatus ) )
5952 {
5953 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005954 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005955 nStatus );
5956 // We'll fall back on the worst case scenario:
5957 nPayload = sizeof( tDot11fNeighborReportRequest );
5958 }
5959 else if ( DOT11F_WARNED( nStatus ) )
5960 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005961 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005962 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005963 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005964 }
5965
5966 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5967
5968 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5969 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5970 {
5971 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005972 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005973 return eSIR_FAILURE;
5974 }
5975
5976 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305977 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005978
5979 // Copy necessary info to BD
5980 if( eSIR_SUCCESS !=
5981 (statusCode = limPopulateMacHeader( pMac,
5982 pFrame,
5983 SIR_MAC_MGMT_FRAME,
5984 SIR_MAC_MGMT_ACTION,
5985 peer, psessionEntry->selfMacAddr)))
5986 goto returnAfterError;
5987
5988 // Update A3 with the BSSID
5989 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5990
5991 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5992
Chet Lanctot186b5732013-03-18 10:26:30 -07005993#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005994 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005995#endif
5996
Jeff Johnson295189b2012-06-20 16:38:30 -07005997 // Now, we're ready to "pack" the frames
5998 nStatus = dot11fPackNeighborReportRequest( pMac,
5999 &frm,
6000 pFrame + sizeof( tSirMacMgmtHdr ),
6001 nPayload,
6002 &nPayload );
6003
6004 if( DOT11F_FAILED( nStatus ))
6005 {
6006 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006007 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006008 nStatus );
6009
6010 // FIXME - Need to convert to tSirRetStatus
6011 statusCode = eSIR_FAILURE;
6012 goto returnAfterError;
6013 }
6014 else if( DOT11F_WARNED( nStatus ))
6015 {
6016 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006017 FL( "There were warnings while packing Neighbor Report "
6018 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006019 }
6020
6021 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006022 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006023 limPrintMacAddr( pMac, peer, LOGW );
6024
6025 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006026 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6027 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006028 )
6029 {
6030 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6031 }
6032
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306033 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6034 psessionEntry->peSessionId,
6035 pMacHdr->fc.subType));
6036 halstatus = halTxFrame( pMac,
6037 pPacket,
6038 (tANI_U16) nBytes,
6039 HAL_TXRX_FRM_802_11_MGMT,
6040 ANI_TXDIR_TODS,
6041 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6042 limTxComplete,
6043 pFrame, txFlag );
6044 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6045 psessionEntry->peSessionId,
6046 halstatus));
6047 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006048 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006049 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006050 statusCode = eSIR_FAILURE;
6051 //Pkt will be freed up by the callback
6052 return statusCode;
6053 }
6054 else
6055 return eSIR_SUCCESS;
6056
6057returnAfterError:
6058 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6059
6060 return statusCode;
6061} // End limSendNeighborReportRequestFrame.
6062
6063/**
6064 * \brief Send a Link Report Action frame
6065 *
6066 *
6067 * \param pMac Pointer to the global MAC structure
6068 *
6069 * \param pLinkReport Address of a tSirMacLinkReport
6070 *
6071 * \param peer mac address of peer station.
6072 *
6073 * \param psessionEntry address of session entry.
6074 *
6075 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6076 *
6077 *
6078 */
6079
6080tSirRetStatus
6081limSendLinkReportActionFrame(tpAniSirGlobal pMac,
6082 tpSirMacLinkReport pLinkReport,
6083 tSirMacAddr peer,
6084 tpPESession psessionEntry
6085 )
6086{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306087 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006088 tDot11fLinkMeasurementReport frm;
6089 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306090 tpSirMacMgmtHdr pMacHdr;
6091 tANI_U32 nBytes, nPayload, nStatus;
6092 void *pPacket;
6093 eHalStatus halstatus;
6094 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006095
6096
6097 if ( psessionEntry == NULL )
6098 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006099 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006100 return eSIR_FAILURE;
6101 }
6102
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306103 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006104
6105 frm.Category.category = SIR_MAC_ACTION_RRM;
6106 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
6107 frm.DialogToken.token = pLinkReport->dialogToken;
6108
6109
6110 //IEEE Std. 802.11 7.3.2.18. for the report element.
6111 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
6112 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
6113 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
6114 //such case this way than changing the frame parser.
6115 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
6116 frm.TPCEleLen.TPCLen = 2;
6117 frm.TxPower.txPower = pLinkReport->txPower;
6118 frm.LinkMargin.linkMargin = 0;
6119
6120 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
6121 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
6122 frm.RCPI.rcpi = pLinkReport->rcpi;
6123 frm.RSNI.rsni = pLinkReport->rsni;
6124
6125 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
6126 if ( DOT11F_FAILED( nStatus ) )
6127 {
6128 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006129 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006130 nStatus );
6131 // We'll fall back on the worst case scenario:
6132 nPayload = sizeof( tDot11fLinkMeasurementReport );
6133 }
6134 else if ( DOT11F_WARNED( nStatus ) )
6135 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006136 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006137 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006138 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006139 }
6140
6141 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6142
6143 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6144 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6145 {
6146 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006147 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006148 return eSIR_FAILURE;
6149 }
6150
6151 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306152 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006153
6154 // Copy necessary info to BD
6155 if( eSIR_SUCCESS !=
6156 (statusCode = limPopulateMacHeader( pMac,
6157 pFrame,
6158 SIR_MAC_MGMT_FRAME,
6159 SIR_MAC_MGMT_ACTION,
6160 peer, psessionEntry->selfMacAddr)))
6161 goto returnAfterError;
6162
6163 // Update A3 with the BSSID
6164 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6165
6166 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6167
Chet Lanctot186b5732013-03-18 10:26:30 -07006168#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006169 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006170#endif
6171
Jeff Johnson295189b2012-06-20 16:38:30 -07006172 // Now, we're ready to "pack" the frames
6173 nStatus = dot11fPackLinkMeasurementReport( pMac,
6174 &frm,
6175 pFrame + sizeof( tSirMacMgmtHdr ),
6176 nPayload,
6177 &nPayload );
6178
6179 if( DOT11F_FAILED( nStatus ))
6180 {
6181 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006182 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006183 nStatus );
6184
6185 // FIXME - Need to convert to tSirRetStatus
6186 statusCode = eSIR_FAILURE;
6187 goto returnAfterError;
6188 }
6189 else if( DOT11F_WARNED( nStatus ))
6190 {
6191 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006192 FL( "There were warnings while packing Link Report (0x%08x)." ),
6193 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006194 }
6195
6196 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006197 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006198 limPrintMacAddr( pMac, peer, LOGW );
6199
6200 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006201 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6202 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006203 )
6204 {
6205 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6206 }
6207
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306208 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6209 psessionEntry->peSessionId,
6210 pMacHdr->fc.subType));
6211 halstatus = halTxFrame( pMac,
6212 pPacket,
6213 (tANI_U16) nBytes,
6214 HAL_TXRX_FRM_802_11_MGMT,
6215 ANI_TXDIR_TODS,
6216 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6217 limTxComplete,
6218 pFrame, txFlag );
6219 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6220 psessionEntry->peSessionId,
6221 halstatus));
6222 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006223 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006224 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006225 statusCode = eSIR_FAILURE;
6226 //Pkt will be freed up by the callback
6227 return statusCode;
6228 }
6229 else
6230 return eSIR_SUCCESS;
6231
6232returnAfterError:
6233 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6234
6235 return statusCode;
6236} // End limSendLinkReportActionFrame.
6237
6238/**
6239 * \brief Send a Beacon Report Action frame
6240 *
6241 *
6242 * \param pMac Pointer to the global MAC structure
6243 *
6244 * \param dialog_token dialog token to be used in the action frame.
6245 *
6246 * \param num_report number of reports in pRRMReport.
6247 *
6248 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
6249 *
6250 * \param peer mac address of peer station.
6251 *
6252 * \param psessionEntry address of session entry.
6253 *
6254 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6255 *
6256 *
6257 */
6258
6259tSirRetStatus
6260limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
6261 tANI_U8 dialog_token,
6262 tANI_U8 num_report,
6263 tpSirMacRadioMeasureReport pRRMReport,
6264 tSirMacAddr peer,
6265 tpPESession psessionEntry
6266 )
6267{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306268 tSirRetStatus statusCode = eSIR_SUCCESS;
6269 tANI_U8 *pFrame;
6270 tpSirMacMgmtHdr pMacHdr;
6271 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006272 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306273 eHalStatus halstatus;
6274 tANI_U8 i;
6275 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006276
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006277 tDot11fRadioMeasurementReport *frm =
6278 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
6279 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006280 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006281 return eSIR_FAILURE;
6282 }
6283
Jeff Johnson295189b2012-06-20 16:38:30 -07006284 if ( psessionEntry == NULL )
6285 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006286 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006287 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006288 return eSIR_FAILURE;
6289 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306290 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006291
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006292 frm->Category.category = SIR_MAC_ACTION_RRM;
6293 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
6294 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07006295
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006296 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 -07006297
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006298 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006299 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006300 frm->MeasurementReport[i].type = pRRMReport[i].type;
6301 frm->MeasurementReport[i].token = pRRMReport[i].token;
6302 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006303 switch( pRRMReport[i].type )
6304 {
6305 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006306 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
6307 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6308 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
6309 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006310 break;
6311 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05306312 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6313 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006314 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006315 break;
6316 }
6317 }
6318
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006319 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07006320 if ( DOT11F_FAILED( nStatus ) )
6321 {
6322 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006323 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006324 nStatus );
6325 // We'll fall back on the worst case scenario:
6326 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006327 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006328 return eSIR_FAILURE;
6329 }
6330 else if ( DOT11F_WARNED( nStatus ) )
6331 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006332 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006333 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006334 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006335 }
6336
6337 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6338
6339 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6340 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6341 {
6342 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006343 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006344 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006345 return eSIR_FAILURE;
6346 }
6347
6348 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306349 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006350
6351 // Copy necessary info to BD
6352 if( eSIR_SUCCESS !=
6353 (statusCode = limPopulateMacHeader( pMac,
6354 pFrame,
6355 SIR_MAC_MGMT_FRAME,
6356 SIR_MAC_MGMT_ACTION,
6357 peer, psessionEntry->selfMacAddr)))
6358 goto returnAfterError;
6359
6360 // Update A3 with the BSSID
6361 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6362
6363 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6364
Chet Lanctot186b5732013-03-18 10:26:30 -07006365#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006366 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006367#endif
6368
Jeff Johnson295189b2012-06-20 16:38:30 -07006369 // Now, we're ready to "pack" the frames
6370 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006371 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07006372 pFrame + sizeof( tSirMacMgmtHdr ),
6373 nPayload,
6374 &nPayload );
6375
6376 if( DOT11F_FAILED( nStatus ))
6377 {
6378 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006379 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006380 nStatus );
6381
6382 // FIXME - Need to convert to tSirRetStatus
6383 statusCode = eSIR_FAILURE;
6384 goto returnAfterError;
6385 }
6386 else if( DOT11F_WARNED( nStatus ))
6387 {
6388 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006389 FL( "There were warnings while packing Radio "
6390 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006391 }
6392
6393 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006394 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006395 limPrintMacAddr( pMac, peer, LOGW );
6396
6397 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006398 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6399 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006400 )
6401 {
6402 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6403 }
6404
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306405 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6406 psessionEntry->peSessionId,
6407 pMacHdr->fc.subType));
6408 halstatus = halTxFrame( pMac,
6409 pPacket,
6410 (tANI_U16) nBytes,
6411 HAL_TXRX_FRM_802_11_MGMT,
6412 ANI_TXDIR_TODS,
6413 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6414 limTxComplete,
6415 pFrame, txFlag );
6416 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6417 psessionEntry->peSessionId,
6418 halstatus));
6419 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006420 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006421 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006422 statusCode = eSIR_FAILURE;
6423 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006424 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006425 return statusCode;
6426 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006427 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006428 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006429 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006430 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006431
6432returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006433 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006434 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07006435 return statusCode;
6436} // End limSendBeaconReportActionFrame.
6437
6438#endif
6439
6440#ifdef WLAN_FEATURE_11W
6441/**
Chet Lanctot8cecea22014-02-11 19:09:36 -08006442 * \brief Send SA query request action frame to peer
6443 *
6444 * \sa limSendSaQueryRequestFrame
6445 *
6446 *
6447 * \param pMac The global tpAniSirGlobal object
6448 *
6449 * \param transId Transaction identifier
6450 *
6451 * \param peer The Mac address of the station to which this action frame is addressed
6452 *
6453 * \param psessionEntry The PE session entry
6454 *
6455 * \return eSIR_SUCCESS if setup completes successfully
6456 * eSIR_FAILURE is some problem is encountered
6457 */
6458
6459tSirRetStatus limSendSaQueryRequestFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
6460 tSirMacAddr peer, tpPESession psessionEntry )
6461{
6462
6463 tDot11fSaQueryReq frm; // SA query request action frame
6464 tANI_U8 *pFrame;
6465 tSirRetStatus nSirStatus;
6466 tpSirMacMgmtHdr pMacHdr;
6467 tANI_U32 nBytes, nPayload, nStatus;
6468 void *pPacket;
6469 eHalStatus halstatus;
6470 tANI_U8 txFlag = 0;
6471
6472 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
6473 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6474 /* 11w action field is :
6475 action: 0 --> SA Query Request action frame
6476 action: 1 --> SA Query Response action frame */
6477 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
6478 /* 11w SA Query Request transId */
6479 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
6480
6481 nStatus = dot11fGetPackedSaQueryReqSize(pMac, &frm, &nPayload);
6482 if ( DOT11F_FAILED( nStatus ) )
6483 {
6484 limLog( pMac, LOGP, FL("Failed to calculate the packed size "
6485 "for an SA Query Request (0x%08x)."),
6486 nStatus );
6487 // We'll fall back on the worst case scenario:
6488 nPayload = sizeof( tDot11fSaQueryReq );
6489 }
6490 else if ( DOT11F_WARNED( nStatus ) )
6491 {
6492 limLog( pMac, LOGW, FL("There were warnings while calculating "
6493 "the packed size for an SA Query Request"
6494 " (0x%08x)."), nStatus );
6495 }
6496
6497 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6498 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6499 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6500 {
6501 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA Query Request "
6502 "action frame"), nBytes );
6503 return eSIR_FAILURE;
6504 }
6505
6506 // Paranoia:
6507 vos_mem_set( pFrame, nBytes, 0 );
6508
6509 // Copy necessary info to BD
6510 nSirStatus = limPopulateMacHeader( pMac,
6511 pFrame,
6512 SIR_MAC_MGMT_FRAME,
6513 SIR_MAC_MGMT_ACTION,
6514 peer, psessionEntry->selfMacAddr );
6515 if ( eSIR_SUCCESS != nSirStatus )
6516 goto returnAfterError;
6517
6518 // Update A3 with the BSSID
6519 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6520
6521 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6522
6523 // Since this is a SA Query Request, set the "protect" (aka WEP) bit
6524 // in the FC
6525 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
6526
6527 // Pack 11w SA Query Request frame
6528 nStatus = dot11fPackSaQueryReq( pMac,
6529 &frm,
6530 pFrame + sizeof( tSirMacMgmtHdr ),
6531 nPayload,
6532 &nPayload );
6533
6534 if ( DOT11F_FAILED( nStatus ))
6535 {
6536 limLog( pMac, LOGE,
6537 FL( "Failed to pack an SA Query Request (0x%08x)." ),
6538 nStatus );
6539 // FIXME - Need to convert to tSirRetStatus
6540 nSirStatus = eSIR_FAILURE;
6541 goto returnAfterError;
6542 }
6543 else if ( DOT11F_WARNED( nStatus ))
6544 {
6545 limLog( pMac, LOGW,
6546 FL( "There were warnings while packing SA Query Request (0x%08x)." ),
6547 nStatus);
6548 }
6549
6550 limLog( pMac, LOG1,
6551 FL( "Sending an SA Query Request to " ));
6552 limPrintMacAddr( pMac, peer, LOG1 );
6553 limPrintMacAddr( pMac, peer, LOGE );
6554 limLog( pMac, LOGE,
6555 FL( "Sending an SA Query Request from " ));
6556 limPrintMacAddr( pMac, psessionEntry->selfMacAddr, LOGE );
6557
6558 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
6559#ifdef WLAN_FEATURE_P2P
6560 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6561 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
6562#endif
6563 )
6564 {
6565 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6566 }
6567
6568 halstatus = halTxFrame( pMac,
6569 pPacket,
6570 (tANI_U16) nBytes,
6571 HAL_TXRX_FRM_802_11_MGMT,
6572 ANI_TXDIR_TODS,
6573 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6574 limTxComplete,
6575 pFrame, txFlag );
6576 if ( eHAL_STATUS_SUCCESS != halstatus )
6577 {
6578 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6579 nSirStatus = eSIR_FAILURE;
6580 //Pkt will be freed up by the callback
6581 return nSirStatus;
6582 }
6583 else {
6584 return eSIR_SUCCESS;
6585 }
6586
6587returnAfterError:
6588 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6589 return nSirStatus;
6590} // End limSendSaQueryRequestFrame
6591
6592/**
Jeff Johnson295189b2012-06-20 16:38:30 -07006593 * \brief Send SA query response action frame to peer
6594 *
6595 * \sa limSendSaQueryResponseFrame
6596 *
6597 *
6598 * \param pMac The global tpAniSirGlobal object
6599 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006600 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006601 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006602 * \param peer The Mac address of the AP to which this action frame is addressed
6603 *
6604 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07006605 *
6606 * \return eSIR_SUCCESS if setup completes successfully
6607 * eSIR_FAILURE is some problem is encountered
6608 */
6609
Chet Lanctot186b5732013-03-18 10:26:30 -07006610tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006611tSirMacAddr peer,tpPESession psessionEntry)
6612{
6613
Chet Lanctot186b5732013-03-18 10:26:30 -07006614 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006615 tANI_U8 *pFrame;
6616 tSirRetStatus nSirStatus;
6617 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07006618 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006619 void *pPacket;
6620 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306621 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006622
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306623 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07006624 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6625 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07006626 action: 0 --> SA query request action frame
6627 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07006628 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
6629 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07006630 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07006631 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006632
Chet Lanctot186b5732013-03-18 10:26:30 -07006633 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6634 if ( DOT11F_FAILED( nStatus ) )
6635 {
6636 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6637 "or a SA Query Response (0x%08x)."),
6638 nStatus );
6639 // We'll fall back on the worst case scenario:
6640 nPayload = sizeof( tDot11fSaQueryRsp );
6641 }
6642 else if ( DOT11F_WARNED( nStatus ) )
6643 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006644 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006645 "the packed size for an SA Query Response"
6646 " (0x%08x)."), nStatus );
6647 }
6648
Jeff Johnson295189b2012-06-20 16:38:30 -07006649 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6650 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6651 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6652 {
6653 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006654 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006655 return eSIR_FAILURE;
6656 }
6657
6658 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306659 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006660
Chet Lanctot186b5732013-03-18 10:26:30 -07006661 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006662 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006663 pFrame,
6664 SIR_MAC_MGMT_FRAME,
6665 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006666 peer, psessionEntry->selfMacAddr );
6667 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006668 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006669
Chet Lanctot186b5732013-03-18 10:26:30 -07006670 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006671 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6672
Chet Lanctot186b5732013-03-18 10:26:30 -07006673 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006674
Chet Lanctot186b5732013-03-18 10:26:30 -07006675 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6676 // in the FC
Chet Lanctot8cecea22014-02-11 19:09:36 -08006677 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -07006678
Chet Lanctot186b5732013-03-18 10:26:30 -07006679 // Pack 11w SA query response frame
6680 nStatus = dot11fPackSaQueryRsp( pMac,
6681 &frm,
6682 pFrame + sizeof( tSirMacMgmtHdr ),
6683 nPayload,
6684 &nPayload );
6685
6686 if ( DOT11F_FAILED( nStatus ))
6687 {
6688 limLog( pMac, LOGE,
6689 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6690 nStatus );
6691 // FIXME - Need to convert to tSirRetStatus
6692 nSirStatus = eSIR_FAILURE;
6693 goto returnAfterError;
6694 }
6695 else if ( DOT11F_WARNED( nStatus ))
6696 {
6697 limLog( pMac, LOGW,
6698 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6699 nStatus);
6700 }
6701
6702 limLog( pMac, LOG1,
6703 FL( "Sending a SA Query Response to " ));
6704 limPrintMacAddr( pMac, peer, LOGW );
6705
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006706 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006707#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006708 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6709 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006710#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006711 )
6712 {
6713 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6714 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006715
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306716 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6717 psessionEntry->peSessionId,
6718 pMacHdr->fc.subType));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006719 halstatus = halTxFrame( pMac,
6720 pPacket,
6721 (tANI_U16) nBytes,
6722 HAL_TXRX_FRM_802_11_MGMT,
6723 ANI_TXDIR_TODS,
6724 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6725 limTxComplete,
6726 pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306727 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6728 psessionEntry->peSessionId,
6729 halstatus));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006730 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006731 {
6732 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6733 nSirStatus = eSIR_FAILURE;
6734 //Pkt will be freed up by the callback
6735 return nSirStatus;
6736 }
6737 else {
6738 return eSIR_SUCCESS;
6739 }
6740
6741returnAfterError:
6742 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6743 return nSirStatus;
6744} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006745#endif