blob: d7993e502ebc840846d74319b4ef47d7998c01e2 [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
Chet Lanctot8cecea22014-02-11 19:09:36 -08001510#ifdef WLAN_FEATURE_11W
Dino Myclea7f18452014-04-24 08:55:31 +05301511 if( eSIR_MAC_TRY_AGAIN_LATER == statusCode )
1512 {
1513 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_MAX_RETRIES,
1514 &maxRetries ) != eSIR_SUCCESS )
1515 limLog( pMac, LOGE, FL("Could not retrieve PMF SA "
1516 "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 "
1521 "Query timer interval value") );
1522 else
1523 PopulateDot11fTimeoutInterval(
1524 pMac, &frm.TimeoutInterval,
1525 SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1526 (maxRetries - pSta->pmfSaQueryRetryCount) * retryInterval );
1527 }
Chet Lanctot8cecea22014-02-11 19:09:36 -08001528#endif
Dino Myclea7f18452014-04-24 08:55:31 +05301529 } // End if on non-NULL 'pSta'.
Jeff Johnson295189b2012-06-20 16:38:30 -07001530
Chet Lanctot8cecea22014-02-11 19:09:36 -08001531 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001532
Jeff Johnson295189b2012-06-20 16:38:30 -07001533 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1534 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1535 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1536 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001537
1538 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1539 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1540
1541 beaconParams.bssIdx = psessionEntry->bssIdx;
1542
1543 //Send message to HAL about beacon parameter change.
1544 if(beaconParams.paramChangeBitmap)
1545 {
1546 schSetFixedBeaconFields(pMac,psessionEntry);
1547 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1548 }
1549
1550 // Allocate a buffer for this frame:
1551 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1552 if ( DOT11F_FAILED( nStatus ) )
1553 {
1554 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001555 "or an Association Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001556 nStatus );
1557 return;
1558 }
1559 else if ( DOT11F_WARNED( nStatus ) )
1560 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001561 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07001562 "the packed size for an Association Re"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001563 "sponse (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001564 }
1565
1566 nBytes = sizeof( tSirMacMgmtHdr ) + nPayload;
1567
1568 if ( pAssocReq != NULL )
1569 {
1570 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1571 &addnIEPresent) != eSIR_SUCCESS)
1572 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301573 limLog(pMac, LOGP, FL("Unable to get "
1574 "WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001575 return;
1576 }
1577
1578 if (addnIEPresent)
1579 {
1580 //Assoc rsp IE available
1581 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1582 &addnIELen) != eSIR_SUCCESS)
1583 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301584 limLog(pMac, LOGP, FL("Unable to get "
1585 "WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001586 return;
1587 }
1588
1589 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1590 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1591 {
1592 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1593 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1594 {
Kalikinkar dhara205da782014-03-21 15:49:32 -07001595
1596 vos_mem_set(( tANI_U8* )&extractedExtCap,
1597 sizeof( tDot11fIEExtCap ), 0);
1598 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
1599 &addIE[0],
1600 &addStripoffIELen,
1601 &extractedExtCap );
1602 if(eSIR_SUCCESS != nSirStatus)
1603 {
1604 limLog(pMac, LOG1,
1605 FL("Unable to Stripoff ExtCap IE from Assoc Rsp"));
1606 }
1607 else
1608 {
1609 addnIELen = addStripoffIELen;
1610 extractedExtCapFlag = eANI_BOOLEAN_TRUE;
1611 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001612 nBytes = nBytes + addnIELen;
1613 }
1614 }
1615 }
1616 }
1617
1618 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1619 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1620 ( void** ) &pPacket );
1621 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1622 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001623 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001624 return;
1625 }
1626
1627 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301628 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001629
1630 // Next, we fill out the buffer descriptor:
1631 nSirStatus = limPopulateMacHeader( pMac,
1632 pFrame,
1633 SIR_MAC_MGMT_FRAME,
1634 ( LIM_ASSOC == subType ) ?
1635 SIR_MAC_MGMT_ASSOC_RSP :
1636 SIR_MAC_MGMT_REASSOC_RSP,
1637 peerMacAddr,psessionEntry->selfMacAddr);
1638 if ( eSIR_SUCCESS != nSirStatus )
1639 {
1640 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001641 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001642 nSirStatus );
1643 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1644 ( void* ) pFrame, ( void* ) pPacket );
1645 return;
1646 }
1647
1648 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1649
Jeff Johnson295189b2012-06-20 16:38:30 -07001650 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1651
Kalikinkar dhara205da782014-03-21 15:49:32 -07001652 /* merge the ExtCap struct*/
1653 if (extractedExtCapFlag)
1654 {
1655 limMergeExtCapIEStruct(&(frm.ExtCap), &extractedExtCap);
1656 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001657 nStatus = dot11fPackAssocResponse( pMac, &frm,
1658 pFrame + sizeof( tSirMacMgmtHdr ),
1659 nPayload, &nPayload );
1660 if ( DOT11F_FAILED( nStatus ) )
1661 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301662 limLog( pMac, LOGE, FL("Failed to pack an Association Response"
1663 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001664 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1665 ( void* ) pFrame, ( void* ) pPacket );
1666 return; // allocated!
1667 }
1668 else if ( DOT11F_WARNED( nStatus ) )
1669 {
1670 limLog( pMac, LOGW, FL("There were warnings while packing an "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001671 "Association Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001672 }
1673
1674 macAddr = pMacHdr->da;
1675
1676 if (subType == LIM_ASSOC)
1677 {
1678 PELOG1(limLog(pMac, LOG1,
1679 FL("*** Sending Assoc Resp status %d aid %d to "),
1680 statusCode, aid);)
1681 }
1682 else{
1683 PELOG1(limLog(pMac, LOG1,
1684 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1685 statusCode, aid);)
1686 }
1687 PELOG1(limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1688
1689 if ( addnIEPresent )
1690 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301691 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 }
1693
1694 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001695 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1696 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001697 )
1698 {
1699 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1700 }
1701
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05301702 limLog( pMac, LOG1, FL("Sending Assoc resp over WQ5 to "MAC_ADDRESS_STR
1703 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
1704 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
1705
1706 txFlag |= HAL_USE_FW_IN_TX_PATH;
1707
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301708 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1709 psessionEntry->peSessionId,
1710 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 /// Queue Association Response frame in high priority WQ
1712 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1713 HAL_TXRX_FRM_802_11_MGMT,
1714 ANI_TXDIR_TODS,
1715 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1716 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301717 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1718 psessionEntry->peSessionId,
1719 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001720 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1721 {
1722 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001723 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001724 nSirStatus);
1725
1726 //Pkt will be freed up by the callback
1727 }
1728
1729 // update the ANI peer station count
1730 //FIXME_PROTECTION : take care of different type of station
1731 // counter inside this function.
1732 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1733
1734} // End limSendAssocRspMgmtFrame.
1735
1736
1737
1738void
1739limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1740 tSirMacAddr peer,
1741 tANI_U16 nStatusCode,
1742 tSirAddtsReqInfo *pAddTS,
1743 tSirMacScheduleIE *pSchedule,
1744 tpPESession psessionEntry)
1745{
1746 tANI_U8 *pFrame;
1747 tpSirMacMgmtHdr pMacHdr;
1748 tDot11fAddTSResponse AddTSRsp;
1749 tDot11fWMMAddTSResponse WMMAddTSRsp;
1750 tSirRetStatus nSirStatus;
1751 tANI_U32 i, nBytes, nPayload, nStatus;
1752 void *pPacket;
1753 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301754 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001755
1756 if(NULL == psessionEntry)
1757 {
1758 return;
1759 }
1760
1761 if ( ! pAddTS->wmeTspecPresent )
1762 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301763 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001764
1765 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1766 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1767 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1768 AddTSRsp.Status.status = nStatusCode;
1769
1770 // The TsDelay information element is only filled in for a specific
1771 // status code:
1772 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1773 {
1774 if ( pAddTS->wsmTspecPresent )
1775 {
1776 AddTSRsp.WMMTSDelay.version = 1;
1777 AddTSRsp.WMMTSDelay.delay = 10;
1778 AddTSRsp.WMMTSDelay.present = 1;
1779 }
1780 else
1781 {
1782 AddTSRsp.TSDelay.delay = 10;
1783 AddTSRsp.TSDelay.present = 1;
1784 }
1785 }
1786
1787 if ( pAddTS->wsmTspecPresent )
1788 {
1789 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1790 }
1791 else
1792 {
1793 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1794 }
1795
1796 if ( pAddTS->wsmTspecPresent )
1797 {
1798 AddTSRsp.num_WMMTCLAS = 0;
1799 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1800 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1801 {
1802 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1803 &AddTSRsp.TCLAS[i] );
1804 }
1805 }
1806 else
1807 {
1808 AddTSRsp.num_TCLAS = 0;
1809 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1810 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1811 {
1812 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1813 &AddTSRsp.WMMTCLAS[i] );
1814 }
1815 }
1816
1817 if ( pAddTS->tclasProcPresent )
1818 {
1819 if ( pAddTS->wsmTspecPresent )
1820 {
1821 AddTSRsp.WMMTCLASPROC.version = 1;
1822 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1823 AddTSRsp.WMMTCLASPROC.present = 1;
1824 }
1825 else
1826 {
1827 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1828 AddTSRsp.TCLASSPROC.present = 1;
1829 }
1830 }
1831
1832 // schedule element is included only if requested in the tspec and we are
1833 // using hcca (or both edca and hcca)
1834 // 11e-D8.0 is inconsistent on whether the schedule element is included
1835 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1836 // pg 46, line 17-18 says something else. So just include it and let the
1837 // sta figure it out
1838 if ((pSchedule != NULL) &&
1839 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1840 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1841 {
1842 if ( pAddTS->wsmTspecPresent )
1843 {
1844 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1845 }
1846 else
1847 {
1848 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1849 }
1850 }
1851
1852 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1853 if ( DOT11F_FAILED( nStatus ) )
1854 {
1855 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001856 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001857 nStatus );
1858 // We'll fall back on the worst case scenario:
1859 nPayload = sizeof( tDot11fAddTSResponse );
1860 }
1861 else if ( DOT11F_WARNED( nStatus ) )
1862 {
1863 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001864 "ting the packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001865 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001866 }
1867 }
1868 else
1869 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301870 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001871
1872 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1873 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1874 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1875 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1876
1877 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1878
1879 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1880 if ( DOT11F_FAILED( nStatus ) )
1881 {
1882 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001883 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001884 nStatus );
1885 // We'll fall back on the worst case scenario:
1886 nPayload = sizeof( tDot11fWMMAddTSResponse );
1887 }
1888 else if ( DOT11F_WARNED( nStatus ) )
1889 {
1890 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001891 "ting the packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001892 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001893 }
1894 }
1895
1896 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1897
1898 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1899 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1900 {
1901 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001902 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001903 return;
1904 }
1905
1906 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301907 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001908
1909 // Next, we fill out the buffer descriptor:
1910 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1911 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1912 if ( eSIR_SUCCESS != nSirStatus )
1913 {
1914 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001915 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001916 nSirStatus );
1917 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1918 return; // allocated!
1919 }
1920
1921 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1922
1923
1924 #if 0
1925 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1926 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1927 {
1928 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001929 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001930 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1931 return; // allocated!
1932 }
1933 #endif //TO SUPPORT BT-AMP
1934 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1935
Chet Lanctot186b5732013-03-18 10:26:30 -07001936#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001937 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001938#endif
1939
Jeff Johnson295189b2012-06-20 16:38:30 -07001940 // That done, pack the struct:
1941 if ( ! pAddTS->wmeTspecPresent )
1942 {
1943 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1944 pFrame + sizeof( tSirMacMgmtHdr ),
1945 nPayload, &nPayload );
1946 if ( DOT11F_FAILED( nStatus ) )
1947 {
1948 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001949 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001950 nStatus );
1951 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1952 return;
1953 }
1954 else if ( DOT11F_WARNED( nStatus ) )
1955 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001956 limLog( pMac, LOGW, FL("There were warnings while packing "
1957 "an Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001958 }
1959 }
1960 else
1961 {
1962 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
1963 pFrame + sizeof( tSirMacMgmtHdr ),
1964 nPayload, &nPayload );
1965 if ( DOT11F_FAILED( nStatus ) )
1966 {
1967 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001968 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001969 nStatus );
1970 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1971 return;
1972 }
1973 else if ( DOT11F_WARNED( nStatus ) )
1974 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001975 limLog( pMac, LOGW, FL("There were warnings while packing "
1976 "a WMM Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001977 }
1978 }
1979
1980 PELOG1(limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
1981 nStatusCode );
1982 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
1983
1984 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001985 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1986 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001987 )
1988 {
1989 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1990 }
1991
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301992 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1993 psessionEntry->peSessionId,
1994 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001995 // Queue the frame in high priority WQ:
1996 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1997 HAL_TXRX_FRM_802_11_MGMT,
1998 ANI_TXDIR_TODS,
1999 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2000 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302001 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2002 psessionEntry->peSessionId,
2003 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002004 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2005 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002006 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002007 nSirStatus );
2008 //Pkt will be freed up by the callback
2009 }
2010
2011} // End limSendAddtsRspActionFrame.
2012
2013void
2014limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
2015 tSirMacAddr peer,
2016 tANI_U8 wmmTspecPresent,
2017 tSirMacTSInfo *pTsinfo,
2018 tSirMacTspecIE *pTspecIe,
2019 tpPESession psessionEntry)
2020{
2021 tANI_U8 *pFrame;
2022 tpSirMacMgmtHdr pMacHdr;
2023 tDot11fDelTS DelTS;
2024 tDot11fWMMDelTS WMMDelTS;
2025 tSirRetStatus nSirStatus;
2026 tANI_U32 nBytes, nPayload, nStatus;
2027 void *pPacket;
2028 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302029 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002030
2031 if(NULL == psessionEntry)
2032 {
2033 return;
2034 }
2035
2036 if ( ! wmmTspecPresent )
2037 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302038 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002039
2040 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
2041 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2042 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
2043
2044 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
2045 if ( DOT11F_FAILED( nStatus ) )
2046 {
2047 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002048 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002049 nStatus );
2050 // We'll fall back on the worst case scenario:
2051 nPayload = sizeof( tDot11fDelTS );
2052 }
2053 else if ( DOT11F_WARNED( nStatus ) )
2054 {
2055 limLog( pMac, LOGW, FL("There were warnings while calcula"
2056 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002057 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 }
2059 }
2060 else
2061 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302062 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002063
2064 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
2065 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2066 WMMDelTS.DialogToken.token = 0;
2067 WMMDelTS.StatusCode.statusCode = 0;
2068 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
2069 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
2070 if ( DOT11F_FAILED( nStatus ) )
2071 {
2072 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002073 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002074 nStatus );
2075 // We'll fall back on the worst case scenario:
2076 nPayload = sizeof( tDot11fDelTS );
2077 }
2078 else if ( DOT11F_WARNED( nStatus ) )
2079 {
2080 limLog( pMac, LOGW, FL("There were warnings while calcula"
2081 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002082 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002083 }
2084 }
2085
2086 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
2087
2088 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
2089 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2090 {
2091 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002092 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002093 return;
2094 }
2095
2096 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302097 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002098
2099 // Next, we fill out the buffer descriptor:
2100 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2101 SIR_MAC_MGMT_ACTION, peer,
2102 psessionEntry->selfMacAddr);
2103 if ( eSIR_SUCCESS != nSirStatus )
2104 {
2105 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002106 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002107 nSirStatus );
2108 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2109 return; // allocated!
2110 }
2111
2112 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
2113
2114 #if 0
2115
2116 cfgLen = SIR_MAC_ADDR_LENGTH;
2117 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
2118 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
2119 {
2120 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002121 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2123 return; // allocated!
2124 }
2125 #endif //TO SUPPORT BT-AMP
2126 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
2127
Chet Lanctot186b5732013-03-18 10:26:30 -07002128#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002129 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07002130#endif
2131
Jeff Johnson295189b2012-06-20 16:38:30 -07002132 // That done, pack the struct:
2133 if ( !wmmTspecPresent )
2134 {
2135 nStatus = dot11fPackDelTS( pMac, &DelTS,
2136 pFrame + sizeof( tSirMacMgmtHdr ),
2137 nPayload, &nPayload );
2138 if ( DOT11F_FAILED( nStatus ) )
2139 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002140 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002141 nStatus );
2142 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2143 return; // allocated!
2144 }
2145 else if ( DOT11F_WARNED( nStatus ) )
2146 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002147 limLog( pMac, LOGW, FL("There were warnings while packing "
2148 "a Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002149 }
2150 }
2151 else
2152 {
2153 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
2154 pFrame + sizeof( tSirMacMgmtHdr ),
2155 nPayload, &nPayload );
2156 if ( DOT11F_FAILED( nStatus ) )
2157 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002158 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 nStatus );
2160 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2161 return; // allocated!
2162 }
2163 else if ( DOT11F_WARNED( nStatus ) )
2164 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002165 limLog( pMac, LOGW, FL("There were warnings while packing "
2166 "a WMM Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002167 }
2168 }
2169
2170 PELOG1(limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
2171 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
2172
2173 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002174 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2175 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002176 )
2177 {
2178 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2179 }
2180
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302181 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2182 psessionEntry->peSessionId,
2183 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2185 HAL_TXRX_FRM_802_11_MGMT,
2186 ANI_TXDIR_TODS,
2187 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2188 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302189 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2190 psessionEntry->peSessionId,
2191 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002192 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2193 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002194 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002195 nSirStatus );
2196 //Pkt will be freed up by the callback
2197 }
2198
2199} // End limSendDeltsReqActionFrame.
2200
2201void
2202limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
2203 tLimMlmAssocReq *pMlmAssocReq,
2204 tpPESession psessionEntry)
2205{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002206 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07002207 tANI_U16 caps;
2208 tANI_U8 *pFrame;
2209 tSirRetStatus nSirStatus;
2210 tLimMlmAssocCnf mlmAssocCnf;
2211 tANI_U32 nBytes, nPayload, nStatus;
2212 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2213 void *pPacket;
2214 eHalStatus halstatus;
2215 tANI_U16 nAddIELen;
2216 tANI_U8 *pAddIE;
2217 tANI_U8 *wpsIe = NULL;
2218#if defined WLAN_FEATURE_VOWIFI
2219 tANI_U8 PowerCapsPopulated = FALSE;
2220#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302221 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302222 tpSirMacMgmtHdr pMacHdr;
Kalikinkar dhara205da782014-03-21 15:49:32 -07002223 tDot11fIEExtCap extractedExtCap;
2224 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002225
2226 if(NULL == psessionEntry)
2227 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302228 limLog(pMac, LOGE, FL("psessionEntry is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002229 return;
2230 }
2231
Jeff Johnson295189b2012-06-20 16:38:30 -07002232 /* check this early to avoid unncessary operation */
2233 if(NULL == psessionEntry->pLimJoinReq)
2234 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302235 limLog(pMac, LOGE, FL("psessionEntry->pLimJoinReq is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002236 return;
2237 }
2238 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
2239 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
2240
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302241 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
2242 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002243 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302244 limLog(pMac, LOGE, FL("Unable to allocate memory") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002245 return;
2246 }
2247
2248
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302249 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002250
Kalikinkar dhara205da782014-03-21 15:49:32 -07002251 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
2252 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac, pAddIE,
2253 &nAddIELen,
2254 &extractedExtCap );
2255 if(eSIR_SUCCESS != nSirStatus )
2256 {
2257 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
2258 limLog(pMac, LOG1,
2259 FL("Unable to Stripoff ExtCap IE from Assoc Req"));
2260 }
2261
Jeff Johnson295189b2012-06-20 16:38:30 -07002262 caps = pMlmAssocReq->capabilityInfo;
2263 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2264 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2265#if defined(FEATURE_WLAN_WAPI)
2266 /* CR: 262463 :
2267 According to WAPI standard:
2268 7.3.1.4 Capability Information field
2269 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2270 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2271 Reassociation management frames. */
2272 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2273 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2274#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002275 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002276
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002277 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2278 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002279 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002280 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002281
2282 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2283 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2284
2285 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2286 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2287
2288 // We prefer .11e asociations:
2289 if ( fQosEnabled ) fWmeEnabled = false;
2290
2291 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2292 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2293
2294 if ( psessionEntry->lim11hEnable &&
2295 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2296 {
2297#if defined WLAN_FEATURE_VOWIFI
2298 PowerCapsPopulated = TRUE;
2299
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002300 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002301#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002302 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002303
2304 }
2305
2306#if defined WLAN_FEATURE_VOWIFI
2307 if( pMac->rrm.rrmPEContext.rrmEnable &&
2308 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2309 {
2310 if (PowerCapsPopulated == FALSE)
2311 {
2312 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002313 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002314 }
2315 }
2316#endif
2317
2318 if ( fQosEnabled &&
2319 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002320 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002321
2322 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002323 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002324
2325#if defined WLAN_FEATURE_VOWIFI
2326 if( pMac->rrm.rrmPEContext.rrmEnable &&
2327 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2328 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002329 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002330 }
2331#endif
2332 // The join request *should* contain zero or one of the WPA and RSN
2333 // IEs. The payload send along with the request is a
2334 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2335
2336 // typedef struct sSirRSNie
2337 // {
2338 // tANI_U16 length;
2339 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2340 // } tSirRSNie, *tpSirRSNie;
2341
2342 // So, we should be able to make the following two calls harmlessly,
2343 // since they do nothing if they don't find the given IE in the
2344 // bytestream with which they're provided.
2345
2346 // The net effect of this will be to faithfully transmit whatever
2347 // security IE is in the join request.
2348
2349 // *However*, if we're associating for the purpose of WPS
2350 // enrollment, and we've been configured to indicate that by
2351 // eliding the WPA or RSN IE, we just skip this:
2352 if( nAddIELen && pAddIE )
2353 {
2354 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2355 }
2356 if ( NULL == wpsIe )
2357 {
2358 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002359 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002360 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002361 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002362#if defined(FEATURE_WLAN_WAPI)
2363 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002364 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002365#endif // defined(FEATURE_WLAN_WAPI)
2366 }
2367
2368 // include WME EDCA IE as well
2369 if ( fWmeEnabled )
2370 {
2371 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2372 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002373 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002374 }
2375
2376 if ( fWsmEnabled &&
2377 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2378 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002379 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002380 }
2381 }
2382
2383 //Populate HT IEs, when operating in 11n or Taurus modes AND
2384 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002385 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002386 pMac->lim.htCapabilityPresentInBeacon)
2387 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002388 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002389#ifdef DISABLE_GF_FOR_INTEROP
2390
2391 /*
2392 * To resolve the interop problem with Broadcom AP,
2393 * where TQ STA could not pass traffic with GF enabled,
2394 * TQ STA will do Greenfield only with TQ AP, for
2395 * everybody else it will be turned off.
2396 */
2397
2398 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2399 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302400 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP,"
2401 " Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002402 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002403 }
2404#endif
2405
2406 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002407#ifdef WLAN_FEATURE_11AC
2408 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002409 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002410 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002411 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002412 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
Jeff Johnsone7245742012-09-05 17:12:55 -07002413 }
2414#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302415 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002416
2417#if defined WLAN_FEATURE_VOWIFI_11R
2418 if (psessionEntry->pLimJoinReq->is11Rconnection)
2419 {
2420#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002421 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002422 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2423 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2424 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2425#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302426 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2427 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002428 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302429 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002430 {
2431 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302432 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002433 }
2434#endif
2435
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002436#ifdef FEATURE_WLAN_ESE
2437 /* For ESE Associations fill the ESE IEs */
2438 if (psessionEntry->isESEconnection &&
2439 psessionEntry->pLimJoinReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002440 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002441#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002442 PopulateDot11fESERadMgmtCap(&pFrm->ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002443#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002444 PopulateDot11fESEVersion(&pFrm->ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002445 }
2446#endif
2447
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002448 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002449 if ( DOT11F_FAILED( nStatus ) )
2450 {
2451 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002452 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002453 nStatus );
2454 // We'll fall back on the worst case scenario:
2455 nPayload = sizeof( tDot11fAssocRequest );
2456 }
2457 else if ( DOT11F_WARNED( nStatus ) )
2458 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002459 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002460 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002461 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002462 }
2463
2464 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2465
2466 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2467 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2468 ( void** ) &pPacket );
2469 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2470 {
2471 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002472 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002473
2474 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002475 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002476
2477
2478 /* Update PE session id*/
2479 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2480
2481 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2482
2483 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2484 ( void* ) pFrame, ( void* ) pPacket );
2485
2486 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2487 ( tANI_U32* ) &mlmAssocCnf);
2488
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302489 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002490 return;
2491 }
2492
2493 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302494 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002495
2496 // Next, we fill out the buffer descriptor:
2497 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2498 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2499 if ( eSIR_SUCCESS != nSirStatus )
2500 {
2501 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002502 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002503 nSirStatus );
2504 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302505 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002506 return;
2507 }
Kalikinkar dhara205da782014-03-21 15:49:32 -07002508 /* merge the ExtCap struct*/
2509 if (extractedExtCapFlag)
2510 {
2511 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
2512 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002513
Abhishek Singh57aebef2014-02-03 18:47:44 +05302514 // That done, pack the Assoc Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002515 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002516 sizeof(tSirMacMgmtHdr),
2517 nPayload, &nPayload );
2518 if ( DOT11F_FAILED( nStatus ) )
2519 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302520 limLog( pMac, LOGE, FL("Failed to pack a Assoc Request (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002521 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002522 nStatus );
2523 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2524 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302525 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002526 return;
2527 }
2528 else if ( DOT11F_WARNED( nStatus ) )
2529 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302530 limLog( pMac, LOGW, FL("There were warnings while packing a Assoc"
2531 "Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002532 }
2533
2534 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002535 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002536 nBytes );)
2537 // limPrintMacAddr( pMac, bssid, LOG1 );
2538
2539 if( psessionEntry->assocReq != NULL )
2540 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302541 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002542 psessionEntry->assocReq = NULL;
2543 }
2544
2545 if( nAddIELen )
2546 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302547 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2548 pAddIE,
2549 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002550 nPayload += nAddIELen;
2551 }
2552
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302553 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2554 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002555 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302556 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store "
2557 "assoc request"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002558 }
2559 else
2560 {
2561 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302562 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002563 psessionEntry->assocReqLen = nPayload;
2564 }
2565
2566 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002567 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2568 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002569 )
2570 {
2571 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2572 }
2573
Ganesh K08bce952012-12-13 15:04:41 -08002574 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2575 {
2576 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2577 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302578
2579 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05302580 limLog( pMac, LOG1, FL("Sending Assoc req over WQ5 to "MAC_ADDRESS_STR
2581 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
2582 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2583 txFlag |= HAL_USE_FW_IN_TX_PATH;
2584
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302585 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2586 psessionEntry->peSessionId,
2587 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002588 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2589 HAL_TXRX_FRM_802_11_MGMT,
2590 ANI_TXDIR_TODS,
2591 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2592 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302593 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2594 psessionEntry->peSessionId,
2595 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002596 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2597 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002598 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002599 halstatus );
2600 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302601 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002602 return;
2603 }
2604
2605 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302606 vos_mem_free(pMlmAssocReq);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002607 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302608 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002609 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002610} // End limSendAssocReqMgmtFrame
2611
2612
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002613#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002614/*------------------------------------------------------------------------------------
2615 *
2616 * Send Reassoc Req with FTIEs.
2617 *
2618 *-----------------------------------------------------------------------------------
2619 */
2620void
2621limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2622 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2623{
2624 static tDot11fReAssocRequest frm;
2625 tANI_U16 caps;
2626 tANI_U8 *pFrame;
2627 tSirRetStatus nSirStatus;
2628 tANI_U32 nBytes, nPayload, nStatus;
2629 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2630 void *pPacket;
2631 eHalStatus halstatus;
2632#if defined WLAN_FEATURE_VOWIFI
2633 tANI_U8 PowerCapsPopulated = FALSE;
2634#endif
2635 tANI_U16 ft_ies_length = 0;
2636 tANI_U8 *pBody;
2637 tANI_U16 nAddIELen;
2638 tANI_U8 *pAddIE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002639#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002640 tANI_U8 *wpsIe = NULL;
2641#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302642 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302643 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002644
2645 if (NULL == psessionEntry)
2646 {
2647 return;
2648 }
2649
Jeff Johnson295189b2012-06-20 16:38:30 -07002650 /* check this early to avoid unncessary operation */
2651 if(NULL == psessionEntry->pLimReAssocReq)
2652 {
2653 return;
2654 }
2655 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2656 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002657 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2658 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002659
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302660 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002661
2662 caps = pMlmReassocReq->capabilityInfo;
2663 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2664 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2665#if defined(FEATURE_WLAN_WAPI)
2666 /* CR: 262463 :
2667 According to WAPI standard:
2668 7.3.1.4 Capability Information field
2669 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2670 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2671 Reassociation management frames. */
2672 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2673 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2674#endif
2675 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2676
2677 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2678
2679 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302680 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002681 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2682
2683 PopulateDot11fSSID2( pMac, &frm.SSID );
2684 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2685 &frm.SuppRates,psessionEntry);
2686
2687 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2688 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2689
2690 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2691 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2692
2693 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2694 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2695
2696 if ( psessionEntry->lim11hEnable &&
2697 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2698 {
2699#if defined WLAN_FEATURE_VOWIFI
2700 PowerCapsPopulated = TRUE;
2701
2702 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2703 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2704#endif
2705 }
2706
2707#if defined WLAN_FEATURE_VOWIFI
2708 if( pMac->rrm.rrmPEContext.rrmEnable &&
2709 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2710 {
2711 if (PowerCapsPopulated == FALSE)
2712 {
2713 PowerCapsPopulated = TRUE;
2714 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2715 }
2716 }
2717#endif
2718
2719 if ( fQosEnabled &&
2720 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2721 {
2722 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2723 }
2724
2725 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2726 &frm.ExtSuppRates, psessionEntry );
2727
2728#if defined WLAN_FEATURE_VOWIFI
2729 if( pMac->rrm.rrmPEContext.rrmEnable &&
2730 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2731 {
2732 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2733 }
2734#endif
2735
2736 // Ideally this should be enabled for 11r also. But 11r does
2737 // not follow the usual norm of using the Opaque object
2738 // for rsnie and fties. Instead we just add
2739 // the rsnie and fties at the end of the pack routine for 11r.
2740 // This should ideally! be fixed.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002741#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002742 //
2743 // The join request *should* contain zero or one of the WPA and RSN
2744 // IEs. The payload send along with the request is a
2745 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2746
2747 // typedef struct sSirRSNie
2748 // {
2749 // tANI_U16 length;
2750 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2751 // } tSirRSNie, *tpSirRSNie;
2752
2753 // So, we should be able to make the following two calls harmlessly,
2754 // since they do nothing if they don't find the given IE in the
2755 // bytestream with which they're provided.
2756
2757 // The net effect of this will be to faithfully transmit whatever
2758 // security IE is in the join request.
2759
2760 // *However*, if we're associating for the purpose of WPS
2761 // enrollment, and we've been configured to indicate that by
2762 // eliding the WPA or RSN IE, we just skip this:
2763 if (!psessionEntry->is11Rconnection)
2764 {
2765 if( nAddIELen && pAddIE )
2766 {
2767 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2768 }
2769 if ( NULL == wpsIe )
2770 {
2771 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2772 &frm.RSNOpaque );
2773 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2774 &frm.WPAOpaque );
2775 }
2776
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002777#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302778 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002779 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002780 PopulateDot11fESECckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2781 &frm.ESECckmOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002782 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002783#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002784 }
2785
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002786#ifdef FEATURE_WLAN_ESE
2787 // For ESE Associations fill the ESE IEs
2788 if (psessionEntry->isESEconnection &&
2789 psessionEntry->pLimReAssocReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002790 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002791#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002792 PopulateDot11fESERadMgmtCap(&frm.ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002793#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002794 PopulateDot11fESEVersion(&frm.ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002795 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002796#endif //FEATURE_WLAN_ESE
2797#endif //FEATURE_WLAN_ESE || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002798
2799 // include WME EDCA IE as well
2800 if ( fWmeEnabled )
2801 {
2802 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2803 {
2804 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2805 }
2806
2807 if ( fWsmEnabled &&
2808 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2809 {
2810 PopulateDot11fWMMCaps( &frm.WMMCaps );
2811 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002812#ifdef FEATURE_WLAN_ESE
2813 if (psessionEntry->isESEconnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07002814 {
2815 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2816
2817 // Populate the TSRS IE if TSPEC is included in the reassoc request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002818 if (psessionEntry->pLimReAssocReq->eseTspecInfo.numTspecs)
Jeff Johnson295189b2012-06-20 16:38:30 -07002819 {
2820 tANI_U32 phyMode;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002821 tSirMacESETSRSIE tsrsIE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002822 limGetPhyMode(pMac, &phyMode, psessionEntry);
2823
2824 tsrsIE.tsid = 0;
2825 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2826 {
2827 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2828 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302829 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002830 {
2831 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2832 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002833 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.ESETrafStrmRateSet, sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07002834 }
2835 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302836#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002837 }
2838
Jeff Johnsone7245742012-09-05 17:12:55 -07002839 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002840 pMac->lim.htCapabilityPresentInBeacon)
2841 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002842 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002843 }
2844
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002845#if defined WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302846 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent && (0 == pMac->ft.ftSmeContext.reassoc_ft_ies_length)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002847#if defined FEATURE_WLAN_ESE
2848 && !psessionEntry->isESEconnection
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302849#endif
2850 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002851 {
2852 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2853 }
2854#endif
2855
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002856#ifdef WLAN_FEATURE_11AC
2857 if ( psessionEntry->vhtCapability &&
2858 psessionEntry->vhtCapabilityPresentInBeacon)
2859 {
2860 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
2861 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002862 }
2863#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302864 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002865
Jeff Johnson295189b2012-06-20 16:38:30 -07002866 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2867 if ( DOT11F_FAILED( nStatus ) )
2868 {
2869 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002870 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002871 nStatus );
2872 // We'll fall back on the worst case scenario:
2873 nPayload = sizeof( tDot11fReAssocRequest );
2874 }
2875 else if ( DOT11F_WARNED( nStatus ) )
2876 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002877 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002879 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002880 }
2881
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002882 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002883
2884#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002885 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002886 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2887#endif
2888
2889#if defined WLAN_FEATURE_VOWIFI_11R
2890 if (psessionEntry->is11Rconnection)
2891 {
2892 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2893 }
2894#endif
2895
2896 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2897 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2898 ( void** ) &pPacket );
2899 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2900 {
2901 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002902 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002903 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002904 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002905 goto end;
2906 }
2907
2908 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302909 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002910
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002911#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002912 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002913#endif
2914 // Next, we fill out the buffer descriptor:
2915 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2916 SIR_MAC_MGMT_REASSOC_REQ,
2917 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2918 if ( eSIR_SUCCESS != nSirStatus )
2919 {
2920 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002921 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002922 nSirStatus );
2923 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2924 goto end;
2925 }
2926
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302927 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07002928 // That done, pack the ReAssoc Request:
2929 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2930 sizeof(tSirMacMgmtHdr),
2931 nPayload, &nPayload );
2932 if ( DOT11F_FAILED( nStatus ) )
2933 {
2934 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002935 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002936 nStatus );
2937 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2938 goto end;
2939 }
2940 else if ( DOT11F_WARNED( nStatus ) )
2941 {
2942 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002943 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002944 }
2945
2946 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002947 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002948 nBytes, nPayload );)
2949 if( psessionEntry->assocReq != NULL )
2950 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302951 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002952 psessionEntry->assocReq = NULL;
2953 }
2954
2955 if( nAddIELen )
2956 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302957 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2958 pAddIE,
2959 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002960 nPayload += nAddIELen;
2961 }
2962
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302963 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2964 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002965 {
2966 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002967 }
2968 else
2969 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002970 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302971 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002972 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002973 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002974
2975 if (psessionEntry->is11Rconnection)
2976 {
2977 {
2978 int i = 0;
2979
2980 pBody = pFrame + nBytes;
2981 for (i=0; i<ft_ies_length; i++)
2982 {
2983 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2984 pBody++;
2985 }
2986 }
2987 }
2988
2989#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002990 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
2991 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002992 (tANI_U8 *)pFrame,
2993 (nBytes + ft_ies_length));)
2994#endif
2995
2996
2997 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002998 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2999 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003000 )
3001 {
3002 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3003 }
3004
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003005 if( NULL != psessionEntry->assocReq )
3006 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303007 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003008 psessionEntry->assocReq = NULL;
3009 }
3010
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303011 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
3012 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003013 {
3014 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003015 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003016 }
3017 else
3018 {
3019 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303020 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
3021 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003022 psessionEntry->assocReqLen = (ft_ies_length);
3023 }
3024
3025
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303026 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3027 psessionEntry->peSessionId,
3028 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003029 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
3030 HAL_TXRX_FRM_802_11_MGMT,
3031 ANI_TXDIR_TODS,
3032 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3033 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303034 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3035 psessionEntry->peSessionId,
3036 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003037 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3038 {
3039 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003040 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003041 nSirStatus );
3042 //Pkt will be freed up by the callback
3043 goto end;
3044 }
3045
3046end:
3047 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303048 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003049 psessionEntry->pLimMlmReassocReq = NULL;
3050
3051}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003052
3053void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
3054 tLimMlmReassocReq *pMlmReassocReq,
3055 tpPESession psessionEntry)
3056{
3057 tLimMlmReassocCnf mlmReassocCnf; // keep sme
3058 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
3059 if(NULL == pTmpMlmReassocReq)
3060 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303061 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
3062 if ( NULL == pTmpMlmReassocReq ) goto end;
3063 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
3064 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003065 }
3066
3067 // Prepare and send Reassociation request frame
3068 // start reassoc timer.
3069 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
3070 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08003071 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003072 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
3073 != TX_SUCCESS)
3074 {
3075 // Could not start reassoc failure timer.
3076 // Log error
3077 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003078 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003079 // Return Reassoc confirm with
3080 // Resources Unavailable
3081 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3082 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3083 goto end;
3084 }
3085
3086 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
3087 return;
3088
3089end:
3090 // Free up buffer allocated for reassocReq
3091 if (pMlmReassocReq != NULL)
3092 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303093 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003094 pMlmReassocReq = NULL;
3095 }
3096 if (pTmpMlmReassocReq != NULL)
3097 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303098 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003099 pTmpMlmReassocReq = NULL;
3100 }
3101 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
3102 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3103 /* Update PE sessio Id*/
3104 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
3105
3106 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3107}
3108
Jeff Johnson295189b2012-06-20 16:38:30 -07003109#endif /* WLAN_FEATURE_VOWIFI_11R */
3110
3111
3112void
3113limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
3114 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
3115{
3116 static tDot11fReAssocRequest frm;
3117 tANI_U16 caps;
3118 tANI_U8 *pFrame;
3119 tSirRetStatus nSirStatus;
3120 tANI_U32 nBytes, nPayload, nStatus;
3121 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
3122 void *pPacket;
3123 eHalStatus halstatus;
3124 tANI_U16 nAddIELen;
3125 tANI_U8 *pAddIE;
3126 tANI_U8 *wpsIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303127 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003128#if defined WLAN_FEATURE_VOWIFI
3129 tANI_U8 PowerCapsPopulated = FALSE;
3130#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303131 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003132
3133 if(NULL == psessionEntry)
3134 {
3135 return;
3136 }
3137
3138 /* check this early to avoid unncessary operation */
3139 if(NULL == psessionEntry->pLimReAssocReq)
3140 {
3141 return;
3142 }
3143 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
3144 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
3145
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303146 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003147
3148 caps = pMlmReassocReq->capabilityInfo;
3149 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
3150 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
3151#if defined(FEATURE_WLAN_WAPI)
3152 /* CR: 262463 :
3153 According to WAPI standard:
3154 7.3.1.4 Capability Information field
3155 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
3156 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
3157 Reassociation management frames. */
3158 if ( psessionEntry->encryptType == eSIR_ED_WPI)
3159 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
3160#endif
3161 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
3162
3163 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
3164
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303165 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
3166 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003167
3168 PopulateDot11fSSID2( pMac, &frm.SSID );
3169 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3170 &frm.SuppRates,psessionEntry);
3171
3172 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
3173 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
3174
3175 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
3176 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
3177
3178 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
3179 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
3180
3181
3182 if ( psessionEntry->lim11hEnable &&
3183 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
3184 {
3185#if defined WLAN_FEATURE_VOWIFI
3186 PowerCapsPopulated = TRUE;
3187 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
3188 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
3189#endif
3190 }
3191
3192#if defined WLAN_FEATURE_VOWIFI
3193 if( pMac->rrm.rrmPEContext.rrmEnable &&
3194 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
3195 {
3196 if (PowerCapsPopulated == FALSE)
3197 {
3198 PowerCapsPopulated = TRUE;
3199 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
3200 }
3201 }
3202#endif
3203
3204 if ( fQosEnabled &&
3205 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
3206 {
3207 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
3208 }
3209
3210 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3211 &frm.ExtSuppRates, psessionEntry );
3212
3213#if defined WLAN_FEATURE_VOWIFI
3214 if( pMac->rrm.rrmPEContext.rrmEnable &&
3215 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
3216 {
3217 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
3218 }
3219#endif
3220 // The join request *should* contain zero or one of the WPA and RSN
3221 // IEs. The payload send along with the request is a
3222 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
3223
3224 // typedef struct sSirRSNie
3225 // {
3226 // tANI_U16 length;
3227 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
3228 // } tSirRSNie, *tpSirRSNie;
3229
3230 // So, we should be able to make the following two calls harmlessly,
3231 // since they do nothing if they don't find the given IE in the
3232 // bytestream with which they're provided.
3233
3234 // The net effect of this will be to faithfully transmit whatever
3235 // security IE is in the join request.
3236
3237 // *However*, if we're associating for the purpose of WPS
3238 // enrollment, and we've been configured to indicate that by
3239 // eliding the WPA or RSN IE, we just skip this:
3240 if( nAddIELen && pAddIE )
3241 {
3242 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
3243 }
3244 if ( NULL == wpsIe )
3245 {
3246 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3247 &frm.RSNOpaque );
3248 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3249 &frm.WPAOpaque );
3250#if defined(FEATURE_WLAN_WAPI)
3251 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3252 &frm.WAPIOpaque );
3253#endif // defined(FEATURE_WLAN_WAPI)
3254 }
3255
3256 // include WME EDCA IE as well
3257 if ( fWmeEnabled )
3258 {
3259 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
3260 {
3261 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
3262 }
3263
3264 if ( fWsmEnabled &&
3265 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3266 {
3267 PopulateDot11fWMMCaps( &frm.WMMCaps );
3268 }
3269 }
3270
Jeff Johnsone7245742012-09-05 17:12:55 -07003271 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003272 pMac->lim.htCapabilityPresentInBeacon)
3273 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003274 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003275 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003276#ifdef WLAN_FEATURE_11AC
3277 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003278 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003279 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003280 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003281 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Sandeep Puligilla60342762014-01-30 21:05:37 +05303282 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003283 }
3284#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003285
3286 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3287 if ( DOT11F_FAILED( nStatus ) )
3288 {
3289 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003290 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003291 nStatus );
3292 // We'll fall back on the worst case scenario:
3293 nPayload = sizeof( tDot11fReAssocRequest );
3294 }
3295 else if ( DOT11F_WARNED( nStatus ) )
3296 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003297 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003298 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003299 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 }
3301
3302 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3303
3304 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3305 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3306 ( void** ) &pPacket );
3307 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3308 {
3309 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003310 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003311 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003312 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003313 goto end;
3314 }
3315
3316 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303317 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003318
3319 // Next, we fill out the buffer descriptor:
3320 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3321 SIR_MAC_MGMT_REASSOC_REQ,
3322 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3323 if ( eSIR_SUCCESS != nSirStatus )
3324 {
3325 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003326 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003327 nSirStatus );
3328 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3329 goto end;
3330 }
3331
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303332 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003333 // That done, pack the Probe Request:
3334 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3335 sizeof(tSirMacMgmtHdr),
3336 nPayload, &nPayload );
3337 if ( DOT11F_FAILED( nStatus ) )
3338 {
3339 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003340 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003341 nStatus );
3342 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3343 goto end;
3344 }
3345 else if ( DOT11F_WARNED( nStatus ) )
3346 {
3347 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003348 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003349 }
3350
3351 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003352 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003353 nBytes );)
3354
3355 if( psessionEntry->assocReq != NULL )
3356 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303357 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003358 psessionEntry->assocReq = NULL;
3359 }
3360
3361 if( nAddIELen )
3362 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303363 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3364 pAddIE,
3365 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003366 nPayload += nAddIELen;
3367 }
3368
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303369 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3370 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003371 {
3372 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003373 }
3374 else
3375 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003376 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303377 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003378 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003379 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003380
3381 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003382 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3383 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003384 )
3385 {
3386 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3387 }
3388
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003389 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003390 {
3391 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3392 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003393
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303394 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3395 psessionEntry->peSessionId,
3396 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003397 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3398 HAL_TXRX_FRM_802_11_MGMT,
3399 ANI_TXDIR_TODS,
3400 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3401 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303402 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3403 psessionEntry->peSessionId,
3404 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003405 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3406 {
3407 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003408 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003409 nSirStatus );
3410 //Pkt will be freed up by the callback
3411 goto end;
3412 }
3413
3414end:
3415 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303416 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003417 psessionEntry->pLimMlmReassocReq = NULL;
3418
3419} // limSendReassocReqMgmtFrame
3420
3421/**
3422 * \brief Send an Authentication frame
3423 *
3424 *
3425 * \param pMac Pointer to Global MAC structure
3426 *
3427 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3428 * to be sent
3429 *
3430 * \param peerMacAddr MAC address of the peer entity to which Authentication
3431 * frame is destined
3432 *
3433 * \param wepBit Indicates whether wep bit to be set in FC while sending
3434 * Authentication frame3
3435 *
3436 *
3437 * This function is called by limProcessMlmMessages(). Authentication frame
3438 * is formatted and sent when this function is called.
3439 *
3440 *
3441 */
3442
3443void
3444limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3445 tpSirMacAuthFrameBody pAuthFrameBody,
3446 tSirMacAddr peerMacAddr,
3447 tANI_U8 wepBit,
3448 tpPESession psessionEntry
3449 )
3450{
3451 tANI_U8 *pFrame, *pBody;
3452 tANI_U32 frameLen = 0, bodyLen = 0;
3453 tpSirMacMgmtHdr pMacHdr;
3454 tANI_U16 i;
3455 void *pPacket;
3456 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303457 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003458
3459 if(NULL == psessionEntry)
3460 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303461 limLog(pMac, LOGE, FL("Error: psession Entry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003462 return;
3463 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05303464
3465 limLog(pMac, LOG1,
3466 FL("Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
3467 pAuthFrameBody->authTransactionSeqNumber,
3468 pAuthFrameBody->authStatusCode,
3469 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3470 MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003471 if (wepBit == LIM_WEP_IN_FC)
3472 {
3473 /// Auth frame3 to be sent with encrypted framebody
3474 /**
3475 * Allocate buffer for Authenticaton frame of size equal
3476 * to management frame header length plus 2 bytes each for
3477 * auth algorithm number, transaction number, status code,
3478 * 128 bytes for challenge text and 4 bytes each for
3479 * IV & ICV.
3480 */
3481
3482 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3483
3484 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3485 } // if (wepBit == LIM_WEP_IN_FC)
3486 else
3487 {
3488 switch (pAuthFrameBody->authTransactionSeqNumber)
3489 {
3490 case SIR_MAC_AUTH_FRAME_1:
3491 /**
3492 * Allocate buffer for Authenticaton frame of size
3493 * equal to management frame header length plus 2 bytes
3494 * each for auth algorithm number, transaction number
3495 * and status code.
3496 */
3497
3498 frameLen = sizeof(tSirMacMgmtHdr) +
3499 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3500 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3501
3502#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003503 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3504 {
3505 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003506 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003507 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003508 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003509 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003510 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003511 else
3512 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303513 limLog(pMac, LOG3, FL("Auth frame, Does not contain "
3514 "FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003515 frameLen += (2+SIR_MDIE_SIZE);
3516 }
3517 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003518#endif
3519 break;
3520
3521 case SIR_MAC_AUTH_FRAME_2:
3522 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3523 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3524 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3525 {
3526 /**
3527 * Allocate buffer for Authenticaton frame of size
3528 * equal to management frame header length plus
3529 * 2 bytes each for auth algorithm number,
3530 * transaction number and status code.
3531 */
3532
3533 frameLen = sizeof(tSirMacMgmtHdr) +
3534 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3535 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3536 }
3537 else
3538 {
3539 // Shared Key algorithm with challenge text
3540 // to be sent
3541 /**
3542 * Allocate buffer for Authenticaton frame of size
3543 * equal to management frame header length plus
3544 * 2 bytes each for auth algorithm number,
3545 * transaction number, status code and 128 bytes
3546 * for challenge text.
3547 */
3548
3549 frameLen = sizeof(tSirMacMgmtHdr) +
3550 sizeof(tSirMacAuthFrame);
3551 bodyLen = sizeof(tSirMacAuthFrameBody);
3552 }
3553
3554 break;
3555
3556 case SIR_MAC_AUTH_FRAME_3:
3557 /// Auth frame3 to be sent without encrypted framebody
3558 /**
3559 * Allocate buffer for Authenticaton frame of size equal
3560 * to management frame header length plus 2 bytes each
3561 * for auth algorithm number, transaction number and
3562 * status code.
3563 */
3564
3565 frameLen = sizeof(tSirMacMgmtHdr) +
3566 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3567 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3568
3569 break;
3570
3571 case SIR_MAC_AUTH_FRAME_4:
3572 /**
3573 * Allocate buffer for Authenticaton frame of size equal
3574 * to management frame header length plus 2 bytes each
3575 * for auth algorithm number, transaction number and
3576 * status code.
3577 */
3578
3579 frameLen = sizeof(tSirMacMgmtHdr) +
3580 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3581 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3582
3583 break;
3584 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3585 } // end if (wepBit == LIM_WEP_IN_FC)
3586
3587
3588 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3589
3590 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3591 {
3592 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003593 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003594
3595 return;
3596 }
3597
3598 for (i = 0; i < frameLen; i++)
3599 pFrame[i] = 0;
3600
3601 // Prepare BD
3602 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3603 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3604 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303605 limLog(pMac, LOGE, FL("call to limPopulateMacHeader failed for "
3606 "AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003607 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3608 return;
3609 }
3610
3611 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3612 pMacHdr->fc.wep = wepBit;
3613
3614 // Prepare BSSId
3615 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3616 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303617 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3618 (tANI_U8 *) psessionEntry->bssId,
3619 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003620 }
3621
3622 /// Prepare Authentication frame body
3623 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3624
3625 if (wepBit == LIM_WEP_IN_FC)
3626 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303627 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003628
3629 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303630 FL("*** Sending Auth seq# 3 status %d (%d) to"MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003631 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303632 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3633 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003634
Jeff Johnson295189b2012-06-20 16:38:30 -07003635 }
3636 else
3637 {
3638 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3639 pBody += sizeof(tANI_U16);
3640 bodyLen -= sizeof(tANI_U16);
3641
3642 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3643 pBody += sizeof(tANI_U16);
3644 bodyLen -= sizeof(tANI_U16);
3645
3646 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3647 pBody += sizeof(tANI_U16);
3648 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003649 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3650 sizeof (pAuthFrameBody->length) +
3651 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303652 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003653
3654#if defined WLAN_FEATURE_VOWIFI_11R
3655 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3656 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3657 {
3658
3659 {
3660 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003661 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3662 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003663#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowdad63eb492014-02-06 12:21:47 -08003664 PELOG2(limLog(pMac, LOG2, FL("Auth1 Frame FTIE is: "));
3665 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
Jeff Johnson295189b2012-06-20 16:38:30 -07003666 (tANI_U8 *)pBody,
3667 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003668#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003669 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3670 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003671 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3672 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003673 }
3674 }
3675 else
3676 {
3677 /* MDID attr is 54*/
3678 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003679 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003680 *pBody = SIR_MDIE_SIZE;
3681 pBody++;
3682 for(i=0;i<SIR_MDIE_SIZE;i++)
3683 {
3684 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3685 pBody++;
3686 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003687 }
3688 }
3689 }
3690#endif
3691
3692 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303693 FL("*** Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003694 pAuthFrameBody->authTransactionSeqNumber,
3695 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303696 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3697 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003698 }
3699 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3700
3701 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003702 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3703 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003704#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303705 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003706 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3707#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003708 )
3709 {
3710 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3711 }
3712
Ganesh K08bce952012-12-13 15:04:41 -08003713 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3714 {
3715 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3716 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003717
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05303718 limLog( pMac, LOG1, FL("Sending Auth Frame over WQ5 to "MAC_ADDRESS_STR
3719 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
3720 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
3721
3722 txFlag |= HAL_USE_FW_IN_TX_PATH;
3723
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303724 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3725 psessionEntry->peSessionId,
3726 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003727 /// Queue Authentication frame in high priority WQ
3728 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3729 HAL_TXRX_FRM_802_11_MGMT,
3730 ANI_TXDIR_TODS,
3731 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3732 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303733 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3734 psessionEntry->peSessionId,
3735 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003736 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3737 {
3738 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003739 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003740 halstatus);
3741
3742 //Pkt will be freed up by the callback
3743 }
3744
3745 return;
3746} /*** end limSendAuthMgmtFrame() ***/
3747
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003748eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3749{
3750 tANI_U16 aid;
3751 tpDphHashNode pStaDs;
3752 tLimMlmDeauthReq *pMlmDeauthReq;
3753 tLimMlmDeauthCnf mlmDeauthCnf;
3754 tpPESession psessionEntry;
3755
3756 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3757 if (pMlmDeauthReq)
3758 {
3759 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3760 {
3761 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3762 }
3763
3764 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3765 {
3766
3767 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003768 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003769 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3770 goto end;
3771 }
3772
3773 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3774 if (pStaDs == NULL)
3775 {
3776 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3777 goto end;
3778 }
3779
3780
3781 /// Receive path cleanup with dummy packet
3782 limCleanupRxPath(pMac, pStaDs,psessionEntry);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05303783
3784#ifdef WLAN_FEATURE_VOWIFI_11R
3785 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
3786 (
3787#ifdef FEATURE_WLAN_ESE
3788 (psessionEntry->isESEconnection ) ||
3789#endif
3790#ifdef FEATURE_WLAN_LFR
3791 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
3792#endif
3793 (psessionEntry->is11Rconnection )))
3794 {
3795 PELOGE(limLog(pMac, LOGE,
3796 FL("FT Preauth Session (%p,%d) Cleanup"
3797 " Deauth reason %d Trigger = %d"),
3798 psessionEntry, psessionEntry->peSessionId,
3799 pMlmDeauthReq->reasonCode,
3800 pMlmDeauthReq->deauthTrigger););
3801 limFTCleanup(pMac);
3802 }
3803 else
3804 {
3805 PELOGE(limLog(pMac, LOGE,
3806 FL("No FT Preauth Session Cleanup in role %d"
3807#ifdef FEATURE_WLAN_ESE
3808 " isESE %d"
3809#endif
3810#ifdef FEATURE_WLAN_LFR
3811 " isLFR %d"
3812#endif
3813 " is11r %d, Deauth reason %d Trigger = %d"),
3814 psessionEntry->limSystemRole,
3815#ifdef FEATURE_WLAN_ESE
3816 psessionEntry->isESEconnection,
3817#endif
3818#ifdef FEATURE_WLAN_LFR
3819 psessionEntry->isFastRoamIniFeatureEnabled,
3820#endif
3821 psessionEntry->is11Rconnection,
3822 pMlmDeauthReq->reasonCode,
3823 pMlmDeauthReq->deauthTrigger););
3824 }
3825#endif
3826
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003827 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303828 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003829 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3830 }
3831 return eHAL_STATUS_SUCCESS;
3832end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303833 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003834 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3835 sizeof(tSirMacAddr));
3836 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3837 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3838 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3839
3840 // Free up buffer allocated
3841 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303842 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003843
3844 limPostSmeMessage(pMac,
3845 LIM_MLM_DEAUTH_CNF,
3846 (tANI_U32 *) &mlmDeauthCnf);
3847 return eHAL_STATUS_SUCCESS;
3848}
3849
3850eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3851{
3852 tANI_U16 aid;
3853 tpDphHashNode pStaDs;
3854 tLimMlmDisassocCnf mlmDisassocCnf;
3855 tpPESession psessionEntry;
3856 tLimMlmDisassocReq *pMlmDisassocReq;
3857
3858 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3859 if (pMlmDisassocReq)
3860 {
3861 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3862 {
3863 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3864 }
3865
3866 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3867 {
3868
3869 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003870 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003871 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3872 goto end;
3873 }
3874
3875 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3876 if (pStaDs == NULL)
3877 {
3878 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3879 goto end;
3880 }
3881
3882 /// Receive path cleanup with dummy packet
3883 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3884 {
3885 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3886 goto end;
3887 }
3888
3889#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003890 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303891 (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003892#ifdef FEATURE_WLAN_ESE
3893 (psessionEntry->isESEconnection ) ||
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003894#endif
3895#ifdef FEATURE_WLAN_LFR
3896 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003897#endif
3898 (psessionEntry->is11Rconnection )) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303899 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003900 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003901 {
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303902 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003903 FL("FT Preauth Session (%p,%d) Cleanup"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003904 psessionEntry, psessionEntry->peSessionId););
3905 limFTCleanup(pMac);
3906 }
3907 else
3908 {
3909 PELOGE(limLog(pMac, LOGE,
3910 FL("No FT Preauth Session Cleanup in role %d"
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003911#ifdef FEATURE_WLAN_ESE
3912 " isESE %d"
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003913#endif
3914#ifdef FEATURE_WLAN_LFR
3915 " isLFR %d"
3916#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003917 " is11r %d reason %d"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003918 psessionEntry->limSystemRole,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003919#ifdef FEATURE_WLAN_ESE
3920 psessionEntry->isESEconnection,
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003921#endif
3922#ifdef FEATURE_WLAN_LFR
3923 psessionEntry->isFastRoamIniFeatureEnabled,
3924#endif
3925 psessionEntry->is11Rconnection,
3926 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003927 }
3928#endif
3929
3930 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303931 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003932 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3933 return eHAL_STATUS_SUCCESS;
3934 }
3935 else
3936 {
3937 return eHAL_STATUS_SUCCESS;
3938 }
3939end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303940 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003941 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3942 sizeof(tSirMacAddr));
3943 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3944 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3945
3946 /* Update PE session ID*/
3947 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3948
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003949 if(pMlmDisassocReq != NULL)
3950 {
3951 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303952 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003953 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3954 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003955
3956 limPostSmeMessage(pMac,
3957 LIM_MLM_DISASSOC_CNF,
3958 (tANI_U32 *) &mlmDisassocCnf);
3959 return eHAL_STATUS_SUCCESS;
3960}
3961
3962eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3963{
3964 return limSendDisassocCnf(pMac);
3965}
3966
3967eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3968{
3969 return limSendDeauthCnf(pMac);
3970}
3971
Jeff Johnson295189b2012-06-20 16:38:30 -07003972/**
3973 * \brief This function is called to send Disassociate frame.
3974 *
3975 *
3976 * \param pMac Pointer to Global MAC structure
3977 *
3978 * \param nReason Indicates the reason that need to be sent in
3979 * Disassociation frame
3980 *
3981 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3982 * sent
3983 *
3984 *
3985 */
3986
3987void
3988limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3989 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003990 tSirMacAddr peer,
3991 tpPESession psessionEntry,
3992 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003993{
3994 tDot11fDisassociation frm;
3995 tANI_U8 *pFrame;
3996 tSirRetStatus nSirStatus;
3997 tpSirMacMgmtHdr pMacHdr;
3998 tANI_U32 nBytes, nPayload, nStatus;
3999 void *pPacket;
4000 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304001 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004002 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004003 if(NULL == psessionEntry)
4004 {
4005 return;
4006 }
4007
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304008 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004009
4010 frm.Reason.code = nReason;
4011
4012 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
4013 if ( DOT11F_FAILED( nStatus ) )
4014 {
4015 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004016 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004017 nStatus );
4018 // We'll fall back on the worst case scenario:
4019 nPayload = sizeof( tDot11fDisassociation );
4020 }
4021 else if ( DOT11F_WARNED( nStatus ) )
4022 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004023 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004024 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004025 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004026 }
4027
4028 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4029
4030 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4031 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4032 ( void** ) &pPacket );
4033 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4034 {
4035 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004036 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004037 return;
4038 }
4039
4040 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304041 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004042
4043 // Next, we fill out the buffer descriptor:
4044 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4045 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
4046 if ( eSIR_SUCCESS != nSirStatus )
4047 {
4048 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004049 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 nSirStatus );
4051 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4052 ( void* ) pFrame, ( void* ) pPacket );
4053 return; // just allocated...
4054 }
4055
4056 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4057
4058 // Prepare the BSSID
4059 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4060
Chet Lanctot186b5732013-03-18 10:26:30 -07004061#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004062 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004063#endif
4064
Jeff Johnson295189b2012-06-20 16:38:30 -07004065 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
4066 sizeof(tSirMacMgmtHdr),
4067 nPayload, &nPayload );
4068 if ( DOT11F_FAILED( nStatus ) )
4069 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004070 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004071 nStatus );
4072 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4073 ( void* ) pFrame, ( void* ) pPacket );
4074 return; // allocated!
4075 }
4076 else if ( DOT11F_WARNED( nStatus ) )
4077 {
4078 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004079 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004080 }
4081
Abhishek Singhcd09b562013-12-24 16:02:20 +05304082 limLog( pMac, LOG1, FL("***Sessionid %d Sending Disassociation frame with "
4083 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4084 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4085 MAC_ADDR_ARRAY(pMacHdr->da),
4086 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004087
4088 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004089 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4090 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004091 )
4092 {
4093 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4094 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004095
Ganesh K08bce952012-12-13 15:04:41 -08004096 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304097 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
4098 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08004099 {
4100 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4101 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004102
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304103 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4104 {
4105 /* This frame will be sent on air by firmware,
4106 which will ensure that this frame goes out
4107 even though DEL_STA is sent immediately */
4108 /* Without this for DEL_STA command there is
4109 risk of flushing frame in BTQM queue without
4110 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304111 limLog( pMac, LOG1, FL("Sending Disassoc Frame over WQ5 to "MAC_ADDRESS_STR
4112 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4113 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304114 txFlag |= HAL_USE_FW_IN_TX_PATH;
4115 }
4116
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004117 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004118 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304119 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4120 psessionEntry->peSessionId,
4121 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004122 // Queue Disassociation frame in high priority WQ
4123 /* get the duration from the request */
4124 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4125 HAL_TXRX_FRM_802_11_MGMT,
4126 ANI_TXDIR_TODS,
4127 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4128 limTxComplete, pFrame, limDisassocTxCompleteCnf,
4129 txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304130 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4131 psessionEntry->peSessionId,
4132 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004133 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07004134
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004135 if (tx_timer_change(
4136 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
4137 != TX_SUCCESS)
4138 {
4139 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004140 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004141 return;
4142 }
4143 else if(TX_SUCCESS != tx_timer_activate(
4144 &pMac->lim.limTimers.gLimDisassocAckTimer))
4145 {
4146 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004147 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004148 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4149 return;
4150 }
4151 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004152 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004153 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304154 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4155 psessionEntry->peSessionId,
4156 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004157 // Queue Disassociation frame in high priority WQ
4158 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4159 HAL_TXRX_FRM_802_11_MGMT,
4160 ANI_TXDIR_TODS,
4161 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4162 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304163 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4164 psessionEntry->peSessionId,
4165 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004166 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4167 {
4168 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004169 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004170 nSirStatus );
4171 //Pkt will be freed up by the callback
4172 return;
4173 }
4174 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004175} // End limSendDisassocMgmtFrame.
4176
4177/**
4178 * \brief This function is called to send a Deauthenticate frame
4179 *
4180 *
4181 * \param pMac Pointer to global MAC structure
4182 *
4183 * \param nReason Indicates the reason that need to be sent in the
4184 * Deauthenticate frame
4185 *
4186 * \param peeer address of the STA to which the frame is to be sent
4187 *
4188 *
4189 */
4190
4191void
4192limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
4193 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004194 tSirMacAddr peer,
4195 tpPESession psessionEntry,
4196 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004197{
4198 tDot11fDeAuth frm;
4199 tANI_U8 *pFrame;
4200 tSirRetStatus nSirStatus;
4201 tpSirMacMgmtHdr pMacHdr;
4202 tANI_U32 nBytes, nPayload, nStatus;
4203 void *pPacket;
4204 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304205 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004206 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004207#ifdef FEATURE_WLAN_TDLS
4208 tANI_U16 aid;
4209 tpDphHashNode pStaDs;
4210#endif
4211
Jeff Johnson295189b2012-06-20 16:38:30 -07004212 if(NULL == psessionEntry)
4213 {
4214 return;
4215 }
4216
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304217 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004218
4219 frm.Reason.code = nReason;
4220
4221 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
4222 if ( DOT11F_FAILED( nStatus ) )
4223 {
4224 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004225 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004226 nStatus );
4227 // We'll fall back on the worst case scenario:
4228 nPayload = sizeof( tDot11fDeAuth );
4229 }
4230 else if ( DOT11F_WARNED( nStatus ) )
4231 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004232 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004233 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004234 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004235 }
4236
4237 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4238
4239 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4240 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4241 ( void** ) &pPacket );
4242 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4243 {
4244 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004245 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004246 return;
4247 }
4248
4249 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304250 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004251
4252 // Next, we fill out the buffer descriptor:
4253 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4254 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
4255 if ( eSIR_SUCCESS != nSirStatus )
4256 {
4257 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004258 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004259 nSirStatus );
4260 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4261 ( void* ) pFrame, ( void* ) pPacket );
4262 return; // just allocated...
4263 }
4264
4265 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4266
4267 // Prepare the BSSID
4268 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4269
Chet Lanctot186b5732013-03-18 10:26:30 -07004270#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004271 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004272#endif
4273
Jeff Johnson295189b2012-06-20 16:38:30 -07004274 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
4275 sizeof(tSirMacMgmtHdr),
4276 nPayload, &nPayload );
4277 if ( DOT11F_FAILED( nStatus ) )
4278 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004279 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004280 nStatus );
4281 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4282 ( void* ) pFrame, ( void* ) pPacket );
4283 return;
4284 }
4285 else if ( DOT11F_WARNED( nStatus ) )
4286 {
4287 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004288 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004289 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05304290 limLog( pMac, LOG1, FL("***Sessionid %d Sending Deauth frame with "
4291 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4292 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4293 MAC_ADDR_ARRAY(pMacHdr->da),
4294 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004295
4296 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004297 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4298 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004299 )
4300 {
4301 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4302 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004303
Ganesh K08bce952012-12-13 15:04:41 -08004304 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304305 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
4306 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08004307 {
4308 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4309 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004310
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304311 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4312 {
4313 /* This frame will be sent on air by firmware,
4314 which will ensure that this frame goes out
4315 even though DEL_STA is sent immediately */
4316 /* Without this for DEL_STA command there is
4317 risk of flushing frame in BTQM queue without
4318 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304319 limLog( pMac, LOG1, FL("Sending Deauth Frame over WQ5 to "MAC_ADDRESS_STR
4320 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4321 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304322 txFlag |= HAL_USE_FW_IN_TX_PATH;
4323 }
4324
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004325#ifdef FEATURE_WLAN_TDLS
4326 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
4327#endif
4328
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004329 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004330 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304331 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4332 psessionEntry->peSessionId,
4333 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004334 // Queue Disassociation frame in high priority WQ
4335 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4336 HAL_TXRX_FRM_802_11_MGMT,
4337 ANI_TXDIR_TODS,
4338 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4339 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304340 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4341 psessionEntry->peSessionId,
4342 halstatus));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304343 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004344 {
4345 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304346 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004347 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08004348 //Pkt will be freed up by the callback limTxComplete
4349
4350 /*Call limProcessDeauthAckTimeout which will send
4351 * DeauthCnf for this frame
4352 */
4353 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004354 return;
4355 }
4356
4357 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
4358
4359 if (tx_timer_change(
4360 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
4361 != TX_SUCCESS)
4362 {
4363 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004364 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004365 return;
4366 }
4367 else if(TX_SUCCESS != tx_timer_activate(
4368 &pMac->lim.limTimers.gLimDeauthAckTimer))
4369 {
4370 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004371 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004372 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4373 return;
4374 }
4375 }
4376 else
4377 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304378 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4379 psessionEntry->peSessionId,
4380 pMacHdr->fc.subType));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004381#ifdef FEATURE_WLAN_TDLS
4382 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4383 {
4384 // Queue Disassociation frame in high priority WQ
4385 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004386 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004387 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004388 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4389 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004390 }
4391 else
4392 {
4393#endif
4394 // Queue Disassociation frame in high priority WQ
4395 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4396 HAL_TXRX_FRM_802_11_MGMT,
4397 ANI_TXDIR_TODS,
4398 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4399 limTxComplete, pFrame, txFlag );
4400#ifdef FEATURE_WLAN_TDLS
4401 }
4402#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304403 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4404 psessionEntry->peSessionId,
4405 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004406 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4407 {
4408 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004409 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004410 nSirStatus );
4411 //Pkt will be freed up by the callback
4412 return;
4413 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004414 }
4415
4416} // End limSendDeauthMgmtFrame.
4417
4418
4419#ifdef ANI_SUPPORT_11H
4420/**
4421 * \brief Send a Measurement Report Action frame
4422 *
4423 *
4424 * \param pMac Pointer to the global MAC structure
4425 *
4426 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4427 *
4428 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4429 *
4430 *
4431 */
4432
4433tSirRetStatus
4434limSendMeasReportFrame(tpAniSirGlobal pMac,
4435 tpSirMacMeasReqActionFrame pMeasReqFrame,
4436 tSirMacAddr peer)
4437{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304438 tDot11fMeasurementReport frm;
4439 tANI_U8 *pFrame;
4440 tSirRetStatus nSirStatus;
4441 tpSirMacMgmtHdr pMacHdr;
4442 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4443 void *pPacket;
4444 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004445
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304446 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004447
4448 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4449 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4450 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4451
4452 switch ( pMeasReqFrame->measReqIE.measType )
4453 {
4454 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4455 nSirStatus =
4456 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4457 &frm.MeasurementReport );
4458 break;
4459 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4460 nSirStatus =
4461 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4462 &frm.MeasurementReport );
4463 break;
4464 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4465 nSirStatus =
4466 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4467 &frm.MeasurementReport );
4468 break;
4469 default:
4470 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004471 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004472 pMeasReqFrame->measReqIE.measType );
4473 return eSIR_FAILURE;
4474 }
4475
4476 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4477
4478 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4479 if ( DOT11F_FAILED( nStatus ) )
4480 {
4481 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004482 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004483 nStatus );
4484 // We'll fall back on the worst case scenario:
4485 nPayload = sizeof( tDot11fMeasurementReport );
4486 }
4487 else if ( DOT11F_WARNED( nStatus ) )
4488 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004489 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004490 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004491 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004492 }
4493
4494 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4495
4496 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4497 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4498 {
4499 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004500 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004501 return eSIR_FAILURE;
4502 }
4503
4504 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304505 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004506
4507 // Next, we fill out the buffer descriptor:
4508 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4509 SIR_MAC_MGMT_ACTION, peer);
4510 if ( eSIR_SUCCESS != nSirStatus )
4511 {
4512 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004513 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004514 nSirStatus );
4515 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4516 return eSIR_FAILURE; // just allocated...
4517 }
4518
4519 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4520
4521 nCfg = 6;
4522 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4523 if ( eSIR_SUCCESS != nSirStatus )
4524 {
4525 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004526 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004527 nSirStatus );
4528 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4529 return eSIR_FAILURE; // just allocated...
4530 }
4531
Chet Lanctot186b5732013-03-18 10:26:30 -07004532#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004533 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004534#endif
4535
Jeff Johnson295189b2012-06-20 16:38:30 -07004536 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4537 sizeof(tSirMacMgmtHdr),
4538 nPayload, &nPayload );
4539 if ( DOT11F_FAILED( nStatus ) )
4540 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004541 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004542 nStatus );
4543 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4544 return eSIR_FAILURE; // allocated!
4545 }
4546 else if ( DOT11F_WARNED( nStatus ) )
4547 {
4548 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004549 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004550 }
4551
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304552 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4553 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4554 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004555 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4556 HAL_TXRX_FRM_802_11_MGMT,
4557 ANI_TXDIR_TODS,
4558 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4559 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304560 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4561 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4562 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004563 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4564 {
4565 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004566 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004567 nSirStatus );
4568 //Pkt will be freed up by the callback
4569 return eSIR_FAILURE; // just allocated...
4570 }
4571
4572 return eSIR_SUCCESS;
4573
4574} // End limSendMeasReportFrame.
4575
4576
4577/**
4578 * \brief Send a TPC Request Action frame
4579 *
4580 *
4581 * \param pMac Pointer to the global MAC datastructure
4582 *
4583 * \param peer MAC address to which the frame should be sent
4584 *
4585 *
4586 */
4587
4588void
4589limSendTpcRequestFrame(tpAniSirGlobal pMac,
4590 tSirMacAddr peer)
4591{
4592 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304593 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004594 tSirRetStatus nSirStatus;
4595 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304596 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4597 void *pPacket;
4598 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004599
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304600 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004601
4602 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4603 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4604 frm.DialogToken.token = 1;
4605 frm.TPCRequest.present = 1;
4606
4607 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4608 if ( DOT11F_FAILED( nStatus ) )
4609 {
4610 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004611 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004612 nStatus );
4613 // We'll fall back on the worst case scenario:
4614 nPayload = sizeof( tDot11fTPCRequest );
4615 }
4616 else if ( DOT11F_WARNED( nStatus ) )
4617 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004618 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004619 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004620 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004621 }
4622
4623 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4624
4625 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4626 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4627 {
4628 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004629 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004630 return;
4631 }
4632
4633 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304634 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004635
4636 // Next, we fill out the buffer descriptor:
4637 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4638 SIR_MAC_MGMT_ACTION, peer);
4639 if ( eSIR_SUCCESS != nSirStatus )
4640 {
4641 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004642 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004643 nSirStatus );
4644 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4645 return; // just allocated...
4646 }
4647
4648 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4649
4650 nCfg = 6;
4651 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4652 if ( eSIR_SUCCESS != nSirStatus )
4653 {
4654 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004655 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004656 nSirStatus );
4657 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4658 return; // just allocated...
4659 }
4660
Chet Lanctot186b5732013-03-18 10:26:30 -07004661#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004662 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004663#endif
4664
Jeff Johnson295189b2012-06-20 16:38:30 -07004665 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4666 sizeof(tSirMacMgmtHdr),
4667 nPayload, &nPayload );
4668 if ( DOT11F_FAILED( nStatus ) )
4669 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004670 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004671 nStatus );
4672 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4673 return; // allocated!
4674 }
4675 else if ( DOT11F_WARNED( nStatus ) )
4676 {
4677 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004678 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004679 }
4680
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304681 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4682 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4683 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004684 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4685 HAL_TXRX_FRM_802_11_MGMT,
4686 ANI_TXDIR_TODS,
4687 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4688 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304689 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4690 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4691 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004692 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4693 {
4694 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004695 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004696 nSirStatus );
4697 //Pkt will be freed up by the callback
4698 return;
4699 }
4700
4701} // End limSendTpcRequestFrame.
4702
4703
4704/**
4705 * \brief Send a TPC Report Action frame
4706 *
4707 *
4708 * \param pMac Pointer to the global MAC datastructure
4709 *
4710 * \param pTpcReqFrame Pointer to the received TPC Request
4711 *
4712 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4713 *
4714 *
4715 */
4716
4717tSirRetStatus
4718limSendTpcReportFrame(tpAniSirGlobal pMac,
4719 tpSirMacTpcReqActionFrame pTpcReqFrame,
4720 tSirMacAddr peer)
4721{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304722 tDot11fTPCReport frm;
4723 tANI_U8 *pFrame;
4724 tSirRetStatus nSirStatus;
4725 tpSirMacMgmtHdr pMacHdr;
4726 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4727 void *pPacket;
4728 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004729
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304730 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004731
4732 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4733 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4734 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4735
4736 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4737 // "misplaced this function, need to replace:
4738 // txPower = halGetRateToPwrValue(pMac, staid,
4739 // pMac->lim.gLimCurrentChannelId, 0);
4740 frm.TPCReport.tx_power = 0;
4741 frm.TPCReport.link_margin = 0;
4742 frm.TPCReport.present = 1;
4743
4744 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4745 if ( DOT11F_FAILED( nStatus ) )
4746 {
4747 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004748 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004749 nStatus );
4750 // We'll fall back on the worst case scenario:
4751 nPayload = sizeof( tDot11fTPCReport );
4752 }
4753 else if ( DOT11F_WARNED( nStatus ) )
4754 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004755 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004756 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004757 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004758 }
4759
4760 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4761
4762 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4763 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4764 {
4765 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004766 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004767 return eSIR_FAILURE;
4768 }
4769
4770 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304771 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004772
4773 // Next, we fill out the buffer descriptor:
4774 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4775 SIR_MAC_MGMT_ACTION, peer);
4776 if ( eSIR_SUCCESS != nSirStatus )
4777 {
4778 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004779 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004780 nSirStatus );
4781 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4782 return eSIR_FAILURE; // just allocated...
4783 }
4784
4785 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4786
4787 nCfg = 6;
4788 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4789 if ( eSIR_SUCCESS != nSirStatus )
4790 {
4791 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004792 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004793 nSirStatus );
4794 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4795 return eSIR_FAILURE; // just allocated...
4796 }
4797
Chet Lanctot186b5732013-03-18 10:26:30 -07004798#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004799 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004800#endif
4801
Jeff Johnson295189b2012-06-20 16:38:30 -07004802 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4803 sizeof(tSirMacMgmtHdr),
4804 nPayload, &nPayload );
4805 if ( DOT11F_FAILED( nStatus ) )
4806 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004807 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004808 nStatus );
4809 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4810 return eSIR_FAILURE; // allocated!
4811 }
4812 else if ( DOT11F_WARNED( nStatus ) )
4813 {
4814 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004815 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004816 }
4817
4818
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304819 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4820 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4821 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004822 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4823 HAL_TXRX_FRM_802_11_MGMT,
4824 ANI_TXDIR_TODS,
4825 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4826 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304827 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4828 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4829 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004830 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4831 {
4832 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004833 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004834 nSirStatus );
4835 //Pkt will be freed up by the callback
4836 return eSIR_FAILURE; // just allocated...
4837 }
4838
4839 return eSIR_SUCCESS;
4840
4841} // End limSendTpcReportFrame.
4842#endif //ANI_SUPPORT_11H
4843
4844
Jeff Johnson295189b2012-06-20 16:38:30 -07004845/**
4846 * \brief Send a Channel Switch Announcement
4847 *
4848 *
4849 * \param pMac Pointer to the global MAC datastructure
4850 *
4851 * \param peer MAC address to which this frame will be sent
4852 *
4853 * \param nMode
4854 *
4855 * \param nNewChannel
4856 *
4857 * \param nCount
4858 *
4859 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4860 *
4861 *
4862 */
4863
4864tSirRetStatus
4865limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4866 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004867 tANI_U8 nMode,
4868 tANI_U8 nNewChannel,
4869 tANI_U8 nCount,
4870 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004871{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304872 tDot11fChannelSwitch frm;
4873 tANI_U8 *pFrame;
4874 tSirRetStatus nSirStatus;
4875 tpSirMacMgmtHdr pMacHdr;
4876 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4877 void *pPacket;
4878 eHalStatus halstatus;
4879 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004880
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304881 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004882
4883 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4884 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4885 frm.ChanSwitchAnn.switchMode = nMode;
4886 frm.ChanSwitchAnn.newChannel = nNewChannel;
4887 frm.ChanSwitchAnn.switchCount = nCount;
4888 frm.ChanSwitchAnn.present = 1;
4889
4890 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4891 if ( DOT11F_FAILED( nStatus ) )
4892 {
4893 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004894 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004895 nStatus );
4896 // We'll fall back on the worst case scenario:
4897 nPayload = sizeof( tDot11fChannelSwitch );
4898 }
4899 else if ( DOT11F_WARNED( nStatus ) )
4900 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004901 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004902 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004903 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004904 }
4905
4906 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4907
4908 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4909 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4910 {
4911 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004912 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004913 return eSIR_FAILURE;
4914 }
4915
4916 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304917 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004918
4919 // Next, we fill out the buffer descriptor:
4920 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004921 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4922 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304923 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4924 (tANI_U8 *) psessionEntry->bssId,
4925 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004926 if ( eSIR_SUCCESS != nSirStatus )
4927 {
4928 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004929 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004930 nSirStatus );
4931 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4932 return eSIR_FAILURE; // just allocated...
4933 }
4934
Jeff Johnsone7245742012-09-05 17:12:55 -07004935#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004936 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4937
4938 nCfg = 6;
4939 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4940 if ( eSIR_SUCCESS != nSirStatus )
4941 {
4942 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004943 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004944 nSirStatus );
4945 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4946 return eSIR_FAILURE; // just allocated...
4947 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004948#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004949
4950#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004951 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004952#endif
4953
Jeff Johnson295189b2012-06-20 16:38:30 -07004954 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4955 sizeof(tSirMacMgmtHdr),
4956 nPayload, &nPayload );
4957 if ( DOT11F_FAILED( nStatus ) )
4958 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004959 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004960 nStatus );
4961 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4962 return eSIR_FAILURE; // allocated!
4963 }
4964 else if ( DOT11F_WARNED( nStatus ) )
4965 {
4966 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004967 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004968 }
4969
Jeff Johnsone7245742012-09-05 17:12:55 -07004970 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004971 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4972 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004973 )
4974 {
4975 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4976 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304977
4978 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4979 psessionEntry->peSessionId,
4980 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004981 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4982 HAL_TXRX_FRM_802_11_MGMT,
4983 ANI_TXDIR_TODS,
4984 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004985 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304986 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4987 psessionEntry->peSessionId,
4988 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004989 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4990 {
4991 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004992 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004993 nSirStatus );
4994 //Pkt will be freed up by the callback
4995 return eSIR_FAILURE;
4996 }
4997
4998 return eSIR_SUCCESS;
4999
5000} // End limSendChannelSwitchMgmtFrame.
5001
Jeff Johnson295189b2012-06-20 16:38:30 -07005002
5003
Mohit Khanna4a70d262012-09-11 16:30:12 -07005004#ifdef WLAN_FEATURE_11AC
5005tSirRetStatus
5006limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
5007 tSirMacAddr peer,
5008 tANI_U8 nMode,
5009 tpPESession psessionEntry )
5010{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305011 tDot11fOperatingMode frm;
5012 tANI_U8 *pFrame;
5013 tSirRetStatus nSirStatus;
5014 tpSirMacMgmtHdr pMacHdr;
5015 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
5016 void *pPacket;
5017 eHalStatus halstatus;
5018 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07005019
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305020 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005021
5022 frm.Category.category = SIR_MAC_ACTION_VHT;
5023 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
5024 frm.OperatingMode.chanWidth = nMode;
5025 frm.OperatingMode.rxNSS = 0;
5026 frm.OperatingMode.rxNSSType = 0;
5027
5028 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
5029 if ( DOT11F_FAILED( nStatus ) )
5030 {
5031 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005032 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005033 nStatus );
5034 // We'll fall back on the worst case scenario:
5035 nPayload = sizeof( tDot11fOperatingMode);
5036 }
5037 else if ( DOT11F_WARNED( nStatus ) )
5038 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005039 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07005040 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005041 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005042 }
5043
5044 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5045
5046 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5047 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5048 {
5049 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005050 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005051 return eSIR_FAILURE;
5052 }
5053
5054 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305055 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005056
5057
5058 // Next, we fill out the buffer descriptor:
5059 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
5060 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5061 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5062 } else
5063 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5064 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
5065 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305066 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5067 (tANI_U8 *) psessionEntry->bssId,
5068 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005069 if ( eSIR_SUCCESS != nSirStatus )
5070 {
5071 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005072 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005073 nSirStatus );
5074 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5075 return eSIR_FAILURE; // just allocated...
5076 }
5077 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
5078 sizeof(tSirMacMgmtHdr),
5079 nPayload, &nPayload );
5080 if ( DOT11F_FAILED( nStatus ) )
5081 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005082 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005083 nStatus );
5084 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5085 return eSIR_FAILURE; // allocated!
5086 }
5087 else if ( DOT11F_WARNED( nStatus ) )
5088 {
5089 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005090 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005091 }
5092 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07005093 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5094 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07005095 )
5096 {
5097 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5098 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305099
5100 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5101 psessionEntry->peSessionId,
5102 pMacHdr->fc.subType));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005103 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5104 HAL_TXRX_FRM_802_11_MGMT,
5105 ANI_TXDIR_TODS,
5106 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5107 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305108 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5109 psessionEntry->peSessionId,
5110 halstatus));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005111 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5112 {
5113 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005114 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005115 nSirStatus );
5116 //Pkt will be freed up by the callback
5117 return eSIR_FAILURE;
5118 }
5119
5120 return eSIR_SUCCESS;
5121}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005122
5123/**
5124 * \brief Send a VHT Channel Switch Announcement
5125 *
5126 *
5127 * \param pMac Pointer to the global MAC datastructure
5128 *
5129 * \param peer MAC address to which this frame will be sent
5130 *
5131 * \param nChanWidth
5132 *
5133 * \param nNewChannel
5134 *
5135 *
5136 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5137 *
5138 *
5139 */
5140
5141tSirRetStatus
5142limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5143 tSirMacAddr peer,
5144 tANI_U8 nChanWidth,
5145 tANI_U8 nNewChannel,
5146 tANI_U8 ncbMode,
5147 tpPESession psessionEntry )
5148{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305149 tDot11fChannelSwitch frm;
5150 tANI_U8 *pFrame;
5151 tSirRetStatus nSirStatus;
5152 tpSirMacMgmtHdr pMacHdr;
5153 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5154 void *pPacket;
5155 eHalStatus halstatus;
5156 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005157
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305158 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005159
5160
5161 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5162 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5163 frm.ChanSwitchAnn.switchMode = 1;
5164 frm.ChanSwitchAnn.newChannel = nNewChannel;
5165 frm.ChanSwitchAnn.switchCount = 1;
5166 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
5167 frm.ExtChanSwitchAnn.present = 1;
5168 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
5169 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
5170 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
5171 frm.ChanSwitchAnn.present = 1;
5172 frm.WiderBWChanSwitchAnn.present = 1;
5173
5174 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5175 if ( DOT11F_FAILED( nStatus ) )
5176 {
5177 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005178 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005179 nStatus );
5180 // We'll fall back on the worst case scenario:
5181 nPayload = sizeof( tDot11fChannelSwitch );
5182 }
5183 else if ( DOT11F_WARNED( nStatus ) )
5184 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005185 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005186 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005187 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005188 }
5189
5190 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5191
5192 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5193 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5194 {
5195 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005196 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005197 return eSIR_FAILURE;
5198 }
5199 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305200 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005201
5202 // Next, we fill out the buffer descriptor:
5203 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5204 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5205 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305206 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5207 (tANI_U8 *) psessionEntry->bssId,
5208 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005209 if ( eSIR_SUCCESS != nSirStatus )
5210 {
5211 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005212 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005213 nSirStatus );
5214 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5215 return eSIR_FAILURE; // just allocated...
5216 }
5217 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5218 sizeof(tSirMacMgmtHdr),
5219 nPayload, &nPayload );
5220 if ( DOT11F_FAILED( nStatus ) )
5221 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005222 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005223 nStatus );
5224 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5225 return eSIR_FAILURE; // allocated!
5226 }
5227 else if ( DOT11F_WARNED( nStatus ) )
5228 {
5229 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005230 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005231 }
5232
5233 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005234 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5235 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005236 )
5237 {
5238 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5239 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305240
5241 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5242 psessionEntry->peSessionId,
5243 pMacHdr->fc.subType));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005244 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5245 HAL_TXRX_FRM_802_11_MGMT,
5246 ANI_TXDIR_TODS,
5247 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5248 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305249 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5250 psessionEntry->peSessionId,
5251 halstatus));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005252 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5253 {
5254 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005255 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005256 nSirStatus );
5257 //Pkt will be freed up by the callback
5258 return eSIR_FAILURE;
5259 }
5260
5261 return eSIR_SUCCESS;
5262
5263} // End limSendVHTChannelSwitchMgmtFrame.
5264
5265
5266
Mohit Khanna4a70d262012-09-11 16:30:12 -07005267#endif
5268
Jeff Johnson295189b2012-06-20 16:38:30 -07005269/**
5270 * \brief Send an ADDBA Req Action Frame to peer
5271 *
5272 * \sa limSendAddBAReq
5273 *
5274 * \param pMac The global tpAniSirGlobal object
5275 *
5276 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
5277 * the necessary parameters reqd by PE send the ADDBA Req Action
5278 * Frame to the peer
5279 *
5280 * \return eSIR_SUCCESS if setup completes successfully
5281 * eSIR_FAILURE is some problem is encountered
5282 */
5283tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305284 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07005285{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305286 tDot11fAddBAReq frmAddBAReq;
5287 tANI_U8 *pAddBAReqBuffer = NULL;
5288 tpSirMacMgmtHdr pMacHdr;
5289 tANI_U32 frameLen = 0, nStatus, nPayload;
5290 tSirRetStatus statusCode;
5291 eHalStatus halStatus;
5292 void *pPacket;
5293 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005294
5295 if(NULL == psessionEntry)
5296 {
5297 return eSIR_FAILURE;
5298 }
5299
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305300 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005301
5302 // Category - 3 (BA)
5303 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
5304
5305 // Action - 0 (ADDBA Req)
5306 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
5307
5308 // FIXME - Dialog Token, generalize this...
5309 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
5310
5311 // Fill the ADDBA Parameter Set
5312 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
5313 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
5314 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
5315
5316 // BA timeout
5317 // 0 - indicates no BA timeout
5318 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
5319
5320 // BA Starting Sequence Number
5321 // Fragment number will always be zero
5322 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
5323 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
5324 }
5325
5326 frmAddBAReq.BAStartingSequenceControl.ssn =
5327 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
5328
5329 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
5330
5331 if( DOT11F_FAILED( nStatus ))
5332 {
5333 limLog( pMac, LOGW,
5334 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005335 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005336 nStatus );
5337
5338 // We'll fall back on the worst case scenario:
5339 nPayload = sizeof( tDot11fAddBAReq );
5340 }
5341 else if( DOT11F_WARNED( nStatus ))
5342 {
5343 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005344 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005345 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005346 nStatus );
5347 }
5348
5349 // Add the MGMT header to frame length
5350 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5351
5352 // Need to allocate a buffer for ADDBA AF
5353 if( eHAL_STATUS_SUCCESS !=
5354 (halStatus = palPktAlloc( pMac->hHdd,
5355 HAL_TXRX_FRM_802_11_MGMT,
5356 (tANI_U16) frameLen,
5357 (void **) &pAddBAReqBuffer,
5358 (void **) &pPacket )))
5359 {
5360 // Log error
5361 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005362 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005363 frameLen,
5364 halStatus );
5365
5366 statusCode = eSIR_MEM_ALLOC_FAILED;
5367 goto returnAfterError;
5368 }
5369
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305370 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005371
5372 // Copy necessary info to BD
5373 if( eSIR_SUCCESS !=
5374 (statusCode = limPopulateMacHeader( pMac,
5375 pAddBAReqBuffer,
5376 SIR_MAC_MGMT_FRAME,
5377 SIR_MAC_MGMT_ACTION,
5378 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5379 goto returnAfterError;
5380
5381 // Update A3 with the BSSID
5382 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
5383
5384 #if 0
5385 cfgLen = SIR_MAC_ADDR_LENGTH;
5386 if( eSIR_SUCCESS != cfgGetStr( pMac,
5387 WNI_CFG_BSSID,
5388 (tANI_U8 *) pMacHdr->bssId,
5389 &cfgLen ))
5390 {
5391 limLog( pMac, LOGP,
5392 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005393 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005394
5395 // FIXME - Need to convert to tSirRetStatus
5396 statusCode = eSIR_FAILURE;
5397 goto returnAfterError;
5398 }
5399 #endif//TO SUPPORT BT-AMP
5400 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5401
Chet Lanctot186b5732013-03-18 10:26:30 -07005402#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005403 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005404#endif
5405
Jeff Johnson295189b2012-06-20 16:38:30 -07005406 // Now, we're ready to "pack" the frames
5407 nStatus = dot11fPackAddBAReq( pMac,
5408 &frmAddBAReq,
5409 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5410 nPayload,
5411 &nPayload );
5412
5413 if( DOT11F_FAILED( nStatus ))
5414 {
5415 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005416 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005417 nStatus );
5418
5419 // FIXME - Need to convert to tSirRetStatus
5420 statusCode = eSIR_FAILURE;
5421 goto returnAfterError;
5422 }
5423 else if( DOT11F_WARNED( nStatus ))
5424 {
5425 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005426 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5427 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005428 }
5429
5430 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005431 FL( "Sending an ADDBA REQ to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005432 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
5433
5434 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005435 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5436 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005437 )
5438 {
5439 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5440 }
5441
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305442 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5443 psessionEntry->peSessionId,
5444 pMacHdr->fc.subType));
5445 halStatus = halTxFrame( pMac,
5446 pPacket,
5447 (tANI_U16) frameLen,
5448 HAL_TXRX_FRM_802_11_MGMT,
5449 ANI_TXDIR_TODS,
5450 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5451 limTxComplete,
5452 pAddBAReqBuffer, txFlag );
5453 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5454 psessionEntry->peSessionId,
5455 halStatus));
5456 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005457 {
5458 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005459 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005460 halStatus );
5461
5462 // FIXME - Need to convert eHalStatus to tSirRetStatus
5463 statusCode = eSIR_FAILURE;
5464 //Pkt will be freed up by the callback
5465 return statusCode;
5466 }
5467 else
5468 return eSIR_SUCCESS;
5469
5470returnAfterError:
5471
5472 // Release buffer, if allocated
5473 if( NULL != pAddBAReqBuffer )
5474 palPktFree( pMac->hHdd,
5475 HAL_TXRX_FRM_802_11_MGMT,
5476 (void *) pAddBAReqBuffer,
5477 (void *) pPacket );
5478
5479 return statusCode;
5480}
5481
5482/**
5483 * \brief Send an ADDBA Rsp Action Frame to peer
5484 *
5485 * \sa limSendAddBARsp
5486 *
5487 * \param pMac The global tpAniSirGlobal object
5488 *
5489 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5490 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5491 * Frame to the peer
5492 *
5493 * \return eSIR_SUCCESS if setup completes successfully
5494 * eSIR_FAILURE is some problem is encountered
5495 */
5496tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5497 tpLimMlmAddBARsp pMlmAddBARsp,
5498 tpPESession psessionEntry)
5499{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305500 tDot11fAddBARsp frmAddBARsp;
5501 tANI_U8 *pAddBARspBuffer = NULL;
5502 tpSirMacMgmtHdr pMacHdr;
5503 tANI_U32 frameLen = 0, nStatus, nPayload;
5504 tSirRetStatus statusCode;
5505 eHalStatus halStatus;
5506 void *pPacket;
5507 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005508
5509 if(NULL == psessionEntry)
5510 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005511 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005512 return eSIR_FAILURE;
5513 }
5514
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305515 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005516
5517 // Category - 3 (BA)
5518 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5519 // Action - 1 (ADDBA Rsp)
5520 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5521
5522 // Should be same as the one we received in the ADDBA Req
5523 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5524
5525 // ADDBA Req status
5526 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5527
5528 // Fill the ADDBA Parameter Set as provided by caller
5529 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5530 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5531 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005532
5533 if(psessionEntry->isAmsduSupportInAMPDU)
5534 {
5535 frmAddBARsp.AddBAParameterSet.amsduSupported =
5536 psessionEntry->amsduSupportedInBA;
5537 }
5538 else
5539 {
5540 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5541 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005542
5543 // BA timeout
5544 // 0 - indicates no BA timeout
5545 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5546
5547 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5548
5549 if( DOT11F_FAILED( nStatus ))
5550 {
5551 limLog( pMac, LOGW,
5552 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005553 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005554 nStatus );
5555
5556 // We'll fall back on the worst case scenario:
5557 nPayload = sizeof( tDot11fAddBARsp );
5558 }
5559 else if( DOT11F_WARNED( nStatus ))
5560 {
5561 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005562 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005563 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005564 nStatus );
5565 }
5566
5567 // Need to allocate a buffer for ADDBA AF
5568 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5569
5570 // Allocate shared memory
5571 if( eHAL_STATUS_SUCCESS !=
5572 (halStatus = palPktAlloc( pMac->hHdd,
5573 HAL_TXRX_FRM_802_11_MGMT,
5574 (tANI_U16) frameLen,
5575 (void **) &pAddBARspBuffer,
5576 (void **) &pPacket )))
5577 {
5578 // Log error
5579 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005580 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005581 frameLen,
5582 halStatus );
5583
5584 statusCode = eSIR_MEM_ALLOC_FAILED;
5585 goto returnAfterError;
5586 }
5587
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305588 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005589
5590 // Copy necessary info to BD
5591 if( eSIR_SUCCESS !=
5592 (statusCode = limPopulateMacHeader( pMac,
5593 pAddBARspBuffer,
5594 SIR_MAC_MGMT_FRAME,
5595 SIR_MAC_MGMT_ACTION,
5596 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5597 goto returnAfterError;
5598
5599 // Update A3 with the BSSID
5600
5601 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5602
5603 #if 0
5604 cfgLen = SIR_MAC_ADDR_LENGTH;
5605 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5606 WNI_CFG_BSSID,
5607 (tANI_U8 *) pMacHdr->bssId,
5608 &cfgLen ))
5609 {
5610 limLog( pMac, LOGP,
5611 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005612 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005613
5614 // FIXME - Need to convert to tSirRetStatus
5615 statusCode = eSIR_FAILURE;
5616 goto returnAfterError;
5617 }
5618 #endif // TO SUPPORT BT-AMP
5619 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5620
Chet Lanctot186b5732013-03-18 10:26:30 -07005621#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005622 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005623#endif
5624
Jeff Johnson295189b2012-06-20 16:38:30 -07005625 // Now, we're ready to "pack" the frames
5626 nStatus = dot11fPackAddBARsp( pMac,
5627 &frmAddBARsp,
5628 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5629 nPayload,
5630 &nPayload );
5631
5632 if( DOT11F_FAILED( nStatus ))
5633 {
5634 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005635 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005636 nStatus );
5637
5638 // FIXME - Need to convert to tSirRetStatus
5639 statusCode = eSIR_FAILURE;
5640 goto returnAfterError;
5641 }
5642 else if( DOT11F_WARNED( nStatus ))
5643 {
5644 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005645 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5646 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005647 }
5648
5649 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005650 FL( "Sending an ADDBA RSP to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005651 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5652
5653 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005654 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5655 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005656 )
5657 {
5658 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5659 }
5660
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305661 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5662 psessionEntry->peSessionId,
5663 pMacHdr->fc.subType));
5664 halStatus = halTxFrame( pMac,
5665 pPacket,
5666 (tANI_U16) frameLen,
5667 HAL_TXRX_FRM_802_11_MGMT,
5668 ANI_TXDIR_TODS,
5669 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5670 limTxComplete,
5671 pAddBARspBuffer, txFlag );
5672 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5673 psessionEntry->peSessionId,
5674 halStatus));
5675 if( eHAL_STATUS_SUCCESS != halStatus )
5676 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005677 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005678 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005679 halStatus );
5680
5681 // FIXME - HAL error codes are different from PE error
5682 // codes!! And, this routine is returning tSirRetStatus
5683 statusCode = eSIR_FAILURE;
5684 //Pkt will be freed up by the callback
5685 return statusCode;
5686 }
5687 else
5688 return eSIR_SUCCESS;
5689
5690 returnAfterError:
Jeff Johnson295189b2012-06-20 16:38:30 -07005691 // Release buffer, if allocated
5692 if( NULL != pAddBARspBuffer )
5693 palPktFree( pMac->hHdd,
5694 HAL_TXRX_FRM_802_11_MGMT,
5695 (void *) pAddBARspBuffer,
5696 (void *) pPacket );
5697
5698 return statusCode;
5699}
5700
5701/**
5702 * \brief Send a DELBA Indication Action Frame to peer
5703 *
5704 * \sa limSendDelBAInd
5705 *
5706 * \param pMac The global tpAniSirGlobal object
5707 *
5708 * \param peerMacAddr MAC Address of peer
5709 *
5710 * \param reasonCode Reason for the DELBA notification
5711 *
5712 * \param pBAParameterSet The DELBA Parameter Set.
5713 * This identifies the TID for which the BA session is
5714 * being deleted.
5715 *
5716 * \return eSIR_SUCCESS if setup completes successfully
5717 * eSIR_FAILURE is some problem is encountered
5718 */
5719tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5720 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5721{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305722 tDot11fDelBAInd frmDelBAInd;
5723 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005724 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305725 tpSirMacMgmtHdr pMacHdr;
5726 tANI_U32 frameLen = 0, nStatus, nPayload;
5727 tSirRetStatus statusCode;
5728 eHalStatus halStatus;
5729 void *pPacket;
5730 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005731
5732 if(NULL == psessionEntry)
5733 {
5734 return eSIR_FAILURE;
5735 }
5736
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305737 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005738
5739 // Category - 3 (BA)
5740 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5741 // Action - 2 (DELBA)
5742 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5743
5744 // Fill the DELBA Parameter Set as provided by caller
5745 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5746 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5747
5748 // BA Starting Sequence Number
5749 // Fragment number will always be zero
5750 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5751
5752 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5753
5754 if( DOT11F_FAILED( nStatus ))
5755 {
5756 limLog( pMac, LOGW,
5757 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005758 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005759 nStatus );
5760
5761 // We'll fall back on the worst case scenario:
5762 nPayload = sizeof( tDot11fDelBAInd );
5763 }
5764 else if( DOT11F_WARNED( nStatus ))
5765 {
5766 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005767 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005768 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005769 nStatus );
5770 }
5771
5772 // Add the MGMT header to frame length
5773 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5774
5775 // Allocate shared memory
5776 if( eHAL_STATUS_SUCCESS !=
5777 (halStatus = palPktAlloc( pMac->hHdd,
5778 HAL_TXRX_FRM_802_11_MGMT,
5779 (tANI_U16) frameLen,
5780 (void **) &pDelBAIndBuffer,
5781 (void **) &pPacket )))
5782 {
5783 // Log error
5784 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005785 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005786 frameLen,
5787 halStatus );
5788
5789 statusCode = eSIR_MEM_ALLOC_FAILED;
5790 goto returnAfterError;
5791 }
5792
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305793 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005794
5795 // Copy necessary info to BD
5796 if( eSIR_SUCCESS !=
5797 (statusCode = limPopulateMacHeader( pMac,
5798 pDelBAIndBuffer,
5799 SIR_MAC_MGMT_FRAME,
5800 SIR_MAC_MGMT_ACTION,
5801 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5802 goto returnAfterError;
5803
5804 // Update A3 with the BSSID
5805 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5806
5807 #if 0
5808 cfgLen = SIR_MAC_ADDR_LENGTH;
5809 if( eSIR_SUCCESS != cfgGetStr( pMac,
5810 WNI_CFG_BSSID,
5811 (tANI_U8 *) pMacHdr->bssId,
5812 &cfgLen ))
5813 {
5814 limLog( pMac, LOGP,
5815 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005816 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005817
5818 // FIXME - Need to convert to tSirRetStatus
5819 statusCode = eSIR_FAILURE;
5820 goto returnAfterError;
5821 }
5822 #endif //TO SUPPORT BT-AMP
5823 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5824
Chet Lanctot186b5732013-03-18 10:26:30 -07005825#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005826 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005827#endif
5828
Jeff Johnson295189b2012-06-20 16:38:30 -07005829 // Now, we're ready to "pack" the frames
5830 nStatus = dot11fPackDelBAInd( pMac,
5831 &frmDelBAInd,
5832 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5833 nPayload,
5834 &nPayload );
5835
5836 if( DOT11F_FAILED( nStatus ))
5837 {
5838 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005839 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005840 nStatus );
5841
5842 // FIXME - Need to convert to tSirRetStatus
5843 statusCode = eSIR_FAILURE;
5844 goto returnAfterError;
5845 }
5846 else if( DOT11F_WARNED( nStatus ))
5847 {
5848 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005849 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
5850 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005851 }
5852
5853 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005854 FL( "Sending a DELBA IND to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005855 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5856
5857 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005858 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5859 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005860 )
5861 {
5862 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5863 }
5864
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305865 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5866 psessionEntry->peSessionId,
5867 pMacHdr->fc.subType));
5868 halStatus = halTxFrame( pMac,
5869 pPacket,
5870 (tANI_U16) frameLen,
5871 HAL_TXRX_FRM_802_11_MGMT,
5872 ANI_TXDIR_TODS,
5873 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5874 limTxComplete,
5875 pDelBAIndBuffer, txFlag );
5876 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5877 psessionEntry->peSessionId,
5878 halStatus));
5879 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005880 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005881 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005882 statusCode = eSIR_FAILURE;
5883 //Pkt will be freed up by the callback
5884 return statusCode;
5885 }
5886 else
5887 return eSIR_SUCCESS;
5888
5889 returnAfterError:
5890
5891 // Release buffer, if allocated
5892 if( NULL != pDelBAIndBuffer )
5893 palPktFree( pMac->hHdd,
5894 HAL_TXRX_FRM_802_11_MGMT,
5895 (void *) pDelBAIndBuffer,
5896 (void *) pPacket );
5897
5898 return statusCode;
5899}
5900
5901#if defined WLAN_FEATURE_VOWIFI
5902
5903/**
5904 * \brief Send a Neighbor Report Request Action frame
5905 *
5906 *
5907 * \param pMac Pointer to the global MAC structure
5908 *
5909 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5910 *
5911 * \param peer mac address of peer station.
5912 *
5913 * \param psessionEntry address of session entry.
5914 *
5915 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5916 *
5917 *
5918 */
5919
5920tSirRetStatus
5921limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5922 tpSirMacNeighborReportReq pNeighborReq,
5923 tSirMacAddr peer,
5924 tpPESession psessionEntry
5925 )
5926{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305927 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005928 tDot11fNeighborReportRequest frm;
5929 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305930 tpSirMacMgmtHdr pMacHdr;
5931 tANI_U32 nBytes, nPayload, nStatus;
5932 void *pPacket;
5933 eHalStatus halstatus;
5934 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005935
5936 if ( psessionEntry == NULL )
5937 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005938 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005939 return eSIR_FAILURE;
5940 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305941 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005942
5943 frm.Category.category = SIR_MAC_ACTION_RRM;
5944 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5945 frm.DialogToken.token = pNeighborReq->dialogToken;
5946
5947
5948 if( pNeighborReq->ssid_present )
5949 {
5950 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5951 }
5952
5953 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5954 if ( DOT11F_FAILED( nStatus ) )
5955 {
5956 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005957 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005958 nStatus );
5959 // We'll fall back on the worst case scenario:
5960 nPayload = sizeof( tDot11fNeighborReportRequest );
5961 }
5962 else if ( DOT11F_WARNED( nStatus ) )
5963 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005964 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005965 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005966 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005967 }
5968
5969 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5970
5971 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5972 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5973 {
5974 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005975 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005976 return eSIR_FAILURE;
5977 }
5978
5979 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305980 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005981
5982 // Copy necessary info to BD
5983 if( eSIR_SUCCESS !=
5984 (statusCode = limPopulateMacHeader( pMac,
5985 pFrame,
5986 SIR_MAC_MGMT_FRAME,
5987 SIR_MAC_MGMT_ACTION,
5988 peer, psessionEntry->selfMacAddr)))
5989 goto returnAfterError;
5990
5991 // Update A3 with the BSSID
5992 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5993
5994 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5995
Chet Lanctot186b5732013-03-18 10:26:30 -07005996#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005997 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005998#endif
5999
Jeff Johnson295189b2012-06-20 16:38:30 -07006000 // Now, we're ready to "pack" the frames
6001 nStatus = dot11fPackNeighborReportRequest( pMac,
6002 &frm,
6003 pFrame + sizeof( tSirMacMgmtHdr ),
6004 nPayload,
6005 &nPayload );
6006
6007 if( DOT11F_FAILED( nStatus ))
6008 {
6009 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006010 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006011 nStatus );
6012
6013 // FIXME - Need to convert to tSirRetStatus
6014 statusCode = eSIR_FAILURE;
6015 goto returnAfterError;
6016 }
6017 else if( DOT11F_WARNED( nStatus ))
6018 {
6019 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006020 FL( "There were warnings while packing Neighbor Report "
6021 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006022 }
6023
6024 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006025 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006026 limPrintMacAddr( pMac, peer, LOGW );
6027
6028 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006029 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6030 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006031 )
6032 {
6033 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6034 }
6035
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306036 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6037 psessionEntry->peSessionId,
6038 pMacHdr->fc.subType));
6039 halstatus = halTxFrame( pMac,
6040 pPacket,
6041 (tANI_U16) nBytes,
6042 HAL_TXRX_FRM_802_11_MGMT,
6043 ANI_TXDIR_TODS,
6044 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6045 limTxComplete,
6046 pFrame, txFlag );
6047 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6048 psessionEntry->peSessionId,
6049 halstatus));
6050 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006051 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006052 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006053 statusCode = eSIR_FAILURE;
6054 //Pkt will be freed up by the callback
6055 return statusCode;
6056 }
6057 else
6058 return eSIR_SUCCESS;
6059
6060returnAfterError:
6061 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6062
6063 return statusCode;
6064} // End limSendNeighborReportRequestFrame.
6065
6066/**
6067 * \brief Send a Link Report Action frame
6068 *
6069 *
6070 * \param pMac Pointer to the global MAC structure
6071 *
6072 * \param pLinkReport Address of a tSirMacLinkReport
6073 *
6074 * \param peer mac address of peer station.
6075 *
6076 * \param psessionEntry address of session entry.
6077 *
6078 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6079 *
6080 *
6081 */
6082
6083tSirRetStatus
6084limSendLinkReportActionFrame(tpAniSirGlobal pMac,
6085 tpSirMacLinkReport pLinkReport,
6086 tSirMacAddr peer,
6087 tpPESession psessionEntry
6088 )
6089{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306090 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006091 tDot11fLinkMeasurementReport frm;
6092 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306093 tpSirMacMgmtHdr pMacHdr;
6094 tANI_U32 nBytes, nPayload, nStatus;
6095 void *pPacket;
6096 eHalStatus halstatus;
6097 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006098
6099
6100 if ( psessionEntry == NULL )
6101 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006102 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006103 return eSIR_FAILURE;
6104 }
6105
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306106 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006107
6108 frm.Category.category = SIR_MAC_ACTION_RRM;
6109 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
6110 frm.DialogToken.token = pLinkReport->dialogToken;
6111
6112
6113 //IEEE Std. 802.11 7.3.2.18. for the report element.
6114 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
6115 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
6116 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
6117 //such case this way than changing the frame parser.
6118 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
6119 frm.TPCEleLen.TPCLen = 2;
6120 frm.TxPower.txPower = pLinkReport->txPower;
6121 frm.LinkMargin.linkMargin = 0;
6122
6123 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
6124 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
6125 frm.RCPI.rcpi = pLinkReport->rcpi;
6126 frm.RSNI.rsni = pLinkReport->rsni;
6127
6128 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
6129 if ( DOT11F_FAILED( nStatus ) )
6130 {
6131 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006132 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006133 nStatus );
6134 // We'll fall back on the worst case scenario:
6135 nPayload = sizeof( tDot11fLinkMeasurementReport );
6136 }
6137 else if ( DOT11F_WARNED( nStatus ) )
6138 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006139 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006140 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006141 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006142 }
6143
6144 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6145
6146 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6147 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6148 {
6149 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006150 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006151 return eSIR_FAILURE;
6152 }
6153
6154 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306155 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006156
6157 // Copy necessary info to BD
6158 if( eSIR_SUCCESS !=
6159 (statusCode = limPopulateMacHeader( pMac,
6160 pFrame,
6161 SIR_MAC_MGMT_FRAME,
6162 SIR_MAC_MGMT_ACTION,
6163 peer, psessionEntry->selfMacAddr)))
6164 goto returnAfterError;
6165
6166 // Update A3 with the BSSID
6167 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6168
6169 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6170
Chet Lanctot186b5732013-03-18 10:26:30 -07006171#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006172 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006173#endif
6174
Jeff Johnson295189b2012-06-20 16:38:30 -07006175 // Now, we're ready to "pack" the frames
6176 nStatus = dot11fPackLinkMeasurementReport( pMac,
6177 &frm,
6178 pFrame + sizeof( tSirMacMgmtHdr ),
6179 nPayload,
6180 &nPayload );
6181
6182 if( DOT11F_FAILED( nStatus ))
6183 {
6184 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006185 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006186 nStatus );
6187
6188 // FIXME - Need to convert to tSirRetStatus
6189 statusCode = eSIR_FAILURE;
6190 goto returnAfterError;
6191 }
6192 else if( DOT11F_WARNED( nStatus ))
6193 {
6194 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006195 FL( "There were warnings while packing Link Report (0x%08x)." ),
6196 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006197 }
6198
6199 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006200 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006201 limPrintMacAddr( pMac, peer, LOGW );
6202
6203 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006204 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6205 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006206 )
6207 {
6208 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6209 }
6210
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306211 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6212 psessionEntry->peSessionId,
6213 pMacHdr->fc.subType));
6214 halstatus = halTxFrame( pMac,
6215 pPacket,
6216 (tANI_U16) nBytes,
6217 HAL_TXRX_FRM_802_11_MGMT,
6218 ANI_TXDIR_TODS,
6219 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6220 limTxComplete,
6221 pFrame, txFlag );
6222 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6223 psessionEntry->peSessionId,
6224 halstatus));
6225 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006226 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006227 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006228 statusCode = eSIR_FAILURE;
6229 //Pkt will be freed up by the callback
6230 return statusCode;
6231 }
6232 else
6233 return eSIR_SUCCESS;
6234
6235returnAfterError:
6236 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6237
6238 return statusCode;
6239} // End limSendLinkReportActionFrame.
6240
6241/**
6242 * \brief Send a Beacon Report Action frame
6243 *
6244 *
6245 * \param pMac Pointer to the global MAC structure
6246 *
6247 * \param dialog_token dialog token to be used in the action frame.
6248 *
6249 * \param num_report number of reports in pRRMReport.
6250 *
6251 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
6252 *
6253 * \param peer mac address of peer station.
6254 *
6255 * \param psessionEntry address of session entry.
6256 *
6257 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6258 *
6259 *
6260 */
6261
6262tSirRetStatus
6263limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
6264 tANI_U8 dialog_token,
6265 tANI_U8 num_report,
6266 tpSirMacRadioMeasureReport pRRMReport,
6267 tSirMacAddr peer,
6268 tpPESession psessionEntry
6269 )
6270{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306271 tSirRetStatus statusCode = eSIR_SUCCESS;
6272 tANI_U8 *pFrame;
6273 tpSirMacMgmtHdr pMacHdr;
6274 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006275 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306276 eHalStatus halstatus;
6277 tANI_U8 i;
6278 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006279
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006280 tDot11fRadioMeasurementReport *frm =
6281 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
6282 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006283 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006284 return eSIR_FAILURE;
6285 }
6286
Jeff Johnson295189b2012-06-20 16:38:30 -07006287 if ( psessionEntry == NULL )
6288 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006289 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006290 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006291 return eSIR_FAILURE;
6292 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306293 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006294
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006295 frm->Category.category = SIR_MAC_ACTION_RRM;
6296 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
6297 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07006298
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006299 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 -07006300
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006301 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006302 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006303 frm->MeasurementReport[i].type = pRRMReport[i].type;
6304 frm->MeasurementReport[i].token = pRRMReport[i].token;
6305 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006306 switch( pRRMReport[i].type )
6307 {
6308 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006309 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
6310 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6311 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
6312 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006313 break;
6314 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05306315 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6316 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006317 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006318 break;
6319 }
6320 }
6321
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006322 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07006323 if ( DOT11F_FAILED( nStatus ) )
6324 {
6325 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006326 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006327 nStatus );
6328 // We'll fall back on the worst case scenario:
6329 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006330 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006331 return eSIR_FAILURE;
6332 }
6333 else if ( DOT11F_WARNED( nStatus ) )
6334 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006335 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006336 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006337 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006338 }
6339
6340 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6341
6342 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6343 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6344 {
6345 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006346 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006347 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006348 return eSIR_FAILURE;
6349 }
6350
6351 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306352 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006353
6354 // Copy necessary info to BD
6355 if( eSIR_SUCCESS !=
6356 (statusCode = limPopulateMacHeader( pMac,
6357 pFrame,
6358 SIR_MAC_MGMT_FRAME,
6359 SIR_MAC_MGMT_ACTION,
6360 peer, psessionEntry->selfMacAddr)))
6361 goto returnAfterError;
6362
6363 // Update A3 with the BSSID
6364 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6365
6366 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6367
Chet Lanctot186b5732013-03-18 10:26:30 -07006368#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006369 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006370#endif
6371
Jeff Johnson295189b2012-06-20 16:38:30 -07006372 // Now, we're ready to "pack" the frames
6373 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006374 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07006375 pFrame + sizeof( tSirMacMgmtHdr ),
6376 nPayload,
6377 &nPayload );
6378
6379 if( DOT11F_FAILED( nStatus ))
6380 {
6381 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006382 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006383 nStatus );
6384
6385 // FIXME - Need to convert to tSirRetStatus
6386 statusCode = eSIR_FAILURE;
6387 goto returnAfterError;
6388 }
6389 else if( DOT11F_WARNED( nStatus ))
6390 {
6391 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006392 FL( "There were warnings while packing Radio "
6393 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006394 }
6395
6396 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006397 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006398 limPrintMacAddr( pMac, peer, LOGW );
6399
6400 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006401 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6402 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006403 )
6404 {
6405 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6406 }
6407
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306408 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6409 psessionEntry->peSessionId,
6410 pMacHdr->fc.subType));
6411 halstatus = halTxFrame( pMac,
6412 pPacket,
6413 (tANI_U16) nBytes,
6414 HAL_TXRX_FRM_802_11_MGMT,
6415 ANI_TXDIR_TODS,
6416 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6417 limTxComplete,
6418 pFrame, txFlag );
6419 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6420 psessionEntry->peSessionId,
6421 halstatus));
6422 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006423 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006424 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006425 statusCode = eSIR_FAILURE;
6426 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006427 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006428 return statusCode;
6429 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006430 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006431 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006432 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006433 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006434
6435returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006436 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006437 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07006438 return statusCode;
6439} // End limSendBeaconReportActionFrame.
6440
6441#endif
6442
6443#ifdef WLAN_FEATURE_11W
6444/**
Chet Lanctot8cecea22014-02-11 19:09:36 -08006445 * \brief Send SA query request action frame to peer
6446 *
6447 * \sa limSendSaQueryRequestFrame
6448 *
6449 *
6450 * \param pMac The global tpAniSirGlobal object
6451 *
6452 * \param transId Transaction identifier
6453 *
6454 * \param peer The Mac address of the station to which this action frame is addressed
6455 *
6456 * \param psessionEntry The PE session entry
6457 *
6458 * \return eSIR_SUCCESS if setup completes successfully
6459 * eSIR_FAILURE is some problem is encountered
6460 */
6461
6462tSirRetStatus limSendSaQueryRequestFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
6463 tSirMacAddr peer, tpPESession psessionEntry )
6464{
6465
6466 tDot11fSaQueryReq frm; // SA query request action frame
6467 tANI_U8 *pFrame;
6468 tSirRetStatus nSirStatus;
6469 tpSirMacMgmtHdr pMacHdr;
6470 tANI_U32 nBytes, nPayload, nStatus;
6471 void *pPacket;
6472 eHalStatus halstatus;
6473 tANI_U8 txFlag = 0;
6474
6475 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
6476 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6477 /* 11w action field is :
6478 action: 0 --> SA Query Request action frame
6479 action: 1 --> SA Query Response action frame */
6480 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
6481 /* 11w SA Query Request transId */
6482 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
6483
6484 nStatus = dot11fGetPackedSaQueryReqSize(pMac, &frm, &nPayload);
6485 if ( DOT11F_FAILED( nStatus ) )
6486 {
6487 limLog( pMac, LOGP, FL("Failed to calculate the packed size "
6488 "for an SA Query Request (0x%08x)."),
6489 nStatus );
6490 // We'll fall back on the worst case scenario:
6491 nPayload = sizeof( tDot11fSaQueryReq );
6492 }
6493 else if ( DOT11F_WARNED( nStatus ) )
6494 {
6495 limLog( pMac, LOGW, FL("There were warnings while calculating "
6496 "the packed size for an SA Query Request"
6497 " (0x%08x)."), nStatus );
6498 }
6499
6500 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6501 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6502 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6503 {
6504 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA Query Request "
6505 "action frame"), nBytes );
6506 return eSIR_FAILURE;
6507 }
6508
6509 // Paranoia:
6510 vos_mem_set( pFrame, nBytes, 0 );
6511
6512 // Copy necessary info to BD
6513 nSirStatus = limPopulateMacHeader( pMac,
6514 pFrame,
6515 SIR_MAC_MGMT_FRAME,
6516 SIR_MAC_MGMT_ACTION,
6517 peer, psessionEntry->selfMacAddr );
6518 if ( eSIR_SUCCESS != nSirStatus )
6519 goto returnAfterError;
6520
6521 // Update A3 with the BSSID
6522 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6523
6524 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6525
6526 // Since this is a SA Query Request, set the "protect" (aka WEP) bit
6527 // in the FC
6528 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
6529
6530 // Pack 11w SA Query Request frame
6531 nStatus = dot11fPackSaQueryReq( pMac,
6532 &frm,
6533 pFrame + sizeof( tSirMacMgmtHdr ),
6534 nPayload,
6535 &nPayload );
6536
6537 if ( DOT11F_FAILED( nStatus ))
6538 {
6539 limLog( pMac, LOGE,
6540 FL( "Failed to pack an SA Query Request (0x%08x)." ),
6541 nStatus );
6542 // FIXME - Need to convert to tSirRetStatus
6543 nSirStatus = eSIR_FAILURE;
6544 goto returnAfterError;
6545 }
6546 else if ( DOT11F_WARNED( nStatus ))
6547 {
6548 limLog( pMac, LOGW,
6549 FL( "There were warnings while packing SA Query Request (0x%08x)." ),
6550 nStatus);
6551 }
6552
6553 limLog( pMac, LOG1,
6554 FL( "Sending an SA Query Request to " ));
6555 limPrintMacAddr( pMac, peer, LOG1 );
6556 limPrintMacAddr( pMac, peer, LOGE );
6557 limLog( pMac, LOGE,
6558 FL( "Sending an SA Query Request from " ));
6559 limPrintMacAddr( pMac, psessionEntry->selfMacAddr, LOGE );
6560
6561 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
6562#ifdef WLAN_FEATURE_P2P
6563 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6564 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
6565#endif
6566 )
6567 {
6568 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6569 }
6570
6571 halstatus = halTxFrame( pMac,
6572 pPacket,
6573 (tANI_U16) nBytes,
6574 HAL_TXRX_FRM_802_11_MGMT,
6575 ANI_TXDIR_TODS,
6576 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6577 limTxComplete,
6578 pFrame, txFlag );
6579 if ( eHAL_STATUS_SUCCESS != halstatus )
6580 {
6581 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6582 nSirStatus = eSIR_FAILURE;
6583 //Pkt will be freed up by the callback
6584 return nSirStatus;
6585 }
6586 else {
6587 return eSIR_SUCCESS;
6588 }
6589
6590returnAfterError:
6591 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6592 return nSirStatus;
6593} // End limSendSaQueryRequestFrame
6594
6595/**
Jeff Johnson295189b2012-06-20 16:38:30 -07006596 * \brief Send SA query response action frame to peer
6597 *
6598 * \sa limSendSaQueryResponseFrame
6599 *
6600 *
6601 * \param pMac The global tpAniSirGlobal object
6602 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006603 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006604 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006605 * \param peer The Mac address of the AP to which this action frame is addressed
6606 *
6607 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07006608 *
6609 * \return eSIR_SUCCESS if setup completes successfully
6610 * eSIR_FAILURE is some problem is encountered
6611 */
6612
Chet Lanctot186b5732013-03-18 10:26:30 -07006613tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006614tSirMacAddr peer,tpPESession psessionEntry)
6615{
6616
Chet Lanctot186b5732013-03-18 10:26:30 -07006617 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006618 tANI_U8 *pFrame;
6619 tSirRetStatus nSirStatus;
6620 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07006621 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006622 void *pPacket;
6623 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306624 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006625
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306626 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07006627 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6628 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07006629 action: 0 --> SA query request action frame
6630 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07006631 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
6632 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07006633 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07006634 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006635
Chet Lanctot186b5732013-03-18 10:26:30 -07006636 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6637 if ( DOT11F_FAILED( nStatus ) )
6638 {
6639 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6640 "or a SA Query Response (0x%08x)."),
6641 nStatus );
6642 // We'll fall back on the worst case scenario:
6643 nPayload = sizeof( tDot11fSaQueryRsp );
6644 }
6645 else if ( DOT11F_WARNED( nStatus ) )
6646 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006647 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006648 "the packed size for an SA Query Response"
6649 " (0x%08x)."), nStatus );
6650 }
6651
Jeff Johnson295189b2012-06-20 16:38:30 -07006652 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6653 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6654 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6655 {
6656 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006657 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006658 return eSIR_FAILURE;
6659 }
6660
6661 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306662 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006663
Chet Lanctot186b5732013-03-18 10:26:30 -07006664 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006665 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006666 pFrame,
6667 SIR_MAC_MGMT_FRAME,
6668 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006669 peer, psessionEntry->selfMacAddr );
6670 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006671 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006672
Chet Lanctot186b5732013-03-18 10:26:30 -07006673 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006674 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6675
Chet Lanctot186b5732013-03-18 10:26:30 -07006676 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006677
Chet Lanctot186b5732013-03-18 10:26:30 -07006678 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6679 // in the FC
Chet Lanctot8cecea22014-02-11 19:09:36 -08006680 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -07006681
Chet Lanctot186b5732013-03-18 10:26:30 -07006682 // Pack 11w SA query response frame
6683 nStatus = dot11fPackSaQueryRsp( pMac,
6684 &frm,
6685 pFrame + sizeof( tSirMacMgmtHdr ),
6686 nPayload,
6687 &nPayload );
6688
6689 if ( DOT11F_FAILED( nStatus ))
6690 {
6691 limLog( pMac, LOGE,
6692 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6693 nStatus );
6694 // FIXME - Need to convert to tSirRetStatus
6695 nSirStatus = eSIR_FAILURE;
6696 goto returnAfterError;
6697 }
6698 else if ( DOT11F_WARNED( nStatus ))
6699 {
6700 limLog( pMac, LOGW,
6701 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6702 nStatus);
6703 }
6704
6705 limLog( pMac, LOG1,
6706 FL( "Sending a SA Query Response to " ));
6707 limPrintMacAddr( pMac, peer, LOGW );
6708
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006709 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006710#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006711 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6712 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006713#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006714 )
6715 {
6716 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6717 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006718
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306719 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6720 psessionEntry->peSessionId,
6721 pMacHdr->fc.subType));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006722 halstatus = halTxFrame( pMac,
6723 pPacket,
6724 (tANI_U16) nBytes,
6725 HAL_TXRX_FRM_802_11_MGMT,
6726 ANI_TXDIR_TODS,
6727 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6728 limTxComplete,
6729 pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306730 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6731 psessionEntry->peSessionId,
6732 halstatus));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006733 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006734 {
6735 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6736 nSirStatus = eSIR_FAILURE;
6737 //Pkt will be freed up by the callback
6738 return nSirStatus;
6739 }
6740 else {
6741 return eSIR_SUCCESS;
6742 }
6743
6744returnAfterError:
6745 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6746 return nSirStatus;
6747} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006748#endif