blob: 1396daf3cc0b5fd6a062b4273295567bc68ffe4f [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
Jeff Johnson295189b2012-06-20 16:38:30 -070067
68/**
69 *
70 * \brief This function is called by various LIM modules to prepare the
71 * 802.11 frame MAC header
72 *
73 *
74 * \param pMac Pointer to Global MAC structure
75 *
76 * \param pBD Pointer to the frame buffer that needs to be populate
77 *
78 * \param type Type of the frame
79 *
80 * \param subType Subtype of the frame
81 *
82 * \return eHalStatus
83 *
84 *
85 * The pFrameBuf argument points to the beginning of the frame buffer to
86 * which - a) The 802.11 MAC header is set b) Following this MAC header
87 * will be the MGMT frame payload The payload itself is populated by the
88 * caller API
89 *
90 *
91 */
92
93tSirRetStatus limPopulateMacHeader( tpAniSirGlobal pMac,
94 tANI_U8* pBD,
95 tANI_U8 type,
96 tANI_U8 subType,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +053097 tSirMacAddr peerAddr, tSirMacAddr selfMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070098{
99 tSirRetStatus statusCode = eSIR_SUCCESS;
100 tpSirMacMgmtHdr pMacHdr;
101
102 /// Prepare MAC management header
103 pMacHdr = (tpSirMacMgmtHdr) (pBD);
104
105 // Prepare FC
106 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
107 pMacHdr->fc.type = type;
108 pMacHdr->fc.subType = subType;
109
110 // Prepare Address 1
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530111 vos_mem_copy( (tANI_U8 *) pMacHdr->da,
Jeff Johnson295189b2012-06-20 16:38:30 -0700112 (tANI_U8 *) peerAddr,
113 sizeof( tSirMacAddr ));
114
115 // Prepare Address 2
Jeff Johnson295189b2012-06-20 16:38:30 -0700116 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
117
118 // Prepare Address 3
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530119 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700120 (tANI_U8 *) peerAddr,
121 sizeof( tSirMacAddr ));
122 return statusCode;
123} /*** end limPopulateMacHeader() ***/
124
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700125#ifdef WLAN_FEATURE_11W
126/**
127 *
128 * \brief This function is called by various LIM modules to correctly set
129 * the Protected bit in the Frame Control Field of the 802.11 frame MAC header
130 *
131 *
132 * \param pMac Pointer to Global MAC structure
133 *
134 * \param psessionEntry Pointer to session corresponding to the connection
135 *
136 * \param peer Peer address of the STA to which the frame is to be sent
137 *
138 * \param pMacHdr Pointer to the frame MAC header
139 *
140 * \return nothing
141 *
142 *
143 */
144void
145limSetProtectedBit(tpAniSirGlobal pMac,
146 tpPESession psessionEntry,
147 tSirMacAddr peer,
148 tpSirMacMgmtHdr pMacHdr)
149{
150 tANI_U16 aid;
151 tpDphHashNode pStaDs;
152
153 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
154 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
155 {
156
157 pStaDs = dphLookupHashEntry( pMac, peer, &aid, &psessionEntry->dph.dphHashTable );
158 if( pStaDs != NULL )
159 if( pStaDs->rmfEnabled )
160 pMacHdr->fc.wep = 1;
161 }
162 else if ( psessionEntry->limRmfEnabled )
163 pMacHdr->fc.wep = 1;
164} /*** end limSetProtectedBit() ***/
165#endif
166
Jeff Johnson295189b2012-06-20 16:38:30 -0700167/**
168 * \brief limSendProbeReqMgmtFrame
169 *
170 *
171 * \param pMac Pointer to Global MAC structure
172 *
173 * \param pSsid SSID to be sent in Probe Request frame
174 *
175 * \param bssid BSSID to be sent in Probe Request frame
176 *
177 * \param nProbeDelay probe delay to be used before sending Probe Request
178 * frame
179 *
180 * \param nChannelNum Channel # on which the Probe Request is going out
181 *
182 * \param nAdditionalIELen if non-zero, include pAdditionalIE in the Probe Request frame
183 *
184 * \param pAdditionalIE if nAdditionalIELen is non zero, include this field in the Probe Request frame
185 *
186 * This function is called by various LIM modules to send Probe Request frame
187 * during active scan/learn phase.
188 * Probe request is sent out in the following scenarios:
189 * --heartbeat failure: session needed
190 * --join req: session needed
191 * --foreground scan: no session
192 * --background scan: no session
193 * --schBeaconProcessing: to get EDCA parameters: session needed
194 *
195 *
196 */
197tSirRetStatus
198limSendProbeReqMgmtFrame(tpAniSirGlobal pMac,
199 tSirMacSSid *pSsid,
200 tSirMacAddr bssid,
201 tANI_U8 nChannelNum,
202 tSirMacAddr SelfMacAddr,
203 tANI_U32 dot11mode,
204 tANI_U32 nAdditionalIELen,
205 tANI_U8 *pAdditionalIE)
206{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530207 tDot11fProbeRequest pr;
208 tANI_U32 nStatus, nBytes, nPayload;
209 tSirRetStatus nSirStatus;
210 tANI_U8 *pFrame;
211 void *pPacket;
212 eHalStatus halstatus;
213 tpPESession psessionEntry;
214 tANI_U8 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700215 tANI_U8 *p2pIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530216 tANI_U32 txFlag = 0;
Sandeep Puligilla60342762014-01-30 21:05:37 +0530217 tANI_U32 chanbond24G = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700218
219#ifndef GEN4_SCAN
220 return eSIR_FAILURE;
221#endif
222
223#if defined ( ANI_DVT_DEBUG )
224 return eSIR_FAILURE;
225#endif
226
Abhishek Singh4beed422014-02-03 16:47:17 +0530227 /* The probe req should not send 11ac capabilieties if band is 2.4GHz,
228 * unless enableVhtFor24GHz is enabled in INI. So if enableVhtFor24GHz
229 * is false and dot11mode is 11ac set it to 11n.
230 */
231 if ( nChannelNum <= SIR_11B_CHANNEL_END &&
232 ( FALSE == pMac->roam.configParam.enableVhtFor24GHz ) &&
233 ( WNI_CFG_DOT11_MODE_11AC == dot11mode ||
234 WNI_CFG_DOT11_MODE_11AC_ONLY == dot11mode ) )
235 dot11mode = WNI_CFG_DOT11_MODE_11N;
Jeff Johnson295189b2012-06-20 16:38:30 -0700236 /*
237 * session context may or may not be present, when probe request needs to be sent out.
238 * following cases exist:
239 * --heartbeat failure: session needed
240 * --join req: session needed
241 * --foreground scan: no session
242 * --background scan: no session
243 * --schBeaconProcessing: to get EDCA parameters: session needed
244 * If session context does not exist, some IEs will be populated from CFGs,
245 * e.g. Supported and Extended rate set IEs
246 */
247 psessionEntry = peFindSessionByBssid(pMac,bssid,&sessionId);
248
249 // The scheme here is to fill out a 'tDot11fProbeRequest' structure
250 // and then hand it off to 'dot11fPackProbeRequest' (for
251 // serialization). We start by zero-initializing the structure:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530252 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700253
254 // & delegating to assorted helpers:
255 PopulateDot11fSSID( pMac, pSsid, &pr.SSID );
256
Jeff Johnson295189b2012-06-20 16:38:30 -0700257 if( nAdditionalIELen && pAdditionalIE )
258 {
259 p2pIe = limGetP2pIEPtr(pMac, pAdditionalIE, nAdditionalIELen);
260 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700261 /* Don't include 11b rate only when device is doing P2P Search */
262 if( ( WNI_CFG_DOT11_MODE_11B != dot11mode ) &&
263 ( p2pIe != NULL ) &&
264 /* Don't include 11b rate if it is a P2P serach or probe request is sent by P2P Client */
265 ( ( ( pMac->lim.gpLimMlmScanReq != NULL ) &&
266 pMac->lim.gpLimMlmScanReq->p2pSearch ) ||
267 ( ( psessionEntry != NULL ) &&
268 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
269 )
270 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700271 {
272 /* In the below API pass channel number > 14, do that it fills only
273 * 11a rates in supported rates */
274 PopulateDot11fSuppRates( pMac, 15, &pr.SuppRates,psessionEntry);
275 }
276 else
277 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700278 PopulateDot11fSuppRates( pMac, nChannelNum,
279 &pr.SuppRates,psessionEntry);
280
281 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
282 {
283 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
284 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700285 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700286
287#if defined WLAN_FEATURE_VOWIFI
288 //Table 7-14 in IEEE Std. 802.11k-2008 says
289 //DS params "can" be present in RRM is disabled and "is" present if
290 //RRM is enabled. It should be ok even if we add it into probe req when
291 //RRM is not enabled.
292 PopulateDot11fDSParams( pMac, &pr.DSParams, nChannelNum, psessionEntry );
293 //Call RRM module to get the tx power for management used.
294 {
295 tANI_U8 txPower = (tANI_U8) rrmGetMgmtTxPower( pMac, psessionEntry );
296 PopulateDot11fWFATPC( pMac, &pr.WFATPC, txPower, 0 );
297 }
298#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700299
300 if (psessionEntry != NULL ) {
Jeff Johnsone7245742012-09-05 17:12:55 -0700301 psessionEntry->htCapability = IS_DOT11_MODE_HT(dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700302 //Include HT Capability IE
Jeff Johnsone7245742012-09-05 17:12:55 -0700303 if (psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -0700304 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700305 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700306 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700307 } else { //psessionEntry == NULL
308 if (IS_DOT11_MODE_HT(dot11mode))
Jeff Johnson295189b2012-06-20 16:38:30 -0700309 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700310 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700311 }
312 }
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800313
Sandeep Puligilla60342762014-01-30 21:05:37 +0530314 /* Get HT40 capability for 2.4GHz band */
315 wlan_cfgGetInt(pMac,WNI_CFG_CHANNEL_BONDING_24G,&chanbond24G);
316 if( (nChannelNum <= SIR_11B_CHANNEL_END) && chanbond24G != TRUE)
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800317 {
318 pr.HTCaps.supportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
319 pr.HTCaps.shortGI40MHz = 0;
320 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700321#ifdef WLAN_FEATURE_11AC
322 if (psessionEntry != NULL ) {
323 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
324 //Include HT Capability IE
325 if (psessionEntry->vhtCapability)
326 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700327 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
328 }
329 } else {
330 if (IS_DOT11_MODE_VHT(dot11mode))
331 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700332 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
333 }
334 }
335#endif
336
Jeff Johnson295189b2012-06-20 16:38:30 -0700337
338 // That's it-- now we pack it. First, how much space are we going to
339 // need?
340 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
341 if ( DOT11F_FAILED( nStatus ) )
342 {
343 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700344 "or a Probe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700345 // We'll fall back on the worst case scenario:
346 nPayload = sizeof( tDot11fProbeRequest );
347 }
348 else if ( DOT11F_WARNED( nStatus ) )
349 {
350 limLog( pMac, LOGW, FL("There were warnings while calculating"
351 "the packed size for a Probe Request ("
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700352 "0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700353 }
354
355 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAdditionalIELen;
356
357 // Ok-- try to allocate some memory:
358 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
359 ( tANI_U16 )nBytes, ( void** ) &pFrame,
360 ( void** ) &pPacket );
361 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
362 {
363 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700364 "be Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700365 return eSIR_MEM_ALLOC_FAILED;
366 }
367
368 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530369 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700370
371 // Next, we fill out the buffer descriptor:
372 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530373 SIR_MAC_MGMT_PROBE_REQ, bssid, SelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700374 if ( eSIR_SUCCESS != nSirStatus )
375 {
376 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700377 "tor for a Probe Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700378 nSirStatus );
379 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
380 ( void* ) pFrame, ( void* ) pPacket );
381 return nSirStatus; // allocated!
382 }
383
384 // That done, pack the Probe Request:
385 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
386 sizeof( tSirMacMgmtHdr ),
387 nPayload, &nPayload );
388 if ( DOT11F_FAILED( nStatus ) )
389 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700390 limLog( pMac, LOGE, FL("Failed to pack a Probe Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700391 nStatus );
392 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
393 return eSIR_FAILURE; // allocated!
394 }
395 else if ( DOT11F_WARNED( nStatus ) )
396 {
397 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800398 "robe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700399 }
400
401 // Append any AddIE if present.
402 if( nAdditionalIELen )
403 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530404 vos_mem_copy( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700405 pAdditionalIE, nAdditionalIELen );
406 nPayload += nAdditionalIELen;
407 }
408
409 /* If this probe request is sent during P2P Search State, then we need
410 * to send it at OFDM rate.
411 */
412 if( ( SIR_BAND_5_GHZ == limGetRFBand(nChannelNum))
Jeff Johnson295189b2012-06-20 16:38:30 -0700413 || (( pMac->lim.gpLimMlmScanReq != NULL) &&
414 pMac->lim.gpLimMlmScanReq->p2pSearch )
Gopichand Nakkala67967212013-02-15 17:31:15 +0530415 /* For unicast probe req mgmt from Join function
416 we don't set above variables. So we need to add
417 one more check whether it is pePersona is P2P_CLIENT or not */
418 || ( ( psessionEntry != NULL ) &&
419 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700420 )
421 {
422 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
423 }
424
Jeff Johnson295189b2012-06-20 16:38:30 -0700425 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload,
426 HAL_TXRX_FRM_802_11_MGMT,
427 ANI_TXDIR_TODS,
428 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
429 limTxComplete, pFrame, txFlag );
430 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
431 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700432 limLog( pMac, LOGE, FL("could not send Probe Request frame!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700433 //Pkt will be freed up by the callback
434 return eSIR_FAILURE;
435 }
436
437 return eSIR_SUCCESS;
438} // End limSendProbeReqMgmtFrame.
439
Jeff Johnson295189b2012-06-20 16:38:30 -0700440tSirRetStatus limGetAddnIeForProbeResp(tpAniSirGlobal pMac,
441 tANI_U8* addIE, tANI_U16 *addnIELen,
442 tANI_U8 probeReqP2pIe)
443{
444 /* If Probe request doesn't have P2P IE, then take out P2P IE
445 from additional IE */
446 if(!probeReqP2pIe)
447 {
448 tANI_U8* tempbuf = NULL;
449 tANI_U16 tempLen = 0;
450 int left = *addnIELen;
451 v_U8_t *ptr = addIE;
452 v_U8_t elem_id, elem_len;
453
454 if(NULL == addIE)
455 {
456 PELOGE(limLog(pMac, LOGE,
457 FL(" NULL addIE pointer"));)
458 return eSIR_FAILURE;
459 }
460
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530461 tempbuf = vos_mem_malloc(left);
462 if ( NULL == tempbuf )
Jeff Johnson295189b2012-06-20 16:38:30 -0700463 {
464 PELOGE(limLog(pMac, LOGE,
465 FL("Unable to allocate memory to store addn IE"));)
466 return eSIR_MEM_ALLOC_FAILED;
467 }
468
469 while(left >= 2)
470 {
471 elem_id = ptr[0];
472 elem_len = ptr[1];
473 left -= 2;
474 if(elem_len > left)
475 {
476 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700477 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 elem_id,elem_len,left);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530479 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700480 return eSIR_FAILURE;
481 }
482 if ( !( (SIR_MAC_EID_VENDOR == elem_id) &&
483 (memcmp(&ptr[2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)==0) ) )
484 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530485 vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -0700486 tempLen += (elem_len + 2);
487 }
488 left -= elem_len;
489 ptr += (elem_len + 2);
490 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530491 vos_mem_copy (addIE, tempbuf, tempLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700492 *addnIELen = tempLen;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530493 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700494 }
495 return eSIR_SUCCESS;
496}
Jeff Johnson295189b2012-06-20 16:38:30 -0700497
498void
499limSendProbeRspMgmtFrame(tpAniSirGlobal pMac,
500 tSirMacAddr peerMacAddr,
501 tpAniSSID pSsid,
502 short nStaId,
503 tANI_U8 nKeepAlive,
504 tpPESession psessionEntry,
505 tANI_U8 probeReqP2pIe)
506{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700507 tDot11fProbeResponse *pFrm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530508 tSirRetStatus nSirStatus;
509 tANI_U32 cfg, nPayload, nBytes, nStatus;
510 tpSirMacMgmtHdr pMacHdr;
511 tANI_U8 *pFrame;
512 void *pPacket;
513 eHalStatus halstatus;
514 tANI_U32 addnIEPresent;
515 tANI_U32 addnIE1Len=0;
516 tANI_U32 addnIE2Len=0;
517 tANI_U32 addnIE3Len=0;
518 tANI_U16 totalAddnIeLen = 0;
519 tANI_U32 wpsApEnable=0, tmp;
520 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700521 tANI_U8 *addIE = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530522 tANI_U8 *pP2pIe = NULL;
523 tANI_U8 noaLen = 0;
524 tANI_U8 total_noaLen = 0;
525 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN
Jeff Johnson295189b2012-06-20 16:38:30 -0700526 + SIR_P2P_IE_HEADER_LEN];
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530527 tANI_U8 noaIe[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -0700528
529 if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests
530 {
531 return; // in this case.
532 }
533
534 if(NULL == psessionEntry)
535 {
536 return;
537 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530538
539 pFrm = vos_mem_malloc(sizeof(tDot11fProbeResponse));
540 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700541 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530542 limLog(pMac, LOGE, FL("Unable to allocate memory in limSendProbeRspMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700543 return;
544 }
545
Jeff Johnson295189b2012-06-20 16:38:30 -0700546 // Fill out 'frm', after which we'll just hand the struct off to
547 // 'dot11fPackProbeResponse'.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530548 vos_mem_set(( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700549
550 // Timestamp to be updated by TFP, below.
551
552 // Beacon Interval:
Jeff Johnson295189b2012-06-20 16:38:30 -0700553 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
554 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700555 pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -0700556 }
557 else
558 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800559 nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg);
560 if (eSIR_SUCCESS != nSirStatus)
561 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700562 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d)."),
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800563 nSirStatus );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530564 vos_mem_free(pFrm);
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800565 return;
566 }
567 pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg;
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800568 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700569
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700570 PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry );
571 PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700572 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700573 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700574
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700575 PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry);
576 PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700577
Jeff Johnson295189b2012-06-20 16:38:30 -0700578
Jeff Johnson295189b2012-06-20 16:38:30 -0700579 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
580 {
581 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
582 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700583 PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700584 }
585 }
586 else
587 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800588 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700589 limLog(pMac, LOGP,"Failed to cfg get id %d", WNI_CFG_WPS_ENABLE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700590
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800591 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
Jeff Johnson295189b2012-06-20 16:38:30 -0700592
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800593 if (wpsApEnable)
594 {
595 PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes);
596 }
597
598 if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
599 {
600 PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
601 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
602 }
603
604 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
605 {
606 DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
607 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
608 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700609 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700610
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700611 PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry);
612 PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700613
Jeff Johnson295189b2012-06-20 16:38:30 -0700614
615 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700616 PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700617
618
619 // N.B. In earlier implementations, the RSN IE would be placed in
620 // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined.
621 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700622 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700623
624 //Populate HT IEs, when operating in 11n or Taurus modes.
Jeff Johnsone7245742012-09-05 17:12:55 -0700625 if ( psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -0700626 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700627 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700628 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700629 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700630#ifdef WLAN_FEATURE_11AC
631 if(psessionEntry->vhtCapability)
632 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -0800633 limLog( pMac, LOG1, FL("Populate VHT IE in Probe Response"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700634 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
635 PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation );
Jeff Johnsone7245742012-09-05 17:12:55 -0700636 // we do not support multi users yet
637 //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad );
Sandeep Puligilla60342762014-01-30 21:05:37 +0530638 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -0700639 }
640#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700641
Sandeep Puligilla60342762014-01-30 21:05:37 +0530642
Jeff Johnson295189b2012-06-20 16:38:30 -0700643 if ( psessionEntry->pLimStartBssReq )
644 {
645 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700646 &pFrm->WPA );
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700647 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
648 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -0700649 }
650
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700651 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700652
653#if defined(FEATURE_WLAN_WAPI)
654 if( psessionEntry->pLimStartBssReq )
655 {
656 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700657 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700658 }
659
660#endif // defined(FEATURE_WLAN_WAPI)
661
662
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700663 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -0700664 if ( DOT11F_FAILED( nStatus ) )
665 {
666 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700667 "or a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700668 nStatus );
669 // We'll fall back on the worst case scenario:
670 nPayload = sizeof( tDot11fProbeResponse );
671 }
672 else if ( DOT11F_WARNED( nStatus ) )
673 {
674 limLog( pMac, LOGW, FL("There were warnings while calculating"
675 "the packed size for a Probe Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700676 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700677 }
678
679 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
680
681 addnIEPresent = false;
682
Jeff Johnson295189b2012-06-20 16:38:30 -0700683 if( pMac->lim.gpLimRemainOnChanReq )
684 {
685 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
686 }
687 //Only use CFG for non-listen mode. This CFG is not working for concurrency
688 //In listening mode, probe rsp IEs is passed in the message from SME to PE
689 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700690 {
691
692 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
693 &addnIEPresent) != eSIR_SUCCESS)
694 {
695 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530696 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 return;
698 }
699 }
700
701 if (addnIEPresent)
702 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530703
704 addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3);
705 if ( NULL == addIE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700706 {
707 PELOGE(limLog(pMac, LOGE,
708 FL("Unable to allocate memory to store addn IE"));)
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530709 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 return;
711 }
712
713 //Probe rsp IE available
714 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
715 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
716 {
717 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530718 vos_mem_free(addIE);
719 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700720 return;
721 }
722 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
723 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
724 {
725 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
726 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
727 &addnIE1Len) )
728 {
729 limLog(pMac, LOGP,
730 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530731 vos_mem_free(addIE);
732 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700733 return;
734 }
735 }
736
737 //Probe rsp IE available
738 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
739 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
740 {
741 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530742 vos_mem_free(addIE);
743 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700744 return;
745 }
746 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
747 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
748 {
749 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
750 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
751 &addnIE2Len) )
752 {
753 limLog(pMac, LOGP,
754 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530755 vos_mem_free(addIE);
756 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700757 return;
758 }
759 }
760
761 //Probe rsp IE available
762 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
763 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
764 {
765 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530766 vos_mem_free(addIE);
767 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700768 return;
769 }
770 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
771 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
772 {
773 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
774 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
775 &addIE[addnIE1Len + addnIE2Len],
776 &addnIE3Len) )
777 {
778 limLog(pMac, LOGP,
779 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530780 vos_mem_free(addIE);
781 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700782 return;
783 }
784 }
785 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
786
Jeff Johnson295189b2012-06-20 16:38:30 -0700787 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
788 {
789 limLog(pMac, LOGP,
790 FL("Unable to get final Additional IE for Probe Req"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530791 vos_mem_free(addIE);
792 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700793 return;
794 }
795 nBytes = nBytes + totalAddnIeLen;
796
797 if (probeReqP2pIe)
798 {
799 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
800 if (pP2pIe != NULL)
801 {
802 //get NoA attribute stream P2P IE
803 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
804 if (noaLen != 0)
805 {
806 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
807 &noaStream[0], noaLen);
808 nBytes = nBytes + total_noaLen;
809 }
810 }
811 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700812 }
813
814 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
815 ( tANI_U16 )nBytes, ( void** ) &pFrame,
816 ( void** ) &pPacket );
817 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
818 {
819 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700820 "be Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700821 if ( addIE != NULL )
822 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530823 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700824 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530825 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700826 return;
827 }
828
829 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530830 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700831
832 // Next, we fill out the buffer descriptor:
833 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
834 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
835 if ( eSIR_SUCCESS != nSirStatus )
836 {
837 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700838 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700839 nSirStatus );
840 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
841 ( void* ) pFrame, ( void* ) pPacket );
842 if ( addIE != NULL )
843 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530844 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700845 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530846 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700847 return;
848 }
849
850 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
851
852 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
853
854 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700855 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -0700856 nPayload, &nPayload );
857 if ( DOT11F_FAILED( nStatus ) )
858 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700859 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700860 nStatus );
861 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
862 if ( addIE != NULL )
863 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530864 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700865 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530866 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700867 return; // allocated!
868 }
869 else if ( DOT11F_WARNED( nStatus ) )
870 {
871 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800872 "robe Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700873 }
874
875 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
876 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
877
878 pMac->sys.probeRespond++;
879
Jeff Johnson295189b2012-06-20 16:38:30 -0700880 if( pMac->lim.gpLimRemainOnChanReq )
881 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530882 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700883 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
884 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700885
886 if ( addnIEPresent )
887 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530888 vos_mem_copy(pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], totalAddnIeLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700889 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700890 if (noaLen != 0)
891 {
Krunal Soni81b24262013-05-15 17:46:41 -0700892 if (total_noaLen > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 {
894 limLog(pMac, LOGE,
Kaushik, Sushant96ac9d72013-12-11 19:28:10 +0530895 FL("Not able to insert NoA because of length constraint."
896 "Total Length is :%d"),total_noaLen);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530897 vos_mem_free(addIE);
898 vos_mem_free(pFrm);
Krunal Soni81b24262013-05-15 17:46:41 -0700899 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
900 ( void* ) pFrame, ( void* ) pPacket );
901 return;
902 }
903 else
904 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530905 vos_mem_copy( &pFrame[nBytes - (total_noaLen)],
Krunal Soni81b24262013-05-15 17:46:41 -0700906 &noaIe[0], total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700907 }
908 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700909
910 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -0700911 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
912 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700913 )
914 {
915 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
916 }
917
918 // Queue Probe Response frame in high priority WQ
919 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
920 ( tANI_U16 ) nBytes,
921 HAL_TXRX_FRM_802_11_MGMT,
922 ANI_TXDIR_TODS,
923 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
924 limTxComplete, pFrame, txFlag );
925 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
926 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700927 limLog( pMac, LOGE, FL("Could not send Probe Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700928 //Pkt will be freed up by the callback
929 }
930
931 if ( addIE != NULL )
932 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530933 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700934 }
935
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530936 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700937 return;
938
939
Jeff Johnson295189b2012-06-20 16:38:30 -0700940} // End limSendProbeRspMgmtFrame.
941
942void
943limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
944 tSirMacAddr peerMacAddr,
945 tSirAddtsReqInfo *pAddTS,
946 tpPESession psessionEntry)
947{
948 tANI_U16 i;
949 tANI_U8 *pFrame;
950 tSirRetStatus nSirStatus;
951 tDot11fAddTSRequest AddTSReq;
952 tDot11fWMMAddTSRequest WMMAddTSReq;
953 tANI_U32 nPayload, nBytes, nStatus;
954 tpSirMacMgmtHdr pMacHdr;
955 void *pPacket;
956#ifdef FEATURE_WLAN_CCX
957 tANI_U32 phyMode;
958#endif
959 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530960 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700961
962 if(NULL == psessionEntry)
963 {
964 return;
965 }
966
967 if ( ! pAddTS->wmeTspecPresent )
968 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530969 vos_mem_set(( tANI_U8* )&AddTSReq, sizeof( AddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700970
971 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
972 AddTSReq.DialogToken.token = pAddTS->dialogToken;
973 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
974 if ( pAddTS->lleTspecPresent )
975 {
976 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
977 }
978 else
979 {
980 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
981 }
982
983 if ( pAddTS->lleTspecPresent )
984 {
985 AddTSReq.num_WMMTCLAS = 0;
986 AddTSReq.num_TCLAS = pAddTS->numTclas;
987 for ( i = 0; i < pAddTS->numTclas; ++i)
988 {
989 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
990 &AddTSReq.TCLAS[i] );
991 }
992 }
993 else
994 {
995 AddTSReq.num_TCLAS = 0;
996 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
997 for ( i = 0; i < pAddTS->numTclas; ++i)
998 {
999 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1000 &AddTSReq.WMMTCLAS[i] );
1001 }
1002 }
1003
1004 if ( pAddTS->tclasProcPresent )
1005 {
1006 if ( pAddTS->lleTspecPresent )
1007 {
1008 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
1009 AddTSReq.TCLASSPROC.present = 1;
1010 }
1011 else
1012 {
1013 AddTSReq.WMMTCLASPROC.version = 1;
1014 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
1015 AddTSReq.WMMTCLASPROC.present = 1;
1016 }
1017 }
1018
1019 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
1020 if ( DOT11F_FAILED( nStatus ) )
1021 {
1022 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001023 "or an Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001024 nStatus );
1025 // We'll fall back on the worst case scenario:
1026 nPayload = sizeof( tDot11fAddTSRequest );
1027 }
1028 else if ( DOT11F_WARNED( nStatus ) )
1029 {
1030 limLog( pMac, LOGW, FL("There were warnings while calculating"
1031 "the packed size for an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001032 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001033 }
1034 }
1035 else
1036 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301037 vos_mem_set(( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001038
1039 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1040 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1041 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1042
1043 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1044 WMMAddTSReq.StatusCode.statusCode = 0;
1045
1046 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
1047#ifdef FEATURE_WLAN_CCX
1048 limGetPhyMode(pMac, &phyMode, psessionEntry);
1049
1050 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1051 {
1052 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1053 }
1054 else
1055 {
1056 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1057 }
1058 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.CCXTrafStrmRateSet,sizeof(tANI_U8));
1059#endif
1060 // fillWmeTspecIE
1061
1062 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1063 if ( DOT11F_FAILED( nStatus ) )
1064 {
1065 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001066 "or a WMM Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001067 nStatus );
1068 // We'll fall back on the worst case scenario:
1069 nPayload = sizeof( tDot11fAddTSRequest );
1070 }
1071 else if ( DOT11F_WARNED( nStatus ) )
1072 {
1073 limLog( pMac, LOGW, FL("There were warnings while calculating"
1074 "the packed size for a WMM Add TS Requ"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001075 "est (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001076 }
1077 }
1078
1079 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1080
1081 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1082 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1083 ( void** ) &pPacket );
1084 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1085 {
1086 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001087 "d TS Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001088 return;
1089 }
1090
1091 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301092 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001093
1094 // Next, we fill out the buffer descriptor:
1095 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1096 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1097 if ( eSIR_SUCCESS != nSirStatus )
1098 {
1099 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001100 "tor for an Add TS Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001101 nSirStatus );
1102 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1103 ( void* ) pFrame, ( void* ) pPacket );
1104 return;
1105 }
1106
1107 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1108
1109 #if 0
1110 cfgLen = SIR_MAC_ADDR_LENGTH;
1111 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1112 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1113 {
1114 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001115 "e sending an Add TS Request.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001116 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1117 ( void* ) pFrame, ( void* ) pPacket );
1118 return;
1119 }
1120 #endif //TO SUPPORT BT-AMP
1121
1122 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1123
Chet Lanctot186b5732013-03-18 10:26:30 -07001124#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001125 limSetProtectedBit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001126#endif
1127
Jeff Johnson295189b2012-06-20 16:38:30 -07001128 // That done, pack the struct:
1129 if ( ! pAddTS->wmeTspecPresent )
1130 {
1131 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1132 pFrame + sizeof(tSirMacMgmtHdr),
1133 nPayload, &nPayload );
1134 if ( DOT11F_FAILED( nStatus ) )
1135 {
1136 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001137 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001138 nStatus );
1139 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1140 return; // allocated!
1141 }
1142 else if ( DOT11F_WARNED( nStatus ) )
1143 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001144 limLog( pMac, LOGW, FL("There were warnings while packing "
1145 "an Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001146 }
1147 }
1148 else
1149 {
1150 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1151 pFrame + sizeof(tSirMacMgmtHdr),
1152 nPayload, &nPayload );
1153 if ( DOT11F_FAILED( nStatus ) )
1154 {
1155 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001156 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001157 nStatus );
1158 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1159 return; // allocated!
1160 }
1161 else if ( DOT11F_WARNED( nStatus ) )
1162 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001163 limLog( pMac, LOGW, FL("There were warnings while packing "
1164 "a WMM Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001165 }
1166 }
1167
1168 PELOG3(limLog( pMac, LOG3, FL("Sending an Add TS Request frame to ") );
1169 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1170
1171 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001172 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1173 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001174 )
1175 {
1176 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1177 }
1178
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301179 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1180 psessionEntry->peSessionId,
1181 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001182 // Queue Addts Response frame in high priority WQ
1183 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1184 HAL_TXRX_FRM_802_11_MGMT,
1185 ANI_TXDIR_TODS,
1186 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1187 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301188 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1189 psessionEntry->peSessionId,
1190 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001191 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1192 {
1193 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001194 " (%X) ***" ), halstatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001195 //Pkt will be freed up by the callback
1196 }
1197
1198} // End limSendAddtsReqActionFrame.
1199
Jeff Johnson295189b2012-06-20 16:38:30 -07001200
1201
1202void
1203limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1204 tANI_U16 statusCode,
1205 tANI_U16 aid,
1206 tSirMacAddr peerMacAddr,
1207 tANI_U8 subType,
1208 tpDphHashNode pSta,tpPESession psessionEntry)
1209{
1210 static tDot11fAssocResponse frm;
1211 tANI_U8 *pFrame, *macAddr;
1212 tpSirMacMgmtHdr pMacHdr;
1213 tSirRetStatus nSirStatus;
1214 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1215 tHalBitVal qosMode, wmeMode;
1216 tANI_U32 nPayload, nBytes, nStatus;
1217 void *pPacket;
1218 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301219 tUpdateBeaconParams beaconParams;
1220 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001221 tANI_U32 addnIEPresent = false;
1222 tANI_U32 addnIELen=0;
1223 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1224 tpSirAssocReq pAssocReq = NULL;
Chet Lanctot8cecea22014-02-11 19:09:36 -08001225#ifdef WLAN_FEATURE_11W
1226 tANI_U32 retryInterval;
1227 tANI_U32 maxRetries;
1228#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001229
1230 if(NULL == psessionEntry)
1231 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301232 limLog( pMac, LOGE, FL("psessionEntry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001233 return;
1234 }
1235
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301236 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001237
1238 limGetQosMode(psessionEntry, &qosMode);
1239 limGetWmeMode(psessionEntry, &wmeMode);
1240
1241 // An Add TS IE is added only if the AP supports it and the requesting
1242 // STA sent a traffic spec.
1243 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1244
1245 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1246
1247 frm.Status.status = statusCode;
1248
1249 frm.AID.associd = aid | LIM_AID_MASK;
1250
1251 if ( NULL == pSta )
1252 {
1253 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1254 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1255 }
1256 else
1257 {
1258 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1259 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1260 }
1261
Jeff Johnson295189b2012-06-20 16:38:30 -07001262 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1263 {
1264 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1265 {
1266 pAssocReq =
1267 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001268 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1269 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1270 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1271 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001272 }
1273 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001274
1275 if ( NULL != pSta )
1276 {
1277 if ( eHAL_SET == qosMode )
1278 {
1279 if ( pSta->lleEnabled )
1280 {
1281 lleMode = 1;
1282 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1283 {
1284 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1285
1286// FramesToDo:...
1287// if ( fAddTS )
1288// {
1289// tANI_U8 *pAf = pBody;
1290// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1291// tANI_U32 tlen;
1292// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1293// &tlen, bufLen - frameLen);
1294// } // End if on Add TS.
1295 }
1296 } // End if on .11e enabled in 'pSta'.
1297 } // End if on QOS Mode on.
1298
1299 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1300 {
1301 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1302 {
1303
Jeff Johnson295189b2012-06-20 16:38:30 -07001304 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001305
1306 if ( pSta->wsmEnabled )
1307 {
1308 PopulateDot11fWMMCaps(&frm.WMMCaps );
1309 }
1310 }
1311 }
1312
1313 if ( pSta->aniPeer )
1314 {
1315 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1316 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1317 {
1318 edcaInclude = 1;
1319 }
1320
1321 } // End if on Airgo peer.
1322
1323 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001324 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001325 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001326 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07001327 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001328 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001329
1330#ifdef WLAN_FEATURE_11AC
1331 if( pSta->mlmStaContext.vhtCapability &&
1332 psessionEntry->vhtCapability )
1333 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08001334 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Response"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001335 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
1336 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation);
Sandeep Puligilla60342762014-01-30 21:05:37 +05301337 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001338 }
1339#endif
1340
Jeff Johnson295189b2012-06-20 16:38:30 -07001341 } // End if on non-NULL 'pSta'.
1342
Chet Lanctot8cecea22014-02-11 19:09:36 -08001343#ifdef WLAN_FEATURE_11W
1344 if( eSIR_MAC_TRY_AGAIN_LATER == statusCode )
1345 {
1346 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_MAX_RETRIES,
1347 &maxRetries ) != eSIR_SUCCESS )
1348 limLog( pMac, LOGE, FL("Could not retrieve PMF SA Query maximum retries value") );
1349 else
1350 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL,
1351 &retryInterval ) != eSIR_SUCCESS)
1352 limLog( pMac, LOGE, FL("Could not retrieve PMF SA Query timer interval value") );
1353 else
1354 PopulateDot11fTimeoutInterval(
1355 pMac, &frm.TimeoutInterval, SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1356 (maxRetries - pSta->pmfSaQueryRetryCount) * retryInterval );
1357 }
1358#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001359
Chet Lanctot8cecea22014-02-11 19:09:36 -08001360 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001361
Jeff Johnson295189b2012-06-20 16:38:30 -07001362 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1363 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1364 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1365 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001366
1367 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1368 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1369
1370 beaconParams.bssIdx = psessionEntry->bssIdx;
1371
1372 //Send message to HAL about beacon parameter change.
1373 if(beaconParams.paramChangeBitmap)
1374 {
1375 schSetFixedBeaconFields(pMac,psessionEntry);
1376 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1377 }
1378
1379 // Allocate a buffer for this frame:
1380 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1381 if ( DOT11F_FAILED( nStatus ) )
1382 {
1383 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001384 "or an Association Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001385 nStatus );
1386 return;
1387 }
1388 else if ( DOT11F_WARNED( nStatus ) )
1389 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001390 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07001391 "the packed size for an Association Re"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001392 "sponse (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001393 }
1394
1395 nBytes = sizeof( tSirMacMgmtHdr ) + nPayload;
1396
1397 if ( pAssocReq != NULL )
1398 {
1399 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1400 &addnIEPresent) != eSIR_SUCCESS)
1401 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301402 limLog(pMac, LOGP, FL("Unable to get "
1403 "WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001404 return;
1405 }
1406
1407 if (addnIEPresent)
1408 {
1409 //Assoc rsp IE available
1410 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1411 &addnIELen) != eSIR_SUCCESS)
1412 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301413 limLog(pMac, LOGP, FL("Unable to get "
1414 "WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001415 return;
1416 }
1417
1418 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1419 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1420 {
1421 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1422 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1423 {
1424 nBytes = nBytes + addnIELen;
1425 }
1426 }
1427 }
1428 }
1429
1430 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1431 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1432 ( void** ) &pPacket );
1433 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1434 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001435 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001436 return;
1437 }
1438
1439 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301440 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001441
1442 // Next, we fill out the buffer descriptor:
1443 nSirStatus = limPopulateMacHeader( pMac,
1444 pFrame,
1445 SIR_MAC_MGMT_FRAME,
1446 ( LIM_ASSOC == subType ) ?
1447 SIR_MAC_MGMT_ASSOC_RSP :
1448 SIR_MAC_MGMT_REASSOC_RSP,
1449 peerMacAddr,psessionEntry->selfMacAddr);
1450 if ( eSIR_SUCCESS != nSirStatus )
1451 {
1452 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001453 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001454 nSirStatus );
1455 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1456 ( void* ) pFrame, ( void* ) pPacket );
1457 return;
1458 }
1459
1460 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1461
Jeff Johnson295189b2012-06-20 16:38:30 -07001462 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1463
1464 nStatus = dot11fPackAssocResponse( pMac, &frm,
1465 pFrame + sizeof( tSirMacMgmtHdr ),
1466 nPayload, &nPayload );
1467 if ( DOT11F_FAILED( nStatus ) )
1468 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301469 limLog( pMac, LOGE, FL("Failed to pack an Association Response"
1470 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001471 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1472 ( void* ) pFrame, ( void* ) pPacket );
1473 return; // allocated!
1474 }
1475 else if ( DOT11F_WARNED( nStatus ) )
1476 {
1477 limLog( pMac, LOGW, FL("There were warnings while packing an "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001478 "Association Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001479 }
1480
1481 macAddr = pMacHdr->da;
1482
1483 if (subType == LIM_ASSOC)
1484 {
1485 PELOG1(limLog(pMac, LOG1,
1486 FL("*** Sending Assoc Resp status %d aid %d to "),
1487 statusCode, aid);)
1488 }
1489 else{
1490 PELOG1(limLog(pMac, LOG1,
1491 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1492 statusCode, aid);)
1493 }
1494 PELOG1(limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1495
1496 if ( addnIEPresent )
1497 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301498 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001499 }
1500
1501 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001502 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1503 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001504 )
1505 {
1506 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1507 }
1508
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301509 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1510 psessionEntry->peSessionId,
1511 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001512 /// Queue Association Response frame in high priority WQ
1513 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1514 HAL_TXRX_FRM_802_11_MGMT,
1515 ANI_TXDIR_TODS,
1516 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1517 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301518 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1519 psessionEntry->peSessionId,
1520 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001521 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1522 {
1523 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001524 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001525 nSirStatus);
1526
1527 //Pkt will be freed up by the callback
1528 }
1529
1530 // update the ANI peer station count
1531 //FIXME_PROTECTION : take care of different type of station
1532 // counter inside this function.
1533 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1534
1535} // End limSendAssocRspMgmtFrame.
1536
1537
1538
1539void
1540limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1541 tSirMacAddr peer,
1542 tANI_U16 nStatusCode,
1543 tSirAddtsReqInfo *pAddTS,
1544 tSirMacScheduleIE *pSchedule,
1545 tpPESession psessionEntry)
1546{
1547 tANI_U8 *pFrame;
1548 tpSirMacMgmtHdr pMacHdr;
1549 tDot11fAddTSResponse AddTSRsp;
1550 tDot11fWMMAddTSResponse WMMAddTSRsp;
1551 tSirRetStatus nSirStatus;
1552 tANI_U32 i, nBytes, nPayload, nStatus;
1553 void *pPacket;
1554 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301555 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001556
1557 if(NULL == psessionEntry)
1558 {
1559 return;
1560 }
1561
1562 if ( ! pAddTS->wmeTspecPresent )
1563 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301564 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001565
1566 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1567 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1568 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1569 AddTSRsp.Status.status = nStatusCode;
1570
1571 // The TsDelay information element is only filled in for a specific
1572 // status code:
1573 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1574 {
1575 if ( pAddTS->wsmTspecPresent )
1576 {
1577 AddTSRsp.WMMTSDelay.version = 1;
1578 AddTSRsp.WMMTSDelay.delay = 10;
1579 AddTSRsp.WMMTSDelay.present = 1;
1580 }
1581 else
1582 {
1583 AddTSRsp.TSDelay.delay = 10;
1584 AddTSRsp.TSDelay.present = 1;
1585 }
1586 }
1587
1588 if ( pAddTS->wsmTspecPresent )
1589 {
1590 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1591 }
1592 else
1593 {
1594 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1595 }
1596
1597 if ( pAddTS->wsmTspecPresent )
1598 {
1599 AddTSRsp.num_WMMTCLAS = 0;
1600 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1601 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1602 {
1603 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1604 &AddTSRsp.TCLAS[i] );
1605 }
1606 }
1607 else
1608 {
1609 AddTSRsp.num_TCLAS = 0;
1610 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1611 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1612 {
1613 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1614 &AddTSRsp.WMMTCLAS[i] );
1615 }
1616 }
1617
1618 if ( pAddTS->tclasProcPresent )
1619 {
1620 if ( pAddTS->wsmTspecPresent )
1621 {
1622 AddTSRsp.WMMTCLASPROC.version = 1;
1623 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1624 AddTSRsp.WMMTCLASPROC.present = 1;
1625 }
1626 else
1627 {
1628 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1629 AddTSRsp.TCLASSPROC.present = 1;
1630 }
1631 }
1632
1633 // schedule element is included only if requested in the tspec and we are
1634 // using hcca (or both edca and hcca)
1635 // 11e-D8.0 is inconsistent on whether the schedule element is included
1636 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1637 // pg 46, line 17-18 says something else. So just include it and let the
1638 // sta figure it out
1639 if ((pSchedule != NULL) &&
1640 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1641 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1642 {
1643 if ( pAddTS->wsmTspecPresent )
1644 {
1645 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1646 }
1647 else
1648 {
1649 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1650 }
1651 }
1652
1653 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1654 if ( DOT11F_FAILED( nStatus ) )
1655 {
1656 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001657 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001658 nStatus );
1659 // We'll fall back on the worst case scenario:
1660 nPayload = sizeof( tDot11fAddTSResponse );
1661 }
1662 else if ( DOT11F_WARNED( nStatus ) )
1663 {
1664 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001665 "ting the packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001666 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001667 }
1668 }
1669 else
1670 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301671 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001672
1673 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1674 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1675 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1676 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1677
1678 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1679
1680 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1681 if ( DOT11F_FAILED( nStatus ) )
1682 {
1683 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001684 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001685 nStatus );
1686 // We'll fall back on the worst case scenario:
1687 nPayload = sizeof( tDot11fWMMAddTSResponse );
1688 }
1689 else if ( DOT11F_WARNED( nStatus ) )
1690 {
1691 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001692 "ting the packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001693 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001694 }
1695 }
1696
1697 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1698
1699 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1700 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1701 {
1702 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001703 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001704 return;
1705 }
1706
1707 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301708 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001709
1710 // Next, we fill out the buffer descriptor:
1711 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1712 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1713 if ( eSIR_SUCCESS != nSirStatus )
1714 {
1715 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001716 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001717 nSirStatus );
1718 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1719 return; // allocated!
1720 }
1721
1722 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1723
1724
1725 #if 0
1726 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1727 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1728 {
1729 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001730 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001731 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1732 return; // allocated!
1733 }
1734 #endif //TO SUPPORT BT-AMP
1735 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1736
Chet Lanctot186b5732013-03-18 10:26:30 -07001737#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001738 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001739#endif
1740
Jeff Johnson295189b2012-06-20 16:38:30 -07001741 // That done, pack the struct:
1742 if ( ! pAddTS->wmeTspecPresent )
1743 {
1744 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1745 pFrame + sizeof( tSirMacMgmtHdr ),
1746 nPayload, &nPayload );
1747 if ( DOT11F_FAILED( nStatus ) )
1748 {
1749 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001750 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001751 nStatus );
1752 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1753 return;
1754 }
1755 else if ( DOT11F_WARNED( nStatus ) )
1756 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001757 limLog( pMac, LOGW, FL("There were warnings while packing "
1758 "an Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001759 }
1760 }
1761 else
1762 {
1763 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
1764 pFrame + sizeof( tSirMacMgmtHdr ),
1765 nPayload, &nPayload );
1766 if ( DOT11F_FAILED( nStatus ) )
1767 {
1768 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001769 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001770 nStatus );
1771 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1772 return;
1773 }
1774 else if ( DOT11F_WARNED( nStatus ) )
1775 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001776 limLog( pMac, LOGW, FL("There were warnings while packing "
1777 "a WMM Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001778 }
1779 }
1780
1781 PELOG1(limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
1782 nStatusCode );
1783 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
1784
1785 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001786 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1787 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001788 )
1789 {
1790 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1791 }
1792
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301793 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1794 psessionEntry->peSessionId,
1795 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001796 // Queue the frame in high priority WQ:
1797 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1798 HAL_TXRX_FRM_802_11_MGMT,
1799 ANI_TXDIR_TODS,
1800 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1801 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301802 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1803 psessionEntry->peSessionId,
1804 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001805 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1806 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001807 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001808 nSirStatus );
1809 //Pkt will be freed up by the callback
1810 }
1811
1812} // End limSendAddtsRspActionFrame.
1813
1814void
1815limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
1816 tSirMacAddr peer,
1817 tANI_U8 wmmTspecPresent,
1818 tSirMacTSInfo *pTsinfo,
1819 tSirMacTspecIE *pTspecIe,
1820 tpPESession psessionEntry)
1821{
1822 tANI_U8 *pFrame;
1823 tpSirMacMgmtHdr pMacHdr;
1824 tDot11fDelTS DelTS;
1825 tDot11fWMMDelTS WMMDelTS;
1826 tSirRetStatus nSirStatus;
1827 tANI_U32 nBytes, nPayload, nStatus;
1828 void *pPacket;
1829 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301830 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001831
1832 if(NULL == psessionEntry)
1833 {
1834 return;
1835 }
1836
1837 if ( ! wmmTspecPresent )
1838 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301839 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001840
1841 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1842 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1843 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
1844
1845 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
1846 if ( DOT11F_FAILED( nStatus ) )
1847 {
1848 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001849 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001850 nStatus );
1851 // We'll fall back on the worst case scenario:
1852 nPayload = sizeof( tDot11fDelTS );
1853 }
1854 else if ( DOT11F_WARNED( nStatus ) )
1855 {
1856 limLog( pMac, LOGW, FL("There were warnings while calcula"
1857 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001858 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001859 }
1860 }
1861 else
1862 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301863 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001864
1865 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
1866 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1867 WMMDelTS.DialogToken.token = 0;
1868 WMMDelTS.StatusCode.statusCode = 0;
1869 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
1870 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
1871 if ( DOT11F_FAILED( nStatus ) )
1872 {
1873 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001874 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001875 nStatus );
1876 // We'll fall back on the worst case scenario:
1877 nPayload = sizeof( tDot11fDelTS );
1878 }
1879 else if ( DOT11F_WARNED( nStatus ) )
1880 {
1881 limLog( pMac, LOGW, FL("There were warnings while calcula"
1882 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001883 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001884 }
1885 }
1886
1887 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1888
1889 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1890 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1891 {
1892 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001893 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001894 return;
1895 }
1896
1897 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301898 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001899
1900 // Next, we fill out the buffer descriptor:
1901 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1902 SIR_MAC_MGMT_ACTION, peer,
1903 psessionEntry->selfMacAddr);
1904 if ( eSIR_SUCCESS != nSirStatus )
1905 {
1906 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001907 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001908 nSirStatus );
1909 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1910 return; // allocated!
1911 }
1912
1913 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1914
1915 #if 0
1916
1917 cfgLen = SIR_MAC_ADDR_LENGTH;
1918 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1919 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1920 {
1921 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001922 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1924 return; // allocated!
1925 }
1926 #endif //TO SUPPORT BT-AMP
1927 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
1928
Chet Lanctot186b5732013-03-18 10:26:30 -07001929#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001930 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001931#endif
1932
Jeff Johnson295189b2012-06-20 16:38:30 -07001933 // That done, pack the struct:
1934 if ( !wmmTspecPresent )
1935 {
1936 nStatus = dot11fPackDelTS( pMac, &DelTS,
1937 pFrame + sizeof( tSirMacMgmtHdr ),
1938 nPayload, &nPayload );
1939 if ( DOT11F_FAILED( nStatus ) )
1940 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001941 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001942 nStatus );
1943 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1944 return; // allocated!
1945 }
1946 else if ( DOT11F_WARNED( nStatus ) )
1947 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001948 limLog( pMac, LOGW, FL("There were warnings while packing "
1949 "a Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001950 }
1951 }
1952 else
1953 {
1954 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
1955 pFrame + sizeof( tSirMacMgmtHdr ),
1956 nPayload, &nPayload );
1957 if ( DOT11F_FAILED( nStatus ) )
1958 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001959 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001960 nStatus );
1961 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1962 return; // allocated!
1963 }
1964 else if ( DOT11F_WARNED( nStatus ) )
1965 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001966 limLog( pMac, LOGW, FL("There were warnings while packing "
1967 "a WMM Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001968 }
1969 }
1970
1971 PELOG1(limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
1972 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1973
1974 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001975 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1976 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001977 )
1978 {
1979 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1980 }
1981
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301982 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1983 psessionEntry->peSessionId,
1984 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001985 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1986 HAL_TXRX_FRM_802_11_MGMT,
1987 ANI_TXDIR_TODS,
1988 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1989 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301990 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1991 psessionEntry->peSessionId,
1992 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001993 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1994 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001995 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001996 nSirStatus );
1997 //Pkt will be freed up by the callback
1998 }
1999
2000} // End limSendDeltsReqActionFrame.
2001
2002void
2003limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
2004 tLimMlmAssocReq *pMlmAssocReq,
2005 tpPESession psessionEntry)
2006{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002007 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07002008 tANI_U16 caps;
2009 tANI_U8 *pFrame;
2010 tSirRetStatus nSirStatus;
2011 tLimMlmAssocCnf mlmAssocCnf;
2012 tANI_U32 nBytes, nPayload, nStatus;
2013 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2014 void *pPacket;
2015 eHalStatus halstatus;
2016 tANI_U16 nAddIELen;
2017 tANI_U8 *pAddIE;
2018 tANI_U8 *wpsIe = NULL;
2019#if defined WLAN_FEATURE_VOWIFI
2020 tANI_U8 PowerCapsPopulated = FALSE;
2021#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302022 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302023 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002024
2025 if(NULL == psessionEntry)
2026 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302027 limLog(pMac, LOGE, FL("psessionEntry is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 return;
2029 }
2030
Jeff Johnson295189b2012-06-20 16:38:30 -07002031 /* check this early to avoid unncessary operation */
2032 if(NULL == psessionEntry->pLimJoinReq)
2033 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302034 limLog(pMac, LOGE, FL("psessionEntry->pLimJoinReq is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002035 return;
2036 }
2037 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
2038 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
2039
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302040 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
2041 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002042 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302043 limLog(pMac, LOGE, FL("Unable to allocate memory") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002044 return;
2045 }
2046
2047
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302048 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002049
2050 caps = pMlmAssocReq->capabilityInfo;
2051 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2052 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2053#if defined(FEATURE_WLAN_WAPI)
2054 /* CR: 262463 :
2055 According to WAPI standard:
2056 7.3.1.4 Capability Information field
2057 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2058 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2059 Reassociation management frames. */
2060 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2061 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2062#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002063 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002064
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002065 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2066 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002067 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002068 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002069
2070 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2071 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2072
2073 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2074 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2075
2076 // We prefer .11e asociations:
2077 if ( fQosEnabled ) fWmeEnabled = false;
2078
2079 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2080 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2081
2082 if ( psessionEntry->lim11hEnable &&
2083 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2084 {
2085#if defined WLAN_FEATURE_VOWIFI
2086 PowerCapsPopulated = TRUE;
2087
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002088 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002089#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002090 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002091
2092 }
2093
2094#if defined WLAN_FEATURE_VOWIFI
2095 if( pMac->rrm.rrmPEContext.rrmEnable &&
2096 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2097 {
2098 if (PowerCapsPopulated == FALSE)
2099 {
2100 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002101 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002102 }
2103 }
2104#endif
2105
2106 if ( fQosEnabled &&
2107 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002108 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002109
2110 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002111 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002112
2113#if defined WLAN_FEATURE_VOWIFI
2114 if( pMac->rrm.rrmPEContext.rrmEnable &&
2115 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2116 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002117 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002118 }
2119#endif
2120 // The join request *should* contain zero or one of the WPA and RSN
2121 // IEs. The payload send along with the request is a
2122 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2123
2124 // typedef struct sSirRSNie
2125 // {
2126 // tANI_U16 length;
2127 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2128 // } tSirRSNie, *tpSirRSNie;
2129
2130 // So, we should be able to make the following two calls harmlessly,
2131 // since they do nothing if they don't find the given IE in the
2132 // bytestream with which they're provided.
2133
2134 // The net effect of this will be to faithfully transmit whatever
2135 // security IE is in the join request.
2136
2137 // *However*, if we're associating for the purpose of WPS
2138 // enrollment, and we've been configured to indicate that by
2139 // eliding the WPA or RSN IE, we just skip this:
2140 if( nAddIELen && pAddIE )
2141 {
2142 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2143 }
2144 if ( NULL == wpsIe )
2145 {
2146 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002147 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002148 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002149 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002150#if defined(FEATURE_WLAN_WAPI)
2151 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002152 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002153#endif // defined(FEATURE_WLAN_WAPI)
2154 }
2155
2156 // include WME EDCA IE as well
2157 if ( fWmeEnabled )
2158 {
2159 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2160 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002161 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002162 }
2163
2164 if ( fWsmEnabled &&
2165 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2166 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002167 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002168 }
2169 }
2170
2171 //Populate HT IEs, when operating in 11n or Taurus modes AND
2172 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002173 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002174 pMac->lim.htCapabilityPresentInBeacon)
2175 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002176 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002177#ifdef DISABLE_GF_FOR_INTEROP
2178
2179 /*
2180 * To resolve the interop problem with Broadcom AP,
2181 * where TQ STA could not pass traffic with GF enabled,
2182 * TQ STA will do Greenfield only with TQ AP, for
2183 * everybody else it will be turned off.
2184 */
2185
2186 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2187 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302188 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP,"
2189 " Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002190 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002191 }
2192#endif
2193
2194 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002195#ifdef WLAN_FEATURE_11AC
2196 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002197 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002198 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002199 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002200 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
Jeff Johnsone7245742012-09-05 17:12:55 -07002201 }
2202#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302203 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002204
2205#if defined WLAN_FEATURE_VOWIFI_11R
2206 if (psessionEntry->pLimJoinReq->is11Rconnection)
2207 {
2208#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002209 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002210 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2211 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2212 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2213#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302214 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2215 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002216 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302217 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002218 {
2219 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302220 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002221 }
2222#endif
2223
2224#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302225 /* For CCX Associations fill the CCX IEs */
2226 if (psessionEntry->isCCXconnection &&
2227 psessionEntry->pLimJoinReq->isCCXFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002228 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002229#ifndef FEATURE_DISABLE_RM
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002230 PopulateDot11fCCXRadMgmtCap(&pFrm->CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002231#endif
Sandeep Puligillae9ffdf62013-11-23 18:23:00 +05302232 PopulateDot11fCCXVersion(&pFrm->CCXVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002233 }
2234#endif
2235
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002236 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002237 if ( DOT11F_FAILED( nStatus ) )
2238 {
2239 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002240 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002241 nStatus );
2242 // We'll fall back on the worst case scenario:
2243 nPayload = sizeof( tDot11fAssocRequest );
2244 }
2245 else if ( DOT11F_WARNED( nStatus ) )
2246 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002247 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002248 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002249 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002250 }
2251
2252 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2253
2254 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2255 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2256 ( void** ) &pPacket );
2257 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2258 {
2259 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002260 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002261
2262 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002263 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002264
2265
2266 /* Update PE session id*/
2267 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2268
2269 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2270
2271 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2272 ( void* ) pFrame, ( void* ) pPacket );
2273
2274 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2275 ( tANI_U32* ) &mlmAssocCnf);
2276
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302277 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002278 return;
2279 }
2280
2281 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302282 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002283
2284 // Next, we fill out the buffer descriptor:
2285 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2286 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2287 if ( eSIR_SUCCESS != nSirStatus )
2288 {
2289 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002290 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002291 nSirStatus );
2292 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302293 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002294 return;
2295 }
2296
2297
Abhishek Singh57aebef2014-02-03 18:47:44 +05302298 // That done, pack the Assoc Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002299 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002300 sizeof(tSirMacMgmtHdr),
2301 nPayload, &nPayload );
2302 if ( DOT11F_FAILED( nStatus ) )
2303 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302304 limLog( pMac, LOGE, FL("Failed to pack a Assoc Request (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002305 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002306 nStatus );
2307 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2308 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302309 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002310 return;
2311 }
2312 else if ( DOT11F_WARNED( nStatus ) )
2313 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302314 limLog( pMac, LOGW, FL("There were warnings while packing a Assoc"
2315 "Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002316 }
2317
2318 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002319 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002320 nBytes );)
2321 // limPrintMacAddr( pMac, bssid, LOG1 );
2322
2323 if( psessionEntry->assocReq != NULL )
2324 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302325 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002326 psessionEntry->assocReq = NULL;
2327 }
2328
2329 if( nAddIELen )
2330 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302331 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2332 pAddIE,
2333 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002334 nPayload += nAddIELen;
2335 }
2336
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302337 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2338 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002339 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302340 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store "
2341 "assoc request"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002342 }
2343 else
2344 {
2345 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302346 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002347 psessionEntry->assocReqLen = nPayload;
2348 }
2349
2350 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002351 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2352 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002353 )
2354 {
2355 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2356 }
2357
Ganesh K08bce952012-12-13 15:04:41 -08002358 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2359 {
2360 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2361 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302362
2363 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
2364 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2365 psessionEntry->peSessionId,
2366 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002367 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2368 HAL_TXRX_FRM_802_11_MGMT,
2369 ANI_TXDIR_TODS,
2370 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2371 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302372 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2373 psessionEntry->peSessionId,
2374 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002375 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2376 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002377 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002378 halstatus );
2379 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302380 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002381 return;
2382 }
2383
2384 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302385 vos_mem_free(pMlmAssocReq);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002386 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302387 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002388 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002389} // End limSendAssocReqMgmtFrame
2390
2391
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002392#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002393/*------------------------------------------------------------------------------------
2394 *
2395 * Send Reassoc Req with FTIEs.
2396 *
2397 *-----------------------------------------------------------------------------------
2398 */
2399void
2400limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2401 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2402{
2403 static tDot11fReAssocRequest frm;
2404 tANI_U16 caps;
2405 tANI_U8 *pFrame;
2406 tSirRetStatus nSirStatus;
2407 tANI_U32 nBytes, nPayload, nStatus;
2408 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2409 void *pPacket;
2410 eHalStatus halstatus;
2411#if defined WLAN_FEATURE_VOWIFI
2412 tANI_U8 PowerCapsPopulated = FALSE;
2413#endif
2414 tANI_U16 ft_ies_length = 0;
2415 tANI_U8 *pBody;
2416 tANI_U16 nAddIELen;
2417 tANI_U8 *pAddIE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002418#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002419 tANI_U8 *wpsIe = NULL;
2420#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302421 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302422 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002423
2424 if (NULL == psessionEntry)
2425 {
2426 return;
2427 }
2428
Jeff Johnson295189b2012-06-20 16:38:30 -07002429 /* check this early to avoid unncessary operation */
2430 if(NULL == psessionEntry->pLimReAssocReq)
2431 {
2432 return;
2433 }
2434 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2435 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002436 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2437 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002438
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302439 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002440
2441 caps = pMlmReassocReq->capabilityInfo;
2442 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2443 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2444#if defined(FEATURE_WLAN_WAPI)
2445 /* CR: 262463 :
2446 According to WAPI standard:
2447 7.3.1.4 Capability Information field
2448 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2449 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2450 Reassociation management frames. */
2451 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2452 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2453#endif
2454 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2455
2456 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2457
2458 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302459 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002460 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2461
2462 PopulateDot11fSSID2( pMac, &frm.SSID );
2463 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2464 &frm.SuppRates,psessionEntry);
2465
2466 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2467 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2468
2469 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2470 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2471
2472 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2473 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2474
2475 if ( psessionEntry->lim11hEnable &&
2476 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2477 {
2478#if defined WLAN_FEATURE_VOWIFI
2479 PowerCapsPopulated = TRUE;
2480
2481 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2482 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2483#endif
2484 }
2485
2486#if defined WLAN_FEATURE_VOWIFI
2487 if( pMac->rrm.rrmPEContext.rrmEnable &&
2488 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2489 {
2490 if (PowerCapsPopulated == FALSE)
2491 {
2492 PowerCapsPopulated = TRUE;
2493 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2494 }
2495 }
2496#endif
2497
2498 if ( fQosEnabled &&
2499 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2500 {
2501 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2502 }
2503
2504 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2505 &frm.ExtSuppRates, psessionEntry );
2506
2507#if defined WLAN_FEATURE_VOWIFI
2508 if( pMac->rrm.rrmPEContext.rrmEnable &&
2509 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2510 {
2511 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2512 }
2513#endif
2514
2515 // Ideally this should be enabled for 11r also. But 11r does
2516 // not follow the usual norm of using the Opaque object
2517 // for rsnie and fties. Instead we just add
2518 // the rsnie and fties at the end of the pack routine for 11r.
2519 // This should ideally! be fixed.
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002520#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002521 //
2522 // The join request *should* contain zero or one of the WPA and RSN
2523 // IEs. The payload send along with the request is a
2524 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2525
2526 // typedef struct sSirRSNie
2527 // {
2528 // tANI_U16 length;
2529 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2530 // } tSirRSNie, *tpSirRSNie;
2531
2532 // So, we should be able to make the following two calls harmlessly,
2533 // since they do nothing if they don't find the given IE in the
2534 // bytestream with which they're provided.
2535
2536 // The net effect of this will be to faithfully transmit whatever
2537 // security IE is in the join request.
2538
2539 // *However*, if we're associating for the purpose of WPS
2540 // enrollment, and we've been configured to indicate that by
2541 // eliding the WPA or RSN IE, we just skip this:
2542 if (!psessionEntry->is11Rconnection)
2543 {
2544 if( nAddIELen && pAddIE )
2545 {
2546 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2547 }
2548 if ( NULL == wpsIe )
2549 {
2550 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2551 &frm.RSNOpaque );
2552 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2553 &frm.WPAOpaque );
2554 }
2555
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002556#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302557 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002558 {
2559 PopulateDot11fCCXCckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2560 &frm.CCXCckmOpaque );
2561 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002562#endif //FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002563 }
2564
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002565#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002566 // For CCX Associations fill the CCX IEs
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302567 if (psessionEntry->isCCXconnection &&
2568 psessionEntry->pLimReAssocReq->isCCXFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002569 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002570#ifndef FEATURE_DISABLE_RM
Jeff Johnson295189b2012-06-20 16:38:30 -07002571 PopulateDot11fCCXRadMgmtCap(&frm.CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002572#endif
Sandeep Puligillae9ffdf62013-11-23 18:23:00 +05302573 PopulateDot11fCCXVersion(&frm.CCXVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302575#endif //FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002576#endif //FEATURE_WLAN_CCX || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002577
2578 // include WME EDCA IE as well
2579 if ( fWmeEnabled )
2580 {
2581 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2582 {
2583 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2584 }
2585
2586 if ( fWsmEnabled &&
2587 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2588 {
2589 PopulateDot11fWMMCaps( &frm.WMMCaps );
2590 }
2591#ifdef FEATURE_WLAN_CCX
2592 if (psessionEntry->isCCXconnection)
2593 {
2594 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2595
2596 // Populate the TSRS IE if TSPEC is included in the reassoc request
2597 if (psessionEntry->pLimReAssocReq->ccxTspecInfo.numTspecs)
2598 {
2599 tANI_U32 phyMode;
2600 tSirMacCCXTSRSIE tsrsIE;
2601 limGetPhyMode(pMac, &phyMode, psessionEntry);
2602
2603 tsrsIE.tsid = 0;
2604 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2605 {
2606 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2607 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302608 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002609 {
2610 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2611 }
2612 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.CCXTrafStrmRateSet, sizeof(tANI_U8));
2613 }
2614 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302615#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002616 }
2617
Jeff Johnsone7245742012-09-05 17:12:55 -07002618 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002619 pMac->lim.htCapabilityPresentInBeacon)
2620 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002621 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002622 }
2623
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002624#if defined WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302625 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent && (0 == pMac->ft.ftSmeContext.reassoc_ft_ies_length)
2626#if defined FEATURE_WLAN_CCX
2627 && !psessionEntry->isCCXconnection
2628#endif
2629 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002630 {
2631 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2632 }
2633#endif
2634
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002635#ifdef WLAN_FEATURE_11AC
2636 if ( psessionEntry->vhtCapability &&
2637 psessionEntry->vhtCapabilityPresentInBeacon)
2638 {
2639 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
2640 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002641 }
2642#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302643 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002644
Jeff Johnson295189b2012-06-20 16:38:30 -07002645 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2646 if ( DOT11F_FAILED( nStatus ) )
2647 {
2648 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002649 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002650 nStatus );
2651 // We'll fall back on the worst case scenario:
2652 nPayload = sizeof( tDot11fReAssocRequest );
2653 }
2654 else if ( DOT11F_WARNED( nStatus ) )
2655 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002656 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002657 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002658 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002659 }
2660
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002661 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002662
2663#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002664 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002665 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2666#endif
2667
2668#if defined WLAN_FEATURE_VOWIFI_11R
2669 if (psessionEntry->is11Rconnection)
2670 {
2671 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2672 }
2673#endif
2674
2675 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2676 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2677 ( void** ) &pPacket );
2678 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2679 {
2680 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002681 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002682 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002683 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002684 goto end;
2685 }
2686
2687 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302688 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002689
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002690#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002691 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002692#endif
2693 // Next, we fill out the buffer descriptor:
2694 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2695 SIR_MAC_MGMT_REASSOC_REQ,
2696 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2697 if ( eSIR_SUCCESS != nSirStatus )
2698 {
2699 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002700 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002701 nSirStatus );
2702 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2703 goto end;
2704 }
2705
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302706 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07002707 // That done, pack the ReAssoc Request:
2708 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2709 sizeof(tSirMacMgmtHdr),
2710 nPayload, &nPayload );
2711 if ( DOT11F_FAILED( nStatus ) )
2712 {
2713 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002714 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002715 nStatus );
2716 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2717 goto end;
2718 }
2719 else if ( DOT11F_WARNED( nStatus ) )
2720 {
2721 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002722 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002723 }
2724
2725 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002726 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002727 nBytes, nPayload );)
2728 if( psessionEntry->assocReq != NULL )
2729 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302730 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002731 psessionEntry->assocReq = NULL;
2732 }
2733
2734 if( nAddIELen )
2735 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302736 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2737 pAddIE,
2738 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002739 nPayload += nAddIELen;
2740 }
2741
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302742 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2743 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002744 {
2745 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002746 }
2747 else
2748 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002749 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302750 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002751 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002752 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002753
2754 if (psessionEntry->is11Rconnection)
2755 {
2756 {
2757 int i = 0;
2758
2759 pBody = pFrame + nBytes;
2760 for (i=0; i<ft_ies_length; i++)
2761 {
2762 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2763 pBody++;
2764 }
2765 }
2766 }
2767
2768#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002769 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
2770 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002771 (tANI_U8 *)pFrame,
2772 (nBytes + ft_ies_length));)
2773#endif
2774
2775
2776 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002777 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2778 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002779 )
2780 {
2781 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2782 }
2783
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002784 if( NULL != psessionEntry->assocReq )
2785 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302786 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002787 psessionEntry->assocReq = NULL;
2788 }
2789
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302790 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
2791 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002792 {
2793 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002794 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002795 }
2796 else
2797 {
2798 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302799 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
2800 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002801 psessionEntry->assocReqLen = (ft_ies_length);
2802 }
2803
2804
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302805 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2806 psessionEntry->peSessionId,
2807 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002808 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
2809 HAL_TXRX_FRM_802_11_MGMT,
2810 ANI_TXDIR_TODS,
2811 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2812 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302813 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2814 psessionEntry->peSessionId,
2815 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002816 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2817 {
2818 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002819 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002820 nSirStatus );
2821 //Pkt will be freed up by the callback
2822 goto end;
2823 }
2824
2825end:
2826 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302827 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07002828 psessionEntry->pLimMlmReassocReq = NULL;
2829
2830}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002831
2832void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
2833 tLimMlmReassocReq *pMlmReassocReq,
2834 tpPESession psessionEntry)
2835{
2836 tLimMlmReassocCnf mlmReassocCnf; // keep sme
2837 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
2838 if(NULL == pTmpMlmReassocReq)
2839 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302840 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
2841 if ( NULL == pTmpMlmReassocReq ) goto end;
2842 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
2843 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002844 }
2845
2846 // Prepare and send Reassociation request frame
2847 // start reassoc timer.
2848 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
2849 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002850 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002851 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
2852 != TX_SUCCESS)
2853 {
2854 // Could not start reassoc failure timer.
2855 // Log error
2856 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002857 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002858 // Return Reassoc confirm with
2859 // Resources Unavailable
2860 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2861 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2862 goto end;
2863 }
2864
2865 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
2866 return;
2867
2868end:
2869 // Free up buffer allocated for reassocReq
2870 if (pMlmReassocReq != NULL)
2871 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302872 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002873 pMlmReassocReq = NULL;
2874 }
2875 if (pTmpMlmReassocReq != NULL)
2876 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302877 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002878 pTmpMlmReassocReq = NULL;
2879 }
2880 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
2881 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2882 /* Update PE sessio Id*/
2883 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
2884
2885 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
2886}
2887
Jeff Johnson295189b2012-06-20 16:38:30 -07002888#endif /* WLAN_FEATURE_VOWIFI_11R */
2889
2890
2891void
2892limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
2893 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2894{
2895 static tDot11fReAssocRequest frm;
2896 tANI_U16 caps;
2897 tANI_U8 *pFrame;
2898 tSirRetStatus nSirStatus;
2899 tANI_U32 nBytes, nPayload, nStatus;
2900 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2901 void *pPacket;
2902 eHalStatus halstatus;
2903 tANI_U16 nAddIELen;
2904 tANI_U8 *pAddIE;
2905 tANI_U8 *wpsIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302906 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002907#if defined WLAN_FEATURE_VOWIFI
2908 tANI_U8 PowerCapsPopulated = FALSE;
2909#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302910 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002911
2912 if(NULL == psessionEntry)
2913 {
2914 return;
2915 }
2916
2917 /* check this early to avoid unncessary operation */
2918 if(NULL == psessionEntry->pLimReAssocReq)
2919 {
2920 return;
2921 }
2922 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2923 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
2924
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302925 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002926
2927 caps = pMlmReassocReq->capabilityInfo;
2928 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2929 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2930#if defined(FEATURE_WLAN_WAPI)
2931 /* CR: 262463 :
2932 According to WAPI standard:
2933 7.3.1.4 Capability Information field
2934 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2935 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2936 Reassociation management frames. */
2937 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2938 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2939#endif
2940 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2941
2942 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2943
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302944 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
2945 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002946
2947 PopulateDot11fSSID2( pMac, &frm.SSID );
2948 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2949 &frm.SuppRates,psessionEntry);
2950
2951 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
2952 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2953
2954 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2955 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2956
2957 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2958 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2959
2960
2961 if ( psessionEntry->lim11hEnable &&
2962 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2963 {
2964#if defined WLAN_FEATURE_VOWIFI
2965 PowerCapsPopulated = TRUE;
2966 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2967 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2968#endif
2969 }
2970
2971#if defined WLAN_FEATURE_VOWIFI
2972 if( pMac->rrm.rrmPEContext.rrmEnable &&
2973 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2974 {
2975 if (PowerCapsPopulated == FALSE)
2976 {
2977 PowerCapsPopulated = TRUE;
2978 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2979 }
2980 }
2981#endif
2982
2983 if ( fQosEnabled &&
2984 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2985 {
2986 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2987 }
2988
2989 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2990 &frm.ExtSuppRates, psessionEntry );
2991
2992#if defined WLAN_FEATURE_VOWIFI
2993 if( pMac->rrm.rrmPEContext.rrmEnable &&
2994 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2995 {
2996 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2997 }
2998#endif
2999 // The join request *should* contain zero or one of the WPA and RSN
3000 // IEs. The payload send along with the request is a
3001 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
3002
3003 // typedef struct sSirRSNie
3004 // {
3005 // tANI_U16 length;
3006 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
3007 // } tSirRSNie, *tpSirRSNie;
3008
3009 // So, we should be able to make the following two calls harmlessly,
3010 // since they do nothing if they don't find the given IE in the
3011 // bytestream with which they're provided.
3012
3013 // The net effect of this will be to faithfully transmit whatever
3014 // security IE is in the join request.
3015
3016 // *However*, if we're associating for the purpose of WPS
3017 // enrollment, and we've been configured to indicate that by
3018 // eliding the WPA or RSN IE, we just skip this:
3019 if( nAddIELen && pAddIE )
3020 {
3021 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
3022 }
3023 if ( NULL == wpsIe )
3024 {
3025 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3026 &frm.RSNOpaque );
3027 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3028 &frm.WPAOpaque );
3029#if defined(FEATURE_WLAN_WAPI)
3030 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3031 &frm.WAPIOpaque );
3032#endif // defined(FEATURE_WLAN_WAPI)
3033 }
3034
3035 // include WME EDCA IE as well
3036 if ( fWmeEnabled )
3037 {
3038 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
3039 {
3040 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
3041 }
3042
3043 if ( fWsmEnabled &&
3044 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3045 {
3046 PopulateDot11fWMMCaps( &frm.WMMCaps );
3047 }
3048 }
3049
Jeff Johnsone7245742012-09-05 17:12:55 -07003050 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003051 pMac->lim.htCapabilityPresentInBeacon)
3052 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003053 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003054 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003055#ifdef WLAN_FEATURE_11AC
3056 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003057 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003058 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003059 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003060 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Sandeep Puligilla60342762014-01-30 21:05:37 +05303061 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003062 }
3063#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003064
3065 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3066 if ( DOT11F_FAILED( nStatus ) )
3067 {
3068 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003069 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003070 nStatus );
3071 // We'll fall back on the worst case scenario:
3072 nPayload = sizeof( tDot11fReAssocRequest );
3073 }
3074 else if ( DOT11F_WARNED( nStatus ) )
3075 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003076 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003077 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003078 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003079 }
3080
3081 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3082
3083 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3084 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3085 ( void** ) &pPacket );
3086 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3087 {
3088 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003089 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003090 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003091 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003092 goto end;
3093 }
3094
3095 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303096 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003097
3098 // Next, we fill out the buffer descriptor:
3099 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3100 SIR_MAC_MGMT_REASSOC_REQ,
3101 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3102 if ( eSIR_SUCCESS != nSirStatus )
3103 {
3104 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003105 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003106 nSirStatus );
3107 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3108 goto end;
3109 }
3110
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303111 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003112 // That done, pack the Probe Request:
3113 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3114 sizeof(tSirMacMgmtHdr),
3115 nPayload, &nPayload );
3116 if ( DOT11F_FAILED( nStatus ) )
3117 {
3118 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003119 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003120 nStatus );
3121 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3122 goto end;
3123 }
3124 else if ( DOT11F_WARNED( nStatus ) )
3125 {
3126 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003127 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003128 }
3129
3130 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003131 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003132 nBytes );)
3133
3134 if( psessionEntry->assocReq != NULL )
3135 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303136 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003137 psessionEntry->assocReq = NULL;
3138 }
3139
3140 if( nAddIELen )
3141 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303142 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3143 pAddIE,
3144 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003145 nPayload += nAddIELen;
3146 }
3147
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303148 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3149 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003150 {
3151 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003152 }
3153 else
3154 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003155 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303156 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003157 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003158 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003159
3160 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003161 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3162 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003163 )
3164 {
3165 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3166 }
3167
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003168 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003169 {
3170 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3171 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003172
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303173 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3174 psessionEntry->peSessionId,
3175 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003176 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3177 HAL_TXRX_FRM_802_11_MGMT,
3178 ANI_TXDIR_TODS,
3179 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3180 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303181 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3182 psessionEntry->peSessionId,
3183 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003184 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3185 {
3186 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003187 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003188 nSirStatus );
3189 //Pkt will be freed up by the callback
3190 goto end;
3191 }
3192
3193end:
3194 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303195 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003196 psessionEntry->pLimMlmReassocReq = NULL;
3197
3198} // limSendReassocReqMgmtFrame
3199
3200/**
3201 * \brief Send an Authentication frame
3202 *
3203 *
3204 * \param pMac Pointer to Global MAC structure
3205 *
3206 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3207 * to be sent
3208 *
3209 * \param peerMacAddr MAC address of the peer entity to which Authentication
3210 * frame is destined
3211 *
3212 * \param wepBit Indicates whether wep bit to be set in FC while sending
3213 * Authentication frame3
3214 *
3215 *
3216 * This function is called by limProcessMlmMessages(). Authentication frame
3217 * is formatted and sent when this function is called.
3218 *
3219 *
3220 */
3221
3222void
3223limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3224 tpSirMacAuthFrameBody pAuthFrameBody,
3225 tSirMacAddr peerMacAddr,
3226 tANI_U8 wepBit,
3227 tpPESession psessionEntry
3228 )
3229{
3230 tANI_U8 *pFrame, *pBody;
3231 tANI_U32 frameLen = 0, bodyLen = 0;
3232 tpSirMacMgmtHdr pMacHdr;
3233 tANI_U16 i;
3234 void *pPacket;
3235 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303236 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003237
3238 if(NULL == psessionEntry)
3239 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303240 limLog(pMac, LOGE, FL("Error: psession Entry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003241 return;
3242 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05303243
3244 limLog(pMac, LOG1,
3245 FL("Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
3246 pAuthFrameBody->authTransactionSeqNumber,
3247 pAuthFrameBody->authStatusCode,
3248 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3249 MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003250 if (wepBit == LIM_WEP_IN_FC)
3251 {
3252 /// Auth frame3 to be sent with encrypted framebody
3253 /**
3254 * Allocate buffer for Authenticaton frame of size equal
3255 * to management frame header length plus 2 bytes each for
3256 * auth algorithm number, transaction number, status code,
3257 * 128 bytes for challenge text and 4 bytes each for
3258 * IV & ICV.
3259 */
3260
3261 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3262
3263 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3264 } // if (wepBit == LIM_WEP_IN_FC)
3265 else
3266 {
3267 switch (pAuthFrameBody->authTransactionSeqNumber)
3268 {
3269 case SIR_MAC_AUTH_FRAME_1:
3270 /**
3271 * Allocate buffer for Authenticaton frame of size
3272 * equal to management frame header length plus 2 bytes
3273 * each for auth algorithm number, transaction number
3274 * and status code.
3275 */
3276
3277 frameLen = sizeof(tSirMacMgmtHdr) +
3278 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3279 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3280
3281#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003282 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3283 {
3284 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003285 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003286 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003287 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003288 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003289 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003290 else
3291 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303292 limLog(pMac, LOG3, FL("Auth frame, Does not contain "
3293 "FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003294 frameLen += (2+SIR_MDIE_SIZE);
3295 }
3296 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003297#endif
3298 break;
3299
3300 case SIR_MAC_AUTH_FRAME_2:
3301 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3302 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3303 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3304 {
3305 /**
3306 * Allocate buffer for Authenticaton frame of size
3307 * equal to management frame header length plus
3308 * 2 bytes each for auth algorithm number,
3309 * transaction number and status code.
3310 */
3311
3312 frameLen = sizeof(tSirMacMgmtHdr) +
3313 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3314 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3315 }
3316 else
3317 {
3318 // Shared Key algorithm with challenge text
3319 // to be sent
3320 /**
3321 * Allocate buffer for Authenticaton frame of size
3322 * equal to management frame header length plus
3323 * 2 bytes each for auth algorithm number,
3324 * transaction number, status code and 128 bytes
3325 * for challenge text.
3326 */
3327
3328 frameLen = sizeof(tSirMacMgmtHdr) +
3329 sizeof(tSirMacAuthFrame);
3330 bodyLen = sizeof(tSirMacAuthFrameBody);
3331 }
3332
3333 break;
3334
3335 case SIR_MAC_AUTH_FRAME_3:
3336 /// Auth frame3 to be sent without encrypted framebody
3337 /**
3338 * Allocate buffer for Authenticaton frame of size equal
3339 * to management frame header length plus 2 bytes each
3340 * for auth algorithm number, transaction number and
3341 * status code.
3342 */
3343
3344 frameLen = sizeof(tSirMacMgmtHdr) +
3345 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3346 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3347
3348 break;
3349
3350 case SIR_MAC_AUTH_FRAME_4:
3351 /**
3352 * Allocate buffer for Authenticaton frame of size equal
3353 * to management frame header length plus 2 bytes each
3354 * for auth algorithm number, transaction number and
3355 * status code.
3356 */
3357
3358 frameLen = sizeof(tSirMacMgmtHdr) +
3359 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3360 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3361
3362 break;
3363 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3364 } // end if (wepBit == LIM_WEP_IN_FC)
3365
3366
3367 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3368
3369 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3370 {
3371 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003372 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003373
3374 return;
3375 }
3376
3377 for (i = 0; i < frameLen; i++)
3378 pFrame[i] = 0;
3379
3380 // Prepare BD
3381 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3382 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3383 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303384 limLog(pMac, LOGE, FL("call to limPopulateMacHeader failed for "
3385 "AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003386 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3387 return;
3388 }
3389
3390 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3391 pMacHdr->fc.wep = wepBit;
3392
3393 // Prepare BSSId
3394 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3395 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303396 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3397 (tANI_U8 *) psessionEntry->bssId,
3398 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003399 }
3400
3401 /// Prepare Authentication frame body
3402 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3403
3404 if (wepBit == LIM_WEP_IN_FC)
3405 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303406 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003407
3408 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303409 FL("*** Sending Auth seq# 3 status %d (%d) to"MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303411 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3412 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003413
Jeff Johnson295189b2012-06-20 16:38:30 -07003414 }
3415 else
3416 {
3417 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3418 pBody += sizeof(tANI_U16);
3419 bodyLen -= sizeof(tANI_U16);
3420
3421 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3422 pBody += sizeof(tANI_U16);
3423 bodyLen -= sizeof(tANI_U16);
3424
3425 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3426 pBody += sizeof(tANI_U16);
3427 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003428 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3429 sizeof (pAuthFrameBody->length) +
3430 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303431 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003432
3433#if defined WLAN_FEATURE_VOWIFI_11R
3434 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3435 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3436 {
3437
3438 {
3439 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003440 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3441 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003442#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowdad63eb492014-02-06 12:21:47 -08003443 PELOG2(limLog(pMac, LOG2, FL("Auth1 Frame FTIE is: "));
3444 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
Jeff Johnson295189b2012-06-20 16:38:30 -07003445 (tANI_U8 *)pBody,
3446 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003447#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003448 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3449 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003450 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3451 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003452 }
3453 }
3454 else
3455 {
3456 /* MDID attr is 54*/
3457 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003458 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003459 *pBody = SIR_MDIE_SIZE;
3460 pBody++;
3461 for(i=0;i<SIR_MDIE_SIZE;i++)
3462 {
3463 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3464 pBody++;
3465 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003466 }
3467 }
3468 }
3469#endif
3470
3471 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303472 FL("*** Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003473 pAuthFrameBody->authTransactionSeqNumber,
3474 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303475 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3476 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003477 }
3478 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3479
3480 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003481 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3482 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07003483#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303484 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003485 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3486#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003487 )
3488 {
3489 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3490 }
3491
Ganesh K08bce952012-12-13 15:04:41 -08003492 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3493 {
3494 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3495 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003496
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303497 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3498 psessionEntry->peSessionId,
3499 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003500 /// Queue Authentication frame in high priority WQ
3501 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3502 HAL_TXRX_FRM_802_11_MGMT,
3503 ANI_TXDIR_TODS,
3504 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3505 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303506 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3507 psessionEntry->peSessionId,
3508 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003509 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3510 {
3511 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003512 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003513 halstatus);
3514
3515 //Pkt will be freed up by the callback
3516 }
3517
3518 return;
3519} /*** end limSendAuthMgmtFrame() ***/
3520
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003521eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3522{
3523 tANI_U16 aid;
3524 tpDphHashNode pStaDs;
3525 tLimMlmDeauthReq *pMlmDeauthReq;
3526 tLimMlmDeauthCnf mlmDeauthCnf;
3527 tpPESession psessionEntry;
3528
3529 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3530 if (pMlmDeauthReq)
3531 {
3532 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3533 {
3534 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3535 }
3536
3537 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3538 {
3539
3540 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003541 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003542 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3543 goto end;
3544 }
3545
3546 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3547 if (pStaDs == NULL)
3548 {
3549 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3550 goto end;
3551 }
3552
3553
3554 /// Receive path cleanup with dummy packet
3555 limCleanupRxPath(pMac, pStaDs,psessionEntry);
3556 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303557 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003558 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3559 }
3560 return eHAL_STATUS_SUCCESS;
3561end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303562 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003563 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3564 sizeof(tSirMacAddr));
3565 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3566 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3567 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3568
3569 // Free up buffer allocated
3570 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303571 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003572
3573 limPostSmeMessage(pMac,
3574 LIM_MLM_DEAUTH_CNF,
3575 (tANI_U32 *) &mlmDeauthCnf);
3576 return eHAL_STATUS_SUCCESS;
3577}
3578
3579eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3580{
3581 tANI_U16 aid;
3582 tpDphHashNode pStaDs;
3583 tLimMlmDisassocCnf mlmDisassocCnf;
3584 tpPESession psessionEntry;
3585 tLimMlmDisassocReq *pMlmDisassocReq;
3586
3587 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3588 if (pMlmDisassocReq)
3589 {
3590 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3591 {
3592 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3593 }
3594
3595 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3596 {
3597
3598 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003599 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003600 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3601 goto end;
3602 }
3603
3604 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3605 if (pStaDs == NULL)
3606 {
3607 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3608 goto end;
3609 }
3610
3611 /// Receive path cleanup with dummy packet
3612 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3613 {
3614 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3615 goto end;
3616 }
3617
3618#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003619 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303620 (
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003621#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303622 (psessionEntry->isCCXconnection ) ||
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003623#endif
3624#ifdef FEATURE_WLAN_LFR
3625 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003626#endif
3627 (psessionEntry->is11Rconnection )) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303628 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003629 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003630 {
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303631 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003632 FL("FT Preauth Session (%p,%d) Cleanup"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003633 psessionEntry, psessionEntry->peSessionId););
3634 limFTCleanup(pMac);
3635 }
3636 else
3637 {
3638 PELOGE(limLog(pMac, LOGE,
3639 FL("No FT Preauth Session Cleanup in role %d"
3640#ifdef FEATURE_WLAN_CCX
3641 " isCCX %d"
3642#endif
3643#ifdef FEATURE_WLAN_LFR
3644 " isLFR %d"
3645#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003646 " is11r %d reason %d"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003647 psessionEntry->limSystemRole,
3648#ifdef FEATURE_WLAN_CCX
3649 psessionEntry->isCCXconnection,
3650#endif
3651#ifdef FEATURE_WLAN_LFR
3652 psessionEntry->isFastRoamIniFeatureEnabled,
3653#endif
3654 psessionEntry->is11Rconnection,
3655 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003656 }
3657#endif
3658
3659 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303660 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003661 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3662 return eHAL_STATUS_SUCCESS;
3663 }
3664 else
3665 {
3666 return eHAL_STATUS_SUCCESS;
3667 }
3668end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303669 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003670 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3671 sizeof(tSirMacAddr));
3672 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3673 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3674
3675 /* Update PE session ID*/
3676 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3677
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003678 if(pMlmDisassocReq != NULL)
3679 {
3680 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303681 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003682 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3683 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003684
3685 limPostSmeMessage(pMac,
3686 LIM_MLM_DISASSOC_CNF,
3687 (tANI_U32 *) &mlmDisassocCnf);
3688 return eHAL_STATUS_SUCCESS;
3689}
3690
3691eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3692{
3693 return limSendDisassocCnf(pMac);
3694}
3695
3696eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3697{
3698 return limSendDeauthCnf(pMac);
3699}
3700
Jeff Johnson295189b2012-06-20 16:38:30 -07003701/**
3702 * \brief This function is called to send Disassociate frame.
3703 *
3704 *
3705 * \param pMac Pointer to Global MAC structure
3706 *
3707 * \param nReason Indicates the reason that need to be sent in
3708 * Disassociation frame
3709 *
3710 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3711 * sent
3712 *
3713 *
3714 */
3715
3716void
3717limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3718 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003719 tSirMacAddr peer,
3720 tpPESession psessionEntry,
3721 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003722{
3723 tDot11fDisassociation frm;
3724 tANI_U8 *pFrame;
3725 tSirRetStatus nSirStatus;
3726 tpSirMacMgmtHdr pMacHdr;
3727 tANI_U32 nBytes, nPayload, nStatus;
3728 void *pPacket;
3729 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303730 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003731 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003732 if(NULL == psessionEntry)
3733 {
3734 return;
3735 }
3736
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303737 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003738
3739 frm.Reason.code = nReason;
3740
3741 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
3742 if ( DOT11F_FAILED( nStatus ) )
3743 {
3744 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003745 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003746 nStatus );
3747 // We'll fall back on the worst case scenario:
3748 nPayload = sizeof( tDot11fDisassociation );
3749 }
3750 else if ( DOT11F_WARNED( nStatus ) )
3751 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003752 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003753 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003754 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003755 }
3756
3757 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3758
3759 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3760 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3761 ( void** ) &pPacket );
3762 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3763 {
3764 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003765 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003766 return;
3767 }
3768
3769 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303770 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003771
3772 // Next, we fill out the buffer descriptor:
3773 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3774 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
3775 if ( eSIR_SUCCESS != nSirStatus )
3776 {
3777 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003778 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003779 nSirStatus );
3780 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3781 ( void* ) pFrame, ( void* ) pPacket );
3782 return; // just allocated...
3783 }
3784
3785 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3786
3787 // Prepare the BSSID
3788 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3789
Chet Lanctot186b5732013-03-18 10:26:30 -07003790#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003791 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003792#endif
3793
Jeff Johnson295189b2012-06-20 16:38:30 -07003794 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
3795 sizeof(tSirMacMgmtHdr),
3796 nPayload, &nPayload );
3797 if ( DOT11F_FAILED( nStatus ) )
3798 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003799 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003800 nStatus );
3801 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3802 ( void* ) pFrame, ( void* ) pPacket );
3803 return; // allocated!
3804 }
3805 else if ( DOT11F_WARNED( nStatus ) )
3806 {
3807 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003808 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003809 }
3810
Abhishek Singhcd09b562013-12-24 16:02:20 +05303811 limLog( pMac, LOG1, FL("***Sessionid %d Sending Disassociation frame with "
3812 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
3813 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
3814 MAC_ADDR_ARRAY(pMacHdr->da),
3815 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003816
3817 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003818 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3819 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003820 )
3821 {
3822 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3823 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003824
Ganesh K08bce952012-12-13 15:04:41 -08003825 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303826 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
3827 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08003828 {
3829 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3830 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003831
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303832 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
3833 {
3834 /* This frame will be sent on air by firmware,
3835 which will ensure that this frame goes out
3836 even though DEL_STA is sent immediately */
3837 /* Without this for DEL_STA command there is
3838 risk of flushing frame in BTQM queue without
3839 sending on air */
3840 txFlag |= HAL_USE_FW_IN_TX_PATH;
3841 }
3842
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003843 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003844 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303845 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3846 psessionEntry->peSessionId,
3847 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003848 // Queue Disassociation frame in high priority WQ
3849 /* get the duration from the request */
3850 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3851 HAL_TXRX_FRM_802_11_MGMT,
3852 ANI_TXDIR_TODS,
3853 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3854 limTxComplete, pFrame, limDisassocTxCompleteCnf,
3855 txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303856 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3857 psessionEntry->peSessionId,
3858 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003859 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07003860
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003861 if (tx_timer_change(
3862 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
3863 != TX_SUCCESS)
3864 {
3865 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003866 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003867 return;
3868 }
3869 else if(TX_SUCCESS != tx_timer_activate(
3870 &pMac->lim.limTimers.gLimDisassocAckTimer))
3871 {
3872 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003873 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003874 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3875 return;
3876 }
3877 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003878 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003879 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303880 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3881 psessionEntry->peSessionId,
3882 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003883 // Queue Disassociation frame in high priority WQ
3884 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3885 HAL_TXRX_FRM_802_11_MGMT,
3886 ANI_TXDIR_TODS,
3887 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3888 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303889 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3890 psessionEntry->peSessionId,
3891 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003892 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3893 {
3894 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003895 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003896 nSirStatus );
3897 //Pkt will be freed up by the callback
3898 return;
3899 }
3900 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003901} // End limSendDisassocMgmtFrame.
3902
3903/**
3904 * \brief This function is called to send a Deauthenticate frame
3905 *
3906 *
3907 * \param pMac Pointer to global MAC structure
3908 *
3909 * \param nReason Indicates the reason that need to be sent in the
3910 * Deauthenticate frame
3911 *
3912 * \param peeer address of the STA to which the frame is to be sent
3913 *
3914 *
3915 */
3916
3917void
3918limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
3919 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003920 tSirMacAddr peer,
3921 tpPESession psessionEntry,
3922 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003923{
3924 tDot11fDeAuth frm;
3925 tANI_U8 *pFrame;
3926 tSirRetStatus nSirStatus;
3927 tpSirMacMgmtHdr pMacHdr;
3928 tANI_U32 nBytes, nPayload, nStatus;
3929 void *pPacket;
3930 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303931 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003932 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003933#ifdef FEATURE_WLAN_TDLS
3934 tANI_U16 aid;
3935 tpDphHashNode pStaDs;
3936#endif
3937
Jeff Johnson295189b2012-06-20 16:38:30 -07003938 if(NULL == psessionEntry)
3939 {
3940 return;
3941 }
3942
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303943 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003944
3945 frm.Reason.code = nReason;
3946
3947 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
3948 if ( DOT11F_FAILED( nStatus ) )
3949 {
3950 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003951 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003952 nStatus );
3953 // We'll fall back on the worst case scenario:
3954 nPayload = sizeof( tDot11fDeAuth );
3955 }
3956 else if ( DOT11F_WARNED( nStatus ) )
3957 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003958 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003959 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003960 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003961 }
3962
3963 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3964
3965 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3966 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3967 ( void** ) &pPacket );
3968 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3969 {
3970 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003971 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003972 return;
3973 }
3974
3975 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303976 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003977
3978 // Next, we fill out the buffer descriptor:
3979 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3980 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
3981 if ( eSIR_SUCCESS != nSirStatus )
3982 {
3983 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003984 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003985 nSirStatus );
3986 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3987 ( void* ) pFrame, ( void* ) pPacket );
3988 return; // just allocated...
3989 }
3990
3991 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3992
3993 // Prepare the BSSID
3994 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3995
Chet Lanctot186b5732013-03-18 10:26:30 -07003996#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003997 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003998#endif
3999
Jeff Johnson295189b2012-06-20 16:38:30 -07004000 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
4001 sizeof(tSirMacMgmtHdr),
4002 nPayload, &nPayload );
4003 if ( DOT11F_FAILED( nStatus ) )
4004 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004005 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004006 nStatus );
4007 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4008 ( void* ) pFrame, ( void* ) pPacket );
4009 return;
4010 }
4011 else if ( DOT11F_WARNED( nStatus ) )
4012 {
4013 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004014 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004015 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05304016 limLog( pMac, LOG1, FL("***Sessionid %d Sending Deauth frame with "
4017 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4018 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4019 MAC_ADDR_ARRAY(pMacHdr->da),
4020 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004021
4022 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004023 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4024 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004025 )
4026 {
4027 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4028 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004029
Ganesh K08bce952012-12-13 15:04:41 -08004030 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304031 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
4032 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08004033 {
4034 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4035 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004036
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304037 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4038 {
4039 /* This frame will be sent on air by firmware,
4040 which will ensure that this frame goes out
4041 even though DEL_STA is sent immediately */
4042 /* Without this for DEL_STA command there is
4043 risk of flushing frame in BTQM queue without
4044 sending on air */
4045 txFlag |= HAL_USE_FW_IN_TX_PATH;
4046 }
4047
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004048#ifdef FEATURE_WLAN_TDLS
4049 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
4050#endif
4051
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004052 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004053 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304054 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4055 psessionEntry->peSessionId,
4056 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004057 // Queue Disassociation frame in high priority WQ
4058 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4059 HAL_TXRX_FRM_802_11_MGMT,
4060 ANI_TXDIR_TODS,
4061 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4062 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304063 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4064 psessionEntry->peSessionId,
4065 halstatus));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304066 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004067 {
4068 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304069 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004070 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08004071 //Pkt will be freed up by the callback limTxComplete
4072
4073 /*Call limProcessDeauthAckTimeout which will send
4074 * DeauthCnf for this frame
4075 */
4076 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004077 return;
4078 }
4079
4080 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
4081
4082 if (tx_timer_change(
4083 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
4084 != TX_SUCCESS)
4085 {
4086 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004087 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004088 return;
4089 }
4090 else if(TX_SUCCESS != tx_timer_activate(
4091 &pMac->lim.limTimers.gLimDeauthAckTimer))
4092 {
4093 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004094 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004095 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4096 return;
4097 }
4098 }
4099 else
4100 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304101 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4102 psessionEntry->peSessionId,
4103 pMacHdr->fc.subType));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004104#ifdef FEATURE_WLAN_TDLS
4105 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4106 {
4107 // Queue Disassociation frame in high priority WQ
4108 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004109 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004110 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004111 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4112 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004113 }
4114 else
4115 {
4116#endif
4117 // Queue Disassociation frame in high priority WQ
4118 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4119 HAL_TXRX_FRM_802_11_MGMT,
4120 ANI_TXDIR_TODS,
4121 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4122 limTxComplete, pFrame, txFlag );
4123#ifdef FEATURE_WLAN_TDLS
4124 }
4125#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304126 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4127 psessionEntry->peSessionId,
4128 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004129 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4130 {
4131 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004132 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004133 nSirStatus );
4134 //Pkt will be freed up by the callback
4135 return;
4136 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004137 }
4138
4139} // End limSendDeauthMgmtFrame.
4140
4141
4142#ifdef ANI_SUPPORT_11H
4143/**
4144 * \brief Send a Measurement Report Action frame
4145 *
4146 *
4147 * \param pMac Pointer to the global MAC structure
4148 *
4149 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4150 *
4151 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4152 *
4153 *
4154 */
4155
4156tSirRetStatus
4157limSendMeasReportFrame(tpAniSirGlobal pMac,
4158 tpSirMacMeasReqActionFrame pMeasReqFrame,
4159 tSirMacAddr peer)
4160{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304161 tDot11fMeasurementReport frm;
4162 tANI_U8 *pFrame;
4163 tSirRetStatus nSirStatus;
4164 tpSirMacMgmtHdr pMacHdr;
4165 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4166 void *pPacket;
4167 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004168
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304169 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004170
4171 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4172 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4173 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4174
4175 switch ( pMeasReqFrame->measReqIE.measType )
4176 {
4177 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4178 nSirStatus =
4179 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4180 &frm.MeasurementReport );
4181 break;
4182 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4183 nSirStatus =
4184 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4185 &frm.MeasurementReport );
4186 break;
4187 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4188 nSirStatus =
4189 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4190 &frm.MeasurementReport );
4191 break;
4192 default:
4193 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004194 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004195 pMeasReqFrame->measReqIE.measType );
4196 return eSIR_FAILURE;
4197 }
4198
4199 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4200
4201 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4202 if ( DOT11F_FAILED( nStatus ) )
4203 {
4204 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004205 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004206 nStatus );
4207 // We'll fall back on the worst case scenario:
4208 nPayload = sizeof( tDot11fMeasurementReport );
4209 }
4210 else if ( DOT11F_WARNED( nStatus ) )
4211 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004212 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004213 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004214 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004215 }
4216
4217 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4218
4219 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4220 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4221 {
4222 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004223 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004224 return eSIR_FAILURE;
4225 }
4226
4227 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304228 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004229
4230 // Next, we fill out the buffer descriptor:
4231 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4232 SIR_MAC_MGMT_ACTION, peer);
4233 if ( eSIR_SUCCESS != nSirStatus )
4234 {
4235 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004236 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004237 nSirStatus );
4238 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4239 return eSIR_FAILURE; // just allocated...
4240 }
4241
4242 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4243
4244 nCfg = 6;
4245 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4246 if ( eSIR_SUCCESS != nSirStatus )
4247 {
4248 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004249 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004250 nSirStatus );
4251 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4252 return eSIR_FAILURE; // just allocated...
4253 }
4254
Chet Lanctot186b5732013-03-18 10:26:30 -07004255#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004256 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004257#endif
4258
Jeff Johnson295189b2012-06-20 16:38:30 -07004259 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4260 sizeof(tSirMacMgmtHdr),
4261 nPayload, &nPayload );
4262 if ( DOT11F_FAILED( nStatus ) )
4263 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004264 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004265 nStatus );
4266 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4267 return eSIR_FAILURE; // allocated!
4268 }
4269 else if ( DOT11F_WARNED( nStatus ) )
4270 {
4271 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004272 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004273 }
4274
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304275 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4276 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4277 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004278 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4279 HAL_TXRX_FRM_802_11_MGMT,
4280 ANI_TXDIR_TODS,
4281 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4282 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304283 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4284 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4285 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004286 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4287 {
4288 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004289 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004290 nSirStatus );
4291 //Pkt will be freed up by the callback
4292 return eSIR_FAILURE; // just allocated...
4293 }
4294
4295 return eSIR_SUCCESS;
4296
4297} // End limSendMeasReportFrame.
4298
4299
4300/**
4301 * \brief Send a TPC Request Action frame
4302 *
4303 *
4304 * \param pMac Pointer to the global MAC datastructure
4305 *
4306 * \param peer MAC address to which the frame should be sent
4307 *
4308 *
4309 */
4310
4311void
4312limSendTpcRequestFrame(tpAniSirGlobal pMac,
4313 tSirMacAddr peer)
4314{
4315 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304316 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004317 tSirRetStatus nSirStatus;
4318 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304319 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4320 void *pPacket;
4321 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004322
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304323 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004324
4325 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4326 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4327 frm.DialogToken.token = 1;
4328 frm.TPCRequest.present = 1;
4329
4330 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4331 if ( DOT11F_FAILED( nStatus ) )
4332 {
4333 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004334 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004335 nStatus );
4336 // We'll fall back on the worst case scenario:
4337 nPayload = sizeof( tDot11fTPCRequest );
4338 }
4339 else if ( DOT11F_WARNED( nStatus ) )
4340 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004341 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004342 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004343 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004344 }
4345
4346 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4347
4348 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4349 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4350 {
4351 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004352 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004353 return;
4354 }
4355
4356 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304357 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004358
4359 // Next, we fill out the buffer descriptor:
4360 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4361 SIR_MAC_MGMT_ACTION, peer);
4362 if ( eSIR_SUCCESS != nSirStatus )
4363 {
4364 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004365 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004366 nSirStatus );
4367 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4368 return; // just allocated...
4369 }
4370
4371 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4372
4373 nCfg = 6;
4374 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4375 if ( eSIR_SUCCESS != nSirStatus )
4376 {
4377 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004378 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 nSirStatus );
4380 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4381 return; // just allocated...
4382 }
4383
Chet Lanctot186b5732013-03-18 10:26:30 -07004384#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004385 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004386#endif
4387
Jeff Johnson295189b2012-06-20 16:38:30 -07004388 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4389 sizeof(tSirMacMgmtHdr),
4390 nPayload, &nPayload );
4391 if ( DOT11F_FAILED( nStatus ) )
4392 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004393 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004394 nStatus );
4395 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4396 return; // allocated!
4397 }
4398 else if ( DOT11F_WARNED( nStatus ) )
4399 {
4400 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004401 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004402 }
4403
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304404 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4405 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4406 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004407 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4408 HAL_TXRX_FRM_802_11_MGMT,
4409 ANI_TXDIR_TODS,
4410 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4411 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304412 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4413 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4414 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004415 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4416 {
4417 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004418 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004419 nSirStatus );
4420 //Pkt will be freed up by the callback
4421 return;
4422 }
4423
4424} // End limSendTpcRequestFrame.
4425
4426
4427/**
4428 * \brief Send a TPC Report Action frame
4429 *
4430 *
4431 * \param pMac Pointer to the global MAC datastructure
4432 *
4433 * \param pTpcReqFrame Pointer to the received TPC Request
4434 *
4435 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4436 *
4437 *
4438 */
4439
4440tSirRetStatus
4441limSendTpcReportFrame(tpAniSirGlobal pMac,
4442 tpSirMacTpcReqActionFrame pTpcReqFrame,
4443 tSirMacAddr peer)
4444{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304445 tDot11fTPCReport frm;
4446 tANI_U8 *pFrame;
4447 tSirRetStatus nSirStatus;
4448 tpSirMacMgmtHdr pMacHdr;
4449 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4450 void *pPacket;
4451 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004452
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304453 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004454
4455 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4456 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4457 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4458
4459 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4460 // "misplaced this function, need to replace:
4461 // txPower = halGetRateToPwrValue(pMac, staid,
4462 // pMac->lim.gLimCurrentChannelId, 0);
4463 frm.TPCReport.tx_power = 0;
4464 frm.TPCReport.link_margin = 0;
4465 frm.TPCReport.present = 1;
4466
4467 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4468 if ( DOT11F_FAILED( nStatus ) )
4469 {
4470 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004471 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004472 nStatus );
4473 // We'll fall back on the worst case scenario:
4474 nPayload = sizeof( tDot11fTPCReport );
4475 }
4476 else if ( DOT11F_WARNED( nStatus ) )
4477 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004478 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004479 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004480 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004481 }
4482
4483 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4484
4485 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4486 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4487 {
4488 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004489 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004490 return eSIR_FAILURE;
4491 }
4492
4493 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304494 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004495
4496 // Next, we fill out the buffer descriptor:
4497 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4498 SIR_MAC_MGMT_ACTION, peer);
4499 if ( eSIR_SUCCESS != nSirStatus )
4500 {
4501 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004502 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004503 nSirStatus );
4504 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4505 return eSIR_FAILURE; // just allocated...
4506 }
4507
4508 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4509
4510 nCfg = 6;
4511 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4512 if ( eSIR_SUCCESS != nSirStatus )
4513 {
4514 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004515 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004516 nSirStatus );
4517 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4518 return eSIR_FAILURE; // just allocated...
4519 }
4520
Chet Lanctot186b5732013-03-18 10:26:30 -07004521#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004522 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004523#endif
4524
Jeff Johnson295189b2012-06-20 16:38:30 -07004525 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4526 sizeof(tSirMacMgmtHdr),
4527 nPayload, &nPayload );
4528 if ( DOT11F_FAILED( nStatus ) )
4529 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004530 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004531 nStatus );
4532 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4533 return eSIR_FAILURE; // allocated!
4534 }
4535 else if ( DOT11F_WARNED( nStatus ) )
4536 {
4537 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004538 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004539 }
4540
4541
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304542 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4543 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4544 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004545 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4546 HAL_TXRX_FRM_802_11_MGMT,
4547 ANI_TXDIR_TODS,
4548 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4549 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304550 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4551 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4552 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004553 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4554 {
4555 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004556 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 nSirStatus );
4558 //Pkt will be freed up by the callback
4559 return eSIR_FAILURE; // just allocated...
4560 }
4561
4562 return eSIR_SUCCESS;
4563
4564} // End limSendTpcReportFrame.
4565#endif //ANI_SUPPORT_11H
4566
4567
Jeff Johnson295189b2012-06-20 16:38:30 -07004568/**
4569 * \brief Send a Channel Switch Announcement
4570 *
4571 *
4572 * \param pMac Pointer to the global MAC datastructure
4573 *
4574 * \param peer MAC address to which this frame will be sent
4575 *
4576 * \param nMode
4577 *
4578 * \param nNewChannel
4579 *
4580 * \param nCount
4581 *
4582 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4583 *
4584 *
4585 */
4586
4587tSirRetStatus
4588limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4589 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004590 tANI_U8 nMode,
4591 tANI_U8 nNewChannel,
4592 tANI_U8 nCount,
4593 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004594{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304595 tDot11fChannelSwitch frm;
4596 tANI_U8 *pFrame;
4597 tSirRetStatus nSirStatus;
4598 tpSirMacMgmtHdr pMacHdr;
4599 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4600 void *pPacket;
4601 eHalStatus halstatus;
4602 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004603
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304604 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004605
4606 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4607 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4608 frm.ChanSwitchAnn.switchMode = nMode;
4609 frm.ChanSwitchAnn.newChannel = nNewChannel;
4610 frm.ChanSwitchAnn.switchCount = nCount;
4611 frm.ChanSwitchAnn.present = 1;
4612
4613 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4614 if ( DOT11F_FAILED( nStatus ) )
4615 {
4616 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004617 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004618 nStatus );
4619 // We'll fall back on the worst case scenario:
4620 nPayload = sizeof( tDot11fChannelSwitch );
4621 }
4622 else if ( DOT11F_WARNED( nStatus ) )
4623 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004624 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004625 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004626 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004627 }
4628
4629 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4630
4631 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4632 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4633 {
4634 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004635 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004636 return eSIR_FAILURE;
4637 }
4638
4639 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304640 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004641
4642 // Next, we fill out the buffer descriptor:
4643 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004644 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4645 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304646 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4647 (tANI_U8 *) psessionEntry->bssId,
4648 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004649 if ( eSIR_SUCCESS != nSirStatus )
4650 {
4651 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004652 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004653 nSirStatus );
4654 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4655 return eSIR_FAILURE; // just allocated...
4656 }
4657
Jeff Johnsone7245742012-09-05 17:12:55 -07004658#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004659 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4660
4661 nCfg = 6;
4662 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4663 if ( eSIR_SUCCESS != nSirStatus )
4664 {
4665 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004666 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004667 nSirStatus );
4668 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4669 return eSIR_FAILURE; // just allocated...
4670 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004671#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004672
4673#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004674 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004675#endif
4676
Jeff Johnson295189b2012-06-20 16:38:30 -07004677 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4678 sizeof(tSirMacMgmtHdr),
4679 nPayload, &nPayload );
4680 if ( DOT11F_FAILED( nStatus ) )
4681 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004682 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004683 nStatus );
4684 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4685 return eSIR_FAILURE; // allocated!
4686 }
4687 else if ( DOT11F_WARNED( nStatus ) )
4688 {
4689 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004690 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004691 }
4692
Jeff Johnsone7245742012-09-05 17:12:55 -07004693 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004694 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4695 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004696 )
4697 {
4698 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4699 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304700
4701 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4702 psessionEntry->peSessionId,
4703 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004704 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4705 HAL_TXRX_FRM_802_11_MGMT,
4706 ANI_TXDIR_TODS,
4707 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004708 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304709 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4710 psessionEntry->peSessionId,
4711 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004712 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4713 {
4714 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004715 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004716 nSirStatus );
4717 //Pkt will be freed up by the callback
4718 return eSIR_FAILURE;
4719 }
4720
4721 return eSIR_SUCCESS;
4722
4723} // End limSendChannelSwitchMgmtFrame.
4724
Jeff Johnson295189b2012-06-20 16:38:30 -07004725
4726
Mohit Khanna4a70d262012-09-11 16:30:12 -07004727#ifdef WLAN_FEATURE_11AC
4728tSirRetStatus
4729limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
4730 tSirMacAddr peer,
4731 tANI_U8 nMode,
4732 tpPESession psessionEntry )
4733{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304734 tDot11fOperatingMode frm;
4735 tANI_U8 *pFrame;
4736 tSirRetStatus nSirStatus;
4737 tpSirMacMgmtHdr pMacHdr;
4738 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
4739 void *pPacket;
4740 eHalStatus halstatus;
4741 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07004742
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304743 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004744
4745 frm.Category.category = SIR_MAC_ACTION_VHT;
4746 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
4747 frm.OperatingMode.chanWidth = nMode;
4748 frm.OperatingMode.rxNSS = 0;
4749 frm.OperatingMode.rxNSSType = 0;
4750
4751 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
4752 if ( DOT11F_FAILED( nStatus ) )
4753 {
4754 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004755 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004756 nStatus );
4757 // We'll fall back on the worst case scenario:
4758 nPayload = sizeof( tDot11fOperatingMode);
4759 }
4760 else if ( DOT11F_WARNED( nStatus ) )
4761 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004762 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07004763 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004764 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004765 }
4766
4767 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4768
4769 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4770 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4771 {
4772 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004773 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004774 return eSIR_FAILURE;
4775 }
4776
4777 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304778 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004779
4780
4781 // Next, we fill out the buffer descriptor:
4782 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
4783 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4784 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4785 } else
4786 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4787 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
4788 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304789 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4790 (tANI_U8 *) psessionEntry->bssId,
4791 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07004792 if ( eSIR_SUCCESS != nSirStatus )
4793 {
4794 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004795 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004796 nSirStatus );
4797 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4798 return eSIR_FAILURE; // just allocated...
4799 }
4800 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
4801 sizeof(tSirMacMgmtHdr),
4802 nPayload, &nPayload );
4803 if ( DOT11F_FAILED( nStatus ) )
4804 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004805 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004806 nStatus );
4807 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4808 return eSIR_FAILURE; // allocated!
4809 }
4810 else if ( DOT11F_WARNED( nStatus ) )
4811 {
4812 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004813 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004814 }
4815 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07004816 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4817 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07004818 )
4819 {
4820 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4821 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304822
4823 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4824 psessionEntry->peSessionId,
4825 pMacHdr->fc.subType));
Mohit Khanna4a70d262012-09-11 16:30:12 -07004826 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4827 HAL_TXRX_FRM_802_11_MGMT,
4828 ANI_TXDIR_TODS,
4829 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4830 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304831 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4832 psessionEntry->peSessionId,
4833 halstatus));
Mohit Khanna4a70d262012-09-11 16:30:12 -07004834 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4835 {
4836 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004837 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004838 nSirStatus );
4839 //Pkt will be freed up by the callback
4840 return eSIR_FAILURE;
4841 }
4842
4843 return eSIR_SUCCESS;
4844}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004845
4846/**
4847 * \brief Send a VHT Channel Switch Announcement
4848 *
4849 *
4850 * \param pMac Pointer to the global MAC datastructure
4851 *
4852 * \param peer MAC address to which this frame will be sent
4853 *
4854 * \param nChanWidth
4855 *
4856 * \param nNewChannel
4857 *
4858 *
4859 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4860 *
4861 *
4862 */
4863
4864tSirRetStatus
4865limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4866 tSirMacAddr peer,
4867 tANI_U8 nChanWidth,
4868 tANI_U8 nNewChannel,
4869 tANI_U8 ncbMode,
4870 tpPESession psessionEntry )
4871{
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;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004880
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304881 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004882
4883
4884 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4885 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4886 frm.ChanSwitchAnn.switchMode = 1;
4887 frm.ChanSwitchAnn.newChannel = nNewChannel;
4888 frm.ChanSwitchAnn.switchCount = 1;
4889 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
4890 frm.ExtChanSwitchAnn.present = 1;
4891 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
4892 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
4893 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
4894 frm.ChanSwitchAnn.present = 1;
4895 frm.WiderBWChanSwitchAnn.present = 1;
4896
4897 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4898 if ( DOT11F_FAILED( nStatus ) )
4899 {
4900 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004901 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004902 nStatus );
4903 // We'll fall back on the worst case scenario:
4904 nPayload = sizeof( tDot11fChannelSwitch );
4905 }
4906 else if ( DOT11F_WARNED( nStatus ) )
4907 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004908 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004909 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004910 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004911 }
4912
4913 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4914
4915 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4916 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4917 {
4918 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004919 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004920 return eSIR_FAILURE;
4921 }
4922 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304923 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004924
4925 // Next, we fill out the buffer descriptor:
4926 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4927 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4928 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304929 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4930 (tANI_U8 *) psessionEntry->bssId,
4931 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004932 if ( eSIR_SUCCESS != nSirStatus )
4933 {
4934 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004935 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004936 nSirStatus );
4937 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4938 return eSIR_FAILURE; // just allocated...
4939 }
4940 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4941 sizeof(tSirMacMgmtHdr),
4942 nPayload, &nPayload );
4943 if ( DOT11F_FAILED( nStatus ) )
4944 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004945 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004946 nStatus );
4947 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4948 return eSIR_FAILURE; // allocated!
4949 }
4950 else if ( DOT11F_WARNED( nStatus ) )
4951 {
4952 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004953 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004954 }
4955
4956 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004957 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4958 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004959 )
4960 {
4961 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4962 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304963
4964 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4965 psessionEntry->peSessionId,
4966 pMacHdr->fc.subType));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004967 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4968 HAL_TXRX_FRM_802_11_MGMT,
4969 ANI_TXDIR_TODS,
4970 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4971 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304972 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4973 psessionEntry->peSessionId,
4974 halstatus));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004975 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4976 {
4977 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004978 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004979 nSirStatus );
4980 //Pkt will be freed up by the callback
4981 return eSIR_FAILURE;
4982 }
4983
4984 return eSIR_SUCCESS;
4985
4986} // End limSendVHTChannelSwitchMgmtFrame.
4987
4988
4989
Mohit Khanna4a70d262012-09-11 16:30:12 -07004990#endif
4991
Jeff Johnson295189b2012-06-20 16:38:30 -07004992/**
4993 * \brief Send an ADDBA Req Action Frame to peer
4994 *
4995 * \sa limSendAddBAReq
4996 *
4997 * \param pMac The global tpAniSirGlobal object
4998 *
4999 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
5000 * the necessary parameters reqd by PE send the ADDBA Req Action
5001 * Frame to the peer
5002 *
5003 * \return eSIR_SUCCESS if setup completes successfully
5004 * eSIR_FAILURE is some problem is encountered
5005 */
5006tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305007 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07005008{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305009 tDot11fAddBAReq frmAddBAReq;
5010 tANI_U8 *pAddBAReqBuffer = NULL;
5011 tpSirMacMgmtHdr pMacHdr;
5012 tANI_U32 frameLen = 0, nStatus, nPayload;
5013 tSirRetStatus statusCode;
5014 eHalStatus halStatus;
5015 void *pPacket;
5016 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005017
5018 if(NULL == psessionEntry)
5019 {
5020 return eSIR_FAILURE;
5021 }
5022
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305023 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005024
5025 // Category - 3 (BA)
5026 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
5027
5028 // Action - 0 (ADDBA Req)
5029 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
5030
5031 // FIXME - Dialog Token, generalize this...
5032 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
5033
5034 // Fill the ADDBA Parameter Set
5035 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
5036 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
5037 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
5038
5039 // BA timeout
5040 // 0 - indicates no BA timeout
5041 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
5042
5043 // BA Starting Sequence Number
5044 // Fragment number will always be zero
5045 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
5046 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
5047 }
5048
5049 frmAddBAReq.BAStartingSequenceControl.ssn =
5050 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
5051
5052 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
5053
5054 if( DOT11F_FAILED( nStatus ))
5055 {
5056 limLog( pMac, LOGW,
5057 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005058 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005059 nStatus );
5060
5061 // We'll fall back on the worst case scenario:
5062 nPayload = sizeof( tDot11fAddBAReq );
5063 }
5064 else if( DOT11F_WARNED( nStatus ))
5065 {
5066 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005067 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005068 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005069 nStatus );
5070 }
5071
5072 // Add the MGMT header to frame length
5073 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5074
5075 // Need to allocate a buffer for ADDBA AF
5076 if( eHAL_STATUS_SUCCESS !=
5077 (halStatus = palPktAlloc( pMac->hHdd,
5078 HAL_TXRX_FRM_802_11_MGMT,
5079 (tANI_U16) frameLen,
5080 (void **) &pAddBAReqBuffer,
5081 (void **) &pPacket )))
5082 {
5083 // Log error
5084 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005085 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005086 frameLen,
5087 halStatus );
5088
5089 statusCode = eSIR_MEM_ALLOC_FAILED;
5090 goto returnAfterError;
5091 }
5092
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305093 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005094
5095 // Copy necessary info to BD
5096 if( eSIR_SUCCESS !=
5097 (statusCode = limPopulateMacHeader( pMac,
5098 pAddBAReqBuffer,
5099 SIR_MAC_MGMT_FRAME,
5100 SIR_MAC_MGMT_ACTION,
5101 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5102 goto returnAfterError;
5103
5104 // Update A3 with the BSSID
5105 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
5106
5107 #if 0
5108 cfgLen = SIR_MAC_ADDR_LENGTH;
5109 if( eSIR_SUCCESS != cfgGetStr( pMac,
5110 WNI_CFG_BSSID,
5111 (tANI_U8 *) pMacHdr->bssId,
5112 &cfgLen ))
5113 {
5114 limLog( pMac, LOGP,
5115 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005116 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005117
5118 // FIXME - Need to convert to tSirRetStatus
5119 statusCode = eSIR_FAILURE;
5120 goto returnAfterError;
5121 }
5122 #endif//TO SUPPORT BT-AMP
5123 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5124
Chet Lanctot186b5732013-03-18 10:26:30 -07005125#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005126 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005127#endif
5128
Jeff Johnson295189b2012-06-20 16:38:30 -07005129 // Now, we're ready to "pack" the frames
5130 nStatus = dot11fPackAddBAReq( pMac,
5131 &frmAddBAReq,
5132 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5133 nPayload,
5134 &nPayload );
5135
5136 if( DOT11F_FAILED( nStatus ))
5137 {
5138 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005139 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005140 nStatus );
5141
5142 // FIXME - Need to convert to tSirRetStatus
5143 statusCode = eSIR_FAILURE;
5144 goto returnAfterError;
5145 }
5146 else if( DOT11F_WARNED( nStatus ))
5147 {
5148 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005149 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5150 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005151 }
5152
5153 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005154 FL( "Sending an ADDBA REQ to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005155 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
5156
5157 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005158 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5159 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005160 )
5161 {
5162 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5163 }
5164
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305165 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5166 psessionEntry->peSessionId,
5167 pMacHdr->fc.subType));
5168 halStatus = halTxFrame( pMac,
5169 pPacket,
5170 (tANI_U16) frameLen,
5171 HAL_TXRX_FRM_802_11_MGMT,
5172 ANI_TXDIR_TODS,
5173 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5174 limTxComplete,
5175 pAddBAReqBuffer, txFlag );
5176 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5177 psessionEntry->peSessionId,
5178 halStatus));
5179 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005180 {
5181 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005182 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005183 halStatus );
5184
5185 // FIXME - Need to convert eHalStatus to tSirRetStatus
5186 statusCode = eSIR_FAILURE;
5187 //Pkt will be freed up by the callback
5188 return statusCode;
5189 }
5190 else
5191 return eSIR_SUCCESS;
5192
5193returnAfterError:
5194
5195 // Release buffer, if allocated
5196 if( NULL != pAddBAReqBuffer )
5197 palPktFree( pMac->hHdd,
5198 HAL_TXRX_FRM_802_11_MGMT,
5199 (void *) pAddBAReqBuffer,
5200 (void *) pPacket );
5201
5202 return statusCode;
5203}
5204
5205/**
5206 * \brief Send an ADDBA Rsp Action Frame to peer
5207 *
5208 * \sa limSendAddBARsp
5209 *
5210 * \param pMac The global tpAniSirGlobal object
5211 *
5212 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5213 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5214 * Frame to the peer
5215 *
5216 * \return eSIR_SUCCESS if setup completes successfully
5217 * eSIR_FAILURE is some problem is encountered
5218 */
5219tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5220 tpLimMlmAddBARsp pMlmAddBARsp,
5221 tpPESession psessionEntry)
5222{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305223 tDot11fAddBARsp frmAddBARsp;
5224 tANI_U8 *pAddBARspBuffer = NULL;
5225 tpSirMacMgmtHdr pMacHdr;
5226 tANI_U32 frameLen = 0, nStatus, nPayload;
5227 tSirRetStatus statusCode;
5228 eHalStatus halStatus;
5229 void *pPacket;
5230 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005231
5232 if(NULL == psessionEntry)
5233 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005234 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005235 return eSIR_FAILURE;
5236 }
5237
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305238 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005239
5240 // Category - 3 (BA)
5241 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5242 // Action - 1 (ADDBA Rsp)
5243 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5244
5245 // Should be same as the one we received in the ADDBA Req
5246 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5247
5248 // ADDBA Req status
5249 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5250
5251 // Fill the ADDBA Parameter Set as provided by caller
5252 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5253 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5254 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005255
5256 if(psessionEntry->isAmsduSupportInAMPDU)
5257 {
5258 frmAddBARsp.AddBAParameterSet.amsduSupported =
5259 psessionEntry->amsduSupportedInBA;
5260 }
5261 else
5262 {
5263 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5264 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005265
5266 // BA timeout
5267 // 0 - indicates no BA timeout
5268 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5269
5270 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5271
5272 if( DOT11F_FAILED( nStatus ))
5273 {
5274 limLog( pMac, LOGW,
5275 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005276 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005277 nStatus );
5278
5279 // We'll fall back on the worst case scenario:
5280 nPayload = sizeof( tDot11fAddBARsp );
5281 }
5282 else if( DOT11F_WARNED( nStatus ))
5283 {
5284 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005285 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005286 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005287 nStatus );
5288 }
5289
5290 // Need to allocate a buffer for ADDBA AF
5291 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5292
5293 // Allocate shared memory
5294 if( eHAL_STATUS_SUCCESS !=
5295 (halStatus = palPktAlloc( pMac->hHdd,
5296 HAL_TXRX_FRM_802_11_MGMT,
5297 (tANI_U16) frameLen,
5298 (void **) &pAddBARspBuffer,
5299 (void **) &pPacket )))
5300 {
5301 // Log error
5302 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005303 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005304 frameLen,
5305 halStatus );
5306
5307 statusCode = eSIR_MEM_ALLOC_FAILED;
5308 goto returnAfterError;
5309 }
5310
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305311 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005312
5313 // Copy necessary info to BD
5314 if( eSIR_SUCCESS !=
5315 (statusCode = limPopulateMacHeader( pMac,
5316 pAddBARspBuffer,
5317 SIR_MAC_MGMT_FRAME,
5318 SIR_MAC_MGMT_ACTION,
5319 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5320 goto returnAfterError;
5321
5322 // Update A3 with the BSSID
5323
5324 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5325
5326 #if 0
5327 cfgLen = SIR_MAC_ADDR_LENGTH;
5328 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5329 WNI_CFG_BSSID,
5330 (tANI_U8 *) pMacHdr->bssId,
5331 &cfgLen ))
5332 {
5333 limLog( pMac, LOGP,
5334 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005335 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005336
5337 // FIXME - Need to convert to tSirRetStatus
5338 statusCode = eSIR_FAILURE;
5339 goto returnAfterError;
5340 }
5341 #endif // TO SUPPORT BT-AMP
5342 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5343
Chet Lanctot186b5732013-03-18 10:26:30 -07005344#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005345 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005346#endif
5347
Jeff Johnson295189b2012-06-20 16:38:30 -07005348 // Now, we're ready to "pack" the frames
5349 nStatus = dot11fPackAddBARsp( pMac,
5350 &frmAddBARsp,
5351 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5352 nPayload,
5353 &nPayload );
5354
5355 if( DOT11F_FAILED( nStatus ))
5356 {
5357 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005358 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005359 nStatus );
5360
5361 // FIXME - Need to convert to tSirRetStatus
5362 statusCode = eSIR_FAILURE;
5363 goto returnAfterError;
5364 }
5365 else if( DOT11F_WARNED( nStatus ))
5366 {
5367 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005368 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5369 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005370 }
5371
5372 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005373 FL( "Sending an ADDBA RSP to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005374 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5375
5376 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005377 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5378 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005379 )
5380 {
5381 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5382 }
5383
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305384 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5385 psessionEntry->peSessionId,
5386 pMacHdr->fc.subType));
5387 halStatus = halTxFrame( pMac,
5388 pPacket,
5389 (tANI_U16) frameLen,
5390 HAL_TXRX_FRM_802_11_MGMT,
5391 ANI_TXDIR_TODS,
5392 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5393 limTxComplete,
5394 pAddBARspBuffer, txFlag );
5395 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5396 psessionEntry->peSessionId,
5397 halStatus));
5398 if( eHAL_STATUS_SUCCESS != halStatus )
5399 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005400 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005401 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005402 halStatus );
5403
5404 // FIXME - HAL error codes are different from PE error
5405 // codes!! And, this routine is returning tSirRetStatus
5406 statusCode = eSIR_FAILURE;
5407 //Pkt will be freed up by the callback
5408 return statusCode;
5409 }
5410 else
5411 return eSIR_SUCCESS;
5412
5413 returnAfterError:
Jeff Johnson295189b2012-06-20 16:38:30 -07005414 // Release buffer, if allocated
5415 if( NULL != pAddBARspBuffer )
5416 palPktFree( pMac->hHdd,
5417 HAL_TXRX_FRM_802_11_MGMT,
5418 (void *) pAddBARspBuffer,
5419 (void *) pPacket );
5420
5421 return statusCode;
5422}
5423
5424/**
5425 * \brief Send a DELBA Indication Action Frame to peer
5426 *
5427 * \sa limSendDelBAInd
5428 *
5429 * \param pMac The global tpAniSirGlobal object
5430 *
5431 * \param peerMacAddr MAC Address of peer
5432 *
5433 * \param reasonCode Reason for the DELBA notification
5434 *
5435 * \param pBAParameterSet The DELBA Parameter Set.
5436 * This identifies the TID for which the BA session is
5437 * being deleted.
5438 *
5439 * \return eSIR_SUCCESS if setup completes successfully
5440 * eSIR_FAILURE is some problem is encountered
5441 */
5442tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5443 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5444{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305445 tDot11fDelBAInd frmDelBAInd;
5446 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005447 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305448 tpSirMacMgmtHdr pMacHdr;
5449 tANI_U32 frameLen = 0, nStatus, nPayload;
5450 tSirRetStatus statusCode;
5451 eHalStatus halStatus;
5452 void *pPacket;
5453 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005454
5455 if(NULL == psessionEntry)
5456 {
5457 return eSIR_FAILURE;
5458 }
5459
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305460 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005461
5462 // Category - 3 (BA)
5463 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5464 // Action - 2 (DELBA)
5465 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5466
5467 // Fill the DELBA Parameter Set as provided by caller
5468 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5469 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5470
5471 // BA Starting Sequence Number
5472 // Fragment number will always be zero
5473 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5474
5475 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5476
5477 if( DOT11F_FAILED( nStatus ))
5478 {
5479 limLog( pMac, LOGW,
5480 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005481 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005482 nStatus );
5483
5484 // We'll fall back on the worst case scenario:
5485 nPayload = sizeof( tDot11fDelBAInd );
5486 }
5487 else if( DOT11F_WARNED( nStatus ))
5488 {
5489 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005490 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005491 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 nStatus );
5493 }
5494
5495 // Add the MGMT header to frame length
5496 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5497
5498 // Allocate shared memory
5499 if( eHAL_STATUS_SUCCESS !=
5500 (halStatus = palPktAlloc( pMac->hHdd,
5501 HAL_TXRX_FRM_802_11_MGMT,
5502 (tANI_U16) frameLen,
5503 (void **) &pDelBAIndBuffer,
5504 (void **) &pPacket )))
5505 {
5506 // Log error
5507 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005508 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 frameLen,
5510 halStatus );
5511
5512 statusCode = eSIR_MEM_ALLOC_FAILED;
5513 goto returnAfterError;
5514 }
5515
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305516 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005517
5518 // Copy necessary info to BD
5519 if( eSIR_SUCCESS !=
5520 (statusCode = limPopulateMacHeader( pMac,
5521 pDelBAIndBuffer,
5522 SIR_MAC_MGMT_FRAME,
5523 SIR_MAC_MGMT_ACTION,
5524 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5525 goto returnAfterError;
5526
5527 // Update A3 with the BSSID
5528 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5529
5530 #if 0
5531 cfgLen = SIR_MAC_ADDR_LENGTH;
5532 if( eSIR_SUCCESS != cfgGetStr( pMac,
5533 WNI_CFG_BSSID,
5534 (tANI_U8 *) pMacHdr->bssId,
5535 &cfgLen ))
5536 {
5537 limLog( pMac, LOGP,
5538 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005539 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005540
5541 // FIXME - Need to convert to tSirRetStatus
5542 statusCode = eSIR_FAILURE;
5543 goto returnAfterError;
5544 }
5545 #endif //TO SUPPORT BT-AMP
5546 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5547
Chet Lanctot186b5732013-03-18 10:26:30 -07005548#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005549 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005550#endif
5551
Jeff Johnson295189b2012-06-20 16:38:30 -07005552 // Now, we're ready to "pack" the frames
5553 nStatus = dot11fPackDelBAInd( pMac,
5554 &frmDelBAInd,
5555 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5556 nPayload,
5557 &nPayload );
5558
5559 if( DOT11F_FAILED( nStatus ))
5560 {
5561 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005562 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005563 nStatus );
5564
5565 // FIXME - Need to convert to tSirRetStatus
5566 statusCode = eSIR_FAILURE;
5567 goto returnAfterError;
5568 }
5569 else if( DOT11F_WARNED( nStatus ))
5570 {
5571 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005572 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
5573 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005574 }
5575
5576 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005577 FL( "Sending a DELBA IND to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005578 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5579
5580 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005581 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5582 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005583 )
5584 {
5585 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5586 }
5587
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305588 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5589 psessionEntry->peSessionId,
5590 pMacHdr->fc.subType));
5591 halStatus = halTxFrame( pMac,
5592 pPacket,
5593 (tANI_U16) frameLen,
5594 HAL_TXRX_FRM_802_11_MGMT,
5595 ANI_TXDIR_TODS,
5596 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5597 limTxComplete,
5598 pDelBAIndBuffer, txFlag );
5599 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5600 psessionEntry->peSessionId,
5601 halStatus));
5602 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005603 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005604 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005605 statusCode = eSIR_FAILURE;
5606 //Pkt will be freed up by the callback
5607 return statusCode;
5608 }
5609 else
5610 return eSIR_SUCCESS;
5611
5612 returnAfterError:
5613
5614 // Release buffer, if allocated
5615 if( NULL != pDelBAIndBuffer )
5616 palPktFree( pMac->hHdd,
5617 HAL_TXRX_FRM_802_11_MGMT,
5618 (void *) pDelBAIndBuffer,
5619 (void *) pPacket );
5620
5621 return statusCode;
5622}
5623
5624#if defined WLAN_FEATURE_VOWIFI
5625
5626/**
5627 * \brief Send a Neighbor Report Request Action frame
5628 *
5629 *
5630 * \param pMac Pointer to the global MAC structure
5631 *
5632 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5633 *
5634 * \param peer mac address of peer station.
5635 *
5636 * \param psessionEntry address of session entry.
5637 *
5638 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5639 *
5640 *
5641 */
5642
5643tSirRetStatus
5644limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5645 tpSirMacNeighborReportReq pNeighborReq,
5646 tSirMacAddr peer,
5647 tpPESession psessionEntry
5648 )
5649{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305650 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005651 tDot11fNeighborReportRequest frm;
5652 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305653 tpSirMacMgmtHdr pMacHdr;
5654 tANI_U32 nBytes, nPayload, nStatus;
5655 void *pPacket;
5656 eHalStatus halstatus;
5657 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005658
5659 if ( psessionEntry == NULL )
5660 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005661 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005662 return eSIR_FAILURE;
5663 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305664 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005665
5666 frm.Category.category = SIR_MAC_ACTION_RRM;
5667 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5668 frm.DialogToken.token = pNeighborReq->dialogToken;
5669
5670
5671 if( pNeighborReq->ssid_present )
5672 {
5673 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5674 }
5675
5676 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5677 if ( DOT11F_FAILED( nStatus ) )
5678 {
5679 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005680 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005681 nStatus );
5682 // We'll fall back on the worst case scenario:
5683 nPayload = sizeof( tDot11fNeighborReportRequest );
5684 }
5685 else if ( DOT11F_WARNED( nStatus ) )
5686 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005687 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005688 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005689 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005690 }
5691
5692 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5693
5694 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5695 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5696 {
5697 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005698 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005699 return eSIR_FAILURE;
5700 }
5701
5702 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305703 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005704
5705 // Copy necessary info to BD
5706 if( eSIR_SUCCESS !=
5707 (statusCode = limPopulateMacHeader( pMac,
5708 pFrame,
5709 SIR_MAC_MGMT_FRAME,
5710 SIR_MAC_MGMT_ACTION,
5711 peer, psessionEntry->selfMacAddr)))
5712 goto returnAfterError;
5713
5714 // Update A3 with the BSSID
5715 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5716
5717 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5718
Chet Lanctot186b5732013-03-18 10:26:30 -07005719#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005720 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005721#endif
5722
Jeff Johnson295189b2012-06-20 16:38:30 -07005723 // Now, we're ready to "pack" the frames
5724 nStatus = dot11fPackNeighborReportRequest( pMac,
5725 &frm,
5726 pFrame + sizeof( tSirMacMgmtHdr ),
5727 nPayload,
5728 &nPayload );
5729
5730 if( DOT11F_FAILED( nStatus ))
5731 {
5732 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005733 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005734 nStatus );
5735
5736 // FIXME - Need to convert to tSirRetStatus
5737 statusCode = eSIR_FAILURE;
5738 goto returnAfterError;
5739 }
5740 else if( DOT11F_WARNED( nStatus ))
5741 {
5742 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005743 FL( "There were warnings while packing Neighbor Report "
5744 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005745 }
5746
5747 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005748 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005749 limPrintMacAddr( pMac, peer, LOGW );
5750
5751 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005752 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5753 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005754 )
5755 {
5756 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5757 }
5758
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305759 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5760 psessionEntry->peSessionId,
5761 pMacHdr->fc.subType));
5762 halstatus = halTxFrame( pMac,
5763 pPacket,
5764 (tANI_U16) nBytes,
5765 HAL_TXRX_FRM_802_11_MGMT,
5766 ANI_TXDIR_TODS,
5767 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5768 limTxComplete,
5769 pFrame, txFlag );
5770 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5771 psessionEntry->peSessionId,
5772 halstatus));
5773 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005774 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005775 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005776 statusCode = eSIR_FAILURE;
5777 //Pkt will be freed up by the callback
5778 return statusCode;
5779 }
5780 else
5781 return eSIR_SUCCESS;
5782
5783returnAfterError:
5784 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5785
5786 return statusCode;
5787} // End limSendNeighborReportRequestFrame.
5788
5789/**
5790 * \brief Send a Link Report Action frame
5791 *
5792 *
5793 * \param pMac Pointer to the global MAC structure
5794 *
5795 * \param pLinkReport Address of a tSirMacLinkReport
5796 *
5797 * \param peer mac address of peer station.
5798 *
5799 * \param psessionEntry address of session entry.
5800 *
5801 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5802 *
5803 *
5804 */
5805
5806tSirRetStatus
5807limSendLinkReportActionFrame(tpAniSirGlobal pMac,
5808 tpSirMacLinkReport pLinkReport,
5809 tSirMacAddr peer,
5810 tpPESession psessionEntry
5811 )
5812{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305813 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005814 tDot11fLinkMeasurementReport frm;
5815 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305816 tpSirMacMgmtHdr pMacHdr;
5817 tANI_U32 nBytes, nPayload, nStatus;
5818 void *pPacket;
5819 eHalStatus halstatus;
5820 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005821
5822
5823 if ( psessionEntry == NULL )
5824 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005825 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005826 return eSIR_FAILURE;
5827 }
5828
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305829 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005830
5831 frm.Category.category = SIR_MAC_ACTION_RRM;
5832 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
5833 frm.DialogToken.token = pLinkReport->dialogToken;
5834
5835
5836 //IEEE Std. 802.11 7.3.2.18. for the report element.
5837 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
5838 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
5839 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
5840 //such case this way than changing the frame parser.
5841 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
5842 frm.TPCEleLen.TPCLen = 2;
5843 frm.TxPower.txPower = pLinkReport->txPower;
5844 frm.LinkMargin.linkMargin = 0;
5845
5846 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
5847 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
5848 frm.RCPI.rcpi = pLinkReport->rcpi;
5849 frm.RSNI.rsni = pLinkReport->rsni;
5850
5851 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
5852 if ( DOT11F_FAILED( nStatus ) )
5853 {
5854 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005855 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005856 nStatus );
5857 // We'll fall back on the worst case scenario:
5858 nPayload = sizeof( tDot11fLinkMeasurementReport );
5859 }
5860 else if ( DOT11F_WARNED( nStatus ) )
5861 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005862 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005863 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005864 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005865 }
5866
5867 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5868
5869 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5870 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5871 {
5872 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005873 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005874 return eSIR_FAILURE;
5875 }
5876
5877 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305878 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005879
5880 // Copy necessary info to BD
5881 if( eSIR_SUCCESS !=
5882 (statusCode = limPopulateMacHeader( pMac,
5883 pFrame,
5884 SIR_MAC_MGMT_FRAME,
5885 SIR_MAC_MGMT_ACTION,
5886 peer, psessionEntry->selfMacAddr)))
5887 goto returnAfterError;
5888
5889 // Update A3 with the BSSID
5890 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5891
5892 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5893
Chet Lanctot186b5732013-03-18 10:26:30 -07005894#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005895 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005896#endif
5897
Jeff Johnson295189b2012-06-20 16:38:30 -07005898 // Now, we're ready to "pack" the frames
5899 nStatus = dot11fPackLinkMeasurementReport( pMac,
5900 &frm,
5901 pFrame + sizeof( tSirMacMgmtHdr ),
5902 nPayload,
5903 &nPayload );
5904
5905 if( DOT11F_FAILED( nStatus ))
5906 {
5907 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005908 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005909 nStatus );
5910
5911 // FIXME - Need to convert to tSirRetStatus
5912 statusCode = eSIR_FAILURE;
5913 goto returnAfterError;
5914 }
5915 else if( DOT11F_WARNED( nStatus ))
5916 {
5917 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005918 FL( "There were warnings while packing Link Report (0x%08x)." ),
5919 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005920 }
5921
5922 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005923 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005924 limPrintMacAddr( pMac, peer, LOGW );
5925
5926 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005927 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5928 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005929 )
5930 {
5931 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5932 }
5933
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305934 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5935 psessionEntry->peSessionId,
5936 pMacHdr->fc.subType));
5937 halstatus = halTxFrame( pMac,
5938 pPacket,
5939 (tANI_U16) nBytes,
5940 HAL_TXRX_FRM_802_11_MGMT,
5941 ANI_TXDIR_TODS,
5942 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5943 limTxComplete,
5944 pFrame, txFlag );
5945 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5946 psessionEntry->peSessionId,
5947 halstatus));
5948 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005949 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005950 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005951 statusCode = eSIR_FAILURE;
5952 //Pkt will be freed up by the callback
5953 return statusCode;
5954 }
5955 else
5956 return eSIR_SUCCESS;
5957
5958returnAfterError:
5959 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5960
5961 return statusCode;
5962} // End limSendLinkReportActionFrame.
5963
5964/**
5965 * \brief Send a Beacon Report Action frame
5966 *
5967 *
5968 * \param pMac Pointer to the global MAC structure
5969 *
5970 * \param dialog_token dialog token to be used in the action frame.
5971 *
5972 * \param num_report number of reports in pRRMReport.
5973 *
5974 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
5975 *
5976 * \param peer mac address of peer station.
5977 *
5978 * \param psessionEntry address of session entry.
5979 *
5980 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5981 *
5982 *
5983 */
5984
5985tSirRetStatus
5986limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
5987 tANI_U8 dialog_token,
5988 tANI_U8 num_report,
5989 tpSirMacRadioMeasureReport pRRMReport,
5990 tSirMacAddr peer,
5991 tpPESession psessionEntry
5992 )
5993{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305994 tSirRetStatus statusCode = eSIR_SUCCESS;
5995 tANI_U8 *pFrame;
5996 tpSirMacMgmtHdr pMacHdr;
5997 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005998 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305999 eHalStatus halstatus;
6000 tANI_U8 i;
6001 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006002
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006003 tDot11fRadioMeasurementReport *frm =
6004 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
6005 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006006 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006007 return eSIR_FAILURE;
6008 }
6009
Jeff Johnson295189b2012-06-20 16:38:30 -07006010 if ( psessionEntry == NULL )
6011 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006012 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006013 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006014 return eSIR_FAILURE;
6015 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306016 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006017
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006018 frm->Category.category = SIR_MAC_ACTION_RRM;
6019 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
6020 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07006021
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006022 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 -07006023
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006024 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006025 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006026 frm->MeasurementReport[i].type = pRRMReport[i].type;
6027 frm->MeasurementReport[i].token = pRRMReport[i].token;
6028 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006029 switch( pRRMReport[i].type )
6030 {
6031 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006032 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
6033 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6034 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
6035 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006036 break;
6037 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05306038 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6039 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006040 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006041 break;
6042 }
6043 }
6044
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006045 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07006046 if ( DOT11F_FAILED( nStatus ) )
6047 {
6048 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006049 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006050 nStatus );
6051 // We'll fall back on the worst case scenario:
6052 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006053 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006054 return eSIR_FAILURE;
6055 }
6056 else if ( DOT11F_WARNED( nStatus ) )
6057 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006058 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006059 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006060 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006061 }
6062
6063 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6064
6065 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6066 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6067 {
6068 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006069 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006070 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006071 return eSIR_FAILURE;
6072 }
6073
6074 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306075 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006076
6077 // Copy necessary info to BD
6078 if( eSIR_SUCCESS !=
6079 (statusCode = limPopulateMacHeader( pMac,
6080 pFrame,
6081 SIR_MAC_MGMT_FRAME,
6082 SIR_MAC_MGMT_ACTION,
6083 peer, psessionEntry->selfMacAddr)))
6084 goto returnAfterError;
6085
6086 // Update A3 with the BSSID
6087 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6088
6089 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6090
Chet Lanctot186b5732013-03-18 10:26:30 -07006091#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006092 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006093#endif
6094
Jeff Johnson295189b2012-06-20 16:38:30 -07006095 // Now, we're ready to "pack" the frames
6096 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006097 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07006098 pFrame + sizeof( tSirMacMgmtHdr ),
6099 nPayload,
6100 &nPayload );
6101
6102 if( DOT11F_FAILED( nStatus ))
6103 {
6104 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006105 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006106 nStatus );
6107
6108 // FIXME - Need to convert to tSirRetStatus
6109 statusCode = eSIR_FAILURE;
6110 goto returnAfterError;
6111 }
6112 else if( DOT11F_WARNED( nStatus ))
6113 {
6114 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006115 FL( "There were warnings while packing Radio "
6116 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006117 }
6118
6119 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006120 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006121 limPrintMacAddr( pMac, peer, LOGW );
6122
6123 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006124 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6125 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006126 )
6127 {
6128 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6129 }
6130
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306131 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6132 psessionEntry->peSessionId,
6133 pMacHdr->fc.subType));
6134 halstatus = halTxFrame( pMac,
6135 pPacket,
6136 (tANI_U16) nBytes,
6137 HAL_TXRX_FRM_802_11_MGMT,
6138 ANI_TXDIR_TODS,
6139 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6140 limTxComplete,
6141 pFrame, txFlag );
6142 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6143 psessionEntry->peSessionId,
6144 halstatus));
6145 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006146 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006147 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006148 statusCode = eSIR_FAILURE;
6149 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006150 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006151 return statusCode;
6152 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006153 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006154 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006155 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006156 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006157
6158returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006159 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006160 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07006161 return statusCode;
6162} // End limSendBeaconReportActionFrame.
6163
6164#endif
6165
6166#ifdef WLAN_FEATURE_11W
6167/**
Chet Lanctot8cecea22014-02-11 19:09:36 -08006168 * \brief Send SA query request action frame to peer
6169 *
6170 * \sa limSendSaQueryRequestFrame
6171 *
6172 *
6173 * \param pMac The global tpAniSirGlobal object
6174 *
6175 * \param transId Transaction identifier
6176 *
6177 * \param peer The Mac address of the station to which this action frame is addressed
6178 *
6179 * \param psessionEntry The PE session entry
6180 *
6181 * \return eSIR_SUCCESS if setup completes successfully
6182 * eSIR_FAILURE is some problem is encountered
6183 */
6184
6185tSirRetStatus limSendSaQueryRequestFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
6186 tSirMacAddr peer, tpPESession psessionEntry )
6187{
6188
6189 tDot11fSaQueryReq frm; // SA query request action frame
6190 tANI_U8 *pFrame;
6191 tSirRetStatus nSirStatus;
6192 tpSirMacMgmtHdr pMacHdr;
6193 tANI_U32 nBytes, nPayload, nStatus;
6194 void *pPacket;
6195 eHalStatus halstatus;
6196 tANI_U8 txFlag = 0;
6197
6198 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
6199 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6200 /* 11w action field is :
6201 action: 0 --> SA Query Request action frame
6202 action: 1 --> SA Query Response action frame */
6203 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
6204 /* 11w SA Query Request transId */
6205 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
6206
6207 nStatus = dot11fGetPackedSaQueryReqSize(pMac, &frm, &nPayload);
6208 if ( DOT11F_FAILED( nStatus ) )
6209 {
6210 limLog( pMac, LOGP, FL("Failed to calculate the packed size "
6211 "for an SA Query Request (0x%08x)."),
6212 nStatus );
6213 // We'll fall back on the worst case scenario:
6214 nPayload = sizeof( tDot11fSaQueryReq );
6215 }
6216 else if ( DOT11F_WARNED( nStatus ) )
6217 {
6218 limLog( pMac, LOGW, FL("There were warnings while calculating "
6219 "the packed size for an SA Query Request"
6220 " (0x%08x)."), nStatus );
6221 }
6222
6223 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6224 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6225 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6226 {
6227 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA Query Request "
6228 "action frame"), nBytes );
6229 return eSIR_FAILURE;
6230 }
6231
6232 // Paranoia:
6233 vos_mem_set( pFrame, nBytes, 0 );
6234
6235 // Copy necessary info to BD
6236 nSirStatus = limPopulateMacHeader( pMac,
6237 pFrame,
6238 SIR_MAC_MGMT_FRAME,
6239 SIR_MAC_MGMT_ACTION,
6240 peer, psessionEntry->selfMacAddr );
6241 if ( eSIR_SUCCESS != nSirStatus )
6242 goto returnAfterError;
6243
6244 // Update A3 with the BSSID
6245 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6246
6247 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6248
6249 // Since this is a SA Query Request, set the "protect" (aka WEP) bit
6250 // in the FC
6251 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
6252
6253 // Pack 11w SA Query Request frame
6254 nStatus = dot11fPackSaQueryReq( pMac,
6255 &frm,
6256 pFrame + sizeof( tSirMacMgmtHdr ),
6257 nPayload,
6258 &nPayload );
6259
6260 if ( DOT11F_FAILED( nStatus ))
6261 {
6262 limLog( pMac, LOGE,
6263 FL( "Failed to pack an SA Query Request (0x%08x)." ),
6264 nStatus );
6265 // FIXME - Need to convert to tSirRetStatus
6266 nSirStatus = eSIR_FAILURE;
6267 goto returnAfterError;
6268 }
6269 else if ( DOT11F_WARNED( nStatus ))
6270 {
6271 limLog( pMac, LOGW,
6272 FL( "There were warnings while packing SA Query Request (0x%08x)." ),
6273 nStatus);
6274 }
6275
6276 limLog( pMac, LOG1,
6277 FL( "Sending an SA Query Request to " ));
6278 limPrintMacAddr( pMac, peer, LOG1 );
6279 limPrintMacAddr( pMac, peer, LOGE );
6280 limLog( pMac, LOGE,
6281 FL( "Sending an SA Query Request from " ));
6282 limPrintMacAddr( pMac, psessionEntry->selfMacAddr, LOGE );
6283
6284 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
6285#ifdef WLAN_FEATURE_P2P
6286 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6287 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
6288#endif
6289 )
6290 {
6291 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6292 }
6293
6294 halstatus = halTxFrame( pMac,
6295 pPacket,
6296 (tANI_U16) nBytes,
6297 HAL_TXRX_FRM_802_11_MGMT,
6298 ANI_TXDIR_TODS,
6299 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6300 limTxComplete,
6301 pFrame, txFlag );
6302 if ( eHAL_STATUS_SUCCESS != halstatus )
6303 {
6304 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6305 nSirStatus = eSIR_FAILURE;
6306 //Pkt will be freed up by the callback
6307 return nSirStatus;
6308 }
6309 else {
6310 return eSIR_SUCCESS;
6311 }
6312
6313returnAfterError:
6314 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6315 return nSirStatus;
6316} // End limSendSaQueryRequestFrame
6317
6318/**
Jeff Johnson295189b2012-06-20 16:38:30 -07006319 * \brief Send SA query response action frame to peer
6320 *
6321 * \sa limSendSaQueryResponseFrame
6322 *
6323 *
6324 * \param pMac The global tpAniSirGlobal object
6325 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006326 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006327 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006328 * \param peer The Mac address of the AP to which this action frame is addressed
6329 *
6330 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07006331 *
6332 * \return eSIR_SUCCESS if setup completes successfully
6333 * eSIR_FAILURE is some problem is encountered
6334 */
6335
Chet Lanctot186b5732013-03-18 10:26:30 -07006336tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006337tSirMacAddr peer,tpPESession psessionEntry)
6338{
6339
Chet Lanctot186b5732013-03-18 10:26:30 -07006340 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006341 tANI_U8 *pFrame;
6342 tSirRetStatus nSirStatus;
6343 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07006344 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006345 void *pPacket;
6346 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306347 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006348
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306349 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07006350 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6351 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07006352 action: 0 --> SA query request action frame
6353 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07006354 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
6355 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07006356 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07006357 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006358
Chet Lanctot186b5732013-03-18 10:26:30 -07006359 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6360 if ( DOT11F_FAILED( nStatus ) )
6361 {
6362 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6363 "or a SA Query Response (0x%08x)."),
6364 nStatus );
6365 // We'll fall back on the worst case scenario:
6366 nPayload = sizeof( tDot11fSaQueryRsp );
6367 }
6368 else if ( DOT11F_WARNED( nStatus ) )
6369 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006370 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006371 "the packed size for an SA Query Response"
6372 " (0x%08x)."), nStatus );
6373 }
6374
Jeff Johnson295189b2012-06-20 16:38:30 -07006375 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6376 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6377 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6378 {
6379 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006380 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006381 return eSIR_FAILURE;
6382 }
6383
6384 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306385 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006386
Chet Lanctot186b5732013-03-18 10:26:30 -07006387 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006388 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006389 pFrame,
6390 SIR_MAC_MGMT_FRAME,
6391 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006392 peer, psessionEntry->selfMacAddr );
6393 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006394 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006395
Chet Lanctot186b5732013-03-18 10:26:30 -07006396 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006397 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6398
Chet Lanctot186b5732013-03-18 10:26:30 -07006399 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006400
Chet Lanctot186b5732013-03-18 10:26:30 -07006401 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6402 // in the FC
Chet Lanctot8cecea22014-02-11 19:09:36 -08006403 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -07006404
Chet Lanctot186b5732013-03-18 10:26:30 -07006405 // Pack 11w SA query response frame
6406 nStatus = dot11fPackSaQueryRsp( pMac,
6407 &frm,
6408 pFrame + sizeof( tSirMacMgmtHdr ),
6409 nPayload,
6410 &nPayload );
6411
6412 if ( DOT11F_FAILED( nStatus ))
6413 {
6414 limLog( pMac, LOGE,
6415 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6416 nStatus );
6417 // FIXME - Need to convert to tSirRetStatus
6418 nSirStatus = eSIR_FAILURE;
6419 goto returnAfterError;
6420 }
6421 else if ( DOT11F_WARNED( nStatus ))
6422 {
6423 limLog( pMac, LOGW,
6424 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6425 nStatus);
6426 }
6427
6428 limLog( pMac, LOG1,
6429 FL( "Sending a SA Query Response to " ));
6430 limPrintMacAddr( pMac, peer, LOGW );
6431
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006432 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006433#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006434 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6435 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006436#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006437 )
6438 {
6439 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6440 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006441
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306442 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6443 psessionEntry->peSessionId,
6444 pMacHdr->fc.subType));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006445 halstatus = halTxFrame( pMac,
6446 pPacket,
6447 (tANI_U16) nBytes,
6448 HAL_TXRX_FRM_802_11_MGMT,
6449 ANI_TXDIR_TODS,
6450 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6451 limTxComplete,
6452 pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306453 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6454 psessionEntry->peSessionId,
6455 halstatus));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006456 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006457 {
6458 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6459 nSirStatus = eSIR_FAILURE;
6460 //Pkt will be freed up by the callback
6461 return nSirStatus;
6462 }
6463 else {
6464 return eSIR_SUCCESS;
6465 }
6466
6467returnAfterError:
6468 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6469 return nSirStatus;
6470} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006471#endif