blob: 1629eeb30de79eaeb67ddfbe404308bf68bf411c [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302 * Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08003 *
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/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
Jeff Johnson295189b2012-06-20 16:38:30 -070041/**
42 * \file limSendManagementFrames.c
43 *
44 * \brief Code for preparing and sending 802.11 Management frames
45 *
Jeff Johnson295189b2012-06-20 16:38:30 -070046 *
47 */
48
49#include "sirApi.h"
50#include "aniGlobal.h"
51#include "sirMacProtDef.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070052#include "cfgApi.h"
53#include "utilsApi.h"
54#include "limTypes.h"
55#include "limUtils.h"
56#include "limSecurityUtils.h"
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -070057#include "limPropExtsUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070058#include "dot11f.h"
59#include "limStaHashApi.h"
60#include "schApi.h"
61#include "limSendMessages.h"
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -080062#include "limAssocUtils.h"
63#include "limFT.h"
64
Jeff Johnson295189b2012-06-20 16:38:30 -070065#if defined WLAN_FEATURE_VOWIFI
66#include "rrmApi.h"
67#endif
68
Jeff Johnson295189b2012-06-20 16:38:30 -070069#include "wlan_qct_wda.h"
70#ifdef WLAN_FEATURE_11W
71#include "dot11fdefs.h"
72#endif
73
74
75////////////////////////////////////////////////////////////////////////
76
Jeff Johnson295189b2012-06-20 16:38:30 -070077
78/**
79 *
80 * \brief This function is called by various LIM modules to prepare the
81 * 802.11 frame MAC header
82 *
83 *
84 * \param pMac Pointer to Global MAC structure
85 *
86 * \param pBD Pointer to the frame buffer that needs to be populate
87 *
88 * \param type Type of the frame
89 *
90 * \param subType Subtype of the frame
91 *
92 * \return eHalStatus
93 *
94 *
95 * The pFrameBuf argument points to the beginning of the frame buffer to
96 * which - a) The 802.11 MAC header is set b) Following this MAC header
97 * will be the MGMT frame payload The payload itself is populated by the
98 * caller API
99 *
100 *
101 */
102
103tSirRetStatus limPopulateMacHeader( tpAniSirGlobal pMac,
104 tANI_U8* pBD,
105 tANI_U8 type,
106 tANI_U8 subType,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530107 tSirMacAddr peerAddr, tSirMacAddr selfMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700108{
109 tSirRetStatus statusCode = eSIR_SUCCESS;
110 tpSirMacMgmtHdr pMacHdr;
111
112 /// Prepare MAC management header
113 pMacHdr = (tpSirMacMgmtHdr) (pBD);
114
115 // Prepare FC
116 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
117 pMacHdr->fc.type = type;
118 pMacHdr->fc.subType = subType;
119
120 // Prepare Address 1
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530121 vos_mem_copy( (tANI_U8 *) pMacHdr->da,
Jeff Johnson295189b2012-06-20 16:38:30 -0700122 (tANI_U8 *) peerAddr,
123 sizeof( tSirMacAddr ));
124
125 // Prepare Address 2
Jeff Johnson295189b2012-06-20 16:38:30 -0700126 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
127
128 // Prepare Address 3
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530129 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700130 (tANI_U8 *) peerAddr,
131 sizeof( tSirMacAddr ));
132 return statusCode;
133} /*** end limPopulateMacHeader() ***/
134
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700135#ifdef WLAN_FEATURE_11W
136/**
137 *
138 * \brief This function is called by various LIM modules to correctly set
139 * the Protected bit in the Frame Control Field of the 802.11 frame MAC header
140 *
141 *
142 * \param pMac Pointer to Global MAC structure
143 *
144 * \param psessionEntry Pointer to session corresponding to the connection
145 *
146 * \param peer Peer address of the STA to which the frame is to be sent
147 *
148 * \param pMacHdr Pointer to the frame MAC header
149 *
150 * \return nothing
151 *
152 *
153 */
154void
155limSetProtectedBit(tpAniSirGlobal pMac,
156 tpPESession psessionEntry,
157 tSirMacAddr peer,
158 tpSirMacMgmtHdr pMacHdr)
159{
160 tANI_U16 aid;
161 tpDphHashNode pStaDs;
162
163 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
164 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
165 {
166
167 pStaDs = dphLookupHashEntry( pMac, peer, &aid, &psessionEntry->dph.dphHashTable );
168 if( pStaDs != NULL )
169 if( pStaDs->rmfEnabled )
170 pMacHdr->fc.wep = 1;
171 }
172 else if ( psessionEntry->limRmfEnabled )
173 pMacHdr->fc.wep = 1;
174} /*** end limSetProtectedBit() ***/
175#endif
176
Jeff Johnson295189b2012-06-20 16:38:30 -0700177/**
178 * \brief limSendProbeReqMgmtFrame
179 *
180 *
181 * \param pMac Pointer to Global MAC structure
182 *
183 * \param pSsid SSID to be sent in Probe Request frame
184 *
185 * \param bssid BSSID to be sent in Probe Request frame
186 *
187 * \param nProbeDelay probe delay to be used before sending Probe Request
188 * frame
189 *
190 * \param nChannelNum Channel # on which the Probe Request is going out
191 *
192 * \param nAdditionalIELen if non-zero, include pAdditionalIE in the Probe Request frame
193 *
194 * \param pAdditionalIE if nAdditionalIELen is non zero, include this field in the Probe Request frame
195 *
196 * This function is called by various LIM modules to send Probe Request frame
197 * during active scan/learn phase.
198 * Probe request is sent out in the following scenarios:
199 * --heartbeat failure: session needed
200 * --join req: session needed
201 * --foreground scan: no session
202 * --background scan: no session
203 * --schBeaconProcessing: to get EDCA parameters: session needed
204 *
205 *
206 */
207tSirRetStatus
208limSendProbeReqMgmtFrame(tpAniSirGlobal pMac,
209 tSirMacSSid *pSsid,
210 tSirMacAddr bssid,
211 tANI_U8 nChannelNum,
212 tSirMacAddr SelfMacAddr,
213 tANI_U32 dot11mode,
214 tANI_U32 nAdditionalIELen,
215 tANI_U8 *pAdditionalIE)
216{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530217 tDot11fProbeRequest pr;
218 tANI_U32 nStatus, nBytes, nPayload;
219 tSirRetStatus nSirStatus;
220 tANI_U8 *pFrame;
221 void *pPacket;
222 eHalStatus halstatus;
223 tpPESession psessionEntry;
224 tANI_U8 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700225 tANI_U8 *p2pIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530226 tANI_U32 txFlag = 0;
Sandeep Puligilla60342762014-01-30 21:05:37 +0530227 tANI_U32 chanbond24G = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700228
229#ifndef GEN4_SCAN
230 return eSIR_FAILURE;
231#endif
232
233#if defined ( ANI_DVT_DEBUG )
234 return eSIR_FAILURE;
235#endif
236
Abhishek Singh4beed422014-02-03 16:47:17 +0530237 /* The probe req should not send 11ac capabilieties if band is 2.4GHz,
238 * unless enableVhtFor24GHz is enabled in INI. So if enableVhtFor24GHz
239 * is false and dot11mode is 11ac set it to 11n.
240 */
241 if ( nChannelNum <= SIR_11B_CHANNEL_END &&
242 ( FALSE == pMac->roam.configParam.enableVhtFor24GHz ) &&
243 ( WNI_CFG_DOT11_MODE_11AC == dot11mode ||
244 WNI_CFG_DOT11_MODE_11AC_ONLY == dot11mode ) )
245 dot11mode = WNI_CFG_DOT11_MODE_11N;
Jeff Johnson295189b2012-06-20 16:38:30 -0700246 /*
247 * session context may or may not be present, when probe request needs to be sent out.
248 * following cases exist:
249 * --heartbeat failure: session needed
250 * --join req: session needed
251 * --foreground scan: no session
252 * --background scan: no session
253 * --schBeaconProcessing: to get EDCA parameters: session needed
254 * If session context does not exist, some IEs will be populated from CFGs,
255 * e.g. Supported and Extended rate set IEs
256 */
257 psessionEntry = peFindSessionByBssid(pMac,bssid,&sessionId);
258
259 // The scheme here is to fill out a 'tDot11fProbeRequest' structure
260 // and then hand it off to 'dot11fPackProbeRequest' (for
261 // serialization). We start by zero-initializing the structure:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530262 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700263
264 // & delegating to assorted helpers:
265 PopulateDot11fSSID( pMac, pSsid, &pr.SSID );
266
Jeff Johnson295189b2012-06-20 16:38:30 -0700267 if( nAdditionalIELen && pAdditionalIE )
268 {
269 p2pIe = limGetP2pIEPtr(pMac, pAdditionalIE, nAdditionalIELen);
270 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700271 /* Don't include 11b rate only when device is doing P2P Search */
272 if( ( WNI_CFG_DOT11_MODE_11B != dot11mode ) &&
273 ( p2pIe != NULL ) &&
274 /* Don't include 11b rate if it is a P2P serach or probe request is sent by P2P Client */
275 ( ( ( pMac->lim.gpLimMlmScanReq != NULL ) &&
276 pMac->lim.gpLimMlmScanReq->p2pSearch ) ||
277 ( ( psessionEntry != NULL ) &&
278 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
279 )
280 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700281 {
282 /* In the below API pass channel number > 14, do that it fills only
283 * 11a rates in supported rates */
284 PopulateDot11fSuppRates( pMac, 15, &pr.SuppRates,psessionEntry);
285 }
286 else
287 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700288 PopulateDot11fSuppRates( pMac, nChannelNum,
289 &pr.SuppRates,psessionEntry);
290
291 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
292 {
293 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
294 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700295 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700296
297#if defined WLAN_FEATURE_VOWIFI
298 //Table 7-14 in IEEE Std. 802.11k-2008 says
299 //DS params "can" be present in RRM is disabled and "is" present if
300 //RRM is enabled. It should be ok even if we add it into probe req when
301 //RRM is not enabled.
302 PopulateDot11fDSParams( pMac, &pr.DSParams, nChannelNum, psessionEntry );
303 //Call RRM module to get the tx power for management used.
304 {
305 tANI_U8 txPower = (tANI_U8) rrmGetMgmtTxPower( pMac, psessionEntry );
306 PopulateDot11fWFATPC( pMac, &pr.WFATPC, txPower, 0 );
307 }
308#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700309
310 if (psessionEntry != NULL ) {
Jeff Johnsone7245742012-09-05 17:12:55 -0700311 psessionEntry->htCapability = IS_DOT11_MODE_HT(dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700312 //Include HT Capability IE
Jeff Johnsone7245742012-09-05 17:12:55 -0700313 if (psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -0700314 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700315 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700316 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700317 } else { //psessionEntry == NULL
318 if (IS_DOT11_MODE_HT(dot11mode))
Jeff Johnson295189b2012-06-20 16:38:30 -0700319 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700320 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700321 }
322 }
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800323
Sandeep Puligilla60342762014-01-30 21:05:37 +0530324 /* Get HT40 capability for 2.4GHz band */
325 wlan_cfgGetInt(pMac,WNI_CFG_CHANNEL_BONDING_24G,&chanbond24G);
326 if( (nChannelNum <= SIR_11B_CHANNEL_END) && chanbond24G != TRUE)
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800327 {
328 pr.HTCaps.supportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
329 pr.HTCaps.shortGI40MHz = 0;
330 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700331#ifdef WLAN_FEATURE_11AC
332 if (psessionEntry != NULL ) {
333 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
334 //Include HT Capability IE
335 if (psessionEntry->vhtCapability)
336 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700337 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
338 }
339 } else {
340 if (IS_DOT11_MODE_VHT(dot11mode))
341 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700342 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps );
343 }
344 }
345#endif
346
Jeff Johnson295189b2012-06-20 16:38:30 -0700347
348 // That's it-- now we pack it. First, how much space are we going to
349 // need?
350 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
351 if ( DOT11F_FAILED( nStatus ) )
352 {
353 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700354 "or a Probe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700355 // We'll fall back on the worst case scenario:
356 nPayload = sizeof( tDot11fProbeRequest );
357 }
358 else if ( DOT11F_WARNED( nStatus ) )
359 {
360 limLog( pMac, LOGW, FL("There were warnings while calculating"
361 "the packed size for a Probe Request ("
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700362 "0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700363 }
364
365 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAdditionalIELen;
366
367 // Ok-- try to allocate some memory:
368 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
369 ( tANI_U16 )nBytes, ( void** ) &pFrame,
370 ( void** ) &pPacket );
371 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
372 {
373 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700374 "be Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700375 return eSIR_MEM_ALLOC_FAILED;
376 }
377
378 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530379 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700380
381 // Next, we fill out the buffer descriptor:
382 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530383 SIR_MAC_MGMT_PROBE_REQ, bssid, SelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700384 if ( eSIR_SUCCESS != nSirStatus )
385 {
386 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700387 "tor for a Probe Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700388 nSirStatus );
389 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
390 ( void* ) pFrame, ( void* ) pPacket );
391 return nSirStatus; // allocated!
392 }
393
394 // That done, pack the Probe Request:
395 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
396 sizeof( tSirMacMgmtHdr ),
397 nPayload, &nPayload );
398 if ( DOT11F_FAILED( nStatus ) )
399 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700400 limLog( pMac, LOGE, FL("Failed to pack a Probe Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700401 nStatus );
402 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
403 return eSIR_FAILURE; // allocated!
404 }
405 else if ( DOT11F_WARNED( nStatus ) )
406 {
407 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800408 "robe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700409 }
410
411 // Append any AddIE if present.
412 if( nAdditionalIELen )
413 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530414 vos_mem_copy( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700415 pAdditionalIE, nAdditionalIELen );
416 nPayload += nAdditionalIELen;
417 }
418
419 /* If this probe request is sent during P2P Search State, then we need
420 * to send it at OFDM rate.
421 */
422 if( ( SIR_BAND_5_GHZ == limGetRFBand(nChannelNum))
Jeff Johnson295189b2012-06-20 16:38:30 -0700423 || (( pMac->lim.gpLimMlmScanReq != NULL) &&
424 pMac->lim.gpLimMlmScanReq->p2pSearch )
Gopichand Nakkala67967212013-02-15 17:31:15 +0530425 /* For unicast probe req mgmt from Join function
426 we don't set above variables. So we need to add
427 one more check whether it is pePersona is P2P_CLIENT or not */
428 || ( ( psessionEntry != NULL ) &&
429 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700430 )
431 {
432 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
433 }
434
Jeff Johnson295189b2012-06-20 16:38:30 -0700435 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload,
436 HAL_TXRX_FRM_802_11_MGMT,
437 ANI_TXDIR_TODS,
438 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
439 limTxComplete, pFrame, txFlag );
440 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
441 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700442 limLog( pMac, LOGE, FL("could not send Probe Request frame!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700443 //Pkt will be freed up by the callback
444 return eSIR_FAILURE;
445 }
446
447 return eSIR_SUCCESS;
448} // End limSendProbeReqMgmtFrame.
449
Jeff Johnson295189b2012-06-20 16:38:30 -0700450tSirRetStatus limGetAddnIeForProbeResp(tpAniSirGlobal pMac,
451 tANI_U8* addIE, tANI_U16 *addnIELen,
452 tANI_U8 probeReqP2pIe)
453{
454 /* If Probe request doesn't have P2P IE, then take out P2P IE
455 from additional IE */
456 if(!probeReqP2pIe)
457 {
458 tANI_U8* tempbuf = NULL;
459 tANI_U16 tempLen = 0;
460 int left = *addnIELen;
461 v_U8_t *ptr = addIE;
462 v_U8_t elem_id, elem_len;
463
464 if(NULL == addIE)
465 {
466 PELOGE(limLog(pMac, LOGE,
467 FL(" NULL addIE pointer"));)
468 return eSIR_FAILURE;
469 }
470
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530471 tempbuf = vos_mem_malloc(left);
472 if ( NULL == tempbuf )
Jeff Johnson295189b2012-06-20 16:38:30 -0700473 {
474 PELOGE(limLog(pMac, LOGE,
475 FL("Unable to allocate memory to store addn IE"));)
476 return eSIR_MEM_ALLOC_FAILED;
477 }
478
479 while(left >= 2)
480 {
481 elem_id = ptr[0];
482 elem_len = ptr[1];
483 left -= 2;
484 if(elem_len > left)
485 {
486 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700487 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700488 elem_id,elem_len,left);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530489 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700490 return eSIR_FAILURE;
491 }
492 if ( !( (SIR_MAC_EID_VENDOR == elem_id) &&
493 (memcmp(&ptr[2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)==0) ) )
494 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530495 vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -0700496 tempLen += (elem_len + 2);
497 }
498 left -= elem_len;
499 ptr += (elem_len + 2);
500 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530501 vos_mem_copy (addIE, tempbuf, tempLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 *addnIELen = tempLen;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530503 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700504 }
505 return eSIR_SUCCESS;
506}
Jeff Johnson295189b2012-06-20 16:38:30 -0700507
508void
509limSendProbeRspMgmtFrame(tpAniSirGlobal pMac,
510 tSirMacAddr peerMacAddr,
511 tpAniSSID pSsid,
512 short nStaId,
513 tANI_U8 nKeepAlive,
514 tpPESession psessionEntry,
515 tANI_U8 probeReqP2pIe)
516{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700517 tDot11fProbeResponse *pFrm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530518 tSirRetStatus nSirStatus;
519 tANI_U32 cfg, nPayload, nBytes, nStatus;
520 tpSirMacMgmtHdr pMacHdr;
521 tANI_U8 *pFrame;
522 void *pPacket;
523 eHalStatus halstatus;
524 tANI_U32 addnIEPresent;
525 tANI_U32 addnIE1Len=0;
526 tANI_U32 addnIE2Len=0;
527 tANI_U32 addnIE3Len=0;
528 tANI_U16 totalAddnIeLen = 0;
529 tANI_U32 wpsApEnable=0, tmp;
530 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700531 tANI_U8 *addIE = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530532 tANI_U8 *pP2pIe = NULL;
533 tANI_U8 noaLen = 0;
534 tANI_U8 total_noaLen = 0;
535 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN
Jeff Johnson295189b2012-06-20 16:38:30 -0700536 + SIR_P2P_IE_HEADER_LEN];
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530537 tANI_U8 noaIe[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -0700538
539 if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests
540 {
541 return; // in this case.
542 }
543
544 if(NULL == psessionEntry)
545 {
546 return;
547 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530548
549 pFrm = vos_mem_malloc(sizeof(tDot11fProbeResponse));
550 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700551 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530552 limLog(pMac, LOGE, FL("Unable to allocate memory in limSendProbeRspMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700553 return;
554 }
555
Jeff Johnson295189b2012-06-20 16:38:30 -0700556 // Fill out 'frm', after which we'll just hand the struct off to
557 // 'dot11fPackProbeResponse'.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530558 vos_mem_set(( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700559
560 // Timestamp to be updated by TFP, below.
561
562 // Beacon Interval:
Jeff Johnson295189b2012-06-20 16:38:30 -0700563 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
564 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700565 pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -0700566 }
567 else
568 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800569 nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg);
570 if (eSIR_SUCCESS != nSirStatus)
571 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700572 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d)."),
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800573 nSirStatus );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530574 vos_mem_free(pFrm);
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800575 return;
576 }
577 pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg;
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800578 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700579
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700580 PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry );
581 PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700582 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700583 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700584
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700585 PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry);
586 PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700587
Jeff Johnson295189b2012-06-20 16:38:30 -0700588
Jeff Johnson295189b2012-06-20 16:38:30 -0700589 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
590 {
591 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
592 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700593 PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700594 }
595 }
596 else
597 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800598 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700599 limLog(pMac, LOGP,"Failed to cfg get id %d", WNI_CFG_WPS_ENABLE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700600
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800601 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
Jeff Johnson295189b2012-06-20 16:38:30 -0700602
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800603 if (wpsApEnable)
604 {
605 PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes);
606 }
607
608 if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
609 {
610 PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
611 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
612 }
613
614 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
615 {
616 DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
617 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
618 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700619 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700620
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700621 PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry);
622 PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700623
Jeff Johnson295189b2012-06-20 16:38:30 -0700624
625 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700626 PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700627
628
629 // N.B. In earlier implementations, the RSN IE would be placed in
630 // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined.
631 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700632 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700633
634 //Populate HT IEs, when operating in 11n or Taurus modes.
Jeff Johnsone7245742012-09-05 17:12:55 -0700635 if ( psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700637 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700638 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700639 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700640#ifdef WLAN_FEATURE_11AC
641 if(psessionEntry->vhtCapability)
642 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -0800643 limLog( pMac, LOG1, FL("Populate VHT IE in Probe Response"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700644 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
645 PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation );
Jeff Johnsone7245742012-09-05 17:12:55 -0700646 // we do not support multi users yet
647 //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad );
Sandeep Puligilla60342762014-01-30 21:05:37 +0530648 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -0700649 }
650#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700651
Sandeep Puligilla60342762014-01-30 21:05:37 +0530652
Jeff Johnson295189b2012-06-20 16:38:30 -0700653 if ( psessionEntry->pLimStartBssReq )
654 {
655 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700656 &pFrm->WPA );
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700657 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
658 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 }
660
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700661 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700662
663#if defined(FEATURE_WLAN_WAPI)
664 if( psessionEntry->pLimStartBssReq )
665 {
666 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700667 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700668 }
669
670#endif // defined(FEATURE_WLAN_WAPI)
671
672
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700673 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -0700674 if ( DOT11F_FAILED( nStatus ) )
675 {
676 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700677 "or a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700678 nStatus );
679 // We'll fall back on the worst case scenario:
680 nPayload = sizeof( tDot11fProbeResponse );
681 }
682 else if ( DOT11F_WARNED( nStatus ) )
683 {
684 limLog( pMac, LOGW, FL("There were warnings while calculating"
685 "the packed size for a Probe Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700686 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700687 }
688
689 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
690
691 addnIEPresent = false;
692
Jeff Johnson295189b2012-06-20 16:38:30 -0700693 if( pMac->lim.gpLimRemainOnChanReq )
694 {
695 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
696 }
697 //Only use CFG for non-listen mode. This CFG is not working for concurrency
698 //In listening mode, probe rsp IEs is passed in the message from SME to PE
699 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700700 {
701
702 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
703 &addnIEPresent) != eSIR_SUCCESS)
704 {
705 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530706 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700707 return;
708 }
709 }
710
711 if (addnIEPresent)
712 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530713
714 addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3);
715 if ( NULL == addIE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700716 {
717 PELOGE(limLog(pMac, LOGE,
718 FL("Unable to allocate memory to store addn IE"));)
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530719 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700720 return;
721 }
722
723 //Probe rsp IE available
724 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
725 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
726 {
727 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530728 vos_mem_free(addIE);
729 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700730 return;
731 }
732 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
733 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
734 {
735 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
736 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
737 &addnIE1Len) )
738 {
739 limLog(pMac, LOGP,
740 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530741 vos_mem_free(addIE);
742 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700743 return;
744 }
745 }
746
747 //Probe rsp IE available
748 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
749 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
750 {
751 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530752 vos_mem_free(addIE);
753 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700754 return;
755 }
756 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
757 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
758 {
759 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
760 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
761 &addnIE2Len) )
762 {
763 limLog(pMac, LOGP,
764 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530765 vos_mem_free(addIE);
766 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700767 return;
768 }
769 }
770
771 //Probe rsp IE available
772 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
773 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
774 {
775 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530776 vos_mem_free(addIE);
777 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700778 return;
779 }
780 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
781 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
782 {
783 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
784 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
785 &addIE[addnIE1Len + addnIE2Len],
786 &addnIE3Len) )
787 {
788 limLog(pMac, LOGP,
789 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530790 vos_mem_free(addIE);
791 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700792 return;
793 }
794 }
795 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
796
Jeff Johnson295189b2012-06-20 16:38:30 -0700797 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
798 {
799 limLog(pMac, LOGP,
800 FL("Unable to get final Additional IE for Probe Req"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530801 vos_mem_free(addIE);
802 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700803 return;
804 }
805 nBytes = nBytes + totalAddnIeLen;
806
807 if (probeReqP2pIe)
808 {
809 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
810 if (pP2pIe != NULL)
811 {
812 //get NoA attribute stream P2P IE
813 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
814 if (noaLen != 0)
815 {
816 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
817 &noaStream[0], noaLen);
818 nBytes = nBytes + total_noaLen;
819 }
820 }
821 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700822 }
823
824 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
825 ( tANI_U16 )nBytes, ( void** ) &pFrame,
826 ( void** ) &pPacket );
827 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
828 {
829 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700830 "be Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700831 if ( addIE != NULL )
832 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530833 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700834 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530835 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700836 return;
837 }
838
839 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530840 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700841
842 // Next, we fill out the buffer descriptor:
843 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
844 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
845 if ( eSIR_SUCCESS != nSirStatus )
846 {
847 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700848 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700849 nSirStatus );
850 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
851 ( void* ) pFrame, ( void* ) pPacket );
852 if ( addIE != NULL )
853 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530854 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700855 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530856 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700857 return;
858 }
859
860 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
861
862 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
863
864 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700865 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -0700866 nPayload, &nPayload );
867 if ( DOT11F_FAILED( nStatus ) )
868 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700869 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700870 nStatus );
871 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
872 if ( addIE != NULL )
873 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530874 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700875 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530876 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700877 return; // allocated!
878 }
879 else if ( DOT11F_WARNED( nStatus ) )
880 {
881 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800882 "robe Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700883 }
884
885 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
886 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
887
888 pMac->sys.probeRespond++;
889
Jeff Johnson295189b2012-06-20 16:38:30 -0700890 if( pMac->lim.gpLimRemainOnChanReq )
891 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530892 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
894 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700895
896 if ( addnIEPresent )
897 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530898 vos_mem_copy(pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], totalAddnIeLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700899 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700900 if (noaLen != 0)
901 {
Krunal Soni81b24262013-05-15 17:46:41 -0700902 if (total_noaLen > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -0700903 {
904 limLog(pMac, LOGE,
Kaushik, Sushant96ac9d72013-12-11 19:28:10 +0530905 FL("Not able to insert NoA because of length constraint."
906 "Total Length is :%d"),total_noaLen);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530907 vos_mem_free(addIE);
908 vos_mem_free(pFrm);
Krunal Soni81b24262013-05-15 17:46:41 -0700909 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
910 ( void* ) pFrame, ( void* ) pPacket );
911 return;
912 }
913 else
914 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530915 vos_mem_copy( &pFrame[nBytes - (total_noaLen)],
Krunal Soni81b24262013-05-15 17:46:41 -0700916 &noaIe[0], total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700917 }
918 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700919
920 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
922 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700923 )
924 {
925 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
926 }
927
928 // Queue Probe Response frame in high priority WQ
929 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
930 ( tANI_U16 ) nBytes,
931 HAL_TXRX_FRM_802_11_MGMT,
932 ANI_TXDIR_TODS,
933 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
934 limTxComplete, pFrame, txFlag );
935 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
936 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700937 limLog( pMac, LOGE, FL("Could not send Probe Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700938 //Pkt will be freed up by the callback
939 }
940
941 if ( addIE != NULL )
942 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530943 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700944 }
945
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530946 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700947 return;
948
949
Jeff Johnson295189b2012-06-20 16:38:30 -0700950} // End limSendProbeRspMgmtFrame.
951
952void
953limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
954 tSirMacAddr peerMacAddr,
955 tSirAddtsReqInfo *pAddTS,
956 tpPESession psessionEntry)
957{
958 tANI_U16 i;
959 tANI_U8 *pFrame;
960 tSirRetStatus nSirStatus;
961 tDot11fAddTSRequest AddTSReq;
962 tDot11fWMMAddTSRequest WMMAddTSReq;
963 tANI_U32 nPayload, nBytes, nStatus;
964 tpSirMacMgmtHdr pMacHdr;
965 void *pPacket;
966#ifdef FEATURE_WLAN_CCX
967 tANI_U32 phyMode;
968#endif
969 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530970 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700971
972 if(NULL == psessionEntry)
973 {
974 return;
975 }
976
977 if ( ! pAddTS->wmeTspecPresent )
978 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530979 vos_mem_set(( tANI_U8* )&AddTSReq, sizeof( AddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700980
981 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
982 AddTSReq.DialogToken.token = pAddTS->dialogToken;
983 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
984 if ( pAddTS->lleTspecPresent )
985 {
986 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
987 }
988 else
989 {
990 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
991 }
992
993 if ( pAddTS->lleTspecPresent )
994 {
995 AddTSReq.num_WMMTCLAS = 0;
996 AddTSReq.num_TCLAS = pAddTS->numTclas;
997 for ( i = 0; i < pAddTS->numTclas; ++i)
998 {
999 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1000 &AddTSReq.TCLAS[i] );
1001 }
1002 }
1003 else
1004 {
1005 AddTSReq.num_TCLAS = 0;
1006 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
1007 for ( i = 0; i < pAddTS->numTclas; ++i)
1008 {
1009 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1010 &AddTSReq.WMMTCLAS[i] );
1011 }
1012 }
1013
1014 if ( pAddTS->tclasProcPresent )
1015 {
1016 if ( pAddTS->lleTspecPresent )
1017 {
1018 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
1019 AddTSReq.TCLASSPROC.present = 1;
1020 }
1021 else
1022 {
1023 AddTSReq.WMMTCLASPROC.version = 1;
1024 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
1025 AddTSReq.WMMTCLASPROC.present = 1;
1026 }
1027 }
1028
1029 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
1030 if ( DOT11F_FAILED( nStatus ) )
1031 {
1032 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001033 "or an Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 nStatus );
1035 // We'll fall back on the worst case scenario:
1036 nPayload = sizeof( tDot11fAddTSRequest );
1037 }
1038 else if ( DOT11F_WARNED( nStatus ) )
1039 {
1040 limLog( pMac, LOGW, FL("There were warnings while calculating"
1041 "the packed size for an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001042 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001043 }
1044 }
1045 else
1046 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301047 vos_mem_set(( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001048
1049 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1050 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1051 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1052
1053 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1054 WMMAddTSReq.StatusCode.statusCode = 0;
1055
1056 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
1057#ifdef FEATURE_WLAN_CCX
1058 limGetPhyMode(pMac, &phyMode, psessionEntry);
1059
1060 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1061 {
1062 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1063 }
1064 else
1065 {
1066 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1067 }
1068 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.CCXTrafStrmRateSet,sizeof(tANI_U8));
1069#endif
1070 // fillWmeTspecIE
1071
1072 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1073 if ( DOT11F_FAILED( nStatus ) )
1074 {
1075 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001076 "or a WMM Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001077 nStatus );
1078 // We'll fall back on the worst case scenario:
1079 nPayload = sizeof( tDot11fAddTSRequest );
1080 }
1081 else if ( DOT11F_WARNED( nStatus ) )
1082 {
1083 limLog( pMac, LOGW, FL("There were warnings while calculating"
1084 "the packed size for a WMM Add TS Requ"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001085 "est (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001086 }
1087 }
1088
1089 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1090
1091 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1092 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1093 ( void** ) &pPacket );
1094 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1095 {
1096 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001097 "d TS Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001098 return;
1099 }
1100
1101 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301102 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001103
1104 // Next, we fill out the buffer descriptor:
1105 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1106 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1107 if ( eSIR_SUCCESS != nSirStatus )
1108 {
1109 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001110 "tor for an Add TS Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001111 nSirStatus );
1112 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1113 ( void* ) pFrame, ( void* ) pPacket );
1114 return;
1115 }
1116
1117 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1118
1119 #if 0
1120 cfgLen = SIR_MAC_ADDR_LENGTH;
1121 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1122 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1123 {
1124 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001125 "e sending an Add TS Request.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001126 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1127 ( void* ) pFrame, ( void* ) pPacket );
1128 return;
1129 }
1130 #endif //TO SUPPORT BT-AMP
1131
1132 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1133
Chet Lanctot186b5732013-03-18 10:26:30 -07001134#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001135 limSetProtectedBit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001136#endif
1137
Jeff Johnson295189b2012-06-20 16:38:30 -07001138 // That done, pack the struct:
1139 if ( ! pAddTS->wmeTspecPresent )
1140 {
1141 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1142 pFrame + sizeof(tSirMacMgmtHdr),
1143 nPayload, &nPayload );
1144 if ( DOT11F_FAILED( nStatus ) )
1145 {
1146 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001147 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001148 nStatus );
1149 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1150 return; // allocated!
1151 }
1152 else if ( DOT11F_WARNED( nStatus ) )
1153 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001154 limLog( pMac, LOGW, FL("There were warnings while packing "
1155 "an Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001156 }
1157 }
1158 else
1159 {
1160 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1161 pFrame + sizeof(tSirMacMgmtHdr),
1162 nPayload, &nPayload );
1163 if ( DOT11F_FAILED( nStatus ) )
1164 {
1165 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001166 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001167 nStatus );
1168 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1169 return; // allocated!
1170 }
1171 else if ( DOT11F_WARNED( nStatus ) )
1172 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001173 limLog( pMac, LOGW, FL("There were warnings while packing "
1174 "a WMM Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001175 }
1176 }
1177
1178 PELOG3(limLog( pMac, LOG3, FL("Sending an Add TS Request frame to ") );
1179 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1180
1181 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001182 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1183 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001184 )
1185 {
1186 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1187 }
1188
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301189 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1190 psessionEntry->peSessionId,
1191 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001192 // Queue Addts Response frame in high priority WQ
1193 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1194 HAL_TXRX_FRM_802_11_MGMT,
1195 ANI_TXDIR_TODS,
1196 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1197 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301198 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1199 psessionEntry->peSessionId,
1200 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001201 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1202 {
1203 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001204 " (%X) ***" ), halstatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001205 //Pkt will be freed up by the callback
1206 }
1207
1208} // End limSendAddtsReqActionFrame.
1209
Jeff Johnson295189b2012-06-20 16:38:30 -07001210
1211
1212void
1213limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1214 tANI_U16 statusCode,
1215 tANI_U16 aid,
1216 tSirMacAddr peerMacAddr,
1217 tANI_U8 subType,
1218 tpDphHashNode pSta,tpPESession psessionEntry)
1219{
1220 static tDot11fAssocResponse frm;
1221 tANI_U8 *pFrame, *macAddr;
1222 tpSirMacMgmtHdr pMacHdr;
1223 tSirRetStatus nSirStatus;
1224 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1225 tHalBitVal qosMode, wmeMode;
1226 tANI_U32 nPayload, nBytes, nStatus;
1227 void *pPacket;
1228 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301229 tUpdateBeaconParams beaconParams;
1230 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001231 tANI_U32 addnIEPresent = false;
1232 tANI_U32 addnIELen=0;
1233 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1234 tpSirAssocReq pAssocReq = NULL;
1235
1236 if(NULL == psessionEntry)
1237 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301238 limLog( pMac, LOGE, FL("psessionEntry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001239 return;
1240 }
1241
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301242 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001243
1244 limGetQosMode(psessionEntry, &qosMode);
1245 limGetWmeMode(psessionEntry, &wmeMode);
1246
1247 // An Add TS IE is added only if the AP supports it and the requesting
1248 // STA sent a traffic spec.
1249 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1250
1251 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1252
1253 frm.Status.status = statusCode;
1254
1255 frm.AID.associd = aid | LIM_AID_MASK;
1256
1257 if ( NULL == pSta )
1258 {
1259 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1260 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1261 }
1262 else
1263 {
1264 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1265 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1266 }
1267
Jeff Johnson295189b2012-06-20 16:38:30 -07001268 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1269 {
1270 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1271 {
1272 pAssocReq =
1273 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001274 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1275 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1276 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1277 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001278 }
1279 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001280
1281 if ( NULL != pSta )
1282 {
1283 if ( eHAL_SET == qosMode )
1284 {
1285 if ( pSta->lleEnabled )
1286 {
1287 lleMode = 1;
1288 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1289 {
1290 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1291
1292// FramesToDo:...
1293// if ( fAddTS )
1294// {
1295// tANI_U8 *pAf = pBody;
1296// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1297// tANI_U32 tlen;
1298// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1299// &tlen, bufLen - frameLen);
1300// } // End if on Add TS.
1301 }
1302 } // End if on .11e enabled in 'pSta'.
1303 } // End if on QOS Mode on.
1304
1305 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1306 {
1307 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1308 {
1309
Jeff Johnson295189b2012-06-20 16:38:30 -07001310 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001311
1312 if ( pSta->wsmEnabled )
1313 {
1314 PopulateDot11fWMMCaps(&frm.WMMCaps );
1315 }
1316 }
1317 }
1318
1319 if ( pSta->aniPeer )
1320 {
1321 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1322 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1323 {
1324 edcaInclude = 1;
1325 }
1326
1327 } // End if on Airgo peer.
1328
1329 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001330 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001331 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001332 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07001333 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001334 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001335
1336#ifdef WLAN_FEATURE_11AC
1337 if( pSta->mlmStaContext.vhtCapability &&
1338 psessionEntry->vhtCapability )
1339 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08001340 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Response"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001341 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
1342 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation);
Sandeep Puligilla60342762014-01-30 21:05:37 +05301343 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001344 }
1345#endif
1346
Jeff Johnson295189b2012-06-20 16:38:30 -07001347 } // End if on non-NULL 'pSta'.
1348
1349
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301350 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001351
Jeff Johnson295189b2012-06-20 16:38:30 -07001352 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1353 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1354 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1355 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001356
1357 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1358 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1359
1360 beaconParams.bssIdx = psessionEntry->bssIdx;
1361
1362 //Send message to HAL about beacon parameter change.
1363 if(beaconParams.paramChangeBitmap)
1364 {
1365 schSetFixedBeaconFields(pMac,psessionEntry);
1366 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1367 }
1368
1369 // Allocate a buffer for this frame:
1370 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1371 if ( DOT11F_FAILED( nStatus ) )
1372 {
1373 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001374 "or an Association Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001375 nStatus );
1376 return;
1377 }
1378 else if ( DOT11F_WARNED( nStatus ) )
1379 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001380 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07001381 "the packed size for an Association Re"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001382 "sponse (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001383 }
1384
1385 nBytes = sizeof( tSirMacMgmtHdr ) + nPayload;
1386
1387 if ( pAssocReq != NULL )
1388 {
1389 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1390 &addnIEPresent) != eSIR_SUCCESS)
1391 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301392 limLog(pMac, LOGP, FL("Unable to get "
1393 "WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001394 return;
1395 }
1396
1397 if (addnIEPresent)
1398 {
1399 //Assoc rsp IE available
1400 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1401 &addnIELen) != eSIR_SUCCESS)
1402 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301403 limLog(pMac, LOGP, FL("Unable to get "
1404 "WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001405 return;
1406 }
1407
1408 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1409 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1410 {
1411 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1412 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1413 {
1414 nBytes = nBytes + addnIELen;
1415 }
1416 }
1417 }
1418 }
1419
1420 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1421 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1422 ( void** ) &pPacket );
1423 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1424 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001425 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001426 return;
1427 }
1428
1429 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301430 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001431
1432 // Next, we fill out the buffer descriptor:
1433 nSirStatus = limPopulateMacHeader( pMac,
1434 pFrame,
1435 SIR_MAC_MGMT_FRAME,
1436 ( LIM_ASSOC == subType ) ?
1437 SIR_MAC_MGMT_ASSOC_RSP :
1438 SIR_MAC_MGMT_REASSOC_RSP,
1439 peerMacAddr,psessionEntry->selfMacAddr);
1440 if ( eSIR_SUCCESS != nSirStatus )
1441 {
1442 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001443 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001444 nSirStatus );
1445 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1446 ( void* ) pFrame, ( void* ) pPacket );
1447 return;
1448 }
1449
1450 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1451
Jeff Johnson295189b2012-06-20 16:38:30 -07001452 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1453
1454 nStatus = dot11fPackAssocResponse( pMac, &frm,
1455 pFrame + sizeof( tSirMacMgmtHdr ),
1456 nPayload, &nPayload );
1457 if ( DOT11F_FAILED( nStatus ) )
1458 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301459 limLog( pMac, LOGE, FL("Failed to pack an Association Response"
1460 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001461 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1462 ( void* ) pFrame, ( void* ) pPacket );
1463 return; // allocated!
1464 }
1465 else if ( DOT11F_WARNED( nStatus ) )
1466 {
1467 limLog( pMac, LOGW, FL("There were warnings while packing an "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001468 "Association Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001469 }
1470
1471 macAddr = pMacHdr->da;
1472
1473 if (subType == LIM_ASSOC)
1474 {
1475 PELOG1(limLog(pMac, LOG1,
1476 FL("*** Sending Assoc Resp status %d aid %d to "),
1477 statusCode, aid);)
1478 }
1479 else{
1480 PELOG1(limLog(pMac, LOG1,
1481 FL("*** Sending ReAssoc Resp status %d aid %d to "),
1482 statusCode, aid);)
1483 }
1484 PELOG1(limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1485
1486 if ( addnIEPresent )
1487 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301488 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001489 }
1490
1491 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001492 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1493 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001494 )
1495 {
1496 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1497 }
1498
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301499 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1500 psessionEntry->peSessionId,
1501 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001502 /// Queue Association Response frame in high priority WQ
1503 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1504 HAL_TXRX_FRM_802_11_MGMT,
1505 ANI_TXDIR_TODS,
1506 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1507 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301508 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1509 psessionEntry->peSessionId,
1510 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001511 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1512 {
1513 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001514 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001515 nSirStatus);
1516
1517 //Pkt will be freed up by the callback
1518 }
1519
1520 // update the ANI peer station count
1521 //FIXME_PROTECTION : take care of different type of station
1522 // counter inside this function.
1523 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1524
1525} // End limSendAssocRspMgmtFrame.
1526
1527
1528
1529void
1530limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1531 tSirMacAddr peer,
1532 tANI_U16 nStatusCode,
1533 tSirAddtsReqInfo *pAddTS,
1534 tSirMacScheduleIE *pSchedule,
1535 tpPESession psessionEntry)
1536{
1537 tANI_U8 *pFrame;
1538 tpSirMacMgmtHdr pMacHdr;
1539 tDot11fAddTSResponse AddTSRsp;
1540 tDot11fWMMAddTSResponse WMMAddTSRsp;
1541 tSirRetStatus nSirStatus;
1542 tANI_U32 i, nBytes, nPayload, nStatus;
1543 void *pPacket;
1544 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301545 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001546
1547 if(NULL == psessionEntry)
1548 {
1549 return;
1550 }
1551
1552 if ( ! pAddTS->wmeTspecPresent )
1553 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301554 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001555
1556 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1557 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1558 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1559 AddTSRsp.Status.status = nStatusCode;
1560
1561 // The TsDelay information element is only filled in for a specific
1562 // status code:
1563 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1564 {
1565 if ( pAddTS->wsmTspecPresent )
1566 {
1567 AddTSRsp.WMMTSDelay.version = 1;
1568 AddTSRsp.WMMTSDelay.delay = 10;
1569 AddTSRsp.WMMTSDelay.present = 1;
1570 }
1571 else
1572 {
1573 AddTSRsp.TSDelay.delay = 10;
1574 AddTSRsp.TSDelay.present = 1;
1575 }
1576 }
1577
1578 if ( pAddTS->wsmTspecPresent )
1579 {
1580 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1581 }
1582 else
1583 {
1584 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1585 }
1586
1587 if ( pAddTS->wsmTspecPresent )
1588 {
1589 AddTSRsp.num_WMMTCLAS = 0;
1590 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1591 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1592 {
1593 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1594 &AddTSRsp.TCLAS[i] );
1595 }
1596 }
1597 else
1598 {
1599 AddTSRsp.num_TCLAS = 0;
1600 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1601 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1602 {
1603 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1604 &AddTSRsp.WMMTCLAS[i] );
1605 }
1606 }
1607
1608 if ( pAddTS->tclasProcPresent )
1609 {
1610 if ( pAddTS->wsmTspecPresent )
1611 {
1612 AddTSRsp.WMMTCLASPROC.version = 1;
1613 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1614 AddTSRsp.WMMTCLASPROC.present = 1;
1615 }
1616 else
1617 {
1618 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1619 AddTSRsp.TCLASSPROC.present = 1;
1620 }
1621 }
1622
1623 // schedule element is included only if requested in the tspec and we are
1624 // using hcca (or both edca and hcca)
1625 // 11e-D8.0 is inconsistent on whether the schedule element is included
1626 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1627 // pg 46, line 17-18 says something else. So just include it and let the
1628 // sta figure it out
1629 if ((pSchedule != NULL) &&
1630 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1631 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1632 {
1633 if ( pAddTS->wsmTspecPresent )
1634 {
1635 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1636 }
1637 else
1638 {
1639 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1640 }
1641 }
1642
1643 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1644 if ( DOT11F_FAILED( nStatus ) )
1645 {
1646 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001647 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001648 nStatus );
1649 // We'll fall back on the worst case scenario:
1650 nPayload = sizeof( tDot11fAddTSResponse );
1651 }
1652 else if ( DOT11F_WARNED( nStatus ) )
1653 {
1654 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001655 "ting the packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001656 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001657 }
1658 }
1659 else
1660 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301661 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001662
1663 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1664 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1665 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1666 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1667
1668 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1669
1670 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1671 if ( DOT11F_FAILED( nStatus ) )
1672 {
1673 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001674 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001675 nStatus );
1676 // We'll fall back on the worst case scenario:
1677 nPayload = sizeof( tDot11fWMMAddTSResponse );
1678 }
1679 else if ( DOT11F_WARNED( nStatus ) )
1680 {
1681 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001682 "ting the packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001683 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001684 }
1685 }
1686
1687 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1688
1689 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1690 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1691 {
1692 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001693 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001694 return;
1695 }
1696
1697 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301698 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001699
1700 // Next, we fill out the buffer descriptor:
1701 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1702 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1703 if ( eSIR_SUCCESS != nSirStatus )
1704 {
1705 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001706 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001707 nSirStatus );
1708 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1709 return; // allocated!
1710 }
1711
1712 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1713
1714
1715 #if 0
1716 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1717 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1718 {
1719 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001720 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001721 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1722 return; // allocated!
1723 }
1724 #endif //TO SUPPORT BT-AMP
1725 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1726
Chet Lanctot186b5732013-03-18 10:26:30 -07001727#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001728 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001729#endif
1730
Jeff Johnson295189b2012-06-20 16:38:30 -07001731 // That done, pack the struct:
1732 if ( ! pAddTS->wmeTspecPresent )
1733 {
1734 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1735 pFrame + sizeof( tSirMacMgmtHdr ),
1736 nPayload, &nPayload );
1737 if ( DOT11F_FAILED( nStatus ) )
1738 {
1739 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001740 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001741 nStatus );
1742 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1743 return;
1744 }
1745 else if ( DOT11F_WARNED( nStatus ) )
1746 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001747 limLog( pMac, LOGW, FL("There were warnings while packing "
1748 "an Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001749 }
1750 }
1751 else
1752 {
1753 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
1754 pFrame + sizeof( tSirMacMgmtHdr ),
1755 nPayload, &nPayload );
1756 if ( DOT11F_FAILED( nStatus ) )
1757 {
1758 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001759 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001760 nStatus );
1761 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1762 return;
1763 }
1764 else if ( DOT11F_WARNED( nStatus ) )
1765 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001766 limLog( pMac, LOGW, FL("There were warnings while packing "
1767 "a WMM Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001768 }
1769 }
1770
1771 PELOG1(limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
1772 nStatusCode );
1773 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );)
1774
1775 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001776 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1777 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001778 )
1779 {
1780 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1781 }
1782
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301783 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1784 psessionEntry->peSessionId,
1785 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001786 // Queue the frame in high priority WQ:
1787 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1788 HAL_TXRX_FRM_802_11_MGMT,
1789 ANI_TXDIR_TODS,
1790 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1791 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301792 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1793 psessionEntry->peSessionId,
1794 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001795 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1796 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001797 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001798 nSirStatus );
1799 //Pkt will be freed up by the callback
1800 }
1801
1802} // End limSendAddtsRspActionFrame.
1803
1804void
1805limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
1806 tSirMacAddr peer,
1807 tANI_U8 wmmTspecPresent,
1808 tSirMacTSInfo *pTsinfo,
1809 tSirMacTspecIE *pTspecIe,
1810 tpPESession psessionEntry)
1811{
1812 tANI_U8 *pFrame;
1813 tpSirMacMgmtHdr pMacHdr;
1814 tDot11fDelTS DelTS;
1815 tDot11fWMMDelTS WMMDelTS;
1816 tSirRetStatus nSirStatus;
1817 tANI_U32 nBytes, nPayload, nStatus;
1818 void *pPacket;
1819 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301820 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001821
1822 if(NULL == psessionEntry)
1823 {
1824 return;
1825 }
1826
1827 if ( ! wmmTspecPresent )
1828 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301829 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001830
1831 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1832 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1833 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
1834
1835 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
1836 if ( DOT11F_FAILED( nStatus ) )
1837 {
1838 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001839 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001840 nStatus );
1841 // We'll fall back on the worst case scenario:
1842 nPayload = sizeof( tDot11fDelTS );
1843 }
1844 else if ( DOT11F_WARNED( nStatus ) )
1845 {
1846 limLog( pMac, LOGW, FL("There were warnings while calcula"
1847 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001848 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001849 }
1850 }
1851 else
1852 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301853 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001854
1855 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
1856 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1857 WMMDelTS.DialogToken.token = 0;
1858 WMMDelTS.StatusCode.statusCode = 0;
1859 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
1860 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
1861 if ( DOT11F_FAILED( nStatus ) )
1862 {
1863 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001864 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001865 nStatus );
1866 // We'll fall back on the worst case scenario:
1867 nPayload = sizeof( tDot11fDelTS );
1868 }
1869 else if ( DOT11F_WARNED( nStatus ) )
1870 {
1871 limLog( pMac, LOGW, FL("There were warnings while calcula"
1872 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001873 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001874 }
1875 }
1876
1877 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1878
1879 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1880 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1881 {
1882 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001883 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001884 return;
1885 }
1886
1887 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301888 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001889
1890 // Next, we fill out the buffer descriptor:
1891 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1892 SIR_MAC_MGMT_ACTION, peer,
1893 psessionEntry->selfMacAddr);
1894 if ( eSIR_SUCCESS != nSirStatus )
1895 {
1896 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001897 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001898 nSirStatus );
1899 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1900 return; // allocated!
1901 }
1902
1903 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1904
1905 #if 0
1906
1907 cfgLen = SIR_MAC_ADDR_LENGTH;
1908 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1909 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1910 {
1911 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001912 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001913 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1914 return; // allocated!
1915 }
1916 #endif //TO SUPPORT BT-AMP
1917 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
1918
Chet Lanctot186b5732013-03-18 10:26:30 -07001919#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001920 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001921#endif
1922
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 // That done, pack the struct:
1924 if ( !wmmTspecPresent )
1925 {
1926 nStatus = dot11fPackDelTS( pMac, &DelTS,
1927 pFrame + sizeof( tSirMacMgmtHdr ),
1928 nPayload, &nPayload );
1929 if ( DOT11F_FAILED( nStatus ) )
1930 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001931 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001932 nStatus );
1933 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1934 return; // allocated!
1935 }
1936 else if ( DOT11F_WARNED( nStatus ) )
1937 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001938 limLog( pMac, LOGW, FL("There were warnings while packing "
1939 "a Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001940 }
1941 }
1942 else
1943 {
1944 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
1945 pFrame + sizeof( tSirMacMgmtHdr ),
1946 nPayload, &nPayload );
1947 if ( DOT11F_FAILED( nStatus ) )
1948 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001949 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001950 nStatus );
1951 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1952 return; // allocated!
1953 }
1954 else if ( DOT11F_WARNED( nStatus ) )
1955 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001956 limLog( pMac, LOGW, FL("There were warnings while packing "
1957 "a WMM Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001958 }
1959 }
1960
1961 PELOG1(limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
1962 limPrintMacAddr(pMac, pMacHdr->da, LOG1);)
1963
1964 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001965 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1966 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001967 )
1968 {
1969 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1970 }
1971
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301972 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1973 psessionEntry->peSessionId,
1974 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001975 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1976 HAL_TXRX_FRM_802_11_MGMT,
1977 ANI_TXDIR_TODS,
1978 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1979 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301980 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1981 psessionEntry->peSessionId,
1982 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001983 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1984 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001985 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001986 nSirStatus );
1987 //Pkt will be freed up by the callback
1988 }
1989
1990} // End limSendDeltsReqActionFrame.
1991
1992void
1993limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
1994 tLimMlmAssocReq *pMlmAssocReq,
1995 tpPESession psessionEntry)
1996{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001997 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07001998 tANI_U16 caps;
1999 tANI_U8 *pFrame;
2000 tSirRetStatus nSirStatus;
2001 tLimMlmAssocCnf mlmAssocCnf;
2002 tANI_U32 nBytes, nPayload, nStatus;
2003 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2004 void *pPacket;
2005 eHalStatus halstatus;
2006 tANI_U16 nAddIELen;
2007 tANI_U8 *pAddIE;
2008 tANI_U8 *wpsIe = NULL;
2009#if defined WLAN_FEATURE_VOWIFI
2010 tANI_U8 PowerCapsPopulated = FALSE;
2011#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302012 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302013 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002014
2015 if(NULL == psessionEntry)
2016 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302017 limLog(pMac, LOGE, FL("psessionEntry is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002018 return;
2019 }
2020
Jeff Johnson295189b2012-06-20 16:38:30 -07002021 /* check this early to avoid unncessary operation */
2022 if(NULL == psessionEntry->pLimJoinReq)
2023 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302024 limLog(pMac, LOGE, FL("psessionEntry->pLimJoinReq is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002025 return;
2026 }
2027 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
2028 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
2029
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302030 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
2031 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002032 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302033 limLog(pMac, LOGE, FL("Unable to allocate memory") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002034 return;
2035 }
2036
2037
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302038 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002039
2040 caps = pMlmAssocReq->capabilityInfo;
2041 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2042 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2043#if defined(FEATURE_WLAN_WAPI)
2044 /* CR: 262463 :
2045 According to WAPI standard:
2046 7.3.1.4 Capability Information field
2047 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2048 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2049 Reassociation management frames. */
2050 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2051 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2052#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002053 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002054
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002055 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2056 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002057 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002058 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002059
2060 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2061 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2062
2063 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2064 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2065
2066 // We prefer .11e asociations:
2067 if ( fQosEnabled ) fWmeEnabled = false;
2068
2069 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2070 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2071
2072 if ( psessionEntry->lim11hEnable &&
2073 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2074 {
2075#if defined WLAN_FEATURE_VOWIFI
2076 PowerCapsPopulated = TRUE;
2077
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002078 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002079#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002080 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002081
2082 }
2083
2084#if defined WLAN_FEATURE_VOWIFI
2085 if( pMac->rrm.rrmPEContext.rrmEnable &&
2086 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2087 {
2088 if (PowerCapsPopulated == FALSE)
2089 {
2090 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002091 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002092 }
2093 }
2094#endif
2095
2096 if ( fQosEnabled &&
2097 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002098 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002099
2100 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002101 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002102
2103#if defined WLAN_FEATURE_VOWIFI
2104 if( pMac->rrm.rrmPEContext.rrmEnable &&
2105 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2106 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002107 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002108 }
2109#endif
2110 // The join request *should* contain zero or one of the WPA and RSN
2111 // IEs. The payload send along with the request is a
2112 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2113
2114 // typedef struct sSirRSNie
2115 // {
2116 // tANI_U16 length;
2117 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2118 // } tSirRSNie, *tpSirRSNie;
2119
2120 // So, we should be able to make the following two calls harmlessly,
2121 // since they do nothing if they don't find the given IE in the
2122 // bytestream with which they're provided.
2123
2124 // The net effect of this will be to faithfully transmit whatever
2125 // security IE is in the join request.
2126
2127 // *However*, if we're associating for the purpose of WPS
2128 // enrollment, and we've been configured to indicate that by
2129 // eliding the WPA or RSN IE, we just skip this:
2130 if( nAddIELen && pAddIE )
2131 {
2132 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2133 }
2134 if ( NULL == wpsIe )
2135 {
2136 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002137 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002138 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002139 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002140#if defined(FEATURE_WLAN_WAPI)
2141 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002142 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002143#endif // defined(FEATURE_WLAN_WAPI)
2144 }
2145
2146 // include WME EDCA IE as well
2147 if ( fWmeEnabled )
2148 {
2149 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2150 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002151 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002152 }
2153
2154 if ( fWsmEnabled &&
2155 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2156 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002157 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002158 }
2159 }
2160
2161 //Populate HT IEs, when operating in 11n or Taurus modes AND
2162 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002163 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002164 pMac->lim.htCapabilityPresentInBeacon)
2165 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002166 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002167#ifdef DISABLE_GF_FOR_INTEROP
2168
2169 /*
2170 * To resolve the interop problem with Broadcom AP,
2171 * where TQ STA could not pass traffic with GF enabled,
2172 * TQ STA will do Greenfield only with TQ AP, for
2173 * everybody else it will be turned off.
2174 */
2175
2176 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2177 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302178 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP,"
2179 " Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002180 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002181 }
2182#endif
2183
2184 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002185#ifdef WLAN_FEATURE_11AC
2186 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002187 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002188 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002189 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002190 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps );
Jeff Johnsone7245742012-09-05 17:12:55 -07002191 }
2192#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302193 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002194
2195#if defined WLAN_FEATURE_VOWIFI_11R
2196 if (psessionEntry->pLimJoinReq->is11Rconnection)
2197 {
2198#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002199 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2201 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2202 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2203#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302204 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2205 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002206 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302207 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002208 {
2209 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302210 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002211 }
2212#endif
2213
2214#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302215 /* For CCX Associations fill the CCX IEs */
2216 if (psessionEntry->isCCXconnection &&
2217 psessionEntry->pLimJoinReq->isCCXFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002218 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002219#ifndef FEATURE_DISABLE_RM
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002220 PopulateDot11fCCXRadMgmtCap(&pFrm->CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002221#endif
Sandeep Puligillae9ffdf62013-11-23 18:23:00 +05302222 PopulateDot11fCCXVersion(&pFrm->CCXVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002223 }
2224#endif
2225
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002226 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002227 if ( DOT11F_FAILED( nStatus ) )
2228 {
2229 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002230 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002231 nStatus );
2232 // We'll fall back on the worst case scenario:
2233 nPayload = sizeof( tDot11fAssocRequest );
2234 }
2235 else if ( DOT11F_WARNED( nStatus ) )
2236 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002237 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002238 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002239 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002240 }
2241
2242 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2243
2244 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2245 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2246 ( void** ) &pPacket );
2247 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2248 {
2249 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002250 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002251
2252 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002253 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002254
2255
2256 /* Update PE session id*/
2257 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2258
2259 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2260
2261 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2262 ( void* ) pFrame, ( void* ) pPacket );
2263
2264 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2265 ( tANI_U32* ) &mlmAssocCnf);
2266
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302267 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002268 return;
2269 }
2270
2271 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302272 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002273
2274 // Next, we fill out the buffer descriptor:
2275 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2276 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2277 if ( eSIR_SUCCESS != nSirStatus )
2278 {
2279 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002280 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002281 nSirStatus );
2282 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302283 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002284 return;
2285 }
2286
2287
Abhishek Singh57aebef2014-02-03 18:47:44 +05302288 // That done, pack the Assoc Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002289 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002290 sizeof(tSirMacMgmtHdr),
2291 nPayload, &nPayload );
2292 if ( DOT11F_FAILED( nStatus ) )
2293 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302294 limLog( pMac, LOGE, FL("Failed to pack a Assoc Request (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002295 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002296 nStatus );
2297 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2298 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302299 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002300 return;
2301 }
2302 else if ( DOT11F_WARNED( nStatus ) )
2303 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302304 limLog( pMac, LOGW, FL("There were warnings while packing a Assoc"
2305 "Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002306 }
2307
2308 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002309 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002310 nBytes );)
2311 // limPrintMacAddr( pMac, bssid, LOG1 );
2312
2313 if( psessionEntry->assocReq != NULL )
2314 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302315 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002316 psessionEntry->assocReq = NULL;
2317 }
2318
2319 if( nAddIELen )
2320 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302321 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2322 pAddIE,
2323 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002324 nPayload += nAddIELen;
2325 }
2326
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302327 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2328 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002329 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302330 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store "
2331 "assoc request"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002332 }
2333 else
2334 {
2335 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302336 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002337 psessionEntry->assocReqLen = nPayload;
2338 }
2339
2340 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002341 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2342 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002343 )
2344 {
2345 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2346 }
2347
Ganesh K08bce952012-12-13 15:04:41 -08002348 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2349 {
2350 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2351 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302352
2353 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
2354 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2355 psessionEntry->peSessionId,
2356 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002357 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2358 HAL_TXRX_FRM_802_11_MGMT,
2359 ANI_TXDIR_TODS,
2360 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2361 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302362 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2363 psessionEntry->peSessionId,
2364 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002365 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2366 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002367 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002368 halstatus );
2369 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302370 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002371 return;
2372 }
2373
2374 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302375 vos_mem_free(pMlmAssocReq);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002376 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302377 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002378 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002379} // End limSendAssocReqMgmtFrame
2380
2381
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002382#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002383/*------------------------------------------------------------------------------------
2384 *
2385 * Send Reassoc Req with FTIEs.
2386 *
2387 *-----------------------------------------------------------------------------------
2388 */
2389void
2390limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2391 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2392{
2393 static tDot11fReAssocRequest frm;
2394 tANI_U16 caps;
2395 tANI_U8 *pFrame;
2396 tSirRetStatus nSirStatus;
2397 tANI_U32 nBytes, nPayload, nStatus;
2398 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2399 void *pPacket;
2400 eHalStatus halstatus;
2401#if defined WLAN_FEATURE_VOWIFI
2402 tANI_U8 PowerCapsPopulated = FALSE;
2403#endif
2404 tANI_U16 ft_ies_length = 0;
2405 tANI_U8 *pBody;
2406 tANI_U16 nAddIELen;
2407 tANI_U8 *pAddIE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002408#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002409 tANI_U8 *wpsIe = NULL;
2410#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302411 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302412 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002413
2414 if (NULL == psessionEntry)
2415 {
2416 return;
2417 }
2418
Jeff Johnson295189b2012-06-20 16:38:30 -07002419 /* check this early to avoid unncessary operation */
2420 if(NULL == psessionEntry->pLimReAssocReq)
2421 {
2422 return;
2423 }
2424 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2425 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002426 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2427 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002428
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302429 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002430
2431 caps = pMlmReassocReq->capabilityInfo;
2432 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2433 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2434#if defined(FEATURE_WLAN_WAPI)
2435 /* CR: 262463 :
2436 According to WAPI standard:
2437 7.3.1.4 Capability Information field
2438 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2439 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2440 Reassociation management frames. */
2441 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2442 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2443#endif
2444 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2445
2446 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2447
2448 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302449 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002450 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2451
2452 PopulateDot11fSSID2( pMac, &frm.SSID );
2453 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2454 &frm.SuppRates,psessionEntry);
2455
2456 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2457 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2458
2459 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2460 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2461
2462 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2463 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2464
2465 if ( psessionEntry->lim11hEnable &&
2466 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2467 {
2468#if defined WLAN_FEATURE_VOWIFI
2469 PowerCapsPopulated = TRUE;
2470
2471 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2472 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2473#endif
2474 }
2475
2476#if defined WLAN_FEATURE_VOWIFI
2477 if( pMac->rrm.rrmPEContext.rrmEnable &&
2478 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2479 {
2480 if (PowerCapsPopulated == FALSE)
2481 {
2482 PowerCapsPopulated = TRUE;
2483 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2484 }
2485 }
2486#endif
2487
2488 if ( fQosEnabled &&
2489 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2490 {
2491 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2492 }
2493
2494 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2495 &frm.ExtSuppRates, psessionEntry );
2496
2497#if defined WLAN_FEATURE_VOWIFI
2498 if( pMac->rrm.rrmPEContext.rrmEnable &&
2499 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2500 {
2501 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2502 }
2503#endif
2504
2505 // Ideally this should be enabled for 11r also. But 11r does
2506 // not follow the usual norm of using the Opaque object
2507 // for rsnie and fties. Instead we just add
2508 // the rsnie and fties at the end of the pack routine for 11r.
2509 // This should ideally! be fixed.
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002510#if defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 //
2512 // The join request *should* contain zero or one of the WPA and RSN
2513 // IEs. The payload send along with the request is a
2514 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2515
2516 // typedef struct sSirRSNie
2517 // {
2518 // tANI_U16 length;
2519 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2520 // } tSirRSNie, *tpSirRSNie;
2521
2522 // So, we should be able to make the following two calls harmlessly,
2523 // since they do nothing if they don't find the given IE in the
2524 // bytestream with which they're provided.
2525
2526 // The net effect of this will be to faithfully transmit whatever
2527 // security IE is in the join request.
2528
2529 // *However*, if we're associating for the purpose of WPS
2530 // enrollment, and we've been configured to indicate that by
2531 // eliding the WPA or RSN IE, we just skip this:
2532 if (!psessionEntry->is11Rconnection)
2533 {
2534 if( nAddIELen && pAddIE )
2535 {
2536 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2537 }
2538 if ( NULL == wpsIe )
2539 {
2540 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2541 &frm.RSNOpaque );
2542 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2543 &frm.WPAOpaque );
2544 }
2545
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002546#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302547 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002548 {
2549 PopulateDot11fCCXCckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2550 &frm.CCXCckmOpaque );
2551 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002552#endif //FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002553 }
2554
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002555#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07002556 // For CCX Associations fill the CCX IEs
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302557 if (psessionEntry->isCCXconnection &&
2558 psessionEntry->pLimReAssocReq->isCCXFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002559 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002560#ifndef FEATURE_DISABLE_RM
Jeff Johnson295189b2012-06-20 16:38:30 -07002561 PopulateDot11fCCXRadMgmtCap(&frm.CCXRadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002562#endif
Sandeep Puligillae9ffdf62013-11-23 18:23:00 +05302563 PopulateDot11fCCXVersion(&frm.CCXVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002564 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302565#endif //FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002566#endif //FEATURE_WLAN_CCX || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002567
2568 // include WME EDCA IE as well
2569 if ( fWmeEnabled )
2570 {
2571 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2572 {
2573 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2574 }
2575
2576 if ( fWsmEnabled &&
2577 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2578 {
2579 PopulateDot11fWMMCaps( &frm.WMMCaps );
2580 }
2581#ifdef FEATURE_WLAN_CCX
2582 if (psessionEntry->isCCXconnection)
2583 {
2584 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2585
2586 // Populate the TSRS IE if TSPEC is included in the reassoc request
2587 if (psessionEntry->pLimReAssocReq->ccxTspecInfo.numTspecs)
2588 {
2589 tANI_U32 phyMode;
2590 tSirMacCCXTSRSIE tsrsIE;
2591 limGetPhyMode(pMac, &phyMode, psessionEntry);
2592
2593 tsrsIE.tsid = 0;
2594 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2595 {
2596 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2597 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302598 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002599 {
2600 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2601 }
2602 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.CCXTrafStrmRateSet, sizeof(tANI_U8));
2603 }
2604 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302605#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 }
2607
Jeff Johnsone7245742012-09-05 17:12:55 -07002608 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002609 pMac->lim.htCapabilityPresentInBeacon)
2610 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002611 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002612 }
2613
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002614#if defined WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302615 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent && (0 == pMac->ft.ftSmeContext.reassoc_ft_ies_length)
2616#if defined FEATURE_WLAN_CCX
2617 && !psessionEntry->isCCXconnection
2618#endif
2619 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002620 {
2621 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2622 }
2623#endif
2624
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002625#ifdef WLAN_FEATURE_11AC
2626 if ( psessionEntry->vhtCapability &&
2627 psessionEntry->vhtCapabilityPresentInBeacon)
2628 {
2629 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
2630 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002631 }
2632#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302633 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002634
Jeff Johnson295189b2012-06-20 16:38:30 -07002635 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2636 if ( DOT11F_FAILED( nStatus ) )
2637 {
2638 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002639 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002640 nStatus );
2641 // We'll fall back on the worst case scenario:
2642 nPayload = sizeof( tDot11fReAssocRequest );
2643 }
2644 else if ( DOT11F_WARNED( nStatus ) )
2645 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002646 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002647 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002648 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002649 }
2650
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002651 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002652
2653#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002654 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002655 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2656#endif
2657
2658#if defined WLAN_FEATURE_VOWIFI_11R
2659 if (psessionEntry->is11Rconnection)
2660 {
2661 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2662 }
2663#endif
2664
2665 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2666 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2667 ( void** ) &pPacket );
2668 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2669 {
2670 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002671 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002672 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002673 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002674 goto end;
2675 }
2676
2677 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302678 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002679
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002680#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002681 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002682#endif
2683 // Next, we fill out the buffer descriptor:
2684 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2685 SIR_MAC_MGMT_REASSOC_REQ,
2686 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2687 if ( eSIR_SUCCESS != nSirStatus )
2688 {
2689 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002690 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002691 nSirStatus );
2692 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2693 goto end;
2694 }
2695
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302696 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07002697 // That done, pack the ReAssoc Request:
2698 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2699 sizeof(tSirMacMgmtHdr),
2700 nPayload, &nPayload );
2701 if ( DOT11F_FAILED( nStatus ) )
2702 {
2703 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002704 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002705 nStatus );
2706 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2707 goto end;
2708 }
2709 else if ( DOT11F_WARNED( nStatus ) )
2710 {
2711 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002712 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002713 }
2714
2715 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002716 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002717 nBytes, nPayload );)
2718 if( psessionEntry->assocReq != NULL )
2719 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302720 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002721 psessionEntry->assocReq = NULL;
2722 }
2723
2724 if( nAddIELen )
2725 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302726 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2727 pAddIE,
2728 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002729 nPayload += nAddIELen;
2730 }
2731
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302732 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2733 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002734 {
2735 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07002736 }
2737 else
2738 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002739 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302740 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002741 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07002742 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002743
2744 if (psessionEntry->is11Rconnection)
2745 {
2746 {
2747 int i = 0;
2748
2749 pBody = pFrame + nBytes;
2750 for (i=0; i<ft_ies_length; i++)
2751 {
2752 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
2753 pBody++;
2754 }
2755 }
2756 }
2757
2758#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002759 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
2760 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002761 (tANI_U8 *)pFrame,
2762 (nBytes + ft_ies_length));)
2763#endif
2764
2765
2766 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002767 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2768 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002769 )
2770 {
2771 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2772 }
2773
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002774 if( NULL != psessionEntry->assocReq )
2775 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302776 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002777 psessionEntry->assocReq = NULL;
2778 }
2779
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302780 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
2781 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002782 {
2783 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002784 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002785 }
2786 else
2787 {
2788 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302789 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
2790 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002791 psessionEntry->assocReqLen = (ft_ies_length);
2792 }
2793
2794
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302795 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2796 psessionEntry->peSessionId,
2797 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002798 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
2799 HAL_TXRX_FRM_802_11_MGMT,
2800 ANI_TXDIR_TODS,
2801 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2802 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302803 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2804 psessionEntry->peSessionId,
2805 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002806 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2807 {
2808 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002809 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002810 nSirStatus );
2811 //Pkt will be freed up by the callback
2812 goto end;
2813 }
2814
2815end:
2816 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302817 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07002818 psessionEntry->pLimMlmReassocReq = NULL;
2819
2820}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002821
2822void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
2823 tLimMlmReassocReq *pMlmReassocReq,
2824 tpPESession psessionEntry)
2825{
2826 tLimMlmReassocCnf mlmReassocCnf; // keep sme
2827 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
2828 if(NULL == pTmpMlmReassocReq)
2829 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302830 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
2831 if ( NULL == pTmpMlmReassocReq ) goto end;
2832 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
2833 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002834 }
2835
2836 // Prepare and send Reassociation request frame
2837 // start reassoc timer.
2838 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
2839 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002840 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002841 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
2842 != TX_SUCCESS)
2843 {
2844 // Could not start reassoc failure timer.
2845 // Log error
2846 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002847 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002848 // Return Reassoc confirm with
2849 // Resources Unavailable
2850 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2851 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2852 goto end;
2853 }
2854
2855 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
2856 return;
2857
2858end:
2859 // Free up buffer allocated for reassocReq
2860 if (pMlmReassocReq != NULL)
2861 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302862 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002863 pMlmReassocReq = NULL;
2864 }
2865 if (pTmpMlmReassocReq != NULL)
2866 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302867 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07002868 pTmpMlmReassocReq = NULL;
2869 }
2870 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
2871 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2872 /* Update PE sessio Id*/
2873 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
2874
2875 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
2876}
2877
Jeff Johnson295189b2012-06-20 16:38:30 -07002878#endif /* WLAN_FEATURE_VOWIFI_11R */
2879
2880
2881void
2882limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
2883 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2884{
2885 static tDot11fReAssocRequest frm;
2886 tANI_U16 caps;
2887 tANI_U8 *pFrame;
2888 tSirRetStatus nSirStatus;
2889 tANI_U32 nBytes, nPayload, nStatus;
2890 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2891 void *pPacket;
2892 eHalStatus halstatus;
2893 tANI_U16 nAddIELen;
2894 tANI_U8 *pAddIE;
2895 tANI_U8 *wpsIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302896 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002897#if defined WLAN_FEATURE_VOWIFI
2898 tANI_U8 PowerCapsPopulated = FALSE;
2899#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302900 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002901
2902 if(NULL == psessionEntry)
2903 {
2904 return;
2905 }
2906
2907 /* check this early to avoid unncessary operation */
2908 if(NULL == psessionEntry->pLimReAssocReq)
2909 {
2910 return;
2911 }
2912 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2913 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
2914
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302915 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002916
2917 caps = pMlmReassocReq->capabilityInfo;
2918 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2919 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2920#if defined(FEATURE_WLAN_WAPI)
2921 /* CR: 262463 :
2922 According to WAPI standard:
2923 7.3.1.4 Capability Information field
2924 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2925 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2926 Reassociation management frames. */
2927 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2928 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2929#endif
2930 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2931
2932 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2933
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302934 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
2935 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002936
2937 PopulateDot11fSSID2( pMac, &frm.SSID );
2938 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2939 &frm.SuppRates,psessionEntry);
2940
2941 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
2942 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2943
2944 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2945 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2946
2947 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2948 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2949
2950
2951 if ( psessionEntry->lim11hEnable &&
2952 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2953 {
2954#if defined WLAN_FEATURE_VOWIFI
2955 PowerCapsPopulated = TRUE;
2956 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2957 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2958#endif
2959 }
2960
2961#if defined WLAN_FEATURE_VOWIFI
2962 if( pMac->rrm.rrmPEContext.rrmEnable &&
2963 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2964 {
2965 if (PowerCapsPopulated == FALSE)
2966 {
2967 PowerCapsPopulated = TRUE;
2968 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2969 }
2970 }
2971#endif
2972
2973 if ( fQosEnabled &&
2974 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2975 {
2976 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2977 }
2978
2979 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2980 &frm.ExtSuppRates, psessionEntry );
2981
2982#if defined WLAN_FEATURE_VOWIFI
2983 if( pMac->rrm.rrmPEContext.rrmEnable &&
2984 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2985 {
2986 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2987 }
2988#endif
2989 // The join request *should* contain zero or one of the WPA and RSN
2990 // IEs. The payload send along with the request is a
2991 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2992
2993 // typedef struct sSirRSNie
2994 // {
2995 // tANI_U16 length;
2996 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2997 // } tSirRSNie, *tpSirRSNie;
2998
2999 // So, we should be able to make the following two calls harmlessly,
3000 // since they do nothing if they don't find the given IE in the
3001 // bytestream with which they're provided.
3002
3003 // The net effect of this will be to faithfully transmit whatever
3004 // security IE is in the join request.
3005
3006 // *However*, if we're associating for the purpose of WPS
3007 // enrollment, and we've been configured to indicate that by
3008 // eliding the WPA or RSN IE, we just skip this:
3009 if( nAddIELen && pAddIE )
3010 {
3011 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
3012 }
3013 if ( NULL == wpsIe )
3014 {
3015 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3016 &frm.RSNOpaque );
3017 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3018 &frm.WPAOpaque );
3019#if defined(FEATURE_WLAN_WAPI)
3020 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3021 &frm.WAPIOpaque );
3022#endif // defined(FEATURE_WLAN_WAPI)
3023 }
3024
3025 // include WME EDCA IE as well
3026 if ( fWmeEnabled )
3027 {
3028 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
3029 {
3030 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
3031 }
3032
3033 if ( fWsmEnabled &&
3034 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3035 {
3036 PopulateDot11fWMMCaps( &frm.WMMCaps );
3037 }
3038 }
3039
Jeff Johnsone7245742012-09-05 17:12:55 -07003040 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003041 pMac->lim.htCapabilityPresentInBeacon)
3042 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003043 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003044 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003045#ifdef WLAN_FEATURE_11AC
3046 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003047 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003048 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003049 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003050 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps );
Sandeep Puligilla60342762014-01-30 21:05:37 +05303051 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003052 }
3053#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003054
3055 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3056 if ( DOT11F_FAILED( nStatus ) )
3057 {
3058 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003059 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003060 nStatus );
3061 // We'll fall back on the worst case scenario:
3062 nPayload = sizeof( tDot11fReAssocRequest );
3063 }
3064 else if ( DOT11F_WARNED( nStatus ) )
3065 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003066 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003067 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003068 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003069 }
3070
3071 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3072
3073 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3074 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3075 ( void** ) &pPacket );
3076 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3077 {
3078 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003079 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003080 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003081 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003082 goto end;
3083 }
3084
3085 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303086 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003087
3088 // Next, we fill out the buffer descriptor:
3089 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3090 SIR_MAC_MGMT_REASSOC_REQ,
3091 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3092 if ( eSIR_SUCCESS != nSirStatus )
3093 {
3094 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003095 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003096 nSirStatus );
3097 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3098 goto end;
3099 }
3100
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303101 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003102 // That done, pack the Probe Request:
3103 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3104 sizeof(tSirMacMgmtHdr),
3105 nPayload, &nPayload );
3106 if ( DOT11F_FAILED( nStatus ) )
3107 {
3108 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003109 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003110 nStatus );
3111 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3112 goto end;
3113 }
3114 else if ( DOT11F_WARNED( nStatus ) )
3115 {
3116 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003117 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003118 }
3119
3120 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003121 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003122 nBytes );)
3123
3124 if( psessionEntry->assocReq != NULL )
3125 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303126 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003127 psessionEntry->assocReq = NULL;
3128 }
3129
3130 if( nAddIELen )
3131 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303132 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3133 pAddIE,
3134 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 nPayload += nAddIELen;
3136 }
3137
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303138 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3139 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003140 {
3141 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003142 }
3143 else
3144 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003145 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303146 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003147 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003148 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003149
3150 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003151 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3152 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003153 )
3154 {
3155 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3156 }
3157
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003158 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003159 {
3160 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3161 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003162
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303163 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3164 psessionEntry->peSessionId,
3165 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003166 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3167 HAL_TXRX_FRM_802_11_MGMT,
3168 ANI_TXDIR_TODS,
3169 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3170 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303171 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3172 psessionEntry->peSessionId,
3173 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003174 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3175 {
3176 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003177 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003178 nSirStatus );
3179 //Pkt will be freed up by the callback
3180 goto end;
3181 }
3182
3183end:
3184 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303185 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003186 psessionEntry->pLimMlmReassocReq = NULL;
3187
3188} // limSendReassocReqMgmtFrame
3189
3190/**
3191 * \brief Send an Authentication frame
3192 *
3193 *
3194 * \param pMac Pointer to Global MAC structure
3195 *
3196 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3197 * to be sent
3198 *
3199 * \param peerMacAddr MAC address of the peer entity to which Authentication
3200 * frame is destined
3201 *
3202 * \param wepBit Indicates whether wep bit to be set in FC while sending
3203 * Authentication frame3
3204 *
3205 *
3206 * This function is called by limProcessMlmMessages(). Authentication frame
3207 * is formatted and sent when this function is called.
3208 *
3209 *
3210 */
3211
3212void
3213limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3214 tpSirMacAuthFrameBody pAuthFrameBody,
3215 tSirMacAddr peerMacAddr,
3216 tANI_U8 wepBit,
3217 tpPESession psessionEntry
3218 )
3219{
3220 tANI_U8 *pFrame, *pBody;
3221 tANI_U32 frameLen = 0, bodyLen = 0;
3222 tpSirMacMgmtHdr pMacHdr;
3223 tANI_U16 i;
3224 void *pPacket;
3225 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303226 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003227
3228 if(NULL == psessionEntry)
3229 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303230 limLog(pMac, LOGE, FL("Error: psession Entry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003231 return;
3232 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05303233
3234 limLog(pMac, LOG1,
3235 FL("Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
3236 pAuthFrameBody->authTransactionSeqNumber,
3237 pAuthFrameBody->authStatusCode,
3238 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3239 MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003240 if (wepBit == LIM_WEP_IN_FC)
3241 {
3242 /// Auth frame3 to be sent with encrypted framebody
3243 /**
3244 * Allocate buffer for Authenticaton frame of size equal
3245 * to management frame header length plus 2 bytes each for
3246 * auth algorithm number, transaction number, status code,
3247 * 128 bytes for challenge text and 4 bytes each for
3248 * IV & ICV.
3249 */
3250
3251 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3252
3253 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3254 } // if (wepBit == LIM_WEP_IN_FC)
3255 else
3256 {
3257 switch (pAuthFrameBody->authTransactionSeqNumber)
3258 {
3259 case SIR_MAC_AUTH_FRAME_1:
3260 /**
3261 * Allocate buffer for Authenticaton frame of size
3262 * equal to management frame header length plus 2 bytes
3263 * each for auth algorithm number, transaction number
3264 * and status code.
3265 */
3266
3267 frameLen = sizeof(tSirMacMgmtHdr) +
3268 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3269 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3270
3271#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003272 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3273 {
3274 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003275 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003276 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003277 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003278 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003279 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003280 else
3281 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303282 limLog(pMac, LOG3, FL("Auth frame, Does not contain "
3283 "FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003284 frameLen += (2+SIR_MDIE_SIZE);
3285 }
3286 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003287#endif
3288 break;
3289
3290 case SIR_MAC_AUTH_FRAME_2:
3291 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3292 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3293 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3294 {
3295 /**
3296 * Allocate buffer for Authenticaton frame of size
3297 * equal to management frame header length plus
3298 * 2 bytes each for auth algorithm number,
3299 * transaction number and status code.
3300 */
3301
3302 frameLen = sizeof(tSirMacMgmtHdr) +
3303 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3304 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3305 }
3306 else
3307 {
3308 // Shared Key algorithm with challenge text
3309 // to be sent
3310 /**
3311 * Allocate buffer for Authenticaton frame of size
3312 * equal to management frame header length plus
3313 * 2 bytes each for auth algorithm number,
3314 * transaction number, status code and 128 bytes
3315 * for challenge text.
3316 */
3317
3318 frameLen = sizeof(tSirMacMgmtHdr) +
3319 sizeof(tSirMacAuthFrame);
3320 bodyLen = sizeof(tSirMacAuthFrameBody);
3321 }
3322
3323 break;
3324
3325 case SIR_MAC_AUTH_FRAME_3:
3326 /// Auth frame3 to be sent without encrypted framebody
3327 /**
3328 * Allocate buffer for Authenticaton frame of size equal
3329 * to management frame header length plus 2 bytes each
3330 * for auth algorithm number, transaction number and
3331 * status code.
3332 */
3333
3334 frameLen = sizeof(tSirMacMgmtHdr) +
3335 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3336 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3337
3338 break;
3339
3340 case SIR_MAC_AUTH_FRAME_4:
3341 /**
3342 * Allocate buffer for Authenticaton frame of size equal
3343 * to management frame header length plus 2 bytes each
3344 * for auth algorithm number, transaction number and
3345 * status code.
3346 */
3347
3348 frameLen = sizeof(tSirMacMgmtHdr) +
3349 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3350 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3351
3352 break;
3353 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3354 } // end if (wepBit == LIM_WEP_IN_FC)
3355
3356
3357 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3358
3359 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3360 {
3361 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003362 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003363
3364 return;
3365 }
3366
3367 for (i = 0; i < frameLen; i++)
3368 pFrame[i] = 0;
3369
3370 // Prepare BD
3371 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3372 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3373 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303374 limLog(pMac, LOGE, FL("call to limPopulateMacHeader failed for "
3375 "AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003376 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3377 return;
3378 }
3379
3380 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3381 pMacHdr->fc.wep = wepBit;
3382
3383 // Prepare BSSId
3384 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3385 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303386 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3387 (tANI_U8 *) psessionEntry->bssId,
3388 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003389 }
3390
3391 /// Prepare Authentication frame body
3392 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3393
3394 if (wepBit == LIM_WEP_IN_FC)
3395 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303396 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003397
3398 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303399 FL("*** Sending Auth seq# 3 status %d (%d) to"MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003400 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303401 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3402 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003403
Jeff Johnson295189b2012-06-20 16:38:30 -07003404 }
3405 else
3406 {
3407 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3408 pBody += sizeof(tANI_U16);
3409 bodyLen -= sizeof(tANI_U16);
3410
3411 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3412 pBody += sizeof(tANI_U16);
3413 bodyLen -= sizeof(tANI_U16);
3414
3415 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3416 pBody += sizeof(tANI_U16);
3417 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003418 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3419 sizeof (pAuthFrameBody->length) +
3420 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303421 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003422
3423#if defined WLAN_FEATURE_VOWIFI_11R
3424 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3425 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3426 {
3427
3428 {
3429 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003430 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3431 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003432#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowdad63eb492014-02-06 12:21:47 -08003433 PELOG2(limLog(pMac, LOG2, FL("Auth1 Frame FTIE is: "));
3434 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
Jeff Johnson295189b2012-06-20 16:38:30 -07003435 (tANI_U8 *)pBody,
3436 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003437#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003438 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3439 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003440 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3441 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003442 }
3443 }
3444 else
3445 {
3446 /* MDID attr is 54*/
3447 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003448 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003449 *pBody = SIR_MDIE_SIZE;
3450 pBody++;
3451 for(i=0;i<SIR_MDIE_SIZE;i++)
3452 {
3453 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3454 pBody++;
3455 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003456 }
3457 }
3458 }
3459#endif
3460
3461 PELOG1(limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303462 FL("*** Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003463 pAuthFrameBody->authTransactionSeqNumber,
3464 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303465 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3466 MAC_ADDR_ARRAY(pMacHdr->da));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003467 }
3468 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3469
3470 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003471 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3472 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07003473#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303474 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003475 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3476#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003477 )
3478 {
3479 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3480 }
3481
Ganesh K08bce952012-12-13 15:04:41 -08003482 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3483 {
3484 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3485 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003486
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303487 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3488 psessionEntry->peSessionId,
3489 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003490 /// Queue Authentication frame in high priority WQ
3491 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3492 HAL_TXRX_FRM_802_11_MGMT,
3493 ANI_TXDIR_TODS,
3494 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3495 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303496 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3497 psessionEntry->peSessionId,
3498 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003499 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3500 {
3501 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003502 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003503 halstatus);
3504
3505 //Pkt will be freed up by the callback
3506 }
3507
3508 return;
3509} /*** end limSendAuthMgmtFrame() ***/
3510
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003511eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3512{
3513 tANI_U16 aid;
3514 tpDphHashNode pStaDs;
3515 tLimMlmDeauthReq *pMlmDeauthReq;
3516 tLimMlmDeauthCnf mlmDeauthCnf;
3517 tpPESession psessionEntry;
3518
3519 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3520 if (pMlmDeauthReq)
3521 {
3522 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3523 {
3524 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3525 }
3526
3527 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3528 {
3529
3530 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003531 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003532 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3533 goto end;
3534 }
3535
3536 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3537 if (pStaDs == NULL)
3538 {
3539 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3540 goto end;
3541 }
3542
3543
3544 /// Receive path cleanup with dummy packet
3545 limCleanupRxPath(pMac, pStaDs,psessionEntry);
3546 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303547 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003548 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3549 }
3550 return eHAL_STATUS_SUCCESS;
3551end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303552 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003553 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3554 sizeof(tSirMacAddr));
3555 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3556 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3557 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3558
3559 // Free up buffer allocated
3560 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303561 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003562
3563 limPostSmeMessage(pMac,
3564 LIM_MLM_DEAUTH_CNF,
3565 (tANI_U32 *) &mlmDeauthCnf);
3566 return eHAL_STATUS_SUCCESS;
3567}
3568
3569eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3570{
3571 tANI_U16 aid;
3572 tpDphHashNode pStaDs;
3573 tLimMlmDisassocCnf mlmDisassocCnf;
3574 tpPESession psessionEntry;
3575 tLimMlmDisassocReq *pMlmDisassocReq;
3576
3577 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3578 if (pMlmDisassocReq)
3579 {
3580 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3581 {
3582 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3583 }
3584
3585 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3586 {
3587
3588 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003589 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003590 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3591 goto end;
3592 }
3593
3594 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3595 if (pStaDs == NULL)
3596 {
3597 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3598 goto end;
3599 }
3600
3601 /// Receive path cleanup with dummy packet
3602 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3603 {
3604 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3605 goto end;
3606 }
3607
3608#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003609 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303610 (
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003611#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303612 (psessionEntry->isCCXconnection ) ||
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003613#endif
3614#ifdef FEATURE_WLAN_LFR
3615 (psessionEntry->isFastRoamIniFeatureEnabled ) ||
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003616#endif
3617 (psessionEntry->is11Rconnection )) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303618 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003619 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003620 {
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303621 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003622 FL("FT Preauth Session (%p,%d) Cleanup"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003623 psessionEntry, psessionEntry->peSessionId););
3624 limFTCleanup(pMac);
3625 }
3626 else
3627 {
3628 PELOGE(limLog(pMac, LOGE,
3629 FL("No FT Preauth Session Cleanup in role %d"
3630#ifdef FEATURE_WLAN_CCX
3631 " isCCX %d"
3632#endif
3633#ifdef FEATURE_WLAN_LFR
3634 " isLFR %d"
3635#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003636 " is11r %d reason %d"),
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003637 psessionEntry->limSystemRole,
3638#ifdef FEATURE_WLAN_CCX
3639 psessionEntry->isCCXconnection,
3640#endif
3641#ifdef FEATURE_WLAN_LFR
3642 psessionEntry->isFastRoamIniFeatureEnabled,
3643#endif
3644 psessionEntry->is11Rconnection,
3645 pMlmDisassocReq->reasonCode););
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003646 }
3647#endif
3648
3649 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303650 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003651 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3652 return eHAL_STATUS_SUCCESS;
3653 }
3654 else
3655 {
3656 return eHAL_STATUS_SUCCESS;
3657 }
3658end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303659 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003660 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3661 sizeof(tSirMacAddr));
3662 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3663 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3664
3665 /* Update PE session ID*/
3666 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3667
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003668 if(pMlmDisassocReq != NULL)
3669 {
3670 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303671 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003672 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3673 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003674
3675 limPostSmeMessage(pMac,
3676 LIM_MLM_DISASSOC_CNF,
3677 (tANI_U32 *) &mlmDisassocCnf);
3678 return eHAL_STATUS_SUCCESS;
3679}
3680
3681eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3682{
3683 return limSendDisassocCnf(pMac);
3684}
3685
3686eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3687{
3688 return limSendDeauthCnf(pMac);
3689}
3690
Jeff Johnson295189b2012-06-20 16:38:30 -07003691/**
3692 * \brief This function is called to send Disassociate frame.
3693 *
3694 *
3695 * \param pMac Pointer to Global MAC structure
3696 *
3697 * \param nReason Indicates the reason that need to be sent in
3698 * Disassociation frame
3699 *
3700 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
3701 * sent
3702 *
3703 *
3704 */
3705
3706void
3707limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
3708 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003709 tSirMacAddr peer,
3710 tpPESession psessionEntry,
3711 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003712{
3713 tDot11fDisassociation frm;
3714 tANI_U8 *pFrame;
3715 tSirRetStatus nSirStatus;
3716 tpSirMacMgmtHdr pMacHdr;
3717 tANI_U32 nBytes, nPayload, nStatus;
3718 void *pPacket;
3719 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303720 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003721 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003722 if(NULL == psessionEntry)
3723 {
3724 return;
3725 }
3726
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303727 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003728
3729 frm.Reason.code = nReason;
3730
3731 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
3732 if ( DOT11F_FAILED( nStatus ) )
3733 {
3734 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003735 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003736 nStatus );
3737 // We'll fall back on the worst case scenario:
3738 nPayload = sizeof( tDot11fDisassociation );
3739 }
3740 else if ( DOT11F_WARNED( nStatus ) )
3741 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003742 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003743 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003744 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003745 }
3746
3747 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3748
3749 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3750 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3751 ( void** ) &pPacket );
3752 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3753 {
3754 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003755 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003756 return;
3757 }
3758
3759 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303760 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003761
3762 // Next, we fill out the buffer descriptor:
3763 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3764 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
3765 if ( eSIR_SUCCESS != nSirStatus )
3766 {
3767 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003768 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003769 nSirStatus );
3770 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3771 ( void* ) pFrame, ( void* ) pPacket );
3772 return; // just allocated...
3773 }
3774
3775 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3776
3777 // Prepare the BSSID
3778 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3779
Chet Lanctot186b5732013-03-18 10:26:30 -07003780#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003781 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003782#endif
3783
Jeff Johnson295189b2012-06-20 16:38:30 -07003784 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
3785 sizeof(tSirMacMgmtHdr),
3786 nPayload, &nPayload );
3787 if ( DOT11F_FAILED( nStatus ) )
3788 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003789 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003790 nStatus );
3791 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3792 ( void* ) pFrame, ( void* ) pPacket );
3793 return; // allocated!
3794 }
3795 else if ( DOT11F_WARNED( nStatus ) )
3796 {
3797 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003798 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003799 }
3800
Abhishek Singhcd09b562013-12-24 16:02:20 +05303801 limLog( pMac, LOG1, FL("***Sessionid %d Sending Disassociation frame with "
3802 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
3803 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
3804 MAC_ADDR_ARRAY(pMacHdr->da),
3805 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003806
3807 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003808 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3809 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003810 )
3811 {
3812 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3813 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003814
Ganesh K08bce952012-12-13 15:04:41 -08003815 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303816 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
3817 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08003818 {
3819 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3820 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003821
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303822 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
3823 {
3824 /* This frame will be sent on air by firmware,
3825 which will ensure that this frame goes out
3826 even though DEL_STA is sent immediately */
3827 /* Without this for DEL_STA command there is
3828 risk of flushing frame in BTQM queue without
3829 sending on air */
3830 txFlag |= HAL_USE_FW_IN_TX_PATH;
3831 }
3832
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003833 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003834 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303835 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3836 psessionEntry->peSessionId,
3837 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003838 // Queue Disassociation frame in high priority WQ
3839 /* get the duration from the request */
3840 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
3841 HAL_TXRX_FRM_802_11_MGMT,
3842 ANI_TXDIR_TODS,
3843 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3844 limTxComplete, pFrame, limDisassocTxCompleteCnf,
3845 txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303846 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3847 psessionEntry->peSessionId,
3848 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003849 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07003850
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003851 if (tx_timer_change(
3852 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
3853 != TX_SUCCESS)
3854 {
3855 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003856 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003857 return;
3858 }
3859 else if(TX_SUCCESS != tx_timer_activate(
3860 &pMac->lim.limTimers.gLimDisassocAckTimer))
3861 {
3862 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003863 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003864 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3865 return;
3866 }
3867 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003868 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003869 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303870 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3871 psessionEntry->peSessionId,
3872 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003873 // Queue Disassociation frame in high priority WQ
3874 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
3875 HAL_TXRX_FRM_802_11_MGMT,
3876 ANI_TXDIR_TODS,
3877 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3878 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303879 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3880 psessionEntry->peSessionId,
3881 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003882 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3883 {
3884 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003885 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003886 nSirStatus );
3887 //Pkt will be freed up by the callback
3888 return;
3889 }
3890 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003891} // End limSendDisassocMgmtFrame.
3892
3893/**
3894 * \brief This function is called to send a Deauthenticate frame
3895 *
3896 *
3897 * \param pMac Pointer to global MAC structure
3898 *
3899 * \param nReason Indicates the reason that need to be sent in the
3900 * Deauthenticate frame
3901 *
3902 * \param peeer address of the STA to which the frame is to be sent
3903 *
3904 *
3905 */
3906
3907void
3908limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
3909 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003910 tSirMacAddr peer,
3911 tpPESession psessionEntry,
3912 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003913{
3914 tDot11fDeAuth frm;
3915 tANI_U8 *pFrame;
3916 tSirRetStatus nSirStatus;
3917 tpSirMacMgmtHdr pMacHdr;
3918 tANI_U32 nBytes, nPayload, nStatus;
3919 void *pPacket;
3920 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303921 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003922 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003923#ifdef FEATURE_WLAN_TDLS
3924 tANI_U16 aid;
3925 tpDphHashNode pStaDs;
3926#endif
3927
Jeff Johnson295189b2012-06-20 16:38:30 -07003928 if(NULL == psessionEntry)
3929 {
3930 return;
3931 }
3932
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303933 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003934
3935 frm.Reason.code = nReason;
3936
3937 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
3938 if ( DOT11F_FAILED( nStatus ) )
3939 {
3940 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003941 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003942 nStatus );
3943 // We'll fall back on the worst case scenario:
3944 nPayload = sizeof( tDot11fDeAuth );
3945 }
3946 else if ( DOT11F_WARNED( nStatus ) )
3947 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003948 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003949 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003950 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003951 }
3952
3953 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
3954
3955 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3956 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3957 ( void** ) &pPacket );
3958 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3959 {
3960 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003961 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003962 return;
3963 }
3964
3965 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303966 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003967
3968 // Next, we fill out the buffer descriptor:
3969 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3970 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
3971 if ( eSIR_SUCCESS != nSirStatus )
3972 {
3973 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003974 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003975 nSirStatus );
3976 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3977 ( void* ) pFrame, ( void* ) pPacket );
3978 return; // just allocated...
3979 }
3980
3981 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3982
3983 // Prepare the BSSID
3984 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
3985
Chet Lanctot186b5732013-03-18 10:26:30 -07003986#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07003987 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07003988#endif
3989
Jeff Johnson295189b2012-06-20 16:38:30 -07003990 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
3991 sizeof(tSirMacMgmtHdr),
3992 nPayload, &nPayload );
3993 if ( DOT11F_FAILED( nStatus ) )
3994 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003995 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003996 nStatus );
3997 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3998 ( void* ) pFrame, ( void* ) pPacket );
3999 return;
4000 }
4001 else if ( DOT11F_WARNED( nStatus ) )
4002 {
4003 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004004 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004005 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05304006 limLog( pMac, LOG1, FL("***Sessionid %d Sending Deauth frame with "
4007 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4008 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4009 MAC_ADDR_ARRAY(pMacHdr->da),
4010 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004011
4012 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004013 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4014 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004015 )
4016 {
4017 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4018 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004019
Ganesh K08bce952012-12-13 15:04:41 -08004020 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304021 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
4022 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08004023 {
4024 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4025 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004026
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304027 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4028 {
4029 /* This frame will be sent on air by firmware,
4030 which will ensure that this frame goes out
4031 even though DEL_STA is sent immediately */
4032 /* Without this for DEL_STA command there is
4033 risk of flushing frame in BTQM queue without
4034 sending on air */
4035 txFlag |= HAL_USE_FW_IN_TX_PATH;
4036 }
4037
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004038#ifdef FEATURE_WLAN_TDLS
4039 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
4040#endif
4041
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004042 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004043 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304044 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4045 psessionEntry->peSessionId,
4046 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004047 // Queue Disassociation frame in high priority WQ
4048 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4049 HAL_TXRX_FRM_802_11_MGMT,
4050 ANI_TXDIR_TODS,
4051 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4052 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304053 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4054 psessionEntry->peSessionId,
4055 halstatus));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304056 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004057 {
4058 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304059 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004060 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08004061 //Pkt will be freed up by the callback limTxComplete
4062
4063 /*Call limProcessDeauthAckTimeout which will send
4064 * DeauthCnf for this frame
4065 */
4066 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004067 return;
4068 }
4069
4070 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
4071
4072 if (tx_timer_change(
4073 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
4074 != TX_SUCCESS)
4075 {
4076 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004077 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004078 return;
4079 }
4080 else if(TX_SUCCESS != tx_timer_activate(
4081 &pMac->lim.limTimers.gLimDeauthAckTimer))
4082 {
4083 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004084 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004085 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4086 return;
4087 }
4088 }
4089 else
4090 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304091 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4092 psessionEntry->peSessionId,
4093 pMacHdr->fc.subType));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004094#ifdef FEATURE_WLAN_TDLS
4095 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4096 {
4097 // Queue Disassociation frame in high priority WQ
4098 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004099 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004100 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004101 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4102 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004103 }
4104 else
4105 {
4106#endif
4107 // Queue Disassociation frame in high priority WQ
4108 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4109 HAL_TXRX_FRM_802_11_MGMT,
4110 ANI_TXDIR_TODS,
4111 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4112 limTxComplete, pFrame, txFlag );
4113#ifdef FEATURE_WLAN_TDLS
4114 }
4115#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304116 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4117 psessionEntry->peSessionId,
4118 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004119 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4120 {
4121 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004122 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004123 nSirStatus );
4124 //Pkt will be freed up by the callback
4125 return;
4126 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004127 }
4128
4129} // End limSendDeauthMgmtFrame.
4130
4131
4132#ifdef ANI_SUPPORT_11H
4133/**
4134 * \brief Send a Measurement Report Action frame
4135 *
4136 *
4137 * \param pMac Pointer to the global MAC structure
4138 *
4139 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4140 *
4141 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4142 *
4143 *
4144 */
4145
4146tSirRetStatus
4147limSendMeasReportFrame(tpAniSirGlobal pMac,
4148 tpSirMacMeasReqActionFrame pMeasReqFrame,
4149 tSirMacAddr peer)
4150{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304151 tDot11fMeasurementReport frm;
4152 tANI_U8 *pFrame;
4153 tSirRetStatus nSirStatus;
4154 tpSirMacMgmtHdr pMacHdr;
4155 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4156 void *pPacket;
4157 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004158
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304159 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004160
4161 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4162 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4163 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4164
4165 switch ( pMeasReqFrame->measReqIE.measType )
4166 {
4167 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4168 nSirStatus =
4169 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4170 &frm.MeasurementReport );
4171 break;
4172 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4173 nSirStatus =
4174 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4175 &frm.MeasurementReport );
4176 break;
4177 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4178 nSirStatus =
4179 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4180 &frm.MeasurementReport );
4181 break;
4182 default:
4183 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004184 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004185 pMeasReqFrame->measReqIE.measType );
4186 return eSIR_FAILURE;
4187 }
4188
4189 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4190
4191 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4192 if ( DOT11F_FAILED( nStatus ) )
4193 {
4194 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004195 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004196 nStatus );
4197 // We'll fall back on the worst case scenario:
4198 nPayload = sizeof( tDot11fMeasurementReport );
4199 }
4200 else if ( DOT11F_WARNED( nStatus ) )
4201 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004202 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004203 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004204 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004205 }
4206
4207 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4208
4209 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4210 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4211 {
4212 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004213 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004214 return eSIR_FAILURE;
4215 }
4216
4217 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304218 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004219
4220 // Next, we fill out the buffer descriptor:
4221 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4222 SIR_MAC_MGMT_ACTION, peer);
4223 if ( eSIR_SUCCESS != nSirStatus )
4224 {
4225 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004226 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004227 nSirStatus );
4228 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4229 return eSIR_FAILURE; // just allocated...
4230 }
4231
4232 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4233
4234 nCfg = 6;
4235 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4236 if ( eSIR_SUCCESS != nSirStatus )
4237 {
4238 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004239 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004240 nSirStatus );
4241 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4242 return eSIR_FAILURE; // just allocated...
4243 }
4244
Chet Lanctot186b5732013-03-18 10:26:30 -07004245#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004246 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004247#endif
4248
Jeff Johnson295189b2012-06-20 16:38:30 -07004249 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4250 sizeof(tSirMacMgmtHdr),
4251 nPayload, &nPayload );
4252 if ( DOT11F_FAILED( nStatus ) )
4253 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004254 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004255 nStatus );
4256 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4257 return eSIR_FAILURE; // allocated!
4258 }
4259 else if ( DOT11F_WARNED( nStatus ) )
4260 {
4261 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004262 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004263 }
4264
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304265 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4266 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4267 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004268 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4269 HAL_TXRX_FRM_802_11_MGMT,
4270 ANI_TXDIR_TODS,
4271 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4272 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304273 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4274 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4275 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004276 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4277 {
4278 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004279 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004280 nSirStatus );
4281 //Pkt will be freed up by the callback
4282 return eSIR_FAILURE; // just allocated...
4283 }
4284
4285 return eSIR_SUCCESS;
4286
4287} // End limSendMeasReportFrame.
4288
4289
4290/**
4291 * \brief Send a TPC Request Action frame
4292 *
4293 *
4294 * \param pMac Pointer to the global MAC datastructure
4295 *
4296 * \param peer MAC address to which the frame should be sent
4297 *
4298 *
4299 */
4300
4301void
4302limSendTpcRequestFrame(tpAniSirGlobal pMac,
4303 tSirMacAddr peer)
4304{
4305 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304306 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004307 tSirRetStatus nSirStatus;
4308 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304309 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4310 void *pPacket;
4311 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004312
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304313 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004314
4315 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4316 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4317 frm.DialogToken.token = 1;
4318 frm.TPCRequest.present = 1;
4319
4320 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4321 if ( DOT11F_FAILED( nStatus ) )
4322 {
4323 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004324 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004325 nStatus );
4326 // We'll fall back on the worst case scenario:
4327 nPayload = sizeof( tDot11fTPCRequest );
4328 }
4329 else if ( DOT11F_WARNED( nStatus ) )
4330 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004331 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004332 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004333 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004334 }
4335
4336 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4337
4338 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4339 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4340 {
4341 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004342 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004343 return;
4344 }
4345
4346 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304347 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004348
4349 // Next, we fill out the buffer descriptor:
4350 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4351 SIR_MAC_MGMT_ACTION, peer);
4352 if ( eSIR_SUCCESS != nSirStatus )
4353 {
4354 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004355 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004356 nSirStatus );
4357 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4358 return; // just allocated...
4359 }
4360
4361 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4362
4363 nCfg = 6;
4364 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4365 if ( eSIR_SUCCESS != nSirStatus )
4366 {
4367 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004368 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004369 nSirStatus );
4370 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4371 return; // just allocated...
4372 }
4373
Chet Lanctot186b5732013-03-18 10:26:30 -07004374#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004375 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004376#endif
4377
Jeff Johnson295189b2012-06-20 16:38:30 -07004378 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4379 sizeof(tSirMacMgmtHdr),
4380 nPayload, &nPayload );
4381 if ( DOT11F_FAILED( nStatus ) )
4382 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004383 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004384 nStatus );
4385 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4386 return; // allocated!
4387 }
4388 else if ( DOT11F_WARNED( nStatus ) )
4389 {
4390 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004391 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004392 }
4393
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304394 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4395 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4396 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004397 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4398 HAL_TXRX_FRM_802_11_MGMT,
4399 ANI_TXDIR_TODS,
4400 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4401 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304402 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4403 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4404 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004405 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4406 {
4407 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004408 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004409 nSirStatus );
4410 //Pkt will be freed up by the callback
4411 return;
4412 }
4413
4414} // End limSendTpcRequestFrame.
4415
4416
4417/**
4418 * \brief Send a TPC Report Action frame
4419 *
4420 *
4421 * \param pMac Pointer to the global MAC datastructure
4422 *
4423 * \param pTpcReqFrame Pointer to the received TPC Request
4424 *
4425 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4426 *
4427 *
4428 */
4429
4430tSirRetStatus
4431limSendTpcReportFrame(tpAniSirGlobal pMac,
4432 tpSirMacTpcReqActionFrame pTpcReqFrame,
4433 tSirMacAddr peer)
4434{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304435 tDot11fTPCReport frm;
4436 tANI_U8 *pFrame;
4437 tSirRetStatus nSirStatus;
4438 tpSirMacMgmtHdr pMacHdr;
4439 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4440 void *pPacket;
4441 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004442
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304443 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004444
4445 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4446 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4447 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4448
4449 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4450 // "misplaced this function, need to replace:
4451 // txPower = halGetRateToPwrValue(pMac, staid,
4452 // pMac->lim.gLimCurrentChannelId, 0);
4453 frm.TPCReport.tx_power = 0;
4454 frm.TPCReport.link_margin = 0;
4455 frm.TPCReport.present = 1;
4456
4457 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4458 if ( DOT11F_FAILED( nStatus ) )
4459 {
4460 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004461 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004462 nStatus );
4463 // We'll fall back on the worst case scenario:
4464 nPayload = sizeof( tDot11fTPCReport );
4465 }
4466 else if ( DOT11F_WARNED( nStatus ) )
4467 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004468 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004469 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004470 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004471 }
4472
4473 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4474
4475 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4476 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4477 {
4478 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004479 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 return eSIR_FAILURE;
4481 }
4482
4483 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304484 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004485
4486 // Next, we fill out the buffer descriptor:
4487 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4488 SIR_MAC_MGMT_ACTION, peer);
4489 if ( eSIR_SUCCESS != nSirStatus )
4490 {
4491 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004492 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004493 nSirStatus );
4494 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4495 return eSIR_FAILURE; // just allocated...
4496 }
4497
4498 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4499
4500 nCfg = 6;
4501 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4502 if ( eSIR_SUCCESS != nSirStatus )
4503 {
4504 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004505 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004506 nSirStatus );
4507 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4508 return eSIR_FAILURE; // just allocated...
4509 }
4510
Chet Lanctot186b5732013-03-18 10:26:30 -07004511#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004512 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004513#endif
4514
Jeff Johnson295189b2012-06-20 16:38:30 -07004515 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4516 sizeof(tSirMacMgmtHdr),
4517 nPayload, &nPayload );
4518 if ( DOT11F_FAILED( nStatus ) )
4519 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004520 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004521 nStatus );
4522 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4523 return eSIR_FAILURE; // allocated!
4524 }
4525 else if ( DOT11F_WARNED( nStatus ) )
4526 {
4527 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004528 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004529 }
4530
4531
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304532 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4533 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4534 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004535 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4536 HAL_TXRX_FRM_802_11_MGMT,
4537 ANI_TXDIR_TODS,
4538 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4539 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304540 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4541 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4542 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004543 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4544 {
4545 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004546 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004547 nSirStatus );
4548 //Pkt will be freed up by the callback
4549 return eSIR_FAILURE; // just allocated...
4550 }
4551
4552 return eSIR_SUCCESS;
4553
4554} // End limSendTpcReportFrame.
4555#endif //ANI_SUPPORT_11H
4556
4557
Jeff Johnson295189b2012-06-20 16:38:30 -07004558/**
4559 * \brief Send a Channel Switch Announcement
4560 *
4561 *
4562 * \param pMac Pointer to the global MAC datastructure
4563 *
4564 * \param peer MAC address to which this frame will be sent
4565 *
4566 * \param nMode
4567 *
4568 * \param nNewChannel
4569 *
4570 * \param nCount
4571 *
4572 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4573 *
4574 *
4575 */
4576
4577tSirRetStatus
4578limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4579 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004580 tANI_U8 nMode,
4581 tANI_U8 nNewChannel,
4582 tANI_U8 nCount,
4583 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004584{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304585 tDot11fChannelSwitch frm;
4586 tANI_U8 *pFrame;
4587 tSirRetStatus nSirStatus;
4588 tpSirMacMgmtHdr pMacHdr;
4589 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4590 void *pPacket;
4591 eHalStatus halstatus;
4592 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004593
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304594 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004595
4596 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4597 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4598 frm.ChanSwitchAnn.switchMode = nMode;
4599 frm.ChanSwitchAnn.newChannel = nNewChannel;
4600 frm.ChanSwitchAnn.switchCount = nCount;
4601 frm.ChanSwitchAnn.present = 1;
4602
4603 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4604 if ( DOT11F_FAILED( nStatus ) )
4605 {
4606 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004607 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004608 nStatus );
4609 // We'll fall back on the worst case scenario:
4610 nPayload = sizeof( tDot11fChannelSwitch );
4611 }
4612 else if ( DOT11F_WARNED( nStatus ) )
4613 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004614 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004615 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004616 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004617 }
4618
4619 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4620
4621 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4622 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4623 {
4624 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004625 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004626 return eSIR_FAILURE;
4627 }
4628
4629 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304630 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004631
4632 // Next, we fill out the buffer descriptor:
4633 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004634 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4635 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304636 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4637 (tANI_U8 *) psessionEntry->bssId,
4638 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004639 if ( eSIR_SUCCESS != nSirStatus )
4640 {
4641 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004642 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004643 nSirStatus );
4644 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4645 return eSIR_FAILURE; // just allocated...
4646 }
4647
Jeff Johnsone7245742012-09-05 17:12:55 -07004648#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004649 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4650
4651 nCfg = 6;
4652 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4653 if ( eSIR_SUCCESS != nSirStatus )
4654 {
4655 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004656 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004657 nSirStatus );
4658 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4659 return eSIR_FAILURE; // just allocated...
4660 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004661#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004662
4663#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004664 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004665#endif
4666
Jeff Johnson295189b2012-06-20 16:38:30 -07004667 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4668 sizeof(tSirMacMgmtHdr),
4669 nPayload, &nPayload );
4670 if ( DOT11F_FAILED( nStatus ) )
4671 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004672 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004673 nStatus );
4674 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4675 return eSIR_FAILURE; // allocated!
4676 }
4677 else if ( DOT11F_WARNED( nStatus ) )
4678 {
4679 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004680 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004681 }
4682
Jeff Johnsone7245742012-09-05 17:12:55 -07004683 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004684 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4685 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004686 )
4687 {
4688 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4689 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304690
4691 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4692 psessionEntry->peSessionId,
4693 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004694 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4695 HAL_TXRX_FRM_802_11_MGMT,
4696 ANI_TXDIR_TODS,
4697 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07004698 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304699 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4700 psessionEntry->peSessionId,
4701 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004702 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4703 {
4704 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004705 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004706 nSirStatus );
4707 //Pkt will be freed up by the callback
4708 return eSIR_FAILURE;
4709 }
4710
4711 return eSIR_SUCCESS;
4712
4713} // End limSendChannelSwitchMgmtFrame.
4714
Jeff Johnson295189b2012-06-20 16:38:30 -07004715
4716
Mohit Khanna4a70d262012-09-11 16:30:12 -07004717#ifdef WLAN_FEATURE_11AC
4718tSirRetStatus
4719limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
4720 tSirMacAddr peer,
4721 tANI_U8 nMode,
4722 tpPESession psessionEntry )
4723{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304724 tDot11fOperatingMode frm;
4725 tANI_U8 *pFrame;
4726 tSirRetStatus nSirStatus;
4727 tpSirMacMgmtHdr pMacHdr;
4728 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
4729 void *pPacket;
4730 eHalStatus halstatus;
4731 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07004732
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304733 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004734
4735 frm.Category.category = SIR_MAC_ACTION_VHT;
4736 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
4737 frm.OperatingMode.chanWidth = nMode;
4738 frm.OperatingMode.rxNSS = 0;
4739 frm.OperatingMode.rxNSSType = 0;
4740
4741 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
4742 if ( DOT11F_FAILED( nStatus ) )
4743 {
4744 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004745 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004746 nStatus );
4747 // We'll fall back on the worst case scenario:
4748 nPayload = sizeof( tDot11fOperatingMode);
4749 }
4750 else if ( DOT11F_WARNED( nStatus ) )
4751 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004752 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07004753 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004754 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004755 }
4756
4757 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4758
4759 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4760 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4761 {
4762 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004763 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004764 return eSIR_FAILURE;
4765 }
4766
4767 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304768 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004769
4770
4771 // Next, we fill out the buffer descriptor:
4772 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
4773 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4774 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4775 } else
4776 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4777 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
4778 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304779 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4780 (tANI_U8 *) psessionEntry->bssId,
4781 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07004782 if ( eSIR_SUCCESS != nSirStatus )
4783 {
4784 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004785 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004786 nSirStatus );
4787 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4788 return eSIR_FAILURE; // just allocated...
4789 }
4790 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
4791 sizeof(tSirMacMgmtHdr),
4792 nPayload, &nPayload );
4793 if ( DOT11F_FAILED( nStatus ) )
4794 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004795 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004796 nStatus );
4797 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4798 return eSIR_FAILURE; // allocated!
4799 }
4800 else if ( DOT11F_WARNED( nStatus ) )
4801 {
4802 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004803 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07004804 }
4805 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07004806 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4807 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07004808 )
4809 {
4810 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4811 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304812
4813 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4814 psessionEntry->peSessionId,
4815 pMacHdr->fc.subType));
Mohit Khanna4a70d262012-09-11 16:30:12 -07004816 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4817 HAL_TXRX_FRM_802_11_MGMT,
4818 ANI_TXDIR_TODS,
4819 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4820 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304821 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4822 psessionEntry->peSessionId,
4823 halstatus));
Mohit Khanna4a70d262012-09-11 16:30:12 -07004824 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4825 {
4826 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004827 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07004828 nSirStatus );
4829 //Pkt will be freed up by the callback
4830 return eSIR_FAILURE;
4831 }
4832
4833 return eSIR_SUCCESS;
4834}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004835
4836/**
4837 * \brief Send a VHT Channel Switch Announcement
4838 *
4839 *
4840 * \param pMac Pointer to the global MAC datastructure
4841 *
4842 * \param peer MAC address to which this frame will be sent
4843 *
4844 * \param nChanWidth
4845 *
4846 * \param nNewChannel
4847 *
4848 *
4849 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4850 *
4851 *
4852 */
4853
4854tSirRetStatus
4855limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4856 tSirMacAddr peer,
4857 tANI_U8 nChanWidth,
4858 tANI_U8 nNewChannel,
4859 tANI_U8 ncbMode,
4860 tpPESession psessionEntry )
4861{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304862 tDot11fChannelSwitch frm;
4863 tANI_U8 *pFrame;
4864 tSirRetStatus nSirStatus;
4865 tpSirMacMgmtHdr pMacHdr;
4866 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4867 void *pPacket;
4868 eHalStatus halstatus;
4869 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004870
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304871 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004872
4873
4874 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4875 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4876 frm.ChanSwitchAnn.switchMode = 1;
4877 frm.ChanSwitchAnn.newChannel = nNewChannel;
4878 frm.ChanSwitchAnn.switchCount = 1;
4879 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
4880 frm.ExtChanSwitchAnn.present = 1;
4881 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
4882 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
4883 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
4884 frm.ChanSwitchAnn.present = 1;
4885 frm.WiderBWChanSwitchAnn.present = 1;
4886
4887 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4888 if ( DOT11F_FAILED( nStatus ) )
4889 {
4890 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004891 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004892 nStatus );
4893 // We'll fall back on the worst case scenario:
4894 nPayload = sizeof( tDot11fChannelSwitch );
4895 }
4896 else if ( DOT11F_WARNED( nStatus ) )
4897 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004898 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004899 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004900 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004901 }
4902
4903 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4904
4905 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4906 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4907 {
4908 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004909 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004910 return eSIR_FAILURE;
4911 }
4912 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304913 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004914
4915 // Next, we fill out the buffer descriptor:
4916 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4917 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4918 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304919 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4920 (tANI_U8 *) psessionEntry->bssId,
4921 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004922 if ( eSIR_SUCCESS != nSirStatus )
4923 {
4924 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004925 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004926 nSirStatus );
4927 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4928 return eSIR_FAILURE; // just allocated...
4929 }
4930 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4931 sizeof(tSirMacMgmtHdr),
4932 nPayload, &nPayload );
4933 if ( DOT11F_FAILED( nStatus ) )
4934 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004935 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004936 nStatus );
4937 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4938 return eSIR_FAILURE; // allocated!
4939 }
4940 else if ( DOT11F_WARNED( nStatus ) )
4941 {
4942 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004943 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004944 }
4945
4946 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004947 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4948 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004949 )
4950 {
4951 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4952 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304953
4954 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4955 psessionEntry->peSessionId,
4956 pMacHdr->fc.subType));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004957 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4958 HAL_TXRX_FRM_802_11_MGMT,
4959 ANI_TXDIR_TODS,
4960 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4961 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304962 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4963 psessionEntry->peSessionId,
4964 halstatus));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004965 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4966 {
4967 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004968 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004969 nSirStatus );
4970 //Pkt will be freed up by the callback
4971 return eSIR_FAILURE;
4972 }
4973
4974 return eSIR_SUCCESS;
4975
4976} // End limSendVHTChannelSwitchMgmtFrame.
4977
4978
4979
Mohit Khanna4a70d262012-09-11 16:30:12 -07004980#endif
4981
Jeff Johnson295189b2012-06-20 16:38:30 -07004982/**
4983 * \brief Send an ADDBA Req Action Frame to peer
4984 *
4985 * \sa limSendAddBAReq
4986 *
4987 * \param pMac The global tpAniSirGlobal object
4988 *
4989 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
4990 * the necessary parameters reqd by PE send the ADDBA Req Action
4991 * Frame to the peer
4992 *
4993 * \return eSIR_SUCCESS if setup completes successfully
4994 * eSIR_FAILURE is some problem is encountered
4995 */
4996tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304997 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07004998{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304999 tDot11fAddBAReq frmAddBAReq;
5000 tANI_U8 *pAddBAReqBuffer = NULL;
5001 tpSirMacMgmtHdr pMacHdr;
5002 tANI_U32 frameLen = 0, nStatus, nPayload;
5003 tSirRetStatus statusCode;
5004 eHalStatus halStatus;
5005 void *pPacket;
5006 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005007
5008 if(NULL == psessionEntry)
5009 {
5010 return eSIR_FAILURE;
5011 }
5012
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305013 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005014
5015 // Category - 3 (BA)
5016 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
5017
5018 // Action - 0 (ADDBA Req)
5019 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
5020
5021 // FIXME - Dialog Token, generalize this...
5022 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
5023
5024 // Fill the ADDBA Parameter Set
5025 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
5026 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
5027 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
5028
5029 // BA timeout
5030 // 0 - indicates no BA timeout
5031 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
5032
5033 // BA Starting Sequence Number
5034 // Fragment number will always be zero
5035 if (pMlmAddBAReq->baSSN < LIM_TX_FRAMES_THRESHOLD_ON_CHIP) {
5036 pMlmAddBAReq->baSSN = LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
5037 }
5038
5039 frmAddBAReq.BAStartingSequenceControl.ssn =
5040 pMlmAddBAReq->baSSN - LIM_TX_FRAMES_THRESHOLD_ON_CHIP;
5041
5042 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
5043
5044 if( DOT11F_FAILED( nStatus ))
5045 {
5046 limLog( pMac, LOGW,
5047 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005048 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005049 nStatus );
5050
5051 // We'll fall back on the worst case scenario:
5052 nPayload = sizeof( tDot11fAddBAReq );
5053 }
5054 else if( DOT11F_WARNED( nStatus ))
5055 {
5056 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005057 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005058 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005059 nStatus );
5060 }
5061
5062 // Add the MGMT header to frame length
5063 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5064
5065 // Need to allocate a buffer for ADDBA AF
5066 if( eHAL_STATUS_SUCCESS !=
5067 (halStatus = palPktAlloc( pMac->hHdd,
5068 HAL_TXRX_FRM_802_11_MGMT,
5069 (tANI_U16) frameLen,
5070 (void **) &pAddBAReqBuffer,
5071 (void **) &pPacket )))
5072 {
5073 // Log error
5074 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005075 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005076 frameLen,
5077 halStatus );
5078
5079 statusCode = eSIR_MEM_ALLOC_FAILED;
5080 goto returnAfterError;
5081 }
5082
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305083 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005084
5085 // Copy necessary info to BD
5086 if( eSIR_SUCCESS !=
5087 (statusCode = limPopulateMacHeader( pMac,
5088 pAddBAReqBuffer,
5089 SIR_MAC_MGMT_FRAME,
5090 SIR_MAC_MGMT_ACTION,
5091 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5092 goto returnAfterError;
5093
5094 // Update A3 with the BSSID
5095 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
5096
5097 #if 0
5098 cfgLen = SIR_MAC_ADDR_LENGTH;
5099 if( eSIR_SUCCESS != cfgGetStr( pMac,
5100 WNI_CFG_BSSID,
5101 (tANI_U8 *) pMacHdr->bssId,
5102 &cfgLen ))
5103 {
5104 limLog( pMac, LOGP,
5105 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005106 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005107
5108 // FIXME - Need to convert to tSirRetStatus
5109 statusCode = eSIR_FAILURE;
5110 goto returnAfterError;
5111 }
5112 #endif//TO SUPPORT BT-AMP
5113 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5114
Chet Lanctot186b5732013-03-18 10:26:30 -07005115#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005116 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005117#endif
5118
Jeff Johnson295189b2012-06-20 16:38:30 -07005119 // Now, we're ready to "pack" the frames
5120 nStatus = dot11fPackAddBAReq( pMac,
5121 &frmAddBAReq,
5122 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5123 nPayload,
5124 &nPayload );
5125
5126 if( DOT11F_FAILED( nStatus ))
5127 {
5128 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005129 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005130 nStatus );
5131
5132 // FIXME - Need to convert to tSirRetStatus
5133 statusCode = eSIR_FAILURE;
5134 goto returnAfterError;
5135 }
5136 else if( DOT11F_WARNED( nStatus ))
5137 {
5138 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005139 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5140 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005141 }
5142
5143 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005144 FL( "Sending an ADDBA REQ to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005145 limPrintMacAddr( pMac, pMlmAddBAReq->peerMacAddr, LOGW );
5146
5147 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005148 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5149 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005150 )
5151 {
5152 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5153 }
5154
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305155 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5156 psessionEntry->peSessionId,
5157 pMacHdr->fc.subType));
5158 halStatus = halTxFrame( pMac,
5159 pPacket,
5160 (tANI_U16) frameLen,
5161 HAL_TXRX_FRM_802_11_MGMT,
5162 ANI_TXDIR_TODS,
5163 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5164 limTxComplete,
5165 pAddBAReqBuffer, txFlag );
5166 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5167 psessionEntry->peSessionId,
5168 halStatus));
5169 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005170 {
5171 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005172 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005173 halStatus );
5174
5175 // FIXME - Need to convert eHalStatus to tSirRetStatus
5176 statusCode = eSIR_FAILURE;
5177 //Pkt will be freed up by the callback
5178 return statusCode;
5179 }
5180 else
5181 return eSIR_SUCCESS;
5182
5183returnAfterError:
5184
5185 // Release buffer, if allocated
5186 if( NULL != pAddBAReqBuffer )
5187 palPktFree( pMac->hHdd,
5188 HAL_TXRX_FRM_802_11_MGMT,
5189 (void *) pAddBAReqBuffer,
5190 (void *) pPacket );
5191
5192 return statusCode;
5193}
5194
5195/**
5196 * \brief Send an ADDBA Rsp Action Frame to peer
5197 *
5198 * \sa limSendAddBARsp
5199 *
5200 * \param pMac The global tpAniSirGlobal object
5201 *
5202 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5203 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5204 * Frame to the peer
5205 *
5206 * \return eSIR_SUCCESS if setup completes successfully
5207 * eSIR_FAILURE is some problem is encountered
5208 */
5209tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5210 tpLimMlmAddBARsp pMlmAddBARsp,
5211 tpPESession psessionEntry)
5212{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305213 tDot11fAddBARsp frmAddBARsp;
5214 tANI_U8 *pAddBARspBuffer = NULL;
5215 tpSirMacMgmtHdr pMacHdr;
5216 tANI_U32 frameLen = 0, nStatus, nPayload;
5217 tSirRetStatus statusCode;
5218 eHalStatus halStatus;
5219 void *pPacket;
5220 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005221
5222 if(NULL == psessionEntry)
5223 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005224 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005225 return eSIR_FAILURE;
5226 }
5227
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305228 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005229
5230 // Category - 3 (BA)
5231 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5232 // Action - 1 (ADDBA Rsp)
5233 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5234
5235 // Should be same as the one we received in the ADDBA Req
5236 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5237
5238 // ADDBA Req status
5239 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5240
5241 // Fill the ADDBA Parameter Set as provided by caller
5242 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5243 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5244 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005245
5246 if(psessionEntry->isAmsduSupportInAMPDU)
5247 {
5248 frmAddBARsp.AddBAParameterSet.amsduSupported =
5249 psessionEntry->amsduSupportedInBA;
5250 }
5251 else
5252 {
5253 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5254 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005255
5256 // BA timeout
5257 // 0 - indicates no BA timeout
5258 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5259
5260 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5261
5262 if( DOT11F_FAILED( nStatus ))
5263 {
5264 limLog( pMac, LOGW,
5265 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005266 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005267 nStatus );
5268
5269 // We'll fall back on the worst case scenario:
5270 nPayload = sizeof( tDot11fAddBARsp );
5271 }
5272 else if( DOT11F_WARNED( nStatus ))
5273 {
5274 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005275 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005276 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005277 nStatus );
5278 }
5279
5280 // Need to allocate a buffer for ADDBA AF
5281 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5282
5283 // Allocate shared memory
5284 if( eHAL_STATUS_SUCCESS !=
5285 (halStatus = palPktAlloc( pMac->hHdd,
5286 HAL_TXRX_FRM_802_11_MGMT,
5287 (tANI_U16) frameLen,
5288 (void **) &pAddBARspBuffer,
5289 (void **) &pPacket )))
5290 {
5291 // Log error
5292 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005293 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005294 frameLen,
5295 halStatus );
5296
5297 statusCode = eSIR_MEM_ALLOC_FAILED;
5298 goto returnAfterError;
5299 }
5300
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305301 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005302
5303 // Copy necessary info to BD
5304 if( eSIR_SUCCESS !=
5305 (statusCode = limPopulateMacHeader( pMac,
5306 pAddBARspBuffer,
5307 SIR_MAC_MGMT_FRAME,
5308 SIR_MAC_MGMT_ACTION,
5309 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5310 goto returnAfterError;
5311
5312 // Update A3 with the BSSID
5313
5314 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5315
5316 #if 0
5317 cfgLen = SIR_MAC_ADDR_LENGTH;
5318 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5319 WNI_CFG_BSSID,
5320 (tANI_U8 *) pMacHdr->bssId,
5321 &cfgLen ))
5322 {
5323 limLog( pMac, LOGP,
5324 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005325 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005326
5327 // FIXME - Need to convert to tSirRetStatus
5328 statusCode = eSIR_FAILURE;
5329 goto returnAfterError;
5330 }
5331 #endif // TO SUPPORT BT-AMP
5332 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5333
Chet Lanctot186b5732013-03-18 10:26:30 -07005334#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005335 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005336#endif
5337
Jeff Johnson295189b2012-06-20 16:38:30 -07005338 // Now, we're ready to "pack" the frames
5339 nStatus = dot11fPackAddBARsp( pMac,
5340 &frmAddBARsp,
5341 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5342 nPayload,
5343 &nPayload );
5344
5345 if( DOT11F_FAILED( nStatus ))
5346 {
5347 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005348 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005349 nStatus );
5350
5351 // FIXME - Need to convert to tSirRetStatus
5352 statusCode = eSIR_FAILURE;
5353 goto returnAfterError;
5354 }
5355 else if( DOT11F_WARNED( nStatus ))
5356 {
5357 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005358 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5359 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005360 }
5361
5362 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005363 FL( "Sending an ADDBA RSP to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005364 limPrintMacAddr( pMac, pMlmAddBARsp->peerMacAddr, LOGW );
5365
5366 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005367 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5368 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005369 )
5370 {
5371 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5372 }
5373
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305374 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5375 psessionEntry->peSessionId,
5376 pMacHdr->fc.subType));
5377 halStatus = halTxFrame( pMac,
5378 pPacket,
5379 (tANI_U16) frameLen,
5380 HAL_TXRX_FRM_802_11_MGMT,
5381 ANI_TXDIR_TODS,
5382 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5383 limTxComplete,
5384 pAddBARspBuffer, txFlag );
5385 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5386 psessionEntry->peSessionId,
5387 halStatus));
5388 if( eHAL_STATUS_SUCCESS != halStatus )
5389 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005390 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005391 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005392 halStatus );
5393
5394 // FIXME - HAL error codes are different from PE error
5395 // codes!! And, this routine is returning tSirRetStatus
5396 statusCode = eSIR_FAILURE;
5397 //Pkt will be freed up by the callback
5398 return statusCode;
5399 }
5400 else
5401 return eSIR_SUCCESS;
5402
5403 returnAfterError:
Jeff Johnson295189b2012-06-20 16:38:30 -07005404 // Release buffer, if allocated
5405 if( NULL != pAddBARspBuffer )
5406 palPktFree( pMac->hHdd,
5407 HAL_TXRX_FRM_802_11_MGMT,
5408 (void *) pAddBARspBuffer,
5409 (void *) pPacket );
5410
5411 return statusCode;
5412}
5413
5414/**
5415 * \brief Send a DELBA Indication Action Frame to peer
5416 *
5417 * \sa limSendDelBAInd
5418 *
5419 * \param pMac The global tpAniSirGlobal object
5420 *
5421 * \param peerMacAddr MAC Address of peer
5422 *
5423 * \param reasonCode Reason for the DELBA notification
5424 *
5425 * \param pBAParameterSet The DELBA Parameter Set.
5426 * This identifies the TID for which the BA session is
5427 * being deleted.
5428 *
5429 * \return eSIR_SUCCESS if setup completes successfully
5430 * eSIR_FAILURE is some problem is encountered
5431 */
5432tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5433 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5434{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305435 tDot11fDelBAInd frmDelBAInd;
5436 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005437 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305438 tpSirMacMgmtHdr pMacHdr;
5439 tANI_U32 frameLen = 0, nStatus, nPayload;
5440 tSirRetStatus statusCode;
5441 eHalStatus halStatus;
5442 void *pPacket;
5443 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005444
5445 if(NULL == psessionEntry)
5446 {
5447 return eSIR_FAILURE;
5448 }
5449
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305450 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005451
5452 // Category - 3 (BA)
5453 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5454 // Action - 2 (DELBA)
5455 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5456
5457 // Fill the DELBA Parameter Set as provided by caller
5458 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5459 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5460
5461 // BA Starting Sequence Number
5462 // Fragment number will always be zero
5463 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5464
5465 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5466
5467 if( DOT11F_FAILED( nStatus ))
5468 {
5469 limLog( pMac, LOGW,
5470 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005471 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005472 nStatus );
5473
5474 // We'll fall back on the worst case scenario:
5475 nPayload = sizeof( tDot11fDelBAInd );
5476 }
5477 else if( DOT11F_WARNED( nStatus ))
5478 {
5479 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005480 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005481 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005482 nStatus );
5483 }
5484
5485 // Add the MGMT header to frame length
5486 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5487
5488 // Allocate shared memory
5489 if( eHAL_STATUS_SUCCESS !=
5490 (halStatus = palPktAlloc( pMac->hHdd,
5491 HAL_TXRX_FRM_802_11_MGMT,
5492 (tANI_U16) frameLen,
5493 (void **) &pDelBAIndBuffer,
5494 (void **) &pPacket )))
5495 {
5496 // Log error
5497 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005498 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005499 frameLen,
5500 halStatus );
5501
5502 statusCode = eSIR_MEM_ALLOC_FAILED;
5503 goto returnAfterError;
5504 }
5505
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305506 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005507
5508 // Copy necessary info to BD
5509 if( eSIR_SUCCESS !=
5510 (statusCode = limPopulateMacHeader( pMac,
5511 pDelBAIndBuffer,
5512 SIR_MAC_MGMT_FRAME,
5513 SIR_MAC_MGMT_ACTION,
5514 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5515 goto returnAfterError;
5516
5517 // Update A3 with the BSSID
5518 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5519
5520 #if 0
5521 cfgLen = SIR_MAC_ADDR_LENGTH;
5522 if( eSIR_SUCCESS != cfgGetStr( pMac,
5523 WNI_CFG_BSSID,
5524 (tANI_U8 *) pMacHdr->bssId,
5525 &cfgLen ))
5526 {
5527 limLog( pMac, LOGP,
5528 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005529 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005530
5531 // FIXME - Need to convert to tSirRetStatus
5532 statusCode = eSIR_FAILURE;
5533 goto returnAfterError;
5534 }
5535 #endif //TO SUPPORT BT-AMP
5536 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5537
Chet Lanctot186b5732013-03-18 10:26:30 -07005538#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005539 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005540#endif
5541
Jeff Johnson295189b2012-06-20 16:38:30 -07005542 // Now, we're ready to "pack" the frames
5543 nStatus = dot11fPackDelBAInd( pMac,
5544 &frmDelBAInd,
5545 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5546 nPayload,
5547 &nPayload );
5548
5549 if( DOT11F_FAILED( nStatus ))
5550 {
5551 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005552 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005553 nStatus );
5554
5555 // FIXME - Need to convert to tSirRetStatus
5556 statusCode = eSIR_FAILURE;
5557 goto returnAfterError;
5558 }
5559 else if( DOT11F_WARNED( nStatus ))
5560 {
5561 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005562 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
5563 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005564 }
5565
5566 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005567 FL( "Sending a DELBA IND to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005568 limPrintMacAddr( pMac, pMlmDelBAReq->peerMacAddr, LOGW );
5569
5570 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005571 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5572 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005573 )
5574 {
5575 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5576 }
5577
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305578 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5579 psessionEntry->peSessionId,
5580 pMacHdr->fc.subType));
5581 halStatus = halTxFrame( pMac,
5582 pPacket,
5583 (tANI_U16) frameLen,
5584 HAL_TXRX_FRM_802_11_MGMT,
5585 ANI_TXDIR_TODS,
5586 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5587 limTxComplete,
5588 pDelBAIndBuffer, txFlag );
5589 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5590 psessionEntry->peSessionId,
5591 halStatus));
5592 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005593 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005594 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005595 statusCode = eSIR_FAILURE;
5596 //Pkt will be freed up by the callback
5597 return statusCode;
5598 }
5599 else
5600 return eSIR_SUCCESS;
5601
5602 returnAfterError:
5603
5604 // Release buffer, if allocated
5605 if( NULL != pDelBAIndBuffer )
5606 palPktFree( pMac->hHdd,
5607 HAL_TXRX_FRM_802_11_MGMT,
5608 (void *) pDelBAIndBuffer,
5609 (void *) pPacket );
5610
5611 return statusCode;
5612}
5613
5614#if defined WLAN_FEATURE_VOWIFI
5615
5616/**
5617 * \brief Send a Neighbor Report Request Action frame
5618 *
5619 *
5620 * \param pMac Pointer to the global MAC structure
5621 *
5622 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5623 *
5624 * \param peer mac address of peer station.
5625 *
5626 * \param psessionEntry address of session entry.
5627 *
5628 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5629 *
5630 *
5631 */
5632
5633tSirRetStatus
5634limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5635 tpSirMacNeighborReportReq pNeighborReq,
5636 tSirMacAddr peer,
5637 tpPESession psessionEntry
5638 )
5639{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305640 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005641 tDot11fNeighborReportRequest frm;
5642 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305643 tpSirMacMgmtHdr pMacHdr;
5644 tANI_U32 nBytes, nPayload, nStatus;
5645 void *pPacket;
5646 eHalStatus halstatus;
5647 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005648
5649 if ( psessionEntry == NULL )
5650 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005651 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005652 return eSIR_FAILURE;
5653 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305654 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005655
5656 frm.Category.category = SIR_MAC_ACTION_RRM;
5657 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5658 frm.DialogToken.token = pNeighborReq->dialogToken;
5659
5660
5661 if( pNeighborReq->ssid_present )
5662 {
5663 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5664 }
5665
5666 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5667 if ( DOT11F_FAILED( nStatus ) )
5668 {
5669 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005670 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005671 nStatus );
5672 // We'll fall back on the worst case scenario:
5673 nPayload = sizeof( tDot11fNeighborReportRequest );
5674 }
5675 else if ( DOT11F_WARNED( nStatus ) )
5676 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005677 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005678 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005679 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005680 }
5681
5682 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5683
5684 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5685 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5686 {
5687 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005688 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005689 return eSIR_FAILURE;
5690 }
5691
5692 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305693 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005694
5695 // Copy necessary info to BD
5696 if( eSIR_SUCCESS !=
5697 (statusCode = limPopulateMacHeader( pMac,
5698 pFrame,
5699 SIR_MAC_MGMT_FRAME,
5700 SIR_MAC_MGMT_ACTION,
5701 peer, psessionEntry->selfMacAddr)))
5702 goto returnAfterError;
5703
5704 // Update A3 with the BSSID
5705 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5706
5707 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5708
Chet Lanctot186b5732013-03-18 10:26:30 -07005709#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005710 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005711#endif
5712
Jeff Johnson295189b2012-06-20 16:38:30 -07005713 // Now, we're ready to "pack" the frames
5714 nStatus = dot11fPackNeighborReportRequest( pMac,
5715 &frm,
5716 pFrame + sizeof( tSirMacMgmtHdr ),
5717 nPayload,
5718 &nPayload );
5719
5720 if( DOT11F_FAILED( nStatus ))
5721 {
5722 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005723 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005724 nStatus );
5725
5726 // FIXME - Need to convert to tSirRetStatus
5727 statusCode = eSIR_FAILURE;
5728 goto returnAfterError;
5729 }
5730 else if( DOT11F_WARNED( nStatus ))
5731 {
5732 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005733 FL( "There were warnings while packing Neighbor Report "
5734 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005735 }
5736
5737 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005738 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005739 limPrintMacAddr( pMac, peer, LOGW );
5740
5741 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005742 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5743 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005744 )
5745 {
5746 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5747 }
5748
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305749 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5750 psessionEntry->peSessionId,
5751 pMacHdr->fc.subType));
5752 halstatus = halTxFrame( pMac,
5753 pPacket,
5754 (tANI_U16) nBytes,
5755 HAL_TXRX_FRM_802_11_MGMT,
5756 ANI_TXDIR_TODS,
5757 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5758 limTxComplete,
5759 pFrame, txFlag );
5760 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5761 psessionEntry->peSessionId,
5762 halstatus));
5763 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005764 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005765 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005766 statusCode = eSIR_FAILURE;
5767 //Pkt will be freed up by the callback
5768 return statusCode;
5769 }
5770 else
5771 return eSIR_SUCCESS;
5772
5773returnAfterError:
5774 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5775
5776 return statusCode;
5777} // End limSendNeighborReportRequestFrame.
5778
5779/**
5780 * \brief Send a Link Report Action frame
5781 *
5782 *
5783 * \param pMac Pointer to the global MAC structure
5784 *
5785 * \param pLinkReport Address of a tSirMacLinkReport
5786 *
5787 * \param peer mac address of peer station.
5788 *
5789 * \param psessionEntry address of session entry.
5790 *
5791 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5792 *
5793 *
5794 */
5795
5796tSirRetStatus
5797limSendLinkReportActionFrame(tpAniSirGlobal pMac,
5798 tpSirMacLinkReport pLinkReport,
5799 tSirMacAddr peer,
5800 tpPESession psessionEntry
5801 )
5802{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305803 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005804 tDot11fLinkMeasurementReport frm;
5805 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305806 tpSirMacMgmtHdr pMacHdr;
5807 tANI_U32 nBytes, nPayload, nStatus;
5808 void *pPacket;
5809 eHalStatus halstatus;
5810 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005811
5812
5813 if ( psessionEntry == NULL )
5814 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005815 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005816 return eSIR_FAILURE;
5817 }
5818
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305819 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005820
5821 frm.Category.category = SIR_MAC_ACTION_RRM;
5822 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
5823 frm.DialogToken.token = pLinkReport->dialogToken;
5824
5825
5826 //IEEE Std. 802.11 7.3.2.18. for the report element.
5827 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
5828 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
5829 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
5830 //such case this way than changing the frame parser.
5831 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
5832 frm.TPCEleLen.TPCLen = 2;
5833 frm.TxPower.txPower = pLinkReport->txPower;
5834 frm.LinkMargin.linkMargin = 0;
5835
5836 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
5837 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
5838 frm.RCPI.rcpi = pLinkReport->rcpi;
5839 frm.RSNI.rsni = pLinkReport->rsni;
5840
5841 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
5842 if ( DOT11F_FAILED( nStatus ) )
5843 {
5844 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005845 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005846 nStatus );
5847 // We'll fall back on the worst case scenario:
5848 nPayload = sizeof( tDot11fLinkMeasurementReport );
5849 }
5850 else if ( DOT11F_WARNED( nStatus ) )
5851 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005852 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005853 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005854 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005855 }
5856
5857 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5858
5859 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5860 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5861 {
5862 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005863 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005864 return eSIR_FAILURE;
5865 }
5866
5867 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305868 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005869
5870 // Copy necessary info to BD
5871 if( eSIR_SUCCESS !=
5872 (statusCode = limPopulateMacHeader( pMac,
5873 pFrame,
5874 SIR_MAC_MGMT_FRAME,
5875 SIR_MAC_MGMT_ACTION,
5876 peer, psessionEntry->selfMacAddr)))
5877 goto returnAfterError;
5878
5879 // Update A3 with the BSSID
5880 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5881
5882 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
5883
Chet Lanctot186b5732013-03-18 10:26:30 -07005884#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005885 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005886#endif
5887
Jeff Johnson295189b2012-06-20 16:38:30 -07005888 // Now, we're ready to "pack" the frames
5889 nStatus = dot11fPackLinkMeasurementReport( pMac,
5890 &frm,
5891 pFrame + sizeof( tSirMacMgmtHdr ),
5892 nPayload,
5893 &nPayload );
5894
5895 if( DOT11F_FAILED( nStatus ))
5896 {
5897 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005898 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005899 nStatus );
5900
5901 // FIXME - Need to convert to tSirRetStatus
5902 statusCode = eSIR_FAILURE;
5903 goto returnAfterError;
5904 }
5905 else if( DOT11F_WARNED( nStatus ))
5906 {
5907 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005908 FL( "There were warnings while packing Link Report (0x%08x)." ),
5909 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005910 }
5911
5912 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005913 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005914 limPrintMacAddr( pMac, peer, LOGW );
5915
5916 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005917 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5918 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005919 )
5920 {
5921 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5922 }
5923
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305924 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5925 psessionEntry->peSessionId,
5926 pMacHdr->fc.subType));
5927 halstatus = halTxFrame( pMac,
5928 pPacket,
5929 (tANI_U16) nBytes,
5930 HAL_TXRX_FRM_802_11_MGMT,
5931 ANI_TXDIR_TODS,
5932 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5933 limTxComplete,
5934 pFrame, txFlag );
5935 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5936 psessionEntry->peSessionId,
5937 halstatus));
5938 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005939 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005940 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005941 statusCode = eSIR_FAILURE;
5942 //Pkt will be freed up by the callback
5943 return statusCode;
5944 }
5945 else
5946 return eSIR_SUCCESS;
5947
5948returnAfterError:
5949 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5950
5951 return statusCode;
5952} // End limSendLinkReportActionFrame.
5953
5954/**
5955 * \brief Send a Beacon Report Action frame
5956 *
5957 *
5958 * \param pMac Pointer to the global MAC structure
5959 *
5960 * \param dialog_token dialog token to be used in the action frame.
5961 *
5962 * \param num_report number of reports in pRRMReport.
5963 *
5964 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
5965 *
5966 * \param peer mac address of peer station.
5967 *
5968 * \param psessionEntry address of session entry.
5969 *
5970 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5971 *
5972 *
5973 */
5974
5975tSirRetStatus
5976limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
5977 tANI_U8 dialog_token,
5978 tANI_U8 num_report,
5979 tpSirMacRadioMeasureReport pRRMReport,
5980 tSirMacAddr peer,
5981 tpPESession psessionEntry
5982 )
5983{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305984 tSirRetStatus statusCode = eSIR_SUCCESS;
5985 tANI_U8 *pFrame;
5986 tpSirMacMgmtHdr pMacHdr;
5987 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07005988 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305989 eHalStatus halstatus;
5990 tANI_U8 i;
5991 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005992
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005993 tDot11fRadioMeasurementReport *frm =
5994 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
5995 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005996 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07005997 return eSIR_FAILURE;
5998 }
5999
Jeff Johnson295189b2012-06-20 16:38:30 -07006000 if ( psessionEntry == NULL )
6001 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006002 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006003 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006004 return eSIR_FAILURE;
6005 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306006 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006007
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006008 frm->Category.category = SIR_MAC_ACTION_RRM;
6009 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
6010 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07006011
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006012 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 -07006013
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006014 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006015 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006016 frm->MeasurementReport[i].type = pRRMReport[i].type;
6017 frm->MeasurementReport[i].token = pRRMReport[i].token;
6018 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006019 switch( pRRMReport[i].type )
6020 {
6021 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006022 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
6023 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6024 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
6025 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006026 break;
6027 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05306028 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6029 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006030 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006031 break;
6032 }
6033 }
6034
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006035 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07006036 if ( DOT11F_FAILED( nStatus ) )
6037 {
6038 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006039 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006040 nStatus );
6041 // We'll fall back on the worst case scenario:
6042 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006043 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006044 return eSIR_FAILURE;
6045 }
6046 else if ( DOT11F_WARNED( nStatus ) )
6047 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006048 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006049 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006050 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006051 }
6052
6053 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6054
6055 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6056 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6057 {
6058 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006059 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006060 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006061 return eSIR_FAILURE;
6062 }
6063
6064 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306065 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006066
6067 // Copy necessary info to BD
6068 if( eSIR_SUCCESS !=
6069 (statusCode = limPopulateMacHeader( pMac,
6070 pFrame,
6071 SIR_MAC_MGMT_FRAME,
6072 SIR_MAC_MGMT_ACTION,
6073 peer, psessionEntry->selfMacAddr)))
6074 goto returnAfterError;
6075
6076 // Update A3 with the BSSID
6077 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6078
6079 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6080
Chet Lanctot186b5732013-03-18 10:26:30 -07006081#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006082 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006083#endif
6084
Jeff Johnson295189b2012-06-20 16:38:30 -07006085 // Now, we're ready to "pack" the frames
6086 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006087 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07006088 pFrame + sizeof( tSirMacMgmtHdr ),
6089 nPayload,
6090 &nPayload );
6091
6092 if( DOT11F_FAILED( nStatus ))
6093 {
6094 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006095 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006096 nStatus );
6097
6098 // FIXME - Need to convert to tSirRetStatus
6099 statusCode = eSIR_FAILURE;
6100 goto returnAfterError;
6101 }
6102 else if( DOT11F_WARNED( nStatus ))
6103 {
6104 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006105 FL( "There were warnings while packing Radio "
6106 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006107 }
6108
6109 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006110 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006111 limPrintMacAddr( pMac, peer, LOGW );
6112
6113 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006114 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6115 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006116 )
6117 {
6118 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6119 }
6120
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306121 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6122 psessionEntry->peSessionId,
6123 pMacHdr->fc.subType));
6124 halstatus = halTxFrame( pMac,
6125 pPacket,
6126 (tANI_U16) nBytes,
6127 HAL_TXRX_FRM_802_11_MGMT,
6128 ANI_TXDIR_TODS,
6129 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6130 limTxComplete,
6131 pFrame, txFlag );
6132 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6133 psessionEntry->peSessionId,
6134 halstatus));
6135 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006136 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006137 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006138 statusCode = eSIR_FAILURE;
6139 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006140 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006141 return statusCode;
6142 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006143 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006144 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006145 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006146 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006147
6148returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006149 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006150 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07006151 return statusCode;
6152} // End limSendBeaconReportActionFrame.
6153
6154#endif
6155
6156#ifdef WLAN_FEATURE_11W
6157/**
6158 * \brief Send SA query response action frame to peer
6159 *
6160 * \sa limSendSaQueryResponseFrame
6161 *
6162 *
6163 * \param pMac The global tpAniSirGlobal object
6164 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006165 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006166 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006167 * \param peer The Mac address of the AP to which this action frame is addressed
6168 *
6169 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07006170 *
6171 * \return eSIR_SUCCESS if setup completes successfully
6172 * eSIR_FAILURE is some problem is encountered
6173 */
6174
Chet Lanctot186b5732013-03-18 10:26:30 -07006175tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006176tSirMacAddr peer,tpPESession psessionEntry)
6177{
6178
Chet Lanctot186b5732013-03-18 10:26:30 -07006179 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006180 tANI_U8 *pFrame;
6181 tSirRetStatus nSirStatus;
6182 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07006183 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006184 void *pPacket;
6185 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306186 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006187
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306188 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07006189 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6190 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07006191 action: 0 --> SA query request action frame
6192 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07006193 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
6194 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07006195 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07006196 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006197
Chet Lanctot186b5732013-03-18 10:26:30 -07006198 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6199 if ( DOT11F_FAILED( nStatus ) )
6200 {
6201 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6202 "or a SA Query Response (0x%08x)."),
6203 nStatus );
6204 // We'll fall back on the worst case scenario:
6205 nPayload = sizeof( tDot11fSaQueryRsp );
6206 }
6207 else if ( DOT11F_WARNED( nStatus ) )
6208 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006209 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006210 "the packed size for an SA Query Response"
6211 " (0x%08x)."), nStatus );
6212 }
6213
Jeff Johnson295189b2012-06-20 16:38:30 -07006214 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6215 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6216 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6217 {
6218 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006219 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006220 return eSIR_FAILURE;
6221 }
6222
6223 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306224 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006225
Chet Lanctot186b5732013-03-18 10:26:30 -07006226 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006227 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006228 pFrame,
6229 SIR_MAC_MGMT_FRAME,
6230 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006231 peer, psessionEntry->selfMacAddr );
6232 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006233 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006234
Chet Lanctot186b5732013-03-18 10:26:30 -07006235 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006236 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6237
Chet Lanctot186b5732013-03-18 10:26:30 -07006238 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006239
Chet Lanctot186b5732013-03-18 10:26:30 -07006240 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6241 // in the FC
6242 if ( psessionEntry->limRmfEnabled )
Jeff Johnson295189b2012-06-20 16:38:30 -07006243 {
Chet Lanctot186b5732013-03-18 10:26:30 -07006244 pMacHdr->fc.wep = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006245 }
6246
Chet Lanctot186b5732013-03-18 10:26:30 -07006247 // Pack 11w SA query response frame
6248 nStatus = dot11fPackSaQueryRsp( pMac,
6249 &frm,
6250 pFrame + sizeof( tSirMacMgmtHdr ),
6251 nPayload,
6252 &nPayload );
6253
6254 if ( DOT11F_FAILED( nStatus ))
6255 {
6256 limLog( pMac, LOGE,
6257 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6258 nStatus );
6259 // FIXME - Need to convert to tSirRetStatus
6260 nSirStatus = eSIR_FAILURE;
6261 goto returnAfterError;
6262 }
6263 else if ( DOT11F_WARNED( nStatus ))
6264 {
6265 limLog( pMac, LOGW,
6266 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6267 nStatus);
6268 }
6269
6270 limLog( pMac, LOG1,
6271 FL( "Sending a SA Query Response to " ));
6272 limPrintMacAddr( pMac, peer, LOGW );
6273
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006274 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006275#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006276 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6277 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006278#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006279 )
6280 {
6281 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6282 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006283
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306284 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6285 psessionEntry->peSessionId,
6286 pMacHdr->fc.subType));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006287 halstatus = halTxFrame( pMac,
6288 pPacket,
6289 (tANI_U16) nBytes,
6290 HAL_TXRX_FRM_802_11_MGMT,
6291 ANI_TXDIR_TODS,
6292 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6293 limTxComplete,
6294 pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306295 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6296 psessionEntry->peSessionId,
6297 halstatus));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006298 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006299 {
6300 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6301 nSirStatus = eSIR_FAILURE;
6302 //Pkt will be freed up by the callback
6303 return nSirStatus;
6304 }
6305 else {
6306 return eSIR_SUCCESS;
6307 }
6308
6309returnAfterError:
6310 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6311 return nSirStatus;
6312} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006313#endif